1. Use different background color for addresses affected by cheats in RAM Search.

2. Fix nothing was checked in the View menu when Hex Editor first launch.
3. Fix when Hex Editor is open, disabling all cheats in replay doesn't refresh the freezed addresses.
This commit is contained in:
owomomo 2019-04-02 23:11:46 +08:00
parent 19d8e8ffbb
commit 85c77109c0
4 changed files with 40 additions and 30 deletions

View File

@ -1031,27 +1031,22 @@ CPoint test = point;
void DisableAllCheats() void DisableAllCheats()
{ {
if(!FCEU_DisableAllCheats() || !hCheat){ if(FCEU_DisableAllCheats() && hCheat){
return;
}
int selcheattemp = SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETCOUNT, 0, 0) - 1;
LRESULT sel; char str[259]; LRESULT sel; char str[259];
while(selcheattemp >= 0) for (int tempSelCheat = SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETCOUNT, 0, 0) - 1; tempSelCheat >= 0; --tempSelCheat)
{ {
SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_GETTEXT,selcheattemp, (LPARAM)(LPCTSTR)str); SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETTEXT, tempSelCheat, (LPARAM)(LPCTSTR)str);
if (str[0] == '*') if (str[0] == '*')
{ {
sel = SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_GETSEL,selcheattemp,0);
str[0] = ' '; str[0] = ' ';
SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_DELETESTRING,selcheattemp,0); sel = SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_GETSEL, tempSelCheat, 0);
SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_INSERTSTRING,selcheattemp, (LPARAM)(LPSTR)str); SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_DELETESTRING, tempSelCheat, 0);
SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_INSERTSTRING, tempSelCheat, (LPARAM)(LPSTR)str);
if (sel) if (sel)
{ SendDlgItemMessage(hCheat, IDC_LIST_CHEATS, LB_SETSEL, 1, tempSelCheat);
SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_SETSEL,1,selcheattemp);
} }
} }
selcheattemp--;
}
sprintf(str, "Active Cheats %d", 0); sprintf(str, "Active Cheats %d", 0);
SetDlgItemText(hCheat, 201, str); SetDlgItemText(hCheat, 201, str);
} }
}

View File

@ -1263,7 +1263,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
// update menus // update menus
for (i = MODE_NES_MEMORY; i <= MODE_NES_FILE; i++) for (i = MODE_NES_MEMORY; i <= MODE_NES_FILE; i++)
if(EditingMode == 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; break;
} }
CheckMenuItem(GetMenu(hwnd), ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY, (MemView_HighlightActivity) ? MF_CHECKED: MF_UNCHECKED); CheckMenuItem(GetMenu(hwnd), ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY, (MemView_HighlightActivity) ? MF_CHECKED: MF_UNCHECKED);

View File

@ -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 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 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; int MAX_RAM_SIZE = 0;
@ -423,10 +423,10 @@ void ItemIndexToVirtualRegion(unsigned int itemIndex, MemoryRegion& virtualRegio
virtualRegion.virtualIndex = region->virtualIndex + bytesWithinRegion; virtualRegion.virtualIndex = region->virtualIndex + bytesWithinRegion;
virtualRegion.itemIndex = itemIndex; virtualRegion.itemIndex = itemIndex;
virtualRegion.cheatAffect = 0; virtualRegion.cheatCount = 0;
for (int i = 0; i < numsubcheats; ++i) for (int i = 0; i < numsubcheats && virtualRegion.cheatCount <= virtualRegion.size; ++i)
if (SubCheats[i].addr >= virtualRegion.hardwareAddress && SubCheats[i].addr < virtualRegion.hardwareAddress + virtualRegion.size) if (SubCheats[i].addr >= virtualRegion.hardwareAddress && SubCheats[i].addr < virtualRegion.hardwareAddress + virtualRegion.size)
++virtualRegion.cheatAffect; ++virtualRegion.cheatCount;
} }
template<typename stepType, typename compareType> template<typename stepType, typename compareType>
@ -494,11 +494,11 @@ unsigned int GetHardwareAddressFromItemIndex(unsigned int itemIndex)
return virtualRegion.hardwareAddress; return virtualRegion.hardwareAddress;
} }
template<typename stepType, typename compareType> template<typename stepType, typename compareType>
unsigned int GetCheatStatusFromItemIndex(unsigned int itemIndex) unsigned int GetNumCheatsFromIndex(unsigned int itemIndex)
{ {
MemoryRegion virtualRegion; MemoryRegion virtualRegion;
ItemIndexToVirtualRegion<stepType, compareType>(itemIndex, virtualRegion); ItemIndexToVirtualRegion<stepType, compareType>(itemIndex, virtualRegion);
return virtualRegion.cheatAffect; return virtualRegion.cheatCount;
} }
// this one might be unreliable, haven't used it much // this one might be unreliable, haven't used it much
@ -1270,7 +1270,17 @@ LRESULT CustomDraw (LPARAM lParam)
{ {
int rv = CDRF_DODEFAULT; 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 // alternate the background color slightly
lplvcd->clrTextBk = RGB(248,248,255); 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); SendDlgItemMessage(hDlg,IDC_C_SEARCHROM,BM_SETCHECK,ShowROM?BST_CHECKED:BST_UNCHECKED,0);
//const char* names[5] = {"Address","Value","Previous","Changes","Notes"}; //const char* names[5] = {"Address","Value","Previous","Changes","Notes"};
//int widths[5] = {62,64,64,55,55}; //int widths[5] = {62,64,64,55,55};
const char* names[5] = {"Addr.","Value","Previous","Changes","Cheats"}; const char* names[5] = {"Addr.","Value","Previous","Changes"};
int widths[5] = {48,80,80,66,52}; int widths[5] = {68,76,76,68};
if (!ResultCount) if (!ResultCount)
reset_address_info(); reset_address_info();
else else
@ -1627,7 +1637,7 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
} return true; } return true;
case 4: 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); sprintf(num, "%d", cheat);
Item->item.pszText = num; Item->item.pszText = num;
} }

View File

@ -731,6 +731,11 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
case IDYES: case IDYES:
extern void DisableAllCheats(); extern void DisableAllCheats();
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
}
} }
} }