(This article is also available via the short link tomrei.ch/gamegenie)
In my last article I discussed how to make minor code hacks to your classic NES games to change game behaviors. We walked through the process modifying Super Mario Bros to give Mario infinite lives. This works great when you have access to awesome debugging tools like the ones available in Mesen, but what if you're a purist and you want to play on actual hardware? There are many options available, but perhaps the purist of the pure involves a device that was released in 1990 while the NES was still the system to have: the Game Genie.
If you were alive and of a certain age during the era of the NES, the Game Genie likely needs no introduction. But just in case you weren't so lucky, the Game Genie is a device that sits between the NES cartridge and the NES itself that allows the user to enter "codes" that modify game behavior. As a kid, this all seemed like magic. But now that we have an understanding of how the NES works, the basic concept of what it does is rather simple. Game Genie codes simply specify a memory location and value, then the device intercepts all calls to the given location and injects the given value. It's really that simple.
It's not important to understand the conversion algorithm, just the basics behind what each code represents. Essentially, each 6-character code refers to a single two-byte memory location along with a single one-byte replacement value. Put another way, you'll need one code for each byte you wish to change. There is also an optional "Compare Value" that allows for 8-character codes, but don't worry about this for now -- I may cover it in a later article.
Let's take a look back at the code update we made in the previous article to give Mario infinite lives:
On the left-hand side we see the code change,
JMP $91E9. On the right-hand side, the
hex version of the change is displayed:
4C E9 91
This represents the three bytes of code that were changed. Also note the start address,
This is all the information we need to do our Game Genie code conversion.
At this point we know we've changed three bytes (meaning we will need three codes) and we know
the start location of the change,
$91D9. All that is left is to calculate the remaining
locations and we're all set. Fortunately this is extremely simple given that each byte location is in order.
The first byte change happens at location
$91D9. The next location comes one byte later, at
$91DA, and so on. So the three changed addresses, with associated bytes, are:
All that's left to do is feed the changes into the encoding tool. Once entered, the Game Genie Code is
And there you have it. The three codes for this change are:
91D9:4C - GKIOPO
91DA:E9 - OVIOZO
91DB:91 - OOIOLP
Key these codes into any Game Genie (or Emulator that supports Game Genie codes) and your change will be applied!
So there you have it - using modern tools to hack your 30+ year old games in a way that can be run on equipment from the time in a non-destructive manner. As a bonus, the online tool can also decrypt codes, so if you want to see what those old codes from your code book do, you can now easily see exactly how they're changing your games. Play around with it and see if you can make the Mario Infinite Lives change even more efficiently. Can you do it with a single code?