mirror of
https://github.com/FIX94/gba-link-cable-dumper.git
synced 2026-09-08 16:45:10 -05:00
added gba bios dumping
This commit is contained in:
@@ -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.3\n");
|
||||
iprintf("\x1b[9;2HGBA Link Cable Dumper v1.4\n");
|
||||
iprintf("\x1b[10;4HPlease look at the TV\n");
|
||||
// disable this, needs power
|
||||
SNDSTAT = 0;
|
||||
@@ -66,7 +66,7 @@ int main(void) {
|
||||
//clear out previous messages
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
while (1) {
|
||||
if((REG_HS_CTRL&JOY_READ))
|
||||
if(REG_HS_CTRL&JOY_READ)
|
||||
{
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
s32 gamesize = getGameSize();
|
||||
@@ -199,6 +199,32 @@ int main(void) {
|
||||
}
|
||||
REG_JOYTR = 0;
|
||||
}
|
||||
else if(REG_HS_CTRL&JOY_WRITE)
|
||||
{
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
u32 choseval = REG_JOYRE;
|
||||
if(choseval == 4)
|
||||
{
|
||||
//disable interrupts
|
||||
u32 prevIrqMask = REG_IME;
|
||||
REG_IME = 0;
|
||||
//dump BIOS
|
||||
for (i = 0; i < 0x4000; i+=4)
|
||||
{
|
||||
// the lower bits are inaccurate, so just get it four times :)
|
||||
u32 a = MidiKey2Freq((WaveData *)(i-4), 180-12, 0) * 2;
|
||||
u32 b = MidiKey2Freq((WaveData *)(i-3), 180-12, 0) * 2;
|
||||
u32 c = MidiKey2Freq((WaveData *)(i-2), 180-12, 0) * 2;
|
||||
u32 d = MidiKey2Freq((WaveData *)(i-1), 180-12, 0) * 2;
|
||||
REG_JOYTR = ((a>>24<<24) | (d>>24<<16) | (c>>24<<8) | (b>>24));
|
||||
while((REG_HS_CTRL&JOY_READ) == 0) ;
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
}
|
||||
//restore interrupts
|
||||
REG_IME = prevIrqMask;
|
||||
}
|
||||
REG_JOYTR = 0;
|
||||
}
|
||||
Halt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@ void printmain()
|
||||
{
|
||||
printf("\x1b[2J");
|
||||
printf("\x1b[37m");
|
||||
printf("GBA Link Cable Dumper v1.3 by FIX94\n");
|
||||
printf("GBA Link Cable Dumper v1.4 by FIX94\n");
|
||||
printf("Save Support based on SendSave by Chishm\n");
|
||||
printf("GBA BIOS Dumper by Dark Fader\n \n");
|
||||
}
|
||||
|
||||
u8 *resbuf,*cmdbuf;
|
||||
@@ -312,7 +313,8 @@ int main(int argc, char *argv[])
|
||||
while(1)
|
||||
{
|
||||
printmain();
|
||||
printf("Press A once you have a GBA Game inserted.\n \n");
|
||||
printf("Press A once you have a GBA Game inserted.\n");
|
||||
printf("Press Y to backup the GBA BIOS.\n \n");
|
||||
PAD_ScanPads();
|
||||
VIDEO_WaitVSync();
|
||||
u32 btns = PAD_ButtonsDown(0);
|
||||
@@ -512,6 +514,41 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(btns&PAD_BUTTON_Y)
|
||||
{
|
||||
char biosname[64];
|
||||
sprintf(biosname,"/dumps/gba_bios.bin");
|
||||
FILE *f = fopen(biosname,"rb");
|
||||
if(f)
|
||||
{
|
||||
fclose(f);
|
||||
warnError("ERROR: BIOS already backed up!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//create base file with size
|
||||
printf("Preparing file...\n");
|
||||
createFile(biosname,0x4000);
|
||||
f = fopen(biosname,"wb");
|
||||
if(!f)
|
||||
fatalError("ERROR: Could not create file! Exit...");
|
||||
//send over bios dump command
|
||||
sendsafe_wait(4);
|
||||
//the gba might still be in a loop itself
|
||||
VIDEO_WaitVSync(); VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync(); VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync(); VIDEO_WaitVSync();
|
||||
//lets go!
|
||||
printf("Dumping...\n");
|
||||
for(i = 0; i < 0x4000; i+=4)
|
||||
*(vu32*)(testdump+i) = recvsafe();
|
||||
fwrite(testdump,0x4000,1,f);
|
||||
printf("Closing file\n");
|
||||
fclose(f);
|
||||
printf("BIOS dumped!\n");
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user