1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-08 08:55:38 +00:00
nescript/tests/emulator/goldens
Claude 7b4570eee5
compiler: i16 / SRAM saves / inline-asm dot labels / docs
Another batch from the cc65/nesdoug catalogue. All gated on
parser-level opt-in or default-false attributes so existing
programs produce byte-identical ROMs (no committed .nes file
changed).

**§A — `i16` signed 16-bit type:**
- New `KwI16` lexer token, `NesType::I16` AST variant, parser
  case in `parse_type`. Type-size and integer-type tables
  treat `i16` like `u16` (2 bytes, integer).
- IR lowering accepts `i16` everywhere it accepts `u16` for
  wide-load / wide-store / widen-narrow paths.
- New constant fold for `UnaryOp::Negate(IntLiteral(v))` that
  emits the wide two's-complement form. Without it, `var vy:
  i16 = -10` would zero-extend to `$00F6` (= 246) instead of
  sign-extending to `$FFF6` (= -10). Negative literals now
  store the right bytes.
- Comparisons reuse the existing unsigned 16-bit compare ops
  (matching the existing `i8` behaviour). Documented in the
  `NesType::I16` doc comment and in `future-work.md` §A.
- Example `examples/i16_demo.ne` with committed golden.
- Tests cover the literal-fold sign-extension and end-to-end
  compile of the example.

**§S — SRAM / battery-backed saves:**
- New `save { var ... }` top-level block. Lexer + parser opt
  into a dedicated `KwSave` token. Analyzer allocates save
  vars from a separate `next_sram_addr` bump pointer starting
  at `$6000`, capped at `$8000` (8 KB cartridge SRAM window).
- Linker reads `analysis.has_battery_saves` and flips iNES
  byte-6 bit-1 via the new `RomBuilder::set_battery` /
  `Linker::with_battery` chain.
- New `W0111` warning for save-var initializers — SRAM is
  preserved across power cycles, so an init expression would
  either silently never run or clobber persisted data on
  every boot. The warning teaches the user about the
  magic-byte sentinel pattern.
- Struct fields in save blocks are explicitly rejected for now
  (the field-flattening path uses the main-RAM allocator).
- Example `examples/sram_demo.ne` with committed golden, plus
  4 integration tests.

**§D (partial) — inline-asm `.label:` syntax:**
- Codegen-side mangler rewrites `.IDENT` → `__ilab_<N>_IDENT`
  per inline-asm block, where `<N>` is the call site's
  monotonic suffix. Two `asm { .loop: ... }` blocks in the
  same function now coexist without colliding in the linker's
  label table.
- Bounds checks on `.` placement: `$2002` and `name.field`
  are unaffected; only `.IDENT` in label / branch context
  triggers the rewrite. Two integration tests pin the
  uniqueness and dollar-vs-dot disambiguation.

**§X follow-up — Mesen trace-log docs:**
- New "Debugger-assisted workflows" section in
  `docs/nes-reference.md` walking through the Mesen / FCEUX
  log workflows alongside the new `debug_port:` attribute.

**Misc:**
- `future-work.md` updated to mark the shipped items out of
  the catalogue and reshuffle the priority ranking. Remaining
  niche follow-ups (signedness on Cmp16, struct save fields,
  inline-asm format specifiers) documented inline so future
  passes know the design.

All 757 tests pass. Clippy clean. 46/46 emulator goldens match.
2026-04-18 20:49:06 +00:00
..
arrays_and_functions.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
arrays_and_functions.png compiler: fix three scoping bugs; war: revert all local/param workarounds 2026-04-15 20:33:41 +00:00
audio_demo.audio.hash codegen: emit gate markers at end of generate() to protect peephole 2026-04-16 21:31:47 +00:00
audio_demo.png tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
auto_chr_background.audio.hash assets: auto-generate CHR data from @nametable() PNG sources 2026-04-15 03:29:58 +00:00
auto_chr_background.png assets: auto-generate CHR data from @nametable() PNG sources 2026-04-15 03:29:58 +00:00
auto_sprite_flicker.audio.hash compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
auto_sprite_flicker.png compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
axrom_simple.audio.hash compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
axrom_simple.png compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
bitwise_ops.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
bitwise_ops.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
bouncing_ball.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
bouncing_ball.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
cnrom_simple.audio.hash compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
cnrom_simple.png compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
coin_cavern.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
coin_cavern.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
comparisons.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
comparisons.png codegen: emit gate markers at end of generate() to protect peephole 2026-04-16 21:31:47 +00:00
edge_input_demo.audio.hash compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
edge_input_demo.png compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
fade_demo.audio.hash compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
fade_demo.png compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
feature_canary.audio.hash examples: add feature_canary that turns red on any memory silent-drop regression 2026-04-18 00:14:40 +00:00
feature_canary.png examples: add feature_canary that turns red on any memory silent-drop regression 2026-04-18 00:14:40 +00:00
friendly_assets.audio.hash codegen: emit gate markers at end of generate() to protect peephole 2026-04-16 21:31:47 +00:00
friendly_assets.png language: pleasant asset syntax for palettes, CHR, bg, sfx, music 2026-04-13 16:09:53 +00:00
function_chain.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
function_chain.png tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
gnrom_simple.audio.hash compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
gnrom_simple.png compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
hello_sprite.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
hello_sprite.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
i16_demo.audio.hash compiler: i16 / SRAM saves / inline-asm dot labels / docs 2026-04-18 20:49:06 +00:00
i16_demo.png compiler: i16 / SRAM saves / inline-asm dot labels / docs 2026-04-18 20:49:06 +00:00
inline_asm_demo.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
inline_asm_demo.png codegen: reuse analyzer's local allocations so inline asm {param} works 2026-04-16 16:03:10 +00:00
logic_ops.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
logic_ops.png tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
loop_break_continue.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
loop_break_continue.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
match_demo.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
match_demo.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
metasprite_demo.audio.hash parser/lowering: declarative metasprites for multi-tile sprite groups 2026-04-15 03:13:30 +00:00
metasprite_demo.png parser/lowering: declarative metasprites for multi-tile sprite groups 2026-04-15 03:13:30 +00:00
mmc1_banked.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
mmc1_banked.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
mmc3_per_state_split.audio.hash main: write the real mapper byte into the iNES header 2026-04-13 01:27:42 +00:00
mmc3_per_state_split.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
nested_structs.audio.hash analyzer/lowering: support nested struct fields and array struct fields 2026-04-15 02:19:49 +00:00
nested_structs.png analyzer/lowering: support nested struct fields and array struct fields 2026-04-15 02:19:49 +00:00
noise_triangle_sfx.audio.hash codegen: emit gate markers at end of generate() to protect peephole 2026-04-16 21:31:47 +00:00
noise_triangle_sfx.png audio: triangle and noise sfx channels 2026-04-14 10:42:53 +00:00
palette_and_background.audio.hash palette/background: first-class declarations with reset-time load and runtime swaps 2026-04-13 11:11:33 +00:00
palette_and_background.png codegen: emit gate markers at end of generate() to protect peephole 2026-04-16 21:31:47 +00:00
palette_brightness_demo.audio.hash compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
palette_brightness_demo.png compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
platformer.audio.hash examples: move state-scoped globals to state-local in coin_cavern + platformer 2026-04-17 11:58:02 +00:00
platformer.png feat(platformer): add stomp-or-die enemy collisions, live HUD, GameOver state 2026-04-13 20:23:07 +00:00
pong.audio.hash analyzer+codegen: lift the 4-param ceiling via a direct-write calling convention 2026-04-18 02:34:56 +00:00
pong.png codegen: fuse compare-then-branch to drop boolean materialization 2026-04-16 17:10:02 +00:00
prng_demo.audio.hash compiler: PRNG / edge input / palette fade / AxROM / CNROM / FCEUX labels 2026-04-18 18:13:18 +00:00
prng_demo.png review: tighten PRNG / void-intrinsic / FCEUX path handling 2026-04-18 18:48:55 +00:00
scanline_split.audio.hash main: write the real mapper byte into the iNES header 2026-04-13 01:27:42 +00:00
scanline_split.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
sfx_pitch_envelope.audio.hash codegen: emit gate markers at end of generate() to protect peephole 2026-04-16 21:31:47 +00:00
sfx_pitch_envelope.png linker: skip default palette + rendering enable for non-visual ROMs 2026-04-16 21:15:08 +00:00
sha256.audio.hash examples/sha256: interactive SHA-256 hasher with on-screen keyboard 2026-04-16 14:02:58 +00:00
sha256.png examples/sha256: interactive SHA-256 hasher with on-screen keyboard 2026-04-16 14:02:58 +00:00
sprite_0_split_demo.audio.hash compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
sprite_0_split_demo.png compiler: GNROM / debug port / sprite flicker / fade / sprite-0 split + docs 2026-04-18 19:31:55 +00:00
sprite_flicker_demo.audio.hash sprite-per-scanline: add cycle_sprites runtime flicker + debug telemetry 2026-04-15 22:07:19 +00:00
sprite_flicker_demo.png sprite-per-scanline: add cycle_sprites runtime flicker + debug telemetry 2026-04-15 22:07:19 +00:00
sprites_and_palettes.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
sprites_and_palettes.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
sram_demo.audio.hash compiler: i16 / SRAM saves / inline-asm dot labels / docs 2026-04-18 20:49:06 +00:00
sram_demo.png compiler: i16 / SRAM saves / inline-asm dot labels / docs 2026-04-18 20:49:06 +00:00
state_machine.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
state_machine.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
structs_enums_for.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
structs_enums_for.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
two_player.audio.hash tests/emulator: record audio goldens alongside screenshots 2026-04-12 22:33:48 +00:00
two_player.png tests/emulator: byte-exact golden-image diffs 2026-04-12 21:30:18 +00:00
uxrom_banked.audio.hash examples: add uxrom_banked and jsnes golden 2026-04-13 02:04:25 +00:00
uxrom_banked.png examples: add uxrom_banked and jsnes golden 2026-04-13 02:04:25 +00:00
uxrom_banked_to_banked.audio.hash codegen: support banked → banked cross-bank function calls 2026-04-15 02:37:19 +00:00
uxrom_banked_to_banked.png codegen: support banked → banked cross-bank function calls 2026-04-15 02:37:19 +00:00
uxrom_user_banked.audio.hash codegen: user code in switchable banks via cross-bank trampolines 2026-04-14 11:41:20 +00:00
uxrom_user_banked.png codegen: user code in switchable banks via cross-bank trampolines 2026-04-14 11:41:20 +00:00
war.audio.hash analyzer+codegen: lift the 4-param ceiling via a direct-write calling convention 2026-04-18 02:34:56 +00:00
war.png examples: regenerate ROMs, gifs, and goldens after codegen local fix 2026-04-16 16:12:46 +00:00