sceKernelPrintf improvement, QOL adjustments

This commit is contained in:
Nemoumbra 2023-04-11 15:47:50 +03:00
parent cf1d8ec4bc
commit 5bf22c15d0
4 changed files with 21 additions and 4 deletions

View File

@ -19,6 +19,7 @@
#include <string>
#include <vector>
#include <map>
#include <sstream>
#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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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"