diff --git a/Core/System.h b/Core/System.h index 2f03b20220..58a5c4d540 100644 --- a/Core/System.h +++ b/Core/System.h @@ -18,10 +18,11 @@ #pragma once #include "../Globals.h" -#include "MemMap.h" -#include "FileSystems/MetaFileSystem.h" -#include "CoreParameter.h" -#include "ELF/ParamSFO.h" +#include "Core/MemMap.h" +#include "Core/Host.h" +#include "Core/FileSystems/MetaFileSystem.h" +#include "Core/CoreParameter.h" +#include "Core/ELF/ParamSFO.h" extern MetaFileSystem pspFileSystem; extern ParamSFOData g_paramSFO; @@ -38,6 +39,13 @@ enum GlobalUIState { extern GlobalUIState globalUIState; +inline static void UpdateUIState(GlobalUIState newState) { + if (globalUIState != newState) { + globalUIState = newState; + host->UpdateDisassembly(); + } +} + bool PSP_Init(const CoreParameter &coreParam, std::string *error_string); bool PSP_IsInited(); void PSP_Shutdown(); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index af3af1574e..62634b18a1 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -166,11 +166,11 @@ void EmuScreen::sendMessage(const char *message, const char *value) { bootGame(value); } else if (!strcmp(message, "control mapping")) { - globalUIState = UISTATE_MENU; + UpdateUIState(UISTATE_MENU); screenManager()->push(new ControlMappingScreen()); } else if (!strcmp(message, "settings")) { - globalUIState = UISTATE_MENU; + UpdateUIState(UISTATE_MENU); screenManager()->push(new GameSettingsScreen(gamePath_)); } } @@ -423,7 +423,7 @@ void EmuScreen::update(InputState &input) { PSP_CoreParameter().pixelWidth = pixel_xres; PSP_CoreParameter().pixelHeight = pixel_yres; - globalUIState = UISTATE_INGAME; + UpdateUIState(UISTATE_INGAME); if (errorMessage_.size()) { I18NCategory *g = GetI18NCategory("Error"); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index e31f399114..a6b0eac362 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -559,18 +559,18 @@ void MainScreen::sendMessage(const char *message, const char *value) { screenManager()->RecreateAllViews(); } if (!strcmp(message, "control mapping")) { - globalUIState = UISTATE_MENU; + UpdateUIState(UISTATE_MENU); screenManager()->push(new ControlMappingScreen()); } if (!strcmp(message, "settings")) { - globalUIState = UISTATE_MENU; + UpdateUIState(UISTATE_MENU); screenManager()->push(new GameSettingsScreen("")); } } void MainScreen::update(InputState &input) { UIScreen::update(input); - globalUIState = UISTATE_MENU; + UpdateUIState(UISTATE_MENU); } UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) { @@ -665,7 +665,7 @@ UI::EventReturn MainScreen::OnExit(UI::EventParams &e) { } void GamePauseScreen::update(InputState &input) { - globalUIState = UISTATE_PAUSEMENU; + UpdateUIState(UISTATE_PAUSEMENU); UIScreen::update(input); } diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d105af1cb7..8befce9fc1 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -389,7 +389,7 @@ UI::EventReturn CreditsScreen::OnOK(UI::EventParams &e) { void CreditsScreen::update(InputState &input_state) { UIScreen::update(input_state); - globalUIState = UISTATE_MENU; + UpdateUIState(UISTATE_MENU); if (input_state.pad_buttons_down & PAD_BUTTON_BACK) { screenManager()->finishDialog(this, DR_OK); } diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 488b843fe4..a7ad9181c3 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -230,7 +230,7 @@ void CDisasm::changeSubWindow(SubWindowType type) void CDisasm::stepInto() { - if (Core_IsActive()) return; + if (!Core_IsStepping()) return; CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); lastTicks = CoreTiming::GetTicks(); @@ -790,7 +790,7 @@ void CDisasm::SetDebugMode(bool _bDebug) HWND hDlg = m_hDlg; // Update Dialog Windows - if (_bDebug) + if (_bDebug && globalUIState == UISTATE_INGAME) { Core_WaitInactive(TEMP_BREAKPOINT_WAIT_MS); CBreakPoints::ClearTemporaryBreakPoints(); @@ -800,6 +800,7 @@ void CDisasm::SetDebugMode(bool _bDebug) updateThreadLabel(false); SetDlgItemText(m_hDlg, IDC_STOPGO, L"Go"); + EnableWindow( GetDlgItem(hDlg, IDC_STOPGO), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEP), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEPOVER), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEPHLE), TRUE); @@ -819,7 +820,16 @@ void CDisasm::SetDebugMode(bool _bDebug) { updateThreadLabel(true); - SetDlgItemText(m_hDlg, IDC_STOPGO, L"Stop"); + if (globalUIState == UISTATE_INGAME) + { + SetDlgItemText(m_hDlg, IDC_STOPGO, L"Stop"); + EnableWindow( GetDlgItem(hDlg, IDC_STOPGO), TRUE); + } + else + { + SetDlgItemText(m_hDlg, IDC_STOPGO, L"Go"); + EnableWindow( GetDlgItem(hDlg, IDC_STOPGO), FALSE); + } EnableWindow( GetDlgItem(hDlg, IDC_STEP), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_STEPOVER), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_STEPHLE), FALSE); diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index 4168a27d5c..4e75cd084d 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -60,6 +60,7 @@ public: virtual void Update() { UpdateDialog(true); + SetDebugMode(Core_IsStepping()); breakpointList->update(); }; void UpdateDialog(bool _bComplete = false); diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 80e99c5e92..c17cea7933 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -742,12 +742,10 @@ namespace MainWindow void CreateDebugWindows() { disasmWindow[0] = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); DialogManager::AddDlg(disasmWindow[0]); - EnableWindow(disasmWindow[0]->GetDlgHandle(),FALSE); disasmWindow[0]->Show(g_Config.bShowDebuggerOnLoad); memoryWindow[0] = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); DialogManager::AddDlg(memoryWindow[0]); - EnableWindow(memoryWindow[0]->GetDlgHandle(),FALSE); } void BrowseAndBoot(std::string defaultPath, bool browseDirectory) { @@ -1071,9 +1069,6 @@ namespace MainWindow break; case ID_EMULATION_STOP: - EnableWindow(disasmWindow[0]->GetDlgHandle(),FALSE); - EnableWindow(memoryWindow[0]->GetDlgHandle(),FALSE); - if (Core_IsStepping()) { // If the current PC is on a breakpoint, disabling stepping doesn't work without // explicitly skipping it @@ -1085,9 +1080,6 @@ namespace MainWindow break; case ID_EMULATION_RESET: - EnableWindow(disasmWindow[0]->GetDlgHandle(),FALSE); - EnableWindow(memoryWindow[0]->GetDlgHandle(),FALSE); - if (Core_IsStepping()) { // If the current PC is on a breakpoint, disabling stepping doesn't work without // explicitly skipping it @@ -1100,9 +1092,6 @@ namespace MainWindow case ID_EMULATION_CHEATS: g_Config.bEnableCheats = !g_Config.bEnableCheats; osm.ShowOnOff(g->T("Cheats"), g_Config.bEnableCheats); - - EnableWindow(disasmWindow[0]->GetDlgHandle(),FALSE); - EnableWindow(memoryWindow[0]->GetDlgHandle(),FALSE); if (Core_IsStepping()) { // If the current PC is on a breakpoint, disabling stepping doesn't work without @@ -1283,12 +1272,10 @@ namespace MainWindow break; case ID_DEBUG_DISASSEMBLY: - EnableWindow(disasmWindow[0]->GetDlgHandle(),TRUE); disasmWindow[0]->Show(true); break; case ID_DEBUG_MEMORYVIEW: - EnableWindow(memoryWindow[0]->GetDlgHandle(),TRUE); memoryWindow[0]->Show(true); break; @@ -1492,9 +1479,6 @@ namespace MainWindow case WM_USER+1: if (g_Config.bFullScreen) _ViewFullScreen(hWnd); - - EnableWindow (disasmWindow[0]->GetDlgHandle(),TRUE); - EnableWindow (memoryWindow[0]->GetDlgHandle(),TRUE); disasmWindow[0]->NotifyMapLoaded(); memoryWindow[0]->NotifyMapLoaded();