Memmap: Drop redundant global bFakeVMEM flag.

This commit is contained in:
degasus 2016-09-04 10:50:48 +02:00
parent d139659ea2
commit ebc47a4b36
3 changed files with 11 additions and 14 deletions

View File

@ -34,9 +34,6 @@
namespace Memory namespace Memory
{ {
// (See comment below describing memory map.)
bool bFakeVMEM = false;
// ================================= // =================================
// Init() declarations // Init() declarations
// ---------------- // ----------------
@ -169,6 +166,7 @@ void Init()
{ {
bool wii = SConfig::GetInstance().bWii; bool wii = SConfig::GetInstance().bWii;
bool bMMU = SConfig::GetInstance().bMMU; bool bMMU = SConfig::GetInstance().bMMU;
bool bFakeVMEM = false;
#ifndef _ARCH_32 #ifndef _ARCH_32
// If MMU is turned off in GameCube mode, turn on fake VMEM hack. // If MMU is turned off in GameCube mode, turn on fake VMEM hack.
// The fake VMEM hack's address space is above the memory space that we // The fake VMEM hack's address space is above the memory space that we
@ -269,7 +267,7 @@ void DoState(PointerWrap& p)
p.DoArray(m_pRAM, RAM_SIZE); p.DoArray(m_pRAM, RAM_SIZE);
p.DoArray(m_pL1Cache, L1_CACHE_SIZE); p.DoArray(m_pL1Cache, L1_CACHE_SIZE);
p.DoMarker("Memory RAM"); p.DoMarker("Memory RAM");
if (bFakeVMEM) if (m_pFakeVMEM)
p.DoArray(m_pFakeVMEM, FAKEVMEM_SIZE); p.DoArray(m_pFakeVMEM, FAKEVMEM_SIZE);
p.DoMarker("Memory FakeVMEM"); p.DoMarker("Memory FakeVMEM");
if (wii) if (wii)
@ -283,7 +281,7 @@ void Shutdown()
u32 flags = 0; u32 flags = 0;
if (SConfig::GetInstance().bWii) if (SConfig::GetInstance().bWii)
flags |= PhysicalMemoryRegion::WII_ONLY; flags |= PhysicalMemoryRegion::WII_ONLY;
if (bFakeVMEM) if (m_pFakeVMEM)
flags |= PhysicalMemoryRegion::FAKE_VMEM; flags |= PhysicalMemoryRegion::FAKE_VMEM;
for (PhysicalMemoryRegion& region : physical_regions) for (PhysicalMemoryRegion& region : physical_regions)
{ {
@ -397,7 +395,7 @@ u8* GetPointer(u32 address)
if (address < REALRAM_SIZE) if (address < REALRAM_SIZE)
return m_pRAM + address; return m_pRAM + address;
if (SConfig::GetInstance().bWii) if (m_pEXRAM)
{ {
if ((address >> 28) == 0x1 && (address & 0x0fffffff) < EXRAM_SIZE) if ((address >> 28) == 0x1 && (address & 0x0fffffff) < EXRAM_SIZE)
return m_pEXRAM + (address & EXRAM_MASK); return m_pEXRAM + (address & EXRAM_MASK);

View File

@ -35,7 +35,6 @@ extern u8* m_pRAM;
extern u8* m_pEXRAM; extern u8* m_pEXRAM;
extern u8* m_pL1Cache; extern u8* m_pL1Cache;
extern u8* m_pFakeVMEM; extern u8* m_pFakeVMEM;
extern bool bFakeVMEM;
enum enum
{ {

View File

@ -211,7 +211,7 @@ __forceinline static T ReadFromHardware(u32 em_address)
// In Fake-VMEM mode, we need to map the memory somewhere into // In Fake-VMEM mode, we need to map the memory somewhere into
// physical memory for BAT translation to work; we currently use // physical memory for BAT translation to work; we currently use
// [0x7E000000, 0x80000000). // [0x7E000000, 0x80000000).
if (Memory::bFakeVMEM && ((em_address & 0xFE000000) == 0x7E000000)) if (Memory::m_pFakeVMEM && ((em_address & 0xFE000000) == 0x7E000000))
{ {
return bswap(*(T*)&Memory::m_pFakeVMEM[em_address & Memory::RAM_MASK]); return bswap(*(T*)&Memory::m_pFakeVMEM[em_address & Memory::RAM_MASK]);
} }
@ -295,7 +295,7 @@ __forceinline static void WriteToHardware(u32 em_address, const T data)
// In Fake-VMEM mode, we need to map the memory somewhere into // In Fake-VMEM mode, we need to map the memory somewhere into
// physical memory for BAT translation to work; we currently use // physical memory for BAT translation to work; we currently use
// [0x7E000000, 0x80000000). // [0x7E000000, 0x80000000).
if (Memory::bFakeVMEM && ((em_address & 0xFE000000) == 0x7E000000)) if (Memory::m_pFakeVMEM && ((em_address & 0xFE000000) == 0x7E000000))
{ {
*(T*)&Memory::m_pFakeVMEM[em_address & Memory::RAM_MASK] = bswap(data); *(T*)&Memory::m_pFakeVMEM[em_address & Memory::RAM_MASK] = bswap(data);
return; return;
@ -395,7 +395,7 @@ TryReadInstResult TryReadInstruction(u32 address)
u32 hex; u32 hex;
// TODO: Refactor this. This icache implementation is totally wrong if used with the fake vmem. // TODO: Refactor this. This icache implementation is totally wrong if used with the fake vmem.
if (Memory::bFakeVMEM && ((address & 0xFE000000) == 0x7E000000)) if (Memory::m_pFakeVMEM && ((address & 0xFE000000) == 0x7E000000))
{ {
hex = bswap(*(const u32*)&Memory::m_pFakeVMEM[address & Memory::FAKEVMEM_MASK]); hex = bswap(*(const u32*)&Memory::m_pFakeVMEM[address & Memory::FAKEVMEM_MASK]);
} }
@ -639,7 +639,7 @@ bool HostIsRAMAddress(u32 address)
return true; return true;
else if (Memory::m_pEXRAM && segment == 0x1 && (address & 0x0FFFFFFF) < Memory::EXRAM_SIZE) else if (Memory::m_pEXRAM && segment == 0x1 && (address & 0x0FFFFFFF) < Memory::EXRAM_SIZE)
return true; return true;
else if (Memory::bFakeVMEM && ((address & 0xFE000000) == 0x7E000000)) else if (Memory::m_pFakeVMEM && ((address & 0xFE000000) == 0x7E000000))
return true; return true;
else if (segment == 0xE && (address < (0xE0000000 + Memory::L1_CACHE_SIZE))) else if (segment == 0xE && (address < (0xE0000000 + Memory::L1_CACHE_SIZE)))
return true; return true;
@ -1166,7 +1166,7 @@ static void UpdateBATs(BatTable& bat_table, u32 base_spr)
// The bottom bit is whether the translation is valid; the second // The bottom bit is whether the translation is valid; the second
// bit from the bottom is whether we can use the fastmem arena. // bit from the bottom is whether we can use the fastmem arena.
u32 valid_bit = 0x1; u32 valid_bit = 0x1;
if (Memory::bFakeVMEM && ((address & 0xFE000000) == 0x7E000000)) if (Memory::m_pFakeVMEM && ((address & 0xFE000000) == 0x7E000000))
valid_bit = 0x3; valid_bit = 0x3;
else if (address < Memory::REALRAM_SIZE) else if (address < Memory::REALRAM_SIZE)
valid_bit = 0x3; valid_bit = 0x3;
@ -1202,7 +1202,7 @@ void DBATUpdated()
bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE; bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE;
if (extended_bats) if (extended_bats)
UpdateBATs(dbat_table, SPR_DBAT4U); UpdateBATs(dbat_table, SPR_DBAT4U);
if (Memory::bFakeVMEM) if (Memory::m_pFakeVMEM)
{ {
// In Fake-MMU mode, insert some extra entries into the BAT tables. // In Fake-MMU mode, insert some extra entries into the BAT tables.
UpdateFakeMMUBat(dbat_table, 0x40000000); UpdateFakeMMUBat(dbat_table, 0x40000000);
@ -1221,7 +1221,7 @@ void IBATUpdated()
bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE; bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE;
if (extended_bats) if (extended_bats)
UpdateBATs(ibat_table, SPR_IBAT4U); UpdateBATs(ibat_table, SPR_IBAT4U);
if (Memory::bFakeVMEM) if (Memory::m_pFakeVMEM)
{ {
// In Fake-MMU mode, insert some extra entries into the BAT tables. // In Fake-MMU mode, insert some extra entries into the BAT tables.
UpdateFakeMMUBat(ibat_table, 0x40000000); UpdateFakeMMUBat(ibat_table, 0x40000000);