Fixed some minor bugs (problems with autostart, duplicate machine IDs, etc)
This commit is contained in:
parent
b60e988aba
commit
3069d317c6
164 changed files with 7277 additions and 934 deletions
|
|
@ -1154,6 +1154,23 @@ DiskDump.prototype.addManifestInfo = function(fileInfo)
|
|||
this.aManifestInfo.push(fileInfo);
|
||||
};
|
||||
|
||||
DiskDump.asTextFileExts = [".MD", ".ME", ".BAS", ".TXT", ".XML"];
|
||||
|
||||
/**
|
||||
* isTextFile(sFileName)
|
||||
*
|
||||
* @this {DiskDump}
|
||||
* @param {string} sFileName
|
||||
* @return {boolean} true if the filename contains a known text file extension, false if unknown
|
||||
*/
|
||||
DiskDump.prototype.isTextFile = function(sFileName)
|
||||
{
|
||||
for (var i = 0; i < DiskDump.asTextFileExts.length; i++) {
|
||||
if (str.endsWith(sFileName, DiskDump.asTextFileExts[i])) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* readDir(sDir, fRoot, done)
|
||||
*
|
||||
|
|
@ -1254,7 +1271,7 @@ DiskDump.prototype.readDir = function(sDir, fRoot, done)
|
|||
} else {
|
||||
fileInfo.FILE_ATTR = DiskDump.ATTR_ARCHIVE;
|
||||
fileInfo.FILE_SIZE = stats.size;
|
||||
if (fileInfo.FILE_NAME == "README.MD") {
|
||||
if (obj.isTextFile(fileInfo.FILE_NAME)) {
|
||||
fs.readFile(fileInfo.FILE_PATH, {encoding: "utf8"}, function doneReadDirEntry(err, s) {
|
||||
if (!err) {
|
||||
s = s.replace(/\n/g, "\r\n").replace(/\r\r/g, "\r");
|
||||
|
|
@ -1384,7 +1401,7 @@ DiskDump.prototype.readPath = function(sPath, done)
|
|||
} else {
|
||||
fileInfo.FILE_ATTR = DiskDump.ATTR_ARCHIVE;
|
||||
fileInfo.FILE_SIZE = stats.size;
|
||||
if (fileInfo.FILE_NAME == "README.MD") {
|
||||
if (obj.isTextFile(fileInfo.FILE_NAME)) {
|
||||
DiskDump.readFile(sFilePath, "utf8", function doneReadPathEntry(err, sData) {
|
||||
if (!err) {
|
||||
sData = sData.replace(/\n/g, "\r\n").replace(/\r\r/g, "\r");
|
||||
|
|
@ -2056,6 +2073,8 @@ DiskDump.prototype.buildImageFromFiles = function(aFiles, done)
|
|||
done(err);
|
||||
return false;
|
||||
}
|
||||
|
||||
done(null);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1771,7 +1771,7 @@ HTMLOut.prototype.processMachines = function(aMachines, done)
|
|||
|
||||
var sScriptEmbed = "";
|
||||
if (infoMachine['func']) {
|
||||
sScriptEmbed = '<script type="text/javascript">' + 'window.' + infoMachine['func'] + '("' + infoMachine['id'] + '","' + infoMachine['xml'] + '"' + (infoMachine['xsl']? (',"' + infoMachine['xsl'] + '"') : '') + (infoMachine['state']? (',"' + infoMachine['state'] + '"') : '') + ');</script>';
|
||||
sScriptEmbed = '<script type="text/javascript">' + 'window.' + infoMachine['func'] + '("' + infoMachine['id'] + '","' + infoMachine['xml'] + '"' + (infoMachine['xsl']? (',"' + infoMachine['xsl'] + '"') : ',""') + (infoMachine['state']? (',"' + infoMachine['state'] + '"') : '') + ');</script>';
|
||||
}
|
||||
|
||||
var asFiles = [];
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ MarkOut.CLI = function()
|
|||
if (err) {
|
||||
MarkOut.logError(err, true);
|
||||
} else {
|
||||
var m = new MarkOut(str, null, req, null, fDebug, fDebug);
|
||||
var m = new MarkOut(str, null, req, null, fDebug);
|
||||
console.log(m.convertMD(" "));
|
||||
}
|
||||
});
|
||||
|
|
@ -733,7 +733,7 @@ MarkOut.prototype.convertMDLines = function(s)
|
|||
MarkOut.prototype.convertMDLinks = function(sBlock)
|
||||
{
|
||||
var aMatch;
|
||||
var re = /\[([^\[\]]*)\]\((.*?)(?:\s*"(.*?)"\)|\))/g;
|
||||
var re = /\[([^\[\]]*)]\((.*?)(?:\s*"(.*?)"\)|\))/g;
|
||||
while ((aMatch = re.exec(sBlock))) {
|
||||
var sTag = "a";
|
||||
var sType = "href";
|
||||
|
|
@ -915,7 +915,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
|
|||
*/
|
||||
var aMatch;
|
||||
var cMatches = 0;
|
||||
var reMachines = /\[(.*?)\]\((.*?)\s*"(PC|C1P)js:(.*?)"\)/gi;
|
||||
var reMachines = /\[(.*?)]\((.*?)\s*"(PC|C1P)js:(.*?)"\)/gi;
|
||||
|
||||
while ((aMatch = reMachines.exec(sBlock))) {
|
||||
|
||||
|
|
|
|||
|
|
@ -668,6 +668,7 @@ Computer.prototype.donePowerOn = function(aParms)
|
|||
* TODO: Do we not care about the return value here? (ie, is checking fRestoreError sufficient)?
|
||||
*/
|
||||
this.powerRestore(this.cpu, stateComputer, fRepower, fRestore);
|
||||
this.cpu.autoStart();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -685,6 +686,34 @@ Computer.prototype.donePowerOn = function(aParms)
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* checkPower()
|
||||
*
|
||||
* @this {Computer}
|
||||
* @return {boolean} true if the computer is fully powered, false otherwise
|
||||
*/
|
||||
Computer.prototype.checkPower = function()
|
||||
{
|
||||
if (this.aFlags.fPowered) return true;
|
||||
|
||||
var component = null, iComponent;
|
||||
var aComponents = Component.getComponents(this.id);
|
||||
for (iComponent = 0; iComponent < aComponents.length; iComponent++) {
|
||||
component = aComponents[iComponent];
|
||||
if (component !== this && !component.aFlags.fReady) break;
|
||||
}
|
||||
if (iComponent == aComponents.length) {
|
||||
for (iComponent = 0; iComponent < aComponents.length; iComponent++) {
|
||||
component = aComponents[iComponent];
|
||||
if (component !== this && !component.aFlags.fPowered) break;
|
||||
}
|
||||
}
|
||||
if (iComponent == aComponents.length) component = this;
|
||||
var s = "The " + component.type + " component (" + component.id + ") is not " + (!component.aFlags.fReady? "ready yet" + (component.fnReady? " (waiting for notification)" : "") : "powered yet") + ".";
|
||||
web.alertUser(s);
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* powerReport(stateComputer)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -96,7 +96,9 @@ function CPU(parmsCPU, nCyclesDefault)
|
|||
*/
|
||||
this.aCounts.mhzTarget = this.aCounts.mhzDefault * this.aCounts.nCyclesMultiplier;
|
||||
|
||||
this.aFlags.fPowered = false;
|
||||
/*
|
||||
* We add a number of flags to the set initialized by Component
|
||||
*/
|
||||
this.aFlags.fRunning = false;
|
||||
this.aFlags.fStarting = false;
|
||||
this.aFlags.fAutoStart = parmsCPU['autoStart'];
|
||||
|
|
@ -264,8 +266,12 @@ CPU.prototype.powerUp = function(data, fRepower)
|
|||
this.println("No debugger detected");
|
||||
}
|
||||
}
|
||||
this.aFlags.fPowered = true;
|
||||
if (!this.autoStart() && this.dbg) this.dbg.updateStatus();
|
||||
/*
|
||||
* The Computer component (which is responsible for all powerDown and powerUp notifications)
|
||||
* is now responsible for managing a component's fPowered flag, not us.
|
||||
*
|
||||
* this.aFlags.fPowered = true;
|
||||
*/
|
||||
this.updateCPU();
|
||||
return true;
|
||||
};
|
||||
|
|
@ -279,7 +285,12 @@ CPU.prototype.powerUp = function(data, fRepower)
|
|||
*/
|
||||
CPU.prototype.powerDown = function(fSave)
|
||||
{
|
||||
this.aFlags.fPowered = false;
|
||||
/*
|
||||
* The Computer component (which is responsible for all powerDown and powerUp notifications)
|
||||
* is now responsible for managing a component's fPowered flag, not us.
|
||||
*
|
||||
* this.aFlags.fPowered = false;
|
||||
*/
|
||||
return fSave && this.save ? this.save() : true;
|
||||
};
|
||||
|
||||
|
|
@ -499,6 +510,7 @@ CPU.prototype.setBinding = function(sHTMLType, sBinding, control)
|
|||
case "run":
|
||||
this.bindings[sBinding] = control;
|
||||
control.onclick = function onClickRun() {
|
||||
if (!cpu.cmp || !cpu.cmp.checkPower()) return;
|
||||
if (!cpu.aFlags.fRunning)
|
||||
cpu.runCPU(true);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -373,8 +373,12 @@ function embedMachine(sName, sVersion, idElement, sXMLFile, sXSLFile, sStateFile
|
|||
xsltProcessor['importStylesheet'](xsl);
|
||||
var eFragment = xsltProcessor['transformToFragment'](xml, window.document);
|
||||
if (eFragment) {
|
||||
eMachine.parentNode.replaceChild(eFragment, eMachine);
|
||||
doneMachine();
|
||||
if (eMachine.parentNode) {
|
||||
eMachine.parentNode.replaceChild(eFragment, eMachine);
|
||||
doneMachine();
|
||||
} else {
|
||||
displayError("invalid machine element: " + idElement);
|
||||
}
|
||||
} else {
|
||||
displayError("transformToFragment failed");
|
||||
}
|
||||
|
|
@ -402,7 +406,7 @@ function embedMachine(sName, sVersion, idElement, sXMLFile, sXSLFile, sStateFile
|
|||
parseXML(sXMLFile, null, idElement, sStateFile, false, displayMessage, loadXSL);
|
||||
}
|
||||
} else {
|
||||
displayError("failed to find machine element: " + idElement);
|
||||
displayError("missing machine element: " + idElement);
|
||||
}
|
||||
} catch(e) {
|
||||
displayError(e.message);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/apps/pc/">Apps</a></li>
|
||||
<li><a href="/disks/pc/">Disks</a></li>
|
||||
<li><a href="/devices/">Machines</a></li>
|
||||
<li><a href="/devices/pc/machine/">Machines</a></li>
|
||||
<li><a href="/docs/">Docs</a></li>
|
||||
<li><a href="/pubs/">Pubs</a></li>
|
||||
<li><a href="/blog/">Blog</a></li>
|
||||
|
|
|
|||
Loading…
Reference in a new issue