diff --git a/Core/Core.cpp b/Core/Core.cpp index 844a3e1186..63894d4d0b 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -136,13 +136,13 @@ static inline void UpdateRunLoop() { EndInputState(&input_state); } - if (globalUIState != UISTATE_EXIT) { + if (GetUIState() != UISTATE_EXIT) { NativeRender(); } } void Core_RunLoop() { - while ((globalUIState != UISTATE_INGAME || !PSP_IsInited()) && globalUIState != UISTATE_EXIT) { + while ((GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT) { time_update(); #if defined(USING_WIN_UI) @@ -161,7 +161,7 @@ void Core_RunLoop() { #endif } - while (!coreState && globalUIState == UISTATE_INGAME) { + while (!coreState && GetUIState() == UISTATE_INGAME) { time_update(); UpdateRunLoop(); #if defined(USING_WIN_UI) @@ -203,9 +203,9 @@ void Core_Run() #endif { reswitch: - if (globalUIState != UISTATE_INGAME) { + if (GetUIState() != UISTATE_INGAME) { CoreStateProcessed(); - if (globalUIState == UISTATE_EXIT) { + if (GetUIState() == UISTATE_EXIT) { return; } Core_RunLoop(); diff --git a/Core/PSPMixer.cpp b/Core/PSPMixer.cpp index e39f1875ca..b82d9e649f 100644 --- a/Core/PSPMixer.cpp +++ b/Core/PSPMixer.cpp @@ -26,5 +26,5 @@ int PSPMixer::Mix(short *stereoout, int numSamples) { - return __AudioMix(stereoout, numSamples); + return __AudioMix(stereoout, numSamples); } diff --git a/Core/System.cpp b/Core/System.cpp index 2a4c27e7a0..94445ac60f 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -72,7 +72,7 @@ enum CPUThreadState { MetaFileSystem pspFileSystem; ParamSFOData g_paramSFO; -GlobalUIState globalUIState; +static GlobalUIState globalUIState; static CoreParameter coreParameter; static PSPMixer *mixer; static std::thread *cpuThread = NULL; @@ -96,6 +96,10 @@ void UpdateUIState(GlobalUIState newState) { } } +GlobalUIState GetUIState() { + return globalUIState; +} + bool IsAudioInitialised() { return mixer != NULL; } diff --git a/Core/System.h b/Core/System.h index 04ac782202..336ac59ff6 100644 --- a/Core/System.h +++ b/Core/System.h @@ -45,9 +45,9 @@ enum PSPDirectories { DIRECTORY_DUMP, }; -extern GlobalUIState globalUIState; void UpdateUIState(GlobalUIState newState); +GlobalUIState GetUIState(); bool PSP_Init(const CoreParameter &coreParam, std::string *error_string); bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 837d8913e5..1e99aa0eba 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -118,7 +118,7 @@ void EmuScreen::bootGame(const std::string &filename) { } void EmuScreen::bootComplete() { - globalUIState = UISTATE_INGAME; + UpdateUIState(UISTATE_INGAME); host->BootDone(); host->UpdateDisassembly(); diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 707e825adc..af1e658e2a 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -76,4 +76,6 @@ private: // In-memory save state used for freezeFrame, which is useful for debugging. std::vector freezeState_; + + std::string tag_; }; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 286bc76175..b089486396 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1063,7 +1063,7 @@ UI::EventReturn MainScreen::OnExit(UI::EventParams &e) { exit(0); #endif - globalUIState = UISTATE_EXIT; + UpdateUIState(UISTATE_EXIT); return UI::EVENT_DONE; } diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 55812ffb85..a21c346e14 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -816,7 +816,7 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) HWND hDlg = m_hDlg; // Update Dialog Windows - if (_bDebug && globalUIState == UISTATE_INGAME && PSP_IsInited()) + if (_bDebug && GetUIState() == UISTATE_INGAME && PSP_IsInited()) { Core_WaitInactive(TEMP_BREAKPOINT_WAIT_MS); CBreakPoints::ClearTemporaryBreakPoints(); @@ -849,7 +849,7 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) { updateThreadLabel(true); - if (globalUIState == UISTATE_INGAME && PSP_IsInited()) + if (GetUIState() == UISTATE_INGAME && PSP_IsInited()) { SetDlgItemText(m_hDlg, IDC_STOPGO, L"Stop"); EnableWindow( GetDlgItem(hDlg, IDC_STOPGO), TRUE); diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 985ed2fb65..7e6412ae2c 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -58,7 +58,7 @@ void EmuThread_Stop() return; } - globalUIState = UISTATE_EXIT; + UpdateUIState(UISTATE_EXIT); Core_Stop(); Core_WaitInactive(800); if (WAIT_TIMEOUT == WaitForSingleObject(emuThread, 800)) @@ -132,7 +132,7 @@ unsigned int WINAPI TheThread(void *) Core_EnableStepping(FALSE); - while (globalUIState != UISTATE_EXIT) + while (GetUIState() != UISTATE_EXIT) { // We're here again, so the game quit. Restart Core_Run() which controls the UI. // This way they can load a new game. diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 24dc8e339c..a0f5153b18 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -267,7 +267,7 @@ namespace MainWindow { } void CorrectCursor() { - bool autoHide = g_Config.bFullScreen && !mouseButtonDown && globalUIState == UISTATE_INGAME; + bool autoHide = g_Config.bFullScreen && !mouseButtonDown && GetUIState() == UISTATE_INGAME; if (autoHide && hideCursor) { while (cursorCounter >= 0) { cursorCounter = ShowCursor(FALSE); @@ -652,7 +652,7 @@ namespace MainWindow { // TODO: Urgh! Why do we need this here? // The menu is supposed to enable/disable this stuff directly afterward. - SetIngameMenuItemStates(globalUIState); + SetIngameMenuItemStates(GetUIState()); DrawMenuBar(hwndMain); UpdateMenus(); @@ -837,7 +837,7 @@ namespace MainWindow { } browsePauseAfter = false; - if (globalUIState == UISTATE_INGAME) { + if (GetUIState() == UISTATE_INGAME) { browsePauseAfter = Core_IsStepping(); if (!browsePauseAfter) Core_EnableStepping(true); @@ -858,7 +858,7 @@ namespace MainWindow { Core_EnableStepping(false); } } else { - if (globalUIState == UISTATE_INGAME || globalUIState == UISTATE_PAUSEMENU) { + if (GetUIState() == UISTATE_INGAME || GetUIState() == UISTATE_PAUSEMENU) { Core_EnableStepping(false); } @@ -1020,7 +1020,7 @@ namespace MainWindow { g_activeWindow = WINDOW_MAINWINDOW; pause = false; } - if (!noFocusPause && g_Config.bPauseOnLostFocus && globalUIState == UISTATE_INGAME) { + if (!noFocusPause && g_Config.bPauseOnLostFocus && GetUIState() == UISTATE_INGAME) { if (pause != Core_IsStepping()) { // != is xor for bools if (disasmWindow[0]) SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); @@ -1100,7 +1100,7 @@ namespace MainWindow { break; case ID_TOGGLE_PAUSE: - if (globalUIState == UISTATE_PAUSEMENU) { + if (GetUIState() == UISTATE_PAUSEMENU) { // Causes hang //NativeMessageReceived("run", ""); @@ -1814,18 +1814,18 @@ namespace MainWindow { static GlobalUIState lastGlobalUIState = UISTATE_PAUSEMENU; static CoreState lastCoreState = CORE_ERROR; - if (lastGlobalUIState == globalUIState && lastCoreState == coreState) + if (lastGlobalUIState == GetUIState() && lastCoreState == coreState) return; lastCoreState = coreState; - lastGlobalUIState = globalUIState; + lastGlobalUIState = GetUIState(); HMENU menu = GetMenu(GetHWND()); - bool isPaused = Core_IsStepping() && globalUIState == UISTATE_INGAME; + bool isPaused = Core_IsStepping() && GetUIState() == UISTATE_INGAME; TranslateMenuItem(ID_TOGGLE_PAUSE, L"\tF8", isPaused ? "Run" : "Pause"); - SetIngameMenuItemStates(globalUIState); + SetIngameMenuItemStates(GetUIState()); EnableMenuItem(menu, ID_DEBUG_LOG, !g_Config.bEnableLogging); }