And more PCjs/PCx86 disambiguation

This commit is contained in:
Jeff Parsons 2016-05-18 00:03:07 -07:00
commit 2629e48bdf
57 changed files with 200 additions and 134 deletions

View file

@ -65,6 +65,7 @@ var C1PJS = {
APPNAME: APPNAME,
APPVERSION: APPVERSION, // shared
COMPILED: COMPILED, // shared
CSSCLASS: CSSCLASS, // shared
DEBUG: DEBUG, // shared
DEBUGGER: DEBUGGER,
MAXDEBUG: MAXDEBUG, // shared

View file

@ -153,7 +153,7 @@ var sMachineXMLFile = "machine.xml";
var sManifestXMLFile = "manifest.xml";
/*
* We need lists of the uncompiled scripts for C1Pjs and PCx86, indexed by machine class, so that if we have
* We need lists of the uncompiled scripts for C1P and PCx86, indexed by machine type, so that if we have
* to inject those individual scripts into the current document, all the ordering dependencies will be honored
* (which is why processMachines() can't simply enumerate all the .js files in the respective script folder).
*
@ -165,9 +165,10 @@ var sManifestXMLFile = "manifest.xml";
* the closing </head> tag, and JS files are added just before the closing </body> tag.
*/
var aMachineFiles = {
'c1p': pkg.c1pCSSFiles.concat(pkg.c1pJSFiles),
'pcx86': pkg.pcCSSFiles.concat(pkg.pcX86Files),
'pc8080': pkg.pcCSSFiles.concat(pkg.pc8080Files)
'C1P': pkg.c1pCSSFiles.concat(pkg.c1pJSFiles), // will be deprecated when PC6502 becomes available
'PC': pkg.pcCSSFiles.concat(pkg.pcX86Files), // deprecated (same as PCx86)
'PCx86': pkg.pcCSSFiles.concat(pkg.pcX86Files),
'PC8080': pkg.pcCSSFiles.concat(pkg.pc8080Files)
};
var aMachineFileTypes = {
'head': [".css"], // put BOTH ".css" and ".js" here if convertMDMachineLinks() embeds its own scripts
@ -1427,15 +1428,15 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
if (aMatch) {
var sStyleSheet = aMatch[1];
/*
* Recognized machine stylesheets are either "production" stylesheets in ("/versions/pcx86"|"/versions/c1pjs")
* or "development" stylesheets in ("/modules/pcx86/templates"|"/modules/c1pjs/templates").
* Recognized machine stylesheets are either production stylesheets in ("/versions/pcx86"|"/versions/c1pjs")
* or development stylesheets in ("/modules/pcx86/templates"|"/modules/c1pjs/templates").
*
* The common denominator in both sets is either "/pc" or "/c1p", which in turn indicates the class of machine
* (ie, "PCx86" or "C1Pjs").
* The common denominator in both sets is either "/pc" or "/c1p", which in turn indicates the type of machine
* (eg, "PC", "C1P", etc).
*/
aMatch = sStyleSheet.match(/\/(pc|c1p)([^/]*)/);
if (aMatch) {
var sMachineClass = aMatch[1].toUpperCase() + aMatch[2];
var sMachineType = aMatch[1].toUpperCase() + (aMatch[2] != "js"? aMatch[2] : "");
/*
* Since the MarkOut module already contains the ability to embed a machine definition with
* one simple line of Markdown-like magic, we'll create such a line and let MarkOut do the rest.
@ -1443,14 +1444,14 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
* The string we initialize the MarkOut object should look like one of
*
* '[Embedded PC](machine.xml "PCx86:machineID:stylesheet:version:options:state")'
* '[Embedded C1P](machine.xml "C1Pjs:machineID:stylesheet:version:options:state")'
* '[Embedded C1P](machine.xml "C1P:machineID:stylesheet:version:options:state")'
*
* where machineID is the machine "id" embedded in the XML, stylesheet is the path to the XML stylesheet,
* version is a version number ('*' or blank for the latest version, which is all we support here), and
* options is a comma-delimited series of, well, options; the only option we currently output is "debugger"
* if a <debugger> element is present in the machine XML.
*/
var sMachineID = "machine" + sMachineClass; // fallback to either "machinePCx86" or "machineC1Pjs" if no ID found
var sMachineID = "machine" + sMachineType; // fallback to either "machinePCx86" or "machineC1P" if no ID found
aMatch = sXML.match(/<machine.*?\sid=(['"])(.*?)\1[^>]*>/);
if (aMatch) sMachineID = aMatch[2];
@ -1460,11 +1461,11 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
* embedding inside an existing HTML document, so any "machine.xsl" stylesheet must be remapped
* to a corresponding "components.xsl" stylesheet (which is what the next line does).
*/
var sMachineDef = sMachineClass + ":" + sMachineID + ":" + sStyleSheet.replace("machine.xsl", "components.xsl");
var sMachineDef = sMachineType + ":" + sMachineID + ":" + sStyleSheet.replace("machine.xsl", "components.xsl");
sMachineDef += (sXML.indexOf("<debugger") > 0? ":*:debugger" : ":*:none");
sMachineDef += (sStateFile? ":" + sStateFile : "");
s = '[Embedded ' + sMachineClass + '](' + sXMLFile + ' "' + sMachineDef + '")';
s = '[Embedded ' + sMachineType + '](' + sXMLFile + ' "' + sMachineDef + '")';
var m = new MarkOut(s, sIndent, obj.req, null, obj.fDebug);
s = m.convertMD(" ").trim();
@ -1832,7 +1833,7 @@ HTMLOut.prototype.getRandomString = function(sIndent)
*
* At a minimum, each machine object should contain the following properties:
*
* 'class' (eg, a machine class, such as "pc" or "c1p")
* 'type' (eg, a machine type, such as "PCx86" or "C1P")
* 'version' (eg, "1.10", "*" to select the current version, or "uncompiled"; "*" is the default)
* 'debugger' (eg, true or false; false is the default)
*
@ -1849,7 +1850,7 @@ HTMLOut.prototype.processMachines = function(aMachines, buildOptions, done)
HTMLOut.logDebug('HTMLOut.processMachines(' + JSON.stringify(infoMachine) + ')');
var sClass = infoMachine['class']; // aka the machine class
var sType = infoMachine['type'];
var fCompiled = !this.fDebug;
var sVersion = infoMachine['version'];
@ -1878,13 +1879,14 @@ HTMLOut.prototype.processMachines = function(aMachines, buildOptions, done)
var asFiles = [];
if (fCompiled) {
var sScriptFolder = sClass + "js"; // aka the app class
var sScriptFile = sClass + (fDebugger? "-dbg" : "") + ".js";
var sScriptName = sType.toLowerCase();
var sScriptFile = sScriptName + (fDebugger? "-dbg" : "") + ".js";
var sScriptFolder = sScriptName + ((sType == "C1P" || sType == "PC")? "js" : "");
asFiles.push("/versions/" + sScriptFolder + "/" + sVersion + "/components.css");
asFiles.push("/versions/" + sScriptFolder + "/" + sVersion + "/" + sScriptFile);
this.addFilesToHTML(asFiles, sScriptEmbed);
}
else if (asFiles = aMachineFiles[sClass]) {
else if (asFiles = aMachineFiles[sType]) {
/*
* SIDEBAR: Why the "slice()"? It's a handy way to create a copy of the array, and we need a copy,
* because if it turns out we need to "cut out" some of the files below (using splice), we don't want that
@ -1935,6 +1937,9 @@ HTMLOut.prototype.processMachines = function(aMachines, buildOptions, done)
this.addFilesToHTML(asFiles, sScriptEmbed);
}
}
else {
HTMLOut.logDebug('HTMLOut.processMachines(): unrecognized machine type "' + sType + '"');
}
}
if (done) done();
};

View file

@ -232,7 +232,7 @@ MarkOut.setOptions = function(options)
* The infoMachine object should contain, at a minimum:
*
* {
* 'class': sMachineClass, // eg, "pcx86"
* 'type': sMachineType, // eg, "PCx86"
* 'func': sMachineFunc,
* 'id': sMachineID,
* 'xml': sMachineXMLFile,
@ -951,7 +951,7 @@ MarkOut.prototype.convertMDLinks = function(sBlock)
}
sURL = sURL.replace(/\*/g, pkg.version);
/*
* My own goofy way of defining a named anchor (by using an exclamation point) in Markdown....
* Check for my own syntax for defining a named anchor (by using an exclamation point) in Markdown....
*/
if (sURL.charAt(0) == '!') {
sTag = "span"; // using <a> to name an anchor is deprecated
@ -1097,9 +1097,9 @@ MarkOut.prototype.convertMDImageLinks = function(sBlock, sIndent)
*
* where a special title attribute triggers generation of an embedded machine rather than a link.
*
* Use "PCx86" or "C1Pjs" to automatically include the latest version of either "pcx86.js" or "c1p.js", followed
* Use "PCx86" or "C1P" to automatically include the latest version of either "pcx86.js" or "c1p.js", followed
* by a colon and the ID you want to use for the embedded <div>. If you need to use the script with the built-in
* Debugger (ie, either "pc-dbg.js" or "c1p-dbg.js"), then include "debugger" in the list of comma-delimited
* Debugger (ie, either "pcx86-dbg.js" or "c1p-dbg.js"), then include "debugger" in the list of comma-delimited
* options, as in:
*
* [IBM PC](/devices/pcx86/machine/5150/mda/64kb/ "PCx86:demoPC:::debugger")
@ -1135,7 +1135,7 @@ MarkOut.prototype.convertMDImageLinks = function(sBlock, sIndent)
MarkOut.prototype.convertMDMachineLinks = function(sBlock)
{
var aMatch, sReplacement;
var sMachine, sMachineID, sMachineXMLFile, sMachineXSLFile, sMachineVersion, sMachineOptions, sMachineParms;
var sMachineType, sMachineID, sMachineXMLFile, sMachineXSLFile, sMachineVersion, sMachineOptions, sMachineParms;
/*
* Before we start looking for Markdown-style machine links, see if there are any Liquid-style machines,
@ -1149,16 +1149,15 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
sMachineID = aMatch[2];
if (this.aMachineDefs[sMachineID]) {
var machine = this.aMachineDefs[sMachineID];
sMachine = machine['type'] || "pcx86";
sMachineOptions = ((sMachine.indexOf("-dbg") > 0 || machine['debugger'] == "true")? "debugger" : "");
sMachine = sMachine.replace("-dbg", "").toUpperCase();
sMachineType = machine['type'] || "PCx86";
sMachineOptions = ((sMachineType.indexOf("-dbg") > 0 || machine['debugger'] == "true")? "debugger" : "");
sMachineType = sMachineType.replace("-dbg", "");
sMachineXMLFile = machine['config'] || this.sMachineFile || "machine.xml";
sMachineXSLFile = machine['template'] || "";
sMachineVersion = ((machine['uncompiled'] == "true")? "uncompiled" : "");
sMachineParms = machine['parms'] || "";
sReplacement = machine['name'] || "Embedded PC";
if (sMachine == "pc" || sMachine == "c1p") sMachine += "js";
sReplacement = "[" + sReplacement + "](" + sMachineXMLFile + ' "' + sMachine + '!' + sMachineID + '!' + sMachineXSLFile + '!!' + sMachineOptions + '!' + sMachineParms + '")';
sReplacement = "[" + sReplacement + "](" + sMachineXMLFile + ' "' + sMachineType + '!' + sMachineID + '!' + sMachineXSLFile + '!!' + sMachineOptions + '!' + sMachineParms + '")';
}
sBlock = sBlock.replace(aMatch[0], sReplacement);
reIncludes.lastIndex = 0; // reset lastIndex, since we just modified the string that reIncludes is iterating over
@ -1170,20 +1169,17 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
* Start looking for Markdown-style machine links now...
*/
var cMatches = 0;
var reMachines = /\[(.*?)]\((.*?)\s*"(PC|C1P)([a-z0-9-]*)([:!|])(.*?)"\)/gi;
var reMachines = /\[(.*?)]\((.*?)\s*"(PC|C1P)([^:!|]*)([:!|])(.*?)"\)/gi;
while ((aMatch = reMachines.exec(sBlock))) {
sMachineXMLFile = aMatch[2];
if (sMachineXMLFile.slice(-1) == "/") sMachineXMLFile += "machine.xml";
sMachine = aMatch[3].toUpperCase();
if (aMatch[4] != "js") sMachine += aMatch[4];
var sMachineFunc = "embed" + sMachine;
var sMachineClass = sMachine.toLowerCase();
sMachineType = aMatch[3].toUpperCase() + (aMatch[4] != "js"? aMatch[4] : "");
var sMachineFunc = "embed" + sMachineType;
var aMachineParms = aMatch[6].split(aMatch[5]);
if (aMatch[4] == "js") sMachine += aMatch[4];
var sMachineMessage = "Waiting for " + sMachine + " to load";
var sMachineMessage = "Waiting for " + sMachineType + " to load";
sMachineID = aMachineParms[0];
sMachineXSLFile = aMachineParms[1] || "";
@ -1199,7 +1195,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
sReplacement = '<div id="' + sMachineID + '" class="machine-placeholder"><p>' + aMatch[1] + '</p><p class="machine-warning">' + sMachineMessage + '</p></div>\n';
/*
* The embedPC()/embedC1P functions take an XSL file as the 3rd parameter, which defaults to:
* The embedXXX() functions take an XSL file as the 3rd parameter, which defaults to:
*
* "/versions/" + APPCLASS + "/" + APPVERSION + "/components.xsl"
*
@ -1208,7 +1204,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
*/
if (!sMachineXSLFile || sMachineXSLFile.indexOf("components.xsl") >= 0) {
if (this.fDebug) {
if (sMachineClass == "c1p") {
if (sMachineType == "C1P") {
sMachineXSLFile = "/modules/c1pjs/templates/components.xsl";
} else {
sMachineXSLFile = "/modules/shared/templates/components.xsl";
@ -1228,7 +1224,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
cMatches++;
this.addMachine({
'class': sMachineClass, // eg, a machine class, such as "pc" or "c1p"
'type': sMachineType, // eg, a machine type, such as "PCx86" or "C1P"
'func': sMachineFunc,
'id': sMachineID,
'xml': sMachineXMLFile,

View file

@ -84,6 +84,7 @@ var PC8080 = {
APPVERSION: APPVERSION, // shared
BYTEARRAYS: BYTEARRAYS,
COMPILED: COMPILED, // shared
CSSCLASS: CSSCLASS, // shared
DEBUG: DEBUG, // shared
DEBUGGER: DEBUGGER,
MAXDEBUG: MAXDEBUG, // shared

View file

@ -130,7 +130,7 @@ function ChipSet(parmsChipSet)
bSwitches = this.parseDIPSwitches(parmsChipSet[ChipSet.CONTROLS.SW2]);
this.aDIPSwitches[1] = [bSwitches, bSwitches];
this.sCellClass = PCX86.APPCLASS + "-bitCell";
this.sCellClass = PCX86.CSSCLASS + "-bitCell";
this.cDMACs = this.cPICs = 1;
if (this.model >= ChipSet.MODEL_5170) {

View file

@ -159,6 +159,7 @@ var PCX86 = {
BUGS_8086: BUGS_8086,
BYTEARRAYS: BYTEARRAYS,
COMPILED: COMPILED, // shared
CSSCLASS: CSSCLASS, // shared
DEBUG: DEBUG, // shared
DEBUGGER: DEBUGGER,
DESKPRO386: DESKPRO386,

View file

@ -1399,24 +1399,27 @@ FDC.prototype.mountDiskette = function(iDrive, sDisketteName, sDiskettePath)
FDC.prototype.loadDiskette = function(iDrive, sDisketteName, sDiskettePath, fAutoMount, file)
{
var drive = this.aDrives[iDrive];
if (sDiskettePath && drive.sDiskettePath != sDiskettePath) {
this.unloadDrive(iDrive, fAutoMount, true);
if (drive.fBusy) {
this.notice("Drive " + iDrive + " busy");
return 0;
if (sDiskettePath) {
sDiskettePath = sDiskettePath.replace("/disks/pc/", "/disks/pcx86/");
if (drive.sDiskettePath != sDiskettePath) {
this.unloadDrive(iDrive, fAutoMount, true);
if (drive.fBusy) {
this.notice("Drive " + iDrive + " busy");
return 0;
}
drive.fBusy = true;
if (fAutoMount) {
drive.fAutoMount = true;
this.cAutoMount++;
if (this.messageEnabled()) this.printMessage("loading diskette '" + sDisketteName + "'");
}
drive.fLocal = !!file;
var disk = new Disk(this, drive, DiskAPI.MODE.PRELOAD);
if (!disk.load(sDisketteName, sDiskettePath, file, this.doneLoadDiskette)) {
return 0;
}
return 1;
}
drive.fBusy = true;
if (fAutoMount) {
drive.fAutoMount = true;
this.cAutoMount++;
if (this.messageEnabled()) this.printMessage("loading diskette '" + sDisketteName + "'");
}
drive.fLocal = !!file;
var disk = new Disk(this, drive, DiskAPI.MODE.PRELOAD);
if (!disk.load(sDisketteName, sDiskettePath, file, this.doneLoadDiskette)) {
return 0;
}
return 1;
}
return -1;
};

View file

@ -42,6 +42,8 @@ var COPYRIGHT = "Copyright © 2012-2016 Jeff Parsons <Jeff@pcjs.org>";
var LICENSE = "License: GPL version 3 or later <http://gnu.org/licenses/gpl.html>";
var CSSCLASS = "pcjs";
/**
* @define {string}
*/
@ -80,6 +82,8 @@ if (NODE) {
global.APPVERSION = APPVERSION;
global.XMLVERSION = XMLVERSION;
global.COPYRIGHT = COPYRIGHT;
global.LICENSE = LICENSE;
global.CSSCLASS = CSSCLASS;
global.SITEHOST = SITEHOST;
global.COMPILED = COMPILED;
global.DEBUG = DEBUG;

View file

@ -488,6 +488,20 @@ function embedMachine(sName, sVersion, idMachine, sXMLFile, sXSLFile, sParms)
eMachine.parentNode.replaceChild(eFragment, eMachine);
doneMachine();
} else {
/*
* NOTE: This error can occur if our Node web server, when processing a folder with
* both a manifest.xml with a machine.xml reference AND a README.md containing a
* machine link, generates duplicate embedXXX() calls for the same machine; if the
* first embedXXX() call finds its target, subsequent calls for the same target will
* fail.
*
* Technically, such a folder is in a misconfigured state, but it happens, in part
* because when we switched to the Jekyll web server, we had to add machine links to
* all README.md files where we had previously relied on manifest.xml or machine.xml
* processing. This is because the Jekyll web server currently doesn't process XML
* files, nor is support for that likely to be added any time soon; it was a nice
* feature of the Node web server, but it's not clear that it's worth doing for Jekyll.
*/
displayError("invalid machine element: " + idMachine);
}
} else {

View file

@ -1,6 +1,6 @@
<!DOCTYPE html>
<!-- Some browsers tend to display a white page before displaying one of our dark pages, which causes annoying "flashes";
setting a background color as early as possible seems to help -->
<!-- Some browsers tend to display a white page before displaying one of our dark pages,
which causes annoying "flashes"; setting a background color as early as possible seems to help -->
<html style="background-color: #1d1d1d">
<head>
<title>pcjs.org | <!-- pcjs:title("The Original IBM PC In Your Web Browser") --></title>
@ -31,9 +31,9 @@
<div class="common-top-left">
<ul>
<li><a href="/">PCjs</a></li>
<li><a href="/apps/pc/">Demos</a></li>
<li><a href="/apps/pcx86/">Demos</a></li>
<li><a href="/devices/">Devices</a></li>
<li><a href="/disks/pc/">Disks</a></li>
<li><a href="/disks/pcx86/">Disks</a></li>
<li><a href="/docs/">Docs</a></li>
<li><a href="/pubs/">Pubs</a></li>
<li><a href="/blog/">Blog</a></li>

View file

@ -33,9 +33,9 @@
<div class="common-top-left">
<ul>
<li><a href="/">PCjs</a></li>
<li><a href="/apps/pc/">Demos</a></li>
<li><a href="/apps/pcx86/">Demos</a></li>
<li><a href="/devices/">Devices</a></li>
<li><a href="/disks/pc/">Disks</a></li>
<li><a href="/disks/pcx86/">Disks</a></li>
<li><a href="/docs/">Docs</a></li>
<li><a href="/pubs/">Pubs</a></li>
<li><a href="/blog/">Blog</a></li>

View file

@ -64,7 +64,7 @@
<xsl:variable name="machineClass">
<xsl:choose>
<xsl:when test="machine/@class"><xsl:value-of select="machine/@class"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$MACHINECLASS"/></xsl:otherwise>
<xsl:otherwise><xsl:value-of select="$APPCLASS"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<html lang="en">