mirror of
https://github.com/FIX94/gba-link-cable-dumper.git
synced 2026-03-21 17:25:22 -05:00
general cleanup
This commit is contained in:
parent
2abebc4d06
commit
42379a1cc4
|
|
@ -25,7 +25,7 @@ INCLUDES := source
|
|||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
|
||||
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ INCLUDES := source
|
|||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
|
||||
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
||||
|
|
|
|||
|
|
@ -4,92 +4,18 @@
|
|||
routine with a pointer to an appropriately sized array of data to
|
||||
be read from or written to the cartridge.
|
||||
Data types are from wintermute's gba_types.h libgba library.
|
||||
Original file from SendSave by Chishm
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//---------------------------------------------------------------------------------
|
||||
#ifndef _gba_types_h_
|
||||
#define _gba_types_h_
|
||||
//---------------------------------------------------------------------------------
|
||||
#include <gba_dma.h>
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Data types
|
||||
//---------------------------------------------------------------------------------
|
||||
/** Unsigned 8 bit value
|
||||
|
||||
*/
|
||||
typedef unsigned char u8;
|
||||
/** Unsigned 16 bit value
|
||||
|
||||
*/
|
||||
typedef unsigned short int u16;
|
||||
/** Unsigned 32 bit value
|
||||
|
||||
*/
|
||||
typedef unsigned int u32;
|
||||
|
||||
/** signed 8 bit value
|
||||
|
||||
*/
|
||||
typedef signed char s8;
|
||||
/** Signed 16 bit value
|
||||
|
||||
*/
|
||||
typedef signed short int s16;
|
||||
/** Signed 32 bit value
|
||||
|
||||
*/
|
||||
typedef signed int s32;
|
||||
|
||||
/** Unsigned volatile 8 bit value
|
||||
|
||||
*/
|
||||
typedef volatile u8 vu8;
|
||||
/** Unsigned volatile 16 bit value
|
||||
|
||||
*/
|
||||
typedef volatile u16 vu16;
|
||||
/** Unsigned volatile 32 bit value
|
||||
|
||||
*/
|
||||
typedef volatile u32 vu32;
|
||||
|
||||
/** Unsigned volatile 8 bit value
|
||||
|
||||
*/
|
||||
typedef volatile s8 vs8;
|
||||
/** Signed volatile 16 bit value
|
||||
|
||||
*/
|
||||
typedef volatile s16 vs16;
|
||||
/** Signed volatile 32 bit value
|
||||
|
||||
*/
|
||||
typedef volatile s32 vs32;
|
||||
|
||||
#ifndef __cplusplus
|
||||
/** C++ compatible bool for C
|
||||
|
||||
*/
|
||||
typedef enum { false, true } bool;
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
#endif // data types
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#define EEPROM_ADDRESS (volatile u16*)0xDFFFF00
|
||||
#define SRAM_ADDRESS (volatile u16*)0x0E000000
|
||||
#define FLASH_1M_ADDRESS (volatile u16*)0x09FE0000
|
||||
#define REG_EEPROM (*(volatile u16*)0xDFFFF00)
|
||||
#define REG_DM3SAD (*(volatile u32*)0x40000D4)
|
||||
#define REG_DM3DAD (*(volatile u32*)0x40000D8)
|
||||
#define REG_DM3CNT (*(volatile u32*)0x40000DC)
|
||||
#define REG_DM3CNT_H (*(volatile u16*)0x40000DE)
|
||||
#define REG_WAITCNT (*(volatile u16*)0x4000204)
|
||||
#define EEPROM_ADDRESS (0xDFFFF00)
|
||||
#define REG_EEPROM *(vu16 *)(EEPROM_ADDRESS)
|
||||
#define REG_DMA3CNT_H *(vu16 *)(REG_BASE + 0x0de)
|
||||
#define REG_WAITCNT *(vu16 *)(REG_BASE + 0x204)
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Common EEPROM Routines
|
||||
|
|
@ -98,19 +24,19 @@ typedef enum { false, true } bool;
|
|||
void EEPROM_SendPacket( u16* packet, int size )
|
||||
{
|
||||
REG_WAITCNT = (REG_WAITCNT & 0xF8FF) | 0x0300;
|
||||
REG_DM3SAD = (u32)packet;
|
||||
REG_DM3DAD = (u32)EEPROM_ADDRESS;
|
||||
REG_DM3CNT = 0x80000000 + size;
|
||||
while((REG_DM3CNT_H & 0x8000) != 0) ;
|
||||
REG_DMA3SAD = (u32)packet;
|
||||
REG_DMA3DAD = EEPROM_ADDRESS;
|
||||
REG_DMA3CNT = 0x80000000 + size;
|
||||
while((REG_DMA3CNT_H & 0x8000) != 0) ;
|
||||
}
|
||||
|
||||
void EEPROM_ReceivePacket( u16* packet, int size )
|
||||
{
|
||||
REG_WAITCNT = (REG_WAITCNT & 0xF8FF) | 0x0300;
|
||||
REG_DM3SAD = (u32)EEPROM_ADDRESS;
|
||||
REG_DM3DAD = (u32)packet;
|
||||
REG_DM3CNT = 0x80000000 + size;
|
||||
while((REG_DM3CNT_H & 0x8000) != 0) ;
|
||||
REG_DMA3SAD = EEPROM_ADDRESS;
|
||||
REG_DMA3DAD = (u32)packet;
|
||||
REG_DMA3CNT = 0x80000000 + size;
|
||||
while((REG_DMA3CNT_H & 0x8000) != 0) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
@ -213,9 +139,6 @@ void GetSave_EEPROM_512B(u8* data)
|
|||
volatile u8 x;
|
||||
u32 sleep;
|
||||
|
||||
// Set up waitstates for EEPROM access etc.
|
||||
*(volatile unsigned short *)0x04000204 = 0x4317;
|
||||
|
||||
for (x=0;x<64;++x){
|
||||
EEPROM_Read_512B(x,&data[x*8]);
|
||||
for(sleep=0;sleep<512000;sleep++);
|
||||
|
|
@ -229,9 +152,6 @@ void PutSave_EEPROM_512B(u8* data)
|
|||
volatile u8 x;
|
||||
u32 sleep;
|
||||
|
||||
// Set up waitstates for EEPROM access etc.
|
||||
*(volatile unsigned short *)0x04000204 = 0x4317;
|
||||
|
||||
for (x=0;x<64;x++){
|
||||
EEPROM_Write_512B(x,&data[x*8]);
|
||||
for(sleep=0;sleep<512000;sleep++);
|
||||
|
|
@ -354,9 +274,6 @@ void GetSave_EEPROM_8KB(u8* data)
|
|||
volatile u16 x;
|
||||
u32 sleep;
|
||||
|
||||
// Set up waitstates for EEPROM access etc.
|
||||
*(volatile unsigned short *)0x04000204 = 0x4317;
|
||||
|
||||
for (x=0;x<1024;x++){
|
||||
EEPROM_Read_8KB(x,&data[x*8]);
|
||||
for(sleep=0;sleep<512000;sleep++);
|
||||
|
|
@ -371,9 +288,6 @@ void PutSave_EEPROM_8KB(u8* data)
|
|||
volatile u16 x;
|
||||
u32 sleep;
|
||||
|
||||
// Set up waitstates for EEPROM access etc.
|
||||
*(volatile unsigned short *)0x04000204 = 0x4317;
|
||||
|
||||
for (x=0;x<1024;x++){
|
||||
EEPROM_Write_8KB(x,&data[x*8]);
|
||||
for(sleep=0;sleep<512000;sleep++);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
|
||||
#include <gba_console.h>
|
||||
#include <gba_video.h>
|
||||
#include <gba_interrupt.h>
|
||||
#include <gba_systemcalls.h>
|
||||
#include <gba_input.h>
|
||||
#include <gba_sio.h>
|
||||
/*
|
||||
* Copyright (C) 2016 FIX94
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
#include <gba.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "libSave.h"
|
||||
|
||||
#define REG_WAITCNT *(vu16 *)(REG_BASE + 0x204)
|
||||
#define JOY_WRITE 2
|
||||
#define JOY_READ 4
|
||||
#define JOY_RW 6
|
||||
|
||||
u8 save_data[0x20000] __attribute__ ((section (".sbss")));
|
||||
|
||||
s32 getGameSize(void)
|
||||
|
|
@ -33,8 +38,7 @@ s32 getGameSize(void)
|
|||
}
|
||||
return i;
|
||||
}
|
||||
#define JOY_WRITE 2
|
||||
#define JOY_READ 4
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Program entry point
|
||||
//---------------------------------------------------------------------------------
|
||||
|
|
@ -52,31 +56,32 @@ int main(void) {
|
|||
// ansi escape sequence to set print co-ordinates
|
||||
// /x1b[line;columnH
|
||||
u32 i;
|
||||
iprintf("\x1b[9;10HROM Dumper\n");
|
||||
iprintf("\x1b[10;5HPlease look at the TV\n");
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
u32 prevIrqMask = REG_IME;
|
||||
iprintf("\x1b[9;2HGBA Link Cable Dumper v1.3\n");
|
||||
iprintf("\x1b[10;4HPlease look at the TV\n");
|
||||
// disable this, needs power
|
||||
SNDSTAT = 0;
|
||||
SNDBIAS = 0;
|
||||
// Set up waitstates for EEPROM access etc.
|
||||
REG_WAITCNT = 0x0317;
|
||||
//clear out previous messages
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
while (1) {
|
||||
if((REG_HS_CTRL&JOY_READ))
|
||||
{
|
||||
irqDisable(IRQ_VBLANK);
|
||||
REG_IME = 0;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
s32 gamesize = getGameSize();
|
||||
u32 savesize = SaveSize(save_data,gamesize);
|
||||
REG_JOYTR = gamesize;
|
||||
//wait for a cmd receive for safety
|
||||
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
REG_JOYTR = savesize;
|
||||
//wait for a cmd receive for safety
|
||||
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
if(gamesize == -1)
|
||||
{
|
||||
REG_JOYTR = 0;
|
||||
REG_IME = prevIrqMask;
|
||||
irqEnable(IRQ_VBLANK);
|
||||
continue; //nothing to read
|
||||
}
|
||||
//game in, send header
|
||||
|
|
@ -84,32 +89,38 @@ int main(void) {
|
|||
{
|
||||
REG_JOYTR = *(vu32*)(0x08000000+i);
|
||||
while((REG_HS_CTRL&JOY_READ) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
}
|
||||
REG_JOYTR = 0;
|
||||
//wait for other side to choose
|
||||
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
u32 choseval = REG_JOYRE;
|
||||
if(choseval == 0)
|
||||
{
|
||||
REG_JOYTR = 0;
|
||||
REG_IME = prevIrqMask;
|
||||
irqEnable(IRQ_VBLANK);
|
||||
continue; //nothing to read
|
||||
}
|
||||
else if(choseval == 1)
|
||||
{
|
||||
//disable interrupts
|
||||
u32 prevIrqMask = REG_IME;
|
||||
REG_IME = 0;
|
||||
//dump the game
|
||||
for(i = 0; i < gamesize; i+=4)
|
||||
{
|
||||
REG_JOYTR = *(vu32*)(0x08000000+i);
|
||||
while((REG_HS_CTRL&JOY_READ) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
}
|
||||
//restore interrupts
|
||||
REG_IME = prevIrqMask;
|
||||
}
|
||||
else if(choseval == 2)
|
||||
{
|
||||
//disable interrupts
|
||||
u32 prevIrqMask = REG_IME;
|
||||
REG_IME = 0;
|
||||
//backup save
|
||||
switch (savesize){
|
||||
case 0x200:
|
||||
|
|
@ -130,16 +141,19 @@ int main(void) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
//restore interrupts
|
||||
REG_IME = prevIrqMask;
|
||||
//say gc side we read it
|
||||
REG_JOYTR = savesize;
|
||||
//wait for a cmd receive for safety
|
||||
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
//send the save
|
||||
for(i = 0; i < savesize; i+=4)
|
||||
{
|
||||
REG_JOYTR = *(vu32*)(save_data+i);
|
||||
while((REG_HS_CTRL&JOY_READ) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
}
|
||||
}
|
||||
else if(choseval == 3)
|
||||
|
|
@ -149,9 +163,12 @@ int main(void) {
|
|||
for(i = 0; i < savesize; i+=4)
|
||||
{
|
||||
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
*(vu32*)(save_data+i) = REG_JOYRE;
|
||||
}
|
||||
//disable interrupts
|
||||
u32 prevIrqMask = REG_IME;
|
||||
REG_IME = 0;
|
||||
//write it
|
||||
switch (savesize){
|
||||
case 0x200:
|
||||
|
|
@ -172,14 +189,15 @@ int main(void) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
//restore interrupts
|
||||
REG_IME = prevIrqMask;
|
||||
//say gc side we're done
|
||||
REG_JOYTR = 0;
|
||||
//wait for a cmd receive for safety
|
||||
while((REG_HS_CTRL&JOY_WRITE) == 0) ;
|
||||
REG_HS_CTRL |= (JOY_WRITE|JOY_READ);
|
||||
REG_HS_CTRL |= JOY_RW;
|
||||
}
|
||||
REG_JOYTR = 0;
|
||||
REG_IME = prevIrqMask;
|
||||
irqEnable(IRQ_VBLANK);
|
||||
}
|
||||
Halt();
|
||||
}
|
||||
|
|
|
|||
114
source/main.c
114
source/main.c
|
|
@ -23,7 +23,7 @@ void printmain()
|
|||
{
|
||||
printf("\x1b[2J");
|
||||
printf("\x1b[37m");
|
||||
printf("GBA Link Cable Dumper v1.2 by FIX94\n");
|
||||
printf("GBA Link Cable Dumper v1.3 by FIX94\n");
|
||||
printf("Save Support based on SendSave by Chishm\n");
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +149,12 @@ void sendsafe(u32 msg)
|
|||
SI_Transfer(1,cmdbuf,5,resbuf,1,transcb,0);
|
||||
wait_for_transfer();
|
||||
}
|
||||
void sendsafe_wait(u32 msg)
|
||||
{
|
||||
sendsafe(msg);
|
||||
//wait for GBA
|
||||
usleep(5000);
|
||||
}
|
||||
u32 recvfast()
|
||||
{
|
||||
cmdbuf[0]=0x14; //read
|
||||
|
|
@ -169,6 +175,30 @@ bool dirExists(const char *path)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
void createFile(const char *path, size_t size)
|
||||
{
|
||||
int fd = open(path, O_WRONLY|O_CREAT);
|
||||
if(fd >= 0)
|
||||
{
|
||||
ftruncate(fd, size);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
void warnError(char *msg)
|
||||
{
|
||||
puts(msg);
|
||||
VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
sleep(2);
|
||||
}
|
||||
void fatalError(char *msg)
|
||||
{
|
||||
puts(msg);
|
||||
VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
sleep(5);
|
||||
exit(0);
|
||||
}
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
void *xfb = NULL;
|
||||
|
|
@ -195,21 +225,13 @@ int main(int argc, char *argv[])
|
|||
if(!fatInitDefault())
|
||||
{
|
||||
printmain();
|
||||
printf("ERROR: No usable device found to write dumped files to!\n");
|
||||
VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
sleep(5);
|
||||
exit(0);
|
||||
fatalError("ERROR: No usable device found to write dumped files to!");
|
||||
}
|
||||
mkdir("/dumps", S_IREAD | S_IWRITE);
|
||||
if(!dirExists("/dumps"))
|
||||
{
|
||||
printmain();
|
||||
printf("ERROR: Could not create dumps folder, make sure you have a supported device connected!\n");
|
||||
VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
sleep(5);
|
||||
exit(0);
|
||||
fatalError("ERROR: Could not create dumps folder, make sure you have a supported device connected!");
|
||||
}
|
||||
int i;
|
||||
while(1)
|
||||
|
|
@ -260,7 +282,7 @@ int main(int argc, char *argv[])
|
|||
for(i = 0; i < 0xC0; i+=4)
|
||||
{
|
||||
sendsafe(__builtin_bswap32(*(vu32*)(gba_mb_gba+i)));
|
||||
if(!(resbuf[0]&0x2)) printf("Possible error %02x\n",resbuf[0]);
|
||||
//if(!(resbuf[0]&0x2)) printf("Possible error %02x\n",resbuf[0]);
|
||||
}
|
||||
//printf("Header done! Sending ROM...\n");
|
||||
for(i = 0xC0; i < sendsize; i+=4)
|
||||
|
|
@ -272,7 +294,7 @@ int main(int argc, char *argv[])
|
|||
enc^=((~(i+(0x20<<20)))+1);
|
||||
enc^=0x20796220;
|
||||
sendsafe(enc);
|
||||
if(!(resbuf[0]&0x2)) printf("Possible error %02x\n",resbuf[0]);
|
||||
//if(!(resbuf[0]&0x2)) printf("Possible error %02x\n",resbuf[0]);
|
||||
}
|
||||
fcrc |= (sendsize<<16);
|
||||
//printf("ROM done! CRC: %08x\n", fcrc);
|
||||
|
|
@ -305,17 +327,12 @@ int main(int argc, char *argv[])
|
|||
int gbasize = 0;
|
||||
while(gbasize == 0)
|
||||
gbasize = __builtin_bswap32(recvsafe());
|
||||
sendsafe(0); //got gbasize
|
||||
usleep(5000); //wait for it to set next val
|
||||
sendsafe_wait(0); //got gbasize
|
||||
u32 savesize = __builtin_bswap32(recvsafe());
|
||||
sendsafe(0); //got savesize
|
||||
usleep(5000); //wait for it to set next val
|
||||
sendsafe_wait(0); //got savesize
|
||||
if(gbasize == -1)
|
||||
{
|
||||
printf("ERROR: No (Valid) GBA Card inserted!\n");
|
||||
VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
sleep(2);
|
||||
warnError("ERROR: No (Valid) GBA Card inserted!\n");
|
||||
continue;
|
||||
}
|
||||
//get rom header
|
||||
|
|
@ -383,9 +400,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
fclose(f);
|
||||
command = 0;
|
||||
printf("ERROR: Game already dumped!\n");
|
||||
VIDEO_WaitVSync();
|
||||
sleep(2);
|
||||
warnError("ERROR: Game already dumped!\n");
|
||||
}
|
||||
}
|
||||
else if(command == 2)
|
||||
|
|
@ -395,9 +410,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
fclose(f);
|
||||
command = 0;
|
||||
printf("ERROR: Save already backed up!\n");
|
||||
VIDEO_WaitVSync();
|
||||
sleep(2);
|
||||
warnError("ERROR: Save already backed up!\n");
|
||||
}
|
||||
}
|
||||
else if(command == 3)
|
||||
|
|
@ -411,9 +424,7 @@ int main(int argc, char *argv[])
|
|||
if(readsize != savesize)
|
||||
{
|
||||
command = 0;
|
||||
printf("ERROR: Save has the wrong size, aborting restore!\n");
|
||||
VIDEO_WaitVSync();
|
||||
sleep(2);
|
||||
warnError("ERROR: Save has the wrong size, aborting restore!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -425,34 +436,20 @@ int main(int argc, char *argv[])
|
|||
else
|
||||
{
|
||||
command = 0;
|
||||
printf("ERROR: No Save to restore!\n");
|
||||
VIDEO_WaitVSync();
|
||||
sleep(2);
|
||||
warnError("ERROR: No Save to restore!\n");
|
||||
}
|
||||
}
|
||||
sendsafe(command);
|
||||
usleep(5000); //wait for it to set next val
|
||||
sendsafe_wait(command);
|
||||
if(command == 0)
|
||||
continue;
|
||||
else if(command == 1)
|
||||
{
|
||||
//create base file with size
|
||||
printf("Creating file...\n");
|
||||
int fd = open(gamename, O_WRONLY|O_CREAT);
|
||||
if(fd >= 0)
|
||||
{
|
||||
ftruncate(fd, gbasize);
|
||||
close(fd);
|
||||
}
|
||||
printf("Preparing file...\n");
|
||||
createFile(gamename,gbasize);
|
||||
FILE *f = fopen(gamename,"wb");
|
||||
if(!f)
|
||||
{
|
||||
printf("ERROR: Could not create file! Exit...\n");
|
||||
VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
sleep(5);
|
||||
exit(0);
|
||||
}
|
||||
fatalError("ERROR: Could not create file! Exit...");
|
||||
printf("Dumping...\n");
|
||||
u32 bytes_read = 0;
|
||||
while(gbasize > 0)
|
||||
|
|
@ -464,10 +461,7 @@ int main(int argc, char *argv[])
|
|||
*(vu32*)(testdump+j) = recvfast();
|
||||
bytes_read+=4;
|
||||
if((bytes_read&0xFFFF) == 0)
|
||||
{
|
||||
printf("\r%02.02f MB done",(float)(bytes_read/1024)/1024.f);
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
}
|
||||
fwrite(testdump,toread,1,f);
|
||||
gbasize -= toread;
|
||||
|
|
@ -479,22 +473,18 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
else if(command == 2)
|
||||
{
|
||||
//create base file with size
|
||||
printf("Preparing file...\n");
|
||||
createFile(savename,savesize);
|
||||
FILE *f = fopen(savename,"wb");
|
||||
if(!f)
|
||||
{
|
||||
printf("ERROR: Could not create file! Exit...\n");
|
||||
VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
sleep(5);
|
||||
exit(0);
|
||||
}
|
||||
fatalError("ERROR: Could not create file! Exit...");
|
||||
printf("Waiting for GBA\n");
|
||||
VIDEO_WaitVSync();
|
||||
u32 readval = 0;
|
||||
while(readval != savesize)
|
||||
readval = __builtin_bswap32(recvsafe());
|
||||
sendsafe(0); //got savesize
|
||||
usleep(5000); //wait for it to set next val
|
||||
sendsafe_wait(0); //got savesize
|
||||
printf("Receiving...\n");
|
||||
for(i = 0; i < savesize; i+=4)
|
||||
*(vu32*)(testdump+i) = recvsafe();
|
||||
|
|
@ -517,7 +507,7 @@ int main(int argc, char *argv[])
|
|||
while(recvsafe() != 0)
|
||||
VIDEO_WaitVSync();
|
||||
printf("Save restored!\n");
|
||||
sendsafe(0);
|
||||
sendsafe_wait(0);
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user