Merge pull request #3171 from lioncash/ucode

UCodes: Minor cleanup
This commit is contained in:
flacs 2015-10-16 05:03:12 +02:00
commit 28cb62dc7f
1 changed files with 15 additions and 10 deletions

View File

@ -4,10 +4,10 @@
#pragma once #pragma once
#include <cstring>
#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Thread.h" #include "Common/Thread.h"
#include "Core/HW/Memmap.h" #include "Core/HW/Memmap.h"
#include "Core/HW/DSPHLE/DSPHLE.h" #include "Core/HW/DSPHLE/DSPHLE.h"
@ -17,12 +17,9 @@
class CMailHandler; class CMailHandler;
inline bool ExramRead(u32 address) constexpr bool ExramRead(u32 address)
{ {
if (address & 0x10000000) return (address & 0x10000000) != 0;
return true;
else
return false;
} }
inline u8 HLEMemory_Read_U8(u32 address) inline u8 HLEMemory_Read_U8(u32 address)
@ -35,18 +32,26 @@ inline u8 HLEMemory_Read_U8(u32 address)
inline u16 HLEMemory_Read_U16(u32 address) inline u16 HLEMemory_Read_U16(u32 address)
{ {
u16 value;
if (ExramRead(address)) if (ExramRead(address))
return Common::swap16(*(u16*)&Memory::m_pEXRAM[address & Memory::EXRAM_MASK]); std::memcpy(&value, &Memory::m_pEXRAM[address & Memory::EXRAM_MASK], sizeof(u16));
else else
return Common::swap16(*(u16*)&Memory::m_pRAM[address & Memory::RAM_MASK]); std::memcpy(&value, &Memory::m_pRAM[address & Memory::RAM_MASK], sizeof(u16));
return Common::swap16(value);
} }
inline u32 HLEMemory_Read_U32(u32 address) inline u32 HLEMemory_Read_U32(u32 address)
{ {
u32 value;
if (ExramRead(address)) if (ExramRead(address))
return Common::swap32(*(u32*)&Memory::m_pEXRAM[address & Memory::EXRAM_MASK]); std::memcpy(&value, &Memory::m_pEXRAM[address & Memory::EXRAM_MASK], sizeof(u32));
else else
return Common::swap32(*(u32*)&Memory::m_pRAM[address & Memory::RAM_MASK]); std::memcpy(&value, &Memory::m_pRAM[address & Memory::RAM_MASK], sizeof(u32));
return Common::swap32(value);
} }
inline void* HLEMemory_Get_Pointer(u32 address) inline void* HLEMemory_Get_Pointer(u32 address)