2019-03-01 05:21:18 +00:00
|
|
|
import { debug } from '../util';
|
2021-03-15 19:51:40 +00:00
|
|
|
import { Card, Restorable, byte } from '../types';
|
2019-11-25 00:52:01 +00:00
|
|
|
import { rom } from '../roms/cards/parallel';
|
2016-11-22 05:17:34 +00:00
|
|
|
|
2021-03-15 19:51:40 +00:00
|
|
|
const LOC = {
|
|
|
|
IOREG: 0x80
|
|
|
|
} as const;
|
2013-10-10 18:03:07 +00:00
|
|
|
|
2021-03-15 19:51:40 +00:00
|
|
|
export interface ParallelState {}
|
|
|
|
export interface ParallelOptions {
|
|
|
|
putChar: (val: byte) => void;
|
|
|
|
}
|
2016-11-28 01:28:49 +00:00
|
|
|
|
2021-03-15 19:51:40 +00:00
|
|
|
export default class Parallel implements Card, Restorable<ParallelState> {
|
|
|
|
constructor(private cbs: ParallelOptions) {
|
|
|
|
debug('Parallel card');
|
|
|
|
}
|
2013-10-10 18:03:07 +00:00
|
|
|
|
2021-03-15 19:51:40 +00:00
|
|
|
private access(off: byte, val?: byte) {
|
2019-02-19 04:42:50 +00:00
|
|
|
switch (off & 0x8f) {
|
2020-11-26 01:28:37 +00:00
|
|
|
case LOC.IOREG:
|
2021-03-15 19:51:40 +00:00
|
|
|
if (this.cbs.putChar && val) {
|
|
|
|
this.cbs.putChar(val);
|
2020-11-26 01:28:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug('Parallel card unknown softswitch', off);
|
2016-11-28 01:28:49 +00:00
|
|
|
}
|
2021-03-15 19:51:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ioSwitch(off: byte, val?: byte) {
|
|
|
|
return this.access(off, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
read(_page: byte, off: byte) {
|
|
|
|
return rom[off];
|
|
|
|
}
|
|
|
|
|
|
|
|
write() {}
|
|
|
|
|
|
|
|
getState() {
|
|
|
|
return {};
|
2016-11-28 01:28:49 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 19:51:40 +00:00
|
|
|
setState(_state: ParallelState) {}
|
2013-10-10 18:03:07 +00:00
|
|
|
}
|