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

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
Hamtaro126
Posts: 783
Joined: Thu Jan 19, 2006 5:08 pm

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

Post by Hamtaro126 »

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.
AKA SmilyMZX/AtariHacker.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

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.
User avatar
Hamtaro126
Posts: 783
Joined: Thu Jan 19, 2006 5:08 pm

Post by Hamtaro126 »

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!
AKA SmilyMZX/AtariHacker.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

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.
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.
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?
User avatar
oRBIT2002
Posts: 643
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Post by oRBIT2002 »

Someone should hack old "Excitebike" to actually support saving/loading.. :)
User avatar
Jeroen
Posts: 1048
Joined: Tue Jul 03, 2007 1:49 pm

Post by Jeroen »

It does you just need to have the famicom tape player thingie ;-)
User avatar
neilbaldwin
Posts: 481
Joined: Tue Apr 28, 2009 4:12 am
Contact:

Post by neilbaldwin »

SRAM, menus and nametables? I've had far more experience of these lately that I really care for. :S

:)
User avatar
Hamtaro126
Posts: 783
Joined: Thu Jan 19, 2006 5:08 pm

Post by Hamtaro126 »

tokumaru wrote:
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
AKA SmilyMZX/AtariHacker.
CKY-2K/Clay Man
Posts: 214
Joined: Sun Apr 01, 2007 2:10 pm

Post by CKY-2K/Clay Man »

Startropics is autosave.
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

CKY-2K/Clay Man wrote:Startropics is autosave.
So is NetHack. In fact, it's so autosave that it saves that you've died.
Post Reply