Switch back to .cht format. Update to byuu's new form.

This commit is contained in:
Brandon Wright 2018-06-03 18:02:48 -05:00
parent 2645ba8d18
commit 642ce83e47
5 changed files with 21 additions and 27 deletions

View File

@ -654,7 +654,7 @@ char *S9xCheatGroupToText (SCheatGroup *g)
{ {
char *tmp = S9xCheatToText (&g->c[i]); char *tmp = S9xCheatToText (&g->c[i]);
if (i != 0) if (i != 0)
text += '+'; text += " + ";
text += tmp; text += tmp;
delete[] tmp; delete[] tmp;
} }
@ -809,10 +809,10 @@ bool8 S9xLoadCheatFile (const char *filename)
return S9xLoadCheatFileClassic (filename); return S9xLoadCheatFileClassic (filename);
} }
n = bml_find_sub (bml, "cartridge"); n = bml_find_sub (bml, "cheat");
if (n) if (n)
{ {
S9xLoadCheatsFromBMLNode (n); S9xLoadCheatsFromBMLNode (bml);
} }
bml_free_node (bml); bml_free_node (bml);
@ -841,22 +841,19 @@ bool8 S9xSaveCheatFile (const char *filename)
if (!file) if (!file)
return FALSE; return FALSE;
fprintf (file, "cartridge sha256=");
for (i = 0; i < 32; i++)
fprintf (file, "%02x", Memory.ROMSHA256[i]);
fprintf (file, "\n");
for (i = 0; i < Cheat.g.size (); i++) for (i = 0; i < Cheat.g.size (); i++)
{ {
char *txt = S9xCheatGroupToText (i); char *txt = S9xCheatGroupToText (i);
fprintf (file, fprintf (file,
" cheat%s\n" "cheat\n"
" description: %s\n" " description: %s\n"
" code: %s\n", " code: %s\n"
(Cheat.g[i].enabled ? " enabled" : ""), "%s\n",
(Cheat.g[i].name ? Cheat.g[i].name : ""), Cheat.g[i].name ? Cheat.g[i].name : "",
txt); txt,
Cheat.g[i].enabled ? " enabled\n" : ""
);
delete[] txt; delete[] txt;
} }

View File

@ -378,7 +378,7 @@ void
S9xAutoSaveSRAM (void) S9xAutoSaveSRAM (void)
{ {
Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR)); Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR));
S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR)); S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
return; return;
} }

View File

@ -1788,7 +1788,6 @@ bool8 CMemory::LoadROMInt (int32 ROMfillSize)
S9xReset(); S9xReset();
S9xDeleteCheats(); S9xDeleteCheats();
if (!S9xLoadCheatFile(S9xGetFilename(".bml", CHEAT_DIR)))
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR)); S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
return (TRUE); return (TRUE);
@ -1955,7 +1954,6 @@ bool8 CMemory::LoadMultiCartInt ()
S9xReset(); S9xReset();
S9xDeleteCheats(); S9xDeleteCheats();
if (!S9xLoadCheatFile(S9xGetFilename(".bml", CHEAT_DIR)))
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR)); S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
return (TRUE); return (TRUE);

View File

@ -1634,7 +1634,7 @@ void S9xExit (void)
Memory.SaveSRAM(S9xGetFilename(".srm", SRAM_DIR)); Memory.SaveSRAM(S9xGetFilename(".srm", SRAM_DIR));
S9xResetSaveTimer(FALSE); S9xResetSaveTimer(FALSE);
S9xSaveCheatFile(S9xGetFilename(".bml", CHEAT_DIR)); S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
S9xUnmapAllControls(); S9xUnmapAllControls();
S9xDeinitDisplay(); S9xDeinitDisplay();
Memory.Deinit(); Memory.Deinit();
@ -1806,7 +1806,6 @@ int main (int argc, char **argv)
if (Settings.ApplyCheats) if (Settings.ApplyCheats)
{ {
if (!S9xLoadCheatFile(S9xGetFilename(".bml", CHEAT_DIR)))
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR)); S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
} }

View File

@ -2353,7 +2353,7 @@ LRESULT CALLBACK WinProc(
{ {
WinSearchCheatDatabase(); WinSearchCheatDatabase();
} }
S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR)); S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
RestoreSNESDisplay (); RestoreSNESDisplay ();
break; break;
case ID_CHEAT_SEARCH: case ID_CHEAT_SEARCH:
@ -2372,7 +2372,7 @@ LRESULT CALLBACK WinProc(
case ID_CHEAT_SEARCH_MODAL: case ID_CHEAT_SEARCH_MODAL:
RestoreGUIDisplay (); RestoreGUIDisplay ();
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEAT_SEARCH), hWnd, DlgCheatSearch); // modal DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEAT_SEARCH), hWnd, DlgCheatSearch); // modal
S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR)); S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
RestoreSNESDisplay (); RestoreSNESDisplay ();
break; break;
case ID_CHEAT_APPLY: case ID_CHEAT_APPLY:
@ -3685,7 +3685,7 @@ loop_exit:
if (!Settings.StopEmulation) if (!Settings.StopEmulation)
{ {
Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR)); Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR));
S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR)); S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
} }
//if (!VOODOO_MODE && !GUI.FullScreen) //if (!VOODOO_MODE && !GUI.FullScreen)
// GetWindowRect (GUI.hWnd, &GUI.window_size); // GetWindowRect (GUI.hWnd, &GUI.window_size);
@ -4133,7 +4133,7 @@ static bool LoadROM(const TCHAR *filename, const TCHAR *filename2 /*= NULL*/) {
if (!Settings.StopEmulation) { if (!Settings.StopEmulation) {
Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR)); Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR));
S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR)); S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
} }
if(filename2) if(filename2)
@ -9289,7 +9289,7 @@ INT_PTR CALLBACK DlgCheatSearch(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
case WM_DESTROY: case WM_DESTROY:
{ {
cheatSearchHWND = NULL; cheatSearchHWND = NULL;
S9xSaveCheatFile (S9xGetFilename (".bml", CHEAT_DIR)); S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
break; break;
} }