From fe5d1b23131e9612c5df1e2602d15e4bbc0a5f17 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 19 Dec 2008 22:11:01 +0000 Subject: [PATCH] Backup savestate is created before a state is loaded --- changelog.txt | 1 + src/drivers/win/state.cpp | 3 +-- src/state.cpp | 15 +++++++++++++++ src/state.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 2bef666f..0e32e2f9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,5 @@ ---version 2.0.4 yet to be released--- +19-dec-2008 - adelikat - Backup savestate is made before loading a state 18-dec-2008 - adelikat - win32 - turbo bypasses sound better if muteturbo is checked 18-dec-2008 - shinydoofy - sdl - fixed compiling errors for SDL due to r1037 18-dec-2008 - adelikat - win32 - fullscreen mode fixed (both enters and returns to fullscreen just fine) diff --git a/src/drivers/win/state.cpp b/src/drivers/win/state.cpp index f9e91b06..9669b71e 100644 --- a/src/drivers/win/state.cpp +++ b/src/drivers/win/state.cpp @@ -55,5 +55,4 @@ void FCEUD_LoadStateFrom() // Load save state if a file was selected. FCEUI_LoadState(nameo); } -} - +} \ No newline at end of file diff --git a/src/state.cpp b/src/state.cpp index 61e84ef4..480c299e 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -48,6 +48,8 @@ #include "zlib.h" #include "driver.h" +using namespace std; + static void (*SPreSave)(void); static void (*SPostSave)(void); @@ -795,6 +797,7 @@ void FCEUI_LoadState(const char *fname) information expected in newer save states, desynchronization won't occur(at least not from this ;)). */ + BackupSaveState(); if(FCEUSS_Load(fname)) { @@ -836,3 +839,15 @@ void FCEU_DrawSaveStates(uint8 *XBuf) StateShow--; } +void BackupSaveState() +{ + //Everytime a load state is loaded, this is run prior so that the user has a backup of the previous emulator state + string filename; + int x; + + filename = strdup(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str()); //Generate normal savestate filename + x = filename.find_last_of("."); //Find last dot + filename = filename.substr(0,x); //Chop off file extension + filename.append(".bak"); //add .bak +} + diff --git a/src/state.h b/src/state.h index c7d640b2..b5b72267 100644 --- a/src/state.h +++ b/src/state.h @@ -61,3 +61,4 @@ void AddExState(void *v, uint32 s, int type, char *desc); void FCEU_DrawSaveStates(uint8 *XBuf); +void BackupSaveState(); //Makes a backupsavestate \ No newline at end of file