Gunroar:Cannon() wrote: ↑Sat Oct 30, 2021 11:48 pm
Can you spread insight on the issue, if you may?
Sure, why not. I'll happily bore anyone to death.
NES games are cartridges, and cartridge is hardware and must be emulated. Many different cartridge boards have been identified, documented and assigned so called
mapper numbers. A game dump has a header that contains the mapper number.
The problematic game in this case works with
mapper 2 hardware, which provides extra memory that
can be bank-switched.
In my bank-switching code, I only used the
lowest 4 bits of the bank number to select one of 16 memory banks (as suggested by the documentation). But this game here has 512 KiB of ROM (32 pages), requiring 5 address lines instead of just 4 to select a bank.
The bug was fixed by using all 8 bits of the bank number when switching banks. It's even right there in the article:
Emulator implementations of iNES mapper 2 treat this as a full 8-bit bank select register, without bus conflicts. This allows the mapper to be used for similar boards that are compatible.
Code: Select all
mapper.write = (addr, val) =>
if addr >= 0x8000
banks[0] = lshift(val, 14)
I could identify one other game that uses this mapper with 5+ address lines, so that makes this my first obscure game bug fixed after a user report