2019-03-01 05:21:18 +00:00
|
|
|
import Prefs from './prefs';
|
|
|
|
|
2019-12-27 23:04:07 +00:00
|
|
|
import { driveLights, initUI, updateUI } from './ui/apple2';
|
2019-03-01 05:21:18 +00:00
|
|
|
import Printer from './ui/printer';
|
2021-12-29 23:00:44 +00:00
|
|
|
import { MouseUI } from './ui/mouse';
|
2019-03-01 05:21:18 +00:00
|
|
|
|
2019-12-27 23:04:07 +00:00
|
|
|
import DiskII from './cards/disk2';
|
2019-03-01 05:21:18 +00:00
|
|
|
import Parallel from './cards/parallel';
|
|
|
|
import RAMFactor from './cards/ramfactor';
|
2020-09-13 02:42:18 +00:00
|
|
|
import SmartPort from './cards/smartport';
|
2019-03-01 05:21:18 +00:00
|
|
|
import Thunderclock from './cards/thunderclock';
|
2021-12-29 23:00:44 +00:00
|
|
|
import Mouse from './cards/mouse';
|
2019-03-01 05:21:18 +00:00
|
|
|
|
2019-12-27 23:04:07 +00:00
|
|
|
import { Apple2 } from './apple2';
|
2019-02-19 04:42:50 +00:00
|
|
|
|
2021-04-24 22:55:21 +00:00
|
|
|
const prefs = new Prefs();
|
|
|
|
const romVersion = prefs.readPref('computer_type2e');
|
|
|
|
let enhanced = false;
|
2021-06-14 00:06:16 +00:00
|
|
|
let rom: string;
|
|
|
|
let characterRom: string;
|
2019-12-27 23:04:07 +00:00
|
|
|
|
2017-09-23 04:42:57 +00:00
|
|
|
switch (romVersion) {
|
2020-11-26 01:28:37 +00:00
|
|
|
case 'apple2e':
|
2021-06-14 00:06:16 +00:00
|
|
|
rom = 'apple2e';
|
|
|
|
characterRom = 'apple2e_char';
|
2020-11-26 01:28:37 +00:00
|
|
|
break;
|
|
|
|
case 'apple2rm':
|
2021-06-14 00:06:16 +00:00
|
|
|
rom = 'apple2e';
|
|
|
|
characterRom = 'rmfont_char';
|
2021-07-17 23:23:49 +00:00
|
|
|
enhanced = true;
|
|
|
|
break;
|
|
|
|
case 'apple2ex':
|
|
|
|
rom = 'apple2ex';
|
|
|
|
characterRom = 'apple2enh_char';
|
2020-11-26 01:28:37 +00:00
|
|
|
enhanced = true;
|
|
|
|
break;
|
|
|
|
default:
|
2021-06-14 00:06:16 +00:00
|
|
|
rom = 'apple2enh';
|
|
|
|
characterRom = 'apple2enh_char';
|
2020-11-26 01:28:37 +00:00
|
|
|
enhanced = true;
|
2017-09-23 04:42:57 +00:00
|
|
|
}
|
|
|
|
|
2021-04-24 22:55:21 +00:00
|
|
|
const options = {
|
2021-04-21 01:03:18 +00:00
|
|
|
gl: prefs.readPref('gl_canvas', 'true') === 'true',
|
2021-04-24 22:55:21 +00:00
|
|
|
canvas: document.querySelector<HTMLCanvasElement>('#screen')!,
|
|
|
|
rom,
|
|
|
|
characterRom,
|
2019-12-27 23:04:07 +00:00
|
|
|
e: true,
|
2021-04-24 22:55:21 +00:00
|
|
|
enhanced,
|
2019-12-27 23:04:07 +00:00
|
|
|
tick: updateUI
|
|
|
|
};
|
2017-09-23 04:42:57 +00:00
|
|
|
|
2021-04-24 22:55:21 +00:00
|
|
|
export const apple2 = new Apple2(options);
|
2021-06-14 00:06:16 +00:00
|
|
|
apple2.ready.then(() => {
|
|
|
|
const io = apple2.getIO();
|
|
|
|
const cpu = apple2.getCPU();
|
2016-11-22 05:17:34 +00:00
|
|
|
|
2021-06-14 00:06:16 +00:00
|
|
|
const printer = new Printer('#printer-modal .paper');
|
2021-12-29 23:00:44 +00:00
|
|
|
const mouseUI = new MouseUI('#screen');
|
2016-11-22 05:17:34 +00:00
|
|
|
|
2021-06-14 00:06:16 +00:00
|
|
|
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 });
|
2021-12-29 23:00:44 +00:00
|
|
|
const mouse = new Mouse(cpu, mouseUI);
|
2016-11-22 05:17:34 +00:00
|
|
|
|
2021-06-14 00:06:16 +00:00
|
|
|
io.setSlot(1, parallel);
|
|
|
|
io.setSlot(2, slinky);
|
2021-12-29 23:00:44 +00:00
|
|
|
io.setSlot(4, mouse);
|
2021-06-14 00:06:16 +00:00
|
|
|
io.setSlot(5, clock);
|
|
|
|
io.setSlot(6, disk2);
|
|
|
|
io.setSlot(7, smartport);
|
2016-11-22 05:17:34 +00:00
|
|
|
|
2021-06-14 00:06:16 +00:00
|
|
|
initUI(apple2, disk2, smartport, printer, options.e);
|
|
|
|
}).catch(console.error);
|