Fix libretro cheats.

This commit is contained in:
Brandon Wright 2018-04-26 15:57:04 -05:00
parent 4fde5d5120
commit 46d8f7bb80
2 changed files with 8 additions and 28 deletions

View File

@ -6,6 +6,7 @@ SOURCES_CXX := $(CORE_DIR)/apu/apu.cpp \
$(CORE_DIR)/apu/bapu/dsp/SPC_DSP.cpp \
$(CORE_DIR)/apu/bapu/smp/smp.cpp \
$(CORE_DIR)/apu/bapu/smp/smp_state.cpp \
$(CORE_DIR)/bml.cpp \
$(CORE_DIR)/bsx.cpp \
$(CORE_DIR)/c4.cpp \
$(CORE_DIR)/c4emu.cpp \

View File

@ -395,16 +395,10 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
void retro_cheat_reset()
{
S9xDeleteCheats();
S9xApplyCheats();
}
void retro_cheat_set(unsigned index, bool enabled, const char *codeline)
{
uint32 address;
uint8 val;
bool8 sram;
uint8 bytes[3];//used only by GoldFinger, ignored for now
char codeCopy[256];
char* code;
@ -421,36 +415,21 @@ void retro_cheat_set(unsigned index, bool enabled, const char *codeline)
code[8]='\0';
}
if (S9xGameGenieToRaw(code, address, val)==NULL ||
S9xProActionReplayToRaw(code, address, val)==NULL)
/* Goldfinger was broken and nobody noticed. Removed */
if (S9xAddCheatGroup ("retro", code) >= 0)
{
Cheat.c[Cheat.num_cheats].address = address;
Cheat.c[Cheat.num_cheats].byte = val;
Cheat.c[Cheat.num_cheats].enabled = enabled;
Cheat.c[Cheat.num_cheats].saved = FALSE; // it'll be saved next time cheats run anyways
Cheat.num_cheats++;
}
else if (S9xGoldFingerToRaw(code, address, sram, val, bytes)==NULL)
{
if (!sram)
{
for (int i=0;i<val;i++){
Cheat.c[Cheat.num_cheats].address = address;
Cheat.c[Cheat.num_cheats].byte = bytes[i];
Cheat.c[Cheat.num_cheats].enabled = enabled;
Cheat.c[Cheat.num_cheats].saved = FALSE; // it'll be saved next time cheats run anyways
Cheat.num_cheats++;
}
}
if (enabled)
S9xEnableCheatGroup (Cheat.g.size () - 1);
}
else
{
printf("CHEAT: Failed to recognize %s\n",code);
}
code=strtok(NULL,"+,.; "); // bad code, ignore
}
Settings.ApplyCheats=true;
S9xApplyCheats();
S9xCheatsEnable();
}
static void init_descriptors(void)