diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index 96499ddee..a629148a8 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -50,24 +50,26 @@ void CMipsMemoryVM::Reset( bool /*EraseMemory*/ ) { if (m_TLB_ReadMap) { - memset(m_TLB_ReadMap,0,(0xFFFFF * sizeof(DWORD))); - memset(m_TLB_WriteMap,0,(0xFFFFF * sizeof(DWORD))); - for (DWORD address = 0x80000000; address < 0xC0000000; address += 0x1000) + size_t address; + + memset(m_TLB_ReadMap , 0, 0xFFFFF * sizeof(size_t)); + memset(m_TLB_WriteMap, 0, 0xFFFFF * sizeof(size_t)); + for (address = 0x80000000; address < 0xC0000000; address += 0x1000) { - m_TLB_ReadMap[address >> 12] = ((DWORD)m_RDRAM + (address & 0x1FFFFFFF)) - address; - m_TLB_WriteMap[address >> 12] = ((DWORD)m_RDRAM + (address & 0x1FFFFFFF)) - address; + m_TLB_ReadMap[address >> 12] = ((size_t)m_RDRAM + (address & 0x1FFFFFFF)) - address; + m_TLB_WriteMap[address >> 12] = ((size_t)m_RDRAM + (address & 0x1FFFFFFF)) - address; } if (g_Settings->LoadDword(Rdb_TLB_VAddrStart) != 0) { - DWORD Start = g_Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000; - DWORD Len = g_Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000; - DWORD PAddr = g_Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30; - DWORD End = Start + Len; - for (DWORD address = Start; address < End; address += 0x1000) + size_t Start = g_Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000; + size_t Len = g_Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000; + size_t PAddr = g_Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30; + size_t End = Start + Len; + for (address = Start; address < End; address += 0x1000) { - m_TLB_ReadMap[address >> 12] = ((DWORD)m_RDRAM + (address - Start + PAddr)) - address; - m_TLB_WriteMap[address >> 12] = ((DWORD)m_RDRAM + (address - Start + PAddr)) - address; + m_TLB_ReadMap[address >> 12] = ((size_t)m_RDRAM + (address - Start + PAddr)) - address; + m_TLB_WriteMap[address >> 12] = ((size_t)m_RDRAM + (address - Start + PAddr)) - address; } } } @@ -164,18 +166,28 @@ bool CMipsMemoryVM::Initialize() } CPifRam::Reset(); - m_TLB_ReadMap = (DWORD *)VirtualAlloc(NULL,0xFFFFF * sizeof(DWORD),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); + m_TLB_ReadMap = (size_t *)VirtualAlloc( + NULL, + 0xFFFFF * sizeof(size_t), + MEM_RESERVE | MEM_COMMIT, + PAGE_READWRITE + ); if (m_TLB_ReadMap == NULL) { - WriteTraceF(TraceError,__FUNCTION__": Failed to Allocate m_TLB_ReadMap (Size: 0x%X)",0xFFFFF * sizeof(DWORD)); + WriteTraceF(TraceError,__FUNCTION__": Failed to Allocate m_TLB_ReadMap (Size: 0x%X)",0xFFFFF * sizeof(size_t)); FreeMemory(); return false; } - m_TLB_WriteMap = (DWORD *)VirtualAlloc(NULL,0xFFFFF * sizeof(DWORD),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); + m_TLB_WriteMap = (size_t *)VirtualAlloc( + NULL, + 0xFFFFF * sizeof(size_t), + MEM_RESERVE | MEM_COMMIT, + PAGE_READWRITE + ); if (m_TLB_WriteMap == NULL) { - WriteTraceF(TraceError,__FUNCTION__": Failed to Allocate m_TLB_WriteMap (Size: 0x%X)",0xFFFFF * sizeof(DWORD)); + WriteTraceF(TraceError,__FUNCTION__": Failed to Allocate m_TLB_WriteMap (Size: 0x%X)",0xFFFFF * sizeof(size_t)); FreeMemory(); return false; } @@ -5349,22 +5361,28 @@ LPCTSTR CMipsMemoryVM::LabelName ( DWORD Address ) const void CMipsMemoryVM::TLB_Mapped( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly ) { - for (DWORD count = VAddr, VEnd = VAddr + Len; count < VEnd; count += 0x1000) + size_t count, VEnd; + + VEnd = VAddr + Len; + for (count = VAddr; count < VEnd; count += 0x1000) { - DWORD Index = count >> 12; - m_TLB_ReadMap[Index] = ((DWORD)m_RDRAM + (count - VAddr + PAddr)) - count; + size_t Index = count >> 12; + m_TLB_ReadMap[Index] = ((size_t)m_RDRAM + (count - VAddr + PAddr)) - count; if (!bReadOnly) { - m_TLB_WriteMap[Index] = ((DWORD)m_RDRAM + (count - VAddr + PAddr)) - count; + m_TLB_WriteMap[Index] = ((size_t)m_RDRAM + (count - VAddr + PAddr)) - count; } } } void CMipsMemoryVM::TLB_Unmaped( DWORD Vaddr, DWORD Len ) { - for (DWORD count = Vaddr, End = Vaddr + Len; count < End; count += 0x1000) + size_t count, End; + + End = Vaddr + Len; + for (count = Vaddr; count < End; count += 0x1000) { - DWORD Index = count >> 12; + size_t Index = count >> 12; m_TLB_ReadMap[Index] = NULL; m_TLB_WriteMap[Index] = NULL; } diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h index efd810e6b..4f11f477c 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -166,6 +166,6 @@ private: mutable char m_strLabelName[100]; //BIG look up table to quickly translate the tlb to real mem address - DWORD * m_TLB_ReadMap; - DWORD * m_TLB_WriteMap; + size_t * m_TLB_ReadMap; + size_t * m_TLB_WriteMap; };