mirror of https://github.com/snes9xgit/snes9x.git
Updated for Windows support.
This commit is contained in:
parent
46d8f7bb80
commit
21a4fe3163
56
bml.cpp
56
bml.cpp
|
@ -1,11 +1,27 @@
|
||||||
#include <ctype.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "port.h"
|
||||||
#include "bml.h"
|
#include "bml.h"
|
||||||
|
|
||||||
static inline bml_node *bml_node_new(void)
|
static char *strndup_p(char *str, int len)
|
||||||
|
{
|
||||||
|
char *buffer;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
buffer = (char *) malloc (len + 1);
|
||||||
|
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
|
for (n = 0; ((n < len) && (str[n] != 0)); n++) buffer[n] = str[n];
|
||||||
|
buffer[n] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bml_node *bml_node_new (void)
|
||||||
{
|
{
|
||||||
bml_node *node = new bml_node;
|
bml_node *node = new bml_node;
|
||||||
|
|
||||||
|
@ -16,6 +32,28 @@ static inline bml_node *bml_node_new(void)
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int islf(char c)
|
||||||
|
{
|
||||||
|
return (c == '\r' || c == '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int isblank(char c)
|
||||||
|
{
|
||||||
|
return (c == ' ' || c == '\t');
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int isalnum(char c)
|
||||||
|
{
|
||||||
|
return ((c >= 'a' && c <= 'z') ||
|
||||||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
|
(c >= '0' && c <= '9'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int bml_valid (char c)
|
||||||
|
{
|
||||||
|
return (isalnum (c) || c == '-');
|
||||||
|
}
|
||||||
|
|
||||||
static char *strndup_trim (char *str, int len)
|
static char *strndup_trim (char *str, int len)
|
||||||
{
|
{
|
||||||
int start;
|
int start;
|
||||||
|
@ -27,17 +65,7 @@ static char *strndup_trim (char *str, int len)
|
||||||
|
|
||||||
for (end = len - 1; isblank (str[end]) || str[end] == '\n' || str[end] == '\r'; end--) {}
|
for (end = len - 1; isblank (str[end]) || str[end] == '\n' || str[end] == '\r'; end--) {}
|
||||||
|
|
||||||
return strndup (str + start, end - start + 1);
|
return strndup_p (str + start, end - start + 1);
|
||||||
}
|
|
||||||
|
|
||||||
static inline int bml_valid (char c)
|
|
||||||
{
|
|
||||||
return (isalnum (c) || c == '-');
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int islf(char c)
|
|
||||||
{
|
|
||||||
return (c == '\r' || c == '\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int bml_read_depth (char *data)
|
static inline unsigned int bml_read_depth (char *data)
|
||||||
|
@ -77,7 +105,7 @@ static void bml_parse_data (bml_node *node, char **data)
|
||||||
if (p[len] != '\"')
|
if (p[len] != '\"')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
node->data = strndup (p + 2, len - 2);
|
node->data = strndup_p (p + 2, len - 2);
|
||||||
*data += len + 1;
|
*data += len + 1;
|
||||||
}
|
}
|
||||||
else if (*p == '=')
|
else if (*p == '=')
|
||||||
|
|
1
cheats.h
1
cheats.h
|
@ -272,6 +272,7 @@ void S9xUpdateCheatsInMemory (void);
|
||||||
bool8 S9xImportCheatsFromDatabase (const char *filename);
|
bool8 S9xImportCheatsFromDatabase (const char *filename);
|
||||||
void S9xCheatsDisable (void);
|
void S9xCheatsDisable (void);
|
||||||
void S9xCheatsEnable (void);
|
void S9xCheatsEnable (void);
|
||||||
|
char *S9xCheatValidate (char *cheat);
|
||||||
|
|
||||||
void S9xInitCheatData (void);
|
void S9xInitCheatData (void);
|
||||||
void S9xInitWatchedAddress (void);
|
void S9xInitWatchedAddress (void);
|
||||||
|
|
52
cheats2.cpp
52
cheats2.cpp
|
@ -613,6 +613,9 @@ int S9xAddCheatGroup (const char *name, const char *cheat)
|
||||||
|
|
||||||
int S9xModifyCheatGroup (uint32 num, const char *name, const char *cheat)
|
int S9xModifyCheatGroup (uint32 num, const char *name, const char *cheat)
|
||||||
{
|
{
|
||||||
|
if (num >= Cheat.g.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
S9xDisableCheatGroup (num);
|
S9xDisableCheatGroup (num);
|
||||||
delete[] Cheat.g[num].name;
|
delete[] Cheat.g[num].name;
|
||||||
|
|
||||||
|
@ -639,21 +642,46 @@ char *S9xCheatToText (SCheat *c)
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *S9xCheatGroupToText(SCheatGroup *g)
|
||||||
|
{
|
||||||
|
std::string text = "";
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
if (g->c.size() == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < g->c.size(); i++)
|
||||||
|
{
|
||||||
|
char *tmp = S9xCheatToText(&g->c[i]);
|
||||||
|
if (i != 0)
|
||||||
|
text += '+';
|
||||||
|
text += tmp;
|
||||||
|
delete[] tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strdup(text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
char *S9xCheatValidate(char *code_string)
|
||||||
|
{
|
||||||
|
SCheatGroup g = S9xCreateCheatGroup ("temp", code_string);
|
||||||
|
|
||||||
|
delete[] g.name;
|
||||||
|
|
||||||
|
if (g.c.size() > 0)
|
||||||
|
{
|
||||||
|
return S9xCheatGroupToText(&g);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char *S9xCheatGroupToText (uint32 num)
|
char *S9xCheatGroupToText (uint32 num)
|
||||||
{
|
{
|
||||||
std::string text = "";
|
if (num >= Cheat.g.size())
|
||||||
unsigned int i;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < Cheat.g[num].c.size (); i++)
|
return S9xCheatGroupToText(&Cheat.g[num]);
|
||||||
{
|
|
||||||
char *tmp = S9xCheatToText (&Cheat.g[num].c[i]);
|
|
||||||
if (i != 0)
|
|
||||||
text += '+';
|
|
||||||
text += tmp;
|
|
||||||
delete[] tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return strdup (text.c_str ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void S9xUpdateCheatsInMemory (void)
|
void S9xUpdateCheatsInMemory (void)
|
||||||
|
|
|
@ -1787,6 +1787,8 @@ bool8 CMemory::LoadROMInt (int32 ROMfillSize)
|
||||||
|
|
||||||
S9xReset();
|
S9xReset();
|
||||||
|
|
||||||
|
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1951,6 +1953,7 @@ bool8 CMemory::LoadMultiCartInt ()
|
||||||
S9xReset();
|
S9xReset();
|
||||||
|
|
||||||
S9xInitCheatData();
|
S9xInitCheatData();
|
||||||
|
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ BEGIN
|
||||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,168,131,10
|
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,168,131,10
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_CHEATER DIALOGEX 0, 0, 262, 218
|
IDD_CHEATER DIALOGEX 0, 0, 262, 194
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Cheat Entry and Editor"
|
CAPTION "Cheat Entry and Editor"
|
||||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||||
|
@ -258,14 +258,10 @@ BEGIN
|
||||||
PUSHBUTTON "C&lear",IDC_CLEAR_CHEATS,215,65,40,15
|
PUSHBUTTON "C&lear",IDC_CLEAR_CHEATS,215,65,40,15
|
||||||
EDITTEXT IDC_CHEAT_CODE,86,134,118,15,ES_UPPERCASE | ES_AUTOHSCROLL
|
EDITTEXT IDC_CHEAT_CODE,86,134,118,15,ES_UPPERCASE | ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_CHEAT_DESCRIPTION,85,154,119,15,ES_AUTOHSCROLL
|
EDITTEXT IDC_CHEAT_DESCRIPTION,85,154,119,15,ES_AUTOHSCROLL
|
||||||
EDITTEXT IDC_CHEAT_ADDRESS,85,175,44,15,ES_UPPERCASE | ES_AUTOHSCROLL
|
PUSHBUTTON "&OK",IDOK,99,174,50,15
|
||||||
EDITTEXT IDC_CHEAT_BYTE,215,175,26,15,ES_UPPERCASE | ES_AUTOHSCROLL
|
PUSHBUTTON "&Cancel",IDCANCEL,154,174,50,15
|
||||||
PUSHBUTTON "&OK",IDOK,93,196,50,15
|
|
||||||
PUSHBUTTON "&Cancel",IDCANCEL,151,196,50,15
|
|
||||||
RTEXT "Enter Cheat Code:",IDC_LABEL_CHEAT_CODE,23,134,59,15,SS_CENTERIMAGE
|
RTEXT "Enter Cheat Code:",IDC_LABEL_CHEAT_CODE,23,134,59,15,SS_CENTERIMAGE
|
||||||
RTEXT "Cheat Description",IDC_LABEL_CHEAT_DESCRIPTION,19,154,61,15,SS_CENTERIMAGE
|
RTEXT "Cheat Description",IDC_LABEL_CHEAT_DESCRIPTION,19,154,61,15,SS_CENTERIMAGE
|
||||||
RTEXT "Cheat Address (hex)",IDC_LABEL_CHEAT_ADDRESS,18,175,64,15,SS_CENTERIMAGE
|
|
||||||
RTEXT "New Value (dec or hex)",IDC_LABEL_CHEAT_BYTE,134,175,74,15,SS_CENTERIMAGE
|
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_NETPLAYPROGRESS DIALOG 0, 0, 186, 61
|
IDD_NETPLAYPROGRESS DIALOG 0, 0, 186, 61
|
||||||
|
|
|
@ -389,6 +389,7 @@
|
||||||
<ClInclude Include="..\msu1.h" />
|
<ClInclude Include="..\msu1.h" />
|
||||||
<ClInclude Include="..\statemanager.h" />
|
<ClInclude Include="..\statemanager.h" />
|
||||||
<ClInclude Include="..\sha256.h" />
|
<ClInclude Include="..\sha256.h" />
|
||||||
|
<ClInclude Include="..\bml.h" />
|
||||||
<CustomBuild Include="..\stream.h" />
|
<CustomBuild Include="..\stream.h" />
|
||||||
<CustomBuild Include="..\tile.h" />
|
<CustomBuild Include="..\tile.h" />
|
||||||
<ClInclude Include="..\unzip\crypt.h" />
|
<ClInclude Include="..\unzip\crypt.h" />
|
||||||
|
@ -519,6 +520,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\statemanager.cpp" />
|
<ClCompile Include="..\statemanager.cpp" />
|
||||||
<ClCompile Include="..\sha256.cpp" />
|
<ClCompile Include="..\sha256.cpp" />
|
||||||
|
<ClCompile Include="..\bml.cpp" />
|
||||||
<ClCompile Include="..\stream.cpp" />
|
<ClCompile Include="..\stream.cpp" />
|
||||||
<ClCompile Include="..\tile.cpp" />
|
<ClCompile Include="..\tile.cpp" />
|
||||||
<ClCompile Include="..\unzip\ioapi.c" />
|
<ClCompile Include="..\unzip\ioapi.c" />
|
||||||
|
|
|
@ -51,6 +51,9 @@
|
||||||
<ClInclude Include="..\sha256.h">
|
<ClInclude Include="..\sha256.h">
|
||||||
<Filter>Emu</Filter>
|
<Filter>Emu</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\bml.h">
|
||||||
|
<Filter>Emu</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\unzip\crypt.h">
|
<ClInclude Include="..\unzip\crypt.h">
|
||||||
<Filter>UnZip</Filter>
|
<Filter>UnZip</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -404,6 +407,9 @@
|
||||||
<ClCompile Include="..\sha256.cpp">
|
<ClCompile Include="..\sha256.cpp">
|
||||||
<Filter>Emu</Filter>
|
<Filter>Emu</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\bml.cpp">
|
||||||
|
<Filter>Emu</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\stream.cpp">
|
<ClCompile Include="..\stream.cpp">
|
||||||
<Filter>Emu</Filter>
|
<Filter>Emu</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -546,6 +546,7 @@ Nintendo is a trade mark.")
|
||||||
the current value. This value is used when a cheat is unapplied.\n\
|
the current value. This value is used when a cheat is unapplied.\n\
|
||||||
(If left blank, no value is restored when the cheat is unapplied)")
|
(If left blank, no value is restored when the cheat is unapplied)")
|
||||||
#define SEARCH_ERR_INVALIDSEARCHVALUE TEXT("Please enter a valid value for a search!")
|
#define SEARCH_ERR_INVALIDSEARCHVALUE TEXT("Please enter a valid value for a search!")
|
||||||
|
#define SEARCH_COLUMN_CODE TEXT("Code")
|
||||||
#define SEARCH_COLUMN_ADDRESS TEXT("Address")
|
#define SEARCH_COLUMN_ADDRESS TEXT("Address")
|
||||||
#define SEARCH_COLUMN_VALUE TEXT("Value")
|
#define SEARCH_COLUMN_VALUE TEXT("Value")
|
||||||
#define SEARCH_COLUMN_DESCRIPTION TEXT("Description")
|
#define SEARCH_COLUMN_DESCRIPTION TEXT("Description")
|
||||||
|
|
|
@ -231,6 +231,7 @@
|
||||||
#include "AVIOutput.h"
|
#include "AVIOutput.h"
|
||||||
#include "InputCustom.h"
|
#include "InputCustom.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#if (((defined(_MSC_VER) && _MSC_VER >= 1300)) || defined(__MINGW32__))
|
#if (((defined(_MSC_VER) && _MSC_VER >= 1300)) || defined(__MINGW32__))
|
||||||
// both MINGW and VS.NET use fstream instead of fstream.h which is deprecated
|
// both MINGW and VS.NET use fstream instead of fstream.h which is deprecated
|
||||||
|
@ -2305,10 +2306,10 @@ LRESULT CALLBACK WinProc(
|
||||||
break;
|
break;
|
||||||
case ID_CHEAT_ENTER:
|
case ID_CHEAT_ENTER:
|
||||||
RestoreGUIDisplay ();
|
RestoreGUIDisplay ();
|
||||||
S9xRemoveCheats ();
|
S9xCheatsDisable ();
|
||||||
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEATER), hWnd, DlgCheater);
|
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEATER), hWnd, DlgCheater);
|
||||||
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
|
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
|
||||||
S9xApplyCheats ();
|
S9xCheatsEnable ();
|
||||||
RestoreSNESDisplay ();
|
RestoreSNESDisplay ();
|
||||||
break;
|
break;
|
||||||
case ID_CHEAT_SEARCH:
|
case ID_CHEAT_SEARCH:
|
||||||
|
@ -2333,14 +2334,14 @@ LRESULT CALLBACK WinProc(
|
||||||
case ID_CHEAT_APPLY:
|
case ID_CHEAT_APPLY:
|
||||||
Settings.ApplyCheats = !Settings.ApplyCheats;
|
Settings.ApplyCheats = !Settings.ApplyCheats;
|
||||||
if (!Settings.ApplyCheats){
|
if (!Settings.ApplyCheats){
|
||||||
S9xRemoveCheats ();
|
S9xCheatsDisable ();
|
||||||
S9xMessage (S9X_INFO, S9X_GAME_GENIE_CODE_ERROR, CHEATS_INFO_DISABLED);
|
S9xMessage (S9X_INFO, S9X_GAME_GENIE_CODE_ERROR, CHEATS_INFO_DISABLED);
|
||||||
}else{
|
}else{
|
||||||
S9xApplyCheats ();
|
S9xCheatsEnable ();
|
||||||
bool on = false;
|
bool on = false;
|
||||||
extern struct SCheatData Cheat;
|
extern struct SCheatData Cheat;
|
||||||
for (uint32 i = 0; i < Cheat.num_cheats && !on; i++)
|
for (uint32 i = 0; i < Cheat.g.size() && !on; i++)
|
||||||
if (Cheat.c [i].enabled)
|
if (Cheat.g [i].enabled)
|
||||||
on = true;
|
on = true;
|
||||||
S9xMessage (S9X_INFO, S9X_GAME_GENIE_CODE_ERROR, on ? CHEATS_INFO_ENABLED : CHEATS_INFO_ENABLED_NONE);
|
S9xMessage (S9X_INFO, S9X_GAME_GENIE_CODE_ERROR, on ? CHEATS_INFO_ENABLED : CHEATS_INFO_ENABLED_NONE);
|
||||||
}
|
}
|
||||||
|
@ -4061,8 +4062,10 @@ static bool LoadROMPlain(const TCHAR *filename)
|
||||||
if (Memory.LoadROM (_tToChar(filename)))
|
if (Memory.LoadROM (_tToChar(filename)))
|
||||||
{
|
{
|
||||||
S9xStartCheatSearch (&Cheat);
|
S9xStartCheatSearch (&Cheat);
|
||||||
|
if (Settings.ApplyCheats)
|
||||||
|
S9xCheatsEnable();
|
||||||
ReInitSound();
|
ReInitSound();
|
||||||
ResetFrameTimer ();
|
ResetFrameTimer();
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
@ -4074,6 +4077,8 @@ static bool LoadROMMulti(const TCHAR *filename, const TCHAR *filename2)
|
||||||
if (Memory.LoadMultiCart(_tToChar(filename), _tToChar(filename2)))
|
if (Memory.LoadMultiCart(_tToChar(filename), _tToChar(filename2)))
|
||||||
{
|
{
|
||||||
S9xStartCheatSearch(&Cheat);
|
S9xStartCheatSearch(&Cheat);
|
||||||
|
if (Settings.ApplyCheats)
|
||||||
|
S9xCheatsEnable();
|
||||||
ReInitSound();
|
ReInitSound();
|
||||||
ResetFrameTimer();
|
ResetFrameTimer();
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
|
@ -8490,6 +8495,7 @@ DWORD* state;
|
||||||
a.pszText=d; \
|
a.pszText=d; \
|
||||||
a.cchTextMax=e; \
|
a.cchTextMax=e; \
|
||||||
ListView_GetItem(GetDlgItem(hDlg, b), &a);
|
ListView_GetItem(GetDlgItem(hDlg, b), &a);
|
||||||
|
#define CHEAT_SIZE 1024
|
||||||
|
|
||||||
INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -8505,64 +8511,52 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_CHEAT_LIST), LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES);
|
ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_CHEAT_LIST), LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES);
|
||||||
|
|
||||||
SendDlgItemMessage(hDlg, IDC_CHEAT_CODE, EM_LIMITTEXT, 14, 0);
|
SendDlgItemMessage(hDlg, IDC_CHEAT_CODE, EM_LIMITTEXT, CHEAT_SIZE, 0);
|
||||||
SendDlgItemMessage(hDlg, IDC_CHEAT_DESCRIPTION, EM_LIMITTEXT, 22, 0);
|
SendDlgItemMessage(hDlg, IDC_CHEAT_DESCRIPTION, EM_LIMITTEXT, CHEAT_SIZE, 0);
|
||||||
SendDlgItemMessage(hDlg, IDC_CHEAT_ADDRESS, EM_LIMITTEXT, 6, 0);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_CHEAT_BYTE, EM_LIMITTEXT, 3, 0);
|
|
||||||
|
|
||||||
LVCOLUMN col;
|
LVCOLUMN col;
|
||||||
TCHAR temp[32];
|
TCHAR temp[32];
|
||||||
lstrcpy(temp,SEARCH_COLUMN_ADDRESS);
|
lstrcpy(temp, SEARCH_COLUMN_CODE);
|
||||||
memset(&col, 0, sizeof(LVCOLUMN));
|
memset(&col, 0, sizeof(LVCOLUMN));
|
||||||
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH;
|
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH;
|
||||||
col.fmt=LVCFMT_LEFT;
|
col.fmt=LVCFMT_LEFT;
|
||||||
col.iOrder=0;
|
col.iOrder=0;
|
||||||
col.cx=70;
|
col.cx=70;
|
||||||
col.cchTextMax=7;
|
|
||||||
col.pszText=temp;
|
col.pszText=temp;
|
||||||
|
|
||||||
ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 0, &col);
|
ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 0, &col);
|
||||||
|
|
||||||
lstrcpy(temp,SEARCH_COLUMN_VALUE);
|
|
||||||
memset(&col, 0, sizeof(LVCOLUMN));
|
|
||||||
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
|
|
||||||
col.fmt=LVCFMT_LEFT;
|
|
||||||
col.iOrder=1;
|
|
||||||
col.cx=43;
|
|
||||||
col.cchTextMax=3;
|
|
||||||
col.pszText=temp;
|
|
||||||
col.iSubItem=1;
|
|
||||||
|
|
||||||
ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 1, &col);
|
|
||||||
|
|
||||||
lstrcpy(temp,SEARCH_COLUMN_DESCRIPTION);
|
lstrcpy(temp,SEARCH_COLUMN_DESCRIPTION);
|
||||||
memset(&col, 0, sizeof(LVCOLUMN));
|
memset(&col, 0, sizeof(LVCOLUMN));
|
||||||
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
|
col.mask=LVCF_FMT|LVCF_ORDER|LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
|
||||||
col.fmt=LVCFMT_LEFT;
|
col.fmt=LVCFMT_LEFT;
|
||||||
col.iOrder=2;
|
col.iOrder=2;
|
||||||
col.cx=165;
|
col.cx=165;
|
||||||
col.cchTextMax=32;
|
|
||||||
col.pszText=temp;
|
col.pszText=temp;
|
||||||
col.iSubItem=2;
|
col.iSubItem=2;
|
||||||
|
|
||||||
ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 2, &col);
|
ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 1, &col);
|
||||||
|
|
||||||
ct.index=new int[Cheat.num_cheats];
|
ct.index=new int[Cheat.g.size()];
|
||||||
ct.state=new DWORD[Cheat.num_cheats];
|
ct.state=new DWORD[Cheat.g.size()];
|
||||||
|
|
||||||
uint32 counter;
|
uint32 counter;
|
||||||
for(counter=0; counter<Cheat.num_cheats; counter++)
|
for(counter=0; counter < Cheat.g.size(); counter++)
|
||||||
{
|
{
|
||||||
TCHAR buffer[22];
|
char *code_string;
|
||||||
|
Utf8ToWide *wstring;
|
||||||
int curr_idx=-1;
|
int curr_idx=-1;
|
||||||
_stprintf(buffer, TEXT("%06X"), Cheat.c[counter].address);
|
code_string = S9xCheatGroupToText(counter);
|
||||||
|
wstring = new Utf8ToWide(code_string);
|
||||||
LVITEM lvi;
|
LVITEM lvi;
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
memset(&lvi, 0, sizeof(LVITEM));
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=buffer;
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
lvi.cchTextMax=7;
|
lvi.pszText = *wstring;
|
||||||
lvi.iItem=counter;
|
lvi.iItem=counter;
|
||||||
curr_idx=ListView_InsertItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
curr_idx=ListView_InsertItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
||||||
|
delete[] code_string;
|
||||||
|
delete wstring;
|
||||||
|
|
||||||
unsigned int k;
|
unsigned int k;
|
||||||
for(k=0;k<counter;k++)
|
for(k=0;k<counter;k++)
|
||||||
|
@ -8573,25 +8567,17 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
ct.index[counter]=curr_idx;
|
ct.index[counter]=curr_idx;
|
||||||
ct.state[counter]=Untouched;
|
ct.state[counter]=Untouched;
|
||||||
|
|
||||||
_stprintf(buffer, TEXT("%02X"), Cheat.c[counter].byte);
|
wstring = new Utf8ToWide(Cheat.g[counter].name);
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
memset(&lvi, 0, sizeof(LVITEM));
|
||||||
lvi.iItem=curr_idx;
|
lvi.iItem=curr_idx;
|
||||||
lvi.iSubItem=1;
|
lvi.iSubItem=1;
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=buffer;
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
lvi.cchTextMax=3;
|
lvi.pszText = *wstring;
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
||||||
|
delete wstring;
|
||||||
|
|
||||||
lstrcpy(buffer,_tFromChar(Cheat.c[counter].name));
|
ListView_SetCheckState(GetDlgItem(hDlg,IDC_CHEAT_LIST), curr_idx, Cheat.g[counter].enabled);
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.iItem=curr_idx;
|
|
||||||
lvi.iSubItem=2;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buffer;
|
|
||||||
lvi.cchTextMax=23;
|
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
|
||||||
|
|
||||||
ListView_SetCheckState(GetDlgItem(hDlg,IDC_CHEAT_LIST), curr_idx, Cheat.c[counter].enabled);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -8622,27 +8608,18 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
new_sel=3;
|
new_sel=3;
|
||||||
//change
|
//change
|
||||||
TCHAR buf[25];
|
TCHAR buf[CHEAT_SIZE];
|
||||||
LV_ITEM lvi;
|
LV_ITEM lvi;
|
||||||
|
|
||||||
ITEM_QUERY (lvi, IDC_CHEAT_LIST, 0, buf, 7);
|
/* Code */
|
||||||
|
ITEM_QUERY (lvi, IDC_CHEAT_LIST, 0, buf, CHEAT_SIZE);
|
||||||
|
SetDlgItemText(hDlg, IDC_CHEAT_CODE, lvi.pszText);
|
||||||
|
|
||||||
SetDlgItemText(hDlg, IDC_CHEAT_ADDRESS, lvi.pszText);
|
/* Description */
|
||||||
|
ITEM_QUERY(lvi, IDC_CHEAT_LIST, 1, buf, CHEAT_SIZE);
|
||||||
ITEM_QUERY (lvi, IDC_CHEAT_LIST, 1, &buf[lstrlen(buf)], 3);
|
|
||||||
|
|
||||||
SetDlgItemText(hDlg, IDC_CHEAT_CODE, buf);
|
|
||||||
TCHAR temp[4];
|
|
||||||
int q;
|
|
||||||
_stscanf(lvi.pszText, TEXT("%02X"), &q);
|
|
||||||
_stprintf(temp, TEXT("%d"), q);
|
|
||||||
SetDlgItemText(hDlg, IDC_CHEAT_BYTE, temp);
|
|
||||||
|
|
||||||
ITEM_QUERY (lvi, IDC_CHEAT_LIST, 2, buf, 24);
|
|
||||||
|
|
||||||
internal_change=true;
|
|
||||||
SetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, lvi.pszText);
|
SetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, lvi.pszText);
|
||||||
|
|
||||||
|
internal_change = true;
|
||||||
}
|
}
|
||||||
sel_idx=ListView_GetSelectionMark(GetDlgItem(hDlg, IDC_CHEAT_LIST));
|
sel_idx=ListView_GetSelectionMark(GetDlgItem(hDlg, IDC_CHEAT_LIST));
|
||||||
has_sel=true;
|
has_sel=true;
|
||||||
|
@ -8677,249 +8654,92 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
case IDC_ADD_CHEAT:
|
case IDC_ADD_CHEAT:
|
||||||
{
|
{
|
||||||
char temp[24];
|
char temp[CHEAT_SIZE];
|
||||||
TCHAR tempDesc[24];
|
TCHAR tempDesc[CHEAT_SIZE];
|
||||||
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, temp, 23);
|
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, temp, CHEAT_SIZE);
|
||||||
if(strcmp(temp, ""))
|
GetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, tempDesc, CHEAT_SIZE);
|
||||||
|
|
||||||
|
char *valid_cheat = S9xCheatValidate (temp);
|
||||||
|
|
||||||
|
if(valid_cheat)
|
||||||
{
|
{
|
||||||
int j;
|
Utf8ToWide *wstring;
|
||||||
bool skip=false;
|
|
||||||
int count=1;
|
|
||||||
uint32 addy;
|
|
||||||
uint8 byte[3];
|
|
||||||
//test game genie
|
|
||||||
if (NULL==S9xGameGenieToRaw (temp, addy, byte[0]))
|
|
||||||
skip=true;
|
|
||||||
//test goldfinger
|
|
||||||
|
|
||||||
// if(!skip
|
wstring = new Utf8ToWide(valid_cheat);
|
||||||
|
|
||||||
//test PAR
|
delete[] valid_cheat;
|
||||||
|
|
||||||
if(!skip)
|
|
||||||
{
|
|
||||||
if(NULL==S9xProActionReplayToRaw(temp, addy, byte[0]))
|
|
||||||
skip=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!skip)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for(j=0; j<count; j++)
|
|
||||||
{
|
|
||||||
TCHAR buffer[7];
|
|
||||||
int curr_idx=-1;
|
|
||||||
_stprintf(buffer, TEXT("%06X"), addy);
|
|
||||||
LVITEM lvi;
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buffer;
|
|
||||||
lvi.cchTextMax=6;
|
|
||||||
lvi.iItem=ListView_GetItemCount(GetDlgItem(hDlg,IDC_CHEAT_LIST));
|
|
||||||
curr_idx=ListView_InsertItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
|
||||||
|
|
||||||
unsigned int k;
|
|
||||||
for(k=0;k<Cheat.num_cheats;k++)
|
|
||||||
{
|
|
||||||
if(ct.index[k]>=curr_idx)
|
|
||||||
ct.index[k]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_stprintf(buffer, TEXT("%02X"), byte[j]);
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.iItem=curr_idx;
|
|
||||||
lvi.iSubItem=1;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buffer;
|
|
||||||
lvi.cchTextMax=2;
|
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
|
||||||
|
|
||||||
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, tempDesc, 23);
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.iItem=curr_idx;
|
|
||||||
lvi.iSubItem=2;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=tempDesc;
|
|
||||||
lvi.cchTextMax=23;
|
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
|
||||||
|
|
||||||
addy++;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint8 byte;
|
|
||||||
TCHAR buffer[7];
|
|
||||||
TCHAR buffer2[7];
|
|
||||||
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_ADDRESS, buffer, 7);
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_BYTE, buffer2, 7);
|
|
||||||
|
|
||||||
int curr_idx=-1;
|
int curr_idx=-1;
|
||||||
|
|
||||||
LVITEM lvi;
|
LVITEM lvi;
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
memset(&lvi, 0, sizeof(LVITEM));
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=buffer;
|
lvi.pszText=*wstring;
|
||||||
lvi.cchTextMax=6;
|
lvi.iItem=ListView_GetItemCount(GetDlgItem(hDlg,IDC_CHEAT_LIST));
|
||||||
lvi.iItem=0;
|
|
||||||
curr_idx=ListView_InsertItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
curr_idx=ListView_InsertItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
||||||
|
|
||||||
int scanres;
|
SetDlgItemText(hDlg, IDC_CHEAT_CODE, *wstring);
|
||||||
if(buffer2[0]=='$')
|
|
||||||
_stscanf(buffer2,TEXT("$%2X"), (unsigned int*)&scanres);
|
|
||||||
else _stscanf(buffer2,TEXT("%d"), &scanres);
|
|
||||||
byte = (uint8)(scanres & 0xff);
|
|
||||||
|
|
||||||
_stprintf(buffer2, TEXT("%02X"), byte);
|
unsigned int k;
|
||||||
|
for(k=0;k<Cheat.g.size();k++)
|
||||||
|
{
|
||||||
|
if(ct.index[k]>=curr_idx)
|
||||||
|
ct.index[k]++;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
memset(&lvi, 0, sizeof(LVITEM));
|
||||||
lvi.iItem=curr_idx;
|
lvi.iItem=curr_idx;
|
||||||
lvi.iSubItem=1;
|
lvi.iSubItem=1;
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=buffer2;
|
|
||||||
lvi.cchTextMax=2;
|
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
|
||||||
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, tempDesc, 23);
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.iItem=curr_idx;
|
|
||||||
lvi.iSubItem=2;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=tempDesc;
|
lvi.pszText=tempDesc;
|
||||||
lvi.cchTextMax=23;
|
lvi.cchTextMax=CHEAT_SIZE;
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
||||||
|
|
||||||
|
delete wstring;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDC_UPDATE_CHEAT:
|
case IDC_UPDATE_CHEAT:
|
||||||
{
|
{
|
||||||
TCHAR temp[24];
|
unsigned int j;
|
||||||
char code[24];
|
TCHAR temp[CHEAT_SIZE];
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_CODE, temp, 23);
|
char code[CHEAT_SIZE];
|
||||||
strcpy(code,_tToChar(temp));
|
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, code, CHEAT_SIZE);
|
||||||
if(strcmp(code, ""))
|
|
||||||
|
char *valid_cheat = S9xCheatValidate(code);
|
||||||
|
|
||||||
|
if(valid_cheat)
|
||||||
{
|
{
|
||||||
int j;
|
Utf8ToWide *wstring;
|
||||||
bool skip=false;
|
|
||||||
int count=1;
|
|
||||||
uint32 addy;
|
|
||||||
uint8 byte[3];
|
|
||||||
//test game genie
|
|
||||||
if (NULL==S9xGameGenieToRaw (code, addy, byte[0]))
|
|
||||||
skip=true;
|
|
||||||
//test goldfinger
|
|
||||||
|
|
||||||
// if(!skip
|
for(j=0;j<(int)Cheat.g.size();j++)
|
||||||
|
|
||||||
//test PAR
|
|
||||||
|
|
||||||
if(!skip)
|
|
||||||
{
|
|
||||||
if(NULL==S9xProActionReplayToRaw(code, addy, byte[0]))
|
|
||||||
skip=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!skip)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for(j=0;j<(int)Cheat.num_cheats;j++)
|
|
||||||
{
|
{
|
||||||
if(ct.index[j]==sel_idx)
|
if(ct.index[j]==sel_idx)
|
||||||
ct.state[j]=Modified;
|
ct.state[j]=Modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j=0; j<count; j++)
|
wstring = new Utf8ToWide(code);
|
||||||
{
|
|
||||||
TCHAR buffer[7];
|
|
||||||
// int curr_idx=-1;
|
|
||||||
_stprintf(buffer, TEXT("%06X"), addy);
|
|
||||||
LVITEM lvi;
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buffer;
|
|
||||||
lvi.cchTextMax=6;
|
|
||||||
lvi.iItem=sel_idx;
|
|
||||||
ListView_SetItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
|
||||||
|
|
||||||
_stprintf(buffer, TEXT("%02X"), byte[j]);
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.iItem=sel_idx;
|
|
||||||
lvi.iSubItem=1;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buffer;
|
|
||||||
lvi.cchTextMax=2;
|
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
|
||||||
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, temp, 23);
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.iItem=sel_idx;
|
|
||||||
lvi.iSubItem=2;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=temp;
|
|
||||||
lvi.cchTextMax=23;
|
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
|
||||||
|
|
||||||
addy++;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint8 byte;
|
|
||||||
TCHAR buffer[7];
|
|
||||||
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_ADDRESS, buffer, 7);
|
|
||||||
int j;
|
|
||||||
for(j=0;j<(int)Cheat.num_cheats;j++)
|
|
||||||
{
|
|
||||||
if(ct.index[j]==sel_idx)
|
|
||||||
ct.state[j]=Modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int curr_idx=-1;
|
|
||||||
LVITEM lvi;
|
LVITEM lvi;
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
memset(&lvi, 0, sizeof(LVITEM));
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=buffer;
|
lvi.pszText=*wstring;
|
||||||
lvi.cchTextMax=6;
|
|
||||||
lvi.iItem=sel_idx;
|
lvi.iItem=sel_idx;
|
||||||
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
ListView_SetItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
ListView_SetItem(GetDlgItem(hDlg,IDC_CHEAT_LIST), &lvi);
|
||||||
|
SetDlgItemText(hDlg, IDC_CHEAT_CODE, *wstring);
|
||||||
|
|
||||||
|
delete wstring;
|
||||||
|
delete[] valid_cheat;
|
||||||
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_BYTE, buffer, 7);
|
GetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, temp, CHEAT_SIZE);
|
||||||
|
|
||||||
int scanres;
|
|
||||||
if(buffer[0]==TEXT('$'))
|
|
||||||
_stscanf(buffer,TEXT("$%2X"), (unsigned int*)&scanres);
|
|
||||||
else _stscanf(buffer,TEXT("%d"), &scanres);
|
|
||||||
byte = (uint8)(scanres & 0xff);
|
|
||||||
|
|
||||||
_stprintf(buffer, TEXT("%02X"), byte);
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
memset(&lvi, 0, sizeof(LVITEM));
|
||||||
lvi.iItem=sel_idx;
|
lvi.iItem=sel_idx;
|
||||||
lvi.iSubItem=1;
|
lvi.iSubItem = 1;
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buffer;
|
|
||||||
lvi.cchTextMax=2;
|
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
|
||||||
|
|
||||||
GetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, temp, 23);
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LVITEM));
|
|
||||||
lvi.iItem=sel_idx;
|
|
||||||
lvi.iSubItem=2;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=temp;
|
lvi.pszText=temp;
|
||||||
lvi.cchTextMax=23;
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8928,16 +8748,16 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
case IDC_DELETE_CHEAT:
|
case IDC_DELETE_CHEAT:
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
for(j=0;j<Cheat.num_cheats;j++)
|
for(j=0;j<Cheat.g.size();j++)
|
||||||
{
|
{
|
||||||
if(ct.index[j]==sel_idx)
|
if(ct.index[j]==sel_idx)
|
||||||
ct.state[j]=Deleted;
|
ct.state[j]=Deleted;
|
||||||
}
|
}
|
||||||
for(j=0;j<Cheat.num_cheats;j++)
|
for(j=0;j<Cheat.g.size();j++)
|
||||||
{
|
{
|
||||||
if(ct.index[j]>sel_idx)
|
if(ct.index[j]>sel_idx)
|
||||||
ct.index[j]--;
|
ct.index[j]--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListView_DeleteItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), sel_idx);
|
ListView_DeleteItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), sel_idx);
|
||||||
|
|
||||||
|
@ -8945,8 +8765,6 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
case IDC_CLEAR_CHEATS:
|
case IDC_CLEAR_CHEATS:
|
||||||
internal_change = true;
|
internal_change = true;
|
||||||
SetDlgItemText(hDlg,IDC_CHEAT_CODE,TEXT(""));
|
SetDlgItemText(hDlg,IDC_CHEAT_CODE,TEXT(""));
|
||||||
SetDlgItemText(hDlg,IDC_CHEAT_ADDRESS,TEXT(""));
|
|
||||||
SetDlgItemText(hDlg,IDC_CHEAT_BYTE,TEXT(""));
|
|
||||||
SetDlgItemText(hDlg,IDC_CHEAT_DESCRIPTION,TEXT(""));
|
SetDlgItemText(hDlg,IDC_CHEAT_DESCRIPTION,TEXT(""));
|
||||||
ListView_SetItemState(GetDlgItem(hDlg, IDC_CHEAT_LIST),sel_idx, 0, LVIS_SELECTED|LVIS_FOCUSED);
|
ListView_SetItemState(GetDlgItem(hDlg, IDC_CHEAT_LIST),sel_idx, 0, LVIS_SELECTED|LVIS_FOCUSED);
|
||||||
ListView_SetSelectionMark(GetDlgItem(hDlg, IDC_CHEAT_LIST), -1);
|
ListView_SetSelectionMark(GetDlgItem(hDlg, IDC_CHEAT_LIST), -1);
|
||||||
|
@ -8963,52 +8781,18 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
switch(HIWORD(wParam))
|
switch(HIWORD(wParam))
|
||||||
{
|
{
|
||||||
case EN_CHANGE:
|
case EN_CHANGE:
|
||||||
if(internal_change)
|
|
||||||
|
char temp[CHEAT_SIZE];
|
||||||
|
char *valid_cheat = NULL;
|
||||||
|
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, temp, CHEAT_SIZE);
|
||||||
|
|
||||||
|
if (temp && temp[0] && (valid_cheat = S9xCheatValidate(temp)))
|
||||||
{
|
{
|
||||||
internal_change=false;
|
if (has_sel)
|
||||||
return true;
|
|
||||||
}
|
|
||||||
SendMessageA((HWND)lParam, WM_GETTEXT, 15,(LPARAM)buffer);
|
|
||||||
GetCaretPos(&point);
|
|
||||||
|
|
||||||
index = SendMessageA((HWND)lParam,(UINT) EM_CHARFROMPOS, 0, (LPARAM) ((point.x&0x0000FFFF) | (((point.y&0x0000FFFF))<<16)));
|
|
||||||
|
|
||||||
k=0;
|
|
||||||
for(j=0; j<strlen(buffer);j++)
|
|
||||||
{
|
|
||||||
if( (buffer[j]>='0' && buffer[j]<='9') || (buffer[j]>='A' && buffer[j]<='F') || buffer[j]=='-' || buffer[j]=='X')
|
|
||||||
{
|
|
||||||
buffer2[k]=buffer[j];
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
else index --;
|
|
||||||
}
|
|
||||||
buffer2[k]='\0';
|
|
||||||
|
|
||||||
if(has_sel&&!new_sel&&strlen(buffer2)!=0)
|
|
||||||
{
|
|
||||||
SetDlgItemTextA(hDlg, IDC_CHEAT_ADDRESS, "");
|
|
||||||
SetDlgItemTextA(hDlg, IDC_CHEAT_BYTE, "");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(new_sel!=0)
|
|
||||||
new_sel--;
|
|
||||||
|
|
||||||
internal_change=true;
|
|
||||||
SendMessageA((HWND)lParam, WM_SETTEXT, 0,(LPARAM)buffer2);
|
|
||||||
SendMessageA((HWND)lParam, (UINT) EM_SETSEL, (WPARAM) (index), index);
|
|
||||||
|
|
||||||
uint32 addy;
|
|
||||||
uint8 val;
|
|
||||||
bool8 sram;
|
|
||||||
uint8 bytes[3];
|
|
||||||
if(NULL==S9xGameGenieToRaw(buffer2, addy, val)||NULL==S9xProActionReplayToRaw(buffer2, addy, val)||NULL==S9xGoldFingerToRaw(buffer2, addy, sram, val, bytes))
|
|
||||||
{
|
|
||||||
if(has_sel)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), true);
|
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), true);
|
||||||
else EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
else EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_ADD_CHEAT), true);
|
EnableWindow(GetDlgItem(hDlg, IDC_ADD_CHEAT), true);
|
||||||
|
delete[] valid_cheat;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -9016,130 +8800,6 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDlgItemText(hDlg, IDC_CHEAT_ADDRESS, "");
|
|
||||||
// SetDlgItemText(hDlg, IDC_CHEAT_BYTE, "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IDC_CHEAT_ADDRESS:
|
|
||||||
{
|
|
||||||
uint32 j, k;
|
|
||||||
long index;
|
|
||||||
char buffer[7];
|
|
||||||
char buffer2[7];
|
|
||||||
POINT point;
|
|
||||||
switch(HIWORD(wParam))
|
|
||||||
{
|
|
||||||
case EN_CHANGE:
|
|
||||||
if(internal_change)
|
|
||||||
{
|
|
||||||
internal_change=false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
SendMessageA((HWND)lParam, WM_GETTEXT, 7,(LPARAM)buffer);
|
|
||||||
GetCaretPos(&point);
|
|
||||||
|
|
||||||
index = SendMessageA((HWND)lParam,(UINT) EM_CHARFROMPOS, 0, (LPARAM) ((point.x&0x0000FFFF) | (((point.y&0x0000FFFF))<<16)));
|
|
||||||
|
|
||||||
k=0;
|
|
||||||
for(j=0; j<strlen(buffer);j++)
|
|
||||||
{
|
|
||||||
if( (buffer[j]>='0' && buffer[j]<='9') || (buffer[j]>='A' && buffer[j]<='F'))
|
|
||||||
{
|
|
||||||
buffer2[k]=buffer[j];
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
else index --;
|
|
||||||
}
|
|
||||||
buffer2[k]='\0';
|
|
||||||
|
|
||||||
|
|
||||||
internal_change=true;
|
|
||||||
SendMessageA((HWND)lParam, WM_SETTEXT, 0,(LPARAM)buffer2);
|
|
||||||
SendMessageA((HWND)lParam, (UINT) EM_SETSEL, (WPARAM) (index), index);
|
|
||||||
|
|
||||||
SendMessageA(GetDlgItem(hDlg, IDC_CHEAT_BYTE), WM_GETTEXT, 4,(LPARAM)buffer);
|
|
||||||
|
|
||||||
if(has_sel&&!new_sel&&0!=strlen(buffer2))
|
|
||||||
SetDlgItemTextA(hDlg, IDC_CHEAT_CODE, "");
|
|
||||||
|
|
||||||
if(new_sel!=0)
|
|
||||||
new_sel--;
|
|
||||||
|
|
||||||
if(strlen(buffer2)!=0 && strlen(buffer) !=0)
|
|
||||||
{
|
|
||||||
if(has_sel)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), true);
|
|
||||||
else EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_ADD_CHEAT), true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_ADD_CHEAT), false);
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IDC_CHEAT_BYTE:
|
|
||||||
{
|
|
||||||
uint32 j, k;
|
|
||||||
long index;
|
|
||||||
char buffer[4];
|
|
||||||
char buffer2[4];
|
|
||||||
POINT point;
|
|
||||||
switch(HIWORD(wParam))
|
|
||||||
{
|
|
||||||
case EN_CHANGE:
|
|
||||||
if(internal_change)
|
|
||||||
{
|
|
||||||
internal_change=false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
SendMessageA((HWND)lParam, WM_GETTEXT, 4,(LPARAM)buffer);
|
|
||||||
GetCaretPos(&point);
|
|
||||||
|
|
||||||
index = SendMessageA((HWND)lParam,(UINT) EM_CHARFROMPOS, 0, (LPARAM) ((point.x&0x0000FFFF) | (((point.y&0x0000FFFF))<<16)));
|
|
||||||
|
|
||||||
k=0;
|
|
||||||
for(j=0; j<strlen(buffer);j++)
|
|
||||||
{
|
|
||||||
if( (buffer[j]>='0' && buffer[j]<='9') || (buffer[j]>='A' && buffer[j]<='F') || buffer[j]=='$')
|
|
||||||
{
|
|
||||||
buffer2[k]=buffer[j];
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
else index --;
|
|
||||||
}
|
|
||||||
buffer2[k]='\0';
|
|
||||||
|
|
||||||
if(has_sel&&!new_sel&&0!=strlen(buffer2))
|
|
||||||
SetDlgItemTextA(hDlg, IDC_CHEAT_CODE, "");
|
|
||||||
|
|
||||||
if(new_sel!=0)
|
|
||||||
new_sel--;
|
|
||||||
|
|
||||||
internal_change=true;
|
|
||||||
SendMessageA((HWND)lParam, WM_SETTEXT, 0,(LPARAM)buffer2);
|
|
||||||
SendMessageA((HWND)lParam, (UINT) EM_SETSEL, (WPARAM) (index), index);
|
|
||||||
|
|
||||||
SendMessageA(GetDlgItem(hDlg, IDC_CHEAT_ADDRESS), WM_GETTEXT, 7,(LPARAM)buffer);
|
|
||||||
if(strlen(buffer2)!=0 && strlen(buffer) !=0)
|
|
||||||
{
|
|
||||||
if(has_sel)
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), true);
|
|
||||||
else EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_ADD_CHEAT), true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_ADD_CHEAT), false);
|
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
|
|
||||||
}
|
|
||||||
//SetDlgItemText(hDlg, IDC_CHEAT_CODE, "");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -9152,119 +8812,86 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
for(k=0;k<ListView_GetItemCount(GetDlgItem(hDlg, IDC_CHEAT_LIST)); k++)
|
for(k=0;k<ListView_GetItemCount(GetDlgItem(hDlg, IDC_CHEAT_LIST)); k++)
|
||||||
{
|
{
|
||||||
hit=false;
|
hit=false;
|
||||||
for(l=0;l<(int)Cheat.num_cheats;l++)
|
for(l=0;l<(int)Cheat.g.size();l++)
|
||||||
{
|
{
|
||||||
if(ct.index[l]==k)
|
if(ct.index[l]==k)
|
||||||
{
|
{
|
||||||
hit=true;
|
hit=true;
|
||||||
Cheat.c[l].enabled=ListView_GetCheckState(GetDlgItem(hDlg, IDC_CHEAT_LIST),l);
|
Cheat.g[l].enabled=ListView_GetCheckState(GetDlgItem(hDlg, IDC_CHEAT_LIST),l);
|
||||||
if(ct.state[l]==Untouched)
|
if(ct.state[l]==Untouched)
|
||||||
l=Cheat.num_cheats;
|
l=Cheat.g.size();
|
||||||
|
|
||||||
else if(ct.state[l]==(unsigned long)Modified)
|
else if(ct.state[l]==(unsigned long)Modified)
|
||||||
{
|
{
|
||||||
if(Cheat.c[l].enabled)
|
S9xDisableCheatGroup(l);
|
||||||
S9xDisableCheat(l);
|
|
||||||
//update me!
|
TCHAR wcode[CHEAT_SIZE];
|
||||||
//get these!
|
TCHAR wdescription[CHEAT_SIZE];
|
||||||
|
|
||||||
TCHAR buf[25];
|
|
||||||
LV_ITEM lvi;
|
LV_ITEM lvi;
|
||||||
memset(&lvi, 0, sizeof(LV_ITEM));
|
memset(&lvi, 0, sizeof(LV_ITEM));
|
||||||
lvi.iItem= k;
|
lvi.iItem= k;
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=buf;
|
lvi.pszText=wcode;
|
||||||
lvi.cchTextMax=7;
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
|
|
||||||
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
||||||
|
|
||||||
ScanAddress(lvi.pszText, scanned);
|
|
||||||
Cheat.c[l].address = scanned;
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LV_ITEM));
|
memset(&lvi, 0, sizeof(LV_ITEM));
|
||||||
lvi.iItem= k;
|
lvi.iItem= k;
|
||||||
lvi.iSubItem=1;
|
lvi.iSubItem=1;
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask=LVIF_TEXT;
|
||||||
lvi.pszText=buf;
|
lvi.pszText=wdescription;
|
||||||
lvi.cchTextMax=3;
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
|
|
||||||
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
||||||
|
|
||||||
|
WideToUtf8 code(wcode);
|
||||||
|
WideToUtf8 description(wdescription);
|
||||||
|
|
||||||
_stscanf(lvi.pszText, TEXT("%02X"), &scanned);
|
S9xModifyCheatGroup(l, description, code);
|
||||||
Cheat.c[l].byte = (uint8)(scanned & 0xff);
|
|
||||||
|
if (ListView_GetCheckState(GetDlgItem(hDlg, IDC_CHEAT_LIST), k))
|
||||||
memset(&lvi, 0, sizeof(LV_ITEM));
|
S9xEnableCheatGroup(l);
|
||||||
lvi.iItem= k;
|
|
||||||
lvi.iSubItem=2;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buf;
|
|
||||||
lvi.cchTextMax=24;
|
|
||||||
|
|
||||||
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
|
||||||
|
|
||||||
strcpy(Cheat.c[l].name,_tToChar(lvi.pszText));
|
|
||||||
|
|
||||||
Cheat.c[l].enabled=ListView_GetCheckState(GetDlgItem(hDlg, IDC_CHEAT_LIST),k);
|
|
||||||
|
|
||||||
if(Cheat.c[l].enabled)
|
|
||||||
S9xEnableCheat(l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!hit)
|
if(!hit)
|
||||||
{
|
{
|
||||||
uint32 address;
|
TCHAR wcode[CHEAT_SIZE];
|
||||||
uint8 byte;
|
TCHAR wdescription[CHEAT_SIZE];
|
||||||
bool8 enabled;
|
|
||||||
TCHAR buf[25];
|
|
||||||
LV_ITEM lvi;
|
LV_ITEM lvi;
|
||||||
memset(&lvi, 0, sizeof(LV_ITEM));
|
memset(&lvi, 0, sizeof(LV_ITEM));
|
||||||
lvi.iItem= k;
|
lvi.iItem = k;
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask = LVIF_TEXT;
|
||||||
lvi.pszText=buf;
|
lvi.pszText = wcode;
|
||||||
lvi.cchTextMax=7;
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
|
|
||||||
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
||||||
|
|
||||||
ScanAddress(lvi.pszText, scanned);
|
|
||||||
address = scanned;
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LV_ITEM));
|
memset(&lvi, 0, sizeof(LV_ITEM));
|
||||||
lvi.iItem= k;
|
lvi.iItem = k;
|
||||||
lvi.iSubItem=1;
|
lvi.iSubItem = 1;
|
||||||
lvi.mask=LVIF_TEXT;
|
lvi.mask = LVIF_TEXT;
|
||||||
lvi.pszText=buf;
|
lvi.pszText = wdescription;
|
||||||
lvi.cchTextMax=3;
|
lvi.cchTextMax = CHEAT_SIZE;
|
||||||
|
|
||||||
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
||||||
|
|
||||||
_stscanf(lvi.pszText, TEXT("%02X"), &scanned);
|
WideToUtf8 code(wcode);
|
||||||
byte = (uint8)(scanned & 0xff);
|
WideToUtf8 description(wdescription);
|
||||||
|
|
||||||
enabled=ListView_GetCheckState(GetDlgItem(hDlg, IDC_CHEAT_LIST),k);
|
|
||||||
|
|
||||||
S9xAddCheat(enabled,true,address,byte);
|
|
||||||
|
|
||||||
memset(&lvi, 0, sizeof(LV_ITEM));
|
|
||||||
lvi.iItem= k;
|
|
||||||
lvi.iSubItem=2;
|
|
||||||
lvi.mask=LVIF_TEXT;
|
|
||||||
lvi.pszText=buf;
|
|
||||||
lvi.cchTextMax=24;
|
|
||||||
|
|
||||||
ListView_GetItem(GetDlgItem(hDlg, IDC_CHEAT_LIST), &lvi);
|
|
||||||
|
|
||||||
strcpy(Cheat.c[Cheat.num_cheats-1].name, _tToChar(lvi.pszText));
|
|
||||||
|
|
||||||
|
int index = S9xAddCheatGroup(description, code);
|
||||||
|
|
||||||
|
if (index >= 0)
|
||||||
|
if (ListView_GetCheckState(GetDlgItem(hDlg, IDC_CHEAT_LIST), k))
|
||||||
|
S9xEnableCheatGroup(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(l=(int)Cheat.num_cheats-1;l>=0;l--)
|
for(l=(int)Cheat.g.size()-1; l>=0; l--)
|
||||||
{
|
{
|
||||||
if(ct.state[l]==Deleted)
|
if(ct.state[l]==Deleted)
|
||||||
{
|
{
|
||||||
S9xDeleteCheat(l);
|
S9xDeleteCheatGroup(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10426,12 +10053,19 @@ INT_PTR CALLBACK DlgCheatSearchAdd(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
GetDlgItemText(hDlg, IDC_NC_DESC, tempBuf, 22);
|
GetDlgItemText(hDlg, IDC_NC_DESC, tempBuf, 22);
|
||||||
strncpy(new_cheat->name,_tToChar(tempBuf),22);
|
strncpy(new_cheat->name,_tToChar(tempBuf),22);
|
||||||
|
|
||||||
new_cheat->enabled=TRUE;
|
std::string code_string;
|
||||||
for(int byteIndex = 0; byteIndex < new_cheat->size; byteIndex++)
|
char code[10];
|
||||||
|
for (int byteIndex = 0; byteIndex < new_cheat->size; byteIndex++)
|
||||||
{
|
{
|
||||||
S9xAddCheat(new_cheat->enabled,new_cheat->saved_val,new_cheat->address+byteIndex,(new_cheat->new_val>>(8*byteIndex))&0xFF);
|
if (byteIndex > 0)
|
||||||
strcpy(Cheat.c[Cheat.num_cheats-1].name,new_cheat->name);
|
code_string += '+';
|
||||||
|
snprintf(code, 10, "%x=%x", new_cheat->address + byteIndex, (new_cheat->new_val >> (8 * byteIndex)) & 0xFF);
|
||||||
|
code_string += code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S9xAddCheatGroup(new_cheat->name, code_string.c_str());
|
||||||
|
S9xEnableCheatGroup(Cheat.g.size() - 1);
|
||||||
|
|
||||||
ret=0;
|
ret=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11049,9 +10683,9 @@ void S9xPostRomInit()
|
||||||
if (Settings.ApplyCheats)
|
if (Settings.ApplyCheats)
|
||||||
{
|
{
|
||||||
extern struct SCheatData Cheat;
|
extern struct SCheatData Cheat;
|
||||||
for (uint32 i = 0; i < Cheat.num_cheats; i++)
|
for (uint32 i = 0; i < Cheat.g.size(); i++)
|
||||||
{
|
{
|
||||||
if (Cheat.c [i].enabled)
|
if (Cheat.g [i].enabled)
|
||||||
{
|
{
|
||||||
char String2 [1024];
|
char String2 [1024];
|
||||||
sprintf(String2, "(CHEATS ARE ON!) %s", String);
|
sprintf(String2, "(CHEATS ARE ON!) %s", String);
|
||||||
|
|
Loading…
Reference in New Issue