From 5b7dce12247e67fbdc791a6e49a0e61bdd7ffaec Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Mon, 1 Feb 2016 10:00:05 -0800 Subject: [PATCH] Add the ability to pass through any string property to PCjs declared at the top of the Markdown file --- _config.yml | 2 +- _includes/machine-engines.html | 2 +- disks/pc/os2/misc/football/87058/README.md | 1 + modules/markout/lib/markout.js | 46 ++++++++++++++++++---- modules/pcjs/lib/debugger.js | 8 +++- modules/pcjs/lib/fdc.js | 2 +- modules/shared/lib/strlib.js | 2 +- 7 files changed, 51 insertions(+), 12 deletions(-) diff --git a/_config.yml b/_config.yml index 9d3b8d542..97d2033ca 100644 --- a/_config.yml +++ b/_config.yml @@ -32,7 +32,7 @@ gems: pcjs: domain: pcjs.org # whereas site.url is used for linking purposes, site.pcjs.domain is used for display purposes version: 1.20.8 # IMPORTANT: keep pcjs.version in sync with package.json:version - compiled: true # by default, the compiled pcjs.version scripts will be used (eg, pc.js or pc-dbg.js) + compiled: false # by default, the compiled pcjs.version scripts will be used (eg, pc.js or pc-dbg.js) pc_scripts: # if pcjs.compiled is false, the following scripts will be included instead, in the order listed - /modules/shared/lib/defines.js - /modules/shared/lib/diskapi.js diff --git a/_includes/machine-engines.html b/_includes/machine-engines.html index a299df49c..1179183e6 100644 --- a/_includes/machine-engines.html +++ b/_includes/machine-engines.html @@ -10,7 +10,7 @@ {% else %} {% assign machine_template = machine.template %} {% endunless %} - {% capture machine_parms %}{{ site.left_brace }}state:"{{ machine.state }}",autoMount:{{ machine.automount|jsonify }}{{ site.right_brace }}{% endcapture %} + {% capture machine_parms %}{{ site.left_brace }}state:"{{ machine.state }}",autoMount:{{ machine.automount|jsonify }},messages:"{{ machine.messages }}"{{ site.right_brace }}{% endcapture %} {% if site.pcjs.compiled == true and machine.uncompiled != true %} {% capture machine_script %}{% endcapture %} {% unless machine_scripts contains machine_script %} diff --git a/disks/pc/os2/misc/football/87058/README.md b/disks/pc/os2/misc/football/87058/README.md index 67bfbc594..1ce2bf665 100644 --- a/disks/pc/os2/misc/football/87058/README.md +++ b/disks/pc/os2/misc/football/87058/README.md @@ -9,6 +9,7 @@ machines: automount: A: path: /disks/pc/os2/misc/football/FOOTBALL-76817.json + messages: disk --- OS/2 FOOTBALL Boot Disk (v7.68.17) diff --git a/modules/markout/lib/markout.js b/modules/markout/lib/markout.js index 6adc77e9e..d2e5819f2 100644 --- a/modules/markout/lib/markout.js +++ b/modules/markout/lib/markout.js @@ -308,6 +308,28 @@ MarkOut.aHTMLEntities = { "\\!": "!" }; +/* + * This is a list of "reserved" Front Matter machine properties (ie, properties that will NOT be + * bundled as strings in the 'parms' property). Any machine property not in this list will be added + * to the 'parms' object as a string property. + * + * 'id' (eg, "ibm5150") + * 'type' (eg, "pc") + * 'config' (eg, "machine.xml") + * 'template' (eg, "machine.xsl") + * 'uncompiled' (eg, true) + * 'automount' (eg, {"A":{"name":"OS/2 FOOTBALL Boot Disk (v7.68.17)","path":"/disks/pc/os2/misc/football/debugger/FOOTBALL-7.68.17.json"}}) + * 'parms' + * + * Non-reserved properties include: + * + * 'state' (eg, "state.json") + * 'messages' (eg, "disk") + * + * and any other string-based property you wish to pass through to PCjs (via the embedPC() sParms parameter). + */ +MarkOut.aFMReservedMachineProps = ['id', 'type', 'config', 'template', 'uncompiled', 'automount', 'parms']; + /** * convertMD() * @@ -377,30 +399,33 @@ MarkOut.prototype.convertMD = function(sIndent) var asMachines = aMachineDefs[1].split(/\n[ \t]+-\s*/); for (var iMachine = 0; iMachine < asMachines.length; iMachine++) { if (!asMachines[iMachine]) continue; - var id = null; + var id = null, iProp, sProp; var aOptions, aaOptions = [], machine = {}; var reOption = /([ \t]*)([^\s]+):[ \t]*([^\n]*)/g; while (aOptions = reOption.exec(asMachines[iMachine])) { aaOptions.push(aOptions); } for (var iOption = 0; iOption < aaOptions.length; iOption++) { - var aOptions = aaOptions[iOption]; + aOptions = aaOptions[iOption]; var sSpace = aOptions[1], sName = aOptions[2], sValue = aOptions[3]; if (!id && sName == 'id') { id = sValue; } else if (sName == 'automount') { /* * I take a simplistic approach to parsing the object definition associated with "automount", - * because I know it only consist of 1 or more drive letters, each of which may be followed by - * 1 or 2 additional properties (eg, "name" and "path"). If we need to support other JSON + * because I know it only consists of 1 or more drive letters, each of which may be followed + * by 1 or 2 additional properties (eg, "name" and "path"). If we need to support other JSON * object definitions in the future, this will have to be generalized. * * Here's an example of "automount" output: * * {"A":{"name":"OS/2 FOOTBALL Boot Disk (v7.68.17)","path":"/disks/pc/os2/misc/football/debugger/FOOTBALL-7.68.17.json"}} + * + * Note that the the only required property for a drive object is 'path'; if 'name' is omitted, + * the FDC component will search for the given 'path' and use whatever name it can find. */ sValue = '{'; - var cDrives = 0, cProps = 0, iProp; + var cDrives = 0, cProps = 0; for (iProp = iOption + 1; iProp < aaOptions.length; iProp++) { var sPropSpace = aaOptions[iProp][1]; if (sPropSpace.length <= sSpace.length) break; @@ -423,9 +448,16 @@ MarkOut.prototype.convertMD = function(sIndent) machine[sName] = sValue; } /* - * Any 'state' and 'automount' properties must now be merged into a 'parms' property. + * Any "non-reserved" properties are now merged into the 'parms' property; 'automount' + * is treated as reserved only because it must be encoded as an object rather than a string. */ - machine['parms'] = '{state:"' + (machine['state'] || "") + '",autoMount:' + machine['automount'] + '}'; + machine['parms'] = '{'; + for (sProp in machine) { + if (MarkOut.aFMReservedMachineProps.indexOf(sProp) < 0) { + machine['parms'] += sProp + ':"' + machine[sProp] + '",'; + } + } + machine['parms'] += 'autoMount:' + machine['automount'] + '}'; if (id) this.aMachineDefs[id] = machine; } } diff --git a/modules/pcjs/lib/debugger.js b/modules/pcjs/lib/debugger.js index dc8802644..f26299d74 100644 --- a/modules/pcjs/lib/debugger.js +++ b/modules/pcjs/lib/debugger.js @@ -250,6 +250,7 @@ function Debugger(parmsDbg) /* * Initialize Debugger message support */ + this.afnDumpers = []; this.messageInit(parmsDbg['messages']); this.sInitCommands = parmsDbg['commands']; @@ -1471,6 +1472,12 @@ if (DEBUGGER) { this.mouse = cmp.getMachineComponent("Mouse"); if (MAXDEBUG) this.chipset = cmp.getMachineComponent("ChipSet"); + /* + * Re-initialize Debugger message support if necessary + */ + var sMessages = cmp.getMachineParm('messages'); + if (sMessages) this.messageInit(sMessages); + this.cchAddr = bus.getWidth() >> 2; this.maskAddr = bus.nBusLimit; @@ -3320,7 +3327,6 @@ if (DEBUGGER) { this.dbg = this; this.bitsMessage = this.bitsWarning = Messages.WARN; this.sMessagePrev = null; - this.afnDumpers = []; /* * Internally, we use "key" instead of "keys", since the latter is a method on JavasScript objects, * but externally, we allow the user to specify "keys"; "kbd" is also allowed as shorthand for "keyboard". diff --git a/modules/pcjs/lib/fdc.js b/modules/pcjs/lib/fdc.js index 51cd35c8e..8654ec66e 100644 --- a/modules/pcjs/lib/fdc.js +++ b/modules/pcjs/lib/fdc.js @@ -1441,7 +1441,7 @@ FDC.prototype.findDiskette = function(sPath) } } } - return null; + return str.getBaseName(sPath, true); }; /** diff --git a/modules/shared/lib/strlib.js b/modules/shared/lib/strlib.js index 8904e7006..7d0b3c9e7 100644 --- a/modules/shared/lib/strlib.js +++ b/modules/shared/lib/strlib.js @@ -249,7 +249,7 @@ str.toHexLong = function(l) * * This is a poor-man's version of Node's path.basename(), which Node-only components should use instead. * - * Note that fStripExt can be used to strip ANY extension, whereas path.basename() will strip the extension only + * Note that if fStripExt is true, this strips ANY extension, whereas path.basename() strips the extension only * if it matches the second parameter (eg, path.basename("/foo/bar/baz/asdf/quux.html", ".html") returns "quux"). * * @param {string} sFileName