mirror of
https://github.com/imjasonh/nescript
synced 2026-07-08 08:55:38 +00:00
Follow-up cleanup on the cc65 parity batch. Addresses issues found during a post-commit code review. **Correctness fixes:** - `rand8()` / `rand16()` at statement position (result discarded) were being eliminated by DCE because `op_dest` returned `Some(dest)` for Rand8/Rand16 even though the ops have a visible side effect — advancing the PRNG state. Now `op_dest` returns `None` for both, keeping the JSR regardless of liveness. New regression test `rand8_statement_survives_dce`. - Void-only intrinsics (`poke`, `seed_rand`, `set_palette_brightness`) used in expression position (e.g. `var x = seed_rand(42)`) were panicking the linker with an unresolved `__ir_fn_X` label. The analyzer now emits E0203 with a clear message; new `void_intrinsic_in_expression_position_errors` test covers all three names. - Statement-position `rand8()` / `rand16()` weren't lowered at all (they fell through to the default Call path). Now both lower to their IR op with a fresh temp that nothing reads; the JSR still runs so the PRNG state advances. - `--fceux-labels foo.nes` was producing `foo.0.nl` because `PathBuf::with_extension` replaces instead of appends. Rewritten to literally append `.<bank>.nl` / `.ram.nl` to the OsString, so users get the FCEUX-expected `foo.nes.<bank>.nl` naming. - Linker now asserts CNROM / AxROM don't accept user-declared switchable PRG banks — their page sizes don't fit the 16 KB per bank model, and silently producing a mis-sized ROM is worse than a loud panic. **PRNG cleanup:** - Removed the stream-of-consciousness comment block in `gen_prng` that described three abandoned algorithms before landing on the actual Galois LFSR. - Simplified `__rand16` to a single JSR + LDX instead of two JSRs + TAY/TYA round-trip — a single shift already produces 16 fresh bits, the doubled call just burned ~40 cycles. The golden PNG for `prng_demo` was regenerated to reflect the new sequence. - Rewrote the `gen_prng` doc comment to accurately describe the algorithm as a Galois LFSR (it was mislabelled as xorshift). - Rewrote the `gen_palette_brightness` doc comment with a proper table of level→mask mappings — the prior prose description didn't match the actual table values. **Tests:** - Three new unit tests in `linker::debug_symbols` covering the FCEUX `.nl` renderer: user-facing labels only, empty output when no user labels exist, and deterministic sorting in `.ram.nl`. - Extended `nes2_mapper_high_nibble_in_byte_8_is_zero_for_small_mappers` to cover AxROM + CNROM. - Renumbered priority list in future-work.md after removing the shipped sections (J, K, N, parts of V and Y). All 737 tests + 40/40 emulator goldens still green. |
||
|---|---|---|
| .. | ||
| arrays_and_functions.audio.hash | ||
| arrays_and_functions.png | ||
| audio_demo.audio.hash | ||
| audio_demo.png | ||
| auto_chr_background.audio.hash | ||
| auto_chr_background.png | ||
| axrom_simple.audio.hash | ||
| axrom_simple.png | ||
| bitwise_ops.audio.hash | ||
| bitwise_ops.png | ||
| bouncing_ball.audio.hash | ||
| bouncing_ball.png | ||
| cnrom_simple.audio.hash | ||
| cnrom_simple.png | ||
| coin_cavern.audio.hash | ||
| coin_cavern.png | ||
| comparisons.audio.hash | ||
| comparisons.png | ||
| edge_input_demo.audio.hash | ||
| edge_input_demo.png | ||
| feature_canary.audio.hash | ||
| feature_canary.png | ||
| friendly_assets.audio.hash | ||
| friendly_assets.png | ||
| function_chain.audio.hash | ||
| function_chain.png | ||
| hello_sprite.audio.hash | ||
| hello_sprite.png | ||
| inline_asm_demo.audio.hash | ||
| inline_asm_demo.png | ||
| logic_ops.audio.hash | ||
| logic_ops.png | ||
| loop_break_continue.audio.hash | ||
| loop_break_continue.png | ||
| match_demo.audio.hash | ||
| match_demo.png | ||
| metasprite_demo.audio.hash | ||
| metasprite_demo.png | ||
| mmc1_banked.audio.hash | ||
| mmc1_banked.png | ||
| mmc3_per_state_split.audio.hash | ||
| mmc3_per_state_split.png | ||
| nested_structs.audio.hash | ||
| nested_structs.png | ||
| noise_triangle_sfx.audio.hash | ||
| noise_triangle_sfx.png | ||
| palette_and_background.audio.hash | ||
| palette_and_background.png | ||
| palette_brightness_demo.audio.hash | ||
| palette_brightness_demo.png | ||
| platformer.audio.hash | ||
| platformer.png | ||
| pong.audio.hash | ||
| pong.png | ||
| prng_demo.audio.hash | ||
| prng_demo.png | ||
| scanline_split.audio.hash | ||
| scanline_split.png | ||
| sfx_pitch_envelope.audio.hash | ||
| sfx_pitch_envelope.png | ||
| sha256.audio.hash | ||
| sha256.png | ||
| sprite_flicker_demo.audio.hash | ||
| sprite_flicker_demo.png | ||
| sprites_and_palettes.audio.hash | ||
| sprites_and_palettes.png | ||
| state_machine.audio.hash | ||
| state_machine.png | ||
| structs_enums_for.audio.hash | ||
| structs_enums_for.png | ||
| two_player.audio.hash | ||
| two_player.png | ||
| uxrom_banked.audio.hash | ||
| uxrom_banked.png | ||
| uxrom_banked_to_banked.audio.hash | ||
| uxrom_banked_to_banked.png | ||
| uxrom_user_banked.audio.hash | ||
| uxrom_user_banked.png | ||
| war.audio.hash | ||
| war.png | ||