Dissasembly Of A Mapper 232 Game

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
Vhyrro
Posts: 3
Joined: Sun Aug 02, 2020 3:31 am

Dissasembly Of A Mapper 232 Game

Post by Vhyrro » Sun Aug 02, 2020 4:04 am

Hello,

I've recently taken a challenge upon myself - to reverse engineer and document my favourite childhood NES game - Super Robin Hood by the Oliver Twins. The game is part of the Quattro Adventure rom.

If have quite a lot of experience with 6502 assembly and how the NES works, that isn't the problem.

The problem is - how on earth do you successfully disassemble a mapper 232 game? I've tried every disassembler on the wiki; while certain disassemblers do do their job it's simply impossible (or at the very least really difficult) to then reassemble the assembly code back into an nes rom file that I can play. Either the dissasemblers generate literally syntactically incorrect code or they don't generate the iNES header, and those that do (disasm6) use .hex mnemonics that can't be recognized by other assemblers. I then tried reassembling with asm6 but guess what, disasm6 did not generate reset: irq: and nmi: labels which I do not know how to locate, so assembly also failed there. I even tried to use asm6f due to the fact that certain parts of the disassembly contain illegal opcodes, but even asm6f had difficulties.

Does anybody know any dissasembler, or at the very least any tool that is fully capable of dissasembling such a rom and then reassembling it back into one coherent .nes file? Additionally (this is not necessary, but would be greatly appreciated), does anybody have any documentation regarding mapper 232 (the links on the nesdev wiki simply aren't enough). I've been stuck for several weeks now.

Thanks

Oziphantom
Posts: 856
Joined: Tue Feb 07, 2017 2:03 am

Re: Dissasembly Of A Mapper 232 Game

Post by Oziphantom » Sun Aug 02, 2020 5:06 am

For dissasembly https://csdb.dk/release/?id=149429 is best, it makes 64tass code but will need some massaging due to duplicate labels it sometimes makes. However it will not understand any mapper nor will it make an iNES header. You will need to extract the banks from the your nes file and give it to it 1 by 1. Likewise for re assembly you will need to make a asm file that assembles and then puts the right bits back where they need to be. To add an iNes header you would then use another program to add it, or just put the 16 bytes at the start of the file that makes the nes rom.
HEX = .byte $
so
HEX 00 01 02 ff fe f9

.byte $00,$01,$02,$ff,$fe,$f9

Documentation for 64tass is here http://tass64.sourceforge.net/

but you file will look something like

Code: Select all

*=$0000
.byte HEADER HERE
.logical $8000
.include "firstPRGBank"
.here
.logical $c000
.include "upperPRGBank"
.here
.logical $c000
.include "nextUpperPRGBank"
.here
.binary "chrData.bin"
expand as you have lower and upper banks.
Assemble as
64tass -b -X -a -i yourFile.asm -o yourbin.bin

64tass format is fairly plain and "standard" and regenerator doesn't do anything fancy so it should be easy to use a couple of find and replace scripts to convert it to something else.

Vhyrro
Posts: 3
Joined: Sun Aug 02, 2020 3:31 am

Re: Dissasembly Of A Mapper 232 Game

Post by Vhyrro » Sun Aug 02, 2020 7:50 am

Thanks a lot for the detailed answer! I'll definitely look into it!

Vhyrro
Posts: 3
Joined: Sun Aug 02, 2020 3:31 am

Re: Dissasembly Of A Mapper 232 Game

Post by Vhyrro » Mon Aug 03, 2020 3:08 am

Extra question:

From researching things about the game I found out that the game uses 16x16KB ROM Banks - to extract the code for each bank is it as simple as reading 16KB from the PRG file, storing it, then reading another 16KB and so on?
Or is there something more complicated at play here?

Thanks in advance

EDIT: After splitting the file into 16x16KB chunks - MOST could be read and parsed by the regenerator, however, some split files could not be read and caused the program to crash. Guess I need to do quite a bit more research haha

Oziphantom
Posts: 856
Joined: Tue Feb 07, 2017 2:03 am

Re: Dissasembly Of A Mapper 232 Game

Post by Oziphantom » Mon Aug 03, 2020 4:11 am

yeah, just don't forget to strip the header.
so 16byte header
bank0
bank1
bank2
...

Don't save them as PRGs though, as PRG has a special meaning on the C64, as it will give it a 2 byte header. name them '.bin' so regenerator knows that are not 'c64 prg' files. You will need to adjust the offsets in the program by hand.

Crashing doesn't sound right when it opens a file, I've never had it crash from opening a file before.

Post Reply