This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Saving in SRAM- Need any info on how cartridge saving works!

Saving in SRAM- Need any info on how cartridge saving works!
by on (#53033)
I am still working on my ''Super Mario Brothers 1 Hack'', I need help creating a Zelda/Star Tropics style ''Save Game Screen'' for a Save RAM Hack. any tutorial, code, or documentation on how it should become is appreciated.

Any info on how to save, load and delete games, plus info on how to input names?

One last thing, info provided can be used in any games that are hacked, free, or/and has source with it.

by on (#53035)
There is no trick. Whatever you write to SRAM stays there and doesn't vanish when the power is switched off. Well, this is what should happen, because there are some conditions that might corrupt SRAM, but there is nothing a programmer can do to avoid this. Newer mappers have some means of protecting that memory, often offering registers to prevent or allow writing to SRAM. Just read the mapper-specific documents to see if they offer SRAM protection and how you can use it.

For saving games you have to backup whatever variables the game needs to resume it's state. Since you didn't program SMB1 it might be hard to tell what those variables are for that game. But since SMB1 didn't have any extra RAM, you should be able to save a game by backing up the whole 2KB of built in RAM ($0000-$07FF). With the standard 8KB of SRAM you could save up to 4 games.

It should be very easy to write a loop to copy the whole RAM to SRAM, as should be copying it back. The hardest part should be programming the menu interface to select those options. If you ave no idea on how to do this, you are out of luck because I doubt you are going to find a guide/tutorial for something as specific as this.

Writing a menu is like any other kind of NES programming. You have to draw the menu to the Name Tables, read the controllers and move a cursor around, and so on. Inputting names is the same thing, you ned to code your own interface, with all the letters and a cursor. This should be easy for anyone that has programmed anything serious (more complex than "Hello World") for the nes, I don't know exactly how much experience with it you have. But if you ask me, your necessity to build this interactive menu might be a great opportunity to learn some more NES programming.

by on (#53046)
tokumaru wrote:
There is no trick. Whatever you write to SRAM stays there and doesn't vanish when the power is switched off. Well, this is what should happen, because there are some conditions that might corrupt SRAM, but there is nothing a programmer can do to avoid this. Newer mappers have some means of protecting that memory, often offering registers to prevent or allow writing to SRAM. Just read the mapper-specific documents to see if they offer SRAM protection and how you can use it.

For saving games you have to backup whatever variables the game needs to resume it's state. Since you didn't program SMB1 it might be hard to tell what those variables are for that game. But since SMB1 didn't have any extra RAM, you should be able to save a game by backing up the whole 2KB of built in RAM ($0000-$07FF). With the standard 8KB of SRAM you could save up to 4 games.

It should be very easy to write a loop to copy the whole RAM to SRAM, as should be copying it back. The hardest part should be programming the menu interface to select those options. If you ave no idea on how to do this, you are out of luck because I doubt you are going to find a guide/tutorial for something as specific as this.

Writing a menu is like any other kind of NES programming. You have to draw the menu to the Name Tables, read the controllers and move a cursor around, and so on. Inputting names is the same thing, you ned to code your own interface, with all the letters and a cursor. This should be easy for anyone that has programmed anything serious (more complex than "Hello World") for the nes, I don't know exactly how much experience with it you have. But if you ask me, your necessity to build this interactive menu might be a great opportunity to learn some more NES programming.


Thanks, I'll see what I come up with,

All I have to do is make a separate title screen, And using SMBDIS, turn the menu into a Save Game Menu, Pretty simple, but can take time to figure out.

No more 2 player mode. 3 saves for Mario only unless otherwise noted, Game over must have a selection screen.

I figured out Graphics already, And Memblers gave me his NESLIB library for nametable uploads!

by on (#53048)
Hamtaro126 wrote:
All I have to do is make a separate title screen, And using SMBDIS, turn the menu into a Save Game Menu, Pretty simple, but can take time to figure out.

I guess this is OK. Having your own title screen and menus is a good idea, but you have to find the appropriate entry points in the original game for starting a game and for continuing an old one.

Quote:
3 saves

This is good, because you can use the rest of the SRAM for names entered by players and checksums to validate the saves. You could probably use it for the menu variables too, so that you don't have to worry about overwriting them when restoring saves.

Quote:
Game over must have a selection screen.

Sounds simple, just another menu. Once you have a menu system, making new ones should be easy.

Will you make saving automatic or does the player get to decide when to save?

by on (#53050)
Someone should hack old "Excitebike" to actually support saving/loading.. :)

by on (#53054)
It does you just need to have the famicom tape player thingie ;-)

by on (#53055)
SRAM, menus and nametables? I've had far more experience of these lately that I really care for. :S

:)

by on (#53062)
tokumaru wrote:
Quote:
Game over must have a selection screen.

Sounds simple, just another menu. Once you have a menu system, making new ones should be easy.

Will you make saving automatic or does the player get to decide when to save?


I'd just go with only letting the players be named MARIO only, for now

I'll let the player decide on continuing or just saving while quitting, And the game over screen is going to be like in Doki Doki Panic style:

GAME OVER

CONTINUE

SAVE & QUIT

by on (#53092)
Startropics is autosave.

by on (#53099)
CKY-2K/Clay Man wrote:
Startropics is autosave.

So is NetHack. In fact, it's so autosave that it saves that you've died.