That time I sent my wife to the Mushroom Kingdom

Ocarina of Time Randomizer

Giving gifts is hard

As a kid, birthdays and Christmas were some of the few times of the year where you had a chance at getting that cool new toy you were wanting. Whether it was a scooter, or a copy of Ocarina of Time; These things were out of reach as a child normally throughout the year.

But what do you get for someone who is a successful adult? Someone who knows what they like and if they really wanted it (and it was, uh, affordable) they probably would just go get it themselves.

sidenote: this is actually a problem we have tried to solve with one of my friend groups. We have each shared an Amazon wishlist that includes things we wouldn’t mind receiving, like a pack of my favorite socks

While passing a gift card back and forth between friends and family in a never-ending loop over the years is fine, I do try to make gifts to my wife feel special. But coming up with an idea that really feels like it will wow her a few times a year is hard!

I have enjoyed watching and learning about Speedrunning since high school. Entire communities sprouted out of individual games; People going for records, searching for glitches and routes, creating guides, and generating tools to support all of the above. Many of the most popular games have been so well researched that the entire assembled code source is picked apart and understood. These developments have spawned further into entire other genre of games, Randomizers. Your favorite retro games, like you’ve literally never played before.

Ocarina of Time Randomizer
This OoT randomizer has a ton of customization options

Every chest with a random item, reskinned graphics (who doesn’t want Link to look like MegaMan?), and even doors that will take you into entire other games. All with the background logic to ensure that the randomized seed that is created is still beatable, and usually with a final product that can run on the actual original hardware.

Okay, what does this have to do with giving gifts again?

I wanted to learn more about this process. How can anyone who doesn’t have access to the source code be able to make such incredible tools? This would have been a huge undertaking, and it’s important to start with manageable bite-sized projects. But maybe I could combine this process with a goal of creating my wife a unique gift. Here was the original plan:

1. Find a game that has been well documented
2. Create sprites of my wife
3. Edit the romfile to include my wife as playable character
4. change the title and text of the game to match

Sprite and Text swapping is one of the simpler edits you can make to a ROM, and I felt it fit within the timeframe of her upcoming birthday to be accomplished. Operation B-Day began.

Super Mario Bros. for the NES has been extremely well documented and it would work as a great starting point for anyone trying to get into ROM editing. Using the emulator FCEUX, I had access to a hex editor under the DEBUG tools, in here you can change the view to the ROM file and edit the games code directly. Any change made here will be reflected on screen after a screen refresh or upon resetting the game. This makes it a very quick process to see how changes to the ROM are actually affecting the game, and when you are happy with the changes you can save the rom (preferably using “Save ROM As” to avoid destroying your file in an unrecoverable way).

But how do we know what in the code to change?

Editing Mario’s name in the scoreboard

All of the text in the game is made up of sprites. These sprites are not logically stored (such as using ASCII hex values), but luckily they are stored sequentially. Using a tool called YY-CHR, a ROM can be loaded as a series of images. The majority of these images will be garbage, as it is actually the games code, but there will be a section containing the games sprites. Editing these sections of ROM is the key to editing sprites. By noting the memory address that contains an image, we can also locate its usage throughout the ROM. When it comes to the text sprites, we don’t want to edit these, we just want to find where they are used so we can edit their use.

sprites
The blank sprite is located at 0x24, by counting backwards we can find the location in ROM for each letter/number

While Playing Super Mario Bros., Mario’s name is used in a few location. Mainly in the top left corner above your score, as well as when toad speaks to you at the end of each world. Back in FCEUX, we can search for MARIO by it’s hex code in the ROM.

rom
Text for Mario is found in a couple of sections of the ROM

An important thing to note is that you will only be able to use as many characters as the original text, I can’t use Catherine’s full name because it’s longer than Mario. The text would end up bleeding into another section of the code, and most likely break the game.

rom
Here I’ve used her nickname, cat, and filled in the remaining letters with blank sprites

After the text swaps and sprite edits, I ended up with this:

cat in Mario

Sidetracked!

How cool would it be if I could actually give her the game? A complete box, manual, and cartridge? I began searching for a solution, and quickly found an individual who sold reproductions of retro game boxes and manuals. After some communication, I was able to get the files he uses for printing so that I could edit them to include my changes.

I had just committed a developer’s greatest sin… I had introduced SCOPE CREEP.

It wasn’t additional software features, but it definitely pushed the completion date way past her birthday.

What about the cartridge? The easiest solution would to buy a flash cart, load the rom onto an sd card, and print a custom label for the cart. The other (cooler and more expensive) option is to buy a programmer, a memory chip, a custom circuit board, and a cartridge casing.

I decided to switch gears, the goal now to get a custom game box ready before B-Day. I figured it would be more exciting to get something she could physically hold, with the note that a playable game would be coming in the future. Everything I had done up to this point was still required, the box art contains shots of in-game footage, so I would still need her custom sprites and additional text changes to do this properly.

This really pushed my lack of artistic ability to the brink. I generated all the art for the box in Procreate on my 11" iPad Pro with the Apple pencil. I found the closest matches to the text I could, and utilized many layers to cover up all the old box art. All of the in-game images were taken from a running version of the game. Eventually I came out the other side with this:

The Final Box