How can you find where an NES game stores save data?

Started by Ar8temis008, March 07, 2018, 12:53:43 PM

Previous topic - Next topic

Ar8temis008

I'm trying to modify All Stars NES for personal use. My biggest issue with it is that lives don't reset on game over. I believe simply not saving them to SRAM would solve this, right? Even if I can't release it publicly, it seems simple enough to be a first time hacking project.

Any way, I'm trying to find where in the rom the game stores save data. I have no clue where to look, and am currently loading back and forth through save states (each with different values saved to sram) using FCEUX and trying to find what lines change using its hex viewer. Am I doing it right? If not, how can I find what I'm looking for?

Psyklax

Okay, ROM means Read Only Memory, which means you can't save to it. :) That's why you can't find anything changing, because it can't. SRAM is separate to the ROM.

Inside an NES cart there are two main chips: CHR ROM, for the graphics, and PRG ROM, for everything else. Later games included other chips, including SRAM, but SRAM is just like any other kind of RAM in that it can hold data provided it has power. This is why a battery is fixed inside the cartridge - a battery backup. If the battery dies, the power to the SRAM is gone, and the data is lost.

In FCEUX, the SRAM is saved in a .sav file in the "sav" folder. This is just a dump of what the SRAM holds. When you say "lives don't reset on game over", what do you mean? Are you saying when you start a new game, you have the same amount of lives? But how do you get a game over, then? :o Or do you mean the game saves your lives to SRAM, so that when you power the console off and on again, you still have the same amount of lives? Remember that SRAM is stored on the cartridge, not the NES. It's only used to save in games like Zelda. Lives are usually stored in the NES's RAM, which is obviously wiped when the system powers on.

If you want to know where your lives are kept in RAM, it's simple: use RAM Search. Start a game with it open, then when you lost a life, search with "Less Than Previous Value", lose another one, repeat. Soon enough you'll see it. It can only be something between $0000 and $07FF, which is the NES's internal RAM. If it IS stored in SRAM, it will be between $6000 and $6FFF, most likely.

Hope this information is helpful! :)

Ar8temis008

Quote from: Psyklax on March 07, 2018, 02:49:14 PM
Okay, ROM means Read Only Memory, which means you can't save to it. :) That's why you can't find anything changing, because it can't. SRAM is separate to the ROM.

Inside an NES cart there are two main chips: CHR ROM, for the graphics, and PRG ROM, for everything else. Later games included other chips, including SRAM, but SRAM is just like any other kind of RAM in that it can hold data provided it has power. This is why a battery is fixed inside the cartridge - a battery backup. If the battery dies, the power to the SRAM is gone, and the data is lost.

In FCEUX, the SRAM is saved in a .sav file in the "sav" folder. This is just a dump of what the SRAM holds. When you say "lives don't reset on game over", what do you mean? Are you saying when you start a new game, you have the same amount of lives? But how do you get a game over, then? :o Or do you mean the game saves your lives to SRAM, so that when you power the console off and on again, you still have the same amount of lives? Remember that SRAM is stored on the cartridge, not the NES. It's only used to save in games like Zelda. Lives are usually stored in the NES's RAM, which is obviously wiped when the system powers on.

If you want to know where your lives are kept in RAM, it's simple: use RAM Search. Start a game with it open, then when you lost a life, search with "Less Than Previous Value", lose another one, repeat. Soon enough you'll see it. It can only be something between $0000 and $07FF, which is the NES's internal RAM. If it IS stored in SRAM, it will be between $6000 and $6FFF, most likely.

Hope this information is helpful! :)
That was very helpful, thanks! When I said lives don't reset I mean they are saved to sram but not cleared upon game over. So if I save with 0 lives, when I use a continue or "retry" I'll still have 0 lives, making it very frustrating to beat.