Fix PRG bank shown in debugger
The old code used a hardcoded 16 KiB bank size, regardless of how the mapper actually maps banks.
There is still a lot of code making this assumption. See debuggerPageSize. Mostly for symbolic debugging.
TBD: This PR is a draft because it may be confusing if the mapper simultaneously uses varying bank sizes.
Does it have the same problem in the tracelog?
Yes, it does. Everything that uses the getBank() function will now display a more accurate bank number based on how the address space is mapped. The old behavior was to assume that all banks are 16 KiB.
Here's a list of notable places where the bank number is getting updated:
- Disassembler
- Breakpoint conditions
- Memory editor context menu
- Trace logger
Possibly broken now:
-
generateNLFilenameForAddress()indebuggersp.cpp. -
getBankIndexForAddress()indebuggersp.cpp. -
loadNameFiles()indebuggersp.cpp. -
generateNLFilenameForAddress()indebugsymboltable.cpp(dead code).
The symbol table code is all hardcoded with the old 16 KiB bank size assumption.
Additional context:
I made this patch for an MMC3 game, and the debugger and trace logger are showing the correct bank numbers with it. MMC3's fixed-size 16 KiB bank window is treated as two 8 KiB banks, but that seems reasonable.
MMC5 is an example that I expect has problems presenting a sane bank number (it can use 8 KiB, 16 KiB, or 32 KiB bank sizes, selectable at runtime). It would probably be helpful if bank size information was provided in addition to a bank index number. E.g., "4th 8 KiB bank" and "2nd 16 KiB bank" both point to the same location, but in address-form 04:8000 and 02:8000 are ambiguous without the size (PRG window) context.