about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--gba/source/main.c25
-rw-r--r--source/main.c27
2 files changed, 35 insertions, 17 deletions
diff --git a/gba/source/main.c b/gba/source/main.c index f309db2..ee94c35 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.5\n"); 59 iprintf("\x1b[9;2HGBA Link Cable Dumper v1.6\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;
@@ -156,15 +156,24 @@ int main(void) {
156 REG_HS_CTRL |= JOY_RW; 156 REG_HS_CTRL |= JOY_RW;
157 } 157 }
158 } 158 }
159 else if(choseval == 3) 159 else if(choseval == 3 || choseval == 4)
160 { 160 {
161 REG_JOYTR = savesize; 161 REG_JOYTR = savesize;
162 //receive the save 162 if(choseval == 3)
163 for(i = 0; i < savesize; i+=4)
164 { 163 {
165 while((REG_HS_CTRL&JOY_WRITE) == 0) ; 164 //receive the save
166 REG_HS_CTRL |= JOY_RW; 165 for(i = 0; i < savesize; i+=4)
167 *(vu32*)(save_data+i) = REG_JOYRE; 166 {
167 while((REG_HS_CTRL&JOY_WRITE) == 0) ;
168 REG_HS_CTRL |= JOY_RW;
169 *(vu32*)(save_data+i) = REG_JOYRE;
170 }
171 }
172 else
173 {
174 //clear the save
175 for(i = 0; i < savesize; i+=4)
176 *(vu32*)(save_data+i) = 0;
168 } 177 }
169 //disable interrupts 178 //disable interrupts
170 u32 prevIrqMask = REG_IME; 179 u32 prevIrqMask = REG_IME;
@@ -203,7 +212,7 @@ int main(void) {
203 { 212 {
204 REG_HS_CTRL |= JOY_RW; 213 REG_HS_CTRL |= JOY_RW;
205 u32 choseval = REG_JOYRE; 214 u32 choseval = REG_JOYRE;
206 if(choseval == 4) 215 if(choseval == 5)
207 { 216 {
208 //disable interrupts 217 //disable interrupts
209 u32 prevIrqMask = REG_IME; 218 u32 prevIrqMask = REG_IME;
diff --git a/source/main.c b/source/main.c index 53879de..7fd5683 100644 --- a/source/main.c +++ b/source/main.c
@@ -27,7 +27,7 @@ void printmain()
27{ 27{
28 printf("\x1b[2J"); 28 printf("\x1b[2J");
29 printf("\x1b[37m"); 29 printf("\x1b[37m");
30 printf("GBA Link Cable Dumper v1.5 by FIX94\n"); 30 printf("GBA Link Cable Dumper v1.6 by FIX94\n");
31 printf("Save Support based on SendSave by Chishm\n"); 31 printf("Save Support based on SendSave by Chishm\n");
32 printf("GBA BIOS Dumper by Dark Fader\n \n"); 32 printf("GBA BIOS Dumper by Dark Fader\n \n");
33} 33}
@@ -354,7 +354,8 @@ int main(int argc, char *argv[])
354 if(savesize > 0) 354 if(savesize > 0)
355 { 355 {
356 printf("Press Y to backup this save file.\n"); 356 printf("Press Y to backup this save file.\n");
357 printf("Press X to restore this save file.\n\n"); 357 printf("Press X to restore this save file.\n");
358 printf("Press Z to clear the save file on the GBA Cartridge.\n\n");
358 } 359 }
359 else 360 else
360 printf("\n"); 361 printf("\n");
@@ -385,6 +386,11 @@ int main(int argc, char *argv[])
385 command = 3; 386 command = 3;
386 break; 387 break;
387 } 388 }
389 else if(btns&PAD_TRIGGER_Z)
390 {
391 command = 4;
392 break;
393 }
388 } 394 }
389 } 395 }
390 if(command == 1) 396 if(command == 1)
@@ -490,19 +496,22 @@ int main(int argc, char *argv[])
490 printf("Save backed up!\n"); 496 printf("Save backed up!\n");
491 sleep(5); 497 sleep(5);
492 } 498 }
493 else if(command == 3) 499 else if(command == 3 || command == 4)
494 { 500 {
495 printf("Sending save\n");
496 VIDEO_WaitVSync();
497 u32 readval = 0; 501 u32 readval = 0;
498 while(readval != savesize) 502 while(readval != savesize)
499 readval = __builtin_bswap32(recv()); 503 readval = __builtin_bswap32(recv());
500 for(i = 0; i < savesize; i+=4) 504 if(command == 3)
501 send(__builtin_bswap32(*(vu32*)(testdump+i))); 505 {
506 printf("Sending save\n");
507 VIDEO_WaitVSync();
508 for(i = 0; i < savesize; i+=4)
509 send(__builtin_bswap32(*(vu32*)(testdump+i)));
510 }
502 printf("Waiting for GBA\n"); 511 printf("Waiting for GBA\n");
503 while(recv() != 0) 512 while(recv() != 0)
504 VIDEO_WaitVSync(); 513 VIDEO_WaitVSync();
505 printf("Save restored!\n"); 514 printf(command == 3 ? "Save restored!\n" : "Save cleared!\n");
506 send(0); 515 send(0);
507 sleep(5); 516 sleep(5);
508 } 517 }
@@ -526,7 +535,7 @@ int main(int argc, char *argv[])
526 if(!f) 535 if(!f)
527 fatalError("ERROR: Could not create file! Exit..."); 536 fatalError("ERROR: Could not create file! Exit...");
528 //send over bios dump command 537 //send over bios dump command
529 send(4); 538 send(5);
530 //the gba might still be in a loop itself 539 //the gba might still be in a loop itself
531 sleep(1); 540 sleep(1);
532 //lets go! 541 //lets go!