diff --git a/Z80/fusetest_Z80/FuseTestRunner.cpp b/Z80/fusetest_Z80/FuseTestRunner.cpp index 10a11cf..6c02004 100644 --- a/Z80/fusetest_Z80/FuseTestRunner.cpp +++ b/Z80/fusetest_Z80/FuseTestRunner.cpp @@ -79,15 +79,15 @@ EightBit::MemoryMapping Fuse::TestRunner::mapping(uint16_t address) { const bool io = m_cpu.requestingIO(); if (io) { - m_ports.setAccessType(EightBit::InputOutput::AccessType::Unknown); + m_ports.accessType() = EightBit::InputOutput::AccessType::Unknown; const bool reading = m_cpu.requestingRead(); if (reading) - m_ports.setAccessType(EightBit::InputOutput::AccessType::Reading); + m_ports.accessType() = EightBit::InputOutput::AccessType::Reading; const bool writing = m_cpu.requestingWrite(); if (writing) - m_ports.setAccessType(EightBit::InputOutput::AccessType::Writing); + m_ports.accessType() = EightBit::InputOutput::AccessType::Writing; return { m_ports, diff --git a/inc/InputOutput.h b/inc/InputOutput.h index afed374..df9cf77 100644 --- a/inc/InputOutput.h +++ b/inc/InputOutput.h @@ -20,24 +20,24 @@ namespace EightBit { int load(std::string path, int writeOffset = 0, int readOffset = 0, int limit = -1) override; int load(const std::vector& bytes, int writeOffset = 0, int readOffset = 0, int limit = -1) override; - [[nodiscard]] AccessType getAccessType() const noexcept { return m_access; } - void setAccessType(AccessType value) noexcept { m_access = value; } + [[nodiscard]] const AccessType& accessType() const noexcept { return m_access; } + [[nodiscard]] AccessType& accessType() noexcept { return m_access; } - auto readPort(uint8_t port, AccessType access) { - setAccessType(access); + [[nodiscard]] auto readPort(uint8_t port, AccessType access) { + accessType() = access; return reference(port); } - auto readInputPort(uint8_t port) { return readPort(port, AccessType::Reading); } - auto readOutputPort(uint8_t port) { return readPort(port, AccessType::Writing); } + [[nodiscard]] auto readInputPort(uint8_t port) { return readPort(port, AccessType::Reading); } + [[nodiscard]] auto readOutputPort(uint8_t port) { return readPort(port, AccessType::Writing); } void writePort(uint8_t port, uint8_t value, AccessType access) { - setAccessType(access); + accessType() = access; reference(port) = value; } - auto writeInputPort(uint8_t port, uint8_t value) { return writePort(port, value, AccessType::Reading); } - auto writeOutputPort(uint8_t port, uint8_t value) { return writePort(port, value, AccessType::Writing); } + void writeInputPort(uint8_t port, uint8_t value) { writePort(port, value, AccessType::Reading); } + void writeOutputPort(uint8_t port, uint8_t value) { writePort(port, value, AccessType::Writing); } protected: void poke(uint16_t address, uint8_t value) override; diff --git a/src/InputOutput.cpp b/src/InputOutput.cpp index 0265220..8d60061 100644 --- a/src/InputOutput.cpp +++ b/src/InputOutput.cpp @@ -15,12 +15,11 @@ uint8_t EightBit::InputOutput::peek(uint16_t) const { uint8_t& EightBit::InputOutput::reference(uint16_t address) { const auto port = register16_t(address).low; - switch (getAccessType()) { + switch (accessType()) { case AccessType::Reading: return m_input.reference(port); case AccessType::Writing: return m_output.reference(port); - case AccessType::Unknown: default: throw std::logic_error("Unknown I/O access type."); }