apple2js/js/main2.ts

90 lines
2.3 KiB
TypeScript
Raw Normal View History

2019-03-01 05:21:18 +00:00
import Prefs from './prefs';
import { driveLights, initUI, updateUI } from './ui/apple2';
2019-03-01 05:21:18 +00:00
import Printer from './ui/printer';
import DiskII from './cards/disk2';
2019-03-01 05:21:18 +00:00
import LanguageCard from './cards/langcard';
import Parallel from './cards/parallel';
import RAMFactor from './cards/ramfactor';
import SmartPort from './cards/smartport';
2019-03-01 05:21:18 +00:00
import Thunderclock from './cards/thunderclock';
import VideoTerm from './cards/videoterm';
2019-03-01 05:21:18 +00:00
import { Apple2 } from './apple2';
2016-11-22 05:17:34 +00:00
2021-04-24 22:55:21 +00:00
const prefs = new Prefs();
const romVersion = prefs.readPref('computer_type2');
let rom: string;
let characterRom: string;
2021-04-24 22:55:21 +00:00
let sectors = 16;
2017-09-23 04:42:57 +00:00
switch (romVersion) {
case 'apple2':
rom = 'intbasic';
characterRom = 'apple2_char';
break;
case 'apple213':
rom = 'intbasic';
characterRom = 'apple2_char';
sectors = 13;
break;
case 'original':
rom = 'original';
characterRom = 'apple2_char';
break;
case 'apple2jplus':
rom = 'apple2j';
characterRom = 'apple2j_char';
break;
case 'apple2pig':
rom = 'fpbasic';
characterRom = 'pigfont_char';
break;
case 'apple2lc':
rom = 'fpbasic';
characterRom = 'apple2lc_char';
break;
default:
rom = 'fpbasic';
characterRom = 'apple2_char';
2016-11-28 01:28:49 +00:00
}
2021-04-24 22:55:21 +00:00
const options = {
canvas: document.querySelector<HTMLCanvasElement>('#screen')!,
gl: prefs.readPref('gl_canvas', 'true') === 'true',
2021-04-24 22:55:21 +00:00
rom,
characterRom,
e: false,
enhanced: false,
tick: updateUI
};
2021-04-24 22:55:21 +00:00
export const apple2 = new Apple2(options);
apple2.ready.then(() => {
const cpu = apple2.getCPU();
const io = apple2.getIO();
2017-09-23 04:42:57 +00:00
const printer = new Printer('#printer-modal .paper');
const lc = new LanguageCard(apple2.getROM());
const parallel = new Parallel(printer);
const videoTerm = new VideoTerm();
const slinky = new RAMFactor(1024 * 1024);
const disk2 = new DiskII(io, driveLights, sectors);
const clock = new Thunderclock();
const smartport = new SmartPort(cpu, { block: true });
2016-11-28 01:28:49 +00:00
io.setSlot(0, lc);
io.setSlot(1, parallel);
io.setSlot(2, slinky);
io.setSlot(4, clock);
io.setSlot(3, videoTerm);
io.setSlot(6, disk2);
io.setSlot(7, smartport);
2016-11-22 05:17:34 +00:00
cpu.addPageHandler(lc);
2021-04-24 22:55:21 +00:00
initUI(apple2, disk2, smartport, printer, false);
}).catch(console.error);