- add manual import\export No$GBA saves;
This commit is contained in:
mtabachenko 2009-09-17 11:42:17 +00:00
parent c151e6983c
commit f7e0c34ef3
4 changed files with 40 additions and 5 deletions

View File

@ -966,7 +966,10 @@ int NDS_ImportSave(const char *filename)
if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0)
return MMU_new.backupDevice.load_duc(filename);
else
return MMU_new.backupDevice.load_raw(filename);
if (MMU_new.backupDevice.load_no_gba(filename))
return 1;
else
return MMU_new.backupDevice.load_raw(filename);
return 0;
}
@ -976,6 +979,15 @@ bool NDS_ExportSave(const char *filename)
if (strlen(filename) < 4)
return false;
if (memcmp(filename+strlen(filename)-5, ".sav*", 5) == 0)
{
char tmp[MAX_PATH];
memset(tmp, 0, MAX_PATH);
strcpy(tmp, filename);
tmp[strlen(tmp)-1] = 0;
return MMU_new.backupDevice.save_no_gba(tmp);
}
if (memcmp(filename+strlen(filename)-4, ".sav", 4) == 0)
return MMU_new.backupDevice.save_raw(filename);
@ -2425,7 +2437,7 @@ void NDS_Reset()
for (int t = 0; t < 4096; t++)
MMU.ARM9_BIOS[t] = 0xFF;
_MMU_write32<ARMCPU_ARM9>(0xFFFF0018, 0xEA000027);
_MMU_write32<ARMCPU_ARM9>(0xFFFF0018, 0xEA000095);
for (int t = 0; t < 156; t++) // load logo
MMU.ARM9_BIOS[t + 0x20] = logo_data[t];

View File

@ -724,6 +724,26 @@ bool BackupDevice::load_no_gba(const char *fname)
return false;
}
bool BackupDevice::save_no_gba(const char* fname)
{
FILE* outf = fopen(fname,"wb");
if(!outf) return false;
u32 size = data.size();
u32 padSize = pad_up_size(size);
if(data.size()>0)
fwrite(&data[0],1,size,outf);
for(u32 i=size;i<padSize;i++)
fputc(0xFF,outf);
if (padSize < 512 * 1024)
{
for(u32 i=padSize; i<512 * 1024; i++)
fputc(0xFF,outf);
}
fclose(outf);
return true;
}
//======================================================================= end
//=======================================================================
//======================================================================= no$GBA

View File

@ -101,6 +101,7 @@ public:
bool load_duc(const char* filename);
bool load_no_gba(const char *fname);
bool save_no_gba(const char* fname);
bool load_raw(const char* filename);
bool save_raw(const char* filename);
bool load_movie(EMUFILE* is);

View File

@ -3780,7 +3780,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
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 Save format (*.sav)\0*.sav\0\0";
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;
@ -3810,12 +3810,12 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Raw Save format (*.sav)\0*.sav\0\0";
ofn.lpstrFilter = "Raw Save format (*.sav)\0*.sav\0No$GBA Save format (*.sav)\0*.sav\0\0";
ofn.nFilterIndex = 0;
ofn.lpstrFile = ImportSavName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "sav";
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
if(!GetSaveFileName(&ofn))
{
@ -3823,6 +3823,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
return 0;
}
if (ofn.nFilterIndex == 2) strcat(ImportSavName, "*");
if (!NDS_ExportSave(ImportSavName))
MessageBox(hwnd,"Save was not successfully exported","Error",MB_OK);
NDS_UnPause();