From 974c3353cc8be1bf3063bfd579ad45ce15d5d7d9 Mon Sep 17 00:00:00 2001 From: "Adrian.Conlon" Date: Tue, 18 Jul 2017 11:28:06 +0100 Subject: [PATCH] Simplify LR35902 memory read/write a little. Signed-off-by: Adrian.Conlon --- LR35902/src/LR35902.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/LR35902/src/LR35902.cpp b/LR35902/src/LR35902.cpp index 73b189b..a80795c 100644 --- a/LR35902/src/LR35902.cpp +++ b/LR35902/src/LR35902.cpp @@ -471,12 +471,12 @@ void EightBit::LR35902::executeCB(int x, int y, int z, int p, int q) { } break; case 1: // BIT y, r[z] - bit(y, R(z)); + bit(y, R(z)); + cycles += 2; + if (z == 6) { + m_bus.fireReadBusEvent(); cycles += 2; - if (z == 6) { - m_bus.fireReadBusEvent(); - cycles += 2; - } + } break; case 2: // RES y, r[z] res(y, R(z)); @@ -788,9 +788,7 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) { break; case 5: // GB: LD (nn),A fetchWord(); - m_memory.ADDRESS() = MEMPTR(); - m_memory.reference() = A(); - m_bus.fireWriteBusEvent(); + m_bus.write(MEMPTR().word, A()); cycles += 4; break; case 6: // GB: LD A,(FF00 + C) @@ -800,9 +798,7 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) { break; case 7: // GB: LD A,(nn) fetchWord(); - m_memory.ADDRESS() = MEMPTR(); - A() = m_memory.reference(); - m_bus.fireReadBusEvent(); + A() = m_bus.read(MEMPTR().word); cycles += 4; break; }