From 8b187e761462ab1bd75bb20f3ba278b6b900d103 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Wed, 9 Jan 2019 09:05:12 +0000 Subject: [PATCH] The clock still has to tick, even while held on RDY low, otherwise cycle timing won't work. Signed-off-by: Adrian Conlon --- M6502/src/mos6502.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index ed6fe1a..d2eee0b 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -22,18 +22,21 @@ void EightBit::MOS6502::powerOn() { int EightBit::MOS6502::step() { resetCycles(); ExecutingInstruction.fire(*this); - if (LIKELY(powered() && raised(RDY()))) { + if (LIKELY(powered())) { + addCycle(); if (UNLIKELY(lowered(SO()))) handleSO(); - lower(SYNC()); // Instruction fetch beginning - opcode() = fetchByte(); - if (UNLIKELY(lowered(RESET()))) - handleRESET(); - else if (UNLIKELY(lowered(NMI()))) - handleNMI(); - else if (UNLIKELY(lowered(IRQ()) && !interruptMasked())) - handleIRQ(); - execute(); + if (LIKELY(raised(RDY()))) { + lower(SYNC()); // Instruction fetch beginning + opcode() = BUS().read(PC()++); // can't use fetchByte + if (UNLIKELY(lowered(RESET()))) + handleRESET(); + else if (UNLIKELY(lowered(NMI()))) + handleNMI(); + else if (UNLIKELY(lowered(IRQ()) && !interruptMasked())) + handleIRQ(); + execute(); + } } ExecutedInstruction.fire(*this); return cycles();