sceKernelPrintf improvement, QOL adjustments

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

No files matched your search

+15
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;