[Project64] Create system on load, not start

This commit is contained in:
zilmar 2016-06-04 17:07:15 +10:00
parent e7d4341106
commit 5de2d7c839
2 changed files with 22 additions and 10 deletions

View File

@ -236,14 +236,18 @@ bool CN64System::RunFileImage(const char * FileLoc)
WriteTrace(TraceN64System, TraceDebug, "Finished Loading (GoodName: %s)", g_Settings->LoadStringVal(Game_GoodName).c_str());
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
g_BaseSystem = new CN64System(g_Plugins, false);
if (g_BaseSystem)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
g_BaseSystem = new CN64System(g_Plugins, false);
if (g_BaseSystem)
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
g_BaseSystem->StartEmulation(true);
}
else
{
g_BaseSystem->SetActiveSystem(true);
}
}
}
else
@ -361,12 +365,14 @@ bool CN64System::RunDiskImage(const char * FileLoc)
void CN64System::CloseSystem()
{
WriteTrace(TraceN64System, TraceDebug, "Start");
if (g_BaseSystem)
{
g_BaseSystem->CloseCpu();
delete g_BaseSystem;
g_BaseSystem = NULL;
}
WriteTrace(TraceN64System, TraceDebug, "Done");
}
bool CN64System::EmulationStarting(CThread * thread)

View File

@ -179,18 +179,24 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
break;
case ID_FILE_STARTEMULATION:
m_Gui->SaveWindowLoc();
//Before we go and create the new system, ensure the previous one has been closed
CN64System::CloseSystem();
//Ok now g_BaseSystem should definitely be clean for initialization
g_BaseSystem = new CN64System(g_Plugins, false);
//Now we have created again, we can start up emulation
g_BaseSystem->StartEmulation(true);
if (g_BaseSystem)
{
g_BaseSystem->StartEmulation(true);
}
else
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
break;
case ID_FILE_ENDEMULATION:
{
CGuard Guard(m_CS);
WriteTrace(TraceUserInterface, TraceDebug, "ID_FILE_ENDEMULATION");
CN64System::CloseSystem();
if (g_BaseSystem)
{
g_BaseSystem->CloseCpu();
}
m_Gui->SaveWindowLoc();
}
break;