Merge pull request #580 from cxd4/so_i_herd_u_liek_bswap
replaced all in-line assembly in Virtual Memory unit
This commit is contained in:
commit
120d4d5590
|
@ -40,6 +40,23 @@ CMipsMemoryVM::CMipsMemoryVM( CMipsMemory_CallBack * CallBack, bool SavesReadOnl
|
||||||
m_IMEM = NULL;
|
m_IMEM = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long swap32by8(unsigned long word)
|
||||||
|
{
|
||||||
|
const unsigned long swapped =
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
_byteswap_ulong(word)
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
__builtin_bswap32(word)
|
||||||
|
#else
|
||||||
|
(word & 0x000000FFul) << 24
|
||||||
|
| (word & 0x0000FF00ul) << 8
|
||||||
|
| (word & 0x00FF0000ul) >> 8
|
||||||
|
| (word & 0xFF000000ul) >> 24
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
return (swapped & 0xFFFFFFFFul);
|
||||||
|
}
|
||||||
|
|
||||||
CMipsMemoryVM::~CMipsMemoryVM()
|
CMipsMemoryVM::~CMipsMemoryVM()
|
||||||
{
|
{
|
||||||
g_Settings->UnregisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)RdramChanged);
|
g_Settings->UnregisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)RdramChanged);
|
||||||
|
@ -2653,32 +2670,16 @@ bool CMipsMemoryVM::LW_NonMemory(DWORD PAddr, DWORD* Value)
|
||||||
case 0x1FC00000:
|
case 0x1FC00000:
|
||||||
if (PAddr < 0x1FC007C0)
|
if (PAddr < 0x1FC007C0)
|
||||||
{
|
{
|
||||||
/* DWORD ToSwap = *(DWORD *)(&PifRom[PAddr - 0x1FC00000]);
|
/* *Value = *(DWORD *)(&PifRom[PAddr - 0x1FC00000]);
|
||||||
_asm
|
*Value = swap32by8(*Value); */
|
||||||
{
|
|
||||||
mov eax,ToSwap
|
|
||||||
bswap eax
|
|
||||||
mov ToSwap,eax
|
|
||||||
}
|
|
||||||
* Value = ToSwap;*/
|
|
||||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (PAddr < 0x1FC00800)
|
else if (PAddr < 0x1FC00800)
|
||||||
{
|
{
|
||||||
#ifdef _M_IX86
|
|
||||||
BYTE * PIF_Ram = g_MMU->PifRam();
|
BYTE * PIF_Ram = g_MMU->PifRam();
|
||||||
DWORD ToSwap = *(DWORD *)(&PIF_Ram[PAddr - 0x1FC007C0]);
|
*Value = *(DWORD *)(&PIF_Ram[PAddr - 0x1FC007C0]);
|
||||||
_asm
|
*Value = swap32by8(*Value);
|
||||||
{
|
|
||||||
mov eax,ToSwap
|
|
||||||
bswap eax
|
|
||||||
mov ToSwap,eax
|
|
||||||
}
|
|
||||||
*Value = ToSwap;
|
|
||||||
#else
|
|
||||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3375,16 +3376,7 @@ bool CMipsMemoryVM::SW_NonMemory(DWORD PAddr, DWORD Value)
|
||||||
}
|
}
|
||||||
else if (PAddr < 0x1FC00800)
|
else if (PAddr < 0x1FC00800)
|
||||||
{
|
{
|
||||||
#ifdef _M_IX86
|
Value = swap32by8(Value);
|
||||||
_asm
|
|
||||||
{
|
|
||||||
mov eax,Value
|
|
||||||
bswap eax
|
|
||||||
mov Value,eax
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
|
||||||
#endif
|
|
||||||
*(DWORD *)(&m_PifRam[PAddr - 0x1FC007C0]) = Value;
|
*(DWORD *)(&m_PifRam[PAddr - 0x1FC007C0]) = Value;
|
||||||
if (PAddr == 0x1FC007FC)
|
if (PAddr == 0x1FC007FC)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue