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:
1 parent
91908d1f15
commit
496de1a31f
10 files changed
+171
-81
No files matched your search
@@ -47,6 +47,7 @@ bool check_collision_self(GameState &state) {
|
||||
for (auto it = state.snake.begin() + 1; it != state.snake.end(); ++it) {
|
||||
if ((*it)[0] == headpos[0] && (*it)[1] == headpos[1]) {
|
||||
state.gameOver = true;
|
||||
state.gameOverReason = GameOverReason::SelfCollision;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -91,6 +92,7 @@ bool check_collision_apples_rotten(GameState &state) {
|
||||
state.bad_apples.erase(it);
|
||||
if (state.snakelength < 2) {
|
||||
state.gameOver = true;
|
||||
state.gameOverReason = GameOverReason::RottenAppleDepleted;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -471,6 +473,7 @@ bool check_collision_barriers(GameState &state) {
|
||||
const auto &head = state.snake.front();
|
||||
if (is_barrier_cell(state, head[0], head[1], false)) {
|
||||
state.gameOver = true;
|
||||
state.gameOverReason = GameOverReason::BarrierCollision;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user