From 4f47f3fc4d1a431ad752903d85552e6c82945c0e Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Thu, 29 Aug 2019 08:51:15 +0100 Subject: [PATCH] Simplifying the Z80 halt implementation looks better. Signed-off-by: Adrian Conlon --- Z80/src/Z80.cpp | 10 ++++------ inc/IntelProcessor.h | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Z80/src/Z80.cpp b/Z80/src/Z80.cpp index 31060b8..10d5e7a 100644 --- a/Z80/src/Z80.cpp +++ b/Z80/src/Z80.cpp @@ -56,8 +56,7 @@ void EightBit::Z80::handleRESET() { void EightBit::Z80::handleNMI() { raiseNMI(); - if (halted()) - proceed(); + raiseHALT(); IFF1() = false; restart(0x66); tick(13); @@ -65,8 +64,7 @@ void EightBit::Z80::handleNMI() { void EightBit::Z80::handleINT() { IntelProcessor::handleINT(); - if (halted()) - proceed(); + raiseHALT(); if (IFF1()) { di(); switch (IM()) { @@ -675,7 +673,7 @@ int EightBit::Z80::step() { handleNMI(); } else if (UNLIKELY(lowered(INT()))) { handleINT(); - } else if (UNLIKELY(halted())) { + } else if (UNLIKELY(lowered(HALT()))) { IntelProcessor::execute(0); // NOP } else { IntelProcessor::execute(fetchByte()); @@ -1274,7 +1272,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in if (UNLIKELY(memoryY || memoryZ)) // M operations tick(3); } else { // Exception (replaces LD (HL), (HL)) - halt(); + lowerHALT(); } tick(4); break; diff --git a/inc/IntelProcessor.h b/inc/IntelProcessor.h index e2c34bf..c035eca 100644 --- a/inc/IntelProcessor.h +++ b/inc/IntelProcessor.h @@ -171,10 +171,6 @@ namespace EightBit { void ret() final; - [[nodiscard]] auto halted() noexcept { return lowered(HALT()); } - void halt() noexcept { --PC(); lowerHALT(); } - void proceed() noexcept { ++PC(); raiseHALT(); } - private: std::array m_decodedOpcodes; register16_t m_sp = Mask16;