fix: decouple VBlank ISR and main loop to prevent IRQ stack overflow

- Make handle_vblank strictly increment frame counter (frame++)
- Move heavy frame logic (background updates, OAM updates, palette animations, and console stats) to update_frame() on the main thread synchronized with swiWaitForVBlank()
- Eliminate 256-byte ARM9 IRQ stack (sp_irq) overflow caused by bg_update and iprintf that was corrupting DTCM stack and causing data aborts
- Preserve all playfield entities on game over with top-screen defeat summary and smooth background deceleration

Co-authored-by: Antigravity <antigravity@google.com>
This commit is contained in:
phillipandAntigravity committed 2026-10-04 00:21:09 +02:00
1 parent 91908d1f15
commit 496de1a31f
10 files changed
+171 -81

No files matched your search

+3
View File
@@ -65,6 +65,7 @@ bool handle_input_frame(InputContext &ctx) {
if ((ctx.state->paused || ctx.state->gameOver) && (keys != 0U) && ((keys & KEY_B) != 0U)) {
ctx.state->scene = Scene::Menu;
ctx.state->paused = false;
ctx.state->gameOver = false;
setBackdropColor(RGB15(2, 2, 6));
setBackdropColorSub(RGB15(2, 2, 6));
draw_menu(*ctx.state, *ctx.renderAssets, audio_is_music_enabled(*ctx.audio));
@@ -182,6 +183,8 @@ bool handle_input_frame(InputContext &ctx) {
} else {
ctx.init_game();
}
} else if (ctx.state->gameOver && (keys != 0U) && ((keys & KEY_A) != 0U)) {
ctx.init_game();
}
return true;