Wrong bank addresses in debug symbol formats for multibank SNES ROMs
Closed this issue · 0 comments
Firstly, the .sym file's bank address of ROM labels is currently assuming banks of 64K which is incorrect, they should be 32K increments but with more caveats depending on the map mode.
We also need to account for fastrom as well as lorom/hirom for determining the correct bank address.
If lorom, then $00..$3F decide the 32K bank number at $8000..$FFFF
If hirom, then $00..$3F are in multiples of 64K and let you view the upper 32K at $8000..$FFFF. You can also view 64K windows by using banks $40..$7D.
If fastrom, start ROM banks at + $80 from their determined bank offset in the output file. This is also the only way to access the last 2 banks of hirom, as $FE and $FF are covered by ram at $7E/$7F.
This might be messy to know what bank to use for symbols, as it normally determines this from the position in the output ROM. The address as provided in the bank declaration isn't used in the symbol offset determination -- only used in the assembly to give symbols absolute addresses as used by the program with in its CPU memory map. This allows us to support many mapper types on other systems, which may have weird banking rules. Banks might have different start addresses depending on the bank used, even if multiple bank select registers can reach the same memory, because things need to be able to use absolute addresses assuming they're loaded at a specific address range (unless they're written to be relocatable).
Anyway, meandering and getting off topic a bit... Either way fix SNES + WLA and try to get the common case of a multibank SNES ROM bugfixed and working better with the supported formats for snes debug symbols.