X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fcheat.c;fp=libpcsxcore%2Fcheat.c;h=2727fd23dc0111ba2a578c249b57778e5c659704;hp=e0cf411e081b6a5c0cf54299ffbd0b42830df271;hb=5162c3ff5086640220dcfa12e8598e4d4e89c5c6;hpb=8412166f53abb220b85e0aff47924c04724abfa4 diff --git a/libpcsxcore/cheat.c b/libpcsxcore/cheat.c index e0cf411e..2727fd23 100644 --- a/libpcsxcore/cheat.c +++ b/libpcsxcore/cheat.c @@ -20,6 +20,7 @@ #include "r3000a.h" #include "psxmem.h" #include "misc.h" +#include "../frontend/plugin_lib.h" // in_keystate for D4 #include "cheat.h" @@ -228,6 +229,10 @@ void ApplyCheats() { psxMu16ref(addr) = SWAPu16(val); break; + case CHEAT_SCRATCHPAD16: // 1F + psxHs16ref(addr) = SWAPu16(val); + break; + case CHEAT_INC16: psxMu16ref(addr) = SWAPu16(psxMu16(addr) + val); break; @@ -319,6 +324,20 @@ void ApplyCheats() { if (PSXMu16(addr) <= val) j++; // skip the next code break; + + case CHEAT_BUTTONS1_16: { // D4 + u16 keys = in_keystate[0]; + keys = (keys << 8) | (keys >> 8); + if (keys != val) + j++; // skip the next code + break; + } + + default: + SysPrintf("unhandled cheat %d,%d code %08X\n", + i, j, CheatCodes[j].Addr); + Cheats[i].WasEnabled = Cheats[i].Enabled = 0; + break; } } } @@ -350,7 +369,7 @@ int AddCheat(const char *descr, char *code) { p2 = code; while (c) { - unsigned int t1, t2; + unsigned int t1, t2, r; while (*p2 != '\n' && *p2 != '\0') p2++; @@ -363,9 +382,11 @@ int AddCheat(const char *descr, char *code) { t1 = 0; t2 = 0; - sscanf(p1, "%x %x", &t1, &t2); + r = sscanf(p1, "%x %x", &t1, &t2); - if (t1 > 0x10000000) { + if (r != 2) + SysPrintf("cheat %d: couldn't parse '%s'\n", NumCodes, p1); + else if (t1 >= 0x10000000) { if (NumCodes >= NumCodesAllocated) { NumCodesAllocated += ALLOC_INCREMENT;