From 644ea117dce672ed13601d29833995169a03303b Mon Sep 17 00:00:00 2001 From: spacy51 Date: Wed, 29 Oct 2008 10:41:52 +0000 Subject: [PATCH] ADDED new function "Load Game -> Do not change cheat list" --- src/Cheats.cpp | 21 +++++++++++++++++++++ src/Cheats.h | 1 + src/Globals.cpp | 1 + src/Globals.h | 3 ++- src/agb/GBA.cpp | 7 ++++++- src/dmg/GB.cpp | 6 +++++- src/dmg/gbCheats.cpp | 29 +++++++++++++++++++++++++++++ src/dmg/gbCheats.h | 1 + src/dmg/gbGlobals.h | 1 + src/win32/MainWnd.cpp | 5 +++++ src/win32/MainWnd.h | 9 ++++++--- src/win32/MainWndFile.cpp | 15 ++++++++++++--- src/win32/VBA.cpp | 12 ++++++------ src/win32/VBA.h | 1 - src/win32/VBA.rc | 4 +++- src/win32/resource.h | 4 ++-- 16 files changed, 101 insertions(+), 19 deletions(-) diff --git a/src/Cheats.cpp b/src/Cheats.cpp index c0e654a4..ba8a6dcd 100644 --- a/src/Cheats.cpp +++ b/src/Cheats.cpp @@ -2667,6 +2667,27 @@ void cheatsReadGame(gzFile file, int version) } } + +// skip the cheat list data +void cheatsReadGameSkip( gzFile file, int version ) +{ + int nCheats = 0; + nCheats = utilReadInt( file ); + + if( version >= 9 ) { + utilGzSeek( file, sizeof( cheatsList ), SEEK_CUR ); + } + + bool firstCodeBreaker = true; + + for( int i = 0; i < nCheats; i++ ) { + if( version < 9 ) { + utilGzSeek( file, ( 7 * sizeof(int) ) + ( 52 * sizeof(char) ), SEEK_CUR ); + } + } +} + + void cheatsSaveCheatList(const char *file) { if(cheatsNumber == 0) diff --git a/src/Cheats.h b/src/Cheats.h index 3f99783c..a9308806 100644 --- a/src/Cheats.h +++ b/src/Cheats.h @@ -25,6 +25,7 @@ void cheatsEnable(int number); void cheatsDisable(int number); void cheatsSaveGame(gzFile file); void cheatsReadGame(gzFile file, int version); +void cheatsReadGameSkip(gzFile file, int version); void cheatsSaveCheatList(const char *file); bool cheatsLoadCheatList(const char *file); void cheatsWriteMemory(u32 address, u32 value); diff --git a/src/Globals.cpp b/src/Globals.cpp index 5d3d895f..f455df55 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -33,6 +33,7 @@ int cpuSaveType = 0; bool cheatsEnabled = true; bool mirroringEnable = false; bool skipSaveGameBattery = false; +bool skipSaveGameCheats = false; // this is an optional hack to change the backdrop/background color: // -1: disabled diff --git a/src/Globals.h b/src/Globals.h index aba86969..c7f54ea2 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -41,7 +41,8 @@ extern bool speedHack; extern int cpuSaveType; extern bool cheatsEnabled; extern bool mirroringEnable; -extern bool skipSaveGameBattery; +extern bool skipSaveGameBattery; // skip battery data when reading save states +extern bool skipSaveGameCheats; // skip cheat list data when reading save states extern int customBackdropColor; extern u8 *bios; diff --git a/src/agb/GBA.cpp b/src/agb/GBA.cpp index 6e9ac7b9..a0a8318b 100644 --- a/src/agb/GBA.cpp +++ b/src/agb/GBA.cpp @@ -740,7 +740,12 @@ static bool CPUReadState(gzFile gzFile) soundReadGame(gzFile, version); if(version > SAVE_GAME_VERSION_1) { - cheatsReadGame(gzFile, version); + if(skipSaveGameCheats) { + // skip cheats list data + cheatsReadGameSkip(gzFile, version); + } else { + cheatsReadGame(gzFile, version); + } } if(version > SAVE_GAME_VERSION_6) { rtcReadGame(gzFile); diff --git a/src/dmg/GB.cpp b/src/dmg/GB.cpp index 2fe1e8ed..65e191d1 100644 --- a/src/dmg/GB.cpp +++ b/src/dmg/GB.cpp @@ -3852,7 +3852,11 @@ static bool gbReadSaveState(gzFile gzFile) systemDrawScreen(); if(version > GBSAVE_GAME_VERSION_1) - gbCheatsReadGame(gzFile, version); + if( skipSaveGameCheats ) { + gbCheatsReadGameSkip(gzFile, version); + } else { + gbCheatsReadGame(gzFile, version); + } if (version<11) { diff --git a/src/dmg/gbCheats.cpp b/src/dmg/gbCheats.cpp index eec086e2..444b052e 100644 --- a/src/dmg/gbCheats.cpp +++ b/src/dmg/gbCheats.cpp @@ -73,6 +73,35 @@ void gbCheatsReadGame(gzFile gzFile, int version) gbCheatUpdateMap(); } + +void gbCheatsReadGameSkip(gzFile gzFile, int version) +{ + if( version <= 8 ) { + int gbGgOn = utilReadInt( gzFile ); + if( gbGgOn ) { + int n = utilReadInt( gzFile ); + if( n > 0 ) { + utilGzSeek( gzFile, n * sizeof(gbXxCheat), SEEK_CUR ); + } + } + + int gbGsOn = utilReadInt( gzFile ); + if( gbGsOn ) { + int n = utilReadInt(gzFile); + if( n > 0 ) { + utilGzSeek( gzFile, n * sizeof(gbXxCheat), SEEK_CUR ); + } + } + } else { + int n = utilReadInt( gzFile ); + + if( n > 0 ) { + utilGzSeek( gzFile, n * sizeof(gbCheat), SEEK_CUR ); + } + } +} + + void gbCheatsSaveCheatList(const char *file) { if(gbCheatNumber == 0) diff --git a/src/dmg/gbCheats.h b/src/dmg/gbCheats.h index 08491e15..261767e4 100644 --- a/src/dmg/gbCheats.h +++ b/src/dmg/gbCheats.h @@ -20,6 +20,7 @@ struct gbCheat { void gbCheatsSaveGame(gzFile); void gbCheatsReadGame(gzFile, int); +void gbCheatsReadGameSkip(gzFile, int); void gbCheatsSaveCheatList(const char *); bool gbCheatsLoadCheatList(const char *); bool gbCheatReadGSCodeFile(const char *); diff --git a/src/dmg/gbGlobals.h b/src/dmg/gbGlobals.h index 03023674..d6c19b6c 100644 --- a/src/dmg/gbGlobals.h +++ b/src/dmg/gbGlobals.h @@ -11,6 +11,7 @@ extern bool useBios; extern bool skipBios; extern u8 *bios; extern bool skipSaveGameBattery; +extern bool skipSaveGameCheats; extern u8 *gbRom; extern u8 *gbRam; diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index 1caffee9..285cfbe8 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -386,8 +386,13 @@ 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) + + ON_COMMAND(ID_LOADGAME_DONOTCHANGECHEATLIST, &MainWnd::OnLoadgameDonotchangecheatlist) + ON_UPDATE_COMMAND_UI(ID_LOADGAME_DONOTCHANGECHEATLIST, &MainWnd::OnUpdateLoadgameDonotchangecheatlist) + ON_COMMAND(ID_OUTPUTAPI_XAUDIO2CONFIG, &MainWnd::OnOutputapiXaudio2config) ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_XAUDIO2CONFIG, &MainWnd::OnUpdateOutputapiXaudio2config) ON_WM_ENTERSIZEMOVE() diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index e53cb65f..353bf73d 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -355,10 +355,13 @@ protected: afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point); afx_msg void OnUpdatePixelfilterMultiThreading(CCmdUI *pCmdUI); afx_msg void OnUpdateOptionsSelectPlugin(CCmdUI *pCmdUI); - afx_msg void OnLoadgameDonotchangebatterysave(); - afx_msg void OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI); - afx_msg void OnEnterSizeMove(); + afx_msg void OnLoadgameDonotchangebatterysave(); + afx_msg void OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI); + afx_msg void OnLoadgameDonotchangecheatlist(); + afx_msg void OnUpdateLoadgameDonotchangecheatlist(CCmdUI *pCmdUI); + + afx_msg void OnEnterSizeMove(); afx_msg void OnAudioCoreSettings(); afx_msg void OnUpdateAudioCoreSettings(CCmdUI *pCmdUI); diff --git a/src/win32/MainWndFile.cpp b/src/win32/MainWndFile.cpp index dad7fd2d..28c2b5e0 100644 --- a/src/win32/MainWndFile.cpp +++ b/src/win32/MainWndFile.cpp @@ -877,11 +877,20 @@ void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI) void MainWnd::OnLoadgameDonotchangebatterysave() { - theApp.winSkipSaveGameBattery = !theApp.winSkipSaveGameBattery; - skipSaveGameBattery = theApp.winSkipSaveGameBattery; + skipSaveGameBattery = !skipSaveGameBattery; } void MainWnd::OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI) { - pCmdUI->SetCheck(theApp.winSkipSaveGameBattery); + pCmdUI->SetCheck(skipSaveGameBattery); +} + +void MainWnd::OnLoadgameDonotchangecheatlist() +{ + skipSaveGameCheats = !skipSaveGameCheats; +} + +void MainWnd::OnUpdateLoadgameDonotchangecheatlist(CCmdUI *pCmdUI) +{ + pCmdUI->SetCheck(skipSaveGameCheats); } diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index a402c057..f6ca57db 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -309,7 +309,6 @@ VBA::VBA() wasPaused = false; frameskipadjust = 0; autoLoadMostRecent = false; - winSkipSaveGameBattery = false; maxScale = 0; romSize = 0; lastWindowed = VIDEO_3X; @@ -1716,11 +1715,11 @@ void VBA::loadSettings() if(joypadDefault < 0 || joypadDefault > 3) joypadDefault = 0; - autoLoadMostRecent = regQueryDwordValue("autoLoadMostRecent", false) ? true : - false; + autoLoadMostRecent = ( 1 == regQueryDwordValue("autoLoadMostRecent", 0) ) ? true : false; - winSkipSaveGameBattery = regQueryDwordValue("winSkipSaveGameBattery", false) ? true : false; - skipSaveGameBattery = theApp.winSkipSaveGameBattery; + skipSaveGameBattery = ( 1 == regQueryDwordValue("skipSaveGameBattery", 0) ) ? true : false; + + skipSaveGameCheats = ( 1 == regQueryDwordValue("skipSaveGameCheats", 0) ) ? true : false; cheatsEnabled = regQueryDwordValue("cheatsEnabled", false) ? true : false; @@ -2633,7 +2632,8 @@ void VBA::saveSettings() regSetDwordValue("joypadDefault", joypadDefault); regSetDwordValue("autoLoadMostRecent", autoLoadMostRecent); - regSetDwordValue("winSkipSaveGameBattery", winSkipSaveGameBattery); + regSetDwordValue("skipSaveGameBattery", skipSaveGameBattery); + regSetDwordValue("skipSaveGameCheats", skipSaveGameCheats); regSetDwordValue("cheatsEnabled", cheatsEnabled); regSetDwordValue("maxScale", maxScale); regSetDwordValue("throttle", throttle); diff --git a/src/win32/VBA.h b/src/win32/VBA.h index 6a238bed..1b6e9fdd 100644 --- a/src/win32/VBA.h +++ b/src/win32/VBA.h @@ -179,7 +179,6 @@ class VBA : public CWinApp bool wasPaused; int frameskipadjust; bool autoLoadMostRecent; - bool winSkipSaveGameBattery; int maxScale; int romSize; VIDEO_SIZE lastWindowed; diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc index 68d2b44a..b0515a10 100644 --- a/src/win32/VBA.rc +++ b/src/win32/VBA.rc @@ -1632,7 +1632,6 @@ 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 @@ -1644,6 +1643,9 @@ BEGIN MENUITEM "Slot #8", ID_FILE_LOADGAME_SLOT8 MENUITEM "Slot #9", ID_FILE_LOADGAME_SLOT9 MENUITEM "Slot #10", ID_FILE_LOADGAME_SLOT10 + MENUITEM SEPARATOR + MENUITEM "Do not change battery save", ID_LOADGAME_DONOTCHANGEBATTERYSAVE + MENUITEM "Do not change cheat list", ID_LOADGAME_DONOTCHANGECHEATLIST END POPUP "Save Game" BEGIN diff --git a/src/win32/resource.h b/src/win32/resource.h index 33675830..aa4cff93 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -392,7 +392,6 @@ #define IDC_MAP_VIEW_ZOOM 1138 #define IDS_MOVIE_PLAY 1138 #define IDC_VIEWER 1140 -#define IDC_SAVE_BG2 1140 #define IDC_CHANGE_BACKDROP 1140 #define IDC_ADDRESSES 1141 #define IDC_GO 1143 @@ -870,13 +869,14 @@ #define ID_FILE_OPEN_GBA 40366 #define ID_FILE_QUICKOPENROM 40367 #define ID_OPTIONS_VIDEO_LAYERS_RESET 40368 +#define ID_LOADGAME_DONOTCHANGECHEATLIST 40370 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 165 -#define _APS_NEXT_COMMAND_VALUE 40370 +#define _APS_NEXT_COMMAND_VALUE 40371 #define _APS_NEXT_CONTROL_VALUE 1297 #define _APS_NEXT_SYMED_VALUE 103 #endif