mirror of https://github.com/snes9xgit/snes9x.git
Improve cheat dialog and fix cheats on ROM load.
This commit is contained in:
parent
c6677d8292
commit
8b00a1fa54
|
@ -13,6 +13,14 @@ enum
|
||||||
|
|
||||||
extern SCheatData Cheat;
|
extern SCheatData Cheat;
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_cheat (uint32 address, uint8 byte, const char *description)
|
||||||
|
{
|
||||||
|
S9xAddCheat (FALSE, TRUE, address, byte);
|
||||||
|
S9xEnableCheat (Cheat.num_cheats - 1);
|
||||||
|
strncpy (Cheat.c[Cheat.num_cheats - 1].name, description, 22);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_errorbox (const char *error)
|
display_errorbox (const char *error)
|
||||||
{
|
{
|
||||||
|
@ -104,9 +112,6 @@ Snes9xCheats::Snes9xCheats (void)
|
||||||
|
|
||||||
gtk_widget_realize (window);
|
gtk_widget_realize (window);
|
||||||
|
|
||||||
gtk_combo_box_set_active (GTK_COMBO_BOX (get_widget ("code_type_combo")),
|
|
||||||
0);
|
|
||||||
|
|
||||||
signal_connect (callbacks);
|
signal_connect (callbacks);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -220,61 +225,26 @@ Snes9xCheats::add_code (void)
|
||||||
uint8 bytes [3];
|
uint8 bytes [3];
|
||||||
bool8 sram;
|
bool8 sram;
|
||||||
uint8 num_bytes;
|
uint8 num_bytes;
|
||||||
const char *error;
|
const char *description;
|
||||||
int errorno = 0;
|
|
||||||
|
|
||||||
int type = get_combo ("code_type_combo");
|
|
||||||
|
|
||||||
const gchar *code = get_entry_text ("code_entry");
|
const gchar *code = get_entry_text ("code_entry");
|
||||||
|
|
||||||
switch (type)
|
description = get_entry_text ("description_entry");
|
||||||
{
|
if (description[0] == '\0')
|
||||||
case TYPE_GAME_GENIE:
|
description = _("No description");
|
||||||
if ((error = S9xGameGenieToRaw (code, address, byte)) == NULL)
|
|
||||||
S9xAddCheat (TRUE, FALSE, address, byte);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
display_errorbox (error);
|
|
||||||
errorno = 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_ACTION_REPLAY:
|
if (!S9xGameGenieToRaw (code, address, byte))
|
||||||
if ((error = S9xProActionReplayToRaw (code, address, byte)) == NULL)
|
add_cheat (address, byte, description);
|
||||||
S9xAddCheat (TRUE, FALSE, address, byte);
|
else if (!S9xProActionReplayToRaw (code, address, byte))
|
||||||
else
|
add_cheat (address, byte, description);
|
||||||
{
|
else if (!S9xGoldFingerToRaw (code, address, sram, num_bytes, bytes))
|
||||||
display_errorbox (error);
|
|
||||||
errorno = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_GOLDFINGER:
|
|
||||||
|
|
||||||
if ((error = S9xGoldFingerToRaw (code, address, sram,
|
|
||||||
num_bytes, bytes)) == NULL)
|
|
||||||
{
|
{
|
||||||
for (int c = 0; c < num_bytes; c++)
|
for (int c = 0; c < num_bytes; c++)
|
||||||
S9xAddCheat (TRUE, FALSE, address + c, bytes [c]);
|
add_cheat (address + c, bytes[c], description);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
display_errorbox (error);
|
display_errorbox (_("Code does not match Game Genie, ProAction Replay, or GoldFinger format."));
|
||||||
errorno = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!errorno)
|
|
||||||
{
|
|
||||||
const char *entry_text = get_entry_text ("description_entry");
|
|
||||||
|
|
||||||
if (strlen (entry_text) <= 0)
|
|
||||||
strncpy (Cheat.c[Cheat.num_cheats - 1].name, _("No description"), 22);
|
|
||||||
else
|
|
||||||
strncpy (Cheat.c[Cheat.num_cheats - 1].name, entry_text, 22);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_grab_focus (get_widget ("code_entry"));
|
gtk_widget_grab_focus (get_widget ("code_entry"));
|
||||||
|
|
|
@ -196,6 +196,16 @@ S9xOpenROM (const char *rom_filename)
|
||||||
{
|
{
|
||||||
Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR));
|
Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR));
|
||||||
S9xLoadCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
|
S9xLoadCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < Cheat.num_cheats; i++)
|
||||||
|
{
|
||||||
|
if (Cheat.c[i].enabled)
|
||||||
|
{
|
||||||
|
/* RAM is fresh, so we need to clean out old saved values */
|
||||||
|
Cheat.c[i].saved = FALSE;
|
||||||
|
S9xApplyCheat (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
4432
gtk/src/snes9x.ui
4432
gtk/src/snes9x.ui
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue