Separate the configured saveType from the runtime saveType
This commit is contained in:
parent
f2b22ad484
commit
97d2f385d2
24
src/Util.cpp
24
src/Util.cpp
|
@ -700,7 +700,7 @@ void utilGBAFindSave(const int size)
|
||||||
{
|
{
|
||||||
u32 *p = (u32 *)&rom[0];
|
u32 *p = (u32 *)&rom[0];
|
||||||
u32 *end = (u32 *)(&rom[0] + size);
|
u32 *end = (u32 *)(&rom[0] + size);
|
||||||
int saveType = 0;
|
int detectedSaveType = 0;
|
||||||
int flashSize = 0x10000;
|
int flashSize = 0x10000;
|
||||||
bool rtcFound = false;
|
bool rtcFound = false;
|
||||||
|
|
||||||
|
@ -709,23 +709,23 @@ void utilGBAFindSave(const int size)
|
||||||
|
|
||||||
if(d == 0x52504545) {
|
if(d == 0x52504545) {
|
||||||
if(memcmp(p, "EEPROM_", 7) == 0) {
|
if(memcmp(p, "EEPROM_", 7) == 0) {
|
||||||
if(saveType == 0)
|
if(detectedSaveType == 0)
|
||||||
saveType = 1;
|
detectedSaveType = 1;
|
||||||
}
|
}
|
||||||
} else if (d == 0x4D415253) {
|
} else if (d == 0x4D415253) {
|
||||||
if(memcmp(p, "SRAM_", 5) == 0) {
|
if(memcmp(p, "SRAM_", 5) == 0) {
|
||||||
if(saveType == 0)
|
if(detectedSaveType == 0)
|
||||||
saveType = 2;
|
detectedSaveType = 2;
|
||||||
}
|
}
|
||||||
} else if (d == 0x53414C46) {
|
} else if (d == 0x53414C46) {
|
||||||
if(memcmp(p, "FLASH1M_", 8) == 0) {
|
if(memcmp(p, "FLASH1M_", 8) == 0) {
|
||||||
if(saveType == 0) {
|
if(detectedSaveType == 0) {
|
||||||
saveType = 3;
|
detectedSaveType = 3;
|
||||||
flashSize = 0x20000;
|
flashSize = 0x20000;
|
||||||
}
|
}
|
||||||
} else if(memcmp(p, "FLASH", 5) == 0) {
|
} else if(memcmp(p, "FLASH", 5) == 0) {
|
||||||
if(saveType == 0) {
|
if(detectedSaveType == 0) {
|
||||||
saveType = 3;
|
detectedSaveType = 3;
|
||||||
flashSize = 0x10000;
|
flashSize = 0x10000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -736,11 +736,11 @@ void utilGBAFindSave(const int size)
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
// if no matches found, then set it to NONE
|
// if no matches found, then set it to NONE
|
||||||
if(saveType == 0) {
|
if(detectedSaveType == 0) {
|
||||||
saveType = 5;
|
detectedSaveType = 5;
|
||||||
}
|
}
|
||||||
rtcEnable(rtcFound);
|
rtcEnable(rtcFound);
|
||||||
cpuSaveType = saveType;
|
saveType = detectedSaveType;
|
||||||
flashSetSize(flashSize);
|
flashSetSize(flashSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -439,6 +439,11 @@ static void gba_init(void)
|
||||||
|
|
||||||
|
|
||||||
utilUpdateSystemColorMaps(false);
|
utilUpdateSystemColorMaps(false);
|
||||||
|
|
||||||
|
if (cpuSaveType == 0)
|
||||||
|
utilGBAFindSave(size);
|
||||||
|
else
|
||||||
|
saveType = cpuSaveType;
|
||||||
|
|
||||||
load_image_preferences();
|
load_image_preferences();
|
||||||
|
|
||||||
|
|
|
@ -1653,6 +1653,11 @@ int main(int argc, char **argv)
|
||||||
int size = CPULoadRom(szFile);
|
int size = CPULoadRom(szFile);
|
||||||
failed = (size == 0);
|
failed = (size == 0);
|
||||||
if(!failed) {
|
if(!failed) {
|
||||||
|
if (cpuSaveType == 0)
|
||||||
|
utilGBAFindSave(size);
|
||||||
|
else
|
||||||
|
saveType = cpuSaveType;
|
||||||
|
|
||||||
sdlApplyPerImagePreferences();
|
sdlApplyPerImagePreferences();
|
||||||
|
|
||||||
doMirroring(mirroringEnable);
|
doMirroring(mirroringEnable);
|
||||||
|
|
|
@ -525,6 +525,8 @@ bool MainWnd::FileRun()
|
||||||
|
|
||||||
if (cpuSaveType == 0)
|
if (cpuSaveType == 0)
|
||||||
utilGBAFindSave(theApp.romSize);
|
utilGBAFindSave(theApp.romSize);
|
||||||
|
else
|
||||||
|
saveType = cpuSaveType;
|
||||||
|
|
||||||
GetModuleFileName(NULL, tempName, 2048);
|
GetModuleFileName(NULL, tempName, 2048);
|
||||||
|
|
||||||
|
@ -1114,8 +1116,9 @@ void MainWnd::OnFileLoadDotCode()
|
||||||
FALSE);
|
FALSE);
|
||||||
if (file.DoModal() == IDOK)
|
if (file.DoModal() == IDOK)
|
||||||
{
|
{
|
||||||
theApp.loadDotCodeFile = file.GetPathName();
|
const char* filename = file.GetPathName();
|
||||||
SetLoadDotCodeFile(theApp.loadDotCodeFile);
|
strcpy(loadDotCodeFile, filename);
|
||||||
|
SetLoadDotCodeFile(loadDotCodeFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1136,8 +1139,9 @@ void MainWnd::OnFileSaveDotCode()
|
||||||
TRUE);
|
TRUE);
|
||||||
if (file.DoModal() == IDOK)
|
if (file.DoModal() == IDOK)
|
||||||
{
|
{
|
||||||
theApp.saveDotCodeFile = file.GetPathName();
|
const char* filename = file.GetPathName();
|
||||||
SetLoadDotCodeFile(theApp.saveDotCodeFile);
|
strcpy(saveDotCodeFile, filename);
|
||||||
|
SetLoadDotCodeFile(saveDotCodeFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -803,7 +803,7 @@ void MainWnd::OnOptionsEmulatorSavetypeDetectNow()
|
||||||
CString answer( _T( "This cartridge has probably no backup media." ) );
|
CString answer( _T( "This cartridge has probably no backup media." ) );
|
||||||
|
|
||||||
utilGBAFindSave(theApp.romSize);
|
utilGBAFindSave(theApp.romSize);
|
||||||
switch (cpuSaveType)
|
switch (saveType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
answer = _T("This cartridge has probably no backup media.");
|
answer = _T("This cartridge has probably no backup media.");
|
||||||
|
|
|
@ -202,6 +202,12 @@ void GameArea::LoadGame(const wxString &name)
|
||||||
cpuSaveType = cfg->Read(wxT("saveType"), gopts.save_type);
|
cpuSaveType = cfg->Read(wxT("saveType"), gopts.save_type);
|
||||||
if(cpuSaveType < 0 || cpuSaveType > 5)
|
if(cpuSaveType < 0 || cpuSaveType > 5)
|
||||||
cpuSaveType = gopts.save_type;
|
cpuSaveType = gopts.save_type;
|
||||||
|
|
||||||
|
if (cpuSaveType == 0)
|
||||||
|
utilGBAFindSave(size);
|
||||||
|
else
|
||||||
|
saveType = cpuSaveType;
|
||||||
|
|
||||||
mirroringEnable = cfg->Read(wxT("mirroringEnabled"), (long)0);
|
mirroringEnable = cfg->Read(wxT("mirroringEnabled"), (long)0);
|
||||||
|
|
||||||
cfg->SetPath(wxT("/"));
|
cfg->SetPath(wxT("/"));
|
||||||
|
@ -209,13 +215,17 @@ void GameArea::LoadGame(const wxString &name)
|
||||||
rtcEnable(gopts.rtc);
|
rtcEnable(gopts.rtc);
|
||||||
flashSetSize(0x10000 << gopts.flash_size);
|
flashSetSize(0x10000 << gopts.flash_size);
|
||||||
cpuSaveType = gopts.save_type;
|
cpuSaveType = gopts.save_type;
|
||||||
|
if (cpuSaveType == 0)
|
||||||
|
utilGBAFindSave(size);
|
||||||
|
else
|
||||||
|
saveType = cpuSaveType;
|
||||||
// mirroring short ROMs is such an uncommon thing that any
|
// mirroring short ROMs is such an uncommon thing that any
|
||||||
// carts needing it should be added to vba-over.ini.
|
// carts needing it should be added to vba-over.ini.
|
||||||
// on the other hand, I would see nothing wrong with enabling
|
// on the other hand, I would see nothing wrong with enabling
|
||||||
// by default on carts that are small enough (i.e., always
|
// by default on carts that are small enough (i.e., always
|
||||||
// set this to true and ignore vba-over.ini). It's just a one-time
|
// set this to true and ignore vba-over.ini). It's just a one-time
|
||||||
// init.
|
// init.
|
||||||
mirroringEnable = false;
|
mirroringEnable = true;
|
||||||
}
|
}
|
||||||
doMirroring(mirroringEnable);
|
doMirroring(mirroringEnable);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue