From 524fd297163f5c5e2d08170c7084902239da35d0 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Wed, 2 Oct 2013 08:51:21 +0200 Subject: [PATCH] Add range selection --- Windows/GEDebugger/CtrlDisplayListView.cpp | 40 +++++++++++++++++----- Windows/GEDebugger/CtrlDisplayListView.h | 7 ++++ Windows/ppsspp.rc | 2 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Windows/GEDebugger/CtrlDisplayListView.cpp b/Windows/GEDebugger/CtrlDisplayListView.cpp index ac25a2b2f4..1a15448d7d 100644 --- a/Windows/GEDebugger/CtrlDisplayListView.cpp +++ b/Windows/GEDebugger/CtrlDisplayListView.cpp @@ -177,8 +177,8 @@ void CtrlDisplayListView::onPaint(WPARAM wParam, LPARAM lParam) // draw background COLORREF backgroundColor = stall ? 0xCCCCFF : 0xFFFFFF; COLORREF textColor = 0x000000; - - if (address == curAddress) + + if (address >= selectRangeStart && address < selectRangeEnd) { if (hasFocus) { @@ -259,16 +259,22 @@ void CtrlDisplayListView::onMouseDown(WPARAM wParam, LPARAM lParam, int button) int line = y/rowHeight; u32 newAddress = windowStart + line*instructionSize; - + + bool extend = GetAsyncKeyState(VK_SHIFT) != 0; if (button == 1) { if (newAddress == curAddress && hasFocus) { toggleBreakpoint(); } + } else if (button == 2) + { + // Maintain the current selection if right clicking into it. + if (newAddress >= selectRangeStart && newAddress < selectRangeEnd) + extend = true; } - setCurAddress(newAddress); + setCurAddress(newAddress,extend); SetFocus(wnd); redraw(); @@ -293,9 +299,19 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) redraw(); break; case ID_DISASM_COPYINSTRUCTIONDISASM: - { - GPUDebugOp op = gpuDebug->DissassembleOp(curAddress); - W32Util::CopyTextToClipboard(wnd, op.desc.c_str()); + { + int space = 256 * (selectRangeEnd - selectRangeStart) / instructionSize; + char *temp = new char[space]; + + char *p = temp, *end = temp + space; + for (u32 pos = selectRangeStart; pos < selectRangeEnd; pos += instructionSize) + { + GPUDebugOp op = gpuDebug->DissassembleOp(pos); + p += snprintf(p, end - p, "%s\r\n", op.desc.c_str()); + } + + W32Util::CopyTextToClipboard(wnd, temp); + delete [] temp; } break; case ID_DISASM_COPYADDRESS: @@ -321,9 +337,15 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) break; case ID_DISASM_COPYINSTRUCTIONHEX: { - char temp[16]; - sprintf(temp,"%08X",Memory::ReadUnchecked_U32(curAddress)); + int space = 24 * (selectRangeEnd - selectRangeStart) / instructionSize; + char *temp = new char[space]; + + char *p = temp, *end = temp + space; + for (u32 pos = selectRangeStart; pos < selectRangeEnd; pos += instructionSize) + p += snprintf(p, end - p, "%08X\r\n", Memory::ReadUnchecked_U32(pos)); + W32Util::CopyTextToClipboard(wnd, temp); + delete [] temp; } break; case ID_DISASM_RUNTOHERE: diff --git a/Windows/GEDebugger/CtrlDisplayListView.h b/Windows/GEDebugger/CtrlDisplayListView.h index 1e9c5fa865..84364f867f 100644 --- a/Windows/GEDebugger/CtrlDisplayListView.h +++ b/Windows/GEDebugger/CtrlDisplayListView.h @@ -3,6 +3,7 @@ #include "Common/CommonWindows.h" #include "Globals.h" #include "GPU/Common/GPUDebugInterface.h" +#include class CtrlDisplayListView { @@ -15,6 +16,9 @@ class CtrlDisplayListView HFONT boldfont; u32 windowStart; u32 curAddress; + u32 selectRangeStart; + u32 selectRangeEnd; + int visibleRows; int charWidth; int rowHeight; @@ -71,7 +75,10 @@ public: void setCurAddress(u32 newAddress, bool extend = false) { + u32 after = newAddress + instructionSize; curAddress = newAddress; + selectRangeStart = extend ? std::min(selectRangeStart, newAddress) : newAddress; + selectRangeEnd = extend ? std::max(selectRangeEnd, after) : after; } void scrollAddressIntoView(); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index a8eaf24643..6dfd2910b0 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -558,7 +558,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Run to Cursor", ID_DISASM_RUNTOHERE MENUITEM "Jump to Cursor", ID_DISASM_SETPCTOHERE - MENUITEM "Set Stall" IDC_DEBUG_LIST_SETSTALL + MENUITEM "Set Stall" IDC_DEBUG_LIST_SETSTALL MENUITEM "Toggle Breakpoint", ID_DISASM_TOGGLEBREAKPOINT MENUITEM SEPARATOR MENUITEM "Go to in Memory View", ID_DISASM_GOTOINMEMORYVIEW