From c85a7623cc29c2f09ac97243decf33dd1d856934 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Thu, 7 Nov 2013 19:49:46 +0100 Subject: [PATCH] Allow copying 16 and 32 bit values from the memory view --- Windows/Debugger/CtrlMemView.cpp | 34 ++++++++++++++++++++++++++++---- Windows/ppsspp.rc | 4 +++- Windows/resource.h | 6 ++++-- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 1554a9cf0b..de987bdb51 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -416,7 +416,15 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) //popup menu? POINT pt; GetCursorPos(&pt); - switch (TrackPopupMenuEx(GetSubMenu(g_hPopupMenus,0),TPM_RIGHTBUTTON|TPM_RETURNCMD,pt.x,pt.y,wnd,0)) + + bool enable16 = !asciiSelected && (curAddress % 2) == 0; + bool enable32 = !asciiSelected && (curAddress % 4) == 0; + + HMENU menu = GetSubMenu(g_hPopupMenus,0); + EnableMenuItem(menu,ID_MEMVIEW_COPYVALUE_16,enable16 ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(menu,ID_MEMVIEW_COPYVALUE_32,enable32 ? MF_ENABLED : MF_GRAYED); + + switch (TrackPopupMenuEx(menu,TPM_RIGHTBUTTON|TPM_RETURNCMD,pt.x,pt.y,wnd,0)) { case ID_MEMVIEW_DUMP: @@ -432,22 +440,40 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) break; } - case ID_MEMVIEW_COPYVALUE: + case ID_MEMVIEW_COPYVALUE_8: { char temp[24]; // it's admittedly not really useful like this if (asciiSelected) { - unsigned char c = Memory::IsValidAddress(curAddress) ? Memory::ReadUnchecked_U8(curAddress) : '.'; + unsigned char c = Memory::IsValidAddress(curAddress) ? Memory::Read_U8(curAddress) : '.'; if (c < 32|| c >= 128) c = '.'; sprintf(temp,"%c",c); } else { - sprintf(temp,"%02X",Memory::IsValidAddress(curAddress) ? Memory::ReadUnchecked_U8(curAddress) : 0xFF); + sprintf(temp,"%02X",Memory::IsValidAddress(curAddress) ? Memory::Read_U8(curAddress) : 0xFF); } W32Util::CopyTextToClipboard(wnd,temp); } break; + + case ID_MEMVIEW_COPYVALUE_16: + { + char temp[24]; + + sprintf(temp,"%04X",Memory::IsValidAddress(curAddress) ? Memory::Read_U16(curAddress) : 0xFFFF); + W32Util::CopyTextToClipboard(wnd,temp); + } + break; + + case ID_MEMVIEW_COPYVALUE_32: + { + char temp[24]; + + sprintf(temp,"%08X",Memory::IsValidAddress(curAddress) ? Memory::Read_U32(curAddress) : 0xFFFFFFFF); + W32Util::CopyTextToClipboard(wnd,temp); + } + break; case ID_MEMVIEW_COPYADDRESS: { diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 7dedc122e0..98f586b596 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -503,7 +503,9 @@ BEGIN MENUITEM "Go to in Disasm", ID_MEMVIEW_GOTOINDISASM MENUITEM "Copy address", ID_MEMVIEW_COPYADDRESS MENUITEM SEPARATOR - MENUITEM "Copy Value", ID_MEMVIEW_COPYVALUE + MENUITEM "Copy Value (8 bit)", ID_MEMVIEW_COPYVALUE_8 + MENUITEM "Copy Value (16 bit)", ID_MEMVIEW_COPYVALUE_16 + MENUITEM "Copy Value (32 bit)", ID_MEMVIEW_COPYVALUE_32 MENUITEM "Dump...", ID_MEMVIEW_DUMP END POPUP "disasm" diff --git a/Windows/resource.h b/Windows/resource.h index e39c754760..cce8701c05 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -166,7 +166,7 @@ #define ID_DISASM_ADDHLE 40002 #define ID_FUNCLIST_KILLFUNCTION 40003 #define ID_DISASM_RUNTOHERE 40004 -#define ID_MEMVIEW_COPYVALUE 40005 +#define ID_MEMVIEW_COPYVALUE_8 40005 #define ID_DISASM_COPYINSTRUCTIONDISASM 40006 #define ID_DISASM_COPYINSTRUCTIONHEX 40007 #define ID_EMULATION_SPEEDLIMIT 40008 @@ -297,6 +297,8 @@ #define ID_DISASM_ADDFUNCTION 40139 #define ID_DISASM_REMOVEFUNCTION 40140 #define ID_OPTIONS_LANGUAGE 40141 +#define ID_MEMVIEW_COPYVALUE_16 40142 +#define ID_MEMVIEW_COPYVALUE_32 40143 // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 @@ -309,7 +311,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 254 -#define _APS_NEXT_COMMAND_VALUE 40139 +#define _APS_NEXT_COMMAND_VALUE 40144 #define _APS_NEXT_CONTROL_VALUE 1193 #define _APS_NEXT_SYMED_VALUE 101 #endif