apple2js/js/main2e.js

94 lines
2.4 KiB
JavaScript
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 Parallel from './cards/parallel';
import RAMFactor from './cards/ramfactor';
import Thunderclock from './cards/thunderclock';
import apple2e_charset from './roms/apple2e_char';
import apple2enh_charset from './roms/apple2enh_char';
2019-03-01 18:15:17 +00:00
import rmfont_charset from './roms/rmfont_char';
2019-03-01 05:21:18 +00:00
import Apple2eROM from './roms/apple2e';
import Apple2eEnhancedROM from './roms/apple2enh';
import { Apple2 } from './apple2';
export * from './ui/apple2';
2016-11-22 05:17:34 +00:00
var prefs = new Prefs();
2017-09-23 04:42:57 +00:00
var romVersion = prefs.readPref('computer_type2e');
var enhanced = false;
var rom;
var characterRom = apple2e_charset;
2017-09-23 04:42:57 +00:00
switch (romVersion) {
case 'apple2e':
rom = new Apple2eROM();
break;
case 'apple2rm':
rom = new Apple2eEnhancedROM();
characterRom = rmfont_charset;
2017-09-23 04:42:57 +00:00
enhanced = true;
break;
default:
rom = new Apple2eEnhancedROM();
characterRom = apple2enh_charset;
2017-09-23 04:42:57 +00:00
enhanced = true;
}
var options = {
screen: [],
multiScreen: false,
rom: rom,
characterRom: characterRom,
e: true,
enhanced: enhanced,
cards: [],
tick: updateUI
};
2017-09-23 04:42:57 +00:00
var canvas1 = document.getElementById('screen');
var canvas2 = document.getElementById('screen2');
var canvas3 = document.getElementById('screen3');
var canvas4 = document.getElementById('screen4');
options.screen[0] = canvas1.getContext('2d');
2017-09-23 04:42:57 +00:00
if (canvas4) {
options.multiScreen = true;
options.screen[1] = canvas2.getContext('2d');
options.screen[2] = canvas3.getContext('2d');
options.screen[3] = canvas4.getContext('2d');
2017-09-23 04:42:57 +00:00
} else if (canvas2) {
options.multiScreen = true;
options.screen[1] = options.screen[0];
options.screen[2] = canvas2.getContext('2d');
options.screen[3] = options.screen[2];
2016-11-22 05:17:34 +00:00
} else {
options.screen[1] = options.screen[0];
options.screen[2] = options.screen[0];
options.screen[3] = options.screen[0];
2016-11-22 05:17:34 +00:00
}
2016-11-28 01:28:49 +00:00
var apple2 = new Apple2(options);
var io = apple2.getIO();
2016-11-22 05:17:34 +00:00
var printer = new Printer('#printer-modal .paper');
2016-11-22 05:17:34 +00:00
var parallel = new Parallel(io, printer);
var slinky = new RAMFactor(io, 1024 * 1024);
var disk2 = new DiskII(io, driveLights);
var clock = new Thunderclock(io);
2016-11-22 05:17:34 +00:00
2020-01-02 18:57:26 +00:00
initUI(apple2, disk2, options.e);
2016-11-22 05:17:34 +00:00
2016-12-06 05:16:21 +00:00
io.setSlot(1, parallel);
io.setSlot(2, slinky);
io.setSlot(4, clock);
2016-12-06 05:16:21 +00:00
io.setSlot(6, disk2);
2016-11-22 05:17:34 +00:00