From a194b850037c03f5fb3ac1ecc9f7a99f73b84104 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sat, 22 Dec 2012 22:16:55 -0500 Subject: Preliminary Snes9x-based cheat code support. Not tested, because the file selection interface freezes when it gets to the folder containing Mightymo's cheat files, whereas it did not do this before with the converted Mightymo cheats. (335 files -> 679, though.) --- source/cheats.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'source/cheats.cpp') diff --git a/source/cheats.cpp b/source/cheats.cpp index 922e08d..dc388d2 100644 --- a/source/cheats.cpp +++ b/source/cheats.cpp @@ -104,20 +104,20 @@ static bool8 S9xAllHex (const char *code, int len) return (TRUE); } -const char *S9xProActionReplayToRaw (const char *code, uint32 &address, uint8 &byte) +const char *S9xProActionReplayToRaw (const char *code, uint32 *address, uint8 *byte) { uint32 data = 0; if (strlen (code) != 8 || !S9xAllHex (code, 8) || sscanf (code, "%x", &data) != 1) return ("Invalid Pro Action Replay code - should be 8 hex digits in length."); - address = data >> 8; - byte = (uint8) data; + *address = data >> 8; + *byte = (uint8) data; return (NULL); } -const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, - uint8 &num_bytes, uint8 bytes[3]) +const char *S9xGoldFingerToRaw (const char *code, uint32 *address, bool8 *sram, + uint8 *num_bytes, uint8 bytes[3]) { char tmp [15]; if (strlen (code) != 14) @@ -125,7 +125,7 @@ const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, strncpy (tmp, code, 5); tmp [5] = 0; - if (sscanf (tmp, "%x", &address) != 1) + if (sscanf (tmp, "%x", address) != 1) return ("Invalid Gold Finger code."); int i; @@ -138,12 +138,12 @@ const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, break; bytes [i] = (uint8) byte; } - num_bytes = i; - sram = code [13] == '1'; + *num_bytes = i; + *sram = code [13] == '1'; return (NULL); } -const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &byte) +const char *S9xGameGenieToRaw (const char *code, uint32 *address, uint8 *byte) { char new_code [12]; @@ -176,15 +176,14 @@ const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &byte) } uint32 data = 0; sscanf (new_code, "%x", &data); - byte = (uint8)(data >> 24); - address = data & 0xffffff; - address = ((address & 0x003c00) << 10) + - ((address & 0x00003c) << 14) + - ((address & 0xf00000) >> 8) + - ((address & 0x000003) << 10) + - ((address & 0x00c000) >> 6) + - ((address & 0x0f0000) >> 12) + - ((address & 0x0003c0) >> 6); + *byte = (uint8)(data >> 24); + *address = ((data & 0x003c00) << 10) + + ((data & 0x00003c) << 14) + + ((data & 0xf00000) >> 8) + + ((data & 0x000003) << 10) + + ((data & 0x00c000) >> 6) + + ((data & 0x0f0000) >> 12) + + ((data & 0x0003c0) >> 6); return (NULL); } -- cgit v1.2.3