- 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>
51 lines
1.6 KiB
C
51 lines
1.6 KiB
C
#ifndef GAME_RENDER_H
|
|
#define GAME_RENDER_H
|
|
|
|
#include <nds.h>
|
|
|
|
#include "game_state.h"
|
|
|
|
struct HudCache {
|
|
int score = -1;
|
|
bool cursed = false;
|
|
bool paused = false;
|
|
bool gameOver = false;
|
|
bool musicEnabled = false;
|
|
bool hardMode = false;
|
|
bool dirty = true;
|
|
};
|
|
|
|
struct BackgroundContext;
|
|
|
|
struct RenderAssets {
|
|
PrintConsole *topScreen = nullptr;
|
|
PrintConsole *bottomScreen = nullptr;
|
|
BackgroundContext *bg_context = nullptr;
|
|
|
|
u16 *gfx_segment = nullptr;
|
|
u16 *gfx_segment_small = nullptr;
|
|
u16 *gfx_head_h = nullptr;
|
|
u16 *gfx_head_v = nullptr;
|
|
u16 *gfx_apple = nullptr;
|
|
u16 *gfx_apple_blink = nullptr;
|
|
u16 *gfx_tail_h[2] = {nullptr, nullptr};
|
|
u16 *gfx_tail_v[2] = {nullptr, nullptr};
|
|
u16 *gfx_apple_rotten = nullptr;
|
|
u16 *gfx_apple_cursed = nullptr;
|
|
u16 *gfx_barrier = nullptr; // Solid, fatal barrier segment
|
|
u16 *gfx_barrier_warn = nullptr; // Dashed outline shown while announcing
|
|
|
|
HudCache hudCache;
|
|
};
|
|
|
|
void invalidate_hud(RenderAssets &assets);
|
|
void draw_game(const GameState &state, const RenderAssets &assets);
|
|
void draw_stats(const GameState &state, RenderAssets &assets, bool internals, bool musicEnabled, uint8_t frame);
|
|
void draw_menu(const GameState &state, RenderAssets &assets, bool musicEnabled);
|
|
void draw_game_over_screen(const GameState &state);
|
|
void blink_apples(const GameState &state, u16 *gfx_apple);
|
|
// Called every VBlank: owns OAM slots [0, BARRIER_OAM_SLOTS) and animates barrier palette entries
|
|
void draw_barriers(const GameState &state, const RenderAssets &assets, uint8_t frame);
|
|
|
|
#endif
|