re-add duc importing for new savefile system
This commit is contained in:
parent
c6c2ec7137
commit
47e27cffa5
|
@ -1090,7 +1090,7 @@ int NDS_ImportSave(const char *filename)
|
|||
return 0;
|
||||
|
||||
if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0)
|
||||
return mc_load_duc(&MMU.bupmem, filename);
|
||||
return MMU_new.backupDevice.load_duc(filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -874,3 +874,39 @@ void BackupDevice::flush()
|
|||
LOG("Unable to open savefile %s\n",filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool BackupDevice::load_duc(const char* filename)
|
||||
{
|
||||
long size;
|
||||
char id[16];
|
||||
FILE* file = fopen(filename, "rb");
|
||||
size_t elems_read = 0;
|
||||
if(file == NULL)
|
||||
return false;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
size = ftell(file) - 500;
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
// Make sure we really have the right file
|
||||
elems_read += fread((void *)id, sizeof(char), 16, file);
|
||||
|
||||
if (memcmp(id, "ARDS000000000001", 16) != 0)
|
||||
{
|
||||
LOG("Not recognized as a valid DUC file\n");
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
// Skip the rest of the header since we don't need it
|
||||
fseek(file, 500, SEEK_SET);
|
||||
|
||||
ensure((u32)size);
|
||||
|
||||
fread(&data[0],1,size,file);
|
||||
fclose(file);
|
||||
|
||||
flush();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
|
@ -88,6 +88,8 @@ public:
|
|||
static u32 addr_size_for_old_save_size(int bupmem_size);
|
||||
static u32 addr_size_for_old_save_type(int bupmem_type);
|
||||
|
||||
bool load_duc(const char* filename);
|
||||
|
||||
private:
|
||||
BOOL write_enable; //is write enabled?
|
||||
u32 com; //persistent command actually handled
|
||||
|
|
Loading…
Reference in New Issue