EightBit/inc/InputOutput.h
Adrian Conlon 382ae30d32 Correct a couple of minor mistakes found while working on the .net port.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2019-02-03 00:46:49 +00:00

40 lines
1010 B
C++

#pragma once
#include <cstdint>
#include <array>
#include "Signal.h"
namespace EightBit {
class InputOutput final {
public:
InputOutput() = default;
[[nodiscard]] auto read(const uint8_t port) { return readInputPort(port); }
void write(const uint8_t port, const uint8_t value) { writeOutputPort(port, value); }
[[nodiscard]] uint8_t readInputPort(uint8_t port);
void writeInputPort(const uint8_t port, const uint8_t value) noexcept { m_input[port] = value; }
[[nodiscard]] auto readOutputPort(const uint8_t port) noexcept { return m_output[port]; }
void writeOutputPort(uint8_t port, uint8_t value);
Signal<uint8_t> ReadingPort;
Signal<uint8_t> ReadPort;
Signal<uint8_t> WritingPort;
Signal<uint8_t> WrittenPort;
protected:
void OnReadingPort(uint8_t port);
void OnReadPort(uint8_t port);
void OnWritingPort(uint8_t port);
void OnWrittenPort(uint8_t port);
private:
std::array<uint8_t, 0x100> m_input = { 0 };
std::array<uint8_t, 0x100> m_output = { 0 };
};
}