From 821e371683886173a546533f00f8aef1c4e464bf Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 19 Oct 2026 07:14:57 +0200 Subject: vnf: mask out bits for bank data on mmc3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- lib/vnf/src/lib.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/vnf/src') 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 -- cgit v1.2.3