aboutsummaryrefslogtreecommitdiff
path: root/libretro.c
diff options
context:
space:
mode:
authortwinaphex2014-12-06 21:55:19 +0100
committertwinaphex2014-12-06 21:55:19 +0100
commit6017ba80d41ebe044721a2190862c0ba54303f02 (patch)
treee626da447856a334d8b3cc8cdfa5498c7f1c9e93 /libretro.c
parent8e3c2e02c2fcde3a0ffc3b616777332ec5b6e5be (diff)
downloadsnes9x2005-6017ba80d41ebe044721a2190862c0ba54303f02.tar.gz
snes9x2005-6017ba80d41ebe044721a2190862c0ba54303f02.tar.bz2
snes9x2005-6017ba80d41ebe044721a2190862c0ba54303f02.zip
Implement cheat code stuff
Diffstat (limited to 'libretro.c')
-rw-r--r--libretro.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/libretro.c b/libretro.c
index bf33bd0..1f1a3aa 100644
--- a/libretro.c
+++ b/libretro.c
@@ -734,11 +734,45 @@ bool retro_unserialize(const void* data, size_t size)
void retro_cheat_reset(void)
{
-
+#ifdef WANT_CHEATS
+ S9xDeleteCheats();
+ S9xApplyCheats();
+#endif
}
+
+#ifdef WANT_CHEATS
+extern SCheatData Cheat;
+#endif
+
void retro_cheat_set(unsigned index, bool enabled, const char* code)
{
-
+#ifdef WANT_CHEATS
+ uint32_t address;
+ uint8_t val;
+
+ bool sram;
+ uint8_t bytes[3];//used only by GoldFinger, ignored for now
+
+ if (S9xGameGenieToRaw(code, &address, &val)!=NULL &&
+ S9xProActionReplayToRaw(code, &address, &val)!=NULL &&
+ S9xGoldFingerToRaw(code, &address, &sram, &val, bytes)!=NULL)
+ { // bad code, ignore
+ return;
+ }
+ if (index > Cheat.num_cheats)
+ return; // cheat added in weird order, ignore
+ if (index == Cheat.num_cheats)
+ Cheat.num_cheats++;
+
+ Cheat.c[index].address = address;
+ Cheat.c[index].byte = val;
+ Cheat.c[index].enabled = enabled;
+
+ Cheat.c[index].saved = false; // it'll be saved next time cheats run anyways
+
+ Settings.ApplyCheats=true;
+ S9xApplyCheats();
+#endif
}
static void init_descriptors(void)