-added the ability to clear the save on the gba cartridge directly

This commit is contained in:
FIX94
2016-07-21 23:54:13 +02:00
parent c8cb99e4ac
commit 004575f7ce
2 changed files with 35 additions and 17 deletions

View File

@@ -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;
@@ -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;
@@ -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;

View File

@@ -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");
}
@@ -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");
@@ -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)
@@ -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);
}
@@ -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!