diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/encoding.c | 14 | ||||
-rw-r--r-- | source/encoding.h | 8 | ||||
-rw-r--r-- | source/main.c | 77 |
3 files changed, 75 insertions, 24 deletions
diff --git a/source/encoding.c b/source/encoding.c new file mode 100644 index 0000000..a69fc7e --- /dev/null +++ b/source/encoding.c | |||
@@ -0,0 +1,14 @@ | |||
1 | #include "encoding.h" | ||
2 | |||
3 | const char charmap[] = { | ||
4 | ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '?', '.', '-', ' ', | ||
5 | ' ', '\"', '\"', '\'', '\'', '*', '*', ' ', ',', ' ', '/', 'A', 'B', 'C', 'D', 'E', | ||
6 | 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', | ||
7 | 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', | ||
8 | 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ' | ||
9 | }; | ||
10 | |||
11 | char debugGen3Decode(u8 val) | ||
12 | { | ||
13 | return charmap[val - 0xA0]; | ||
14 | } | ||
diff --git a/source/encoding.h b/source/encoding.h new file mode 100644 index 0000000..be99895 --- /dev/null +++ b/source/encoding.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef ENCODING_H_95547384 | ||
2 | #define ENCODING_H_95547384 | ||
3 | |||
4 | #include <gccore.h> | ||
5 | |||
6 | char debugGen3Decode(u8 val); | ||
7 | |||
8 | #endif /* end of include guard: ENCODING_H_95547384 */ | ||
diff --git a/source/main.c b/source/main.c index 79fd2fc..dfcdc3b 100644 --- a/source/main.c +++ b/source/main.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <dirent.h> | 17 | #include <dirent.h> |
18 | #include <fat.h> | 18 | #include <fat.h> |
19 | #include "link.h" | 19 | #include "link.h" |
20 | #include "encoding.h" | ||
20 | 21 | ||
21 | //from my tests 50us seems to be the lowest | 22 | //from my tests 50us seems to be the lowest |
22 | //safe si transfer delay in between calls | 23 | //safe si transfer delay in between calls |
@@ -308,6 +309,21 @@ u32 deriveKeyC(u32 keyCderive, u32 kcrc) { | |||
308 | return keyc; | 309 | return keyc; |
309 | } | 310 | } |
310 | 311 | ||
312 | u32 getMsg() | ||
313 | { | ||
314 | u32 val = 0; | ||
315 | while (val == 0) | ||
316 | { | ||
317 | val = __builtin_bswap32(recv()); | ||
318 | fsleep(1); | ||
319 | } | ||
320 | send(0); | ||
321 | while (recv()!=0) {fsleep(1);}; | ||
322 | send(0); | ||
323 | |||
324 | return val; | ||
325 | } | ||
326 | |||
311 | int main(int argc, char *argv[]) | 327 | int main(int argc, char *argv[]) |
312 | { | 328 | { |
313 | void *xfb = NULL; | 329 | void *xfb = NULL; |
@@ -482,7 +498,7 @@ int main(int argc, char *argv[]) | |||
482 | u32 bootkey = docrc(0xBB,keyc) | 0xbb000000; | 498 | u32 bootkey = docrc(0xBB,keyc) | 0xbb000000; |
483 | printf("BootKey = 0x%08lx\n",bootkey); | 499 | printf("BootKey = 0x%08lx\n",bootkey); |
484 | send(bootkey); | 500 | send(bootkey); |
485 | /* | 501 | /* |
486 | printf("GBA Found! Waiting on BIOS...\n"); | 502 | printf("GBA Found! Waiting on BIOS...\n"); |
487 | 503 | ||
488 | resbuf[2]=0; | 504 | resbuf[2]=0; |
@@ -557,12 +573,12 @@ int main(int argc, char *argv[]) | |||
557 | endproc(); | 573 | endproc(); |
558 | } else if (btns & PAD_BUTTON_A) | 574 | } else if (btns & PAD_BUTTON_A) |
559 | {*/ | 575 | {*/ |
560 | sleep(1); | 576 | sleep(2); |
561 | //recv(); | 577 | //recv(); |
562 | 578 | ||
563 | //if (recv() == 0) //ready | 579 | //if (recv() == 0) //ready |
564 | { | 580 | //{ |
565 | 581 | {{ | |
566 | printf("Waiting for GBA...\n"); | 582 | printf("Waiting for GBA...\n"); |
567 | while (recv() != 0) {fsleep(1);}; | 583 | while (recv() != 0) {fsleep(1);}; |
568 | send(0); | 584 | send(0); |
@@ -604,6 +620,7 @@ int main(int argc, char *argv[]) | |||
604 | 620 | ||
605 | send(0); | 621 | send(0); |
606 | while (recv()!=0) {fsleep(1);}; | 622 | while (recv()!=0) {fsleep(1);}; |
623 | send(0); | ||
607 | //sleep(1); | 624 | //sleep(1); |
608 | 625 | ||
609 | if (gameId == -1) | 626 | if (gameId == -1) |
@@ -644,27 +661,26 @@ int main(int argc, char *argv[]) | |||
644 | 661 | ||
645 | send(0); | 662 | send(0); |
646 | while (recv()!=0) {fsleep(1);}; | 663 | while (recv()!=0) {fsleep(1);}; |
664 | send(0); | ||
647 | //sleep(1); | 665 | //sleep(1); |
648 | /* | 666 | |
649 | // Get trainer name | 667 | // Get trainer name |
650 | u8 trainerName[8]; | 668 | u8 trainerName[8]; |
651 | 669 | ||
652 | u32 tnd = recv(); | 670 | u32 tnd = getMsg(); |
653 | send(0); | 671 | //send(0); |
654 | trainerName[0] = (tnd & 0xFF000000); | 672 | trainerName[0] = (tnd & 0xFF000000) >> 24; |
655 | trainerName[1] = (tnd & 0x00FF0000) >> 8; | 673 | trainerName[1] = (tnd & 0x00FF0000) >> 16; |
656 | trainerName[2] = (tnd & 0x0000FF00) >> 16; | 674 | trainerName[2] = (tnd & 0x0000FF00) >> 8; |
657 | trainerName[3] = (tnd & 0x000000FF) >> 24; | 675 | trainerName[3] = (tnd & 0x000000FF); |
658 | 676 | ||
659 | tnd = recv(); | 677 | tnd = getMsg(); |
660 | send(0); | 678 | //send(0); |
661 | trainerName[4] = (tnd & 0xFF000000); | 679 | trainerName[4] = (tnd & 0xFF000000) >> 24; |
662 | trainerName[5] = (tnd & 0x00FF0000) >> 8; | 680 | trainerName[5] = (tnd & 0x00FF0000) >> 16; |
663 | trainerName[6] = (tnd & 0x0000FF00) >> 16; | 681 | trainerName[6] = (tnd & 0x0000FF00) >> 8; |
664 | trainerName[7] = (tnd & 0x000000FF) >> 24; | 682 | trainerName[7] = (tnd & 0x000000FF); |
665 | 683 | ||
666 | printf("Trainer: %s", (char*) trainerName); | ||
667 | */ | ||
668 | // Get trainer ID | 684 | // Get trainer ID |
669 | u32 trainerId = 0; | 685 | u32 trainerId = 0; |
670 | while (trainerId == 0) | 686 | while (trainerId == 0) |
@@ -674,7 +690,20 @@ int main(int argc, char *argv[]) | |||
674 | } | 690 | } |
675 | send(0); | 691 | send(0); |
676 | while (recv()!=0) {fsleep(1);}; | 692 | while (recv()!=0) {fsleep(1);}; |
693 | send(0); | ||
677 | //sleep(1); | 694 | //sleep(1); |
695 | |||
696 | printf("Trainer: "); | ||
697 | |||
698 | for (int i = 0; i < 8; i++) | ||
699 | { | ||
700 | if (trainerName[i] == 0xFF) | ||
701 | { | ||
702 | break; | ||
703 | } else { | ||
704 | printf("%c", debugGen3Decode(trainerName[i])); | ||
705 | } | ||
706 | } | ||
678 | 707 | ||
679 | printf(" (%ld)\n", trainerId); | 708 | printf(" (%ld)\n", trainerId); |
680 | 709 | ||
@@ -917,9 +946,9 @@ int main(int argc, char *argv[]) | |||
917 | sleep(5); | 946 | sleep(5); |
918 | } | 947 | } |
919 | }*/ | 948 | }*/ |
920 | // } | 949 | } |
921 | // } | 950 | // } |
922 | // } | 951 | // } |
923 | } | 952 | } |
924 | return 0; | 953 | return 0; |
925 | } | 954 | } |