support cheats to any address, not just main memory.
This commit is contained in:
parent
9b33859c68
commit
9767f79346
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2009-2015 DeSmuME team
|
Copyright (C) 2009-2016 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -50,7 +50,7 @@ BOOL CHEATS::add(u8 size, u32 address, u32 val, char *description, BOOL enabled)
|
||||||
{
|
{
|
||||||
size_t num = list.size();
|
size_t num = list.size();
|
||||||
list.push_back(CHEATS_LIST());
|
list.push_back(CHEATS_LIST());
|
||||||
list[num].code[0][0] = address & 0x00FFFFFF;
|
list[num].code[0][0] = address & 0x0FFFFFFF;
|
||||||
list[num].code[0][1] = val;
|
list[num].code[0][1] = val;
|
||||||
list[num].num = 1;
|
list[num].num = 1;
|
||||||
list[num].type = 0;
|
list[num].type = 0;
|
||||||
|
@ -63,7 +63,7 @@ BOOL CHEATS::add(u8 size, u32 address, u32 val, char *description, BOOL enabled)
|
||||||
BOOL CHEATS::update(u8 size, u32 address, u32 val, char *description, BOOL enabled, u32 pos)
|
BOOL CHEATS::update(u8 size, u32 address, u32 val, char *description, BOOL enabled, u32 pos)
|
||||||
{
|
{
|
||||||
if (pos >= list.size()) return FALSE;
|
if (pos >= list.size()) return FALSE;
|
||||||
list[pos].code[0][0] = address & 0x00FFFFFF;
|
list[pos].code[0][0] = address & 0x0FFFFFFF;
|
||||||
list[pos].code[0][1] = val;
|
list[pos].code[0][1] = val;
|
||||||
list[pos].num = 1;
|
list[pos].num = 1;
|
||||||
list[pos].type = 0;
|
list[pos].type = 0;
|
||||||
|
@ -727,7 +727,7 @@ BOOL CHEATS::load()
|
||||||
if (tmp_cht.type == 0)
|
if (tmp_cht.type == 0)
|
||||||
{
|
{
|
||||||
tmp_cht.size = std::min<u32>(3, ((tmp_cht.code[i][0] & 0xF0000000) >> 28));
|
tmp_cht.size = std::min<u32>(3, ((tmp_cht.code[i][0] & 0xF0000000) >> 28));
|
||||||
tmp_cht.code[i][0] &= 0x00FFFFFF;
|
tmp_cht.code[i][0] &= 0x0FFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(tmp_buf, &codeStr[(i * 16) + 8], 8);
|
strncpy(tmp_buf, &codeStr[(i * 16) + 8], 8);
|
||||||
|
@ -765,8 +765,8 @@ void CHEATS::process(int targetType)
|
||||||
{
|
{
|
||||||
case 0: // internal cheat system
|
case 0: // internal cheat system
|
||||||
{
|
{
|
||||||
//INFO("list at 0x02|%06X value %i (size %i)\n",list[i].code[0], list[i].lo[0], list[i].size);
|
//INFO("list at 0x0|%07X value %i (size %i)\n",list[i].code[0], list[i].lo[0], list[i].size);
|
||||||
u32 addr = list[i].code[0][0] | 0x02000000;
|
u32 addr = list[i].code[0][0];
|
||||||
u32 val = list[i].code[0][1];
|
u32 val = list[i].code[0][1];
|
||||||
switch (list[i].size)
|
switch (list[i].size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2009-2015 DeSmuME team
|
Copyright (C) 2009-2016 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -96,7 +96,16 @@ void generateAR(HWND dialog, u32 addr, u32 val, u8 size)
|
||||||
// Action Replay code generate
|
// Action Replay code generate
|
||||||
if (size > 3) size = 3;
|
if (size > 3) size = 3;
|
||||||
char buf[64] = {0};
|
char buf[64] = {0};
|
||||||
sprintf(buf, "%X%07X %08X", 3-size, addr | 0x02000000, val);
|
|
||||||
|
//I don't think this is needed, really
|
||||||
|
//we'll just accurately produce an AR code that faithfully doesn't work
|
||||||
|
//if((addr&0x02000000) != 0x02000000)
|
||||||
|
//{
|
||||||
|
// SetWindowText(GetDlgItem(dialog, IDC_AR_CODE), "");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
sprintf(buf, "%X%07X %08X", 3-size, addr, val);
|
||||||
SetWindowText(GetDlgItem(dialog, IDC_AR_CODE), buf);
|
SetWindowText(GetDlgItem(dialog, IDC_AR_CODE), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +186,7 @@ INT_PTR CALLBACK CheatsAddProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam
|
||||||
memset(editBuf, 0, sizeof(editBuf));
|
memset(editBuf, 0, sizeof(editBuf));
|
||||||
memset(&tempCheat, 0, sizeof(tempCheat));
|
memset(&tempCheat, 0, sizeof(tempCheat));
|
||||||
saveOldEditProc = oldEditProc;
|
saveOldEditProc = oldEditProc;
|
||||||
SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 6, 0);
|
SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 7, 0);
|
||||||
SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 11, 0);
|
SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 11, 0);
|
||||||
SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0);
|
SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0);
|
||||||
oldEditProcHEX = SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG_PTR)EditValueHEXProc);
|
oldEditProcHEX = SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG_PTR)EditValueHEXProc);
|
||||||
|
@ -186,8 +195,8 @@ INT_PTR CALLBACK CheatsAddProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam
|
||||||
if (searchAddMode == 1 || searchAddMode == 2)
|
if (searchAddMode == 1 || searchAddMode == 2)
|
||||||
{
|
{
|
||||||
char buf[12];
|
char buf[12];
|
||||||
searchAddAddress &= 0x00FFFFFF;
|
searchAddAddress &= 0x0FFFFFFF;
|
||||||
wsprintf(buf, "%06X", searchAddAddress);
|
wsprintf(buf, "%07X", searchAddAddress);
|
||||||
SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf);
|
SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf);
|
||||||
wsprintf(buf, "%i", searchAddValue);
|
wsprintf(buf, "%i", searchAddValue);
|
||||||
SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf);
|
SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf);
|
||||||
|
@ -371,7 +380,7 @@ INT_PTR CALLBACK CheatsEditProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpara
|
||||||
memset(editBuf, 0, sizeof(editBuf));
|
memset(editBuf, 0, sizeof(editBuf));
|
||||||
memset(&tempCheat, 0, sizeof(tempCheat));
|
memset(&tempCheat, 0, sizeof(tempCheat));
|
||||||
saveOldEditProc = oldEditProc;
|
saveOldEditProc = oldEditProc;
|
||||||
SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 6, 0);
|
SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 7, 0);
|
||||||
SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 10, 0);
|
SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 10, 0);
|
||||||
SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0);
|
SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0);
|
||||||
oldEditProcHEX = SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG_PTR)EditValueHEXProc);
|
oldEditProcHEX = SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG_PTR)EditValueHEXProc);
|
||||||
|
@ -381,8 +390,8 @@ INT_PTR CALLBACK CheatsEditProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpara
|
||||||
|
|
||||||
memset(buf, 0, 100);
|
memset(buf, 0, 100);
|
||||||
memset(buf2, 0, 100);
|
memset(buf2, 0, 100);
|
||||||
tempCheat.code[0][0] &= 0x00FFFFFF;
|
tempCheat.code[0][0] &= 0x0FFFFFFF;
|
||||||
wsprintf(buf, "%06X", tempCheat.code[0][0]);
|
wsprintf(buf, "%07X", tempCheat.code[0][0]);
|
||||||
SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf);
|
SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf);
|
||||||
wsprintf(buf, "%i", tempCheat.code[0][1]);
|
wsprintf(buf, "%i", tempCheat.code[0][1]);
|
||||||
SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf);
|
SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf);
|
||||||
|
@ -428,7 +437,7 @@ INT_PTR CALLBACK CheatsEditProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpara
|
||||||
|
|
||||||
u32 val = 0;
|
u32 val = 0;
|
||||||
sscanf_s(editBuf[0], "%x", &val);
|
sscanf_s(editBuf[0], "%x", &val);
|
||||||
val &= 0x00FFFFFF;
|
val &= 0x0FFFFFFF;
|
||||||
CheatAddVerify(dialog,editBuf[0],editBuf[1],tempCheat.size);
|
CheatAddVerify(dialog,editBuf[0],editBuf[1],tempCheat.size);
|
||||||
tempCheat.code[0][0] = val;
|
tempCheat.code[0][0] = val;
|
||||||
}
|
}
|
||||||
|
@ -710,7 +719,7 @@ INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM l
|
||||||
{
|
{
|
||||||
u32 row = ListView_InsertItem(cheatListView, &lvi);
|
u32 row = ListView_InsertItem(cheatListView, &lvi);
|
||||||
ListView_SetCheckState(cheatListView, row, tempCheat.enabled);
|
ListView_SetCheckState(cheatListView, row, tempCheat.enabled);
|
||||||
wsprintf(buf, "0x02%06X", tempCheat.code[0][0]);
|
wsprintf(buf, "0x0%07X", tempCheat.code[0][0]);
|
||||||
ListView_SetItemText(cheatListView, row, 1, buf);
|
ListView_SetItemText(cheatListView, row, 1, buf);
|
||||||
ltoa(tempCheat.code[0][1], buf, 10);
|
ltoa(tempCheat.code[0][1], buf, 10);
|
||||||
ListView_SetItemText(cheatListView, row, 2, buf);
|
ListView_SetItemText(cheatListView, row, 2, buf);
|
||||||
|
@ -836,7 +845,7 @@ INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM l
|
||||||
lvi.iItem = INT_MAX;
|
lvi.iItem = INT_MAX;
|
||||||
|
|
||||||
u32 row = ListView_InsertItem(cheatListView, &lvi);
|
u32 row = ListView_InsertItem(cheatListView, &lvi);
|
||||||
wsprintf(buf, "0x02%06X", searchAddAddress);
|
wsprintf(buf, "0x0%07X", searchAddAddress);
|
||||||
ListView_SetItemText(cheatListView, row, 1, buf);
|
ListView_SetItemText(cheatListView, row, 1, buf);
|
||||||
ltoa(searchAddValue, buf, 10);
|
ltoa(searchAddValue, buf, 10);
|
||||||
ListView_SetItemText(cheatListView, row, 2, buf);
|
ListView_SetItemText(cheatListView, row, 2, buf);
|
||||||
|
@ -899,7 +908,7 @@ INT_PTR CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM l
|
||||||
char buf[256];
|
char buf[256];
|
||||||
cheats->get(&tempCheat, cheatEditPos);
|
cheats->get(&tempCheat, cheatEditPos);
|
||||||
ListView_SetCheckState(cheatListView, cheatEditPos, tempCheat.enabled);
|
ListView_SetCheckState(cheatListView, cheatEditPos, tempCheat.enabled);
|
||||||
wsprintf(buf, "0x02%06X", tempCheat.code[0][0]);
|
wsprintf(buf, "0x0%07X", tempCheat.code[0][0]);
|
||||||
ListView_SetItemText(cheatListView, cheatEditPos, 1, buf);
|
ListView_SetItemText(cheatListView, cheatEditPos, 1, buf);
|
||||||
ltoa(tempCheat.code[0][1], buf, 10);
|
ltoa(tempCheat.code[0][1], buf, 10);
|
||||||
ListView_SetItemText(cheatListView, cheatEditPos, 2, buf);
|
ListView_SetItemText(cheatListView, cheatEditPos, 2, buf);
|
||||||
|
@ -998,7 +1007,7 @@ void CheatsAddDialog(HWND parentHwnd, u32 address, u32 value, u8 size, const cha
|
||||||
//char buf[256];
|
//char buf[256];
|
||||||
//cheats->get(&tempCheat, cheatEditPos);
|
//cheats->get(&tempCheat, cheatEditPos);
|
||||||
//ListView_SetCheckState(cheatListView, cheatEditPos, 0, tempCheat.enabled);
|
//ListView_SetCheckState(cheatListView, cheatEditPos, 0, tempCheat.enabled);
|
||||||
//wsprintf(buf, "0x02%06X", tempCheat.code[0][0]);
|
//wsprintf(buf, "0x0%07X", tempCheat.code[0][0]);
|
||||||
//ListView_SetItemText(cheatListView, cheatEditPos, 1, buf);
|
//ListView_SetItemText(cheatListView, cheatEditPos, 1, buf);
|
||||||
//ltoa(tempCheat.code[0][1], buf, 10);
|
//ltoa(tempCheat.code[0][1], buf, 10);
|
||||||
//ListView_SetItemText(cheatListView, cheatEditPos, 2, buf);
|
//ListView_SetItemText(cheatListView, cheatEditPos, 2, buf);
|
||||||
|
@ -1157,7 +1166,7 @@ INT_PTR CALLBACK CheatsSearchViewWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM
|
||||||
while (cheatSearch->getList(&address, &val))
|
while (cheatSearch->getList(&address, &val))
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
wsprintf(buf, "0x02%06X", address);
|
wsprintf(buf, "0x0%07X", address);
|
||||||
lvi.pszText= buf;
|
lvi.pszText= buf;
|
||||||
u32 row = SendMessage(searchListView, LVM_INSERTITEM, 0, (LPARAM)&lvi);
|
u32 row = SendMessage(searchListView, LVM_INSERTITEM, 0, (LPARAM)&lvi);
|
||||||
_ltoa(val, buf, 10);
|
_ltoa(val, buf, 10);
|
||||||
|
@ -1184,7 +1193,7 @@ INT_PTR CALLBACK CheatsSearchViewWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM
|
||||||
u32 pos = ListView_GetNextItem(searchListView, -1, LVNI_SELECTED|LVNI_FOCUSED);
|
u32 pos = ListView_GetNextItem(searchListView, -1, LVNI_SELECTED|LVNI_FOCUSED);
|
||||||
ListView_GetItemText(searchListView, pos, 0, buf, 12);
|
ListView_GetItemText(searchListView, pos, 0, buf, 12);
|
||||||
sscanf_s(buf, "%x", &val);
|
sscanf_s(buf, "%x", &val);
|
||||||
searchAddAddress = val & 0x00FFFFFF;
|
searchAddAddress = val & 0x0FFFFFFF;
|
||||||
ListView_GetItemText(searchListView, pos, 1, buf, 12);
|
ListView_GetItemText(searchListView, pos, 1, buf, 12);
|
||||||
searchAddValue = atol(buf);
|
searchAddValue = atol(buf);
|
||||||
searchAddMode = 1;
|
searchAddMode = 1;
|
||||||
|
@ -1358,14 +1367,15 @@ void CheatAddVerify(HWND dialog,char* addre, char* valu,u8 size)
|
||||||
{
|
{
|
||||||
u32 fix = 0;
|
u32 fix = 0;
|
||||||
sscanf_s(addre, "%x", &fix);
|
sscanf_s(addre, "%x", &fix);
|
||||||
fix &= 0x00FFFFFF;
|
fix &= 0x0FFFFFFF;
|
||||||
|
|
||||||
int parseOffset = 0;
|
int parseOffset = 0;
|
||||||
if(valu[0] && valu[1] == '-')
|
if(valu[0] && valu[1] == '-')
|
||||||
parseOffset = 1; // typed something in front of -
|
parseOffset = 1; // typed something in front of -
|
||||||
u32 fix2 = strtoul(valu+parseOffset,NULL,10);
|
u32 fix2 = strtoul(valu+parseOffset,NULL,10);
|
||||||
|
|
||||||
if ( (strlen(addre) < 6) || (!strlen(valu)) || fix > 0x400000
|
if ( (strlen(addre) < 7) || (!strlen(valu))
|
||||||
|
//|| fix > 0x400000 //zero 23-may-2016 - if you want to freeze an address that's nonsense, it's your own funeral
|
||||||
|| (fix2 > searchRange[size][1] && !(valu[0] == '-' && u32(-s32(fix2))-1 <= searchRange[size][1]/2)) )
|
|| (fix2 > searchRange[size][1] && !(valu[0] == '-' && u32(-s32(fix2))-1 <= searchRange[size][1]/2)) )
|
||||||
{
|
{
|
||||||
EnableWindow(GetDlgItem(dialog, IDOK), FALSE);
|
EnableWindow(GetDlgItem(dialog, IDOK), FALSE);
|
||||||
|
|
|
@ -162,7 +162,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTI
|
||||||
CAPTION "Add cheat"
|
CAPTION "Add cheat"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
EDITTEXT IDC_EDIT1,26,17,88,14,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT1,22,17,92,14,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT2,7,42,107,14,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT2,7,42,107,14,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_EDIT3,7,67,107,30,ES_MULTILINE
|
EDITTEXT IDC_EDIT3,7,67,107,30,ES_MULTILINE
|
||||||
CONTROL "freeze value",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,47,101,67,10
|
CONTROL "freeze value",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,47,101,67,10
|
||||||
|
@ -175,7 +175,7 @@ BEGIN
|
||||||
LTEXT "Address:",IDC_STATIC,9,9,30,8
|
LTEXT "Address:",IDC_STATIC,9,9,30,8
|
||||||
LTEXT "Value:",IDC_STATIC,9,34,21,8
|
LTEXT "Value:",IDC_STATIC,9,34,21,8
|
||||||
LTEXT "Description:",IDC_STATIC,9,59,39,8
|
LTEXT "Description:",IDC_STATIC,9,59,39,8
|
||||||
LTEXT "0x02",IDC_STATIC,7,19,17,8
|
LTEXT "0x0",IDC_STATIC,7,19,13,8
|
||||||
GROUPBOX " Select size ",IDC_STATIC,7,114,107,57
|
GROUPBOX " Select size ",IDC_STATIC,7,114,107,57
|
||||||
LTEXT "[0..255]",IDC_STATIC_S1,53,124,60,8
|
LTEXT "[0..255]",IDC_STATIC_S1,53,124,60,8
|
||||||
LTEXT "[0..65535]",IDC_STATIC_S2,53,134,60,8
|
LTEXT "[0..65535]",IDC_STATIC_S2,53,134,60,8
|
||||||
|
@ -213,7 +213,7 @@ BEGIN
|
||||||
DEFPUSHBUTTON "Save",IDOK,109,263,50,14,WS_DISABLED
|
DEFPUSHBUTTON "Save",IDOK,109,263,50,14,WS_DISABLED
|
||||||
PUSHBUTTON "Cancel",IDCANCEL,163,263,50,14
|
PUSHBUTTON "Cancel",IDCANCEL,163,263,50,14
|
||||||
GROUPBOX " Add cheats code as... ",IDC_STATIC,7,230,205,31
|
GROUPBOX " Add cheats code as... ",IDC_STATIC,7,230,205,31
|
||||||
PUSHBUTTON "Cheats base",IDC_EXPORT,246,263,61,14
|
PUSHBUTTON "Cheats Database",IDC_EXPORT,246,263,63,14
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_CHEAT_SEARCH DIALOGEX 0, 0, 177, 211
|
IDD_CHEAT_SEARCH DIALOGEX 0, 0, 177, 211
|
||||||
|
|
Loading…
Reference in New Issue