Just this summer, the Nintendo Entertainment System had its 35th release anniversary, and even after years of discontinuation, it is still going strong in the hacker community. Exhibit A: [Matthew Earl]. For one of his upcoming projects, [Matthew] needed to get his hands on the background images of the NES classic Super Mario Bros. Instead of just getting some ready-rendered images and stitching them together, he decided to take care of the rendering himself, once he extracts the raw game data.
Since there is no official source code available for Super Mario Bros, [Matthew] used a disassembled version to get started looking for the image data. To avoid reading through thousands of lines of assembly code, and to also see what actually happens during execution, he wrapped the game’s ROM data into py65emu, a Python library emulating the 6502, the CPU that drives the NES. By adding a simple wrapper around the emulator’s memory handler that tracks reads on uninitialized data, [Matthew] managed to find out which parameters he needs to feed to the parser routine in order to get the image tile data. After an excursion into the Picture Processing Unit (PPU) and its memory arrangements, [Matthew] had everything he needed to create the Python script that will render the game background straight from its ROM data.
Even if extracting NES game data is not your thing, the emulator concept [Matthew] uses might be still worth a read. On the other hand, if you want to dig deeper into the NES, you should definitely have a look at emulating an SNES game on a NES, presented on the NES itself.
8 thoughts on “Find Your Level – Extracting NES Game Data Using Python”
This is really cool, and a very neat approach to do it! Thanks for that excellent write-up, bookmarked!
What is the difference between metatile c1 and c0?
power up vs coin?
Yep, the different indices are used as gameplay collision data :) a very common practice bitd.
Did I just have a stroke?
Nope, it’s just the fever caused by all that radiated extraterrestrial heat. o_O
If this came out six months ago I would have saved a ton of time. (was working on a SMB AI player).
DBZbUAkQkk COyuvQyDFl mWGUyjybDH YbEbZkKRbv yntqCskuav nFATenLNLB PTFhWiXCFl ksMKhulMCj JcysLHJKBE UUCPSySKGb
Please be kind and respectful to help make the comments section excellent. (Comment Policy)