Mike Tyson's Punch-Out Disassembly

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

I am beginning the reverse engineering of Mike Tyson's Punch-Out and I'm creating this topic to document my progress. The repository can be found here:

https://github.com/nmikstas/mike-tysons ... isassembly

As I make progress and interesting discoveries, I'll try to keep this topic up to date. The intention is to give people insight (at least from my perspective) into the reverse engineering process of a NES game.
DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

The initial repository is online now! It can be downloaded and the build_script can be run from the Git bash command window. It will assemble all 14 PRG assembly files and perform md5sums to ensure they assemble to exact copies of the original PRG banks. The basic work environment is ready to go...now for the hard work!

This game is interesting in that it appears to be the only game to use the MMC2 mapper. There are a total of 16 PRG banks that are 8KB each. The lower 8KB is the only one that is bank switched. The upper 3 are static. I have included the upper 3 banks into a single file called PRG_BankDEF.asm. The other 13 8KB banks are separate. This creates a total of 14 PRG assembly files.

There is a total of 128KB of PRG memory but there is about 30KB of blank space which is more than 20% of the total PRG area. It has been marked on the completion map.
DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

I wanted to mention the helper_programs folder in the repository. One thing that can make life so much easier is to write simple programs to format data tables and other things in a way the assembler can understand. In all the disassembles I have done, there are always data tables for things like game text and music that follow very specific patterns. Once I understand those patterns, I write helper programs to format the segments of hex data into tables. As I have mentioned in another post, this eliminates human transcription errors and greatly speeds up the time it takes to format the tables. I already have 3 helper programs in the repository. one program is designed to take a whole CHR bank and turn it into byte strings the assembler can understand. The 2nd program takes segments of hex data and turns in into rows of assembler byte data. For example:

00 34 EA A0 12
becomes:
.byte $00, $34, $EA, $A0, $12

I have another simple program that forms hex strings into word data:

00 34 EA A0 12
becomes:
.word $3400, $A0EA, $12A0

More complex helper programs will almost certainly be written as the disassembly progresses.

I used to use Java to write these kinds of programs. I recently took a full stack web boot-camp. I know, they are kinda scammy but I did learn a lot and I really like the flexibility of Javascript. From now on I will write these programs in Javascript and run them with Node. I feel like Java is starting to show its age and is not as convenient as it used to be. An alternative to Javascriot I was considering is C#. Basically any program that can be used to write code quickly is best. Efficiency is not a concern in this context. If anyone has languages they like to use for this kind of down and dirty string processing, let me know! I figure Python is probably pretty good for this stuff but I've never used it.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Mike Tyson's Punch-Out Disassembly

Post by Memblers »

Pretty cool!

If you weren't aware of it already, you might be interested in the Playchoice-10 version of the game (and is the only PC10 game that's not 100% identical to the NES carts). It includes battery-backed RAM, and records the players initials and the shortest match times. The only way to view the table is to beat a score on it, so it becomes increasingly hidden away over time.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Mike Tyson's Punch-Out Disassembly

Post by Oziphantom »

Use https://csdb.dk/release/?id=149429 it has built in support to make and detect
byte array
word arrays
lo/hi split arrays
hi/lo split arrays
and you can make then have -1 if they are "return addresses"

It has a very simple text format for database so you can easily make extra tools to augment it, such as I've done with https://csdb.dk/release/?id=148193 however its very C64 centric and won't help with NES, but adding something to auto find and comment NES register values etc would be just as trivial.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Mike Tyson's Punch-Out Disassembly

Post by calima »

Perl, awk, tcl were made for that stuff, but it sounds like you're on Windows.
FrankWDoom
Posts: 260
Joined: Mon Jan 23, 2012 11:27 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by FrankWDoom »

Memblers wrote: Sun Aug 02, 2020 10:47 pm Pretty cool!

If you weren't aware of it already, you might be interested in the Playchoice-10 version of the game (and is the only PC10 game that's not 100% identical to the NES carts). It includes battery-backed RAM, and records the players initials and the shortest match times. The only way to view the table is to beat a score on it, so it becomes increasingly hidden away over time.
You can push select at the pre fight matchup to view best times. Iirc that's the only way to view the Tyson best times as beating him kicks you into end credits.

The other notable change is the post title fight cutscenes stop and give the password immediately, presumably because the player is on a time limit
fadden
Posts: 2
Joined: Tue Aug 04, 2020 3:03 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by fadden »

DirtyMcDingus wrote: Sun Aug 02, 2020 9:32 pm I wanted to mention the helper_programs folder in the repository. One thing that can make life so much easier is to write simple programs to format data tables and other things in a way the assembler can understand. In all the disassembles I have done, there are always data tables for things like game text and music that follow very specific patterns.
A quick plug for SourceGen: you can do the same by same by selecting the bytes with the mouse and formatting them. "Bulk data" (bytes), character strings, 2-byte/3-byte/4-byte words, big- or little-endian. Bulk data can be formatted as N bytes per line, e.g. if you have something that's 6 or 8 bytes per chunk. You can format data as 2-byte/3-byte addresses, in which case they automatically turn into labels. It can turn format tables of addresses split into two separate chunks (thanks in no small part to oziphantom pointing out various edge cases).

This made it easy to mimic the original SMB disassembly, e.g. this part.

You can run C# scripts, but that's for formatting inline data following JSR/JSL/BRK and converting graphics, not general data formatting.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Mike Tyson's Punch-Out Disassembly

Post by Memblers »

FrankWDoom wrote: Mon Aug 03, 2020 9:09 am
You can push select at the pre fight matchup to view best times. Iirc that's the only way to view the Tyson best times as beating him kicks you into end credits.

The other notable change is the post title fight cutscenes stop and give the password immediately, presumably because the player is on a time limit
Oh thanks, I didn't know! Now I regret swapping out that battery, those decades-old records were unbeatable for me, and I was curious to see them. Almost dumped the RAM but it seemed like too much work (I later made a PC10 cart to NES adapter that I could have used for that).
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by dougeff »

Have you considered using a disassembler? da65, for example.
nesdoug.com -- blog/tutorial on programming for the NES
DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

Memblers,
I Have already done a big portion of the disassembly of the normal NES version. I can go back in after and compare the Player's 10 Choice version with the NES version. I'm assuming there is not a ton of difference. It should be an interesting comparison.
DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

Oziphantom,
I browsed through the website you posted. It looks interesting! I may have to sit down and try to figure out if I can use it for my needs. That's the type of thing I need to format a lot of data.
DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

fadden,
I watched the video for SourceGen. Dang! that thing is pretty cool. I'll download it and see how much of it I can use. I'm particularly interested in it for converting portions code into byte data and word data. I looks like it doesn't have support for the keywords .alias (equivalent to .EQU), .byte (Equivqlent to .DB) or .word (equivalent to .DW). I'm using a lesser used syntax, I guess. I'm in too deep! It's too late to turn back!
DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

calima,
I took an undergraduate web programming class back in the heyday of Perl and JSP and we used Perl extensively in that class. I still have nightmares about it...
DirtyMcDingus
Posts: 38
Joined: Sat Jul 25, 2020 5:31 pm

Re: Mike Tyson's Punch-Out Disassembly

Post by DirtyMcDingus »

I have pretty much torn down the audio engine in the game. I still need to comment and format the data in it but it is nearly all understood. I'll try to detail my thoughts and methods while reverse engineering it here in the next few posts. One thing I am noticing about Mike Tyson's Punchout is that the code is very cleanly written, unlike Dragon Warrior. The entry point into the audio engine starts at the first address in the memory bank, which is nice. The progression through the bank is very straight forward and the sound effects routines and music routines are organized and are completely encapsulated in their own little areas. If the rest of the code follows this pattern, this should be a relatively easy disassembly. I was able to figure out the various sections of the audio engine without too much trouble.
Post Reply