make instances save to different save files, too
This commit is contained in:
parent
135524675d
commit
80c3fe4b25
|
@ -34,6 +34,7 @@ void StopEmu();
|
|||
|
||||
// instance ID, for local multiplayer
|
||||
int InstanceID();
|
||||
std::string InstanceFileSuffix();
|
||||
|
||||
// configuration values
|
||||
|
||||
|
|
14
src/SPI.cpp
14
src/SPI.cpp
|
@ -79,16 +79,6 @@ bool VerifyCRC16(u32 start, u32 offset, u32 len, u32 crcoffset)
|
|||
return (crc_stored == crc_calced);
|
||||
}
|
||||
|
||||
std::string InstanceSuffix()
|
||||
{
|
||||
int inst = Platform::InstanceID();
|
||||
if (inst == 0) return "";
|
||||
|
||||
char suffix[16] = {0};
|
||||
snprintf(suffix, 15, ".%d", inst+1);
|
||||
return suffix;
|
||||
}
|
||||
|
||||
|
||||
bool Init()
|
||||
{
|
||||
|
@ -225,7 +215,7 @@ void LoadDefaultFirmware()
|
|||
// wifi access points
|
||||
// TODO: WFC ID??
|
||||
|
||||
FILE* f = Platform::OpenLocalFile("wfcsettings.bin"+InstanceSuffix(), "rb");
|
||||
FILE* f = Platform::OpenLocalFile("wfcsettings.bin"+Platform::InstanceFileSuffix(), "rb");
|
||||
if (!f) f = Platform::OpenLocalFile("wfcsettings.bin", "rb");
|
||||
if (f)
|
||||
{
|
||||
|
@ -348,7 +338,7 @@ void Reset()
|
|||
|
||||
bool makecopy = false;
|
||||
std::string origpath = FirmwarePath;
|
||||
FirmwarePath += InstanceSuffix();
|
||||
FirmwarePath += Platform::InstanceFileSuffix();
|
||||
|
||||
FILE* f = Platform::OpenLocalFile(FirmwarePath, "rb");
|
||||
if (!f)
|
||||
|
|
|
@ -158,6 +158,16 @@ int InstanceID()
|
|||
return IPCInstanceID;
|
||||
}
|
||||
|
||||
std::string InstanceFileSuffix()
|
||||
{
|
||||
int inst = IPCInstanceID;
|
||||
if (inst == 0) return "";
|
||||
|
||||
char suffix[16] = {0};
|
||||
snprintf(suffix, 15, ".%d", inst+1);
|
||||
return suffix;
|
||||
}
|
||||
|
||||
|
||||
int GetConfigInt(ConfigEntry entry)
|
||||
{
|
||||
|
|
|
@ -326,6 +326,7 @@ bool LoadState(std::string filename)
|
|||
|
||||
std::string savefile = filename.substr(LastSep(filename)+1);
|
||||
savefile = GetAssetPath(false, Config::SaveFilePath, ".sav", savefile);
|
||||
savefile += Platform::InstanceFileSuffix();
|
||||
NDSSave->SetPath(savefile, true);
|
||||
}
|
||||
|
||||
|
@ -350,6 +351,7 @@ bool SaveState(std::string filename)
|
|||
{
|
||||
std::string savefile = filename.substr(LastSep(filename)+1);
|
||||
savefile = GetAssetPath(false, Config::SaveFilePath, ".sav", savefile);
|
||||
savefile += Platform::InstanceFileSuffix();
|
||||
NDSSave->SetPath(savefile, false);
|
||||
}
|
||||
|
||||
|
@ -432,6 +434,7 @@ void Reset()
|
|||
{
|
||||
std::string oldsave = NDSSave->GetPath();
|
||||
std::string newsave = GetAssetPath(false, Config::SaveFilePath, ".sav");
|
||||
newsave += Platform::InstanceFileSuffix();
|
||||
if (oldsave != newsave)
|
||||
NDSSave->SetPath(newsave, false);
|
||||
}
|
||||
|
@ -440,6 +443,7 @@ void Reset()
|
|||
{
|
||||
std::string oldsave = GBASave->GetPath();
|
||||
std::string newsave = GetAssetPath(true, Config::SaveFilePath, ".sav");
|
||||
newsave += Platform::InstanceFileSuffix();
|
||||
if (oldsave != newsave)
|
||||
GBASave->SetPath(newsave, false);
|
||||
}
|
||||
|
@ -562,7 +566,11 @@ bool LoadROM(QStringList filepath, bool reset)
|
|||
u8* savedata = nullptr;
|
||||
|
||||
std::string savname = GetAssetPath(false, Config::SaveFilePath, ".sav");
|
||||
std::string origsav = savname;
|
||||
savname += Platform::InstanceFileSuffix();
|
||||
|
||||
FILE* sav = Platform::OpenFile(savname, "rb", true);
|
||||
if (!sav) sav = Platform::OpenFile(origsav, "rb", true);
|
||||
if (sav)
|
||||
{
|
||||
fseek(sav, 0, SEEK_END);
|
||||
|
@ -711,7 +719,11 @@ bool LoadGBAROM(QStringList filepath)
|
|||
u8* savedata = nullptr;
|
||||
|
||||
std::string savname = GetAssetPath(true, Config::SaveFilePath, ".sav");
|
||||
std::string origsav = savname;
|
||||
savname += Platform::InstanceFileSuffix();
|
||||
|
||||
FILE* sav = Platform::OpenFile(savname, "rb", true);
|
||||
if (!sav) sav = Platform::OpenFile(origsav, "rb", true);
|
||||
if (sav)
|
||||
{
|
||||
fseek(sav, 0, SEEK_END);
|
||||
|
|
Loading…
Reference in New Issue