From 47624ecf3cef8397f63dd8de9b7d6e112ab275c9 Mon Sep 17 00:00:00 2001 From: iLag Date: Tue, 24 Jan 2017 13:56:59 -0800 Subject: Enable support for multiline cheats. All non hexdec characters will be read as delimiters and reformatted for PCSX's preferred format. --- frontend/libretro.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 9e2d031..0c0ed3e 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -39,6 +39,9 @@ #define PORTS_NUMBER 8 +#define ISHEXDEC ((buf[cursor]>='0') && (buf[cursor]<='9')) || ((buf[cursor]>='a') && (buf[cursor]<='f')) || ((buf[cursor]>='A') && (buf[cursor]<='F')) + + //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key int rebootemu = 0; @@ -776,6 +779,21 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) // cheat funcs are destructive, need a copy.. strncpy(buf, code, sizeof(buf)); buf[sizeof(buf) - 1] = 0; + + //Prepare buffered cheat for PCSX's AddCheat fucntion. + int cursor=0; + int nonhexdec=0; + while (buf[cursor]){ + if (!(ISHEXDEC)){ + if (++nonhexdec%2){ + buf[cursor]=' '; + } else { + buf[cursor]='\n'; + } + } + cursor++; + } + if (index < NumCheats) ret = EditCheat(index, "", buf); @@ -783,7 +801,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) ret = AddCheat("", buf); if (ret != 0) - SysPrintf("Failed to set cheat %#u\n", index); + SysPrintf("Failed to set cheat %#u: %s\n", index, code); else if (index < NumCheats) Cheats[index].Enabled = enabled; } -- cgit v1.2.3 From 4dbb320e3d1cf3e9d99a91ef5f76255b62bed406 Mon Sep 17 00:00:00 2001 From: iLag Date: Tue, 24 Jan 2017 14:01:45 -0800 Subject: Cleanup a bit more. --- frontend/libretro.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 0c0ed3e..10e9694 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -41,7 +41,6 @@ #define ISHEXDEC ((buf[cursor]>='0') && (buf[cursor]<='9')) || ((buf[cursor]>='a') && (buf[cursor]<='f')) || ((buf[cursor]>='A') && (buf[cursor]<='F')) - //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key int rebootemu = 0; @@ -801,7 +800,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) ret = AddCheat("", buf); if (ret != 0) - SysPrintf("Failed to set cheat %#u: %s\n", index, code); + SysPrintf("Failed to set cheat %#u\n", index); else if (index < NumCheats) Cheats[index].Enabled = enabled; } -- cgit v1.2.3