1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-08 17:06:04 +00:00
nescript/tests/emulator
Claude 40dec7907a
examples: move state-scoped globals to state-local in coin_cavern + platformer
Both examples declared their gameplay variables at the top level
even though every read and write happened inside one specific state.
That pattern hid the overlay feature from new users and kept the
state-local code path from being exercised outside the dedicated
`state_machine.ne` demo (which is how the "state-locals silently
drop their writes" bug survived so long).

`coin_cavern.ne`: the five Playing-only physics/position/inventory
vars (`player_x`, `player_y`, `player_vy`, `on_ground`,
`coins_left`) move onto Playing's state block. `score` stays
global because GameOver-era code could reasonably grow to read it.
The `on_enter` body loses its redundant resets — the declared
initializers on the state-locals re-run on every entry, so
retrying after `transition Title` comes back to a fresh state.

`platformer.ne`: player physics, camera, liveness, animation
phase, and the autopilot budget (`player_y`, `on_ground`,
`rise_count`, `fall_vy`, `camera_x`, `anim_tick`, `alive`,
`auto_jumps`) all move onto Playing. `frame_tick` and
`stomp_count` stay global — Title reads the former to
auto-advance, GameOver reads the latter to tally coins on the
death screen. The analyzer now overlays Title's `blink`,
Playing's eight physics vars, and GameOver's `linger` starting
at the same ZP byte (`$1A`), so the three scenes share a
9-byte window instead of each claiming their own slots.

Byte-level ROM bytes for both examples shift because variable
addresses moved. Video goldens stay pixel-identical (the harness
doesn't see Playing in coin_cavern, and the pre-transition
Title→Playing timing in platformer is preserved); the platformer
audio hash needed one more refresh because the now-slightly-shorter
reset prologue shifts APU writes within each frame.

https://claude.ai/code/session_015kvJu3iEFLSRJoShPBfm3X
2026-04-17 11:58:02 +00:00
..
goldens examples: move state-scoped globals to state-local in coin_cavern + platformer 2026-04-17 11:58:02 +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