mirror of
https://github.com/imjasonh/nescript
synced 2026-07-09 01:16:12 +00:00
main: write the real mapper byte into the iNES header
The CLI's build path was calling `Linker::new(mirroring)`, which hardcodes the mapper number to NROM (0) regardless of the source file's `mapper:` declaration. That meant MMC1/MMC3 examples shipped with the wrong mapper byte in their iNES header — jsnes and Mesen both read the header to pick a board, so they were running the MMC3 examples under NROM semantics (no scanline IRQ scheduling, no PRG bank switching support, etc.). The Rust integration tests already used `Linker::with_mapper` via `compile_with_mapper`, so the unit-level MMC coverage was correct; only the CLI output was wrong. Swap to `Linker::with_mapper(program.game.mirroring, program.game.mapper)` so the header matches the source. Confirmed by inspecting the rebuilt example ROMs: mmc3_per_state_split.nes: flags6=40 (mapper=4) ← was 00 scanline_split.nes: flags6=40 (mapper=4) ← was 00 mmc1_banked.nes: flags6=11 (mapper=1) ← was 01 hello_sprite.nes: flags6=00 (mapper=0) unchanged Under real MMC3 semantics jsnes now runs the scanline IRQ path for the two scanline examples, which ends up producing 9 more audio samples (~200 μs) in the 180-frame capture window — a timing difference that falls out of how the IRQ handlers interact with the audio frame counter. Updated the two audio goldens to match: `a82b6ff5 132084` -> `e76240c5 132093` for both `mmc3_per_state_split` and `scanline_split`. PNG goldens are unchanged — the visible output is the same. All 19 emulator goldens now match. 381 unit tests + 43 integration tests green. Clippy and fmt clean. https://claude.ai/code/session_015WfaDttE3DpWn9rpyfpQd8
This commit is contained in:
parent
a3b0ea34a0
commit
b708eb5554
3 changed files with 8 additions and 9 deletions
13
src/main.rs
13
src/main.rs
|
|
@ -313,13 +313,12 @@ fn compile(input: &PathBuf, opts: &CompileOptions) -> Result<Vec<u8>, ()> {
|
|||
}
|
||||
|
||||
// Link into ROM with both graphic assets (sprite CHR) and audio
|
||||
// assets (sfx envelopes, music note streams) spliced in. Note:
|
||||
// `Linker::new` hardcodes the mapper byte to NROM regardless of
|
||||
// the source's `mapper:` declaration — that's a pre-existing
|
||||
// bug separate from the audio work, and fixing it would change
|
||||
// the iNES header of committed MMC1/MMC3 example ROMs. Left as
|
||||
// `new` here to keep this PR focused on audio.
|
||||
let linker = Linker::new(program.game.mirroring);
|
||||
// assets (sfx envelopes, music note streams) spliced in. We use
|
||||
// `Linker::with_mapper` so the iNES header's mapper byte
|
||||
// reflects the source's `mapper:` declaration — without this
|
||||
// the CLI always shipped mapper 0 (NROM) regardless of whether
|
||||
// the program actually needed MMC1/MMC3 bank switching.
|
||||
let linker = Linker::with_mapper(program.game.mirroring, program.game.mapper);
|
||||
let rom = linker.link_with_all_assets(&instructions, &sprites, &sfx, &music);
|
||||
|
||||
Ok(rom)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
a82b6ff5 132084
|
||||
e76240c5 132093
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
a82b6ff5 132084
|
||||
e76240c5 132093
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue