From 75b17e47a846ca8b8ac07af375995c1c7cab4e88 Mon Sep 17 00:00:00 2001 From: "Adrian.Conlon" Date: Sat, 19 Aug 2017 17:33:28 +0100 Subject: [PATCH] Better method of enabling/disabling boot ROM. Signed-off-by: Adrian.Conlon --- LR35902/inc/Bus.h | 6 +++--- LR35902/src/Bus.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/LR35902/inc/Bus.h b/LR35902/inc/Bus.h index ca76298..5093480 100644 --- a/LR35902/inc/Bus.h +++ b/LR35902/inc/Bus.h @@ -158,13 +158,13 @@ namespace EightBit { writeRegister(LY, 0); } - void disableBootRom() { m_disableBootRom = true; } - void enableBootRom() { m_disableBootRom = false; } + bool bootRomDisabled() const { return m_disableBootRom; } + bool bootRomEnabled() const { return !bootRomDisabled(); } void loadBootRom(const std::string& path); bool isBootRom(uint16_t address) const { - return !m_disableBootRom && (address < m_boot.size()) && !peek(BASE + BOOT_DISABLE); + return (address < m_boot.size()) && bootRomEnabled(); } virtual uint8_t peek(uint16_t address) const; diff --git a/LR35902/src/Bus.cpp b/LR35902/src/Bus.cpp index 6b464ef..bd04d0f 100644 --- a/LR35902/src/Bus.cpp +++ b/LR35902/src/Bus.cpp @@ -2,8 +2,8 @@ #include "Bus.h" EightBit::Bus::Bus() -: Memory(0xffff), - m_disableBootRom(false) { +: Memory(0xffff) { + WrittenByte.connect(std::bind(&Bus::Bus_WrittenByte, this, std::placeholders::_1)); } void EightBit::Bus::reset() { @@ -39,8 +39,11 @@ uint8_t EightBit::Bus::peek(uint16_t address) const { void EightBit::Bus::Bus_WrittenByte(const AddressEventArgs& e) { switch (e.getAddress()) { - case EightBit::Bus::BASE + TAC: + case BASE + TAC: m_timerRate = timerClockTicks(); break; + case BASE + BOOT_DISABLE: + m_disableBootRom = e.getCell() != 0; + break; } } \ No newline at end of file