|
I made an attempt at this a while back, first disassembling by hand, then with the aid of a homegrown disassembler.
Unless your disassembler is extremely intelligent, it's most likely screwed up the jumptables. SMB (and a number of other nintendo titles) do something like this for jumptables:
LDA #$03 JSR do_jumptable DW $A020, $8002, etc
do_jumptable: ASL A ; adjust index into table TAY PLA ; grab high byte STA $01 PLA ; grab low byte STA $00 INY ; point at the low byte of the entry LDA ($00), Y STA $03 INY LDA ($00), Y STA $02 JMP ($0002)
Their version is probably a little bit shorter, as that was from memory. That pops the return address off the stack, and uses it as the base address for a jumptable indexed by A. The RTS at the end of whatever bit of code that entry points at will return to the first function's caller.
Nintendo likes to nest these, I think I remember seeing a set that was 4 tables deep in SMB1 somewhere.
|