How to Best Disassemble NES PRG-ROM

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
How to Best Disassemble NES PRG-ROM
by on (#149000)
Currently I am disassembling the PRG-ROM data of an NES ROM file by reading the file in a hex editor, pasting the values into a text editor, and using a table of 6502 operands to translate the values into the corresponding 6502 instructions. The results appear accurate, but it takes a long time even when starting out with NROM games.

an example:
20 20 C1 = jsr $C120
A9 00 = lda #$00

What disassembly programs are available that might speed this up a bit? I don't mind tweaking the output a little bit if the results aren't 100% accurate. Besides data tables, disassembly is fairly straightforward going sequentially from one instruction to the next. I would prefer a program that can output to a text file or ideally a file that can be used with one of the available NES assemblers.

If there is a better approach to NES disassembly, please direct me. Thanks in advance for any suggestions.
Re: How to Best Disassemble NES PRG-ROM
by on (#149001)
FCEUX will let you create a code-data log that maps which part of a ROM are data and which are code. Turn on logging, and play through the game to map as much of the code/data as you can.

Next use a disassembler (e.g. da65) to do the actual disassembly, don't translate it by hand except where you have to. What I like to do is create an disassembly info file for da65, starting with information from the code-data log, but then slowly add labels to it as I figure out what various bits of code are for. Every time I add a few labels, I re-disassemble to have those labels appear in the disaasembly. Eventually I end up with something pretty comprehensive, at which point I might stop messing with da65 and just hand-edit the disassembly file until it looks nice.

I have an example here, from my last disassembly project, if it helps: http://rainwarrior.ca/projects/nes/startropics_music_fix.zip
Re: How to Best Disassemble NES PRG-ROM
by on (#149004)
You could also load the ROM into YY-CHR and pan through the data to see if anything looks like graphics. This would only apply to games that use CHR RAM in the case of the NES, but this helped me a lot on a non-NES disassembly.
Re: How to Best Disassemble NES PRG-ROM
by on (#149012)
Bisqwit's project nescom contains "clever-disasm", which is a tracing disassembler. It does a nice job, and can use a configuration file that allows you to hand-guide it through the places it can't figure out.

There's also "disasm6", which is uses FCEUX's CDL files, but doesn't handle PRG banking. (But that means it's fine for NROM, CNROM, and the 32 KiB MMC1 games)