Node version of PCjs runs again

This commit is contained in:
Jeff Parsons 2016-02-22 09:45:29 -08:00
commit 62f64f5571
7 changed files with 1002 additions and 1003 deletions

View file

@ -21,14 +21,14 @@
"name": "",
"addr": 0xf6000,
"size": 0x08000,
"file": "/devices/pc/basic/ibm-basic-1.00.json",
"file": "/devices/pc/rom/5150/basic/BASIC100.json",
"notify": ""
},
{ "id": "romBIOS",
"name": "",
"addr": 0xfe000,
"size": 0x02000,
"file": "/devices/pc/bios/5150/1981-04-24.json",
"file": "/devices/pc/rom/5150/bios/1981-04-24/PCBIOS-REV1.json",
"notify": ""
}
],

View file

@ -84,7 +84,7 @@ try {
var Component;
var dbg;
var aComponents = [];
var asComponentsIgnore = ["embed"];
var asComponentsIgnore = ["embed","save"];
/**
* loadComponents(asFiles)

View file

@ -1035,11 +1035,11 @@ Disk.prototype.load = function(sDiskName, sDiskPath, file, fnNotify, controller)
this.sDiskPath = sDiskPath;
this.sDiskFile = str.getBaseName(sDiskPath);
var disk = this;
this.fnNotify = fnNotify;
this.controllerNotify = controller || this.controller;
if (file) {
var disk = this;
var reader = new FileReader();
reader.onload = function() {
disk.build(reader.result, true);
@ -1099,7 +1099,6 @@ Disk.prototype.load = function(sDiskName, sDiskPath, file, fnNotify, controller)
}
}
}
var disk = this;
return !!web.getResource(sDiskURL, null, true, function(sURL, sResponse, nErrorCode) {
disk.doneLoad(sURL, sResponse, nErrorCode);
});

View file

@ -51,7 +51,7 @@
"use strict";
/* global document: true, window: true, DEBUG: true */
/* global window: true, DEBUG: true */
if (NODE) {
require("./defines");
@ -257,7 +257,10 @@ Component.addMachine = function(idMachine)
*/
Component.addMachineResource = function(idMachine, sName, data)
{
Component.assert(Component.machines[idMachine]);
/*
* I used to assert(Component.machines[idMachine]), but when we're running as a Node app, embed.js is not used,
* so addMachine() is never called, so resources do not need to be recorded.
*/
if (Component.machines[idMachine] && sName) {
Component.assert(Component.machines[idMachine][sName] === undefined);
Component.machines[idMachine][sName] = data;
@ -537,8 +540,6 @@ Component.bindExternalControl = function(component, sControl, sBinding, sType)
}
};
if (document && !document.ELEMENT_NODE) document.ELEMENT_NODE = 1;
/**
* Component.bindComponentControls(component, element, sAppClass)
*
@ -556,7 +557,7 @@ Component.bindComponentControls = function(component, element, sAppClass)
for (var iNode = 0; iNode < aeChildNodes.length; iNode++) {
var control = aeChildNodes[iNode];
if (control.nodeType !== document.ELEMENT_NODE) {
if (control.nodeType !== 1 /* document.ELEMENT_NODE */) {
continue;
}
var sClass = control.getAttribute("class");

View file

@ -252,10 +252,9 @@ web.getResource = function(sURL, dataPost, fAsync, done)
if (!fAsync) {
sResource = xmlHTTP.responseText;
if (xmlHTTP.status == 200) {
response = sResource;
if (MAXDEBUG) web.log("web.getResource(" + sURL + "): returned " + sResource.length + " bytes");
} else {
response = nErrorCode = xmlHTTP.status || -1;
nErrorCode = xmlHTTP.status || -1;
web.log("web.getResource(" + sURL + "): error code " + nErrorCode);
}
if (done) done(sURL, sResource, nErrorCode);
@ -630,30 +629,30 @@ web.downloadJSON = function(sJSON, sFileName)
/**
* onCountRepeat(n, fn, fnComplete, msDelay)
* onCountRepeat(n, fnRepeat, fnComplete, msDelay)
*
* Call fn() n times with an msDelay millisecond delay between calls, then
* call fnComplete() when the count has been exhausted OR fn() returns false.
* Call fnRepeat() n times with an msDelay millisecond delay between calls,
* then call fnComplete() when n has been exhausted OR fnRepeat() returns false.
*
* @param {number} n
* @param {function()} fn
* @param {function()} fnRepeat
* @param {function()} fnComplete
* @param {number} [msDelay]
*/
web.onCountRepeat = function(n, fn, fnComplete, msDelay)
web.onCountRepeat = function(n, fnRepeat, fnComplete, msDelay)
{
var fnRepeat = function doCountRepeat() {
var fnTimeout = function doCountRepeat() {
n -= 1;
if (n >= 0) {
if (!fn()) n = 0;
if (!fnRepeat()) n = 0;
}
if (n > 0) {
setTimeout(fnRepeat, msDelay || 0);
setTimeout(fnTimeout, msDelay || 0);
return;
}
fnComplete();
};
fnRepeat();
fnTimeout();
};
/**