apple2js/js/main2e.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

78 lines
2.1 KiB
TypeScript

import Prefs from './prefs';
import { driveLights, initUI, updateUI } from './ui/apple2';
import Printer from './ui/printer';
import { MouseUI } from './ui/mouse';
import DiskII from './cards/disk2';
import Parallel from './cards/parallel';
import RAMFactor from './cards/ramfactor';
import SmartPort from './cards/smartport';
import Thunderclock from './cards/thunderclock';
import Mouse from './cards/mouse';
import { Apple2 } from './apple2';
const prefs = new Prefs();
const romVersion = prefs.readPref('computer_type2e');
let enhanced = false;
let rom: string;
let characterRom: string;
switch (romVersion) {
case 'apple2e':
rom = 'apple2e';
characterRom = 'apple2e_char';
break;
case 'apple2rm':
rom = 'apple2e';
characterRom = 'rmfont_char';
enhanced = true;
break;
case 'apple2ex':
rom = 'apple2ex';
characterRom = 'apple2enh_char';
enhanced = true;
break;
default:
rom = 'apple2enh';
characterRom = 'apple2enh_char';
enhanced = true;
}
const options = {
gl: prefs.readPref('gl_canvas', 'true') === 'true',
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
canvas: document.querySelector<HTMLCanvasElement>('#screen')!,
rom,
characterRom,
e: true,
enhanced,
tick: updateUI
};
export const apple2 = new Apple2(options);
apple2.ready.then(() => {
const io = apple2.getIO();
const cpu = apple2.getCPU();
const printer = new Printer('#printer-modal .paper');
const mouseUI = new MouseUI(options.canvas);
const parallel = new Parallel(printer);
const slinky = new RAMFactor(1024 * 1024);
const disk2 = new DiskII(io, driveLights);
const clock = new Thunderclock();
const smartport = new SmartPort(cpu, { block: !enhanced });
const mouse = new Mouse(cpu, mouseUI);
io.setSlot(1, parallel);
io.setSlot(2, slinky);
io.setSlot(4, mouse);
io.setSlot(5, clock);
io.setSlot(6, disk2);
io.setSlot(7, smartport);
initUI(apple2, disk2, smartport, printer, options.e);
}).catch(console.error);