Finishing the common bus for all modes

This commit is contained in:
AnonymusRaccoon
2020-01-28 17:44:16 +01:00
parent dd002759ca
commit 2bcd046f78
2 changed files with 12 additions and 9 deletions
+11 -8
View File
@@ -48,12 +48,14 @@ namespace ComSquare
void MemoryBus::_mirrorComponents(SNES &console, int i) void MemoryBus::_mirrorComponents(SNES &console, int i)
{ {
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.wram, i, i + 0x2000)); this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.wram, i, i + 0x2000));
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.ppu, i + 0x2100, i + 0x2140));
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.apu, i + 0x2140, i + 0x2144));
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.cpu, i + 0x4200, i + 0x4220)); this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.cpu, i + 0x4200, i + 0x4220));
} }
void MemoryBus::mapComponents(SNES &console) void MemoryBus::mapComponents(SNES &console)
{ {
// The WRam is always mapped in the bank 7E and 7F, no matter the memory mapping mode. // The WRam and PU registers are always mapped at the same address no matter the mapping mode.
console.wram->setMemoryRegion(0x7E0000, 0x7FFFFF); console.wram->setMemoryRegion(0x7E0000, 0x7FFFFF);
this->_memoryAccessors.push_back(console.wram); this->_memoryAccessors.push_back(console.wram);
@@ -67,14 +69,15 @@ namespace ComSquare
this->_memoryAccessors.push_back(console.cpu); this->_memoryAccessors.push_back(console.cpu);
// TODO implement DMA & HDMA (4220 to 4300) // TODO implement DMA & HDMA (4220 to 4300)
// TODO implement Joys.
//Mirror the first $2000 bits of the WRam to all banks of the Q1 & Q3. // Map to the quarter 1.
for (uint24_t i = 0; i < 0x400000; i += 0x10000) { for (uint24_t i = 0; i < 0x400000; i += 0x10000)
this->_mirrorComponents(console, i); this->_mirrorComponents(console, i);
} // Map to the quarter 3.
for (uint24_t i = 0x800000; i < 0xC00000; i += 0x10000) { for (uint24_t i = 0x800000; i < 0xC00000; i += 0x10000)
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.wram, i, i + 0x2000)); this->_mirrorComponents(console, i);
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.cpu, i + 0x4200, i + 0x4220));
} // TODO should map sram, cartridge etc via the mapping mode of the cartridge.
} }
} }
+1 -1
View File
@@ -23,7 +23,7 @@ namespace ComSquare
std::shared_ptr<IMemory> getAccessor(uint24_t addr); std::shared_ptr<IMemory> getAccessor(uint24_t addr);
//! @brief The last value read via the memory bus. //! @brief The last value read via the memory bus.
uint8_t _openbus = 0; uint8_t _openbus = 0;
//! @brief Mirror components to other banks. (Used by the mapComponents method). //! @brief WRam, CPU, PPU & ALU registers are mirrored to all banks of Q1 & Q3. This function is used for the mirroring.
//! @param console All the components. //! @param console All the components.
//! @param i Base address for the mirrors. //! @param i Base address for the mirrors.
inline void _mirrorComponents(struct SNES &console, int i); inline void _mirrorComponents(struct SNES &console, int i);