Some minor changes to make it easier to load a machine in the Node environment
This commit is contained in:
parent
5e2073f3ac
commit
d930b31c53
38 changed files with 4216 additions and 3743 deletions
|
|
@ -156,7 +156,7 @@ function C1PVideo(parmsVideo, canvas, context, imgChars)
|
|||
*/
|
||||
var i, sEvent, asWebPrefixes = ['', 'moz', 'ms', 'webkit'];
|
||||
var fSmoothing = parmsVideo['smoothing'];
|
||||
var sSmoothing = Component.parmsURL['smoothing'];
|
||||
var sSmoothing = web.getURLParm('smoothing');
|
||||
if (sSmoothing) fSmoothing = (sSmoothing == "true");
|
||||
if (fSmoothing != null) {
|
||||
for (i = 0; i < asWebPrefixes.length; i++) {
|
||||
|
|
|
|||
|
|
@ -3243,6 +3243,6 @@ DiskDump.prototype.encodeAsBase64 = function(buf)
|
|||
if (NODE) {
|
||||
module.exports = DiskDump;
|
||||
} else {
|
||||
var aParms = web.getURLParameters();
|
||||
var aParms = web.parseURLParms();
|
||||
DiskDump.API(aParms);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,13 +351,13 @@ Computer.prototype.setMachineParms = function(parmsMachine)
|
|||
Computer.prototype.getMachineParm = function(sParm, parmsComponent)
|
||||
{
|
||||
/*
|
||||
* When checking parmsURL, the check is allowed be a bit looser, because URL parameters are
|
||||
* When using getURLParm(), the check is allowed be a bit looser, because URL parameters are
|
||||
* user-supplied, whereas most other parameters are developer-supplied. Granted, a developer
|
||||
* may also be sloppy and neglect to use correct case (eg, 'automount' instead of 'autoMount'),
|
||||
* but there are limits to my paranoia.
|
||||
*/
|
||||
var sParmLC = sParm.toLowerCase();
|
||||
var value = Component.parmsURL[sParm] || Component.parmsURL[sParmLC];
|
||||
var value = web.getURLParm(sParm) || web.getURLParm(sParmLC);
|
||||
|
||||
if (value === undefined && this.parmsMachine) {
|
||||
value = this.parmsMachine[sParm];
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ function Video(parmsVideo, canvas, context, textarea, container)
|
|||
* that's apparently been added to Chrome. Sigh.
|
||||
*/
|
||||
var fSmoothing = parmsVideo['smoothing'];
|
||||
var sSmoothing = Component.parmsURL['smoothing'];
|
||||
var sSmoothing = web.getURLParm('smoothing');
|
||||
if (sSmoothing) fSmoothing = (sSmoothing == "true");
|
||||
if (fSmoothing != null) {
|
||||
for (i = 0; i < asWebPrefixes.length; i++) {
|
||||
|
|
@ -625,7 +625,7 @@ Video.init = function()
|
|||
* until we figure out a better UI. And note that we use our web.onPageEvent() helper function to make
|
||||
* sure we don't trample any other 'onresize' handler(s) attached to the window object.
|
||||
*/
|
||||
var aspect = +(parmsVideo['aspect'] || Component.parmsURL['aspect']);
|
||||
var aspect = +(parmsVideo['aspect'] || web.getURLParm('aspect'));
|
||||
/*
|
||||
* No 'aspect' parameter yields NaN, which is falsey, and anything else must satisfy my arbitrary
|
||||
* constraints of 0.3 <= aspect <= 3.33, to prevent any useless (or worse, browser-blowing) results.
|
||||
|
|
|
|||
|
|
@ -342,13 +342,13 @@ Computer8080.prototype.setMachineParms = function(parmsMachine)
|
|||
Computer8080.prototype.getMachineParm = function(sParm, parmsComponent)
|
||||
{
|
||||
/*
|
||||
* When checking parmsURL, the check is allowed be a bit looser, because URL parameters are
|
||||
* When using getURLParm(), the check is allowed be a bit looser, because URL parameters are
|
||||
* user-supplied, whereas most other parameters are developer-supplied. Granted, a developer
|
||||
* may also be sloppy and neglect to use correct case (eg, 'automount' instead of 'autoMount'),
|
||||
* but there are limits to my paranoia.
|
||||
*/
|
||||
var sParmLC = sParm.toLowerCase();
|
||||
var value = Component.parmsURL[sParm] || Component.parmsURL[sParmLC];
|
||||
var value = web.getURLParm(sParm) || web.getURLParm(sParmLC);
|
||||
|
||||
if (value === undefined && this.parmsMachine) {
|
||||
value = this.parmsMachine[sParm];
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ function Video8080(parmsVideo, canvas, context, textarea, container)
|
|||
* that's apparently been added to Chrome. Sigh.
|
||||
*/
|
||||
var fSmoothing = parmsVideo['smoothing'];
|
||||
var sSmoothing = Component.parmsURL['smoothing'];
|
||||
var sSmoothing = web.getURLParm('smoothing');
|
||||
if (sSmoothing) fSmoothing = (sSmoothing == "true");
|
||||
if (fSmoothing != null) {
|
||||
for (i = 0; i < asWebPrefixes.length; i++) {
|
||||
|
|
@ -1410,7 +1410,7 @@ Video8080.init = function()
|
|||
* until we figure out a better UI. And note that we use our web.onPageEvent() helper function to make
|
||||
* sure we don't trample any other 'onresize' handler(s) attached to the window object.
|
||||
*/
|
||||
var aspect = +(parmsVideo['aspect'] || Component.parmsURL['aspect']);
|
||||
var aspect = +(parmsVideo['aspect'] || web.getURLParm('aspect'));
|
||||
/*
|
||||
* No 'aspect' parameter yields NaN, which is falsey, and anything else must satisfy my arbitrary
|
||||
* constraints of 0.3 <= aspect <= 3.33, to prevent any useless (or worse, browser-blowing) results.
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
/**
|
||||
* @fileoverview Implements the PCx86 command-line interface
|
||||
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
|
||||
* @version 1.0
|
||||
* @copyright © Jeff Parsons 2012-2016
|
||||
* @suppress {missingProperties}
|
||||
* Created 2012-Sep-04
|
||||
*
|
||||
* Copyright © 2012-2016 Jeff Parsons <Jeff@pcjs.org>
|
||||
*
|
||||
* This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
|
||||
*
|
||||
|
|
@ -218,7 +215,7 @@ function loadMachine(sFile)
|
|||
*
|
||||
* TODO: I've since removed the comments from my sample "ibm5150.json" file, so we could
|
||||
* try to reinstate this code; however, there are still hex constants, which I find *much*
|
||||
* preferable to the decimal equivalents. JSON's restrictions continue to infuriate me.
|
||||
* preferable to the decimal equivalents. JSON's restrictions continue to irritate me.
|
||||
*
|
||||
* var machine = require(lib + "../bin/" +sFile);
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -371,13 +371,13 @@ Computer.prototype.setMachineParms = function(parmsMachine)
|
|||
Computer.prototype.getMachineParm = function(sParm, parmsComponent)
|
||||
{
|
||||
/*
|
||||
* When checking parmsURL, the check is allowed be a bit looser, because URL parameters are
|
||||
* When using getURLParm(), the check is allowed be a bit looser, because URL parameters are
|
||||
* user-supplied, whereas most other parameters are developer-supplied. Granted, a developer
|
||||
* may also be sloppy and neglect to use correct case (eg, 'automount' instead of 'autoMount'),
|
||||
* but there are limits to my paranoia.
|
||||
*/
|
||||
var sParmLC = sParm.toLowerCase();
|
||||
var value = Component.parmsURL[sParm] || Component.parmsURL[sParmLC];
|
||||
var value = web.getURLParm(sParm) || web.getURLParm(sParmLC);
|
||||
|
||||
if (value === undefined && this.parmsMachine) {
|
||||
value = this.parmsMachine[sParm];
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ function Video(parmsVideo, canvas, context, textarea, container)
|
|||
* that's apparently been added to Chrome. Sigh.
|
||||
*/
|
||||
var fSmoothing = parmsVideo['smoothing'];
|
||||
var sSmoothing = Component.parmsURL['smoothing'];
|
||||
var sSmoothing = web.getURLParm('smoothing');
|
||||
if (sSmoothing) fSmoothing = (sSmoothing == "true");
|
||||
if (fSmoothing != null) {
|
||||
for (i = 0; i < asWebPrefixes.length; i++) {
|
||||
|
|
@ -7303,7 +7303,7 @@ Video.init = function()
|
|||
* until we figure out a better UI. And note that we use our web.onPageEvent() helper function to make
|
||||
* sure we don't trample any other 'onresize' handler(s) attached to the window object.
|
||||
*/
|
||||
var aspect = +(parmsVideo['aspect'] || Component.parmsURL['aspect']);
|
||||
var aspect = +(parmsVideo['aspect'] || web.getURLParm('aspect'));
|
||||
/*
|
||||
* No 'aspect' parameter yields NaN, which is falsey, and anything else must satisfy my arbitrary
|
||||
* constraints of 0.3 <= aspect <= 3.33, to prevent any useless (or worse, browser-blowing) results.
|
||||
|
|
|
|||
404
modules/pdp11/bin/pdp11
Normal file
404
modules/pdp11/bin/pdp11
Normal file
|
|
@ -0,0 +1,404 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* @fileoverview Implements the PDP11 command-line interface
|
||||
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
|
||||
* @copyright © Jeff Parsons 2012-2016
|
||||
* @suppress {missingProperties}
|
||||
*
|
||||
* This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
|
||||
*
|
||||
* PCjs is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either version 3
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCjs. If not,
|
||||
* see <http://www.gnu.org/licenses/gpl.html>.
|
||||
*
|
||||
* You are required to include the above copyright notice in every modified copy of this work
|
||||
* and to display that copyright notice when the software starts running; see COPYRIGHT in
|
||||
* <http://pcjs.org/modules/shared/lib/defines.js>.
|
||||
*
|
||||
* Some PCjs files also attempt to load external resource files, such as character-image files,
|
||||
* ROM files, and disk image files. Those external resource files are not considered part of PCjs
|
||||
* for purposes of the GNU General Public License, and the author does not claim any copyright
|
||||
* as to their contents.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var repl = require("repl");
|
||||
var Defines = require("../../shared/es6/defines");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Proc = require("../../shared/es6/proclib");
|
||||
|
||||
var fConsole = false;
|
||||
var fDebug = false;
|
||||
var args = Proc.getArgs();
|
||||
var argv = args.argv;
|
||||
var sCmdPrev = "";
|
||||
if (argv['console'] !== undefined) fConsole = argv['console'];
|
||||
if (argv['debug'] !== undefined) fDebug = argv['debug'];
|
||||
|
||||
var lib = path.join(path.dirname(fs.realpathSync(__filename)), "../lib/");
|
||||
|
||||
try {
|
||||
var pkg = require(lib + "../../../package.json");
|
||||
} catch(err) {
|
||||
console.log(err.message);
|
||||
}
|
||||
|
||||
/*
|
||||
* We will build an array of components whose names will match the component names
|
||||
* used in a JSON machine definition file; eg:
|
||||
*
|
||||
* [
|
||||
* {name: "panel",
|
||||
* Create: Panel,
|
||||
* objects: []
|
||||
* },
|
||||
* {name: "chipset":
|
||||
* Create: ChipSet,
|
||||
* objects: []
|
||||
* },
|
||||
* ...
|
||||
* ]
|
||||
*
|
||||
* Every component name comes from the component filename, minus the ".js" extension;
|
||||
* Create is the constructor returned by require().
|
||||
*
|
||||
* TODO: Update the list of ignored (ie, ignorable) components.
|
||||
*/
|
||||
var Component;
|
||||
var dbg;
|
||||
var aComponents = [];
|
||||
var asComponentsIgnore = ["embed", "save"];
|
||||
|
||||
/*
|
||||
* A few of the components are subclasses of other classes (eg, "cpustate" is a subclass of "cpu").
|
||||
* In those situations, we "hoist" the subclass constructor into the corresponding superclass,
|
||||
* because it is the name of the superclass that we rely on during machine initialization.
|
||||
*/
|
||||
var aSubClasses = {
|
||||
"pdp11/lib/cpustate": "pdp11/lib/cpu",
|
||||
"pdp11/lib/debugger": "shared/es6/debugger"
|
||||
};
|
||||
|
||||
/**
|
||||
* loadComponents(asFiles)
|
||||
*
|
||||
* @param {Array.<string>} asFiles
|
||||
*/
|
||||
function loadComponents(asFiles)
|
||||
{
|
||||
for (var i = 0; i < asFiles.length; i++) {
|
||||
var sFile = asFiles[i];
|
||||
if (Str.getExtension(sFile) != "js") continue;
|
||||
var sName = Str.getBaseName(sFile, true);
|
||||
if (asComponentsIgnore.indexOf(sName) >= 0) continue;
|
||||
if (fDebug) console.log(sFile);
|
||||
try {
|
||||
/*
|
||||
* We COULD load ("require") all the files on-demand, because it's only the
|
||||
* browser initialization sequence we want to mimic in loadMachine(), but this
|
||||
* is simpler, and it also gives us direct references to certain components
|
||||
* we'll want to access later (eg, "component" in getComponentByType()).
|
||||
*/
|
||||
var fn = require(lib + "../../../" + sFile);
|
||||
var sSuperClass = null;
|
||||
for (var s in aSubClasses) {
|
||||
if (sFile.indexOf(s) >= 0) {
|
||||
sSuperClass = aSubClasses[s];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sSuperClass) {
|
||||
for (var j = 0; j < aComponents.length; j++) {
|
||||
if (aComponents[j].path.indexOf(sSuperClass) >= 0) {
|
||||
if (fDebug) console.log("updating superclass " + aComponents[j].path + " with subclass " + sFile);
|
||||
aComponents[j].Create = fn;
|
||||
sName = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sName == "component") {
|
||||
fn.log = fn.println = function(s, type) {
|
||||
console.log((type !== undefined? (type + ": ") : "") + (s || ""));
|
||||
}; // jshint ignore:line
|
||||
}
|
||||
if (sName) {
|
||||
aComponents.push({name: sName, path: sFile, Create: fn, objects: []});
|
||||
}
|
||||
if (sName == "defines") {
|
||||
/*
|
||||
* Enabling component console messages requires setting CONSOLE to true.
|
||||
*/
|
||||
if (global.DEBUG !== undefined) {
|
||||
global.DEBUG = fDebug;
|
||||
global.CONSOLE = fConsole;
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getComponentByName(sName)
|
||||
*
|
||||
* @param sName
|
||||
* @return {*}
|
||||
*/
|
||||
function getComponentByName(sName)
|
||||
{
|
||||
for (var i = 0; i < aComponents.length; i++) {
|
||||
if (aComponents[i].name == sName) {
|
||||
return aComponents[i].Create;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* getComponentByType(sType)
|
||||
*
|
||||
* @param sType
|
||||
* @return {*}
|
||||
*/
|
||||
function getComponentByType(sType)
|
||||
{
|
||||
var component = null;
|
||||
|
||||
if (!Component) {
|
||||
Component = getComponentByName("component");
|
||||
}
|
||||
if (Component) {
|
||||
component = Component.getComponentByType(sType);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* loadMachine(sFile)
|
||||
*
|
||||
* @param {string} sFile
|
||||
* @return {Object} representing the machine whose component objects have been loaded into aComponents
|
||||
*/
|
||||
function loadMachine(sFile)
|
||||
{
|
||||
if (fDebug) console.log('loadMachine("' + sFile + '")');
|
||||
|
||||
/*
|
||||
* Clear any/all saved objects from any previous machine
|
||||
*/
|
||||
var i, j;
|
||||
Component = dbg = null;
|
||||
for (i = 0; i < aComponents.length; i++) {
|
||||
aComponents[i].objects = [];
|
||||
}
|
||||
|
||||
var machine;
|
||||
try {
|
||||
/*
|
||||
* Since our JSON files may contain comments, hex values, and/or other tokens deemed
|
||||
* unacceptable by the JSON Overlords, we can't use require() to load it, as we're able to
|
||||
* do with "package.json". Also note that require() assumes the same path as that of the
|
||||
* requiring file, whereas fs.readFileSync() assumes the path reported by process.cwd().
|
||||
*
|
||||
* TODO: I've since removed the comments from my sample "ibm5150.json" file, so we could
|
||||
* try to reinstate this code; however, there are still hex constants, which I find *much*
|
||||
* preferable to the decimal equivalents. JSON's restrictions continue to irritate me.
|
||||
*
|
||||
* var machine = require(lib + "../bin/" +sFile);
|
||||
*/
|
||||
var sMachine = fs.readFileSync(sFile, {encoding: "utf8"});
|
||||
sMachine = '(' + sMachine + ')';
|
||||
if (fDebug) console.log(sMachine);
|
||||
machine = eval(sMachine); // jshint ignore:line
|
||||
if (machine) {
|
||||
/*
|
||||
* Since we have a machine object, we now mimic the initialization sequence that occurs
|
||||
* in the browser, by walking the list of PDPjs components we loaded above and looking for
|
||||
* matches.
|
||||
*/
|
||||
var idMachine = "";
|
||||
|
||||
/*
|
||||
* 'machine' is a pseudo-component that is only used to define an ID for the entire machine;
|
||||
* if it exists, then that ID is prepended to every component ID, just as our XSLT code would
|
||||
* do for a machine XML file. This relieves the JSON file from having to manually prepend
|
||||
* a machine ID to every component ID itself.
|
||||
*
|
||||
* This doesn't mean I anticipate a Node environment running multiple machines, as we do in
|
||||
* a browser; it only means that I'm trying to make both environments operate similarly.
|
||||
*/
|
||||
if (machine['machine']) {
|
||||
idMachine = machine['machine']['id'];
|
||||
}
|
||||
|
||||
for (i = 0; i < aComponents.length; i++) {
|
||||
|
||||
var component = aComponents[i];
|
||||
var parms = machine[component.name];
|
||||
/*
|
||||
* If parms is undefined, it means there is no component with that name defined in the
|
||||
* machine object (NOT that the component has no parms), and therefore we should skip it.
|
||||
*/
|
||||
if (parms === undefined) continue;
|
||||
/*
|
||||
* If parms is an Array, then we must create an object for each parms element; and yes,
|
||||
* I'm relying on the fact that none of my parm objects use a "length" property, as a quick
|
||||
* and dirty way of differentiating objects from arrays.
|
||||
*/
|
||||
var aParms = parms.length !== undefined? parms : [parms];
|
||||
for (j = 0; j < aParms.length; j++) {
|
||||
|
||||
var obj;
|
||||
var parmsObj = aParms[j];
|
||||
if (idMachine) parmsObj['id'] = idMachine + '.' + parmsObj['id'];
|
||||
|
||||
if (fDebug) {
|
||||
console.log("creating " + component.name + "...");
|
||||
console.log(parmsObj);
|
||||
}
|
||||
|
||||
if (component.name == "cpu") {
|
||||
parmsObj['autoStart'] = false;
|
||||
}
|
||||
|
||||
try {
|
||||
obj = new component.Create(parmsObj);
|
||||
} catch(err) {
|
||||
console.log("error creating " + component.name + ": " + err.message);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(obj['id'] + " object created");
|
||||
component.objects.push(obj);
|
||||
|
||||
if (obj.type == "Debugger") {
|
||||
dbg = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Return the original machine object only in DEBUG mode
|
||||
*/
|
||||
if (!fDebug) machine = true;
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.message);
|
||||
}
|
||||
return machine;
|
||||
}
|
||||
|
||||
/**
|
||||
* doCommand(sCmd)
|
||||
*
|
||||
* @param {string} sCmd
|
||||
* @return {*}
|
||||
*/
|
||||
function doCommand(sCmd)
|
||||
{
|
||||
if (!sCmd) {
|
||||
sCmd = sCmdPrev;
|
||||
} else {
|
||||
sCmdPrev = sCmd;
|
||||
}
|
||||
|
||||
var result = false;
|
||||
var aTokens = sCmd.split(' ');
|
||||
|
||||
switch(aTokens[0]) {
|
||||
case "cwd":
|
||||
result = process.cwd();
|
||||
break;
|
||||
case "load":
|
||||
result = loadMachine(aTokens[1]);
|
||||
break;
|
||||
case "quit":
|
||||
process.exit();
|
||||
result = true;
|
||||
break;
|
||||
default:
|
||||
if (sCmd) {
|
||||
try {
|
||||
if (dbg && !dbg.doCommands(sCmd, true)) {
|
||||
sCmd = '(' + sCmd + ')';
|
||||
result = eval(sCmd); // jshint ignore:line
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* onCommand(cmd, context, filename, callback)
|
||||
*
|
||||
* The Node docs (http://nodejs.org/api/repl.html) say that repl.start's "eval" option is:
|
||||
*
|
||||
* a function that will be used to eval each given line; defaults to an async wrapper for eval()
|
||||
*
|
||||
* and it gives this example of such a function:
|
||||
*
|
||||
* function eval(cmd, context, filename, callback) {
|
||||
* callback(null, result);
|
||||
* }
|
||||
*
|
||||
* but it defines NEITHER the parameters for the function NOR the parameters for the callback().
|
||||
*
|
||||
* It's pretty clear that "result" is expected to return whatever "eval()" would return for the expression
|
||||
* in "cmd" (which is always parenthesized in preparation for a call to "eval()"), but it's not clear what
|
||||
* the first callback() parameter (represented by null) is supposed to be. Should we assume it's an Error
|
||||
* object, in case we want to report an error?
|
||||
*
|
||||
* @param {string} cmd
|
||||
* @param {Object} context
|
||||
* @param {string} filename
|
||||
* @param {function(Object|null, Object)} callback
|
||||
*/
|
||||
var onCommand = function (cmd, context, filename, callback)
|
||||
{
|
||||
var result = false;
|
||||
/*
|
||||
* WARNING: After updating from Node v0.10.x to v0.11.x, the incoming expression in "cmd" is no longer
|
||||
* parenthesized, so I had to tweak the RegExp below. But... WTF. Do we not care what we break, folks?
|
||||
*/
|
||||
var match = cmd.match(/^\(?\s*(.*?)\s*\)?$/);
|
||||
if (match) result = doCommand(match[1]);
|
||||
callback(null, result);
|
||||
};
|
||||
|
||||
if (pkg) {
|
||||
loadComponents(pkg.pdp11Files);
|
||||
}
|
||||
|
||||
/*
|
||||
* Before falling into the REPL, process any command-line (--cmd) commands -- which should eventually include batch files.
|
||||
*/
|
||||
if (argv['cmd'] !== undefined) {
|
||||
var cmds = argv['cmd'];
|
||||
var aCmds = (typeof cmds == "string"? [cmds] : cmds);
|
||||
for (var i = 0; i < aCmds.length; i++) {
|
||||
doCommand(aCmds[i]);
|
||||
}
|
||||
sCmdPrev = "";
|
||||
}
|
||||
|
||||
repl.start({
|
||||
prompt: "PDP11> ",
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
eval: onCommand
|
||||
});
|
||||
|
|
@ -1422,4 +1422,4 @@ BusPDP11.IOController = {
|
|||
}
|
||||
};
|
||||
|
||||
if (NODE) module.exports = BusPDP11;
|
||||
module.exports = BusPDP11;
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ class ComputerPDP11 extends Component {
|
|||
* but there are limits to my paranoia.
|
||||
*/
|
||||
var sParmLC = sParm.toLowerCase();
|
||||
var value = Component.parmsURL[sParm] || Component.parmsURL[sParmLC];
|
||||
var value = Web.getURLParm(sParm) || Web.getURLParm(sParmLC);
|
||||
|
||||
if (value === undefined && this.parmsMachine) {
|
||||
value = this.parmsMachine[sParm];
|
||||
|
|
|
|||
|
|
@ -885,4 +885,26 @@ PDP11.ACCESS.UPDATE_BYTE = PDP11.ACCESS.BYTE | PDP11.ACCESS.UPDATE; // forme
|
|||
*/
|
||||
PDP11.PSW.FLAGS = (PDP11.PSW.NF | PDP11.PSW.ZF | PDP11.PSW.VF | PDP11.PSW.CF);
|
||||
|
||||
module.exports = PDP11;
|
||||
/*
|
||||
* Combine all the shared globals and machine-specific globals into one machine-specific global object,
|
||||
* which all machine components should start using; eg: "if (PDP11.DEBUGGER)" instead of "if (DEBUGGER)".
|
||||
*/
|
||||
PDP11.APPCLASS = APPCLASS;
|
||||
PDP11.APPNAME = APPNAME;
|
||||
PDP11.DEBUGGER = DEBUGGER;
|
||||
PDP11.BYTEARRAYS = BYTEARRAYS;
|
||||
PDP11.TYPEDARRAYS = TYPEDARRAYS;
|
||||
PDP11.MEMFAULT = MEMFAULT;
|
||||
PDP11.WORDBUS = WORDBUS;
|
||||
|
||||
if (NODE) {
|
||||
global.APPCLASS = APPCLASS;
|
||||
global.APPNAME = APPNAME;
|
||||
global.DEBUGGER = DEBUGGER;
|
||||
global.BYTEARRAYS = BYTEARRAYS;
|
||||
global.TYPEDARRAYS = TYPEDARRAYS;
|
||||
global.PDP11 = PDP11;
|
||||
global.MEMFAULT = MEMFAULT;
|
||||
global.WORDBUS = WORDBUS;
|
||||
module.exports = PDP11;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Component = require("../../shared/lib/component");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var PDP11 = require("./defines");
|
||||
var MessagesPDP11 = require("./messages");
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Web = require("../../shared/es6/weblib");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var PDP11 = require("./defines");
|
||||
var BusPDP11 = require("./bus");
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var DumpAPI = require("../../shared/lib/dumpapi");
|
||||
var Component = require("../../shared/lib/component");
|
||||
var State = require("../../shared/lib/state");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Web = require("../../shared/es6/weblib");
|
||||
var DumpAPI = require("../../shared/es6/dumpapi");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var State = require("../../shared/es6/state");
|
||||
var PDP11 = require("./defines");
|
||||
var MessagesPDP11 = require("./messages");
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var DumpAPI = require("../../shared/lib/dumpapi");
|
||||
var Component = require("../../shared/lib/component");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Web = require("../../shared/es6/weblib");
|
||||
var DumpAPI = require("../../shared/es6/dumpapi");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var PDP11 = require("./defines");
|
||||
var MemoryPDP11 = require("./memory");
|
||||
var MessagesPDP11 = require("./messages");
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var DiskAPI = require("../../shared/lib/diskapi");
|
||||
var Component = require("../../shared/lib/component");
|
||||
var State = require("../../shared/lib/state");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Web = require("../../shared/es6/weblib");
|
||||
var DiskAPI = require("../../shared/es6/diskapi");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var State = require("../../shared/es6/state");
|
||||
var PDP11 = require("./defines");
|
||||
var MessagesPDP11 = require("./messages");
|
||||
var DiskPDP11 = require("./disk");
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var DiskAPI = require("../../shared/lib/diskapi");
|
||||
var Component = require("../../shared/lib/component");
|
||||
var State = require("../../shared/lib/state");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Web = require("../../shared/es6/weblib");
|
||||
var DiskAPI = require("../../shared/es6/diskapi");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var State = require("../../shared/es6/state");
|
||||
var PDP11 = require("./defines");
|
||||
var MessagesPDP11 = require("./messages");
|
||||
var DiskPDP11 = require("./disk");
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var DumpAPI = require("../../shared/lib/dumpapi");
|
||||
var Component = require("../../shared/lib/component");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Web = require("../../shared/es6/weblib");
|
||||
var DumpAPI = require("../../shared/es6/dumpapi");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var PDP11 = require("./defines");
|
||||
var BusPDP11 = require("./bus");
|
||||
var MemoryPDP11 = require("./memory");
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var Component = require("../../shared/lib/component");
|
||||
var Keys = require("../../shared/lib/keys");
|
||||
var State = require("../../shared/lib/state");
|
||||
var Str = require("../../shared/es6/strlib");
|
||||
var Web = require("../../shared/es6/weblib");
|
||||
var Component = require("../../shared/es6/component");
|
||||
var Keys = require("../../shared/es6/keys");
|
||||
var State = require("../../shared/es6/state");
|
||||
var PDP11 = require("./defines");
|
||||
var MessagesPDP11 = require("./messages");
|
||||
|
||||
|
|
|
|||
|
|
@ -971,15 +971,6 @@ class Component {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Component.parmsURL
|
||||
*
|
||||
* Initialized to the set of URL parameters, if any, for the current web page.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
Component.parmsURL = Web.getURLParameters();
|
||||
|
||||
/*
|
||||
* Every component created on the current page is recorded in this array (see Component.add()),
|
||||
* enabling any component to locate another component by ID (see Component.getComponentByID())
|
||||
|
|
|
|||
|
|
@ -110,3 +110,30 @@ var RS232 = {
|
|||
MASK: 0x00400000
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* NODE should be true if we're running under NodeJS (eg, command-line), false if not (eg, web browser)
|
||||
*/
|
||||
var NODE = false;
|
||||
if (typeof module !== 'undefined') {
|
||||
NODE = true;
|
||||
}
|
||||
|
||||
if (NODE) {
|
||||
global.window = false; // provides an alternative "if (typeof window === 'undefined')" (ie, "if (window) ...")
|
||||
global.APPVERSION = APPVERSION;
|
||||
global.XMLVERSION = XMLVERSION;
|
||||
global.COPYRIGHT = COPYRIGHT;
|
||||
global.LICENSE = LICENSE;
|
||||
global.CSSCLASS = CSSCLASS;
|
||||
global.SITEHOST = SITEHOST;
|
||||
global.COMPILED = COMPILED;
|
||||
global.DEBUG = DEBUG;
|
||||
global.MAXDEBUG = MAXDEBUG;
|
||||
global.PRIVATE = PRIVATE;
|
||||
global.RS232 = RS232;
|
||||
global.NODE = NODE;
|
||||
/*
|
||||
* TODO: When we're "required" by Node, should we return anything via module.exports?
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -660,12 +660,26 @@ class Web {
|
|||
}
|
||||
|
||||
/**
|
||||
* getURLParameters(sParms)
|
||||
* getURLParm(sParm)
|
||||
*
|
||||
* @param {string} sParm
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
static getURLParm(sParm)
|
||||
{
|
||||
if (!Web.parmsURL) {
|
||||
Web.parmsURL = Web.parseURLParms();
|
||||
}
|
||||
return Web.parmsURL[sParm];
|
||||
}
|
||||
|
||||
/**
|
||||
* parseURLParms(sParms)
|
||||
*
|
||||
* @param {string} [sParms] containing the parameter portion of a URL (ie, after the '?')
|
||||
* @return {Object} containing properties for each parameter found
|
||||
*/
|
||||
static getURLParameters(sParms)
|
||||
static parseURLParms(sParms)
|
||||
{
|
||||
var aParms = {};
|
||||
if (window) { // an alternative to "if (typeof module === 'undefined')" if require("defines") was used
|
||||
|
|
@ -944,6 +958,8 @@ class Web {
|
|||
}
|
||||
}
|
||||
|
||||
Web.parmsURL = null; // initialized on first call to parseURLParms()
|
||||
|
||||
Web.aPageEventHandlers = {
|
||||
'init': [], // list of window 'onload' handlers
|
||||
'show': [], // list of window 'onpageshow' handlers
|
||||
|
|
|
|||
|
|
@ -133,15 +133,6 @@ function Component(type, parms, constructor, bitsMessage)
|
|||
Component.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component.parmsURL
|
||||
*
|
||||
* Initialized to the set of URL parameters, if any, for the current web page.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
Component.parmsURL = web.getURLParameters();
|
||||
|
||||
/**
|
||||
* Component.inherit(p)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -116,19 +116,19 @@ if (typeof module !== 'undefined') {
|
|||
}
|
||||
|
||||
if (NODE) {
|
||||
global.window = false; // provides an alternative "if (typeof window === 'undefined')" (ie, "if (window) ...")
|
||||
global.APPVERSION = APPVERSION;
|
||||
global.XMLVERSION = XMLVERSION;
|
||||
global.COPYRIGHT = COPYRIGHT;
|
||||
global.LICENSE = LICENSE;
|
||||
global.CSSCLASS = CSSCLASS;
|
||||
global.SITEHOST = SITEHOST;
|
||||
global.COMPILED = COMPILED;
|
||||
global.DEBUG = DEBUG;
|
||||
global.MAXDEBUG = MAXDEBUG;
|
||||
global.PRIVATE = PRIVATE;
|
||||
global.RS232 = RS232;
|
||||
global.NODE = NODE;
|
||||
global.window = false; // provides an alternative "if (typeof window === 'undefined')" (ie, "if (window) ...")
|
||||
global.APPVERSION = APPVERSION;
|
||||
global.XMLVERSION = XMLVERSION;
|
||||
global.COPYRIGHT = COPYRIGHT;
|
||||
global.LICENSE = LICENSE;
|
||||
global.CSSCLASS = CSSCLASS;
|
||||
global.SITEHOST = SITEHOST;
|
||||
global.COMPILED = COMPILED;
|
||||
global.DEBUG = DEBUG;
|
||||
global.MAXDEBUG = MAXDEBUG;
|
||||
global.PRIVATE = PRIVATE;
|
||||
global.RS232 = RS232;
|
||||
global.NODE = NODE;
|
||||
/*
|
||||
* TODO: When we're "required" by Node, should we return anything via module.exports?
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -705,12 +705,26 @@ web.isMobile = function()
|
|||
};
|
||||
|
||||
/**
|
||||
* getURLParameters(sParms)
|
||||
* getURLParm(sParm)
|
||||
*
|
||||
* @param {string} sParm
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
web.getURLParm = function(sParm)
|
||||
{
|
||||
if (!web.parmsURL) {
|
||||
web.parmsURL = web.parseURLParms();
|
||||
}
|
||||
return web.parmsURL[sParm];
|
||||
};
|
||||
|
||||
/**
|
||||
* parseURLParms(sParms)
|
||||
*
|
||||
* @param {string} [sParms] containing the parameter portion of a URL (ie, after the '?')
|
||||
* @return {Object} containing properties for each parameter found
|
||||
*/
|
||||
web.getURLParameters = function(sParms)
|
||||
web.parseURLParms = function(sParms)
|
||||
{
|
||||
var aParms = {};
|
||||
if (window) { // an alternative to "if (typeof module === 'undefined')" if require("defines") was used
|
||||
|
|
@ -855,6 +869,8 @@ web.onClickRepeat = function(e, msDelay, msRepeat, fn)
|
|||
};
|
||||
};
|
||||
|
||||
web.parmsURL = null; // initialized on first call to parseURLParms()
|
||||
|
||||
web.aPageEventHandlers = {
|
||||
'init': [], // list of window 'onload' handlers
|
||||
'show': [], // list of window 'onpageshow' handlers
|
||||
|
|
|
|||
Loading…
Reference in a new issue