-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlp11.cpp
62 lines (57 loc) · 1.2 KB
/
lp11.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <cstdlib>
#include <fcntl.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <Arduino.h>
#include "kb11.h"
#include "lp11.h"
extern KB11 cpu;
void LP11::poll() {
if (!(lps & 0x80)) {
if (++count > 3000) {
fputc(lpb & 0x7f, stdout);
lps |= 0x80;
if (lps & (1 << 6)) {
cpu.interrupt(0200, 4);
}
}
}
}
uint16_t LP11::read16(uint32_t a) {
switch (a) {
case 0777514:
return lps;
case 0777516:
return 0; // lpb cannot be read
default:
Serial.printf("lp11: read from invalid address %06o\n", a);
std::abort();
}
}
void LP11::write16(uint32_t a, uint16_t v) {
switch (a) {
case 0777514:
if (v & (1 << 6)) {
lps |= 1 << 6;
} else {
lps &= ~(1 << 6);
}
if (lps & (1 << 6)) {
cpu.interrupt(0200, 4);
}
break;
case 0777516:
lpb = v & 0x7f;
lps &= 0xff7f;
count = 0;
break;
default:
Serial.printf("lp11: write to invalid address %06o\n", a);
std::abort();
}
}
void LP11::reset() {
lps = 0x80;
lpb = 0;
}