diff --git a/src/EEprom.cpp b/src/EEprom.cpp index 2b6b3800..fc74bf6a 100644 --- a/src/EEprom.cpp +++ b/src/EEprom.cpp @@ -77,6 +77,15 @@ void eepromReadGame(gzFile gzFile, int version) } } +void eepromReadGameSkip(gzFile gzFile, int version) +{ + // skip the eeprom data in a save game + utilReadDataSkip(gzFile, eepromSaveData); + if(version >= SAVE_GAME_VERSION_3) { + utilGzSeek(gzFile, sizeof(int), SEEK_CUR); + utilGzSeek(gzFile, 0x2000, SEEK_CUR); + } +} int eepromRead(u32 /* address */) { diff --git a/src/EEprom.h b/src/EEprom.h index 3418ec4a..2130d2d4 100644 --- a/src/EEprom.h +++ b/src/EEprom.h @@ -22,6 +22,7 @@ extern void eepromSaveGame(gzFile _gzFile); extern void eepromReadGame(gzFile _gzFile, int version); +extern void eepromReadGameSkip(gzFile _gzFile, int version); extern int eepromRead(u32 address); extern void eepromWrite(u32 address, u8 value); extern void eepromInit(); diff --git a/src/Flash.cpp b/src/Flash.cpp index 362a424d..98427c9e 100644 --- a/src/Flash.cpp +++ b/src/Flash.cpp @@ -97,6 +97,18 @@ void flashReadGame(gzFile gzFile, int version) } } +void flashReadGameSkip(gzFile gzFile, int version) +{ + // skip the flash data in a save game + if(version < SAVE_GAME_VERSION_5) + utilReadDataSkip(gzFile, flashSaveData); + else if(version < SAVE_GAME_VERSION_7) { + utilReadDataSkip(gzFile, flashSaveData2); + } else { + utilReadDataSkip(gzFile, flashSaveData3); + } +} + void flashSetSize(int size) { // log("Setting flash size to %d\n", size); diff --git a/src/Flash.h b/src/Flash.h index debda734..90865f91 100644 --- a/src/Flash.h +++ b/src/Flash.h @@ -22,6 +22,7 @@ extern void flashSaveGame(gzFile _gzFile); extern void flashReadGame(gzFile _gzFile, int version); +extern void flashReadGameSkip(gzFile _gzFile, int version); extern u8 flashRead(u32 address); extern void flashWrite(u32 address, u8 byte); extern void flashDelayedWrite(u32 address, u8 byte); diff --git a/src/Globals.cpp b/src/Globals.cpp index a5350163..1812cfaf 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -50,6 +50,7 @@ bool speedHack = false; int cpuSaveType = 0; bool cheatsEnabled = true; bool mirroringEnable = false; +bool skipSaveGameBattery = false; u8 *bios = NULL; u8 *rom = NULL; diff --git a/src/Globals.h b/src/Globals.h index 1d5febda..209145e6 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -60,6 +60,7 @@ extern bool speedHack; extern int cpuSaveType; extern bool cheatsEnabled; extern bool mirroringEnable; +extern bool skipSaveGameBattery; extern u8 *bios; extern u8 *rom; diff --git a/src/Util.cpp b/src/Util.cpp index ea30fc40..cde98abf 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -57,6 +57,7 @@ extern u32 systemColorMap32[0x10000]; static int (ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL; static int (ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL; static int (ZEXPORT *utilGzCloseFunc)(gzFile) = NULL; +static z_off_t (ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL; bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix) { @@ -631,6 +632,14 @@ void utilReadData(gzFile gzFile, variable_desc* data) } } +void utilReadDataSkip(gzFile gzFile, variable_desc* data) +{ + while(data->address) { + utilGzSeek(gzFile, data->size, SEEK_CUR); + data++; + } +} + void utilWriteData(gzFile gzFile, variable_desc *data) { while(data->address) { @@ -644,6 +653,7 @@ gzFile utilGzOpen(const char *file, const char *mode) utilGzWriteFunc = (int (ZEXPORT *)(void *,void * const, unsigned int))gzwrite; utilGzReadFunc = gzread; utilGzCloseFunc = gzclose; + utilGzSeekFunc = gzseek; return gzopen(file, mode); } @@ -672,6 +682,11 @@ int utilGzClose(gzFile file) return utilGzCloseFunc(file); } +z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence) +{ + return utilGzSeekFunc(file, offset, whence); +} + long utilGzMemTell(gzFile file) { return memtell(file); diff --git a/src/Util.h b/src/Util.h index 38451c8b..6e51802e 100644 --- a/src/Util.h +++ b/src/Util.h @@ -52,6 +52,7 @@ extern void utilPutDword(u8 *, u32); extern void utilPutWord(u8 *, u16); extern void utilWriteData(gzFile, variable_desc *); extern void utilReadData(gzFile, variable_desc *); +extern void utilReadDataSkip(gzFile, variable_desc *); extern int utilReadInt(gzFile); extern void utilWriteInt(gzFile, int); extern gzFile utilGzOpen(const char *file, const char *mode); @@ -59,6 +60,7 @@ extern gzFile utilMemGzOpen(char *memory, int available, const char *mode); extern int utilGzWrite(gzFile file, const voidp buffer, unsigned int len); extern int utilGzRead(gzFile file, voidp buffer, unsigned int len); extern int utilGzClose(gzFile file); +extern z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence); extern long utilGzMemTell(gzFile file); extern void utilGBAFindSave(const u8 *, const int); extern void utilUpdateSystemColorMaps(); diff --git a/src/agb/GBA.cpp b/src/agb/GBA.cpp index 42fecd66..0fbb9a0b 100644 --- a/src/agb/GBA.cpp +++ b/src/agb/GBA.cpp @@ -746,8 +746,15 @@ static bool CPUReadState(gzFile gzFile) utilGzRead(gzFile, pix, 4*241*162); utilGzRead(gzFile, ioMem, 0x400); - eepromReadGame(gzFile, version); - flashReadGame(gzFile, version); + if(skipSaveGameBattery) { + // skip eeprom data + eepromReadGameSkip(gzFile, version); + // skip flash data + flashReadGameSkip(gzFile, version); + } else { + eepromReadGame(gzFile, version); + flashReadGame(gzFile, version); + } soundReadGame(gzFile, version); if(version > SAVE_GAME_VERSION_1) { diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index 162bf26d..dd060ea3 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -440,6 +440,8 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd) ON_COMMAND(ID_PIXELFILTER_MULTI, &MainWnd::OnPixelfilterMultiThreading) ON_UPDATE_COMMAND_UI(ID_PIXELFILTER_MULTI, &MainWnd::OnUpdatePixelfilterMultiThreading) ON_UPDATE_COMMAND_UI(ID_OPTIONS_SELECT_PLUGIN, &MainWnd::OnUpdateOptionsSelectPlugin) + ON_COMMAND(ID_LOADGAME_DONOTCHANGEBATTERYSAVE, &MainWnd::OnLoadgameDonotchangebatterysave) + ON_UPDATE_COMMAND_UI(ID_LOADGAME_DONOTCHANGEBATTERYSAVE, &MainWnd::OnUpdateLoadgameDonotchangebatterysave) END_MESSAGE_MAP() diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index c6e41b98..cd4f64c5 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -428,6 +428,8 @@ public: afx_msg void OnPixelfilterMultiThreading(); afx_msg void OnUpdatePixelfilterMultiThreading(CCmdUI *pCmdUI); afx_msg void OnUpdateOptionsSelectPlugin(CCmdUI *pCmdUI); + afx_msg void OnLoadgameDonotchangebatterysave(); + afx_msg void OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI); }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32/MainWndFile.cpp b/src/win32/MainWndFile.cpp index f901fa9b..a6cc690d 100644 --- a/src/win32/MainWndFile.cpp +++ b/src/win32/MainWndFile.cpp @@ -991,3 +991,14 @@ void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI) { pCmdUI->SetCheck(theApp.autoLoadMostRecent); } + +void MainWnd::OnLoadgameDonotchangebatterysave() +{ + theApp.winSkipSaveGameBattery = !theApp.winSkipSaveGameBattery; + skipSaveGameBattery = theApp.winSkipSaveGameBattery; +} + +void MainWnd::OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI) +{ + pCmdUI->SetCheck(theApp.winSkipSaveGameBattery); +} diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 2f58ba54..8a2ed048 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -336,6 +336,7 @@ VBA::VBA() wasPaused = false; frameskipadjust = 0; autoLoadMostRecent = false; + winSkipSaveGameBattery = false; fsMaxScale = 0; romSize = 0; lastWindowed = VIDEO_3X; @@ -1761,6 +1762,9 @@ void VBA::loadSettings() autoLoadMostRecent = regQueryDwordValue("autoLoadMostRecent", false) ? true : false; + winSkipSaveGameBattery = regQueryDwordValue("winSkipSaveGameBattery", false) ? true : false; + skipSaveGameBattery = theApp.winSkipSaveGameBattery; + cheatsEnabled = regQueryDwordValue("cheatsEnabled", false) ? true : false; fsMaxScale = regQueryDwordValue("fsMaxScale", 0); @@ -2669,6 +2673,7 @@ void VBA::saveSettings() regSetDwordValue("joypadDefault", joypadDefault); regSetDwordValue("autoLoadMostRecent", autoLoadMostRecent); + regSetDwordValue("winSkipSaveGameBattery", winSkipSaveGameBattery); regSetDwordValue("cheatsEnabled", cheatsEnabled); regSetDwordValue("fsMaxScale", fsMaxScale); regSetDwordValue("throttle", throttle); diff --git a/src/win32/VBA.h b/src/win32/VBA.h index 22d7964d..43198d60 100644 --- a/src/win32/VBA.h +++ b/src/win32/VBA.h @@ -201,6 +201,7 @@ class VBA : public CWinApp bool wasPaused; int frameskipadjust; bool autoLoadMostRecent; + bool winSkipSaveGameBattery; int fsMaxScale; int romSize; VIDEO_SIZE lastWindowed; diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc index df2b17a7..45e573d6 100644 --- a/src/win32/VBA.rc +++ b/src/win32/VBA.rc @@ -12,6 +12,38 @@ ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.\0" +END + + +3 TEXTINCLUDE +BEGIN + "\r\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources @@ -1515,6 +1547,7 @@ BEGIN BEGIN MENUITEM "Most recent", ID_FILE_LOADGAME_MOSTRECENT MENUITEM "Auto load most recent", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT + MENUITEM "Do not change battery save", ID_LOADGAME_DONOTCHANGEBATTERYSAVE MENUITEM SEPARATOR MENUITEM "Slot #1", ID_FILE_LOADGAME_SLOT1 MENUITEM "Slot #2", ID_FILE_LOADGAME_SLOT2 diff --git a/src/win32/resource.h b/src/win32/resource.h index fba68827..4da1f21f 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -855,13 +855,15 @@ #define ID_FILE_OPEN_GBC 40358 #define ID_OUTPUTAPI_XAUDIO2 40359 #define ID_PIXELFILTER_MULTI 40360 +#define ID_EMULATOR_LOADSTATESHOULD 40361 +#define ID_LOADGAME_DONOTCHANGEBATTERYSAVE 40362 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 163 -#define _APS_NEXT_COMMAND_VALUE 40361 +#define _APS_NEXT_COMMAND_VALUE 40363 #define _APS_NEXT_CONTROL_VALUE 1285 #define _APS_NEXT_SYMED_VALUE 103 #endif