aboutsummaryrefslogtreecommitdiff
path: root/src/AREngine.cpp
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2020-02-15 16:20:53 +0100
committerArisotura <thetotalworm@gmail.com>2020-02-15 16:20:53 +0100
commite40d414c567c46fd971b2b09d669a2eae7ce674a (patch)
treea74c55cb613639465874aadd0ad1bdba179a13ba /src/AREngine.cpp
parented39122c67ab1fbdaf5d2ab78fe1573378797e1b (diff)
now we can even parse the code from a text code. bahaahhhh
Diffstat (limited to 'src/AREngine.cpp')
-rw-r--r--src/AREngine.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/AREngine.cpp b/src/AREngine.cpp
index e8fb314..760ca39 100644
--- a/src/AREngine.cpp
+++ b/src/AREngine.cpp
@@ -37,6 +37,69 @@ CheatEntry CheatCodes[64];
u32 NumCheatCodes;
+void ParseTextCode(char* text, u32* code, int len) // or whatever this should be named?
+{
+ // TODO: they should atleast ensure they parsed all the crap before the actual code. we ain't taking care of that.
+ // this is melonDS not kindergarten. seriously.
+
+ u32 cur_word = 0;
+ u32 ndigits = 0;
+ u32 nout = 0;
+
+ char c;
+ while ((c = *text++) != '\0')
+ {
+ // hope they didn't forget the terminator, either
+ // otherwise
+ // they will be the ones getting terminated
+ // blarg.
+
+ // so, what do we do here.
+ u32 val;
+ if (c >= '0' && c <= '9')
+ val = c - '0';
+ else if (c >= 'a' && c <= 'f')
+ val = c - 'a' + 0xA;
+ else if (c >= 'A' && c <= 'F')
+ val = c - 'A' + 0xA;
+ else
+ continue;
+
+ // okay, there's atleast that.
+
+ cur_word <<= 4;
+ cur_word |= val;
+
+ // now I figure we can't keep doing that forever? can we?
+ // maybe we can, after all
+ // but it's not a good idea.
+
+ ndigits++;
+ if (ndigits >= 8)
+ {
+ if (nout >= len)
+ {
+ // OH SHIT SHIT SHIT SHIT
+ printf("AR: code too long!\n");
+ return;
+ }
+
+ *code++ = cur_word;
+ nout++;
+
+ ndigits = 0;
+ cur_word = 0;
+ }
+ }
+
+ if (nout & 1)
+ {
+ printf("AR: code was missing one word??\n");
+ *code++ = 0;
+ }
+}
+
+
bool Init()
{
return true;
@@ -70,6 +133,32 @@ void Reset()
// or the video card.
// well.
//
+
+
+ char* test = R"(9209D09A 00000000
+6209B468 00000000
+B209B468 00000000
+10000672 000003FF
+D2000000 00000000
+9209D09A 00000000
+94000130 FCBF0000
+6209B468 00000000
+B209B468 00000000
+200006B3 00000001
+200006B4 00000001
+D2000000 00000000
+9209D09A 00000000
+94000130 FC7F0000
+6209B468 00000000
+B209B468 00000000
+10000672 00000000
+D2000000 00000000)";
+ ParseTextCode(test, entry->Code, 2*64);
+ printf("PARSED CODE:\n");
+ for (int i = 0; i < 2*64; i+=2)
+ {
+ printf("%08X %08X\n", entry->Code[i], entry->Code[i+1]);
+ }
entry->Enabled = true;
NumCheatCodes++;
}