-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.cpp
44 lines (40 loc) · 741 Bytes
/
io.cpp
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
42
43
44
#include <stdint.h>
#include <stddef.h>
#include <memory.h>
#include <CPU.h>
#include <ports.h>
#include <i8080.h>
#include <display.h>
#include "kbd.h"
#include "io.h"
void IO::reset() {
dsk_reset();
_kbd.reset();
scr_reset();
}
uint8_t IO::in(uint16_t port, i8080 *cpu) {
uint8_t c = 0;
port &= 0xff;
if (port == 4)
c = _kbd.read();
else if (port == 2)
c = _kbd.avail();
else if (port == 14)
c = dsk_read();
else if (port == 15)
c = dsk_write();
return c;
}
void IO::out(uint16_t port, uint8_t a, i8080 *cpu) {
port &= 0xff;
if (port == 4)
scr_display(a);
else if (port == 20)
dsk_select(a);
else if (port == 21)
settrk = a;
else if (port == 22)
setsec = a;
else if (port == 23)
setdma = cpu->hl();
}