Skip to content

Commit

Permalink
add signed HostRead/HostWrite functions to MMU
Browse files Browse the repository at this point in the history
  • Loading branch information
Felk committed Jul 18, 2018
1 parent b2d47fc commit 152d204
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
48 changes: 48 additions & 0 deletions Source/Core/Core/PowerPC/MMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ inline u32 bswap(u32 val)
{
return Common::swap32(val);
}
inline s32 bswap(s32 val)
{
return Common::swap32(val);
}
inline u64 bswap(u64 val)
{
return Common::swap64(val);
}
inline s64 bswap(s64 val)
{
return Common::swap64(val);
}
// =================

enum class XCheckTLBFlag
Expand Down Expand Up @@ -575,6 +583,26 @@ u64 HostRead_U64(const u32 address)
return ReadFromHardware<XCheckTLBFlag::NoException, u64>(address);
}

s8 HostRead_S8(const u32 address)
{
return static_cast<s8>(HostRead_U8(address));
}

s16 HostRead_S16(const u32 address)
{
return static_cast<s16>(HostRead_U16(address));
}

s32 HostRead_S32(const u32 address)
{
return static_cast<s32>(HostRead_U32(address));
}

s64 HostRead_S64(const u32 address)
{
return static_cast<s64>(HostRead_U64(address));
}

float HostRead_F32(const u32 address)
{
const u32 integral = HostRead_U32(address);
Expand Down Expand Up @@ -609,6 +637,26 @@ void HostWrite_U64(const u64 var, const u32 address)
WriteToHardware<XCheckTLBFlag::NoException, u64>(address, var);
}

void HostWrite_S8(const s8 var, const u32 address)
{
HostWrite_U8(static_cast<u8>(var), address);
}

void HostWrite_S16(const s16 var, const u32 address)
{
HostWrite_U16(static_cast<u16>(var), address);
}

void HostWrite_S32(const s32 var, const u32 address)
{
HostWrite_U32(static_cast<u32>(var), address);
}

void HostWrite_S64(const s64 var, const u32 address)
{
HostWrite_U64(static_cast<u64>(var), address);
}

void HostWrite_F32(const float var, const u32 address)
{
const u32 integral = Common::BitCast<u32>(var);
Expand Down
10 changes: 9 additions & 1 deletion Source/Core/Core/PowerPC/MMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ namespace PowerPC
{
// Routines for debugger UI, cheats, etc. to access emulated memory from the
// perspective of the CPU. Not for use by core emulation routines.
// Use "Host_" prefix.
// Use "Host" prefix.
u8 HostRead_U8(u32 address);
u16 HostRead_U16(u32 address);
u32 HostRead_U32(u32 address);
u64 HostRead_U64(u32 address);
s8 HostRead_S8(u32 address);
s16 HostRead_S16(u32 address);
s32 HostRead_S32(u32 address);
s64 HostRead_S64(u32 address);
float HostRead_F32(u32 address);
double HostRead_F64(u32 address);
u32 HostRead_Instruction(u32 address);
Expand All @@ -27,6 +31,10 @@ void HostWrite_U8(u8 var, u32 address);
void HostWrite_U16(u16 var, u32 address);
void HostWrite_U32(u32 var, u32 address);
void HostWrite_U64(u64 var, u32 address);
void HostWrite_S8(s8 var, u32 address);
void HostWrite_S16(s16 var, u32 address);
void HostWrite_S32(s32 var, u32 address);
void HostWrite_S64(s64 var, u32 address);
void HostWrite_F32(float var, u32 address);
void HostWrite_F64(double var, u32 address);

Expand Down

0 comments on commit 152d204

Please sign in to comment.