diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index a1597b96a5..e682589953 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -867,6 +867,22 @@ std::string MMU::HostGetString(const Core::CPUThreadGuard& guard, u32 address, s return s; } +std::u16string MMU::HostGetU16String(const Core::CPUThreadGuard& guard, u32 address, size_t size) +{ + std::u16string s; + do + { + if (!HostIsRAMAddress(guard, address) || !HostIsRAMAddress(guard, address + 1)) + break; + const u16 res = HostRead_U16(guard, address); + if (!res) + break; + s += static_cast(res); + address += 2; + } while (size == 0 || s.length() < size); + return s; +} + std::optional> MMU::HostTryReadString(const Core::CPUThreadGuard& guard, u32 address, size_t size, RequestedAddressSpace space) diff --git a/Source/Core/Core/PowerPC/MMU.h b/Source/Core/Core/PowerPC/MMU.h index 2ee0173eb5..63e037c679 100644 --- a/Source/Core/Core/PowerPC/MMU.h +++ b/Source/Core/Core/PowerPC/MMU.h @@ -132,6 +132,8 @@ public: static double HostRead_F64(const Core::CPUThreadGuard& guard, u32 address); static u32 HostRead_Instruction(const Core::CPUThreadGuard& guard, u32 address); static std::string HostGetString(const Core::CPUThreadGuard& guard, u32 address, size_t size = 0); + static std::u16string HostGetU16String(const Core::CPUThreadGuard& guard, u32 address, + size_t size = 0); // Try to read a value from emulated memory at the given address in the given memory space. // If the read succeeds, the returned value will be present and the ReadResult contains the read