From 926e1ebddc5b983cd178cbbb0ed85b51b0d931ae Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Jun 2013 00:31:15 -0700 Subject: [PATCH] Keep EmuThread running on game shutdown. Especially relevant for games that call sceKernelExitGame(), like most homebrew. Otherwise, EmuThread actually quits and we can't continue. --- Core/System.h | 1 + Windows/EmuThread.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/System.h b/Core/System.h index 9ed6e7bbd9..9ddcb2a8d5 100644 --- a/Core/System.h +++ b/Core/System.h @@ -32,6 +32,7 @@ enum GlobalUIState { UISTATE_MENU, UISTATE_PAUSEMENU, UISTATE_INGAME, + UISTATE_EXIT, }; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 76ba989006..cb0be4f817 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -67,6 +67,7 @@ void EmuThread_Start() void EmuThread_Stop() { + globalUIState = UISTATE_EXIT; // DSound_UpdateSound(); Core_Stop(); Core_WaitInactive(800); @@ -137,7 +138,14 @@ unsigned int WINAPI TheThread(void *) Core_EnableStepping(FALSE); - Core_Run(); + while (globalUIState != UISTATE_EXIT) + { + Core_Run(); + + // We're here again, so the game quit. Restart Core_Run() which controls the UI. + // This way they can load a new game. + Core_UpdateState(CORE_RUNNING); + } shutdown: _InterlockedExchange(&emuThreadReady, THREAD_SHUTDOWN);