mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-19 07:30:55 +00:00
load/register platform files individually
This commit is contained in:
parent
7fce763f64
commit
9d3a1bb48b
@ -273,10 +273,6 @@ canvas {
|
|||||||
<script src="src/emu.js"></script>
|
<script src="src/emu.js"></script>
|
||||||
<script src="src/util.js"></script>
|
<script src="src/util.js"></script>
|
||||||
<script src="src/disasm.js"></script>
|
<script src="src/disasm.js"></script>
|
||||||
<script src="src/platform/vcs.js"></script>
|
|
||||||
<script src="src/platform/apple2.js"></script>
|
|
||||||
<script src="src/platform/atarivec.js"></script>
|
|
||||||
<script src="src/platform/spaceinv.js"></script>
|
|
||||||
<script src="src/ui.js"></script>
|
<script src="src/ui.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
"author": "Steven Hugg",
|
"author": "Steven Hugg",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "^3.2.0"
|
"mocha": "^3.2.0",
|
||||||
|
"mocha-phantomjs": "^4.1.0"
|
||||||
},
|
},
|
||||||
"description": "8bitworkshop.com",
|
"description": "8bitworkshop.com",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
// Emulator classes
|
// Emulator classes
|
||||||
|
|
||||||
|
var PLATFORMS = {};
|
||||||
|
|
||||||
function noise() {
|
function noise() {
|
||||||
return (Math.random() * 256) & 0xff;
|
return (Math.random() * 256) & 0xff;
|
||||||
}
|
}
|
||||||
@ -39,7 +41,7 @@ var RasterVideo = function(mainElement, width, height, options) {
|
|||||||
|
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
canvas = __createCanvas(mainElement, width, height);
|
canvas = __createCanvas(mainElement, width, height);
|
||||||
if (options.rotate) {
|
if (options && options.rotate) {
|
||||||
canvas.style.transform = "rotate("+options.rotate+"deg)";
|
canvas.style.transform = "rotate("+options.rotate+"deg)";
|
||||||
}
|
}
|
||||||
ctx = canvas.getContext('2d');
|
ctx = canvas.getContext('2d');
|
||||||
|
@ -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,
|
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
|
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;
|
||||||
|
@ -264,3 +264,5 @@ var DVGStateMachine = function(bus, video) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLATFORMS['atarivec'] = AtariVectorPlatform;
|
||||||
|
@ -192,3 +192,5 @@ var ExidyPlatform = function(mainElement) {
|
|||||||
return ram.mem;
|
return ram.mem;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PLATFORMS['exidy'] = ExidyPlatform;
|
||||||
|
@ -222,3 +222,5 @@ var SpaceInvadersPlatform = function(mainElement) {
|
|||||||
return "\n" + dumpRAM(stack, state.c.SP, stack.length);
|
return "\n" + dumpRAM(stack, state.c.SP, stack.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLATFORMS['spaceinv'] = SpaceInvadersPlatform;
|
||||||
|
@ -114,3 +114,5 @@ var VCSPlatform = function() {
|
|||||||
return "\n" + dumpRAM(ram, 0x80, 0x80);
|
return "\n" + dumpRAM(ram, 0x80, 0x80);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PLATFORMS['vcs'] = VCSPlatform;
|
||||||
|
60
src/ui.js
60
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
|
// 8bitworkshop IDE user interface
|
||||||
|
|
||||||
var PRESETS; // presets array
|
var PRESETS; // presets array
|
||||||
@ -860,44 +863,35 @@ if (qs['sharekey']) {
|
|||||||
window.location = "?" + $.param(qs);
|
window.location = "?" + $.param(qs);
|
||||||
}, 'text');
|
}, 'text');
|
||||||
} else {
|
} 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?
|
// reset file?
|
||||||
if (qs['file'] && qs['reset']) {
|
if (qs['file'] && qs['reset']) {
|
||||||
store.deleteFile(qs['file']);
|
store.deleteFile(qs['file']);
|
||||||
qs['reset'] = '';
|
qs['reset'] = '';
|
||||||
window.location = "?" + $.param(qs);
|
window.location = "?" + $.param(qs);
|
||||||
} else if (qs['file']) {
|
|
||||||
// load file
|
|
||||||
loadPreset(qs['file']);
|
|
||||||
updateSelector();
|
|
||||||
} else {
|
} else {
|
||||||
// try to load last file
|
// add default platform?
|
||||||
var lastid = localStorage.getItem("__lastid_"+platform_id) || localStorage.getItem("__lastid");
|
platform_id = qs['platform'] || localStorage.getItem("__lastplatform");
|
||||||
localStorage.removeItem("__lastid");
|
if (!platform_id) {
|
||||||
gotoPresetNamed(lastid || PRESETS[0].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);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user