aboutsummaryrefslogtreecommitdiff
path: root/source/cheats.cpp
diff options
context:
space:
mode:
authorNebuleon Fumika2012-12-22 22:16:55 -0500
committerNebuleon Fumika2012-12-22 22:16:55 -0500
commita194b850037c03f5fb3ac1ecc9f7a99f73b84104 (patch)
treee741bc4898e81b568552a8ae91867fd6a2ed3523 /source/cheats.cpp
parente7f7d0282a7126f9e1095481b39c43e3e24909bf (diff)
downloadsnes9x2005-a194b850037c03f5fb3ac1ecc9f7a99f73b84104.tar.gz
snes9x2005-a194b850037c03f5fb3ac1ecc9f7a99f73b84104.tar.bz2
snes9x2005-a194b850037c03f5fb3ac1ecc9f7a99f73b84104.zip
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.)
Diffstat (limited to 'source/cheats.cpp')
-rw-r--r--source/cheats.cpp35
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);
}