diff --git a/Z80/inc/Z80.h b/Z80/inc/Z80.h index 7700143..9ae6dcd 100644 --- a/Z80/inc/Z80.h +++ b/Z80/inc/Z80.h @@ -120,7 +120,7 @@ namespace EightBit { void memoryUpdate(int ticks = 1) noexcept; void memoryWrite() noexcept final; - uint8_t memoryRead() noexcept final; + void memoryRead() noexcept final; void refreshMemory() noexcept; void jumpRelative(int8_t offset) noexcept final; diff --git a/Z80/src/Z80.cpp b/Z80/src/Z80.cpp index 170198e..2b5d2ef 100644 --- a/Z80/src/Z80.cpp +++ b/Z80/src/Z80.cpp @@ -23,6 +23,9 @@ EightBit::Z80::Z80(Bus& bus, InputOutput& ports) noexcept IX() = IY() = Mask16; + // One of the register sets has been initialised + // (by the IntelProcessor base class) + // so now lets initialise the other register set. exx(); exxAF(); @@ -169,7 +172,7 @@ void EightBit::Z80::refreshMemory() noexcept { raiseRFSH(); } -uint8_t EightBit::Z80::memoryRead() noexcept { +void EightBit::Z80::memoryRead() noexcept { ReadingMemory.fire(); tick(); lowerMREQ(); @@ -182,7 +185,6 @@ uint8_t EightBit::Z80::memoryRead() noexcept { refreshMemory(); tick(); ReadMemory.fire(); - return BUS().DATA(); } void EightBit::Z80::handleRESET() noexcept { @@ -423,9 +425,8 @@ void EightBit::Z80::add(const register16_t value, int carry) noexcept { } void EightBit::Z80::xhtl(register16_t& exchange) noexcept { - MEMPTR().low = IntelProcessor::memoryRead(SP()); - ++BUS().ADDRESS(); - MEMPTR().high = memoryRead(); + BUS().ADDRESS() = SP(); + getInto(MEMPTR()); BUS().DATA() = exchange.high; exchange.high = MEMPTR().high; memoryUpdate(2); @@ -905,19 +906,6 @@ uint8_t EightBit::Z80::fetchInstruction() noexcept { return data; } -//void EightBit::Z80::loadAccumulatorIndirect(addresser_t addresser) noexcept { -// MEMPTR() = BUS().ADDRESS() = addresser(); -// ++MEMPTR(); -// A() = memoryRead(); -//} -// -//void EightBit::Z80::storeAccumulatorIndirect(addresser_t addresser) noexcept { -// MEMPTR() = BUS().ADDRESS() = addresser(); -// ++MEMPTR(); -// MEMPTR().high = BUS().DATA() = A(); -// memoryWrite(); -//} - void EightBit::Z80::readInternalRegister(reader_t reader) noexcept { adjustSZXY(A() = reader()); clearBit(NF | HC); @@ -1092,7 +1080,8 @@ void EightBit::Z80::executeCB(const int x, const int y, const int z) noexcept { if (displaced()) { tick(2); displaceAddress(); - operand = memoryRead(); + memoryRead(); + operand = BUS().DATA(); } else { operand = R(z); } diff --git a/inc/Bus.h b/inc/Bus.h index c086545..ca40c72 100644 --- a/inc/Bus.h +++ b/inc/Bus.h @@ -33,7 +33,7 @@ namespace EightBit { void poke(const uint16_t address, const uint8_t value) noexcept { reference(address) = value; } void poke(const register16_t address, const uint8_t value) noexcept { poke(address.joined, value); } - [[nodiscard]] uint8_t read() noexcept; + void read() noexcept; void write() noexcept; virtual void raisePOWER() noexcept; diff --git a/inc/Processor.h b/inc/Processor.h index 5b479c7..2f8b566 100644 --- a/inc/Processor.h +++ b/inc/Processor.h @@ -66,9 +66,9 @@ namespace EightBit { virtual void memoryWrite() noexcept; void busWrite() noexcept; - uint8_t memoryRead(register16_t address) noexcept; - virtual uint8_t memoryRead() noexcept; - uint8_t busRead() noexcept; + void memoryRead(register16_t address) noexcept; + virtual void memoryRead() noexcept; + void busRead() noexcept; virtual register16_t& incrementPC() noexcept; diff --git a/src/Bus.cpp b/src/Bus.cpp index 85342b7..9100b64 100644 --- a/src/Bus.cpp +++ b/src/Bus.cpp @@ -8,11 +8,10 @@ void EightBit::Bus::raisePOWER() noexcept {} void EightBit::Bus::lowerPOWER() noexcept {} -uint8_t EightBit::Bus::read() noexcept { +void EightBit::Bus::read() noexcept { ReadingByte.fire(); - const auto returned = DATA() = reference(); + DATA() = reference(); ReadByte.fire(); - return returned; } void EightBit::Bus::write() noexcept { diff --git a/src/Processor.cpp b/src/Processor.cpp index 8dc9cdd..64d21da 100644 --- a/src/Processor.cpp +++ b/src/Processor.cpp @@ -49,17 +49,17 @@ void EightBit::Processor::busWrite() noexcept { BUS().write(); } -uint8_t EightBit::Processor::memoryRead(const register16_t address) noexcept { +void EightBit::Processor::memoryRead(const register16_t address) noexcept { BUS().ADDRESS() = address; - return memoryRead(); + memoryRead(); } -uint8_t EightBit::Processor::memoryRead() noexcept { - return busRead(); +void EightBit::Processor::memoryRead() noexcept { + busRead(); } -uint8_t EightBit::Processor::busRead() noexcept { - return BUS().read(); +void EightBit::Processor::busRead() noexcept { + BUS().read(); } void EightBit::Processor::getShortPaged(register16_t address) noexcept {