diff options
Diffstat (limited to 'source/cheats.cpp')
-rw-r--r-- | source/cheats.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
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); } |