EightBit/LR35902/src/Bus.cpp
Adrian.Conlon 93bac42547 Bring LR35902 a little more in line with the Z80 implementation.
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
2017-06-09 11:42:32 +01:00

32 lines
747 B
C++

#include "stdafx.h"
#include "Bus.h"
EightBit::Bus::Bus()
: Memory(0xffff) {
}
void EightBit::Bus::reset() {
REG(NR52) = 0xf1;
REG(LCDC) = 0x91;
}
void EightBit::Bus::loadBootRom(const std::string& path) {
auto size = loadMemory(path, 0);
if (size != 0x100)
throw std::runtime_error("Incorrectly sized boot ROM");
std::copy_n(m_bus.cbegin(), size, m_boot.begin());
}
uint8_t& EightBit::Bus::reference() {
auto effective = effectiveAddress(ADDRESS().word);
if (isBootRom(effective))
return placeDATA(m_boot[effective]);
return Memory::reference();
}
uint8_t EightBit::Bus::peek(uint16_t address) const {
auto effective = effectiveAddress(address);
if (isBootRom(effective))
return m_boot[effective];
return m_bus[effective];
}