Merge pull request #650 from cxd4/mem

Remove external linkage of swap32by8()--now static.
This commit is contained in:
zilmar 2015-10-27 05:29:16 +11:00
commit 572418ec30
3 changed files with 25 additions and 26 deletions

View File

@ -40,9 +40,9 @@ CMipsMemoryVM::CMipsMemoryVM( CMipsMemory_CallBack * CallBack, bool SavesReadOnl
m_IMEM = NULL;
}
unsigned long swap32by8(unsigned long word)
static uint32_t swap32by8(uint32_t word)
{
const unsigned long swapped =
const uint32_t swapped =
#if defined(_MSC_VER)
_byteswap_ulong(word)
#elif defined(__GNUC__)
@ -282,7 +282,7 @@ bool CMipsMemoryVM::LB_VAddr(DWORD VAddr, BYTE& Value)
return false;
}
Value = *(BYTE*)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 3));
Value = *(uint8_t *)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 3));
return true;
}
@ -293,7 +293,7 @@ bool CMipsMemoryVM::LH_VAddr(DWORD VAddr, WORD& Value)
return false;
}
Value = *(WORD*)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 2));
Value = *(uint16_t *)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 2));
return true;
}
@ -344,7 +344,7 @@ bool CMipsMemoryVM::LB_PAddr(DWORD PAddr, BYTE& Value)
{
if (PAddr < RdramSize())
{
Value = *(BYTE*)(m_RDRAM + (PAddr ^ 3));
Value = *(uint8_t *)(m_RDRAM + (PAddr ^ 3));
return true;
}
@ -361,7 +361,7 @@ bool CMipsMemoryVM::LH_PAddr(DWORD PAddr, WORD& Value)
{
if (PAddr < RdramSize())
{
Value = *(WORD*)(m_RDRAM + (PAddr ^ 2));
Value = *(uint16_t *)(m_RDRAM + (PAddr ^ 2));
return true;
}
@ -416,7 +416,7 @@ bool CMipsMemoryVM::SB_VAddr(DWORD VAddr, BYTE Value)
return false;
}
*(BYTE*)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 3)) = Value;
*(uint8_t *)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 3)) = Value;
return true;
}
@ -427,7 +427,7 @@ bool CMipsMemoryVM::SH_VAddr(DWORD VAddr, WORD Value)
return false;
}
*(WORD*)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 2)) = Value;
*(uint16_t *)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 2)) = Value;
return true;
}
@ -469,7 +469,7 @@ bool CMipsMemoryVM::SB_PAddr(DWORD PAddr, BYTE Value)
{
if (PAddr < RdramSize())
{
*(BYTE*)(m_RDRAM + (PAddr ^ 3)) = Value;
*(uint8_t *)(m_RDRAM + (PAddr ^ 3)) = Value;
return true;
}
@ -486,7 +486,7 @@ bool CMipsMemoryVM::SH_PAddr(DWORD PAddr, WORD Value)
{
if (PAddr < RdramSize())
{
*(WORD*)(m_RDRAM + (PAddr ^ 2)) = Value;
*(uint16_t *)(m_RDRAM + (PAddr ^ 2)) = Value;
return true;
}

View File

@ -30,7 +30,16 @@
#define Eip Rip
#endif
extern unsigned long swap32by8(unsigned long word);
/*
* To do: Have address translation functions here?
* `return` either the translated address or the mask to XOR by?
*
* This will help us gradually be able to port Project64 for big-endian CPUs.
* Currently it is written to assume 32-bit little-endian, like so:
*
* 0xAABBCCDD EEFFGGHH --> 0xDDCCBBAA HHGGFFEE
* GPR bits[63..0] b1b2b3b4 b5b6b7b8
*/
class CMipsMemoryVM :
public CMipsMemory,

View File

@ -297,19 +297,14 @@ void CPifRam::SI_DMA_READ()
{
continue;
}
RDRAM[RdramPos ^3] = m_PifRam[count];
RDRAM[RdramPos ^ 3] = m_PifRam[count];
}
}
else
{
for (size_t i = 0; i < 64; i += 4)
for (size_t i = 0; i < 64; i++)
{
unsigned __int32 pif_ram_dword;
std::memcpy(&pif_ram_dword, &PifRamPos[i], sizeof(unsigned __int32));
pif_ram_dword = swap32by8(pif_ram_dword);
std::memcpy(&RDRAM[SI_DRAM_ADDR_REG + i], &pif_ram_dword, sizeof(unsigned __int32));
RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3] = PifRamPos[i];
}
}
@ -393,14 +388,9 @@ void CPifRam::SI_DMA_WRITE()
}
else
{
for (size_t i = 0; i < 64; i += 4)
for (size_t i = 0; i < 64; i++)
{
unsigned __int32 rdram_dword;
std::memcpy(&rdram_dword, &RDRAM[SI_DRAM_ADDR_REG + i], sizeof(unsigned __int32));
rdram_dword = swap32by8(rdram_dword);
std::memcpy(&PifRamPos[i], &rdram_dword, sizeof(unsigned __int32));
PifRamPos[i] = RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3];
}
}