From 21bdc2b4c95030c2ce7b8608e2772b890da1b000 Mon Sep 17 00:00:00 2001 From: xebra Date: Thu, 6 Dec 2018 18:16:54 +0900 Subject: [PATCH 1/2] GE Debugger: Add step count dialog. --- Windows/GEDebugger/GEDebugger.cpp | 59 ++++++++++++++++++++++--------- Windows/GEDebugger/GEDebugger.h | 11 ++++++ Windows/ppsspp.rc | 12 +++++++ Windows/resource.h | 5 +++ 4 files changed, 70 insertions(+), 17 deletions(-) diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 57f122694e..5bde53fa6f 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -57,13 +57,52 @@ enum PrimaryDisplayType { PRIMARY_STENCILBUF, }; +StepCountDlg::StepCountDlg(HINSTANCE _hInstance, HWND _hParent) : Dialog((LPCSTR)IDD_GEDBG_STEPCOUNT, _hInstance, _hParent) { + for (int i = 0; i < 4; i++) // Add items 1, 10, 100, 1000 + SendMessageA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), CB_ADDSTRING, 0, (LPARAM)std::to_string((int)pow(10, i)).c_str()); + SetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), "1"); +} + +void StepCountDlg::Jump(bool minus, bool relative) { + char str[5]; + int count; + GetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), str, 5); + if (TryParse(str, &count)) { + SetBreakNext(BreakNext::COUNT); + SetBreakCount(count * (minus ? -1 : 1), relative); + } +}; + +BOOL StepCountDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { + switch (message) { + case WM_CLOSE: + Show(false); + return TRUE; + case WM_COMMAND: + switch (wParam) { + case IDC_GEDBG_STEPCOUNT_DEC: + Jump(true, true); + return TRUE; + case IDC_GEDBG_STEPCOUNT_INC: + Jump(false, true); + return TRUE; + case IDC_GEDBG_STEPCOUNT_JUMP: + Jump(false, false); + return TRUE; + } + default: + return FALSE; + } +} + void CGEDebugger::Init() { SimpleGLWindow::RegisterClass(); CtrlDisplayListView::registerClass(); } CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent) - : Dialog((LPCSTR)IDD_GEDEBUGGER, _hInstance, _hParent) { + : Dialog((LPCSTR)IDD_GEDEBUGGER, _hInstance, _hParent) + , stepCountDlg(_hInstance, m_hDlg) { // minimum size = a little more than the default RECT windowRect; GetWindowRect(m_hDlg, &windowRect); @@ -658,6 +697,7 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { case WM_CLOSE: GPUDebug::SetActive(false); + stepCountDlg.Show(false); Show(false); return TRUE; @@ -726,22 +766,7 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { break; case IDC_GEDBG_STEPCOUNT: - { - std::string value; - int count; - if (InputBox_GetString(GetModuleHandle(NULL), m_hDlg, L"Prim count", "", value)) { - if (value.length() > 1 && value[0] == '+' && TryParse(value.substr(1), &count)) { - SetBreakNext(BreakNext::COUNT); - SetBreakCount(count, true); - } else if (value.length() > 1 && value[0] == '-' && TryParse(value.substr(1), &count)) { - SetBreakNext(BreakNext::COUNT); - SetBreakCount(-count, true); - } else if (TryParse(value, &count)) { - SetBreakNext(BreakNext::COUNT); - SetBreakCount(count); - } - } - } + stepCountDlg.Show(true); break; case IDC_GEDBG_BREAKTEX: diff --git a/Windows/GEDebugger/GEDebugger.h b/Windows/GEDebugger/GEDebugger.h index 79db21dc1b..a11de7267e 100644 --- a/Windows/GEDebugger/GEDebugger.h +++ b/Windows/GEDebugger/GEDebugger.h @@ -44,6 +44,15 @@ class TabMatrices; class TabStateWatch; struct GPUgstate; +class StepCountDlg : public Dialog { +public: + StepCountDlg(HINSTANCE _hInstance, HWND _hParent); +protected: + BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); +private: + void Jump(bool minus, bool relative); +}; + class CGEDebugger : public Dialog { public: CGEDebugger(HINSTANCE _hInstance, HWND _hParent); @@ -100,4 +109,6 @@ private: int previewsEnabled_ = 3; int minWidth_; int minHeight_; + + StepCountDlg stepCountDlg; }; diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 195f92eb05..144a50db06 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -234,6 +234,18 @@ BEGIN PUSHBUTTON "Break on Target...",IDC_GEDBG_BREAKTARGET,394,211,100,14 END +IDD_GEDBG_STEPCOUNT DIALOGEX 0, 0, 124, 18 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_TOOLWINDOW +CAPTION "Step Count" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + COMBOBOX IDC_GEDBG_STEPCOUNT_COMBO,6,3,50,13,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP | ES_NUMBER + PUSHBUTTON "-",IDC_GEDBG_STEPCOUNT_DEC,58,2,14,14 + PUSHBUTTON "+",IDC_GEDBG_STEPCOUNT_INC,73,2,14,14 + PUSHBUTTON "Jump",IDC_GEDBG_STEPCOUNT_JUMP,88,2,30,14 +END + IDD_GEDBG_TAB_VALUES DIALOGEX 0, 0, 316, 183 STYLE DS_SETFONT | WS_CHILD | DS_CONTROL diff --git a/Windows/resource.h b/Windows/resource.h index ee64c5759f..1f701e442e 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -81,6 +81,7 @@ #define IDD_DUMPMEMORY 253 #define IDD_GEDBG_TAB_VERTICES 254 #define IDD_GEDBG_TAB_MATRICES 255 +#define IDD_GEDBG_STEPCOUNT 256 #define IDC_STOPGO 1001 #define IDC_ADDRESS 1002 @@ -364,6 +365,10 @@ #define ID_OPTIONS_SCREENFILTER_MENU 40197 #define ID_OPTIONS_TEXTURESCALING_MENU 40198 #define IDC_GEDBG_STEPCOUNT 40199 +#define IDC_GEDBG_STEPCOUNT_DEC 40200 +#define IDC_GEDBG_STEPCOUNT_INC 40201 +#define IDC_GEDBG_STEPCOUNT_JUMP 40202 +#define IDC_GEDBG_STEPCOUNT_COMBO 40203 // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 From f64156c8e757ff9968418e64b14ed1cc5438bb51 Mon Sep 17 00:00:00 2001 From: xebra Date: Tue, 18 Dec 2018 00:27:02 +0900 Subject: [PATCH 2/2] GE Debugger: Improve step count dialog. --- Windows/GEDebugger/GEDebugger.cpp | 50 +++++++++++++++++++++++-------- Windows/GEDebugger/GEDebugger.h | 3 +- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 5bde53fa6f..9f20c87d36 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -58,22 +58,34 @@ enum PrimaryDisplayType { }; StepCountDlg::StepCountDlg(HINSTANCE _hInstance, HWND _hParent) : Dialog((LPCSTR)IDD_GEDBG_STEPCOUNT, _hInstance, _hParent) { + DialogManager::AddDlg(this); + for (int i = 0; i < 4; i++) // Add items 1, 10, 100, 1000 SendMessageA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), CB_ADDSTRING, 0, (LPARAM)std::to_string((int)pow(10, i)).c_str()); SetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), "1"); } -void StepCountDlg::Jump(bool minus, bool relative) { - char str[5]; - int count; - GetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), str, 5); - if (TryParse(str, &count)) { - SetBreakNext(BreakNext::COUNT); - SetBreakCount(count * (minus ? -1 : 1), relative); - } +StepCountDlg::~StepCountDlg() { + DialogManager::RemoveDlg(this); +} + +void StepCountDlg::Jump(int count, bool relative) { + if (relative && count == 0) + return; + SetBreakNext(BreakNext::COUNT); + SetBreakCount(count, relative); }; BOOL StepCountDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { + int count; + bool relative; + auto GetValue = [&]() { + char str[7]; // +/-99999\0 + GetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), str, 7); + relative = str[0] == '+' || str[0] == '-'; + return TryParse(str, &count); + }; + switch (message) { case WM_CLOSE: Show(false); @@ -81,18 +93,30 @@ BOOL StepCountDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { case WM_COMMAND: switch (wParam) { case IDC_GEDBG_STEPCOUNT_DEC: - Jump(true, true); + if (GetValue()) + Jump(-abs(count), true); return TRUE; case IDC_GEDBG_STEPCOUNT_INC: - Jump(false, true); + if (GetValue()) + Jump(abs(count), true); return TRUE; case IDC_GEDBG_STEPCOUNT_JUMP: - Jump(false, false); + if (GetValue()) + Jump(abs(count), false); + return TRUE; + case IDOK: + if (GetValue()) + Jump(count, relative); + Show(false); + return TRUE; + case IDCANCEL: + SetFocus(m_hParent); + Show(false); return TRUE; } - default: - return FALSE; + break; } + return FALSE; } void CGEDebugger::Init() { diff --git a/Windows/GEDebugger/GEDebugger.h b/Windows/GEDebugger/GEDebugger.h index a11de7267e..271d20569e 100644 --- a/Windows/GEDebugger/GEDebugger.h +++ b/Windows/GEDebugger/GEDebugger.h @@ -47,10 +47,11 @@ struct GPUgstate; class StepCountDlg : public Dialog { public: StepCountDlg(HINSTANCE _hInstance, HWND _hParent); + ~StepCountDlg(); protected: BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); private: - void Jump(bool minus, bool relative); + void Jump(int value, bool relative); }; class CGEDebugger : public Dialog {