parent
ee6ee321a4
commit
f864e4386c
|
@ -962,7 +962,7 @@ void MMU_Reset()
|
||||||
|
|
||||||
//HACK!!!
|
//HACK!!!
|
||||||
//until we improve all our session tracking stuff, we need to save the backup memory filename
|
//until we improve all our session tracking stuff, we need to save the backup memory filename
|
||||||
std::string bleh = MMU_new.backupDevice.filename;
|
std::string bleh = MMU_new.backupDevice.getFilename();
|
||||||
BackupDevice tempBackupDevice;
|
BackupDevice tempBackupDevice;
|
||||||
bool bleh2 = MMU_new.backupDevice.isMovieMode;
|
bool bleh2 = MMU_new.backupDevice.isMovieMode;
|
||||||
if(bleh2) tempBackupDevice = MMU_new.backupDevice;
|
if(bleh2) tempBackupDevice = MMU_new.backupDevice;
|
||||||
|
|
|
@ -602,8 +602,6 @@ int NDS_LoadROM(const char *filename, const char *logicalFilename)
|
||||||
if(gameInfo.isHomebrew)
|
if(gameInfo.isHomebrew)
|
||||||
DLDI::tryPatch((void*)gameInfo.romdata, gameInfo.romsize);
|
DLDI::tryPatch((void*)gameInfo.romdata, gameInfo.romsize);
|
||||||
|
|
||||||
NDS_Reset();
|
|
||||||
|
|
||||||
memset(buf, 0, MAX_PATH);
|
memset(buf, 0, MAX_PATH);
|
||||||
path.getpathnoext(path.BATTERY, buf);
|
path.getpathnoext(path.BATTERY, buf);
|
||||||
strcat(buf, ".dsv"); // DeSmuME memory card :)
|
strcat(buf, ".dsv"); // DeSmuME memory card :)
|
||||||
|
@ -614,6 +612,8 @@ int NDS_LoadROM(const char *filename, const char *logicalFilename)
|
||||||
strcat(buf, ".dct"); // DeSmuME cheat :)
|
strcat(buf, ".dct"); // DeSmuME cheat :)
|
||||||
cheats->init(buf);
|
cheats->init(buf);
|
||||||
|
|
||||||
|
NDS_Reset();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,20 +627,38 @@ void NDS_FreeROM(void)
|
||||||
MMU_unsetRom();
|
MMU_unsetRom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 NDS_ImportSaveSize(const char *filename)
|
||||||
|
|
||||||
int NDS_ImportSave(const char *filename)
|
|
||||||
{
|
{
|
||||||
if (strlen(filename) < 4)
|
u32 res = 0;
|
||||||
return 0;
|
if (strlen(filename) < 4) return 0;
|
||||||
|
|
||||||
if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0)
|
if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0)
|
||||||
return MMU_new.backupDevice.load_duc(filename);
|
{
|
||||||
|
res = MMU_new.backupDevice.get_save_duc_size(filename);
|
||||||
|
if (res == 0xFFFFFFFF) return 0;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = MMU_new.backupDevice.get_save_nogba_size(filename);
|
||||||
|
if (res != 0xFFFFFFFF) return res;
|
||||||
|
|
||||||
|
res = MMU_new.backupDevice.get_save_raw_size(filename);
|
||||||
|
if (res != 0xFFFFFFFF) return res;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NDS_ImportSave(const char *filename, u32 force_size)
|
||||||
|
{
|
||||||
|
if (strlen(filename) < 4) return 0;
|
||||||
|
|
||||||
|
if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0)
|
||||||
|
return MMU_new.backupDevice.load_duc(filename, force_size);
|
||||||
else
|
else
|
||||||
if (MMU_new.backupDevice.load_no_gba(filename))
|
if (MMU_new.backupDevice.load_no_gba(filename, force_size))
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return MMU_new.backupDevice.load_raw(filename);
|
return MMU_new.backupDevice.load_raw(filename, force_size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,7 +445,8 @@ void NDS_suspendProcessingInput(bool suspend);
|
||||||
int NDS_LoadROM(const char *filename, const char* logicalFilename=0);
|
int NDS_LoadROM(const char *filename, const char* logicalFilename=0);
|
||||||
void NDS_FreeROM(void);
|
void NDS_FreeROM(void);
|
||||||
void NDS_Reset();
|
void NDS_Reset();
|
||||||
int NDS_ImportSave(const char *filename);
|
int NDS_ImportSave(const char *filename, u32 force_size = 0);
|
||||||
|
u32 NDS_ImportSaveSize(const char *filename);
|
||||||
bool NDS_ExportSave(const char *filename);
|
bool NDS_ExportSave(const char *filename);
|
||||||
|
|
||||||
void nds_savestate(EMUFILE* os);
|
void nds_savestate(EMUFILE* os);
|
||||||
|
|
|
@ -216,8 +216,8 @@ bool CommandLine::validate()
|
||||||
if((_cflash_image && _gbaslot_rom) || (_cflash_path && _gbaslot_rom)) {
|
if((_cflash_image && _gbaslot_rom) || (_cflash_path && _gbaslot_rom)) {
|
||||||
g_printerr("Cannot specify both cflash and gbaslot rom (both occupy SLOT-2)\n");
|
g_printerr("Cannot specify both cflash and gbaslot rom (both occupy SLOT-2)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((autodetect_method < 0) || (autodetect_method > 1)) {
|
if ((autodetect_method != -1) && (autodetect_method < 0) || (autodetect_method > 1)) {
|
||||||
g_printerr("Invalid autodetect save method (0 - internal, 1 - from database)\n");
|
g_printerr("Invalid autodetect save method (0 - internal, 1 - from database)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ static const u32 saveSizes[] = {512, // 4k
|
||||||
static const u32 saveSizes_count = ARRAY_SIZE(saveSizes);
|
static const u32 saveSizes_count = ARRAY_SIZE(saveSizes);
|
||||||
|
|
||||||
//the lookup table from user save types to save parameters
|
//the lookup table from user save types to save parameters
|
||||||
static const int save_types[][2] = {
|
const int save_types[][2] = {
|
||||||
{MC_TYPE_AUTODETECT,1},
|
{MC_TYPE_AUTODETECT,1},
|
||||||
{MC_TYPE_EEPROM1,MC_SIZE_4KBITS},
|
{MC_TYPE_EEPROM1,MC_SIZE_4KBITS},
|
||||||
{MC_TYPE_EEPROM2,MC_SIZE_64KBITS},
|
{MC_TYPE_EEPROM2,MC_SIZE_64KBITS},
|
||||||
|
@ -408,6 +408,7 @@ void BackupDevice::reset_hardware()
|
||||||
|
|
||||||
void BackupDevice::reset()
|
void BackupDevice::reset()
|
||||||
{
|
{
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
reset_hardware();
|
reset_hardware();
|
||||||
resize(0);
|
resize(0);
|
||||||
data_autodetect.resize(0);
|
data_autodetect.resize(0);
|
||||||
|
@ -432,6 +433,16 @@ void BackupDevice::close_rom()
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 BackupDevice::searchFileSaveType(u32 size)
|
||||||
|
{
|
||||||
|
for (u8 i = 1; i < MAX_SAVE_TYPES; i++)
|
||||||
|
{
|
||||||
|
if (size == save_types[i][1])
|
||||||
|
return (i-1);
|
||||||
|
}
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
void BackupDevice::reset_command()
|
void BackupDevice::reset_command()
|
||||||
{
|
{
|
||||||
//printf("MC RESET\n");
|
//printf("MC RESET\n");
|
||||||
|
@ -741,11 +752,42 @@ void BackupDevice::load_old_state(u32 addr_size, u8* data, u32 datasize)
|
||||||
//======================================================================= no$GBA
|
//======================================================================= no$GBA
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
const char no_GBA_HEADER_ID[] = "NocashGbaBackupMediaSavDataFile";
|
||||||
|
const char no_GBA_HEADER_SRAM_ID[] = "SRAM";
|
||||||
|
|
||||||
|
u32 BackupDevice::get_save_nogba_size(const char* fname)
|
||||||
|
{
|
||||||
|
FILE *fsrc = fopen(fname, "rb");
|
||||||
|
if (fsrc)
|
||||||
|
{
|
||||||
|
char src[0x50] = {0};
|
||||||
|
u32 fsize = 0;
|
||||||
|
fseek(fsrc, 0, SEEK_END);
|
||||||
|
fsize = ftell(fsrc);
|
||||||
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
|
if (fsize < 0x50) { fclose(fsrc); return 0xFFFFFFFF; }
|
||||||
|
memset(&src[0], 0, sizeof(src));
|
||||||
|
if (fread(src, 1, sizeof(src), fsrc) != sizeof(src)) { fclose(fsrc); return 0xFFFFFFFF; }
|
||||||
|
|
||||||
|
for (u8 i = 0; i < 0x1F; i++)
|
||||||
|
if (src[i] != no_GBA_HEADER_ID[i]) { fclose(fsrc); return 0xFFFFFFFF; }
|
||||||
|
if (src[0x1F] != 0x1A) { fclose(fsrc); return 0xFFFFFFFF; }
|
||||||
|
for (int i = 0; i < 0x4; i++)
|
||||||
|
if (src[i+0x40] != no_GBA_HEADER_SRAM_ID[i]) { fclose(fsrc); return 0xFFFFFFFF; }
|
||||||
|
|
||||||
|
u32 compressMethod = *((u32*)(src+0x44));
|
||||||
|
if (compressMethod == 0)
|
||||||
|
{ fclose(fsrc); return *((u32*)(src+0x48)); }
|
||||||
|
else
|
||||||
|
if (compressMethod == 1)
|
||||||
|
{ fclose(fsrc); return *((u32*)(src+0x4C)); }
|
||||||
|
fclose(fsrc);
|
||||||
|
}
|
||||||
|
return 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
static int no_gba_unpackSAV(void *in_buf, u32 fsize, void *out_buf, u32 &size)
|
static int no_gba_unpackSAV(void *in_buf, u32 fsize, void *out_buf, u32 &size)
|
||||||
{
|
{
|
||||||
const char no_GBA_HEADER_ID[] = "NocashGbaBackupMediaSavDataFile";
|
|
||||||
const char no_GBA_HEADER_SRAM_ID[] = "SRAM";
|
|
||||||
u8 *src = (u8 *)in_buf;
|
u8 *src = (u8 *)in_buf;
|
||||||
u8 *dst = (u8 *)out_buf;
|
u8 *dst = (u8 *)out_buf;
|
||||||
u32 src_pos = 0;
|
u32 src_pos = 0;
|
||||||
|
@ -857,7 +899,7 @@ static u32 no_gba_fillLeft(u32 size)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BackupDevice::load_no_gba(const char *fname)
|
bool BackupDevice::load_no_gba(const char *fname, u32 force_size)
|
||||||
{
|
{
|
||||||
FILE *fsrc = fopen(fname, "rb");
|
FILE *fsrc = fopen(fname, "rb");
|
||||||
u8 *in_buf = NULL;
|
u8 *in_buf = NULL;
|
||||||
|
@ -881,12 +923,14 @@ bool BackupDevice::load_no_gba(const char *fname)
|
||||||
memset(out_buf, 0xFF, 8 * 1024 * 1024 / 8);
|
memset(out_buf, 0xFF, 8 * 1024 * 1024 / 8);
|
||||||
if (no_gba_unpackSAV(in_buf, fsize, out_buf, size) == 0)
|
if (no_gba_unpackSAV(in_buf, fsize, out_buf, size) == 0)
|
||||||
{
|
{
|
||||||
|
if (force_size > 0)
|
||||||
|
size = force_size;
|
||||||
//printf("New size %i byte(s)\n", size);
|
//printf("New size %i byte(s)\n", size);
|
||||||
size = no_gba_savTrim(out_buf, size);
|
size = no_gba_savTrim(out_buf, size);
|
||||||
//printf("--- new size after trim %i byte(s)\n", size);
|
//printf("--- new size after trim %i byte(s)\n", size);
|
||||||
size = no_gba_fillLeft(size);
|
size = no_gba_fillLeft(size);
|
||||||
//printf("--- new size after fill %i byte(s)\n", size);
|
//printf("--- new size after fill %i byte(s)\n", size);
|
||||||
raw_applyUserSettings(size);
|
raw_applyUserSettings(size, (force_size > 0));
|
||||||
resize(size);
|
resize(size);
|
||||||
for (u32 tt = 0; tt < size; tt++)
|
for (u32 tt = 0; tt < size; tt++)
|
||||||
data[tt] = out_buf[tt];
|
data[tt] = out_buf[tt];
|
||||||
|
@ -992,24 +1036,47 @@ void BackupDevice::loadfile()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inf->fseek(-24, SEEK_CUR);
|
inf->fseek(-24, SEEK_CUR);
|
||||||
struct {
|
|
||||||
u32 size,padSize,type,addr_size,mem_size;
|
|
||||||
} info;
|
|
||||||
read32le(&info.size,inf);
|
read32le(&info.size,inf);
|
||||||
read32le(&info.padSize,inf);
|
read32le(&info.padSize,inf);
|
||||||
read32le(&info.type,inf);
|
read32le(&info.type,inf);
|
||||||
read32le(&info.addr_size,inf);
|
read32le(&info.addr_size,inf);
|
||||||
read32le(&info.mem_size,inf);
|
read32le(&info.mem_size,inf);
|
||||||
|
|
||||||
|
u32 left = 0;
|
||||||
|
if (CommonSettings.autodetectBackupMethod == 1)
|
||||||
|
{
|
||||||
|
if (advsc.isLoaded())
|
||||||
|
{
|
||||||
|
info.type = advsc.getSaveType();
|
||||||
|
if (info.type != 0xFF || info.type != 0xFE)
|
||||||
|
{
|
||||||
|
u32 adv_size = save_types[info.type+1][1];
|
||||||
|
if (info.size > adv_size)
|
||||||
|
info.size = adv_size;
|
||||||
|
else
|
||||||
|
if (info.size < adv_size)
|
||||||
|
{
|
||||||
|
left = adv_size - info.size;
|
||||||
|
info.size = adv_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//establish the save data
|
//establish the save data
|
||||||
resize(info.size);
|
resize(info.size);
|
||||||
inf->fseek(0, SEEK_SET);
|
inf->fseek(0, SEEK_SET);
|
||||||
if(info.size>0)
|
if(info.size>0)
|
||||||
inf->fread(&data[0],info.size); //read all the raw data we have
|
inf->fread(&data[0],info.size - left); //read all the raw data we have
|
||||||
state = RUNNING;
|
state = RUNNING;
|
||||||
addr_size = info.addr_size;
|
addr_size = info.addr_size;
|
||||||
//none of the other fields are used right now
|
//none of the other fields are used right now
|
||||||
|
|
||||||
|
|
||||||
|
if (CommonSettings.autodetectBackupMethod != 1 && info.type == 0)
|
||||||
|
{
|
||||||
|
info.type = searchFileSaveType(info.size);
|
||||||
|
if (info.type == 0xFF) info.type = 0;
|
||||||
|
}
|
||||||
u32 ss = info.size * 8 / 1024;
|
u32 ss = info.size * 8 / 1024;
|
||||||
if (ss >= 1024)
|
if (ss >= 1024)
|
||||||
{
|
{
|
||||||
|
@ -1065,6 +1132,8 @@ void BackupDevice::flush()
|
||||||
//never use save files if we are in movie mode
|
//never use save files if we are in movie mode
|
||||||
if(isMovieMode) return;
|
if(isMovieMode) return;
|
||||||
|
|
||||||
|
if (filename.length() == 0) return;
|
||||||
|
|
||||||
EMUFILE* outf = new EMUFILE_FILE(filename.c_str(),"wb");
|
EMUFILE* outf = new EMUFILE_FILE(filename.c_str(),"wb");
|
||||||
if(!outf->fail())
|
if(!outf->fail())
|
||||||
{
|
{
|
||||||
|
@ -1087,9 +1156,9 @@ void BackupDevice::flush()
|
||||||
//and now the actual footer
|
//and now the actual footer
|
||||||
write32le(size,outf); //the size of data that has actually been written
|
write32le(size,outf); //the size of data that has actually been written
|
||||||
write32le(padSize,outf); //the size we padded it to
|
write32le(padSize,outf); //the size we padded it to
|
||||||
write32le(0,outf); //save memory type
|
write32le(info.type,outf); //save memory type
|
||||||
write32le(addr_size,outf);
|
write32le(addr_size,outf);
|
||||||
write32le(0,outf); //save memory size
|
write32le(info.size,outf); //save memory size
|
||||||
write32le(0,outf); //version number
|
write32le(0,outf); //version number
|
||||||
outf->fprintf("%s", kDesmumeSaveCookie); //this is what we'll use to recognize the desmume format save
|
outf->fprintf("%s", kDesmumeSaveCookie); //this is what we'll use to recognize the desmume format save
|
||||||
|
|
||||||
|
@ -1098,22 +1167,28 @@ void BackupDevice::flush()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete outf;
|
delete outf;
|
||||||
printf("Unable to open savefile %s\n",filename.c_str());
|
printf("Unable to open savefile %s\n", filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackupDevice::raw_applyUserSettings(u32& size)
|
void BackupDevice::raw_applyUserSettings(u32& size, bool manual)
|
||||||
{
|
{
|
||||||
//respect the user's choice of backup memory type
|
//respect the user's choice of backup memory type
|
||||||
if(CommonSettings.manualBackupType == MC_TYPE_AUTODETECT)
|
if(CommonSettings.manualBackupType == MC_TYPE_AUTODETECT && !manual)
|
||||||
{
|
{
|
||||||
addr_size = addr_size_for_old_save_size(size);
|
addr_size = addr_size_for_old_save_size(size);
|
||||||
resize(size);
|
resize(size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int savetype = save_types[CommonSettings.manualBackupType][0];
|
u32 type = CommonSettings.manualBackupType;
|
||||||
int savesize = save_types[CommonSettings.manualBackupType][1];
|
if (manual)
|
||||||
|
{
|
||||||
|
u32 res = searchFileSaveType(size);
|
||||||
|
if (res != 0xFF) type = (res + 1); // +1 - skip autodetect
|
||||||
|
}
|
||||||
|
int savetype = save_types[type][0];
|
||||||
|
int savesize = save_types[type][1];
|
||||||
addr_size = addr_size_for_old_save_type(savetype);
|
addr_size = addr_size_for_old_save_type(savetype);
|
||||||
if((u32)savesize<size) size = savesize;
|
if((u32)savesize<size) size = savesize;
|
||||||
resize(savesize);
|
resize(savesize);
|
||||||
|
@ -1122,28 +1197,42 @@ void BackupDevice::raw_applyUserSettings(u32& size)
|
||||||
state = RUNNING;
|
state = RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 BackupDevice::get_save_raw_size(const char* fname)
|
||||||
|
{
|
||||||
|
FILE* inf = fopen(fname,"rb");
|
||||||
|
if (!inf) return 0xFFFFFFFF;
|
||||||
|
|
||||||
bool BackupDevice::load_raw(const char* filename)
|
fseek(inf, 0, SEEK_END);
|
||||||
|
u32 size = (u32)ftell(inf);
|
||||||
|
fclose(inf);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BackupDevice::load_raw(const char* filename, u32 force_size)
|
||||||
{
|
{
|
||||||
FILE* inf = fopen(filename,"rb");
|
FILE* inf = fopen(filename,"rb");
|
||||||
|
|
||||||
|
if (!inf) return false;
|
||||||
|
|
||||||
fseek(inf, 0, SEEK_END);
|
fseek(inf, 0, SEEK_END);
|
||||||
u32 size = (u32)ftell(inf);
|
u32 size = (u32)ftell(inf);
|
||||||
u32 left = 0;
|
u32 left = 0;
|
||||||
u8 sv = advsc.getSaveType();
|
|
||||||
if (sv < MAX_SAVE_TYPES)
|
if (force_size > 0)
|
||||||
{
|
{
|
||||||
if (size > save_types[sv+1][1])
|
if (size > force_size)
|
||||||
size = save_types[sv+1][1];
|
size = force_size;
|
||||||
else
|
else
|
||||||
if (size < save_types[sv+1][1])
|
if (size < force_size)
|
||||||
{
|
{
|
||||||
left = save_types[sv+1][1] - size;
|
left = force_size - size;
|
||||||
size = save_types[sv+1][1];
|
size = force_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(inf, 0, SEEK_SET);
|
fseek(inf, 0, SEEK_SET);
|
||||||
|
|
||||||
raw_applyUserSettings(size);
|
raw_applyUserSettings(size, (force_size > 0));
|
||||||
|
|
||||||
fread(&data[0],1,size-left,inf);
|
fread(&data[0],1,size-left,inf);
|
||||||
fclose(inf);
|
fclose(inf);
|
||||||
|
@ -1154,14 +1243,25 @@ bool BackupDevice::load_raw(const char* filename)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 BackupDevice::get_save_duc_size(const char* fname)
|
||||||
|
{
|
||||||
|
FILE* inf = fopen(fname,"rb");
|
||||||
|
if (!inf) return 0xFFFFFFFF;
|
||||||
|
|
||||||
bool BackupDevice::load_duc(const char* filename)
|
fseek(inf, 0, SEEK_END);
|
||||||
|
u32 size = (u32)ftell(inf);
|
||||||
|
fclose(inf);
|
||||||
|
if (size < 500) return 0xFFFFFFFF;
|
||||||
|
return (size - 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BackupDevice::load_duc(const char* filename, u32 force_size)
|
||||||
{
|
{
|
||||||
u32 size;
|
u32 size;
|
||||||
char id[16];
|
char id[16];
|
||||||
FILE* file = fopen(filename, "rb");
|
FILE* file = fopen(filename, "rb");
|
||||||
if(file == NULL)
|
|
||||||
return false;
|
if(!file) return false;
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
size = (u32)ftell(file) - 500;
|
size = (u32)ftell(file) - 500;
|
||||||
|
@ -1172,28 +1272,27 @@ bool BackupDevice::load_duc(const char* filename)
|
||||||
|
|
||||||
if (memcmp(id, "ARDS000000000001", 16) != 0)
|
if (memcmp(id, "ARDS000000000001", 16) != 0)
|
||||||
{
|
{
|
||||||
printf("Not recognized as a valid DUC file\n");
|
printf("Not recognized as a valid DUC file\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Skip the rest of the header since we don't need it
|
// Skip the rest of the header since we don't need it
|
||||||
fseek(file, 500, SEEK_SET);
|
fseek(file, 500, SEEK_SET);
|
||||||
|
|
||||||
u32 left = 0;
|
u32 left = 0;
|
||||||
u8 sv = advsc.getSaveType();
|
if (force_size > 0)
|
||||||
if (sv < MAX_SAVE_TYPES)
|
|
||||||
{
|
{
|
||||||
if (size > save_types[sv+1][1])
|
if (size > force_size)
|
||||||
size = save_types[sv+1][1];
|
size = force_size;
|
||||||
else
|
else
|
||||||
if (size < save_types[sv+1][1])
|
if (size < force_size)
|
||||||
{
|
{
|
||||||
left = save_types[sv+1][1] - size;
|
left = force_size - size;
|
||||||
size = save_types[sv+1][1];
|
size = force_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_applyUserSettings(size);
|
raw_applyUserSettings(size, (force_size > 0));
|
||||||
|
|
||||||
ensure((u32)size);
|
ensure((u32)size);
|
||||||
|
|
||||||
|
@ -1255,6 +1354,7 @@ void BackupDevice::forceManualBackupType()
|
||||||
// ============================================= ADVANsCEne
|
// ============================================= ADVANsCEne
|
||||||
u8 ADVANsCEne::checkDB(const char *serial)
|
u8 ADVANsCEne::checkDB(const char *serial)
|
||||||
{
|
{
|
||||||
|
loaded = false;
|
||||||
FILE *fp = fopen(database_path, "rb");
|
FILE *fp = fopen(database_path, "rb");
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
|
@ -1284,6 +1384,7 @@ u8 ADVANsCEne::checkDB(const char *serial)
|
||||||
//printf("%s founded: crc32=%04X, save type %02X\n", serial, crc32, buf[12]);
|
//printf("%s founded: crc32=%04X, save type %02X\n", serial, crc32, buf[12]);
|
||||||
saveType = buf[12];
|
saveType = buf[12];
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
loaded = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ private:
|
||||||
time_t createTime;
|
time_t createTime;
|
||||||
u8 saveType;
|
u8 saveType;
|
||||||
u32 crc32;
|
u32 crc32;
|
||||||
|
bool loaded;
|
||||||
|
|
||||||
// XML
|
// XML
|
||||||
const char *datName;
|
const char *datName;
|
||||||
|
@ -75,17 +76,19 @@ private:
|
||||||
bool getXMLConfig(const char *in_filaname);
|
bool getXMLConfig(const char *in_filaname);
|
||||||
public:
|
public:
|
||||||
ADVANsCEne() : saveType(0xFF),
|
ADVANsCEne() : saveType(0xFF),
|
||||||
crc32(0)
|
crc32(0),
|
||||||
|
loaded(false)
|
||||||
{
|
{
|
||||||
memset(database_path, 0, sizeof(database_path));
|
memset(database_path, 0, sizeof(database_path));
|
||||||
memset(versionBase, 0, sizeof(versionBase));
|
memset(versionBase, 0, sizeof(versionBase));
|
||||||
memset(version, 0, sizeof(version));
|
memset(version, 0, sizeof(version));
|
||||||
}
|
}
|
||||||
void setDatabase(const char *path) { strcpy(database_path, path); }
|
void setDatabase(const char *path) { loaded = false; strcpy(database_path, path); }
|
||||||
u32 convertDB(const char *in_filaname);
|
u32 convertDB(const char *in_filaname);
|
||||||
u8 checkDB(const char *serial);
|
u8 checkDB(const char *serial);
|
||||||
u32 getSaveType() { return saveType; }
|
u32 getSaveType() { return saveType; }
|
||||||
u32 getCRC32() { return crc32; }
|
u32 getCRC32() { return crc32; }
|
||||||
|
bool isLoaded() { return loaded; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,6 +130,8 @@ public:
|
||||||
void close_rom();
|
void close_rom();
|
||||||
void forceManualBackupType();
|
void forceManualBackupType();
|
||||||
void reset_hardware();
|
void reset_hardware();
|
||||||
|
std::string getFilename() { return filename; }
|
||||||
|
u8 searchFileSaveType(u32 size);
|
||||||
|
|
||||||
bool save_state(EMUFILE* os);
|
bool save_state(EMUFILE* os);
|
||||||
bool load_state(EMUFILE* is);
|
bool load_state(EMUFILE* is);
|
||||||
|
@ -148,14 +153,17 @@ public:
|
||||||
static u32 addr_size_for_old_save_type(int bupmem_type);
|
static u32 addr_size_for_old_save_type(int bupmem_type);
|
||||||
|
|
||||||
static u32 pad_up_size(u32 startSize);
|
static u32 pad_up_size(u32 startSize);
|
||||||
void raw_applyUserSettings(u32& size);
|
void raw_applyUserSettings(u32& size, bool manual = false);
|
||||||
|
|
||||||
bool load_duc(const char* filename);
|
bool load_duc(const char* filename, u32 force_size = 0);
|
||||||
bool load_no_gba(const char *fname);
|
bool load_no_gba(const char *fname, u32 force_size = 0);
|
||||||
bool save_no_gba(const char* fname);
|
bool save_no_gba(const char* fname);
|
||||||
bool load_raw(const char* filename);
|
bool load_raw(const char* filename, u32 force_size = 0);
|
||||||
bool save_raw(const char* filename);
|
bool save_raw(const char* filename);
|
||||||
bool load_movie(EMUFILE* is);
|
bool load_movie(EMUFILE* is);
|
||||||
|
u32 get_save_duc_size(const char* filename);
|
||||||
|
u32 get_save_nogba_size(const char* filename);
|
||||||
|
u32 get_save_raw_size(const char* filename);
|
||||||
|
|
||||||
//call me once a second or so to lazy flush the save data
|
//call me once a second or so to lazy flush the save data
|
||||||
//here's the reason for this system: we want to dump save files when theyre READ
|
//here's the reason for this system: we want to dump save files when theyre READ
|
||||||
|
@ -164,17 +172,19 @@ public:
|
||||||
void lazy_flush();
|
void lazy_flush();
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
public: //SHOULD BE PRIVATE!!!!!!!!
|
struct {
|
||||||
std::string filename;
|
u32 size,padSize,type,addr_size,mem_size;
|
||||||
bool isMovieMode;
|
} info;
|
||||||
|
|
||||||
|
bool isMovieMode;
|
||||||
private:
|
private:
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
bool write_enable; //is write enabled?
|
bool write_enable; //is write enabled?
|
||||||
u32 com; //persistent command actually handled
|
u32 com; //persistent command actually handled
|
||||||
u32 addr_size, addr_counter;
|
u32 addr_size, addr_counter;
|
||||||
u32 addr;
|
u32 addr;
|
||||||
|
|
||||||
|
|
||||||
std::vector<u8> data_autodetect;
|
std::vector<u8> data_autodetect;
|
||||||
enum STATE {
|
enum STATE {
|
||||||
DETECTING = 0, RUNNING = 1
|
DETECTING = 0, RUNNING = 1
|
||||||
|
@ -218,6 +228,7 @@ void backup_setManualBackupType(int type);
|
||||||
void backup_forceManualBackupType();
|
void backup_forceManualBackupType();
|
||||||
|
|
||||||
extern const char *save_names[];
|
extern const char *save_names[];
|
||||||
|
extern const int save_types[][2];
|
||||||
|
|
||||||
#endif /*__FW_H__*/
|
#endif /*__FW_H__*/
|
||||||
|
|
||||||
|
|
|
@ -729,6 +729,14 @@
|
||||||
RelativePath=".\hotkey.h"
|
RelativePath=".\hotkey.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\importSave.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\importSave.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\inputdx.cpp"
|
RelativePath=".\inputdx.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1562,6 +1562,14 @@
|
||||||
RelativePath=".\hotkey.h"
|
RelativePath=".\hotkey.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\importSave.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\importSave.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\inputdx.cpp"
|
RelativePath=".\inputdx.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -543,6 +543,7 @@
|
||||||
<ClCompile Include="FirmConfig.cpp" />
|
<ClCompile Include="FirmConfig.cpp" />
|
||||||
<ClCompile Include="gbaslot_config.cpp" />
|
<ClCompile Include="gbaslot_config.cpp" />
|
||||||
<ClCompile Include="hotkey.cpp" />
|
<ClCompile Include="hotkey.cpp" />
|
||||||
|
<ClCompile Include="importSave.cpp" />
|
||||||
<ClCompile Include="inputdx.cpp" />
|
<ClCompile Include="inputdx.cpp" />
|
||||||
<ClCompile Include="luaconsole.cpp" />
|
<ClCompile Include="luaconsole.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
@ -684,6 +685,7 @@
|
||||||
<ClInclude Include="FirmConfig.h" />
|
<ClInclude Include="FirmConfig.h" />
|
||||||
<ClInclude Include="gbaslot_config.h" />
|
<ClInclude Include="gbaslot_config.h" />
|
||||||
<ClInclude Include="hotkey.h" />
|
<ClInclude Include="hotkey.h" />
|
||||||
|
<ClInclude Include="importSave.h" />
|
||||||
<ClInclude Include="inputdx.h" />
|
<ClInclude Include="inputdx.h" />
|
||||||
<ClInclude Include="main.h" />
|
<ClInclude Include="main.h" />
|
||||||
<ClInclude Include="OpenArchive.h" />
|
<ClInclude Include="OpenArchive.h" />
|
||||||
|
|
|
@ -468,6 +468,9 @@
|
||||||
<ClCompile Include="..\filter\bilinear.cpp">
|
<ClCompile Include="..\filter\bilinear.cpp">
|
||||||
<Filter>Core\filter</Filter>
|
<Filter>Core\filter</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="importSave.cpp">
|
||||||
|
<Filter>Windows</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\addons.h">
|
<ClInclude Include="..\addons.h">
|
||||||
|
@ -879,6 +882,9 @@
|
||||||
<ClInclude Include="..\filter\lq2x.h">
|
<ClInclude Include="..\filter\lq2x.h">
|
||||||
<Filter>Core\filter</Filter>
|
<Filter>Core\filter</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="importSave.h">
|
||||||
|
<Filter>Windows</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\instruction_tabdef.inc">
|
<None Include="..\instruction_tabdef.inc">
|
||||||
|
|
|
@ -0,0 +1,190 @@
|
||||||
|
/*
|
||||||
|
Copyright 2006 Theo Berkau
|
||||||
|
Copyright (C) 2006-2012 DeSmuME team
|
||||||
|
|
||||||
|
This file is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This file is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../types.h"
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../path.h"
|
||||||
|
#include "../MMU.h"
|
||||||
|
#include "../NDSSystem.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "importSave.h"
|
||||||
|
|
||||||
|
char ImportSavFName[MAX_PATH] = {0};
|
||||||
|
u32 fileSaveSize = 0;
|
||||||
|
u32 fileSaveType = 0xFF;
|
||||||
|
|
||||||
|
BOOL CALLBACK ImportSizeSelect_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
char buf[256] = {0};
|
||||||
|
|
||||||
|
if (advsc.isLoaded())
|
||||||
|
{
|
||||||
|
|
||||||
|
memset(&buf, 0, sizeof(buf));
|
||||||
|
u8 sv = advsc.getSaveType();
|
||||||
|
if (sv == 0xFF)
|
||||||
|
{
|
||||||
|
strcpy(buf, "Unknown");
|
||||||
|
EnableWindow(GetDlgItem(hDlg, IDC_IMP_AUTO_ADVANSCENE), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (sv == 0xFE)
|
||||||
|
{
|
||||||
|
strcpy(buf, "None");
|
||||||
|
EnableWindow(GetDlgItem(hDlg, IDC_IMP_AUTO_ADVANSCENE), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy(buf, save_names[sv]);
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_IMP_INFO_ADVANSCENE), buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
EnableWindow(GetDlgItem(hDlg, IDC_IMP_AUTO_ADVANSCENE), false);
|
||||||
|
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_IMP_INFO_CURRENT), save_names[MMU_new.backupDevice.info.type]);
|
||||||
|
SendDlgItemMessage(hDlg, IDC_IMP_AUTO_CURRENT, BM_SETCHECK, true, 0);
|
||||||
|
|
||||||
|
for (u8 i = 1; i <= MAX_SAVE_TYPES; i++)
|
||||||
|
{
|
||||||
|
u32 ss = save_types[i][1] * 8 / 1024;
|
||||||
|
if (ss >= 1024)
|
||||||
|
sprintf(buf, "%i Mbit", ss / 1024);
|
||||||
|
else
|
||||||
|
sprintf(buf, "%i Kbit", ss);
|
||||||
|
SendDlgItemMessage(hDlg, IDC_IMP_MANUAL_SIZE, CB_ADDSTRING, 0, (LPARAM)buf);
|
||||||
|
}
|
||||||
|
SendDlgItemMessage(hDlg, IDC_IMP_MANUAL_SIZE, CB_SETCURSEL, MMU_new.backupDevice.info.type, 0);
|
||||||
|
|
||||||
|
fileSaveSize = NDS_ImportSaveSize(ImportSavFName);
|
||||||
|
|
||||||
|
if (fileSaveSize > 0)
|
||||||
|
{
|
||||||
|
fileSaveType = MMU_new.backupDevice.searchFileSaveType(fileSaveSize);
|
||||||
|
if (fileSaveType == 0xFF)
|
||||||
|
{
|
||||||
|
sprintf(buf, "%i bytes - ERROR", fileSaveSize);
|
||||||
|
EnableWindow(GetDlgItem(hDlg, IDC_IMP_AUTO_FILE), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char sizeS[30] = {0};
|
||||||
|
memset(&sizeS[0], 0, sizeof(size));
|
||||||
|
u32 ss = save_types[fileSaveType+1][1] * 8 / 1024;
|
||||||
|
if (ss >= 1024)
|
||||||
|
sprintf(sizeS, "%i Mbit", ss / 1024);
|
||||||
|
else
|
||||||
|
sprintf(sizeS, "%i Kbit", ss);
|
||||||
|
sprintf(buf, "%s - %i bytes", sizeS, fileSaveSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(buf, "ERROR"); // TODO: disable OK button
|
||||||
|
EnableWindow(GetDlgItem(hDlg, IDC_IMP_AUTO_FILE), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_IMP_INFO_FILE), buf);
|
||||||
|
|
||||||
|
SetFocus(GetDlgItem(hDlg, IDC_IMP_AUTO_CURRENT));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
{
|
||||||
|
switch(LOWORD(wParam))
|
||||||
|
{
|
||||||
|
case IDOK:
|
||||||
|
{
|
||||||
|
u32 res = 0;
|
||||||
|
|
||||||
|
if (SendDlgItemMessage(hDlg, IDC_IMP_AUTO_CURRENT, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||||
|
res = MMU_new.backupDevice.info.type;
|
||||||
|
else
|
||||||
|
if (SendDlgItemMessage(hDlg, IDC_IMP_AUTO_FILE, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||||
|
{
|
||||||
|
if (fileSaveSize == 0) break;
|
||||||
|
if (fileSaveType == 0xFF) break;
|
||||||
|
res = fileSaveType;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (SendDlgItemMessage(hDlg, IDC_IMP_AUTO_ADVANSCENE, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||||
|
{
|
||||||
|
if (!advsc.isLoaded()) break;
|
||||||
|
res = advsc.getSaveType();
|
||||||
|
if (res > MAX_SAVE_TYPES) break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (SendDlgItemMessage(hDlg, IDC_IMP_MANUAL, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||||
|
res = SendDlgItemMessage(hDlg, IDC_IMP_MANUAL_SIZE, CB_GETCURSEL, 0, 0)+1;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
EndDialog(hDlg, res);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDCANCEL:
|
||||||
|
EndDialog(hDlg, MAX_SAVE_TYPES + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool importSave(HWND hwnd, HINSTANCE hAppInst)
|
||||||
|
{
|
||||||
|
OPENFILENAME ofn;
|
||||||
|
|
||||||
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.hwndOwner = hwnd;
|
||||||
|
ofn.lpstrFilter = "All supported types\0*.duc;*.sav\0Action Replay DS Save (*.duc)\0*.duc\0Raw/No$GBA Save format (*.sav)\0*.sav\0\0";
|
||||||
|
ofn.nFilterIndex = 1;
|
||||||
|
ofn.lpstrFile = ImportSavFName;
|
||||||
|
ofn.nMaxFile = MAX_PATH;
|
||||||
|
ofn.lpstrDefExt = "duc";
|
||||||
|
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
|
||||||
|
|
||||||
|
char buffer[MAX_PATH] = {0};
|
||||||
|
ZeroMemory(buffer, sizeof(buffer));
|
||||||
|
path.getpath(path.BATTERY, buffer);
|
||||||
|
ofn.lpstrInitialDir = buffer;
|
||||||
|
|
||||||
|
if(!GetOpenFileName(&ofn))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
u32 res = DialogBoxW(hAppInst, MAKEINTRESOURCEW(IDD_IMPORT_SAVE_SIZE), hwnd, (DLGPROC)ImportSizeSelect_Proc);
|
||||||
|
if (res < MAX_SAVE_TYPES)
|
||||||
|
{
|
||||||
|
res = NDS_ImportSave(ImportSavFName, save_types[res+1][1]);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
printf("Save was successfully imported\n");
|
||||||
|
NDS_Reset(); // reboot game
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("Save was not successfully imported");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (res == (MAX_SAVE_TYPES + 1));
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
Copyright 2006 Theo Berkau
|
||||||
|
Copyright (C) 2006-2012 DeSmuME team
|
||||||
|
|
||||||
|
This file is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This file is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _IMPORT_SAVE_H_
|
||||||
|
#define _IMPORT_SAVE_H_
|
||||||
|
|
||||||
|
extern bool importSave(HWND hwnd, HINSTANCE hAppInst);
|
||||||
|
|
||||||
|
#endif
|
|
@ -104,6 +104,7 @@ along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "ram_search.h"
|
#include "ram_search.h"
|
||||||
#include "aviout.h"
|
#include "aviout.h"
|
||||||
#include "soundView.h"
|
#include "soundView.h"
|
||||||
|
#include "importSave.h"
|
||||||
//
|
//
|
||||||
//static size_t heapram = 0;
|
//static size_t heapram = 0;
|
||||||
//void* operator new[](size_t amt)
|
//void* operator new[](size_t amt)
|
||||||
|
@ -382,8 +383,8 @@ struct DDRAW
|
||||||
|
|
||||||
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
char SavName[MAX_PATH] = "";
|
char SavName[MAX_PATH] = {0};
|
||||||
char ImportSavName[MAX_PATH] = "";
|
char ImportSavName[MAX_PATH] = {0};
|
||||||
char szClassName[ ] = "DeSmuME";
|
char szClassName[ ] = "DeSmuME";
|
||||||
int romnum = 0;
|
int romnum = 0;
|
||||||
|
|
||||||
|
@ -4110,7 +4111,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
MainWindow->checkMenu(IDC_SAVETYPE+i, false);
|
MainWindow->checkMenu(IDC_SAVETYPE+i, false);
|
||||||
|
|
||||||
MainWindow->checkMenu(IDC_SAVETYPE+CommonSettings.manualBackupType, true);
|
MainWindow->checkMenu(IDC_SAVETYPE+CommonSettings.manualBackupType, true);
|
||||||
MainWindow->checkMenu(IDM_AUTODETECTSAVETYPE_INTERNAL+CommonSettings.autodetectBackupMethod, true);
|
MainWindow->checkMenu(IDM_AUTODETECTSAVETYPE_INTERNAL, CommonSettings.autodetectBackupMethod == 0);
|
||||||
|
MainWindow->checkMenu(IDM_AUTODETECTSAVETYPE_FROMDATABASE, CommonSettings.autodetectBackupMethod == 1);
|
||||||
|
|
||||||
// recent/active scripts menu
|
// recent/active scripts menu
|
||||||
PopulateLuaSubmenu();
|
PopulateLuaSubmenu();
|
||||||
|
@ -4959,29 +4961,8 @@ DOKEYDOWN:
|
||||||
{
|
{
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
NDS_Pause();
|
NDS_Pause();
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
if (!importSave(hwnd, hAppInst))
|
||||||
ofn.lStructSize = sizeof(ofn);
|
MessageBox(hwnd,"Save was not successfully imported", "Error", MB_OK | MB_ICONERROR);
|
||||||
ofn.hwndOwner = hwnd;
|
|
||||||
ofn.lpstrFilter = "All supported types\0*.duc;*.sav\0Action Replay DS Save (*.duc)\0*.duc\0Raw/No$GBA Save format (*.sav)\0*.sav\0\0";
|
|
||||||
ofn.nFilterIndex = 1;
|
|
||||||
ofn.lpstrFile = ImportSavName;
|
|
||||||
ofn.nMaxFile = MAX_PATH;
|
|
||||||
ofn.lpstrDefExt = "duc";
|
|
||||||
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
|
|
||||||
|
|
||||||
char buffer[MAX_PATH];
|
|
||||||
ZeroMemory(buffer, sizeof(buffer));
|
|
||||||
path.getpath(path.BATTERY, buffer);
|
|
||||||
ofn.lpstrInitialDir = buffer;
|
|
||||||
|
|
||||||
if(!GetOpenFileName(&ofn))
|
|
||||||
{
|
|
||||||
NDS_UnPause();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NDS_ImportSave(ImportSavName))
|
|
||||||
MessageBox(hwnd,"Save was not successfully imported","Error",MB_OK);
|
|
||||||
NDS_UnPause();
|
NDS_UnPause();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue