refactor: optimize snake sprite rendering using preloaded directional assets and implement HUD caching

This commit is contained in:
phillip committed 2026-10-01 22:00:55 +02:00
1 parent db9013c9c5
commit 60740a53c2
5 files changed
+268 -152

No files matched your search

+3 -1
View File
@@ -179,7 +179,9 @@ The repository includes preconfigured tasks in [`.vscode/tasks.json`](.vscode/ta
### 6.2 Asset Pipeline
- **Graphics Pipeline:**
- [`gfx/tilemap.png`](gfx/tilemap.png) + [`gfx/tilemap.grit`](gfx/tilemap.grit) are processed by `grit` into `${CMAKE_CURRENT_BINARY_DIR}/tilemap.s` and `tilemap.h`.
- Sprites are referenced by index: tile 1 (segment), 2 (small segment), 3 (head), 5/6 (apple flash frames), 7/8/9/10 (tail variations), 11 (rotten apple).
- Sprites are referenced by index: tile 1 (segment), 2 (small segment), 3 (head horizontal), 4 (head vertical), 5/6 (apple flash frames), 7/8/9/10 (tail variations), 11 (rotten apple). All 12 sprite tiles are preloaded once into VRAM at startup; directional and blinking variants are rendered via pointer selection and hardware flipping flags without mid-frame DMA transfers.
- Active OAM sprites are clamped at hardware limit (128) and trailing unused sprites are hidden every frame via `oamClear(&oamSub, oamId, 128 - oamId)`.
- Console text HUD rendering in `draw_stats()` is throttled via dirty-flag caching (`HudCache`), eliminating redundant `iprintf` calls on VBlank.
- **Audio Pipeline:**
- Audio files in [`sounds/`](sounds/) are compiled by `mmutil` into `soundbank.bin` and header `soundbank.h`.
- `bin2s` embeds `soundbank.bin` into assembly source `soundbank_bin.S` and header `soundbank_bin.h`.