From f52b88818649d56a1e49f967cbdd11333ca1dae6 Mon Sep 17 00:00:00 2001 From: dl471 Date: Sun, 21 Oct 2018 05:17:38 +0100 Subject: [PATCH 1/5] Make space for offsets (dirty implementation) --- Windows/Debugger/CtrlMemView.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index f1cc93e37..2ef1dc4c2 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -277,7 +277,14 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,oldBrush); // copy bitmap to the actual hdc - BitBlt(actualHdc,0,0,rect.right,rect.bottom,hdc,0,0,SRCCOPY); + if (writeOffsets) + { + BitBlt(actualHdc, 0, rowHeight*2, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); + } + else + { + BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); + } DeleteObject(hBM); DeleteDC(hdc); @@ -409,6 +416,10 @@ void CtrlMemView::redraw() GetClientRect(wnd, &rect); visibleRows = (rect.bottom/rowHeight); + if (writeOffsets) { + visibleRows -= 2; + } + InvalidateRect(wnd, NULL, FALSE); UpdateWindow(wnd); } @@ -517,6 +528,10 @@ void CtrlMemView::gotoPoint(int x, int y) int line = y/rowHeight; int lineAddress = windowStart+line*rowSize; + if (writeOffsets) { + lineAddress -= (rowSize * 2); + } + if (x >= asciiStart) { int col = (x-asciiStart) / (charWidth+2); From c11cfe37f862a9182bfb6a789342805be83edbde Mon Sep 17 00:00:00 2001 From: dl471 Date: Sun, 21 Oct 2018 06:07:31 +0100 Subject: [PATCH 2/5] Implement saner making space for offsets -Adjust the y coordinates of the rows as they are drawn -Adjust visible rows -Adjust clicks --- Windows/Debugger/CtrlMemView.cpp | 21 +++++++++------------ Windows/Debugger/CtrlMemView.h | 2 ++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 2ef1dc4c2..79c991280 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -203,6 +203,10 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) unsigned int address=windowStart + i*rowSize; int rowY = rowHeight*i; + + if (writeOffsets) + rowY += rowHeight * 2; // skip the first two rows to make space for the offets + sprintf(temp,"%08X",address); SetTextColor(hdc,0x600000); @@ -277,14 +281,7 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,oldBrush); // copy bitmap to the actual hdc - if (writeOffsets) - { - BitBlt(actualHdc, 0, rowHeight*2, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); - } - else - { - BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); - } + BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); DeleteObject(hBM); DeleteDC(hdc); @@ -417,7 +414,7 @@ void CtrlMemView::redraw() visibleRows = (rect.bottom/rowHeight); if (writeOffsets) { - visibleRows -= 2; + visibleRows -= 2; // visibleRows is calculated based on the size of the control, but 2 of the rows have already been used for the offsets and are not longer usable } InvalidateRect(wnd, NULL, FALSE); @@ -528,9 +525,9 @@ void CtrlMemView::gotoPoint(int x, int y) int line = y/rowHeight; int lineAddress = windowStart+line*rowSize; - if (writeOffsets) { - lineAddress -= (rowSize * 2); - } + if (writeOffsets) + lineAddress -= (rowSize * 2); // since each row has been written 2 rows down from where the window expected it to be written the target of the clicks must be adjusted + if (x >= asciiStart) { diff --git a/Windows/Debugger/CtrlMemView.h b/Windows/Debugger/CtrlMemView.h index 194832273..c0a0b3901 100644 --- a/Windows/Debugger/CtrlMemView.h +++ b/Windows/Debugger/CtrlMemView.h @@ -38,6 +38,8 @@ class CtrlMemView bool asciiSelected; int selectedNibble; + bool writeOffsets = true; + int visibleRows; std::string searchQuery; From b25adc7ba88d69e49c34f4be869902b834138e45 Mon Sep 17 00:00:00 2001 From: dl471 Date: Sun, 21 Oct 2018 07:37:35 +0100 Subject: [PATCH 3/5] Implement drawing of offset scale -Add function to draw offset -Add checkbox to allow toggling of offset writing -Set writeOffsets default value to Off -Ensure the drawing and user input is not affected by the offset --- Windows/Debugger/CtrlMemView.cpp | 56 ++++++++++++++++++++++--- Windows/Debugger/CtrlMemView.h | 16 ++++++- Windows/Debugger/Debugger_MemoryDlg.cpp | 11 +++++ Windows/ppsspp.rc | 1 + Windows/resource.h | 1 + 5 files changed, 78 insertions(+), 7 deletions(-) diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 79c991280..fa934e11c 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -28,6 +28,7 @@ CtrlMemView::CtrlMemView(HWND _wnd) rowHeight = g_Config.iFontHeight; charWidth = g_Config.iFontWidth; + offsetPositionY = offsetLine*rowHeight; font = CreateFont(rowHeight,charWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, @@ -93,6 +94,7 @@ LRESULT CALLBACK CtrlMemView::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM { CtrlMemView *ccp = CtrlMemView::getFrom(hwnd); static bool lmbDown=false,rmbDown=false; + switch(msg) { case WM_NCCREATE: @@ -196,6 +198,10 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,standardBrush); Rectangle(hdc,0,0,rect.right,rect.bottom); + if (writeOffsets) { + drawOffsetScale(hdc); + } + // draw one extra row that may be partially visible for (int i = 0; i < visibleRows+1; i++) { @@ -205,7 +211,7 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) int rowY = rowHeight*i; if (writeOffsets) - rowY += rowHeight * 2; // skip the first two rows to make space for the offets + rowY += rowHeight * offsetSpace; // skip the first X rows to make space for the offsets sprintf(temp,"%08X",address); @@ -281,7 +287,7 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,oldBrush); // copy bitmap to the actual hdc - BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); + BitBlt(actualHdc,0,0,rect.right,rect.bottom,hdc,0,0,SRCCOPY); DeleteObject(hBM); DeleteDC(hdc); @@ -414,7 +420,7 @@ void CtrlMemView::redraw() visibleRows = (rect.bottom/rowHeight); if (writeOffsets) { - visibleRows -= 2; // visibleRows is calculated based on the size of the control, but 2 of the rows have already been used for the offsets and are not longer usable + visibleRows -= offsetSpace; // visibleRows is calculated based on the size of the control, but X rows have already been used for the offsets and are no longer usable } InvalidateRect(wnd, NULL, FALSE); @@ -525,9 +531,16 @@ void CtrlMemView::gotoPoint(int x, int y) int line = y/rowHeight; int lineAddress = windowStart+line*rowSize; - if (writeOffsets) - lineAddress -= (rowSize * 2); // since each row has been written 2 rows down from where the window expected it to be written the target of the clicks must be adjusted - + if (writeOffsets) + { + if (line < offsetSpace) // ignore clicks on the offset space + { + updateStatusBarText(); + redraw(); + return; + } + lineAddress -= (rowSize * offsetSpace); // since each row has been written X rows down from where the window expected it to be written the target of the clicks must be adjusted + } if (x >= asciiStart) { @@ -720,3 +733,34 @@ void CtrlMemView::search(bool continueSearch) searching = false; redraw(); } + +void CtrlMemView::drawOffsetScale(HDC hdc) +{ + int currentX = addressStart; + + SetTextColor(hdc, 0x600000); + TextOutA(hdc, currentX, offsetPositionY, "Offset", 6); + + currentX = addressStart + ((8 + 1)*charWidth); // the start offset, the size of the hex addresses and one space + + char temp[64]; + + for (int i = 0; i < 16; i++) + { + sprintf(temp, "%02X", i); + TextOutA(hdc, currentX, offsetPositionY, temp, 2); + currentX += 3 * charWidth; // hex and space + } + +} + +void CtrlMemView::toggleOffsetScale(OffsetToggles toggle) +{ + if (toggle == On) + writeOffsets = true; + else if (toggle == Off) + writeOffsets = false; + + updateStatusBarText(); + redraw(); +} diff --git a/Windows/Debugger/CtrlMemView.h b/Windows/Debugger/CtrlMemView.h index c0a0b3901..b4c3129ad 100644 --- a/Windows/Debugger/CtrlMemView.h +++ b/Windows/Debugger/CtrlMemView.h @@ -19,6 +19,16 @@ #include "../../Core/Debugger/DebugInterface.h" +enum OffsetSpacing { + offsetSpace = 3, + offsetLine = 1, +}; + +enum OffsetToggles { + On, + Off, +}; + class CtrlMemView { HWND wnd; @@ -30,6 +40,7 @@ class CtrlMemView unsigned int windowStart; int rowHeight; int rowSize; + int offsetPositionY; int addressStart; int charWidth; @@ -38,7 +49,7 @@ class CtrlMemView bool asciiSelected; int selectedNibble; - bool writeOffsets = true; + bool writeOffsets = false; int visibleRows; @@ -81,4 +92,7 @@ public: void gotoAddr(unsigned int addr); void scrollWindow(int lines); void scrollCursor(int bytes); + + void drawOffsetScale(HDC hdc); + void toggleOffsetScale(OffsetToggles toggle); }; \ No newline at end of file diff --git a/Windows/Debugger/Debugger_MemoryDlg.cpp b/Windows/Debugger/Debugger_MemoryDlg.cpp index 1aa6297c3..a60f3ebfe 100644 --- a/Windows/Debugger/Debugger_MemoryDlg.cpp +++ b/Windows/Debugger/Debugger_MemoryDlg.cpp @@ -154,6 +154,17 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) break; }; break; + case IDC_SHOWOFFSETS: + switch (HIWORD(wParam)) + { + case BN_CLICKED: + if (SendDlgItemMessage(m_hDlg, IDC_SHOWOFFSETS, BM_GETCHECK, 0, 0)) + mv->toggleOffsetScale(On); + else + mv->toggleOffsetScale(Off); + break; + } + break; } } break; diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index e461def07..3b3486261 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -304,6 +304,7 @@ BEGIN CONTROL "Normal",IDC_MODENORMAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,248,9,40,9 CONTROL "Symbols",IDC_MODESYMBOLS,"Button",BS_AUTORADIOBUTTON,291,9,43,8 GROUPBOX "Mode",IDC_STATIC,241,0,104,22 + AUTOCHECKBOX "Show Offsets",IDC_SHOWOFFSETS,365,9,55,8 COMBOBOX IDC_REGIONS,87,5,88,139,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END diff --git a/Windows/resource.h b/Windows/resource.h index 665db6d8f..0c7873911 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -164,6 +164,7 @@ #define IDC_GEDBG_FORCEOPAQUE 1197 #define IDC_GEDBG_SHOWCLUT 1198 #define IDC_BREAKPOINT_LOG_FORMAT 1199 +#define IDC_SHOWOFFSETS 1200 #define ID_SHADERS_BASE 5000 From 7f3aaaa0f7a41e4bc66f7037a04f58466adf917a Mon Sep 17 00:00:00 2001 From: dl471 Date: Mon, 22 Oct 2018 03:17:45 +0100 Subject: [PATCH 4/5] Readability improvements -Change variable names related to offsets for consistency -Add a few comments --- Windows/Debugger/CtrlMemView.cpp | 14 +++++++------- Windows/Debugger/CtrlMemView.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index fa934e11c..ff28e1b99 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -198,9 +198,9 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,standardBrush); Rectangle(hdc,0,0,rect.right,rect.bottom); - if (writeOffsets) { + if (displayOffsetScale) drawOffsetScale(hdc); - } + // draw one extra row that may be partially visible for (int i = 0; i < visibleRows+1; i++) @@ -210,7 +210,7 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) unsigned int address=windowStart + i*rowSize; int rowY = rowHeight*i; - if (writeOffsets) + if (displayOffsetScale) rowY += rowHeight * offsetSpace; // skip the first X rows to make space for the offsets @@ -419,7 +419,7 @@ void CtrlMemView::redraw() GetClientRect(wnd, &rect); visibleRows = (rect.bottom/rowHeight); - if (writeOffsets) { + if (displayOffsetScale) { visibleRows -= offsetSpace; // visibleRows is calculated based on the size of the control, but X rows have already been used for the offsets and are no longer usable } @@ -531,7 +531,7 @@ void CtrlMemView::gotoPoint(int x, int y) int line = y/rowHeight; int lineAddress = windowStart+line*rowSize; - if (writeOffsets) + if (displayOffsetScale) { if (line < offsetSpace) // ignore clicks on the offset space { @@ -757,9 +757,9 @@ void CtrlMemView::drawOffsetScale(HDC hdc) void CtrlMemView::toggleOffsetScale(OffsetToggles toggle) { if (toggle == On) - writeOffsets = true; + displayOffsetScale = true; else if (toggle == Off) - writeOffsets = false; + displayOffsetScale = false; updateStatusBarText(); redraw(); diff --git a/Windows/Debugger/CtrlMemView.h b/Windows/Debugger/CtrlMemView.h index b4c3129ad..d5f8079d7 100644 --- a/Windows/Debugger/CtrlMemView.h +++ b/Windows/Debugger/CtrlMemView.h @@ -20,8 +20,8 @@ #include "../../Core/Debugger/DebugInterface.h" enum OffsetSpacing { - offsetSpace = 3, - offsetLine = 1, + offsetSpace = 3, // the number of blank lines that should be left to make space for the offsets + offsetLine = 1, // the line on which the offsets should be written }; enum OffsetToggles { @@ -49,7 +49,7 @@ class CtrlMemView bool asciiSelected; int selectedNibble; - bool writeOffsets = false; + bool displayOffsetScale = false; int visibleRows; From f68fed7da57069eb3ab72b0565d53769a963a365 Mon Sep 17 00:00:00 2001 From: dl471 Date: Tue, 23 Oct 2018 23:36:08 +0100 Subject: [PATCH 5/5] Fix whitespace --- Windows/ppsspp.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 3b3486261..6fdcdaf9e 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -304,7 +304,7 @@ BEGIN CONTROL "Normal",IDC_MODENORMAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,248,9,40,9 CONTROL "Symbols",IDC_MODESYMBOLS,"Button",BS_AUTORADIOBUTTON,291,9,43,8 GROUPBOX "Mode",IDC_STATIC,241,0,104,22 - AUTOCHECKBOX "Show Offsets",IDC_SHOWOFFSETS,365,9,55,8 + AUTOCHECKBOX "Show Offsets",IDC_SHOWOFFSETS,365,9,55,8 COMBOBOX IDC_REGIONS,87,5,88,139,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END