From 252e2911383a5267673f00c08419e2afeac35a31 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 13 Jul 2017 15:22:55 -0400 Subject: App now waits for confirmation to import, and reads pokedex seen&caught --- gba/source/main.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'gba/source/main.c') diff --git a/gba/source/main.c b/gba/source/main.c index 6207685..14d2f1d 100644 --- a/gba/source/main.c +++ b/gba/source/main.c @@ -10,6 +10,10 @@ int main(void) { + // This possibly increases stability, I don't rightly know, this is all black + // magic, will test more later. + REG_IME = 0; + initializeLink(); // Identify the host game. @@ -105,4 +109,57 @@ int main(void) sendU32(tti); waitForAck(); + + // Does the player want to import this game? + if (waitForResponse() == 0) + { + return 0; + } + + // Send Pokédex data + u8* pokedexSeen = 0; + if (GAME_RS) + { + pokedexSeen = SaveBlock2->rs.pokedex.seen; + } else if (GAME_FRLG) + { + pokedexSeen = SaveBlock2->frlg.pokedex.seen; + } else if (GAME_EM) + { + pokedexSeen = SaveBlock2->e.pokedex.seen; + } + + for (int i=0; i<13; i++) + { + u32 psi = + (pokedexSeen[i*4]) + | (pokedexSeen[i*4+1] << 8) + | (pokedexSeen[i*4+2] << 16) + | (pokedexSeen[i*4+3] << 24); + + directSendU32(psi); + } + + u8* pokedexCaught = 0; + if (GAME_RS) + { + pokedexCaught = SaveBlock2->rs.pokedex.owned; + } else if (GAME_FRLG) + { + pokedexCaught = SaveBlock2->frlg.pokedex.owned; + } else if (GAME_EM) + { + pokedexCaught = SaveBlock2->e.pokedex.owned; + } + + for (int i=0; i<13; i++) + { + u32 psi = + (pokedexCaught[i*4]) + | (pokedexCaught[i*4+1] << 8) + | (pokedexCaught[i*4+2] << 16) + | (pokedexCaught[i*4+3] << 24); + + directSendU32(psi); + } } -- cgit 1.4.1