Question about saving.

Archived bsnes development news, feature requests and bug reports. Forum is now located at

Question about saving.

Post by Names »

A few days ago I realized that bsnes does not write changes to a game's srm file until the game has been unloaded. If possible, I would like to recompile bsnes so that it writes changes to the file shortly after a game saves. I'm unsure of whether there is a technical reason for this behaviour, or if it's just a design preference.

After looking through the source a bit I found the function which saves the file; now I would like to modify the code which interprets the snes save call to include this, but I'm not sure how to find it.

Is it possible to do this, and if so, can someone point me in the right direction?

Post by byuu »

Not a good idea to save on # of RAM writes, hard to say when a transmission finishes. I'd recommend doing it every few minutes or so.


Code: Select all

  while(terminate == false) {

    //add this
    static time_t delta = time(0);
    if((int)(time(0) - delta) > 180) {  //save every 3 minutes
      //call Cartridge::save_ram()-like function
      //eg as in Cartridge::unload_normal()
      //won't work here since these functions are private
      //if(cart.ram) save_file(get_filename(cart.filename, "srm",, cart.ram, cart.ram_size);
      delta = time(0);


Since it's requested, I'll add it in a future release.
Posts: 152
Joined: Tue Apr 10, 2007 4:30 pm
Location: Sweden

Post by henke37 »

Doesn't most emulators just save after a certain period of save memory inactivity?
If the game hasn't written to the save area in a sec, it is most definitely done writing to it.

Post by Names »

That works, thanks byuu! :)
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

do you have to explicitly flush memory mapped files?
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.