diff --git a/index.html b/index.html index 76f735bc..6eceef8f 100644 --- a/index.html +++ b/index.html @@ -273,10 +273,6 @@ canvas { - - - - diff --git a/package.json b/package.json index c0ed04ef..9d930331 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "author": "Steven Hugg", "dependencies": {}, "devDependencies": { - "mocha": "^3.2.0" + "mocha": "^3.2.0", + "mocha-phantomjs": "^4.1.0" }, "description": "8bitworkshop.com", "main": "main.js", diff --git a/src/emu.js b/src/emu.js index abb73136..0564c310 100644 --- a/src/emu.js +++ b/src/emu.js @@ -2,6 +2,8 @@ // Emulator classes +var PLATFORMS = {}; + function noise() { return (Math.random() * 256) & 0xff; } @@ -39,7 +41,7 @@ var RasterVideo = function(mainElement, width, height, options) { this.create = function() { canvas = __createCanvas(mainElement, width, height); - if (options.rotate) { + if (options && options.rotate) { canvas.style.transform = "rotate("+options.rotate+"deg)"; } ctx = canvas.getContext('2d'); diff --git a/src/platform/apple2.js b/src/platform/apple2.js index addf52ac..1cc8899a 100644 --- a/src/platform/apple2.js +++ b/src/platform/apple2.js @@ -958,3 +958,5 @@ var APPLEIIGO_LZG = [ 62,41,15,240,6,9,192,160,0,240,2,169,253,148,0,149,1,96,234,234,76,0,224,52,30,115,59,29,59,13,169,135, 76,237,253,165,72,72,165,69,166,70,164,71,52,110,22,52,62,27,59,30,59,14,245,3,251,3,98,250,98,250 ]; + +PLATFORMS['apple2'] = Apple2Platform; diff --git a/src/platform/atarivec.js b/src/platform/atarivec.js index 8bf31ff1..80936713 100644 --- a/src/platform/atarivec.js +++ b/src/platform/atarivec.js @@ -264,3 +264,5 @@ var DVGStateMachine = function(bus, video) { } } } + +PLATFORMS['atarivec'] = AtariVectorPlatform; diff --git a/src/platform/exidy.js b/src/platform/exidy.js index d7e30f30..e2e908d5 100644 --- a/src/platform/exidy.js +++ b/src/platform/exidy.js @@ -192,3 +192,5 @@ var ExidyPlatform = function(mainElement) { return ram.mem; } }; + +PLATFORMS['exidy'] = ExidyPlatform; diff --git a/src/platform/spaceinv.js b/src/platform/spaceinv.js index bf326c93..9529126f 100644 --- a/src/platform/spaceinv.js +++ b/src/platform/spaceinv.js @@ -222,3 +222,5 @@ var SpaceInvadersPlatform = function(mainElement) { return "\n" + dumpRAM(stack, state.c.SP, stack.length); } } + +PLATFORMS['spaceinv'] = SpaceInvadersPlatform; diff --git a/src/platform/vcs.js b/src/platform/vcs.js index 7ceebbf6..c912190e 100644 --- a/src/platform/vcs.js +++ b/src/platform/vcs.js @@ -114,3 +114,5 @@ var VCSPlatform = function() { return "\n" + dumpRAM(ram, 0x80, 0x80); } }; + +PLATFORMS['vcs'] = VCSPlatform; diff --git a/src/ui.js b/src/ui.js index 9767f10b..fdd64993 100644 --- a/src/ui.js +++ b/src/ui.js @@ -16,6 +16,9 @@ if (typeof window.onerror == "object") { }; } +// make sure VCS doesn't start +Javatari.AUTO_START = false; + // 8bitworkshop IDE user interface var PRESETS; // presets array @@ -860,44 +863,35 @@ if (qs['sharekey']) { window.location = "?" + $.param(qs); }, 'text'); } else { - // add default platform? - platform_id = qs['platform'] || localStorage.getItem("__lastplatform"); - if (!platform_id) { - platform_id = qs['platform'] = "vcs"; - } - // load and start platform object - // TODO: self-register platforms - if (platform_id == 'vcs') { - platform = new VCSPlatform(); - $("#booklink_vcs").show(); - } else if (platform_id == 'apple2') { - platform = new Apple2Platform($("#emulator")[0]); - } else if (platform_id == 'atarivec') { - platform = new AtariVectorPlatform($("#emulator")[0]); - } else if (platform_id == 'exidy') { - platform = new ExidyPlatform($("#emulator")[0]); - } else if (platform_id == 'spaceinv') { - platform = new SpaceInvadersPlatform($("#emulator")[0]); - } else { - alert("Platform " + platform_id + " not recognized"); - } - store = new FileStore(localStorage, platform_id + '/'); - PRESETS = platform.getPresets(); - setupDebugControls(); - platform.start(); // reset file? if (qs['file'] && qs['reset']) { store.deleteFile(qs['file']); qs['reset'] = ''; window.location = "?" + $.param(qs); - } else if (qs['file']) { - // load file - loadPreset(qs['file']); - updateSelector(); } else { - // try to load last file - var lastid = localStorage.getItem("__lastid_"+platform_id) || localStorage.getItem("__lastid"); - localStorage.removeItem("__lastid"); - gotoPresetNamed(lastid || PRESETS[0].id); + // add default platform? + platform_id = qs['platform'] || localStorage.getItem("__lastplatform"); + if (!platform_id) { + platform_id = qs['platform'] = "vcs"; + } + // load and start platform object + $.getScript('src/platform/' + platform_id + '.js', function() { + platform = new PLATFORMS[platform_id]($("#emulator")[0]); + console.log("loaded platform", platform_id); + store = new FileStore(localStorage, platform_id + '/'); + PRESETS = platform.getPresets(); + setupDebugControls(); + platform.start(); + if (qs['file']) { + // load file + loadPreset(qs['file']); + updateSelector(); + } else { + // try to load last file + var lastid = localStorage.getItem("__lastid_"+platform_id) || localStorage.getItem("__lastid"); + localStorage.removeItem("__lastid"); + gotoPresetNamed(lastid || PRESETS[0].id); + } + }); } }