diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-07-17 22:31:22 +0200 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-07-29 15:11:00 +0200 |
| commit | 7f29f0398c4280edc5b096ef3fc6dc5bb75e7652 (patch) | |
| tree | e2f1f6e4f97ae03dcb81fa2a7837739d2e1a7935 /Source/Core | |
| parent | 163c97e24241dd8c67a1d44e33e2f9a67b91709b (diff) | |
MMU: Add a HostGetU16String() function for wide strings used by emulated software.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/PowerPC/MMU.cpp | 16 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/MMU.h | 2 |
2 files changed, 18 insertions, 0 deletions
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<char16_t>(res); + address += 2; + } while (size == 0 || s.length() < size); + return s; +} + std::optional<ReadResult<std::string>> 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 |
