(back to project list)

Super Mario Bros. Disassembly

Nintendo's Super Mario Bros. is often cited as one of the greatest video games of all time. The authors crammed a remarkable amount of gameplay into a 40KB cartridge.

I wanted to see how SourceGen handled NES ROMs, so I started searching the web for cartridge disassemblies. The first thing I looked for was SMB, because it's the only NES game I could think of off the top of my head. The first link that came up was a "comprehensive Super Mario Bros. disassembly" by doppelganger. I ported it to SourceGen, and I think the results came out pretty well.

Super Mario Bros. is copyright 1985 Nintendo, Inc.


I know very little about the NES, so I have not attempted to modify the original disassembly in meaningful ways. I have not altered labels, changed globals to locals, or added local variable tables.

Most of the code can be represented in the same way it was in the original disassembly, but SourceGen doesn't yet have a way to handle expressions with multiple symbols, so data offsets (e.g. .dd1 thingAddress - baseAddress) are just output as hex. The list of constants is sorted numerically, which is somewhat tragic.

The names of the hardware registers don't match what's in the original disassembly. The names defined in the SourceGen symbol file come from the NesDev wiki.

I added visualizers for the pattern table data. For the CHR ROM this is straightforward, although it's currently limited to a few palettes. (With only 4 colors it's feasible to just specify each value explicitly, but that's inconvenient.) I also added a "tile grid" that displays an MxN set of tiles. Much of the time this works:

mario walk   mario jump

In other places the code flips some parts around, so it doesn't always come out quite right:

lakitu hiding   lakitu up

Copyright 2020 by Andy McFadden