diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-07-13 15:22:55 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-07-13 15:22:55 -0400 |
commit | 252e2911383a5267673f00c08419e2afeac35a31 (patch) | |
tree | 9713a54f6a17afa14999bab5b4c4e982ca40bfea /source | |
parent | 2c837223756de2596931c22c8f4fa2ba4a4237a9 (diff) | |
download | gen3uploader-252e2911383a5267673f00c08419e2afeac35a31.tar.gz gen3uploader-252e2911383a5267673f00c08419e2afeac35a31.tar.bz2 gen3uploader-252e2911383a5267673f00c08419e2afeac35a31.zip |
App now waits for confirmation to import, and reads pokedex seen&caught
Diffstat (limited to 'source')
-rw-r--r-- | source/main.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/source/main.c b/source/main.c index 128feb9..dd252b5 100644 --- a/source/main.c +++ b/source/main.c | |||
@@ -240,12 +240,29 @@ u32 getMsg() | |||
240 | } | 240 | } |
241 | 241 | ||
242 | send(0); | 242 | send(0); |
243 | while (recv()!=0) {sleep(1);}; | 243 | while (recv()!=0) {sleep(1);} |
244 | send(0); | 244 | send(0); |
245 | 245 | ||
246 | return val; | 246 | return val; |
247 | } | 247 | } |
248 | 248 | ||
249 | void getMsgArr(u32* arr, int len) | ||
250 | { | ||
251 | for (int i=0; i<len; i++) | ||
252 | { | ||
253 | *(vu32*)(arr+i) = __builtin_bswap32(recv()); | ||
254 | usleep(500000); | ||
255 | } | ||
256 | } | ||
257 | |||
258 | void sendMsg(u32 msg) | ||
259 | { | ||
260 | while (recv()==0) {sleep(1);} | ||
261 | send(msg); | ||
262 | while (recv()!=0) {sleep(1);} | ||
263 | send(0); | ||
264 | } | ||
265 | |||
249 | int main(int argc, char *argv[]) | 266 | int main(int argc, char *argv[]) |
250 | { | 267 | { |
251 | void *xfb = NULL; | 268 | void *xfb = NULL; |
@@ -520,8 +537,44 @@ int main(int argc, char *argv[]) | |||
520 | 537 | ||
521 | if (waitForButtons(PAD_BUTTON_A | PAD_BUTTON_B) & PAD_BUTTON_B) | 538 | if (waitForButtons(PAD_BUTTON_A | PAD_BUTTON_B) & PAD_BUTTON_B) |
522 | { | 539 | { |
540 | printf("Cancelling...\n"); | ||
541 | VIDEO_WaitVSync(); | ||
542 | |||
543 | sendMsg(0); | ||
544 | |||
523 | continue; | 545 | continue; |
524 | } | 546 | } |
547 | |||
548 | printf("Importing...\n"); | ||
549 | VIDEO_WaitVSync(); | ||
550 | |||
551 | sendMsg(1); | ||
552 | |||
553 | // Get Pokédex data | ||
554 | u32 pokedexSeen[13]; | ||
555 | u32 pokedexCaught[13]; | ||
556 | |||
557 | getMsgArr(pokedexSeen, 13); | ||
558 | getMsgArr(pokedexCaught, 13); | ||
559 | int numCaught = 0; | ||
560 | int numSeen = 0; | ||
561 | for (int i=0; i<(13*32); i++) | ||
562 | { | ||
563 | if (pokedexCaught[i >> 5] >> (i & 31) & 1) | ||
564 | { | ||
565 | //printf("Caught #%d\n", i); | ||
566 | numCaught++; | ||
567 | numSeen++; | ||
568 | } else if (pokedexSeen[i >> 5] >> (i & 31) & 1) | ||
569 | { | ||
570 | //printf("Saw #%d\n", i); | ||
571 | numSeen++; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | printf("Caught: %d\nSeen: %d\n", numCaught, numSeen); | ||
576 | |||
577 | waitForButtons(PAD_BUTTON_START); | ||
525 | } | 578 | } |
526 | } | 579 | } |
527 | 580 | ||