Correct a couple of small oddities in the IntelProcessor InputOutput class.

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2020-12-27 15:46:05 +00:00
parent 778aacaef6
commit 5ddbd8a5e8
3 changed files with 13 additions and 14 deletions

View File

@ -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,

View File

@ -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<uint8_t>& 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;

View File

@ -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.");
}