From 5bf22c15d05e8e21075926f4dfb5c5b15d171d3a Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Tue, 11 Apr 2023 15:47:50 +0300 Subject: [PATCH] sceKernelPrintf improvement, QOL adjustments --- Core/HLE/sceKernelMemory.cpp | 15 +++++++++++++++ Windows/Debugger/CtrlMemView.cpp | 3 ++- Windows/MainWindowMenu.cpp | 2 +- Windows/ppsspp.rc | 5 +++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index d4122b63b9..d2ca493844 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "Common/Thread/ParallelLoop.h" #include "Core/CoreTiming.h" @@ -1100,6 +1101,8 @@ static int sceKernelPrintf(const char *formatString) char tempStr[24]; char tempFormat[24] = {'%'}; std::string result, format = formatString; + std::stringstream stream; + float f_arg; // Each printf is a separate line already in the log, so don't double space. // This does mean we break up strings, unfortunately. @@ -1172,6 +1175,18 @@ static int sceKernelPrintf(const char *formatString) ++i; break; + case 'f': + static_assert(sizeof(float) == 4, "sizeof(float) != sizeof(u32)!"); + + // Maybe worth replacing with std::bit_cast when (if) we move to C++20 + std::memcpy(&f_arg, &PARAM(param++), sizeof(u32)); + stream << f_arg; + result += stream.str(); + + ++i; + stream.str(std::string()); // Reset the stream + break; + default: supported = false; break; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 16f0a12cc2..44d5387110 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -584,7 +584,8 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) { auto memLock = Memory::Lock(); std::ostringstream stream; stream << (Memory::IsValidAddress(curAddress_) ? Memory::Read_Float(curAddress_) : NAN); - W32Util::CopyTextToClipboard(wnd, stream.str().c_str()); + auto temp_string = stream.str(); + W32Util::CopyTextToClipboard(wnd, temp_string.c_str()); } break; diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index ce2c83dcf3..48fde122d8 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -776,7 +776,7 @@ namespace MainWindow { case ID_DEBUG_MEMORYBASE: { - W32Util::CopyTextToClipboard(hWnd, ConvertUTF8ToWString(StringFromFormat("%016llx", (uintptr_t)Memory::base))); + W32Util::CopyTextToClipboard(hWnd, ConvertUTF8ToWString(StringFromFormat("%016llx", (uint64_t)(uintptr_t)Memory::base))); break; } diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 25a720bacb..fcfa2278e2 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -555,7 +555,7 @@ BEGIN MENUITEM "GE Debugger...", ID_DEBUG_GEDEBUGGER MENUITEM "Extract File...", ID_DEBUG_EXTRACTFILE MENUITEM "Log Console", ID_DEBUG_LOG - MENUITEM "Copy PSP memory base pointer", ID_DEBUG_MEMORYBASE + MENUITEM "Copy PSP memory base address", ID_DEBUG_MEMORYBASE MENUITEM "Memory View...", ID_DEBUG_MEMORYVIEW END @@ -715,10 +715,11 @@ BEGIN MENUITEM "Go to Extent Begin", ID_MEMVIEW_EXTENTBEGIN MENUITEM "Go to Extent End", ID_MEMVIEW_EXTENTEND MENUITEM SEPARATOR + MENUITEM "Copy Float (32 bit)", ID_MEMVIEW_COPYFLOAT_32 + MENUITEM SEPARATOR 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 "Copy Float (32 bit)", ID_MEMVIEW_COPYFLOAT_32 MENUITEM "Dump...", ID_MEMVIEW_DUMP END POPUP "disasm"