diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-10-19 07:14:57 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-10-19 07:14:57 +0200 |
| commit | 821e371683886173a546533f00f8aef1c4e464bf (patch) | |
| tree | d2c8566c213b8a9ae4e13a8275691c4b2e8a80be /lib/vnf/src | |
| parent | 57a15f9385560308e5ac05aa057f3bcb1df22824 (diff) | |
| download | tools.nes-821e371683886173a546533f00f8aef1c4e464bf.tar.gz tools.nes-821e371683886173a546533f00f8aef1c4e464bf.zip | |
vnf: mask out bits for bank data on mmc3
The two most significant bits for the bank data are to be ignored if we
want to honor MMC3's maximum capacity for ROM space.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib/vnf/src')
| -rw-r--r-- | lib/vnf/src/lib.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs index b9a5fd2..4642afb 100644 --- a/lib/vnf/src/lib.rs +++ b/lib/vnf/src/lib.rs @@ -1765,12 +1765,22 @@ impl Machine { } } 0x0001 => { + // Registers 6 and 7 ignore the two most significant bits, as + // the MMC3 has only 6 PRG ROM address lines. This then allows + // for 64 banks of 8KB, and hence the MMC3's limit of 512KB for + // PRG ROM. + let val = value & 0x3F; + if chip.next_register_update == 6 { - chip.r6 = value as usize; + chip.r6 = val as usize; } else if chip.next_register_update == 7 { - chip.r7 = value as usize; + chip.r7 = val as usize; } - // NOTE: other registers are ignored. + // NOTE: no further checks are done. If the programmer is + // referencing out of ROM's capacity, translate_rom_address() + // will just return zeroes and make the whole run to fail + // organically. + // NOTE: all the other registers are ignored. } 0x2000 => { // NOTE: nametable arrangement. Since this is a headless |
