Skip to content

Commit 06b9013

Browse files
committed
Minor tweaks
1 parent 9b2a79f commit 06b9013

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

examples/Wasm_PyBadge_Dino/Wasm_PyBadge_Dino.ino

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,28 +158,30 @@ void setup()
158158

159159
// Process inputs
160160
uint32_t pressed_buttons = arcada.readButtons();
161-
if (pressed_buttons & ARCADA_BUTTONMASK_START) {
161+
if (arcada.justPressedButtons() & ARCADA_BUTTONMASK_START) {
162162
//NVIC_SystemReset();
163163

164164
// Restart Dino game
165165
init_random();
166166
display_info();
167167
load_wasm();
168-
delay(100);
169-
170-
} else if (pressed_buttons & ARCADA_BUTTONMASK_A && pressed_buttons & ARCADA_BUTTONMASK_B) {
171-
*(uint32_t*)(mem) = 3;
172-
} else if (pressed_buttons & ARCADA_BUTTONMASK_B) { // Down
173-
*(uint32_t*)(mem) = 2;
174-
} else if (pressed_buttons & ARCADA_BUTTONMASK_A) { // Up
175-
*(uint32_t*)(mem) = 1;
176-
} else {
177-
*(uint32_t*)(mem) = 0;
168+
}
169+
170+
uint32_t* input = (uint32_t*)(mem + 0x0000);
171+
172+
*input = 0;
173+
if (pressed_buttons & ARCADA_BUTTONMASK_A) { // Up
174+
*input |= 0x1;
175+
}
176+
if (pressed_buttons & ARCADA_BUTTONMASK_B) { // Down
177+
*input |= 0x2;
178178
}
179179

180180
// Render frame
181181
result = m3_CallWithArgs (func_run, 0, i_argv);
182182
if (result) break;
183+
184+
// Output to display
183185
arcada.display->drawRGBBitmap(0, 40, (uint16_t*)(mem+0x5000), 160, 75);
184186

185187
//Serial.print("FPS: "); Serial.println(1000/(millis() - framestart));

0 commit comments

Comments
 (0)