From 433df9a40045288ab70ab4f317bdd5e4e53ecb1b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 24 Sep 2017 19:16:47 -0400 Subject: Extractor now gets box names --- gba/source/main.c | 20 ++++++++++++++++++++ source/main.c | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/gba/source/main.c b/gba/source/main.c index 375adb8..30f11d6 100644 --- a/gba/source/main.c +++ b/gba/source/main.c @@ -214,6 +214,26 @@ int main(void) for (int bi=0; bi<14; bi++) { + u8* boxName = pc->boxNames[bi]; + + u32 bn1 = + (boxName[0] << 24) + | (boxName[1] << 16) + | (boxName[2] << 8) + | (boxName[3]); + + u32 bn2 = + (boxName[4] << 24) + | (boxName[5] << 16) + | (boxName[6] << 8) + | (boxName[7]); + + sendU32(bn1); + waitForAck(); + + sendU32(bn2); + waitForAck(); + struct BoxPokemon* box = pc->boxes[bi]; for (int si=0; si<30; si++) diff --git a/source/main.c b/source/main.c index de36755..4ce2315 100644 --- a/source/main.c +++ b/source/main.c @@ -292,6 +292,7 @@ void* extractor(void* userdata) u32 partyCount = getMsg(); cJSON* jParty = cJSON_CreateArray(); + cJSON* jBoxes = cJSON_CreateArray(); for (u32 i = 0; i < partyCount; i++) { @@ -314,8 +315,29 @@ void* extractor(void* userdata) { printf("Getting box %d...\n", i+1); + u8 boxName[8]; + + u32 bnd = getMsg(); + boxName[0] = (bnd & 0xFF000000) >> 24; + boxName[1] = (bnd & 0x00FF0000) >> 16; + boxName[2] = (bnd & 0x0000FF00) >> 8; + boxName[3] = (bnd & 0x000000FF); + + bnd = getMsg(); + boxName[4] = (bnd & 0xFF000000) >> 24; + boxName[5] = (bnd & 0x00FF0000) >> 16; + boxName[6] = (bnd & 0x0000FF00) >> 8; + boxName[7] = (bnd & 0x000000FF); + + char d_boxName[25]; + decodePokemonCharset(boxName, 9, d_boxName, gameLanguage); + + cJSON_AddItemToArray(jBoxes, cJSON_CreateString(d_boxName)); + for (int j=0; j<30; j++) { + usleep(5000); + int isPoke = getMsg(); if (isPoke == 1) @@ -339,6 +361,7 @@ void* extractor(void* userdata) } } + cJSON_AddItemToObject(root, "boxes", jBoxes); cJSON_AddItemToObject(root, "pokemon", jParty); char *rendered = cJSON_Print(root); -- cgit 1.4.1