1. New cheat list box 0.0.0.4 Alpha, separated the normal cheat adding method and the cheat code/game genie method. While you're inputting the values, they are synced to the formatted string which is very convinience. In the past, the game genie was added from the name edit control, now the name is separated and the code can have a name even if it's a game genie.

2. Solved a problem of the add/editing watch dialog when pop up repeatedly from multiple places, because there are 3 places can pop up it now.
3. Fixed a bug when loading cheats from file crashes the emulator.
4. Detail.
This commit is contained in:
owomomo 2019-05-10 02:17:16 +08:00
parent 07f0c1af2c
commit 0713de844c
7 changed files with 274 additions and 195 deletions

View File

@ -189,8 +189,8 @@ void FCEU_LoadGameCheats(FILE *override, int override_existing)
unsigned int compare;
int x;
char linebuf[2048];
char namebuf[128];
char linebuf[2048] = { 0 };
char namebuf[128] = { 0 };
int tc = 0;
char *fn;

View File

@ -31,7 +31,7 @@
static HWND pwindow = 0; //Handle to Cheats dialog
HWND hCheat = 0; //mbg merge 7/19/06 had to add
static HMENU hCheatcontext; //Handle to cheat context menu
HMENU hCheatcontext = 0; //Handle to cheat context menu
bool pauseWhileActive = false; //For checkbox "Pause while active"
extern bool wasPausedByCheats;
@ -67,7 +67,7 @@ char GGcode[10];
int GGlist[GGLISTSIZE];
static int dontupdateGG; //this eliminates recursive crashing
bool dodecode;
// bool dodecode;
HWND hGGConv;
@ -106,15 +106,7 @@ char *U8ToStr(uint8 a)
int RedoCheatsCallB(char *name, uint32 a, uint8 v, int c, int s, int type, void* data)
{
char str[256] = { 0 };
if(a >= 0x8000)
EncodeGG(str, a, v, c);
else {
if(c == -1)
sprintf(str, "%04X:%02X", (int)a, (int)v);
else
sprintf(str, "%04X?%02X:%02X", (int)a, (int)c, (int)v);
}
GetCheatStr(str, a, v, c);
LVITEM lvi = { 0 };
lvi.mask = LVIF_TEXT;
@ -255,12 +247,20 @@ int ShowResults(HWND hwndDlg, bool supressUpdate = false)
void EnableCheatButtons(HWND hwndDlg, int enable)
{
EnableWindow(GetDlgItem(hwndDlg,IDC_CHEAT_VAL_KNOWN),enable);
EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_KNOWN),enable);
EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_EQ),enable);
EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_NE),enable);
EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_GT),enable);
EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_LT),enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CHEAT_KNOWN), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_KNOWN), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_LABEL_KNOWN), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CHEAT_EQ), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CHEAT_NE), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_CHECK_NE_BY), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_NE_BY), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CHEAT_GT), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_CHECK_GT_BY), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_GT_BY), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CHEAT_LT), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_CHECK_LT_BY), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_LT_BY), enable);
}
HWND InitializeCheatList(HWND hwnd)
@ -313,6 +313,7 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SendDlgItemMessage(hwndDlg, IDC_CHEAT_VAL_NE_BY, WM_SETFONT, (WPARAM)hNewFont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_CHEAT_VAL_GT_BY, WM_SETFONT, (WPARAM)hNewFont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_CHEAT_VAL_LT_BY, WM_SETFONT, (WPARAM)hNewFont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_CHEAT_TEXT, WM_SETFONT, (WPARAM)hNewFont, FALSE);
//text limits
SendDlgItemMessage(hwndDlg, IDC_CHEAT_ADDR, EM_SETLIMITTEXT, 4, 0);
@ -323,15 +324,16 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SendDlgItemMessage(hwndDlg, IDC_CHEAT_VAL_NE_BY, EM_SETLIMITTEXT, 2, 0);
SendDlgItemMessage(hwndDlg, IDC_CHEAT_VAL_GT_BY, EM_SETLIMITTEXT, 2, 0);
SendDlgItemMessage(hwndDlg, IDC_CHEAT_VAL_LT_BY, EM_SETLIMITTEXT, 2, 0);
SendDlgItemMessage(hwndDlg, IDC_CHEAT_TEXT, EM_SETLIMITTEXT, 10, 0);
//disable or enable buttons
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_KNOWN), FALSE);
CheckDlgButton(hwndDlg, IDC_RADIO_ADDRESS, MF_CHECKED);
possiTotalCount = 0;
possiItemCount = SendDlgItemMessage(hwndDlg, IDC_CHEAT_LIST_POSSIBILITIES, LVM_GETCOUNTPERPAGE, 0, 0);
EnableCheatButtons(hwndDlg, possiTotalCount != 0);
ShowResults(hwndDlg);
EnableCheatButtons(hwndDlg, possiTotalCount != 0);
//add header for cheat list and possibilities
InitializeCheatList(hwndDlg);
@ -427,13 +429,11 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
RECT wrect;
wrect.left = LVIR_BOUNDS;
SendMessage(itemHwnd, LVM_GETITEMRECT, sel, (LPARAM)&wrect);
POINT point;
point.x = wrect.left + (wrect.right - wrect.left) / 2;
point.y = wrect.top + (wrect.bottom - wrect.top) / 2;
ClientToScreen(itemHwnd, &point);
}
TrackPopupMenu(hCheatcontextsub, TPM_RIGHTBUTTON, point.x, point.y, 0, hwndDlg, 0); //Create menu
}
}
break;
@ -552,33 +552,11 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
break;
case IDC_BTN_CHEAT_ADD:
{
char str[256] = { 0 };
uint32 a = 0;
uint8 v = 0;
int c = 0;
dodecode = true;
char name[256] = { 0 }; uint32 a; uint8 v = 0; int c = 0;
GetUICheatInfo(hwndDlg, name, &a, &v, &c);
GetDlgItemText(hwndDlg, IDC_CHEAT_ADDR, str, 5);
if(str[0] != 0)
dodecode = false;
a = StrToU16(str);
GetDlgItemText(hwndDlg, IDC_CHEAT_VAL, str, 3);
if(str[0] != 0)
dodecode = false;
v = StrToU8(str);
GetDlgItemText(hwndDlg,IDC_CHEAT_COM, str, 3);
if(str[0] != 0)
dodecode = false;
c = (str[0] == 0) ? -1 : StrToU8(str);
GetDlgItemText(hwndDlg, IDC_CHEAT_NAME, str, 256);
if(dodecode && (strlen(str) == 6 || strlen(str) == 8))
if(FCEUI_DecodeGG(str, &GGaddr, &GGval, &GGcomp)) {
a = GGaddr;
v = GGval;
c = GGcomp;
}
if (FCEUI_AddCheat(str, a, v, c, 1)) {
RedoCheatsCallB(str, a, v, c, 1, 1, NULL);
if (FCEUI_AddCheat(name, a, v, c, 1)) {
RedoCheatsCallB(name, a, v, c, 1, 1, NULL);
int newselcheat = SendDlgItemMessage(hwndDlg, IDC_LIST_CHEATS, LVM_GETITEMCOUNT, 0, 0) - 1;
ListView_MoveSelectionMark(GetDlgItem(hwndDlg, IDC_LIST_CHEATS), selcheat, newselcheat);
@ -628,35 +606,14 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case IDC_BTN_CHEAT_UPD:
{
selcheat = SendDlgItemMessage(hwndDlg, IDC_LIST_CHEATS, LVM_GETSELECTIONMARK, 0, 0);
dodecode = true;
char str[256] = { 0 };
char* name = ""; uint32 a; uint8 v; int s; int c;
if (selcheat < 0)
break;
GetDlgItemText(hwndDlg, IDC_CHEAT_ADDR, str, 5);
if (str[0] != 0)
dodecode = false;
a = StrToU16(str);
GetDlgItemText(hwndDlg, IDC_CHEAT_VAL, str, 3);
if (str[0] != 0)
dodecode = false;
v = StrToU8(str);
GetDlgItemText(hwndDlg, IDC_CHEAT_COM, str, 3);
if (str[0] != 0)
dodecode = false;
c = (str[0] == 0) ? -1 : StrToU8(str);
GetDlgItemText(hwndDlg, IDC_CHEAT_NAME, str, 256);
if (dodecode && (strlen(str) == 6 || strlen(str) == 8)) {
if (FCEUI_DecodeGG(str, &GGaddr, &GGval, &GGcomp)) {
a = GGaddr;
v = GGval;
c = GGcomp;
}
}
FCEUI_SetCheat(selcheat, str, a, v, c, -1, 1);
FCEUI_GetCheat(selcheat, &name, &a, &v, &c, &s, NULL);
char name[256]; uint32 a; uint8 v; int s; int c;
GetUICheatInfo(hwndDlg, name, &a, &v, &c);
FCEUI_SetCheat(selcheat, name, a, v, c, -1, 1);
FCEUI_GetCheat(selcheat, NULL, &a, &v, &c, &s, NULL);
RedoCheatsCallB(name, a, v, c, s, 1, &selcheat);
SendDlgItemMessage(hwndDlg, IDC_LIST_CHEATS, LVM_SETSELECTIONMARK, 0, selcheat);
@ -700,8 +657,8 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
savecheats = 1;
}
}
break;
}
break;
case IDC_BTN_CHEAT_RESET:
FCEUI_CheatSearchBegin();
ShowResults(hwndDlg);
@ -715,8 +672,8 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
knownvalue = StrToU8(str);
FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_KNOWN, knownvalue, 0);
ShowResults(hwndDlg);
break;
}
break;
case IDC_BTN_CHEAT_EQ:
searchdone = 1;
FCEUI_CheatSearchEnd(FCEU_SEARCH_PUERLY_RELATIVE_CHANGE,0,0);
@ -732,8 +689,8 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
else FCEUI_CheatSearchEnd(FCEU_SEARCH_ANY_CHANGE, 0, 0);
ShowResults(hwndDlg);
break;
}
break;
case IDC_BTN_CHEAT_GT:
{
char str[256] = { 0 };
@ -744,8 +701,8 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
else FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_GT, 0, 0);
ShowResults(hwndDlg);
break;
}
break;
case IDC_BTN_CHEAT_LT:
{
char str[256] = { 0 };
@ -756,10 +713,63 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
else FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_LT, 0, 0);
ShowResults(hwndDlg);
break;
}
break;
case IDC_RADIO_ADDRESS:
case IDC_RADIO_TEXT_CODE:
ToggleCheatInputMode(hwndDlg, LOWORD(wParam));
break;
}
break;
case EN_UPDATE:
switch (LOWORD(wParam))
{
case IDC_CHEAT_ADDR:
case IDC_CHEAT_VAL:
case IDC_CHEAT_COM:
{
if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_ADDRESS))
{
char buf[16]; uint32 a; uint8 v; int c;
GetUICheatInfo(hwndDlg, NULL, &a, &v, &c);
GetCheatStr(buf, a, v, c);
SetDlgItemText(hwndDlg, IDC_CHEAT_TEXT, buf);
}
// it was saparated to the text/game genie position
/*
if (dodecode && (strlen(buf) == 6 || strlen(buf) == 8))
if (FCEUI_DecodeGG(buf, &GGaddr, &GGval, &GGcomp)) {
a = GGaddr;
v = GGval;
c = GGcomp;
}
*/
}
break;
case IDC_CHEAT_TEXT:
{
if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TEXT_CODE))
{
char buf[16];
GetDlgItemText(hwndDlg, IDC_CHEAT_TEXT, buf, 16);
int a = -1, v = -1; int c = -1;
if (strchr(buf, ':'))
{
if (strchr(buf, '?'))
sscanf(buf, "%X:%X?%X", &a, &c, &v);
else
sscanf(buf, "%X:%X", &a, &v);
}
else if (strlen(buf) == 6 || strlen(buf) == 8)
FCEUI_DecodeGG(buf, &a, &v, &c);
SetDlgItemText(hwndDlg, IDC_CHEAT_ADDR, (LPTSTR)(a == -1 ? "" : U16ToStr(a)));
SetDlgItemText(hwndDlg, IDC_CHEAT_VAL, (LPTSTR)(v == -1 ? "" : U8ToStr(v)));
SetDlgItemText(hwndDlg, IDC_CHEAT_COM, (LPTSTR)(c == -1 ? "" : U8ToStr(c)));
}
}
}
break;
}
break;
case WM_NOTIFY:
@ -788,6 +798,11 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SetDlgItemText(hwndDlg, IDC_CHEAT_ADDR, (LPTSTR)U16ToStr(a));
SetDlgItemText(hwndDlg, IDC_CHEAT_VAL, (LPTSTR)U8ToStr(v));
SetDlgItemText(hwndDlg, IDC_CHEAT_COM, (LPTSTR)(c == -1 ? "" : U8ToStr(c)));
char code[32];
GetCheatStr(code, a, v, c);
SetDlgItemText(hwndDlg, IDC_CHEAT_TEXT, code);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CHEAT_DEL), selcheatcount > 0);
@ -960,6 +975,16 @@ void UpdateCheatsAdded()
UpdateCheatListGroupBoxUI();
}
void ToggleCheatInputMode(HWND hwndDlg, int modeId)
{
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_ADDR), modeId == IDC_RADIO_ADDRESS);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_VAL), modeId == IDC_RADIO_ADDRESS);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_COM), modeId == IDC_RADIO_ADDRESS);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_VAL_LABEL), modeId == IDC_RADIO_ADDRESS);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_COM_LABEL), modeId == IDC_RADIO_ADDRESS);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHEAT_TEXT), modeId == IDC_RADIO_TEXT_CODE);
}
BOOL CALLBACK GGConvCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
char str[100];
@ -981,66 +1006,63 @@ BOOL CALLBACK GGConvCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
};
case WM_INITDIALOG:
//todo: set text limits
if (GGConv_wndx==-32000) GGConv_wndx=0; //Just in case
if (GGConv_wndy==-32000) GGConv_wndy=0;
SetWindowPos(hwndDlg,0,GGConv_wndx,GGConv_wndy,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER);
break;
case WM_CREATE:
break;
case WM_PAINT:
if (GGConv_wndx == -32000)
GGConv_wndx = 0; //Just in case
if (GGConv_wndy == -32000)
GGConv_wndy = 0;
SetWindowPos(hwndDlg, 0, GGConv_wndx, GGConv_wndy, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
SendDlgItemMessage(hwndDlg, IDC_GAME_GENIE_CODE, EM_SETLIMITTEXT, 8, 0);
break;
case WM_CLOSE:
case WM_QUIT:
DestroyWindow(hGGConv);
hGGConv = 0;
break;
case WM_COMMAND:
switch(HIWORD(wParam)) {
case EN_UPDATE:
if(dontupdateGG)break;
dontupdateGG = 1;
switch(LOWORD(wParam)){ //lets find out what edit control got changed
case IDC_GAME_GENIE_CODE: //The Game Genie Code - in this case decode it.
GetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode,9);
if((strlen(GGcode) != 8) && (strlen(GGcode) != 6))break;
switch(HIWORD(wParam)) {
case EN_UPDATE:
if(dontupdateGG)break;
dontupdateGG = 1;
switch(LOWORD(wParam)){ //lets find out what edit control got changed
case IDC_GAME_GENIE_CODE: //The Game Genie Code - in this case decode it.
GetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode,9);
if((strlen(GGcode) != 8) && (strlen(GGcode) != 6))break;
FCEUI_DecodeGG(GGcode, &GGaddr, &GGval, &GGcomp);
FCEUI_DecodeGG(GGcode, &GGaddr, &GGval, &GGcomp);
sprintf(str,"%04X",GGaddr);
SetDlgItemText(hGGConv,IDC_GAME_GENIE_ADDR,str);
sprintf(str,"%04X",GGaddr);
SetDlgItemText(hGGConv,IDC_GAME_GENIE_ADDR,str);
if(GGcomp != -1)
sprintf(str,"%02X",GGcomp);
else str[0] = 0;
if(GGcomp != -1)
sprintf(str,"%02X",GGcomp);
else str[0] = 0;
SetDlgItemText(hGGConv,IDC_GAME_GENIE_COMP,str);
sprintf(str,"%02X",GGval);
SetDlgItemText(hGGConv,IDC_GAME_GENIE_VAL,str);
sprintf(str,"%02X",GGval);
SetDlgItemText(hGGConv,IDC_GAME_GENIE_VAL,str);
//ListGGAddresses();
break;
break;
case IDC_GAME_GENIE_ADDR:
case IDC_GAME_GENIE_COMP:
case IDC_GAME_GENIE_VAL:
case IDC_GAME_GENIE_ADDR:
case IDC_GAME_GENIE_COMP:
case IDC_GAME_GENIE_VAL:
GetDlgItemText(hGGConv,IDC_GAME_GENIE_ADDR,str,5);
if(strlen(str) != 4) break;
GetDlgItemText(hGGConv,IDC_GAME_GENIE_ADDR,str,5);
if(strlen(str) != 4) break;
GetDlgItemText(hGGConv,IDC_GAME_GENIE_VAL,str,5);
if(strlen(str) != 2) {GGval = -1; break;}
GetDlgItemText(hGGConv,IDC_GAME_GENIE_VAL,str,5);
if(strlen(str) != 2) {GGval = -1; break;}
GGaddr = GetEditHex(hGGConv,IDC_GAME_GENIE_ADDR);
GGval = GetEditHex(hGGConv,IDC_GAME_GENIE_VAL);
GGaddr = GetEditHex(hGGConv,IDC_GAME_GENIE_ADDR);
GGval = GetEditHex(hGGConv,IDC_GAME_GENIE_VAL);
GetDlgItemText(hGGConv,IDC_GAME_GENIE_COMP,str,5);
if(strlen(str) != 2) GGcomp = -1;
else GGcomp = GetEditHex(hGGConv,IDC_GAME_GENIE_COMP);
GetDlgItemText(hGGConv,IDC_GAME_GENIE_COMP,str,5);
if(strlen(str) != 2) GGcomp = -1;
else GGcomp = GetEditHex(hGGConv,IDC_GAME_GENIE_COMP);
EncodeGG(GGcode, GGaddr, GGval, GGcomp);
SetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode);
//ListGGAddresses();
EncodeGG(GGcode, GGaddr, GGval, GGcomp);
SetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode);
//ListGGAddresses();
break;
}
ListGGAddresses();
@ -1074,7 +1096,6 @@ BOOL CALLBACK GGConvCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
}
break;
case LBN_DBLCLK:
switch (LOWORD(wParam)) {
case IDC_LIST_GGADDRESSES:
@ -1192,11 +1213,31 @@ void DoGGConv()
return;
}
/*
void ListBox::OnRButtonDown(UINT nFlags, CPoint point)
inline void GetCheatStr(char* buf, int a, int v, int c)
{
CPoint test = point;
} */
if (a >= 0x8000)
EncodeGG(buf, a, v, c);
else {
if (c == -1)
sprintf(buf, "%04X:%02X", (int)a, (int)v);
else
sprintf(buf, "%04X?%02X:%02X", (int)a, (int)c, (int)v);
}
}
void GetUICheatInfo(HWND hwndDlg, char* name, uint32* a, uint8* v, int* c)
{
char buf[16];
GetDlgItemText(hwndDlg, IDC_CHEAT_ADDR, buf, 5);
*a = StrToU16(buf);
GetDlgItemText(hwndDlg, IDC_CHEAT_VAL, buf, 3);
*v = StrToU8(buf);
GetDlgItemText(hwndDlg, IDC_CHEAT_COM, buf, 3);
*c = (buf[0] == 0) ? -1 : StrToU8(buf);
if (name)
GetDlgItemText(hwndDlg, IDC_CHEAT_NAME, name, 256);
}
void DisableAllCheats()
{

View File

@ -15,6 +15,9 @@ void SetGGConvFocus(int address,int compare);
void UpdateCheatList();
void UpdateCheatListGroupBoxUI();
void UpdateCheatsAdded();
void ToggleCheatInputMode(HWND hwndDlg, int modeId);
void GetUICheatInfo(HWND hwndDlg, char* name, uint32* a, uint8* v, int* c);
inline void GetCheatStr(char* buf, int a, int v, int c);
extern unsigned int FrozenAddressCount;
extern std::vector<uint16> FrozenAddresses;
@ -35,5 +38,6 @@ SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, newIndex)
(SetDlgItemText(hwnd, IDC_CHEAT_ADDR, (LPTSTR)"") & \
SetDlgItemText(hwnd, IDC_CHEAT_VAL, (LPTSTR)"") & \
SetDlgItemText(hwnd, IDC_CHEAT_COM, (LPTSTR)"") & \
SetDlgItemText(hwnd, IDC_CHEAT_NAME, (LPTSTR)""))
SetDlgItemText(hwnd, IDC_CHEAT_NAME, (LPTSTR)"") & \
SetDlgItemText(hwnd, IDC_CHEAT_TEXT, (LPTSTR)""))

View File

@ -131,7 +131,6 @@ bool InsertWatch(const AddressWatcher& Watch)
return true;
}
bool InsertWatch(const AddressWatcher& Watch, HWND parent)
{
if(!VerifyWatchNotAlreadyAdded(Watch))
@ -144,9 +143,20 @@ bool InsertWatch(const AddressWatcher& Watch, HWND parent)
int prevWatchCount = WatchCount;
rswatches[WatchCount] = Watch;
rswatches[WatchCount].CurValue = GetCurrentValue(rswatches[WatchCount]);
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), parent, (DLGPROC)EditWatchProc, (LPARAM)WatchCount);
int tmpWatchIndex;
if (parent == RamWatchHWnd)
tmpWatchIndex = WatchCount;
else if (parent == RamSearchHWnd)
tmpWatchIndex = -2;
else if (parent == hCheat)
tmpWatchIndex = -3;
else
tmpWatchIndex = -4;
rswatches[tmpWatchIndex] = Watch;
rswatches[tmpWatchIndex].CurValue = GetCurrentValue(rswatches[tmpWatchIndex]);
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), parent, (DLGPROC)EditWatchProc, tmpWatchIndex);
rswatches.erase(tmpWatchIndex);
return WatchCount > prevWatchCount;
}
@ -158,7 +168,9 @@ bool InsertWatches(const AddressWatcher* watches, HWND parent, const int count)
else
{
bool success = false;
char comment[256];
rswatches[-1] = watches[0];
rswatches[-1].comment = comment;
if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), parent, (DLGPROC)EditWatchProc, (LPARAM)-1))
for (int i = 0; i < count; ++i)
{
@ -166,7 +178,6 @@ bool InsertWatches(const AddressWatcher* watches, HWND parent, const int count)
watcher.comment = rswatches[-1].comment;
success |= InsertWatch(watcher);
}
free(rswatches[-1].comment);
rswatches.erase(-1);
return success;
}
@ -768,7 +779,9 @@ void RefreshWatchListSelectedItemControlStatus(HWND hDlg)
LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets info for a RAM Watch, and then inserts it into the Watch List
{
static int index;
// since there are 3 windows can pops up the add watch dialog, we should store them separately.
// 0 for ram watch, 1 for ram search, 2 for cheat dialog.
static int indexes[4];
switch(uMsg)
{
@ -778,11 +791,11 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
GetWindowRect(hWnd, &r);
SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
index = (int)lParam;
AddressWatcher& watcher = rswatches[index];
AddressWatcher& watcher = rswatches[lParam];
if (watcher.Type != 'S') {
char Str_Tmp[1024];
if (index != -1)
// -1 means batch add
if (lParam != -1)
{
sprintf(Str_Tmp, "%04X", watcher.Address);
SetDlgItemText(hDlg, IDC_EDIT_COMPAREADDRESS, Str_Tmp);
@ -821,6 +834,8 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SetDlgItemText(hDlg, IDC_PROMPT_EDIT, watcher.comment);
HWND parent = GetParent(hDlg);
indexes[GetDlgStoreIndex(parent)] = lParam;
if (watcher.Type == 'S' || parent == RamSearchHWnd || parent == hCheat)
{
EnableWindow(GetDlgItem(hDlg, IDC_SPECIFICADDRESS), FALSE);
@ -845,21 +860,25 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
{
case IDOK:
{
char Str_Tmp[1024];
char Str_Tmp[256];
HWND parent = GetParent(hDlg);
int index = indexes[GetDlgStoreIndex(parent)];
// not a single watch editing operation
if (index != -1)
{
// a normal watch, copy it to a temporary one
AddressWatcher watcher = rswatches[index];
if (watcher.comment != NULL)
watcher.comment = strcpy((char*)malloc(strlen(watcher.comment) + 2), watcher.comment);
// if (watcher.comment != NULL)
// watcher.comment = strcpy((char*)malloc(strlen(watcher.comment) + 2), watcher.comment);
// It's from ram watch window, not a separator
// When it's from ram search window, all the information required is already set,
// When it's from ram search or cheat window, all the information required is already set,
// so this is also unecessary
if (RamWatchHWnd && RamWatchHWnd == GetParent(hDlg) && watcher.Type != 'S')
{
GetDlgItemText(hDlg, IDC_PROMPT_EDIT, Str_Tmp, 1024);
GetDlgItemText(hDlg, IDC_PROMPT_EDIT, Str_Tmp, 256);
// type
if (SendDlgItemMessage(hDlg, IDC_SIGNED, BM_GETCHECK, 0, 0) == BST_CHECKED)
@ -910,9 +929,9 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
watcher.comment = Str_Tmp;
// finallly update the watch list
if (index < WatchCount)
if (index >= 0 && index < WatchCount)
// it's a watch editing operation.
// Only ram watch window can edit a watch, the ram search window only add watch.
// Only ram watch window can edit a watch, the ram search window and cheat window only add watch.
EditWatch(index, watcher);
else
InsertWatch(watcher);
@ -924,7 +943,7 @@ LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
AddressWatcher& watcher = rswatches[index];
// comment
GetDlgItemText(hDlg, IDC_PROMPT_EDIT, Str_Tmp, 80);
watcher.comment = strcpy((char*) malloc(strlen(Str_Tmp) + 2), Str_Tmp);
strcpy(watcher.comment, Str_Tmp);
}
EndDialog(hDlg, true);
@ -1289,7 +1308,7 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST));
if(watchIndex != -1)
{
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM)watchIndex);
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC)EditWatchProc, watchIndex);
SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST));
}
return true;
@ -1300,7 +1319,7 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
target.WrongEndian = 0;
target.Size = 'b';
target.Type = 's';
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC)EditWatchProc, (LPARAM)WatchCount);
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC)EditWatchProc, WatchCount);
SetFocus(GetDlgItem(hDlg, IDC_WATCHLIST));
return true;
}

View File

@ -78,4 +78,9 @@ extern HWND RamWatchHWnd;
#define WatchSizeConv(watch) (watch.Type == 'S' ? 0 : watch.Size == 'd' ? 4 : watch.Size == 'w' ? 2 : watch.Size == 'b' ? 1 : 0)
#define SizeConvWatch(size) (size == 4 ? 'd' : size == 2 ? 'w' : size == 1 : 'b' : 0)
#define GetDlgStoreIndex(parent) \
(parent == RamWatchHWnd ? 0 : \
parent == RamSearchHWnd ? 1 : \
parent == hCheat ? 2 : 3)
#endif

View File

@ -12,7 +12,7 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
// Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
@ -25,8 +25,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON3 ICON "res\\taseditor-icon.ico"
IDI_ICON4 ICON "res\\taseditor-icon32.ico"
IDI_ICON3 ICON "res/taseditor-icon.ico"
IDI_ICON4 ICON "res/taseditor-icon32.ico"
ICON_1 ICON "res/ICON_1.ico"
ICON_2 ICON "res/ICON_2.ico"
@ -1567,7 +1567,7 @@ STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS
CAPTION "Game Genie Encoder/Decoder Tool"
FONT 8, "Tahoma", 0, 0, 0x0
BEGIN
EDITTEXT IDC_GAME_GENIE_CODE,115,22,53,14,ES_AUTOHSCROLL
EDITTEXT IDC_GAME_GENIE_CODE,115,22,53,14,ES_UPPERCASE | ES_AUTOHSCROLL
GROUPBOX "Game Genie Code",-1,107,5,69,42
GROUPBOX "Address/Compare/Value",65534,9,5,91,75
LTEXT "Address:",65533,18,24,35,8
@ -1973,45 +1973,47 @@ BEGIN
LTEXT "New Selection Name:",-1,5,240,68,8
END
CHEATCONSOLE DIALOGEX 0, 0, 431, 198
CHEATCONSOLE DIALOGEX 0, 0, 395, 216
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Cheat Search"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Active Cheats",IDC_GROUPBOX_CHEATLIST,5,2,171,191,WS_TABSTOP
GROUPBOX "Cheat Search",IDC_GROUPBOX_CHEATSEARCH,181,2,244,191,WS_TABSTOP
CONTROL "",IDC_LIST_CHEATS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,11,11,159,131
GROUPBOX "Active Cheats",IDC_GROUPBOX_CHEATLIST,5,2,178,209,WS_TABSTOP
GROUPBOX "Cheat Search",IDC_GROUPBOX_CHEATSEARCH,188,2,201,209,WS_TABSTOP
CONTROL "",IDC_LIST_CHEATS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,11,11,167,131
LTEXT "Name:",IDC_STATIC,13,147,22,10
LTEXT "Address:",IDC_STATIC,13,162,30,8
LTEXT "Value:",IDC_STATIC,74,162,22,8
LTEXT "Compare:",IDC_STATIC,117,162,34,8
EDITTEXT IDC_CHEAT_NAME,37,145,132,12,ES_AUTOHSCROLL | ES_WANTRETURN
EDITTEXT IDC_CHEAT_ADDR,45,160,25,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_CHEAT_VAL,98,160,16,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_CHEAT_COM,153,160,16,12,ES_UPPERCASE | ES_WANTRETURN
DEFPUSHBUTTON "Add",IDC_BTN_CHEAT_ADD,12,174,36,16
PUSHBUTTON "Delete",IDC_BTN_CHEAT_DEL,48,174,36,16
PUSHBUTTON "Update",IDC_BTN_CHEAT_UPD,84,174,36,16
PUSHBUTTON "Reset",IDC_BTN_CHEAT_RESET,187,12,55,15
PUSHBUTTON "Known Value:",IDC_BTN_CHEAT_KNOWN,187,35,55,15
LTEXT "0x",IDC_STATIC,246,38,9,8
EDITTEXT IDC_CHEAT_VAL_KNOWN,256,36,18,12,ES_UPPERCASE
GROUPBOX "Previous Compare",204,186,57,113,119
PUSHBUTTON "Equal",IDC_BTN_CHEAT_EQ,192,74,55,15,WS_GROUP
PUSHBUTTON "Not Equal",IDC_BTN_CHEAT_NE,192,101,55,15
CONTROL "By:",IDC_CHEAT_CHECK_NE_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,251,104,22,10
EDITTEXT IDC_CHEAT_VAL_NE_BY,275,103,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Greater Than",IDC_BTN_CHEAT_GT,192,128,55,15
CONTROL "By:",IDC_CHEAT_CHECK_GT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,251,131,22,10
EDITTEXT IDC_CHEAT_VAL_GT_BY,275,130,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Less Than",IDC_BTN_CHEAT_LT,192,155,55,15
CONTROL "By:",IDC_CHEAT_CHECK_LT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,251,158,22,10
EDITTEXT IDC_CHEAT_VAL_LT_BY,275,157,18,12,ES_UPPERCASE | ES_WANTRETURN
GROUPBOX "Possibilities",IDC_CHEAT_BOX_POSSIBILITIES,304,8,116,168,WS_TABSTOP
CONTROL "",IDC_CHEAT_LIST_POSSIBILITIES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,309,18,106,153
LTEXT "Value:",IDC_CHEAT_VAL_LABEL,83,162,22,8
LTEXT "Compare:",IDC_CHEAT_COM_LABEL,126,162,34,8
EDITTEXT IDC_CHEAT_NAME,37,145,141,12,ES_AUTOHSCROLL | ES_WANTRETURN
EDITTEXT IDC_CHEAT_ADDR,54,160,25,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_CHEAT_VAL,107,160,16,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_CHEAT_COM,162,160,16,12,ES_UPPERCASE | ES_WANTRETURN
DEFPUSHBUTTON "Add",IDC_BTN_CHEAT_ADD,11,192,36,16
PUSHBUTTON "Delete",IDC_BTN_CHEAT_DEL,49,192,36,16
PUSHBUTTON "Update",IDC_BTN_CHEAT_UPD,87,192,36,16
PUSHBUTTON "Reset",IDC_BTN_CHEAT_RESET,200,12,55,15
PUSHBUTTON "Known Value:",IDC_BTN_CHEAT_KNOWN,200,32,55,15
LTEXT "0x",IDC_CHEAT_LABEL_KNOWN,225,51,9,8
EDITTEXT IDC_CHEAT_VAL_KNOWN,236,49,18,12,ES_UPPERCASE
GROUPBOX "Previous Compare",IDC_GROUP_PREV_COM,193,63,69,132
PUSHBUTTON "Equal",IDC_BTN_CHEAT_EQ,200,75,55,15,WS_GROUP
PUSHBUTTON "Not Equal",IDC_BTN_CHEAT_NE,200,96,55,15
CONTROL "By:",IDC_CHEAT_CHECK_NE_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,212,114,22,10
EDITTEXT IDC_CHEAT_VAL_NE_BY,236,113,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Greater Than",IDC_BTN_CHEAT_GT,200,129,55,15
CONTROL "By:",IDC_CHEAT_CHECK_GT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,212,147,22,10
EDITTEXT IDC_CHEAT_VAL_GT_BY,236,146,18,12,ES_UPPERCASE | ES_WANTRETURN
PUSHBUTTON "Less Than",IDC_BTN_CHEAT_LT,200,162,55,15
CONTROL "By:",IDC_CHEAT_CHECK_LT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,212,180,22,10
EDITTEXT IDC_CHEAT_VAL_LT_BY,236,179,18,12,ES_UPPERCASE | ES_WANTRETURN
GROUPBOX "Possibilities",IDC_CHEAT_BOX_POSSIBILITIES,266,8,117,187,WS_TABSTOP
CONTROL "",IDC_CHEAT_LIST_POSSIBILITIES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,272,18,106,172
CONTROL " Pause emulation when this window is active",IDC_CHEAT_PAUSEWHENACTIVE,
"Button",BS_AUTOCHECKBOX,188,179,157,10
PUSHBUTTON "Import...",IDC_BTN_CHEAT_ADDFROMFILE,128,174,43,16
"Button",BS_AUTOCHECKBOX,198,198,157,10
PUSHBUTTON "Import...",IDC_BTN_CHEAT_ADDFROMFILE,136,192,43,16
CONTROL "Address:",IDC_RADIO_ADDRESS,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,161,42,10
CONTROL "Cheat Code / Game Genie:",IDC_RADIO_TEXT_CODE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,176,101,10
EDITTEXT IDC_CHEAT_TEXT,115,175,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
END
IDD_LUA DIALOGEX 0, 0, 270, 150
@ -2431,8 +2433,8 @@ BEGIN
"CHEATCONSOLE", DIALOG
BEGIN
RIGHTMARGIN, 430
BOTTOMMARGIN, 197
RIGHTMARGIN, 394
BOTTOMMARGIN, 215
END
"VIDEOCONFIG", DIALOG
@ -2682,12 +2684,12 @@ IDB_BITMAP_SELECTED17 BITMAP "res\\te_17_selected.bmp"
IDB_BITMAP_SELECTED18 BITMAP "res\\te_18_selected.bmp"
IDB_BITMAP_SELECTED19 BITMAP "res\\te_19_selected.bmp"
IDB_BRANCH_SPRITESHEET BITMAP "res\\branch_spritesheet.bmp"
#endif // English (U.S.) resources
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
// English (U.S) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
@ -2716,7 +2718,7 @@ END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
#endif // English (U.S) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 res.rc 使用
// Microsoft Visual C++ generated file
// for res.rc
//
#define CLOSE_BUTTON 1
#define BUTTON_CLOSE 1
@ -273,6 +273,7 @@
#define COMBO_NETMOO_LOCAL_PLAYERS 204
#define MENU_MV_EDIT_FIND_NEXT 204
#define IDC_DEBUGGER_FLAG_D 204
#define IDC_GROUP_PREV_COM 204
#define IDC_NETMOO_KEY 205
#define IDC_DEBUGGER_FLAG_I 205
#define IDB_BITMAP20 205
@ -584,6 +585,7 @@
#define IDC_NOTE_TO_FIND 1147
#define IDC_AUTOSAVE_PERIOD 1147
#define IDC_EXTRA_SCANLINES 1147
#define IDC_CHEAT_TEXT 1147
#define IDC_BUTTON9 1148
#define TASEDITOR_FIND_NEXT_SIMILAR_MARKER 1148
#define IDC_SYMBOLIC_ADDRESS 1148
@ -792,6 +794,12 @@
#define IDC_EXTRA_SCANLINES_TEXT 1309
#define IDC_DATASIZE_GROUPBOX 1310
#define IDC_DATATYPE_GROUPBOX 1311
#define IDC_RADIO_ADDRESS 1312
#define IDC_RADIO_TEXT_CODE 1313
#define IDC_CHEAT_VAL_LABEL 1314
#define IDC_CHEAT_COM_LABEL 1315
#define IDC_CHEAT_KNOWN_LABEL 1316
#define IDC_CHEAT_LABEL_KNOWN 1316
#define MENU_NETWORK 40040
#define MENU_PALETTE 40041
#define MENU_SOUND 40042
@ -1273,7 +1281,7 @@
#define MENU_MV_FILE_LOAD_OAM 40599
#define DISASM_CONTEXT_SELECTALL 40599
#define CHEAT_CONTEXT_POSSI_ADDTOMEMORYWATCH 40600
#define CHEAT_CONTEXT_POSSI_ADDCHEAT 40601
#define CHEAT_CONTEXT_POSSI_ADDCHEAT 40601
#define CHEAT_CONTEXT_POSSI_GOTOINHEXEDITOR 40602
#define CHEAT_CONTEXT_POSSI_ADDTORAMWATCH 40603
#define IDC_DEBUGGER_ICONTRAY 55535
@ -1290,7 +1298,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 304
#define _APS_NEXT_COMMAND_VALUE 40611
#define _APS_NEXT_CONTROL_VALUE 1312
#define _APS_NEXT_CONTROL_VALUE 1317
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif