1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* SPDX-License-Identifier: Unlicense
*/
#pragma once
#include "bus.hpp"
class IO {
public:
constexpr IO(const uint32_t base_address_a): base_address(base_address_a) {}
uint32_t Read(uint32_t offset, enum bitness);
void Write(uint32_t offset, enum bitness, uint32_t value);
const uint32_t base_address;
constexpr static uint32_t kData1Offset = 0x3;
constexpr static uint32_t kData2Offset = 0x5;
constexpr static uint32_t kData3Offset = 0x7;
constexpr static uint32_t kControl1Offset = 0x9;
constexpr static uint32_t kControl2Offset = 0xb;
constexpr static uint32_t kControl3Offset = 0xd;
constexpr static uint32_t kTx1Offset = 0xf;
constexpr static uint32_t kRx1Offset = 0x11;
constexpr static uint32_t kStatus1Offset = 0x13;
constexpr static uint32_t kTx2Offset = 0x15;
constexpr static uint32_t kRx2Offset = 0x17;
constexpr static uint32_t kStatus2Offset = 0x19;
constexpr static uint32_t kTx3Offset = 0x1b;
constexpr static uint32_t kRx3Offset = 0x1d;
constexpr static uint32_t kStatus3Offset = 0x1f;
constexpr static uint32_t kZ80BusReq = 0x1100;
constexpr static uint32_t kZ80Reset = 0x1200;
private:
uint32_t read(uint32_t offset);
void write(uint32_t offset, uint8_t value);
uint8_t _control1{}, _control2{}, _control3{};
uint8_t _data1{}, _data2{}, _data3{};
uint8_t _tx1{}, _rx1{}, _status1{};
uint8_t _tx2{}, _rx2{}, _status2{};
uint8_t _tx3{}, _rx3{}, _status3{};
bool _z80_reset{};
bool _z80_busreq{};
};
|