one thing I've noticed almost all NES disassemblers lack is support for mappers and multiple rom banks.. and its not surprising. I want to add this feature to DASM6, but I'd like to get some insight from those who are more familiar with dealing with mappers than i am
To disassemble a rom with a mapper, there are the following difficulties:
1. Knowing how the rom file is mapped into memory.
For some mappers this is relatively straightforward (ex mapper 2), but for others, it's totally up to the programmer. We can use CDL logs to know where in memory the file was mapped to, but even then, it's technically possible for the same bytes in the file to be loaded into either rom bank, so a CDL log might not be 100% correct
possible solutions:
* allow use of user provided memory map in addition to CDL
* don't support games which put the same bank in two locations
* ?
2. Knowing how to deal with label references which are outside of the current bank
for example, lets say a game has a bank hard coded to 0xc000, and code in that bank jumps to someplace around 0x8000. But which bank is it jumping to? It's possible that the proper destination for the jump code is only in one bank.. but we don't know which bank.
Assuming it exists in all banks will mess up the output of the other banks
possible solutions
* only allow "code" labels (mentioned in jmp/jsr/branch) from other banks if CDL says it's code and also the label points to an opcode, not inside of a command. and conversely only allow data labels (lda/sta) if CDL says it's data
* allow user defined labels to also specify which bank it exists in (seems like we'll need this anyways) and add label to that bank if the user specified it. using this alone could lead to invalid labels though.. so maybe output a list of labels which weren't found and force user to define them?
i separated this from my DASM6 thread since it could be handy for other disassembler authors.. would love to hear about other problems and solutions to disassembling roms which use mappers.
funny thing is just writing this out has helped me brainstorm lol
To disassemble a rom with a mapper, there are the following difficulties:
1. Knowing how the rom file is mapped into memory.
For some mappers this is relatively straightforward (ex mapper 2), but for others, it's totally up to the programmer. We can use CDL logs to know where in memory the file was mapped to, but even then, it's technically possible for the same bytes in the file to be loaded into either rom bank, so a CDL log might not be 100% correct
possible solutions:
* allow use of user provided memory map in addition to CDL
* don't support games which put the same bank in two locations
* ?
2. Knowing how to deal with label references which are outside of the current bank
for example, lets say a game has a bank hard coded to 0xc000, and code in that bank jumps to someplace around 0x8000. But which bank is it jumping to? It's possible that the proper destination for the jump code is only in one bank.. but we don't know which bank.
Assuming it exists in all banks will mess up the output of the other banks
possible solutions
* only allow "code" labels (mentioned in jmp/jsr/branch) from other banks if CDL says it's code and also the label points to an opcode, not inside of a command. and conversely only allow data labels (lda/sta) if CDL says it's data
* allow user defined labels to also specify which bank it exists in (seems like we'll need this anyways) and add label to that bank if the user specified it. using this alone could lead to invalid labels though.. so maybe output a list of labels which weren't found and force user to define them?
i separated this from my DASM6 thread since it could be handy for other disassembler authors.. would love to hear about other problems and solutions to disassembling roms which use mappers.
funny thing is just writing this out has helped me brainstorm lol