2017-06-04 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2017-09-01 15:41:50 +00:00
|
|
|
#include <array>
|
|
|
|
|
2017-06-04 20:38:34 +00:00
|
|
|
#include "Signal.h"
|
|
|
|
|
|
|
|
namespace EightBit {
|
2018-04-14 08:39:06 +00:00
|
|
|
class InputOutput final {
|
2017-06-04 20:38:34 +00:00
|
|
|
public:
|
2017-11-11 15:13:26 +00:00
|
|
|
InputOutput() = default;
|
|
|
|
|
2018-10-27 16:30:23 +00:00
|
|
|
auto read(const uint8_t port) { return readInputPort(port); }
|
2018-04-14 08:39:06 +00:00
|
|
|
void write(const uint8_t port, const uint8_t value) { return writeOutputPort(port, value); }
|
2017-06-04 20:38:34 +00:00
|
|
|
|
|
|
|
uint8_t readInputPort(uint8_t port);
|
2018-04-14 08:39:06 +00:00
|
|
|
void writeInputPort(const uint8_t port, const uint8_t value) { m_input[port] = value; }
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2018-10-27 16:30:23 +00:00
|
|
|
auto readOutputPort(const uint8_t port) { return m_output[port]; }
|
2017-06-04 20:38:34 +00:00
|
|
|
void writeOutputPort(uint8_t port, uint8_t value);
|
|
|
|
|
2017-10-22 20:31:20 +00:00
|
|
|
Signal<uint8_t> ReadingPort;
|
|
|
|
Signal<uint8_t> ReadPort;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-10-22 20:31:20 +00:00
|
|
|
Signal<uint8_t> WritingPort;
|
|
|
|
Signal<uint8_t> WrittenPort;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void OnReadingPort(uint8_t port);
|
|
|
|
void OnReadPort(uint8_t port);
|
|
|
|
|
|
|
|
void OnWritingPort(uint8_t port);
|
|
|
|
void OnWrittenPort(uint8_t port);
|
|
|
|
|
|
|
|
private:
|
2018-08-11 20:19:19 +00:00
|
|
|
std::array<uint8_t, 0x100> m_input = { 0 };
|
|
|
|
std::array<uint8_t, 0x100> m_output = { 0 };
|
2017-06-04 20:38:34 +00:00
|
|
|
};
|
2017-11-30 23:19:17 +00:00
|
|
|
}
|