mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-25 23:25:40 +00:00
Added ability to load save state at startup using -load-state or InitStateFile (in config file)
This commit is contained in:
parent
d21e71dced
commit
f0ea6b45a8
|
@ -552,12 +552,13 @@ static void SaveState(IEmulator *Model3)
|
|||
DebugLog("Saved state to '%s'.\n", file_path.c_str());
|
||||
}
|
||||
|
||||
static void LoadState(IEmulator *Model3)
|
||||
static void LoadState(IEmulator *Model3, std::string file_path = std::string())
|
||||
{
|
||||
CBlockFile SaveState;
|
||||
|
||||
// Generate file path
|
||||
std::string file_path = Util::Format() << "Saves/" << Model3->GetGame().name << ".st" << s_saveSlot;
|
||||
if (file_path.empty())
|
||||
file_path = Util::Format() << "Saves/" << Model3->GetGame().name << ".st" << s_saveSlot;
|
||||
|
||||
// Open and check to make sure format is correct
|
||||
if (OKAY != SaveState.Load(file_path))
|
||||
|
@ -779,6 +780,7 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In
|
|||
int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *Inputs, COutputs *Outputs)
|
||||
{
|
||||
#endif // SUPERMODEL_DEBUGGER
|
||||
std::string initialState = s_runtime_config["InitStateFile"].ValueAs<std::string>();
|
||||
unsigned prevFPSTicks;
|
||||
unsigned fpsFramesElapsed;
|
||||
bool gameHasLightguns = false;
|
||||
|
@ -839,6 +841,10 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In
|
|||
// Reset emulator
|
||||
Model3->Reset();
|
||||
|
||||
// Load initial save state if requested
|
||||
if (initialState.length() > 0)
|
||||
LoadState(Model3, initialState);
|
||||
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
// If debugger was supplied, set it as logger and attach it to system
|
||||
oldLogger = GetLogger();
|
||||
|
@ -1273,6 +1279,7 @@ static Util::Config::Node DefaultConfig()
|
|||
{
|
||||
Util::Config::Node config("Global");
|
||||
config.Set("GameXMLFile", s_gameXMLFilePath);
|
||||
config.Set("InitStateFile", "");
|
||||
// CModel3
|
||||
config.Set("MultiThreaded", true);
|
||||
config.Set("GPUMultiThreaded", true);
|
||||
|
@ -1352,6 +1359,7 @@ static void Help(void)
|
|||
puts(" -no-threads Disable multi-threading entirely");
|
||||
puts(" -gpu-multi-threaded Run graphics rendering in separate thread [Default]");
|
||||
puts(" -no-gpu-thread Run graphics rendering in main thread");
|
||||
puts(" -load-state=<file> Load save state after starting");
|
||||
puts("");
|
||||
puts("Video Options:");
|
||||
puts(" -res=<x>,<y> Resolution [Default: 496,384]");
|
||||
|
@ -1432,6 +1440,7 @@ static ParsedCommandLine ParseCommandLine(int argc, char **argv)
|
|||
const std::map<std::string, std::string> valued_options
|
||||
{ // -option=value
|
||||
{ "-game-xml-file", "GameXMLFile" },
|
||||
{ "-load-state", "InitStateFile" },
|
||||
{ "-ppc-frequency", "PowerPCFrequency" },
|
||||
{ "-crosshairs", "Crosshairs" },
|
||||
{ "-vert-shader", "VertexShader" },
|
||||
|
|
Loading…
Reference in a new issue