Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Jan 18, 2024
2 parents 7860c0c + db0f681 commit 372aa2f
Show file tree
Hide file tree
Showing 64 changed files with 15,538 additions and 15,268 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@
"PFDIR",
"PFINFO",
"PFLA",
"PFLEN",
"PFPUEN",
"PFSEL",
"PGDATA",
Expand Down
80 changes: 44 additions & 36 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* This file is part of PCjs, a computer emulation software project at <https://www.pcjs.org>.
*/

/*
/**
* Tasks
*
* default (eg: `gulp` or `gulp default`)
Expand Down Expand Up @@ -69,9 +69,10 @@ import closureCompiler from "google-closure-compiler";
import gulpSourceMaps from "gulp-sourcemaps";
import pcjslib from "./tools/modules/pcjslib.js";

var argv = pcjslib.getArgs()[1];
var gulpClosureCompiler = closureCompiler.gulp();
var pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"));
let argv = pcjslib.getArgs()[1];
let gulpClosureCompiler = closureCompiler.gulp();
let pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"));
let eol = process.platform === "win32"? "\r\n" : "\n";

/**
* Every machine must necessarily have a unique machine type ID (eg, "ti57").
Expand All @@ -96,11 +97,11 @@ var pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"));
/**
* @type {Object.<string,Machine>}
*/
var machines = JSON.parse(fs.readFileSync("./machines/machines.json", "utf8"));
let machines = JSON.parse(fs.readFileSync("./machines/machines.json", "utf8"));
if (!machines.shared) machines.shared = {};
var siteHost = "https://www.pcjs.org";
let siteHost = "https://www.pcjs.org";

/*
/**
* This is the set of the disk collections (stored as JSON) that the PCx86 floppy disk component (FDC) typically
* loads -- although the exact set can vary, and some machines, like PCSIG08, load several additional collections.
*
Expand All @@ -115,21 +116,21 @@ var siteHost = "https://www.pcjs.org";
* Another advantage of the combined file is the PCx86 FDC can now choose to load the combined file at runtime as well,
* instead of using the separate files, and speed up machine page loads slightly.
*/
var aSrcDiskCollections = [
let aSrcDiskCollections = [
"./disks/diskettes/pcx86/diskettes.json",
"./disks/gamedisks/pcx86/diskettes.json",
"./disks/miscdisks/pcx86/diskettes.json"
];
var sDstDiskCollection = "./machines/pcx86/diskettes.json";
let sDstDiskCollection = "./machines/pcx86/diskettes.json";

if (pkg.homepage) {
let match = pkg.homepage.match(/^(https?:\/\/[^/]*)(.*)/);
if (match) siteHost = match[1];
}

var aMachines = Object.keys(machines);
var aConcatTasks = [], aCompileTasks = [];
var aWatchedFiles = aSrcDiskCollections.slice();
let aMachines = Object.keys(machines);
let aConcatTasks = [], aCompileTasks = [];
let aWatchedFiles = aSrcDiskCollections.slice();

aMachines.forEach(function(machineID)
{
Expand Down Expand Up @@ -158,7 +159,7 @@ aMachines.forEach(function(machineID)
let machineReleaseFile = machineID + ".js";
let machineUncompiledFile = machineID + "-uncompiled.js";

/*
/**
* The following @defines should always be overridden, even if the Machine didn't list them.
*/
let alwaysDefine = ["MAXDEBUG", "DEBUG", "COMPILED"];
Expand Down Expand Up @@ -203,7 +204,7 @@ aMachines.forEach(function(machineID)
let machineFiles = Machine.css || machines.shared.css || [];
machineFiles = machineFiles.concat(Machine.xsl || machines.shared.xsl || []);

/*
/**
* The gulpNewer() plugin doesn't seem to work properly with the closureCompiler() plugin;
* if the destination file is newer than the source, the compiler still gets invoked, but
* with an incomplete stream, resulting in bogus errors. My work-around is to compare filetimes
Expand Down Expand Up @@ -234,18 +235,18 @@ aMachines.forEach(function(machineID)
.pipe(gulpForEach(function(stream, file) {
aMachinesOutdated.push(machineID);
return stream
.pipe(gulpHeader('/**\n * @copyright ' + file.path.replace(/.*[\\/](machines)[\\/](.*)/, "https://www.pcjs.org/$1/$2").replace(/\\/g,'/') + ' (C) 2012-' + pkg.year + ' Jeff Parsons\n */\n\n'))
.pipe(gulpReplace(/APPVERSION = "0.00"/g, 'APPVERSION = "' + machineVersion + '"'))
.pipe(gulpReplace(/(var\s+VERSION\s*=\s*)"[0-9.]*"/g, '$1"' + machineVersion + '"'))
.pipe(gulpReplace(/(^|\n)[ \t]*(['"])use strict\2;?/g, ""))
.pipe(gulpReplace(/^import[ \t]+[^\n]*\n/gm, ""))
.pipe(gulpReplace(/^export[ \t]+(.*?;\r?\n|default[ \t]+|\{.*?\}|)/gm, ""))
.pipe(gulpHeader('/**' + eol + ' * @copyright ' + file.path.replace(/.*[\\/](machines)[\\/](.*)/, "https://www.pcjs.org/$1/$2").replace(/\\/g,'/') + ' (C) 2012-' + pkg.year + ' Jeff Parsons' + eol + ' */' + eol + eol))
.pipe(gulpReplace(/(\s+APPVERSION\s*=\s*)"(0\.00|[0-9]\.xx)"/g, '$1"' + machineVersion + '"'))
.pipe(gulpReplace(/(\s+VERSION\s*=\s*)"[0-9X.]*"/g, '$1"' + machineVersion + '"'))
.pipe(gulpReplace(/(^|\r?\n)[ \t]*(['"])use strict\2;?/gm, ""))
.pipe(gulpReplace(/^import[ \t]+[^\r\n]*\r?\n/gm, ""))
.pipe(gulpReplace(/^export[ \t]+(.*;\r?\n|default[ \t]+|)/gm, ""))
.pipe(gulpReplace(/^[ \t]*var\s+\S+\s*=\s*require\((['"]).*?\1\)[^;]*;/gm, ""))
.pipe(gulpReplace(/^[ \t]*(if\s+\(NODE\)\s*|)module\.exports\s*=\s*[^;]*;/gm, ""))
.pipe(gulpReplace(/\/\*\*\s*\*\s*@fileoverview[\s\S]*?\*\/\s*/g, ""))
.pipe(gulpReplace(/[ \t]*if\s*\(NODE\)\s*({[^}]*}|[^\n]*)(\n|$)/gm, ""))
.pipe(gulpReplace(/[ \t]*if\s*\(typeof\s+module\s*!==?\s*(['"])undefined\1\)\s*({[^}]*}|[^\n]*)(\n|$)/gm, ""))
.pipe(gulpReplace(/\/\*\*[^@]*@typedef\s*{([A-Z][A-Za-z0-9_<>.]+)}\s*(\S+)\s*([\s\S]*?)\*\//g, function(match, def, type, props) {
.pipe(gulpReplace(/\/\*\*\s*\*\s*@fileoverview[\s\S]*?\*\/\s*/gm, ""))
.pipe(gulpReplace(/[ \t]*if\s*\(NODE\)\s*({[^}]*}|[^\r\n]*)(\r?\n|$)/gm, ""))
.pipe(gulpReplace(/[ \t]*if\s*\(typeof\s+module\s*!==?\s*(['"])undefined\1\)\s*({[^}]*}|[^\r\n]*)(\r?\n|$)/gm, ""))
.pipe(gulpReplace(/\/\*\*[^@/]*@typedef\s*{([A-Z][A-Za-z0-9_<>.]+)}\s*(\S+)\s*([\s\S]*?)\*\//g, function(match, def, type, props) {
let sType = "/** @typedef {", sProps = "";
let reProps = /@property\s*{([^}]*)}\s*(\[|)([^\s\]]+)]?/g, matchProps;
while ((matchProps = reProps.exec(props))) {
Expand All @@ -257,13 +258,13 @@ aMachines.forEach(function(machineID)
} else {
sType += "{ " + sProps + " }";
}
sType += "} */\nlet " + type + ";";
sType += "} */" + eol + "let " + type + ";";
return sType;
}))
.pipe(gulpReplace(/[ \t]*(if *\(DEBUG\) *|if *\(MAXDEBUG\) *|)[A-Za-z_][A-Za-z0-9_.]*(\.assert\(|\.printf\(Messages\.DEBUG|\.printf\(Device\.MESSAGE\.DEBUG)[^\n]*\);[^\n]*/g, ""));
.pipe(gulpReplace(/[ \t]*(if *\(DEBUG\) *|if *\(MAXDEBUG\) *|)[A-Za-z_][A-Za-z0-9_.]*(\.assert\(|\.printf\(Messages\.DEBUG|\.printf\(Device\.MESSAGE\.DEBUG)[^\r\n]*\);[^\r\n]*/g, ""));
}))
.pipe(gulpConcat(machineUncompiledFile))
// .pipe(gulpHeader('"use strict";\n\n'))
.pipe(gulpConcat(machineUncompiledFile, {newLine: eol}))
// .pipe(gulpHeader('"use strict";' + eol + eol))
.pipe(gulp.dest(machineReleaseDir));
});

Expand All @@ -284,15 +285,22 @@ aMachines.forEach(function(machineID)
output_wrapper: '(function(){%output%})()',
js_output_file: machineReleaseFile, // NOTE: if we go back to doing debugger/non-debugger releases, this must be updated
create_source_map: true
})) // gulp-sourcemaps automatically adds the sourcemap url comment
.pipe(gulpSourceMaps.mapSources(function(sourcePath, file) {
// console.log("mapSources: " + sourcePath + " (" + srcFile + ")");
if (sourcePath == srcFile.replaceAll('\\', '/')) {
sourcePath = path.basename(srcFile); // for reasons unknown, sourcePath is a full path in Windows, so we apply basename to make macOS and Windows consistent
}
return sourcePath;
}))
.pipe(gulpSourceMaps.write('./')) // gulp-sourcemaps automatically adds the sourcemap url comment
.pipe(gulpSourceMaps.write('./', {includeContent: false}))
.pipe(gulp.dest(machineReleaseDir));
}
return stream;
});
});

var combineTask = true;
let combineTask = true;
for (let i = 0; i < aSrcDiskCollections.length; i++) {
if (!fs.existsSync(aSrcDiskCollections[i])) {
combineTask = false;
Expand All @@ -306,11 +314,11 @@ if (combineTask) {
let mergeOptions = {
fileName: sDstDiskCollection,
edit: function(collection, file) {
/*
* Each parsed collection should have a '@server' property at the top level; the combined file
* obviously can't have multiple '@server' properties at the top level, so we propagate it to each
* of the top level objects and then remove it.
*/
/**
* Each parsed collection should have a '@server' property at the top level; the combined file
* obviously can't have multiple '@server' properties at the top level, so we propagate it to each
* of the top level objects and then remove it.
*/
if (collection['@server']) {
let keys = Object.keys(collection);
for (let k = 0; k < keys.length; k++) {
Expand Down Expand Up @@ -358,7 +366,7 @@ gulp.task("version", function() {

gulp.task("copyright", function(done) {
let baseDir = "./";
/*
/**
* TODO: Although I've added the 'skipBinary' option to gulpReplace(), to avoid mucking up files like ATT4425.ttf,
* it would also be nice if we could avoid rewriting ANY file that contains no matches, because Gulp's default behavior
* seems to be rewrite EVERYTHING, at least when we're doing these sorts of "in place" operations.
Expand Down
2 changes: 1 addition & 1 deletion machines/arcade/invaders/releases/3.00/invaders.js.map

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions machines/dec/pdp10/releases/2.21/pdp10-uncompiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
/**
* @define {string}
*/
const APPVERSION = "2.XX"; // this @define is overridden by the Closure Compiler with the version in machines.json
const APPVERSION = "2.xx"; // this @define is overridden with the version in machines.json

/**
* COMPILED is false by default; overridden with true in the Closure Compiler release.
*
* @define {boolean}
*/
const COMPILED = false; // this @define is overridden by the Closure Compiler (to true)
const COMPILED = false; // this @define is overridden by the Closure Compiler

/**
* @define {string}
Expand All @@ -32,7 +32,7 @@ const CSSCLASS = "pcjs";
*
* @define {boolean}
*/
const DEBUG = true; // this @define is overridden by the Closure Compiler (to false) to remove DEBUG-only code
const DEBUG = true;

/**
* WARNING: DEBUGGER needs to accurately reflect whether or not the Debugger component is (or will be) loaded.
Expand All @@ -47,25 +47,28 @@ const DEBUG = true; // this @define is overridden by the Clo
*
* @define {boolean}
*/
var DEBUGGER = true; // this @define is overridden by the Closure Compiler to remove Debugger-related support
var DEBUGGER = true;

/**
* @define {string}
*/
const LICENSE = "License: MIT <https://www.pcjs.org/LICENSE.txt>";

/**
* MAXDEBUG is false by default; overridden with false in the Closure Compiler release. Set it to
* true to manually to enable any hyper-aggressive DEBUG checks.
* MAXDEBUG can be set to true to enable MAXDEBUG-only code (ie, hyper-aggressive DEBUG checks that should only be
* enabled in special cases); it always overridden with false in the Closure Compiler release.
*
* @define {boolean}
*/
const MAXDEBUG = false; // this @define is overridden by the Closure Compiler (to false) to remove MAXDEBUG-only code
const MAXDEBUG = false;

/**
* PRIVATE can be set to true to enable PRIVATE-only code (ie, code that should never be enabled in a public release);
* it always overridden with false in the Closure Compiler release.
*
* @define {boolean}
*/
const PRIVATE = false; // this @define is overridden by the Closure Compiler (to false) to enable PRIVATE code
const PRIVATE = false;

/*
* RS-232 DB-25 Pin Definitions, mapped to bits 1-25 in a 32-bit status value.
Expand Down Expand Up @@ -113,9 +116,11 @@ const RS232 = {
};

/**
* SITEURL is the URL of the web server; it is replaced by the Closure Compiler (eg, "https://www.pcjs.org")
*
* @define {string}
*/
const SITEURL = "http://localhost:8088";// this @define is overridden by the Closure Compiler with "https://www.pcjs.org"
const SITEURL = "http://localhost:8088";

/**
* LOCALDISKS is intended to reflect the webserver's operating mode. Normally, we assume that all web
Expand Down Expand Up @@ -1772,7 +1777,7 @@ class StrLib {
/**
* toHex(n, cch, fPrefix)
*
* Converts an integer to hex, with the specified number of digits (default of 4 or 8, max of 9).
* Converts an integer to hex, with the specified number of digits (default of 2/4/8, max of 9).
*
* You might be tempted to use the built-in n.toString(16) instead, but it doesn't zero-pad and it
* doesn't properly convert negative values; for example, if n is -2147483647, then n.toString(16)
Expand All @@ -1787,7 +1792,7 @@ class StrLib {
* s = s.substr(0, cch).toUpperCase();
*
* @param {number|*} n (supports integers up to 36 bits now)
* @param {number} [cch] is the desired number of hex digits (0 or undefined for default of either 4, 8, or 9)
* @param {number} [cch] is the desired number of hex digits (0 or undefined for default of 2/4/8/9)
* @param {boolean} [fPrefix]
* @returns {string} the hex representation of n
*/
Expand All @@ -1796,7 +1801,9 @@ class StrLib {
if (!cch) {
// cch = Math.ceil(Math.log(Math.abs(n) + 1) / Math.log(16)) || 1;
let v = Math.abs(n);
if (v <= 0xffff) {
if (v <= 0xff) {
cch = 2;
} else if (v <= 0xffff) {
cch = 4;
} else if (v <= 0xffffffff) {
cch = 8;
Expand Down
2 changes: 1 addition & 1 deletion machines/dec/pdp10/releases/2.21/pdp10.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion machines/dec/pdp10/releases/2.21/pdp10.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 372aa2f

Please sign in to comment.