mirror of https://github.com/snes9xgit/snes9x.git
Fix a couple bugs. Change cheats on unix to work like they used to.
This commit is contained in:
parent
831176983a
commit
e69fd7c50e
|
@ -744,6 +744,8 @@ static void S9xLoadCheatsFromBMLNode (bml_node *n)
|
||||||
|
|
||||||
tmp = bml_find_sub(c, "description");
|
tmp = bml_find_sub(c, "description");
|
||||||
desc = tmp->data;
|
desc = tmp->data;
|
||||||
|
if (!desc)
|
||||||
|
desc = (char *) "";
|
||||||
|
|
||||||
tmp = bml_find_sub(c, "code");
|
tmp = bml_find_sub(c, "code");
|
||||||
code = tmp->data;
|
code = tmp->data;
|
||||||
|
@ -751,7 +753,7 @@ static void S9xLoadCheatsFromBMLNode (bml_node *n)
|
||||||
if (bml_find_sub(c, "enabled"))
|
if (bml_find_sub(c, "enabled"))
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
|
||||||
if (desc && code && !S9xCheatIsDuplicate (desc, code))
|
if (code && !S9xCheatIsDuplicate (desc, code))
|
||||||
{
|
{
|
||||||
int index = S9xAddCheatGroup (desc, code);
|
int index = S9xAddCheatGroup (desc, code);
|
||||||
|
|
||||||
|
@ -773,8 +775,6 @@ bool8 S9xLoadCheatFileClassic (const char *filename)
|
||||||
if (!fs)
|
if (!fs)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
S9xDeleteCheats ();
|
|
||||||
|
|
||||||
while (fread ((void *) data, 1, 28, fs) == 28)
|
while (fread ((void *) data, 1, 28, fs) == 28)
|
||||||
{
|
{
|
||||||
SCheat c;
|
SCheat c;
|
||||||
|
@ -855,7 +855,7 @@ bool8 S9xSaveCheatFile (const char *filename)
|
||||||
" description: %s\n"
|
" description: %s\n"
|
||||||
" code: %s\n",
|
" code: %s\n",
|
||||||
(Cheat.g[i].enabled ? " enabled" : ""),
|
(Cheat.g[i].enabled ? " enabled" : ""),
|
||||||
Cheat.g[i].name,
|
(Cheat.g[i].name ? Cheat.g[i].name : ""),
|
||||||
txt);
|
txt);
|
||||||
|
|
||||||
delete[] txt;
|
delete[] txt;
|
||||||
|
|
|
@ -215,6 +215,7 @@ enum s9x_getdirtype
|
||||||
|
|
||||||
void S9xUsage (void);
|
void S9xUsage (void);
|
||||||
char * S9xParseArgs (char **, int);
|
char * S9xParseArgs (char **, int);
|
||||||
|
void S9xParseArgsForCheats (char **, int);
|
||||||
void S9xLoadConfigFiles (char **, int);
|
void S9xLoadConfigFiles (char **, int);
|
||||||
void S9xSetInfoString (const char *);
|
void S9xSetInfoString (const char *);
|
||||||
|
|
||||||
|
|
|
@ -195,8 +195,6 @@ S9xOpenROM (const char *rom_filename)
|
||||||
if (loaded)
|
if (loaded)
|
||||||
{
|
{
|
||||||
Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR));
|
Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR));
|
||||||
S9xDeleteCheats ();
|
|
||||||
S9xLoadCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1787,6 +1787,7 @@ bool8 CMemory::LoadROMInt (int32 ROMfillSize)
|
||||||
|
|
||||||
S9xReset();
|
S9xReset();
|
||||||
|
|
||||||
|
S9xDeleteCheats();
|
||||||
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
|
@ -1952,6 +1953,7 @@ bool8 CMemory::LoadMultiCartInt ()
|
||||||
|
|
||||||
S9xReset();
|
S9xReset();
|
||||||
|
|
||||||
|
S9xDeleteCheats();
|
||||||
S9xInitCheatData();
|
S9xInitCheatData();
|
||||||
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
||||||
|
|
||||||
|
|
35
snes9x.cpp
35
snes9x.cpp
|
@ -584,9 +584,8 @@ void S9xUsage (void)
|
||||||
// PATCH/CHEAT OPTIONS
|
// PATCH/CHEAT OPTIONS
|
||||||
S9xMessage(S9X_INFO, S9X_USAGE, "-nopatch Do not apply any available IPS/UPS patches");
|
S9xMessage(S9X_INFO, S9X_USAGE, "-nopatch Do not apply any available IPS/UPS patches");
|
||||||
S9xMessage(S9X_INFO, S9X_USAGE, "-cheat Apply saved cheats");
|
S9xMessage(S9X_INFO, S9X_USAGE, "-cheat Apply saved cheats");
|
||||||
S9xMessage(S9X_INFO, S9X_USAGE, "-gamegenie <code> Supply a Game Genie code");
|
S9xMessage(S9X_INFO, S9X_USAGE, "-cheatcode <code> Supply a cheat code in Game Genie,");
|
||||||
S9xMessage(S9X_INFO, S9X_USAGE, "-actionreplay <code> Supply a Pro-Action Reply code");
|
S9xMessage(S9X_INFO, S9X_USAGE, " Pro-Action Replay, or Raw format (address=byte)");
|
||||||
S9xMessage(S9X_INFO, S9X_USAGE, "-goldfinger <code> Supply a Gold Finger code");
|
|
||||||
S9xMessage(S9X_INFO, S9X_USAGE, "");
|
S9xMessage(S9X_INFO, S9X_USAGE, "");
|
||||||
|
|
||||||
#ifdef NETPLAY_SUPPORT
|
#ifdef NETPLAY_SUPPORT
|
||||||
|
@ -625,6 +624,31 @@ void S9xUsage (void)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void S9xParseArgsForCheats (char **argv, int argc)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
if (!strcasecmp(argv[i], "-gamegenie") ||
|
||||||
|
!strcasecmp(argv[i], "-actionreplay") ||
|
||||||
|
!strcasecmp(argv[i], "-cheatcode"))
|
||||||
|
{
|
||||||
|
if (i + 1 < argc)
|
||||||
|
{
|
||||||
|
if (S9xAddCheatGroup ("Unknown", argv[++i]) < 0)
|
||||||
|
{
|
||||||
|
S9xMessage(S9X_ERROR, S9X_GAME_GENIE_CODE_ERROR, "Code format invalid");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
S9xEnableCheatGroup (Cheat.g.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
S9xUsage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char * S9xParseArgs (char **argv, int argc)
|
char * S9xParseArgs (char **argv, int argc)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
|
@ -778,7 +802,9 @@ char * S9xParseArgs (char **argv, int argc)
|
||||||
if (!strcasecmp(argv[i], "-cheat"))
|
if (!strcasecmp(argv[i], "-cheat"))
|
||||||
Settings.ApplyCheats = TRUE;
|
Settings.ApplyCheats = TRUE;
|
||||||
else
|
else
|
||||||
if (!strcasecmp(argv[i], "-gamegenie") || !strcasecmp(argv[i], "-actionreplay"))
|
if (!strcasecmp(argv[i], "-gamegenie") ||
|
||||||
|
!strcasecmp(argv[i], "-actionreplay") ||
|
||||||
|
!strcasecmp(argv[i], "-cheatcode"))
|
||||||
{
|
{
|
||||||
if (i + 1 < argc)
|
if (i + 1 < argc)
|
||||||
{
|
{
|
||||||
|
@ -795,7 +821,6 @@ char * S9xParseArgs (char **argv, int argc)
|
||||||
S9xUsage();
|
S9xUsage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
||||||
// NETPLAY OPTIONS
|
// NETPLAY OPTIONS
|
||||||
|
|
||||||
#ifdef NETPLAY_SUPPORT
|
#ifdef NETPLAY_SUPPORT
|
||||||
|
|
|
@ -1619,10 +1619,8 @@ void S9xExit (void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Memory.SaveSRAM(S9xGetFilename(".srm", SRAM_DIR));
|
Memory.SaveSRAM(S9xGetFilename(".srm", SRAM_DIR));
|
||||||
if (Settings.ApplyCheats)
|
|
||||||
S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
|
||||||
S9xResetSaveTimer(FALSE);
|
S9xResetSaveTimer(FALSE);
|
||||||
|
S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
||||||
S9xUnmapAllControls();
|
S9xUnmapAllControls();
|
||||||
S9xDeinitDisplay();
|
S9xDeinitDisplay();
|
||||||
Memory.Deinit();
|
Memory.Deinit();
|
||||||
|
@ -1699,6 +1697,7 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
S9xLoadConfigFiles(argv, argc);
|
S9xLoadConfigFiles(argv, argc);
|
||||||
rom_filename = S9xParseArgs(argv, argc);
|
rom_filename = S9xParseArgs(argv, argc);
|
||||||
|
S9xDeleteCheats();
|
||||||
|
|
||||||
make_snes9x_dirs();
|
make_snes9x_dirs();
|
||||||
|
|
||||||
|
@ -1786,14 +1785,18 @@ int main (int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S9xDeleteCheats();
|
||||||
|
S9xCheatsEnable();
|
||||||
NSRTControllerSetup();
|
NSRTControllerSetup();
|
||||||
Memory.LoadSRAM(S9xGetFilename(".srm", SRAM_DIR));
|
Memory.LoadSRAM(S9xGetFilename(".srm", SRAM_DIR));
|
||||||
|
|
||||||
if (Settings.ApplyCheats)
|
if (Settings.ApplyCheats)
|
||||||
{
|
{
|
||||||
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
|
||||||
S9xCheatsEnable ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S9xParseArgsForCheats(argv, argc);
|
||||||
|
|
||||||
CPU.Flags = saved_flags;
|
CPU.Flags = saved_flags;
|
||||||
Settings.StopEmulation = FALSE;
|
Settings.StopEmulation = FALSE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue