Simplifying the Z80 halt implementation looks better.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2019-08-29 08:51:15 +01:00
parent 2efd53d33a
commit 4f47f3fc4d
2 changed files with 4 additions and 10 deletions

View File

@ -56,8 +56,7 @@ void EightBit::Z80::handleRESET() {
void EightBit::Z80::handleNMI() { void EightBit::Z80::handleNMI() {
raiseNMI(); raiseNMI();
if (halted()) raiseHALT();
proceed();
IFF1() = false; IFF1() = false;
restart(0x66); restart(0x66);
tick(13); tick(13);
@ -65,8 +64,7 @@ void EightBit::Z80::handleNMI() {
void EightBit::Z80::handleINT() { void EightBit::Z80::handleINT() {
IntelProcessor::handleINT(); IntelProcessor::handleINT();
if (halted()) raiseHALT();
proceed();
if (IFF1()) { if (IFF1()) {
di(); di();
switch (IM()) { switch (IM()) {
@ -675,7 +673,7 @@ int EightBit::Z80::step() {
handleNMI(); handleNMI();
} else if (UNLIKELY(lowered(INT()))) { } else if (UNLIKELY(lowered(INT()))) {
handleINT(); handleINT();
} else if (UNLIKELY(halted())) { } else if (UNLIKELY(lowered(HALT()))) {
IntelProcessor::execute(0); // NOP IntelProcessor::execute(0); // NOP
} else { } else {
IntelProcessor::execute(fetchByte()); 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 if (UNLIKELY(memoryY || memoryZ)) // M operations
tick(3); tick(3);
} else { // Exception (replaces LD (HL), (HL)) } else { // Exception (replaces LD (HL), (HL))
halt(); lowerHALT();
} }
tick(4); tick(4);
break; break;

View File

@ -171,10 +171,6 @@ namespace EightBit {
void ret() final; void ret() final;
[[nodiscard]] auto halted() noexcept { return lowered(HALT()); }
void halt() noexcept { --PC(); lowerHALT(); }
void proceed() noexcept { ++PC(); raiseHALT(); }
private: private:
std::array<opcode_decoded_t, 0x100> m_decodedOpcodes; std::array<opcode_decoded_t, 0x100> m_decodedOpcodes;
register16_t m_sp = Mask16; register16_t m_sp = Mask16;