mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-11-09 13:07:15 +00:00
d70f6b375b
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
40 lines
905 B
C++
40 lines
905 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <array>
|
|
|
|
#include "Signal.h"
|
|
|
|
namespace EightBit {
|
|
class InputOutput {
|
|
public:
|
|
InputOutput() = default;
|
|
|
|
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);
|
|
void writeInputPort(uint8_t port, uint8_t value) { m_input[port] = value; }
|
|
|
|
uint8_t readOutputPort(uint8_t port) { 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;
|
|
std::array<uint8_t, 0x100> m_output;
|
|
};
|
|
}
|