From 88d773708c1c3ac1eb54ff2029cdde9217e29098 Mon Sep 17 00:00:00 2001 From: "Adrian.Conlon" Date: Sun, 6 Aug 2017 22:04:13 +0100 Subject: [PATCH] Correct some outstanding LR35902 problems arising. Signed-off-by: Adrian.Conlon --- LR35902/inc/Bus.h | 16 ++++------------ LR35902/src/Bus.cpp | 4 ++-- LR35902/src/LR35902.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/LR35902/inc/Bus.h b/LR35902/inc/Bus.h index e770e90..e1c956b 100644 --- a/LR35902/inc/Bus.h +++ b/LR35902/inc/Bus.h @@ -80,22 +80,19 @@ namespace EightBit { void reset(); void writeRegister(int offset, uint8_t content) { - REG(offset) = content; - fireWriteBusEvent(); + return Memory::write(BASE + offset, content); } uint8_t readRegister(int offset) { - auto returned = REG(offset); - fireReadBusEvent(); - return returned; + return Memory::read(BASE + offset); } void incrementLY() { - REG(LY) = (REG(LY) + 1) % TotalLineCount; + writeRegister(LY, (readRegister(LY) + 1) % TotalLineCount); } void resetLY() { - REG(LY) = 0; + writeRegister(LY, 0); } void loadBootRom(const std::string& path); @@ -110,10 +107,5 @@ namespace EightBit { private: std::array m_boot; - - uint8_t& REG(int offset) { - ADDRESS().word = BASE + offset; - return Memory::reference(); - } }; } \ No newline at end of file diff --git a/LR35902/src/Bus.cpp b/LR35902/src/Bus.cpp index b695e05..b56cdd2 100644 --- a/LR35902/src/Bus.cpp +++ b/LR35902/src/Bus.cpp @@ -6,8 +6,8 @@ EightBit::Bus::Bus() } void EightBit::Bus::reset() { - REG(NR52) = 0xf1; - REG(LCDC) = 0x91; + writeRegister(NR52, 0xf1); + writeRegister(LCDC, 0x91); } void EightBit::Bus::loadBootRom(const std::string& path) { diff --git a/LR35902/src/LR35902.cpp b/LR35902/src/LR35902.cpp index 2444406..e84051f 100644 --- a/LR35902/src/LR35902.cpp +++ b/LR35902/src/LR35902.cpp @@ -570,16 +570,16 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) { case 7: // Assorted operations on accumulator/flags switch (y) { case 0: - rlc(f, a); + a = rlc(f, a); break; case 1: - rrc(f, a); + a = rrc(f, a); break; case 2: - rl(f, a); + a = rl(f, a); break; case 3: - rr(f, a); + a = rr(f, a); break; case 4: daa(a, f);