Convert to webpack first pass.

This commit is contained in:
Will Scullin 2019-02-28 21:21:18 -08:00
parent b8261252e3
commit 573f36510d
No known key found for this signature in database
GPG Key ID: 9092A5C0A673416B
42 changed files with 4743 additions and 375 deletions

View File

@ -20,7 +20,11 @@
"env": { "env": {
"builtin": true, "builtin": true,
"browser": true, "browser": true,
"jquery": true "jquery": true,
"es6": true
},
"parserOptions": {
"sourceType": "module"
}, },
"extends": "eslint:recommended" "extends": "eslint:recommended"
} }

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
.*~ .*~
.checked-*.js .checked-*.js
node_modules /dist
/node_modules

View File

@ -44,32 +44,6 @@
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">
</script> </script>
<!-- Emulator Scripts -->
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/prefs.js"></script>
<script type="text/javascript" src="js/ram.js"></script>
<script type="text/javascript" src="js/applesoft/decompiler.js"></script>
<script type="text/javascript" src="js/intbasic/decompiler.js"></script>
<script type="text/javascript" src="js/canvas.js"></script>
<script type="text/javascript" src="js/apple2io.js"></script>
<script type="text/javascript" src="js/cards/langcard.js"></script>
<script type="text/javascript" src="js/cards/parallel.js"></script>
<script type="text/javascript" src="js/cards/videoterm.js"></script>
<script type="text/javascript" src="js/cards/disk2.js"></script>
<script type="text/javascript" src="js/cards/ramfactor.js"></script>
<script type="text/javascript" src="js/cards/thunderclock.js"></script>
<script type="text/javascript" src="js/cpu6502.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
<script type="text/javascript" src="js/roms/fpbasic.js"></script>
<script type="text/javascript" src="js/roms/intbasic.js"></script>
<script type="text/javascript" src="js/roms/original.js"></script>
<script type="text/javascript" src="js/roms/apple2_char.js"></script>
<script type="text/javascript" src="js/ui/audio.js"></script>
<script type="text/javascript" src="js/ui/keyboard.js"></script>
<script type="text/javascript" src="js/ui/gamepad.js"></script>
<script type="text/javascript" src="js/ui/printer.js"></script>
<script type="text/javascript" src="js/ui/tape.js"></script>
<!-- Disk Index --> <!-- Disk Index -->
<script type="text/javascript" src="json/disks/index.js"></script> <script type="text/javascript" src="json/disks/index.js"></script>
@ -310,6 +284,6 @@
<div class="paper"> <div class="paper">
</div> </div>
</div> </div>
<script src="js/main2.js"></script> <script src="dist/main2.js"></script>
</body> </body>
</html> </html>

View File

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2010-2016 Will Scullin <scullin@scullinsteel.com> Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
Permission to use, copy, modify, distribute, and sell this software and its Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that documentation for any purpose is hereby granted without fee, provided that
@ -44,31 +44,6 @@
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">
</script> </script>
<!-- Emulator Scripts -->
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/prefs.js"></script>
<script type="text/javascript" src="js/ram.js"></script>
<script type="text/javascript" src="js/mmu.js"></script>
<script type="text/javascript" src="js/applesoft/decompiler.js"></script>
<script type="text/javascript" src="js/intbasic/decompiler.js"></script>
<script type="text/javascript" src="js/canvas.js"></script>
<script type="text/javascript" src="js/apple2io.js"></script>
<script type="text/javascript" src="js/cards/parallel.js"></script>
<script type="text/javascript" src="js/cards/disk2.js"></script>
<script type="text/javascript" src="js/cards/ramfactor.js"></script>
<script type="text/javascript" src="js/cards/thunderclock.js"></script>
<script type="text/javascript" src="js/cpu6502.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
<script type="text/javascript" src="js/roms/apple2e.js"></script>
<script type="text/javascript" src="js/roms/apple2enh.js"></script>
<script type="text/javascript" src="js/roms/apple2e_char.js"></script>
<script type="text/javascript" src="js/roms/apple2enh_char.js"></script>
<script type="text/javascript" src="js/ui/audio.js"></script>
<script type="text/javascript" src="js/ui/keyboard.js"></script>
<script type="text/javascript" src="js/ui/gamepad.js"></script>
<script type="text/javascript" src="js/ui/printer.js"></script>
<script type="text/javascript" src="js/ui/tape.js"></script>
<!-- Disk Index --> <!-- Disk Index -->
<script type="text/javascript" src="json/disks/index.js"></script> <script type="text/javascript" src="json/disks/index.js"></script>
@ -287,6 +262,6 @@
<div class="paper"> <div class="paper">
</div> </div>
</div> </div>
<script src="js/main2e.js"></script> <script type="text/javascript" src="dist/main2e.js"></script>
</body> </body>
</html> </html>

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2016 Will Scullin */ /* Copyright 2010-2019 Will Scullin */
#header { #header {
width: 580px; width: 580px;

View File

@ -4,7 +4,7 @@
var LOG = false; var LOG = false;
function Test6502() { export default function Test6502() {
var data = [ var data = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

View File

@ -5,7 +5,7 @@
var LOG = false; var LOG = false;
function Test65C02() { export default function Test65C02() {
var data = [ var data = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,13 +9,10 @@
* implied warranty. * implied warranty.
*/ */
/*globals debug: false */ import { debug } from './util';
/*exported Apple2IO */
function Apple2IO(cpu, callbacks) export default function Apple2IO(cpu, callbacks)
{ {
'use strict';
var _slot = []; var _slot = [];
var _auxRom = null; var _auxRom = null;

View File

@ -1,7 +1,6 @@
/*exported ApplesoftDump */ import { debug } from '../util';
/*global debug */
function ApplesoftDump(mem) export default function ApplesoftDump(mem)
{ {
var _mem = mem; var _mem = mem;

View File

@ -1,6 +1,6 @@
/*exported base64_encode, base64_decode */ /*exported base64_encode, base64_decode */
function base64_encode (data) { export function base64_encode (data) {
// Twacked by Will Scullin to handle arrays of "bytes" // Twacked by Will Scullin to handle arrays of "bytes"
// http://kevin.vanzonneveld.net // http://kevin.vanzonneveld.net
@ -57,7 +57,7 @@ function base64_encode (data) {
return enc; return enc;
} }
function base64_decode(data) { export function base64_decode(data) {
// Twacked by Will Scullin to handle arrays of "bytes" // Twacked by Will Scullin to handle arrays of "bytes"
// http://kevin.vanzonneveld.net // http://kevin.vanzonneveld.net

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,11 +9,10 @@
* implied warranty. * implied warranty.
*/ */
/*globals allocMemPages: false, debug: false, import { base64_decode, base64_encode } from './base64';
base64_encode: false, base64_decode: false, import { allocMemPages, debug } from './util';
enhanced: false */
/*exported LoresPage, HiresPage, VideoModes, scanlines, multiScreen */
var enhanced = false;
var multiScreen = false; var multiScreen = false;
var textMode = true; var textMode = true;
var mixedMode = false; var mixedMode = false;
@ -52,7 +51,7 @@ var blackCol = [0x00, 0x00, 0x00];
* *
***************************************************************************/ ***************************************************************************/
function LoresPage(page, charset, e, context) export function LoresPage(page, charset, e, context)
{ {
'use strict'; 'use strict';
@ -479,7 +478,7 @@ function LoresPage(page, charset, e, context)
* *
***************************************************************************/ ***************************************************************************/
function HiresPage(page, context) export function HiresPage(page, context)
{ {
'use strict'; 'use strict';
@ -912,7 +911,7 @@ function HiresPage(page, context)
}; };
} }
function VideoModes(gr, hgr, gr2, hgr2, e) { export function VideoModes(gr, hgr, gr2, hgr2, e) {
var _grs = [gr, gr2]; var _grs = [gr, gr2];
var _hgrs = [hgr, hgr2]; var _hgrs = [hgr, hgr2];
var _seq = ''; var _seq = '';
@ -1052,6 +1051,12 @@ function VideoModes(gr, hgr, gr2, hgr2, e) {
_refresh(); _refresh();
} }
}, },
enhanced: function(on) {
enhanced = on;
},
multiScreen: function(on) {
multiScreen = on;
},
isText: function() { isText: function() {
return textMode; return textMode;
}, },

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,16 +9,11 @@
* implied warranty. * implied warranty.
*/ */
/*exported DiskII */ import { base64_decode, base64_encode } from '../base64';
/*globals bytify: false, debug: false import { bytify, debug } from '../util';
base64_decode: false, base64_encode: false
Uint8Array: false
*/
function DiskII(io, slot, callbacks) export default function DiskII(io, slot, callbacks)
{ {
'use strict';
slot = slot || 6; slot = slot || 6;
var _drives = [ var _drives = [
{ // Drive 1 { // Drive 1
@ -791,6 +786,22 @@ function DiskII(io, slot, callbacks)
var s = _drives[disk - 1].fmt == 'po' ? _PO[sector] : _DO[sector]; var s = _drives[disk - 1].fmt == 'po' ? _PO[sector] : _DO[sector];
return _readSector(disk, track, s); return _readSector(disk, track, s);
}, },
getMetadata: function disk_getMetadata(driveNo) {
var drive = _drives[driveNo - 1];
if (drive.tracks.length) {
return {
format: drive.format,
volume: drive.volume,
track: drive.track,
head: drive.head,
phase: drive.phase,
readOnly: drive.readOnly,
dirty: drive.dirty
};
} else {
return null;
}
},
setDisk: function disk2_setDisk(drive, disk) { setDisk: function disk2_setDisk(drive, disk) {
var fmt = disk.type, readOnly = disk.readOnly; var fmt = disk.type, readOnly = disk.readOnly;

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,13 +9,10 @@
* implied warranty. * implied warranty.
*/ */
/*exported LanguageCard */ import RAM from '../ram';
/*globals debug: false import { debug } from '../util';
RAM: false */
function LanguageCard(io, slot, rom) {
'use strict';
export default function LanguageCard(io, slot, rom) {
var _rom = rom; var _rom = rom;
var _bank1 = null; var _bank1 = null;
var _bank2 = null; var _bank2 = null;

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,12 +9,9 @@
* implied warranty. * implied warranty.
*/ */
/*exported Parallel */ import { debug } from '../util';
/*globals debug: false */
function Parallel(io, slot, cbs) {
'use strict';
export default function Parallel(io, slot, cbs) {
slot = slot || 1; slot = slot || 1;
debug('Parallel card in slot', slot); debug('Parallel card in slot', slot);

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,13 +9,10 @@
* implied warranty. * implied warranty.
*/ */
/*exported RAMFactor */ import { base64_decode, base64_encode } from '../base64';
/*globals allocMem: false, bytify: false, debug: false, import { allocMem, bytify, debug } from '../util';
base64_encode: false, base64_decode: false
*/
function RAMFactor(io, slot, size) {
'use strict';
export default function RAMFactor(io, slot, size) {
var rom = [ var rom = [
0x43,0x4f,0x50,0x59,0x52,0x49,0x47,0x48, 0x43,0x4f,0x50,0x59,0x52,0x49,0x47,0x48,
0x54,0x20,0x28,0x43,0x29,0x20,0x31,0x39, 0x54,0x20,0x28,0x43,0x29,0x20,0x31,0x39,

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,13 +9,10 @@
* implied warranty. * implied warranty.
*/ */
/*exported Thunderclock */ import { debug } from '../util';
/*global debug: false */
function Thunderclock(io, slot) export default function Thunderclock(io, slot)
{ {
'use strict';
var rom = [ var rom = [
0x08,0x78,0x28,0x2c,0x58,0xff,0x70,0x05, // 00 0x08,0x78,0x28,0x2c,0x58,0xff,0x70,0x05, // 00
0x38,0xb0,0x01,0x18,0xb8,0x08,0x78,0x48, 0x38,0xb0,0x01,0x18,0xb8,0x08,0x78,0x48,

View File

@ -9,12 +9,9 @@
* implied warranty. * implied warranty.
*/ */
/*exported Videoterm */ import { allocMemPages, debug } from '../util';
/*globals debug: false, allocMemPages: false */
function Videoterm(io, slot, context) {
'use strict';
export default function Videoterm(io, slot, context) {
slot = slot || 3; slot = slot || 3;
debug('Videx Videoterm card in slot', slot); debug('Videx Videoterm card in slot', slot);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> * Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -10,10 +10,9 @@
* implied warranty. * implied warranty.
*/ */
/*exported CPU6502 */ import { debug, toHex } from './util';
/*globals debug: false, toHex: false */
function CPU6502(options) export default function CPU6502(options)
{ {
'use strict'; 'use strict';

View File

@ -1,6 +1,6 @@
/*exported IntBasicDump */ /*exported IntBasicDump */
function IntBasicDump(mem) export default function IntBasicDump(mem)
{ {
var _mem = mem; var _mem = mem;

View File

@ -1,38 +1,31 @@
/* globals debug: false, gup: false, hup: false, toHex: false, import Apple2IO from './apple2io';
CPU6502: false, import ApplesoftDump from './applesoft/decompiler';
RAM: false, import { HiresPage, LoresPage, VideoModes, multiScreen } from './canvas';
Apple2ROM: false, IntBASIC: false, OriginalROM: false, import CPU6502 from './cpu6502';
Apple2jROM: false, import Prefs from './prefs';
apple2_charset: false, apple2j_charset: false, import RAM from './ram';
pigfont_charset: false, apple2lc_charset: false, import { debug, gup, hup } from './util';
Apple2IO: false
LoresPage: false, HiresPage: false, VideoModes: false, import Audio from './ui/audio';
KeyBoard: false, import { gamepad, initGamepad, processGamepad } from './ui/gamepad';
Parallel: false, import KeyBoard from './ui/keyboard';
Videoterm: false, import Printer from './ui/printer';
DiskII: false, import Tape from './ui/tape';
Printer: false,
LanguageCard: false, import DiskII from './cards/disk2';
RAMFactor: false, import LanguageCard from './cards/langcard';
Thunderclock: false, import Parallel from './cards/parallel';
Prefs: false, import RAMFactor from './cards/ramfactor';
disk_index: false, import Thunderclock from './cards/thunderclock';
Audio: false, import Videoterm from './cards/videoterm';
initGamepad: false, processGamepad: false, gamepad: false,
Tape: false, import apple2_charset from './roms/apple2_char';
ApplesoftDump: false, SYMBOLS: false,
multiScreen: true import Apple2ROM from './roms/fpbasic';
*/ import IntBASIC from './roms/intbasic';
/* exported openLoad, openSave, doDelete, handleDragOver, handleDragEnd, handleDrop, import OriginalROM from './roms/original';
selectCategory, selectDisk, clickDisk,
multiScreen, import SYMBOLS from './symbols';
updateJoystick,
pauseRun, step,
toggleSound,
restoreState, saveState,
dumpProgram, PageDebug,
enhanced
*/
var kHz = 1023; var kHz = 1023;
@ -53,6 +46,7 @@ var trace = [];
* Page viewer * Page viewer
*/ */
/*
function PageDebug(page) function PageDebug(page)
{ {
var _page = page; var _page = page;
@ -84,6 +78,7 @@ function PageDebug(page)
} }
}; };
} }
*/
var disk_categories = {'Local Saves': []}; var disk_categories = {'Local Saves': []};
var disk_sets = {}; var disk_sets = {};
@ -129,7 +124,7 @@ var TAPE_TYPES = ['wav','aiff','aif','mp3','m4a'];
var _currentDrive = 1; var _currentDrive = 1;
function openLoad(drive, event) window.openLoad = function(drive, event)
{ {
_currentDrive = parseInt(drive, 10); _currentDrive = parseInt(drive, 10);
if (event.metaKey) { if (event.metaKey) {
@ -140,9 +135,9 @@ function openLoad(drive, event)
} }
$('#load').dialog('open'); $('#load').dialog('open');
} }
} };
function openSave(drive, event) window.openSave = function(drive, event)
{ {
_currentDrive = parseInt(drive, 10); _currentDrive = parseInt(drive, 10);
@ -160,14 +155,14 @@ function openSave(drive, event)
$('#save_name').val(drivelights.label(drive)); $('#save_name').val(drivelights.label(drive));
$('#save').dialog('open'); $('#save').dialog('open');
} }
} };
function handleDragOver(drive, event) { window.handleDragOver = function(drive, event) {
event.preventDefault(); event.preventDefault();
event.dataTransfer.dropEffect = 'copy'; event.dataTransfer.dropEffect = 'copy';
} };
function handleDragEnd(drive, event) { window.handleDragEnd = function(drive, event) {
var dt = event.dataTransfer; var dt = event.dataTransfer;
if (dt.items) { if (dt.items) {
for (var i = 0; i < dt.items.length; i++) { for (var i = 0; i < dt.items.length; i++) {
@ -176,9 +171,9 @@ function handleDragEnd(drive, event) {
} else { } else {
event.dataTransfer.clearData(); event.dataTransfer.clearData();
} }
} };
function handleDrop(drive, event) { window.handleDrop = function(drive, event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -208,7 +203,7 @@ function handleDrop(drive, event) {
} }
} }
} }
} };
var loading = false; var loading = false;
@ -282,11 +277,11 @@ function doSave() {
$('#save').dialog('close'); $('#save').dialog('close');
} }
function doDelete(name) { window.doDelete = function(name) {
if (window.confirm('Delete ' + name + '?')) { if (window.confirm('Delete ' + name + '?')) {
deleteLocalStorage(name); deleteLocalStorage(name);
} }
} };
function doLoadLocal(drive, file) { function doLoadLocal(drive, file) {
var parts = file.name.split('.'); var parts = file.name.split('.');
@ -352,7 +347,7 @@ function openManage() {
var prefs = new Prefs(); var prefs = new Prefs();
var romVersion = prefs.readPref('computer_type2'); var romVersion = prefs.readPref('computer_type2');
var enhanced = false; export var enhanced = false;
var rom; var rom;
var char_rom = apple2_charset; var char_rom = apple2_charset;
switch (romVersion) { switch (romVersion) {
@ -362,18 +357,18 @@ case 'apple2':
case'original': case'original':
rom = new OriginalROM(); rom = new OriginalROM();
break; break;
case 'apple2jplus': // case 'apple2jplus':
rom = new Apple2jROM(); // rom = new Apple2jROM();
char_rom = apple2j_charset; // char_rom = apple2j_charset;
break; // break;
case 'apple2pig': // case 'apple2pig':
rom = new Apple2ROM(); // rom = new Apple2ROM();
char_rom = pigfont_charset; // char_rom = pigfont_charset;
break; // break;
case 'apple2lc': // case 'apple2lc':
rom = new Apple2ROM(); // rom = new Apple2ROM();
char_rom = apple2lc_charset; // char_rom = apple2lc_charset;
break; // break;
default: default:
rom = new Apple2ROM(); rom = new Apple2ROM();
} }
@ -420,7 +415,7 @@ var dumper = new ApplesoftDump(cpu);
var drivelights = new DriveLights(); var drivelights = new DriveLights();
var io = new Apple2IO(cpu, vm); var io = new Apple2IO(cpu, vm);
var keyboard = new KeyBoard(io); var keyboard = new KeyBoard(cpu, io);
var audio = new Audio(io); var audio = new Audio(io);
var tape = new Tape(io); var tape = new Tape(io);
var printer = new Printer($('#printer .paper')); var printer = new Printer($('#printer .paper'));
@ -492,16 +487,16 @@ function dumpDisk(drive) {
wind.document.close(); wind.document.close();
} }
function dumpProgram() { window.dumpProgram = function() {
var wind = window.open('', '_blank'); var wind = window.open('', '_blank');
wind.document.title = 'Program Listing'; wind.document.title = 'Program Listing';
wind.document.write('<pre>'); wind.document.write('<pre>');
wind.document.write(dumper.toString()); wind.document.write(dumper.toString());
wind.document.write('</pre>'); wind.document.write('</pre>');
wind.document.close(); wind.document.close();
} };
function step() window.step = function()
{ {
if (runTimer) { if (runTimer) {
clearInterval(runTimer); clearInterval(runTimer);
@ -512,7 +507,7 @@ function step()
debug(cpu.dumpRegisters()); debug(cpu.dumpRegisters());
debug(cpu.dumpPC()); debug(cpu.dumpPC());
}); });
} };
var accelerated = false; var accelerated = false;
@ -685,7 +680,7 @@ function loadBinary(bin) {
run(bin.start); run(bin.start);
} }
function selectCategory() { window.selectCategory = function() {
$('#disk_select').empty(); $('#disk_select').empty();
var cat = disk_categories[$('#category_select').val()]; var cat = disk_categories[$('#category_select').val()];
if (cat) { if (cat) {
@ -701,15 +696,15 @@ function selectCategory() {
} }
} }
} }
} };
function selectDisk() { window.selectDisk = function() {
$('#local_file').val(''); $('#local_file').val('');
} };
function clickDisk() { window.clickDisk = function() {
doLoad(); doLoad();
} };
function loadDisk(drive, disk) { function loadDisk(drive, disk) {
var name = disk.name; var name = disk.name;
@ -888,7 +883,7 @@ var flipX = false;
var flipY = false; var flipY = false;
var swapXY = false; var swapXY = false;
function updateJoystick() { window.updateJoystick = function() {
disableMouseJoystick = $('#disable_mouse').prop('checked'); disableMouseJoystick = $('#disable_mouse').prop('checked');
flipX = $('#flip_x').prop('checked'); flipX = $('#flip_x').prop('checked');
flipY = $('#flip_y').prop('checked'); flipY = $('#flip_y').prop('checked');
@ -899,7 +894,7 @@ function updateJoystick() {
io.paddle(1, 0.5); io.paddle(1, 0.5);
return; return;
} }
} };
function _mousemove(evt) { function _mousemove(evt) {
if (gamepad || disableMouseJoystick) { if (gamepad || disableMouseJoystick) {
@ -921,7 +916,7 @@ function _mousemove(evt) {
io.paddle(1, flipY ? 1 - y : y); io.paddle(1, flipY ? 1 - y : y);
} }
function pauseRun() { window.pauseRun = function() {
var label = $('#pause-run i'); var label = $('#pause-run i');
if (paused) { if (paused) {
run(); run();
@ -931,13 +926,13 @@ function pauseRun() {
label.removeClass('fa-pause').addClass('fa-play'); label.removeClass('fa-pause').addClass('fa-play');
} }
paused = !paused; paused = !paused;
} };
function toggleSound() { window.toggleSound = function() {
var enableSound = $('#enable_sound'); var enableSound = $('#enable_sound');
enableSound.prop('checked', !enableSound.prop('checked')); enableSound.prop('checked', !enableSound.prop('checked'));
updateSound(); updateSound();
} };
$(function() { $(function() {
hashtag = document.location.hash; hashtag = document.location.hash;
@ -1052,8 +1047,8 @@ $(function() {
} }
var oldcat = ''; var oldcat = '';
for (var idx = 0; idx < disk_index.length; idx++) { for (var idx = 0; idx < window.disk_index.length; idx++) {
var file = disk_index[idx]; var file = window.disk_index[idx];
var cat = file.category; var cat = file.category;
var name = file.name, disk = file.disk; var name = file.name, disk = file.disk;
if (file.e) { if (file.e) {

View File

@ -1,35 +1,29 @@
/* globals debug: false, gup: false, hup: false, toHex: false, import Apple2IO from './apple2io';
CPU6502: false, import ApplesoftDump from './applesoft/decompiler';
Apple2eROM: false, Apple2eEnhancedROM: false, import { HiresPage, LoresPage, VideoModes } from './canvas';
apple2e_charset: false, rmfont_charset: false, import CPU6502 from './cpu6502';
apple2enh_charset: false, import MMU from './mmu';
Apple2IO: false import Prefs from './prefs';
LoresPage: false, HiresPage: false, VideoModes: false, import { debug, gup, hup } from './util';
KeyBoard: false,
Parallel: false, import Audio from './ui/audio';
DiskII: false, import { gamepad, initGamepad, processGamepad } from './ui/gamepad';
Printer: false, import KeyBoard from './ui/keyboard';
MMU: false, import Printer from './ui/printer';
RAMFactor: false, import Tape from './ui/tape';
Thunderclock: false,
Prefs: false, import DiskII from './cards/disk2';
disk_index: false, import Parallel from './cards/parallel';
Audio: false, import RAMFactor from './cards/ramfactor';
initGamepad: false, processGamepad: false, gamepad: false, import Thunderclock from './cards/thunderclock';
Tape: false,
ApplesoftDump: false, SYMBOLS: false, import apple2e_charset from './roms/apple2e_char';
multiScreen: true import apple2enh_charset from './roms/apple2enh_char';
*/
/* exported openLoad, openSave, doDelete, handleDragOver, handleDragEnd, handleDrop, import Apple2eROM from './roms/apple2e';
selectCategory, selectDisk, clickDisk, import Apple2eEnhancedROM from './roms/apple2enh';
multiScreen,
updateJoystick, import SYMBOLS from './symbols';
pauseRun, step,
toggleSound,
restoreState, saveState,
dumpProgram, PageDebug,
enhanced
*/
var kHz = 1023; var kHz = 1023;
@ -50,6 +44,7 @@ var trace = [];
* Page viewer * Page viewer
*/ */
/*
function PageDebug(page) function PageDebug(page)
{ {
var _page = page; var _page = page;
@ -81,6 +76,7 @@ function PageDebug(page)
} }
}; };
} }
*/
var disk_categories = {'Local Saves': []}; var disk_categories = {'Local Saves': []};
var disk_sets = {}; var disk_sets = {};
@ -126,7 +122,7 @@ var TAPE_TYPES = ['wav','aiff','aif','mp3','m4a'];
var _currentDrive = 1; var _currentDrive = 1;
function openLoad(drive, event) window.openLoad = function(drive, event)
{ {
_currentDrive = parseInt(drive, 10); _currentDrive = parseInt(drive, 10);
if (event.metaKey) { if (event.metaKey) {
@ -137,9 +133,9 @@ function openLoad(drive, event)
} }
$('#load').dialog('open'); $('#load').dialog('open');
} }
} };
function openSave(drive, event) window.openSave = function(drive, event)
{ {
_currentDrive = parseInt(drive, 10); _currentDrive = parseInt(drive, 10);
@ -157,14 +153,14 @@ function openSave(drive, event)
$('#save_name').val(drivelights.label(drive)); $('#save_name').val(drivelights.label(drive));
$('#save').dialog('open'); $('#save').dialog('open');
} }
} };
function handleDragOver(drive, event) { window.handleDragOver = function(drive, event) {
event.preventDefault(); event.preventDefault();
event.dataTransfer.dropEffect = 'copy'; event.dataTransfer.dropEffect = 'copy';
} };
function handleDragEnd(drive, event) { window.handleDragEnd = function(drive, event) {
var dt = event.dataTransfer; var dt = event.dataTransfer;
if (dt.items) { if (dt.items) {
for (var i = 0; i < dt.items.length; i++) { for (var i = 0; i < dt.items.length; i++) {
@ -173,9 +169,9 @@ function handleDragEnd(drive, event) {
} else { } else {
event.dataTransfer.clearData(); event.dataTransfer.clearData();
} }
} };
function handleDrop(drive, event) { window.handleDrop = function(drive, event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -195,7 +191,7 @@ function handleDrop(drive, event) {
doLoadLocal(1, dt.files[0]); doLoadLocal(1, dt.files[0]);
doLoadLocal(2, dt.files[1]); doLoadLocal(2, dt.files[1]);
} }
} };
var loading = false; var loading = false;
@ -269,11 +265,11 @@ function doSave() {
$('#save').dialog('close'); $('#save').dialog('close');
} }
function doDelete(name) { window.doDelete = function(name) {
if (window.confirm('Delete ' + name + '?')) { if (window.confirm('Delete ' + name + '?')) {
deleteLocalStorage(name); deleteLocalStorage(name);
} }
} };
function doLoadLocal(drive, file) { function doLoadLocal(drive, file) {
var parts = file.name.split('.'); var parts = file.name.split('.');
@ -340,17 +336,18 @@ function openManage() {
var prefs = new Prefs(); var prefs = new Prefs();
var romVersion = prefs.readPref('computer_type2e'); var romVersion = prefs.readPref('computer_type2e');
var enhanced = false; var enhanced = false;
var multiScreen = false;
var rom; var rom;
var char_rom = apple2e_charset; var char_rom = apple2e_charset;
switch (romVersion) { switch (romVersion) {
case 'apple2e': case 'apple2e':
rom = new Apple2eROM(); rom = new Apple2eROM();
break; break;
case 'apple2rm': // case 'apple2rm':
rom = new Apple2eEnhancedROM(); // rom = new Apple2eEnhancedROM();
char_rom = rmfont_charset; // char_rom = rmfont_charset;
enhanced = true; // enhanced = true;
break; // break;
default: default:
rom = new Apple2eEnhancedROM(); rom = new Apple2eEnhancedROM();
char_rom =apple2enh_charset; char_rom =apple2enh_charset;
@ -390,11 +387,13 @@ var hgr = new HiresPage(1, context3);
var hgr2 = new HiresPage(2, context4); var hgr2 = new HiresPage(2, context4);
var vm = new VideoModes(gr, hgr, gr2, hgr2, true); var vm = new VideoModes(gr, hgr, gr2, hgr2, true);
vm.enhanced(enhanced);
vm.multiScreen(multiScreen);
var dumper = new ApplesoftDump(cpu); var dumper = new ApplesoftDump(cpu);
var drivelights = new DriveLights(); var drivelights = new DriveLights();
var io = new Apple2IO(cpu, vm); var io = new Apple2IO(cpu, vm);
var keyboard = new KeyBoard(io, true); var keyboard = new KeyBoard(cpu, io, true);
var audio = new Audio(io); var audio = new Audio(io);
var tape = new Tape(io); var tape = new Tape(io);
var printer = new Printer($('#printer .paper')); var printer = new Printer($('#printer .paper'));
@ -436,7 +435,7 @@ function updateKHz() {
lastFrames = renderedFrames; lastFrames = renderedFrames;
} }
function updateSound() { window.updateSound = function() {
var on = $('#enable_sound').prop('checked'); var on = $('#enable_sound').prop('checked');
var label = $('#toggle-sound i'); var label = $('#toggle-sound i');
audio.enable(on); audio.enable(on);
@ -445,7 +444,7 @@ function updateSound() {
} else { } else {
label.removeClass('fa-volume-up').addClass('fa-volume-off'); label.removeClass('fa-volume-up').addClass('fa-volume-off');
} }
} };
function dumpDisk(drive) { function dumpDisk(drive) {
var wind = window.open('', '_blank'); var wind = window.open('', '_blank');
@ -456,16 +455,16 @@ function dumpDisk(drive) {
wind.document.close(); wind.document.close();
} }
function dumpProgram() { window.dumpProgram = function() {
var wind = window.open('', '_blank'); var wind = window.open('', '_blank');
wind.document.title = 'Program Listing'; wind.document.title = 'Program Listing';
wind.document.write('<pre>'); wind.document.write('<pre>');
wind.document.write(dumper.toString()); wind.document.write(dumper.toString());
wind.document.write('</pre>'); wind.document.write('</pre>');
wind.document.close(); wind.document.close();
} };
function step() window.step = function()
{ {
if (runTimer) { if (runTimer) {
clearInterval(runTimer); clearInterval(runTimer);
@ -476,11 +475,11 @@ function step()
debug(cpu.dumpRegisters()); debug(cpu.dumpRegisters());
debug(cpu.dumpPC()); debug(cpu.dumpPC());
}); });
} };
var accelerated = false; var accelerated = false;
function updateCPU() window.updateCPU = function()
{ {
accelerated = $('#accelerator_toggle').prop('checked'); accelerated = $('#accelerator_toggle').prop('checked');
kHz = accelerated ? 4092 : 1023; kHz = accelerated ? 4092 : 1023;
@ -488,7 +487,7 @@ function updateCPU()
if (runTimer) { if (runTimer) {
run(); run();
} }
} };
var _requestAnimationFrame = var _requestAnimationFrame =
window.requestAnimationFrame || window.requestAnimationFrame ||
@ -634,7 +633,7 @@ function loadBinary(bin) {
run(bin.start); run(bin.start);
} }
function selectCategory() { window.selectCategory = function() {
$('#disk_select').empty(); $('#disk_select').empty();
var cat = disk_categories[$('#category_select').val()]; var cat = disk_categories[$('#category_select').val()];
if (cat) { if (cat) {
@ -650,15 +649,15 @@ function selectCategory() {
} }
} }
} }
} };
function selectDisk() { window.selectDisk = function() {
$('#local_file').val(''); $('#local_file').val('');
} };
function clickDisk() { window.clickDisk = function() {
doLoad(); doLoad();
} };
function loadDisk(drive, disk) { function loadDisk(drive, disk) {
var name = disk.name; var name = disk.name;
@ -843,20 +842,20 @@ function _keyup(evt) {
} }
} }
function updateScreen() { window.updateScreen = function() {
var green = $('#green_screen').prop('checked'); var green = $('#green_screen').prop('checked');
var scanlines = $('#show_scanlines').prop('checked'); var scanlines = $('#show_scanlines').prop('checked');
vm.green(green); vm.green(green);
vm.scanlines(scanlines); vm.scanlines(scanlines);
} };
var disableMouseJoystick = false; var disableMouseJoystick = false;
var flipX = false; var flipX = false;
var flipY = false; var flipY = false;
var swapXY = false; var swapXY = false;
function updateJoystick() { window.updateJoystick = function() {
disableMouseJoystick = $('#disable_mouse').prop('checked'); disableMouseJoystick = $('#disable_mouse').prop('checked');
flipX = $('#flip_x').prop('checked'); flipX = $('#flip_x').prop('checked');
flipY = $('#flip_y').prop('checked'); flipY = $('#flip_y').prop('checked');
@ -867,7 +866,7 @@ function updateJoystick() {
io.paddle(1, 0.5); io.paddle(1, 0.5);
return; return;
} }
} };
function _mousemove(evt) { function _mousemove(evt) {
if (gamepad || disableMouseJoystick) { if (gamepad || disableMouseJoystick) {
@ -889,7 +888,7 @@ function _mousemove(evt) {
io.paddle(1, flipY ? 1 - y : y); io.paddle(1, flipY ? 1 - y : y);
} }
function pauseRun() { window.pauseRun = function() {
var label = $('#pause-run i'); var label = $('#pause-run i');
if (paused) { if (paused) {
run(); run();
@ -899,13 +898,13 @@ function pauseRun() {
label.removeClass('fa-pause').addClass('fa-play'); label.removeClass('fa-pause').addClass('fa-play');
} }
paused = !paused; paused = !paused;
} };
function toggleSound() { window.toggleSound = function() {
var enableSound = $('#enable_sound'); var enableSound = $('#enable_sound');
enableSound.prop('checked', !enableSound.prop('checked')); enableSound.prop('checked', !enableSound.prop('checked'));
updateSound(); window.updateSound();
} };
$(function() { $(function() {
hashtag = document.location.hash; hashtag = document.location.hash;
@ -968,9 +967,9 @@ $(function() {
reset(); reset();
setInterval(updateKHz, 1000); setInterval(updateKHz, 1000);
updateSound(); window.updateSound();
updateScreen(); window.updateScreen();
updateCPU(); window.updateCPU();
var cancel = function() { $(this).dialog('close'); }; var cancel = function() { $(this).dialog('close'); };
$('#loading').dialog({ autoOpen: false, modal: true }); $('#loading').dialog({ autoOpen: false, modal: true });
@ -1020,8 +1019,8 @@ $(function() {
} }
var oldcat = ''; var oldcat = '';
for (var idx = 0; idx < disk_index.length; idx++) { for (var idx = 0; idx < window.disk_index.length; idx++) {
var file = disk_index[idx]; var file = window.disk_index[idx];
var cat = file.category; var cat = file.category;
var name = file.name, disk = file.disk; var name = file.name, disk = file.disk;
if (cat != oldcat) { if (cat != oldcat) {

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,15 +9,11 @@
* implied warranty. * implied warranty.
*/ */
/*exported MMU */ import RAM from './ram';
/*globals debug: false, toHex: false import { debug, toHex } from './util';
RAM: false
*/
function MMU(cpu, vm, lores1, lores2, hires1, hires2, io, rom) export default function MMU(cpu, vm, lores1, lores2, hires1, hires2, io, rom)
{ {
'use strict';
var idx; var idx;
var _readPages = new Array(0x100); var _readPages = new Array(0x100);
@ -494,7 +490,7 @@ function MMU(cpu, vm, lores1, lores2, hires1, hires2, io, rom)
} }
break; break;
// Graphics Switches // Graphics Switches
case LOC.PAGE1: case LOC.PAGE1:
_page2 = false; _page2 = false;
@ -523,7 +519,7 @@ function MMU(cpu, vm, lores1, lores2, hires1, hires2, io, rom)
_debug('Hires on'); _debug('Hires on');
break; break;
// Language Card Switches // Language Card Switches
case LOC.READBSR2: // 0xC080 case LOC.READBSR2: // 0xC080
case LOC._READBSR2: // 0xC084 case LOC._READBSR2: // 0xC084
@ -590,7 +586,7 @@ function MMU(cpu, vm, lores1, lores2, hires1, hires2, io, rom)
//_debug('Bank 1 Read/Write'); //_debug('Bank 1 Read/Write');
break; break;
// Status registers // Status registers
case LOC.BSRBANK2: case LOC.BSRBANK2:
_debug('Bank 2 Read ' + !_bank1); _debug('Bank 2 Read ' + !_bank1);

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,12 +9,8 @@
* implied warranty. * implied warranty.
*/ */
/*exported Prefs */ export default function Prefs()
function Prefs()
{ {
'use strict';
return { return {
havePrefs: function() { havePrefs: function() {
return typeof(localStorage) != 'undefined'; return typeof(localStorage) != 'undefined';

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,14 +9,10 @@
* implied warranty. * implied warranty.
*/ */
/*exported RAM */ import { base64_decode, base64_encode } from './base64';
/*globals allocMemPages: false import { allocMemPages } from './util';
base64_encode: false, base64_decode: false
*/
function RAM(sp, ep) {
'use strict';
export default function RAM(sp, ep) {
var mem; var mem;
var start_page = sp; var start_page = sp;
var end_page = ep; var end_page = ep;

View File

@ -258,3 +258,5 @@ var apple2_charset = [
0x80,0x90,0x88,0x84,0x82,0x84,0x88,0x90, 0x80,0x90,0x88,0x84,0x82,0x84,0x88,0x90,
0x80,0x9c,0xa2,0x84,0x88,0x88,0x80,0x88 0x80,0x9c,0xa2,0x84,0x88,0x88,0x80,0x88
]; ];
export default apple2_charset;

View File

@ -1,6 +1,6 @@
/*exported Apple2eROM*/ /*exported Apple2eROM*/
function Apple2eROM() export default function Apple2eROM()
{ {
var rom = [ var rom = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

View File

@ -514,3 +514,5 @@ var apple2e_charset = [
0x81,0x81,0x11,0x44,0x81,0x81,0x00,0x00, 0x81,0x81,0x11,0x44,0x81,0x81,0x00,0x00,
0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00 0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00
]; ];
export default apple2e_charset;

View File

@ -1,6 +1,6 @@
/*exported Apple2eEnhancedROM */ /*exported Apple2eEnhancedROM */
function Apple2eEnhancedROM() export default function Apple2eEnhancedROM()
{ {
var rom = [ var rom = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

View File

@ -514,3 +514,5 @@ var apple2enh_charset = [
0x81,0x81,0x11,0x44,0x81,0x81,0x00,0x00, 0x81,0x81,0x11,0x44,0x81,0x81,0x00,0x00,
0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00 0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00
]; ];
export default apple2enh_charset;

View File

@ -1,5 +1,4 @@
/*exported Apple2ROM */ export default function Apple2ROM()
function Apple2ROM()
{ {
var rom = [ var rom = [
0x6f,0xd8,0x65,0xd7,0xf8,0xdc,0x94,0xd9, 0x6f,0xd8,0x65,0xd7,0xf8,0xdc,0x94,0xd9,

View File

@ -1,6 +1,4 @@
/*exported IntBASIC */ export default function IntBASIC()
function IntBASIC()
{ {
var rom = [ var rom = [
0xa9,0x20,0x8d,0x26,0x03,0xad,0x57,0xc0, 0xa9,0x20,0x8d,0x26,0x03,0xad,0x57,0xc0,

View File

@ -1,6 +1,4 @@
/*exported OriginalROM */ export default function OriginalROM()
function OriginalROM()
{ {
var rom = [ var rom = [
0xa9,0x20,0x8d,0x26,0x03,0xad,0x57,0xc0, 0xa9,0x20,0x8d,0x26,0x03,0xad,0x57,0xc0,

View File

@ -740,3 +740,5 @@ var SYMBOLS = {
0xFEFD: 'MON.READ', 0xFEFD: 'MON.READ',
0xFF02: 'MON.READ2' 0xFF02: 'MON.READ2'
}; };
export default SYMBOLS;

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,14 +9,13 @@
* implied warranty. * implied warranty.
*/ */
/*globals debug: false */ import { debug } from '../util';
/*exported Audio */
/* /*
* Audio Handling * Audio Handling
*/ */
function Audio(io) { export default function Audio(io) {
var sound = true; var sound = true;
var _samples = []; var _samples = [];

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,14 +9,12 @@
* implied warranty. * implied warranty.
*/ */
/*jshint jquery: true, browser: true */
/*globals flipX: false, flipY: false */
/*exported processGamepad, initGamepad, gamepad */
var getGamepads = navigator.getGamepads || navigator.webkitGetGamepads; var getGamepads = navigator.getGamepads || navigator.webkitGetGamepads;
var gamepad; export var gamepad;
var gamepadMap = []; var gamepadMap = [];
var gamepadState = []; var gamepadState = [];
var flipX = false;
var flipY = false;
var BUTTON = { var BUTTON = {
// Buttons // Buttons
@ -50,14 +48,14 @@ var DEFAULT_GAMEPAD = {
'B': 1, 'B': 1,
'L1': 0, 'L1': 0,
'R1': 1, 'R1': 1,
'START': '\033' 'START': 0x1B
}; };
window.addEventListener('gamepadconnected', function(e) { window.addEventListener('gamepadconnected', function(e) {
gamepad = e.gamepad; gamepad = e.gamepad;
}); });
function processGamepad(io) { export function processGamepad(io) {
if (getGamepads) { if (getGamepads) {
gamepad = getGamepads.call(navigator)[0]; gamepad = getGamepads.call(navigator)[0];
} }
@ -98,7 +96,7 @@ function processGamepad(io) {
} }
} }
function initGamepad(data) { export function initGamepad(data) {
for (var idx = 0; idx < 16; idx++) { for (var idx = 0; idx < 16; idx++) {
gamepadMap[idx] = undefined; gamepadMap[idx] = undefined;
} }

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -9,11 +9,9 @@
* implied warranty. * implied warranty.
*/ */
/*jshint jquery: true, browser: true */ import { debug, toHex } from '../util';
/*globals debug: false, toHex: false, reset: false */
/*exported KeyBoard */
function KeyBoard(io, e) { export default function KeyBoard(cpu, io, e) {
// keycode: [plain, cntl, shift] // keycode: [plain, cntl, shift]
var keymap = { var keymap = {
// Most of these won't happen // Most of these won't happen
@ -219,7 +217,7 @@ function KeyBoard(io, e) {
} }
if (key == 0x7F && evt.shiftKey && evt.ctrlKey) { if (key == 0x7F && evt.shiftKey && evt.ctrlKey) {
reset(); cpu.reset();
key = 0xff; key = 0xff;
} }
@ -281,7 +279,7 @@ function KeyBoard(io, e) {
reset: function keyboard_reset(event) { reset: function keyboard_reset(event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
reset(); cpu.reset();
}, },
create: function keyboard_create(el) { create: function keyboard_create(el) {
@ -316,25 +314,25 @@ function KeyBoard(io, e) {
key = '\t'; key = '\t';
break; break;
case 'DELETE': case 'DELETE':
key = '\177'; key = 0x7F;
break; break;
case '&larr;': case '&larr;':
key = '\010'; key = 0x04;
break; break;
case '&rarr;': case '&rarr;':
key = '\025'; key = 0x15;
break; break;
case '&darr;': case '&darr;':
key = '\012'; key = 0x0A;
break; break;
case '&uarr;': case '&uarr;':
key = '\013'; key = 0x0B;
break; break;
case '&nbsp;': case '&nbsp;':
key = ' '; key = ' ';
break; break;
case 'ESC': case 'ESC':
key = '\033'; key = 0x1B;
break; break;
default: default:
break; break;
@ -358,7 +356,7 @@ function KeyBoard(io, e) {
window.location.reload(); window.location.reload();
break; break;
case 'RESET': case 'RESET':
reset(); cpu.reset();
break; break;
case 'OPEN_APPLE': case 'OPEN_APPLE':
self.commandKey(!commanded); self.commandKey(!commanded);

View File

@ -1,6 +1,15 @@
/*exported Printer */ /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
function Printer(paper) { export default function Printer(paper) {
var _lineBuffer; var _lineBuffer;
var _line; var _line;
@ -23,7 +32,7 @@ function Printer(paper) {
_lineBuffer = ''; _lineBuffer = '';
} else if (c == '\t') { } else if (c == '\t') {
_lineBuffer += ' '; _lineBuffer += ' ';
} else if (c == '\010') { } else if (c == 0x04) {
_lineBuffer = _lineBuffer.slice(0, -1); _lineBuffer = _lineBuffer.slice(0, -1);
} else { } else {
if (visible) { if (visible) {

View File

@ -1,7 +1,18 @@
/*globals debug */
/*exported Tape */
function Tape(io) { /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
import { debug } from '../util';
export default function Tape(io) {
var AudioContext = window.AudioContext || window.webkitAudioContext; var AudioContext = window.AudioContext || window.webkitAudioContext;
return { return {

View File

@ -1,4 +1,4 @@
/* Copyright 2010-2017 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2019 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -10,20 +10,11 @@
*/ */
/*eslint no-console: 0*/ /*eslint no-console: 0*/
/*exported allocMemPages, bytify, debug, each, gup, hup, toBinary, toHex
*/
/*global Uint8Array: false */
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
var hex_digits = '0123456789ABCDEF'; var hex_digits = '0123456789ABCDEF';
var bin_digits = '01'; var bin_digits = '01';
function allocMem(size) { export function allocMem(size) {
function garbage() { function garbage() {
return (Math.random() * 0x100) & 0xff; return (Math.random() * 0x100) & 0xff;
} }
@ -47,11 +38,11 @@ function allocMem(size) {
return result; return result;
} }
function allocMemPages(pages) { export function allocMemPages(pages) {
return allocMem(pages * 0x100); return allocMem(pages * 0x100);
} }
function bytify(ary) { export function bytify(ary) {
var result = ary; var result = ary;
if (window.Uint8Array) { if (window.Uint8Array) {
result = new Uint8Array(ary); result = new Uint8Array(ary);
@ -59,13 +50,13 @@ function bytify(ary) {
return result; return result;
} }
function debug() { export function debug() {
if (typeof console != 'undefined' && 'log' in console) { if (typeof console != 'undefined' && 'log' in console) {
console.log.apply(console, arguments); console.log.apply(console, arguments);
} }
} }
function toHex(v, n) { export function toHex(v, n) {
if (!n) { if (!n) {
n = v < 256 ? 2 : 4; n = v < 256 ? 2 : 4;
} }
@ -77,7 +68,7 @@ function toHex(v, n) {
return result; return result;
} }
function toBinary(v) { export function toBinary(v) {
var result = ''; var result = '';
for (var idx = 0; idx < 8; idx++) { for (var idx = 0; idx < 8; idx++) {
result = bin_digits[v & 0x01] + result; result = bin_digits[v & 0x01] + result;
@ -87,7 +78,7 @@ function toBinary(v) {
} }
// From http://www.netlobo.com/url_query_string_javascript.html // From http://www.netlobo.com/url_query_string_javascript.html
function gup( name ) export function gup( name )
{ {
name = name.replace(/[[]/,'\\[').replace(/[\]]/,'\\]'); name = name.replace(/[[]/,'\\[').replace(/[\]]/,'\\]');
var regexS = '[\\?&]'+name+'=([^&#]*)'; var regexS = '[\\?&]'+name+'=([^&#]*)';
@ -99,7 +90,7 @@ function gup( name )
return results[1]; return results[1];
} }
function hup() { export function hup() {
var regex = new RegExp('#(.*)'); var regex = new RegExp('#(.*)');
var results = regex.exec(window.location.hash); var results = regex.exec(window.location.hash);
if ( !results ) if ( !results )
@ -108,7 +99,7 @@ function hup() {
return results[1]; return results[1];
} }
function keys(obj) { export function keys(obj) {
var result = []; var result = [];
for (var key in obj) { for (var key in obj) {
if (obj.hasOwnProperty(key)) { if (obj.hasOwnProperty(key)) {
@ -118,6 +109,6 @@ function keys(obj) {
return result; return result;
} }
function each(obj, fn) { export function each(obj, fn) {
keys(obj).forEach(fn); keys(obj).forEach(fn);
} }

4408
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,11 @@
"name": "apple2js", "name": "apple2js",
"version": "0.0.1", "version": "0.0.1",
"description": "Apple II Emulator in JavaScript", "description": "Apple II Emulator in JavaScript",
"main": "index.js",
"scripts": { "scripts": {
"build": "webpack",
"index": "scripts/index.pl > json/disks/index.js", "index": "scripts/index.pl > json/disks/index.js",
"lint": "eslint js" "lint": "eslint js",
"start": "webpack-dev-server"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -17,7 +18,11 @@
"url": "https://github.com/whscullin/apple2js/issues" "url": "https://github.com/whscullin/apple2js/issues"
}, },
"homepage": "https://github.com/whscullin/apple2js#readme", "homepage": "https://github.com/whscullin/apple2js#readme",
"dependencies": { "devDependencies": {
"eslint": "^5.12.0" "ajv": "^6.9.2",
"eslint": "^5.12.0",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.2.1"
} }
} }

20
webpack.config.js Normal file
View File

@ -0,0 +1,20 @@
/*globals require module */
const path = require('path');
module.exports =
{
mode: 'development',
devtool: 'source-map',
entry: {
main2: path.resolve('js/main2.js'),
main2e: path.resolve('js/main2e.js'),
},
output: {
path: path.resolve('dist/'),
},
devServer: {
compress: true,
watchContentBase: true,
writeToDisk: true
}
};