Adding shadows

This commit is contained in:
AnonymusRaccoon
2020-01-28 17:29:41 +01:00
parent dbca55e98c
commit 235f147109
12 changed files with 90 additions and 21 deletions

View File

@@ -5,6 +5,8 @@
#include <algorithm>
#include <iostream>
#include "MemoryBus.hpp"
#include "../SNES.hpp"
#include "MemoryShadow.hpp"
namespace ComSquare
{
@@ -42,4 +44,37 @@ namespace ComSquare
}
handler->write(addr - handler->getStart(), data);
}
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.cpu, i + 0x4200, i + 0x4220));
}
void MemoryBus::mapComponents(SNES &console)
{
// The WRam is always mapped in the bank 7E and 7F, no matter the memory mapping mode.
console.wram->setMemoryRegion(0x7E0000, 0x7FFFFF);
this->_memoryAccessors.push_back(console.wram);
console.ppu->setMemoryRegion(0x2100, 0x2140);
this->_memoryAccessors.push_back(console.ppu);
console.apu->setMemoryRegion(0x2140, 0x2144);
this->_memoryAccessors.push_back(console.apu);
console.cpu->setMemoryRegion(0x4200, 0x4220);
this->_memoryAccessors.push_back(console.cpu);
// TODO implement DMA & HDMA (4220 to 4300)
//Mirror the first $2000 bits of the WRam to all banks of the Q1 & Q3.
for (uint24_t i = 0; i < 0x400000; i += 0x10000) {
this->_mirrorComponents(console, i);
}
for (uint24_t i = 0x800000; i < 0xC00000; i += 0x10000) {
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.wram, i, i + 0x2000));
this->_memoryAccessors.push_back(Memory::MemoryShadow::createShadow(console.cpu, i + 0x4200, i + 0x4220));
}
}
}