state saving
authorJavier S. Pedro <maemo@javispedro.com>
Sat, 15 Aug 2009 00:58:11 +0000 (02:58 +0200)
committerJavier S. Pedro <maemo@javispedro.com>
Sat, 15 Aug 2009 00:58:11 +0000 (02:58 +0200)
debian/changelog
gfx.cpp
platform/config.cpp
platform/sdl.cpp

index 4129ed8..4546bbd 100644 (file)
@@ -1,3 +1,9 @@
+drnoksnes (0.9.3) unstable; urgency=low
+
+  * SRAM save on exiting and every 15 minutes.
+
+ -- Javier S. Pedro <maemo@javispedro.com>  Sat, 15 Aug 2009 00:18:19 +0200
+
 drnoksnes (0.9.2) unstable; urgency=low
 
   * Fixed a hang on shutdown issue (random libgcc_s bug; now using
diff --git a/gfx.cpp b/gfx.cpp
index 75482b1..3ade0ba 100644 (file)
--- a/gfx.cpp
+++ b/gfx.cpp
@@ -695,7 +695,6 @@ void S9xEndScreenRefresh()
     }
 #endif
 
-/* 
     if (CPU.SRAMModified)
     {
                if (!CPU.AutoSaveTimer)
@@ -712,7 +711,6 @@ void S9xEndScreenRefresh()
                        }
                }
     }
-*/
 }
 
 void S9xSetInfoString (const char *string)
index 3a5ab92..f21fd7d 100644 (file)
@@ -175,6 +175,8 @@ static void loadDefaults()
     Settings.HacksFilter = FALSE;
 
        Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;
+
+       Settings.AutoSaveDelay = 15*60; // Autosave each 15 minutes.
 }
 
 static void setRomFile(const char * path)
index 8675df2..b347748 100644 (file)
@@ -31,6 +31,11 @@ void S9xLoadSDD1Data()
        Settings.SDD1Pack=FALSE;
 }
 
+void S9xAutoSaveSRAM()
+{
+       Memory.SaveSRAM(S9xGetFilename(".srm"));
+}
+
 static void S9xInit() 
 {
        if (!Memory.Init () || !S9xInitAPU())
@@ -181,7 +186,7 @@ int main(int argc, const char ** argv) {
        S9xInit();
        S9xReset();
        
-       // Load rom and related files
+       // Load rom and related files: state
        loadRom();
        
        // Late initialization
@@ -202,7 +207,13 @@ int main(int argc, const char ** argv) {
        S9xAudioOutputEnable(false);
        S9xDeinitAudioOutput();
        S9xDeinitDisplay();
+
+       // Save state
+       Memory.SaveSRAM(S9xGetFilename(".srm"));
+
+       // Late deinitialization
        S9xGraphicsDeinit();
+       Memory.Deinit();
 
        SDL_Quit();