diff options
author | FIX94 <fix94.1@gmail.com> | 2016-04-10 16:14:38 +0200 |
---|---|---|
committer | FIX94 <fix94.1@gmail.com> | 2016-04-10 16:14:38 +0200 |
commit | 089ba86faf70be52e25eef5bbfbeb54439ea67f6 (patch) | |
tree | 851b0142a0a55139d9ba529938555b75b8f1d620 | |
parent | 378d297c658754980a03df1dbd7ff141ee59ae81 (diff) | |
download | gen3uploader-089ba86faf70be52e25eef5bbfbeb54439ea67f6.tar.gz gen3uploader-089ba86faf70be52e25eef5bbfbeb54439ea67f6.tar.bz2 gen3uploader-089ba86faf70be52e25eef5bbfbeb54439ea67f6.zip |
added gba bios dumping
-rw-r--r-- | gba/source/main.c | 30 | ||||
-rw-r--r-- | source/main.c | 41 |
2 files changed, 67 insertions, 4 deletions
diff --git a/gba/source/main.c b/gba/source/main.c index 49cf2a1..d3782a6 100644 --- a/gba/source/main.c +++ b/gba/source/main.c | |||
@@ -56,7 +56,7 @@ int main(void) { | |||
56 | // ansi escape sequence to set print co-ordinates | 56 | // ansi escape sequence to set print co-ordinates |
57 | // /x1b[line;columnH | 57 | // /x1b[line;columnH |
58 | u32 i; | 58 | u32 i; |
59 | iprintf("\x1b[9;2HGBA Link Cable Dumper v1.3\n"); | 59 | iprintf("\x1b[9;2HGBA Link Cable Dumper v1.4\n"); |
60 | iprintf("\x1b[10;4HPlease look at the TV\n"); | 60 | iprintf("\x1b[10;4HPlease look at the TV\n"); |
61 | // disable this, needs power | 61 | // disable this, needs power |
62 | SNDSTAT = 0; | 62 | SNDSTAT = 0; |
@@ -66,7 +66,7 @@ int main(void) { | |||
66 | //clear out previous messages | 66 | //clear out previous messages |
67 | REG_HS_CTRL |= JOY_RW; | 67 | REG_HS_CTRL |= JOY_RW; |
68 | while (1) { | 68 | while (1) { |
69 | if((REG_HS_CTRL&JOY_READ)) | 69 | if(REG_HS_CTRL&JOY_READ) |
70 | { | 70 | { |
71 | REG_HS_CTRL |= JOY_RW; | 71 | REG_HS_CTRL |= JOY_RW; |
72 | s32 gamesize = getGameSize(); | 72 | s32 gamesize = getGameSize(); |
@@ -199,6 +199,32 @@ int main(void) { | |||
199 | } | 199 | } |
200 | REG_JOYTR = 0; | 200 | REG_JOYTR = 0; |
201 | } | 201 | } |
202 | else if(REG_HS_CTRL&JOY_WRITE) | ||
203 | { | ||
204 | REG_HS_CTRL |= JOY_RW; | ||
205 | u32 choseval = REG_JOYRE; | ||
206 | if(choseval == 4) | ||
207 | { | ||
208 | //disable interrupts | ||
209 | u32 prevIrqMask = REG_IME; | ||
210 | REG_IME = 0; | ||
211 | //dump BIOS | ||
212 | for (i = 0; i < 0x4000; i+=4) | ||
213 | { | ||
214 | // the lower bits are inaccurate, so just get it four times :) | ||
215 | u32 a = MidiKey2Freq((WaveData *)(i-4), 180-12, 0) * 2; | ||
216 | u32 b = MidiKey2Freq((WaveData *)(i-3), 180-12, 0) * 2; | ||
217 | u32 c = MidiKey2Freq((WaveData *)(i-2), 180-12, 0) * 2; | ||
218 | u32 d = MidiKey2Freq((WaveData *)(i-1), 180-12, 0) * 2; | ||
219 | REG_JOYTR = ((a>>24<<24) | (d>>24<<16) | (c>>24<<8) | (b>>24)); | ||
220 | while((REG_HS_CTRL&JOY_READ) == 0) ; | ||
221 | REG_HS_CTRL |= JOY_RW; | ||
222 | } | ||
223 | //restore interrupts | ||
224 | REG_IME = prevIrqMask; | ||
225 | } | ||
226 | REG_JOYTR = 0; | ||
227 | } | ||
202 | Halt(); | 228 | Halt(); |
203 | } | 229 | } |
204 | } | 230 | } |
diff --git a/source/main.c b/source/main.c index 6c34b92..f57aa6f 100644 --- a/source/main.c +++ b/source/main.c | |||
@@ -23,8 +23,9 @@ void printmain() | |||
23 | { | 23 | { |
24 | printf("\x1b[2J"); | 24 | printf("\x1b[2J"); |
25 | printf("\x1b[37m"); | 25 | printf("\x1b[37m"); |
26 | printf("GBA Link Cable Dumper v1.3 by FIX94\n"); | 26 | printf("GBA Link Cable Dumper v1.4 by FIX94\n"); |
27 | printf("Save Support based on SendSave by Chishm\n"); | 27 | printf("Save Support based on SendSave by Chishm\n"); |
28 | printf("GBA BIOS Dumper by Dark Fader\n \n"); | ||
28 | } | 29 | } |
29 | 30 | ||
30 | u8 *resbuf,*cmdbuf; | 31 | u8 *resbuf,*cmdbuf; |
@@ -312,7 +313,8 @@ int main(int argc, char *argv[]) | |||
312 | while(1) | 313 | while(1) |
313 | { | 314 | { |
314 | printmain(); | 315 | printmain(); |
315 | printf("Press A once you have a GBA Game inserted.\n \n"); | 316 | printf("Press A once you have a GBA Game inserted.\n"); |
317 | printf("Press Y to backup the GBA BIOS.\n \n"); | ||
316 | PAD_ScanPads(); | 318 | PAD_ScanPads(); |
317 | VIDEO_WaitVSync(); | 319 | VIDEO_WaitVSync(); |
318 | u32 btns = PAD_ButtonsDown(0); | 320 | u32 btns = PAD_ButtonsDown(0); |
@@ -512,6 +514,41 @@ int main(int argc, char *argv[]) | |||
512 | } | 514 | } |
513 | } | 515 | } |
514 | } | 516 | } |
517 | else if(btns&PAD_BUTTON_Y) | ||
518 | { | ||
519 | char biosname[64]; | ||
520 | sprintf(biosname,"/dumps/gba_bios.bin"); | ||
521 | FILE *f = fopen(biosname,"rb"); | ||
522 | if(f) | ||
523 | { | ||
524 | fclose(f); | ||
525 | warnError("ERROR: BIOS already backed up!\n"); | ||
526 | } | ||
527 | else | ||
528 | { | ||
529 | //create base file with size | ||
530 | printf("Preparing file...\n"); | ||
531 | createFile(biosname,0x4000); | ||
532 | f = fopen(biosname,"wb"); | ||
533 | if(!f) | ||
534 | fatalError("ERROR: Could not create file! Exit..."); | ||
535 | //send over bios dump command | ||
536 | sendsafe_wait(4); | ||
537 | //the gba might still be in a loop itself | ||
538 | VIDEO_WaitVSync(); VIDEO_WaitVSync(); | ||
539 | VIDEO_WaitVSync(); VIDEO_WaitVSync(); | ||
540 | VIDEO_WaitVSync(); VIDEO_WaitVSync(); | ||
541 | //lets go! | ||
542 | printf("Dumping...\n"); | ||
543 | for(i = 0; i < 0x4000; i+=4) | ||
544 | *(vu32*)(testdump+i) = recvsafe(); | ||
545 | fwrite(testdump,0x4000,1,f); | ||
546 | printf("Closing file\n"); | ||
547 | fclose(f); | ||
548 | printf("BIOS dumped!\n"); | ||
549 | sleep(5); | ||
550 | } | ||
551 | } | ||
515 | } | 552 | } |
516 | } | 553 | } |
517 | } | 554 | } |