mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
MMU: Add a HostGetU16String() function for wide strings used by emulated software.
This commit is contained in:
parent
163c97e242
commit
7f29f0398c
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user