From 757c13e22af355fb2b25a83b5e4a56bc42eeaff3 Mon Sep 17 00:00:00 2001 From: owomomo Date: Sun, 6 Sep 2020 08:20:20 +0800 Subject: [PATCH] Cheat Search: Switch of show address in Game Genie format --- src/cheat.cpp | 1 + src/drivers/win/cheat.cpp | 34 ++++++++++++++++++++++++++++++---- src/drivers/win/config.cpp | 2 ++ src/drivers/win/res.rc | 8 ++++---- src/drivers/win/resource.h | 5 ++--- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/cheat.cpp b/src/cheat.cpp index fe2db821..e2b2ad9b 100644 --- a/src/cheat.cpp +++ b/src/cheat.cpp @@ -63,6 +63,7 @@ CHEATF_SUBFAST SubCheats[256] = { 0 }; uint32 numsubcheats = 0; int globalCheatDisabled = 0; int disableAutoLSCheats = 0; +bool disableShowGG = 0; static _8BYTECHEATMAP* cheatMap = NULL; struct CHEATF *cheats = 0, *cheatsl = 0; diff --git a/src/drivers/win/cheat.cpp b/src/drivers/win/cheat.cpp index 51420385..e501b6c7 100644 --- a/src/drivers/win/cheat.cpp +++ b/src/drivers/win/cheat.cpp @@ -37,6 +37,7 @@ HMENU hCheatcontext = 0; //Handle to cheat context menu bool pauseWhileActive = false; //For checkbox "Pause while active" extern int globalCheatDisabled; extern int disableAutoLSCheats; +extern bool disableShowGG; extern bool wasPausedByCheats; int CheatWindow; @@ -316,6 +317,7 @@ INT_PTR CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA CheckDlgButton(hwndDlg, IDC_CHEAT_PAUSEWHENACTIVE, pauseWhileActive ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CHEAT_GLOBAL_SWITCH, globalCheatDisabled ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton(hwndDlg, IDC_CHEAT_AUTOLOADSAVE, disableAutoLSCheats == 2 ? BST_UNCHECKED : disableAutoLSCheats == 1 ? BST_INDETERMINATE : BST_CHECKED); + CheckDlgButton(hwndDlg, IDC_CHEAT_SHOWGG, disableShowGG ? BST_UNCHECKED : BST_CHECKED); //setup font SetupCheatFont(hwndDlg); @@ -761,6 +763,31 @@ INT_PTR CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA } SetCheatToolTip(hwndDlg, IDC_CHEAT_AUTOLOADSAVE); } + break; + case IDC_CHEAT_SHOWGG: + { + disableShowGG ^= 1; + void(*CreateCheatStr)(char* buf, int a, int v, int c) = disableShowGG ? GetCheatCodeStr : EncodeGG; + + int i = 0; + char buf[32]; + + LVITEM lvi; + lvi.iSubItem = 0; + struct CHEATF* cheat = cheats; + + while (cheat != NULL) + { + if (cheat->addr > 0x7FFF) + { + CreateCheatStr(buf, cheat->addr, cheat->val, cheat->compare); + lvi.pszText = buf; + SendDlgItemMessage(hwndDlg, IDC_LIST_CHEATS, LVM_SETITEMTEXT, i, (LPARAM)&lvi); + } + cheat = cheat->next; + ++i; + } + } } break; case EN_SETFOCUS: @@ -1311,11 +1338,10 @@ void DoGGConv() inline void GetCheatStr(char* buf, int a, int v, int c) { - if (a > 0x7FFF) - EncodeGG(buf, a, v, c); - else { + if (a < 0x8000 || disableShowGG) GetCheatCodeStr(buf, a, v, c); - } + else + EncodeGG(buf, a, v, c); } inline void GetCheatCodeStr(char* buf, int a, int v, int c) diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 006e58c3..1cc440d9 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -58,6 +58,7 @@ extern int CurrentState; extern bool pauseWhileActive; //adelikat: Cheats dialog extern int globalCheatDisabled; extern int disableAutoLSCheats; +extern bool disableShowGG; extern bool enableHUDrecording; extern bool disableMovieMessages; extern bool replaceP2StartWithMicrophone; @@ -469,6 +470,7 @@ static CFGSTRUCT fceuconfig[] = AC(compressSavestates), AC(pauseWhileActive), AC(disableAutoLSCheats), + AC(disableShowGG), AC(globalCheatDisabled), AC(enableHUDrecording), AC(disableMovieMessages), diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 629de76b..f1d132d8 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -1380,10 +1380,10 @@ CAPTION "Cheat Search" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Active Cheats",IDC_GROUPBOX_CHEATLIST,5,2,169,219,WS_TABSTOP - CONTROL "Enable cheats",IDC_CHEAT_GLOBAL_SWITCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,12,58,10 - CONTROL "Auto load / save with game",IDC_CHEAT_AUTOLOADSAVE, - "Button",BS_AUTO3STATE | WS_TABSTOP,71,12,100,10 - CONTROL "",IDC_LIST_CHEATS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,11,24,157,133 + CONTROL "Enable",IDC_CHEAT_GLOBAL_SWITCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,12,38,10 + CONTROL "Auto load / save",IDC_CHEAT_AUTOLOADSAVE,"Button",BS_AUTO3STATE | WS_TABSTOP,59,12,66,10 + CONTROL "Show GG", IDC_CHEAT_SHOWGG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 127, 12, 42, 10 + CONTROL "",IDC_LIST_CHEATS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,11,24,157,133 LTEXT "Name:",IDC_STATIC,12,162,22,10 EDITTEXT IDC_CHEAT_NAME,37,160,131,12,ES_AUTOHSCROLL | ES_WANTRETURN LTEXT "Address:",IDC_CHEAT_ADDRESS_LABEL,12,176,30,8 diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 4a960f12..49982418 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -625,12 +625,10 @@ #define IDC_MISCELLANEOUS_ROMS_EDIT 1087 #define IDC_EXTEND_SYSTEM_GROUP 1089 #define IDC_EXTEND_SYSTEM_TEXT 1090 -#define IDC_BUTTON1 1094 #define IDC_CHEAT_SWITCH 1096 #define IDC_CHEAT_GLOBAL_SWITCH 1096 #define IDC_GAME_GENIE_LABEL 1097 #define IDC_CHEAT_GAME_GENIE_TEXT 1098 -#define IDC_CHECK2 1099 #define IDC_RADIO_SHORTCUT1 1100 #define IDC_RADIO_SHORTCUT2 1101 #define IDC_RADIO_SHORTCUT3 1102 @@ -643,6 +641,7 @@ #define IDC_RADIO_SHORTCUT0 1109 #define IDC_BOOKMARK_VIEW_TEXT 1110 #define IDC_BOOKMARK_COMBO_VIEW 1112 +#define IDC_CHEAT_SHOWGG 1112 #define BTN_ALLOW_LRUD 1117 #define IDC_PRGROM_EDIT 1118 #define IDC_CHRROM_EDIT 1119 @@ -1167,7 +1166,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 309 #define _APS_NEXT_COMMAND_VALUE 40005 -#define _APS_NEXT_CONTROL_VALUE 1112 +#define _APS_NEXT_CONTROL_VALUE 1113 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif