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());
|
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;
|
CBlockFile SaveState;
|
||||||
|
|
||||||
// Generate file path
|
// 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
|
// Open and check to make sure format is correct
|
||||||
if (OKAY != SaveState.Load(file_path))
|
if (OKAY != SaveState.Load(file_path))
|
||||||
|
@ -779,12 +780,13 @@ 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)
|
int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *Inputs, COutputs *Outputs)
|
||||||
{
|
{
|
||||||
#endif // SUPERMODEL_DEBUGGER
|
#endif // SUPERMODEL_DEBUGGER
|
||||||
unsigned prevFPSTicks;
|
std::string initialState = s_runtime_config["InitStateFile"].ValueAs<std::string>();
|
||||||
unsigned fpsFramesElapsed;
|
unsigned prevFPSTicks;
|
||||||
bool gameHasLightguns = false;
|
unsigned fpsFramesElapsed;
|
||||||
bool quit = false;
|
bool gameHasLightguns = false;
|
||||||
bool paused = false;
|
bool quit = false;
|
||||||
bool dumpTimings = false;
|
bool paused = false;
|
||||||
|
bool dumpTimings = false;
|
||||||
|
|
||||||
// Initialize and load ROMs
|
// Initialize and load ROMs
|
||||||
if (OKAY != Model3->Init())
|
if (OKAY != Model3->Init())
|
||||||
|
@ -839,6 +841,10 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In
|
||||||
// Reset emulator
|
// Reset emulator
|
||||||
Model3->Reset();
|
Model3->Reset();
|
||||||
|
|
||||||
|
// Load initial save state if requested
|
||||||
|
if (initialState.length() > 0)
|
||||||
|
LoadState(Model3, initialState);
|
||||||
|
|
||||||
#ifdef SUPERMODEL_DEBUGGER
|
#ifdef SUPERMODEL_DEBUGGER
|
||||||
// If debugger was supplied, set it as logger and attach it to system
|
// If debugger was supplied, set it as logger and attach it to system
|
||||||
oldLogger = GetLogger();
|
oldLogger = GetLogger();
|
||||||
|
@ -1273,6 +1279,7 @@ static Util::Config::Node DefaultConfig()
|
||||||
{
|
{
|
||||||
Util::Config::Node config("Global");
|
Util::Config::Node config("Global");
|
||||||
config.Set("GameXMLFile", s_gameXMLFilePath);
|
config.Set("GameXMLFile", s_gameXMLFilePath);
|
||||||
|
config.Set("InitStateFile", "");
|
||||||
// CModel3
|
// CModel3
|
||||||
config.Set("MultiThreaded", true);
|
config.Set("MultiThreaded", true);
|
||||||
config.Set("GPUMultiThreaded", true);
|
config.Set("GPUMultiThreaded", true);
|
||||||
|
@ -1352,6 +1359,7 @@ static void Help(void)
|
||||||
puts(" -no-threads Disable multi-threading entirely");
|
puts(" -no-threads Disable multi-threading entirely");
|
||||||
puts(" -gpu-multi-threaded Run graphics rendering in separate thread [Default]");
|
puts(" -gpu-multi-threaded Run graphics rendering in separate thread [Default]");
|
||||||
puts(" -no-gpu-thread Run graphics rendering in main thread");
|
puts(" -no-gpu-thread Run graphics rendering in main thread");
|
||||||
|
puts(" -load-state=<file> Load save state after starting");
|
||||||
puts("");
|
puts("");
|
||||||
puts("Video Options:");
|
puts("Video Options:");
|
||||||
puts(" -res=<x>,<y> Resolution [Default: 496,384]");
|
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
|
const std::map<std::string, std::string> valued_options
|
||||||
{ // -option=value
|
{ // -option=value
|
||||||
{ "-game-xml-file", "GameXMLFile" },
|
{ "-game-xml-file", "GameXMLFile" },
|
||||||
|
{ "-load-state", "InitStateFile" },
|
||||||
{ "-ppc-frequency", "PowerPCFrequency" },
|
{ "-ppc-frequency", "PowerPCFrequency" },
|
||||||
{ "-crosshairs", "Crosshairs" },
|
{ "-crosshairs", "Crosshairs" },
|
||||||
{ "-vert-shader", "VertexShader" },
|
{ "-vert-shader", "VertexShader" },
|
||||||
|
|
Loading…
Reference in a new issue