The NES: The Game State That Lasted Seven Days

March 28, 2021
Topaz renting Final Fantasy, declaring he will beat it in seven days.

Before the first NES game with battery backup, The Legend of Zelda, came out, you had two options:

  • Either you beat the whole game in one sitting
  • Or you got these weird passcodes you had to type in to restore where you were.

Old-school Metroid players knew of JUSTIN BAILEY, the amazingly random password that gave you all sorts of crazy gear. Mega Man had you put dots in spots to get your gear back. These both worked by recreating the state of the game.

When a game (or any computer program) runs, it interacts with the outside world. You move a character, an AI shoots at you, you drink a healing potion. These decisions change the program state. Every program that does anything useful has state. This state is stored in the NES’s powered-on RAM while you play, and is continuously updated. On the NES, this data would be in the 2K of RAM available to games. But when you power down the NES, the state goes away with it. The trick is finding a way to preserve the game state so you can keep playing from where you left off.

With a game like Mega Man 3, the state is very simple, and it’s easy to store and recreate from a few dots on the screen. All you need to know is:

  • What bosses were defeated
  • How many energy tanks you had
A password for Mega Man 3 for being Magnet Man with 0 E-Tanks

Need a password for having defeated Magnet Man with 0 Energy Tanks? Well here it is. I got it especially for you. Top Man is next if you go by that one copy of Nintendo Power I still own.

With a game like Final Fantasy, though, there’s no way all of the game state can be stored in a simple password:

  • Every warrior has a name and individual stats, gear, and spells
  • You have different items and counts of items
  • You’ve unlocked different parts of the game
Topaz, dressed as a Fighter, not looking forward to entering in a grid password to restore his saved game.

This 38x38 grid of 2 bit (3 different dots + empty) squares will give you just over 768 bytes of data, enough to represent the important parts of the Final Fantasy God Mode save file.

The memory magician, as a red mage, casting a spell on a RAM chip

Final Fantasy used a common memory magician – I mean, memory management chip – named the MMC1. The MMC1 allowed for storing game state on a RAM chip on the cartridge board that was powered by a button battery.

The code of the game could talk to the memory magician on the board and let it know it wanted to read and write to the cartridge’s RAM, treating it as part of one of the PRG banks loaded and saved in the upper 32K of the NES’s RAM. Normal RAM chips typically need constant electricity to remember what was stored there (unlike EEPROMs – Flash memory is a type of EEPROM used to make SSDs). When the game was in the NES and powered on, these on-board RAM chips were powered by the console. When the power cut out because you held in the RESET button while powering off the NES (or you had to shut it off quick ‘cause it was time for dinner and Mom had already called you, like, ten times), the battery on the cartridge board took over and kept the onboard RAM powered up just enough to preserve the game state.

There were problems with this, of course. Batteries could die, and couldn’t be user-replaced easily. The hardware on the cartridge might not handle the transition from NES-power to battery-power well, corrupting the fragile state. You might forget to hold down RESET while powering off the system (or be forced to not do so because of dinner) and the CPU continued to execute, corrupting your game. But for most games, and most of the time, it worked. The battery backed-up RAM allowed players to play much larger games, paving the way for truly large RPGs like Final Fantasy and Dragon Warrior, adventure games and ARPGs like The Legend of Zelda and Crystalis, and in-depth simulation games like Bandit Kings of Ancient China.

Topaz returning Final Fantasy, not having beaten it in the 7 day rental period.

And yes, I did try to beat Final Fantasy this way twice, in two separate 7 day rental periods, and could never pull it off fast enough.

Changelog

  • 2021-03-28: Initial Post