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 {
|
|
|
|
class InputOutput {
|
|
|
|
public:
|
2017-11-11 15:13:26 +00:00
|
|
|
InputOutput() = default;
|
|
|
|
|
2017-06-04 20:38:34 +00:00
|
|
|
uint8_t read(uint8_t port) { return readInputPort(port); }
|
|
|
|
void write(uint8_t port, uint8_t value) { return writeOutputPort(port, value); }
|
|
|
|
|
|
|
|
uint8_t readInputPort(uint8_t port);
|
2017-11-03 22:05:01 +00:00
|
|
|
void writeInputPort(uint8_t port, uint8_t value) { m_input[port] = value; }
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-11-03 22:05:01 +00:00
|
|
|
uint8_t readOutputPort(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:
|
2017-11-03 22:05:01 +00:00
|
|
|
std::array<uint8_t, 0x100> m_input;
|
|
|
|
std::array<uint8_t, 0x100> m_output;
|
2017-06-04 20:38:34 +00:00
|
|
|
};
|
|
|
|
}
|