diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 30f7709d56..a42fe32c32 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -87,6 +87,9 @@ LRESULT CALLBACK FuncListProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa return (LRESULT)CallWindowProc((WNDPROC)DefFuncListProc,hDlg,message,wParam,lParam); } +static constexpr UINT_PTR IDT_UPDATE = 0xC0DE0042; +static constexpr UINT UPDATE_DELAY = 1000 / 60; + CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_DISASM, _hInstance, _hParent) { cpu = _cpu; lastTicks = PSP_IsInited() ? CoreTiming::GetTicks() : 0; @@ -236,10 +239,8 @@ void CDisasm::stepInto() if (vfpudlg) vfpudlg->Update(); - CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW))->redraw(); threadList->reloadThreads(); stackTraceView->loadStackTrace(); - updateThreadLabel(false); } void CDisasm::stepOver() @@ -678,6 +679,14 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) g_activeWindow = WINDOW_CPUDEBUGGER; } break; + + case WM_TIMER: + if (wParam == IDT_UPDATE) { + ProcessUpdateDialog(); + updateDialogScheduled_ = false; + KillTimer(GetDlgHandle(), wParam); + } + break; } return FALSE; } @@ -786,9 +795,7 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) threadList->reloadThreads(); stackTraceView->loadStackTrace(); moduleList->loadModules(); - 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); @@ -802,27 +809,13 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) ptr->gotoPC(); ptr->scanFunctions(); - CtrlMemView *mem = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); - mem->redraw(); - - // update the callstack - //CDisam::blah blah - UpdateDialog(); } else { - updateThreadLabel(true); - if (ingame) - { - SetDlgItemText(m_hDlg, IDC_STOPGO, L"Break"); 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); @@ -832,6 +825,8 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) CtrlRegisterList *reglist = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); reglist->redraw(); } + + UpdateDialog(); } void CDisasm::Show(bool bShow, bool includeToTop) { @@ -863,8 +858,29 @@ void CDisasm::Goto(u32 addr) ptr->redraw(); } -void CDisasm::UpdateDialog(bool _bComplete) -{ +void CDisasm::UpdateDialog() { + if (!updateDialogScheduled_) { + SetTimer(GetDlgHandle(), IDT_UPDATE, UPDATE_DELAY, nullptr); + updateDialogScheduled_ = true; + } + + // Since these update on a delay, it's okay to do them immediately. + CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); + ptr->redraw(); + CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg, IDC_REGLIST)); + rl->redraw(); + + // Repaint windows at the bottom. only the memory view needs to be forced to redraw. + // All others are updated manually + CtrlMemView *memview = CtrlMemView::getFrom(GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW)); + memview->redraw(); + + // Update memory window too. + if (memoryWindow) + memoryWindow->Update(); +} + +void CDisasm::ProcessUpdateDialog() { /* HWND gotoInt = GetDlgItem(m_hDlg, IDC_GOTOINT); ComboBox_ResetContent(gotoInt); @@ -878,23 +894,20 @@ void CDisasm::UpdateDialog(bool _bComplete) ComboBox_SetItemData(gotoInt,0,0xFFFFFFFF); ComboBox_SetCurSel(gotoInt,0); */ - CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); - ptr->redraw(); - CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); - rl->redraw(); + // Update Debug Counter - wchar_t tempTicks[24]; if (PSP_IsInited()) { + wchar_t tempTicks[24]; _snwprintf(tempTicks, 24, L"%lld", CoreTiming::GetTicks() - lastTicks); SetDlgItemText(m_hDlg, IDC_DEBUG_COUNT, tempTicks); } - // Update memory window - if (memoryWindow) - memoryWindow->Update(); + bool ingame = (GetUIState() == UISTATE_INGAME || GetUIState() == UISTATE_EXCEPTION) && PSP_IsInited(); + if (Core_IsStepping() || !ingame) { + SetDlgItemText(m_hDlg, IDC_STOPGO, L"Go"); + } else { + SetDlgItemText(m_hDlg, IDC_STOPGO, L"Break"); + } - // repaint windows at the bottom. only the memory view needs to be forced to - // redraw. all others are updated manually - CtrlMemView *memview = CtrlMemView::getFrom(GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW)); - memview->redraw(); + updateThreadLabel(!ingame || !Core_IsStepping()); } diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index 9b14cbc7ba..d66a1757bd 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -52,14 +52,18 @@ public: void Show(bool bShow, bool includeToTop = true) override; void Update() override { - UpdateDialog(true); + UpdateDialog(); SetDebugMode(Core_IsStepping(), false); breakpointList->reloadBreakpoints(); }; - void UpdateDialog(bool _bComplete = false); - // SetDebugMode + void UpdateDialog(); void SetDebugMode(bool _bDebug, bool switchPC); void Goto(u32 addr); void NotifyMapLoaded(); + +private: + void ProcessUpdateDialog(); + + bool updateDialogScheduled_ = false; }; diff --git a/Windows/W32Util/Misc.cpp b/Windows/W32Util/Misc.cpp index 100d1aafba..e3c86fd671 100644 --- a/Windows/W32Util/Misc.cpp +++ b/Windows/W32Util/Misc.cpp @@ -255,8 +255,10 @@ void GenericListControl::HandleNotify(LPARAM lParam) } void GenericListControl::Update() { - SetTimer(handle, IDT_UPDATE, UPDATE_DELAY, nullptr); - updateScheduled_ = true; + if (!updateScheduled_) { + SetTimer(handle, IDT_UPDATE, UPDATE_DELAY, nullptr); + updateScheduled_ = true; + } } void GenericListControl::ProcessUpdate() {