apple2js/js/cards/parallel.ts
Ian Flanigan 04ae0327c2
Add the recommended eslint plugins for TypeScript (#121)
This adds both the recommended TypeScript checks, plus the recommended
TypeScript checks that require type checking.  This latter addition
means that eslint essentially has to compile all of the TypeScript in
the project, causing it to be slower. This isn't much of a problem in
VS Code because there's a lot of caching being done, but it's clearly
slower when run on the commandline.

All of the errors are either fixed or suppressed.  Some errors are
suppressed because fixing them would be too laborious for the little
value gained.

The eslint config is also slightly refactored to separate the strictly
TypeScript checks from the JavaScript checks.
2022-05-31 08:38:40 -07:00

52 lines
1.1 KiB
TypeScript

import { debug } from '../util';
import { Card, Restorable, byte } from '../types';
import { rom } from '../roms/cards/parallel';
const LOC = {
IOREG: 0x80
} as const;
export interface ParallelState {}
export interface ParallelOptions {
putChar: (val: byte) => void;
}
export default class Parallel implements Card, Restorable<ParallelState> {
constructor(private cbs: ParallelOptions) {
debug('Parallel card');
}
private access(off: byte, val?: byte) {
switch (off & 0x8f) {
case LOC.IOREG:
if (this.cbs.putChar && val) {
this.cbs.putChar(val);
}
break;
default:
debug('Parallel card unknown softswitch', off);
}
return 0;
}
ioSwitch(off: byte, val?: byte) {
return this.access(off, val);
}
read(_page: byte, off: byte) {
return rom[off];
}
write() {
// not writable
}
getState() {
return {};
}
setState(_state: ParallelState) {
// can't set the state
}
}