1. Limit text input for Edit watch dialog and ram search.

2. As bbbradsmith in Pull Request #62 mentioned, SetWindowLong is replaced by SetWindowLongPtr for 64 bit compatible, I partially changed those written by myself.
This commit is contained in:
owomomo 2019-06-27 00:53:52 +08:00
parent fb0f6ee35f
commit 7dde5467fd
10 changed files with 553 additions and 450 deletions

View File

@ -343,16 +343,16 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SendDlgItemMessage(hwndDlg, IDC_CHEAT_GAME_GENIE_TEXT, EM_SETLIMITTEXT, 8, 0);
// limit their characters
DefaultEditCtrlProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_ADDR), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_ADDR), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_VAL), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_COM), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_KNOWN), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_NE_BY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_GT_BY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_LT_BY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_TEXT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_CHEAT_GAME_GENIE_TEXT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_ADDR), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_ADDR), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_VAL), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_COM), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_KNOWN), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_NE_BY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_GT_BY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_LT_BY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_TEXT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHEAT_GAME_GENIE_TEXT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
// Create popup to "Auto load / save with game", since it has 3 states and the text need some explanation
SetCheatToolTip(hwndDlg, IDC_CHEAT_AUTOLOADSAVE);
@ -1109,10 +1109,10 @@ BOOL CALLBACK GGConvCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
SendDlgItemMessage(hwndDlg, IDC_GAME_GENIE_VAL, WM_SETFONT, (WPARAM)hNewFont, FALSE);
// limit their characters
DefaultEditCtrlProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_GAME_GENIE_CODE), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_GAME_GENIE_ADDR), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_GAME_GENIE_COMP), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_GAME_GENIE_VAL), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_GAME_GENIE_CODE), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_GAME_GENIE_ADDR), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_GAME_GENIE_COMP), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_GAME_GENIE_VAL), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
}
break;
case WM_CLOSE:

View File

@ -279,8 +279,8 @@ BOOL CALLBACK AddbpCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
SendDlgItemMessage(hwndDlg, IDC_ADDBP_ADDR_START, EM_SETLIMITTEXT, 4, 0);
SendDlgItemMessage(hwndDlg, IDC_ADDBP_ADDR_END, EM_SETLIMITTEXT, 4, 0);
DefaultEditCtrlProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_ADDBP_ADDR_START), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_ADDBP_ADDR_END), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_ADDBP_ADDR_START), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_ADDBP_ADDR_END), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
if (WP_edit >= 0)
{
@ -1825,12 +1825,12 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_SPR,EM_SETLIMITTEXT,2,0);
// limit input
DefaultEditCtrlProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_PCSEEK), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_PC), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_A), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_X), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_Y), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_DEBUGGER_BOOKMARK), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_PCSEEK), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_PC), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_A), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_X), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DEBUGGER_VAL_Y), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DEBUGGER_BOOKMARK), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
//I'm lazy, disable the controls which I can't mess with right now
SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_PPU,EM_SETREADONLY,TRUE,0);

View File

@ -296,17 +296,17 @@ HWND InitHeaderEditDialog(HWND hwnd, iNES_HEADER* header)
// Change the default wndproc of these control to limit their text
// PRG ROM
DefaultEditCtrlProc = (WNDPROC)SetWindowLong(GetDlgItem(GetDlgItem(hwnd, IDC_PRGROM_COMBO), IDC_PRGROM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(GetDlgItem(hwnd, IDC_PRGROM_COMBO), IDC_PRGROM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
// PRG RAM
SetWindowLong(GetDlgItem(GetDlgItem(hwnd, IDC_PRGRAM_COMBO), IDC_PRGRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(GetDlgItem(hwnd, IDC_PRGRAM_COMBO), IDC_PRGRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
// PRG NVRAM
SetWindowLong(GetDlgItem(GetDlgItem(hwnd, IDC_PRGNVRAM_COMBO), IDC_PRGNVRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(GetDlgItem(hwnd, IDC_PRGNVRAM_COMBO), IDC_PRGNVRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
// CHR ROM
SetWindowLong(GetDlgItem(GetDlgItem(hwnd, IDC_CHRROM_COMBO), IDC_CHRROM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(GetDlgItem(hwnd, IDC_CHRROM_COMBO), IDC_CHRROM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
// CHR RAM
SetWindowLong(GetDlgItem(GetDlgItem(hwnd, IDC_CHRRAM_COMBO), IDC_CHRRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(GetDlgItem(hwnd, IDC_CHRRAM_COMBO), IDC_CHRRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
// CHR NVRAM
SetWindowLong(GetDlgItem(GetDlgItem(hwnd, IDC_CHRNVRAM_COMBO), IDC_CHRNVRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(GetDlgItem(hwnd, IDC_CHRNVRAM_COMBO), IDC_CHRNVRAM_EDIT), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
ToggleINES20(hwnd, IsDlgButtonChecked(hwnd, IDC_RADIO_VERSION_INES20) == BST_CHECKED);

View File

@ -795,7 +795,7 @@ static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
// experimental: limit the text length and input to hex values
SendDlgItemMessage(hwndDlg, MW_ADDR[i], EM_SETLIMITTEXT, 4, 0);
DefaultEditCtrlProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, MW_ADDR[i]), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, MW_ADDR[i]), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
}
//Populate Formula pulldown menus

View File

@ -641,6 +641,18 @@ unsigned int HardwareAddressToItemIndex(HWAddressType hardwareAddress)
: functionName<char, type>(p0, p1, p2, p3)) \
: functionName<char, type>(p0, p1, p2, p3))
#define CONV_VAL_TO_STR(sizeTypeID, type, val, buf) (sprintf(buf, type == 's' ? "%d" : type == 'u' ? "%u" : type == 'd' ? "%08X" : type == 'w' ? "%04X" : "%02X", sizeTypeID == 'd' ? (type == 's' ? (long)(val & 0xFFFFFFFF) : (unsigned long)(val & 0xFFFFFFFF)) : sizeTypeID == 'w' ? (type == 's' ? (short)(val & 0xFFFF) : (unsigned short)(val & 0xFFFF)) : (type == 's' ? (char)(val & 0xFF) : (unsigned char)(val & 0xFF))), buf)
#define ConvEditTextNum(hDlg, id, sizeTypeID, type) \
{ \
BOOL success = FALSE; \
int val = ReadControlInt(id, type == 'h', success); \
if (success) \
{ \
char num[11]; \
SetDlgItemText(hDlg, id, CONV_VAL_TO_STR(sizeTypeID, type, val, num)); \
} else SetDlgItemText(hDlg, id, ""); \
}
// basic comparison functions:
template <typename T> inline bool LessCmp (T x, T y, T i) { return x < y; }
template <typename T> inline bool MoreCmp (T x, T y, T i) { return x > y; }
@ -1401,7 +1413,8 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
static int watchIndex=0;
switch(uMsg)
{
case WM_INITDIALOG: {
case WM_INITDIALOG:
{
RamSearchHWnd = hDlg;
CalcSubWindowPos(hDlg, NULL);
@ -1435,6 +1448,7 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true);
break;
}
switch (rs_c)
{
case 'r':
@ -1453,6 +1467,7 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true);
break;
}
switch (rs_t)
{
case 's':
@ -1465,6 +1480,7 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0);
break;
}
switch (rs_type_size)
{
case 'b':
@ -1517,8 +1533,16 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
ListView_SetCallbackMask(GetDlgItem(hDlg,IDC_RAMLIST), LVIS_FOCUSED|LVIS_SELECTED);
SendDlgItemMessage(hDlg, IDC_EDIT_COMPAREADDRESS, EM_SETLIMITTEXT, 4, 0);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDIT_MODBY), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDIT_COMPAREVALUE), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDIT_COMPAREADDRESS), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
return true;
} break;
}
break;
case WM_NOTIFY:
{
LPNMHDR lP = (LPNMHDR) lParam;
@ -1561,28 +1585,12 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
case 1:
{
int i = CALL_WITH_T_SIZE_TYPES_1(GetCurValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum);
const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X"));
switch (rs_type_size)
{
case 'b':
default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break;
case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break;
case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break;
}
Item->item.pszText = num;
Item->item.pszText = CONV_VAL_TO_STR(rs_type_size, rs_t, i, num);
} return true;
case 2:
{
int i = CALL_WITH_T_SIZE_TYPES_1(GetPrevValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum);
const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X"));
switch (rs_type_size)
{
case 'b':
default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break;
case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break;
case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break;
}
Item->item.pszText = num;
Item->item.pszText = CONV_VAL_TO_STR(rs_type_size, rs_t, i, num);
} return true;
case 3:
{
@ -1646,415 +1654,451 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
// return 0;
//}
}
break;
}
break;
case WM_COMMAND:
{
int rv = false;
switch(LOWORD(wParam))
switch (HIWORD(wParam))
{
case IDC_SIGNED:
rs_t='s';
signal_new_size();
{rv = true; break;}
case IDC_UNSIGNED:
rs_t='u';
signal_new_size();
{rv = true; break;}
case IDC_HEX:
rs_t='h';
signal_new_size();
{rv = true; break;}
case IDC_1_BYTE:
rs_type_size = 'b';
signal_new_size();
{rv = true; break;}
case IDC_2_BYTES:
rs_type_size = 'w';
signal_new_size();
{rv = true; break;}
case IDC_4_BYTES:
rs_type_size = 'd';
signal_new_size();
{rv = true; break;}
case IDC_MISALIGN:
noMisalign = !noMisalign;
//CompactAddrs();
signal_new_size();
{rv = true; break;}
// case IDC_ENDIAN:
//// littleEndian = !littleEndian;
//// signal_new_size();
// {rv = true; break;}
case IDC_LESSTHAN:
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
rs_o = '<';
{rv = true; break;}
case IDC_MORETHAN:
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
rs_o = '>';
{rv = true; break;}
case IDC_NOMORETHAN:
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
rs_o = 'l';
{rv = true; break;}
case IDC_NOLESSTHAN:
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
rs_o = 'm';
{rv = true; break;}
case IDC_EQUALTO:
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
rs_o = '=';
{rv = true; break;}
case IDC_DIFFERENTFROM:
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
rs_o = '!';
{rv = true; break;}
case IDC_DIFFERENTBY:
case BN_CLICKED:
{
rs_o = 'd';
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),true);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false);
if(!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_DIFFBY);
} {rv = true; break;}
case IDC_MODULO:
{
rs_o = '%';
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true);
if(!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_MODBY);
} {rv = true; break;}
case IDC_PREVIOUSVALUE:
rs_c='r';
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false);
{rv = true; break;}
case IDC_SPECIFICVALUE:
{
rs_c = 's';
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),true);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false);
if(!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_COMPAREVALUE);
{rv = true; break;}
}
case IDC_SPECIFICADDRESS:
{
rs_c = 'a';
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),true);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false);
if(!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_COMPAREADDRESS);
} {rv = true; break;}
case IDC_NUMBEROFCHANGES:
{
rs_c = 'n';
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false);
EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false);
if(!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_COMPARECHANGES);
} {rv = true; break;}
case IDC_C_ADDCHEAT:
{
HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
while (watchItemIndex >= 0)
int rv = true;
bool needRefresh = true;
switch (LOWORD(wParam))
{
unsigned long address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
unsigned long curvalue = CALL_WITH_T_SIZE_TYPES_1(GetCurValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex);
int sizeType = -1;
if(rs_type_size == 'b')
sizeType = 0;
else if(rs_type_size == 'w')
sizeType = 1;
else if(rs_type_size == 'd')
sizeType = 2;
int numberType = -1;
if(rs_t == 's')
numberType = 0;
else if(rs_t == 'u')
numberType = 1;
else if(rs_t == 'h')
numberType = 2;
// Don't open cheat dialog
switch (sizeType) {
case 0:
FCEUI_AddCheat("",address,curvalue, -1, 1);
break;
case 1:
FCEUI_AddCheat("",address,curvalue & 0xFF, -1, 1);
FCEUI_AddCheat("",address + 1,(curvalue & 0xFF00) / 0x100, -1, 1);
break;
case 2:
FCEUI_AddCheat("",address,curvalue & 0xFF,-1,1);
FCEUI_AddCheat("",address + 1,(curvalue & 0xFF00) / 0x100, -1, 1);
FCEUI_AddCheat("",address + 2,(curvalue & 0xFF0000) / 0x10000, -1, 1);
FCEUI_AddCheat("",address + 3,(curvalue & 0xFF000000) / 0x1000000, -1, 1);
break;
}
UpdateCheatsAdded();
UpdateCheatRelatedWindow();
watchItemIndex = ListView_GetNextItem(ramListControl, watchItemIndex, LVNI_SELECTED);
}
} {rv = true; break;}
case IDC_C_SEARCHROM:
ShowROM = SendDlgItemMessage(hDlg, IDC_C_SEARCHROM, BM_GETCHECK, 0, 0) != 0;
case IDC_C_RESET:
{
RamSearchSaveUndoStateIfNotTooBig(RamSearchHWnd);
int prevNumItems = last_rs_possible;
soft_reset_address_info();
if(prevNumItems == last_rs_possible)
SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo
ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all
//ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount);
ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0);
RefreshRamListSelectedCountControlStatus(hDlg);
Update_RAM_Search();
{rv = true; break;}
}
case IDC_C_RESET_CHANGES:
memset(s_numChanges, 0, (sizeof(*s_numChanges)*(MAX_RAM_SIZE)));
ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1);
Update_RAM_Search();
//SetRamSearchUndoType(hDlg, 0);
{rv = true; break;}
case IDC_C_UNDO:
if(s_undoType>0)
{
// Clear_Sound_Buffer();
EnterCriticalSection(&s_activeMemoryRegionsCS);
if(s_activeMemoryRegions.size() < tooManyRegionsForUndo)
case IDC_SIGNED:
{
MemoryList tempMemoryList = s_activeMemoryRegions;
s_activeMemoryRegions = s_activeMemoryRegionsBackup;
s_activeMemoryRegionsBackup = tempMemoryList;
LeaveCriticalSection(&s_activeMemoryRegionsCS);
SetRamSearchUndoType(hDlg, 3 - s_undoType);
rs_t = 's';
signal_new_size();
ConvEditTextNum(hDlg, IDC_EDIT_COMPAREVALUE, rs_type_size, rs_t);
ConvEditTextNum(hDlg, IDC_EDIT_DIFFBY, rs_type_size, rs_t);
ConvEditTextNum(hDlg, IDC_EDIT_MODBY, rs_type_size, rs_t);
}
else
break;
case IDC_UNSIGNED:
{
s_activeMemoryRegions = s_activeMemoryRegionsBackup;
LeaveCriticalSection(&s_activeMemoryRegionsCS);
SetRamSearchUndoType(hDlg, -1);
rs_t = 'u';
signal_new_size();
ConvEditTextNum(hDlg, IDC_EDIT_COMPAREVALUE, rs_type_size, rs_t);
ConvEditTextNum(hDlg, IDC_EDIT_DIFFBY, rs_type_size, rs_t);
ConvEditTextNum(hDlg, IDC_EDIT_MODBY, rs_type_size, rs_t);
}
CompactAddrs();
ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all
ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0);
RefreshRamListSelectedCountControlStatus(hDlg);
}
{rv = true; break;}
case IDC_C_AUTOSEARCH:
AutoSearch = SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_GETCHECK, 0, 0) != 0;
AutoSearchAutoRetry = false;
if (!AutoSearch) {rv = true; break;}
case IDC_C_SEARCH:
{
// Clear_Sound_Buffer();
if(!rs_val_valid && !(rs_val_valid = Set_RS_Val()))
goto invalid_field;
if(ResultCount)
{
RamSearchSaveUndoStateIfNotTooBig(hDlg);
prune(rs_c,rs_o,rs_t=='s',rs_val,rs_param);
RefreshRamListSelectedCountControlStatus(hDlg);
}
if(!ResultCount)
{
MessageBox(RamSearchHWnd,"Resetting search.","Out of results.",MB_OK|MB_ICONINFORMATION);
soft_reset_address_info();
}
{rv = true; break;}
invalid_field:
MessageBox(RamSearchHWnd,"Invalid or out-of-bound entered value.","Error",MB_OK|MB_ICONSTOP);
if(AutoSearch) // stop autosearch if it just started
{
SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0);
SendMessage(hDlg, WM_COMMAND, IDC_C_AUTOSEARCH, 0);
}
{rv = true; break;}
}
case IDC_C_HEXEDITOR:
{
HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
int selCount = ListView_GetSelectedCount(ramListControl);
int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
if (watchItemIndex >= 0)
{
unsigned int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size, rs_t=='s', noMisalign, watchItemIndex);
ChangeMemViewFocus(0, addr, -1);
}
break;
}
case IDC_C_WATCH:
{
HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
int selCount = SendMessage(ramListControl, LVM_GETSELECTEDCOUNT, 0, 0);
if (selCount > 0)
{
AddressWatcher tempWatch;
tempWatch.Size = rs_type_size;
tempWatch.Type = rs_t;
tempWatch.WrongEndian = 0; //Replace when I get little endian working
tempWatch.comment = NULL;
bool inserted = false;
AddressWatcher* watches = (AddressWatcher*)malloc(selCount * sizeof(AddressWatcher));
int i = 0;
int watchItemIndex = -1;
while ((watchItemIndex = SendMessage(ramListControl, LVM_GETNEXTITEM, watchItemIndex, LVNI_SELECTED)) >= 0)
break;
case IDC_HEX:
{
tempWatch.Address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size, rs_t == 's', noMisalign, watchItemIndex);
watches[i] = tempWatch;
++i;
rs_t = 'h';
signal_new_size();
ConvEditTextNum(hDlg, IDC_EDIT_COMPAREVALUE, rs_type_size, rs_t);
ConvEditTextNum(hDlg, IDC_EDIT_DIFFBY, rs_type_size, rs_t);
ConvEditTextNum(hDlg, IDC_EDIT_MODBY, rs_type_size, rs_t);
}
// bring up the ram watch window if it's not already showing so the user knows where the watch went
if ((selCount == 1 ?
InsertWatch(watches[0], hDlg) : InsertWatches(watches, hDlg, selCount))
&& !RamWatchHWnd)
SendMessage(hWnd, WM_COMMAND, ID_RAM_WATCH, 0);
SetForegroundWindow(RamSearchHWnd);
free(watches);
}
{rv = true; break;}
}
// eliminate all selected items
case IDC_C_ELIMINATE:
{
RamSearchSaveUndoStateIfNotTooBig(hDlg);
HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST);
int size = (rs_type_size=='b' || !noMisalign) ? 1 : 2;
int selCount = ListView_GetSelectedCount(ramListControl);
int watchIndex = -1;
// time-saving trick #1:
// condense the selected items into an array of address ranges
std::vector<AddrRange> selHardwareAddrs;
for(int i = 0, j = 1024; i < selCount; ++i, --j)
{
watchIndex = ListView_GetNextItem(ramListControl, watchIndex, LVNI_SELECTED);
int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchIndex);
if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End())
selHardwareAddrs.back().size += size;
else
selHardwareAddrs.push_back(AddrRange(addr,size));
if(!j) UpdateRamSearchProgressBar(i * 50 / selCount), j = 1024;
}
// now deactivate the ranges
// time-saving trick #2:
// take advantage of the fact that the listbox items must be in the same order as the regions
MemoryList::iterator iter = s_activeMemoryRegions.begin();
int numHardwareAddrRanges = selHardwareAddrs.size();
for(int i = 0, j = 16; i < numHardwareAddrRanges; ++i, --j)
{
int addr = selHardwareAddrs[i].addr;
int size = selHardwareAddrs[i].size;
bool affected = false;
while(iter != s_activeMemoryRegions.end())
break;
case IDC_1_BYTE:
{
MemoryRegion& region = *iter;
int affNow = DeactivateRegion(region, iter, addr, size);
if(affNow)
affected = true;
else if(affected)
needRefresh = false;
rs_type_size = 'b';
signal_new_size();
BOOL success = FALSE;
int val = ReadControlInt(IDC_EDIT_COMPAREVALUE, false, success);
if (success)
{
char num[11];
SetDlgItemText(hDlg, IDC_EDIT_COMPAREVALUE, CONV_VAL_TO_STR(rs_type_size, rs_t, val, num));
}
}
break;
case IDC_2_BYTES:
needRefresh = false;
rs_type_size = 'w';
signal_new_size();
break;
case IDC_4_BYTES:
needRefresh = false;
rs_type_size = 'd';
signal_new_size();
break;
case IDC_MISALIGN:
needRefresh = false;
noMisalign = !noMisalign;
//CompactAddrs();
signal_new_size();
break;
// case IDC_ENDIAN:
// littleEndian = !littleEndian;
// signal_new_size();
// break;
case IDC_LESSTHAN:
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), false);
rs_o = '<';
break;
case IDC_MORETHAN:
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), false);
rs_o = '>';
break;
case IDC_NOMORETHAN:
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), false);
rs_o = 'l';
break;
case IDC_NOLESSTHAN:
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), false);
rs_o = 'm';
break;
case IDC_EQUALTO:
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), false);
rs_o = '=';
break;
case IDC_DIFFERENTFROM:
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), false);
rs_o = '!';
break;
case IDC_DIFFERENTBY:
{
rs_o = 'd';
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), true);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), false);
if (!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_DIFFBY);
break;
}
case IDC_MODULO:
{
rs_o = '%';
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_DIFFBY), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MODBY), true);
if (!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_MODBY);
break;
}
case IDC_PREVIOUSVALUE:
rs_c = 'r';
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREVALUE), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREADDRESS), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPARECHANGES), false);
break;
case IDC_SPECIFICVALUE:
{
rs_c = 's';
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREVALUE), true);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREADDRESS), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPARECHANGES), false);
if (!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_COMPAREVALUE);
break;
}
case IDC_SPECIFICADDRESS:
{
rs_c = 'a';
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREADDRESS), true);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREVALUE), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPARECHANGES), false);
if (!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_COMPAREADDRESS);
break;
}
case IDC_NUMBEROFCHANGES:
{
rs_c = 'n';
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPARECHANGES), true);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREVALUE), false);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_COMPAREADDRESS), false);
if (!SelectingByKeyboard())
SelectEditControl(IDC_EDIT_COMPARECHANGES);
break;
}
case IDC_C_ADDCHEAT:
{
needRefresh = false;
HWND ramListControl = GetDlgItem(hDlg, IDC_RAMLIST);
int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
while (watchItemIndex >= 0)
{
unsigned long address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size, rs_t == 's', noMisalign, watchItemIndex);
unsigned long curvalue = CALL_WITH_T_SIZE_TYPES_1(GetCurValueFromItemIndex, rs_type_size, rs_t == 's', noMisalign, watchItemIndex);
int sizeType = -1;
if (rs_type_size == 'b')
sizeType = 0;
else if (rs_type_size == 'w')
sizeType = 1;
else if (rs_type_size == 'd')
sizeType = 2;
int numberType = -1;
if (rs_t == 's')
numberType = 0;
else if (rs_t == 'u')
numberType = 1;
else if (rs_t == 'h')
numberType = 2;
// Don't open cheat dialog
switch (sizeType) {
case 0:
FCEUI_AddCheat("", address, curvalue, -1, 1);
break;
case 1:
FCEUI_AddCheat("", address, curvalue & 0xFF, -1, 1);
FCEUI_AddCheat("", address + 1, (curvalue & 0xFF00) / 0x100, -1, 1);
break;
case 2:
FCEUI_AddCheat("", address, curvalue & 0xFF, -1, 1);
FCEUI_AddCheat("", address + 1, (curvalue & 0xFF00) / 0x100, -1, 1);
FCEUI_AddCheat("", address + 2, (curvalue & 0xFF0000) / 0x10000, -1, 1);
FCEUI_AddCheat("", address + 3, (curvalue & 0xFF000000) / 0x1000000, -1, 1);
break;
}
UpdateCheatsAdded();
UpdateCheatRelatedWindow();
watchItemIndex = ListView_GetNextItem(ramListControl, watchItemIndex, LVNI_SELECTED);
}
break;
}
case IDC_C_SEARCHROM:
ShowROM = SendDlgItemMessage(hDlg, IDC_C_SEARCHROM, BM_GETCHECK, 0, 0) != 0;
case IDC_C_RESET:
{
needRefresh = false;
RamSearchSaveUndoStateIfNotTooBig(RamSearchHWnd);
int prevNumItems = last_rs_possible;
soft_reset_address_info();
if (prevNumItems == last_rs_possible)
SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo
ListView_SetItemState(GetDlgItem(hDlg, IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all
//ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount);
ListView_SetSelectionMark(GetDlgItem(hDlg, IDC_RAMLIST), 0);
RefreshRamListSelectedCountControlStatus(hDlg);
Update_RAM_Search();
break;
}
case IDC_C_RESET_CHANGES:
needRefresh = false;
memset(s_numChanges, 0, (sizeof(*s_numChanges)*(MAX_RAM_SIZE)));
ListView_Update(GetDlgItem(hDlg, IDC_RAMLIST), -1);
Update_RAM_Search();
//SetRamSearchUndoType(hDlg, 0);
break;
case IDC_C_UNDO:
needRefresh = false;
if (s_undoType > 0)
{
// Clear_Sound_Buffer();
EnterCriticalSection(&s_activeMemoryRegionsCS);
if (s_activeMemoryRegions.size() < tooManyRegionsForUndo)
{
MemoryList tempMemoryList = s_activeMemoryRegions;
s_activeMemoryRegions = s_activeMemoryRegionsBackup;
s_activeMemoryRegionsBackup = tempMemoryList;
LeaveCriticalSection(&s_activeMemoryRegionsCS);
SetRamSearchUndoType(hDlg, 3 - s_undoType);
}
else
{
s_activeMemoryRegions = s_activeMemoryRegionsBackup;
LeaveCriticalSection(&s_activeMemoryRegionsCS);
SetRamSearchUndoType(hDlg, -1);
}
CompactAddrs();
ListView_SetItemState(GetDlgItem(hDlg, IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all
ListView_SetSelectionMark(GetDlgItem(hDlg, IDC_RAMLIST), 0);
RefreshRamListSelectedCountControlStatus(hDlg);
}
break;
case IDC_C_AUTOSEARCH:
needRefresh = false;
AutoSearch = SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_GETCHECK, 0, 0) != 0;
AutoSearchAutoRetry = false;
if (!AutoSearch)
break;
if(affNow != 2)
++iter;
else
rv = false;
case IDC_C_SEARCH:
{
needRefresh = false;
// Clear_Sound_Buffer();
if (!rs_val_valid && !(rs_val_valid = Set_RS_Val()))
{
MessageBox(RamSearchHWnd, "Invalid or out-of-bound entered value.", "Error", MB_OK | MB_ICONSTOP);
if (AutoSearch) // stop autosearch if it just started
{
SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0);
SendMessage(hDlg, WM_COMMAND, IDC_C_AUTOSEARCH, 0);
}
}
else {
if (ResultCount)
{
RamSearchSaveUndoStateIfNotTooBig(hDlg);
prune(rs_c, rs_o, rs_t == 's', rs_val, rs_param);
RefreshRamListSelectedCountControlStatus(hDlg);
}
if (!ResultCount)
{
MessageBox(RamSearchHWnd, "Resetting search.", "Out of results.", MB_OK | MB_ICONINFORMATION);
soft_reset_address_info();
}
}
break;
}
case IDC_C_HEXEDITOR:
{
needRefresh = false;
HWND ramListControl = GetDlgItem(hDlg, IDC_RAMLIST);
int selCount = ListView_GetSelectedCount(ramListControl);
int watchItemIndex = ListView_GetNextItem(ramListControl, -1, LVNI_SELECTED);
if (watchItemIndex >= 0)
{
unsigned int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size, rs_t == 's', noMisalign, watchItemIndex);
ChangeMemViewFocus(0, addr, -1);
}
rv = false;
break;
}
case IDC_C_WATCH:
{
needRefresh = false;
HWND ramListControl = GetDlgItem(hDlg, IDC_RAMLIST);
int selCount = SendMessage(ramListControl, LVM_GETSELECTEDCOUNT, 0, 0);
if (selCount > 0)
{
AddressWatcher tempWatch;
tempWatch.Size = rs_type_size;
tempWatch.Type = rs_t;
tempWatch.WrongEndian = 0; //Replace when I get little endian working
tempWatch.comment = NULL;
bool inserted = false;
AddressWatcher* watches = (AddressWatcher*)malloc(selCount * sizeof(AddressWatcher));
int i = 0;
int watchItemIndex = -1;
while ((watchItemIndex = SendMessage(ramListControl, LVM_GETNEXTITEM, watchItemIndex, LVNI_SELECTED)) >= 0)
{
tempWatch.Address = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size, rs_t == 's', noMisalign, watchItemIndex);
watches[i] = tempWatch;
++i;
}
// bring up the ram watch window if it's not already showing so the user knows where the watch went
if ((selCount == 1 ?
InsertWatch(watches[0], hDlg) : InsertWatches(watches, hDlg, selCount))
&& !RamWatchHWnd)
SendMessage(hWnd, WM_COMMAND, ID_RAM_WATCH, 0);
SetForegroundWindow(RamSearchHWnd);
free(watches);
}
break;
}
if(!j) UpdateRamSearchProgressBar(50 + (i * 50 / selCount)), j = 16;
// eliminate all selected items
case IDC_C_ELIMINATE:
{
needRefresh = false;
RamSearchSaveUndoStateIfNotTooBig(hDlg);
HWND ramListControl = GetDlgItem(hDlg, IDC_RAMLIST);
int size = (rs_type_size == 'b' || !noMisalign) ? 1 : 2;
int selCount = ListView_GetSelectedCount(ramListControl);
int watchIndex = -1;
// time-saving trick #1:
// condense the selected items into an array of address ranges
std::vector<AddrRange> selHardwareAddrs;
for (int i = 0, j = 1024; i < selCount; ++i, --j)
{
watchIndex = ListView_GetNextItem(ramListControl, watchIndex, LVNI_SELECTED);
int addr = CALL_WITH_T_SIZE_TYPES_1(GetHardwareAddressFromItemIndex, rs_type_size, rs_t == 's', noMisalign, watchIndex);
if (!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End())
selHardwareAddrs.back().size += size;
else
selHardwareAddrs.push_back(AddrRange(addr, size));
if (!j) UpdateRamSearchProgressBar(i * 50 / selCount), j = 1024;
}
// now deactivate the ranges
// time-saving trick #2:
// take advantage of the fact that the listbox items must be in the same order as the regions
MemoryList::iterator iter = s_activeMemoryRegions.begin();
int numHardwareAddrRanges = selHardwareAddrs.size();
for (int i = 0, j = 16; i < numHardwareAddrRanges; ++i, --j)
{
int addr = selHardwareAddrs[i].addr;
int size = selHardwareAddrs[i].size;
bool affected = false;
while (iter != s_activeMemoryRegions.end())
{
MemoryRegion& region = *iter;
int affNow = DeactivateRegion(region, iter, addr, size);
if (affNow)
affected = true;
else if (affected)
break;
if (affNow != 2)
++iter;
}
if (!j) UpdateRamSearchProgressBar(50 + (i * 50 / selCount)), j = 16;
}
UpdateRamSearchTitleBar();
// careful -- if the above two time-saving tricks aren't working,
// the runtime can absolutely explode (seconds -> hours) when there are lots of regions
ListView_SetItemState(ramListControl, -1, 0, LVIS_SELECTED); // deselect all
signal_new_size();
break;
}
default:
rv = false;
needRefresh = false;
break;
}
UpdateRamSearchTitleBar();
// careful -- if the above two time-saving tricks aren't working,
// the runtime can absolutely explode (seconds -> hours) when there are lots of regions
ListView_SetItemState(ramListControl, -1, 0, LVIS_SELECTED); // deselect all
signal_new_size();
{rv = true; break;}
}
}
// check refresh for comparison preview color update
// also, update rs_val if needed
bool needRefresh = false;
switch(LOWORD(wParam))
{
case IDC_LESSTHAN:
case IDC_MORETHAN:
case IDC_NOMORETHAN:
case IDC_NOLESSTHAN:
case IDC_EQUALTO:
case IDC_DIFFERENTFROM:
case IDC_DIFFERENTBY:
case IDC_MODULO:
case IDC_PREVIOUSVALUE:
case IDC_SPECIFICVALUE:
case IDC_SPECIFICADDRESS:
case IDC_NUMBEROFCHANGES:
case IDC_SIGNED:
case IDC_UNSIGNED:
case IDC_HEX:
rs_val_valid = Set_RS_Val();
needRefresh = true;
break;
case IDC_EDIT_COMPAREVALUE:
case IDC_EDIT_COMPAREADDRESS:
case IDC_EDIT_COMPARECHANGES:
case IDC_EDIT_DIFFBY:
case IDC_EDIT_MODBY:
if(HIWORD(wParam) == EN_CHANGE)
if (needRefresh)
{
rs_val_valid = Set_RS_Val();
needRefresh = true;
ListView_Update(GetDlgItem(hDlg, IDC_RAMLIST), -1);
}
break;
return rv;
}
case EN_CHANGE:
{
switch (LOWORD(wParam))
{
case IDC_EDIT_COMPAREVALUE:
case IDC_EDIT_COMPAREADDRESS:
case IDC_EDIT_COMPARECHANGES:
case IDC_EDIT_DIFFBY:
case IDC_EDIT_MODBY:
rs_val_valid = Set_RS_Val();
ListView_Update(GetDlgItem(hDlg, IDC_RAMLIST), -1);
}
}
}
if(needRefresh)
ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1);
return rv;
} break;
}
break;
case WM_CLOSE:
DestroyWindow(hDlg);
break;
@ -2067,6 +2111,7 @@ invalid_field:
return false;
}
void UpdateRamSearchTitleBar(int percent)
{
#define HEADER_STR " RAM Search - "

View File

@ -854,6 +854,11 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
EnableWindow(GetDlgItem(hDlg, IDC_4_BYTES), FALSE);
SetFocus(GetDlgItem(hDlg, IDC_PROMPT_EDIT));
}
else {
SetFocus(GetDlgItem(hDlg, IDC_EDIT_COMPAREADDRESS));
SendDlgItemMessage(hDlg, IDC_EDIT_COMPAREADDRESS, EM_SETLIMITTEXT, 4, 0);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDIT_COMPAREADDRESS), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
}
}
return true;

View File

@ -12,7 +12,7 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English(United States) resources
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
@ -2165,7 +2165,7 @@ BEGIN
CONTROL "Number of Changes:",IDC_NUMBEROFCHANGES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,212,76,10
EDITTEXT IDC_EDIT_COMPAREVALUE,203,187,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
EDITTEXT IDC_EDIT_COMPAREADDRESS,203,199,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
EDITTEXT IDC_EDIT_COMPARECHANGES,203,211,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
EDITTEXT IDC_EDIT_COMPARECHANGES,203,211,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
GROUPBOX "Data Type / Display",IDC_STATIC,196,228,75,45,0,WS_EX_TRANSPARENT
CONTROL "Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,200,238,67,9
CONTROL "Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,200,249,67,9
@ -2213,6 +2213,7 @@ BEGIN
CONTROL "&Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,18,47,67,9
CONTROL "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,57,67,9
CONTROL "&Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,67,67,9
CONTROL "&Binary",IDC_BINARY,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,77,67,9
GROUPBOX "Data Size",IDC_DATASIZE_GROUPBOX,94,37,73,52,0,WS_EX_TRANSPARENT
CONTROL "&1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,98,47,61,11
CONTROL "&2 bytes",IDC_2_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,57,61,11
@ -2743,6 +2744,11 @@ BEGIN
0
END
IDD_RAMSEARCH AFX_DIALOG_LAYOUT
BEGIN
0
END
/////////////////////////////////////////////////////////////////////////////
//

View File

@ -1288,10 +1288,10 @@ BOOL CALLBACK VideoConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
EnableWindow(GetDlgItem(hwndDlg, IDC_TVASPECT_Y), eoptions&EO_TVASPECT);
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_SLASHTEXT), eoptions&EO_TVASPECT);
DefaultEditCtrlProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_WINSIZE_MUL_X), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_WINSIZE_MUL_Y), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_TVASPECT_X), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLong(GetDlgItem(hwndDlg, IDC_TVASPECT_Y), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_WINSIZE_MUL_X), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_WINSIZE_MUL_Y), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TVASPECT_X), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TVASPECT_Y), GWL_WNDPROC, (LONG)FilterEditCtrlProc);
break;
}

View File

@ -3342,10 +3342,6 @@ bool inline (*GetIsLetterLegal(UINT id))(char letter)
// Debugger -> Add breakpoint
case IDC_ADDBP_ADDR_START: case IDC_ADDBP_ADDR_END:
// RAM Watch / RAM Search / Cheat -> Add watch
// TODO: Some other features
// case IDC_EDIT_COMPAREADDRESS:
// Address, Value, Compare, Known Value, Note equal, Greater than and Less than in Cheat
case IDC_CHEAT_ADDR: case IDC_CHEAT_VAL: case IDC_CHEAT_COM:
case IDC_CHEAT_VAL_KNOWN: case IDC_CHEAT_VAL_NE_BY:
@ -3361,6 +3357,10 @@ bool inline (*GetIsLetterLegal(UINT id))(char letter)
case MW_ADDR12: case MW_ADDR13: case MW_ADDR14: case MW_ADDR15:
case MW_ADDR16: case MW_ADDR17: case MW_ADDR18: case MW_ADDR19:
case MW_ADDR20: case MW_ADDR21: case MW_ADDR22: case MW_ADDR23:
// Specific Address in RAM Search
// RAM Watch / RAM Search / Cheat -> Add watch
case IDC_EDIT_COMPAREADDRESS:
return IsLetterLegalHex;
// Size multiplier and TV Aspect in Video Config
@ -3372,10 +3372,24 @@ bool inline (*GetIsLetterLegal(UINT id))(char letter)
case IDC_CHEAT_TEXT:
return IsLetterLegalCheat;
// PRG ROM, PRG RAM, PRG NVRAM, CHR ROM, CHR RAM, CHR NVRAM in iNES Header Editor
// PRG ROM, PRG RAM, PRG NVRAM, CHR ROM, CHR RAM and CHR NVRAM in iNES Header Editor
case IDC_PRGROM_EDIT: case IDC_PRGRAM_EDIT: case IDC_PRGNVRAM_EDIT:
case IDC_CHRROM_EDIT: case IDC_CHRRAM_EDIT: case IDC_CHRNVRAM_EDIT:
return IsLetterLegalSize;
// Specific value, Different by and Modulo in RAM search
case IDC_EDIT_COMPAREVALUE:
case IDC_EDIT_DIFFBY:
case IDC_EDIT_MODBY:
{
extern char rs_t;
switch (rs_t)
{
case 's': return IsLetterLegalDecHexMixed;
case 'u': return IsLetterLegalUnsignedDecHexMixed;
case 'h': return IsLetterLegalHex;
}
}
}
return NULL;
}
@ -3430,7 +3444,28 @@ inline char* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter))
if (IsLetterLegal == IsLetterLegalSize)
return "You can only type decimal number followed with B, KB or MB.";
if (IsLetterLegal == IsLetterLegalDec)
return "You can only type decimal number (minus is acceptable).";
return "You can only type decimal number (sign character is acceptable).";
if (IsLetterLegal == IsLetterLegalDecHexMixed)
return
"You can only type decimal or hexademical number\n"
"(sign character is acceptable).\n\n"
"When your number contains letter A-F,\n"
"it is regarded as hexademical number,\n"
"however, if you want to express a heademical number\n"
"but all the digits are in 0-9,\n"
"you must add a $ prefix to prevent ambiguous.\n"
"eg. 10 is a decimal number,\n"
"$10 means a hexademical number that is 16 in decimal.";
if (IsLetterLegal == IsLetterLegalUnsignedDecHexMixed)
return
"You can only type decimal or hexademical number.\n\n"
"When your number contains letter A-F,\n"
"it is regarded as hexademical number,\n"
"however, if you want to express a heademical number\n"
"but all the digits are in 0-9,\n"
"you must add a $ prefix to prevent ambiguous.\n"
"eg. 10 is a decimal number,\n"
"$10 means a hexademical number that is 16 in decimal.";
return "Your input contains invalid characters.";
}
@ -3466,10 +3501,20 @@ inline bool IsLetterLegalSize(char letter)
inline bool IsLetterLegalDec(char letter)
{
return letter >= '0' && letter <= '9' || letter == '-';
return letter >= '0' && letter <= '9' || letter == '-' || letter == '+';
}
inline bool IsLetterLegalFloat(char letter)
{
return letter >= '0' && letter <= '9' || letter == '.';
return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+';
}
inline bool IsLetterLegalDecHexMixed(char letter)
{
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+';
}
inline bool IsLetterLegalUnsignedDecHexMixed(char letter)
{
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$';
}

View File

@ -140,6 +140,8 @@ inline bool IsLetterLegalCheat(char letter);
inline bool IsLetterLegalDec(char letter);
inline bool IsLetterLegalSize(char letter);
inline bool IsLetterLegalFloat(char letter);
inline bool IsLetterLegalDecHexMixed(char letter);
inline bool IsLetterLegalUnsignedDecHexMixed(char letter);
extern WNDPROC DefaultEditCtrlProc;
extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT msg, WPARAM wP, LPARAM lP);