Skip to content

Commit

Permalink
-added the ability to clear the save on the gba cartridge directly
Browse files Browse the repository at this point in the history
  • Loading branch information
FIX94 committed Jul 21, 2016
1 parent c8cb99e commit 004575f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
25 changes: 17 additions & 8 deletions gba/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(void) {
// ansi escape sequence to set print co-ordinates
// /x1b[line;columnH
u32 i;
iprintf("\x1b[9;2HGBA Link Cable Dumper v1.5\n");
iprintf("\x1b[9;2HGBA Link Cable Dumper v1.6\n");
iprintf("\x1b[10;4HPlease look at the TV\n");
// disable this, needs power
SNDSTAT = 0;
Expand Down Expand Up @@ -156,15 +156,24 @@ int main(void) {
REG_HS_CTRL |= JOY_RW;
}
}
else if(choseval == 3)
else if(choseval == 3 || choseval == 4)
{
REG_JOYTR = savesize;
//receive the save
for(i = 0; i < savesize; i+=4)
if(choseval == 3)
{
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
REG_HS_CTRL |= JOY_RW;
*(vu32*)(save_data+i) = REG_JOYRE;
//receive the save
for(i = 0; i < savesize; i+=4)
{
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
REG_HS_CTRL |= JOY_RW;
*(vu32*)(save_data+i) = REG_JOYRE;
}
}
else
{
//clear the save
for(i = 0; i < savesize; i+=4)
*(vu32*)(save_data+i) = 0;
}
//disable interrupts
u32 prevIrqMask = REG_IME;
Expand Down Expand Up @@ -203,7 +212,7 @@ int main(void) {
{
REG_HS_CTRL |= JOY_RW;
u32 choseval = REG_JOYRE;
if(choseval == 4)
if(choseval == 5)
{
//disable interrupts
u32 prevIrqMask = REG_IME;
Expand Down
27 changes: 18 additions & 9 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void printmain()
{
printf("\x1b[2J");
printf("\x1b[37m");
printf("GBA Link Cable Dumper v1.5 by FIX94\n");
printf("GBA Link Cable Dumper v1.6 by FIX94\n");
printf("Save Support based on SendSave by Chishm\n");
printf("GBA BIOS Dumper by Dark Fader\n \n");
}
Expand Down Expand Up @@ -354,7 +354,8 @@ int main(int argc, char *argv[])
if(savesize > 0)
{
printf("Press Y to backup this save file.\n");
printf("Press X to restore this save file.\n\n");
printf("Press X to restore this save file.\n");
printf("Press Z to clear the save file on the GBA Cartridge.\n\n");
}
else
printf("\n");
Expand Down Expand Up @@ -385,6 +386,11 @@ int main(int argc, char *argv[])
command = 3;
break;
}
else if(btns&PAD_TRIGGER_Z)
{
command = 4;
break;
}
}
}
if(command == 1)
Expand Down Expand Up @@ -490,19 +496,22 @@ int main(int argc, char *argv[])
printf("Save backed up!\n");
sleep(5);
}
else if(command == 3)
else if(command == 3 || command == 4)
{
printf("Sending save\n");
VIDEO_WaitVSync();
u32 readval = 0;
while(readval != savesize)
readval = __builtin_bswap32(recv());
for(i = 0; i < savesize; i+=4)
send(__builtin_bswap32(*(vu32*)(testdump+i)));
if(command == 3)
{
printf("Sending save\n");
VIDEO_WaitVSync();
for(i = 0; i < savesize; i+=4)
send(__builtin_bswap32(*(vu32*)(testdump+i)));
}
printf("Waiting for GBA\n");
while(recv() != 0)
VIDEO_WaitVSync();
printf("Save restored!\n");
printf(command == 3 ? "Save restored!\n" : "Save cleared!\n");
send(0);
sleep(5);
}
Expand All @@ -526,7 +535,7 @@ int main(int argc, char *argv[])
if(!f)
fatalError("ERROR: Could not create file! Exit...");
//send over bios dump command
send(4);
send(5);
//the gba might still be in a loop itself
sleep(1);
//lets go!
Expand Down

0 comments on commit 004575f

Please sign in to comment.