diff --git a/src/drivers/win/cheat.cpp b/src/drivers/win/cheat.cpp index ef60cc3f..95d83390 100644 --- a/src/drivers/win/cheat.cpp +++ b/src/drivers/win/cheat.cpp @@ -1031,27 +1031,22 @@ CPoint test = point; void DisableAllCheats() { - if(!FCEU_DisableAllCheats() || !hCheat){ - return; - } - int selcheattemp = SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETCOUNT, 0, 0) - 1; - LRESULT sel; char str[259]; - while(selcheattemp >= 0) - { - SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_GETTEXT,selcheattemp, (LPARAM)(LPCTSTR)str); - if(str[0] == '*') + if(FCEU_DisableAllCheats() && hCheat){ + LRESULT sel; char str[259]; + for (int tempSelCheat = SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETCOUNT, 0, 0) - 1; tempSelCheat >= 0; --tempSelCheat) { - sel = SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_GETSEL,selcheattemp,0); - str[0] = ' '; - SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_DELETESTRING,selcheattemp,0); - SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_INSERTSTRING,selcheattemp, (LPARAM)(LPSTR)str); - if(sel) + SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETTEXT, tempSelCheat, (LPARAM)(LPCTSTR)str); + if (str[0] == '*') { - SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_SETSEL,1,selcheattemp); + str[0] = ' '; + sel = SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETSEL, tempSelCheat, 0); + SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_DELETESTRING, tempSelCheat, 0); + SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_INSERTSTRING, tempSelCheat, (LPARAM)(LPSTR)str); + if (sel) + SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_SETSEL, 1, tempSelCheat); } } - selcheattemp--; - } - sprintf(str, "Active Cheats %d", 0); - SetDlgItemText(hCheat, 201, str); + sprintf(str, "Active Cheats %d", 0); + SetDlgItemText(hCheat, 201, str); + } } \ No newline at end of file diff --git a/src/drivers/win/memview.cpp b/src/drivers/win/memview.cpp index 6f46e452..a6c2cc0a 100644 --- a/src/drivers/win/memview.cpp +++ b/src/drivers/win/memview.cpp @@ -1263,7 +1263,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa // update menus for (i = MODE_NES_MEMORY; i <= MODE_NES_FILE; i++) if(EditingMode == i) { - CheckMenuRadioItem(GetMenu(hMemView), MENU_MV_VIEW_RAM, MENU_MV_VIEW_ROM, MENU_MV_VIEW_RAM + i, MF_BYCOMMAND); + CheckMenuRadioItem(GetMenu(hwnd), MENU_MV_VIEW_RAM, MENU_MV_VIEW_ROM, MENU_MV_VIEW_RAM, MF_BYCOMMAND); break; } CheckMenuItem(GetMenu(hwnd), ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY, (MemView_HighlightActivity) ? MF_CHECKED: MF_UNCHECKED); diff --git a/src/drivers/win/ram_search.cpp b/src/drivers/win/ram_search.cpp index b7c73a85..5e3e9a19 100644 --- a/src/drivers/win/ram_search.cpp +++ b/src/drivers/win/ram_search.cpp @@ -85,7 +85,7 @@ struct MemoryRegion unsigned int virtualIndex; // index into s_prevValues, s_curValues, and s_numChanges, valid after being initialized in ResetMemoryRegions() unsigned int itemIndex; // index into listbox items, valid when s_itemIndicesInvalid is false - unsigned int cheatAffect; // how many bytes affected by the cheats. 0 indicates for free, max value is the size. + unsigned int cheatCount; // how many bytes affected by the cheats. 0 indicates for free, max value is the size. }; int MAX_RAM_SIZE = 0; @@ -423,10 +423,10 @@ void ItemIndexToVirtualRegion(unsigned int itemIndex, MemoryRegion& virtualRegio virtualRegion.virtualIndex = region->virtualIndex + bytesWithinRegion; virtualRegion.itemIndex = itemIndex; - virtualRegion.cheatAffect = 0; - for (int i = 0; i < numsubcheats; ++i) + virtualRegion.cheatCount = 0; + for (int i = 0; i < numsubcheats && virtualRegion.cheatCount <= virtualRegion.size; ++i) if (SubCheats[i].addr >= virtualRegion.hardwareAddress && SubCheats[i].addr < virtualRegion.hardwareAddress + virtualRegion.size) - ++virtualRegion.cheatAffect; + ++virtualRegion.cheatCount; } template @@ -494,11 +494,11 @@ unsigned int GetHardwareAddressFromItemIndex(unsigned int itemIndex) return virtualRegion.hardwareAddress; } template -unsigned int GetCheatStatusFromItemIndex(unsigned int itemIndex) +unsigned int GetNumCheatsFromIndex(unsigned int itemIndex) { MemoryRegion virtualRegion; ItemIndexToVirtualRegion(itemIndex, virtualRegion); - return virtualRegion.cheatAffect; + return virtualRegion.cheatCount; } // this one might be unreliable, haven't used it much @@ -1270,7 +1270,17 @@ LRESULT CustomDraw (LPARAM lParam) { int rv = CDRF_DODEFAULT; - if(lplvcd->nmcd.dwItemSpec % 2) + if (int cheat = CALL_WITH_T_SIZE_TYPES_1(GetNumCheatsFromIndex, rs_type_size, rs_t == 's', noMisalign, lplvcd->nmcd.dwItemSpec)) + { + switch (cheat) { + case 1: lplvcd->clrTextBk = RGB(216, 203, 253); break; + case 2: lplvcd->clrTextBk = RGB(195, 186, 253); break; + case 3: lplvcd->clrTextBk = RGB(176, 139, 252); break; + case 4: lplvcd->clrTextBk = RGB(175, 94, 253); break; + } + rv = CDRF_NEWFONT; + } + else if(lplvcd->nmcd.dwItemSpec % 2) { // alternate the background color slightly lplvcd->clrTextBk = RGB(248,248,255); @@ -1518,8 +1528,8 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara SendDlgItemMessage(hDlg,IDC_C_SEARCHROM,BM_SETCHECK,ShowROM?BST_CHECKED:BST_UNCHECKED,0); //const char* names[5] = {"Address","Value","Previous","Changes","Notes"}; //int widths[5] = {62,64,64,55,55}; - const char* names[5] = {"Addr.","Value","Previous","Changes","Cheats"}; - int widths[5] = {48,80,80,66,52}; + const char* names[5] = {"Addr.","Value","Previous","Changes"}; + int widths[5] = {68,76,76,68}; if (!ResultCount) reset_address_info(); else @@ -1627,7 +1637,7 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara } return true; case 4: { - int cheat = CALL_WITH_T_SIZE_TYPES_1(GetCheatStatusFromItemIndex, rs_type_size, rs_t=='s', noMisalign, iNum); + int cheat = CALL_WITH_T_SIZE_TYPES_1(GetNumCheatsFromIndex, rs_type_size, rs_t=='s', noMisalign, iNum); sprintf(num, "%d", cheat); Item->item.pszText = num; } diff --git a/src/drivers/win/replay.cpp b/src/drivers/win/replay.cpp index 9b5e7520..c0a3b7c7 100644 --- a/src/drivers/win/replay.cpp +++ b/src/drivers/win/replay.cpp @@ -731,6 +731,11 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP case IDYES: extern void DisableAllCheats(); DisableAllCheats(); + extern HWND hMemView; + if (hMemView) { + extern void UpdateColorTable(); + UpdateColorTable(); //if the memory viewer is open then update any blue freeze locations in it as well + } } }