1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-08 08:55:38 +00:00
nescript/tests/emulator
Claude a806bfd3bd
hud_demo: declare proper digit + heart CHR so the HUD is readable
The previous version of hud_demo passed `score & 0x0F` and tile
index `1` (= Heart) to nt_set / nt_fill_h, but the demo had no
Heart sprite declared and tile 1 in CHR was uninitialized garbage.
The result was a screen of blue smileys with a tiny red strip in
the corner — the buffer mechanism worked, but the visual gave no
sense that anything HUD-shaped was happening.

This commit makes the HUD actually look like a HUD:

- 12 sprite declarations (Bar, Heart, Digit0..9, Ball) that the
  compiler lays into CHR at known tile indices in declaration
  order. Tile-index constants (`BAR_TILE`, `HEART_TILE`,
  `DIGIT_BASE`) match that order so the call sites can use names
  instead of magic numbers.
- bg1 palette restructured to `[red, white, yellow]` so pixel-art
  characters resolve to visible colours: `#` = red (background
  fill), `%` = white (heart shape), `@` = yellow (digit strokes).
- Background pre-paints row 1 with the solid `Bar` (red) tile
  via a `legend { "B": 1 }` entry, giving the HUD a uniform red
  canvas for individual cell writes to land on.
- Eight `nt_attr` calls at startup paint the entire top metatile
  row (4 rows × 32 cols) with sub-palette 1 so the HUD chrome
  reads as visually distinct from the playfield.

The result at frame 180 is unmistakably HUD-shaped: a yellow-on-
red status bar at the top of the screen above blue playfield with
a yellow ball bouncing around. Per-frame cost still scales with
what changed — `last_score` / `last_lives` shadow-compares mean
the buffer stays empty on the ~58 of 60 frames where nothing
ticks.

Tests: 758 pass. Clippy clean. 48/48 emulator goldens match.
2026-04-18 22:12:43 +00:00
..
goldens hud_demo: declare proper digit + heart CHR so the HUD is readable 2026-04-18 22:12:43 +00:00
.gitignore tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
harness.html tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
package-lock.json platformer: end-to-end side-scroller demo + three runtime bug fixes 2026-04-13 13:04:26 +00:00
package.json platformer: end-to-end side-scroller demo + three runtime bug fixes 2026-04-13 13:04:26 +00:00
record_gif.mjs docs: add docs/pong.gif demo to README 2026-04-16 10:44:57 +00:00
run_examples.mjs tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00