diff --git a/README.md b/README.md index 3857565cd..ca1126540 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ Welcome to PCjs, home of [PCx86](/docs/pcx86/), the original IBM PC simulation t one of several JavaScript Machines in the [PCjs Project](https://github.com/jeffpar/pcjs), an open-source project that includes: -* [PCx86](/docs/pcx86/), an x86-based IBM PC and PC-compatible emulator -* [PC8080](/modules/pc8080/), an 8080 machine emulator (e.g., [Space Invaders](/devices/pc8080/machine/invaders/), [VT100 Terminal](/devices/pc8080/machine/vt100/)) +* [PCx86](/docs/pcx86/), an x86-based emulator of [IBM PC and PC-compatible Machines](/devices/pcx86/machine/) +* [PC8080](/modules/pc8080/), an 8080 machine emulator (e.g., [Space Invaders](/devices/pc8080/machine/invaders/) and the [VT100 Terminal](/devices/pc8080/machine/vt100/)) * [C1Pjs](/docs/c1pjs/), an emulation of the 6502-based [Ohio Scientific Challenger 1P](/devices/c1p/) -* [PDPjs](/modules/pdp11/), a PDP-11 emulator currently in development (e.g., [PDP-11/20](/devices/pdp11/machine/1120/), [PDP-11/45](/devices/pdp11/machine/1145/), [PDP-11/70](/devices/pdp11/machine/1170/)) +* [PDPjs](/modules/pdp11/), a [PDP-11 Machine](/devices/pdp11/machine/) emulator that supports the [PDP-11/20](/devices/pdp11/machine/1120/), [PDP-11/45](/devices/pdp11/machine/1145/), and [PDP-11/70](/devices/pdp11/machine/1170/) All PCjs machine simulations are written entirely in [JavaScript](/modules/). No Flash, Java or other plugins are required. Supported browsers include modern versions of Chrome, Safari, Firefox, Internet Explorer (v9.0 and up), Edge, diff --git a/_posts/2016-12-30-out-with-the-old-in-with-ecmascript-2015.md b/_posts/2016-12-30-out-with-the-old-in-with-ecmascript-2015.md index 3da568fab..ae546a781 100644 --- a/_posts/2016-12-30-out-with-the-old-in-with-ecmascript-2015.md +++ b/_posts/2016-12-30-out-with-the-old-in-with-ecmascript-2015.md @@ -84,10 +84,10 @@ apparently Google's Closure Compiler seized the ES6 opportunity to try to enforc the default is `@struct`. Needless to say, when it came time to convert the next machine (PC8080) to classes, I prefaced all my classes with `@unrestricted`. -One downside of switching to ES6 one machine at a time is that, for now, I've had to fork the shared modules into +One downside of switching to ES6 one machine at a time is that I had to temporarily fork the shared modules into separate ES5 and ES6 folders. For example, one of the shared modules, [Component](/modules/shared/lib/component.js), is the base class underlying most other machine components; ES5 objects *subclass* [Component](/modules/shared/lib/component.js), -whereas ES6 classes *extend* [Component](/modules/shared/es6/component.js). Not all the shared modules needed to be forked, +whereas ES6 classes *extend* [Component](/modules/shared/lib/component.js). Not all the shared modules needed to be forked, but creating a new shared folder was the simplest solution. Once all the machines have been converted to use ES6 classes, the new shared modules will become the default, and the old ones will fade away. diff --git a/_posts/2017-01-31-completing-the-switch-to-es6-classes.md b/_posts/2017-01-31-completing-the-switch-to-es6-classes.md new file mode 100644 index 000000000..665f19379 --- /dev/null +++ b/_posts/2017-01-31-completing-the-switch-to-es6-classes.md @@ -0,0 +1,70 @@ +--- +layout: post +title: Completing the Switch to ES6 Classes +date: 2017-01-31 15:00:00 +permalink: /blog/2017/01/31/ +--- + +As I [mentioned](/blog/2016/12/30/) last December, I had started converting PCjs machines to ECMAScript 2015, more +conveniently known as ES6. At the time, only one PCjs machine, [PDPjs](/modules/pdp11/), had been converted, which +left the website in the unfortunate position of having duplicate shared modules: one set for ES5-based machines +and another set for ES6. + +Well, I'm happy to report that today marks the completion of the ES6 conversion, and the return of a single set of +[shared modules](/modules/shared/lib/). + +Admittedly, I was dragging my feet a bit, because the largest and most complex machine emulator, [PCx86](/modules/pcx86/), +was going to require a fair bit work, not to mention regression testing. However, after converting three other +PCjs machines ([PDPjs](/modules/pdp11/), [PC8080](/modules/pc8080/), and [C1Pjs](/modules/c1pjs/)), I had become +pretty proficient at the conversion, so I was able to bulldoze my way through all the PCx86 files in a few hours, +and fixing all the Closure Compiler compilation errors only took another hour or so. + +It's hard to say whether the conversion was really worth the effort, since I'm still using the Closure Compiler to +transpile the code back to ES5. Also, since two of the emulators ([PCx86](/modules/pcx86/) and [PDPjs](/modules/pdp11/)) +can also be launched from the Node command-line, I've adopted Node's *require()* convention for importing the other +scripts as modules, which makes them difficult to load inside a web browser if you want to test or debug the uncompiled +code. + +To resolve that, I updated the built-in Node web server to "magically" strip out all the Node-specific stuff before +serving up the individual JavaScript files. Eventually, I'll change the Node server's page template to use +`\n'; - sAlert += '\n\n'; - sAlert += 'The machine should appear where the
is located.'; - Component.alertUser(sAlert); - return; - } - Component.alertUser("Missing XML/XSL resources"); -} - -/** - * Prevent the Closure Compiler from renaming functions we want to export, by adding them - * as (named) properties of a global object. - */ -window['savePC'] = savePC; diff --git a/modules/shared/es6/state.js b/modules/shared/es6/state.js deleted file mode 100644 index 683d02dbb..000000000 --- a/modules/shared/es6/state.js +++ /dev/null @@ -1,397 +0,0 @@ -/** - * @fileoverview The State class used by PCjs machines. - * @author Jeff Parsons - * @copyright © Jeff Parsons 2012-2017 - * - * This file is part of PCjs, a computer emulation software project at . - * - * 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 . - * - * 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 - * . - * - * 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"; - -if (NODE) { - var Web = require("../../shared/es6/weblib"); - var Component = require("../../shared/es6/component"); -} - -class State { - /** - * State(component, sVersion, sSuffix) - * - * State objects are used by components to save/restore their state. - * - * During a save operation, components add data to a State object via set(), and then return - * the resulting data using data(). - * - * During a restore operation, the Computer component passes the results of each data() call - * back to the originating component. - * - * WARNING: Since State objects are low-level objects that have no UI requirements, they do not - * inherit from the Component class, so you should only use class methods of Component, such as - * Component.assert() (or Debugger methods if the Debugger is available). - * - * NOTE: 1.01 is the first version to provide limited save/restore support using localStorage. - * From that point on, care must be taken to insure that any new version that's incompatible with - * previous localStorage data be released with a version number that is at least 1 greater, - * since we're tagging the localStorage data with the integer portion of the version string. - * - * @param {Component} component - * @param {string} [sVersion] is used to append a major version number to the key - * @param {string} [sSuffix] is used to append any additional suffixes to the key - */ - constructor(component, sVersion, sSuffix) - { - this.id = component.id; - this.dbg = component.dbg; - this.json = ""; - this.state = {}; - this.fLoaded = this.fParsed = false; - this.key = State.key(component, sVersion, sSuffix); - this.unload(component.parms); - } - - /** - * set(id, data) - * - * @this {State} - * @param {number|string} id - * @param {Object|string} data - */ - set(id, data) - { - try { - this.state[id] = data; - } catch(e) { - Component.log(e.message); - } - } - - /** - * get(id) - * - * @this {State} - * @param {number|string} id - * @return {Object|string|null} - */ - get(id) - { - return this.state[id] || null; - } - - /** - * data() - * - * @this {State} - * @return {Object} - */ - data() - { - return this.state; - } - - /** - * load(json) - * - * WARNING: Make sure you follow this call with either a call to parse() or unload(), - * because any stringified data that we've loaded isn't usable until it's been parsed. - * - * @this {State} - * @param {string|null} [json] - * @return {boolean} true if state exists in localStorage, false if not - */ - load(json) - { - if (json) { - this.json = json; - this.fLoaded = true; - this.fParsed = false; - return true; - } - if (this.fLoaded) { - /* - * This is assumed to be a redundant load(). - */ - return true; - } - if (Web.hasLocalStorage()) { - var s = Web.getLocalStorageItem(this.key); - if (s) { - this.json = s; - this.fLoaded = true; - if (DEBUG) Component.log("localStorage(" + this.key + "): " + s.length + " bytes loaded"); - return true; - } - } - return false; - } - - /** - * parse() - * - * This completes the load() operation, by parsing what was loaded, on the assumption there - * might be some benefit to deferring parsing until we've given the user a chance to confirm. - * Otherwise, load() could have just as easily done this, too. - * - * @this {State} - * @return {boolean} true if successful, false if error - */ - parse() - { - var fSuccess = true; - if (!this.fParsed) { - try { - this.state = JSON.parse(this.json); - this.fParsed = true; - } catch (e) { - Component.error(e.message || e); - fSuccess = false; - } - } - return fSuccess; - } - - /** - * store() - * - * @this {State} - * @return {boolean} true if successful, false if error - */ - store() - { - var fSuccess = true; - if (Web.hasLocalStorage()) { - var s = JSON.stringify(this.state); - if (Web.setLocalStorageItem(this.key, s)) { - if (DEBUG) Component.log("localStorage(" + this.key + "): " + s.length + " bytes stored"); - } else { - /* - * WARNING: Because browsers tend to disable all alerts() during an "unload" operation, - * it's unlikely anyone will ever see the "quota" errors that occur at this point. Need to - * think of some way to notify the user that there's a problem, and offer a way of cleaning - * up old states. - */ - Component.error("Unable to store " + s.length + " bytes in browser local storage"); - fSuccess = false; - } - } - return fSuccess; - } - - /** - * toString() - * - * @this {State} - * @return {string} JSON-encoded state - */ - toString() - { - return this.state? JSON.stringify(this.state) : this.json; - } - - /** - * unload(parms) - * - * This discards any data saved via set() or loaded via load(), creating an empty State object. - * Note that you have to follow this call with an explicit call to store() if you want to remove - * the state from localStorage as well. - * - * @this {State} - * @param {Object} [parms] - */ - unload(parms) - { - this.json = ""; - this.state = {}; - this.fLoaded = this.fParsed = false; - if (parms) this.set("parms", parms); - } - - /** - * clear(fAll) - * - * This unloads the current state, and then clears ALL localStorage for the current machine, - * independent of version, to reduce the chance of orphaned states wasting part of our limited allocation. - * - * @this {State} - * @param {boolean} [fAll] true to unconditionally clear ALL localStorage for the current domain - */ - clear(fAll) - { - this.unload(); - var aKeys = Web.getLocalStorageKeys(); - for (var i = 0; i < aKeys.length; i++) { - var sKey = aKeys[i]; - if (sKey && (fAll || sKey.substr(0, this.key.length) == this.key)) { - Web.removeLocalStorageItem(sKey); - if (DEBUG) Component.log("localStorage(" + sKey + ") removed"); - aKeys.splice(i, 1); - i = 0; - } - } - } - - /** - * State.key(component, sVersion, sSuffix) - * - * This encapsulates the key generation code. - * - * @param {Component} component - * @param {string} [sVersion] is used to append a major version number to the key - * @param {string} [sSuffix] is used to append any additional suffixes to the key - * @return {string} key - */ - static key(component, sVersion, sSuffix) - { - var key = component.id; - if (sVersion) { - var i = sVersion.indexOf('.'); - if (i > 0) key += ".v" + sVersion.substr(0, i); - } - if (sSuffix) { - key += "." + sSuffix; - } - return key; - } - - /** - * State.compress(aSrc) - * - * @param {Array.|null} aSrc - * @return {Array.|null} is either the original array (aSrc), or a smaller array of "count, value" pairs (aComp) - */ - static compress(aSrc) - { - if (aSrc) { - var iSrc = 0; - var iComp = 0; - var aComp = []; - while (iSrc < aSrc.length) { - var n = aSrc[iSrc]; - Component.assert(n !== undefined); - var iCompare = iSrc + 1; - while (iCompare < aSrc.length && aSrc[iCompare] === n) iCompare++; - aComp[iComp++] = iCompare - iSrc; - aComp[iComp++] = n; - iSrc = iCompare; - } - if (aComp.length < aSrc.length) return aComp; - } - return aSrc; - } - - /** - * State.decompress(aComp) - * - * @param {Array.} aComp - * @param {number} nLength is expected length of decompressed data - * @return {Array.} - */ - static decompress(aComp, nLength) - { - var iDst = 0; - var aDst = new Array(nLength); - var iComp = 0; - while (iComp < aComp.length - 1) { - var c = aComp[iComp++]; - var n = aComp[iComp++]; - while (c--) { - aDst[iDst++] = n; - } - } - Component.assert(aDst.length == nLength); - return aDst; - } - - /** - * State.compressEvenOdd(aSrc) - * - * This is a very simple variation on compress() that compresses all the EVEN elements of aSrc first, - * followed by all the ODD elements. This tends to work better on EGA video memory, because when odd/even - * addressing is enabled (eg, for text modes), the DWORD values tend to alternate, which is the worst case - * for compress(), but the best case for compressEvenOdd(). - * - * One wrinkle we support: if the first element is uninitialized, then we assume the entire array is undefined, - * and return an empty compressed array. Conversely, decompressEvenOdd() will take an empty compressed array - * and return an uninitialized array. - * - * @param {Array.|null} aSrc - * @return {Array.|null} is either the original array (aSrc), or a smaller array of "count, value" pairs (aComp) - */ - static compressEvenOdd(aSrc) - { - if (aSrc) { - var iComp = 0, aComp = []; - if (aSrc[0] !== undefined) { - for (var off = 0; off < 2; off++) { - var iSrc = off; - while (iSrc < aSrc.length) { - var n = aSrc[iSrc]; - var iCompare = iSrc + 2; - while (iCompare < aSrc.length && aSrc[iCompare] === n) iCompare += 2; - aComp[iComp++] = (iCompare - iSrc) >> 1; - aComp[iComp++] = n; - iSrc = iCompare; - } - } - } - if (aComp.length < aSrc.length) return aComp; - } - return aSrc; - } - - /** - * State.decompressEvenOdd(aComp, nLength) - * - * This is the counterpart to compressEvenOdd(). Note that because there's nothing in the compressed sequence - * that differentiates a compress() sequence from a compressEvenOdd() sequence, you simply have to be consistent: - * if you used even/odd compression, then you must use even/odd decompression. - * - * @param {Array.} aComp - * @param {number} nLength is expected length of decompressed data - * @return {Array.} - */ - static decompressEvenOdd(aComp, nLength) - { - var iDst = 0; - var aDst = new Array(nLength); - var iComp = 0; - while (iComp < aComp.length - 1) { - var c = aComp[iComp++]; - var n = aComp[iComp++]; - while (c--) { - aDst[iDst] = n; - iDst += 2; - } - /* - * The output of a "count,value" pair will never exceed the end of the output array, so as soon as we reach it - * the first time, we know it's time to switch to ODD elements, and as soon as we reach it again, we should be - * done. - */ - Component.assert(iDst <= nLength || iComp == aComp.length); - if (iDst == nLength) iDst = 1; - } - Component.assert(aDst.length == nLength); - return aDst; - } -} - -if (NODE) module.exports = State; diff --git a/modules/shared/es6/strlib.js b/modules/shared/es6/strlib.js deleted file mode 100644 index a9dbf0bf8..000000000 --- a/modules/shared/es6/strlib.js +++ /dev/null @@ -1,635 +0,0 @@ -/** - * @fileoverview String-related helper functions - * @author Jeff Parsons (@jeffpar) - * @copyright © Jeff Parsons 2012-2017 - * - * This file is part of PCjs, a computer emulation software project at . - * - * 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 . - * - * 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 - * . - * - * 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"; - -class Str { - /** - * isValidInt(s, base) - * - * The built-in parseInt() function has the annoying feature of returning a partial value (ie, - * up to the point where it encounters an invalid character); eg, parseInt("foo", 16) returns 0xf. - * - * So it's best to use our own Str.parseInt() function, which will in turn use this function to - * validate the entire string. - * - * @param {string} s is the string representation of some number - * @param {number} [base] is the radix to use (default is 10); only 2, 8, 10 and 16 are supported - * @return {boolean} true if valid, false if invalid (or the specified base isn't supported) - */ - static isValidInt(s, base) - { - if (!base || base == 10) return s.match(/^[0-9]+$/) !== null; - if (base == 16) return s.match(/^[0-9a-f]+$/i) !== null; - if (base == 8) return s.match(/^[0-7]+$/) !== null; - if (base == 2) return s.match(/^[01]+$/) !== null; - return false; - } - - /** - * parseInt(s, base) - * - * This is a wrapper around the built-in parseInt() function. Our wrapper recognizes certain prefixes - * ('$' or "0x" for hex, '#' or "0o" for octal) and suffixes ('.' for decimal, 'h' for hex, 'y' for - * binary), and then calls isValidInt() to ensure we don't convert strings that contain partial values; - * see isValidInt() for details. - * - * The use of multiple prefix/suffix combinations is undefined (although for the record, we process - * prefixes first). We do NOT support the "0b" prefix to indicate binary UNLESS one or more commas are - * also present (because "0b" is also a valid hex sequence), and we do NOT support a single leading zero - * to indicate octal (because such a number could also be decimal or hex). Any number of commas are - * allowed; we remove them all before calling the built-in parseInt(). - * - * To summarize our non-standard alternatives: a 'y' suffix indicates binary, a '#' prefix indicates - * octal, a '$' prefix indicates hex, and a "0b" prefix indicates binary IF at least one comma is present. - * Commas are useful for grouping binary digits, but if you don't want to use them, then you must use a - * 'y' suffix for binary numbers. - * - * @param {string} s is the string representation of some number - * @param {number} [base] is the radix to use (default is 10); can be overridden by prefixes/suffixes - * @return {number|undefined} corresponding value, or undefined if invalid - */ - static parseInt(s, base) - { - var value; - - if (s) { - if (!base) base = 10; - var chPrefix = s.charAt(0); - var fCommas = (s.indexOf(',') > 0); - if (fCommas) s = s.replace(/,/g, ''); - if (chPrefix == '#') { - base = 8; - chPrefix = null; - } - else if (chPrefix == '$') { - base = 16; - chPrefix = null; - } - if (chPrefix == null) { - s = s.substr(1); - } - else { - if (chPrefix == '0') { - chPrefix = s.charAt(1); - if (chPrefix == 'b' && fCommas) { - base = 2; - chPrefix = null; - } - if (chPrefix == 'o') { - base = 8; - chPrefix = null; - } - else if (chPrefix == 'x') { - base = 16; - chPrefix = null; - } - } - if (chPrefix == null) { - s = s.substr(2); - } - else { - var chSuffix = s.charAt(s.length - 1).toLowerCase(); - if (chSuffix == 'y') { - base = 2; - chSuffix = null; - } - else if (chSuffix == '.') { - base = 10; - chSuffix = null; - } - else if (chSuffix == 'h') { - base = 16; - chSuffix = null; - } - if (chSuffix == null) s = s.substr(0, s.length - 1); - } - } - var v; - if (Str.isValidInt(s, base) && !isNaN(v = parseInt(s, base))) { - value = v | 0; - } - } - return value; - } - - /** - * toBin(n, cch, grouping) - * - * Converts an integer to binary, with the specified number of digits (up to the default of 32). - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of binary digits (32 is both the default and the maximum) - * @param {number} [grouping] - * @return {string} the binary representation of n - */ - static toBin(n, cch, grouping) - { - var s = ""; - if (!cch) { - cch = 32; - } else { - if (cch > 32) cch = 32; - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. - * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. - */ - var fInvalid = (n == null || isNaN(n)); - var group = (grouping = grouping || cch); - while (cch-- > 0) { - if (!group) { - s = "," + s; - group = grouping; - } - s = (fInvalid ? '?' : ((n & 0x1) ? '1' : '0')) + s; - n >>= 1; - group--; - } - return s; - } - - /** - * toBinBytes(n, cb, fPrefix) - * - * Converts an integer to binary, with the specified number of bytes (up to the default of 4). - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cb] is the desired number of binary bytes (4 is both the default and the maximum) - * @param {boolean} [fPrefix] - * @return {string} the binary representation of n - */ - static toBinBytes(n, cb, fPrefix) - { - var s = ""; - if (!cb || cb > 4) cb = 4; - for (var i = 0; i < cb; i++) { - if (s) s = ',' + s; - s = Str.toBin(n & 0xff, 8) + s; - n >>= 8; - } - return (fPrefix ? "0b" : "") + s; - } - - /** - * toOct(n, cch, fPrefix) - * - * Converts an integer to octal, with the specified number of digits (default of 6; max of 11) - * - * You might be tempted to use the built-in n.toString(8) instead, but it doesn't zero-pad and it - * doesn't properly convert negative values. Moreover, if n is undefined, n.toString() will throw - * an exception, whereas this function will return '?' characters. - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of octal digits (0 or undefined for default of either 6 or 11) - * @param {boolean} [fPrefix] - * @return {string} the octal representation of n - */ - static toOct(n, cch, fPrefix) - { - var s = ""; - - if (cch) { - if (cch > 11) cch = 11; - } else { - cch = (n & ~0xffffff) ? 11 : ((n & ~0xffff) ? 8 : 6); - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. - * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. - */ - if (n == null || isNaN(n)) { - while (cch-- > 0) s = '?' + s; - } else { - while (cch-- > 0) { - var d = (n & 7) + 0x30; - s = String.fromCharCode(d) + s; - n >>= 3; - } - } - return (fPrefix ? "0o" : "") + s; - } - - /** - * toDec(n, cch) - * - * Converts an integer to decimal, with the specified number of digits (default of 5; max of 10) - * - * You might be tempted to use the built-in n.toString(10) instead, but it doesn't zero-pad and it - * doesn't properly convert negative values. Moreover, if n is undefined, n.toString() will throw - * an exception, whereas this function will return '?' characters. - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of decimal digits (0 or undefined for default of either 5 or 10) - * @return {string} the octal representation of n - */ - static toDec(n, cch) - { - var s = ""; - - if (cch) { - if (cch > 10) cch = 10; - } else { - cch = (n & ~0xffff) ? 10 : 5; - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. - * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. - */ - if (n == null || isNaN(n)) { - while (cch-- > 0) s = '?' + s; - } else { - while (cch-- > 0) { - var d = (n % 10) + 0x30; - s = String.fromCharCode(d) + s; - n /= 10; - } - } - return s; - } - - /** - * toHex(n, cch, fPrefix) - * - * Converts an integer to hex, with the specified number of digits (default of 4 or 8, max of 8). - * - * 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) - * will return "-7fffffff" instead of "80000001". Moreover, if n is undefined, n.toString() will - * throw an exception, whereas this function will return '?' characters. - * - * NOTE: The following work-around (adapted from code found on StackOverflow) would be another solution, - * taking care of negative values, zero-padding, and upper-casing, but not null/undefined/NaN values: - * - * s = (n < 0? n + 0x100000000 : n).toString(16); - * s = "00000000".substr(0, 8 - s.length) + s; - * s = s.substr(0, cch).toUpperCase(); - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of hex digits (0 or undefined for default of either 4 or 8) - * @param {boolean} [fPrefix] - * @return {string} the hex representation of n - */ - static toHex(n, cch, fPrefix) - { - var s = ""; - - if (cch) { - if (cch > 8) cch = 8; - } else { - cch = (n & ~0xffff) ? 8 : 4; - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. - * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. - */ - if (n == null || isNaN(n)) { - while (cch-- > 0) s = '?' + s; - } else { - while (cch-- > 0) { - var d = n & 0xf; - d += (d >= 0 && d <= 9 ? 0x30 : 0x41 - 10); - s = String.fromCharCode(d) + s; - n >>= 4; - } - } - return (fPrefix ? "0x" : "") + s; - } - - /** - * toHexByte(b) - * - * Alias for Str.toHex(b, 2, true) - * - * @param {number|null|undefined} b is a byte value - * @return {string} the hex representation of b - */ - static toHexByte(b) - { - return Str.toHex(b, 2, true); - } - - /** - * toHexWord(w) - * - * Alias for Str.toHex(w, 4, true) - * - * @param {number|null|undefined} w is a word (16-bit) value - * @return {string} the hex representation of w - */ - static toHexWord(w) - { - return Str.toHex(w, 4, true); - } - - /** - * toHexLong(l) - * - * Alias for Str.toHex(l, 8, true) - * - * @param {number|null|undefined} l is a dword (32-bit) value - * @return {string} the hex representation of w - */ - static toHexLong(l) - { - return Str.toHex(l, 8, true); - } - - /** - * getBaseName(sFileName, fStripExt) - * - * This is a poor-man's version of Node's path.basename(), which Node-only components should use instead. - * - * 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 - * @param {boolean} [fStripExt] - * @return {string} - */ - static getBaseName(sFileName, fStripExt) - { - var sBaseName = sFileName; - - var i = sFileName.lastIndexOf('/'); - if (i >= 0) sBaseName = sFileName.substr(i + 1); - - /* - * This next bit is a kludge to clean up names that are part of a URL that includes unsightly query parameters. - */ - i = sBaseName.indexOf('&'); - if (i > 0) sBaseName = sBaseName.substr(0, i); - - if (fStripExt) { - i = sBaseName.lastIndexOf("."); - if (i > 0) { - sBaseName = sBaseName.substring(0, i); - } - } - return sBaseName; - } - - /** - * getExtension(sFileName) - * - * This is a poor-man's version of Node's path.extname(), which Node-only components should use instead. - * - * Note that we EXCLUDE the period from the returned extension, whereas path.extname() includes it. - * - * @param {string} sFileName - * @return {string} the filename's extension (in lower-case and EXCLUDING the "."), or an empty string - */ - static getExtension(sFileName) - { - var sExtension = ""; - var i = sFileName.lastIndexOf("."); - if (i >= 0) { - sExtension = sFileName.substr(i + 1).toLowerCase(); - } - return sExtension; - } - - /** - * endsWith(s, sSuffix) - * - * @param {string} s - * @param {string} sSuffix - * @return {boolean} true if s ends with sSuffix, false if not - */ - static endsWith(s, sSuffix) - { - return s.indexOf(sSuffix, s.length - sSuffix.length) !== -1; - } - - /** - * escapeHTML(sHTML) - * - * @param {string} sHTML - * @return {string} with HTML entities "escaped", similar to PHP's htmlspecialchars() - */ - static escapeHTML(sHTML) - { - return sHTML.replace(/[&<>"']/g, function(m) - { - return Str.aHTMLEscapeMap[m]; - }); - } - - /** - * replaceAll(sFind, sReplace, s) - * - * @param {string} sFind - * @param {string} sReplace - * @param {string} s - * @return {string} - */ - static replaceAll(sFind, sReplace, s) - { - var a = {}; - a[sFind] = sReplace; - return Str.replaceArray(a, s); - } - - /** - * replaceArray(a, s) - * - * @param {Object} a - * @param {string} s - * @return {string} - */ - static replaceArray(a, s) - { - var sMatch = ""; - for (var k in a) { - /* - * As noted in: - * - * http://www.regexguru.com/2008/04/escape-characters-only-when-necessary/ - * - * inside character classes, only backslash, caret, hyphen and the closing bracket need to be - * escaped. And in fact, if you ensure that the closing bracket is first, the caret is not first, - * and the hyphen is last, you can avoid escaping those as well. - */ - k = k.replace(/([\\[\]*{}().+?])/g, "\\$1"); - sMatch += (sMatch ? '|' : '') + k; - } - return s.replace(new RegExp('(' + sMatch + ')', "g"), function(m) - { - return a[m]; - }); - } - - /** - * pad(s, cch, fPadLeft) - * - * NOTE: the maximum amount of padding currently supported is 40 spaces. - * - * @param {string} s is a string - * @param {number} cch is desired length - * @param {boolean} [fPadLeft] (default is padding on the right) - * @return {string} the original string (s) with spaces padding it to the specified length - */ - static pad(s, cch, fPadLeft) - { - var sPadding = " "; - return fPadLeft ? (sPadding + s).slice(-cch) : (s + sPadding).slice(0, cch); - } - - /** - * stripLeadingZeros(s, fPad) - * - * @param {string} s - * @param {boolean} [fPad] - * @return {string} - */ - static stripLeadingZeros(s, fPad) - { - var cch = s.length; - s = s.replace(/^0+([0-9A-F]+)$/i, "$1"); - if (fPad) s = Str.pad(s, cch, true); - return s; - } - - /** - * trim(s) - * - * @param {string} s - * @return {string} - */ - static trim(s) - { - if (String.prototype.trim) { - return s.trim(); - } - return s.replace(/^\s+|\s+$/g, ""); - } - - /** - * toASCIICode(b) - * - * @param {number} b - * @return {string} - */ - static toASCIICode(b) - { - var s; - if (b != Str.ASCII.CR && b != Str.ASCII.LF) { - s = Str.aASCIICodes[b]; - } - if (s) { - s = '<' + s + '>'; - } else { - s = String.fromCharCode(b); - } - return s; - } -} - -Str.aHTMLEscapeMap = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' -}; - -/* - * Future home of a general-purpose ASCII table. TODO: Flesh it out. - */ -Str.ASCII = { - LF: 0x0A, - CR: 0x0D -}; - -/* - * Table for converting "unprintable" ASCII codes into mnemonics, to more clearly see what's being printed. - */ -Str.aASCIICodes = { - 0x00: "NUL", - 0x01: "SOH", // (CTRL_A) Start of Heading - 0x02: "STX", // (CTRL_B) Start of Text - 0x03: "ETX", // (CTRL_C) End of Text - 0x04: "EOT", // (CTRL_D) End of Transmission - 0x05: "ENQ", // (CTRL_E) Enquiry - 0x06: "ACK", // (CTRL_F) Acknowledge - 0x07: "BEL", // (CTRL_G) Bell - 0x08: "BS", // (CTRL_H) Backspace - 0x09: "TAB", // (CTRL_I) Horizontal Tab - 0x0A: "LF", // (CTRL_J) Line Feed (New Line) - 0x0B: "VT", // (CTRL_K) Vertical Tab - 0x0C: "FF", // (CTRL_L) Form Feed (New Page) - 0x0D: "CR", // (CTRL_M) Carriage Return - 0x0E: "SO", // (CTRL_N) Shift Out - 0x0F: "SI", // (CTRL_O) Shift In - 0x10: "DLE", // (CTRL_P) Data Link Escape - 0x11: "XON", // (CTRL_Q) Device Control 1 (aka DC1) - 0x12: "DC2", // (CTRL_R) Device Control 2 - 0x13: "XOFF", // (CTRL_S) Device Control 3 (aka DC3) - 0x14: "DC4", // (CTRL_T) Device Control 4 - 0x15: "NAK", // (CTRL_U) Negative Acknowledge - 0x16: "SYN", // (CTRL_V) Synchronous Idle - 0x17: "ETB", // (CTRL_W) End of Transmission Block - 0x18: "CAN", // (CTRL_X) Cancel - 0x19: "EM", // (CTRL_Y) End of Medium - 0x1A: "SUB", // (CTRL_Z) Substitute - 0x1B: "ESC", // Escape - 0x1C: "FS", // File Separator - 0x1D: "GS", // Group Separator - 0x1E: "RS", // Record Separator - 0x1F: "US" // Unit Separator -}; - -Str.TYPES = { - NULL: 0, - BYTE: 1, - WORD: 2, - DWORD: 3, - NUMBER: 4, - STRING: 5, - BOOLEAN: 6, - OBJECT: 7, - ARRAY: 8 -}; - -if (NODE) module.exports = Str; diff --git a/modules/shared/es6/userapi.js b/modules/shared/es6/userapi.js deleted file mode 100644 index 1a24b3a77..000000000 --- a/modules/shared/es6/userapi.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @fileoverview User API, as defined by httpapi.js - * @author Jeff Parsons - * @copyright © Jeff Parsons 2012-2017 - * - * This file is part of PCjs, a computer emulation software project at . - * - * 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 . - * - * 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 - * . - * - * 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"; - -/* - * Examples of User API requests: - * - * web.getHost() + UserAPI.ENDPOINT + '?' + UserAPI.QUERY.REQ + '=' + UserAPI.REQ.VERIFY + '&' + UserAPI.QUERY.USER + '=' + sUser; - */ -var UserAPI = { - ENDPOINT: "/api/v1/user", - QUERY: { - REQ: "req", // specifies a request - USER: "user", // specifies a user ID - STATE: "state", // specifies a state ID - DATA: "data" // specifies state data - }, - REQ: { - CREATE: "create", // creates a user ID - VERIFY: "verify", // requests verification of a user ID - STORE: "store", // stores a machine state on the server - LOAD: "load" // loads a machine state from the server - }, - RES: { - CODE: "code", - DATA: "data" - }, - CODE: { - OK: "ok", - FAIL: "error" - }, - FAIL: { - DUPLICATE: "user already exists", - VERIFY: "unable to verify user", - BADSTATE: "invalid state parameter", - NOSTATE: "no machine state", - BADLOAD: "unable to load machine state", - BADSTORE: "unable to save machine state" - } -}; - -if (NODE) module.exports = UserAPI; diff --git a/modules/shared/es6/usrlib.js b/modules/shared/es6/usrlib.js deleted file mode 100644 index 490768b90..000000000 --- a/modules/shared/es6/usrlib.js +++ /dev/null @@ -1,312 +0,0 @@ -/** - * @fileoverview Assorted helper functions - * @author Jeff Parsons (@jeffpar) - * @copyright © Jeff Parsons 2012-2017 - * - * This file is part of PCjs, a computer emulation software project at . - * - * 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 . - * - * 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 - * . - * - * 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"; - -/** - * @typedef {{ - * mask: number, - * shift: number - * }} - */ -var BitField; - -/** - * @typedef {Object.} - */ -var BitFields; - -class Usr { - /** - * binarySearch(a, v, fnCompare) - * - * @param {Array} a is an array - * @param {number|string|Array|Object} v - * @param {function((number|string|Array|Object), (number|string|Array|Object))} [fnCompare] - * @return {number} the index of matching entry if non-negative, otherwise the index of the insertion point - */ - static binarySearch(a, v, fnCompare) - { - var left = 0; - var right = a.length; - var found = 0; - if (fnCompare === undefined) { - fnCompare = function(a, b) - { - return a > b ? 1 : a < b ? -1 : 0; - }; - } - while (left < right) { - var middle = (left + right) >> 1; - var compareResult; - compareResult = fnCompare(v, a[middle]); - if (compareResult > 0) { - left = middle + 1; - } else { - right = middle; - found = !compareResult; - } - } - return found ? left : ~left; - } - - /** - * binaryInsert(a, v, fnCompare) - * - * If element v already exists in array a, the array is unchanged (we don't allow duplicates); otherwise, the - * element is inserted into the array at the appropriate index. - * - * @param {Array} a is an array - * @param {number|string|Array|Object} v is the value to insert - * @param {function((number|string|Array|Object), (number|string|Array|Object))} [fnCompare] - */ - static binaryInsert(a, v, fnCompare) - { - var index = Usr.binarySearch(a, v, fnCompare); - if (index < 0) { - a.splice(-(index + 1), 0, v); - } - } - - /** - * getTimestamp() - * - * @return {string} timestamp containing the current date and time ("yyyy-mm-dd hh:mm:ss") - */ - static getTimestamp() - { - var date = new Date(); - var padNum = function(n) - { - return (n < 10 ? "0" : "") + n; - }; - return date.getFullYear() + "-" + padNum(date.getMonth() + 1) + "-" + padNum(date.getDate()) + " " + padNum(date.getHours()) + ":" + padNum(date.getMinutes()) + ":" + padNum(date.getSeconds()); - } - - /** - * getMonthDays(nMonth, nYear) - * - * Note that if we're being called on behalf of the RTC, its year is always truncated to two digits (mod 100), - * so we have no idea what century the year 0 might refer to. When using the normal leap-year formula, 0 fails - * the mod 100 test but passes the mod 400 test, so as far as the RTC is concerned, every century year is a leap - * year. Since we're most likely dealing with the year 2000, that's fine, since 2000 was also a leap year. - * - * TODO: There IS a separate CMOS byte that's supposed to be set to CMOS_ADDR.CENTURY_DATE; it's always BCD, - * so theoretically it will contain values like 0x19 or 0x20 (for the 20th and 21st centuries, respectively), and - * we could add that as another parameter to this function, to improve the accuracy, but that would go beyond what - * a real RTC actually does. - * - * @param {number} nMonth (1-12) - * @param {number} nYear (normally a 4-digit year, but it may also be mod 100) - * @return {number} the maximum (1-based) day allowed for the specified month and year - */ - static getMonthDays(nMonth, nYear) - { - var nDays = Usr.aMonthDays[nMonth - 1]; - if (nDays == 28) { - if ((nYear % 4) === 0 && ((nYear % 100) || (nYear % 400) === 0)) { - nDays++; - } - } - return nDays; - } - - /** - * formatDate(sFormat, date) - * - * @param {string} sFormat (eg, "F j, Y", "Y-m-d H:i:s") - * @param {Date} [date] (default is the current time) - * @return {string} - * - * Supported identifiers in sFormat include: - * - * a: lowercase ante meridiem and post meridiem (am or pm) - * d: day of the month, 2 digits with leading zeros (01,...,31) - * g: hour in 12-hour format, without leading zeros (1,...,12) - * i: minutes, with leading zeros (00,...,59) - * j: day of the month, without leading zeros (1,...,31) - * l: day of the week ("Sunday",...,"Saturday") - * m: month, with leading zeros (01,...,12) - * s: seconds, with leading zeros (00,...,59) - * F: month ("January",...,"December") - * H: hour in 24-hour format, with leading zeros (00,...,23) - * Y: year (eg, 2014) - * - * For more inspiration, see: http://php.net/manual/en/function.date.php - */ - static formatDate(sFormat, date) - { - var sDate = ""; - if (!date) date = new Date(); - var iHour = date.getHours(); - var iDay = date.getDate(); - var iMonth = date.getMonth() + 1; - for (var i = 0; i < sFormat.length; i++) { - var ch; - switch ((ch = sFormat.charAt(i))) { - case 'a': - sDate += (iHour < 12 ? "am" : "pm"); - break; - case 'd': - sDate += ('0' + iDay).slice(-2); - break; - case 'g': - sDate += (!iHour ? 12 : (iHour > 12 ? iHour - 12 : iHour)); - break; - case 'i': - sDate += ('0' + date.getMinutes()).slice(-2); - break; - case 'j': - sDate += iDay; - break; - case 'l': - sDate += Usr.asDays[date.getDay()]; - break; - case 'm': - sDate += ('0' + iMonth).slice(-2); - break; - case 's': - sDate += ('0' + date.getSeconds()).slice(-2); - break; - case 'F': - sDate += Usr.asMonths[iMonth - 1]; - break; - case 'H': - sDate += ('0' + iHour).slice(-2); - break; - case 'Y': - sDate += date.getFullYear(); - break; - default: - sDate += ch; - break; - } - } - return sDate; - } - - /** - * defineBitFields(bfs) - * - * Prepares a bit field definition for use with getBitField() and setBitField(); eg: - * - * var bfs = Usr.defineBitFields({num:20, count:8, btmod:1, type:3}); - * - * The above defines a set of bit fields containing four fields: num (bits 0-19), count (bits 20-27), btmod (bit 28), and type (bits 29-31). - * - * Usr.setBitField(bfs.num, n, 1); - * - * The above set bit field "bfs.num" in numeric variable "n" to the value 1. - * - * @param {Object} bfs - * @return {BitFields} - */ - static defineBitFields(bfs) - { - var bit = 0; - for (var f in bfs) { - var width = bfs[f]; - var mask = ((1 << width) - 1) << bit; - bfs[f] = {mask: mask, shift: bit}; - bit += width; - } - return bfs; - } - - /** - * initBitFields(bfs, ...) - * - * @param {BitFields} bfs - * @param {...number} var_args - * @return {number} a value containing all supplied bit fields - */ - static initBitFields(bfs, var_args) - { - var v = 0, i = 1; - for (var f in bfs) { - if (i >= arguments.length) break; - v = Usr.setBitField(bfs[f], v, arguments[i++]); - } - return v; - } - - /** - * getBitField(bf, v) - * - * @param {BitField} bf - * @param {number} v is a value containing bit fields - * @return {number} the value of the bit field in v defined by bf - */ - static getBitField(bf, v) - { - return (v & bf.mask) >> bf.shift; - } - - /** - * setBitField(bf, v, n) - * - * @param {BitField} bf - * @param {number} v is a value containing bit fields - * @param {number} n is a value to store in v in the bit field defined by bf - * @return {number} updated v - */ - static setBitField(bf, v, n) - { - return (v & ~bf.mask) | ((n << bf.shift) & bf.mask); - } - - /** - * indexOf(a, t, i) - * - * Use this instead of Array.prototype.indexOf() if you can't be sure the browser supports it. - * - * @param {Array} a - * @param {*} t - * @param {number} [i] - * @returns {number} - */ - static indexOf(a, t, i) - { - if (Array.prototype.indexOf) { - return a.indexOf(t, i); - } - i = i || 0; - if (i < 0) i += a.length; - if (i < 0) i = 0; - for (var n = a.length; i < n; i++) { - if (i in a && a[i] === t) return i; - } - return -1; - } -} - -Usr.asDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; -Usr.asMonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; -Usr.aMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - -if (NODE) module.exports = Usr; diff --git a/modules/shared/es6/weblib.js b/modules/shared/es6/weblib.js deleted file mode 100644 index b514856e0..000000000 --- a/modules/shared/es6/weblib.js +++ /dev/null @@ -1,973 +0,0 @@ -/** - * @fileoverview Browser-related helper functions - * @author Jeff Parsons (@jeffpar) - * @copyright © Jeff Parsons 2012-2017 - * - * This file is part of PCjs, a computer emulation software project at . - * - * 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 . - * - * 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 - * . - * - * 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"; - -if (NODE) { - var Component = require("../../shared/es6/component"); - var ReportAPI = require("../../shared/es6/reportapi"); -} - -/* - * According to http://www.w3schools.com/jsref/jsref_obj_global.asp, these are the *global* properties - * and functions of JavaScript-in-the-Browser: - * - * Property Description - * --- - * Infinity A numeric value that represents positive/negative infinity - * NaN "Not-a-Number" value - * undefined Indicates that a variable has not been assigned a value - * - * Function Description - * --- - * decodeURI() Decodes a URI - * decodeURIComponent() Decodes a URI component - * encodeURI() Encodes a URI - * encodeURIComponent() Encodes a URI component - * escape() Deprecated in version 1.5. Use encodeURI() or encodeURIComponent() instead - * eval() Evaluates a string and executes it as if it was script code - * isFinite() Determines whether a value is a finite, legal number - * isNaN() Determines whether a value is an illegal number - * Number() Converts an object's value to a number - * parseFloat() Parses a string and returns a floating point number - * parseInt() Parses a string and returns an integer - * String() Converts an object's value to a string - * unescape() Deprecated in version 1.5. Use decodeURI() or decodeURIComponent() instead - * - * And according to http://www.w3schools.com/jsref/obj_window.asp, these are the properties and functions - * of the *window* object. - * - * Property Description - * --- - * closed Returns a Boolean value indicating whether a window has been closed or not - * defaultStatus Sets or returns the default text in the statusbar of a window - * document Returns the Document object for the window (See Document object) - * frames Returns an array of all the frames (including iframes) in the current window - * history Returns the History object for the window (See History object) - * innerHeight Returns the inner height of a window's content area - * innerWidth Returns the inner width of a window's content area - * length Returns the number of frames (including iframes) in a window - * location Returns the Location object for the window (See Location object) - * name Sets or returns the name of a window - * navigator Returns the Navigator object for the window (See Navigator object) - * opener Returns a reference to the window that created the window - * outerHeight Returns the outer height of a window, including toolbars/scrollbars - * outerWidth Returns the outer width of a window, including toolbars/scrollbars - * pageXOffset Returns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window - * pageYOffset Returns the pixels the current document has been scrolled (vertically) from the upper left corner of the window - * parent Returns the parent window of the current window - * screen Returns the Screen object for the window (See Screen object) - * screenLeft Returns the x coordinate of the window relative to the screen - * screenTop Returns the y coordinate of the window relative to the screen - * screenX Returns the x coordinate of the window relative to the screen - * screenY Returns the y coordinate of the window relative to the screen - * self Returns the current window - * status Sets or returns the text in the statusbar of a window - * top Returns the topmost browser window - * - * Method Description - * --- - * alert() Displays an alert box with a message and an OK button - * atob() Decodes a base-64 encoded string - * blur() Removes focus from the current window - * btoa() Encodes a string in base-64 - * clearInterval() Clears a timer set with setInterval() - * clearTimeout() Clears a timer set with setTimeout() - * close() Closes the current window - * confirm() Displays a dialog box with a message and an OK and a Cancel button - * createPopup() Creates a pop-up window - * focus() Sets focus to the current window - * moveBy() Moves a window relative to its current position - * moveTo() Moves a window to the specified position - * open() Opens a new browser window - * print() Prints the content of the current window - * prompt() Displays a dialog box that prompts the visitor for input - * resizeBy() Resizes the window by the specified pixels - * resizeTo() Resizes the window to the specified width and height - * scroll() This method has been replaced by the scrollTo() method. - * scrollBy() Scrolls the content by the specified number of pixels - * scrollTo() Scrolls the content to the specified coordinates - * setInterval() Calls a function or evaluates an expression at specified intervals (in milliseconds) - * setTimeout() Calls a function or evaluates an expression after a specified number of milliseconds - * stop() Stops the window from loading - */ - -class Web { - /** - * log(s, type) - * - * For diagnostic output only. DEBUG must be true (or "--debug" specified via the command-line) - * for Component.log() to display anything. - * - * @param {string} [s] is the message text - * @param {string} [type] is the message type - */ - static log(s, type) - { - Component.log(s, type); - } - - /** - * notice(s, fPrintOnly, id) - * - * @param {string} s is the message text - * @param {boolean} [fPrintOnly] - * @param {string} [id] is the caller's ID, if any - */ - static notice(s, fPrintOnly, id) - { - Component.notice(s, fPrintOnly, id); - } - - /** - * getResource(sURL, dataPost, fAsync, done) - * - * Request the specified resource (sURL), and once the request is complete, notify done(). - * - * Also, if dataPost is set to a string, that string can be used to control the response format; - * by default, the response format is plain text, but you can specify "bytes" to request arbitrary - * binary data, which should come back as a string of bytes. - * - * TODO: The "bytes" option works by calling overrideMimeType(), which was never a best practice. - * Instead, we should implement supported response types ("text" and "arraybuffer", at a minimum) - * by setting xmlHTTP.responseType to one of those values before calling xmlHTTP.send(). - * - * ES6 ALERT: Default parameters. - * - * @param {string} sURL - * @param {string|Object|null} [dataPost] for a POST request (default is a GET request) - * @param {boolean} [fAsync] is true for an asynchronous request - * @param {function(string,string,number)} [done] - * @return {Array|null} Array containing [sResource, nErrorCode], or null if no response yet - */ - static getResource(sURL, dataPost, fAsync = false, done) - { - var nErrorCode = 0, sResource = null, response = null; - - if (typeof resources == 'object' && (sResource = resources[sURL])) { - if (done) done(sURL, sResource, nErrorCode); - return [sResource, nErrorCode]; - } - else if (fAsync && typeof resources == 'function') { - resources(sURL, function(sResource, nErrorCode) - { - if (done) done(sURL, sResource, nErrorCode); - }); - return response; - } - - if (DEBUG) { - /* - * The larger resources we put on archive.pcjs.org should also be available locally... - */ - sURL = sURL.replace(/^http:\/\/archive.pcjs.org(\/.*)\/([^\/]*)$/, "$1/archive/$2"); - } - - if (NODE) { - /* - * We don't even need to load Component, because we can't use any of the code below - * within Node anyway. Instead, we must hand this request off to our network library. - * - * if (!Component) Component = require("./component"); - */ - var Net = require("./netlib"); - return Net.getResource(sURL, dataPost, fAsync, done); - } - - var xmlHTTP = (window.XMLHttpRequest? new window.XMLHttpRequest() : new window.ActiveXObject("Microsoft.XMLHTTP")); - if (fAsync) { - xmlHTTP.onreadystatechange = function() - { - if (xmlHTTP.readyState === 4) { - /* - * The following line was recommended for WebKit, as a work-around to prevent the handler firing multiple - * times when debugging. Unfortunately, that's not the only XMLHttpRequest problem that occurs when - * debugging, so I think the WebKit problem is deeper than that. When we have multiple XMLHttpRequests - * pending, any debugging activity means most of them simply get dropped on floor, so what may actually be - * happening are mis-notifications rather than redundant notifications. - * - * xmlHTTP.onreadystatechange = undefined; - */ - sResource = xmlHTTP.responseText; - /* - * The normal "success" case is an HTTP status code of 200, but when testing with files loaded - * from the local file system (ie, when using the "file:" protocol), we have to be a bit more "flexible". - */ - if (xmlHTTP.status == 200 || !xmlHTTP.status && sResource.length && Web.getHostProtocol() == "file:") { - if (MAXDEBUG) Web.log("xmlHTTP.onreadystatechange(" + sURL + "): returned " + sResource.length + " bytes"); - } - else { - nErrorCode = xmlHTTP.status || -1; - Web.log("xmlHTTP.onreadystatechange(" + sURL + "): error code " + nErrorCode); - } - if (done) done(sURL, sResource, nErrorCode); - } - }; - } - - if (dataPost && typeof dataPost == "object") { - var sDataPost = ""; - for (var p in dataPost) { - if (!dataPost.hasOwnProperty(p)) continue; - if (sDataPost) sDataPost += "&"; - sDataPost += p + '=' + encodeURIComponent(dataPost[p]); - } - sDataPost = sDataPost.replace(/%20/g, '+'); - if (MAXDEBUG) Web.log("Web.getResource(POST " + sURL + "): " + sDataPost.length + " bytes"); - xmlHTTP.open("POST", sURL, fAsync); // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it) - xmlHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - xmlHTTP.send(sDataPost); - } else { - if (MAXDEBUG) Web.log("Web.getResource(GET " + sURL + ")"); - xmlHTTP.open("GET", sURL, fAsync); // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it) - if (dataPost == "bytes") { - xmlHTTP.overrideMimeType("text/plain; charset=x-user-defined"); - } - xmlHTTP.send(); - } - - if (!fAsync) { - sResource = xmlHTTP.responseText; - if (xmlHTTP.status == 200) { - if (MAXDEBUG) Web.log("Web.getResource(" + sURL + "): returned " + sResource.length + " bytes"); - } else { - nErrorCode = xmlHTTP.status || -1; - Web.log("Web.getResource(" + sURL + "): error code " + nErrorCode); - } - if (done) done(sURL, sResource, nErrorCode); - response = [sResource, nErrorCode]; - } - return response; - } - - /** - * parseMemoryResource(sURL, sData) - * - * @param {string} sURL - * @param {string} sData - * @return {Object|null} (resource) - */ - static parseMemoryResource(sURL, sData) - { - var i; - var resource = { - aBytes: null, - aSymbols: null, - addrLoad: null, - addrExec: null - }; - - if (sData.charAt(0) == "[" || sData.charAt(0) == "{") { - try { - var a, ib, data; - - if (sData.substr(0, 1) == "<") { // if the "data" begins with a "<"... - /* - * Early server configs reported an error (via the nErrorCode parameter) if a tape URL was invalid, - * but more recent server configs now display a somewhat friendlier HTML error page. The downside, - * however, is that the original error has been buried, and we've received "data" that isn't actually - * tape data. So if the data we've received appears to be "HTML-like", we treat it as an error message. - */ - throw new Error(sData); - } - - /* - * TODO: IE9 is rather unfriendly and restrictive with regard to how much data it's willing to - * eval(). In particular, the 10Mb disk image we use for the Windows 1.01 demo config fails in - * IE9 with an "Out of memory" exception. One work-around would be to chop the data into chunks - * (perhaps one track per chunk, using regular expressions) and then manually re-assemble it. - * - * However, it turns out that using JSON.parse(sDiskData) instead of eval("(" + sDiskData + ")") - * is a much easier fix. The only drawback is that we must first quote any unquoted property names - * and remove any comments, because while eval() was cool with them, JSON.parse() is more particular; - * the following RegExp replacements take care of those requirements. - * - * The use of hex values is something else that eval() was OK with, but JSON.parse() is not, and - * while I've stopped using hex values in DumpAPI responses (at least when "format=json" is specified), - * I can't guarantee they won't show up in "legacy" images, and there's no simple RegExp replacement - * for transforming hex values into decimal values, so I cop out and fall back to eval() if I detect - * any hex prefixes ("0x") in the sequence. Ditto for error messages, which appear like so: - * - * ["unrecognized disk path: test.img"] - */ - if (sData.indexOf("0x") < 0 && sData.substr(0, 2) != "[\"") { - data = JSON.parse(sData.replace(/([a-z]+):/gm, "\"$1\":").replace(/\/\/[^\n]*/gm, "")); - } else { - data = eval("(" + sData + ")"); - } - - resource.addrLoad = data['load']; - resource.addrExec = data['exec']; - - if (a = data['bytes']) { - resource.aBytes = a; - } - else if (a = data['words']) { - /* - * Convert all words into bytes - */ - resource.aBytes = new Array(a.length * 2); - for (i = 0, ib = 0; i < a.length; i++) { - resource.aBytes[ib++] = a[i] & 0xff; - resource.aBytes[ib++] = (a[i] >> 8) & 0xff; - Component.assert(!(a[i] & ~0xffff)); - } - } - else if (a = data['data']) { - /* - * Convert all dwords (longs) into bytes - */ - resource.aBytes = new Array(a.length * 4); - for (i = 0, ib = 0; i < a.length; i++) { - resource.aBytes[ib++] = a[i] & 0xff; - resource.aBytes[ib++] = (a[i] >> 8) & 0xff; - resource.aBytes[ib++] = (a[i] >> 16) & 0xff; - resource.aBytes[ib++] = (a[i] >> 24) & 0xff; - } - } - else { - resource.aBytes = data; - } - - resource.aSymbols = data['symbols']; - - if (!resource.aBytes.length) { - Component.error("Empty resource: " + sURL); - resource = null; - } - else if (resource.aBytes.length == 1) { - Component.error(resource.aBytes[0]); - resource = null; - } - } catch (e) { - Component.error("Resource data error (" + sURL + "): " + e.message); - resource = null; - } - } - else { - /* - * Parse the data manually; we assume it's a series of hex byte-values separated by whitespace. - */ - var ab = []; - var sHexData = sData.replace(/\n/gm, " ").replace(/ +$/, ""); - var asHexData = sHexData.split(" "); - for (i = 0; i < asHexData.length; i++) { - var n = parseInt(asHexData[i], 16); - if (isNaN(n)) { - Component.error("Resource data error (" + sURL + "): invalid hex byte (" + asHexData[i] + ")"); - break; - } - ab.push(n & 0xff); - } - if (i == asHexData.length) resource.aBytes = ab; - } - return resource; - } - - /** - * sendReport(sApp, sVer, sURL, sUser, sType, sReport, sHostName) - * - * Send a report (eg, bug report) to the server. - * - * @param {string} sApp (eg, "PCjs") - * @param {string} sVer (eg, "1.02") - * @param {string} sURL (eg, "/devices/pc/machine/5150/mda/64kb/machine.xml") - * @param {string} sUser (ie, the user key, if any) - * @param {string} sType (eg, "bug"); one of ReportAPI.TYPE.* - * @param {string} sReport (eg, unparsed state data) - * @param {string} [sHostName] (default is http://SITEHOST) - */ - static sendReport(sApp, sVer, sURL, sUser, sType, sReport, sHostName) - { - var dataPost = {}; - dataPost[ReportAPI.QUERY.APP] = sApp; - dataPost[ReportAPI.QUERY.VER] = sVer; - dataPost[ReportAPI.QUERY.URL] = sURL; - dataPost[ReportAPI.QUERY.USER] = sUser; - dataPost[ReportAPI.QUERY.TYPE] = sType; - dataPost[ReportAPI.QUERY.DATA] = sReport; - var sReportURL = (sHostName? sHostName : "http://" + SITEHOST) + ReportAPI.ENDPOINT; - Web.getResource(sReportURL, dataPost, true); - } - - /** - * getHost() - * - * @return {string} - */ - static getHost() - { - return ("http://" + (window? window.location.host : SITEHOST)); - } - - /** - * getHostURL() - * - * @return {string|null} - */ - static getHostURL() - { - return (window? window.location.href : null); - } - - /** - * getHostProtocol() - * - * @return {string} - */ - static getHostProtocol() - { - return (window? window.location.protocol : "file:"); - } - - /** - * getUserAgent() - * - * @return {string} - */ - static getUserAgent() - { - return (window? window.navigator.userAgent : ""); - } - - /** - * hasLocalStorage - * - * true if localStorage support exists, is enabled, and works; false otherwise - * - * @return {boolean} - */ - static hasLocalStorage() - { - if (Web.fLocalStorage == null) { - var f = false; - if (window) { - try { - window.localStorage.setItem(Web.sLocalStorageTest, Web.sLocalStorageTest); - f = (window.localStorage.getItem(Web.sLocalStorageTest) == Web.sLocalStorageTest); - window.localStorage.removeItem(Web.sLocalStorageTest); - } catch (e) { - Web.logLocalStorageError(e); - f = false; - } - } - Web.fLocalStorage = f; - } - return Web.fLocalStorage; - } - - /** - * logLocalStorageError(e) - * - * @param {Error} e is an exception - */ - static logLocalStorageError(e) - { - Web.log(e.message, "localStorage error"); - } - - /** - * getLocalStorageItem(sKey) - * - * Returns the requested key value, or null if the key does not exist, or undefined if localStorage is not available - * - * @param {string} sKey - * @return {string|null|undefined} sValue - */ - static getLocalStorageItem(sKey) - { - var sValue; - if (window) { - try { - sValue = window.localStorage.getItem(sKey); - } catch (e) { - Web.logLocalStorageError(e); - } - } - return sValue; - } - - /** - * setLocalStorageItem(sKey, sValue) - * - * @param {string} sKey - * @param {string} sValue - * @return {boolean} true if localStorage is available, false if not - */ - static setLocalStorageItem(sKey, sValue) - { - try { - window.localStorage.setItem(sKey, sValue); - return true; - } catch (e) { - Web.logLocalStorageError(e); - } - return false; - } - - /** - * removeLocalStorageItem(sKey) - * - * @param {string} sKey - */ - static removeLocalStorageItem(sKey) - { - try { - window.localStorage.removeItem(sKey); - } catch (e) { - Web.logLocalStorageError(e); - } - } - - /** - * getLocalStorageKeys() - * - * @return {Array} - */ - static getLocalStorageKeys() - { - var a = []; - try { - for (var i = 0, c = window.localStorage.length; i < c; i++) { - a.push(window.localStorage.key(i)); - } - } catch (e) { - Web.logLocalStorageError(e); - } - return a; - } - - /** - * reloadPage() - */ - static reloadPage() - { - if (window) window.location.reload(); - } - - /** - * isUserAgent(s) - * - * Check the browser's user-agent string for the given substring; "iOS" and "MSIE" are special values you can - * use that will match any iOS or MSIE browser, respectively (even IE11, in the case of "MSIE"). - * - * 2013-11-06: In a questionable move, MSFT changed the user-agent reported by IE11 on Windows 8.1, eliminating - * the "MSIE" string (which MSDN calls a "version token"; see http://msdn.microsoft.com/library/ms537503.aspx); - * they say "public websites should rely on feature detection, rather than browser detection, in order to design - * their sites for browsers that don't support the features used by the website." So, in IE11, we get a user-agent - * that tries to fool apps into thinking the browser is more like WebKit or Gecko: - * - * Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko - * - * That's a nice idea, but in the meantime, they hosed the XSL transform code in embed.js, which contained - * some very critical browser-specific code; turning on IE's "Compatibility Mode" didn't help either, because - * that's a sledgehammer solution which restores the old user-agent string but also disables other features like - * HTML5 canvas support. As an interim solution, I'm treating any "MSIE" check as a check for either "MSIE" or - * "Trident". - * - * UPDATE: I've since found ways to make the code in embed.js more browser-agnostic, so for now, there's isn't - * any code that cares about "MSIE", but I've left the change in place, because I wouldn't be surprised if I'll - * need more IE-specific code in the future, perhaps for things like copy/paste functionality, or mouse capture. - * - * @param {string} s is a substring to search for in the user-agent; as noted above, "iOS" and "MSIE" are special values - * @return {boolean} is true if the string was found, false if not - */ - static isUserAgent(s) - { - if (window) { - var userAgent = Web.getUserAgent(); - /* - * Here's one case where we have to be careful with Component, because when isUserAgent() is called by - * the init code below, component.js hasn't been loaded yet. The simple solution for now is to remove the call. - * - * Web.log("agent: " + userAgent); - * - * And yes, it would be pointless to use the conditional (?) operator below, if not for the Google Closure - * Compiler (v20130823) failing to detect the entire expression as a boolean. - */ - return s == "iOS" && !!userAgent.match(/(iPod|iPhone|iPad)/) && !!userAgent.match(/AppleWebKit/) || s == "MSIE" && !!userAgent.match(/(MSIE|Trident)/) || (userAgent.indexOf(s) >= 0); - } - return false; - } - - /** - * isMobile() - * - * Check the browser's user-agent string for the substring "Mobi", as per Mozilla recommendation: - * - * https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent - * - * @return {boolean} is true if the browser appears to be a mobile (ie, non-desktop) web browser, false if not - */ - static isMobile() - { - return Web.isUserAgent("Mobi"); - } - - /** - * 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 parseURLParms(sParms) - { - var aParms = {}; - if (window) { // an alternative to "if (typeof module === 'undefined')" if require("defines") was used - if (!sParms) { - /* - * Note that window.location.href returns the entire URL, whereas window.location.search - * returns only the parameters, if any (starting with the '?', which we skip over with a substr() call). - */ - sParms = window.location.search.substr(1); - } - var match; - var pl = /\+/g; // RegExp for replacing addition symbol with a space - var search = /([^&=]+)=?([^&]*)/g; - var decode = function(s) - { - return decodeURIComponent(s.replace(pl, " ")); - }; - - while ((match = search.exec(sParms))) { - aParms[decode(match[1])] = decode(match[2]); - } - } - return aParms; - } - - /** - * downloadFile(sData, sType, fBase64, sFileName) - * - * @param {string} sData - * @param {string} sType - * @param {boolean} [fBase64] - * @param {string} [sFileName] - */ - static downloadFile(sData, sType, fBase64, sFileName) - { - var link = null, sAlert; - var sURI = "data:application/" + sType + (fBase64? ";base64" : "") + ","; - - if (!Web.isUserAgent("Firefox")) { - sURI += (fBase64? sData : encodeURI(sData)); - } else { - sURI += (fBase64? sData : encodeURIComponent(sData)); - } - if (sFileName) { - link = document.createElement('a'); - if (typeof link.download != 'string') link = null; - } - if (link) { - link.href = sURI; - link.download = sFileName; - document.body.appendChild(link); // Firefox allegedly requires the link to be in the body - link.click(); - document.body.removeChild(link); - sAlert = 'Check your Downloads folder for ' + sFileName + '.'; - } else { - window.open(sURI); - sAlert = 'Check your browser for a new window/tab containing the requested data' + (sFileName? (' (' + sFileName + ')') : '') + '.'; - } - return sAlert; - } - - /** - * onCountRepeat(n, fnRepeat, fnComplete, msDelay) - * - * Call fnRepeat() n times with an msDelay millisecond delay between calls, - * then call fnComplete() when n has been exhausted OR fnRepeat() returns false. - * - * @param {number} n - * @param {function()} fnRepeat - * @param {function()} fnComplete - * @param {number} [msDelay] - */ - static onCountRepeat(n, fnRepeat, fnComplete, msDelay) - { - var fnTimeout = function doCountRepeat() - { - n -= 1; - if (n >= 0) { - if (!fnRepeat()) n = 0; - } - if (n > 0) { - setTimeout(fnTimeout, msDelay || 0); - return; - } - fnComplete(); - }; - fnTimeout(); - } - - /** - * onClickRepeat(e, msDelay, msRepeat, fn) - * - * Repeatedly call fn() with an initial msDelay, and an msRepeat delay thereafter, - * as long as HTML control Object e has an active "down" event and fn() returns true. - * - * @param {Object} e - * @param {number} msDelay - * @param {number} msRepeat - * @param {function(boolean)} fn is passed false on the first call, true on all repeated calls - */ - static onClickRepeat(e, msDelay, msRepeat, fn) - { - var ms = 0, timer = null, fIgnoreMouseEvents = false; - - var fnRepeat = function doClickRepeat() - { - if (fn(ms === msRepeat)) { - timer = setTimeout(fnRepeat, ms); - ms = msRepeat; - } - }; - e.onmousedown = function() - { - // Web.log("onMouseDown()"); - if (!fIgnoreMouseEvents) { - if (!timer) { - ms = msDelay; - fnRepeat(); - } - } - }; - e.ontouchstart = function() - { - // Web.log("onTouchStart()"); - if (!timer) { - ms = msDelay; - fnRepeat(); - } - }; - e.onmouseup = e.onmouseout = function() - { - // Web.log("onMouseUp()/onMouseOut()"); - if (timer) { - clearTimeout(timer); - timer = null; - } - }; - e.ontouchend = e.ontouchcancel = function() - { - // Web.log("onTouchEnd()/onTouchCancel()"); - if (timer) { - clearTimeout(timer); - timer = null; - } - /* - * Devices that generate ontouch* events ALSO generate onmouse* events, - * and generally do so immediately after all the touch events are complete, - * so unless we want double the action, we need to ignore mouse events. - */ - fIgnoreMouseEvents = true; - }; - } - - /** - * onPageEvent(sName, fn) - * - * For 'onload', 'onunload', and 'onpageshow' events, most callers should NOT use this function, but - * instead use Web.onInit(), Web.onShow(), and Web.onExit(), respectively. - * - * The only components that should still use onPageEvent() are THIS component (see the bottom of this file) - * and components that need to capture other events (eg, the 'onresize' event in the Video component). - * - * This function creates a chain of callbacks, allowing multiple JavaScript modules to define handlers - * for the same event, which wouldn't be possible if everyone modified window['onload'], window['onunload'], - * etc, themselves. However, that's less of a concern now, because assuming everyone else is now using - * onInit(), onExit(), etc, then there really IS only one component setting the window callback: this one. - * - * NOTE: It's risky to refer to obscure event handlers with "dot" names, because the Closure Compiler may - * erroneously replace them (eg, window.onpageshow is a good example). - * - * @param {string} sFunc - * @param {function()} fn - */ - static onPageEvent(sFunc, fn) - { - if (window) { - var fnPrev = window[sFunc]; - if (typeof fnPrev !== 'function') { - window[sFunc] = fn; - } else { - /* - * TODO: Determine whether there's any value in receiving/sending the Event object that the - * browser provides when it generates the original event. - */ - window[sFunc] = function onWindowEvent() - { - if (fnPrev) fnPrev(); - fn(); - }; - } - } - }; - - /** - * onInit(fn) - * - * Use this instead of setting window.onload. Allows multiple JavaScript modules to define their own 'onload' event handler. - * - * @param {function()} fn - */ - static onInit(fn) - { - Web.aPageEventHandlers['init'].push(fn); - }; - - /** - * onShow(fn) - * - * @param {function()} fn - * - * Use this instead of setting window.onpageshow. Allows multiple JavaScript modules to define their own 'onpageshow' event handler. - */ - static onShow(fn) - { - Web.aPageEventHandlers['show'].push(fn); - }; - - /** - * onExit(fn) - * - * @param {function()} fn - * - * Use this instead of setting window.onunload. Allows multiple JavaScript modules to define their own 'onunload' event handler. - */ - static onExit(fn) - { - Web.aPageEventHandlers['exit'].push(fn); - }; - - /** - * doPageEvent(afn) - * - * @param {Array.} afn - */ - static doPageEvent(afn) - { - if (Web.fPageEventsEnabled) { - try { - for (var i = 0; i < afn.length; i++) { - afn[i](); - } - } catch (e) { - Web.notice("An unexpected exception occurred:\n\n" + e.message + "\n\nPlease send this information to support@pcjs.org. Thanks."); - } - } - }; - - /** - * enablePageEvents(fEnable) - * - * @param {boolean} fEnable is true to enable page events, false to disable (they're enabled by default) - */ - static enablePageEvents(fEnable) - { - if (!Web.fPageEventsEnabled && fEnable) { - Web.fPageEventsEnabled = true; - if (Web.fPageLoaded) Web.sendPageEvent('init'); - if (Web.fPageShowed) Web.sendPageEvent('show'); - return; - } - Web.fPageEventsEnabled = fEnable; - } - - /** - * sendPageEvent(sEvent) - * - * This allows us to manually trigger page events. - * - * @param {string} sEvent (one of 'init', 'show' or 'exit') - */ - static sendPageEvent(sEvent) - { - if (Web.aPageEventHandlers[sEvent]) { - Web.doPageEvent(Web.aPageEventHandlers[sEvent]); - } - } -} - -Web.parmsURL = null; // initialized on first call to parseURLParms() - -Web.aPageEventHandlers = { - 'init': [], // list of window 'onload' handlers - 'show': [], // list of window 'onpageshow' handlers - 'exit': [] // list of window 'onunload' handlers (although we prefer to use 'onbeforeunload' if possible) -}; - -Web.fPageLoaded = false; // set once the page's first 'onload' event has occurred -Web.fPageShowed = false; // set once the page's first 'onpageshow' event has occurred -Web.fPageEventsEnabled = true; // default is true, set to false (or true) by enablePageEvents() - -/** - * fLocalStorage - * - * true if localStorage support exists, is enabled, and works; "falsey" otherwise - * - * @type {boolean|null} - */ -Web.fLocalStorage = null; - -/** - * TODO: Is there any way to get the Closure Compiler to stop inlining this string? This isn't cutting it. - * - * @const {string} - */ -Web.sLocalStorageTest = "PCjs.localStorage"; - -Web.onPageEvent('onload', function onPageLoad() { - Web.fPageLoaded = true; - Web.doPageEvent(Web.aPageEventHandlers['init']); -}); - -Web.onPageEvent('onpageshow', function onPageShow() { - Web.fPageShowed = true; - Web.doPageEvent(Web.aPageEventHandlers['show']); -}); - -Web.onPageEvent(Web.isUserAgent("Opera") || Web.isUserAgent("iOS")? 'onunload' : 'onbeforeunload', function onPageUnload() { - Web.doPageEvent(Web.aPageEventHandlers['exit']); -}); - -if (NODE) module.exports = Web; diff --git a/modules/shared/lib/component.js b/modules/shared/lib/component.js index 76e5b7518..58bafd9ff 100644 --- a/modules/shared/lib/component.js +++ b/modules/shared/lib/component.js @@ -27,627 +27,614 @@ */ /* - * All the PCjs components now use JSDoc types, primarily so that Google's Closure Compiler will - * compile everything with ZERO warnings. For more information about the JSDoc types supported by - * the Closure Compiler: + * All PCjs components now use JSDoc types, primarily so that Google's Closure Compiler will compile + * everything with zero warnings when ADVANCED_OPTIMIZATIONS are enabled. For more information about + * the JSDoc types supported by the Closure Compiler: * * https://developers.google.com/closure/compiler/docs/js-for-compiler#types * - * I also attempted to use JSLint, but it's excessively strict for my taste, so this is the only file - * I tried massaging for JSLint's sake. I gave up when it complained about my use of "while (true)"; - * replacing "true" with an assignment expression didn't make it any happier. + * I also attempted to validate this code with JSLint, but it complained too much; eg, it didn't like + * "while (true)", a tried and "true" programming convention for decades, and it wanted me to replace + * all "++" and "--" operators with "+= 1" and "-= 1", use "(s || '')" instead of "(s? s : '')", etc. * - * I wasn't thrilled about replacing all "++" and "--" operators with "+= 1" and "-= 1", nor about using - * "(s || '')" instead of "(s? s : '')", because while the former may seem simpler, it is NOT more portable. - * It's not that I'm trying to write "portable JavaScript", but some of this code was ported from C code I'd - * written about 14 years earlier, and portability is good, so I'm not going to rewrite if there's no need. + * I prefer sticking with traditional C-style idioms, in part because they are more portable. That + * does NOT mean I'm trying to write "portable JavaScript," but some of this code was ported from C code + * I'd written long ago, so portability is good, and I'm not going to throw that away if there's no need. * - * UPDATE: I've since switched to JSHint, which seems to have more reasonable defaults. + * UPDATE: I've since switched from JSLint to JSHint, which seems to have more reasonable defaults. + * And for new code, I have adopted some popular JavaScript idioms, like "(s || '')", although the need + * for those kinds of expressions will be reduced as I also start adopting some ES6 features, like + * default parameters. */ "use strict"; -/* global window: true, DEBUG: true */ - -if (NODE) { - require("./defines"); - var usr = require("./usrlib"); - var web = require("./weblib"); -} - /** - * Component(type, parms, constructor, bitsMessage) + * Since the Closure Compiler treats ES6 classes as @struct rather than @dict by default, + * it deters us from defining named properties on our components; eg: * - * A Component object requires: + * this['exports'] = {...} * - * type: a user-defined type name (eg, "CPU") + * results in an error: * - * and accepts any or all of the following (parms) properties: + * Cannot do '[]' access on a struct * - * id: component ID (default is "") - * name: component name (default is ""; if blank, toString() will use the type name only) - * comment: component comment string (default is undefined) + * So, in order to define 'exports', we must override the @struct assumption by annotating + * the class as @unrestricted (or @dict). Note that this must be done both here and in the + * subclass (eg, SerialPort), because otherwise the Compiler won't allow us to *reference* + * the named property either. * - * Subclasses that use Component.subclass() to extend Component will likely have additional (parms) properties. + * TODO: Consider marking ALL our classes unrestricted, because otherwise it forces us to + * define every single property the class uses in its constructor, which results in a fair + * bit of redundant initialization, since many properties aren't (and don't need to be) fully + * initialized until the appropriate init(), reset(), restore(), etc. function is called. * - * @constructor - * @param {string} type - * @param {Object} [parms] - * @param {Object} [constructor] - * @param {number} [bitsMessage] selects message(s) that the component wants to enable (default is 0) + * The upside, however, may be that since the structure of the class is completely defined by + * the constructor, JavaScript engines may be able to optimize and run more efficiently. + * + * @unrestricted */ -function Component(type, parms, constructor, bitsMessage) -{ - this.type = type; +class Component { + /** + * Component(type, parms, bitsMessage) + * + * A Component object requires: + * + * type: a user-defined type name (eg, "CPU") + * + * and accepts any or all of the following (parms) properties: + * + * id: component ID (default is "") + * name: component name (default is ""; if blank, toString() will use the type name only) + * comment: component comment string (default is undefined) + * + * Component subclasses will usually have additional (parms) properties. + * + * @param {string} type + * @param {Object} [parms] + * @param {number} [bitsMessage] selects message(s) that the component wants to enable (default is 0) + */ + constructor(type, parms, bitsMessage) + { + this.type = type; - if (!parms) parms = {'id': "", 'name': ""}; + if (!parms) parms = {'id': "", 'name': ""}; - this.id = parms['id'] || ""; - this.name = parms['name']; - this.comment = parms['comment']; - this.parms = parms; + this.id = parms['id'] || ""; + this.name = parms['name']; + this.comment = parms['comment']; + this.parms = parms; - var i = this.id.indexOf('.'); - if (i < 0) { - this.idComponent = this.id; - } else { - this.idMachine = this.id.substr(0, i); - this.idComponent = this.id.substr(i + 1); + /* + * The following Component properties need to be accessible by other machines and/or command scripts; + * well, OK, or we could have exported some new functions to walk the contents of these properties, as we + * did with findMachineComponent(), but this works just as well. + * + * Also, while the double-assignment looks silly (ie, using both dot and bracket property notation), it + * resolves a complaint from the Closure Compiler, because if we use ONLY bracket notation here, then the + * Compiler wants us to change all the other references to bracket notation as well. + */ + this.exports = this['exports'] = {}; + this.bindings = this['bindings'] = {}; + + var i = this.id.indexOf('.'); + if (i < 0) { + this.idComponent = this.id; + } else { + this.idMachine = this.id.substr(0, i); + this.idComponent = this.id.substr(i + 1); + } + + /* + * Gather all the various component flags (booleans) into a single "flags" object, and encourage + * subclasses to do the same, to reduce the property clutter we have to wade through while debugging. + */ + this.flags = { + ready: false, + busy: false, + busyCancel: false, + powered: false, + error: false + }; + + this.fnReady = null; + this.clearError(); + this.bitsMessage = bitsMessage || 0; + + /** @type {Object|null} controlPrint is the HTML control, if any, that we can print to */ + this.controlPrint = null; + + this.cmp = null; + this.bus = null; + this.cpu = null; + this.dbg = null; + + /* + * TODO: Consider adding another parameter to the Component() constructor that allows components to tell + * us if they support single or multiple instances per machine. For example, there can be multiple SerialPort + * components per machine, but only one CPU component (some machines also support an FPU, but that component + * is considered separate from the CPU). + * + * It's not critical, but it would help catch machine configuration errors; for example, a machine that mistakenly + * includes two CPU components may, aside from wasting memory, end up with odd side-effects, like unresponsive + * CPU controls. + */ + Component.add(this); } - /* - * Recording the constructor is really just a debugging aid, because many of our constructors - * have class constants, but they're hard to find when the constructors are buried among all the - * other globals. + /** + * Component.add(component) + * + * @param {Component} component */ - this[type] = constructor; + static add(component) + { + /* + * This just generates a lot of useless noise, handy in the early days, not so much these days.... + * + * if (DEBUG) Component.log("Component.add(" + component.type + "," + component.id + ")"); + */ + Component.components.push(component); + } - /* - * Gather all the various component flags (booleans) into a single "flags" object, and encourage - * subclasses to do the same, to reduce the property clutter we have to wade through while debugging. + /** + * Component.addMachine(idMachine) + * + * @param {string} idMachine */ - this.flags = { - ready: false, - busy: false, - busyCancel: false, - powered: false, - error: false + static addMachine(idMachine) + { + Component.machines[idMachine] = {}; + } + + /** + * Component.addMachineResource(idMachine, sName, data) + * + * @param {string} idMachine + * @param {string|null} sName (name of the resource) + * @param {*} data + */ + static addMachineResource(idMachine, sName, data) + { + /* + * I used to assert(Component.machines[idMachine]), but when we're running as a Node app, embed.js is not used, + * so addMachine() is never called, so resources do not need to be recorded. + */ + if (Component.machines[idMachine] && sName) { + Component.machines[idMachine][sName] = data; + } + } + + /** + * Component.getMachineResources(idMachine) + * + * @param {string} idMachine + * @return {Object|undefined} + */ + static getMachineResources(idMachine) + { + return Component.machines[idMachine]; + } + + /** + * Component.getTime() + * + * @return {number} the current time, in milliseconds + */ + static getTime() + { + return Date.now() || +new Date(); + } + + /** + * Component.log(s, type) + * + * For diagnostic output only. + * + * @param {string} [s] is the message text + * @param {string} [type] is the message type + */ + static log(s, type) + { + if (!COMPILED) { + if (s) { + var sElapsed = "", sMsg = (type? (type + ": ") : "") + s; + if (typeof Usr != "undefined") { + if (Component.msStart === undefined) { + Component.msStart = Component.getTime(); + } + sElapsed = (Component.getTime() - Component.msStart) + "ms: "; + } + if (window && window.console) console.log(sElapsed + sMsg.replace(/\n/g, " ")); + } + } + } + + /** + * Component.assert(f, s) + * + * Verifies conditions that must be true (for DEBUG builds only). + * + * The Closure Compiler should automatically remove all references to Component.assert() in non-DEBUG builds. + * TODO: Add a task to the build process that "asserts" there are no instances of "assertion failure" in RELEASE builds. + * + * @param {boolean} f is the expression we are asserting to be true + * @param {string} [s] is description of the assertion on failure + */ + static assert(f, s) + { + if (DEBUG) { + if (!f) { + if (!s) s = "assertion failure"; + Component.log(s); + throw new Error(s); + } + } + } + + /** + * Component.println(s, type, id) + * + * For non-diagnostic messages, which components may override to control the destination/appearance of their output. + * + * Components that inherit from this class should use the instance method, this.println(), rather than Component.println(), + * because if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the class + * method would improperly affect any other machines loaded on the same page). + * + * @param {string} [s] is the message text + * @param {string} [type] is the message type + * @param {string} [id] is the caller's ID, if any + */ + static println(s, type, id) + { + if (!COMPILED) { + Component.log((id? (id + ": ") : "") + (s? ("\"" + s + "\"") : ""), type); + } + } + + /** + * Component.notice(s, fPrintOnly, id) + * + * notice() is like println() but implies a need for user notification, so we alert() as well. + * + * @param {string} s is the message text + * @param {boolean} [fPrintOnly] + * @param {string} [id] is the caller's ID, if any + */ + static notice(s, fPrintOnly, id) + { + if (!COMPILED) { + Component.println(s, "notice", id); + } + if (!fPrintOnly) Component.alertUser((id? (id + ": ") : "") + s); + } + + /** + * Component.warning(s) + * + * @param {string} s describes the warning + */ + static warning(s) + { + if (!COMPILED) { + Component.println(s, "warning"); + } + Component.alertUser(s); + } + + /** + * Component.error(s) + * + * @param {string} s describes the error; an alert() is displayed as well + */ + static error(s) + { + if (!COMPILED) { + Component.println(s, "error"); + } + Component.alertUser(s); + } + + /** + * Component.alertUser(sMessage) + * + * @param {string} sMessage + */ + static alertUser(sMessage) + { + if (window) { + window.alert(sMessage); + } else { + Component.log(sMessage); + } }; - this.fnReady = null; - this.clearError(); - this.bindings = {}; - this.dbg = null; // by default, no connection to a Debugger - this.bitsMessage = bitsMessage || 0; - - /* - * TODO: Consider adding another parameter to the Component() constructor that allows components to tell - * us if they support single or multiple instances per machine. For example, there can be multiple SerialPort - * components per machine, but only one CPU component (well, OK, an FPU is also supported, but that's considered - * a different component). - * - * It's not critical, but it would help catch machine configuration errors; for example, a machine that mistakenly - * includes two CPU components may, aside from wasting memory, end up with odd side-effects, like unresponsive - * CPU controls. - */ - Component.add(this); -} - -/** - * Component.inherit(p) - * - * Returns a newly created object that inherits properties from the prototype object p. - * It uses the ECMAScript 5 function Object.create() if it is defined, and otherwise falls back to an older technique. - * - * See: Flanagan, David (2011-04-18). JavaScript: The Definitive Guide: The Definitive Guide (Kindle Locations 9854-9903). OReilly Media - A. Kindle Edition (Example 6-1) - * - * @param {Object} p - */ -Component.inherit = function(p) -{ - if (window) { - if (!p) throw new TypeError(); - if (Object.create) { - return Object.create(p); - } - var t = typeof p; - if (t !== "object" && t !== "function") throw new TypeError(); - } /** - * @constructor - */ - function F() {} - F.prototype = p; - return new F(); -}; - -/** - * Component.extend(o, p) - * - * Copies the enumerable properties of p to o and returns o. - * If o and p have a property by the same name, o's property is overwritten. - * - * See: Flanagan, David (2011-04-18). JavaScript: The Definitive Guide: The Definitive Guide (Kindle Locations 9854-9903). OReilly Media - A. Kindle Edition (Example 6-2) - * - * @param {Object} o - * @param {Object} p - */ -Component.extend = function(o, p) -{ - for (var prop in p) { - o[prop] = p[prop]; - } - return o; -}; - -/** - * Component.subclass(subclass, superclass, methods, statics) - * - * See: Flanagan, David (2011-04-18). JavaScript: The Definitive Guide: The Definitive Guide (Kindle Locations 9854-9903). OReilly Media - A. Kindle Edition (Example 9-11) - * - * @param {Object} subclass is the constructor for the new subclass - * @param {Object} [superclass] is the constructor of the superclass (default is Component) - * @param {Object} [methods] contains all instance methods - * @param {Object} [statics] contains all class properties and methods - */ -Component.subclass = function(subclass, superclass, methods, statics) -{ - if (!superclass) superclass = Component; - subclass.prototype = Component.inherit(superclass.prototype); - subclass.prototype.constructor = subclass; - subclass.prototype.parent = superclass.prototype; - if (methods) { - Component.extend(subclass.prototype, methods); - } - if (statics) { - Component.extend(subclass, statics); - } - return subclass; -}; - -/* - * 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()) - * or by type (see Component.getComponentByType()). - * - * Every machine on the page are now recorded as well, by their machine ID. We then record the - * various resources used by that machine. - */ -if (window) { - if (!window['PCjs']) window['PCjs'] = {}; - Component.machines = window['PCjs']['Machines'] || (window['PCjs']['Machines'] = {}); - Component.components = window['PCjs']['Components'] || (window['PCjs']['Components'] = []); -} -else { - /* - * Fallback for non-browser-based environments (ie, Node). TODO: This will need to be - * tailored to Node, probably using the global object instead of the window object, if we - * ever want to support multi-machine configs in that environment. - */ - Component.machines = {}; - Component.components = []; -} - -/** - * Component.add(component) - * - * @param {Component} component - */ -Component.add = function(component) -{ - /* - * This just generates a lot of useless noise, handy in the early days, not so much these days.... + * Component.confirmUser(sPrompt) * - * if (DEBUG) Component.log("Component.add(" + component.type + "," + component.id + ")"); + * @param {string} sPrompt + * @returns {boolean} true if the user clicked OK, false if Cancel/Close */ - Component.components.push(component); -}; - -/** - * Component.addMachine(idMachine) - * - * @param {string} idMachine - */ -Component.addMachine = function(idMachine) -{ - Component.machines[idMachine] = {}; -}; - -/** - * Component.addMachineResource(idMachine, sName, data) - * - * @param {string} idMachine - * @param {string|null} sName (name of the resource) - * @param {*} data - */ -Component.addMachineResource = function(idMachine, sName, data) -{ - /* - * I used to assert(Component.machines[idMachine]), but when we're running as a Node app, embed.js is not used, - * so addMachine() is never called, so resources do not need to be recorded. - */ - if (Component.machines[idMachine] && sName) { - Component.machines[idMachine][sName] = data; - } -}; - -/** - * Component.getMachineResources(idMachine) - * - * @param {string} idMachine - * @return {Object|undefined} - */ -Component.getMachineResources = function(idMachine) -{ - return Component.machines[idMachine]; -}; - -/** - * Component.log(s, type) - * - * For diagnostic output only. - * - * @param {string} [s] is the message text - * @param {string} [type] is the message type - */ -Component.log = function(s, type) -{ - if (!COMPILED) { - if (s) { - var sElapsed = "", sMsg = (type? (type + ": ") : "") + s; - if (typeof usr != "undefined") { - if (Component.msStart === undefined) { - Component.msStart = usr.getTime(); - } - sElapsed = (usr.getTime() - Component.msStart) + "ms: "; - } - if (window && window.console) console.log(sElapsed + sMsg.replace(/\n/g, " ")); + static confirmUser(sPrompt) + { + var fResponse = false; + if (window) { + fResponse = window.confirm(sPrompt); } + return fResponse; } -}; -/** - * Component.assert(f, s) - * - * Verifies conditions that must be true (for DEBUG builds only). - * - * The Closure Compiler should automatically remove all references to Component.assert() in non-DEBUG builds. - * TODO: Add a task to the build process that "asserts" there are no instances of "assertion failure" in RELEASE builds. - * - * @param {boolean} f is the expression we are asserting to be true - * @param {string} [s] is description of the assertion on failure - */ -Component.assert = function(f, s) -{ - if (DEBUG) { - if (!f) { - if (!s) s = "assertion failure"; - Component.log(s); - throw new Error(s); - } - } -}; - -/** - * Component.println(s, type, id) - * - * For non-diagnostic messages, which components may override to control the destination/appearance of their output. - * - * Components that inherit from this class should use the instance method, this.println(), rather than Component.println(), - * because if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the class - * method would improperly affect any other machines loaded on the same page). - * - * @param {string} [s] is the message text - * @param {string} [type] is the message type - * @param {string} [id] is the caller's ID, if any - */ -Component.println = function(s, type, id) -{ - if (!COMPILED) { - Component.log((id? (id + ": ") : "") + (s? ("\"" + s + "\"") : ""), type); - } -}; - -/** - * Component.notice(s, fPrintOnly, id) - * - * notice() is like println() but implies a need for user notification, so we alert() as well. - * - * @param {string} s is the message text - * @param {boolean} [fPrintOnly] - * @param {string} [id] is the caller's ID, if any - */ -Component.notice = function(s, fPrintOnly, id) -{ - if (!COMPILED) { - Component.println(s, "notice", id); - } - if (!fPrintOnly) web.alertUser((id? (id + ": ") : "") + s); -}; - -/** - * Component.warning(s) - * - * @param {string} s describes the warning - */ -Component.warning = function(s) -{ - if (!COMPILED) { - Component.println(s, "warning"); - } - web.alertUser(s); -}; - -/** - * Component.error(s) - * - * @param {string} s describes the error; an alert() is displayed as well - */ -Component.error = function(s) -{ - if (!COMPILED) { - Component.println(s, "error"); - } - web.alertUser(s); -}; - -/** - * Component.getComponents(idRelated) - * - * We could store components as properties, using the component's ID, and change - * this linear lookup into a property lookup, but some components may have no ID. - * - * @param {string} [idRelated] of related component - * @return {Array} of components - */ -Component.getComponents = function(idRelated) -{ - var i; - var aComponents = []; - /* - * getComponentByID(id, idRelated) + /** + * Component.promptUser() * - * If idRelated is provided, we check it for a machine prefix, and use any - * existing prefix to constrain matches to IDs with the same prefix, in order to - * avoid matching components belonging to other machines. + * @param {string} sPrompt + * @param {string} [sDefault] + * @returns {string|null} */ - if (idRelated) { - if ((i = idRelated.indexOf('.')) > 0) - idRelated = idRelated.substr(0, i + 1); - else - idRelated = ""; - } - for (i = 0; i < Component.components.length; i++) { - var component = Component.components[i]; - if (!idRelated || !component.id.indexOf(idRelated)) { - aComponents.push(component); + static promptUser(sPrompt, sDefault) + { + var sResponse = null; + if (window) { + sResponse = window.prompt(sPrompt, sDefault === undefined? "" : sDefault); } + return sResponse; } - return aComponents; -}; -/** - * Component.getComponentByID(id, idRelated) - * - * We could store components as properties, using the component's ID, and change - * this linear lookup into a property lookup, but some components may have no ID. - * - * @param {string} id of the desired component - * @param {string} [idRelated] of related component - * @return {Component|null} - */ -Component.getComponentByID = function(id, idRelated) -{ - if (id !== undefined) { - var i; - /* - * If idRelated is provided, we check it for a machine prefix, and use any - * existing prefix to constrain matches to IDs with the same prefix, in order to - * avoid matching components belonging to other machines. - */ - if (idRelated && (i = idRelated.indexOf('.')) > 0) { - id = idRelated.substr(0, i + 1) + id; - } - for (i = 0; i < Component.components.length; i++) { - if (Component.components[i].id === id) { - return Component.components[i]; - } - } - if (Component.components.length) { - Component.log("Component ID '" + id + "' not found", "warning"); - } - } - return null; -}; - -/** - * Component.getComponentByType(sType, idRelated, componentPrev) - * - * @param {string} sType of the desired component - * @param {string} [idRelated] of related component - * @param {Component|null} [componentPrev] of previously returned component, if any - * @return {Component|null} - */ -Component.getComponentByType = function(sType, idRelated, componentPrev) -{ - if (sType !== undefined) { + /** + * Component.getComponents(idRelated) + * + * We could store components as properties, using the component's ID, and change + * this linear lookup into a property lookup, but some components may have no ID. + * + * @param {string} [idRelated] of related component + * @return {Array} of components + */ + static getComponents(idRelated) + { var i; + var aComponents = []; /* + * getComponentByID(id, idRelated) + * * If idRelated is provided, we check it for a machine prefix, and use any * existing prefix to constrain matches to IDs with the same prefix, in order to * avoid matching components belonging to other machines. */ if (idRelated) { - if ((i = idRelated.indexOf('.')) > 0) { + if ((i = idRelated.indexOf('.')) > 0) idRelated = idRelated.substr(0, i + 1); - } else { + else idRelated = ""; - } } for (i = 0; i < Component.components.length; i++) { - if (componentPrev) { - if (componentPrev == Component.components[i]) componentPrev = null; - continue; - } - if (sType == Component.components[i].type && (!idRelated || !Component.components[i].id.indexOf(idRelated))) { - return Component.components[i]; + var component = Component.components[i]; + if (!idRelated || !component.id.indexOf(idRelated)) { + aComponents.push(component); } } - Component.log("Component type '" + sType + "' not found", "warning"); + return aComponents; } - return null; -}; -/** - * Component.getComponentParms(element) - * - * @param {Object} element from the DOM - */ -Component.getComponentParms = function(element) -{ - var parms = null; - var sParms = element.getAttribute("data-value"); - if (sParms) { - try { - parms = eval("(" + sParms + ")"); // jshint ignore:line + /** + * Component.getComponentByID(id, idRelated) + * + * We could store components as properties, using the component's ID, and change + * this linear lookup into a property lookup, but some components may have no ID. + * + * @param {string} id of the desired component + * @param {string} [idRelated] of related component + * @return {Component|null} + */ + static getComponentByID(id, idRelated) + { + if (id !== undefined) { + var i; /* - * We can no longer invoke removeAttribute() because some components (eg, Panel) need - * to run their initXXX() code more than once, to avoid initialization-order dependencies. - * - * if (!DEBUG) { - * element.removeAttribute("data-value"); - * } + * If idRelated is provided, we check it for a machine prefix, and use any + * existing prefix to constrain matches to IDs with the same prefix, in order to + * avoid matching components belonging to other machines. */ - } catch(e) { - Component.error(e.message + " (" + sParms + ")"); - } - } - return parms; -}; - -/** - * Component.bindExternalControl(component, sControl, sBinding, sType) - * - * @param {Component} component - * @param {string} sControl - * @param {string} sBinding - * @param {string} [sType] is the external component type - */ -Component.bindExternalControl = function(component, sControl, sBinding, sType) -{ - if (sControl) { - if (sType === undefined) sType = "Panel"; - var target = Component.getComponentByType(sType, component.id); - if (target) { - var eBinding = target.bindings[sControl]; - if (eBinding) { - component.setBinding(null, sBinding, eBinding); + if (idRelated && (i = idRelated.indexOf('.')) > 0) { + id = idRelated.substr(0, i + 1) + id; + } + for (i = 0; i < Component.components.length; i++) { + if (Component.components[i].id === id) { + return Component.components[i]; + } + } + if (Component.components.length) { + Component.log("Component ID '" + id + "' not found", "warning"); } } + return null; } -}; -/** - * Component.bindComponentControls(component, element, sAppClass) - * - * @param {Component} component - * @param {Object} element from the DOM - * @param {string} sAppClass - */ -Component.bindComponentControls = function(component, element, sAppClass) -{ - var aeControls = Component.getElementsByClass(element.parentNode, sAppClass + "-control"); - - for (var iControl = 0; iControl < aeControls.length; iControl++) { - - var aeChildNodes = aeControls[iControl].childNodes; - - for (var iNode = 0; iNode < aeChildNodes.length; iNode++) { - var control = aeChildNodes[iNode]; - if (control.nodeType !== 1 /* document.ELEMENT_NODE */) { - continue; + /** + * Component.getComponentByType(sType, idRelated, componentPrev) + * + * @param {string} sType of the desired component + * @param {string} [idRelated] of related component + * @param {Component|null} [componentPrev] of previously returned component, if any + * @return {Component|null} + */ + static getComponentByType(sType, idRelated, componentPrev) + { + if (sType !== undefined) { + var i; + /* + * If idRelated is provided, we check it for a machine prefix, and use any + * existing prefix to constrain matches to IDs with the same prefix, in order to + * avoid matching components belonging to other machines. + */ + if (idRelated) { + if ((i = idRelated.indexOf('.')) > 0) { + idRelated = idRelated.substr(0, i + 1); + } else { + idRelated = ""; + } } - var sClass = control.getAttribute("class"); - if (!sClass) continue; - var aClasses = sClass.split(" "); - for (var iClass = 0; iClass < aClasses.length; iClass++) { - var parms; - sClass = aClasses[iClass]; - switch (sClass) { - case sAppClass + "-binding": - parms = Component.getComponentParms(control); - if (parms && parms['binding']) { - component.setBinding(parms['type'], parms['binding'], control, parms['value']); - } else if (!parms || parms['type'] != "description") { - Component.log("Component '" + component.toString() + "' missing binding" + (parms? " for " + parms['type'] : ""), "warning"); - } - iClass = aClasses.length; - break; - default: - // if (DEBUG) Component.log("Component.bindComponentControls(" + component.toString() + "): unrecognized control class \"" + sClass + "\"", "warning"); - break; + for (i = 0; i < Component.components.length; i++) { + if (componentPrev) { + if (componentPrev == Component.components[i]) componentPrev = null; + continue; + } + if (sType == Component.components[i].type && (!idRelated || !Component.components[i].id.indexOf(idRelated))) { + return Component.components[i]; + } + } + Component.log("Component type '" + sType + "' not found", "warning"); + } + return null; + } + + /** + * Component.getComponentParms(element) + * + * @param {Object} element from the DOM + */ + static getComponentParms(element) + { + var parms = null; + var sParms = element.getAttribute("data-value"); + if (sParms) { + try { + parms = eval("(" + sParms + ")"); // jshint ignore:line + /* + * We can no longer invoke removeAttribute() because some components (eg, Panel) need + * to run their initXXX() code more than once, to avoid initialization-order dependencies. + * + * if (!DEBUG) { + * element.removeAttribute("data-value"); + * } + */ + } catch(e) { + Component.error(e.message + " (" + sParms + ")"); + } + } + return parms; + } + + /** + * Component.bindExternalControl(component, sControl, sBinding, sType) + * + * @param {Component} component + * @param {string} sControl + * @param {string} sBinding + * @param {string} [sType] is the external component type + */ + static bindExternalControl(component, sControl, sBinding, sType) + { + if (sControl) { + if (sType === undefined) sType = "Panel"; + var target = Component.getComponentByType(sType, component.id); + if (target) { + var eBinding = target.bindings[sControl]; + if (eBinding) { + component.setBinding(null, sBinding, eBinding); } } } } -}; -/** - * Component.getElementsByClass(element, sClass, sObjClass) - * - * This is a cross-browser helper function, since not all browser's support getElementsByClassName() - * - * TODO: This should probably be moved into weblib.js at some point, along with the control binding functions above, - * to keep all the browser-related code together. - * - * @param {Object} element from the DOM - * @param {string} sClass - * @param {string} [sObjClass] - * @return {Array|NodeList} - */ -Component.getElementsByClass = function(element, sClass, sObjClass) -{ - if (sObjClass) sClass += '-' + sObjClass + "-object"; - /* - * Use the browser's built-in getElementsByClassName() if it appears to be available - * (for example, it's not available in IE8, but it should be available in IE9 and up) + /** + * Component.bindComponentControls(component, element, sAppClass) + * + * @param {Component} component + * @param {Object} element from the DOM + * @param {string} sAppClass */ - if (element.getElementsByClassName) { - return element.getElementsByClassName(sClass); - } - var i, j, ae = []; - var aeAll = element.getElementsByTagName("*"); - var re = new RegExp('(^| )' + sClass + '( |$)'); - for (i = 0, j = aeAll.length; i < j; i++) { - if (re.test(aeAll[i].className)) { - ae.push(aeAll[i]); + static bindComponentControls(component, element, sAppClass) + { + var aeControls = Component.getElementsByClass(element.parentNode, sAppClass + "-control"); + + for (var iControl = 0; iControl < aeControls.length; iControl++) { + + var aeChildNodes = aeControls[iControl].childNodes; + + for (var iNode = 0; iNode < aeChildNodes.length; iNode++) { + var control = aeChildNodes[iNode]; + if (control.nodeType !== 1 /* document.ELEMENT_NODE */) { + continue; + } + var sClass = control.getAttribute("class"); + if (!sClass) continue; + var aClasses = sClass.split(" "); + for (var iClass = 0; iClass < aClasses.length; iClass++) { + var parms; + sClass = aClasses[iClass]; + switch (sClass) { + case sAppClass + "-binding": + parms = Component.getComponentParms(control); + if (parms && parms['binding']) { + component.setBinding(parms['type'], parms['binding'], control, parms['value']); + } else if (!parms || parms['type'] != "description") { + Component.log("Component '" + component.toString() + "' missing binding" + (parms? " for " + parms['type'] : ""), "warning"); + } + iClass = aClasses.length; + break; + default: + // if (DEBUG) Component.log("Component.bindComponentControls(" + component.toString() + "): unrecognized control class \"" + sClass + "\"", "warning"); + break; + } + } + } } } - if (!ae.length) { - Component.log('No elements of class "' + sClass + '" found'); - } - return ae; -}; -Component.prototype = { - constructor: Component, - parent: null, + /** + * Component.getElementsByClass(element, sClass, sObjClass) + * + * This is a cross-browser helper function, since not all browser's support getElementsByClassName() + * + * TODO: This should probably be moved into weblib.js at some point, along with the control binding functions above, + * to keep all the browser-related code together. + * + * @param {Object} element from the DOM + * @param {string} sClass + * @param {string} [sObjClass] + * @return {Array|NodeList} + */ + static getElementsByClass(element, sClass, sObjClass) + { + if (sObjClass) sClass += '-' + sObjClass + "-object"; + /* + * Use the browser's built-in getElementsByClassName() if it appears to be available + * (for example, it's not available in IE8, but it should be available in IE9 and up) + */ + if (element.getElementsByClassName) { + return element.getElementsByClassName(sClass); + } + var i, j, ae = []; + var aeAll = element.getElementsByTagName("*"); + var re = new RegExp('(^| )' + sClass + '( |$)'); + for (i = 0, j = aeAll.length; i < j; i++) { + if (re.test(aeAll[i].className)) { + ae.push(aeAll[i]); + } + } + if (!ae.length) { + Component.log('No elements of class "' + sClass + '" found'); + } + return ae; + } + /** * toString() * * @this {Component} * @return {string} */ - toString: function() { + toString() { return (this.name? this.name : (this.id || this.type)); - }, + } + /** * getMachineNum() * * @this {Component} * @return {number} unique machine number */ - getMachineNum: function() { + getMachineNum() { var nMachine = 1; if (this.idMachine) { var aDigits = this.idMachine.match(/\d+/); @@ -655,7 +642,8 @@ Component.prototype = { nMachine = parseInt(aDigits[0], 10); } return nMachine; - }, + } + /** * setBinding(sHTMLType, sBinding, control, sValue) * @@ -668,7 +656,7 @@ Component.prototype = { * @param {string} [sValue] optional data value * @return {boolean} true if binding was successful, false if unrecognized binding request */ - setBinding: function(sHTMLType, sBinding, control, sValue) { + setBinding(sHTMLType, sBinding, control, sValue) { switch (sBinding) { case "clear": if (!this.bindings[sBinding]) { @@ -711,7 +699,7 @@ Component.prototype = { }; }(control)); /** - * Override this.notice() with a replacement function that eliminates the web.alertUser() call + * Override this.notice() with a replacement function that eliminates the Component.alertUser() call * * @this {Component} * @param {string} s @@ -726,7 +714,8 @@ Component.prototype = { default: return false; } - }, + } + /** * log(s, type) * @@ -740,11 +729,12 @@ Component.prototype = { * @param {string} [s] is the message text * @param {string} [type] is the message type */ - log: function(s, type) { + log(s, type) { if (!COMPILED) { Component.log(s, type || this.id || this.type); } - }, + } + /** * assert(f, s) * @@ -760,7 +750,7 @@ Component.prototype = { * @param {boolean|number} f is the expression asserted to be true * @param {string} [s] is a description of the assertion to be displayed or logged on failure */ - assert: function(f, s) { + assert(f, s) { if (DEBUG) { if (!f) { s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : ""); @@ -792,9 +782,10 @@ Component.prototype = { throw new Error(s); } } - }, + } + /** - * println(s, type, id) + * println(s, type) * * For non-diagnostic messages, which components may override to control the destination/appearance of their output. * @@ -806,9 +797,10 @@ Component.prototype = { * @param {string} [type] is the message type * @param {string} [id] is the caller's ID, if any */ - println: function(s, type, id) { + println(s, type, id) { Component.println(s, type, id || this.id); - }, + } + /** * status(s) * @@ -817,9 +809,10 @@ Component.prototype = { * * @param {string} s is the message text */ - status: function(s) { + status(s) { this.println(this.idComponent + ": " + s); - }, + } + /** * notice(s, fPrintOnly) * @@ -832,9 +825,10 @@ Component.prototype = { * @param {boolean} [fPrintOnly] * @param {string} [id] is the caller's ID, if any */ - notice: function(s, fPrintOnly, id) { + notice(s, fPrintOnly, id) { Component.notice(s, fPrintOnly, id || this.type); - }, + } + /** * setError(s) * @@ -843,10 +837,11 @@ Component.prototype = { * @this {Component} * @param {string} s describes a fatal error condition */ - setError: function(s) { + setError(s) { this.flags.error = true; this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "? - }, + } + /** * clearError() * @@ -854,9 +849,10 @@ Component.prototype = { * * @this {Component} */ - clearError: function() { + clearError() { this.flags.error = false; - }, + } + /** * isError() * @@ -865,13 +861,14 @@ Component.prototype = { * @this {Component} * @return {boolean} true if a fatal error condition exists, false if not */ - isError: function() { + isError() { if (this.flags.error) { this.println(this.toString() + " error"); return true; } return false; - }, + } + /** * isReady(fnReady) * @@ -885,7 +882,7 @@ Component.prototype = { * @param {function()} [fnReady] * @return {boolean} true if the component is in a "ready" state, false if not */ - isReady: function(fnReady) { + isReady(fnReady) { if (fnReady) { if (this.flags.ready) { fnReady(); @@ -895,7 +892,8 @@ Component.prototype = { } } return this.flags.ready; - }, + } + /** * setReady(fReady) * @@ -904,7 +902,7 @@ Component.prototype = { * @this {Component} * @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false */ - setReady: function(fReady) { + setReady(fReady) { if (!this.flags.error) { this.flags.ready = (fReady !== false); if (this.flags.ready) { @@ -914,7 +912,8 @@ Component.prototype = { if (fnReady) fnReady(); } } - }, + } + /** * isBusy(fCancel) * @@ -924,7 +923,7 @@ Component.prototype = { * @param {boolean} [fCancel] is set to true to cancel a "busy" state * @return {boolean} true if "busy", false if not */ - isBusy: function(fCancel) { + isBusy(fCancel) { if (this.flags.busy) { if (fCancel) { this.flags.busyCancel = true; @@ -933,7 +932,8 @@ Component.prototype = { } } return this.flags.busy; - }, + } + /** * setBusy(fBusy) * @@ -943,7 +943,7 @@ Component.prototype = { * @param {boolean} fBusy * @return {boolean} */ - setBusy: function(fBusy) { + setBusy(fBusy) { if (this.flags.busyCancel) { this.flags.busy = false; this.flags.busyCancel = false; @@ -955,7 +955,8 @@ Component.prototype = { } this.flags.busy = fBusy; return this.flags.busy; - }, + } + /** * powerUp(fSave) * @@ -964,10 +965,11 @@ Component.prototype = { * @param {boolean} [fRepower] is true if this is "repower" notification * @return {boolean} true if successful, false if failure */ - powerUp: function(data, fRepower) { + powerUp(data, fRepower) { this.flags.powered = true; return true; - }, + } + /** * powerDown(fSave, fShutdown) * @@ -976,10 +978,11 @@ Component.prototype = { * @param {boolean} [fShutdown] * @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure */ - powerDown: function(fSave, fShutdown) { + powerDown(fSave, fShutdown) { if (fShutdown) this.flags.powered = false; return true; - }, + } + /** * messageEnabled(bitsMessage) * @@ -989,7 +992,7 @@ Component.prototype = { * @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s) * @return {boolean} true if all specified message enabled, false if not */ - messageEnabled: function(bitsMessage) { + messageEnabled(bitsMessage) { if (DEBUGGER && this.dbg) { if (this === this.dbg) { bitsMessage |= 0; @@ -1000,7 +1003,8 @@ Component.prototype = { return (!!bitsMessage && bitsEnabled === bitsMessage || !!(bitsEnabled & this.dbg.bitsWarning)); } return false; - }, + } + /** * printMessage(sMessage, bitsMessage, fAddress) * @@ -1012,13 +1016,14 @@ Component.prototype = { * @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s) * @param {boolean} [fAddress] is true to display the current address */ - printMessage: function(sMessage, bitsMessage, fAddress) { + printMessage(sMessage, bitsMessage, fAddress) { if (DEBUGGER && this.dbg) { if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) { this.dbg.message(sMessage, fAddress); } } - }, + } + /** * printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) * @@ -1033,7 +1038,7 @@ Component.prototype = { * @param {number|null} [bIn] is the input value, if known, on an input operation * @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s) */ - printMessageIO: function(port, bOut, addrFrom, name, bIn, bitsMessage) { + printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) { if (DEBUGGER && this.dbg) { if (bitsMessage === true) { bitsMessage = 0; @@ -1043,7 +1048,27 @@ Component.prototype = { this.dbg.messageIO(this, port, bOut, addrFrom, name, bIn, bitsMessage); } } -}; +} + +/* + * 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()) + * or by type (see Component.getComponentByType()). + * + * Every machine on the page are now recorded as well, by their machine ID. We then record the + * various resources used by that machine. + * + * Includes a fallback for non-browser-based environments (ie, Node). TODO: This will need to be + * tailored to Node, probably using the global object instead of the window object, if we ever want + * to support multi-machine configs in that environment. + */ +if (window) { + if (!window['PCjs']) window['PCjs'] = {}; + if (!window['PCjs']['Machines']) window['PCjs']['Machines'] = {}; + if (!window['PCjs']['Components']) window['PCjs']['Components'] = []; +} +Component.machines = window? window['PCjs']['Machines'] : {}; +Component.components = window? window['PCjs']['Components'] : []; /* * The following polyfills provide ES5 functionality that's missing in older browsers (eg, IE8), @@ -1061,10 +1086,10 @@ Component.prototype = { */ if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(obj, start) { - for (var i = (start || 0), j = this.length; i < j; i++) { - if (this[i] === obj) { return i; } - } - return -1; + for (var i = (start || 0), j = this.length; i < j; i++) { + if (this[i] === obj) { return i; } + } + return -1; } } diff --git a/modules/shared/lib/debugger.js b/modules/shared/lib/debugger.js index cb8391baf..1d2d015bb 100644 --- a/modules/shared/lib/debugger.js +++ b/modules/shared/lib/debugger.js @@ -28,11 +28,9 @@ "use strict"; -if (DEBUGGER) { - if (NODE) { - var str = require("../../shared/lib/strlib"); - var Component = require("../../shared/lib/component"); - } +if (NODE) { + var Str = require("../../shared/lib/strlib"); + var Component = require("../../shared/lib/component"); } /** @@ -50,105 +48,102 @@ if (DEBUGGER) { * fTemporary:(boolean|undefined), * sCmd:(string|undefined), * aCmds:(Array.|undefined) - * }} DbgAddr + * }} */ var DbgAddr; /** - * Debugger(parmsDbg) + * Since the Closure Compiler treats ES6 classes as @struct rather than @dict by default, + * it deters us from defining named properties on our components; eg: * - * The Debugger component supports the following optional (parmsDbg) properties: + * this['exports'] = {...} * - * base: the base to use for most numeric input/output (default is 16) + * results in an error: * - * The Debugger component is a shared component containing a subset of functionality used by - * the other CPU-specific Debuggers (eg, DebuggerX86). Over time, the goal is to factor out as - * much common debugging support as possible from those components into this one. + * Cannot do '[]' access on a struct * - * @constructor - * @extends Component - * @param {Object} parmsDbg + * So, in order to define 'exports', we must override the @struct assumption by annotating + * the class as @unrestricted (or @dict). Note that this must be done both here and in the + * subclass (eg, SerialPort), because otherwise the Compiler won't allow us to *reference* + * the named property either. + * + * TODO: Consider marking ALL our classes unrestricted, because otherwise it forces us to + * define every single property the class uses in its constructor, which results in a fair + * bit of redundant initialization, since many properties aren't (and don't need to be) fully + * initialized until the appropriate init(), reset(), restore(), etc. function is called. + * + * The upside, however, may be that since the structure of the class is completely defined by + * the constructor, JavaScript engines may be able to optimize and run more efficiently. + * + * @unrestricted */ -function Debugger(parmsDbg) -{ - if (DEBUGGER) { +class Debugger extends Component { + /** + * Debugger(parmsDbg) + * + * The Debugger component supports the following optional (parmsDbg) properties: + * + * base: the base to use for most numeric input/output (default is 16) + * + * The Debugger component is a shared component containing a subset of functionality used by + * the other CPU-specific Debuggers (eg, DebuggerX86). Over time, the goal is to factor out as + * much common debugging support as possible from those components into this one. + * + * @param {Object} parmsDbg + */ + constructor(parmsDbg) { + if (DEBUGGER) { - Component.call(this, "Debugger", parmsDbg, Debugger); + super("Debugger", parmsDbg); - /* - * Default base used to display all values; modified with the "s base" command. - */ - this.nBase = parmsDbg['base'] || 16; - this.fParens = false; + /* + * Default base used to display all values; modified with the "s base" command. + */ + this.nBase = +parmsDbg['base'] || 16; + this.fParens = false; - /* - * These keep track of instruction activity, but only when tracing or when Debugger checks - * have been enabled (eg, one or more breakpoints have been set). - * - * They are zeroed by the reset() notification handler. cInstructions is advanced by - * stepCPU() and checkInstruction() calls. nCycles is updated by every stepCPU() or stop() - * call and simply represents the number of cycles performed by the last run of instructions. - */ - this.nCycles = 0; - this.cOpcodes = this.cOpcodesStart = 0; + /* + * These keep track of instruction activity, but only when tracing or when Debugger checks + * have been enabled (eg, one or more breakpoints have been set). + * + * They are zeroed by the reset() notification handler. cInstructions is advanced by + * stepCPU() and checkInstruction() calls. nCycles is updated by every stepCPU() or stop() + * call and simply represents the number of cycles performed by the last run of instructions. + */ + this.nCycles = 0; + this.cOpcodes = this.cOpcodesStart = 0; - /* - * fAssemble is true when "assemble mode" is active, false when not. - */ - this.fAssemble = false; + /* + * fAssemble is true when "assemble mode" is active, false when not. + */ + this.fAssemble = false; - /* - * This maintains command history. New commands are inserted at index 0 of the array. - * When Enter is pressed on an empty input buffer, we default to the command at aPrevCmds[0]. - */ - this.iPrevCmd = -1; - this.aPrevCmds = []; + /* + * This maintains command history. New commands are inserted at index 0 of the array. + * When Enter is pressed on an empty input buffer, we default to the command at aPrevCmds[0]. + */ + this.iPrevCmd = -1; + this.aPrevCmds = []; - /* - * aVariables is an object with properties that grow as setVariable() assigns more variables; - * each property corresponds to one variable, where the property name is the variable name (ie, - * a string beginning with a letter or underscore, followed by zero or more additional letters, - * digits, or underscores) and the property value is the variable's numeric value. See doVar() - * and setVariable() for details. - * - * Note that parseValue() parses variables before numbers, so any variable that looks like a - * unprefixed hex value (eg, "a5" as opposed to "0xa5") will trump the numeric value. Unprefixed - * hex values are a convenience of parseValue(), which always calls str.parseInt() with a default - * base of 16; however, that default be overridden with a variety of explicit prefixes or suffixes - * (eg, a leading "0o" to indicate octal, a trailing period to indicate decimal, etc.) - * - * See str.parseInt() for more details about supported numbers. - */ - this.aVariables = {}; + /* + * aVariables is an object with properties that grow as setVariable() assigns more variables; + * each property corresponds to one variable, where the property name is the variable name (ie, + * a string beginning with a letter or underscore, followed by zero or more additional letters, + * digits, or underscores) and the property value is the variable's numeric value. See doVar() + * and setVariable() for details. + * + * Note that parseValue() parses variables before numbers, so any variable that looks like a + * unprefixed hex value (eg, "a5" as opposed to "0xa5") will trump the numeric value. Unprefixed + * hex values are a convenience of parseValue(), which always calls Str.parseInt() with a default + * base of 16; however, that default be overridden with a variety of explicit prefixes or suffixes + * (eg, a leading "0o" to indicate octal, a trailing period to indicate decimal, etc.) + * + * See Str.parseInt() for more details about supported numbers. + */ + this.aVariables = {}; - } // endif DEBUGGER -} - -if (DEBUGGER) { - - Component.subclass(Debugger); - - Debugger.aBinOpPrecedence = { - '||': 0, // logical OR - '&&': 1, // logical AND - '|': 2, // bitwise OR - '^': 3, // bitwise XOR - '&': 4, // bitwise AND - '!=': 5, // inequality - '==': 5, // equality - '>=': 6, // greater than or equal to - '>': 6, // greater than - '<=': 6, // less than or equal to - '<': 6, // less than - '>>>': 7, // unsigned bitwise right shift - '>>': 7, // bitwise right shift - '<<': 7, // bitwise left shift - '-': 8, // subtraction - '+': 8, // addition - '%': 9, // remainder - '/': 9, // division - '*': 9 // multiplication - }; + } // endif DEBUGGER + } /** * getRegIndex(sReg, off) @@ -160,10 +155,9 @@ if (DEBUGGER) { * @param {number} [off] optional offset into sReg * @return {number} register index, or -1 if not found */ - Debugger.prototype.getRegIndex = function(sReg, off) - { + getRegIndex(sReg, off) { return -1; - }; + } /** * getRegValue(iReg) @@ -174,10 +168,9 @@ if (DEBUGGER) { * @param {number} iReg * @return {number|undefined} */ - Debugger.prototype.getRegValue = function(iReg) - { + getRegValue(iReg) { return undefined; - }; + } /** * parseAddrReference(s, sAddr) @@ -191,10 +184,9 @@ if (DEBUGGER) { * @param {string} sAddr * @return {string} */ - Debugger.prototype.parseAddrReference = function(s, sAddr) - { + parseAddrReference(s, sAddr) { return s.replace('[' + sAddr + ']', "unimplemented"); - }; + } /** * getNextCommand() @@ -202,8 +194,7 @@ if (DEBUGGER) { * @this {Debugger} * @return {string} */ - Debugger.prototype.getNextCommand = function() - { + getNextCommand() { var sCmd; if (this.iPrevCmd > 0) { sCmd = this.aPrevCmds[--this.iPrevCmd]; @@ -212,7 +203,7 @@ if (DEBUGGER) { this.iPrevCmd = -1; } return sCmd; - }; + } /** * getPrevCommand() @@ -220,14 +211,13 @@ if (DEBUGGER) { * @this {Debugger} * @return {string|null} */ - Debugger.prototype.getPrevCommand = function() - { + getPrevCommand() { var sCmd = null; if (this.iPrevCmd < this.aPrevCmds.length - 1) { sCmd = this.aPrevCmds[++this.iPrevCmd]; } return sCmd; - }; + } /** * parseCommand(sCmd, fSave, chSep) @@ -238,8 +228,7 @@ if (DEBUGGER) { * @param {string} [chSep] is the command separator character (default is ';') * @return {Array.} */ - Debugger.prototype.parseCommand = function(sCmd, fSave, chSep) - { + parseCommand(sCmd, fSave, chSep) { if (fSave) { if (!sCmd) { if (this.fAssemble) { @@ -265,7 +254,7 @@ if (DEBUGGER) { * associated with a breakpoint), we can no longer perform simplistic splitting. * * a = sCmd.split(chSep || ';'); - * for (var i = 0; i < a.length; i++) a[i] = str.trim(a[i]); + * for (var i = 0; i < a.length; i++) a[i] = Str.trim(a[i]); * * We may now split on semi-colons ONLY if they are outside a quoted sequence. * @@ -298,13 +287,13 @@ if (DEBUGGER) { * Recall that substring() accepts starting (inclusive) and ending (exclusive) * indexes, whereas substr() accepts a starting index and a length. We need the former. */ - a.push(str.trim(sCmd.substring(iPrev, i))); + a.push(Str.trim(sCmd.substring(iPrev, i))); iPrev = i + 1; } } } return a; - }; + } /** * evalExpression(aVals, aOps, cOps) @@ -327,8 +316,7 @@ if (DEBUGGER) { * @param {number} [cOps] (default is all) * @return {boolean} true if successful, false if error */ - Debugger.prototype.evalExpression = function(aVals, aOps, cOps) - { + evalExpression(aVals, aOps, cOps) { cOps = cOps || -1; while (cOps-- && aOps.length) { var chOp = aOps.pop(); @@ -402,7 +390,7 @@ if (DEBUGGER) { aVals.push(valNew|0); } return true; - }; + } /** * parseExpression(sExp, fPrint) @@ -440,8 +428,7 @@ if (DEBUGGER) { * @param {boolean} [fPrint] is true to print all resolved values, false for quiet parsing * @return {number|undefined} numeric value, or undefined if sExp contains any undefined or invalid values */ - Debugger.prototype.parseExpression = function(sExp, fPrint) - { + parseExpression(sExp, fPrint) { var value; if (sExp) { @@ -468,7 +455,7 @@ if (DEBUGGER) { while (i < asValues.length) { var sValue = asValues[i++]; var cchValue = sValue.length; - var s = str.trim(sValue); + var s = Str.trim(sValue); if (!s) { fError = true; break; @@ -500,7 +487,7 @@ if (DEBUGGER) { } } return value; - }; + } /** * parseReference(s) @@ -514,8 +501,7 @@ if (DEBUGGER) { * @param {string} s * @return {string} */ - Debugger.prototype.parseReference = function(s) - { + parseReference(s) { var a; var chOpen = this.fParens? '(' : '{'; var chClose = this.fParens? ')' : '}'; @@ -530,7 +516,7 @@ if (DEBUGGER) { s = this.parseAddrReference(s, a[1]); } return this.parseSysVars(s); - }; + } /** * parseSysVars(s) @@ -543,8 +529,7 @@ if (DEBUGGER) { * @param {string} s * @return {string} */ - Debugger.prototype.parseSysVars = function(s) - { + parseSysVars(s) { var a; while (a = s.match(/\$([a-z]+)/i)) { var v = null; @@ -557,7 +542,7 @@ if (DEBUGGER) { s = s.replace(a[0], v.toString()); } return s; - }; + } /** * parseValue(sValue, sName, fQuiet) @@ -568,8 +553,7 @@ if (DEBUGGER) { * @param {boolean} [fQuiet] * @return {number|undefined} numeric value, or undefined if sValue is either undefined or invalid */ - Debugger.prototype.parseValue = function(sValue, sName, fQuiet) - { + parseValue(sValue, sName, fQuiet) { var value; if (sValue != null) { var iReg = this.getRegIndex(sValue); @@ -578,7 +562,7 @@ if (DEBUGGER) { } else { value = this.getVariable(sValue); if (value == null) { - value = str.parseInt(sValue, this.nBase); + value = Str.parseInt(sValue, this.nBase); } } if (value == null && !fQuiet) this.println("invalid " + (sName? sName : "value") + ": " + sValue); @@ -586,7 +570,7 @@ if (DEBUGGER) { if (!fQuiet) this.println("missing " + (sName || "value")); } return value; - }; + } /** * printValue(sVar, value) @@ -596,13 +580,12 @@ if (DEBUGGER) { * @param {number|undefined} value * @return {boolean} true if value defined, false if not */ - Debugger.prototype.printValue = function(sVar, value) - { + printValue(sVar, value) { var sValue; var fDefined = false; if (value !== undefined) { fDefined = true; - sValue = str.toHex(value, 0, true) + " " + value + ". " + str.toOct(value, 0, true) + " " + str.toBinBytes(value, 4, true); + sValue = Str.toHex(value, 0, true) + " " + value + ". " + Str.toOct(value, 0, true) + " " + Str.toBinBytes(value, 4, true); if (value >= 0x20 && value < 0x7F) { sValue += " '" + String.fromCharCode(value) + "'"; } @@ -610,7 +593,7 @@ if (DEBUGGER) { sVar = (sVar != null? (sVar + ": ") : ""); this.println(sVar + sValue); return fDefined; - }; + } /** * printVariable(sVar) @@ -619,8 +602,7 @@ if (DEBUGGER) { * @param {string} [sVar] * @return {boolean} true if all value(s) defined, false if not */ - Debugger.prototype.printVariable = function(sVar) - { + printVariable(sVar) { if (sVar) { return this.printValue(sVar, this.aVariables[sVar]); } @@ -630,7 +612,7 @@ if (DEBUGGER) { cVariables++; } return cVariables > 0; - }; + } /** * delVariable(sVar) @@ -638,10 +620,9 @@ if (DEBUGGER) { * @this {Debugger} * @param {string} sVar */ - Debugger.prototype.delVariable = function(sVar) - { + delVariable(sVar) { delete this.aVariables[sVar]; - }; + } /** * getVariable(sVar) @@ -650,10 +631,9 @@ if (DEBUGGER) { * @param {string} sVar * @return {number|undefined} */ - Debugger.prototype.getVariable = function(sVar) - { + getVariable(sVar) { return this.aVariables[sVar]; - }; + } /** * setVariable(sVar, value) @@ -662,15 +642,14 @@ if (DEBUGGER) { * @param {string} sVar * @param {number} value */ - Debugger.prototype.setVariable = function(sVar, value) - { + setVariable(sVar, value) { this.aVariables[sVar] = value; - }; + } /** * toStrBase(n, nBytes, fStripLeadingZeros) * - * Use this instead of str.toHex() or str.toOct() to convert bytes/words to the Debugger's default base. + * Use this instead of Str.toHex() or Str.toOct() to convert bytes/words to the Debugger's default base. * * @this {Debugger} * @param {number|null|undefined} n @@ -678,22 +657,46 @@ if (DEBUGGER) { * @param {boolean} [fStripLeadingZeros] * @return {string} */ - Debugger.prototype.toStrBase = function(n, nBytes, fStripLeadingZeros) - { + toStrBase(n, nBytes, fStripLeadingZeros) { var s; switch(this.nBase) { case 8: - s = str.toOct(n, nBytes * 3 - (nBytes > 2? 1 : 0)); + s = Str.toOct(n, nBytes * 3 - (nBytes > 2? 1 : 0)); break; case 10: s = n.toString(); break; case 16: default: - s = str.toHex(n, nBytes * 2); + s = Str.toHex(n, nBytes * 2); break; } - return (fStripLeadingZeros? str.stripLeadingZeros(s) : s); + return (fStripLeadingZeros? Str.stripLeadingZeros(s) : s); + } +} + +if (DEBUGGER) { + + Debugger.aBinOpPrecedence = { + '||': 0, // logical OR + '&&': 1, // logical AND + '|': 2, // bitwise OR + '^': 3, // bitwise XOR + '&': 4, // bitwise AND + '!=': 5, // inequality + '==': 5, // equality + '>=': 6, // greater than or equal to + '>': 6, // greater than + '<=': 6, // less than or equal to + '<': 6, // less than + '>>>': 7, // unsigned bitwise right shift + '>>': 7, // bitwise right shift + '<<': 7, // bitwise left shift + '-': 8, // subtraction + '+': 8, // addition + '%': 9, // remainder + '/': 9, // division + '*': 9 // multiplication }; } // endif DEBUGGER diff --git a/modules/shared/lib/defines.js b/modules/shared/lib/defines.js index f8b8d6b40..14f56f4a7 100644 --- a/modules/shared/lib/defines.js +++ b/modules/shared/lib/defines.js @@ -32,9 +32,13 @@ * @define {string} */ var APPVERSION = "1.x.x"; // this @define is overridden by the Closure Compiler with the version in package.json + var XMLVERSION = null; // this is set in non-COMPILED builds by embedMachine() if a version number was found in the machine XML + var COPYRIGHT = "Copyright © 2012-2017 Jeff Parsons "; + var LICENSE = "License: GPL version 3 or later "; + var CSSCLASS = "pcjs"; /** diff --git a/modules/shared/lib/diskapi.js b/modules/shared/lib/diskapi.js index 16814946b..f06355871 100644 --- a/modules/shared/lib/diskapi.js +++ b/modules/shared/lib/diskapi.js @@ -69,36 +69,33 @@ var DiskAPI = { }; /* - * Common (supported) disk formats + * Common (supported) diskette formats * - * Each entry in DISK_FORMATS begins with an array of three "CHS" values: + * For no particular reason that I can recall, each entry in DISK_FORMATS is an array of values in "CHS" order: * * [# cylinders, # heads, # sectors/track, # bytes/sector, media type] * - * The 4th value is optional; if omitted, the sector size is assumed to be 512 bytes. The order of these geometric - * values mirrors the structure of our JSON-encoded disk images, which consist of an array of cylinders, each of which - * is an array of heads, each of which is an array of sector objects. - * - * The 5th value is also optional and is used only with PC-DOS diskettes, to help us verify that the logical format - * matches the physical format; it should be one of the values in DiskAPI.FAT. TODO: Actually use the DiskAPI.FAT values. + * If the 4th value is omitted, the sector size is assumed to be 512. The order of these "geometric" values mirrors + * the structure of our JSON-encoded disk images, which consist of an array of cylinders, each of which is an array of + * heads, each of which is an array of sector objects. */ DiskAPI.DISK_FORMATS = { - 163840: [ 40,1, 8,,0xFE], // media type 0xFE: 40 cylinders, 1 head (single-sided), 8 sectors/track, ( 320 total sectors x 512 bytes/sector == 163840) - 184320: [ 40,1, 9,,0xFC], // media type 0xFC: 40 cylinders, 1 head (single-sided), 9 sectors/track, ( 360 total sectors x 512 bytes/sector == 184320) - 327680: [ 40,2, 8,,0xFF], // media type 0xFF: 40 cylinders, 2 heads (double-sided), 8 sectors/track, ( 640 total sectors x 512 bytes/sector == 327680) - 368640: [ 40,2, 9,,0xFD], // media type 0xFD: 40 cylinders, 2 heads (double-sided), 9 sectors/track, ( 720 total sectors x 512 bytes/sector == 368640) - 737280: [ 80,2, 9,,0xF9], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 9 sectors/track, (1440 total sectors x 512 bytes/sector == 737280) - 1228800: [ 80,2,15,,0xF9], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 15 sectors/track, (2400 total sectors x 512 bytes/sector == 1228800) - 1474560: [ 80,2,18,,0xF0], // media type 0xF0: 80 cylinders, 2 heads (double-sided), 18 sectors/track, (2880 total sectors x 512 bytes/sector == 1474560) - 2949120: [ 80,2,36,,0xF0], // media type 0xF0: 80 cylinders, 2 heads (double-sided), 36 sectors/track, (5760 total sectors x 512 bytes/sector == 2949120) + 163840: [40,1,8,,0xFE], // media type 0xFE: 40 cylinders, 1 head (single-sided), 8 sectors/track, ( 320 total sectors x 512 bytes/sector == 163840) + 184320: [40,1,9,,0xFC], // media type 0xFC: 40 cylinders, 1 head (single-sided), 9 sectors/track, ( 360 total sectors x 512 bytes/sector == 184320) + 327680: [40,2,8,,0xFF], // media type 0xFF: 40 cylinders, 2 heads (double-sided), 8 sectors/track, ( 640 total sectors x 512 bytes/sector == 327680) + 368640: [40,2,9,,0xFD], // media type 0xFD: 40 cylinders, 2 heads (double-sided), 9 sectors/track, ( 720 total sectors x 512 bytes/sector == 368640) + 737280: [80,2,9,,0xF9], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 9 sectors/track, (1440 total sectors x 512 bytes/sector == 737280) + 1228800: [80,2,15,,0xF9], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 15 sectors/track, (2400 total sectors x 512 bytes/sector == 1228800) + 1474560: [80,2,18,,0xF0], // media type 0xF0: 80 cylinders, 2 heads (double-sided), 18 sectors/track, (2880 total sectors x 512 bytes/sector == 1474560) + 2949120: [80,2,36,,0xF0], // media type 0xF0: 80 cylinders, 2 heads (double-sided), 36 sectors/track, (5760 total sectors x 512 bytes/sector == 2949120) /* - * The following are common early hard drive sizes, which we explicitly map to CHS values, since the BPB can mislead us when attempting to calculate total cylinders. + * The following are common early hard drive sizes, which we explicitly map to CHS values, since the BPB can mislead us when attempting to calculate total cylinders */ 21368320:[615,4,17], // PC AT 20Mb hard drive (type 2) /* * Assorted DEC disk pack formats. */ - 2494464: [203,2,12,512], // RK03 single-platter disk cartridge: 203 tracks, 2 heads, 12 sectors/track, 512 bytes/sector, for a total of 2494464 bytes + 2494464: [203,2,12,512], // RK03 single-platter disk cartridge: 203 tracks, 2 heads, 12 sectors/track, 512 bytes/sector, for a total of 2494464 bytes 5242880: [256,2,40,256], // RL01K single-platter disk cartridge: 256 tracks, 2 heads, 40 sectors/track, 256 bytes/sector, for a total of 5242880 bytes 10485760:[512,2,40,256] // RL02K single-platter disk cartridge: 512 tracks, 2 heads, 40 sectors/track, 256 bytes/sector, for a total of 10485760 bytes }; diff --git a/modules/shared/lib/embed.js b/modules/shared/lib/embed.js index 03f7fcb02..4f3493c05 100644 --- a/modules/shared/lib/embed.js +++ b/modules/shared/lib/embed.js @@ -28,12 +28,10 @@ "use strict"; -/* global document: true, window: true, XSLTProcessor: false, APPNAME: false, APPVERSION: false, XMLVERSION: true, DEBUG: true */ - if (NODE) { - var Component = require("./component"); - var str = require("./strlib"); - var web = require("./weblib"); + var Str = require("../../shared/lib/strlib"); + var Web = require("../../shared/lib/weblib"); + var Component = require("../../shared/lib/component"); } /* @@ -45,8 +43,8 @@ if (NODE) { * machine component init() handlers. * * Also, to prevent those init() handlers from running prematurely, we must disable all page - * notification events at the start of the embedding process (web.enablePageEvents(false)) and - * re-enable them at the end (web.enablePageEvents(true)). + * notification events at the start of the embedding process (Web.enablePageEvents(false)) and + * re-enable them at the end (Web.enablePageEvents(true)). */ var fAsync = true; var cAsyncMachines = 0; @@ -95,7 +93,7 @@ function loadXML(sXMLFile, idMachine, sAppName, sAppClass, sParms, fResolve, dis parseXML(sXML, sXMLFile, idMachine, sAppName, sAppClass, sParms, fResolve, display, done); }; display("Loading " + sXMLFile + "..."); - web.getResource(sXMLFile, null, fAsync, doneLoadXML); + Web.getResource(sXMLFile, null, fAsync, doneLoadXML); } /** @@ -171,9 +169,11 @@ function parseXML(sXML, sXMLFile, idMachine, sAppName, sAppClass, sParms, fResol /* * Non-COMPILED kludge to replace the version number template in the XSL file (which we assume we're reading, * since fResolve is false) with whatever XMLVERSION we extracted from the XML file (see corresponding kludge below). + * + * ES6 ALERT: Template strings. */ if (!COMPILED && XMLVERSION) { - sXML = sXML.replace(/1.x.x<\/xsl:variable>/, '' + XMLVERSION + ''); + sXML = sXML.replace(/1.x.x<\/xsl:variable>/, `${XMLVERSION}`); } } @@ -188,7 +188,7 @@ function parseXML(sXML, sXMLFile, idMachine, sAppName, sAppClass, sParms, fResol * Supposedly, the IE XML DOM parser will throw an exception, but I haven't tested that, and unless all other * browsers do that, that's not helpful. * - * The best I can do at this stage (assuming web.getResource() didn't drop any error information on the floor) + * The best I can do at this stage (assuming Web.getResource() didn't drop any error information on the floor) * is verify that the requested resource "looks like" valid XML (in other words, it begins with a '<'). */ var xmlDoc = null; @@ -320,7 +320,7 @@ function resolveXML(sXML, display, done) }; display("Loading " + sRefFile + "..."); - web.getResource(sRefFile, null, fAsync, doneReadXML); + Web.getResource(sRefFile, null, fAsync, doneReadXML); return; } done(sXML, null); @@ -350,7 +350,7 @@ function embedMachine(sAppName, sAppClass, sVersion, idMachine, sXMLFile, sXSLFi var doneMachine = function() { Component.assert(cAsyncMachines > 0); if (!--cAsyncMachines) { - if (fAsync) web.enablePageEvents(true); + if (fAsync) Web.enablePageEvents(true); } }; @@ -378,7 +378,7 @@ function embedMachine(sAppName, sAppClass, sVersion, idMachine, sXMLFile, sXSLFi var aeWarning = (eMachine && Component.getElementsByClass(eMachine, "machine-warning")); eWarning = (aeWarning && aeWarning[0]) || eMachine; } - if (eWarning) eWarning.innerHTML = str.escapeHTML(sMessage); + if (eWarning) eWarning.innerHTML = Str.escapeHTML(sMessage); }; try { @@ -545,7 +545,7 @@ function embedMachine(sAppName, sAppClass, sVersion, idMachine, sXMLFile, sXSLFi */ function embedC1P(idMachine, sXMLFile, sXSLFile) { - if (fAsync) web.enablePageEvents(false); + if (fAsync) Web.enablePageEvents(false); return embedMachine("C1Pjs", "c1pjs", APPVERSION, idMachine, sXMLFile, sXSLFile); } @@ -560,7 +560,7 @@ function embedC1P(idMachine, sXMLFile, sXSLFile) */ function embedPCx86(idMachine, sXMLFile, sXSLFile, sParms) { - if (fAsync) web.enablePageEvents(false); + if (fAsync) Web.enablePageEvents(false); return embedMachine("PCx86", "pcx86", APPVERSION, idMachine, sXMLFile, sXSLFile, sParms); } @@ -575,7 +575,7 @@ function embedPCx86(idMachine, sXMLFile, sXSLFile, sParms) */ function embedPC8080(idMachine, sXMLFile, sXSLFile, sParms) { - if (fAsync) web.enablePageEvents(false); + if (fAsync) Web.enablePageEvents(false); return embedMachine("PC8080", "pc8080", APPVERSION, idMachine, sXMLFile, sXSLFile, sParms); } @@ -590,10 +590,22 @@ function embedPC8080(idMachine, sXMLFile, sXSLFile, sParms) */ function embedPDP11(idMachine, sXMLFile, sXSLFile, sParms) { - if (fAsync) web.enablePageEvents(false); + if (fAsync) Web.enablePageEvents(false); return embedMachine("PDPjs", "pdp11", APPVERSION, idMachine, sXMLFile, sXSLFile, sParms); } +/** + * findMachineComponent(idMachine, sType) + * + * @param {string} idMachine + * @param {string} sType + * @return {Component|null} + */ +function findMachineComponent(idMachine, sType) +{ + return Component.getComponentByType(sType, idMachine + ".machine"); +} + /** * Prevent the Closure Compiler from renaming functions we want to export, by adding them as global properties. */ @@ -611,5 +623,7 @@ if (APPNAME == "PDPjs") { window['embedPDP11'] = embedPDP11; } -window['enableEvents'] = web.enablePageEvents; -window['sendEvent'] = web.sendPageEvent; +window['findMachineComponent'] = findMachineComponent; + +window['enableEvents'] = Web.enablePageEvents; +window['sendEvent'] = Web.sendPageEvent; diff --git a/modules/shared/lib/keys.js b/modules/shared/lib/keys.js index e9e78cc81..67670a1a4 100644 --- a/modules/shared/lib/keys.js +++ b/modules/shared/lib/keys.js @@ -32,7 +32,7 @@ var Keys = { /* * Keys and/or key combinations that generate common ASCII codes. * - * NOTE: If you're looking for a general-purpose ASCII code table, see str.ASCII in strlib.js; + * NOTE: If you're looking for a general-purpose ASCII code table, see Str.ASCII in strlib.js; * if something's missing, that's probably the more appropriate table to add it to. * * TODO: The Closure Compiler doesn't inline all references to these values, at least those with @@ -201,6 +201,7 @@ var Keys = { */ Keys.KEYCODE.NUM_CR = Keys.KEYCODE.CR + Keys.KEYCODE.ONRIGHT; + /* * Maps Firefox keyCodes to their more common keyCode counterparts; a number of entries in this table * are no longer valid (if indeed they ever were), so they've been commented out. It's likely that I diff --git a/modules/shared/lib/netlib.js b/modules/shared/lib/netlib.js index f0b3ededa..3ef0478fc 100644 --- a/modules/shared/lib/netlib.js +++ b/modules/shared/lib/netlib.js @@ -28,18 +28,345 @@ "use strict"; -/* global Buffer: false */ - -var net = {}; - if (NODE) { - var sServerRoot; var fs = require("fs"); var http = require("http"); var path = require("path"); var url = require("url"); } +class Net { + /** + * hasParm(sParm, sValue, req) + * + * @param {string} sParm + * @param {string|null} sValue (pass null to check for the presence of ANY sParm) + * @param {Object} [req] is the web server's (ie, Express) request object, if any + * @return {boolean} true if the request Object contains the specified parameter/value, false if not + * + * TODO: Consider whether sParm === null should check for the presence of ANY parameter in Net.asPropagate. + */ + static hasParm(sParm, sValue, req) + { + return (req && req.query && req.query[sParm] && (!sValue || req.query[sParm] == sValue)); + } + + /** + * propagateParms(sURL, req) + * + * Propagates any "special" query parameters (as listed in Net.asPropagate) from the given + * request object (req) to the given URL (sURL). + * + * We do not modify an sURL that already contains a '?' OR that begins with a protocol + * (eg, http:, mailto:, etc), in order to keep this function simple, since it's only for + * debugging purposes anyway. I also considered blowing off any URLs with a '#' for the + * same reason, since any hash string must follow any query parameters, but stripping + * and re-appending the hash string is pretty trivial, so we do handle that. + * + * TODO: Make propagateParms() more general-purpose (eg, capable of detecting any URL + * to the same site, and capable of merging any of our "special" query parameters with any + * existing query parameters. + * + * @param {string|null} sURL + * @param {Object} [req] is the web server's (ie, Express) request object, if any + * @return {string} massaged sURL + */ + static propagateParms(sURL, req) + { + if (sURL !== null && sURL.indexOf('?') < 0) { + var i; + var sHash = ""; + if ((i = sURL.indexOf('#')) >= 0) { + sHash = sURL.substr(i); + sURL = sURL.substr(0, i); + } + var match = sURL.match(/^([a-z])+:(.*)/); + if (!match && req && req.query) { + for (i = 0; i < Net.asPropagate.length; i++) { + var sQuery = Net.asPropagate[i]; + var sValue; + if ((sValue = req.query[sQuery])) { + var sParm = (sURL.indexOf('?') < 0 ? '?' : '&'); + sParm += sQuery + '='; + if (sURL.indexOf(sParm) < 0) sURL += sParm + encodeURIComponent(sValue); + } + } + } + sURL += sHash; + } + return sURL; + } + + /** + * encodeURL(sURL, req, fDebug) + * + * Used to encodes any URLs presented on the current page, using this, um, simple 5-step process: + * + * 1) Replace any backslashes with slashes, in case the URL was derived from a file system path + * 2) Remap links that begin with "archive/" to the corresponding URL at "http://archive.pcjs.org/" + * 3) Use decodeURI() to eliminate escape sequences (like "%20") so that encodeURI() won't re-encode the "%" + * 4) Use encodeURI() to transform all "htmlspecialchars" and reserved characters into the appropriate sequences + * 5) Massage the result with Net.propagateParms(), so that any special parameters are passed along + * + * @param {string} sURL + * @param {Object} req is the web server's (ie, Express) request object, if any + * @param {boolean} [fDebug] + * @return {string} encoded URL + */ + static encodeURL(sURL, req, fDebug) + { + if (sURL) { + sURL = sURL.replace(/\\/g, '/'); + if (!fDebug) { + if (sURL.match(/^[^:?]*archive\//)) { + if (sURL.charAt(0) != '/') sURL = path.join(req.path, sURL); + sURL = "http://archive.pcjs.org" + sURL.replace("/archive/", "/"); + } + } + /* + * If the incoming URL already contains URI-style escape sequences (eg, "%20" instead of spaces), + * calling decodeURI() first will eliminate them, preventing encodeURI() from converting leading + * "%" into "%25" and corrupting sequences like "%20" by turning them into "%2520". + */ + return Net.propagateParms(encodeURI(decodeURI(sURL)), req); + } + return sURL; + } + + /** + * isRemote(sPath) + * + * TODO: Add support for FTP? HTTPS? Anything else? + * + * @param {string} sPath + * @return {boolean} true if sPath is a (supported) remote path, false if not + */ + static isRemote(sPath) + { + return (sPath.indexOf("http:") === 0); + } + + /** + * getStat(sURL, done) + * + * @param {string} sURL + * @param {function(Error,Object)} done + */ + static getStat(sURL, done) + { + var options = url.parse(sURL); + options.method = "HEAD"; + options.path = options.pathname; // TODO: Determine the necessity of aliasing this + var req = http.request(options, function(res) + { + var err = null; + var stat = null; + // console.log(JSON.stringify(res.headers)); + if (res.statusCode == 200) { + /* + * Apparently Node lower-cases response headers (at least incoming headers, despite + * lots of amusing whining by certain people in the Node community), which seems like + * a good thing, because that means I can do two simple key look-ups. + */ + var sLength = res.headers['content-length']; + var sModified = res.headers['last-modified']; + stat = { + size: sLength ? parseInt(sLength, 10) : -1, + mtime: sModified ? new Date(sModified) : null, + remote: true // an additional property we provide to indicate this is not your normal stats object + }; + } else { + err = new Error("unexpected response code: " + res.statusCode); + } + done(err, stat); + }); + req.on('error', function(err) + { + done(err, null); + }); + req.end(); + } + + /** + * getFile(sURL, sEncoding, done) + * + * TODO: Add support for FTP? HTTPS? Anything else? + * + * @param {string} sURL is the source file + * @param {string|null} sEncoding is the encoding to assume, if any + * @param {function(Error,number,(string|Buffer))} done receives an Error, an HTTP status code, and a Buffer (if any) + */ + static getFile(sURL, sEncoding, done) + { + /* + * Buffer objects are a fixed size, so my choices are: 1) call getStat() first, hope it returns + * the true size, and then preallocate a buffer; or 2) create a new, larger buffer every time a new + * chunk arrives. The latter seems best. + * + * However, if an encoding is given, we'll simply concatenate all the data into a String and return + * that instead. Note that the incoming data is always a Buffer, but concatenation with a String + * performs an implied "toString()" on the Buffer. + * + * WARNING: Even when an encoding is provided, we don't make any attempt to verify that the incoming + * data matches that encoding. + */ + var sFile = ""; + var bufFile = null; + http.get(sURL, function(res) + { + res.on('data', function(data) + { + if (sEncoding) { + sFile += data; + return; + } + if (!bufFile) { + bufFile = data; + return; + } + /* + * We need to grow bufFile. I used to do this myself, using the "copy" method: + * + * buf.copy(targetBuffer, [targetStart], [sourceStart], [sourceEnd]) + * + * which defaults to 0 for [targetStart] and [sourceStart], but the docs don't clearly + * define the default value for [sourceEnd]. They say "buffer.length", but there is no + * parameter here named "buffer". Let's hope that in the case of "bufFile.copy(buf)" + * they meant "bufFile.length". + * + * However, it turns out this is moot, because there's a new kid in town: Buffer.concat(). + * + * buf = new Buffer(bufFile.length + data.length); + * bufFile.copy(buf); + * data.copy(buf, bufFile.length); + * bufFile = buf; + */ + bufFile = Buffer.concat([bufFile, data], bufFile.length + data.length); + }).on('end', function() + { + /* + * TODO: Decide what to do when res.statusCode is actually an error code (eg, 404), because + * in such cases, the file content will likely just be an HTML error page. + */ + if (res.statusCode < 400) { + done(null, res.statusCode, sEncoding? sFile : bufFile); + } else { + done(new Error(sEncoding? sFile : bufFile), res.statusCode, null); + } + }).on('error', function(err) + { + done(err, res.statusCode, null); + }); + }); + } + + /** + * downloadFile(sURL, sFile, done) + * + * @param {string} sURL is the source file + * @param {string} sFile is a fully-qualified target file + * @param {function(Error,number)} done is a callback that receives an Error and a HTTP status code + */ + static downloadFile(sURL, sFile, done) + { + var file = fs.createWriteStream(sFile); + + /* + * http.get() accepts a "url" string in lieu of an "options" object; it automatically builds + * the latter from the former using url.parse(). This is good, because it relieves me from + * building my own "options" object, and also from wondering why http functions expect "options" + * to contain a "path" property, whereas url.parse() returns a "pathname" property. + * + * Either the documentation isn't quite right for url.parse() or http.request() (the big brother + * of http.get), or one of those "options" properties is aliased to the other, or...? + */ + http.get(sURL, function(res) + { + res.on('data', function(data) + { + file.write(data); + }).on('end', function() + { + file.end(); + /* + * TODO: We should try to update the file's modification time to match the 'last-modified' + * response header value, if any. + * + * TODO: Decide what to do when res.statusCode is actually an error code (eg, 404), because + * in such cases, the file content will likely just be an HTML error page. + */ + done(null, res.statusCode); + }).on('error', function(err) + { + done(err, res.statusCode); + }); + }); + } + + /** + * getResource(sURL, dataPost, fAsync, done) + * + * Request the specified resource (sURL), and once the request is complete, notify done(). + * + * @param {string} sURL + * @param {Object|null} [dataPost] for a POST request (default is a GET request) + * @param {boolean} [fAsync] is true for an asynchronous request + * @param {function(string,string|null,number)} [done] + * @return {Array|null} Array containing [sResource, nErrorCode], or null if no response yet + */ + static getResource(sURL, dataPost, fAsync, done) + { + var nErrorCode = -1, sResource = null, response = null; + + if (Net.isRemote(sURL)) { + /* + * TODO: This code is nothing more than a band-aid. It assumes the URL uses "http:" + * (hence the call to getFile(), which only supports HTTP GET operations), it assumes + * the requested data is UTF-8 string data (which is normally the case, because nearly + * all our requests are for JSON files), it doesn't deal with dataPost, it assumes + * that fAsync is true, and it performs very simplistic error code mapping. + * + * But, it gets the job done for what little we actually ask of it, when our machines + * are running in the Node environment. + */ + Net.getFile(sURL, "utf8", function(err, status, data) { + if (done) done(sURL, data, err? status : 0); + }); + } else { + if (!Net.sServerRoot) { + Net.sServerRoot = path.join(path.dirname(fs.realpathSync(__filename)), "../../../"); + } + var sFile = path.join(Net.sServerRoot, sURL); + if (fAsync) { + fs.readFile(sFile, {encoding: "utf8"}, function(err, s) + { + /* + * TODO: If err is set, is there an error code we should return (instead of -1)? + */ + if (!err) { + sResource = s; + nErrorCode = 0; + } + if (done) done(sURL, sResource, nErrorCode); + }); + } else { + try { + sResource = fs.readFileSync(sFile, {encoding: "utf8"}); + nErrorCode = 0; + } catch (err) { + /* + * TODO: If err is set, is there an error code we should return (instead of -1)? + */ + console.log(err.message); + } + if (done) done(sURL, sResource, nErrorCode); + response = [sResource, nErrorCode]; + } + } + return response; + } +} + /* * The following are (super-secret) commands that can be added to the URL to enable special features. * @@ -49,342 +376,24 @@ if (NODE) { * http://www.pcjs.org/?gort=debug * * hasParm() detects the presence of the specified command, and propagateParms() is a URL filter that ensures - * any commands listed in asPropagate are passed through to all other URLs on the same page; using any of these + * any commands listed in Net.asPropagate are passed through to all other URLs on the same page; using any of these * commands also forces the page to be rebuilt and not cached (since we would never want a cached "index.html" to * contain/expose any of these commands). */ -net.GORT_COMMAND = "gort"; -net.GORT_DEBUG = "debug"; // use this to force uncompiled JavaScript even on a Release server -net.GORT_NODEBUG = "nodebug"; // use this to force uncompiled JavaScript but with DEBUG code disabled -net.GORT_RELEASE = "release"; // use this to force the use of compiled JavaScript even on a Debug server -net.GORT_REBUILD = "rebuild"; // use this to force the "index.html" in the current directory to be rebuilt +Net.GORT_COMMAND = "gort"; +Net.GORT_DEBUG = "debug"; // use this to force uncompiled JavaScript even on a Release server +Net.GORT_NODEBUG = "nodebug"; // use this to force uncompiled JavaScript but with DEBUG code disabled +Net.GORT_RELEASE = "release"; // use this to force the use of compiled JavaScript even on a Debug server +Net.GORT_REBUILD = "rebuild"; // use this to force the "index.html" in the current directory to be rebuilt -net.REVEAL_COMMAND = "reveal"; -net.REVEAL_PDFS = "pdfs"; +Net.REVEAL_COMMAND = "reveal"; +Net.REVEAL_PDFS = "pdfs"; /* * This is a list of the URL parameters that propagateParms() will propagate from the requester's URL to * other URLs provided by the requester. */ -var asPropagate = [net.GORT_COMMAND, "autostart"]; +Net.asPropagate = [Net.GORT_COMMAND, "autostart"]; +Net.sServerRoot = null; -/** - * hasParm(sParm, sValue, req) - * - * @param {string} sParm - * @param {string|null} sValue (pass null to check for the presence of ANY sParm) - * @param {Object} [req] is the web server's (ie, Express) request object, if any - * @return {boolean} true if the request Object contains the specified parameter/value, false if not - * - * TODO: Consider whether sParm === null should check for the presence of ANY parameter in asPropagate. - */ -net.hasParm = function(sParm, sValue, req) -{ - return (req && req.query && req.query[sParm] && (!sValue || req.query[sParm] == sValue)); -}; - -/** - * propagateParms(sURL, req) - * - * Propagates any "special" query parameters (as listed in asPropagate) from the given - * request object (req) to the given URL (sURL). - * - * We do not modify an sURL that already contains a '?' OR that begins with a protocol - * (eg, http:, mailto:, etc), in order to keep this function simple, since it's only for - * debugging purposes anyway. I also considered blowing off any URLs with a '#' for the - * same reason, since any hash string must follow any query parameters, but stripping - * and re-appending the hash string is pretty trivial, so we do handle that. - * - * TODO: Make propagateParms() more general-purpose (eg, capable of detecting any URL - * to the same site, and capable of merging any of our "special" query parameters with any - * existing query parameters. - * - * @param {string|null} sURL - * @param {Object} [req] is the web server's (ie, Express) request object, if any - * @return {string} massaged sURL - */ -net.propagateParms = function(sURL, req) -{ - if (sURL !== null && sURL.indexOf('?') < 0) { - var i; - var sHash = ""; - if ((i = sURL.indexOf('#')) >= 0) { - sHash = sURL.substr(i); - sURL = sURL.substr(0, i); - } - var match = sURL.match(/^([a-z])+:(.*)/); - if (!match && req && req.query) { - for (i = 0; i < asPropagate.length; i++) { - var sQuery = asPropagate[i]; - var sValue; - if ((sValue = req.query[sQuery])) { - var sParm = (sURL.indexOf('?') < 0? '?' : '&'); - sParm += sQuery + '='; - if (sURL.indexOf(sParm) < 0) sURL += sParm + encodeURIComponent(sValue); - } - } - } - sURL += sHash; - } - return sURL; -}; - -/** - * encodeURL(sURL, req, fDebug) - * - * Used to encodes any URLs presented on the current page, using this, um, simple 5-step process: - * - * 1) Replace any backslashes with slashes, in case the URL was derived from a file system path - * 2) Remap links that begin with "archive/" to the corresponding URL at "http://archive.pcjs.org/" - * 3) Use decodeURI() to eliminate escape sequences (like "%20") so that encodeURI() won't re-encode the "%" - * 4) Use encodeURI() to transform all "htmlspecialchars" and reserved characters into the appropriate sequences - * 5) Massage the result with net.propagateParms(), so that any special parameters are passed along - * - * @param {string} sURL - * @param {Object} req is the web server's (ie, Express) request object, if any - * @param {boolean} [fDebug] - * @return {string} encoded URL - */ -net.encodeURL = function(sURL, req, fDebug) -{ - if (sURL) { - sURL = sURL.replace(/\\/g, '/'); - if (!fDebug) { - if (sURL.match(/^[^:?]*archive\//)) { - if (sURL.charAt(0) != '/') sURL = path.join(req.path, sURL); - sURL = "http://archive.pcjs.org" + sURL.replace("/archive/", "/"); - } - } - /* - * If the incoming URL already contains URI-style escape sequences (eg, "%20" instead of spaces), - * calling decodeURI() first will eliminate them, preventing encodeURI() from converting leading - * "%" into "%25" and corrupting sequences like "%20" by turning them into "%2520". - */ - return net.propagateParms(encodeURI(decodeURI(sURL)), req); - } - return sURL; -}; - -/** - * isRemote(sPath) - * - * @param {string} sPath - * @return {boolean} true if sPath is a (supported) remote path, false if not - * - * TODO: Add support for FTP? HTTPS? Anything else? - */ -net.isRemote = function(sPath) -{ - return (sPath.indexOf("http:") === 0); -}; - -/** - * getStat(sURL, done) - * - * @param {string} sURL - * @param {function(Error,Object)} done - */ -net.getStat = function(sURL, done) -{ - var options = url.parse(sURL); - options.method = "HEAD"; - options.path = options.pathname; // TODO: Determine the necessity of aliasing this - var req = http.request(options, function(res) { - var err = null; - var stat = null; - // console.log(JSON.stringify(res.headers)); - if (res.statusCode == 200) { - /* - * Apparently Node lower-cases response headers (at least incoming headers, despite - * lots of amusing whining by certain people in the Node community), which seems like - * a good thing, because that means I can do two simple key look-ups. - */ - var sLength = res.headers['content-length']; - var sModified = res.headers['last-modified']; - stat = { - size: sLength? parseInt(sLength, 10) : -1, - mtime: sModified? new Date(sModified) : null, - remote: true // an additional property we provide to indicate this is not your normal stats object - }; - } else { - err = new Error("unexpected response code: " + res.statusCode); - } - done(err, stat); - }); - req.on('error', function(err) { - done(err, null); - }); - req.end(); -}; - -/** - * getFile(sURL, sEncoding, done) - * - * @param {string} sURL is the source file - * @param {string|null} sEncoding is the encoding to assume, if any - * @param {function(Error,number,(string|Buffer))} done receives an Error, an HTTP status code, and a Buffer (if any) - * - * TODO: Add support for FTP? HTTPS? Anything else? - */ -net.getFile = function(sURL, sEncoding, done) -{ - /* - * Buffer objects are a fixed size, so my choices are: 1) call getStat() first, hope it returns - * the true size, and then preallocate a buffer; or 2) create a new, larger buffer every time a new - * chunk arrives. The latter seems best. - * - * However, if an encoding is given, we'll simply concatenate all the data into a String and return - * that instead. Note that the incoming data is always a Buffer, but concatenation with a String - * performs an implied "toString()" on the Buffer. - * - * WARNING: Even when an encoding is provided, we don't make any attempt to verify that the incoming - * data matches that encoding. - */ - var sFile = ""; - var bufFile = null; - http.get(sURL, function(res) { - res.on('data', function(data) { - if (sEncoding) { - sFile += data; - return; - } - if (!bufFile) { - bufFile = data; - return; - } - /* - * We need to grow bufFile. I used to do this myself, using the "copy" method: - * - * buf.copy(targetBuffer, [targetStart], [sourceStart], [sourceEnd]) - * - * which defaults to 0 for [targetStart] and [sourceStart], but the docs don't clearly - * define the default value for [sourceEnd]. They say "buffer.length", but there is no - * parameter here named "buffer". Let's hope that in the case of "bufFile.copy(buf)" - * they meant "bufFile.length". - * - * However, it turns out this is moot, because there's a new kid in town: Buffer.concat(). - * - * buf = new Buffer(bufFile.length + data.length); - * bufFile.copy(buf); - * data.copy(buf, bufFile.length); - * bufFile = buf; - */ - bufFile = Buffer.concat([bufFile, data], bufFile.length + data.length); - }).on('end', function() { - /* - * TODO: Decide what to do when res.statusCode is actually an error code (eg, 404), because - * in such cases, the file content will likely just be an HTML error page. - */ - if (res.statusCode < 400) { - done(null, res.statusCode, sEncoding? sFile : bufFile); - } else { - done(new Error(sEncoding? sFile : bufFile), res.statusCode, null); - } - }).on('error', function(err) { - done(err, res.statusCode, null); - }); - }); -}; - -/** - * downloadFile(sURL, sFile, done) - * - * @param {string} sURL is the source file - * @param {string} sFile is a fully-qualified target file - * @param {function(Error,number)} done is a callback that receives an Error and a HTTP status code - */ -net.downloadFile = function(sURL, sFile, done) -{ - var file = fs.createWriteStream(sFile); - - /* - * http.get() accepts a "url" string in lieu of an "options" object; it automatically builds - * the latter from the former using url.parse(). This is good, because it relieves me from - * building my own "options" object, and also from wondering why http functions expect "options" - * to contain a "path" property, whereas url.parse() returns a "pathname" property. - * - * Either the documentation isn't quite right for url.parse() or http.request() (the big brother - * of http.get), or one of those "options" properties is aliased to the other, or...? - */ - http.get(sURL, function(res) { - res.on('data', function(data) { - file.write(data); - }).on('end', function() { - file.end(); - /* - * TODO: We should try to update the file's modification time to match the 'last-modified' - * response header value, if any. - * - * TODO: Decide what to do when res.statusCode is actually an error code (eg, 404), because - * in such cases, the file content will likely just be an HTML error page. - */ - done(null, res.statusCode); - }).on('error', function(err) { - done(err, res.statusCode); - }); - }); -}; - -/** - * getResource(sURL, dataPost, fAsync, done) - * - * Request the specified resource (sURL), and once the request is complete, notify done(). - * - * @param {string} sURL - * @param {Object|null} [dataPost] for a POST request (default is a GET request) - * @param {boolean} [fAsync] is true for an asynchronous request - * @param {function(string,string,number)} [done] - * @return {Array|null} Array containing [sResource, nErrorCode], or null if no response yet - */ -net.getResource = function(sURL, dataPost, fAsync, done) -{ - var nErrorCode = -1, sResource = null, response = null; - - if (net.isRemote(sURL)) { - /* - * TODO: This code is nothing more than a band-aid. It assumes the URL uses "http:" - * (hence the call to getFile(), which only supports HTTP GET operations), it assumes - * the requested data is UTF-8 string data (which is normally the case, because nearly - * all our requests are for JSON files), it doesn't deal with dataPost, it assumes - * that fAsync is true, and it performs very simplistic error code mapping. - * - * But, it gets the job done for what little we actually ask of it, when our machines - * are running in the Node environment. - */ - Net.getFile(sURL, "utf8", function(err, status, data) { - if (done) done(sURL, data, err? status : 0); - }); - } else { - if (!sServerRoot) { - sServerRoot = path.join(path.dirname(fs.realpathSync(__filename)), "../../../"); - } - var sFile = path.join(sServerRoot, sURL); - if (fAsync) { - fs.readFile(sFile, {encoding: "utf8"}, function(err, s) { - /* - * TODO: If err is set, is there an error code we should return (instead of -1)? - */ - if (!err) { - sResource = s; - nErrorCode = 0; - } - if (done) done(sURL, sResource, nErrorCode); - }); - } else { - try { - sResource = fs.readFileSync(sFile, {encoding: "utf8"}); - nErrorCode = 0; - } catch(err) { - /* - * TODO: If err is set, is there an error code we should return (instead of -1)? - */ - console.log(err.message); - } - if (done) done(sURL, sResource, nErrorCode); - response = [sResource, nErrorCode]; - } - } - return response; -}; - -if (NODE) module.exports = net; +if (NODE) module.exports = Net; diff --git a/modules/shared/lib/nodebug.js b/modules/shared/lib/nodebug.js index fb5990b0f..20b862ec3 100644 --- a/modules/shared/lib/nodebug.js +++ b/modules/shared/lib/nodebug.js @@ -28,8 +28,6 @@ "use strict"; -/* global DEBUG: true */ - /* * In the compiled case, we rely on the Closure Compiler to override DEBUG, setting it to false, * so that all DEBUG-only code will be removed by the compiler. diff --git a/modules/shared/lib/private.js b/modules/shared/lib/private.js index b87bf2c9e..4974c28b3 100644 --- a/modules/shared/lib/private.js +++ b/modules/shared/lib/private.js @@ -28,8 +28,6 @@ "use strict"; -/* global PRIVATE: true */ - /* * PRIVATE enables certain private features that we don't want enabled on the public web server, so by default, * PRIVATE is false. For Jekyll configurations, if site.pcjs.private is set, this file gets included, overriding diff --git a/modules/shared/lib/proclib.js b/modules/shared/lib/proclib.js index 7ce3d54c3..5b861fa46 100644 --- a/modules/shared/lib/proclib.js +++ b/modules/shared/lib/proclib.js @@ -28,59 +28,60 @@ "use strict"; -var proc = {}; - -/** - * getArgs() - * - * Processes command-line arguments. Arguments may be introduced by either - * a double-hyphen (--) or a long dash (—), and argument values, if any, must be - * separated by an "=" without any intervening whitespace. Arguments without - * an explicit value default to true, and any argument appearing more than once - * is automatically converted to an Array. - * - * Single-hyphen (-) arguments are allowed as well; they are treated as a series - * of single-character arguments, each set to true, and any of these arguments - * appearing more than once is discarded. - * - * @return {{argc:number, argv:{}}} - */ -proc.getArgs = function() { - var argc = 0; - var argv = {}; - for (var i = 2; i < process.argv.length; i++) { - var j, sSep; - var sArg = process.argv[i]; - if (!sArg.indexOf(sSep = "--") || !sArg.indexOf(sSep = "—")) { - sArg = sArg.substr(sSep.length); - var sValue = true; - j = sArg.indexOf("="); - if (j > 0) { - sValue = sArg.substr(j+1); - sArg = sArg.substr(0, j); - sValue = (sValue == "true")? true : ((sValue == "false")? false : sValue); - } - if (argv[sArg] === undefined) { - argc++; - argv[sArg] = sValue; - } else { - // console.log("too many '" + sArg + "' arguments"); - if (typeof argv[sArg] == "string") { - argv[sArg] = [argv[sArg]]; +class Proc { + /** + * getArgs() + * + * Processes command-line arguments. Arguments may be introduced by either + * a double-hyphen (--) or a long dash (—), and argument values, if any, must be + * separated by an "=" without any intervening whitespace. Arguments without + * an explicit value default to true, and any argument appearing more than once + * is automatically converted to an Array. + * + * Single-hyphen (-) arguments are allowed as well; they are treated as a series + * of single-character arguments, each set to true, and any of these arguments + * appearing more than once is discarded. + * + * @return {{argc:number, argv:{}}} + */ + static getArgs() + { + var argc = 0; + var argv = {}; + for (var i = 2; i < process.argv.length; i++) { + var j, sSep; + var sArg = process.argv[i]; + if (!sArg.indexOf(sSep = "--") || !sArg.indexOf(sSep = "—")) { + sArg = sArg.substr(sSep.length); + var sValue = true; + j = sArg.indexOf("="); + if (j > 0) { + sValue = sArg.substr(j + 1); + sArg = sArg.substr(0, j); + sValue = (sValue == "true") ? true : ((sValue == "false") ? false : sValue); } - argv[sArg].push(sValue); - } - } else if (!sArg.indexOf("-")) { - for (j = 1; j < sArg.length; j++) { - var ch = sArg.charAt(j); - if (argv[ch] === undefined) { - argv[ch] = true; + if (argv[sArg] === undefined) { argc++; + argv[sArg] = sValue; + } else { + // console.log("too many '" + sArg + "' arguments"); + if (typeof argv[sArg] == "string") { + argv[sArg] = [argv[sArg]]; + } + argv[sArg].push(sValue); + } + } else if (!sArg.indexOf("-")) { + for (j = 1; j < sArg.length; j++) { + var ch = sArg.charAt(j); + if (argv[ch] === undefined) { + argv[ch] = true; + argc++; + } } } } + return {argc: argc, argv: argv}; } - return {argc: argc, argv: argv}; -}; +} -if (NODE) module.exports = proc; +if (NODE) module.exports = Proc; diff --git a/modules/shared/lib/save.js b/modules/shared/lib/save.js index 5dd0a7cd4..22a44a803 100644 --- a/modules/shared/lib/save.js +++ b/modules/shared/lib/save.js @@ -28,12 +28,10 @@ "use strict"; -/* global window: true, APPVERSION: false, XMLVERSION: true, DEBUG: true */ - if (NODE) { - var Component = require("./component"); - var str = require("./strlib"); - var web = require("./weblib"); + var Str = require("../../shared/lib/strlib"); + var Web = require("../../shared/lib/weblib"); + var Component = require("../../shared/lib/component"); } /** @@ -59,12 +57,12 @@ function savePC(idMachine, sPCJSFile, callback) } } if (callback && callback({ state: sState, parms: sParms })) return true; - web.getResource(sPCJSFile, null, true, function(sURL, sResponse, nErrorCode) { - downloadCSS(sURL, sResponse, nErrorCode, [idMachine, str.getBaseName(sPCJSFile, true), sParms, sState]); + Web.getResource(sPCJSFile, null, true, function(sURL, sResponse, nErrorCode) { + downloadCSS(sURL, sResponse, nErrorCode, [idMachine, Str.getBaseName(sPCJSFile, true), sParms, sState]); }); return true; } - web.alertUser("Unable to identify machine '" + idMachine + "'"); + Component.alertUser("Unable to identify machine '" + idMachine + "'"); return false; } @@ -83,7 +81,7 @@ function downloadCSS(sURL, sPCJS, nErrorCode, aMachineInfo) var res = Component.getMachineResources(aMachineInfo[0]); var sCSSFile = null; for (var sName in res) { - if (str.endsWith(sName, "components.xsl")) { + if (Str.endsWith(sName, "components.xsl")) { sCSSFile = sName.replace(".xsl", ".css"); break; } @@ -94,13 +92,13 @@ function downloadCSS(sURL, sPCJS, nErrorCode, aMachineInfo) */ downloadPC(sURL, null, 0, aMachineInfo); } else { - web.getResource(sCSSFile, null, true, function(sURL, sResponse, nErrorCode) { + Web.getResource(sCSSFile, null, true, function(sURL, sResponse, nErrorCode) { downloadPC(sURL, sResponse, nErrorCode, aMachineInfo); }); } return; } - web.alertUser("Error (" + nErrorCode + ") requesting " + sURL); + Component.alertUser("Error (" + nErrorCode + ") requesting " + sURL); } /** @@ -152,7 +150,7 @@ function downloadPC(sURL, sCSS, nErrorCode, aMachineInfo) var resOld = Component.getMachineResources(idMachine), resNew = {}; for (var sName in resOld) { var data = resOld[sName]; - var sExt = str.getExtension(sName); + var sExt = Str.getExtension(sName); if (sExt == "xml") { /* * Look through this resource for entries whose paths do not appear as one of the @@ -169,10 +167,10 @@ function downloadPC(sURL, sCSS, nErrorCode, aMachineInfo) } } } - sXMLFile = sName = str.getBaseName(sName); + sXMLFile = sName = Str.getBaseName(sName); } else if (sExt == "xsl") { - sXSLFile = sName = str.getBaseName(sName); + sXSLFile = sName = Str.getBaseName(sName); } Component.log("saving resource: '" + sName + "' (" + data.length + " bytes)"); resNew[sName] = data; @@ -202,7 +200,7 @@ function downloadPC(sURL, sCSS, nErrorCode, aMachineInfo) sPCJS = sPCJS.replace(/\u00A9/g, "©"); - var sAlert = web.downloadFile(sPCJS, "javascript", false, sScript); + var sAlert = Web.downloadFile(sPCJS, "javascript", false, sScript); sAlert += ', copy it to your web server as "' + sScript + '", and then add the following to your web page:\n\n'; sAlert += '
\n'; @@ -210,10 +208,10 @@ function downloadPC(sURL, sCSS, nErrorCode, aMachineInfo) sAlert += '\n'; sAlert += '\n\n'; sAlert += 'The machine should appear where the
is located.'; - web.alertUser(sAlert); + Component.alertUser(sAlert); return; } - web.alertUser("Missing XML/XSL resources"); + Component.alertUser("Missing XML/XSL resources"); } /** diff --git a/modules/shared/lib/state.js b/modules/shared/lib/state.js index 53a181e09..94844fab0 100644 --- a/modules/shared/lib/state.js +++ b/modules/shared/lib/state.js @@ -29,183 +29,46 @@ "use strict"; if (NODE) { - var web = require("./../../shared/lib/weblib"); - var Component = require("./../../shared/lib/component"); + var Web = require("../../shared/lib/weblib"); + var Component = require("../../shared/lib/component"); } -/** - * State(component, sVersion, sSuffix) - * - * State objects are used by components to save/restore their state. - * - * During a save operation, components add data to a State object via set(), and then return - * the resulting data using data(). - * - * During a restore operation, the Computer component passes the results of each data() call - * back to the originating component. - * - * WARNING: Since State objects are low-level objects that have no UI requirements, they do not - * inherit from the Component class, so you should only use class methods of Component, such as - * Component.assert() (or Debugger methods if the Debugger is available). - * - * NOTE: 1.01 is the first version to provide limited save/restore support using localStorage. - * From that point on, care must be taken to insure that any new version that's incompatible with - * previous localStorage data be released with a version number that is at least 1 greater, - * since we're tagging the localStorage data with the integer portion of the version string. - * - * @constructor - * @param {Component} component - * @param {string} [sVersion] is used to append a major version number to the key - * @param {string} [sSuffix] is used to append any additional suffixes to the key - */ -function State(component, sVersion, sSuffix) { - this.id = component.id; - this.key = State.key(component, sVersion, sSuffix); - this.dbg = component.dbg; - this.unload(component.parms); -} - -/** - * State.key(component, sVersion, sSuffix) - * - * This encapsulates the key generation code. - * - * @param {Component} component - * @param {string} [sVersion] is used to append a major version number to the key - * @param {string} [sSuffix] is used to append any additional suffixes to the key - * @return {string} key - */ -State.key = function(component, sVersion, sSuffix) { - var key = component.id; - if (sVersion) { - var i = sVersion.indexOf('.'); - if (i > 0) key += ".v" + sVersion.substr(0, i); +class State { + /** + * State(component, sVersion, sSuffix) + * + * State objects are used by components to save/restore their state. + * + * During a save operation, components add data to a State object via set(), and then return + * the resulting data using data(). + * + * During a restore operation, the Computer component passes the results of each data() call + * back to the originating component. + * + * WARNING: Since State objects are low-level objects that have no UI requirements, they do not + * inherit from the Component class, so you should only use class methods of Component, such as + * Component.assert() (or Debugger methods if the Debugger is available). + * + * NOTE: 1.01 is the first version to provide limited save/restore support using localStorage. + * From that point on, care must be taken to insure that any new version that's incompatible with + * previous localStorage data be released with a version number that is at least 1 greater, + * since we're tagging the localStorage data with the integer portion of the version string. + * + * @param {Component} component + * @param {string} [sVersion] is used to append a major version number to the key + * @param {string} [sSuffix] is used to append any additional suffixes to the key + */ + constructor(component, sVersion, sSuffix) + { + this.id = component.id; + this.dbg = component.dbg; + this.json = ""; + this.state = {}; + this.fLoaded = this.fParsed = false; + this.key = State.key(component, sVersion, sSuffix); + this.unload(component.parms); } - if (sSuffix) { - key += "." + sSuffix; - } - return key; -}; -/** - * State.compress(aSrc) - * - * @param {Array.|null} aSrc - * @return {Array.|null} is either the original array (aSrc), or a smaller array of "count, value" pairs (aComp) - */ -State.compress = function(aSrc) { - if (aSrc) { - var iSrc = 0; - var iComp = 0; - var aComp = []; - while (iSrc < aSrc.length) { - var n = aSrc[iSrc]; - Component.assert(n !== undefined); - var iCompare = iSrc + 1; - while (iCompare < aSrc.length && aSrc[iCompare] === n) iCompare++; - aComp[iComp++] = iCompare - iSrc; - aComp[iComp++] = n; - iSrc = iCompare; - } - if (aComp.length < aSrc.length) return aComp; - } - return aSrc; -}; - -/** - * State.decompress(aComp) - * - * @param {Array.} aComp - * @param {number} nLength is expected length of decompressed data - * @return {Array.} - */ -State.decompress = function(aComp, nLength) { - var iDst = 0; - var aDst = new Array(nLength); - var iComp = 0; - while (iComp < aComp.length - 1) { - var c = aComp[iComp++]; - var n = aComp[iComp++]; - while (c--) { - aDst[iDst++] = n; - } - } - Component.assert(aDst.length == nLength); - return aDst; -}; - -/** - * State.compressEvenOdd(aSrc) - * - * This is a very simple variation on compress() that compresses all the EVEN elements of aSrc first, - * followed by all the ODD elements. This tends to work better on EGA video memory, because when odd/even - * addressing is enabled (eg, for text modes), the DWORD values tend to alternate, which is the worst case - * for compress(), but the best case for compressEvenOdd(). - * - * One wrinkle we support: if the first element is uninitialized, then we assume the entire array is undefined, - * and return an empty compressed array. Conversely, decompressEvenOdd() will take an empty compressed array - * and return an uninitialized array. - * - * @param {Array.|null} aSrc - * @return {Array.|null} is either the original array (aSrc), or a smaller array of "count, value" pairs (aComp) - */ -State.compressEvenOdd = function(aSrc) { - if (aSrc) { - var iComp = 0, aComp = []; - if (aSrc[0] !== undefined) { - for (var off = 0; off < 2; off++) { - var iSrc = off; - while (iSrc < aSrc.length) { - var n = aSrc[iSrc]; - var iCompare = iSrc + 2; - while (iCompare < aSrc.length && aSrc[iCompare] === n) iCompare += 2; - aComp[iComp++] = (iCompare - iSrc) >> 1; - aComp[iComp++] = n; - iSrc = iCompare; - } - } - } - if (aComp.length < aSrc.length) return aComp; - } - return aSrc; -}; - -/** - * State.decompressEvenOdd(aComp, nLength) - * - * This is the counterpart to compressEvenOdd(). Note that because there's nothing in the compressed sequence - * that differentiates a compress() sequence from a compressEvenOdd() sequence, you simply have to be consistent: - * if you used even/odd compression, then you must use even/odd decompression. - * - * @param {Array.} aComp - * @param {number} nLength is expected length of decompressed data - * @return {Array.} - */ -State.decompressEvenOdd = function(aComp, nLength) { - var iDst = 0; - var aDst = new Array(nLength); - var iComp = 0; - while (iComp < aComp.length - 1) { - var c = aComp[iComp++]; - var n = aComp[iComp++]; - while (c--) { - aDst[iDst] = n; - iDst += 2; - } - /* - * The output of a "count,value" pair will never exceed the end of the output array, so as soon as we reach it - * the first time, we know it's time to switch to ODD elements, and as soon as we reach it again, we should be - * done. - */ - Component.assert(iDst <= nLength || iComp == aComp.length); - if (iDst == nLength) iDst = 1; - } - Component.assert(aDst.length == nLength); - return aDst; -}; - -State.prototype = { - constructor: State, /** * set(id, data) * @@ -213,13 +76,15 @@ State.prototype = { * @param {number|string} id * @param {Object|string} data */ - set: function(id, data) { + set(id, data) + { try { - this[this.id][id] = data; + this.state[id] = data; } catch(e) { Component.log(e.message); } - }, + } + /** * get(id) * @@ -227,43 +92,38 @@ State.prototype = { * @param {number|string} id * @return {Object|string|null} */ - get: function(id) { - return this[this.id][id] || null; - }, - /** - * value() - * - * Use this instead of data() if you haven't called parse() yet. - * - * @this {State} - * @return {string} - */ - value: function() { - return this[this.id]; - }, + get(id) + { + return this.state[id] || null; + } + /** * data() * * @this {State} * @return {Object} */ - data: function() { - return this[this.id]; - }, + data() + { + return this.state; + } + /** - * load(s) + * load(json) * * WARNING: Make sure you follow this call with either a call to parse() or unload(), * because any stringified data that we've loaded isn't usable until it's been parsed. * * @this {State} - * @param {Object|string|null} [s] + * @param {string|null} [json] * @return {boolean} true if state exists in localStorage, false if not */ - load: function(s) { - if (s) { - this[this.id] = s; + load(json) + { + if (json) { + this.json = json; this.fLoaded = true; + this.fParsed = false; return true; } if (this.fLoaded) { @@ -272,17 +132,18 @@ State.prototype = { */ return true; } - if (web.hasLocalStorage()) { - s = web.getLocalStorageItem(this.key); + if (Web.hasLocalStorage()) { + var s = Web.getLocalStorageItem(this.key); if (s) { - this[this.id] = s; + this.json = s; this.fLoaded = true; if (DEBUG) Component.log("localStorage(" + this.key + "): " + s.length + " bytes loaded"); return true; } } return false; - }, + } + /** * parse() * @@ -293,27 +154,33 @@ State.prototype = { * @this {State} * @return {boolean} true if successful, false if error */ - parse: function() { + parse() + { var fSuccess = true; - try { - this[this.id] = JSON.parse(this[this.id]); - } catch (e) { - Component.error(e.message || e); - fSuccess = false; + if (!this.fParsed) { + try { + this.state = JSON.parse(this.json); + this.fParsed = true; + } catch (e) { + Component.error(e.message || e); + fSuccess = false; + } } return fSuccess; - }, + } + /** * store() * * @this {State} * @return {boolean} true if successful, false if error */ - store: function() { + store() + { var fSuccess = true; - if (web.hasLocalStorage()) { - var s = JSON.stringify(this[this.id]); - if (web.setLocalStorageItem(this.key, s)) { + if (Web.hasLocalStorage()) { + var s = JSON.stringify(this.state); + if (Web.setLocalStorageItem(this.key, s)) { if (DEBUG) Component.log("localStorage(" + this.key + "): " + s.length + " bytes stored"); } else { /* @@ -327,20 +194,19 @@ State.prototype = { } } return fSuccess; - }, + } + /** * toString() * - * We can't know whether this might be called before parse() or after parse(), so we check. - * If before, then this[this.id] will still be in string form; if after, it will be an Object. - * * @this {State} * @return {string} JSON-encoded state */ - toString: function() { - var value = this[this.id]; - return (typeof value == "string"? value : JSON.stringify(value)); - }, + toString() + { + return this.state? JSON.stringify(this.state) : this.json; + } + /** * unload(parms) * @@ -351,11 +217,14 @@ State.prototype = { * @this {State} * @param {Object} [parms] */ - unload: function(parms) { - this[this.id] = {}; + unload(parms) + { + this.json = ""; + this.state = {}; + this.fLoaded = this.fParsed = false; if (parms) this.set("parms", parms); - this.fLoaded = false; - }, + } + /** * clear(fAll) * @@ -365,19 +234,164 @@ State.prototype = { * @this {State} * @param {boolean} [fAll] true to unconditionally clear ALL localStorage for the current domain */ - clear: function(fAll) { + clear(fAll) + { this.unload(); - var aKeys = web.getLocalStorageKeys(); + var aKeys = Web.getLocalStorageKeys(); for (var i = 0; i < aKeys.length; i++) { var sKey = aKeys[i]; if (sKey && (fAll || sKey.substr(0, this.key.length) == this.key)) { - web.removeLocalStorageItem(sKey); + Web.removeLocalStorageItem(sKey); if (DEBUG) Component.log("localStorage(" + sKey + ") removed"); aKeys.splice(i, 1); i = 0; } } } -}; + + /** + * State.key(component, sVersion, sSuffix) + * + * This encapsulates the key generation code. + * + * @param {Component} component + * @param {string} [sVersion] is used to append a major version number to the key + * @param {string} [sSuffix] is used to append any additional suffixes to the key + * @return {string} key + */ + static key(component, sVersion, sSuffix) + { + var key = component.id; + if (sVersion) { + var i = sVersion.indexOf('.'); + if (i > 0) key += ".v" + sVersion.substr(0, i); + } + if (sSuffix) { + key += "." + sSuffix; + } + return key; + } + + /** + * State.compress(aSrc) + * + * @param {Array.|null} aSrc + * @return {Array.|null} is either the original array (aSrc), or a smaller array of "count, value" pairs (aComp) + */ + static compress(aSrc) + { + if (aSrc) { + var iSrc = 0; + var iComp = 0; + var aComp = []; + while (iSrc < aSrc.length) { + var n = aSrc[iSrc]; + Component.assert(n !== undefined); + var iCompare = iSrc + 1; + while (iCompare < aSrc.length && aSrc[iCompare] === n) iCompare++; + aComp[iComp++] = iCompare - iSrc; + aComp[iComp++] = n; + iSrc = iCompare; + } + if (aComp.length < aSrc.length) return aComp; + } + return aSrc; + } + + /** + * State.decompress(aComp) + * + * @param {Array.} aComp + * @param {number} nLength is expected length of decompressed data + * @return {Array.} + */ + static decompress(aComp, nLength) + { + var iDst = 0; + var aDst = new Array(nLength); + var iComp = 0; + while (iComp < aComp.length - 1) { + var c = aComp[iComp++]; + var n = aComp[iComp++]; + while (c--) { + aDst[iDst++] = n; + } + } + Component.assert(aDst.length == nLength); + return aDst; + } + + /** + * State.compressEvenOdd(aSrc) + * + * This is a very simple variation on compress() that compresses all the EVEN elements of aSrc first, + * followed by all the ODD elements. This tends to work better on EGA video memory, because when odd/even + * addressing is enabled (eg, for text modes), the DWORD values tend to alternate, which is the worst case + * for compress(), but the best case for compressEvenOdd(). + * + * One wrinkle we support: if the first element is uninitialized, then we assume the entire array is undefined, + * and return an empty compressed array. Conversely, decompressEvenOdd() will take an empty compressed array + * and return an uninitialized array. + * + * @param {Array.|null} aSrc + * @return {Array.|null} is either the original array (aSrc), or a smaller array of "count, value" pairs (aComp) + */ + static compressEvenOdd(aSrc) + { + if (aSrc) { + var iComp = 0, aComp = []; + if (aSrc[0] !== undefined) { + for (var off = 0; off < 2; off++) { + var iSrc = off; + while (iSrc < aSrc.length) { + var n = aSrc[iSrc]; + var iCompare = iSrc + 2; + while (iCompare < aSrc.length && aSrc[iCompare] === n) iCompare += 2; + aComp[iComp++] = (iCompare - iSrc) >> 1; + aComp[iComp++] = n; + iSrc = iCompare; + } + } + } + if (aComp.length < aSrc.length) return aComp; + } + return aSrc; + } + + /** + * State.decompressEvenOdd(aComp, nLength) + * + * This is the counterpart to compressEvenOdd(). Note that because there's nothing in the compressed sequence + * that differentiates a compress() sequence from a compressEvenOdd() sequence, you simply have to be consistent: + * if you used even/odd compression, then you must use even/odd decompression. + * + * @param {Array.} aComp + * @param {number} nLength is expected length of decompressed data + * @return {Array.} + */ + static decompressEvenOdd(aComp, nLength) + { + var iDst = 0; + var aDst = new Array(nLength); + var iComp = 0; + while (iComp < aComp.length - 1) { + var c = aComp[iComp++]; + var n = aComp[iComp++]; + while (c--) { + aDst[iDst] = n; + iDst += 2; + } + /* + * The output of a "count,value" pair will never exceed the end of the output array, so as soon as we reach it + * the first time, we know it's time to switch to ODD elements, and as soon as we reach it again, we should be + * done. + */ + Component.assert(iDst <= nLength || iComp == aComp.length); + if (iDst == nLength) iDst = 1; + } + Component.assert(aDst.length == nLength); + return aDst; + } +} if (NODE) module.exports = State; diff --git a/modules/shared/lib/strlib.js b/modules/shared/lib/strlib.js index 7ac90e98d..a9dbf0bf8 100644 --- a/modules/shared/lib/strlib.js +++ b/modules/shared/lib/strlib.js @@ -28,422 +28,545 @@ "use strict"; -var str = {}; +class Str { + /** + * isValidInt(s, base) + * + * The built-in parseInt() function has the annoying feature of returning a partial value (ie, + * up to the point where it encounters an invalid character); eg, parseInt("foo", 16) returns 0xf. + * + * So it's best to use our own Str.parseInt() function, which will in turn use this function to + * validate the entire string. + * + * @param {string} s is the string representation of some number + * @param {number} [base] is the radix to use (default is 10); only 2, 8, 10 and 16 are supported + * @return {boolean} true if valid, false if invalid (or the specified base isn't supported) + */ + static isValidInt(s, base) + { + if (!base || base == 10) return s.match(/^[0-9]+$/) !== null; + if (base == 16) return s.match(/^[0-9a-f]+$/i) !== null; + if (base == 8) return s.match(/^[0-7]+$/) !== null; + if (base == 2) return s.match(/^[01]+$/) !== null; + return false; + } -/** - * isValidInt(s, base) - * - * The built-in parseInt() function has the annoying feature of returning a partial value (ie, - * up to the point where it encounters an invalid character); eg, parseInt("foo", 16) returns 0xf. - * - * So it's best to use our own str.parseInt() function, which will in turn use this function to - * validate the entire string. - * - * @param {string} s is the string representation of some number - * @param {number} [base] is the radix to use (default is 10); only 2, 8, 10 and 16 are supported - * @return {boolean} true if valid, false if invalid (or the specified base isn't supported) - */ -str.isValidInt = function(s, base) -{ - if (!base || base == 10) return s.match(/^[0-9]+$/) !== null; - if (base == 16) return s.match(/^[0-9a-f]+$/i) !== null; - if (base == 8) return s.match(/^[0-7]+$/) !== null; - if (base == 2) return s.match(/^[01]+$/) !== null; - return false; -}; + /** + * parseInt(s, base) + * + * This is a wrapper around the built-in parseInt() function. Our wrapper recognizes certain prefixes + * ('$' or "0x" for hex, '#' or "0o" for octal) and suffixes ('.' for decimal, 'h' for hex, 'y' for + * binary), and then calls isValidInt() to ensure we don't convert strings that contain partial values; + * see isValidInt() for details. + * + * The use of multiple prefix/suffix combinations is undefined (although for the record, we process + * prefixes first). We do NOT support the "0b" prefix to indicate binary UNLESS one or more commas are + * also present (because "0b" is also a valid hex sequence), and we do NOT support a single leading zero + * to indicate octal (because such a number could also be decimal or hex). Any number of commas are + * allowed; we remove them all before calling the built-in parseInt(). + * + * To summarize our non-standard alternatives: a 'y' suffix indicates binary, a '#' prefix indicates + * octal, a '$' prefix indicates hex, and a "0b" prefix indicates binary IF at least one comma is present. + * Commas are useful for grouping binary digits, but if you don't want to use them, then you must use a + * 'y' suffix for binary numbers. + * + * @param {string} s is the string representation of some number + * @param {number} [base] is the radix to use (default is 10); can be overridden by prefixes/suffixes + * @return {number|undefined} corresponding value, or undefined if invalid + */ + static parseInt(s, base) + { + var value; -/** - * parseInt(s, base) - * - * This is a wrapper around the built-in parseInt() function. Our wrapper recognizes certain prefixes - * ('$' or "0x" for hex, '#' or "0o" for octal) and suffixes ('.' for decimal, 'h' for hex, 'y' for - * binary), and then calls isValidInt() to ensure we don't convert strings that contain partial values; - * see isValidInt() for details. - * - * The use of multiple prefix/suffix combinations is undefined (although for the record, we process - * prefixes first). We do NOT support the "0b" prefix to indicate binary UNLESS one or more commas are - * also present (because "0b" is also a valid hex sequence), and we do NOT support a single leading zero - * to indicate octal (because such a number could also be decimal or hex). Any number of commas are - * allowed; we remove them all before calling the built-in parseInt(). - * - * To summarize our non-standard alternatives: a 'y' suffix indicates binary, a '#' prefix indicates - * octal, a '$' prefix indicates hex, and a "0b" prefix indicates binary IF at least one comma is present. - * Commas are useful for grouping binary digits, but if you don't want to use them, then you must use a - * 'y' suffix for binary numbers. - * - * @param {string} s is the string representation of some number - * @param {number} [base] is the radix to use (default is 10); can be overridden by prefixes/suffixes - * @return {number|undefined} corresponding value, or undefined if invalid - */ -str.parseInt = function(s, base) -{ - var value; - - if (s) { - if (!base) base = 10; - var chPrefix = s.charAt(0); - var fCommas = (s.indexOf(',') > 0); - if (fCommas) s = s.replace(/,/g, ''); - if (chPrefix == '#') { - base = 8; - chPrefix = null; - } - else if (chPrefix == '$') { - base = 16; - chPrefix = null; - } - if (chPrefix == null) { - s = s.substr(1); - } - else { - if (chPrefix == '0') { - chPrefix = s.charAt(1); - if (chPrefix == 'b' && fCommas) { - base = 2; - chPrefix = null; - } - if (chPrefix == 'o') { - base = 8; - chPrefix = null; - } - else if (chPrefix == 'x') { - base = 16; - chPrefix = null; - } + if (s) { + if (!base) base = 10; + var chPrefix = s.charAt(0); + var fCommas = (s.indexOf(',') > 0); + if (fCommas) s = s.replace(/,/g, ''); + if (chPrefix == '#') { + base = 8; + chPrefix = null; + } + else if (chPrefix == '$') { + base = 16; + chPrefix = null; } if (chPrefix == null) { - s = s.substr(2); + s = s.substr(1); } else { - var chSuffix = s.charAt(s.length-1).toLowerCase(); - if (chSuffix == 'y') { - base = 2; - chSuffix = null; + if (chPrefix == '0') { + chPrefix = s.charAt(1); + if (chPrefix == 'b' && fCommas) { + base = 2; + chPrefix = null; + } + if (chPrefix == 'o') { + base = 8; + chPrefix = null; + } + else if (chPrefix == 'x') { + base = 16; + chPrefix = null; + } } - else if (chSuffix == '.') { - base = 10; - chSuffix = null; + if (chPrefix == null) { + s = s.substr(2); } - else if (chSuffix == 'h') { - base = 16; - chSuffix = null; + else { + var chSuffix = s.charAt(s.length - 1).toLowerCase(); + if (chSuffix == 'y') { + base = 2; + chSuffix = null; + } + else if (chSuffix == '.') { + base = 10; + chSuffix = null; + } + else if (chSuffix == 'h') { + base = 16; + chSuffix = null; + } + if (chSuffix == null) s = s.substr(0, s.length - 1); } - if (chSuffix == null) s = s.substr(0, s.length-1); + } + var v; + if (Str.isValidInt(s, base) && !isNaN(v = parseInt(s, base))) { + value = v | 0; } } - var v; - if (str.isValidInt(s, base) && !isNaN(v = parseInt(s, base))) { - value = v|0; - } + return value; } - return value; -}; -/** - * toBin(n, cch, grouping) - * - * Converts an integer to binary, with the specified number of digits (up to the default of 32). - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of binary digits (32 is both the default and the maximum) - * @param {number} [grouping] - * @return {string} the binary representation of n - */ -str.toBin = function(n, cch, grouping) -{ - var s = ""; - if (!cch) { - cch = 32; - } else { - if (cch > 32) cch = 32; - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + /** + * toBin(n, cch, grouping) * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. - */ - var fInvalid = (n == null || isNaN(n)); - var group = (grouping = grouping || cch); - while (cch-- > 0) { - if (!group) { - s = "," + s; - group = grouping; - } - s = (fInvalid? '?' : ((n & 0x1)? '1' : '0')) + s; - n >>= 1; - group--; - } - return s; -}; - -/** - * toBinBytes(n, cb, fPrefix) - * - * Converts an integer to binary, with the specified number of bytes (up to the default of 4). - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cb] is the desired number of binary bytes (4 is both the default and the maximum) - * @param {boolean} [fPrefix] - * @return {string} the binary representation of n - */ -str.toBinBytes = function(n, cb, fPrefix) -{ - var s = ""; - if (!cb || cb > 4) cb = 4; - for (var i = 0; i < cb; i++) { - if (s) s = ',' + s; - s = str.toBin(n & 0xff, 8) + s; - n >>= 8; - } - return (fPrefix? "0b" : "") + s; -}; - -/** - * toOct(n, cch, fPrefix) - * - * Converts an integer to octal, with the specified number of digits (default of 6; max of 11) - * - * You might be tempted to use the built-in n.toString(8) instead, but it doesn't zero-pad and it - * doesn't properly convert negative values. Moreover, if n is undefined, n.toString() will throw - * an exception, whereas this function will return '?' characters. - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of octal digits (0 or undefined for default of either 6 or 11) - * @param {boolean} [fPrefix] - * @return {string} the octal representation of n - */ -str.toOct = function(n, cch, fPrefix) -{ - var s = ""; - - if (cch) { - if (cch > 11) cch = 11; - } else { - cch = (n & ~0xffffff)? 11 : ((n & ~0xffff)? 8 : 6); - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + * Converts an integer to binary, with the specified number of digits (up to the default of 32). * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. + * @param {number|null|undefined} n is a 32-bit value + * @param {number} [cch] is the desired number of binary digits (32 is both the default and the maximum) + * @param {number} [grouping] + * @return {string} the binary representation of n */ - if (n == null || isNaN(n)) { - while (cch-- > 0) s = '?' + s; - } else { + static toBin(n, cch, grouping) + { + var s = ""; + if (!cch) { + cch = 32; + } else { + if (cch > 32) cch = 32; + } + /* + * An initial "falsey" check for null takes care of both null and undefined; + * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + * + * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, + * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those + * values displayed differently. + */ + var fInvalid = (n == null || isNaN(n)); + var group = (grouping = grouping || cch); while (cch-- > 0) { - var d = (n & 7) + 0x30; - s = String.fromCharCode(d) + s; - n >>= 3; + if (!group) { + s = "," + s; + group = grouping; + } + s = (fInvalid ? '?' : ((n & 0x1) ? '1' : '0')) + s; + n >>= 1; + group--; } + return s; } - return (fPrefix? "0o" : "") + s; -}; -/** - * toDec(n, cch) - * - * Converts an integer to decimal, with the specified number of digits (default of 5; max of 10) - * - * You might be tempted to use the built-in n.toString(10) instead, but it doesn't zero-pad and it - * doesn't properly convert negative values. Moreover, if n is undefined, n.toString() will throw - * an exception, whereas this function will return '?' characters. - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of decimal digits (0 or undefined for default of either 5 or 10) - * @return {string} the octal representation of n - */ -str.toDec = function(n, cch) -{ - var s = ""; - - if (cch) { - if (cch > 10) cch = 10; - } else { - cch = (n & ~0xffff)? 10 : 5; - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + /** + * toBinBytes(n, cb, fPrefix) * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. - */ - if (n == null || isNaN(n)) { - while (cch-- > 0) s = '?' + s; - } else { - while (cch-- > 0) { - var d = (n % 10) + 0x30; - s = String.fromCharCode(d) + s; - n /= 10; - } - } - return s; -}; - -/** - * toHex(n, cch, fPrefix) - * - * Converts an integer to hex, with the specified number of digits (default of 4 or 8, max of 8). - * - * 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) - * will return "-7fffffff" instead of "80000001". Moreover, if n is undefined, n.toString() will - * throw an exception, whereas this function will return '?' characters. - * - * NOTE: The following work-around (adapted from code found on StackOverflow) would be another solution, - * taking care of negative values, zero-padding, and upper-casing, but not null/undefined/NaN values: - * - * s = (n < 0? n + 0x100000000 : n).toString(16); - * s = "00000000".substr(0, 8 - s.length) + s; - * s = s.substr(0, cch).toUpperCase(); - * - * @param {number|null|undefined} n is a 32-bit value - * @param {number} [cch] is the desired number of hex digits (0 or undefined for default of either 4 or 8) - * @param {boolean} [fPrefix] - * @return {string} the hex representation of n - */ -str.toHex = function(n, cch, fPrefix) -{ - var s = ""; - - if (cch) { - if (cch > 8) cch = 8; - } else { - cch = (n & ~0xffff)? 8 : 4; - } - /* - * An initial "falsey" check for null takes care of both null and undefined; - * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + * Converts an integer to binary, with the specified number of bytes (up to the default of 4). * - * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, - * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those - * values displayed differently. + * @param {number|null|undefined} n is a 32-bit value + * @param {number} [cb] is the desired number of binary bytes (4 is both the default and the maximum) + * @param {boolean} [fPrefix] + * @return {string} the binary representation of n */ - if (n == null || isNaN(n)) { - while (cch-- > 0) s = '?' + s; - } else { - while (cch-- > 0) { - var d = n & 0xf; - d += (d >= 0 && d <= 9? 0x30 : 0x41 - 10); - s = String.fromCharCode(d) + s; - n >>= 4; + static toBinBytes(n, cb, fPrefix) + { + var s = ""; + if (!cb || cb > 4) cb = 4; + for (var i = 0; i < cb; i++) { + if (s) s = ',' + s; + s = Str.toBin(n & 0xff, 8) + s; + n >>= 8; } + return (fPrefix ? "0b" : "") + s; } - return (fPrefix? "0x" : "") + s; -}; -/** - * toHexByte(b) - * - * Alias for str.toHex(b, 2, true) - * - * @param {number|null|undefined} b is a byte value - * @return {string} the hex representation of b - */ -str.toHexByte = function(b) -{ - return str.toHex(b, 2, true); -}; - -/** - * toHexWord(w) - * - * Alias for str.toHex(w, 4, true) - * - * @param {number|null|undefined} w is a word (16-bit) value - * @return {string} the hex representation of w - */ -str.toHexWord = function(w) -{ - return str.toHex(w, 4, true); -}; - -/** - * toHexLong(l) - * - * Alias for str.toHex(l, 8, true) - * - * @param {number|null|undefined} l is a dword (32-bit) value - * @return {string} the hex representation of w - */ -str.toHexLong = function(l) -{ - return str.toHex(l, 8, true); -}; - -/** - * getBaseName(sFileName, fStripExt) - * - * This is a poor-man's version of Node's path.basename(), which Node-only components should use instead. - * - * 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 - * @param {boolean} [fStripExt] - * @return {string} - */ -str.getBaseName = function(sFileName, fStripExt) -{ - var sBaseName = sFileName; - - var i = sFileName.lastIndexOf('/'); - if (i >= 0) sBaseName = sFileName.substr(i + 1); - - /* - * This next bit is a kludge to clean up names that are part of a URL that includes unsightly query parameters. + /** + * toOct(n, cch, fPrefix) + * + * Converts an integer to octal, with the specified number of digits (default of 6; max of 11) + * + * You might be tempted to use the built-in n.toString(8) instead, but it doesn't zero-pad and it + * doesn't properly convert negative values. Moreover, if n is undefined, n.toString() will throw + * an exception, whereas this function will return '?' characters. + * + * @param {number|null|undefined} n is a 32-bit value + * @param {number} [cch] is the desired number of octal digits (0 or undefined for default of either 6 or 11) + * @param {boolean} [fPrefix] + * @return {string} the octal representation of n */ - i = sBaseName.indexOf('&'); - if (i > 0) sBaseName = sBaseName.substr(0, i); + static toOct(n, cch, fPrefix) + { + var s = ""; - if (fStripExt) { - i = sBaseName.lastIndexOf("."); - if (i > 0) { - sBaseName = sBaseName.substring(0, i); + if (cch) { + if (cch > 11) cch = 11; + } else { + cch = (n & ~0xffffff) ? 11 : ((n & ~0xffff) ? 8 : 6); } + /* + * An initial "falsey" check for null takes care of both null and undefined; + * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + * + * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, + * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those + * values displayed differently. + */ + if (n == null || isNaN(n)) { + while (cch-- > 0) s = '?' + s; + } else { + while (cch-- > 0) { + var d = (n & 7) + 0x30; + s = String.fromCharCode(d) + s; + n >>= 3; + } + } + return (fPrefix ? "0o" : "") + s; } - return sBaseName; -}; -/** - * getExtension(sFileName) - * - * This is a poor-man's version of Node's path.extname(), which Node-only components should use instead. - * - * Note that we EXCLUDE the period from the returned extension, whereas path.extname() includes it. - * - * @param {string} sFileName - * @return {string} the filename's extension (in lower-case and EXCLUDING the "."), or an empty string - */ -str.getExtension = function(sFileName) -{ - var sExtension = ""; - var i = sFileName.lastIndexOf("."); - if (i >= 0) { - sExtension = sFileName.substr(i + 1).toLowerCase(); + /** + * toDec(n, cch) + * + * Converts an integer to decimal, with the specified number of digits (default of 5; max of 10) + * + * You might be tempted to use the built-in n.toString(10) instead, but it doesn't zero-pad and it + * doesn't properly convert negative values. Moreover, if n is undefined, n.toString() will throw + * an exception, whereas this function will return '?' characters. + * + * @param {number|null|undefined} n is a 32-bit value + * @param {number} [cch] is the desired number of decimal digits (0 or undefined for default of either 5 or 10) + * @return {string} the octal representation of n + */ + static toDec(n, cch) + { + var s = ""; + + if (cch) { + if (cch > 10) cch = 10; + } else { + cch = (n & ~0xffff) ? 10 : 5; + } + /* + * An initial "falsey" check for null takes care of both null and undefined; + * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + * + * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, + * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those + * values displayed differently. + */ + if (n == null || isNaN(n)) { + while (cch-- > 0) s = '?' + s; + } else { + while (cch-- > 0) { + var d = (n % 10) + 0x30; + s = String.fromCharCode(d) + s; + n /= 10; + } + } + return s; } - return sExtension; -}; -/** - * endsWith(s, sSuffix) - * - * @param {string} s - * @param {string} sSuffix - * @return {boolean} true if s ends with sSuffix, false if not - */ -str.endsWith = function(s, sSuffix) -{ - return s.indexOf(sSuffix, s.length - sSuffix.length) !== -1; -}; + /** + * toHex(n, cch, fPrefix) + * + * Converts an integer to hex, with the specified number of digits (default of 4 or 8, max of 8). + * + * 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) + * will return "-7fffffff" instead of "80000001". Moreover, if n is undefined, n.toString() will + * throw an exception, whereas this function will return '?' characters. + * + * NOTE: The following work-around (adapted from code found on StackOverflow) would be another solution, + * taking care of negative values, zero-padding, and upper-casing, but not null/undefined/NaN values: + * + * s = (n < 0? n + 0x100000000 : n).toString(16); + * s = "00000000".substr(0, 8 - s.length) + s; + * s = s.substr(0, cch).toUpperCase(); + * + * @param {number|null|undefined} n is a 32-bit value + * @param {number} [cch] is the desired number of hex digits (0 or undefined for default of either 4 or 8) + * @param {boolean} [fPrefix] + * @return {string} the hex representation of n + */ + static toHex(n, cch, fPrefix) + { + var s = ""; -str.aHTMLEscapeMap = { + if (cch) { + if (cch > 8) cch = 8; + } else { + cch = (n & ~0xffff) ? 8 : 4; + } + /* + * An initial "falsey" check for null takes care of both null and undefined; + * we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough. + * + * Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN, + * since JavaScript coerces such operands to zero, but I think there's "value" in seeing those + * values displayed differently. + */ + if (n == null || isNaN(n)) { + while (cch-- > 0) s = '?' + s; + } else { + while (cch-- > 0) { + var d = n & 0xf; + d += (d >= 0 && d <= 9 ? 0x30 : 0x41 - 10); + s = String.fromCharCode(d) + s; + n >>= 4; + } + } + return (fPrefix ? "0x" : "") + s; + } + + /** + * toHexByte(b) + * + * Alias for Str.toHex(b, 2, true) + * + * @param {number|null|undefined} b is a byte value + * @return {string} the hex representation of b + */ + static toHexByte(b) + { + return Str.toHex(b, 2, true); + } + + /** + * toHexWord(w) + * + * Alias for Str.toHex(w, 4, true) + * + * @param {number|null|undefined} w is a word (16-bit) value + * @return {string} the hex representation of w + */ + static toHexWord(w) + { + return Str.toHex(w, 4, true); + } + + /** + * toHexLong(l) + * + * Alias for Str.toHex(l, 8, true) + * + * @param {number|null|undefined} l is a dword (32-bit) value + * @return {string} the hex representation of w + */ + static toHexLong(l) + { + return Str.toHex(l, 8, true); + } + + /** + * getBaseName(sFileName, fStripExt) + * + * This is a poor-man's version of Node's path.basename(), which Node-only components should use instead. + * + * 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 + * @param {boolean} [fStripExt] + * @return {string} + */ + static getBaseName(sFileName, fStripExt) + { + var sBaseName = sFileName; + + var i = sFileName.lastIndexOf('/'); + if (i >= 0) sBaseName = sFileName.substr(i + 1); + + /* + * This next bit is a kludge to clean up names that are part of a URL that includes unsightly query parameters. + */ + i = sBaseName.indexOf('&'); + if (i > 0) sBaseName = sBaseName.substr(0, i); + + if (fStripExt) { + i = sBaseName.lastIndexOf("."); + if (i > 0) { + sBaseName = sBaseName.substring(0, i); + } + } + return sBaseName; + } + + /** + * getExtension(sFileName) + * + * This is a poor-man's version of Node's path.extname(), which Node-only components should use instead. + * + * Note that we EXCLUDE the period from the returned extension, whereas path.extname() includes it. + * + * @param {string} sFileName + * @return {string} the filename's extension (in lower-case and EXCLUDING the "."), or an empty string + */ + static getExtension(sFileName) + { + var sExtension = ""; + var i = sFileName.lastIndexOf("."); + if (i >= 0) { + sExtension = sFileName.substr(i + 1).toLowerCase(); + } + return sExtension; + } + + /** + * endsWith(s, sSuffix) + * + * @param {string} s + * @param {string} sSuffix + * @return {boolean} true if s ends with sSuffix, false if not + */ + static endsWith(s, sSuffix) + { + return s.indexOf(sSuffix, s.length - sSuffix.length) !== -1; + } + + /** + * escapeHTML(sHTML) + * + * @param {string} sHTML + * @return {string} with HTML entities "escaped", similar to PHP's htmlspecialchars() + */ + static escapeHTML(sHTML) + { + return sHTML.replace(/[&<>"']/g, function(m) + { + return Str.aHTMLEscapeMap[m]; + }); + } + + /** + * replaceAll(sFind, sReplace, s) + * + * @param {string} sFind + * @param {string} sReplace + * @param {string} s + * @return {string} + */ + static replaceAll(sFind, sReplace, s) + { + var a = {}; + a[sFind] = sReplace; + return Str.replaceArray(a, s); + } + + /** + * replaceArray(a, s) + * + * @param {Object} a + * @param {string} s + * @return {string} + */ + static replaceArray(a, s) + { + var sMatch = ""; + for (var k in a) { + /* + * As noted in: + * + * http://www.regexguru.com/2008/04/escape-characters-only-when-necessary/ + * + * inside character classes, only backslash, caret, hyphen and the closing bracket need to be + * escaped. And in fact, if you ensure that the closing bracket is first, the caret is not first, + * and the hyphen is last, you can avoid escaping those as well. + */ + k = k.replace(/([\\[\]*{}().+?])/g, "\\$1"); + sMatch += (sMatch ? '|' : '') + k; + } + return s.replace(new RegExp('(' + sMatch + ')', "g"), function(m) + { + return a[m]; + }); + } + + /** + * pad(s, cch, fPadLeft) + * + * NOTE: the maximum amount of padding currently supported is 40 spaces. + * + * @param {string} s is a string + * @param {number} cch is desired length + * @param {boolean} [fPadLeft] (default is padding on the right) + * @return {string} the original string (s) with spaces padding it to the specified length + */ + static pad(s, cch, fPadLeft) + { + var sPadding = " "; + return fPadLeft ? (sPadding + s).slice(-cch) : (s + sPadding).slice(0, cch); + } + + /** + * stripLeadingZeros(s, fPad) + * + * @param {string} s + * @param {boolean} [fPad] + * @return {string} + */ + static stripLeadingZeros(s, fPad) + { + var cch = s.length; + s = s.replace(/^0+([0-9A-F]+)$/i, "$1"); + if (fPad) s = Str.pad(s, cch, true); + return s; + } + + /** + * trim(s) + * + * @param {string} s + * @return {string} + */ + static trim(s) + { + if (String.prototype.trim) { + return s.trim(); + } + return s.replace(/^\s+|\s+$/g, ""); + } + + /** + * toASCIICode(b) + * + * @param {number} b + * @return {string} + */ + static toASCIICode(b) + { + var s; + if (b != Str.ASCII.CR && b != Str.ASCII.LF) { + s = Str.aASCIICodes[b]; + } + if (s) { + s = '<' + s + '>'; + } else { + s = String.fromCharCode(b); + } + return s; + } +} + +Str.aHTMLEscapeMap = { '&': '&', '<': '<', '>': '>', @@ -451,111 +574,10 @@ str.aHTMLEscapeMap = { "'": ''' }; -/** - * escapeHTML(sHTML) - * - * @param {string} sHTML - * @return {string} with HTML entities "escaped", similar to PHP's htmlspecialchars() - */ -str.escapeHTML = function(sHTML) -{ - return sHTML.replace(/[&<>"']/g, function(m) { - return str.aHTMLEscapeMap[m]; - }); -}; - -/** - * replaceAll(sFind, sReplace, s) - * - * @param {string} sFind - * @param {string} sReplace - * @param {string} s - * @return {string} - */ -str.replaceAll = function(sFind, sReplace, s) -{ - var a = {}; - a[sFind] = sReplace; - return str.replaceArray(a, s); -}; - -/** - * replaceArray(a, s) - * - * @param {Object} a - * @param {string} s - * @return {string} - */ -str.replaceArray = function(a, s) -{ - var sMatch = ""; - for (var k in a) { - /* - * As noted in: - * - * http://www.regexguru.com/2008/04/escape-characters-only-when-necessary/ - * - * inside character classes, only backslash, caret, hyphen and the closing bracket need to be - * escaped. And in fact, if you ensure that the closing bracket is first, the caret is not first, - * and the hyphen is last, you can avoid escaping those as well. - */ - k = k.replace(/([\\[\]*{}().+?])/g, "\\$1"); - sMatch += (sMatch? '|' : '') + k; - } - return s.replace(new RegExp('(' + sMatch + ')', "g"), function(m) { - return a[m]; - }); -}; - -/** - * pad(s, cch, fPadLeft) - * - * NOTE: the maximum amount of padding currently supported is 40 spaces. - * - * @param {string} s is a string - * @param {number} cch is desired length - * @param {boolean} [fPadLeft] (default is padding on the right) - * @return {string} the original string (s) with spaces padding it to the specified length - */ -str.pad = function(s, cch, fPadLeft) -{ - var sPadding = " "; - return fPadLeft? (sPadding + s).slice(-cch) : (s + sPadding).slice(0, cch); -}; - -/** - * stripLeadingZeros(s, fPad) - * - * @param {string} s - * @param {boolean} [fPad] - * @return {string} - */ -str.stripLeadingZeros = function(s, fPad) -{ - var cch = s.length; - s = s.replace(/^0+([0-9A-F]+)$/i, "$1"); - if (fPad) s = str.pad(s, cch, true); - return s; -}; - -/** - * trim(s) - * - * @param {string} s - * @return {string} - */ -str.trim = function(s) -{ - if (String.prototype.trim) { - return s.trim(); - } - return s.replace(/^\s+|\s+$/g, ""); -}; - /* * Future home of a general-purpose ASCII table. TODO: Flesh it out. */ -str.ASCII = { +Str.ASCII = { LF: 0x0A, CR: 0x0D }; @@ -563,7 +585,7 @@ str.ASCII = { /* * Table for converting "unprintable" ASCII codes into mnemonics, to more clearly see what's being printed. */ -str.aASCIICodes = { +Str.aASCIICodes = { 0x00: "NUL", 0x01: "SOH", // (CTRL_A) Start of Heading 0x02: "STX", // (CTRL_B) Start of Text @@ -598,21 +620,16 @@ str.aASCIICodes = { 0x1F: "US" // Unit Separator }; -/** - * toASCIICode(b) - * - * @param {number} b - * @return {string} - */ -str.toASCIICode = function(b) -{ - var s = (b != str.ASCII.CR && b != str.ASCII.LF? str.aASCIICodes[b] : null); - if (s) { - s = '<' + s + '>'; - } else { - s = String.fromCharCode(b); - } - return s; +Str.TYPES = { + NULL: 0, + BYTE: 1, + WORD: 2, + DWORD: 3, + NUMBER: 4, + STRING: 5, + BOOLEAN: 6, + OBJECT: 7, + ARRAY: 8 }; -if (NODE) module.exports = str; +if (NODE) module.exports = Str; diff --git a/modules/shared/lib/userapi.js b/modules/shared/lib/userapi.js index 312405cce..1a24b3a77 100644 --- a/modules/shared/lib/userapi.js +++ b/modules/shared/lib/userapi.js @@ -33,7 +33,6 @@ * * web.getHost() + UserAPI.ENDPOINT + '?' + UserAPI.QUERY.REQ + '=' + UserAPI.REQ.VERIFY + '&' + UserAPI.QUERY.USER + '=' + sUser; */ - var UserAPI = { ENDPOINT: "/api/v1/user", QUERY: { diff --git a/modules/shared/lib/usrlib.js b/modules/shared/lib/usrlib.js index b6562e240..b76b46e78 100644 --- a/modules/shared/lib/usrlib.js +++ b/modules/shared/lib/usrlib.js @@ -28,181 +28,6 @@ "use strict"; -var usr = {}; - -/** - * binarySearch(a, v, fnCompare) - * - * @param {Array} a is an array - * @param {number|string|Array|Object} v - * @param {function((number|string|Array|Object), (number|string|Array|Object))} [fnCompare] - * @return {number} the index of matching entry if non-negative, otherwise the index of the insertion point - */ -usr.binarySearch = function(a, v, fnCompare) { - var left = 0; - var right = a.length; - var found = 0; - if (fnCompare === undefined) { - fnCompare = function(a, b) { - return a > b? 1 : a < b? -1 : 0; - }; - } - while (left < right) { - var middle = (left + right) >> 1; - var compareResult; - compareResult = fnCompare(v, a[middle]); - if (compareResult > 0) { - left = middle + 1; - } else { - right = middle; - found = !compareResult; - } - } - return found? left : ~left; -}; - -/** - * binaryInsert(a, v, fnCompare) - * - * If element v already exists in array a, the array is unchanged (we don't allow duplicates); otherwise, the - * element is inserted into the array at the appropriate index. - * - * @param {Array} a is an array - * @param {number|string|Array|Object} v is the value to insert - * @param {function((number|string|Array|Object), (number|string|Array|Object))} [fnCompare] - */ -usr.binaryInsert = function(a, v, fnCompare) { - var index = usr.binarySearch(a, v, fnCompare); - if (index < 0) { - a.splice(-(index + 1), 0, v); - } -}; - -/** - * getTime() - * - * @return {number} the current time, in milliseconds - */ -usr.getTime = Date.now || function() { return +new Date(); }; - -/** - * getTimestamp() - * - * @return {string} timestamp containing the current date and time ("yyyy-mm-dd hh:mm:ss") - */ -usr.getTimestamp = function() { - var date = new Date(); - var padNum = function(n) { - return (n < 10? "0" : "") + n; - }; - return date.getFullYear() + "-" + padNum(date.getMonth() + 1) + "-" + padNum(date.getDate()) + " " + padNum(date.getHours()) + ":" + padNum(date.getMinutes()) + ":" + padNum(date.getSeconds()); -}; - -/** - * getMonthDays(nMonth, nYear) - * - * Note that if we're being called on behalf of the RTC, its year is always truncated to two digits (mod 100), - * so we have no idea what century the year 0 might refer to. When using the normal leap-year formula, 0 fails - * the mod 100 test but passes the mod 400 test, so as far as the RTC is concerned, every century year is a leap - * year. Since we're most likely dealing with the year 2000, that's fine, since 2000 was also a leap year. - * - * TODO: There IS a separate CMOS byte that's supposed to be set to CMOS_ADDR.CENTURY_DATE; it's always BCD, - * so theoretically it will contain values like 0x19 or 0x20 (for the 20th and 21st centuries, respectively), and - * we could add that as another parameter to this function, to improve the accuracy, but that would go beyond what - * a real RTC actually does. - * - * @param {number} nMonth (1-12) - * @param {number} nYear (normally a 4-digit year, but it may also be mod 100) - * @return {number} the maximum (1-based) day allowed for the specified month and year - */ -usr.getMonthDays = function(nMonth, nYear) -{ - var nDays = usr.aMonthDays[nMonth - 1]; - if (nDays == 28) { - if ((nYear % 4) === 0 && ((nYear % 100) || (nYear % 400) === 0)) { - nDays++; - } - } - return nDays; -}; - -usr.asDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; -usr.asMonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; -usr.aMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - -/** - * formatDate(sFormat, date) - * - * @param {string} sFormat (eg, "F j, Y", "Y-m-d H:i:s") - * @param {Date} [date] (default is the current time) - * @return {string} - * - * Supported identifiers in sFormat include: - * - * a: lowercase ante meridiem and post meridiem (am or pm) - * d: day of the month, 2 digits with leading zeros (01,...,31) - * g: hour in 12-hour format, without leading zeros (1,...,12) - * i: minutes, with leading zeros (00,...,59) - * j: day of the month, without leading zeros (1,...,31) - * l: day of the week ("Sunday",...,"Saturday") - * m: month, with leading zeros (01,...,12) - * s: seconds, with leading zeros (00,...,59) - * F: month ("January",...,"December") - * H: hour in 24-hour format, with leading zeros (00,...,23) - * Y: year (eg, 2014) - * - * For more inspiration, see: http://php.net/manual/en/function.date.php - */ -usr.formatDate = function(sFormat, date) { - var sDate = ""; - if (!date) date = new Date(); - var iHour = date.getHours(); - var iDay = date.getDate(); - var iMonth = date.getMonth() + 1; - for (var i = 0; i < sFormat.length; i++) { - var ch; - switch((ch = sFormat.charAt(i))) { - case 'a': - sDate += (iHour < 12? "am" : "pm"); - break; - case 'd': - sDate += ('0' + iDay).slice(-2); - break; - case 'g': - sDate += (!iHour? 12 : (iHour > 12? iHour - 12 : iHour)); - break; - case 'i': - sDate += ('0' + date.getMinutes()).slice(-2); - break; - case 'j': - sDate += iDay; - break; - case 'l': - sDate += usr.asDays[date.getDay()]; - break; - case 'm': - sDate += ('0' + iMonth).slice(-2); - break; - case 's': - sDate += ('0' + date.getSeconds()).slice(-2); - break; - case 'F': - sDate += usr.asMonths[iMonth - 1]; - break; - case 'H': - sDate += ('0' + iHour).slice(-2); - break; - case 'Y': - sDate += date.getFullYear(); - break; - default: - sDate += ch; - break; - } - } - return sDate; -}; - /** * @typedef {{ * mask: number, @@ -216,100 +41,279 @@ var BitField; */ var BitFields; -/** - * defineBitFields(bfs) - * - * Prepares a bit field definition for use with getBitField() and setBitField(); eg: - * - * var bfs = usr.defineBitFields({num:20, count:8, btmod:1, type:3}); - * - * The above defines a set of bit fields containg four fields: num (bits 0-19), count (bits 20-27), btmod (bit 28), and type (bits 29-31). - * - * usr.setBitField(bfs.num, n, 1); - * - * The above set bit field "bfs.num" in numeric variable "n" to the value 1. - * - * @param {Object} bfs - * @return {BitFields} - */ -usr.defineBitFields = function(bfs) -{ - var bit = 0; - for (var f in bfs) { - var width = bfs[f]; - var mask = ((1 << width) - 1) << bit; - bfs[f] = {mask: mask, shift: bit}; - bit += width; +class Usr { + /** + * binarySearch(a, v, fnCompare) + * + * @param {Array} a is an array + * @param {number|string|Array|Object} v + * @param {function((number|string|Array|Object), (number|string|Array|Object))} [fnCompare] + * @return {number} the index of matching entry if non-negative, otherwise the index of the insertion point + */ + static binarySearch(a, v, fnCompare) + { + var left = 0; + var right = a.length; + var found = 0; + if (fnCompare === undefined) { + fnCompare = function(a, b) + { + return a > b ? 1 : a < b ? -1 : 0; + }; + } + while (left < right) { + var middle = (left + right) >> 1; + var compareResult; + compareResult = fnCompare(v, a[middle]); + if (compareResult > 0) { + left = middle + 1; + } else { + right = middle; + found = !compareResult; + } + } + return found ? left : ~left; } - // Component.assert(bit <= 32); - return bfs; -}; -/** - * initBitFields(bfs, ...) - * - * @param {BitFields} bfs - * @param {...number} var_args - * @return {number} a value containing all supplied bit fields - */ -usr.initBitFields = function(bfs, var_args) -{ - var v = 0, i = 1; - for (var f in bfs) { - if (i >= arguments.length) break; - v = usr.setBitField(bfs[f], v, arguments[i++]); + /** + * binaryInsert(a, v, fnCompare) + * + * If element v already exists in array a, the array is unchanged (we don't allow duplicates); otherwise, the + * element is inserted into the array at the appropriate index. + * + * @param {Array} a is an array + * @param {number|string|Array|Object} v is the value to insert + * @param {function((number|string|Array|Object), (number|string|Array|Object))} [fnCompare] + */ + static binaryInsert(a, v, fnCompare) + { + var index = Usr.binarySearch(a, v, fnCompare); + if (index < 0) { + a.splice(-(index + 1), 0, v); + } } - return v; -}; -/** - * getBitField(bf, v) - * - * @param {BitField} bf - * @param {number} v is a value containing bit fields - * @return {number} the value of the bit field in v defined by bf - */ -usr.getBitField = function(bf, v) -{ - return (v & bf.mask) >> bf.shift; -}; - -/** - * setBitField(bf, v, n) - * - * @param {BitField} bf - * @param {number} v is a value containing bit fields - * @param {number} n is a value to store in v in the bit field defined by bf - * @return {number} updated v - */ -usr.setBitField = function(bf, v, n) -{ - // Component.assert(!(n & ~(bf.mask >>> bf.shift))); - return (v & ~bf.mask) | ((n << bf.shift) & bf.mask); -}; - -/** - * indexOf(a, t, i) - * - * Use this instead of Array.prototype.indexOf() if you can't be sure the browser supports it. - * - * @param {Array} a - * @param {*} t - * @param {number} [i] - * @returns {number} - */ -usr.indexOf = function(a, t, i) -{ - if (Array.prototype.indexOf) { - return a.indexOf(t, i); + /** + * getTimestamp() + * + * @return {string} timestamp containing the current date and time ("yyyy-mm-dd hh:mm:ss") + */ + static getTimestamp() + { + var date = new Date(); + var padNum = function(n) + { + return (n < 10 ? "0" : "") + n; + }; + return date.getFullYear() + "-" + padNum(date.getMonth() + 1) + "-" + padNum(date.getDate()) + " " + padNum(date.getHours()) + ":" + padNum(date.getMinutes()) + ":" + padNum(date.getSeconds()); } - i = i || 0; - if (i < 0) i += a.length; - if (i < 0) i = 0; - for (var n = a.length; i < n; i++) { - if (i in a && a[i] === t) return i; - } - return -1; -}; -if (NODE) module.exports = usr; + /** + * getMonthDays(nMonth, nYear) + * + * Note that if we're being called on behalf of the RTC, its year is always truncated to two digits (mod 100), + * so we have no idea what century the year 0 might refer to. When using the normal leap-year formula, 0 fails + * the mod 100 test but passes the mod 400 test, so as far as the RTC is concerned, every century year is a leap + * year. Since we're most likely dealing with the year 2000, that's fine, since 2000 was also a leap year. + * + * TODO: There IS a separate CMOS byte that's supposed to be set to CMOS_ADDR.CENTURY_DATE; it's always BCD, + * so theoretically it will contain values like 0x19 or 0x20 (for the 20th and 21st centuries, respectively), and + * we could add that as another parameter to this function, to improve the accuracy, but that would go beyond what + * a real RTC actually does. + * + * @param {number} nMonth (1-12) + * @param {number} nYear (normally a 4-digit year, but it may also be mod 100) + * @return {number} the maximum (1-based) day allowed for the specified month and year + */ + static getMonthDays(nMonth, nYear) + { + var nDays = Usr.aMonthDays[nMonth - 1]; + if (nDays == 28) { + if ((nYear % 4) === 0 && ((nYear % 100) || (nYear % 400) === 0)) { + nDays++; + } + } + return nDays; + } + + /** + * formatDate(sFormat, date) + * + * @param {string} sFormat (eg, "F j, Y", "Y-m-d H:i:s") + * @param {Date} [date] (default is the current time) + * @return {string} + * + * Supported identifiers in sFormat include: + * + * a: lowercase ante meridiem and post meridiem (am or pm) + * d: day of the month, 2 digits with leading zeros (01,...,31) + * g: hour in 12-hour format, without leading zeros (1,...,12) + * i: minutes, with leading zeros (00,...,59) + * j: day of the month, without leading zeros (1,...,31) + * l: day of the week ("Sunday",...,"Saturday") + * m: month, with leading zeros (01,...,12) + * s: seconds, with leading zeros (00,...,59) + * F: month ("January",...,"December") + * H: hour in 24-hour format, with leading zeros (00,...,23) + * Y: year (eg, 2014) + * + * For more inspiration, see: http://php.net/manual/en/function.date.php + */ + static formatDate(sFormat, date) + { + var sDate = ""; + if (!date) date = new Date(); + var iHour = date.getHours(); + var iDay = date.getDate(); + var iMonth = date.getMonth() + 1; + for (var i = 0; i < sFormat.length; i++) { + var ch; + switch ((ch = sFormat.charAt(i))) { + case 'a': + sDate += (iHour < 12 ? "am" : "pm"); + break; + case 'd': + sDate += ('0' + iDay).slice(-2); + break; + case 'g': + sDate += (!iHour ? 12 : (iHour > 12 ? iHour - 12 : iHour)); + break; + case 'i': + sDate += ('0' + date.getMinutes()).slice(-2); + break; + case 'j': + sDate += iDay; + break; + case 'l': + sDate += Usr.asDays[date.getDay()]; + break; + case 'm': + sDate += ('0' + iMonth).slice(-2); + break; + case 's': + sDate += ('0' + date.getSeconds()).slice(-2); + break; + case 'F': + sDate += Usr.asMonths[iMonth - 1]; + break; + case 'H': + sDate += ('0' + iHour).slice(-2); + break; + case 'Y': + sDate += date.getFullYear(); + break; + default: + sDate += ch; + break; + } + } + return sDate; + } + + /** + * defineBitFields(bfs) + * + * Prepares a bit field definition for use with getBitField() and setBitField(); eg: + * + * var bfs = Usr.defineBitFields({num:20, count:8, btmod:1, type:3}); + * + * The above defines a set of bit fields containing four fields: num (bits 0-19), count (bits 20-27), btmod (bit 28), and type (bits 29-31). + * + * Usr.setBitField(bfs.num, n, 1); + * + * The above set bit field "bfs.num" in numeric variable "n" to the value 1. + * + * @param {Object} bfs + * @return {BitFields} + */ + static defineBitFields(bfs) + { + var bit = 0; + for (var f in bfs) { + var width = bfs[f]; + var mask = ((1 << width) - 1) << bit; + bfs[f] = {mask: mask, shift: bit}; + bit += width; + } + return bfs; + } + + /** + * initBitFields(bfs, ...) + * + * @param {BitFields} bfs + * @param {...number} var_args + * @return {number} a value containing all supplied bit fields + */ + static initBitFields(bfs, var_args) + { + var v = 0, i = 1; + for (var f in bfs) { + if (i >= arguments.length) break; + v = Usr.setBitField(bfs[f], v, arguments[i++]); + } + return v; + } + + /** + * getBitField(bf, v) + * + * @param {BitField} bf + * @param {number} v is a value containing bit fields + * @return {number} the value of the bit field in v defined by bf + */ + static getBitField(bf, v) + { + return (v & bf.mask) >> bf.shift; + } + + /** + * setBitField(bf, v, n) + * + * @param {BitField} bf + * @param {number} v is a value containing bit fields + * @param {number} n is a value to store in v in the bit field defined by bf + * @return {number} updated v + */ + static setBitField(bf, v, n) + { + return (v & ~bf.mask) | ((n << bf.shift) & bf.mask); + } + + /** + * indexOf(a, t, i) + * + * Use this instead of Array.prototype.indexOf() if you can't be sure the browser supports it. + * + * @param {Array} a + * @param {*} t + * @param {number} [i] + * @returns {number} + */ + static indexOf(a, t, i) + { + if (Array.prototype.indexOf) { + return a.indexOf(t, i); + } + i = i || 0; + if (i < 0) i += a.length; + if (i < 0) i = 0; + for (var n = a.length; i < n; i++) { + if (i in a && a[i] === t) return i; + } + return -1; + } +} + +Usr.asDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; +Usr.asMonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; +Usr.aMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +/** + * getTime() + * + * @return {number} the current time, in milliseconds + */ +Usr.getTime = Date.now || function() { return +new Date(); }; + +if (NODE) module.exports = Usr; diff --git a/modules/shared/lib/weblib.js b/modules/shared/lib/weblib.js index 8da5967f7..54be9e08d 100644 --- a/modules/shared/lib/weblib.js +++ b/modules/shared/lib/weblib.js @@ -26,6 +26,13 @@ * as to their contents. */ +"use strict"; + +if (NODE) { + var Component = require("../../shared/lib/component"); + var ReportAPI = require("../../shared/lib/reportapi"); +} + /* * According to http://www.w3schools.com/jsref/jsref_obj_global.asp, these are the *global* properties * and functions of JavaScript-in-the-Browser: @@ -110,409 +117,828 @@ * stop() Stops the window from loading */ -"use strict"; - -/* global window: true, setTimeout: false, clearTimeout: false, SITEHOST: false */ - -if (NODE) { - var Component; - require("./defines"); - var str = require("./strlib"); - var ReportAPI = require("./reportapi"); -} - -var web = {}; - -/* - * We must defer loading the Component module until the function(s) requiring it are - * called; otherwise, we create an initialization cycle in which Component requires weblib - * and weblib requires Component. - * - * In an ideal world, weblib would not be dependent on Component, but we really want to use - * its I/O functions. The simplest solution is to create wrapper functions. - */ - -/** - * log(s, type) - * - * For diagnostic output only. DEBUG must be true (or "--debug" specified via the command-line) - * for Component.log() to display anything. - * - * @param {string} [s] is the message text - * @param {string} [type] is the message type - */ -web.log = function(s, type) -{ - if (NODE) { - if (!Component) Component = require("./component"); +class Web { + /** + * log(s, type) + * + * For diagnostic output only. DEBUG must be true (or "--debug" specified via the command-line) + * for Component.log() to display anything. + * + * @param {string} [s] is the message text + * @param {string} [type] is the message type + */ + static log(s, type) + { + Component.log(s, type); } - Component.log(s, type); -}; -/** - * notice(s, fPrintOnly, id) - * - * If Component.notice() calls web.alertUser(), it will fall back to web.log() if all else fails. - * - * @param {string} s is the message text - * @param {boolean} [fPrintOnly] - * @param {string} [id] is the caller's ID, if any - */ -web.notice = function(s, fPrintOnly, id) -{ - if (NODE) { - if (!Component) Component = require("./component"); + /** + * notice(s, fPrintOnly, id) + * + * @param {string} s is the message text + * @param {boolean} [fPrintOnly] + * @param {string} [id] is the caller's ID, if any + */ + static notice(s, fPrintOnly, id) + { + Component.notice(s, fPrintOnly, id); } - Component.notice(s, fPrintOnly, id); -}; -/** - * getResource(sURL, dataPost, fAsync, done) - * - * Request the specified resource (sURL), and once the request is complete, notify done(). - * - * Also, if dataPost is set to a string, that string can be used to control the response format; - * by default, the response format is plain text, but you can specify "bytes" to request arbitrary - * binary data, which should come back as a string of bytes. - * - * TODO: The "bytes" option works by calling overrideMimeType(), which was never a best practice. - * Instead, we should implement supported response types ("text" and "arraybuffer", at a minimum) - * by setting xmlHTTP.responseType to one of those values before calling xmlHTTP.send(). - * - * @param {string} sURL - * @param {string|Object|null} [dataPost] for a POST request (default is a GET request) - * @param {boolean} [fAsync] is true for an asynchronous request - * @param {function(string,string,number)} [done] - * @return {Array|null} Array containing [sResource, nErrorCode], or null if no response yet - */ -web.getResource = function(sURL, dataPost, fAsync, done) -{ - var nErrorCode = 0, sResource = null, response = null; + /** + * getResource(sURL, dataPost, fAsync, done) + * + * Request the specified resource (sURL), and once the request is complete, notify done(). + * + * Also, if dataPost is set to a string, that string can be used to control the response format; + * by default, the response format is plain text, but you can specify "bytes" to request arbitrary + * binary data, which should come back as a string of bytes. + * + * TODO: The "bytes" option works by calling overrideMimeType(), which was never a best practice. + * Instead, we should implement supported response types ("text" and "arraybuffer", at a minimum) + * by setting xmlHTTP.responseType to one of those values before calling xmlHTTP.send(). + * + * ES6 ALERT: Default parameters. + * + * @param {string} sURL + * @param {string|Object|null} [dataPost] for a POST request (default is a GET request) + * @param {boolean} [fAsync] is true for an asynchronous request + * @param {function(string,string,number)} [done] + * @return {Array|null} Array containing [sResource, nErrorCode], or null if no response yet + */ + static getResource(sURL, dataPost, fAsync = false, done) + { + var nErrorCode = 0, sResource = null, response = null; - if (typeof resources == 'object' && (sResource = resources[sURL])) { - if (done) done(sURL, sResource, nErrorCode); - return [sResource, nErrorCode]; - } - else if (fAsync && typeof resources == 'function') { - resources(sURL, function(sResource, nErrorCode) { + if (typeof resources == 'object' && (sResource = resources[sURL])) { if (done) done(sURL, sResource, nErrorCode); - }); + return [sResource, nErrorCode]; + } + else if (fAsync && typeof resources == 'function') { + resources(sURL, function(sResource, nErrorCode) + { + if (done) done(sURL, sResource, nErrorCode); + }); + return response; + } + + if (DEBUG) { + /* + * The larger resources we put on archive.pcjs.org should also be available locally... + */ + sURL = sURL.replace(/^http:\/\/archive.pcjs.org(\/.*)\/([^\/]*)$/, "$1/archive/$2"); + } + + if (NODE) { + /* + * We don't even need to load Component, because we can't use any of the code below + * within Node anyway. Instead, we must hand this request off to our network library. + * + * if (!Component) Component = require("./component"); + */ + var Net = require("./netlib"); + return Net.getResource(sURL, dataPost, fAsync, done); + } + + var xmlHTTP = (window.XMLHttpRequest? new window.XMLHttpRequest() : new window.ActiveXObject("Microsoft.XMLHTTP")); + if (fAsync) { + xmlHTTP.onreadystatechange = function() + { + if (xmlHTTP.readyState === 4) { + /* + * The following line was recommended for WebKit, as a work-around to prevent the handler firing multiple + * times when debugging. Unfortunately, that's not the only XMLHttpRequest problem that occurs when + * debugging, so I think the WebKit problem is deeper than that. When we have multiple XMLHttpRequests + * pending, any debugging activity means most of them simply get dropped on floor, so what may actually be + * happening are mis-notifications rather than redundant notifications. + * + * xmlHTTP.onreadystatechange = undefined; + */ + sResource = xmlHTTP.responseText; + /* + * The normal "success" case is an HTTP status code of 200, but when testing with files loaded + * from the local file system (ie, when using the "file:" protocol), we have to be a bit more "flexible". + */ + if (xmlHTTP.status == 200 || !xmlHTTP.status && sResource.length && Web.getHostProtocol() == "file:") { + if (MAXDEBUG) Web.log("xmlHTTP.onreadystatechange(" + sURL + "): returned " + sResource.length + " bytes"); + } + else { + nErrorCode = xmlHTTP.status || -1; + Web.log("xmlHTTP.onreadystatechange(" + sURL + "): error code " + nErrorCode); + } + if (done) done(sURL, sResource, nErrorCode); + } + }; + } + + if (dataPost && typeof dataPost == "object") { + var sDataPost = ""; + for (var p in dataPost) { + if (!dataPost.hasOwnProperty(p)) continue; + if (sDataPost) sDataPost += "&"; + sDataPost += p + '=' + encodeURIComponent(dataPost[p]); + } + sDataPost = sDataPost.replace(/%20/g, '+'); + if (MAXDEBUG) Web.log("Web.getResource(POST " + sURL + "): " + sDataPost.length + " bytes"); + xmlHTTP.open("POST", sURL, fAsync); // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it) + xmlHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + xmlHTTP.send(sDataPost); + } else { + if (MAXDEBUG) Web.log("Web.getResource(GET " + sURL + ")"); + xmlHTTP.open("GET", sURL, fAsync); // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it) + if (dataPost == "bytes") { + xmlHTTP.overrideMimeType("text/plain; charset=x-user-defined"); + } + xmlHTTP.send(); + } + + if (!fAsync) { + sResource = xmlHTTP.responseText; + if (xmlHTTP.status == 200) { + if (MAXDEBUG) Web.log("Web.getResource(" + sURL + "): returned " + sResource.length + " bytes"); + } else { + nErrorCode = xmlHTTP.status || -1; + Web.log("Web.getResource(" + sURL + "): error code " + nErrorCode); + } + if (done) done(sURL, sResource, nErrorCode); + response = [sResource, nErrorCode]; + } return response; } - if (DEBUG) { - /* - * The larger resources we put on archive.pcjs.org should also be available locally... - */ - sURL = sURL.replace(/^http:\/\/archive.pcjs.org(\/.*)\/([^\/]*)$/, "$1/archive/$2"); - } + /** + * parseMemoryResource(sURL, sData) + * + * @param {string} sURL + * @param {string} sData + * @return {Object|null} (resource) + */ + static parseMemoryResource(sURL, sData) + { + var i; + var resource = { + aBytes: null, + aSymbols: null, + addrLoad: null, + addrExec: null + }; - if (NODE) { - /* - * We don't even need to load Component, because we can't use any of the code below - * within Node anyway. Instead, we must hand this request off to our network library. - * - * if (!Component) Component = require("./component"); - */ - var net = require("./netlib"); - return net.getResource(sURL, dataPost, fAsync, done); - } + if (sData.charAt(0) == "[" || sData.charAt(0) == "{") { + try { + var a, ib, data; + + if (sData.substr(0, 1) == "<") { // if the "data" begins with a "<"... + /* + * Early server configs reported an error (via the nErrorCode parameter) if a tape URL was invalid, + * but more recent server configs now display a somewhat friendlier HTML error page. The downside, + * however, is that the original error has been buried, and we've received "data" that isn't actually + * tape data. So if the data we've received appears to be "HTML-like", we treat it as an error message. + */ + throw new Error(sData); + } - var xmlHTTP = (window.XMLHttpRequest? new window.XMLHttpRequest() : new window.ActiveXObject("Microsoft.XMLHTTP")); - if (fAsync) { - xmlHTTP.onreadystatechange = function() { - if (xmlHTTP.readyState === 4) { /* - * The following line was recommended for WebKit, as a work-around to prevent the handler firing multiple - * times when debugging. Unfortunately, that's not the only XMLHttpRequest problem that occurs when - * debugging, so I think the WebKit problem is deeper than that. When we have multiple XMLHttpRequests - * pending, any debugging activity means most of them simply get dropped on floor, so what may actually be - * happening are mis-notifications rather than redundant notifications. + * TODO: IE9 is rather unfriendly and restrictive with regard to how much data it's willing to + * eval(). In particular, the 10Mb disk image we use for the Windows 1.01 demo config fails in + * IE9 with an "Out of memory" exception. One work-around would be to chop the data into chunks + * (perhaps one track per chunk, using regular expressions) and then manually re-assemble it. * - * xmlHTTP.onreadystatechange = undefined; + * However, it turns out that using JSON.parse(sDiskData) instead of eval("(" + sDiskData + ")") + * is a much easier fix. The only drawback is that we must first quote any unquoted property names + * and remove any comments, because while eval() was cool with them, JSON.parse() is more particular; + * the following RegExp replacements take care of those requirements. + * + * The use of hex values is something else that eval() was OK with, but JSON.parse() is not, and + * while I've stopped using hex values in DumpAPI responses (at least when "format=json" is specified), + * I can't guarantee they won't show up in "legacy" images, and there's no simple RegExp replacement + * for transforming hex values into decimal values, so I cop out and fall back to eval() if I detect + * any hex prefixes ("0x") in the sequence. Ditto for error messages, which appear like so: + * + * ["unrecognized disk path: test.img"] */ - sResource = xmlHTTP.responseText; - /* - * The normal "success" case is an HTTP status code of 200, but when testing with files loaded - * from the local file system (ie, when using the "file:" protocol), we have to be a bit more "flexible". - */ - if (xmlHTTP.status == 200 || !xmlHTTP.status && sResource.length && web.getHostProtocol() == "file:") { - if (MAXDEBUG) web.log("xmlHTTP.onreadystatechange(" + sURL + "): returned " + sResource.length + " bytes"); + if (sData.indexOf("0x") < 0 && sData.substr(0, 2) != "[\"") { + data = JSON.parse(sData.replace(/([a-z]+):/gm, "\"$1\":").replace(/\/\/[^\n]*/gm, "")); + } else { + data = eval("(" + sData + ")"); + } + + resource.addrLoad = data['load']; + resource.addrExec = data['exec']; + + if (a = data['bytes']) { + resource.aBytes = a; + } + else if (a = data['words']) { + /* + * Convert all words into bytes + */ + resource.aBytes = new Array(a.length * 2); + for (i = 0, ib = 0; i < a.length; i++) { + resource.aBytes[ib++] = a[i] & 0xff; + resource.aBytes[ib++] = (a[i] >> 8) & 0xff; + Component.assert(!(a[i] & ~0xffff)); + } + } + else if (a = data['data']) { + /* + * Convert all dwords (longs) into bytes + */ + resource.aBytes = new Array(a.length * 4); + for (i = 0, ib = 0; i < a.length; i++) { + resource.aBytes[ib++] = a[i] & 0xff; + resource.aBytes[ib++] = (a[i] >> 8) & 0xff; + resource.aBytes[ib++] = (a[i] >> 16) & 0xff; + resource.aBytes[ib++] = (a[i] >> 24) & 0xff; + } } else { - nErrorCode = xmlHTTP.status || -1; - web.log("xmlHTTP.onreadystatechange(" + sURL + "): error code " + nErrorCode); + resource.aBytes = data; } - if (done) done(sURL, sResource, nErrorCode); + + resource.aSymbols = data['symbols']; + + if (!resource.aBytes.length) { + Component.error("Empty resource: " + sURL); + resource = null; + } + else if (resource.aBytes.length == 1) { + Component.error(resource.aBytes[0]); + resource = null; + } + } catch (e) { + Component.error("Resource data error (" + sURL + "): " + e.message); + resource = null; } + } + else { + /* + * Parse the data manually; we assume it's a series of hex byte-values separated by whitespace. + */ + var ab = []; + var sHexData = sData.replace(/\n/gm, " ").replace(/ +$/, ""); + var asHexData = sHexData.split(" "); + for (i = 0; i < asHexData.length; i++) { + var n = parseInt(asHexData[i], 16); + if (isNaN(n)) { + Component.error("Resource data error (" + sURL + "): invalid hex byte (" + asHexData[i] + ")"); + break; + } + ab.push(n & 0xff); + } + if (i == asHexData.length) resource.aBytes = ab; + } + return resource; + } + + /** + * sendReport(sApp, sVer, sURL, sUser, sType, sReport, sHostName) + * + * Send a report (eg, bug report) to the server. + * + * @param {string} sApp (eg, "PCjs") + * @param {string} sVer (eg, "1.02") + * @param {string} sURL (eg, "/devices/pc/machine/5150/mda/64kb/machine.xml") + * @param {string} sUser (ie, the user key, if any) + * @param {string} sType (eg, "bug"); one of ReportAPI.TYPE.* + * @param {string} sReport (eg, unparsed state data) + * @param {string} [sHostName] (default is http://SITEHOST) + */ + static sendReport(sApp, sVer, sURL, sUser, sType, sReport, sHostName) + { + var dataPost = {}; + dataPost[ReportAPI.QUERY.APP] = sApp; + dataPost[ReportAPI.QUERY.VER] = sVer; + dataPost[ReportAPI.QUERY.URL] = sURL; + dataPost[ReportAPI.QUERY.USER] = sUser; + dataPost[ReportAPI.QUERY.TYPE] = sType; + dataPost[ReportAPI.QUERY.DATA] = sReport; + var sReportURL = (sHostName? sHostName : "http://" + SITEHOST) + ReportAPI.ENDPOINT; + Web.getResource(sReportURL, dataPost, true); + } + + /** + * getHost() + * + * @return {string} + */ + static getHost() + { + return ("http://" + (window? window.location.host : SITEHOST)); + } + + /** + * getHostURL() + * + * @return {string|null} + */ + static getHostURL() + { + return (window? window.location.href : null); + } + + /** + * getHostProtocol() + * + * @return {string} + */ + static getHostProtocol() + { + return (window? window.location.protocol : "file:"); + } + + /** + * getUserAgent() + * + * @return {string} + */ + static getUserAgent() + { + return (window? window.navigator.userAgent : ""); + } + + /** + * hasLocalStorage + * + * true if localStorage support exists, is enabled, and works; false otherwise + * + * @return {boolean} + */ + static hasLocalStorage() + { + if (Web.fLocalStorage == null) { + var f = false; + if (window) { + try { + window.localStorage.setItem(Web.sLocalStorageTest, Web.sLocalStorageTest); + f = (window.localStorage.getItem(Web.sLocalStorageTest) == Web.sLocalStorageTest); + window.localStorage.removeItem(Web.sLocalStorageTest); + } catch (e) { + Web.logLocalStorageError(e); + f = false; + } + } + Web.fLocalStorage = f; + } + return Web.fLocalStorage; + } + + /** + * logLocalStorageError(e) + * + * @param {Error} e is an exception + */ + static logLocalStorageError(e) + { + Web.log(e.message, "localStorage error"); + } + + /** + * getLocalStorageItem(sKey) + * + * Returns the requested key value, or null if the key does not exist, or undefined if localStorage is not available + * + * @param {string} sKey + * @return {string|null|undefined} sValue + */ + static getLocalStorageItem(sKey) + { + var sValue; + if (window) { + try { + sValue = window.localStorage.getItem(sKey); + } catch (e) { + Web.logLocalStorageError(e); + } + } + return sValue; + } + + /** + * setLocalStorageItem(sKey, sValue) + * + * @param {string} sKey + * @param {string} sValue + * @return {boolean} true if localStorage is available, false if not + */ + static setLocalStorageItem(sKey, sValue) + { + try { + window.localStorage.setItem(sKey, sValue); + return true; + } catch (e) { + Web.logLocalStorageError(e); + } + return false; + } + + /** + * removeLocalStorageItem(sKey) + * + * @param {string} sKey + */ + static removeLocalStorageItem(sKey) + { + try { + window.localStorage.removeItem(sKey); + } catch (e) { + Web.logLocalStorageError(e); + } + } + + /** + * getLocalStorageKeys() + * + * @return {Array} + */ + static getLocalStorageKeys() + { + var a = []; + try { + for (var i = 0, c = window.localStorage.length; i < c; i++) { + a.push(window.localStorage.key(i)); + } + } catch (e) { + Web.logLocalStorageError(e); + } + return a; + } + + /** + * reloadPage() + */ + static reloadPage() + { + if (window) window.location.reload(); + } + + /** + * isUserAgent(s) + * + * Check the browser's user-agent string for the given substring; "iOS" and "MSIE" are special values you can + * use that will match any iOS or MSIE browser, respectively (even IE11, in the case of "MSIE"). + * + * 2013-11-06: In a questionable move, MSFT changed the user-agent reported by IE11 on Windows 8.1, eliminating + * the "MSIE" string (which MSDN calls a "version token"; see http://msdn.microsoft.com/library/ms537503.aspx); + * they say "public websites should rely on feature detection, rather than browser detection, in order to design + * their sites for browsers that don't support the features used by the website." So, in IE11, we get a user-agent + * that tries to fool apps into thinking the browser is more like WebKit or Gecko: + * + * Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko + * + * That's a nice idea, but in the meantime, they hosed the XSL transform code in embed.js, which contained + * some very critical browser-specific code; turning on IE's "Compatibility Mode" didn't help either, because + * that's a sledgehammer solution which restores the old user-agent string but also disables other features like + * HTML5 canvas support. As an interim solution, I'm treating any "MSIE" check as a check for either "MSIE" or + * "Trident". + * + * UPDATE: I've since found ways to make the code in embed.js more browser-agnostic, so for now, there's isn't + * any code that cares about "MSIE", but I've left the change in place, because I wouldn't be surprised if I'll + * need more IE-specific code in the future, perhaps for things like copy/paste functionality, or mouse capture. + * + * @param {string} s is a substring to search for in the user-agent; as noted above, "iOS" and "MSIE" are special values + * @return {boolean} is true if the string was found, false if not + */ + static isUserAgent(s) + { + if (window) { + var userAgent = Web.getUserAgent(); + /* + * Here's one case where we have to be careful with Component, because when isUserAgent() is called by + * the init code below, component.js hasn't been loaded yet. The simple solution for now is to remove the call. + * + * Web.log("agent: " + userAgent); + * + * And yes, it would be pointless to use the conditional (?) operator below, if not for the Google Closure + * Compiler (v20130823) failing to detect the entire expression as a boolean. + */ + return s == "iOS" && !!userAgent.match(/(iPod|iPhone|iPad)/) && !!userAgent.match(/AppleWebKit/) || s == "MSIE" && !!userAgent.match(/(MSIE|Trident)/) || (userAgent.indexOf(s) >= 0); + } + return false; + } + + /** + * isMobile() + * + * Check the browser's user-agent string for the substring "Mobi", as per Mozilla recommendation: + * + * https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent + * + * @return {boolean} is true if the browser appears to be a mobile (ie, non-desktop) web browser, false if not + */ + static isMobile() + { + return Web.isUserAgent("Mobi"); + } + + /** + * 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 parseURLParms(sParms) + { + var aParms = {}; + if (window) { // an alternative to "if (typeof module === 'undefined')" if require("defines") was used + if (!sParms) { + /* + * Note that window.location.href returns the entire URL, whereas window.location.search + * returns only the parameters, if any (starting with the '?', which we skip over with a substr() call). + */ + sParms = window.location.search.substr(1); + } + var match; + var pl = /\+/g; // RegExp for replacing addition symbol with a space + var search = /([^&=]+)=?([^&]*)/g; + var decode = function(s) + { + return decodeURIComponent(s.replace(pl, " ")); + }; + + while ((match = search.exec(sParms))) { + aParms[decode(match[1])] = decode(match[2]); + } + } + return aParms; + } + + /** + * downloadFile(sData, sType, fBase64, sFileName) + * + * @param {string} sData + * @param {string} sType + * @param {boolean} [fBase64] + * @param {string} [sFileName] + */ + static downloadFile(sData, sType, fBase64, sFileName) + { + var link = null, sAlert; + var sURI = "data:application/" + sType + (fBase64? ";base64" : "") + ","; + + if (!Web.isUserAgent("Firefox")) { + sURI += (fBase64? sData : encodeURI(sData)); + } else { + sURI += (fBase64? sData : encodeURIComponent(sData)); + } + if (sFileName) { + link = document.createElement('a'); + if (typeof link.download != 'string') link = null; + } + if (link) { + link.href = sURI; + link.download = sFileName; + document.body.appendChild(link); // Firefox allegedly requires the link to be in the body + link.click(); + document.body.removeChild(link); + sAlert = 'Check your Downloads folder for ' + sFileName + '.'; + } else { + window.open(sURI); + sAlert = 'Check your browser for a new window/tab containing the requested data' + (sFileName? (' (' + sFileName + ')') : '') + '.'; + } + return sAlert; + } + + /** + * onCountRepeat(n, fnRepeat, fnComplete, msDelay) + * + * Call fnRepeat() n times with an msDelay millisecond delay between calls, + * then call fnComplete() when n has been exhausted OR fnRepeat() returns false. + * + * @param {number} n + * @param {function()} fnRepeat + * @param {function()} fnComplete + * @param {number} [msDelay] + */ + static onCountRepeat(n, fnRepeat, fnComplete, msDelay) + { + var fnTimeout = function doCountRepeat() + { + n -= 1; + if (n >= 0) { + if (!fnRepeat()) n = 0; + } + if (n > 0) { + setTimeout(fnTimeout, msDelay || 0); + return; + } + fnComplete(); + }; + fnTimeout(); + } + + /** + * onClickRepeat(e, msDelay, msRepeat, fn) + * + * Repeatedly call fn() with an initial msDelay, and an msRepeat delay thereafter, + * as long as HTML control Object e has an active "down" event and fn() returns true. + * + * @param {Object} e + * @param {number} msDelay + * @param {number} msRepeat + * @param {function(boolean)} fn is passed false on the first call, true on all repeated calls + */ + static onClickRepeat(e, msDelay, msRepeat, fn) + { + var ms = 0, timer = null, fIgnoreMouseEvents = false; + + var fnRepeat = function doClickRepeat() + { + if (fn(ms === msRepeat)) { + timer = setTimeout(fnRepeat, ms); + ms = msRepeat; + } + }; + e.onmousedown = function() + { + // Web.log("onMouseDown()"); + if (!fIgnoreMouseEvents) { + if (!timer) { + ms = msDelay; + fnRepeat(); + } + } + }; + e.ontouchstart = function() + { + // Web.log("onTouchStart()"); + if (!timer) { + ms = msDelay; + fnRepeat(); + } + }; + e.onmouseup = e.onmouseout = function() + { + // Web.log("onMouseUp()/onMouseOut()"); + if (timer) { + clearTimeout(timer); + timer = null; + } + }; + e.ontouchend = e.ontouchcancel = function() + { + // Web.log("onTouchEnd()/onTouchCancel()"); + if (timer) { + clearTimeout(timer); + timer = null; + } + /* + * Devices that generate ontouch* events ALSO generate onmouse* events, + * and generally do so immediately after all the touch events are complete, + * so unless we want double the action, we need to ignore mouse events. + */ + fIgnoreMouseEvents = true; }; } - if (dataPost && typeof dataPost == "object") { - var sDataPost = ""; - for (var p in dataPost) { - if (!dataPost.hasOwnProperty(p)) continue; - if (sDataPost) sDataPost += "&"; - sDataPost += p + '=' + encodeURIComponent(dataPost[p]); + /** + * onPageEvent(sName, fn) + * + * For 'onload', 'onunload', and 'onpageshow' events, most callers should NOT use this function, but + * instead use Web.onInit(), Web.onShow(), and Web.onExit(), respectively. + * + * The only components that should still use onPageEvent() are THIS component (see the bottom of this file) + * and components that need to capture other events (eg, the 'onresize' event in the Video component). + * + * This function creates a chain of callbacks, allowing multiple JavaScript modules to define handlers + * for the same event, which wouldn't be possible if everyone modified window['onload'], window['onunload'], + * etc, themselves. However, that's less of a concern now, because assuming everyone else is now using + * onInit(), onExit(), etc, then there really IS only one component setting the window callback: this one. + * + * NOTE: It's risky to refer to obscure event handlers with "dot" names, because the Closure Compiler may + * erroneously replace them (eg, window.onpageshow is a good example). + * + * @param {string} sFunc + * @param {function()} fn + */ + static onPageEvent(sFunc, fn) + { + if (window) { + var fnPrev = window[sFunc]; + if (typeof fnPrev !== 'function') { + window[sFunc] = fn; + } else { + /* + * TODO: Determine whether there's any value in receiving/sending the Event object that the + * browser provides when it generates the original event. + */ + window[sFunc] = function onWindowEvent() + { + if (fnPrev) fnPrev(); + fn(); + }; + } } - sDataPost = sDataPost.replace(/%20/g, '+'); - if (MAXDEBUG) web.log("web.getResource(POST " + sURL + "): " + sDataPost.length + " bytes"); - xmlHTTP.open("POST", sURL, !!fAsync); // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it) - xmlHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - xmlHTTP.send(sDataPost); - } else { - if (MAXDEBUG) web.log("web.getResource(GET " + sURL + ")"); - xmlHTTP.open("GET", sURL, !!fAsync); // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it) - if (dataPost == "bytes") { - xmlHTTP.overrideMimeType("text/plain; charset=x-user-defined"); - } - xmlHTTP.send(); - } - - if (!fAsync) { - sResource = xmlHTTP.responseText; - if (xmlHTTP.status == 200) { - if (MAXDEBUG) web.log("web.getResource(" + sURL + "): returned " + sResource.length + " bytes"); - } else { - nErrorCode = xmlHTTP.status || -1; - web.log("web.getResource(" + sURL + "): error code " + nErrorCode); - } - if (done) done(sURL, sResource, nErrorCode); - response = [sResource, nErrorCode]; - } - return response; -}; - -/** - * parseMemoryResource(sURL, sData) - * - * @param {string} sURL - * @param {string} sData - * @return {Object|null} (resource) - */ -web.parseMemoryResource = function(sURL, sData) -{ - var i; - var resource = { - aBytes: null, - aSymbols: null, - addrLoad: null, - addrExec: null }; - if (sData.charAt(0) == "[" || sData.charAt(0) == "{") { - try { - var a, ib, data; + /** + * onInit(fn) + * + * Use this instead of setting window.onload. Allows multiple JavaScript modules to define their own 'onload' event handler. + * + * @param {function()} fn + */ + static onInit(fn) + { + Web.aPageEventHandlers['init'].push(fn); + }; - if (sData.substr(0, 1) == "<") { // if the "data" begins with a "<"... - /* - * Early server configs reported an error (via the nErrorCode parameter) if a tape URL was invalid, - * but more recent server configs now display a somewhat friendlier HTML error page. The downside, - * however, is that the original error has been buried, and we've received "data" that isn't actually - * tape data. So if the data we've received appears to be "HTML-like", we treat it as an error message. - */ - throw new Error(sData); - } + /** + * onShow(fn) + * + * @param {function()} fn + * + * Use this instead of setting window.onpageshow. Allows multiple JavaScript modules to define their own 'onpageshow' event handler. + */ + static onShow(fn) + { + Web.aPageEventHandlers['show'].push(fn); + }; - /* - * TODO: IE9 is rather unfriendly and restrictive with regard to how much data it's willing to - * eval(). In particular, the 10Mb disk image we use for the Windows 1.01 demo config fails in - * IE9 with an "Out of memory" exception. One work-around would be to chop the data into chunks - * (perhaps one track per chunk, using regular expressions) and then manually re-assemble it. - * - * However, it turns out that using JSON.parse(sDiskData) instead of eval("(" + sDiskData + ")") - * is a much easier fix. The only drawback is that we must first quote any unquoted property names - * and remove any comments, because while eval() was cool with them, JSON.parse() is more particular; - * the following RegExp replacements take care of those requirements. - * - * The use of hex values is something else that eval() was OK with, but JSON.parse() is not, and - * while I've stopped using hex values in DumpAPI responses (at least when "format=json" is specified), - * I can't guarantee they won't show up in "legacy" images, and there's no simple RegExp replacement - * for transforming hex values into decimal values, so I cop out and fall back to eval() if I detect - * any hex prefixes ("0x") in the sequence. Ditto for error messages, which appear like so: - * - * ["unrecognized disk path: test.img"] - */ - if (sData.indexOf("0x") < 0 && sData.substr(0, 2) != "[\"") { - data = JSON.parse(sData.replace(/([a-z]+):/gm, "\"$1\":").replace(/\/\/[^\n]*/gm, "")); - } else { - data = eval("(" + sData + ")"); - } + /** + * onExit(fn) + * + * @param {function()} fn + * + * Use this instead of setting window.onunload. Allows multiple JavaScript modules to define their own 'onunload' event handler. + */ + static onExit(fn) + { + Web.aPageEventHandlers['exit'].push(fn); + }; - resource.addrLoad = data['load']; - resource.addrExec = data['exec']; - - if (a = data['bytes']) { - resource.aBytes = a; - } - else if (a = data['words']) { - /* - * Convert all words into bytes - */ - resource.aBytes = new Array(a.length * 2); - for (i = 0, ib = 0; i < a.length; i++) { - resource.aBytes[ib++] = a[i] & 0xff; - resource.aBytes[ib++] = (a[i] >> 8) & 0xff; - Component.assert(!(a[i] & ~0xffff)); + /** + * doPageEvent(afn) + * + * @param {Array.} afn + */ + static doPageEvent(afn) + { + if (Web.fPageEventsEnabled) { + try { + for (var i = 0; i < afn.length; i++) { + afn[i](); } + } catch (e) { + Web.notice("An unexpected exception occurred:\n\n" + e.message + "\n\nPlease send this information to support@pcjs.org. Thanks."); } - else if (a = data['data']) { - /* - * Convert all dwords (longs) into bytes - */ - resource.aBytes = new Array(a.length * 4); - for (i = 0, ib = 0; i < a.length; i++) { - resource.aBytes[ib++] = a[i] & 0xff; - resource.aBytes[ib++] = (a[i] >> 8) & 0xff; - resource.aBytes[ib++] = (a[i] >> 16) & 0xff; - resource.aBytes[ib++] = (a[i] >> 24) & 0xff; - } - } - else { - resource.aBytes = data; - } + } + }; - resource.aSymbols = data['symbols']; + /** + * enablePageEvents(fEnable) + * + * @param {boolean} fEnable is true to enable page events, false to disable (they're enabled by default) + */ + static enablePageEvents(fEnable) + { + if (!Web.fPageEventsEnabled && fEnable) { + Web.fPageEventsEnabled = true; + if (Web.fPageLoaded) Web.sendPageEvent('init'); + if (Web.fPageShowed) Web.sendPageEvent('show'); + return; + } + Web.fPageEventsEnabled = fEnable; + } - if (!resource.aBytes.length) { - Component.error("Empty resource: " + sURL); - resource = null; - } - else if (resource.aBytes.length == 1) { - Component.error(resource.aBytes[0]); - resource = null; - } - } catch (e) { - Component.error("Resource data error (" + sURL + "): " + e.message); - resource = null; + /** + * sendPageEvent(sEvent) + * + * This allows us to manually trigger page events. + * + * @param {string} sEvent (one of 'init', 'show' or 'exit') + */ + static sendPageEvent(sEvent) + { + if (Web.aPageEventHandlers[sEvent]) { + Web.doPageEvent(Web.aPageEventHandlers[sEvent]); } } - else { - /* - * Parse the data manually; we assume it's a series of hex byte-values separated by whitespace. - */ - var ab = []; - var sHexData = sData.replace(/\n/gm, " ").replace(/ +$/, ""); - var asHexData = sHexData.split(" "); - for (i = 0; i < asHexData.length; i++) { - var n = parseInt(asHexData[i], 16); - if (isNaN(n)) { - Component.error("Resource data error (" + sURL + "): invalid hex byte (" + asHexData[i] + ")"); - break; - } - ab.push(n & 0xff); - } - if (i == asHexData.length) resource.aBytes = ab; - } - return resource; +} + +Web.parmsURL = null; // initialized on first call to parseURLParms() + +Web.aPageEventHandlers = { + 'init': [], // list of window 'onload' handlers + 'show': [], // list of window 'onpageshow' handlers + 'exit': [] // list of window 'onunload' handlers (although we prefer to use 'onbeforeunload' if possible) }; -/** - * sendReport(sApp, sVer, sURL, sUser, sType, sReport, sHostName) - * - * Send a report (eg, bug report) to the server. - * - * @param {string} sApp (eg, "PCjs") - * @param {string} sVer (eg, "1.02") - * @param {string} sURL (eg, "/devices/pc/machine/5150/mda/64kb/machine.xml") - * @param {string} sUser (ie, the user key, if any) - * @param {string} sType (eg, "bug"); one of ReportAPI.TYPE.* - * @param {string} sReport (eg, unparsed state data) - * @param {string} [sHostName] (default is http://SITEHOST) - */ -web.sendReport = function(sApp, sVer, sURL, sUser, sType, sReport, sHostName) -{ - var dataPost = {}; - dataPost[ReportAPI.QUERY.APP] = sApp; - dataPost[ReportAPI.QUERY.VER] = sVer; - dataPost[ReportAPI.QUERY.URL] = sURL; - dataPost[ReportAPI.QUERY.USER] = sUser; - dataPost[ReportAPI.QUERY.TYPE] = sType; - dataPost[ReportAPI.QUERY.DATA] = sReport; - var sReportURL = (sHostName? sHostName : "http://" + SITEHOST) + ReportAPI.ENDPOINT; - web.getResource(sReportURL, dataPost, true); -}; - -/** - * getHost() - * - * @return {string} - */ -web.getHost = function() -{ - return ("http://" + (window? window.location.host : SITEHOST)); -}; - -/** - * getHostURL() - * - * @return {string|null} - */ -web.getHostURL = function() -{ - return (window? window.location.href : null); -}; - -/** - * getHostProtocol() - * - * @return {string} - */ -web.getHostProtocol = function() -{ - return (window? window.location.protocol : "file:"); -}; - -/** - * getUserAgent() - * - * @return {string} - */ -web.getUserAgent = function() -{ - return (window? window.navigator.userAgent : ""); -}; - -/** - * alertUser(sMessage) - * - * @param {string} sMessage - */ -web.alertUser = function(sMessage) -{ - if (window) window.alert(sMessage); else web.log(sMessage); -}; - -/** - * confirmUser(sPrompt) - * - * @param {string} sPrompt - * @returns {boolean} true if the user clicked OK, false if Cancel/Close - */ -web.confirmUser = function(sPrompt) -{ - var fResponse = false; - if (window) { - fResponse = window.confirm(sPrompt); - } - return fResponse; -}; - -/** - * promptUser() - * - * @param {string} sPrompt - * @param {string} [sDefault] - * @returns {string|null} - */ -web.promptUser = function(sPrompt, sDefault) -{ - var sResponse = null; - if (window) { - sResponse = window.prompt(sPrompt, sDefault === undefined? "" : sDefault); - } - return sResponse; -}; +Web.fPageLoaded = false; // set once the page's first 'onload' event has occurred +Web.fPageShowed = false; // set once the page's first 'onpageshow' event has occurred +Web.fPageEventsEnabled = true; // default is true, set to false (or true) by enablePageEvents() /** * fLocalStorage @@ -521,501 +947,27 @@ web.promptUser = function(sPrompt, sDefault) * * @type {boolean|null} */ -web.fLocalStorage = null; +Web.fLocalStorage = null; /** - * TODO: Is there any way to get the Closure Compiler to stop inlining this string? This - * isn't cutting it. + * TODO: Is there any way to get the Closure Compiler to stop inlining this string? This isn't cutting it. * * @const {string} */ -web.sLocalStorageTest = "PCjs.localStorage"; +Web.sLocalStorageTest = "PCjs.localStorage"; -/** - * hasLocalStorage - * - * true if localStorage support exists, is enabled, and works; false otherwise - * - * @return {boolean} - */ -web.hasLocalStorage = function() { - if (web.fLocalStorage == null) { - var f = false; - if (window) { - try { - window.localStorage.setItem(web.sLocalStorageTest, web.sLocalStorageTest); - f = (window.localStorage.getItem(web.sLocalStorageTest) == web.sLocalStorageTest); - window.localStorage.removeItem(web.sLocalStorageTest); - } catch(e) { - web.logLocalStorageError(e); - f = false; - } - } - web.fLocalStorage = f; - } - return web.fLocalStorage; -}; - -/** - * logLocalStorageError(e) - * - * @param {Error} e is an exception - */ -web.logLocalStorageError = function(e) -{ - web.log(e.message, "localStorage error"); -}; - -/** - * getLocalStorageItem(sKey) - * - * Returns the requested key value, or null if the key does not exist, or undefined if localStorage is not available - * - * @param {string} sKey - * @return {string|null|undefined} sValue - */ -web.getLocalStorageItem = function(sKey) -{ - var sValue; - if (window) { - try { - sValue = window.localStorage.getItem(sKey); - } catch(e) { - web.logLocalStorageError(e); - } - } - return sValue; -}; - -/** - * setLocalStorageItem(sKey, sValue) - * - * @param {string} sKey - * @param {string} sValue - * @return {boolean} true if localStorage is available, false if not - */ -web.setLocalStorageItem = function(sKey, sValue) -{ - try { - window.localStorage.setItem(sKey, sValue); - return true; - } catch(e) { - web.logLocalStorageError(e); - } - return false; -}; - -/** - * removeLocalStorageItem(sKey) - * - * @param {string} sKey - */ -web.removeLocalStorageItem = function(sKey) -{ - try { - window.localStorage.removeItem(sKey); - } catch(e) { - web.logLocalStorageError(e); - } -}; - -/** - * getLocalStorageKeys() - * - * @return {Array} - */ -web.getLocalStorageKeys = function() -{ - var a = []; - try { - for (var i = 0, c = window.localStorage.length; i < c; i++) { - a.push(window.localStorage.key(i)); - } - } catch(e) { - web.logLocalStorageError(e); - } - return a; -}; - -/** - * reloadPage() - */ -web.reloadPage = function() -{ - if (window) window.location.reload(); -}; - -/** - * isUserAgent(s) - * - * Check the browser's user-agent string for the given substring; "iOS" and "MSIE" are special values you can - * use that will match any iOS or MSIE browser, respectively (even IE11, in the case of "MSIE"). - * - * 2013-11-06: In a questionable move, MSFT changed the user-agent reported by IE11 on Windows 8.1, eliminating - * the "MSIE" string (which MSDN calls a "version token"; see http://msdn.microsoft.com/library/ms537503.aspx); - * they say "public websites should rely on feature detection, rather than browser detection, in order to design - * their sites for browsers that don't support the features used by the website." So, in IE11, we get a user-agent - * that tries to fool apps into thinking the browser is more like WebKit or Gecko: - * - * Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko - * - * That's a nice idea, but in the meantime, they hosed the XSL transform code in embed.js, which contained - * some very critical browser-specific code; turning on IE's "Compatibility Mode" didn't help either, because - * that's a sledgehammer solution which restores the old user-agent string but also disables other features like - * HTML5 canvas support. As an interim solution, I'm treating any "MSIE" check as a check for either "MSIE" or - * "Trident". - * - * UPDATE: I've since found ways to make the code in embed.js more browser-agnostic, so for now, there's isn't - * any code that cares about "MSIE", but I've left the change in place, because I wouldn't be surprised if I'll - * need more IE-specific code in the future, perhaps for things like copy/paste functionality, or mouse capture. - * - * @param {string} s is a substring to search for in the user-agent; as noted above, "iOS" and "MSIE" are special values - * @return {boolean} is true if the string was found, false if not - */ -web.isUserAgent = function(s) -{ - if (window) { - var userAgent = web.getUserAgent(); - /* - * Here's one case where we have to be careful with Component, because when isUserAgent() is called by - * the init code below, component.js hasn't been loaded yet. The simple solution for now is to remove the call. - * - * web.log("agent: " + userAgent); - * - * And yes, it would be pointless to use the conditional (?) operator below, if not for the Google Closure - * Compiler (v20130823) failing to detect the entire expression as a boolean. - */ - return (s == "iOS" && userAgent.match(/(iPod|iPhone|iPad)/) && userAgent.match(/AppleWebKit/) || s == "MSIE" && userAgent.match(/(MSIE|Trident)/) || (userAgent.indexOf(s) >= 0))? true : false; - } - return false; -}; - -/** - * isMobile() - * - * Check the browser's user-agent string for the substring "Mobi", as per Mozilla recommendation: - * - * https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent - * - * @return {boolean} is true if the browser appears to be a mobile (ie, non-desktop) web browser, false if not - */ -web.isMobile = function() -{ - return web.isUserAgent("Mobi"); -}; - -/** - * 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.parseURLParms = function(sParms) -{ - var aParms = {}; - if (window) { // an alternative to "if (typeof module === 'undefined')" if require("defines") was used - if (!sParms) { - /* - * Note that window.location.href returns the entire URL, whereas window.location.search - * returns only the parameters, if any (starting with the '?', which we skip over with a substr() call). - */ - sParms = window.location.search.substr(1); - } - var match; - var pl = /\+/g; // RegExp for replacing addition symbol with a space - var search = /([^&=]+)=?([^&]*)/g; - var decode = function(s) { return decodeURIComponent(s.replace(pl, " ")); }; - - while ((match = search.exec(sParms))) { - aParms[decode(match[1])] = decode(match[2]); - } - } - return aParms; -}; - -/** - * downloadFile(sData, sType, fBase64, sFileName) - * - * @param {string} sData - * @param {string} sType - * @param {boolean} [fBase64] - * @param {string} [sFileName] - */ -web.downloadFile = function(sData, sType, fBase64, sFileName) -{ - var link = null, sAlert; - var sURI = "data:application/" + sType + (fBase64? ";base64" : "") + ","; - - if (!web.isUserAgent("Firefox")) { - sURI += (fBase64? sData : encodeURI(sData)); - } else { - sURI += (fBase64? sData : encodeURIComponent(sData)); - } - if (sFileName) { - link = document.createElement('a'); - if (typeof link.download != 'string') link = null; - } - if (link) { - link.href = sURI; - link.download = sFileName; - document.body.appendChild(link); // Firefox allegedly requires the link to be in the body - link.click(); - document.body.removeChild(link); - sAlert = 'Check your Downloads folder for ' + sFileName + '.'; - } else { - window.open(sURI); - sAlert = 'Check your browser for a new window/tab containing the requested data' + (sFileName? (' (' + sFileName + ')') : '') + '.'; - } - return sAlert; -}; - -/** - * onCountRepeat(n, fnRepeat, fnComplete, msDelay) - * - * Call fnRepeat() n times with an msDelay millisecond delay between calls, - * then call fnComplete() when n has been exhausted OR fnRepeat() returns false. - * - * @param {number} n - * @param {function()} fnRepeat - * @param {function()} fnComplete - * @param {number} [msDelay] - */ -web.onCountRepeat = function(n, fnRepeat, fnComplete, msDelay) -{ - var fnTimeout = function doCountRepeat() { - n -= 1; - if (n >= 0) { - if (!fnRepeat()) n = 0; - } - if (n > 0) { - setTimeout(fnTimeout, msDelay || 0); - return; - } - fnComplete(); - }; - fnTimeout(); -}; - -/** - * onClickRepeat(e, msDelay, msRepeat, fn) - * - * Repeatedly call fn() with an initial msDelay, and an msRepeat delay thereafter, - * as long as HTML control Object e has an active "down" event and fn() returns true. - * - * @param {Object} e - * @param {number} msDelay - * @param {number} msRepeat - * @param {function(boolean)} fn is passed false on the first call, true on all repeated calls - */ -web.onClickRepeat = function(e, msDelay, msRepeat, fn) -{ - var ms = 0, timer = null, fIgnoreMouseEvents = false; - - var fnRepeat = function doClickRepeat() { - if (fn(ms === msRepeat)) { - timer = setTimeout(fnRepeat, ms); - ms = msRepeat; - } - }; - e.onmousedown = function() { - // web.log("onMouseDown()"); - if (!fIgnoreMouseEvents) { - if (!timer) { - ms = msDelay; - fnRepeat(); - } - } - }; - e.ontouchstart = function() { - // web.log("onTouchStart()"); - if (!timer) { - ms = msDelay; - fnRepeat(); - } - }; - e.onmouseup = e.onmouseout = function() { - // web.log("onMouseUp()/onMouseOut()"); - if (timer) { - clearTimeout(timer); - timer = null; - } - }; - e.ontouchend = e.ontouchcancel = function() { - // web.log("onTouchEnd()/onTouchCancel()"); - if (timer) { - clearTimeout(timer); - timer = null; - } - /* - * Devices that generate ontouch* events ALSO generate onmouse* events, - * and generally do so immediately after all the touch events are complete, - * so unless we want double the action, we need to ignore mouse events. - */ - fIgnoreMouseEvents = true; - }; -}; - -web.parmsURL = null; // initialized on first call to parseURLParms() - -web.aPageEventHandlers = { - 'init': [], // list of window 'onload' handlers - 'show': [], // list of window 'onpageshow' handlers - 'exit': [] // list of window 'onunload' handlers (although we prefer to use 'onbeforeunload' if possible) -}; - -web.fPageLoaded = false; // set once the page's first 'onload' event has occurred -web.fPageShowed = false; // set once the page's first 'onpageshow' event has occurred -web.fPageEventsEnabled = true; // default is true, set to false (or true) by enablePageEvents() - -/** - * onPageEvent(sName, fn) - * - * For 'onload', 'onunload', and 'onpageshow' events, most callers should NOT use this function, but - * instead use web.onInit(), web.onShow(), and web.onExit(), respectively. - * - * The only components that should still use onPageEvent() are THIS component (see the bottom of this file) - * and components that need to capture other events (eg, the 'onresize' event in the Video component). - * - * This function creates a chain of callbacks, allowing multiple JavaScript modules to define handlers - * for the same event, which wouldn't be possible if everyone modified window['onload'], window['onunload'], - * etc, themselves. However, that's less of a concern now, because assuming everyone else is now using - * onInit(), onExit(), etc, then there really IS only one component setting the window callback: this one. - * - * NOTE: It's risky to refer to obscure event handlers with "dot" names, because the Closure Compiler may - * erroneously replace them (eg, window.onpageshow is a good example). - * - * @param {string} sFunc - * @param {function()} fn - */ -web.onPageEvent = function(sFunc, fn) -{ - if (window) { - var fnPrev = window[sFunc]; - if (typeof fnPrev !== 'function') { - window[sFunc] = fn; - } else { - /* - * TODO: Determine whether there's any value in receiving/sending the Event object that the - * browser provides when it generates the original event. - */ - window[sFunc] = function onWindowEvent() { - if (fnPrev) fnPrev(); - fn(); - }; - } - } -}; - -/** - * onInit(fn) - * - * Use this instead of setting window.onload. Allows multiple JavaScript modules to define their own 'onload' event handler. - * - * @param {function()} fn - */ -web.onInit = function(fn) -{ - web.aPageEventHandlers['init'].push(fn); -}; - -/** - * onShow(fn) - * - * @param {function()} fn - * - * Use this instead of setting window.onpageshow. Allows multiple JavaScript modules to define their own 'onpageshow' event handler. - */ -web.onShow = function(fn) -{ - web.aPageEventHandlers['show'].push(fn); -}; - -/** - * onExit(fn) - * - * @param {function()} fn - * - * Use this instead of setting window.onunload. Allows multiple JavaScript modules to define their own 'onunload' event handler. - */ -web.onExit = function(fn) -{ - web.aPageEventHandlers['exit'].push(fn); -}; - -/** - * doPageEvent(afn) - * - * @param {Array.} afn - */ -web.doPageEvent = function(afn) -{ - if (web.fPageEventsEnabled) { - try { - for (var i = 0; i < afn.length; i++) { - afn[i](); - } - } catch(e) { - web.notice("An unexpected exception occurred:\n\n" + e.message + "\n\nPlease send this information to support@pcjs.org. Thanks."); - } - } -}; - -/** - * enablePageEvents(fEnable) - * - * @param {boolean} fEnable is true to enable page events, false to disable (they're enabled by default) - */ -web.enablePageEvents = function(fEnable) -{ - if (!web.fPageEventsEnabled && fEnable) { - web.fPageEventsEnabled = true; - if (web.fPageLoaded) web.sendPageEvent('init'); - if (web.fPageShowed) web.sendPageEvent('show'); - return; - } - web.fPageEventsEnabled = fEnable; -}; - -/** - * sendPageEvent(sEvent) - * - * This allows us to manually trigger page events. - * - * @param {string} sEvent (one of 'init', 'show' or 'exit') - */ -web.sendPageEvent = function(sEvent) -{ - if (web.aPageEventHandlers[sEvent]) { - web.doPageEvent(web.aPageEventHandlers[sEvent]); - } -}; - -web.onPageEvent('onload', function onPageLoad() { - web.fPageLoaded = true; - web.doPageEvent(web.aPageEventHandlers['init']); +Web.onPageEvent('onload', function onPageLoad() { + Web.fPageLoaded = true; + Web.doPageEvent(Web.aPageEventHandlers['init']); }); -web.onPageEvent('onpageshow', function onPageShow() { - web.fPageShowed = true; - web.doPageEvent(web.aPageEventHandlers['show']); +Web.onPageEvent('onpageshow', function onPageShow() { + Web.fPageShowed = true; + Web.doPageEvent(Web.aPageEventHandlers['show']); }); -web.onPageEvent(web.isUserAgent("Opera") || web.isUserAgent("iOS")? 'onunload' : 'onbeforeunload', function onPageUnload() { - web.doPageEvent(web.aPageEventHandlers['exit']); +Web.onPageEvent(Web.isUserAgent("Opera") || Web.isUserAgent("iOS")? 'onunload' : 'onbeforeunload', function onPageUnload() { + Web.doPageEvent(Web.aPageEventHandlers['exit']); }); -if (NODE) module.exports = web; +if (NODE) module.exports = Web; diff --git a/package.json b/package.json index e9f0d1555..a8e91475a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pcjs", - "version": "1.32.2", + "version": "1.33.0", "description": "Node-enabled version of PCjs", "license": "GPL-3.0", "engine": "node ^6.7.0", @@ -144,15 +144,15 @@ "./modules/shared/lib/save.js" ], "pc8080Files": [ - "./modules/shared/es6/defines.js", - "./modules/shared/es6/dumpapi.js", - "./modules/shared/es6/reportapi.js", - "./modules/shared/es6/userapi.js", - "./modules/shared/es6/keys.js", - "./modules/shared/es6/component.js", - "./modules/shared/es6/strlib.js", - "./modules/shared/es6/usrlib.js", - "./modules/shared/es6/weblib.js", + "./modules/shared/lib/defines.js", + "./modules/shared/lib/dumpapi.js", + "./modules/shared/lib/reportapi.js", + "./modules/shared/lib/userapi.js", + "./modules/shared/lib/keys.js", + "./modules/shared/lib/component.js", + "./modules/shared/lib/strlib.js", + "./modules/shared/lib/usrlib.js", + "./modules/shared/lib/weblib.js", "./modules/pc8080/lib/defines.js", "./modules/pc8080/lib/cpudef.js", "./modules/pc8080/lib/messages.js", @@ -168,23 +168,23 @@ "./modules/pc8080/lib/keyboard.js", "./modules/pc8080/lib/video.js", "./modules/pc8080/lib/serial.js", - "./modules/shared/es6/debugger.js", + "./modules/shared/lib/debugger.js", "./modules/pc8080/lib/debugger.js", "./modules/pc8080/lib/computer.js", - "./modules/shared/es6/state.js", - "./modules/shared/es6/embed.js" + "./modules/shared/lib/state.js", + "./modules/shared/lib/embed.js" ], "pdp11Files": [ - "./modules/shared/es6/defines.js", - "./modules/shared/es6/diskapi.js", - "./modules/shared/es6/dumpapi.js", - "./modules/shared/es6/reportapi.js", - "./modules/shared/es6/userapi.js", - "./modules/shared/es6/keys.js", - "./modules/shared/es6/component.js", - "./modules/shared/es6/strlib.js", - "./modules/shared/es6/usrlib.js", - "./modules/shared/es6/weblib.js", + "./modules/shared/lib/defines.js", + "./modules/shared/lib/diskapi.js", + "./modules/shared/lib/dumpapi.js", + "./modules/shared/lib/reportapi.js", + "./modules/shared/lib/userapi.js", + "./modules/shared/lib/keys.js", + "./modules/shared/lib/component.js", + "./modules/shared/lib/strlib.js", + "./modules/shared/lib/usrlib.js", + "./modules/shared/lib/weblib.js", "./modules/pdp11/lib/defines.js", "./modules/pdp11/lib/messages.js", "./modules/pdp11/lib/panel.js", @@ -203,10 +203,10 @@ "./modules/pdp11/lib/drive.js", "./modules/pdp11/lib/rk11.js", "./modules/pdp11/lib/rl11.js", - "./modules/shared/es6/debugger.js", + "./modules/shared/lib/debugger.js", "./modules/pdp11/lib/debugger.js", "./modules/pdp11/lib/computer.js", - "./modules/shared/es6/state.js", - "./modules/shared/es6/embed.js" + "./modules/shared/lib/state.js", + "./modules/shared/lib/embed.js" ] } diff --git a/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine-debugger.xml b/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine-debugger.xml index 0778271b4..6e6f55ffd 100644 --- a/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine-debugger.xml +++ b/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine-debugger.xml @@ -1,5 +1,5 @@ - + IBM PC XT (Model 5160), CGA, 256Kb, 10Mb Drive diff --git a/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine.xml b/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine.xml index c01989144..2e87cf171 100644 --- a/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine.xml +++ b/pubs/pc/programming/Graphics_for_the_IBM_PC/demos/machine.xml @@ -1,5 +1,5 @@ - + IBM PC XT (Model 5160), CGA, 256Kb, 10Mb Drive diff --git a/pubs/pc/programming/manifest.xml b/pubs/pc/programming/manifest.xml index 43017942c..db3fdc809 100644 --- a/pubs/pc/programming/manifest.xml +++ b/pubs/pc/programming/manifest.xml @@ -1,5 +1,5 @@ - + PC Programming Guides diff --git a/pubs/pc/reference/ibm/5150/techref/manifest.xml b/pubs/pc/reference/ibm/5150/techref/manifest.xml index fb60bd7e6..51420f97e 100644 --- a/pubs/pc/reference/ibm/5150/techref/manifest.xml +++ b/pubs/pc/reference/ibm/5150/techref/manifest.xml @@ -1,5 +1,5 @@ - + IBM 5150 Technical Reference minuszerodegrees.net diff --git a/pubs/pc/reference/ibm/5160/techref/manifest.xml b/pubs/pc/reference/ibm/5160/techref/manifest.xml index 42be70b01..002941e20 100644 --- a/pubs/pc/reference/ibm/5160/techref/manifest.xml +++ b/pubs/pc/reference/ibm/5160/techref/manifest.xml @@ -1,5 +1,5 @@ - + IBM 5160 Technical Reference retroarchive.org diff --git a/pubs/pc/reference/ibm/5170/setup/manifest.xml b/pubs/pc/reference/ibm/5170/setup/manifest.xml index 61c9e62bc..e5a793c90 100644 --- a/pubs/pc/reference/ibm/5170/setup/manifest.xml +++ b/pubs/pc/reference/ibm/5170/setup/manifest.xml @@ -1,5 +1,5 @@ - + IBM 5170 Installation and Setup minuszerodegrees.net diff --git a/pubs/pc/reference/ibm/5170/techref/manifest.xml b/pubs/pc/reference/ibm/5170/techref/manifest.xml index bc59fe215..b2df28a8f 100644 --- a/pubs/pc/reference/ibm/5170/techref/manifest.xml +++ b/pubs/pc/reference/ibm/5170/techref/manifest.xml @@ -1,5 +1,5 @@ - + IBM 5170 Technical Reference minuszerodegrees.net diff --git a/pubs/pc/reference/ibm/ps2/manifest.xml b/pubs/pc/reference/ibm/ps2/manifest.xml index 112d005d3..f54f8705d 100644 --- a/pubs/pc/reference/ibm/ps2/manifest.xml +++ b/pubs/pc/reference/ibm/ps2/manifest.xml @@ -1,5 +1,5 @@ - + PS/2 Technical Reference diff --git a/pubs/pc/reference/ibm/video/ega/manifest.xml b/pubs/pc/reference/ibm/video/ega/manifest.xml index a3ce570b6..d472c5ef0 100644 --- a/pubs/pc/reference/ibm/video/ega/manifest.xml +++ b/pubs/pc/reference/ibm/video/ega/manifest.xml @@ -1,5 +1,5 @@ - + IBM Enhanced Graphics Adapter minuszerodegrees.net diff --git a/pubs/pc/reference/intel/80286/manifest.xml b/pubs/pc/reference/intel/80286/manifest.xml index fc62bda41..fa537debb 100644 --- a/pubs/pc/reference/intel/80286/manifest.xml +++ b/pubs/pc/reference/intel/80286/manifest.xml @@ -1,5 +1,5 @@ - + Intel 80286 References diff --git a/pubs/pc/software/os2/microsoft/sdk10/manifest.xml b/pubs/pc/software/os2/microsoft/sdk10/manifest.xml index d02226971..975fd26e4 100644 --- a/pubs/pc/software/os2/microsoft/sdk10/manifest.xml +++ b/pubs/pc/software/os2/microsoft/sdk10/manifest.xml @@ -1,5 +1,5 @@ - + OS/2 1.0 Programmer's Toolkit 1.0 diff --git a/pubs/pc/software/windows/sdk200/manifest.xml b/pubs/pc/software/windows/sdk200/manifest.xml index 3690f38be..ec67e8dba 100644 --- a/pubs/pc/software/windows/sdk200/manifest.xml +++ b/pubs/pc/software/windows/sdk200/manifest.xml @@ -1,5 +1,5 @@ - + Microsoft Windows Software Development Kit 2.00 diff --git a/versions/pcx86/1.33.0/common.css b/versions/pcx86/1.33.0/common.css new file mode 100644 index 000000000..a569abc64 --- /dev/null +++ b/versions/pcx86/1.33.0/common.css @@ -0,0 +1,278 @@ +@CHARSET "UTF-8"; +/** + @author Jeff Parsons (@jeffpar) + @website http://www.pcjs.org/ + @created 2013-05-05 + @modified 2014-02-23 + @license http://www.gnu.org/licenses/gpl.html + */ +body { + margin: 0; + background: #202020; +} +h1, h2 { + margin-top: 0; + color: #cccccc; +} +h1, h2, h3, h4 { + word-wrap: break-word; +} + +h4 a { + color: #cccccc !important; +} +p { + line-height: 1.5em; +} +img { + max-width: 100%; +} +a img { + vertical-align: bottom; +} +pre, code { + color: #000000; + background-color: #cccccc; + font-family: Monaco, Consolas, "Lucida Console", monospace; + font-size: 12px; +} +pre { + margin: 1em 2em; + padding: 1em; + border-radius: 5px; + overflow: auto; +} +code { + padding: 1px; +} +pre a, code a { + color: #006400 !important; +} +.common { + width: 100%; + margin: 0 auto; + color: #cccccc; +} +.common a { + + color: #7fc07f; + text-decoration: none; +} +.common hr { + border-color: #808080; +} +.common a:hover { + text-decoration: underline; +} +.common, .machine { + font-family: "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif; + font-size: 15px; +} +.machine { + + overflow: hidden; +} +.c1pjs { + overflow: visible; +} +.machine-placeholder { + text-align: center; + font-weight: bold; +} +.machine-floating { + position: relative; + z-index: auto; + background-color: transparent; + padding-right: 0; +} +.machine-sticky { + position: fixed !important; + z-index: 1 !important; + background-color: #404040 !important; + padding-right: 16px !important; + top: 0 !important; +} +.common-top { + background: #202020; + font-size: small; +} +.common-top-left { + float: left; + width: 60%; +} +.common-top-left ul { + line-height: 1.5em; + list-style-type: none; + margin: 0; + padding: 1em 1em 1em 9px; + overflow: hidden; +} +.common-top-left ul li { + display: block; + float: left; +} +.common-top-left ul li a { + border-right: 1px solid #6f6f6f; + padding: 2px 6px 2px 6px; +} +.common-top-left ul li:last-child a { + border-right: none; +} +.common-top-right { + float: right; + width: 40%; +} +.common-top-right p { + float: right; + margin: 0; + padding: 1em; +} +.common-middle { + clear: both; + padding: 1px 1em 1px 1em; + background: #404040; +} +.common-sidebar { + float: left; + font-size: small; + width: 140px; + padding-bottom: 20px; + overflow: hidden; + white-space: nowrap; + word-wrap: break-word; +} +.common-list { + list-style-type: none; + margin-top: 0; + margin-bottom: 0; + padding-left: 0; +} +.common-list li { + + padding-bottom: 7px; +} +.common-list-data { + list-style-type: none; + margin-top: 0; + margin-bottom: 0; + padding-left: 0; +} +.common-list-data li { + line-height: 1.5em; +} +.common-list-data-items, .common-list-data-subitems { + font-size: x-small; + list-style-type: none; + margin-top: 0; + margin-bottom: 0; + padding-left: 2em; +} +.common-list-data-items li, .common-list-data-subitems li { + padding-bottom: 0; +} +.common-main { + margin-left: 150px; + +} +.common-main blockquote { + text-align: justify; +} +.common-image-gallery { + margin: 0 auto; + text-align: center; +} +.common-image-gallery:after { + content: ''; + display: block; +} +.common-image-frame { + display: inline-block; + margin: 8px; + text-align: center; +} +.common-image-link { + padding: 5px; + border: 1px solid black; + border-radius: 5px; + background-color: #FAEBD7; +} +.common-image-label { + font-size: x-small; +} +.common-bottom { + clear: both; + padding-top: 1em; +} +.common-bottom:after { + content: ''; + display: block; + clear: both; +} +.common-reference { + float: left; + font-size: x-small; +} +.common-reference a { + text-decoration: none; +} +.common-copyright { + float: right; + font-size: x-small; +} +.common-copyright a { + text-decoration: none; +} +.md-list { +} +.md-list li { + line-height: 1.5em; + margin-bottom: 1em; +} +.md-list li p { + padding-left: 2em; +} +.md-list-compact { +} +.md-list-compact li { + margin-bottom: 0; +} +.md-list-none { + list-style-type: none; + padding-left: 2em; +} +.md-list-none li { + margin-bottom: 0; +} +@media screen and (max-width: 900px) { + + .common-sidebar { + width: 100%; + white-space: normal; + } + .common-list { + padding-left: 0; + } + .common-list-data { + padding-left: 0; + } + .common-sidebar h4, .common-list li, .common-list-data li, .common-list-data-items li { + width: 130px; + float: left; + overflow: hidden; + vertical-align: top; + padding-right: 1em; + margin-top: 0; + } + .common-list-data-subitems { + display: none; + } + .common-main { + clear: both; + margin-left: 0; + padding-left: 0; + padding-right: 0; + } + .md-list-none { + padding-left: 1em; + } +} diff --git a/versions/pcx86/1.33.0/common.xsl b/versions/pcx86/1.33.0/common.xsl new file mode 100644 index 000000000..c992ed17f --- /dev/null +++ b/versions/pcx86/1.33.0/common.xsl @@ -0,0 +1,56 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+

Powered by JavaScript, Vanilla JS, and GitHub

+
+
+
+ + +
+

+ +
+
+ +
diff --git a/versions/pcx86/1.33.0/components.css b/versions/pcx86/1.33.0/components.css new file mode 100644 index 000000000..283fddcd6 --- /dev/null +++ b/versions/pcx86/1.33.0/components.css @@ -0,0 +1,257 @@ +@CHARSET "UTF-8"; + + +*:not(input,textarea) { + -webkit-user-select: none; +} +.pcjs-embed { +} +.pcjs-embed:after { + clear:both; +} +.pcjs-machine { +} +.pcjs-name, .pcjs-menu { + clear: both; + font-weight: bold; + padding-bottom: 4px; +} +.pcjs-menu { + float: left; +} +.pcjs-canvas { + width: 100%; + height: auto; +} +.pcjs-container { + color: #000000; + position: relative; +} +.pcjs-label { + font-size: small; + line-height: 20px; + vertical-align: middle; + float: left; + font-family: Monaco, "Lucida Console", monospace; +} +.pcjs-controls textarea { + font-family: Monaco, "Lucida Console", monospace; + font-size: x-small; +} +.pcjs-fieldset { + border: none; + margin: 0; + padding: 0; +} +.pcjs-flag { + font-family: Monaco, "Lucida Console", monospace; + font-size: small; + text-align: center; + line-height: 20px; + vertical-align: middle; +} +.pcjs-progress { + height: 20px; + width: 200px; + margin-top: 8px; + border: 1px solid black; + position: relative; +} +.pcjs-progress-bar { + height: 20px; + width: 0; + background-color: gold; + position: absolute; + top: 0; +} +.pcjs-progress-text { + height: 20px; + width: 200px; + font-size: small; + line-height: 20px; + text-align: center; + position: absolute; + top: 0; + z-index: 1; +} +.pcjs-register { + font-family: Monaco, "Lucida Console", monospace; + font-size: small; + text-align: center; + line-height: 20px; + vertical-align: middle; + border: 1px solid black; +} +.pcjs-switches { + float: left; +} +.pcjs-bitBucket { + float: left; + width: 19px; + height: 38px; +} +.pcjs-bitCell { + float: left; + width: 19px; + height: 19px; + margin-right: -1px; + margin-bottom: -1px; + border: 1px solid black; + text-align: center; + line-height: 19px; +} +.pcjs-bitCellLeft { + border-left: 1px solid black; +} +.pcjs-bitLabel { + font-size: xx-small; + text-align: center; +} +.pcjs-description, .pcjs-status { + font-size: x-small; + line-height: 2.8em; +} +.pcjs-key { + border: 1px solid black; + font-size: x-small; + text-align: center; + position: absolute; + height: 34px; + line-height: 34px; + background-color: #ffffff; +} +.pcjs-panel-group { + color: #ffffff; + background-color: #404040; +} +.pcjs-triplet { + padding: 1px; +} +.pcjs-ledlbl { + text-align: center; + font-size: 40%; + background-color: #000000; +} +.pcjs-ledlbl0 { + text-align: right; + font-size: 50%; + background-color: #8d4076; +} +.pcjs-ledlbl1 { + text-align: right; + font-size: 50%; + background-color: #d83662; +} +.pcjs-ledpad { + text-align: center; + font-size: x-small; + line-height: 32px; + background-color: #000000; + border-bottom-left-radius: 20%; + border-bottom-right-radius: 20%; +} +.pcjs-led { + float: left; + width: 8px; + height: 8px; + margin: 4px; + border: 1px solid black; + text-align: center; + vertical-align: middle; + background-color: #000000; +} +.pcjs-rled { + float: left; + width: 8px; + height: 8px; + margin: 4px; + border: 1px solid black; + border-radius: 50%; + text-align: center; + vertical-align: middle; + background-color: #ff0000; + max-width: 50%; + max-height: 50%; +} +.pcjs-swlbl { + text-align: center; + font-size: 40%; + line-height: 16px; + background-color: #000000; + border-top-left-radius: 20%; + border-top-right-radius: 20%; +} +.pcjs-swpad { + height: 32px; + background-color: #000000; +} +.pcjs-switch { + height: 10px; + width: 28px; + margin-top: 0; + max-width: 90%; + background-color: #00ff00; +} +.pcjs-screen { + clear: both; + height: auto; + position: relative; + line-height: 0; +} +.pcjs-screen textarea { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + opacity: 0; + border: 0; + padding: 0; + line-height: 0; +} +.pcjs-reference { + float: left; + font-size: x-small; +} +.pcjs-reference a { + text-decoration: none; +} +.pcjs-copyright { + float: right; + font-size: x-small; +} +.pcjs-copyright a { + text-decoration: none; +} +@media screen and (max-width: 800px) { + .pcjs-textarea { + width: 100% !important; + } + .pcjs-registers { + width: 100% !important; + max-width: none !important; + padding-left: 0 !important; + padding-right: 0 !important; + } + .pdp11-device { + width: 98% !important; + max-width: none !important; + margin-left: 8px !important; + padding-left: 0 !important; + padding-right: 0 !important; + } +} +@media screen and (min-width: 1200px) { + .machine-left { + max-width: 48%; + float: left; + } + .machine-right { + max-width: 48%; + float: left; + margin-left: 30px; + } + .machine-right + * { + clear: both; + } +} diff --git a/versions/pcx86/1.33.0/components.xsl b/versions/pcx86/1.33.0/components.xsl new file mode 100644 index 000000000..ea17df7f1 --- /dev/null +++ b/versions/pcx86/1.33.0/components.xsl @@ -0,0 +1,1383 @@ + + + +]> + + + + + + + + pc + pcjs + pcx86 + PCx86 + 1.33.0 + www.pcjs.org + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + float: + + + + + + + js + + + +
+ + + + + + + + + + js + + + "" + + + + + +
+
+ + + + + + + + + + + + + + + , + + + + + + + + + + + + + .machine + . + . + + + + + + + + + + + + + + + + + + + + ,comment:'' + + + + + + border:1px solid black;border-radius:15px; + border:; + + + + + + left:; + + + + + + top:; + + + + + + + + width:; + width:;max-width:; + width:auto;max-width:; + + + + + + + + height:; + + + + + + padding:; + + padding-top:; + padding-right:; + padding-bottom:; + padding-left:; + + + + + + float:left; + float:right; + margin:0 auto;clear:both; + position:; + position:relative; + + + + + overflow:auto;width:100%; + background-color:; + + + + - -component + +
+ + + + + + +
+ + + + + + + + --object -screen + + +
+
+ +
+ +
+
+ + + + +
+ + +
[XML]
+ +
+ + +
+
+
+
+ + + + + text-align:center; + + + +

+
+ + +
+
+ + + + + + +
+
+ + + + type:'' + + + binding:'' + + + value:'' + + + + border:1px solid black; + border:; + + + + + + width:; + + + + + + height:; + + + + + + left:; + + + + + + top:; + + + + + + padding:; + + padding-top:; + padding-right:; + padding-bottom:; + padding-left:; + + + + + + float:left; + float:right; + margin:0 auto; + clear:both; + position:; + position:relative; + text-align:; + float:left; + + + + + + + + + + + + + + + + + + +
+ + + font-size:; + + + + + -label + + + + width:; + width:; + + + + + + + + text-align:right; + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ + + + +
+
+ +
+
+
+ + +
+
+
+
+
+
+ + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + + + + + + + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + + + + + + + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + ; + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + + + + + ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8088 + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + 1 + + + + + + + null + + + + + + 0 + + + + + + + -1 + + + + + + + -1 + + + + + + + -1 + + + + + + ,model:'',stepping:'',fpu:,cycles:,multiplier:,autoStart:,addrReset:,csStart:,csInterval:,csStop: + + + + + + + + + + + + + + + 8087 + + + + + + + + + + + + ,model:'',stepping:'' + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + true + + + + + + false + + + + + + {} + + + + + + + + + + + + + + + + + chipset + ,model:'',scaleTimers:,sw1:'',sw2:'',sound:,floppies:,monitor:'',rtcDate:'' + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + device + ,type:'',baudReceive:,baudTransmit:,autoMount:'' + + + + + + + + + + + + + + + + + + + + keyboard + ,model:'' + + + + + + + + + + + + + + + 0 + + + + + + + + + + + parallel + ,adapter:,binding:'' + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + + 0 + + + + + + + 0 + + + + + + + false + + + + + serial + ,adapter:,baudReceive:,baudTransmit:,binding:'',tabSize:,charBOL:,upperCase: + + + + + + + + + + + + + + + + + + + + mouse + ,serial:'' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fdc + ,autoMount:'',sortBy:'' + + + + + + + + + + + + + + + + + + + + + xt + + + + + hdc + ,drives:'',type:'' + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + null + + + + + + + + + + + + + + + + + rom + ,addr:,size:,alias:,file:'',notify:'' + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + null + + + + + + null + + + + + + true + + + + + ram + ,addr:,size:,file:'',load:,exec:,test: + + + + + + + + + + + + + + + + + + + + + null + + + + + + + 256 + + + + + + + 224 + + + + + + + black + + + + + + 0 + + + + + + 0 + + + + + + false + + + + + + 1bpp + + + + + + 0 + + + + + + 0 + + + + + + 1 + + + + + + 0 + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + false + + + + + + 1 + + + + + + 1 + + + + + + + 80 + + + + + + + 25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + 0 + + + + + + null + + + + + + 0 + + + + + + 60 + + + + + video + ,model:'',mode:,screenWidth:,screenHeight:,screenColor:'',screenRotate:,bufferAddr:,bufferRAM:,bufferFormat:'',bufferCols:,bufferRows:,bufferBits:,bufferLeft:,bufferRotate:,memory:,switches:'',scale:,cellWidth:,cellHeight:,charCols:,charRows:,fontROM:'',fontColor:'',touchScreen:'',autoLock:,aspectRatio:,smoothing:,interruptRate:,refreshRate: + + + + + + + + + + + + + + + 16 + + + + + + + + + + + + + + + + + debugger + ,base:,commands:'',messages:'' + + + + + + + + + + + + + + panel + + + + + + + + + + + + + + + + + + + + + true + + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + computer + ,autoPower:,busWidth:,resume:'',state:'' + + + + + + + +
diff --git a/versions/pcx86/1.33.0/document.css b/versions/pcx86/1.33.0/document.css new file mode 100644 index 000000000..7072b406e --- /dev/null +++ b/versions/pcx86/1.33.0/document.css @@ -0,0 +1,162 @@ +@CHARSET "UTF-8"; + +.page { + margin: 2% 2%; + padding: 2% 2%; + min-width: 30em; + overflow: auto; + font-size: large; + font-family: Helvetica, Arial, sans-serif; + background: #303030; + color: #ccc; + +} +.page-header { +} +.page-header-title { + text-align: center; + +} +.page a { + color: #7fc07f; + text-decoration: none; +} +a.footlink, a.paralink { + text-decoration: none; +} +a.footlink:link, a.paralink:link { + color: blue; +} +a.footlink:visited, a.paralink:visited { + color: blue; +} +.galleryitem { + float: left; + width: 200px; +} +.item { + float: left; + width: 2em; + text-indent: 1em; +} +.list { + margin-left: 3em; + text-indent: 0; + text-align: justify; +} +ul { + list-style: none; +} +div.pnumber { + float: left; + width: 2em; + text-indent: 1em; +} +div.pitem { + margin-left: 10em; +} +p.indent, .justified p { + text-indent: 2em; + text-align: justify; + line-height: 1.5em; +} +p.noindent { + text-indent: 0; + text-align: justify; +} +p.center, .center { + text-align: center; +} +li.para { + margin-top: 1em; + margin-bottom: 1em; +} +.left { + text-align: left; +} +.right { + text-align: right; +} +blockquote.tag { + font-size: small; + font-family: Monaco, Fixed, monospace; + margin-top: 0; + margin-bottom: 0; +} +.blockquote { + padding-left: 1em; + text-indent: 0; + text-align: justify; +} +.italics { + font-style: italic; +} +.medium { + font-size: medium; +} +.small { + font-size: x-small; +} +.smallcaps { + font-variant: small-caps; +} +.strike { + text-decoration: line-through; +} +.summation, .bracelist { + display: inline-block; + position: relative; + vertical-align: middle; + text-align: center; + margin-bottom: 0.5ex; + text-indent: 0; +} +.bracelist-symbol { + font-size: 3em; + vertical-align: -40%; +} +.summation .summation-lower, .summation .summation-upper, .bracelist-item { + display: block; + font-size: 75%; + text-align: center; +} +.summation .summation-upper { + margin-bottom: 0; + margin-left: 0.8ex; + font-style: italic; +} +.summation .summation-lower{ + margin-bottom: -0.6ex; + font-style: italic; +} +.summation .summation-symbol { + font-size: 2em; +} +p sup { + vertical-align: baseline; + position: relative; + bottom: .5em; + font-size: small; +} +p sub { + vertical-align: baseline; + position: relative; + bottom: -.5em; + font-size: small; +} +.footnote { + font-size: medium; + text-indent: 1em; + text-align: justify; + margin-top: .5em; +} +.image-right { + float: right; + margin-left: 1em; + margin-top: 1em; + margin-bottom: 1em; +} +.image-caption { + font-size: small; + text-align: center; +} \ No newline at end of file diff --git a/versions/pcx86/1.33.0/document.xsl b/versions/pcx86/1.33.0/document.xsl new file mode 100644 index 000000000..acd9f8c71 --- /dev/null +++ b/versions/pcx86/1.33.0/document.xsl @@ -0,0 +1,452 @@ + + + + + +]> + + + + + + + + + +

+
+ + + + + + + +

+
+ +

+
+
+
+ + + + + + +
+
+ + +
+ +   + + +
+
+ +
+
+ + + + + + + + + + + + + + + + +

+
+ + +

+
+ + +

+
+ + +
+
+ + +
+
+ + + + + + + + + + + + + + +
+
+ + +
+
+ + +
  • +
    + + +
    image
    +
    + + +
    +
    + + + + +
    {.}
    +
    + +
    {.}
    +
    +
    +
    + + + + + + + + + + < + > + + + + × + + ÷ + σ + + + + + + + + + + + + { + + + + + + + + + + [] + + + + +
    + +
    +
    + + + , and + + + + + MDY + + + + + + + + + + + + + + + + + + + + January + February + March + April + May + June + July + August + September + October + November + December + + + , + + + + + +

    + +
    +
    + + +
    + {.}
    +
    +
    +
    + + + +

    Timeline

    +
    + +

    +
    +
    + +
    +
    + + + + + + + + + +

    +
    + +
    +
    +
    + + + +

    People

    +
    + +

    +
    +
    + +
    +
    + + +

    + +
    + + +

    +
      + +
    +
    + + + + + + + + + + +
  • + +
  • +
    + + + +

    +
    +

    + +

    +
    +
    + + + + false + + + + + + [Original] + + + + + + + + + + [] + + +
    by
    + + +
    + [Source: + + + + + + + ] +
    +
    +
    + + + +

    Resources

    +
    + +

    +
    +
    + +
    +
    + + +

    + +
    + + + +

    +
    +
      + +
    +
    + + +
  • +
    + + + +

    +
    +
    + +
    +
    + + + +

    +
    + +
    + + + +

    +
    +
      + +
    +
    + + + + + +
      + +
    +
    + + + + +
  • +
    + +
  • +
    + +
  • +
    +
    +
    + + +
  • +
    + + + + + + + + + + +
    + < ="" + + ></> + ></> + /> + +
    +
    + +
    diff --git a/versions/pcx86/1.33.0/machine.xsl b/versions/pcx86/1.33.0/machine.xsl new file mode 100644 index 000000000..2775f2c97 --- /dev/null +++ b/versions/pcx86/1.33.0/machine.xsl @@ -0,0 +1,61 @@ + + + + +]> + + + + + + + + + + + + + + + + + js + + + + + + <xsl:value-of select="$SITEHOST"/> + + + + +
    + +
    +

    +
    + + + + + , + +
    +
    + +
    + + + + -dbg + + + + + + +
    + +
    diff --git a/versions/pcx86/1.33.0/manifest.xsl b/versions/pcx86/1.33.0/manifest.xsl new file mode 100644 index 000000000..61e1ec3f4 --- /dev/null +++ b/versions/pcx86/1.33.0/manifest.xsl @@ -0,0 +1,247 @@ + + + + +]> + + + + + + + + + + + <xsl:value-of select="$SITEHOST"/> + + + + +
    + +
    +

    Document Manifest

    +
    +
      + + + + None + + + + + + + + + + + + + + + + +
    +
    +
    +

    + +
    +
    +
    + + +
    + + + + + + + + + + + <xsl:value-of select="$SITEHOST"/> + + + + +
    + +
    +

    Software Manifest

    +
    +
      + + + + None + + + + + Unknown + + + + + None + + + + + None + + + + + + + + + + + + + UpdatedReleased + + Unknown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + +

    No default machine specified for '' in manifest.xml

    +
    + +
    +
    +
    + + + + -dbg + + + + + + +
    + + + + + Unknown + +
  • +
      + + + + + + + + +
    • + + + + + + + + + + + + + + + + + + + + + + + + + +
        + +
      • + + + + + + +
      • +
        +
      +
      +
    • +
      + + + + + + + + +
    +
  • +
    +
    + +
    diff --git a/versions/pcx86/1.33.0/outline.xsl b/versions/pcx86/1.33.0/outline.xsl new file mode 100644 index 000000000..a81fd1b9f --- /dev/null +++ b/versions/pcx86/1.33.0/outline.xsl @@ -0,0 +1,47 @@ + + + + +]> + + + + + + + + + + + + + + + + + + <xsl:value-of select="title"/><xsl:text> | </xsl:text><xsl:value-of select="$SITEHOST"/> + + + + + +
    +
    + +
    +
    + + + + -dbg + + + + + + +
    + +
    diff --git a/versions/pcx86/1.33.0/pcx86-dbg.js b/versions/pcx86/1.33.0/pcx86-dbg.js new file mode 100644 index 000000000..4ccd93d2e --- /dev/null +++ b/versions/pcx86/1.33.0/pcx86-dbg.js @@ -0,0 +1,881 @@ +(function(){/* + http://pcjs.org/modules/shared/lib/diskapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/dumpapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/reportapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/userapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/keys.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/strlib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/weblib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/interrupts.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/messages.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/debugger.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/state.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/embed.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/defines.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/usrlib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/component.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/defines.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/panel.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/bus.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/memory.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/cpu.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86seg.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86cpu.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86fpu.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86func.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86help.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86mods.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86ops.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/x86op0f.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/chipset.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/rom.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/ram.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/keyboard.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/video.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/parallel.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/serial.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/mouse.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/disk.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/fdc.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/hdc.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/debugger.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pcx86/lib/computer.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/save.js (C) Jeff Parsons 2012-2017 +*/ +var l,aa;function ba(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a;for(var d in b)if(Object.defineProperties){var e=Object.getOwnPropertyDescriptor(b,d);e&&Object.defineProperty(a,d,e)}else a[d]=b[d]} +var da={163840:[40,1,8,,254],184320:[40,1,9,,252],327680:[40,2,8,,255],368640:[40,2,9,,253],737280:[80,2,9,,249],1228800:[80,2,15,,249],1474560:[80,2,18,,240],2949120:[80,2,36,,240],21368320:[615,4,17],2494464:[203,2,12,512],5242880:[256,2,40,256],10485760:[512,2,40,256]},n={jp:0,lp:1,mp:2,hl:3,np:4,op:5,pp:6,qp:7,rp:8,sp:9,tp:10,up:11,vp:12,wp:13,xp:14,yp:15,zp:16,Ap:17,Bp:18,Cp:19,Dp:20,Ep:21,Fp:22,Gp:23,Hp:24,Ip:25,Jp:26," ":32,"!":33,'"':34,"#":35,$:36,"%":37,"&":38,"'":39,"(":40,")":41,"*":42, +"+":43,",":44,"-":45,".":46,"/":47,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,":":58,";":59,"<":60,"=":61,">":62,"?":63,"@":64,ce:65,ti:66,ui:67,vi:68,E:69,wi:70,xi:71,yi:72,zi:73,Ai:74,Bi:75,Ci:76,Di:77,Ei:78,Fi:79,Gi:80,Q:81,Hi:82,Ii:83,Ji:84,Ki:85,Li:86,Mi:87,Ni:88,Oi:89,eg:90,"[":91,"\\":92,"]":93,"^":94,_:95,"`":96,de:97,vl:98,xl:99,d:100,e:101,Hl:102,Il:103,Jl:104,Kl:105,an:106,k:107,bn:108,fn:109,n:110,on:111,p:112,q:113,r:114,Lo:115,t:116,Oo:117,Po:118,Qo:119,x:120,y:121,z:122,"{":123, +"|":124,"}":125,"~":126,Kp:127},ea={};ea[173]=n["-"];ea[186]=n[";"];ea[187]=n["="];ea[189]=n["-"];ea[188]=n[","];ea[190]=n["."];ea[191]=n["/"];ea[192]=n["`"];ea[219]=n["["];ea[220]=n["\\"];ea[221]=n["]"];ea[222]=n["'"];var fa={};fa[n["1"]]=n["!"];fa[n["2"]]=n["@"];fa[n["3"]]=n["#"];fa[n["4"]]=n.$;fa[n["5"]]=n["%"];fa[n["6"]]=n["^"];fa[n["7"]]=n["&"];fa[n["8"]]=n["*"];fa[n["9"]]=n["("];fa[n["0"]]=n[")"];fa[186]=n[":"];fa[187]=n["+"];fa[188]=n["<"];fa[189]=n._;fa[190]=n[">"];fa[191]=n["?"]; +fa[192]=n["~"];fa[219]=n["{"];fa[220]=n["|"];fa[221]=n["}"];fa[222]=n['"'];fa[173]=n._;fa[61]=n["+"];fa[59]=n[":"]; +function ga(a,b){var c;if(a){b||(b=10);var d=a.charAt(0),e=0>=1,f--;return d}function ia(a,b,c){var d="";if(!b||4>=8;return(c?"0b":"")+d} +function ja(a,b,c){var d="";b?11>=3;return(c?"0o":"")+d}function q(a,b,c){var d="";b?8=e?48:55),d=String.fromCharCode(e)+d;a>>=4}return(c?"0x":"")+d}function r(a){return q(a,2,!0)}function ka(a){return q(a,4,!0)} +function la(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0"']/g,function(a){return pa[a]})} +function qa(a,b,c){return c?(" "+a).slice(-b):(a+" ").slice(0,b)}function ra(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")} +var pa={"&":"&","<":"<",">":">",'"':""","'":"'"},sa={0:"NUL",1:"SOH",2:"STX",3:"ETX",4:"EOT",5:"ENQ",6:"ACK",7:"BEL",8:"BS",9:"TAB",10:"LF",11:"VT",12:"FF",13:"CR",14:"SO",15:"SI",16:"DLE",17:"XON",18:"DC2",19:"XOFF",20:"DC4",21:"NAK",22:"SYN",23:"ETB",24:"CAN",25:"EM",26:"SUB",27:"ESC",28:"FS",29:"GS",30:"RS",31:"US"};function ta(a,b,c){var d=0,e=a.length,f=0;for(c||(c=function(a,b){return a>b?1:a>1,h;h=c(b,a[g]);0a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}function wa(a,b){var c=0,d=1,e;for(e in a){if(d>=arguments.length)break;var f=a[e],g=arguments[d++],c=c&~f.nh|g<>a.shift} +function ya(a,b){var c;if(Array.prototype.indexOf)return a.indexOf(b,c);c=c||0;0>c&&(c+=a.length);0>c&&(c=0);for(var d=a.length;ca?this.be=this.id:(this.xe=this.id.substr(0,a),this.be=this.id.substr(a+1));this.ea={ready:!1,pf:!1,$g:!1,Yb:!1,error:!1};this.pg=null;this.ea.error=!1;this.ic=c||0;this.ba=this.H=this.ka=this.pa=this.Ie=null;bb.push(this)} +function eb(a,b,c){gb[a]&&b&&(gb[a][b]=c)}function Wa(a){window&&window.alert(a)}function hb(a){var b=!1;window&&(b=window.confirm(a));return b}function jb(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b=this.x&&a=this.y&&b=c>>2);d?(b=new Fb(a.x,a.y,a.Nc,a.A*b/c|0),a.y+=b.A,a.A-=b.A):(b=new Fb(a.x,a.y,a.Nc*b/c|0,a.A),a.x+=b.Nc,a.Nc-=b.Nc);return b}function Ib(a){ab.call(this,"Panel",a);this.F=this.G=this.L=-1}ba(Ib,ab);l=Ib.prototype;l.Cb=function(a,b,c,d){return this.pa&&this.pa.Cb(a,b,c,d)||this.H&&this.H.Cb(a,b,c,d)||this.B&&this.B.Cb(a,b,c,d)||this.ba&&this.ba.Cb(a,b,c,d)?!0:ab.prototype.Cb.call(this,a,b,c,d)}; +l.uc=function(a,b,c,d){this.pa=a;this.ka=b;this.H=c;this.ba=d;this.B=Jb(a,"Keyboard")};l.Xb=function(a,b){b||Kb();return!0};l.Wb=function(){return!0};l.Vd=function(a,b){a.button||(this.L=b?0:-1,Lb(this,a,b))};l.tf=function(a){Lb(this,a)}; +function Lb(a,b,c){var d=Mb/null.offsetWidth,e=Nb/null.offsetHeight,f=null.getBoundingClientRect(),d=(b.clientX-f.left)*d|0;b=(b.clientY-f.top)*e|0;null==c&&(a.L||(a.L=Math.abs(a.F-d)>Math.abs(a.G-b)?1:2),1==a.L?b=a.G:2==a.L&&(d=a.F));a.F=d;a.G=b;if(0<=d&&dd&&(f=d);c= +f;break a}c=-1}if(-1!==c&&(c&=-16,c!=a.ga)){b=c;if(a.context&&a.N&&a.O){e=Qb-Rb;f=a.N.width;a.O.fillStyle=Sb;a.O.fillRect(0,e,f,Rb);Tb(a,e+Ub,a.N,a.O);a.W=a.ha.width/24|0;if(null==b)Vb(a,"Mouse over memory to dump");else for(Vb(a,q(b,8,!0),null,0,1),d=1;16>=d;d++){for(var g="",h=1;8>=h;h++){var k;k=a.ka;var m=b++;k=k.aa[(m&k.C)>>>k.A].Zd(m&k.D,m);Vb(a,q(k,2),null,1);g+=32<=k&&128>k?String.fromCharCode(k):"."}Vb(a,g,null,0,1)}a.context.drawImage(a.N,0,e,f,Rb,a.Da,a.Ha,a.va,a.za)}a.ga=c}}} +function Wb(a,b,c,d){a.A.kf[a.A.$i++]={Ll:b,Hd:c,type:d};return wa(Pb,b,c,0,d)}function Tb(a,b,c,d){var e,f=null.style.color,g=a.ta=10;a.C=g;a.I=b;a.J=a.aa=Ub;e||(e=a.Z||a.aa+"px "+Xb);a.M=a.Z=e;c&&(a.ha=c);d&&(a.D=d,a.la=f||"white")}function Vb(a,b,c,d,e){a.D.font=a.M;a.D.fillStyle=a.la;a.D.fillText(b,a.C,a.I);a.C+=a.W;null!=c&&(16!=a.Ca?b=c.toString():(b=8>a.qa?"0x":"",b+=q(c,a.qa)),a.D.fillText(b,a.C,a.I),a.C+=a.W);d&&(a.C+=a.W*d);e&&(a.C=a.ta,a.I+=(a.J+2)*(e||1))} +function Kb(){for(var a=!1,b=pb(document,"pcx86","panel"),c=0;c>2,Yb=Nb,Qb=Nb,Sb="black",Rb=Nb>>1;Ra(Kb); +function Zb(a,b,c){ab.call(this,"Bus",a);this.H=b;this.ba=c;this.I=a.busWidth||20;this.O=Math.pow(2,this.I);this.N=this.C=this.O-1|0;this.A=32==this.I||20>=this.I?12:24>=this.I?14:15;this.B=1<>2;this.D=this.B-1;this.M=this.O/this.B|0;this.W=this.M-1;this.F=[];this.G=[];this.K=this.L=!1;this.Y=[];this.Z=[];a=new w;$b(a,this.ba);this.aa=Array(this.M);for(b=0;b>>a.A;0g&&(p=g);if(k&&k.size){if(k.type==d&&k.controller==e){if(f+g<=k.xa)return k.ve+=k.xa-f,k.xa=f,!0;if(f>=k.xa+k.ve){p=k.size-(f-m);p>g&&(p=g);k.ve=f-k.xa+p;f=m+a.B;g-=p;h++;continue}}return cc(a,dc,f,g)}f=new w(f,p,a.B,d,e);$b(f,a.ba,k);a.aa[h++]=f;f=m+a.B;g-=p}return 0>=g?(ec(a.H),a.H.ea.vb||a.status(Math.floor(c/1024)+"Kb "+fc[d]+" at "+q(b)),!0):cc(a,gc,b,c)} +function ac(a,b){32==a.I?b?a.J&&(hc(a,1048576,1048576,a.J),a.J=null):a.J||(a.J=ic(a,1048576,1048576),hc(a,1048576,1048576,ic(a,0,1048576))):20>>this.A;0>>a.A;0>>=a.A;0>>a.A;0>>this.A].Bc(a&this.D,a)};function vc(a,b){var c=b&a.D,d=(b&a.C)>>>a.A;return c!=a.D?a.aa[d].Nf(c,b):a.aa[d++].Zd(c,b)|a.aa[d&a.W].Zd(0,b+1)<<8} +l.fc=function(a,b){this.aa[(a&this.C)>>>this.A].Dc(a&this.D,b&255,a)};function wc(a,b,c){var d=b&a.D,e=(b&a.C)>>>a.A;d!=a.D?a.aa[e].ri(d,c&65535,b):(a.aa[e++].bf(d,c&255,b),a.aa[e&a.W].bf(0,c>>8&255,b+1))}l.wj=function(){return null}; +function xc(a,b){var c=0,d=[],e=!a.J&&a.N==a.C;e||ac(a,!0);for(var f=0;f>>=f)&k;if(void 0!==g){if(g[0])g[0](b,k,e);a.ba&&a.L!=g[1]&&Fc(a.ba,b,k)}else a.ba&&(yb(a.ba,a,b,k,e),a.L&&Fc(a.ba,b,k));f+=h<<3;b+=h;c-=h}}function cc(a,b,c,d,e){b="Memory block error ("+b+": "+q(c)+","+q(d)+")";e?a.ba?a.ba.message(b):a.log(b):Wa(b);return!1}var Pb,Gc={Hk:20,count:8,Zp:1,type:3},Hc=0,Ic;for(Ic in Gc){var Jc=Gc[Ic];Gc[Ic]={nh:(1<>1),this.X=new Int32Array(this.I,0,c>>2),kc(this,pc?qc:sc);else{this.X=Array(c>>2);for(e=0;e>2),b=0;b>8,c)};l.oi=function(a,b,c){this.Dc(a++,b&255,c++);this.Dc(a++,b>>8&255,c++);this.Dc(a++,b>>16&255,c++);this.Dc(a,b>>>24,c)};l.vo=function(a){return this.X[a>>2]>>>((a&3)<<3)&255}; +l.Ho=function(a){var b=a>>2;a=(a&3)<<3;var c=this.X[b]>>a;return 24>a?c&65535:c&255|(this.X[b+1]&255)<<8};l.Bo=function(a){var b=a>>2;a=(a&3)<<3;var c=this.X[b];a&&(c=c>>>a|this.X[b+1]<<32-a);return c};l.To=function(a,b){var c=a>>2;a=(a&3)<<3;this.X[c]=this.X[c]&~(255<>2;a=(a&3)<<3;24>a?this.X[c]=this.X[c]&~(65535<>8);this.Oa=!0}; +l.Zo=function(a,b){var c=a>>2;if(a=(a&3)<<3){var d=-1<>>32-a}else this.X[c]=b;this.Oa=!0};l.uo=function(a,b){this.ba&&null!=this.xa&&Zc(this.ba,this.xa+a)||this.C&&$c(this.C,b,1,!1);return this.Zd(a,b)};l.Go=function(a,b){this.ba&&null!=this.xa&&Zc(this.ba,this.xa+a,2)||this.C&&$c(this.C,b,2,!1);return this.Nf(a,b)};l.Ao=function(a,b){this.ba&&null!=this.xa&&Zc(this.ba,this.xa+a,4)||this.C&&$c(this.C,b,4,!1);return this.ji(a,b)}; +l.So=function(a,b,c){this.ba&&null!=this.xa&&ad(this.ba,this.xa+a)||this.C&&$c(this.C,c,1,!0);this.D?this.cf(0,b,c):this.bf(a,b,c)};l.ep=function(a,b,c){this.ba&&null!=this.xa&&ad(this.ba,this.xa+a,2)||this.C&&$c(this.C,c,2,!0);this.D?this.cf(0,b,c):this.ri(a,b,c)};l.Yo=function(a,b,c){this.ba&&null!=this.xa&&ad(this.ba,this.xa+a,4)||this.C&&$c(this.C,c,4,!0);this.D?this.cf(0,b,c):this.K(a,b,c)};l.xo=function(a,b){this.lb.X[this.A]|=this.F;this.mb.X[this.B]|=this.F;return this.pd.Bc(a,b)}; +l.Jo=function(a,b){this.lb.X[this.A]|=this.F;this.mb.X[this.B]|=this.F;return this.pd.Mf(a,b)};l.Do=function(a,b){this.lb.X[this.A]|=this.F;this.mb.X[this.B]|=this.F;return this.pd.Nd(a,b)};l.Vo=function(a,b,c){this.lb.X[this.A]|=this.F;this.mb.X[this.B]|=this.J;this.pd.Dc(a,b,c)};l.hp=function(a,b,c){this.lb.X[this.A]|=this.F;this.mb.X[this.B]|=this.J;this.pd.Tf(a,b,c)};l.ap=function(a,b,c){this.lb.X[this.A]|=this.F;this.mb.X[this.B]|=this.J;this.pd.Sf(a,b,c)}; +l.yo=function(a,b){return bd(this.C,b,!1).Bc(a,b)};l.Ko=function(a,b){return bd(this.C,b,!1).Mf(a,b)};l.Eo=function(a,b){return bd(this.C,b,!1).Nd(a,b)};l.Wo=function(a,b,c){bd(this.C,c,!0).Dc(a,b,c)};l.ip=function(a,b,c){bd(this.C,c,!0).Tf(a,b,c)};l.bp=function(a,b,c){bd(this.C,c,!0).Sf(a,b,c)};l.to=function(a){return this.Pa[a]};l.Qk=function(a){return this.Pa[a]};l.wo=function(a){this.lb.X[this.A]|=32;this.mb.X[this.B]|=32;this.Bc=this.Qk;return this.Pa[a]}; +l.Fo=function(a){return this.G.getUint16(a,!0)};l.Vk=function(a){return a&1?this.Pa[a]|this.Pa[a+1]<<8:this.Rd[a>>1]};l.Io=function(a){this.lb.X[this.A]|=32;this.mb.X[this.B]|=32;this.Mf=this.Vk;return a&1?this.Pa[a]|this.Pa[a+1]<<8:this.Rd[a>>1]};l.zo=function(a){return this.G.getInt32(a,!0)};l.Sk=function(a){return a&3?this.Pa[a]|this.Pa[a+1]<<8|this.Pa[a+2]<<16|this.Pa[a+3]<<24:this.X[a>>2]}; +l.Co=function(a){this.lb.X[this.A]|=32;this.mb.X[this.B]|=32;this.Nd=this.Sk;return a&3?this.Pa[a]|this.Pa[a+1]<<8|this.Pa[a+2]<<16|this.Pa[a+3]<<24:this.X[a>>2]};l.Ro=function(a,b){this.Pa[a]=b;this.Oa=!0};l.el=function(a,b){this.Pa[a]=b;this.Oa=!0};l.Uo=function(a,b){this.Pa[a]=b;this.lb.X[this.A]|=32;this.mb.X[this.B]|=96;this.Dc=this.el;this.pd.Oa=!0};l.cp=function(a,b){this.G.setUint16(a,b,!0);this.Oa=!0};l.gl=function(a,b){a&1?(this.Pa[a]=b,this.Pa[a+1]=b>>8):this.Rd[a>>1]=b;this.Oa=!0}; +l.gp=function(a,b){a&1?(this.Pa[a]=b,this.Pa[a+1]=b>>8):this.Rd[a>>1]=b;this.lb.X[this.A]|=32;this.mb.X[this.B]|=96;this.Tf=this.gl;this.pd.Oa=!0};l.Xo=function(a,b){this.G.setInt32(a,b,!0);this.Oa=!0};l.fl=function(a,b){a&3?(this.Pa[a]=b,this.Pa[a+1]=b>>8,this.Pa[a+2]=b>>16,this.Pa[a+3]=b>>24):this.X[a>>2]=b;this.Oa=!0}; +l.$o=function(a,b){a&3?(this.Pa[a]=b,this.Pa[a+1]=b>>8,this.Pa[a+2]=b>>16,this.Pa[a+3]=b>>24):this.X[a>>2]=b;this.lb.X[this.A]|=32;this.mb.X[this.B]|=96;this.Sf=this.fl;this.pd.Oa=!0};function cd(a){zb&&!pc&&(a=a<<24|a<<8&16711680|a>>8&65280|a>>>24);return a} +var Oc=0,oc=2,Pc=5,Rc=6,dd=["black","blue","green","cyan"],fc="NONE RAM ROM VIDEO H/W UNPAGED PAGED".split(" "),Nc=0,Tc=[],tc=[w.prototype.vo,w.prototype.To,w.prototype.Ho,w.prototype.fp,w.prototype.Bo,w.prototype.Zo],Yc=[w.prototype.uo,w.prototype.So,w.prototype.Go,w.prototype.ep,w.prototype.Ao,w.prototype.Yo],Sc=[w.prototype.xo,w.prototype.Vo,w.prototype.Jo,w.prototype.hp,w.prototype.Do,w.prototype.ap],Qc=[w.prototype.yo,w.prototype.Wo,w.prototype.Ko,w.prototype.ip,w.prototype.Eo,w.prototype.bp]; +if(zb)var sc=[w.prototype.to,w.prototype.Ro,w.prototype.Fo,w.prototype.cp,w.prototype.zo,w.prototype.Xo],qc=[w.prototype.Qk,w.prototype.el,w.prototype.Vk,w.prototype.gl,w.prototype.Sk,w.prototype.fl],ed=[w.prototype.wo,w.prototype.Uo,w.prototype.Io,w.prototype.gp,w.prototype.Co,w.prototype.$o]; +function fd(a,b){ab.call(this,"CPU",a,1);b=a.cycles||b;var c=a.multiplier||1;this.T={};this.T.sd=b;this.T.Kd=c;this.T.rg=Math.round(this.T.sd/1E4)/100;this.T.oe=this.T.rg*this.T.Kd;this.ea.vb=!1;this.ea.ni=!1;this.ea.lf=a.autoStart;this.ea.kj=!1;this.ea.He=!1;this.T.uf=this.T.Te=0;this.T.wf=a.csStart;this.T.Se=a.csInterval;this.T.Ue=a.csStop;this.Ql=this.Uf.bind(this);tb(this)}ba(fd,ab);l=fd.prototype; +l.uc=function(a,b,c,d){this.pa=a;this.ka=b;this.ba=d;for(b=0;b=a.T.Te&&(a.T.Te+=a.T.Se,c=!0);0<=a.T.Ue&&a.T.Ue<=qd(a)&&(a.T.Se=a.T.Ue=-1,nd(a),a.Jb(),c=!0);c&&a.P(qd(a)+" cycles: checksum="+q(a.T.uf))}} +l.Cb=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.na[b]=c;a=!0;break;case "run":this.na[b]=c;c.onclick=function(){var a;if(a=d.pa)if(a=d.pa,a.ea.Yb)a=!0;else{var b=null,c,h=jb(a.id);for(c=0;ca.T.rg&&(c=Math.round(c/a.T.Kd));return c}function id(a){a.T.Wd=0;a.Dd=a.md=a.zc=a.A=0;nd(a);rd(a,1)} +function rd(a,b,c){var d=!1;if(void 0!==b){.8>a.T.Wd/a.T.oe?b=1:d=!0;a.T.Kd=b;b=a.T.rg*a.T.Kd;if(a.T.oe!=b){a.T.oe=b;b=a.T.oe.toFixed(2)+"Mhz";var e=a.na.setSpeed;e&&(e.textContent=b);a.P("target speed: "+b)}c&&a.pa&&a.pa.ld()}td(a,a.md);a.md=0;a.T.Xd=Ba();a.T.pe=0;ud(a);return d} +l.Uf=function(a){if(vb(this,!0)){if(!this.ea.vb){rd(this);this.pa&&this.pa.start(this.T.Xd,qd(this));this.ea.vb=!0;this.ea.ni=!0;this.W&&this.W.start();var b=this.na.run;b&&(b.textContent="Halt");this.pa&&(yd(this.pa,!0),a&&this.pa.ld(!0))}this.T.th>=this.T.sd&&ud(this,!0);this.T.zf=0;this.T.sg=Ba();this.T.pe&&(a=this.T.sg-this.T.pe,a>this.T.Dj&&(this.T.Xd+=a,this.T.Xd>this.T.sg&&(this.T.Xd=this.T.sg)));try{do{var c=this.ea.He?1:this.T.kn;if(this.W){zd(this.W);var d=this.W;a=c;var e=d.G[0];if(e.le){var f= +(qd(d.H,d.O)-e.jd)/d.Ba|0,g=Ad(d,0)-f;e.mode==Bd&&(g-=f);var h=g*d.Ba|0;e.mode==Bd&&(h>>=1);a>h&&(a=h)}var c=a,k=this.W;a=c;if(k.A&&k.A[Cd]&Dd){var m=k.Z-qd(k.H,k.O);0m&&(a=m)}c=a}try{this.Lg(c)}catch(x){if("number"!=typeof x)throw x;}var p=this.zc-this.A;this.md+=p;this.T.zf+=p;td(this,0,!0);pd(this,p);this.T.yf-=p;0>=this.T.yf&&(this.T.yf+=this.T.Fj,this.pa&&Ed(this.pa));this.T.xf-=p;0>=this.T.xf&&(this.T.xf+=this.T.Ej,this.pa&&yd(this.pa));this.T.Ve-=p;if(0>=this.T.Ve){this.T.Ve+=this.T.sh; +break}}while(this.ea.vb)}catch(x){this.Jb();od(this);this.pa&&this.pa.stop(Ba(),qd(this));vb(this,!1);qb(this,x.stack||x.message);return}c=setTimeout;d=this.Ql;this.T.pe=Ba();e=this.T.Dj;this.T.zf&&(e=Math.round(e*this.T.zf/this.T.sh));e-=this.T.pe-this.T.sg;if(f=this.T.pe-this.T.Xd)this.T.Wd=Math.round(this.md/(10*f))/100,864E5<=f&&(this.Dd=0,this.W&&zd(this.W,!0),rd(this));if(0>e||this.T.Wde&&(this.T.Xd-=e),e=0;this.T.th+=this.T.zf;this.T.pe+=e;c(d,e)}else od(this),this.pa&&this.pa.stop(Ba(), +qd(this))};l.Lg=function(){return 0};l.Jb=function(a){ub(this,!0);this.zc-=this.A;this.A=0;td(this,this.md);this.md=0;if(this.ea.vb){this.ea.vb=!1;this.W&&this.W.stop();var b=this.na.run;b&&(b.textContent="Run")}this.ea.complete=a};function od(a,b){a.pa&&(Ed(a.pa,b),yd(a.pa,b))}var vd=30,wd=60,xd=2,gd=["power","reset"]; +function Fd(a,b,c,d){this.gc=a;this.ba=a.ba;this.id=b;this.$b=c||"";this.U=0;this.Ka=65535;this.Nb=this.Ka+1;this.Ab=this.qc=this.ext=this.jb=this.type=this.ua=0;this.Lb=-1;this.V=this.Jc=2;this.R=this.wa=65535;this.G=this.mh;this.D=this.dj;this.F=this.fj;this.A={U:-1,ua:0,Ka:0,jb:0,type:0,ext:0,Lb:-1};1==this.id&&(this.Jf=0,this.C=null,this.Pe=!1,this.H=Array(32),this.B=[]);Gd(this,!0,d)}function Hd(a,b){a.B.push(b);return[a.B.length,Id]}l=Fd.prototype; +l.mh=function(a){this.U=a&65535;return this.ua=this.U<<4};l.qg=function(a,b){var c,d,e=this.gc;a&=65535;a&4?(c=e.Eb.ua,d=c+e.Eb.Ka|0):(c=e.Kb,d=e.Pc);if(c){c=c+(a&65528)|0;if(d-c|0)return e.A-=15,Jd(this,c,a,b);this.id>>0)+b<=this.Nb?this.ua+a|0:this.kg()};l.zl=function(a,b){return(a>>>0)+b>this.Nb?this.ua+a|0:this.kg()};l.kg=function(){y.call(this.gc,13,0);return-1};l.ej=function(a,b){return(a>>>0)+b<=this.Nb?this.ua+a|0:this.lg()}; +l.Al=function(a,b){return(a>>>0)+b>this.Nb?this.ua+a|0:this.lg()};l.lg=function(){y.call(this.gc,13,0);return-1};function Nd(a,b,c,d,e){a.U=b;a.ua=d;a.Ka=e;a.Nb=(e>>>0)+1;a.jb=c;a.type=c&7936;a.ext=c>>16&192;a.Lb=(b&4?a.gc.Eb.ua:a.gc.Kb)+(b&65528)|0;a.id>>0)+1;a.jb=e;a.type=e&7936;a.ext=0;a.Lb=b;a.id>>0)+1,a.jb=a.A.jb,a.type=a.A.type,a.ext=a.A.ext,a.Lb=a.A.Lb,a.A.U=-1,Gd(a,!0,!0,!1),a.ua;a.A.U=-1;var f=e.ja(b+0),g=e.ja(b+4),h=g&7936,k=e.ja(b+2)|(g&255)<<16,m=e.ja(b+6),p=c&65528;if(80386<=e.ca){var x=f,k=k|(m&65280)<<16,f=f|(m&15)<<16;m&128&&(f=f<<12|4095)}switch(a.id){case Qd:var u=a.C;a.Pe=!1;if(u&&c==Id&&a.B.length){var F=a.B[a.Jf-1];if(F&&!F())return-1}var K=c&3,H=(g&24576)>>13,F=-1,I,T;p||b>= +e.Kb&&b=a.Ab&&(K>a.Ab&&(F=Rd(e),Td(e,Rd(e),!0),Ud(e,F),a.Pe=!0),F=0);else{if(256==h||2304==h)return Vd(a,c,u)?a.ua:-1;if(1024==h)F=2,T=0,Kh||2048==(h&2560))return y.call(e,13,c&65532),-1;if(!(g&32768))return y.call(e,11,c&65532),-1}break;case Md:if(!p||4096>h||512!=(h&2560))return y.call(e,13,c&65532),-1;if(!(g&32768))return y.call(e,12,c&65532), +-1;break;case Od:u=h&-513;if(!p||256!=u&&2304!=u)return y.call(e,13,c&65532),-1;2304==u&&(a.Si=k+e.ja(k+102)|0,a.tl=k+a.Ka|0);break;case Kd:if(!(h&4096)&&768>>0)+1,a.jb=g,a.type=h,a.ext=m,a.Lb=b,Gd(a,!0,!0,!1));return k} +function Vd(a,b,c){var d=a.gc,e=a.Ab,f=d.la.U,g=d.la.ua;if(!c){if(!(d.la.type&512))return y.call(d,13,b&65532),!1;d.fb(d.la.Lb+4,d.la.jb&=-513)}if(-1===d.la.load(b))return!1;var h=d.la.ua;if(!1!==c){if(d.la.type&512)return y.call(d,13,b&65532),!1;d.fb(d.la.Lb+4,d.la.jb|=512)}d.la.type=d.la.type&-513|d.la.jb&512;256==d.la.type||768==d.la.type?(d.fb(g+14,A(d)),d.fb(g+16,de(d)),d.fb(g+18,d.D),d.fb(g+20,d.I),d.fb(g+22,d.L),d.fb(g+24,d.G),d.fb(g+26,z(d)),d.fb(g+28,d.M),d.fb(g+30,d.K),d.fb(g+32,d.J),d.fb(g+ +34,d.oa.U),d.fb(g+36,d.Z.U),d.fb(g+38,d.Y.U),d.fb(g+40,d.Ca.U),d.Eb.load(d.ja(h+42)),ee(d,d.ja(h+16)|(c?16384:0)),d.D=d.ja(h+18),d.I=d.ja(h+20),d.L=d.ja(h+22),d.G=d.ja(h+24),d.M=d.ja(h+28),d.K=d.ja(h+30),d.J=d.ja(h+32),d.oa.load(d.ja(h+34)),d.Ca.load(d.ja(h+40)),fe(d,d.ja(h+14),d.ja(h+36)),b=38,g=26,a.Ab>>0)+1)}; +function Gd(a,b,c,d){void 0===c&&(c=!!(a.gc.qa&1));a.Oc=!1;if(c)if(a.load=a.qg,a.Cj=a.dn,a.bc=a.cj,a.cc=a.ej,void 0===d&&(d=!!(a.gc.O&131072)),d)a.load=a.G,a.bc=a.D,a.cc=a.F,a.Ab=a.qc=3,a.V=2,a.R=a.wa=65535,a.Ka=65535,a.Nb=a.Ka+1,a.Jc=a.V,a.Lb=-1,a.Pe=!1;else{if(!(a.U&-4))a.bc=a.kg,a.cc=a.lg;else if(a.type&4096){6144==(a.type&6656)&&(a.bc=a.kg);if(a.type&2048||!(a.type&512))a.cc=a.lg;1024==(a.type&3072)&&(a.bc==a.cj&&(a.bc=a.zl),a.cc==a.ej&&(a.cc=a.Al),a.Oc=!0);b&&a.id>13,80386>a.gc.ca||!(a.ext&64)?(a.V=2,a.R=65535):(a.V=4,a.R=-1),a.Jc=a.V,a.wa=a.R)}else a.load=a.mh,a.Cj=a.en,a.bc=a.dj,a.cc=a.fj,a.Ab=a.qc=0,a.Lb=-1,a.Pe=!1}var Qd=1,ce=2,Md=3,Od=4,Kd=6,Id=1; +function he(a){var b=+a.model||8088,c;switch(b){default:c=4772727;break;case 80286:c=6E6;break;case 80386:c=16E6}fd.call(this,a,c);this.ca=b;a=a.stepping;this.we=b+(a?ga(a,16):0);this.Ri=61442;this.Qd=1792;this.si=28672;this.Vf=4;this.Ta=255;this.B=80286<=this.ca?Bb:Ab;this.va=ie;this.bj=je;this.ij=ke;this.nj=le;if(80186<=this.ca&&(this.va=ie.slice(),this.bj=je.slice(),this.ij=ke.slice(),this.Ta=31,this.va[15]=me,this.va[96]=ne,this.va[97]=oe,this.va[98]=pe,this.va[99]=me,this.va[100]=me,this.va[101]= +me,this.va[102]=me,this.va[103]=me,this.va[104]=qe,this.va[105]=re,this.va[106]=se,this.va[107]=te,this.va[108]=ue,this.va[109]=ze,this.va[110]=Ae,this.va[111]=Be,this.va[192]=Ce,this.va[193]=De,this.va[200]=Ee,this.va[201]=Fe,this.va[241]=Ge,this.bj[7]=He,this.ij[7]=He,80286<=this.ca)){this.Ri=2;this.Qd|=28672;this.Vf=0;this.va[15]=Ie;this.Pd=Je.slice();for(b=0;b=this.we&&(this.Pd[166]=Re,this.Pd[167]=Se)}}this.Yf=[];this.Zf=[];this.ag=0;id(this);this.ea.complete=this.ea.jj=!1;this.tj=0;this.sc=this.aa=[];this.qb=this.Ng=this.Db=this.Wf=this.df=this.ef=this.ed=0;Te(this)}ba(he,fd);function Ue(a,b,c,d){b=(d?a.sc:a.aa)[b>>>a.qb];c?--b.ie||Xc(b):--b.he||Wc(b);d&&ec(a)} +function Ve(a){var b;if(a.aa===a.sc){a.aa=Array(a.Wf);a.$f=new w(null,0,0,Pc,null,a);$b(a.$f,a.ba);for(b=0;b>>20,f=a.sc[(a.Wc+e&a.ef)>>>a.qb],g=f.Nd(e);if(!(g&1))return d||Xe.call(a,b,!1,c),a.ff;if(!(g&4)&&3==a.Ma)return d||Xe.call(a,b,!0,c),a.ff;var h=(b&4190208)>>>10,g=a.sc[((g&-4096)+h&a.ef)>>>a.qb],k=g.Nd(h);if(!(k&1))return d||Xe.call(a,b,!1,c),a.ff;if(!(k&4)&&3==a.Ma)return d||Xe.call(a,b,!0,c),a.ff;c=a.sc[((k&-4096)+(b&4095)&a.ef)>>>a.qb];if(d)return c;d=b>>>a.qb;k=a.aa[d];b&=-4096;var m;0>2;b.mb=g;b.B=h>>2;zb&&pc&&c.X&&!c.controller&&!c.he&&!c.ie?(b.Pa=c.Pa,b.Rd=c.Rd,b.X=c.X,kc(b,ed)):(b.F=c?cd(32):0,b.J=c?cd(96):0,kc(b,Sc));$b(b,a.ba,k);a.aa[d]=b;a.Xf.push(d);return b}function Ye(a){a.aa!==a.sc&&(a.aa=a.sc,a.$f=null,a.Xf=null,a.ff=null)}l=he.prototype;l.reset=function(){this.ea.vb&&this.Jb();Te(this);id(this);this.ea.error=!1}; +function Ze(a,b){var c;switch(b){case 0:c=a.D;break;case 1:c=a.I;break;case 2:c=a.L;break;case 3:c=a.G;break;case 4:c=z(a);break;case 5:c=a.M;break;case 6:c=a.K;break;case 7:c=a.J}return c}function $e(a,b,c){switch(b){case 0:a.D=c;break;case 1:a.I=c;break;case 2:a.L=c;break;case 3:a.G=c;break;case 4:Ud(a,c);break;case 5:a.M=c;break;case 6:a.K=c;break;case 7:a.J=c}} +function Te(a){a.D=0;a.G=0;a.I=0;a.L=0;a.Hc=0;a.M=0;a.K=0;a.J=0;a.vc=!1;a.Ba=a.$a=0;a.ya=0;a.sj=0;a.ga=0;a.qa=65520;a.Pb=0;a.cd=1023;a.O=a.lc=0;a.ze=a.hf=a.ye=a.Ae=0;a.Uc=-1;a.Ad=a.Vc=-1;a.Bd=a.ta=-1;a.Z=new Fd(a,Qd,"CS");a.Ca=new Fd(a,ce,"DS");a.oa=new Fd(a,ce,"ES");a.Y=new Fd(a,Md,"SS");Ud(a,0);Td(a,0);if(80386<=a.ca){switch(a.we){case 80562:case 80563:a.L=771;break;case 80578:a.L=772;break;case 80594:a.L=773;break;case 80595:case 80596:a.L=776}a.qa=16;a.Og=0;a.Cd=0;a.Wc=0;a.Qb=[0,0,0,0,null,null, +0,0];a.dg=[null,null,null,null,null,null,0,0];a.Ga=new Fd(a,ce,"FS");a.Ha=new Fd(a,ce,"GS");Ye(a)}a.Qg=new Fd(a,0,"NULL");a.Da=a.Ca;a.Rb=a.Y;a.N=a.ha=0;a.C=a.F=-1;a.eb=a.Qg;a.Za=0;if(80286>a.ca)fe(a,0,65535);else{a.Kb=0;a.Pc=65535;a.Eb=new Fd(a,5,"LDT",!0);a.la=new Fd(a,Od,"TSS",!0);a.xb=new Fd(a,Kd,"VER",!0);fe(a,65520,61440);var b,c=A(a);b=a.Z;var d=-65536;80386>b.gc.ca&&(d&=16777215);b=b.ua=d;a.da=b+c|0;a.Pg=(b>>>0)+(a.Z.Ka>>>0)+1}ee(a,0);Wd(a)} +function af(a){2==a.Jc?(a.Sb=a.ja,a.kc=ef,a.tc=ff,a.kd=gf,2==a.V?(a.ma=hf,a.za=jf,a.rb=kf):(a.ma=lf,a.za=rf,a.rb=sf)):(a.Sb=a.ia,a.kc=tf,a.tc=uf,a.kd=vf,2==a.V?(a.ma=wf,a.za=xf,a.rb=yf):(a.ma=zf,a.za=Af,a.rb=Bf))}function Xd(a,b){a.V!=b&&(a.ha|=1024,a.V=b,a.R=2==b?65535:-1,Cf(a))}function Cf(a){2==a.V?(a.Fb=32768,a.hb=a.ja,a.yb=a.fb,2==a.Jc?(a.ma=hf,a.za=jf,a.rb=kf):(a.ma=wf,a.za=xf,a.rb=yf)):(a.Fb=-2147483648,a.hb=a.ia,a.yb=a.ab,2==a.Jc?(a.ma=lf,a.za=rf,a.rb=sf):(a.ma=zf,a.za=Af,a.rb=Bf))} +function Df(a){a.Jc=a.Z.Jc;a.wa=a.Z.wa;af(a);a.V=a.Z.V;a.R=a.Z.R;Cf(a);a.ha&=-3073}l.uj=function(){var a=this.D+this.G+this.I+this.L+z(this)+this.M+this.K+this.J|0;return a=a+A(this)+this.Z.U+this.Ca.U+this.Y.U+this.oa.U+de(this)|0};function Ef(a,b,c){void 0===a.Yf[b]&&(a.Yf[b]=[]);a.Yf[b].push(c)}function Ff(a,b,c){c&&(null==a.Zf[b]&&a.ag++,a.Zf[b]=c)}function Gf(a,b){var c=a.Zf[b];null!=c&&(c(--a.ag),delete a.Zf[b])} +function Hf(a,b){for(var c=a.Qb[7],d=c>>16,e=0;4>e;e++){if(c&3){var f=!!(d&1),g=a.Qb[e],g=g&~(d>>2&3);b?a.aa[g>>>a.qb].Gd(g&a.Db,f,a):(g=a.aa[g>>>a.qb],f?--g.ie||Xc(g):--g.he||Wc(g))}c>>=2;d>>=4}}function $c(a,b,c,d){if(!(a.N&8192)&&a.Qb[7]&255){c--;var e=a.Qb[7],f=e>>16;d=d?1:0==d?3:0;for(var g=0;4>g;g++){if(e&3&&(f&3)==d){var h=f>>2;if(b+c>=a.Qb[g]&&b<=a.Qb[g]+h){a.Qb[6]|=1<>=2;f>>=4}}} +function Wd(a,b,c){void 0===b&&(b=!!(a.qa&1));void 0===c&&(c=!!(a.O&131072));a.nj=b&&!c?If:le;Gd(a.Z,!1,b,c);Gd(a.Ca,!1,b,c);Gd(a.Y,!1,b,c);Gd(a.oa,!1,b,c);80386<=a.ca&&(Gd(a.Ga,!1,b,c),Gd(a.Ha,!1,b,c));Df(a)} +l.save=function(){var a=new Jf(this);a.set(0,[this.D,this.G,this.I,this.L,z(this),this.M,this.K,this.J]);var b=A(this),c=this.Z.save(),d=this.Ca.save(),e=this.Y.save(),f=this.oa.save(),g;null!=this.Kb?(g=[this.qa,this.Kb,this.Pc,this.Pb,this.cd,this.Eb.save(),this.la.save(),this.lc],80386<=this.ca&&(g.push(this.Og),g.push(this.Cd),g.push(this.Wc),g.push(this.Qb),g.push(this.dg))):g=null;b=[b,c,d,e,f,g,de(this)];80386<=this.ca&&(b.push(this.Ga.save()),b.push(this.Ha.save()));a.set(1,b);a.set(2,[this.Da.$b, +this.Rb.$b,this.N,this.ha,this.Za,this.C,this.F]);a.set(3,[0,this.Dd,this.T.Kd]);a.set(4,xc(this.ka,!!(this.qa&-2147483648)));return a.data()}; +l.restore=function(a){var b=a[0];this.D=b[0];this.G=b[1];this.I=b[2];this.L=b[3];var c=b[4];this.M=b[5];this.K=b[6];this.J=b[7];b=a[1];this.Z.restore(b[1]);this.Ca.restore(b[2]);this.Y.restore(b[3]);this.oa.restore(b[4]);var d=b[5];d&&d.length&&(this.qa=d[0],this.Kb=d[1],this.Pc=d[2],this.Pb=d[3],this.cd=d[4],this.Eb.restore(d[5]),this.la.restore(d[6]),this.lc=d[7],80386<=this.ca&&(this.Og=d[8],this.Cd=d[9],this.Wc=d[10],this.Qb=d[11],this.dg=d[12]),Wd(this));ee(this,b[6]);var d=!1,e;a:{e=this.ka; +var f=a[4],g;for(g=0;g>>0)+(a.Z.Ka>>>0)+1;a.Ma=a.Z.Ab;Df(a)}function fe(a,b,c,d){var e=a.Z;e.Jf=b;e.C=d;b=e.load(c);return-1!==b?(Mf(a,b+(a.Z.Jf&a.Z.R)),a.Z.Pe):null} +function Nf(a,b){b=(a.da>>>0)+b;b>a.Pg&&(8088>=a.ca||a.Z.Ka==a.Z.wa?b=a.Z.ua+(b-a.Pg&a.R):y.call(a,13,0));return b|0}function Of(a){a.da=a.Bd}function z(a){return a.Hc&~a.Y.wa|a.Aa-a.Y.ua}function Ud(a,b){a.Hc=b;a.Aa=a.Y.ua+(b&a.Y.wa)|0}function Pf(a,b,c,d,e,f){if(63!=(e&63)&&e!=a.resultType){var g=(e^a.resultType)&a.resultType;g&&(g&1&&Qf(a),g&2&&Rf(a),g&4&&Sf(a),g&8&&Tf(a),g&16&&Uf(a),g&32&&Vf(a))}f?(a.ze=d,a.ye=b):(a.ze=b,a.ye=d);a.hf=c;a.Ae=d;a.resultType=e} +function Wf(a,b,c,d,e){a.resultType=c|26;a.Ae=b;d?Xf(a):Yf(a);e?Zf(a):$f(a);return b}function ag(a,b,c,d){c&d?Xf(a):Yf(a);(b^c)&d?Zf(a):$f(a)}function bg(a){return Qf(a)?1:0}function Qf(a){a.resultType&1&&(a.O&=-2,(a.ze^(a.ze^a.hf)&(a.hf^a.ye))&a.resultType&-2147450752&&(a.O|=1),a.resultType&=-2);return a.O&1}function Rf(a){a.resultType&2&&(a.O&=-5,38505>>((a.Ae^a.Ae>>4)&15)&1&&(a.O|=4),a.resultType&=-3);return a.O&4} +function Sf(a){a.resultType&4&&(a.O&=-17,(a.ye^a.ze^a.hf)&16&&(a.O|=16),a.resultType&=-5);return a.O&16}function Tf(a){a.resultType&8&&(a.O&=-65,a.Ae&((a.resultType&-2147450752)-1|a.resultType&-2147450752)||(a.O|=64),a.resultType&=-9);return a.O&64}function Uf(a){a.resultType&16&&(a.O&=-129,a.Ae&a.resultType&-2147450752&&(a.O|=128),a.resultType&=-17);return a.O&128} +function Vf(a){a.resultType&32&&(a.O&=-2049,(a.ze^a.ye)&(a.hf^a.ye)&a.resultType&-2147450752&&(a.O|=2048),a.resultType&=-33);return a.O&2048}function Yf(a){a.resultType&=-2;a.O&=-2}function cg(a){a.resultType&=-5;a.O&=-17}function dg(a){a.resultType&=-9;a.O&=-65}function $f(a){a.resultType&=-33;a.O&=-2049}function Xf(a){a.resultType&=-2;a.O|=1}function eg(a){a.resultType&=-5;a.O|=16}function fg(a){a.resultType&=-9;a.O|=64}function Zf(a){a.resultType&=-33;a.O|=2048} +function de(a){return a.O&-2262|Qf(a)|Rf(a)|Sf(a)|Tf(a)|Uf(a)|Vf(a)}function gg(a,b){b|=a.qa&1|65520;a.qa=a.qa&-65536|b&65535;a.qa&1&&Wd(a,!0)}function ee(a,b,c){a.qa&1||(b&=~a.si);void 0===c&&(c=a.Ma);c?b=b&-12289|a.O&12288:a.lc=(b&12288)>>12;c>a.lc&&(b=b&-513|a.O&512);a.resultType=128;a.O=a.O&~(a.Qd|2261)|b&(a.Qd|2261)|a.Ri;a.O&256&&(a.Za|=2,a.N|=4)} +function hg(a,b,c,d){var e=0;if(a.qa&1&&(a.Ma>a.lc||a.O&131072)&&a.la.Si)for(var f=a.la.Si+(b>>>3),e=(1<>>=8,f++;return e?(t(a,256)&&wb(a,"checkIOPM("+ka(b)+","+c+","+(d?"input":"output")+"): trapped",!0,!0),y.call(a,13,0),!1):!0} +l.Cb=function(a,b,c){switch(b){case "EAX":case "EBX":case "ECX":case "EDX":case "ESP":case "EBP":case "ESI":case "EDI":case "EIP":case "AX":case "BX":case "CX":case "DX":case "SP":case "BP":case "SI":case "DI":case "IP":case "PC":case "CS":case "DS":case "SS":case "ES":case "FS":case "GS":case "CR0":case "CR2":case "CR3":case "PS":case "C":case "P":case "A":case "Z":case "S":case "T":case "I":case "D":case "V":this.na[b]=c;this.tj++;a=!0;break;default:a=fd.prototype.Cb.call(this,a,b,c)}return a}; +function ig(a,b,c,d){var e=(d?a.sc:a.aa)[(b&a.ed)>>>a.qb];e&&e.type==Pc&&(e=bd(a,b,!1,!0));if(e){var f=b&a.Db;if(!c||1==c)return e.Zd(f,b);if(2==c)return f>>this.qb].Bc(a&this.Db,a)}; +l.ja=function(a){var b=a&this.Db,c=(a&this.ed)>>>this.qb;this.A-=this.B.zg;if(b>>this.qb;if(b>>this.qb].Dc(a&this.Db,b&255,a)}; +l.fb=function(a,b){var c=a&this.Db,d=(a&this.ed)>>>this.qb;this.A-=this.B.zg;c>8&255,a+1))};l.ab=function(a,b){var c=a&this.Db,d=(a&this.ed)>>>this.qb;this.A-=this.B.zg;if(c>>=8}}; +function jg(a,b,c){a.eb=b;a.wb=c&a.wa;a.C=b.bc(a.wb,1);return a.N&1?0:a.Ia(a.C)}function D(a,b){return jg(a,a.Da,b)}function kg(a,b){return jg(a,a.Rb,b)}function lg(a,b,c){a.eb=b;a.wb=c&a.wa;a.C=b.bc(a.wb,a.V);return a.N&1?0:a.hb(a.C)}function E(a,b){a.eb=a.Da;a.wb=b&a.wa;a.C=a.eb.bc(a.wb,2);return a.N&1?0:a.ja(a.C)}function mg(a,b){a.eb=a.Rb;a.wb=b&a.wa;a.C=a.eb.bc(a.wb,2);return a.N&1?0:a.ja(a.C)}function G(a,b){a.eb=a.Da;a.wb=b&a.wa;a.C=a.eb.bc(a.wb,4);return a.N&1?0:a.ia(a.C)} +function ng(a,b){a.eb=a.Rb;a.wb=b&a.wa;a.C=a.eb.bc(a.wb,4);return a.N&1?0:a.ia(a.C)}function og(a,b){a.N&2||a.fc(a.eb.cc(a.wb,1),b)}function pg(a,b){a.N&2||a.fb(a.eb.cc(a.wb,2),b)}function qg(a,b){a.N&2||a.ab(a.eb.cc(a.wb,4),b)}function Yd(a,b,c){return a.hb(b.bc(c,a.V))}l.ra=function(){var a=Nf(this,1),b=this.Ia(this.da);this.da=a;return b};function tg(a){var b=Nf(a,2),c=a.ja(a.da);a.da=b;return c}function J(a){var b=Nf(a,a.Jc),c=a.Sb(a.da);a.da=b;return c} +l.Ea=function(){var a=Nf(this,this.V),b=this.hb(this.da);this.da=a;return b};l.S=function(){var a=Nf(this,1),b=this.Ia(this.da)<<24>>24;this.da=a;return b};function Rd(a){var b=a.hb(a.Aa);a.Aa=a.Aa+a.V|0;var c=a.cg-a.Aa|0;0>c&&0<=(a.cg^a.Aa)&&(8088>=a.ca||!a.Y.Oc&&a.Y.Ka==a.Y.wa||a.Y.Oc&&!a.Y.Ka?Ud(a,a.Aa-a.Y.ua&a.Y.wa):-1>c&&y.call(a,12,0));return b} +function Zd(a,b,c,d){c=a.Aa-c|0;0>(c-a.gf|0)&&0<=(a.gf^c)&&(8088>=a.ca||!a.Y.Oc&&a.Y.Ka==a.Y.wa||a.Y.Oc&&!a.Y.Ka?(Ud(a,c-a.Y.ua&a.Y.wa),c=a.Aa):y.call(a,12,0));switch(d){case 1:a.fc(c,b);break;case 2:a.fb(c,b);break;case 4:a.ab(c,b)}a.Aa=c}function be(a,b){var c=a.Aa-a.V|0;0>(c-a.gf|0)&&0<=(a.gf^c)&&(8088>=a.ca||!a.Y.Oc&&a.Y.Ka==a.Y.wa||a.Y.Oc&&!a.Y.Ka?(Ud(a,c-a.Y.ua&a.Y.wa),c=a.Aa):y.call(a,12,0));a.yb(c,b);a.Aa=c} +function ug(a,b,c){var d=4;1==b.length&&(d=1,c=c?1:0);if(80386>a.ca)2this.ca?0:1,e=0;2>e;e++){switch(d){case 0:if(this.Za&1&&this.O&512){var f=wg(this.W);if(-1<=f&&(this.Za&=-2,0<=f)){this.Za&=-5; +xg.call(this,f);d=!0;break a}}break;case 1:if(this.Za&2){this.Za&=-3;80386<=this.ca&&(this.Qb[6]|=16384);xg.call(this,1);d=!0;break a}}d=1-d}d=!1}if(d&&!a){this.P("interrupt dispatched");this.N=0;break}if(this.Za&4){this.N=this.A=0;break}}if(b){if(yg(this.ba,this.da,c)){this.Jb();break}c=1}this.N=0;this.va[this.ra()].call(this)}while(0>11;Dg(this);Eg(this,a[b++]);for(c=0;c=Fg&&Gg(a,Hg))}function Dg(a){a.fa&=-129;a.fa&~a.Zb&63&&(a.fa|=128);if(a.fa&128&&!(a.Zb&128))return a=a.W,a.ca>=Fg?Ig(a,Hg):a.da&Jg||xg.call(a.H,2),!0;a=a.W;a.ca>=Fg&&Gg(a,Hg);return!1}function Kg(a,b){80387<=a.ca||(b&=-65);a.fa|=b;return Dg(a)} +function Bg(a){return a.fa|a.B<<11}function Lg(a,b){return isFinite(b)?!0:!Kg(a,Infinity===b?8:16)}function Yg(a,b,c){var d=null;null!=b&&null!=c&&(d=b+c,Lg(a,d)||(d=null));return d}function Zg(a,b,c){var d=null;null!=b&&null!=c&&(d=b-c,Lg(a,d)||(d=null));return d}function $g(a,b,c){var d=null;null!=b&&null!=c&&(d=b*c,Lg(a,d)||(d=null));return d}function ah(a,b,c){var d=null;null==b||null==c||!c&&Kg(a,2)||(d=b/c,Lg(a,d)||(d=null));return d} +function bh(a,b,c){if(null!=b&&null!=c){var d=0;isNaN(b)||isNaN(c)?d=17664:(b-=c,0>b?d=256:b||(d=16384));a.fa=a.fa&-18177|d;return!0}return!1}function ch(a,b,c){if(null==b)return null;var d=a.Zb&3072;d?d=1024==d||3072==d&&0=c){if(Kg(a,1))return null;d=-c}else if(d<-c){if(Kg(a,1))return null;d=-c}a.G[0]=d|0;2147483648d&&(a.G[1]=-1))}return d} +function dh(a,b){var c=3;a.C&1<=c;c<<=1)3!=(b&3)&&(a.C|=c),b>>=2}function eh(a){var b=a.B+0&7;return a.C&1<>16}function jh(a){return a.H.ia(a.H.C)}function kh(a){a.ha[0]=a.H.ia(a.H.C);return a.Z[0]}function lh(a){a.G[0]=a.H.ia(a.H.C);a.G[1]=a.H.ia(a.H.C+4);return a.K[0]} +function mh(a){a.D[0]=a.H.ia(a.H.C);a.D[1]=a.H.ia(a.H.C+4);a.D[2]=a.H.ja(a.H.C+8);return a.D}l.mi=function(){this.H.ab(this.H.C,this.G[0])};l.bl=function(){this.H.ab(this.H.C,this.G[0]);this.H.ab(this.H.C+4,this.G[1])};function nh(a){a.H.ab(a.H.C,a.D[0]);a.H.ab(a.H.C+4,a.D[1]);a.H.fb(a.H.C+8,a.D[2])}function oh(a,b){var c=b[1],d=(b[2]&32768)>>4,e=b[2]&32767;b=b[0]>>>11|c<<21;c=c>>11&1048575;32767==e?e=2047:e&&(e+=-15360,0>=e&&(e=2047,b=c=0));a.G[0]=b;a.G[1]=c|(d|e)<<20;return a.K[0]} +function hh(a,b,c){var d=c>>20&2047,e=2147483648|(c&1048575)<<11|b>>>21;2047==d?d=32767:d?d+=15360:e&=2147483647;a.D[0]=b<<11;a.D[1]=e;a.D[2]=c>>16&32768|d;return a.D}function ph(a,b){for(var c=0,d=1;b--;)c+=(a&15)*d,d*=10,a>>=4;return c}function qh(a,b){for(var c=0,d=0;b--;)c|=a%10<>11;Dg(a);Eg(a,d.hb(b+=d.V));!(d.qa&1)||d.O&131072?(a.I=d.hb(b+=d.V),c=d.hb(b+=d.V),a.O=c&2047,a.I|=(c&-4096)<<4,a.M=-1,a.J=d.hb(b+=d.V),a.J|=(d.hb(b+=d.V)&-4096)<<4,a.N=-1):(a.I=d.hb(b+=d.V),c=d.hb(b+=d.V),a.M=c&65535,a.O=c>>16&2047,a.J=d.hb(b+=d.V),a.N=d.hb(b+=d.V)&65535);return b+d.V} +function uh(a,b){var c=a.H;c.yb(b,a.Zb);c.yb(b+=c.V,Bg(a));c.yb(b+=c.V,Cg(a));if(!(c.qa&1)||c.O&131072){var d=(a.M<<4)+a.I;c.yb(b+=c.V,d);c.yb(b+=c.V,d>>4&-4096|a.O);d=(a.N<<4)+a.J;c.yb(b+=c.V,d);c.yb(b+=c.V,d>>4&-4096)}else c.yb(b+=c.V,a.I),c.yb(b+=c.V,a.M|a.O<<16),c.yb(b+=c.V,a.J),c.yb(b+=c.V,a.N);return b+c.V}function vh(){this.fa&=-32896;Dg(this)}function wh(){bh(this,M(this,0),M(this,this.A))}function xh(){bh(this,M(this,0),M(this,this.A))&&rh(this)}function yh(){xh.call(this)} +function zh(){N(this,0,ah(this,M(this,0),kh(this)))}function Ah(){this.C&=~(1<>20&2047)-1023),this.G[1]=(this.G[1]|1072693248)&-1073741825,sh(this,this.K[0]))},102:function(){this.B=this.B-1&7;this.fa&=-513},103:function(){this.B= +this.B+1&7;this.fa&=-513},112:function(){N(this,0,M(this,0)%M(this,1))},113:function(){N(this,1,M(this,1)*Math.log(M(this,0)+1)/Math.LN2)&&rh(this)},114:function(){var a=M(this,0),b=null;if(0<=a||!Kg(this,1))b=Math.sqrt(a),Lg(this,b)||(b=null);N(this,0,b)},116:function(){N(this,0,ch(this,M(this,0),Th))},117:function(){var a=M(this,0),b=M(this,1);null!=a&&null!=b&&N(this,0,a*Math.pow(2,0>>0);sh(this,a)},6:function(){var a=ch(this,rh(this));null!=a&&(this.D[0]=qh(a,8),this.D[1]=qh(a/1E8,8),this.D[2]=qh(a/1E16,2),0>a&&(this.D[2]|=32768),nh(this))},7:function(){null!=ch(this,M(this,0),Th)&&(this.bl(),rh(this))},48:function(){Ah.call(this);rh(this)},49:Nh,50:Ih,51:Ih,52:Lh}},Vh=[vh,Bh,Ch,Dh,Eh,Fh,Jh,Gh,Kh,Lh];Ra(function(){for(var a=pb(document,"pcx86","fpu"),b=0;b>16,c=c<<16>>16,d=d<<16>>16);this.A-=this.B.Ij;(bd)&&y.call(this,5);this.N|=2;return a}function di(a,b){var c=0;if(b){dg(this);for(var d=1;d&this.R;){if(b&d){a=c;break}d<<=1;c++}}else fg(this);this.A-=11+3*c;return a}function ei(a,b){var c=0;if(b){dg(this);for(var d=2==this.V?15:31,e=1<>>=1;c++;d--}}else fg(this);this.A-=11+3*c;return a} +function fi(a,b){a&1<<(b&(2==this.V?15:31))?Xf(this):Yf(this);this.A-=-1===this.C?3:6;this.N|=2;return a}function gi(a,b){b=1<<(b&(2==this.V?15:31));a&b?Xf(this):Yf(this);this.A-=-1===this.C?6:8;return a^b}function hi(a,b){b=1<<(b&(2==this.V?15:31));a&b?Xf(this):Yf(this);this.A-=-1===this.C?6:8;return a&~b}function ii(a,b){b=1<<(b&(2==this.V?15:31));a&b?Xf(this):Yf(this);this.A-=-1===this.C?6:8;return a|b} +function ji(a,b){if(-1===this.C)return fi.call(this,a,b);var c=this.V<<3;if(b>=c||b<-c)a=lg(this,this.eb,this.wb+(b>>(2==this.V?4:5))*this.V);b=1<<(b&(2==this.V?15:31));a&b?Xf(this):Yf(this);this.A-=6;this.N|=2;return a}function ki(a,b){if(-1===this.C)return gi.call(this,a,b);var c=this.V<<3;if(b>=c||b<-c)a=lg(this,this.eb,this.wb+(b>>(2==this.V?4:5))*this.V);b=1<<(b&(2==this.V?15:31));a&b?Xf(this):Yf(this);this.A-=8;return a^b} +function li(a,b){if(-1===this.C)return hi.call(this,a,b);var c=this.V<<3;if(b>=c||b<-c)a=lg(this,this.eb,this.wb+(b>>(2==this.V?4:5))*this.V);b=1<<(b&(2==this.V?15:31));a&b?Xf(this):Yf(this);this.A-=8;return a&~b}function mi(a,b){if(-1===this.C)return ii.call(this,a,b);var c=this.V<<3;if(b>=c||b<-c)a=lg(this,this.eb,this.wb+(b>>(2==this.V?4:5))*this.V);b=1<<(b&(2==this.V?15:31));a&b?Xf(this):Yf(this);this.A-=8;return a|b} +function ni(a,b){Pf(this,a,b,a-b|0,191,!0);this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ah:this.B.Ib;this.N|=2;return a}function oi(a,b){Pf(this,a,b,a-b|0,this.Fb|63,!0);this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ah:this.B.Ib;this.N|=2;return a} +function pi(a){if(this.Tc){var b=this.Tc,c=this.sj,d=this.ga,e=d>>3&7;b.A=d&7;var f=(3>(d>>6&3)?0:48)+e;(217==c||219==c)&&52<=f&&(f=e<<4|b.A);if(e=Uh[c][f]){if(0>Vh.indexOf(e)){var f=b.H,g=f.Bd;8087==b.ca&&(f.ha&16&&g++,f.ha&32&&g++);b.M=f.Z.U;b.I=g-f.Z.ua;-1!==f.C&&(b.N=f.eb.U,b.J=f.C-f.eb.ua);b.O=(c&7)<<8|d}e.call(b)}}this.A-=-1===this.C?2:8;return a}function qi(a){if(80186>this.ca)return ri.call(this,a);y.call(this,13,0);return a}function He(a){y.call(this,6);return a} +function ri(a){Ke.call(this);return a}function si(a,b){a=ti.call(this,this.S(),b);80386>this.ca&&(this.A-=12);return a}function ui(a,b){a=this.Ea();a=2==this.V?ti.call(this,a,b):vi.call(this,a,b);80386>this.ca&&(this.A-=12);return a}function wi(a,b){var c=!1;0>b&&(b=-b|0,c=!c);0>a&&(a=-a|0,c=!c);xi.call(this,a,b);c&&(this.Ba=~this.Ba+1|0,this.$a=~this.$a+(this.Ba?0:1)|0)} +function ti(a,b){a=(a<<16>>16)*(b<<16>>16)|0;32767a?(Xf(this),Zf(this)):(Yf(this),$f(this));this.A-=-1===this.C?9:12;return a&65535}function vi(a,b){wi.call(this,a,b);this.$a!=this.Ba>>31?(Xf(this),Zf(this)):(Yf(this),$f(this));this.A-=-1===this.C?9:12;return this.Ba}function yi(a,b){this.A-=14+(-1===this.C?0:2);dg(this);-1!==this.xb.load(b)&&this.xb.qc>=this.Ma&&this.xb.qc>=(b&3)&&(fg(this),a=this.xb.jb&-256,2=this.Ma)&&this.xb.qc>=(b&3))return fg(this),this.xb.Ka;dg(this);return a}function Fi(a,b){if(-1===this.C)return Ke.call(this),a;Td(this,this.ja(this.C+this.V));this.A-=this.B.Xe;return b} +function Gi(a,b){this.A-=-1===this.F?-1===this.C?this.B.sk:this.B.rk:this.B.pk;return b}function Hi(a,b){switch(this.ga>>3&7){case 4:this.ya=this.D;break;case 5:this.ya=this.I;break;case 6:this.ya=this.L;break;case 7:this.ya=this.G}return b}function Ii(a,b){return b} +function Ji(a,b){a=this.ga>>3&7;switch(a){case 0:this.ya=this.D;break;case 2:this.ya=this.L;break;case 3:this.ya=this.G;break;default:if(80286==this.ca||80386==this.ca&&4!=a&&5!=a)y.call(this,6);else switch(a){case 1:this.ya=this.I;break;case 4:this.ya=z(this);break;case 5:this.ya=this.M;break;case 6:this.ya=this.K;break;case 7:this.ya=this.J}}return Gi.call(this,0,b)} +function Ki(a,b){switch(this.ga>>3&7){case 0:b=this.oa.U;break;case 1:b=this.Z.U;break;case 2:b=this.Y.U;break;case 3:b=this.Ca.U;break;case 4:if(80386<=this.ca){b=this.Ga.U;break}y.call(this,6);b=a;break;case 5:if(80386<=this.ca){b=this.Ha.U;break}default:y.call(this,6),b=a}-1!==this.F&&Xd(this,2);return Gi.call(this,0,b)} +function xi(a,b){if(a&-65536||b&-65536){var c=b&65535;b>>>=16;var d=a&65535;a>>>=16;var e=c*d,d=(e>>>16)+b*d,f=d>>>16,d=(d&65535)+c*a;this.Ba=d<<16|e&65535;this.$a=f+((d>>>16)+b*a)|0}else this.Ba=a*b|0,this.$a=0}function Li(a,b){this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return Wf(this,a|b,128)}function Mi(a,b){this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return Wf(this,a|b,this.Fb)&this.R} +function Ni(a,b){var c=a-b-bg(this)|0;Pf(this,a,b,c,191,!0);this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return c&255}function Oi(a,b){var c=a-b-bg(this)|0;Pf(this,a,b,c,this.Fb|63,!0);this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return c&this.R}function Pi(){return Vf(this)?1:0}function $i(){return Qf(this)?1:0}function aj(){return Qf(this)?0:1}function bj(){return Tf(this)?1:0}function cj(){return Tf(this)?0:1}function dj(){return Qf(this)||Tf(this)?1:0} +function ej(){return Qf(this)||Tf(this)?0:1}function fj(){return Uf(this)?1:0}function gj(){return Uf(this)?0:1}function hj(){return Rf(this)?1:0}function ij(){return Rf(this)?0:1}function jj(){return!Uf(this)!=!Vf(this)?1:0}function kj(){return!Uf(this)!=!Vf(this)?0:1}function lj(){return Tf(this)||!Uf(this)!=!Vf(this)?1:0}function mj(){return Tf(this)||!Uf(this)!=!Vf(this)?0:1}function nj(a,b){return oj.call(this,a,b,this.ra())}function pj(a,b){return qj.call(this,a,b,this.ra())} +function rj(a,b){return oj.call(this,a,b,this.I&31)}function sj(a,b){return qj.call(this,a,b,this.I&31)}function tj(a,b){return uj.call(this,a,b,this.ra())}function vj(a,b){return wj.call(this,a,b,this.ra())}function xj(a,b){return uj.call(this,a,b,this.I&31)}function yj(a,b){return wj.call(this,a,b,this.I&31)}function zj(a,b){var c=a-b|0;Pf(this,a,b,c,191,!0);this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return c&255} +function Aj(a,b){var c=a-b|0;Pf(this,a,b,c,this.Fb|63,!0);this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return c&this.R}function Bj(a,b){Wf(this,a&b,128);this.A-=-1===this.F?-1===this.C?this.B.bi:this.B.Gf:this.B.Gf;this.N|=2;return a}function Cj(a,b){Wf(this,a&b,this.Fb);this.A-=-1===this.F?-1===this.C?this.B.bi:this.B.Gf:this.B.Gf;this.N|=2;return a}function Dj(a,b){var c=this.D&this.R,d=(1<<(this.I&31))-1;return a&~(d<>(this.D&this.R)&(1<<(this.I&31))-1&this.R}function Fj(a,b){if(-1===this.C){switch(this.ga&7){case 0:this.D=this.D&-256|a;break;case 1:this.I=this.I&-256|a;break;case 2:this.L=this.L&-256|a;break;case 3:this.G=this.G&-256|a;break;case 4:this.D=this.D&-65281|a<<8;break;case 5:this.I=this.I&-65281|a<<8;break;case 6:this.L=this.L&-65281|a<<8;break;case 7:this.G=this.G&-65281|a<<8}this.A-=this.B.di}else this.F=this.C,og(this,a),this.A-=this.B.ci;return b} +function Gj(a,b){if(-1===this.C){switch(this.ga&7){case 0:this.D=this.D&~this.R|a;break;case 1:this.I=this.I&~this.R|a;break;case 2:this.L=this.L&~this.R|a;break;case 3:this.G=this.G&~this.R|a;break;case 4:Ud(this,z(this)&~this.R|a);break;case 5:this.M=this.G&~this.R|a;break;case 6:this.K=this.K&~this.R|a;break;case 7:this.J=this.J&~this.R|a}this.A-=this.B.di}else this.F=this.C,this.N&2||this.yb(this.eb.cc(this.wb,this.V),a),this.A-=this.B.ci;return b} +function Hj(a,b){a^=b;Wf(this,a,128);this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return a}function Ij(a,b){this.A-=-1===this.F?-1===this.C?this.B.mc:this.B.Ib:this.B.Ac;return Wf(this,a^b,this.Fb)&this.R}function Jj(a,b){var c=a[1]-b[1];c||(c=a[0]-b[0]);return c}function Kj(a){var b=a-1|0;Pf(this,a,1,b,this.Fb|62,!0);this.A-=2;return a&~this.R|b&this.R} +function Lj(a,b,c){c>>>=0;if(!c||c<=b>>>0)return!1;var d=0,e=1;c=[c>>>0,0];for(a=[a>>>0,b>>>0];0>>=0,b[1]++);e+=e}do 0<=Jj(a,c)&&(b=a,f=c,b[0]-=f[0],b[1]-=f[1],0>b[0]&&(b[0]>>>=0,b[1]--),d+=e),b=c,b[0]>>>=1,b[1]&1&&(b[0]=(b[0]|2147483648)>>>0),b[1]>>>=1,e/=2;while(1<=e);this.Ba=d;this.$a=a[0];return!0}function Mj(a){var b=a+1|0;Pf(this,a,1,b,this.Fb|62);this.A-=2;return a&~this.R|b&this.R} +function Nj(a){this.qa=a;Wd(this);this.qa&-2147483648?Ve(this):Ye(this)}function ge(a){this.Wc=a;ec(this)}function Oj(a){this.N|=1;this.tc.call(this,a);this.A-=-1===this.C?4:5}function oj(a,b,c){if(c){16>>16-c)&65535;Wf(this,a,32768,d&32768)}return a}function qj(a,b,c){if(c){var d=a<>>32-c;Wf(this,a,-2147483648,d&-2147483648)}return a} +function uj(a,b,c){if(c){16>>c-1;a=(d>>>1|b<<16-c)&65535;Wf(this,a,32768,d&1)}return a}function wj(a,b,c){if(c){var d=a>>>c-1;a=d>>>1|b<<32-c;Wf(this,a,-2147483648,d&1)}return a}function Pj(){this.A-=-1===this.C?2:this.B.Fk;return 1}function Qj(){var a=this.I&255;this.A-=(-1===this.C?this.B.Vh:this.B.Uh)+(a<this.Uc?(-1!=this.Ad&&(this.Ad!==this.Z.U&&(this.Z.Ab=this.Ad&3,Lf(this,this.Ad)),this.Ad=-1),this.Bd!==this.da&&Mf(this,this.Bd),-1!=this.Vc&&(this.Vc!==this.Y.U&&Td(this,this.Vc),this.Vc=-1),-1!==this.ta&&(this.ta!==this.Aa&&Ud(this,this.Hc&~this.Y.wa|this.ta-this.Y.ua),this.ta=-1)):8!=this.Uc?(b=0,a=8):(b=0,a=-1,Te(this),e=d=!1)):Mf(this,this.Bd);var f=a,g=b,h=32,k=ig(this,this.da);204!=k||this.cd||(d=!1);this.O&131072&&(6== +f&&99==k||13==f&&205==k)&&(d=!1);!1===d&&(h|=1);983040<=this.da&&1048575>=this.da&&(d=!1);t(this,h|-2147483648)&&(d=!0);if(t(this,h)||d){var m=this.ea.vb,f="Fault "+r(f)+(null!=g?" ("+ka(g)+")":"")+" on opcode "+r(k);d&&m&&(f+=" (blocked)");this.ba?(wb(this,f,d||h,!0),d&&(d=m,this.ba.Jb())):(this.Fa(f),this.Jb())}if(d&&e)throw-1;if(e)throw this.Uc=a,Vj.call(this,a,b,c),this.Bd=this.da,this.N=1==a?this.N|8192:this.N|4096,a;} +function Xe(a,b,c){this.Cd=a;a=0;b&&(a|=1);c&&(a|=2);3==this.Ma&&(a|=4);y.call(this,14,a)}function Xj(a){var b=a.jb&7680;a.U&65528&&(6144==b||7168==b||7168>b&&a.qc>8&255;break;case 197:c=this.I>>8&255;break;case 198:c=this.L>>8&255;break;case 199:c=this.G>>8&255;break;default:c=0}var d=this.ga>>3&7;switch(d){case 0:b=this.D&255;break;case 1:b=this.I&255;break;case 2:b=this.L&255;break;case 3:b=this.G&255;break;case 4:b=this.D>>8&255;break;case 5:b=this.I>>8&255;break;case 6:b=this.L>>8&255;break;case 7:b=this.G>>8&255;break;default:b=0}a=a.call(this,b,c);switch(d){case 0:this.D= +this.D&-256|a;break;case 1:this.I=this.I&-256|a;break;case 2:this.L=this.L&-256|a;break;case 3:this.G=this.G&-256|a;break;case 4:this.D=this.D&-65281|a<<8;break;case 5:this.I=this.I&-65281|a<<8;break;case 6:this.L=this.L&-65281|a<<8;break;case 7:this.G=this.G&-65281|a<<8}} +function ff(a){var b,c,d=(this.ga=this.ra())&199;switch(d){case 0:b=D(this,this.G+this.K);this.F=this.C;break;case 1:b=D(this,this.G+this.J);this.F=this.C;break;case 2:b=kg(this,this.M+this.K);this.F=this.C;break;case 3:b=kg(this,this.M+this.J);this.F=this.C;break;case 4:b=D(this,this.K);this.F=this.C;break;case 5:b=D(this,this.J);this.F=this.C;break;case 6:b=D(this,J(this));this.F=this.C;break;case 7:b=D(this,this.G);this.F=this.C;break;case 64:b=D(this,this.G+this.K+this.S());this.F=this.C;break; +case 65:b=D(this,this.G+this.J+this.S());this.F=this.C;break;case 66:b=kg(this,this.M+this.K+this.S());this.F=this.C;break;case 67:b=kg(this,this.M+this.J+this.S());this.F=this.C;break;case 68:b=D(this,this.K+this.S());this.F=this.C;break;case 69:b=D(this,this.J+this.S());this.F=this.C;break;case 70:b=kg(this,this.M+this.S());this.F=this.C;break;case 71:b=D(this,this.G+this.S());this.F=this.C;break;case 128:b=D(this,this.G+this.K+J(this));this.F=this.C;break;case 129:b=D(this,this.G+this.J+J(this)); +this.F=this.C;break;case 130:b=kg(this,this.M+this.K+J(this));this.F=this.C;break;case 131:b=kg(this,this.M+this.J+J(this));this.F=this.C;break;case 132:b=D(this,this.K+J(this));this.F=this.C;break;case 133:b=D(this,this.J+J(this));this.F=this.C;break;case 134:b=kg(this,this.M+J(this));this.F=this.C;break;case 135:b=D(this,this.G+J(this));this.F=this.C;break;case 192:b=this.D&255;break;case 193:b=this.I&255;break;case 194:b=this.L&255;break;case 195:b=this.G&255;break;case 196:b=this.D>>8&255;break; +case 197:b=this.I>>8&255;break;case 198:b=this.L>>8&255;break;case 199:b=this.G>>8&255;break;default:b=0}switch(this.ga>>3&7){case 0:c=this.D&255;break;case 1:c=this.I&255;break;case 2:c=this.L&255;break;case 3:c=this.G&255;break;case 4:c=this.D>>8&255;break;case 5:c=this.I>>8&255;break;case 6:c=this.L>>8&255;break;case 7:c=this.G>>8&255;break;default:c=0}a=a.call(this,b,c);switch(d){case 0:case 3:og(this,a);this.A-=this.B.Rc;break;case 1:case 2:og(this,a);this.A-=this.B.Sc;break;case 4:case 5:case 7:og(this, +a);this.A-=this.B.wc;break;case 6:og(this,a);this.A-=this.B.td;break;case 64:case 67:case 128:case 131:og(this,a);this.A-=this.B.Tb;break;case 65:case 66:case 129:case 130:og(this,a);this.A-=this.B.Ub;break;case 68:case 69:case 70:case 71:case 132:case 133:case 134:case 135:og(this,a);this.A-=this.B.Va;break;case 192:this.D=this.D&-256|a;break;case 193:this.I=this.I&-256|a;break;case 194:this.L=this.L&-256|a;break;case 195:this.G=this.G&-256|a;break;case 196:this.D=this.D&-65281|a<<8;break;case 197:this.I= +this.I&-65281|a<<8;break;case 198:this.L=this.L&-65281|a<<8;break;case 199:this.G=this.G&-65281|a<<8}} +function gf(a,b){var c,d=(this.ga=this.ra())&199;switch(d){case 0:c=D(this,this.G+this.K);this.F=this.C;break;case 1:c=D(this,this.G+this.J);this.F=this.C;break;case 2:c=kg(this,this.M+this.K);this.F=this.C;break;case 3:c=kg(this,this.M+this.J);this.F=this.C;break;case 4:c=D(this,this.K);this.F=this.C;break;case 5:c=D(this,this.J);this.F=this.C;break;case 6:c=D(this,J(this));this.F=this.C;break;case 7:c=D(this,this.G);this.F=this.C;break;case 64:c=D(this,this.G+this.K+this.S());this.F=this.C;break; +case 65:c=D(this,this.G+this.J+this.S());this.F=this.C;break;case 66:c=kg(this,this.M+this.K+this.S());this.F=this.C;break;case 67:c=kg(this,this.M+this.J+this.S());this.F=this.C;break;case 68:c=D(this,this.K+this.S());this.F=this.C;break;case 69:c=D(this,this.J+this.S());this.F=this.C;break;case 70:c=kg(this,this.M+this.S());this.F=this.C;break;case 71:c=D(this,this.G+this.S());this.F=this.C;break;case 128:c=D(this,this.G+this.K+J(this));this.F=this.C;break;case 129:c=D(this,this.G+this.J+J(this)); +this.F=this.C;break;case 130:c=kg(this,this.M+this.K+J(this));this.F=this.C;break;case 131:c=kg(this,this.M+this.J+J(this));this.F=this.C;break;case 132:c=D(this,this.K+J(this));this.F=this.C;break;case 133:c=D(this,this.J+J(this));this.F=this.C;break;case 134:c=kg(this,this.M+J(this));this.F=this.C;break;case 135:c=D(this,this.G+J(this));this.F=this.C;break;case 192:c=this.D&255;break;case 193:c=this.I&255;break;case 194:c=this.L&255;break;case 195:c=this.G&255;break;case 196:c=this.D>>8&255;break; +case 197:c=this.I>>8&255;break;case 198:c=this.L>>8&255;break;case 199:c=this.G>>8&255;break;default:c=0}a=a[this.ga>>3&7].call(this,c,b.call(this));switch(d){case 0:case 3:og(this,a);this.A-=this.B.Rc;break;case 1:case 2:og(this,a);this.A-=this.B.Sc;break;case 4:case 5:case 7:og(this,a);this.A-=this.B.wc;break;case 6:og(this,a);this.A-=this.B.td;break;case 64:case 67:case 128:case 131:og(this,a);this.A-=this.B.Tb;break;case 65:case 66:case 129:case 130:og(this,a);this.A-=this.B.Ub;break;case 68:case 69:case 70:case 71:case 132:case 133:case 134:case 135:og(this, +a);this.A-=this.B.Va;break;case 192:this.D=this.D&-256|a;break;case 193:this.I=this.I&-256|a;break;case 194:this.L=this.L&-256|a;break;case 195:this.G=this.G&-256|a;break;case 196:this.D=this.D&-65281|a<<8;break;case 197:this.I=this.I&-65281|a<<8;break;case 198:this.L=this.L&-65281|a<<8;break;case 199:this.G=this.G&-65281|a<<8}} +function hf(a){var b,c;switch((this.ga=this.ra())&199){case 0:c=E(this,this.G+this.K);this.A-=this.B.Rc;break;case 1:c=E(this,this.G+this.J);this.A-=this.B.Sc;break;case 2:c=mg(this,this.M+this.K);this.A-=this.B.Sc;break;case 3:c=mg(this,this.M+this.J);this.A-=this.B.Rc;break;case 4:c=E(this,this.K);this.A-=this.B.wc;break;case 5:c=E(this,this.J);this.A-=this.B.wc;break;case 6:c=E(this,J(this));this.A-=this.B.td;break;case 7:c=E(this,this.G);this.A-=this.B.wc;break;case 64:c=E(this,this.G+this.K+ +this.S());this.A-=this.B.Tb;break;case 65:c=E(this,this.G+this.J+this.S());this.A-=this.B.Ub;break;case 66:c=mg(this,this.M+this.K+this.S());this.A-=this.B.Ub;break;case 67:c=mg(this,this.M+this.J+this.S());this.A-=this.B.Tb;break;case 68:c=E(this,this.K+this.S());this.A-=this.B.Va;break;case 69:c=E(this,this.J+this.S());this.A-=this.B.Va;break;case 70:c=mg(this,this.M+this.S());this.A-=this.B.Va;break;case 71:c=E(this,this.G+this.S());this.A-=this.B.Va;break;case 128:c=E(this,this.G+this.K+J(this)); +this.A-=this.B.Tb;break;case 129:c=E(this,this.G+this.J+J(this));this.A-=this.B.Ub;break;case 130:c=mg(this,this.M+this.K+J(this));this.A-=this.B.Ub;break;case 131:c=mg(this,this.M+this.J+J(this));this.A-=this.B.Tb;break;case 132:c=E(this,this.K+J(this));this.A-=this.B.Va;break;case 133:c=E(this,this.J+J(this));this.A-=this.B.Va;break;case 134:c=mg(this,this.M+J(this));this.A-=this.B.Va;break;case 135:c=E(this,this.G+J(this));this.A-=this.B.Va;break;case 192:c=this.D&65535;break;case 193:c=this.I& +65535;break;case 194:c=this.L&65535;break;case 195:c=this.G&65535;break;case 196:c=z(this)&65535;break;case 197:c=this.M&65535;break;case 198:c=this.K&65535;break;case 199:c=this.J&65535;break;default:c=0}var d=this.ga>>3&7;switch(d){case 0:b=this.D&65535;break;case 1:b=this.I&65535;break;case 2:b=this.L&65535;break;case 3:b=this.G&65535;break;case 4:b=z(this)&65535;break;case 5:b=this.M&65535;break;case 6:b=this.K&65535;break;case 7:b=this.J&65535;break;default:b=0}a=a.call(this,b,c);switch(d){case 0:this.D= +this.D&-65536|a;break;case 1:this.I=this.I&-65536|a;break;case 2:this.L=this.L&-65536|a;break;case 3:this.G=this.G&-65536|a;break;case 4:Ud(this,z(this)&-65536|a);break;case 5:this.M=this.M&-65536|a;break;case 6:this.K=this.K&-65536|a;break;case 7:this.J=this.J&-65536|a}} +function jf(a){var b,c,d=(this.ga=this.ra())&199;switch(d){case 0:b=E(this,this.G+this.K);this.F=this.C;break;case 1:b=E(this,this.G+this.J);this.F=this.C;break;case 2:b=mg(this,this.M+this.K);this.F=this.C;break;case 3:b=mg(this,this.M+this.J);this.F=this.C;break;case 4:b=E(this,this.K);this.F=this.C;break;case 5:b=E(this,this.J);this.F=this.C;break;case 6:b=E(this,J(this));this.F=this.C;break;case 7:b=E(this,this.G);this.F=this.C;break;case 64:b=E(this,this.G+this.K+this.S());this.F=this.C;break; +case 65:b=E(this,this.G+this.J+this.S());this.F=this.C;break;case 66:b=mg(this,this.M+this.K+this.S());this.F=this.C;break;case 67:b=mg(this,this.M+this.J+this.S());this.F=this.C;break;case 68:b=E(this,this.K+this.S());this.F=this.C;break;case 69:b=E(this,this.J+this.S());this.F=this.C;break;case 70:b=mg(this,this.M+this.S());this.F=this.C;break;case 71:b=E(this,this.G+this.S());this.F=this.C;break;case 128:b=E(this,this.G+this.K+J(this));this.F=this.C;break;case 129:b=E(this,this.G+this.J+J(this)); +this.F=this.C;break;case 130:b=mg(this,this.M+this.K+J(this));this.F=this.C;break;case 131:b=mg(this,this.M+this.J+J(this));this.F=this.C;break;case 132:b=E(this,this.K+J(this));this.F=this.C;break;case 133:b=E(this,this.J+J(this));this.F=this.C;break;case 134:b=mg(this,this.M+J(this));this.F=this.C;break;case 135:b=E(this,this.G+J(this));this.F=this.C;break;case 192:b=this.D&65535;break;case 193:b=this.I&65535;break;case 194:b=this.L&65535;break;case 195:b=this.G&65535;break;case 196:b=z(this)&65535; +break;case 197:b=this.M&65535;break;case 198:b=this.K&65535;break;case 199:b=this.J&65535;break;default:b=0}switch(this.ga>>3&7){case 0:c=this.D&65535;break;case 1:c=this.I&65535;break;case 2:c=this.L&65535;break;case 3:c=this.G&65535;break;case 4:c=z(this)&65535;break;case 5:c=this.M&65535;break;case 6:c=this.K&65535;break;case 7:c=this.J&65535;break;default:c=0}a=a.call(this,b,c);switch(d){case 0:case 3:pg(this,a);this.A-=this.B.Rc;break;case 1:case 2:pg(this,a);this.A-=this.B.Sc;break;case 4:case 5:case 7:pg(this, +a);this.A-=this.B.wc;break;case 6:pg(this,a);this.A-=this.B.td;break;case 64:case 67:case 128:case 131:pg(this,a);this.A-=this.B.Tb;break;case 65:case 66:case 129:case 130:pg(this,a);this.A-=this.B.Ub;break;case 68:case 69:case 70:case 71:case 132:case 133:case 134:case 135:pg(this,a);this.A-=this.B.Va;break;case 192:this.D=this.D&-65536|a;break;case 193:this.I=this.I&-65536|a;break;case 194:this.L=this.L&-65536|a;break;case 195:this.G=this.G&-65536|a;break;case 196:Ud(this,z(this)&-65536|a);break; +case 197:this.M=this.M&-65536|a;break;case 198:this.K=this.K&-65536|a;break;case 199:this.J=this.J&-65536|a}} +function kf(a,b){var c,d=(this.ga=this.ra())&199;switch(d){case 0:c=E(this,this.G+this.K);this.F=this.C;break;case 1:c=E(this,this.G+this.J);this.F=this.C;break;case 2:c=mg(this,this.M+this.K);this.F=this.C;break;case 3:c=mg(this,this.M+this.J);this.F=this.C;break;case 4:c=E(this,this.K);this.F=this.C;break;case 5:c=E(this,this.J);this.F=this.C;break;case 6:c=E(this,J(this));this.F=this.C;break;case 7:c=E(this,this.G);this.F=this.C;break;case 64:c=E(this,this.G+this.K+this.S());this.F=this.C;break; +case 65:c=E(this,this.G+this.J+this.S());this.F=this.C;break;case 66:c=mg(this,this.M+this.K+this.S());this.F=this.C;break;case 67:c=mg(this,this.M+this.J+this.S());this.F=this.C;break;case 68:c=E(this,this.K+this.S());this.F=this.C;break;case 69:c=E(this,this.J+this.S());this.F=this.C;break;case 70:c=mg(this,this.M+this.S());this.F=this.C;break;case 71:c=E(this,this.G+this.S());this.F=this.C;break;case 128:c=E(this,this.G+this.K+J(this));this.F=this.C;break;case 129:c=E(this,this.G+this.J+J(this)); +this.F=this.C;break;case 130:c=mg(this,this.M+this.K+J(this));this.F=this.C;break;case 131:c=mg(this,this.M+this.J+J(this));this.F=this.C;break;case 132:c=E(this,this.K+J(this));this.F=this.C;break;case 133:c=E(this,this.J+J(this));this.F=this.C;break;case 134:c=mg(this,this.M+J(this));this.F=this.C;break;case 135:c=E(this,this.G+J(this));this.F=this.C;break;case 192:c=this.D&65535;break;case 193:c=this.I&65535;break;case 194:c=this.L&65535;break;case 195:c=this.G&65535;break;case 196:c=z(this)&65535; +break;case 197:c=this.M&65535;break;case 198:c=this.K&65535;break;case 199:c=this.J&65535;break;default:c=0}a=a[this.ga>>3&7].call(this,c,b.call(this));switch(d){case 0:case 3:pg(this,a);this.A-=this.B.Rc;break;case 1:case 2:pg(this,a);this.A-=this.B.Sc;break;case 4:case 5:case 7:pg(this,a);this.A-=this.B.wc;break;case 6:pg(this,a);this.A-=this.B.td;break;case 64:case 67:case 128:case 131:pg(this,a);this.A-=this.B.Tb;break;case 65:case 66:case 129:case 130:pg(this,a);this.A-=this.B.Ub;break;case 68:case 69:case 70:case 71:case 132:case 133:case 134:case 135:pg(this, +a);this.A-=this.B.Va;break;case 192:this.D=this.D&-65536|a;break;case 193:this.I=this.I&-65536|a;break;case 194:this.L=this.L&-65536|a;break;case 195:this.G=this.G&-65536|a;break;case 196:Ud(this,z(this)&-65536|a);break;case 197:this.M=this.M&-65536|a;break;case 198:this.K=this.K&-65536|a;break;case 199:this.J=this.J&-65536|a}} +function lf(a){var b,c;switch((this.ga=this.ra())&199){case 0:c=G(this,this.G+this.K);this.A-=this.B.Rc;break;case 1:c=G(this,this.G+this.J);this.A-=this.B.Sc;break;case 2:c=ng(this,this.M+this.K);this.A-=this.B.Sc;break;case 3:c=ng(this,this.M+this.J);this.A-=this.B.Rc;break;case 4:c=G(this,this.K);this.A-=this.B.wc;break;case 5:c=G(this,this.J);this.A-=this.B.wc;break;case 6:c=G(this,J(this));this.A-=this.B.td;break;case 7:c=G(this,this.G);this.A-=this.B.wc;break;case 64:c=G(this,this.G+this.K+ +this.S());this.A-=this.B.Tb;break;case 65:c=G(this,this.G+this.J+this.S());this.A-=this.B.Ub;break;case 66:c=ng(this,this.M+this.K+this.S());this.A-=this.B.Ub;break;case 67:c=ng(this,this.M+this.J+this.S());this.A-=this.B.Tb;break;case 68:c=G(this,this.K+this.S());this.A-=this.B.Va;break;case 69:c=G(this,this.J+this.S());this.A-=this.B.Va;break;case 70:c=ng(this,this.M+this.S());this.A-=this.B.Va;break;case 71:c=G(this,this.G+this.S());this.A-=this.B.Va;break;case 128:c=G(this,this.G+this.K+J(this)); +this.A-=this.B.Tb;break;case 129:c=G(this,this.G+this.J+J(this));this.A-=this.B.Ub;break;case 130:c=ng(this,this.M+this.K+J(this));this.A-=this.B.Ub;break;case 131:c=ng(this,this.M+this.J+J(this));this.A-=this.B.Tb;break;case 132:c=G(this,this.K+J(this));this.A-=this.B.Va;break;case 133:c=G(this,this.J+J(this));this.A-=this.B.Va;break;case 134:c=ng(this,this.M+J(this));this.A-=this.B.Va;break;case 135:c=G(this,this.G+J(this));this.A-=this.B.Va;break;case 192:c=this.D;break;case 193:c=this.I;break; +case 194:c=this.L;break;case 195:c=this.G;break;case 196:c=z(this);break;case 197:c=this.M;break;case 198:c=this.K;break;case 199:c=this.J;break;default:c=0}var d=this.ga>>3&7;switch(d){case 0:b=this.D;break;case 1:b=this.I;break;case 2:b=this.L;break;case 3:b=this.G;break;case 4:b=z(this);break;case 5:b=this.M;break;case 6:b=this.K;break;case 7:b=this.J;break;default:b=0}a=a.call(this,b,c);switch(d){case 0:this.D=a;break;case 1:this.I=a;break;case 2:this.L=a;break;case 3:this.G=a;break;case 4:Ud(this, +a);break;case 5:this.M=a;break;case 6:this.K=a;break;case 7:this.J=a}} +function rf(a){var b,c,d=(this.ga=this.ra())&199;switch(d){case 0:b=G(this,this.G+this.K);this.F=this.C;break;case 1:b=G(this,this.G+this.J);this.F=this.C;break;case 2:b=ng(this,this.M+this.K);this.F=this.C;break;case 3:b=ng(this,this.M+this.J);this.F=this.C;break;case 4:b=G(this,this.K);this.F=this.C;break;case 5:b=G(this,this.J);this.F=this.C;break;case 6:b=G(this,J(this));this.F=this.C;break;case 7:b=G(this,this.G);this.F=this.C;break;case 64:b=G(this,this.G+this.K+this.S());this.F=this.C;break; +case 65:b=G(this,this.G+this.J+this.S());this.F=this.C;break;case 66:b=ng(this,this.M+this.K+this.S());this.F=this.C;break;case 67:b=ng(this,this.M+this.J+this.S());this.F=this.C;break;case 68:b=G(this,this.K+this.S());this.F=this.C;break;case 69:b=G(this,this.J+this.S());this.F=this.C;break;case 70:b=ng(this,this.M+this.S());this.F=this.C;break;case 71:b=G(this,this.G+this.S());this.F=this.C;break;case 128:b=G(this,this.G+this.K+J(this));this.F=this.C;break;case 129:b=G(this,this.G+this.J+J(this)); +this.F=this.C;break;case 130:b=ng(this,this.M+this.K+J(this));this.F=this.C;break;case 131:b=ng(this,this.M+this.J+J(this));this.F=this.C;break;case 132:b=G(this,this.K+J(this));this.F=this.C;break;case 133:b=G(this,this.J+J(this));this.F=this.C;break;case 134:b=ng(this,this.M+J(this));this.F=this.C;break;case 135:b=G(this,this.G+J(this));this.F=this.C;break;case 192:b=this.D;break;case 193:b=this.I;break;case 194:b=this.L;break;case 195:b=this.G;break;case 196:b=z(this);break;case 197:b=this.M;break; +case 198:b=this.K;break;case 199:b=this.J;break;default:b=0}switch(this.ga>>3&7){case 0:c=this.D;break;case 1:c=this.I;break;case 2:c=this.L;break;case 3:c=this.G;break;case 4:c=z(this);break;case 5:c=this.M;break;case 6:c=this.K;break;case 7:c=this.J;break;default:c=0}a=a.call(this,b,c);switch(d){case 0:case 3:qg(this,a);this.A-=this.B.Rc;break;case 1:case 2:qg(this,a);this.A-=this.B.Sc;break;case 4:case 5:case 7:qg(this,a);this.A-=this.B.wc;break;case 6:qg(this,a);this.A-=this.B.td;break;case 64:case 67:case 128:case 131:qg(this, +a);this.A-=this.B.Tb;break;case 65:case 66:case 129:case 130:qg(this,a);this.A-=this.B.Ub;break;case 68:case 69:case 70:case 71:case 132:case 133:case 134:case 135:qg(this,a);this.A-=this.B.Va;break;case 192:this.D=a;break;case 193:this.I=a;break;case 194:this.L=a;break;case 195:this.G=a;break;case 196:Ud(this,a);break;case 197:this.M=a;break;case 198:this.K=a;break;case 199:this.J=a}} +function sf(a,b){var c,d=(this.ga=this.ra())&199;switch(d){case 0:c=G(this,this.G+this.K);this.F=this.C;break;case 1:c=G(this,this.G+this.J);this.F=this.C;break;case 2:c=ng(this,this.M+this.K);this.F=this.C;break;case 3:c=ng(this,this.M+this.J);this.F=this.C;break;case 4:c=G(this,this.K);this.F=this.C;break;case 5:c=G(this,this.J);this.F=this.C;break;case 6:c=G(this,J(this));this.F=this.C;break;case 7:c=G(this,this.G);this.F=this.C;break;case 64:c=G(this,this.G+this.K+this.S());this.F=this.C;break; +case 65:c=G(this,this.G+this.J+this.S());this.F=this.C;break;case 66:c=ng(this,this.M+this.K+this.S());this.F=this.C;break;case 67:c=ng(this,this.M+this.J+this.S());this.F=this.C;break;case 68:c=G(this,this.K+this.S());this.F=this.C;break;case 69:c=G(this,this.J+this.S());this.F=this.C;break;case 70:c=ng(this,this.M+this.S());this.F=this.C;break;case 71:c=G(this,this.G+this.S());this.F=this.C;break;case 128:c=G(this,this.G+this.K+J(this));this.F=this.C;break;case 129:c=G(this,this.G+this.J+J(this)); +this.F=this.C;break;case 130:c=ng(this,this.M+this.K+J(this));this.F=this.C;break;case 131:c=ng(this,this.M+this.J+J(this));this.F=this.C;break;case 132:c=G(this,this.K+J(this));this.F=this.C;break;case 133:c=G(this,this.J+J(this));this.F=this.C;break;case 134:c=ng(this,this.M+J(this));this.F=this.C;break;case 135:c=G(this,this.G+J(this));this.F=this.C;break;case 192:c=this.D;break;case 193:c=this.I;break;case 194:c=this.L;break;case 195:c=this.G;break;case 196:c=z(this);break;case 197:c=this.M;break; +case 198:c=this.K;break;case 199:c=this.J}a=a[this.ga>>3&7].call(this,c,b.call(this));switch(d){case 0:case 3:qg(this,a);this.A-=this.B.Rc;break;case 1:case 2:qg(this,a);this.A-=this.B.Sc;break;case 4:case 5:case 7:qg(this,a);this.A-=this.B.wc;break;case 6:qg(this,a);this.A-=this.B.td;break;case 64:case 67:case 128:case 131:qg(this,a);this.A-=this.B.Tb;break;case 65:case 66:case 129:case 130:qg(this,a);this.A-=this.B.Ub;break;case 68:case 69:case 70:case 71:case 132:case 133:case 134:case 135:qg(this, +a);this.A-=this.B.Va;break;case 192:this.D=a;break;case 193:this.I=a;break;case 194:this.L=a;break;case 195:this.G=a;break;case 196:Ud(this,a);break;case 197:this.M=a;break;case 198:this.K=a;break;case 199:this.J=a}} +function tf(a){var b,c;switch((this.ga=this.ra())&199){case 0:c=D(this,this.D);break;case 1:c=D(this,this.I);break;case 2:c=D(this,this.L);break;case 3:c=D(this,this.G);break;case 4:c=D(this,Zj.call(this,0));break;case 5:c=D(this,J(this));break;case 6:c=D(this,this.K);break;case 7:c=D(this,this.J);break;case 64:c=D(this,this.D+this.S());break;case 65:c=D(this,this.I+this.S());break;case 66:c=D(this,this.L+this.S());break;case 67:c=D(this,this.G+this.S());break;case 68:c=D(this,Zj.call(this,1)+this.S()); +break;case 69:c=kg(this,this.M+this.S());break;case 70:c=D(this,this.K+this.S());break;case 71:c=D(this,this.J+this.S());break;case 128:c=D(this,this.D+J(this));break;case 129:c=D(this,this.I+J(this));break;case 130:c=D(this,this.L+J(this));break;case 131:c=D(this,this.G+J(this));break;case 132:c=D(this,Zj.call(this,2)+J(this));break;case 133:c=kg(this,this.M+J(this));break;case 134:c=D(this,this.K+J(this));break;case 135:c=D(this,this.J+J(this));break;case 192:c=this.D&255;break;case 193:c=this.I& +255;break;case 194:c=this.L&255;break;case 195:c=this.G&255;break;case 196:c=this.D>>8&255;break;case 197:c=this.I>>8&255;break;case 198:c=this.L>>8&255;break;case 199:c=this.G>>8&255;break;default:c=0}var d=this.ga>>3&7;switch(d){case 0:b=this.D&255;break;case 1:b=this.I&255;break;case 2:b=this.L&255;break;case 3:b=this.G&255;break;case 4:b=this.D>>8&255;break;case 5:b=this.I>>8&255;break;case 6:b=this.L>>8&255;break;case 7:b=this.G>>8&255;break;default:b=0}a=a.call(this,b,c);switch(d){case 0:this.D= +this.D&-256|a;break;case 1:this.I=this.I&-256|a;break;case 2:this.L=this.L&-256|a;break;case 3:this.G=this.G&-256|a;break;case 4:this.D=this.D&-65281|a<<8;break;case 5:this.I=this.I&-65281|a<<8;break;case 6:this.L=this.L&-65281|a<<8;break;case 7:this.G=this.G&-65281|a<<8}} +function uf(a){var b,c,d=(this.ga=this.ra())&199;switch(d){case 0:b=D(this,this.D);this.F=this.C;break;case 1:b=D(this,this.I);this.F=this.C;break;case 2:b=D(this,this.L);this.F=this.C;break;case 3:b=D(this,this.G);this.F=this.C;break;case 4:b=D(this,Zj.call(this,0));this.F=this.C;break;case 5:b=D(this,J(this));this.F=this.C;break;case 6:b=D(this,this.K);this.F=this.C;break;case 7:b=D(this,this.J);this.F=this.C;break;case 64:b=D(this,this.D+this.S());this.F=this.C;break;case 65:b=D(this,this.I+this.S()); +this.F=this.C;break;case 66:b=D(this,this.L+this.S());this.F=this.C;break;case 67:b=D(this,this.G+this.S());this.F=this.C;break;case 68:b=D(this,Zj.call(this,1)+this.S());this.F=this.C;break;case 69:b=kg(this,this.M+this.S());this.F=this.C;break;case 70:b=D(this,this.K+this.S());this.F=this.C;break;case 71:b=D(this,this.J+this.S());this.F=this.C;break;case 128:b=D(this,this.D+J(this));this.F=this.C;break;case 129:b=D(this,this.I+J(this));this.F=this.C;break;case 130:b=D(this,this.L+J(this));this.F= +this.C;break;case 131:b=D(this,this.G+J(this));this.F=this.C;break;case 132:b=D(this,Zj.call(this,2)+J(this));this.F=this.C;break;case 133:b=kg(this,this.M+J(this));this.F=this.C;break;case 134:b=D(this,this.K+J(this));this.F=this.C;break;case 135:b=D(this,this.J+J(this));this.F=this.C;break;case 192:b=this.D&255;break;case 193:b=this.I&255;break;case 194:b=this.L&255;break;case 195:b=this.G&255;break;case 196:b=this.D>>8&255;break;case 197:b=this.I>>8&255;break;case 198:b=this.L>>8&255;break;case 199:b= +this.G>>8&255;break;default:b=0}switch(this.ga>>3&7){case 0:c=this.D&255;break;case 1:c=this.I&255;break;case 2:c=this.L&255;break;case 3:c=this.G&255;break;case 4:c=this.D>>8&255;break;case 5:c=this.I>>8&255;break;case 6:c=this.L>>8&255;break;case 7:c=this.G>>8&255;break;default:c=0}a=a.call(this,b,c);switch(d){case 192:this.D=this.D&-256|a;break;case 193:this.I=this.I&-256|a;break;case 194:this.L=this.L&-256|a;break;case 195:this.G=this.G&-256|a;break;case 196:this.D=this.D&-65281|a<<8;break;case 197:this.I= +this.I&-65281|a<<8;break;case 198:this.L=this.L&-65281|a<<8;break;case 199:this.G=this.G&-65281|a<<8;break;default:og(this,a)}} +function vf(a,b){var c,d=(this.ga=this.ra())&199;switch(d){case 0:c=D(this,this.D);this.F=this.C;break;case 1:c=D(this,this.I);this.F=this.C;break;case 2:c=D(this,this.L);this.F=this.C;break;case 3:c=D(this,this.G);this.F=this.C;break;case 4:c=D(this,Zj.call(this,0));this.F=this.C;break;case 5:c=D(this,J(this));this.F=this.C;break;case 6:c=D(this,this.K);this.F=this.C;break;case 7:c=D(this,this.J);this.F=this.C;break;case 64:c=D(this,this.D+this.S());this.F=this.C;break;case 65:c=D(this,this.I+this.S()); +this.F=this.C;break;case 66:c=D(this,this.L+this.S());this.F=this.C;break;case 67:c=D(this,this.G+this.S());this.F=this.C;break;case 68:c=D(this,Zj.call(this,1)+this.S());this.F=this.C;break;case 69:c=kg(this,this.M+this.S());this.F=this.C;break;case 70:c=D(this,this.K+this.S());this.F=this.C;break;case 71:c=D(this,this.J+this.S());this.F=this.C;break;case 128:c=D(this,this.D+J(this));this.F=this.C;break;case 129:c=D(this,this.I+J(this));this.F=this.C;break;case 130:c=D(this,this.L+J(this));this.F= +this.C;break;case 131:c=D(this,this.G+J(this));this.F=this.C;break;case 132:c=D(this,Zj.call(this,2)+J(this));this.F=this.C;break;case 133:c=kg(this,this.M+J(this));this.F=this.C;break;case 134:c=D(this,this.K+J(this));this.F=this.C;break;case 135:c=D(this,this.J+J(this));this.F=this.C;break;case 192:c=this.D&255;break;case 193:c=this.I&255;break;case 194:c=this.L&255;break;case 195:c=this.G&255;break;case 196:c=this.D>>8&255;break;case 197:c=this.I>>8&255;break;case 198:c=this.L>>8&255;break;case 199:c= +this.G>>8&255;break;default:c=0}a=a[this.ga>>3&7].call(this,c,b.call(this));switch(d){case 192:this.D=this.D&-256|a;break;case 193:this.I=this.I&-256|a;break;case 194:this.L=this.L&-256|a;break;case 195:this.G=this.G&-256|a;break;case 196:this.D=this.D&-65281|a<<8;break;case 197:this.I=this.I&-65281|a<<8;break;case 198:this.L=this.L&-65281|a<<8;break;case 199:this.G=this.G&-65281|a<<8;break;default:og(this,a)}} +function wf(a){var b,c;switch((this.ga=this.ra())&199){case 0:c=E(this,this.D);break;case 1:c=E(this,this.I);break;case 2:c=E(this,this.L);break;case 3:c=E(this,this.G);break;case 4:c=E(this,Zj.call(this,0));break;case 5:c=E(this,J(this));break;case 6:c=E(this,this.K);break;case 7:c=E(this,this.J);break;case 64:c=E(this,this.D+this.S());break;case 65:c=E(this,this.I+this.S());break;case 66:c=E(this,this.L+this.S());break;case 67:c=E(this,this.G+this.S());break;case 68:c=E(this,Zj.call(this,1)+this.S()); +break;case 69:c=mg(this,this.M+this.S());break;case 70:c=E(this,this.K+this.S());break;case 71:c=E(this,this.J+this.S());break;case 128:c=E(this,this.D+J(this));break;case 129:c=E(this,this.I+J(this));break;case 130:c=E(this,this.L+J(this));break;case 131:c=E(this,this.G+J(this));break;case 132:c=E(this,Zj.call(this,2)+J(this));break;case 133:c=mg(this,this.M+J(this));break;case 134:c=E(this,this.K+J(this));break;case 135:c=E(this,this.J+J(this));break;case 192:c=this.D&65535;break;case 193:c=this.I& +65535;break;case 194:c=this.L&65535;break;case 195:c=this.G&65535;break;case 196:c=z(this)&65535;break;case 197:c=this.M&65535;break;case 198:c=this.K&65535;break;case 199:c=this.J&65535;break;default:c=0}var d=this.ga>>3&7;switch(d){case 0:b=this.D&65535;break;case 1:b=this.I&65535;break;case 2:b=this.L&65535;break;case 3:b=this.G&65535;break;case 4:b=z(this)&65535;break;case 5:b=this.M&65535;break;case 6:b=this.K&65535;break;case 7:b=this.J&65535;break;default:b=0}a=a.call(this,b,c);switch(d){case 0:this.D= +this.D&-65536|a;break;case 1:this.I=this.I&-65536|a;break;case 2:this.L=this.L&-65536|a;break;case 3:this.G=this.G&-65536|a;break;case 4:Ud(this,z(this)&-65536|a);break;case 5:this.M=this.M&-65536|a;break;case 6:this.K=this.K&-65536|a;break;case 7:this.J=this.J&-65536|a}} +function xf(a){var b,c,d=(this.ga=this.ra())&199;switch(d){case 0:b=E(this,this.D);this.F=this.C;break;case 1:b=E(this,this.I);this.F=this.C;break;case 2:b=E(this,this.L);this.F=this.C;break;case 3:b=E(this,this.G);this.F=this.C;break;case 4:b=E(this,Zj.call(this,0));this.F=this.C;break;case 5:b=E(this,J(this));this.F=this.C;break;case 6:b=E(this,this.K);this.F=this.C;break;case 7:b=E(this,this.J);this.F=this.C;break;case 64:b=E(this,this.D+this.S());this.F=this.C;break;case 65:b=E(this,this.I+this.S()); +this.F=this.C;break;case 66:b=E(this,this.L+this.S());this.F=this.C;break;case 67:b=E(this,this.G+this.S());this.F=this.C;break;case 68:b=E(this,Zj.call(this,1)+this.S());this.F=this.C;break;case 69:b=mg(this,this.M+this.S());this.F=this.C;break;case 70:b=E(this,this.K+this.S());this.F=this.C;break;case 71:b=E(this,this.J+this.S());this.F=this.C;break;case 128:b=E(this,this.D+J(this));this.F=this.C;break;case 129:b=E(this,this.I+J(this));this.F=this.C;break;case 130:b=E(this,this.L+J(this));this.F= +this.C;break;case 131:b=E(this,this.G+J(this));this.F=this.C;break;case 132:b=E(this,Zj.call(this,2)+J(this));this.F=this.C;break;case 133:b=mg(this,this.M+J(this));this.F=this.C;break;case 134:b=E(this,this.K+J(this));this.F=this.C;break;case 135:b=E(this,this.J+J(this));this.F=this.C;break;case 192:b=this.D&65535;break;case 193:b=this.I&65535;break;case 194:b=this.L&65535;break;case 195:b=this.G&65535;break;case 196:b=z(this)&65535;break;case 197:b=this.M&65535;break;case 198:b=this.K&65535;break; +case 199:b=this.J&65535;break;default:b=0}switch(this.ga>>3&7){case 0:c=this.D&65535;break;case 1:c=this.I&65535;break;case 2:c=this.L&65535;break;case 3:c=this.G&65535;break;case 4:c=z(this)&65535;break;case 5:c=this.M&65535;break;case 6:c=this.K&65535;break;case 7:c=this.J&65535;break;default:c=0}a=a.call(this,b,c);switch(d){case 192:this.D=this.D&-65536|a;break;case 193:this.I=this.I&-65536|a;break;case 194:this.L=this.L&-65536|a;break;case 195:this.G=this.G&-65536|a;break;case 196:Ud(this,z(this)& +-65536|a);break;case 197:this.M=this.M&-65536|a;break;case 198:this.K=this.K&-65536|a;break;case 199:this.J=this.J&-65536|a;break;default:pg(this,a)}} +function yf(a,b){var c,d=(this.ga=this.ra())&199;switch(d){case 0:c=E(this,this.D);this.F=this.C;break;case 1:c=E(this,this.I);this.F=this.C;break;case 2:c=E(this,this.L);this.F=this.C;break;case 3:c=E(this,this.G);this.F=this.C;break;case 4:c=E(this,Zj.call(this,0));this.F=this.C;break;case 5:c=E(this,J(this));this.F=this.C;break;case 6:c=E(this,this.K);this.F=this.C;break;case 7:c=E(this,this.J);this.F=this.C;break;case 64:c=E(this,this.D+this.S());this.F=this.C;break;case 65:c=E(this,this.I+this.S()); +this.F=this.C;break;case 66:c=E(this,this.L+this.S());this.F=this.C;break;case 67:c=E(this,this.G+this.S());this.F=this.C;break;case 68:c=E(this,Zj.call(this,1)+this.S());this.F=this.C;break;case 69:c=mg(this,this.M+this.S());this.F=this.C;break;case 70:c=E(this,this.K+this.S());this.F=this.C;break;case 71:c=E(this,this.J+this.S());this.F=this.C;break;case 128:c=E(this,this.D+J(this));this.F=this.C;break;case 129:c=E(this,this.I+J(this));this.F=this.C;break;case 130:c=E(this,this.L+J(this));this.F= +this.C;break;case 131:c=E(this,this.G+J(this));this.F=this.C;break;case 132:c=E(this,Zj.call(this,2)+J(this));this.F=this.C;break;case 133:c=mg(this,this.M+J(this));this.F=this.C;break;case 134:c=E(this,this.K+J(this));this.F=this.C;break;case 135:c=E(this,this.J+J(this));this.F=this.C;break;case 192:c=this.D&65535;break;case 193:c=this.I&65535;break;case 194:c=this.L&65535;break;case 195:c=this.G&65535;break;case 196:c=z(this)&65535;break;case 197:c=this.M&65535;break;case 198:c=this.K&65535;break; +case 199:c=this.J&65535;break;default:c=0}a=a[this.ga>>3&7].call(this,c,b.call(this));switch(d){case 192:this.D=this.D&-65536|a;break;case 193:this.I=this.I&-65536|a;break;case 194:this.L=this.L&-65536|a;break;case 195:this.G=this.G&-65536|a;break;case 196:Ud(this,z(this)&-65536|a);break;case 197:this.M=this.M&-65536|a;break;case 198:this.K=this.K&-65536|a;break;case 199:this.J=this.J&-65536|a;break;default:pg(this,a)}} +function zf(a){var b,c;switch((this.ga=this.ra())&199){case 0:c=G(this,this.D);break;case 1:c=G(this,this.I);break;case 2:c=G(this,this.L);break;case 3:c=G(this,this.G);break;case 4:c=G(this,Zj.call(this,0));break;case 5:c=G(this,J(this));break;case 6:c=G(this,this.K);break;case 7:c=G(this,this.J);break;case 64:c=G(this,this.D+this.S());break;case 65:c=G(this,this.I+this.S());break;case 66:c=G(this,this.L+this.S());break;case 67:c=G(this,this.G+this.S());break;case 68:c=G(this,Zj.call(this,1)+this.S()); +break;case 69:c=ng(this,this.M+this.S());break;case 70:c=G(this,this.K+this.S());break;case 71:c=G(this,this.J+this.S());break;case 128:c=G(this,this.D+J(this));break;case 129:c=G(this,this.I+J(this));break;case 130:c=G(this,this.L+J(this));break;case 131:c=G(this,this.G+J(this));break;case 132:c=G(this,Zj.call(this,2)+J(this));break;case 133:c=ng(this,this.M+J(this));break;case 134:c=G(this,this.K+J(this));break;case 135:c=G(this,this.J+J(this));break;case 192:c=this.D;break;case 193:c=this.I;break; +case 194:c=this.L;break;case 195:c=this.G;break;case 196:c=z(this);break;case 197:c=this.M;break;case 198:c=this.K;break;case 199:c=this.J;break;default:c=0}var d=this.ga>>3&7;switch(d){case 0:b=this.D;break;case 1:b=this.I;break;case 2:b=this.L;break;case 3:b=this.G;break;case 4:b=z(this);break;case 5:b=this.M;break;case 6:b=this.K;break;case 7:b=this.J;break;default:b=0}a=a.call(this,b,c);switch(d){case 0:this.D=a;break;case 1:this.I=a;break;case 2:this.L=a;break;case 3:this.G=a;break;case 4:Ud(this, +a);break;case 5:this.M=a;break;case 6:this.K=a;break;case 7:this.J=a}} +function Af(a){var b,c,d=(this.ga=this.ra())&199;switch(d){case 0:b=G(this,this.D);this.F=this.C;break;case 1:b=G(this,this.I);this.F=this.C;break;case 2:b=G(this,this.L);this.F=this.C;break;case 3:b=G(this,this.G);this.F=this.C;break;case 4:b=G(this,Zj.call(this,0));this.F=this.C;break;case 5:b=G(this,J(this));this.F=this.C;break;case 6:b=G(this,this.K);this.F=this.C;break;case 7:b=G(this,this.J);this.F=this.C;break;case 64:b=G(this,this.D+this.S());this.F=this.C;break;case 65:b=G(this,this.I+this.S()); +this.F=this.C;break;case 66:b=G(this,this.L+this.S());this.F=this.C;break;case 67:b=G(this,this.G+this.S());this.F=this.C;break;case 68:b=G(this,Zj.call(this,1)+this.S());this.F=this.C;break;case 69:b=ng(this,this.M+this.S());this.F=this.C;break;case 70:b=G(this,this.K+this.S());this.F=this.C;break;case 71:b=G(this,this.J+this.S());this.F=this.C;break;case 128:b=G(this,this.D+J(this));this.F=this.C;break;case 129:b=G(this,this.I+J(this));this.F=this.C;break;case 130:b=G(this,this.L+J(this));this.F= +this.C;break;case 131:b=G(this,this.G+J(this));this.F=this.C;break;case 132:b=G(this,Zj.call(this,2)+J(this));this.F=this.C;break;case 133:b=ng(this,this.M+J(this));this.F=this.C;break;case 134:b=G(this,this.K+J(this));this.F=this.C;break;case 135:b=G(this,this.J+J(this));this.F=this.C;break;case 192:b=this.D;break;case 193:b=this.I;break;case 194:b=this.L;break;case 195:b=this.G;break;case 196:b=z(this);break;case 197:b=this.M;break;case 198:b=this.K;break;case 199:b=this.J;break;default:b=0}switch(this.ga>> +3&7){case 0:c=this.D;break;case 1:c=this.I;break;case 2:c=this.L;break;case 3:c=this.G;break;case 4:c=z(this);break;case 5:c=this.M;break;case 6:c=this.K;break;case 7:c=this.J;break;default:c=0}a=a.call(this,b,c);switch(d){case 192:this.D=a;break;case 193:this.I=a;break;case 194:this.L=a;break;case 195:this.G=a;break;case 196:Ud(this,a);break;case 197:this.M=a;break;case 198:this.K=a;break;case 199:this.J=a;break;default:qg(this,a)}} +function Bf(a,b){var c,d=(this.ga=this.ra())&199;switch(d){case 0:c=G(this,this.D);this.F=this.C;break;case 1:c=G(this,this.I);this.F=this.C;break;case 2:c=G(this,this.L);this.F=this.C;break;case 3:c=G(this,this.G);this.F=this.C;break;case 4:c=G(this,Zj.call(this,0));this.F=this.C;break;case 5:c=G(this,J(this));this.F=this.C;break;case 6:c=G(this,this.K);this.F=this.C;break;case 7:c=G(this,this.J);this.F=this.C;break;case 64:c=G(this,this.D+this.S());this.F=this.C;break;case 65:c=G(this,this.I+this.S()); +this.F=this.C;break;case 66:c=G(this,this.L+this.S());this.F=this.C;break;case 67:c=G(this,this.G+this.S());this.F=this.C;break;case 68:c=G(this,Zj.call(this,1)+this.S());this.F=this.C;break;case 69:c=ng(this,this.M+this.S());this.F=this.C;break;case 70:c=G(this,this.K+this.S());this.F=this.C;break;case 71:c=G(this,this.J+this.S());this.F=this.C;break;case 128:c=G(this,this.D+J(this));this.F=this.C;break;case 129:c=G(this,this.I+J(this));this.F=this.C;break;case 130:c=G(this,this.L+J(this));this.F= +this.C;break;case 131:c=G(this,this.G+J(this));this.F=this.C;break;case 132:c=G(this,Zj.call(this,2)+J(this));this.F=this.C;break;case 133:c=ng(this,this.M+J(this));this.F=this.C;break;case 134:c=G(this,this.K+J(this));this.F=this.C;break;case 135:c=G(this,this.J+J(this));this.F=this.C;break;case 192:c=this.D;break;case 193:c=this.I;break;case 194:c=this.L;break;case 195:c=this.G;break;case 196:c=z(this);break;case 197:c=this.M;break;case 198:c=this.K;break;case 199:c=this.J;break;default:c=0}a=a[this.ga>> +3&7].call(this,c,b.call(this));switch(d){case 192:this.D=a;break;case 193:this.I=a;break;case 194:this.L=a;break;case 195:this.G=a;break;case 196:Ud(this,a);break;case 197:this.M=a;break;case 198:this.K=a;break;case 199:this.J=a;break;default:qg(this,a)}} +function Zj(a){var b=this.ra(),c=b>>6,d,e;switch(b>>3&7){case 0:d=this.D;break;case 1:d=this.I;break;case 2:d=this.L;break;case 3:d=this.G;break;case 4:d=0;break;case 5:d=this.M;break;case 6:d=this.K;break;case 7:d=this.J}switch(b&7){case 0:e=this.D;break;case 1:e=this.I;break;case 2:e=this.L;break;case 3:e=this.G;break;case 4:e=z(this);this.Da=this.Rb;break;case 5:a?(e=this.M,this.Da=this.Rb):e=J(this);break;case 6:e=this.K;break;case 7:e=this.J}return(d<>8&255;9<(c&15)||Sf(this)?(c+=6,80286<=this.ca&&255>8&255;9<(c&15)||Sf(this)?(c=c-6&15,d=d-1&255,a=b=1):a=b=0;this.D=this.D&-65536|d<<8|c;a?Xf(this):Yf(this);b?eg(this):cg(this);this.A-=this.B.qe},function(){this.D=Mj.call(this,this.D)},function(){this.I=Mj.call(this,this.I)},function(){this.L=Mj.call(this,this.L)},function(){this.G=Mj.call(this,this.G)},function(){Ud(this, +Mj.call(this,z(this)))},function(){this.M=Mj.call(this,this.M)},function(){this.K=Mj.call(this,this.K)},function(){this.J=Mj.call(this,this.J)},function(){this.D=Kj.call(this,this.D)},function(){this.I=Kj.call(this,this.I)},function(){this.L=Kj.call(this,this.L)},function(){this.G=Kj.call(this,this.G)},function(){Ud(this,Kj.call(this,z(this)))},function(){this.M=Kj.call(this,this.M)},function(){this.K=Kj.call(this,this.K)},function(){this.J=Kj.call(this,this.J)},function(){be(this,this.D&this.R); +this.A-=this.B.Ic},function(){be(this,this.I&this.R);this.A-=this.B.Ic},function(){be(this,this.L&this.R);this.A-=this.B.Ic},function(){be(this,this.G&this.R);this.A-=this.B.Ic},function(){be(this,z(this)-2&65535);this.A-=this.B.Ic},function(){be(this,this.M&this.R);this.A-=this.B.Ic},function(){be(this,this.K&this.R);this.A-=this.B.Ic},function(){be(this,this.J&this.R);this.A-=this.B.Ic},function(){this.D=this.D&~this.R|Rd(this);this.A-=this.B.nc},function(){this.I=this.I&~this.R|Rd(this);this.A-= +this.B.nc},function(){this.L=this.L&~this.R|Rd(this);this.A-=this.B.nc},function(){this.G=this.G&~this.R|Rd(this);this.A-=this.B.nc},function(){Ud(this,z(this)&~this.R|Rd(this));this.A-=this.B.nc},function(){this.M=this.M&~this.R|Rd(this);this.A-=this.B.nc},function(){this.K=this.K&~this.R|Rd(this);this.A-=this.B.nc},function(){this.J=this.J&~this.R|Rd(this);this.A-=this.B.nc},ak,bk,ck,dk,ek,fk,gk,hk,ik,jk,kk,lk,mk,nk,ok,pk,ak,bk,ck,dk,ek,fk,gk,hk,ik,jk,kk,lk,mk,nk,ok,pk,qk,function(){this.rb.call(this, +Fk,this.Ea);this.A-=-1===this.F?1:this.B.yg},qk,function(){this.rb.call(this,Fk,this.S);this.A-=-1===this.F?1:this.B.yg},function(){this.tc.call(this,Bj)},function(){this.za.call(this,Cj)},function(){this.kc.call(this,Fj)},function(){this.ma.call(this,Gj)},sk,tk,uk,vk,function(){this.N|=1;this.za.call(this,Ki)},function(){this.N|=1;this.Da=this.Rb=this.Qg;this.ma.call(this,Ai)},function(){var a;this.ma.call(this,Ji);switch(this.ga>>3&7){case 0:a=this.D;this.D=this.ya;ae(this,a);break;case 1:a=this.I; +this.I=this.ya;Lf(this,a);break;case 2:a=this.L;this.L=this.ya;Td(this,a);break;case 3:a=this.G;this.G=this.ya;$d(this,a);break;case 4:a=z(this);Ud(this,this.ya);80386<=this.ca?this.Ga.load(a):ae(this,a);break;case 5:a=this.M;this.M=this.ya;80386<=this.ca?this.Ha.load(a):Lf(this,a);break;case 6:a=this.K;this.K=this.ya;Td(this,a);break;case 7:a=this.J,this.J=this.ya,$d(this,a)}},function(){this.N|=1;this.ta=this.Aa;this.ya=Rd(this);this.rb.call(this,Gk,Tj);this.ta=-1},function(){this.A-=3},function(){var a= +this.D;this.D=this.D&~this.R|this.I&this.R;this.I=this.I&~this.R|a&this.R;this.A-=3},function(){var a=this.D;this.D=this.D&~this.R|this.L&this.R;this.L=this.L&~this.R|a&this.R;this.A-=3},function(){var a=this.D;this.D=this.D&~this.R|this.G&this.R;this.G=this.G&~this.R|a&this.R;this.A-=3},function(){var a=this.D,b=z(this);this.D=this.D&~this.R|b&this.R;Ud(this,b&~this.R|a&this.R);this.A-=3},function(){var a=this.D;this.D=this.D&~this.R|this.M&this.R;this.M=this.M&~this.R|a&this.R;this.A-=3},function(){var a= +this.D;this.D=this.D&~this.R|this.K&this.R;this.K=this.K&~this.R|a&this.R;this.A-=3},function(){var a=this.D;this.D=this.D&~this.R|this.J&this.R;this.J=this.J&~this.R|a&this.R;this.A-=3},function(){this.D=2==this.V?this.D&-65536|this.D<<24>>24&65535:this.D<<16>>16;this.A-=2},function(){this.L=2==this.V?this.L&-65536|(this.D&32768?65535:0):this.D&-2147483648?-1:0;this.A-=this.B.Kj},function(){Uj.call(this,this.Ea(),tg(this));this.A-=this.B.Nj},function(){this.A-=3},function(){var a=de(this);a&131072&& +3>this.lc?y.call(this,13,0):(be(this,a&-196609),this.A-=this.B.Ic)},function(){if(this.O&131072&&3>this.lc)y.call(this,13,0);else{var a=Rd(this),a=a&65535|this.O&-65536;ee(this,a);this.A-=this.B.nc}},function(){var a=this.D>>8&255;a&1?Xf(this):Yf(this);a&4?(this.resultType&=-3,this.O|=4):(this.resultType&=-3,this.O&=-5);a&16?eg(this):cg(this);a&64?fg(this):dg(this);a&128?(this.resultType&=-17,this.O|=128):(this.resultType&=-17,this.O&=-129);this.A-=this.B.Vb},function(){this.D=this.D&-65281|(de(this)& +213)<<8;this.A-=this.B.Vb},function(){var a=this.D&-256,b;b=J(this);b=this.Ia(this.Da.bc(b,1));this.D=a|b;this.A-=this.B.Kh},function(){this.D=this.D&~this.R|Yd(this,this.Da,J(this));this.A-=this.B.Kh},function(){var a=J(this),b=this.D;this.fc(this.Da.cc(a,1),b);this.A-=this.B.Lh},function(){var a=J(this),b=this.D;this.yb(this.Da.cc(a,this.V),b);this.A-=this.B.Lh},function(){var a=1,b=0,c=this.wa,d=this.B.Mh;this.ha&192&&(a=this.I&c,b=1,d=this.B.Oh,this.ha&256||(this.A-=this.B.Nh));if(a--){var e= +this.Ia(this.Da.bc(this.K&c,1));this.fc(this.oa.cc(this.J&c,1),e);e=this.O&1024?-1:1;this.K=this.K&~c|this.K+e&c;this.J=this.J&~c|this.J+e&c;this.A-=d;this.I=this.I&~c|this.I-b&c;a&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.Mh;this.ha&192&&(a=this.I&c,b=1,d=this.B.Oh,this.ha&256||(this.A-=this.B.Nh));if(a--){var e=Yd(this,this.Da,this.K&c);this.yb(this.oa.cc(this.J&c,this.V),e);e=this.O&1024?-this.V:this.V;this.K=this.K&~c|this.K+e&c;this.J=this.J&~c|this.J+e&c;this.A-=d; +this.I=this.I&~c|this.I-b&c;a&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.xh;this.ha&192&&(a=this.I&c,b=1,d=this.B.zh,this.ha&256||(this.A-=this.B.yh));if(a--){var e=jg(this,this.Da,this.K),f=jg(this,this.oa,this.J);this.F=this.C;ni.call(this,e,f);e=this.O&1024?-1:1;this.K=this.K&~c|this.K+e&c;this.J=this.J&~c|this.J+e&c;this.I=this.I&~c|this.I-b&c;this.A-=d-this.B.Ib;a&&Tf(this)==(this.ha&64)&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.xh;this.ha&192&& +(a=this.I&c,b=1,d=this.B.zh,this.ha&256||(this.A-=this.B.yh));if(a--){var e=lg(this,this.Da,this.K&c),f=lg(this,this.oa,this.J&c);this.F=this.C;oi.call(this,e,f);e=this.O&1024?-this.V:this.V;this.K=this.K&~c|this.K+e&c;this.J=this.J&~c|this.J+e&c;this.I=this.I&~c|this.I-b&c;this.A-=d-this.B.Ib;a&&Tf(this)==(this.ha&64)&&(Of(this),this.N|=256)}},function(){Wf(this,this.D&this.ra(),128);this.A-=this.B.qe},function(){Wf(this,this.D&this.Ea(),this.Fb);this.A-=this.B.qe},function(){var a=1,b=0,c=this.wa, +d=this.B.Xh;this.ha&192&&(a=this.I&c,b=1,d=this.B.Zh,this.ha&256||(this.A-=this.B.Yh));if(a--){var e=this.D;this.fc(this.oa.cc(this.J&c,1),e);this.I=this.I&~c|this.I-b&c;80546<=this.we&&80564>=this.we&&!(this.ha&2048)!=(103!=this.Ia(this.da))&&(c^=-65536);this.J=this.J&~c|this.J+(this.O&1024?-1:1)&c;this.A-=d;a&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.Xh;this.ha&192&&(a=this.I&c,b=1,d=this.B.Zh,this.ha&256||(this.A-=this.B.Yh));if(a--){var e=this.D;this.yb(this.oa.cc(this.J& +c,this.V),e);this.J=this.J&~c|this.J+(this.O&1024?-this.V:this.V)&c;this.I=this.I&~c|this.I-b&c;this.A-=d;a&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.Eh;this.ha&192&&(a=this.I&c,b=1,d=this.B.Gh,this.ha&256||(this.A-=this.B.Fh));if(a--){var e=this.Ia(this.Da.bc(this.K&c,1));this.D=this.D&-256|e;this.K=this.K&~c|this.K+(this.O&1024?-1:1)&c;this.I=this.I&~c|this.I-b&c;this.A-=d;a&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.Eh;this.ha&192&&(a=this.I&c, +b=1,d=this.B.Gh,this.ha&256||(this.A-=this.B.Fh));if(a--){var e=Yd(this,this.Da,this.K&c);this.D=this.D&~this.R|e;this.K=this.K&~c|this.K+(this.O&1024?-this.V:this.V)&c;this.I=this.I&~c|this.I-b&c;this.A-=d;a&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.Rh;this.ha&192&&(a=this.I&c,b=1,d=this.B.Th,this.ha&256||(this.A-=this.B.Sh));if(a--){var e=this.D&255,f=jg(this,this.oa,this.J);this.F=this.C;ni.call(this,e,f);this.J=this.J&~c|this.J+(this.O&1024?-1:1)&c;this.I=this.I&~c|this.I- +b&c;this.A-=d-this.B.Ib;a&&Tf(this)==(this.ha&64)&&(Of(this),this.N|=256)}},function(){var a=1,b=0,c=this.wa,d=this.B.Rh;this.ha&192&&(a=this.I&c,b=1,d=this.B.Th,this.ha&256||(this.A-=this.B.Sh));if(a--){var e=this.D&this.R,f=lg(this,this.oa,this.J&c);this.F=this.C;oi.call(this,e,f);this.J=this.J&~c|this.J+(this.O&1024?-this.V:this.V)&c;this.I=this.I&~c|this.I-b&c;this.A-=d-this.B.Ib;a&&Tf(this)==(this.ha&64)&&(Of(this),this.N|=256)}},function(){this.D=this.D&-256|this.ra();this.A-=this.B.Vb},function(){this.I= +this.I&-256|this.ra();this.A-=this.B.Vb},function(){this.L=this.L&-256|this.ra();this.A-=this.B.Vb},function(){this.G=this.G&-256|this.ra();this.A-=this.B.Vb},function(){this.D=this.D&-65281|this.ra()<<8;this.A-=this.B.Vb},function(){this.I=this.I&-65281|this.ra()<<8;this.A-=this.B.Vb},function(){this.L=this.L&-65281|this.ra()<<8;this.A-=this.B.Vb},function(){this.G=this.G&-65281|this.ra()<<8;this.A-=this.B.Vb},function(){this.D=this.D&~this.R|this.Ea();this.A-=this.B.Vb},function(){this.I=this.I& +~this.R|this.Ea();this.A-=this.B.Vb},function(){this.L=this.L&~this.R|this.Ea();this.A-=this.B.Vb},function(){this.G=this.G&~this.R|this.Ea();this.A-=this.B.Vb},function(){Ud(this,z(this)&~this.R|this.Ea());this.A-=this.B.Vb},function(){this.M=this.M&~this.R|this.Ea();this.A-=this.B.Vb},function(){this.K=this.K&~this.R|this.Ea();this.A-=this.B.Vb},function(){this.J=this.J&~this.R|this.Ea();this.A-=this.B.Vb},zk,Ak,zk,Ak,function(){this.ma.call(this,Bi)},function(){this.ma.call(this,zi)},function(){this.N|= +1;this.kd.call(this,Hk,this.ra)},function(){this.N|=1;this.rb.call(this,Hk,this.Ea)},Bk,Ck,Bk,Ck,function(){if(this.O&131072&&3>this.lc)y.call(this,13,0);else{var a=this.B.dk;this.Uc=-1;Vj.call(this,3,null,a)}},function(){var a=this.ra();if(this.O&131072&&3>this.lc)y.call(this,13,0);else{var b;a:{b=this.Yf[a];if(void 0!==b)for(var c=0;cthis.lc)y.call(this,13,0);else{var a=this.B.ek;this.Uc=-1;Vj.call(this,4,null,a)}else this.A-=this.B.fk},function(){if(this.O&131072&&3>this.lc)y.call(this,13,0);else{this.Vc=this.Y.U;this.ta=this.Aa;this.A-=this.B.bk;if(this.qa&1&&this.O&16384){var a=this.ja(this.la.ua+0);Vd(this.Z,a,!1)}else{var a=this.Ma,b=Rd(this),c=Rd(this),d=Rd(this);if(this.O&131072)d=d&131071|this.O&-131072;else if(d&131072){var e=Rd(this),f=Rd(this),g=Rd(this),h=Rd(this),k=Rd(this),m=Rd(this);Wd(this,!0,!0);Td(this, +f);Ud(this,e);ae(this,g);$d(this,h);this.Ga.load(k);this.Ha.load(m)}null!=fe(this,b,c,!1)&&(ee(this,d,a),this.ag&&Gf(this,this.da))}this.Vc=this.ta=-1}},function(){this.kd.call(this,wk,Pj)},function(){this.rb.call(this,2==this.V?xk:yk,Pj)},function(){this.kd.call(this,wk,Qj)},function(){this.rb.call(this,2==this.V?xk:yk,Qj)},function(){var a=this.ra();if(a){var b=this.D&255;this.D=this.D&-65536|b/a<<8|b%a;Wf(this,this.D,128);this.A-=this.B.Hj}else Yj.call(this)},function(){var a=this.D&255,b=(this.D>> +8&255)*this.ra()|0,c=a+b|0;this.D=this.D&-65536|c&255;Pf(this,a,b,c,191);this.A-=this.B.Gj},function(){this.D=this.D&-256|(Qf(this)?255:0);this.A-=2},function(){this.D=this.D&-256|jg(this,this.Da,this.G+(this.D&255));this.A-=this.B.Gk},function(){Dk.call(this,216)},function(){Dk.call(this,217)},function(){Dk.call(this,218)},function(){Dk.call(this,219)},function(){Dk.call(this,220)},function(){Dk.call(this,221)},function(){Dk.call(this,222)},function(){Dk.call(this,223)},function(){var a=this.S(), +b=this.I-1&this.wa;this.I=this.I&~this.wa|b;b&&!Tf(this)?(C(this,A(this)+a),this.A-=this.B.mk):this.A-=this.B.Hh},function(){var a=this.S(),b=this.I-1&this.wa;this.I=this.I&~this.wa|b;b&&Tf(this)?(C(this,A(this)+a),this.A-=this.B.Ih):this.A-=this.B.Jh},function(){var a=this.S(),b=this.I-1&this.wa;this.I=this.I&~this.wa|b;b?(C(this,A(this)+a),this.A-=this.B.lk):this.A-=this.B.Hh},function(){var a=this.S();this.I&this.wa?this.A-=this.B.Jh:(C(this,A(this)+a),this.A-=this.B.Ih)},function(){var a=this.ra(); +hg(this,a,1,!0)&&(this.D=this.D&-256|Ac(this.ka,a,1,this.da-2)&255,this.A-=this.B.Ch)},function(){var a=this.ra();hg(this,a,this.V,!0)&&(this.D=this.D&~this.R|Ac(this.ka,a,this.V,this.da-2)&this.R,this.A-=this.B.Ch)},function(){var a=this.ra();hg(this,a,1,!1)&&(Ec(this.ka,a,1,this.D&255,this.da-2),this.A-=this.B.Qh)},function(){var a=this.ra();hg(this,a,this.V,!1)&&(Ec(this.ka,a,this.V,this.D&this.R,this.da-2),this.A-=this.B.Qh)},function(){var a=this.Ea(),b=A(this),a=b+a;be(this,b);C(this,a);this.A-= +this.B.Lj},function(){var a=this.Ea();C(this,A(this)+a);this.A-=this.B.Dh},function(){fe(this,this.Ea(),tg(this));this.A-=this.B.hk},function(){var a=this.S();C(this,A(this)+a);this.A-=this.B.Dh},function(){var a=this.L&65535;hg(this,a,1,!0)&&(this.D=this.D&-256|Ac(this.ka,a,1,this.da-1)&255,this.A-=this.B.Bh)},function(){var a=this.L&65535;hg(this,a,this.V,!0)&&(this.D=this.D&~this.R|Ac(this.ka,a,this.V,this.da-1)&this.R,this.A-=this.B.Bh)},function(){var a=this.L&65535;hg(this,a,1,!1)&&(Ec(this.ka, +a,1,this.D&255,this.da-1),this.A-=this.B.Ph)},function(){var a=this.L&65535;hg(this,a,2,!1)&&(Ec(this.ka,a,this.V,this.D&this.R,this.da-1),this.A-=this.B.Ph)},Ek,Ek,function(){this.N|=132;this.A-=this.B.bd},function(){this.N|=68;this.A-=this.B.bd},function(){this.O&131072?y.call(this,13,0):(this.Za|=4,this.A-=2,this.ba&&t(this,-2147483648)?(Of(this),this.ba.Jb()):this.O&512||(this.ba&&Of(this),this.Jb()))},function(){Qf(this)?Yf(this):Xf(this);this.A-=2},function(){this.vc=!1;this.kd.call(this,Jk, +Sj);this.vc&&(this.D=this.D&~this.R|this.Ba&this.R)},function(){this.vc=!1;this.rb.call(this,Kk,Sj);this.vc&&(this.D=this.D&~this.R|this.Ba&this.R,this.L=this.L&~this.R|this.$a&this.R)},function(){Yf(this);this.A-=2},function(){Xf(this);this.A-=2},function(){this.Ma>this.lc?y.call(this,13,0):(this.O&=-513,this.A-=this.B.Jj)},function(){this.Ma>this.lc?y.call(this,13,0):(this.O|=512,this.N|=4,this.A-=2)},function(){this.O&=-1025;this.A-=2},function(){this.O|=1024;this.A-=2},function(){this.kd.call(this, +je,Sj)},function(){this.rb.call(this,ke,Sj)}],rk=[Yh,Li,Wh,Ni,$h,zj,Hj,ni],Fk=[Zh,Mi,Xh,Oi,ai,Aj,Ij,oi],Gk=[function(a,b){this.A-=-1===this.F?this.B.nc:this.B.yk;return b},qi,qi,qi,qi,qi,qi,qi],Hk=[function(a,b){this.A-=-1===this.F?this.B.qk:this.B.nk;return b},ri,ri,ri,ri,ri,ri,ri],wk=[function(a,b){var c=a;if(b&=this.Ta){var d;(b&=7)?(d=a<>8-b)&255):d=a<<7;ag(this,c,d,128)}return c},function(a,b){var c=a;if(b&=this.Ta){var d;(b&=7)?(d=a<<8-b,c=(a>>>b|d)&255):d=a;ag(this,c,d,128)}return c}, +function(a,b){var c=a;if(b&=this.Ta){var d=bg(this);(b%=9)?(c=(a<>9-b)&255,d=a<>b|d<<8-b|a<<9-b)&255,d=a<<8-b):d<<=7;ag(this,c,d,128)}return c},function(a,b){var c=a;if(b&=this.Ta){var d=0;8>>b-1,a=b>>>1&255,Wf(this,a,128,b&1,a&128);return a},ri,function(a,b){if(b&=this.Ta)9>24>>b-1,a=b>>1&255,Wf(this,a,128,b&1);return a}],xk=[function(a,b){var c=a;if(b&=this.Ta){var d;(b&=15)?(d=a<>16-b)&65535):d=a<<15;ag(this,c,d,32768)}return c},function(a,b){var c=a;if(b&=this.Ta){var d;(b&=15)?(d=a<<16-b,c=(a>>>b|d)&65535):d=a;ag(this,c,d,32768)}return c},function(a,b){var c=a;if(b&=this.Ta){var d=bg(this);(b%=17)?(c=(a<>17-b)&65535,d=a<>b|d<<16-b|a<<17-b)&65535,d=a<<16-b):d<<=15;ag(this,c,d,32768)}return c},function(a,b){var c=a;if(b&=this.Ta){var d=0;16>>b-1,a=b>>>1&65535,Wf(this,a,32768,b&1,a&32768);return a},ri,function(a,b){if(b&=this.Ta)17>16>>b-1,a=b>>1&65535,Wf(this,a,32768,b&1);return a}],yk=[function(a,b){var c=a;if(b&=this.Ta)c=a<>>32-b,ag(this,c,a<>>b|d;ag(this,c,d,-2147483648)}return c},function(a,b){var c=a;if(b&=this.Ta)c=bg(this),c=a<>>32-b>>>1,ag(this,c,a<>>b|c<<32-b|a<<32-b<<1,ag(this,c,a<<32-b,-2147483648);return c},function(a,b){var c=a;if(b&=this.Ta)a<<=b-1,c=a<<1,Wf(this,c,-2147483648,a&-2147483648,(c^a)&-2147483648);return c},function(a,b){if(b&=this.Ta)b=a>>>b-1,a=b>>>1,Wf(this,a,-2147483648, +b&1,a&-2147483648);return a},ri,function(a,b){if(b&=this.Ta)b=a>>b-1,a=b>>1,Wf(this,a,-2147483648,b&1);return a}],Jk=[function(a,b){b=this.ra();Wf(this,a&b,128);this.A-=-1===this.C?this.B.ai:this.B.$h;this.N|=2;return a},ri,function(a){this.A-=-1===this.C?this.B.Ff:this.B.Ef;return a^255},function(a){var b=-a|0;Pf(this,0,a,b,191,!0);this.A-=-1===this.C?this.B.Ff:this.B.Ef;return b&255},function(a){this.Ba=(this.D&255)*a&65535;this.Ba&65280?(Xf(this),Zf(this)):(Yf(this),$f(this));this.vc=!0;this.A-= +-1===this.C?this.B.uk:this.B.tk;this.N|=2;return a},function(a){var b=(this.D<<24>>24)*(a<<24>>24)|0;this.Ba=b&65535;127b?(Xf(this),Zf(this)):(Yf(this),$f(this));this.vc=!0;this.A-=-1===this.C?this.B.Zj:this.B.Yj;this.N|=2;return a},function(a,b){if(!a)return Yj.call(this),a;var c=(b=this.D&65535)/a;if(255>24,d= +(b=this.D<<16>>16)/c|0;if(d!=d<<24>>24||8086==this.ca&&-128==d)return Yj.call(this),a;this.Ba=d&255|(b%c&255)<<8;this.vc=!0;this.A-=-1===this.C?this.B.Vj:this.B.Uj;this.N|=2;return a}],Kk=[function(a,b){b=this.Ea();Wf(this,a&b,this.Fb);this.A-=-1===this.C?this.B.ai:this.B.$h;this.N|=2;return a},ri,function(a){this.A-=-1===this.C?this.B.Ff:this.B.Ef;return a^this.R},function(a){var b=-a|0;Pf(this,0,a,b,this.Fb|63,!0);this.A-=-1===this.C?this.B.Ff:this.B.Ef;return b&this.R},function(a,b){2==this.V? +(b=this.D&65535,b=b*a|0,this.Ba=b&65535,this.$a=b>>16&65535):(xi.call(this,a,this.D),80563==this.we&&68657152==this.D&&129==a&&(this.$a=0));this.$a?(Xf(this),Zf(this)):(Yf(this),$f(this));this.vc=!0;this.A-=-1===this.C?this.B.wk:this.B.vk;this.N|=2;return a},function(a,b){2==this.V?(b=this.D&65535,b=(b<<16>>16)*(a<<16>>16)|0,this.Ba=b&65535,this.$a=b>>16&65535,b=32767b):(wi.call(this,a,this.D),b=this.$a!=this.Ba>>31);b?(Xf(this),Zf(this)):(Yf(this),$f(this));this.vc=!0;this.A-=-1===this.C? +this.B.ak:this.B.$j;this.N|=2;return a},function(a,b){if(2==this.V){if(!a)return Yj.call(this),a;b=65536*(this.L&65535)+(this.D&65535);var c=b/a;if(65536<=c)return Yj.call(this),a;this.Ba=c&65535;this.$a=b%a&65535}else{if(!Lj.call(this,this.D,this.L,a))return Yj.call(this),a;this.Ba|=0;this.$a|=0}this.vc=!0;this.A-=-1===this.C?this.B.Tj:this.B.Sj;this.N|=2;return a},function(a,b){if(2==this.V){if(!a)return Yj.call(this),a;var c=a<<16>>16,d=(b=this.L<<16|this.D&65535)/c|0;if(d!=d<<16>>16||8086==this.ca&& +-32768==d)return Yj.call(this),a;this.Ba=d&65535;this.$a=b%c&65535}else{b=this.D;var c=this.L,d=a,e=0,f=0;0>d&&(d=-d|0,e=1-e);0>c&&(b=-b|0,c=~c+(b?0:1)|0,f=1,e=1-e);!Lj.call(this,b,c,d)||this.Ba>2147483647+e||this.$a>2147483647+f?b=!1:(e&&(this.Ba=-this.Ba),f&&(this.$a=-this.$a),b=!0);if(!b)return Yj.call(this),a;this.Ba|=0;this.$a|=0}this.vc=!0;this.A-=-1===this.C?this.B.Xj:this.B.Wj;this.N|=2;return a}],je=[function(a){var b=a+1|0;Pf(this,a,1,b,190);this.A-=-1===this.C?this.B.Df:this.B.Cf;return b& +255},function(a){var b=a-1|0;Pf(this,a,1,b,190,!0);this.A-=-1===this.C?this.B.Df:this.B.Cf;return b&255},ri,ri,ri,ri,ri,ri],ke=[function(a){var b=a+1|0;Pf(this,a,1,b,this.Fb|62);this.A-=-1===this.C?this.B.Df:this.B.Cf;return b&this.R},function(a){var b=a-1|0;Pf(this,a,1,b,this.Fb|62,!0);this.A-=-1===this.C?this.B.Df:this.B.Cf;return b&this.R},function(a){be(this,A(this));C(this,a);this.A-=-1===this.C?this.B.Pj:this.B.Oj;this.N|=2;return a},function(a){if(-1===this.C)return ri.call(this,a);this.ta= +this.Aa;Uj.call(this,a,this.ja(this.C+this.V));this.A-=this.B.Mj;this.N|=2;this.ta=-1;return a},function(a){C(this,a);this.A-=-1===this.C?this.B.jk:this.B.ik;this.N|=2;return a},function(a){if(-1===this.C)return ri.call(this,a);fe(this,a,this.ja(this.C+this.V));this.A-=this.B.gk;this.N|=2;return a},function(a){var b=a;this.N&512&&(a=a-2&65535,80286>this.ca&&(b=a));be(this,b);this.A-=-1===this.C?this.B.Ic:this.B.Ak;this.N|=2;return a},ri]; +function Re(){this.ma.call(this,Ej);this.A-=-1===this.C?6:13}function Se(){this.za.call(this,Dj);this.A-=-1===this.C?12:19}var Je=Array(256);Je[0]=function(){16>(this.Ia(this.da)&56)&&(this.N|=1);this.rb.call(this,this.nj,Sj)};Je[1]=function(){this.Ia(this.da)&16||(this.N|=1);this.rb.call(this,Lk,Sj)};Je[2]=function(){!(this.qa&1)||this.O&131072?y.call(this,6):this.ma.call(this,yi)};Je[3]=function(){!(this.qa&1)||this.O&131072?y.call(this,6):this.ma.call(this,Ei)}; +Je[5]=function(){this.Ma?y.call(this,13,0,0,!0):(gg(this,this.ja(2054)),this.J=this.ja(2086),this.K=this.ja(2088),this.M=this.ja(2090),this.G=this.ja(2094),this.L=this.ja(2096),this.I=this.ja(2098),this.D=this.ja(2100),Pd(this.oa,2102,this.ja(2084)),Pd(this.Z,2108,this.ja(2082)),Pd(this.Y,2114,this.ja(2080)),Pd(this.Ca,2120,this.ja(2078)),ee(this,this.ja(2072)),C(this,this.ja(2074)),Ud(this,this.ja(2092)),this.Kb=this.ja(2126)|this.Ia(2128)<<16,this.Pc=this.Kb+this.ja(2130),this.Pb=this.ja(2138)| +this.Ia(2140)<<16,this.cd=this.Pb+this.ja(2142),Pd(this.Eb,2132,this.ja(2076)),Pd(this.la,2144,this.ja(2070)),this.A-=195)};Je[6]=function(){this.Ma?y.call(this,13,0):(this.qa&=-9,this.A-=2)};Je[11]=me;Je[166]=me;Je[255]=me;var B=[];B[5]=me; +B[7]=function(){if(this.Ma)y.call(this,13,0,0,!0);else{var a=this.oa.bc(this.J&this.wa,204);if(-1!==a){Nj.call(this,this.ia(a));var b=this.ia(a+168),c=(b&24576)>>13;ee(this,this.ia(a+4),c);this.Kb=this.ia(a+112);this.Pc=this.Kb+this.ia(a+116);this.Pb=this.ia(a+100);this.cd=this.Pb+this.ia(a+104);Nd(this.Eb,this.ia(a+56),this.ia(a+120),this.ia(a+124),this.ia(a+128));Nd(this.la,this.ia(a+52),this.ia(a+84),this.ia(a+88),this.ia(a+92));this.J=this.ia(a+12);this.K=this.ia(a+16);this.M=this.ia(a+20);this.G= +this.ia(a+28);this.L=this.ia(a+32);this.I=this.ia(a+36);this.D=this.ia(a+40);Nd(this.Ha,this.ia(a+60),this.ia(a+132),this.ia(a+136),this.ia(a+140));Nd(this.Ga,this.ia(a+64),this.ia(a+144),this.ia(a+148),this.ia(a+152));Nd(this.Ca,this.ia(a+68),this.ia(a+156),this.ia(a+160),this.ia(a+164));Nd(this.Y,this.ia(a+72),b,this.ia(a+172),this.ia(a+176));Nd(this.Z,this.ia(a+76),this.ia(a+180),this.ia(a+184),this.ia(a+188));Nd(this.oa,this.ia(a+80),this.ia(a+192),this.ia(a+196),this.ia(a+200));C(this,this.ia(a+ +8));Ud(this,this.ia(a+24))}this.A-=122<<(a&3?1:0)}};B[16]=sk;B[17]=tk;B[18]=uk;B[19]=vk;B[32]=function(){if(this.Ma)y.call(this,13,0);else{var a,b=this.ra();switch((b&56)>>3){case 0:a=this.qa;break;case 2:a=this.Cd;break;case 3:a=this.Wc;break;default:Ke.call(this);return}$e(this,b&7,a);this.A-=6}};B[33]=function(){if(this.Ma)y.call(this,13,0);else{var a=this.ra(),b=(a&56)>>3;4==b||5==b?Ke.call(this):($e(this,a&7,this.Qb[b]),this.A-=22)}}; +B[34]=function(){if(this.Ma)y.call(this,13,0);else{var a=this.ra(),b=Ze(this,a&7);switch((a&56)>>3){case 0:Nj.call(this,b);this.A-=10;break;case 2:this.Cd=b;this.A-=4;break;case 3:ge.call(this,b);this.A-=5;break;default:Ke.call(this)}}};B[35]=function(){if(this.Ma)y.call(this,13,0);else{var a=this.ra(),b=(a&56)>>3;4==b||5==b?Ke.call(this):(a=Ze(this,a&7),a!=this.Qb[b]&&(Hf(this,!1),this.Qb[b]=a,Hf(this,!0)),this.A-=4>b?22:14)}}; +B[36]=function(){if(this.Ma)y.call(this,13,0);else{var a=this.ra(),b=(a&56)>>3;6>b?Ke.call(this):($e(this,a&7,this.dg[b]),this.A-=12)}};B[38]=function(){if(this.Ma)y.call(this,13,0);else{var a=this.ra(),b=(a&56)>>3;6>b?Ke.call(this):(this.dg[b]=Ze(this,a&7),this.A-=12)}};B[128]=function(){var a=this.Ea();Vf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[129]=function(){var a=this.Ea();Vf(this)?this.A-=this.B.Ra:(C(this,A(this)+a),this.A-=this.B.Qa)}; +B[130]=function(){var a=this.Ea();Qf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[131]=function(){var a=this.Ea();Qf(this)?this.A-=this.B.Ra:(C(this,A(this)+a),this.A-=this.B.Qa)};B[132]=function(){var a=this.Ea();Tf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[133]=function(){var a=this.Ea();Tf(this)?this.A-=this.B.Ra:(C(this,A(this)+a),this.A-=this.B.Qa)};B[134]=function(){var a=this.Ea();Qf(this)||Tf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra}; +B[135]=function(){var a=this.Ea();Qf(this)||Tf(this)?this.A-=this.B.Ra:(C(this,A(this)+a),this.A-=this.B.Qa)};B[136]=function(){var a=this.Ea();Uf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[137]=function(){var a=this.Ea();Uf(this)?this.A-=this.B.Ra:(C(this,A(this)+a),this.A-=this.B.Qa)};B[138]=function(){var a=this.Ea();Rf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[139]=function(){var a=this.Ea();Rf(this)?this.A-=this.B.Ra:(C(this,A(this)+a),this.A-=this.B.Qa)}; +B[140]=function(){var a=this.Ea();!Uf(this)!=!Vf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[141]=function(){var a=this.Ea();!Uf(this)==!Vf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[142]=function(){var a=this.Ea();Tf(this)||!Uf(this)!=!Vf(this)?(C(this,A(this)+a),this.A-=this.B.Qa):this.A-=this.B.Ra};B[143]=function(){var a=this.Ea();Tf(this)||!Uf(this)!=!Vf(this)?this.A-=this.B.Ra:(C(this,A(this)+a),this.A-=this.B.Qa)};B[144]=function(){Oj.call(this,Pi)}; +B[145]=function(){Oj.call(this,Pi)};B[146]=function(){Oj.call(this,$i)};B[147]=function(){Oj.call(this,aj)};B[148]=function(){Oj.call(this,bj)};B[149]=function(){Oj.call(this,cj)};B[150]=function(){Oj.call(this,dj)};B[151]=function(){Oj.call(this,ej)};B[152]=function(){Oj.call(this,fj)};B[153]=function(){Oj.call(this,gj)};B[154]=function(){Oj.call(this,hj)};B[155]=function(){Oj.call(this,ij)};B[156]=function(){Oj.call(this,jj)};B[157]=function(){Oj.call(this,kj)};B[158]=function(){Oj.call(this,lj)}; +B[159]=function(){Oj.call(this,mj)};B[160]=function(){Zd(this,this.Ga.U,this.V,2);this.A-=this.B.re};B[161]=function(){this.ta=this.Aa;var a=Rd(this);this.Ga.load(a);this.A-=this.B.nc;this.ta=-1};B[163]=function(){this.za.call(this,ji);-1!==this.C&&(this.A-=6)};B[164]=function(){this.za.call(this,2==this.V?nj:pj);this.A-=-1===this.C?3:7};B[165]=function(){this.za.call(this,2==this.V?rj:sj);this.A-=-1===this.C?3:7};B[168]=function(){Zd(this,this.Ha.U,this.V,2);this.A-=this.B.re}; +B[169]=function(){this.ta=this.Aa;var a=Rd(this);this.Ha.load(a);this.A-=this.B.nc;this.ta=-1};B[171]=function(){this.za.call(this,mi);-1!==this.C&&(this.A-=5)};B[172]=function(){this.za.call(this,2==this.V?tj:vj);this.A-=-1===this.C?3:7};B[173]=function(){this.za.call(this,2==this.V?xj:yj);this.A-=-1===this.C?3:7};B[175]=function(){this.ma.call(this,2==this.V?ti:vi)};B[178]=function(){this.ma.call(this,Fi)};B[179]=function(){this.za.call(this,li);-1!==this.C&&(this.A-=5)}; +B[180]=function(){this.ma.call(this,Ci)};B[181]=function(){this.ma.call(this,Di)}; +B[182]=function(){this.kc.call(this,Hi);switch(this.ga>>3&7){case 0:this.D=this.D&~this.R|this.D&255;break;case 1:this.I=this.I&~this.R|this.I&255;break;case 2:this.L=this.L&~this.R|this.L&255;break;case 3:this.G=this.G&~this.R|this.G&255;break;case 4:this.Hc=this.Hc&~this.R|this.D>>8&255;this.D=this.ya;break;case 5:this.M=this.M&~this.R|this.I>>8&255;this.I=this.ya;break;case 6:this.K=this.K&~this.R|this.L>>8&255;this.L=this.ya;break;case 7:this.J=this.J&~this.R|this.G>>8&255,this.G=this.ya}this.A-= +-1===this.C?3:6};B[183]=function(){Xd(this,2);this.ma.call(this,Ii);switch(this.ga>>3&7){case 0:this.D=this.D&65535;break;case 1:this.I=this.I&65535;break;case 2:this.L=this.L&65535;break;case 3:this.G=this.G&65535;break;case 4:this.Hc=this.Hc&65535;break;case 5:this.M=this.M&65535;break;case 6:this.K=this.K&65535;break;case 7:this.J=this.J&65535}this.A-=-1===this.C?3:6};B[186]=function(){this.rb.call(this,Mk,this.ra)};B[187]=function(){this.za.call(this,ki);-1!==this.C&&(this.A-=5)}; +B[188]=function(){this.ma.call(this,di)};B[189]=function(){this.ma.call(this,ei)}; +B[190]=function(){this.kc.call(this,Hi);switch(this.ga>>3&7){case 0:this.D=this.D&~this.R|(this.D&255)<<24>>24&this.R;break;case 1:this.I=this.I&~this.R|(this.I&255)<<24>>24&this.R;break;case 2:this.L=this.L&~this.R|(this.L&255)<<24>>24&this.R;break;case 3:this.G=this.G&~this.R|(this.G&255)<<24>>24&this.R;break;case 4:this.Hc=this.Hc&~this.R|this.D<<16>>24&this.R;this.D=this.ya;break;case 5:this.M=this.M&~this.R|this.I<<16>>24&this.R;this.I=this.ya;break;case 6:this.K=this.K&~this.R|this.L<<16>>24& +this.R;this.L=this.ya;break;case 7:this.J=this.J&~this.R|this.G<<16>>24&this.R,this.G=this.ya}this.A-=-1===this.C?3:6};B[191]=function(){Xd(this,2);this.ma.call(this,Ii);switch(this.ga>>3&7){case 0:this.D=this.D<<16>>16;break;case 1:this.I=this.I<<16>>16;break;case 2:this.L=this.L<<16>>16;break;case 3:this.G=this.G<<16>>16;break;case 4:this.Hc=this.Hc<<16>>16;break;case 5:this.M=this.M<<16>>16;break;case 6:this.K=this.K<<16>>16;break;case 7:this.J=this.J<<16>>16}this.A-=-1===this.C?3:6}; +var If=[function(){this.A-=2+(-1===this.C?0:1);return this.Eb.U},function(){this.A-=2+(-1===this.C?0:1);return this.la.U},function(a){this.N|=2;this.Eb.load(a);this.A-=17+(-1===this.C?0:2);return a},function(a){this.N|=2;-1!==this.la.load(a)&&(this.fb(this.la.Lb+4,this.la.jb|=512),this.la.type|=512);this.A-=17+(-1===this.C?0:2);return a},function(a){this.N|=2;this.A-=14+(-1===this.C?0:2);if(-1!==this.xb.load(a)&&2048!=(this.xb.jb&2560)&&(this.xb.qc>=this.Ma&&this.xb.qc>=(a&3)||7168==(this.xb.jb&7168)))return fg(this), +a;dg(this);return a},function(a){this.N|=2;this.A-=14+(-1===this.C?0:2);if(-1!==this.xb.load(a)&&512==(this.xb.jb&2560)&&this.xb.qc>=this.Ma&&this.xb.qc>=(a&3))return fg(this),a;dg(this);return a},ri,ri],le=[He,He,He,He,He,He,ri,ri],Lk=[function(a){if(-1===this.C)y.call(this,6);else{a=this.Pc-this.Kb;var b=this.Kb;80286==this.ca?b|=-16777216:80386<=this.ca&&2!=this.V&&(a|=b<<16);this.ab(this.C+2,b);this.A-=11}return a},function(a){if(-1===this.C)y.call(this,6);else{a=this.cd-this.Pb;var b=this.Pb; +80286==this.ca?b|=-16777216:80386<=this.ca&&2!=this.V&&(a|=b<<16);this.ab(this.C+2,b);this.A-=12}return a},function(a){-1===this.C||this.O&131072?y.call(this,6):(this.Kb=this.ia(this.C+2)&(this.R|this.R<<8),a&=65535,this.Pc=this.Kb+a,this.N|=2,this.A-=11);return a},function(a){-1===this.C||this.O&131072?y.call(this,6):(this.Pb=this.ia(this.C+2)&(this.R|this.R<<8),a&=65535,this.cd=this.Pb+a,this.N|=2,this.A-=12);return a},function(){this.A-=2+(-1===this.C?0:1);return this.qa},ri,function(a){this.O& +131072?y.call(this,6):(gg(this,a),this.A-=-1===this.C?3:6,this.N|=2);return a},ri],Mk=[ri,ri,ri,ri,fi,ii,hi,gi]; +function Nk(a){ab.call(this,"ChipSet",a,32768);var b=a.model;b&&!Ok[b]&&Wa("Unrecognized ChipSet model: "+b);this.ca=Ok[b]||Pk;this.C=[];b=Qk(a[Rk]);this.C[0]=[b,b];null==b&&(this.N=[360,360],(b=a.floppies)&&b.length&&(this.N=b),Sk(this,Tk,this.N.length),Sk(this,Uk,a.monitor||(this.ca=Fg&&(this.za=this.ha=2);this.O=a.scaleTimers||!1;this.Ma=a.rtcDate;this.Ga=!1;a.sound&&(this.Da=this.la=null,window&&(this.Da=window.AudioContext|| +window.webkitAudioContext),this.Da&&(this.la=new this.Da));this.reset(!0);tb(this)}ba(Nk,ab);l=Nk.prototype;l.Cb=function(a,b,c){switch(b){case Rk:return this.na[b]=c,Wk(this,0,b),!0;case Vk:if((this.ca|0)==Xk||this.ca==Yk)return this.na[b]=c,Wk(this,1,b),!0;break;case Zk:return this.na[b]=c,!0}return!1}; +l.uc=function(a,b,c,d){this.ka=b;this.H=c;this.ba=d;this.pa=a;this.Tc=Jb(a,"FPU");Sk(this,$k,this.Tc?1:0,!0);this.B=Jb(a,"Keyboard");this.Ba=c.T.sd/al;zc(b,this,bl);Dc(b,this,cl);this.ca=Fg){this.D=zl;this.L=0;this.K=Al;this.oa=0;this.M=Bl|Cl;512<=Dl(this)&&(this.M|=El);+Fl(this,Uk,void 0)==Gl&&(this.M|=Hl);(this.ca|0)==jl&&(this.M=this.M|Il|Jl);this.qa= +Kl|Ll;this.Y=Array(8);this.W=0;a&&(this.A=Array(ol));Ml(this,this.Ma);for(a=Nl;a<=Ol;a++)this.A[a]=0;for(a=Pl;ac?c=c?c:12:c=(c-=12)?c+128:140,d=!0);a.A[Cd]&Dm||(d&&128>8} +l.save=function(){var a=new Jf(this);a.set(0,[this.C]);for(var b=[],c=0;c=Fg&&(a.set(5,[this.D,this.L,this.K,this.oa,this.M,this.qa]),a.set(6,[this.Y[7],this.Y,this.W,this.A,this.ma,this.Z]));return a.data()}; +l.restore=function(a){var b,c;b=a[0];Array.isArray(b[0])?this.C=b[0]:(this.C[0][0]=b[0],this.C[1][0]=b[1]&15,this.C[0][1]=b[2],this.C[1][1]=b[3]&15);rl(this);b=a[1];for(c=0;c=f;f++){var g="pcjs-bitCell";f||(g+=" pcjs-bitCellLeft");d+='
    '+f+"
    \n"}e.innerHTML=d;Om(a,b,c,!0)}function Pm(a,b,c){if(b=(a=Qm[a.ca|0])&&a[b])for(var d in b)if(a=b[d],a.yc&1<g.nb[0]&&(g.nb[0]=255,g.nb[1]--,0>g.nb[1]&&(g.nb[1]=255)));return h}function dn(a,b,c,d,e,f){var g=a.F[b];t(a,768)&&v(a,d,e,f,"DMA"+b+".CHANNEL"+c+".COUNT["+g.zb+"]",null,!0);a=g.oc[c];a.nb[g.zb]=a.pc[g.zb]=e;g.zb^=1}function en(a,b,c,d){var e=a.F[b],f=e.Mb|fn;e.Mb&=~gn;t(a,768)&&v(a,c,null,d,"DMA"+b+".STATUS",f,!0);return f} +function hn(a,b,c,d,e){var f=a.F[b];t(a,768)&&v(a,c,d,e,"DMA"+b+".REQ",null,!0);a=d&3;f.Mb=f.Mb&~(16<>2].oc[b&3],c,d,e)}function mn(a,b,c){b=a.F[b>>2].oc[b&3];b.mg&&b.eh&&b.Ag?(c&&(b.done=c),b.ne||wn(a,b,!0)):c&&c(!0)} +function wn(a,b,c){c&&(b.count=b.nb[1]<<8|b.nb[0],b.type=b.mode&xn,b.rj=b.ng=!1);for(var d=!1;0<=b.count&&(c=b.hg<<16|b.sb[1]<<8|b.sb[0],b.type==yn?(d=!0,function(c){b.eh.call(b.mg,b.Ag,-1,function(e,g){0>e&&(b.rj||(b.rj=!0),e=255);b.ne||a.ka.fc(c,e);(d=g)&&setTimeout(function(){zn(b)||wn(a,b)},0)})}(c)):b.type==An?(c=a.ka.Ia(c),0>b.eh.call(b.mg,b.Ag,c)&&(b.ng=!0)):b.type!=Bn&&(b.ng=!0)),!d&&!zn(b););} +function zn(a){if(!a.ng&&0<=--a.count&&(a.mode&Cn?(a.sb[0]--,0>a.sb[0]&&(a.sb[0]=255,a.sb[1]--,0>a.sb[1]&&(a.sb[1]=255))):(a.sb[0]++,255>3];b=1<<(b&7);d.ac&b||(d.ac|=b,d.We=c||0,Rn(a))}function Gg(a,b){var c=a.hc[b>>3];b=1<<(b&7);c.ac&b&&(c.ac&=~b,Rn(a))}function Rn(a,b){var c,d=-1;1>=1),sd(a.H,e))),b==eo&&c==io&&Hm(a))}function jo(a,b,c,d){v(a,c,null,d,"PIT"+b+".CTRL",null,2048);return b?a.va:a.ta} +function ko(a,b,c,d,e){v(a,c,d,e,"PIT"+b+".CTRL",null,2048);e=0;c=d&lo;b?(e=3,a.va=d):a.ta=d;if(c==mo){if(!(d&no))for(c=0;2>=c;c++)if(d&oo<=c;c++)d&oo<>=to;var f=d&uo,g=d&vo;d&=wo;if(d==xo)so(a,e+c);else{e+=c;var h=a.G[e];h.Qf=d;h.mode=g;h.Zg=f;h.pc=[0,0];h.nb=[0,0];h.je=[0,0];h.gd=!1;h.Me=!1;h.le=!1;h.Qe=!1;$n(a,e);b==eo&&c==fo&&Gg(a,go);b==eo&&c==io&&255==a.hc[0].od&& +a.J==(yo|zo|Ao|Bo)&&(b=a.G[0],b.Mc[0]=b.pc[0],b.Mc[1]=b.pc[1],b.jd=qd(a.H,a.O))}}}function ho(a,b){a=a.G[b];(b=a.pc[1]<<8|a.pc[0])||(b=1==a.ad?256:65536);return b}function Ad(a,b){a=a.G[b];(b=a.Mc[1]<<8|a.Mc[0])||(b=1==a.ad?256:65536);return b}function so(a,b){nl(a,b);var c=a.G[b];c.je[0]=c.nb[0];c.je[1]=c.nb[1];c.Me=!0;$n(a,b)}function $n(a,b){a=a.G[b];a.rd=a.Qf==Co?1:0;a.ad=a.Qf==Do?2:1} +function nl(a,b,c){var d=a.G[b];if(d.le&&(b!=io||a.J&yo)){var e=qd(a.H,a.O),f=(e-d.jd)/a.Ba|0;0>f&&(d.jd=e,f=0);var g=ho(a,b),h=Ad(a,b)-f;d.mode==bo?(0>=h&&(h=0),h||(d.gd=!0,d.le=!1,b||Ig(a,go))):d.mode==Eo?(d.gd=1!=h,0>=h&&(h=g+h,0>=h&&(h=g),d.Mc[0]=h&255,d.Mc[1]=h>>8&255,d.jd=e,!b&&d.gd&&Ig(a,go))):d.mode==Bd&&(h-=f,0>=h&&(d.gd=!d.gd,h=g+h,0>=h&&(h=g),d.Mc[0]=h&255,d.Mc[1]=h>>8&255,d.jd=e,!b&&d.gd&&Ig(a,go)));d.nb[0]=h&255;d.nb[1]=h>>8&255;c&&(a.jd=0)}return d} +function zd(a,b){for(var c=0;c=Fg){b=a.H.T.sd;c=qd(a.H,a.O);null==a.Aa&&(a.ma=qd(a.H,a.O),a.Ha=1024,a.Aa=Math.floor(a.H.T.sd/a.Ha),Fm(a));c>=a.Z&&(a.A[Bm]|=Fo,a.A[Cd]&Dd&&(a.A[Bm]|=Go,Ig(a,Ho)),a.Z=c+a.Aa);a.A[Yl]==a.A[Zl]&&a.A[$l]==a.A[am]&&a.A[bm]==a.A[cm]&&(a.A[Bm]|=Io,a.A[Cd]&Jo&&(a.A[Bm]|=Go,Ig(a,Ho)));var d=c-a.ma,e=Math.floor(d/b);if(e&&!(a.A[Cd]&Ko)){for(;e--;)if(60<=++a.A[Yl]&&(a.A[Yl]=0,60<=++a.A[$l]&&(a.A[$l]=0,24<=++a.A[bm]))){a.A[bm]=0;a.A[dm]=a.A[dm]% +7+1;var f;f=a.A[gm];var g=Aa[a.A[fm]-1];28==g&&(f%4||!(f%100)&&f%400||g++);f=g;++a.A[em]>f&&(a.A[em]=1,12<++a.A[fm]&&(a.A[fm]=1,a.A[gm]=(a.A[gm]+1)%100))}a.A[Bm]|=Lo;a.A[Cd]&Mo&&(a.A[Bm]|=Go,Ig(a,Ho))}a.ma=c-d%b}}l.Gm=function(a,b){var c=this.ya;this.ga&No&&(this.J&Oo?c=this.C[0][1]:this.B&&(c=Po(this.B)));v(this,a,null,b,"PPI_A",c);return c};l.ho=function(a,b,c){v(this,a,b,c,"PPI_A");this.ya=b};l.Hm=function(a,b){var c=this.J;v(this,a,null,b,"PPI_B",c);return c}; +l.io=function(a,b,c){v(this,a,b,c,"PPI_B");Qo(this,b)};function Qo(a,b){var c=!!(b&Ro),d=!!(a.J&Ro);a.J=b;a.B&&So(a.B,!(b&Oo),!!(b&Bo));c!=d&&Hm(a,c)}l.Im=function(a,b){var c=0,c=(this.ca|0)==Xk?this.J&zo?c|this.C[1][1]&To:c|this.C[1][1]>>4&1:this.J&Uo?c|this.C[0][1]>>4:c|this.C[0][1]&15;this.J&yo&&nl(this,io).gd&&(c=this.J&Ro?c|Vo:c|Wo);v(this,a,null,b,"PPI_C",c,32896);return c};l.jo=function(a,b,c){v(this,a,b,c,"PPI_C");this.Ca=b};l.Jm=function(a,b){var c=this.ga;v(this,a,null,b,"PPI_CTRL",c);return c}; +l.ko=function(a,b,c){v(this,a,b,c,"PPI_CTRL");this.ga=b};l.Sl=function(a,b){var c=this.B?Po(this.B):0;v(this,a,null,b,"8041_KBD",c);this.aa&=~Xo;return c};l.rn=function(a,b,c){v(this,a,b,c,"8041_KBD")};l.Rl=function(a,b){var c=this.J;v(this,a,null,b,"8041_CTRL",c);return c};l.qn=function(a,b,c){v(this,a,b,c,"8041_CTRL");Qo(this,b)};l.Tl=function(a,b){var c=this.aa;v(this,a,null,b,"8041_STATUS",c);return c}; +l.Ul=function(a,b){var c=this.oa;v(this,a,null,b,"8042_OUTBUFF",c,16384);this.D&=~(Xo|Yo);this.B&&Zo(this.B);return c}; +l.tn=function(a,b,c){v(this,a,b,c,"8042_INBUF.DATA",null,16384);if(this.D&$o)switch(this.L){case ap:bp(this,b);break;case cp:dp(this,b);break;default:if(bp(this,this.K&~Al),this.B){a=this.B;c=b;var d=-1;t(a)&&wb(a,"sendCmd("+r(c)+")");switch(a.F||c){case ep:d=fp;gp(a);break;case hp:a.F&&(c=0);ip(a,fp);a.F=c;break;case jp:a.F&&(c=0);ip(a,fp);a.F=c;break;default:wb(a,"sendCmd(): unrecognized command")}kp(this,d)}}this.L=b;this.D&=~$o}; +l.Vl=function(a,b){var c=this.J&~(lp|mp)|(qd(this.H)&64?mp:0);v(this,a,null,b,"8042_RWREG",c,16384);return c};l.un=function(a,b,c){v(this,a,b,c,"8042_RWREG",null,16384);Qo(this,b)};l.Wl=function(a,b){v(this,a,null,b,"8042_STATUS",this.D,16384);a=this.D&255;this.D&Yo&&(this.D|=Xo,this.D&=~Yo);return a}; +l.sn=function(a,b,c){v(this,a,b,c,"8042_INBUFF.CMD",null,16384);this.L=b;this.D|=$o;a=0;this.L>=np&&(a=this.L^15,this.L=np);switch(this.L){case op:kp(this,this.K);break;case pp:bp(this,this.K|Al);break;case qp:bp(this,this.K&~Al);this.B&&Zo(this.B);break;case rp:this.B&&(a=this.B,a.A=[],t(a)&&wb(a,"scan codes flushed"));bp(this,this.K|Al);kp(this,sp);dp(this,Kl|Ll);break;case tp:kp(this,up);break;case vp:kp(this,this.M);break;case wp:kp(this,this.qa);break;case xp:kp(this,this.K&Al?0:yp);break;case np:a& +1&&Te(this.H)}};function bp(a,b){a.K=b;a.D=a.D&~zp|b&Ap;a.B&&So(a.B,!!(b&Bp),!(b&Al))}function kp(a,b,c){0<=b&&(a.oa=b,c?a.D|=Xo:(a.D&=~Xo,a.D|=Yo))}function dp(a,b){a.qa=b;ac(a.ka,!!(b&Ll));b&Kl||Te(a.H)}function Cp(a,b){a.ca>4)+(c&15),e=!0);if(d==bm||d==cm)e&&23=c?c=12==c?0:c:(c-=116,c=24==c?12:c))}}else c=b;this.A[d]=c;d==Cd&&a&Dd&&b&Dd&&Fm(this)};l.Nk=function(a,b,c){v(this,a,b,c,"NMI");this.da=b};l.Tn=function(a,b,c){v(this,a,b,c,"FPU.CLEAR")};l.Un=function(a,b,c){v(this,a,b,c,"FPU.RESET");this.Tc&&Ag(this.Tc)}; +l.Xm=function(a){if(t(this,16)&&Ik(this.ba,26,a)){var b=this.H.D>>8;Ff(this.H,a,function(a,d){return function(c){d=qd(a.H)-d;var e,g=a.H.L&255,h=a.H.L>>8,k=a.H.L&255,m=a.H.L>>8;if(2==b||3==b)e=" CH(hour)="+ka(h)+" CL(min)="+r(g)+" DH(sec)="+r(m);else if(4==b||5==b)e=" CX(year)="+ka(a.H.I)+" DH(month)="+r(m)+" DL(day)="+r(k);g=a.ba;h=d;g.message("INT "+r(26)+": C="+(Qf(g.H)?1:0)+(e||"")+" (cycles="+h+(c?",level="+(c+1):"")+")")}}(this,qd(this.H)))}return!0}; +function Hm(a,b){if(a.la)try{void 0!==b?a.Ga=b:b=!!(a.Ga&&a.H&&a.H.ea.vb);var c=Math.round(al/ho(a,io));if(20>c||2E4>>4,0,this.F,this.C,this.Fd),delete this.Fd);return!0};Kp.prototype.Wb=function(){return!0}; +function Lp(a,b,c,d){if(d)a.Fa("Unable to load system ROM (error "+d+": "+b+")");else{eb(a.xe,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,g=e.data;if(f)a.A=f;else if(g)for(a.A=Array(4*g.length),d=c=0;c>8&255,a.A[d++]=g[c]>>16&255,a.A[d++]=g[c]>>24&255;else a.A=e;a.Fd=e.symbols;if(!a.A.length){Wa("Empty ROM: "+b);return}if(1==a.A.length){Wa(a.A[0]);return}}catch(h){a.Fa("ROM data error: "+h.message);return}else for(b= +c.replace(/\n/gm," ").replace(/ +$/,"").split(" "),a.A=Array(b.length),e=0;e>>d.A].bf(e&d.D,a.A[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.D?b.push(a.D):null!=a.D&&a.D.length&&(b=a.D);for(c=0;cthis.B?Nl:23,c=a.A[b]|a.A[b+1]<<8,c=c+(this.A>>10);a.A[b]=c&255;a.A[b+1]=c>>8;Xl(a)}}else Wa("No RAM allocated")}; +l.save=function(){var a=new Jf(this);this.controller&&a.set(0,this.controller.save());return a.data()};l.restore=function(a){return this.controller?this.controller.restore(a[0]):!0};function Sp(a){this.D=a;this.C=Up;this.H=Vp;this.B=Wp;this.A=null}l=Sp.prototype;l.save=function(){return[this.C,this.B]};l.restore=function(a){this.fc(0,a[0]&255);this.fc(2,a[1]&255);return!0};l.Ia=function(a){var b=255;2>a?b=a&1?this.H>>8:this.H&255:4>a&&(b=a&1?this.B>>8:this.B&255);return b}; +l.fc=function(a,b){if(a)2==a&&(this.B=this.B&-256|b);else if(b!=(this.C&255)){a=this.D.ka;if(b&Xp)this.A&&(hc(a,Yp,Zp,this.A),this.A=null);else{this.A||(this.A=ic(a,Yp,Zp));var c=ic(a,$p,Zp);hc(a,Yp,Zp,c,b&aq?1:oc)}this.C=this.C&-256|b}};l.vj=function(){return bq};l.fh=function(){return cq};var Tp=-2134900736,$p=16646144,Yp=917504,Zp=131072,Xp=1,aq=2,Up=65535,Vp=2575,Wp=2,bq=[null,0],cq=[function(a){return this.controller.Ia(a)},null,null,function(a,b){this.controller.fc(a,b)},null,null]; +Ra(function(){for(var a=pb(document,"pcx86","ram"),b=0;b=n.de&&d<=n.z&&(d-=n.de-n.ce),d=nq[e]==d),d){(a=a.na["key-"+e])&&void 0!==c&&(a.style.color=c?"#ffffff":"#000000",a.style.backgroundColor=c?"#000000":"#ffffff");break}}}l.uc=function(a,b,c,d){this.pa=a;this.ka=b;this.H=c;this.ba=d;this.W=Jb(a,"ChipSet")}; +function eq(a,b){var c=0;a.ca=null;"string"==typeof b&&(a.ca=b.toUpperCase(),c=rq.indexOf(a.ca),0>c&&(c=0));if(b=rq[c])a.Y=parseInt(b.substr(2),10)}function gp(a){wb(a,"keyboard reset",65792);a.A=[];ip(a,sq)}function So(a,b,c){a.J!==c&&(a.J=a.K=c)&&(a.G=!0);a.I!==b&&(a.I=b)&&!a.K&&Ep(a,!0);a.I&&a.K&&(gp(a),a.K=!1)}function ip(a,b){a.W&&(a.A.unshift(b),a.G=!0,Cp(a.W,b))} +function Zo(a){var b=0;a.A.length&&a.G&&(b=a.A[0],a.W&&Cp(a.W,b));t(a)&&wb(a,b?"scan code "+r(b)+" available":"no scan codes available")}function Po(a){var b=0;a.A.length&&(b=a.A[0]);t(a)&&wb(a,"scan code "+r(b)+" delivered");return b}function Ep(a,b){0>=1);if(b&wq){if(!1===d)return!0;d=null}null==d?d=!((c?a.C:a.jc)&b):d||b&xq&&(b=xq);if(c){a.C&=~b;d&&(a.C|=b);c=b;var f,g;for(g in yq)d="led-"+g,e=yq[g],c&&c!=e||!(f=a.na[d])||(f.style.backgroundColor=a.C&e?"#00ff00":"#000000")}else a.jc&=~b,d&&(a.jc|=b);return!0}}return!1} +function hq(a,b,c){if(O[b]&&a.H&&a.H.ea.vb){uq[b]&&a.B.length&&0e||(e==a.B.length&&(d={},d.ue=b,d.jc=a.jc,qq(a,b,!0),e++),0b.ud){if(!b.qf){oq(a,b.ue);return}b.qf=!1;c=a.Z}else c=1==b.ud++?500:100;b.cl=setTimeout(function(a){return function(){zq(a,b)}}(a),c)}} +function Bq(a,b,c){var d=b;if(b>=n.ce&&b<=n.eg)!(a.jc&(Cq|Dq|Eq))==c&&(d=b+(n.de-n.ce));else if(b>=n.de&&b<=n.z)!!(a.jc&(Cq|Dq|Eq))==c&&(d=b-(n.de-n.ce));else if(!!(a.jc&(Cq|Dq))==c){if(a=fa[b])d=a}else if(a=ea[b])d=a;return d}l.Bg=function(a){a||(this.jc&=~xq)}; +function fq(a,b,c){var d=!0,e=!1,f=!1,g=b.keyCode,h=Bq(a,g,!0);a.dh&&h==n["`"]&&(g=h=27);if(O[g+1E3])if(h+=1E3,2==b.location&&(h+=2E3),mq(a,h,!1,c)){if(20==g||144==g||145==g)a.O||(c=e=!0);if(!(c||91!=g&&93!=g))for(var k=0;k=n.ce&&b<=n.eg||b>=n.de&&b<=n.z;e>>>=8;){var g=0,h=e&255;f==Oq||f==Pq?d.push(f|(c?0:Nq)):(h==P?a.C&(Cq|Dq)||a.C&Eq&&b||(g=h):h==Qq?a.C&(Fq|Rq)||(g=h):h==Sq?a.C&(Gq|Tq)||(g=h):d.push(f|(c?0:Nq)),g&&(c?d.unshift(g):d.push(g|Nq)))}for(c=0;c"]]=52|P<<8;O[n["/"]]=53; +O[n["?"]]=53|P<<8;O[3016]=54;O[1044]=55;O[1018]=Sq;O[1032]=57;O[iq]=58;O[1112]=59;O[1113]=60;O[1114]=61;O[1115]=62;O[1116]=63;O[1117]=64;O[1118]=65;O[1119]=66;O[1120]=67;O[1121]=68;O[jq]=69;O[kq]=70;O[1036]=71;O[1038]=72;O[1033]=73;O[1109]=74;O[1037]=75;O[1101]=76;O[1039]=77;O[1107]=78;O[1035]=79;O[1040]=80;O[1034]=81;O[1045]=82;O[1046]=Mq;O[4027]=84;O[1122]=87;O[1123]=88;O[1091]=91;O[1093]=93;O[1224]=91;O[Wq]=46|Qq<<8;O[Hq]=70|Qq<<8;O[4046]=Mq|Qq<<8|Sq<<16;O[4045]=82|Qq<<8|Sq<<16; +O[4013]=28|Qq<<8|Sq<<16;var ep=255,hp=243,jp=237,sq=170,fp=250,Vq=255,Uq=20;Ra(function(){for(var a=pb(document,"pcx86","keyboard"),b=0;bc.length)c=[!1,0,null,null,0,Array(b>2,32768));this.rc=c[0];this.Xc=c[1];this.Ze=c[2];this.fa=c[3];this.ec=c[4]&255;this.Fg=c[4]>>8&255;this.Wa=c[5];this.oh=Zq;this.gg=ar;if(b>=Op){this.oh=$q;this.gg=br;(b=c[6])||(b=[!1,0,Array(cr),0,f== +Gl?0:dr,0,0,Array(er),0,0,0,Array(fr),0,[this.bb,this.Ob,this.qd],Array(this.qd>>2),gr|hr|ir|jr|kr,0,-1,0,-1,0,-1,0,0,0,0,lr,mr,0,0,nr,Array(or)]);this.Ke=b[0];this.wd=b[1];this.Cc=b[2];this.Tg=pr;this.Ig=b[3];this.af=b[4];this.Pf=b[5];this.zd=b[6];this.$d=b[7];this.Vg=qr;this.Wk=b[8];this.Xk=b[9];this.yd=b[10];this.xd=b[11];this.Ug=rr;this.tb=b[12];d=b[13];"number"==typeof d&&(d=[this.bb,this.Ob,d]);this.bb=d[0];this.Ob=d[1];d=this.qd>>2;if((this.fd=b[14])&&this.fd.length=Op){var c=[];c[0]=a.Ke;c[1]=a.wd;c[2]=a.Cc;c[3]=a.Ig;c[4]=a.af;c[5]=a.Pf;c[6]=a.zd;c[7]=a.$d;c[8]=a.Wk;c[9]=a.Xk;c[10]=a.yd;c[11]=a.xd;c[12]=a.tb;c[13]=[a.bb,a.Ob,a.qd];var d;if(d=a.fd){var e=0,f=[];if(void 0!==d[0])for(var g=0;2>g;g++)for(var h=g;h>1;f[e++]=k;h=m}f.length=Op){var d=0,e=0,f=0;switch(b){case Ar:d=Br;a.La==Qp&&(e=Cr);break;case Dr:a.La==Op&&(d=Er);break;case Fr:d=Gr;a.La==Qp&&(e=Hr);break;case Ir:d=Jr;a.La==Qp&&(e=Kr);break;case Lr:d=Mr;a.La==Qp&&(f=Nr);break;case Or:d=Pr,a.La==Qp&&(f=Qr)}d&&(c|=a.Wa[Rr]&d?256:0,c|=a.Wa[Rr]&e?512:0,c|=a.Wa[Sr]&f?512:0)}return c} +var Zq=18,Ar=6,Rr=7,Br=1,Jr=2,Gr=4,Mr=8,Pr=16,Er=32,Cr=32,Kr=64,Hr=128,Sr=9,Nr=32,Qr=64,Dr=10,Fr=16,Ir=18,Lr=21,Or=24,$q=25,ar="HTOTAL HDISP HSYNC_POS HSYNC_WIDTH VTOTAL VTOTAL_ADJ VDISP VSYNC_POS INTERLACE_POS MAX_SCAN CURSOR_START CURSOR_END START_ADDR_HI START_ADDR_LO CURSOR_ADDR_HI CURSOR_ADDR_LO LIGHT_PEN_HI LIGHT_PEN_LO".split(" "),br="HTOTAL HDISP_END HBLANK_START HBLANK_END HRETRACE_START HRETRACE_END VTOTAL OVERFLOW PRESET_SCAN MAX_SCAN CURSOR_START CURSOR_END START_ADDR_HI START_ADDR_LO CURSOR_ADDR_HI CURSOR_ADDR_LO VRETRACE_START VRETRACE_END VDISP_END OFFSET UNDERLINE VBLANK_START VBLANK_END MODE_CTRL LINE_COMPARE".split(" "), +cr=20,pr="PAL00 PAL01 PAL02 PAL03 PAL04 PAL05 PAL06 PAL07 PAL08 PAL09 PAL0A PAL0B PAL0C PAL0D PAL0E PAL0F MODE OVERSCAN PLANES HPAN".split(" "),dr=1,lr=1,er=5,qr=["RESET","CLOCKING","MAPMASK","CHARMAP","MEMMODE"],mr=255,nr=0,or=256,fr=9,rr="SRESET ESRESET COLORCMP DATAROT READMAP MODE MISC COLORDC BITMASK".split(" "),gr=1024,hr=4096,xr=65280,ir=0,jr=16,zr=255,kr=-2147483648,sr=[];sr[2]=gr;sr[3]=gr|hr;sr[16]=1280;sr[512]=ir;sr[1024]=ir|32;sr[1536]=ir|96;sr[2560]=ir|160;sr[3584]=ir|224;sr[768]=ir|jr; +sr[4096]=1;sr[8192]=2;sr[24576]=98;sr[40960]=162;sr[57344]=226;var yr=[];yr[gr]=function(a){a+=this.H;return(this.controller.tb=this.X[a])>>this.controller.ei&255};yr[gr|16384]=function(a){return(this.controller.tb=this.X[(a&-4)+this.H])>>((a&3)<<3)&255};yr[gr|hr]=function(a){a+=this.H;var b=this.controller.tb=this.X[a&-2];return(a&1?b>>8:b)&255}; +yr[1280]=function(a){a+=this.H;a=this.controller.tb=this.X[a];for(var b=this.controller.qh,c=this.controller.ph&b,d=0,e=128;e;)(a&b)==c&&(d|=e),c>>>=1,b>>>=1,e>>=1;return d};yr[ir]=function(a,b){a+=this.H;b=(b|b<<8|b<<16|b<<24)&this.controller.Md|this.controller.Yd;b=b&this.controller.Bb|this.controller.tb&~this.controller.Bb;b=b&this.controller.gb|this.X[a]&~this.controller.gb;this.X[a]!=b&&(this.X[a]=b,this.Oa=!0)}; +yr[ir|32]=function(a,b){a+=this.H;b=b>>this.controller.Qc|b<<8-this.controller.Qc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.Md|this.controller.Yd;b=b&this.controller.Bb|this.controller.tb&~this.controller.Bb;b=b&this.controller.gb|this.X[a]&~this.controller.gb;this.X[a]!=b&&(this.X[a]=b,this.Oa=!0)}; +yr[ir|96]=function(a,b){a+=this.H;b=b>>this.controller.Qc|b<<8-this.controller.Qc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.Md|this.controller.Yd;b&=this.controller.tb;b=b&this.controller.Bb|this.controller.tb&~this.controller.Bb;b=b&this.controller.gb|this.X[a]&~this.controller.gb;this.X[a]!=b&&(this.X[a]=b,this.Oa=!0)}; +yr[ir|160]=function(a,b){a+=this.H;b=b>>this.controller.Qc|b<<8-this.controller.Qc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.Md|this.controller.Yd;b|=this.controller.tb;b=b&this.controller.Bb|this.controller.tb&~this.controller.Bb;b=b&this.controller.gb|this.X[a]&~this.controller.gb;this.X[a]!=b&&(this.X[a]=b,this.Oa=!0)}; +yr[ir|224]=function(a,b){a+=this.H;b=b>>this.controller.Qc|b<<8-this.controller.Qc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.Md|this.controller.Yd;b^=this.controller.tb;b=b&this.controller.Bb|this.controller.tb&~this.controller.Bb;b=b&this.controller.gb|this.X[a]&~this.controller.gb;this.X[a]!=b&&(this.X[a]=b,this.Oa=!0)};yr[ir|4]=function(a,b){var c=(a&-4)+this.H;a=(a&3)<<3;b=b<>this.controller.Qc|b<<8-this.controller.Qc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.Bb;b=this.controller.Hf&b|this.controller.tb&~b;b=b&this.controller.gb|this.X[a]&~this.controller.gb;this.X[a]!=b&&(this.X[a]=b,this.Oa=!0)}; +function Q(a,b,c,d,e){ab.call(this,"Video",a,262144);var f=this;this.Tc=Ja("Gecko/");var g=["","moz","ms","webkit"];this.ca=a.model;var h=Ur[this.ca]||Ur.mda;this.La=h[0];this.qd=a.memory||0;this.cd=a.switches;this.da=a.mode;if(null==this.da||null==Vr[this.da])this.da=h[1];this.Fb=a.charCols;this.sc=a.charRows;if(void 0===this.Fb||void 0===this.sc)this.Fb=Vr[this.da][0],this.sc=Vr[this.da][1];this.Z=a.screenWidth;this.la=a.screenHeight;this.Uc=a.scale;this.Cd=12<=Math.round(this.Z/this.Fb);this.O= +b;this.L=c;this.D=(this.Qd=d)||b||null;b=a.smoothing;(c=Ka("smoothing"))&&(b="true"==c);if(null!=b)for(c=0;c=Op&&(zc(b,this,es),Dc(b,this,fs));this.La==Qp&&(zc(b,this,gs),Dc(b,this,hs));if(d){var e=this;ml(d,262144,function(a){if(e.C)if(a[0]){var b=e.C;if(b.fd){var c,d,f,g=!1,u=8,F=8,K=-1,H=b.video.F>>3;for(c=0;c=d&&(F=d,g=!0);break; +case "p":0<=d&&3>=d&&(K=d);break;case "w":d=b.bb&&(f-=b.bb);a="";for(c=0;cK?q(T):ha(T>>(K<<3),8));g&&(f+=H-F);a&&(a+="\n");a+=I}a&&b.ba.P(a);b.B=f}else b.ba.P("no buffer")}else e.ba.P("BIOSMODE: "+r(e.oa)),b=e.C,vr(b,"CRTC",b.ec,b.Wa,b.gg),b.La>=Op&&(vr(b," GRC",b.yd,b.xd,b.Ug),vr(b," SEQ",b.zd,b.$d,b.Vg),vr(b," ATC",b.wd,b.Cc, +b.Tg),vr(b," ATCINDX",b.wd),b.ba.P(" ATCDATA: "+b.Ke),vr(b," FEAT",b.Pf),vr(b," MISC",b.af),vr(b," STATUS0",b.Ig)),vr(b," STATUS1",b.fa),b.La!=bs&&b.La!=Zr||vr(b," MODEREG",b.Xc),b.La==Zr&&vr(b," COLOR",b.Ze),b.La>=Op&&(b.ba.P(" LATCHES: "+q(b.tb)),b.ba.P(" ACCESS: "+q(b.tg,4)),b.ba.P("Use 'dump video [addr]' to dump video memory"));else e.ba.P("no active video card")})}if((this.B=Jb(a,"Keyboard"))&&this.O){for(var f in this.na)0c&&(a=Math.round(c/b*100)+"%")}this.Tc?(this.O.style.width=a,this.O.style.width=a,this.O.style.display="block",this.O.style.margin="auto"):(this.N.style.width=a,this.N.style.height="auto");this.N.style.backgroundColor="black";this.N.Je();a=!0}this.D&&this.D.focus()}return a}; +function Xr(a,b){!b&&a.N&&(a.Tc?a.O.style.width=a.O.style.height="":a.N.style.width=a.N.style.height="");wb(a,"notifyFullScreen("+b+")",!0);a.B&&(a.B.dh=b)}l.me=function(a){var b=!1;this.D&&(a?this.D.me&&(this.D.me(),this.G&&this.G.If(!0),b=!0):this.D.dl&&(this.D.dl(),this.G&&this.G.If(!1),b=!0),this.D&&this.D.focus());return b};l.If=function(a){this.G&&(this.G.If(a),this.B&&(this.B.dh=a));var b=this.na.lockPointer;b&&(b.textContent=a?"Press Esc to Unlock Pointer":this.Dd)}; +function is(a,b){var c=a.D;c&&!a.tc&&(c.addEventListener("touchstart",function(b){ms(a,b,!0)},!1),c.addEventListener("touchmove",function(b){ms(a,b)},!0),c.addEventListener("touchend",function(b){ms(a,b,!1)},!1),a.tc=b,a.qb=a.rb=a.kd=-1,a.lc=!1,a.Db=null,a.kc=!1,a.Pd=function(){a.kc=!0;a.G.Vd(ns,!0)})}l.Bg=function(a){this.B&&this.B.Bg(a)}; +function ms(a,b,c){var d,e,f=0,g=0;e=a.O;do isNaN(e.offsetLeft)||(f+=e.offsetLeft,g+=e.offsetTop);while(e=e.offsetParent);var h=a.Z/a.O.offsetWidth,k=a.la/a.O.offsetHeight;b.targetTouches&&b.targetTouches.length?(d=b.targetTouches[0].pageX,e=b.targetTouches[0].pageY):(d=b.pageX,e=b.pageY);d=(d-f)*h;e=(e-g)*k;if(a.tc==ks)d=d/(a.Z/3)|0,e=e/(a.la/3)|0,1!=e?e?hq(a.B,1040,!0):hq(a.B,1038,!0):1!=d&&(d?hq(a.B,1039,!0):hq(a.B,1037,!0));else if(a.G){g=a.lc;f=b.timeStamp-a.kd;!0===c?(a.lc=500f){a.G.Vd(ns,!0);a.G.Vd(ns,!1);return}}if(c||0>a.qb||0>a.rb)a.qb=d,a.rb=e;c=Math.round(d-a.qb);b=Math.round(e-a.rb);a.qb=d;a.rb=e;a.G.tf(c,b,a.qb,a.rb)}}l.Xb=function(a,b){if(!b)if(!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};l.Wb=function(a){return a?this.save():!0}; +l.reset=function(){var a=!0,b=0;this.W&&(b=+Fl(this.W,Uk,void 0));this.ca||(this.La=b==Gl?bs:Zr);this.da=os;switch(this.La){case Qp:b=7;break;case Op:var c=ps[this.xb];c&&(b=c[0]);b||(b=4);break;case bs:b=Gl;this.da=qs;break;default:b=2}this.ga!==b&&(this.ga=b,a=!0);this.C=null;this.Y=this.Kb=new Xq(this,bs);this.K=this.yb=new Xq(this,Zr);this.La>1&255,d=d>>8&~us,d>>4==(d&15)&&(d^=15)):(c=d&255,d=(d&256?vs|ws:xs|ys)|zs&d>>8);wc(this.ka,b,c|d<<8)}ls(this,!0)}};function rs(a){a.A.af&dr?(a.Y=a.Kb,a.K=a.A):(a.Y=a.A,a.K=a.yb)}l.save=function(){var a=new Jf(this);a.set(0,ur(this.Kb));a.set(1,ur(this.yb));a.set(2,[this.ga,this.da,this.oa]);a.set(3,ur(this.A));return a.data()}; +l.restore=function(a){var b=a[2];this.ga=b[0];this.da=b[1];this.oa=b[2];this.C=null;this.Y=this.Kb=new Xq(this,bs,a[0]);this.K=this.yb=new Xq(this,Zr,a[1]);this.A=new Xq(this,this.La,a[3],this.qd);this.A.rc&&rs(this);ss(this);if(!As(this))return!1;Bs(this);return!0}; +function Yr(a,b,c,d){if(d)a.Fa("Unable to load font ROM (error "+d+": "+b+")");else{eb(a.xe,b,c);try{var e=eval("("+c+")"),f=e.bytes||e;if(!f.length){Wa("Empty font ROM: "+b);return}if(1==f.length){Wa(f[0]);return}if(8192==f.length)Pp(a,f,[6144,0]);else if(2048==f.length)Pp(a,f,[0]);else{a.Fa("Unrecognized font data length ("+f.length+")");return}}catch(g){a.Fa("Font ROM data error: "+g.message);return}(a.L||a.ba)&&tb(a)}} +function Cs(a,b){if(1==b)return a.ha[0]=Ds[xs],a.ha[1]=Ds[vs],a.ha;if(2==b){var c=a.C.Ze;if(a.C===a.A){var d=a.A.Cc[0],c=d&7;d&16&&(c|=8);18!=a.A.Cc[1]&&(c|=32)}a.ha[0]=Ds[c&15];c=c&32?Es:Fs;for(d=0;de;e++)f=d[e]||0,g=f<<2&252,h=f>>4&252,f=f>>10&252,a.ha[e]=[g,h,f,255];else{var k=d&&d[255];b=null!=c.Cc[15]?c.Cc:Gs;for(e=0;16>e;e++)f=b[e]&63,k?(f|= +(c.Cc[20]&12)<<4,c.Cc[16]&128&&(f&=-49,f|=(c.Cc[20]&3)<<4),f=d[f],g=f<<2&252,h=f>>4&252,f=f>>10&252):(g=(f&4?170:0)|(f&32?85:0),h=(f&2?170:0)|(f&16?85:0),f=(f&1?170:0)|(f&8?85:0)),a.ha[e]=[g,h,f,255]}a.Ga=!0}return a.ha}function Pp(a,b,c,d){a.wb=b;a.Ta=c;a.Da=d} +function ss(a,b){var c=!1;if(window&&a.wb&&(!b||a.I)){b=0;var d=a.Da?a.Da:8,e=Cs(a);null!=a.Ta[0]&&Hs(a,Is,a.Ta[0],b,d,8,a.wb,e)&&(c=!0);b=a.Da?0:2048;d=a.Da?a.Da:9;null!=a.Ta[1]&&(Hs(a,Js,a.Ta[1],b,d,14,a.wb,Ks,Ls)&&(c=!0),a.Da&&Hs(a,a.La,a.Ta[1],0,a.Da,14,a.wb,e)&&(c=!0))}return c}function Hs(a,b,c,d,e,f,g,h,k){var m=!1;null!=c&&(Ms(a,b,c,d,e,f,g,h,k)&&(m=!0),a.Cd&&Ms(a,b<<1,c,d,e,f,g,h,k)&&(m=!0));return m} +function Ms(a,b,c,d,e,f,g,h,k){var m=!1,p=b&1?0:1,x=a.va[b],u=16>h.length?h.length:16;x||(x={Fc:e<ua||!T?ua:8,ib=cb.createImageData(m.Fc,m.Gc);for(Sa=0;256>Sa;Sa++){for(db=0;db=ua-2,Ld=ca[db>(8<=rb&&192<=Sa&&223>=Sa?7:rb)?F:xb;Ns(ib,rg,df,sg);H&&Ns(ib,rg+1,df,sg)}cb.putImageData(ib,(Sa&15)*m.Fc,(Sa>>4)*m.Gc)}m.Be[K]="#"+q(F[0],2)+q(F[1],2)+q(F[2],2);m.Qi[K]=F;m.Sg[K]=za;m=!0}}a.va[b]=x;return m}function Os(a){0a.Aa&&(a.Aa=0):a.Aa=-1} +function Bs(a){if(a.I){for(var b=10;15>=b;b++)if(null==a.C.Wa[b])return;var c=a.C.Wa[10],b=c&31,d=a.C.Wa[11]&31,e=a.C.Wa[9]&31,f=!1;a.C===a.A&&(f=!0,7!=e||4!=b||d||(d=7));if(c&32||b>d&&!f||b>e)Ps(a);else{c=a.C.Wa[15]+((a.C.Wa[14]&63)<<8);a.aa!=c&&(Ps(a),a.aa=c);d=d-b+1;if(a.md!=b||a.Hc!=d)a.md=b,a.Hc=d;a.za=e+1;Os(a)}}} +function Ps(a){if(0<=a.aa){if(void 0!==a.M){var b=Qs<<8,c=a.M[a.aa];if(c&b){var c=c&~b,b=a.aa%a.F,d=a.aa/a.F|0;a.I&&a.va[a.I]&&(a.Ca&&Rs(a,b,d,c,a.Ca),Rs(a,b,d,c));a.M[a.aa]=c}}a.aa=-1}} +function Ss(a){var b,c=a.C;a.Pc=!1;var d=c.xd[5];if(null!=d){b=gr;var e=ir,f=c.xd[3]&31;switch(d&3){case 0:if(f){e=ir|32;switch(f&24){case 8:e=ir|96;break;case 16:e=ir|160;break;case 24:e=ir|224}c.Qc=f&7}break;case 1:e=1;break;case 2:switch(f&24){default:e=2;break;case 8:e=98;break;case 16:e=162;break;case 24:e=226}break;case 3:a.La==Qp&&(e=3,c.Qc=f&7)}d&8&&(b=1280);c=c.$d[4];null!=c&&(c&4||(b|=hr,e|=jr),d&64&&(c&8&&(b|=16384,e|=4),a.Pc=!0));b|=e}return b} +function Ts(a,b){var c=a.C;return c&&null!=b&&b!=c.tg?(c.Kg(b),a.ka.Kg(c.bb,c.Ob,c.fh(),!0),!0):!1} +function As(a,b){var c,d=a.oa,e=a.C;if(e)if(e.La==bs)d=qs;else if(e.La>=Op){var d=null,f=e.qd>>2,g=32768=e.Wa[Ir]?Ys:Zs:$s:g&128|| +350>f?d=m?at:bt:480<=f&&(d=a.ga==Gl?ct:dt):d=m?7-d:et:d-=m?2:0);c=Ss(a)}}else e.Xc&8&&(e.Xc&2?(d=e.Xc&16?et:ft,e.Xc&4||--d):(d=e.Xc&1?os:gt,e.Xc&4&&--d));else a.oa=null,null==d&&(d=a.da);if(!ts(a,d,b))return!1;Ts(a,c);return!0} +function ts(a,b,c){if(null!=b&&(b!=a.oa||c)){a.Ad=0;a.oa=b;a.Ga=!1;b=a.C||(b==qs?a.Y:a.K);if(b!=a.C||b.bb!=a.bb||b.Ob!=a.Ob){Ps(a);if(a.bb){if(!mc(a.ka,a.bb,a.Ob))return!1;a.C&&(a.C.rc=!1)}a.C=b;b.rc=!0;a.bb=b.bb;a.Ob=b.Ob;if(!bc(a.ka,b.bb,b.Ob,3,b===a.A?b:null))return!1}a:{a.I=0;a.F=a.Fb;a.J=a.sc;a.Ma=a.F;a.Eb=Vr[qs][2];b=0;if(c=Vr[a.oa])a.F=c[0],a.J=c[1],a.Eb=c[2],b=c[3],a.I=c[4],4!=a.ga&&7!=a.ga||a.C!==a.A||a.I!=Is||(7==(a.A.Wa[Sr]&31)?a.J=350>wr(a.A,Ir)?43:50:a.I=a.La);a.Wc=a.F*a.J|0;a.Vc=a.Wc/ +a.Eb|0;a.Za=a.Vc;a.Pb=0;void 0!==b&&(a.Za=(a.Za<<1)+b|0,a.Pb=a.Za+b>>1);if(a.va.length){a.qa=a.Z/a.F|0;a.ta=a.la/a.J|0;if(a.I){b=a.va[a.I];if(!b)break a;c=a.va[a.I<<1];a.Uc&&80==a.F?c&&a.qa>=3*c.Fc>>2&&(a.I<<=1,b=c):(c&&a.qa>=c.Fc&&(a.I<<=1,b=c),a.Uc||(a.qa=b.Fc,a.ta=b.Gc));a.$a=a.eb=0;b&&(a.$a=a.F*b.Fc,a.eb=a.J*b.Gc)}else a.qa=a.ta=1,a.$a=a.F,a.eb=a.J;a.Ha=a.L.createImageData(a.$a,a.eb);a.Ba=document.createElement("canvas");a.Ba.width=a.$a;a.Ba.height=a.eb;a.Ca=a.Ba.getContext("2d");a.vc=a.zc=0; +a.Qb=a.Z;a.Rb=a.la;b=a.Z-a.F*a.qa;c=a.la-a.J*a.ta;0>1,a.Qb-=b);0>1,a.Rb-=c);if(b||c)a.L.fillStyle=a.O.style.backgroundColor,a.L.fillRect(0,0,a.Z,a.la)}}ht(a,!0);ls(a)}return!0}function Ns(a,b,c,d){b=(b+c*a.width)*d.length;a.data[b]=d[0];a.data[b+1]=d[1];a.data[b+2]=d[2];a.data[b+3]=d[3]}function it(a){a.ya=-1;a.ma=!1;var b=a.Vc;if(void 0===a.M||a.M.length!=b)a.M=Array(b)}function ht(a,b){b||(a.Ga=!1);it(a)} +function Rs(a,b,c,d,e){var f=d&255,g=d>>8;d=g&15;var h=a.va[a.I];h.jf&&(d=h.jf[d]);var k=g>>4&15;h.jf&&(k=h.jf[k]);e?(b*=h.Fc,c*=h.Gc,e.fillStyle=h.Be[k],e.fillRect(b,c,h.Fc,h.Gc)):(b=b*a.qa+a.vc,c=c*a.ta+a.zc,a.L.fillStyle=h.Be[k],a.L.fillRect(b,c,a.qa,a.ta));g&Ht&&(k=(f&15)*h.Fc,f=(f>>4)*h.Gc,e?e.drawImage(h.Sg[d],k,f,h.Fc,h.Gc,b,c,h.Fc,h.Gc):a.L.drawImage(h.Sg[d],k,f,h.Fc,h.Gc,b,c,a.qa,a.ta));g&Qs&&(f=a.md,g=a.Hc,e?(a.za&&a.za!==h.Gc&&(f=f*h.Gc/a.za|0,g=g*h.Gc/a.za|0),e.fillStyle=h.Be[d],e.fillRect(b, +c+f,h.Fc,g)):(a.za&&a.za!==a.ta&&(f=f*a.ta/a.za|0,g=g*a.ta/a.za|0),a.L.fillStyle=h.Be[d],a.L.fillRect(b,c+f,a.qa,g)))} +function ls(a,b){if(a.ea.Yb){var c=!1,d=a.C;d&&(d!==a.A?d.Xc&8&&(c=!0):d.wd&32&&(c=!0));if(c||b){if(b)it(a);else if(void 0===a.M)return;var e=!1;!(b||++a.Ad&15)&&0<=a.Aa&&(a.Aa++,e=!0);var f=0,g=a.Wc,h=a.bb,c=h,k=c+a.Ob;a.oa>=Ys&&(h=c=655360,k=c+65536);if(Jt(a,d)&8||d.Ye&&d.Ye=Op&&d.Wa[19]&&d.Wa[19]<<1!=d.Wa[1]+1&&(a.Ma=d.Wa[19]<<(a.I?1:d.Wa[20]&64?3:4),m=(a.Ma*(a.J-1)+a.F)/a.Eb|0,a.oa<=qs&& +(m<<=1));c+m>k&&(m=k-c,0>m&&(m=0));k=c+m;if(b=!b&&a.ma){b=a.ka;for(var p=!0,x=c>>>b.A;0f)return;g=f+1}}if(a.I){if(a.va[a.I]){d=f;f=0;e=a.ya=0;h=Ht<<8;b=1048575;p=a.C.Xc&32;a.La>=Op&&(p=a.C.Cc[16]&8);m=a.aa-a.C.vd;p&&(e=us<<8,b&=~e,a.Aa&2||(b&=~h));for(c+=d<<1;c>8|(u&255)<<8;var I=e,T=16;m>=h))>>(T-=h);Ns(a.Ha,m++,p,b[ua])}m>F&&(F=m);p=H&&(H=p+1)}k+=2;d++;if(m>=a.F){m=0;p+=2;if(p>a.J)break;p==a.J&&(p=1,k=c+a.Pb)}}a.ma=!0; +xa.F?a.Ma-a.F-u>>3:0;c>=8;b>x&&(x=b);m=K&&(K=m+1)}c+=H;if(b>=a.F){b=0;if(++m>a.J)break;c+=I}}u||(a.ma=!0);pa.F?a.Ma-a.F-K>>3:0;cI&&(T=I)):(u<<=K,T-=K,a.ma=!1):(a.ma&&u===a.M[d]?(h+=T,T=0):a.M[d]=u,d++);if(T){hp&&(p=h);b=F&&(F=b+1)}if(h>=a.F){h=0;if(++b>a.J)break;c+=H}}K||(a.ma=!0);ma&&(b.wh=a,a=-a|0);a%b.rh>b.jn&&(c|=1);a%b.uh>b.mn&&(c|=9);b.fi=a/b.uh|0;return c}l.Cm=function(a,b){return Lt(this,this.Y,a,b)};l.co=function(a,b,c){var d=this.Y;d.Fg=d.ec;d.ec=b&31;v(this,a,b,c,"CRTC.INDX")};l.Bm=function(a,b){return Mt(this,this.Y,a,b)};l.bo=function(a,b,c){Nt(this,this.Y,a,b,c)};l.Dm=function(a,b){return Ot(this,this.Y,b)};l.eo=function(a,b,c){a=this.Y;v(this,a.port+4,b,c,"MODE");a.Xc=b;As(this,!1)}; +l.Em=function(a,b){return Pt(this,this.Y,b)};l.Mk=function(a,b,c){this.A.Pf=this.A.Pf&-4|b&3;v(this,a,b,c,"FEAT")};l.am=function(a,b){a=this.A.wd;b&&!t(this)||v(this,960,null,b,"ATC.INDX",a);return a};l.rl=function(a,b){a=this.A.Cc[this.A.wd&31];b&&!t(this)||v(this,960,null,b,"ATC."+this.A.Tg[this.A.wd&31],a);return a}; +l.Lk=function(a,b,c){var d=this.A,e=d.wd&32;if(d.Ke){d.Ke=!1;var f=d.wd&31;if(16<=f||!e)if(Qt||d.Cc[f]!==b)c&&!t(this)||v(this,a,b,c,"ATC."+d.Tg[f]),d.Cc[f]=b,ht(this,!1)}else d.wd=b,v(this,a,b,c,"ATC.INDX"),d.Ke=!0,b&32&&!e&&ss(this,!0)&&ls(this,!0),a=(d.Wa[12]<<8)+d.Wa[13]|0,d.vd!=a&&(d.vd=a,ht(this)),d.Ye=0}; +l.Om=function(a,b){a=0;if(this.La==Op)a=3-((this.A.af&12)>>2),a=(this.xb&1<>this.A.xc&63;b&&!t(this)||v(this,969,null,b,"DAC.DATA["+r(this.A.dd)+"]["+r(this.A.xc)+"]",a);this.A.xc+=6;12Missing <canvas> support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=Ea().indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height= +(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Ka("aspect"));f&&.3<=f&&3.33>=f&&(Pa("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");Ja("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"),f.style.fontSize="16px");c.appendChild(f);var g=e.getContext("2d"),d=new Q(d,e,g,f,c);ob(d,c)}}); +function Rt(a){ab.call(this,"ParallelPort",a,4194304);this.G=a.adapter;switch(this.G){case 1:this.D=956;this.C=7;break;case 2:this.D=888;this.C=7;break;case 3:this.D=632;this.C=5;break;default:Wa("Unrecognized parallel adapter #"+this.G);return}this.A=this.B=null;a=a.binding;"console"==a?this.B="":nb(this,a,St)}ba(Rt,ab);l=Rt.prototype;l.Cb=function(a,b,c){switch(b){case St:return this.na[b]=this.A=c,!0}return!1}; +l.uc=function(a,b,c,d){this.ka=b;this.H=c;this.ba=d;this.W=Jb(a,"ChipSet");zc(b,this,Tt,this.D);Dc(b,this,Ut,this.D);tb(this)};l.Xb=function(a,b){if(!b)if(!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};l.Wb=function(a){return a?this.save():!0};l.reset=function(){Vt(this)};l.save=function(){var a=new Jf(this),b=0,c=[];c[b++]=this.F;c[b++]=this.Mb;c[b]=this.mf;a.set(0,c);return a.data()};l.restore=function(a){return Vt(this,a[0])}; +function Vt(a,b){var c=0;b||(b=[0,0,0]);a.F=b[c++];a.Mb=b[c++];a.mf=b[c];return!0}l.pm=function(a,b){var c=this.F;v(this,a,null,b,"DATA",c);return c};l.Nm=function(a,b){var c=this.Mb;v(this,a,null,b,"STAT",c);return c};l.lm=function(a,b){var c=this.mf;v(this,a,null,b,"CTRL",c);return c}; +l.Pn=function(a,b,c){v(this,a,b,c,"DATA");this.F=b;this.Mb|=Wt;a=!1;wb(this,"transmitByte("+r(b)+")");this.A&&(8==b?this.A.value=this.A.value.slice(0,-1):(this.A.value+=String.fromCharCode(b),this.A.scrollTop=this.A.scrollHeight),a=!0);if(null!=this.B){if(10==b||1024<=this.B.length)this.P(this.B),this.B="";10!=b&&(this.B+=String.fromCharCode(b));a=!0}a&&(this.Mb&=~Wt);Xt(this)};l.Kn=function(a,b,c){v(this,a,b,c,"CTRL");this.mf=b;Xt(this)}; +function Xt(a){a.W&&a.C&&(a.mf&Yt&&!(a.Mb&Wt)?Ig(a.W,a.C):Gg(a.W,a.C))}var St="buffer",Wt=64,Yt=16,Tt={0:Rt.prototype.pm,1:Rt.prototype.Nm,2:Rt.prototype.lm},Ut={0:Rt.prototype.Pn,2:Rt.prototype.Kn};Ra(function(){for(var a=pb(document,"pcx86","parallel"),b=0;b=b)a.preventDefault&&a.preventDefault(),64");if(2==c.length){var d=ra(c[0]);if(d!=this.be)return;c=ra(c[1]);if(this.D=kb(c)){var e=this.D.exports;if(e){var f=e.connect;f&&f.call(this.D,this.O);if(this.aa=e.receiveData){this.O=a;this.Y=e.receiveStatus;this.status("Connected "+this.xe+"."+d+" to "+c);return}}}}this.status("Unable to establish connection: "+b)}}}; +l.Xb=function(a,b){if(!b)if(this.zj(this.O),!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};l.Wb=function(a){return a?this.save():!0};l.reset=function(){eu(this)};l.save=function(){var a=new Jf(this),b=0,c=[];c[b++]=this.ga;c[b++]=this.la;c[b++]=this.L;c[b++]=this.N;c[b++]=this.G;c[b++]=this.C;c[b++]=this.Z;c[b++]=this.B;c[b++]=this.A;c[b]=this.J;a.set(0,c);return a.data()};l.restore=function(a){return eu(this,a[0])}; +function eu(a,b){var c=0;b||(b=[0,0,fu,0,gu,0,0,hu|iu,a.qa,[]]);a.ga=b[c++];a.la=b[c++];a.L=b[c++];a.N=b[c++];a.G=b[c++];a.C=b[c++];a.Z=b[c++];a.B=b[c++];a.A=b[c++];a.J=b[c];return!0}l.Of=function(a){if("number"==typeof a)this.J.push(a);else if("string"==typeof a)for(var b=0;b>8:this.N;v(this,a,null,b,this.C&ou?"DLM":"IER",c);return c};l.xm=function(a,b){var c=this.G;v(this,a,null,b,"IIR",c);return c};l.ym=function(a,b){var c=this.C;v(this,a,null,b,"LCR",c);return c};l.Am=function(a,b){var c=this.Z;v(this,a,null,b,"MCR",c);return c}; +l.zm=function(a,b){var c=this.B;v(this,a,null,b,"LSR",c);return c};l.Fm=function(a,b){var c=this.A;this.A&=~(ku|lu);v(this,a,null,b,"MSR",c);return c}; +l.no=function(a,b,c){v(this,a,b,c,this.C&ou?"DLL":"THR");if(this.C&ou)this.L=this.L&-256|b;else{this.la=b;this.B&=~(hu|iu);a=!1;wb(this,"transmitByte("+r(b)+")");this.aa&&this.aa.call(this.D,b)&&(a=!0);if(this.F){if(13==b)this.K=0;else if(8==b)this.F.value=this.F.value.slice(0,-1),0":String.fromCharCode(b);a=d.length;32>b&&1==a&&(a=0);9==b&&(b=this.oa||8,a=b-this.K%b,this.oa&&(d=qa("",a)));this.ma&&!this.K&&a&&(d=String.fromCharCode(this.ma)+ +d);this.F.value+=d;this.F.scrollTop=this.F.scrollHeight;this.K+=a}a=!0}else if(null!=this.I){if(10==b||1024<=this.I.length)this.P(this.I),this.I="";10!=b&&(this.I+=String.fromCharCode(b));a=!0}a&&(this.B=this.B|hu|iu)}};l.Zn=function(a,b,c){v(this,a,b,c,this.C&ou?"DLM":"IER");this.C&ou?this.L=this.L&255|b<<8:this.N=b};l.$n=function(a,b,c){v(this,a,b,c,"LCR");this.C=b}; +l.ao=function(a,b,c){var d=b^this.Z;v(this,a,b,c,"MCR");this.Z=b;d&(pu|qu)&&this.Y&&(a=0,this.O?(a|=b&qu?32:0,a|=b&pu?320:0):(a|=b&qu?16:0,a|=b&pu?1048576:0),this.Y.call(this.D,a))};function mu(a){var b=-1;a.B&nu&&a.N&ru?b=su:a.A&(ku|lu)&&a.N&tu&&(b=uu);0<=b?(a.G&=~(gu|vu),a.G|=b,a.W&&a.M&&Ig(a.W,a.M,100)):(a.G|=gu,a.W&&a.M&&Gg(a.W,a.M))} +var bu="buffer",fu=384,ru=1,tu=8,gu=1,su=4,uu=0,vu=6,ou=128,pu=1,qu=2,nu=1,hu=32,iu=64,ku=1,lu=2,$t=16,au=32,cu={0:Zt.prototype.Km,1:Zt.prototype.wm,2:Zt.prototype.xm,3:Zt.prototype.ym,4:Zt.prototype.Am,5:Zt.prototype.zm,6:Zt.prototype.Fm},du={0:Zt.prototype.no,1:Zt.prototype.Zn,3:Zt.prototype.$n,4:Zt.prototype.ao};Ra(function(){for(var a=pb(document,"pcx86","serial"),b=0;ba.F||0>a.G)a.F=b.clientX,a.G=b.clientY;a.M?(c=b.movementX||b.mozMovementX||b.webkitMovementX||0,d=b.movementY||b.mozMovementY||b.webkitMovementY||0):(c=b.clientX-a.F,d=b.clientY-a.G);a.F=b.clientX;a.G=b.clientY;a.tf(c,d,a.F,a.G)}} +l.Vd=function(a,b){if(this.rc&&this.H&&this.H.ea.vb){var c="mouse button"+a+" "+(b?"dn":"up");switch(a){case ns:if(this.K!=b){this.K=b;Cu(this,c);return}break;case Du:if(this.L!=b){this.L=b;Cu(this,c);return}}wb(this,c+": ignored")}};l.tf=function(a,b,c,d){this.rc&&this.H&&this.H.ea.vb&&(a||b)&&(this.I=a,this.J=b,Cu(this,null,c,d))}; +function Cu(a,b,c,d){var e=64|(a.K?32:0)|(a.L?16:0)|(a.J&192)>>4|(a.I&192)>>6,f=a.I&63,g=a.J&63;t(a,8388608)&&wb(a,(b?b+": ":"")+(void 0!==d?"mouse ("+c+","+d+"): ":"")+"serial packet ["+r(e)+","+r(f)+","+r(g)+"]",0,!0);a.D.Of([e,f,g]);a.I=a.J=0} +l.pl=function(a){var b=1048592==(a&1048592);if(b){if(!this.rc){var c=!1;this.A&16||(this.reset(),wb(this,"serial mouse reset"),c=!0);this.A&1048576||(wb(this,"serial mouse ID requested"),c=!0);c&&(this.D.Of([Eu,Eu]),wb(this,"serial mouse ID sent"));xu(this);this.rc=b}}else this.rc&&(wb(this,"serial mouse inactive"),yu(this),this.rc=b);this.A=a};var Eu=77,ns=0,Du=2;Ra(function(){for(var a=pb(document,"pcx86","mouse"),b=0;b>2;var e=d=0,a=new DataView(a,0,c);g.A=Array(g.ob);for(c=0;cb.indexOf("/api/v1/dump")&&(a=ma(b),"json"==a||"gz"==a?f=encodeURI(b):"demandrw"==this.mode||"demandro"==this.mode?(f=Mu(this,b),this.og=!0):(c="path",d="&mbhd=10",!b.indexOf("http:")||!b.indexOf("ftp:")||0<="dsk ima img 360 720 12 144".split(" ").indexOf(a)?(c="disk",d="&mbhd=0"):na(b, +"/")&&(c="dir"),f=Da()+"/api/v1/dump?"+c+"="+encodeURIComponent(b)+(this.Oe?"":d)+"&format=json"));return!!Ca(f,null,!0,function(a,b,c){Nu(g,a,b,c)})}; +function Nu(a,b,c,d){var e=null;a.Re=!1;var f=!(!(0>d&&a.pa)||a.pa.ea.Yb);if(a.og)d?a.controller.Fa('Unable to connect to disk "'+a.I+'" (error '+d+": "+c+")",f):(a.D=!0,Ou(a),e=a);else if(d)a.controller.Fa('Unable to load disk "'+a.F+'" (error '+d+": "+b+")",f);else{eb(a.controller.xe,b,c);try{if(0g&&0c.indexOf("0x")&&'["'!=c.substr(0,2)?JSON.parse(c.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+c+")");if(h.length)if(1==h.length)Wa(h[0]);else{a.ob=h.length;a.ib=h[0].length;a.Ya=h[0][0].length;var k=h[0][0][0];a.Na=k&&k.length||512;for(d=c=0;d>2,p=k.pattern;void 0===p&&(p=k.pattern=0);var x=k.data;if(void 0===x){var u=k.bytes;if(void 0!==u&&u.length){for(var F= +m<<2,K=u.length;Kb;b++){if(128==Ru(a,e,c+0,1)){d.Kf=Ru(a,e,c+8,4);(e=Qu(a,d.Kf))&&(f=!0);break}c+=16}if(!f)return}d.sf||(d.sf=Ru(a,e,19,2)||Ru(a,e,32,4),d.rf=Ru(a,e,14,2),d.lh=d.rf+Ru(a,e,22,2)*Ru(a,e,16,1),d.vh=Ru(a,e,17,2),d.vf=Ru(a,e,13,1));d.jh=d.lh+((32*d.vh+(d.Na-1))/d.Na|0);d.hn=(d.sf-d.jh)/d.vf|0;d.vg=4084>=d.hn?12:16;d.Nl=12==d.vg?4086:65526;b=[];for(e=d.lh;e>=8;f+=2;if(k)for(;m--;)ev(d,f,1),254>=k?(p=k,x=ev(d,f+1),f+=3):(p=ev(d,f+3,1),x=ev(d,f+4),f+=6),d.nd[p]&&(d.nd[p].ee[h]=[x]),d.A[h]=[p,x],h++;else h+=m}(g=Uu(e,hv,c))&&iv(e,g+c);g=Uu(e,jv,c);h=Uu(e,kv,c);g&&h&&iv(e,g,g+h)}}}} +function Tu(a,b,c,d,e){var f,g=a.C.length,h=b.Na/32|0;b.aq=d+"\\";for(var k=0;kK)break;for(var H=u.jh+(K-2)*u.vf,I=0;I>3,1),d?e=16==b.vg?e<<8:c&7?e<<4:(e&15)<<8:c&7&&(e>>=4));return e} +function Qu(a,b){var c=a.ib*a.Ya,d=b/c|0;return dg)break;e|=g<=f)break;e+=String.fromCharCode(f)}return e}function Lu(a,b,c,d,e,f){a||(a={sector:d,length:e,data:[],pattern:f});a.Ol=b;a.Pl=c;a.hd=a.Lc=0;a.Oa=!1;return a} +function Mu(a,b){b="action=open&volume="+b+("&mode="+a.mode);b+="&chs="+a.ob+":"+a.ib+":"+a.Ya+":"+a.Na;b+="&machine="+Ju(a.controller);b+="&user="+Ku(a.controller);return Da()+"/api/v1/disk?"+b} +function nv(a,b,c,d,e,f,g){if(a.D){var h;h="action=read&volume="+a.I;h+="&chs="+a.ob+":"+a.ib+":"+a.Ya+":"+a.Na;h=h+("&addr="+b+":"+c+":"+d+":"+e)+("&machine="+Ju(a.controller));h+="&user="+Ku(a.controller);Ca(Da()+"/api/v1/disk?"+h,null,f,function(h,m,p){h=[b,c,d,e,f,g];var k=!1,u=h[0],F=h[1],K=h[2],H=h[3];if(!p){m=JSON.parse(m);for(k=0;H--;){var I=a.seek(u,F,K,!0);if(!I)break;Pu(I,m,k);k+=I.length;K++}k=h[4]}(h=h[5])&&h(p,k)})}else g&&g(-1,!1)} +function ov(a,b,c,d,e,f,g){if(a.D){var h={};a.N=!0;h.action="write";h.volume=a.I;h.chs=a.ob+":"+a.ib+":"+a.Ya+":"+a.Na;h.addr=b+":"+c+":"+d+":"+e;h.machine=Ju(a.controller);h.user=Ku(a.controller);h.data=JSON.stringify(f);Ca(Da()+"/api/v1/disk",h,g,function(f,h,p){var k=[b,c,d,e,g];f=k[0];h=k[1];var m=k[2],F=k[3],k=k[4];a.N=!1;if(0<=f&&fb&&(b=0);2E3>2,e=Array(d),f=0;f>2,e=a.data;a=a.pattern;for(var f=0;f>8&255;c[d++]=g>>16&255;c[d++]=g>>24&255}return c}l.read=function(a,b){var c=-1;if(a&&b>2,c=(d>((b&3)<<3)&255;return c}; +l.write=function(a,b,c){if(this.Re)return!1;if(b>2;b=(b&3)<<3;for(var g=d.length;g<=f;g++)d[g]=e;a.Lc?f=a.hd+a.Lc&&(a.Lc+=f-(a.hd+a.Lc)+1):(a.hd=f,a.Lc=1);d[f]=d[f]&~(255<=this.A.length||k>=this.A[h].length||m>=this.A[h][k].length){c="sector (CHS="+h+":"+k+":"+m+") out of range ("+ +b+" changes applied)";b=-1;break}if(this.Re){c="unable to modify write-protected disk";b=-1;break}e=g[f++];f=g[f++];g=e+f.length;if(h=this.A[h][k][m]){for(k=h.data.length;kb?-2!=b&&this.controller.Fa("Unable to restore disk '"+this.F+": "+c):Ou(this);return b}; +l.toJSON=function(){var a;a=0;for(var b;b=Qu(this,a++);)tv(b);a=JSON.stringify(this.A,function(a,b){if("file"!=a)return b});a=a.replace(/,"length":512/gm,"").replace(/,"pattern":0/gm,"");a=a.replace(/"(sector|length|data|pattern)":/gm,"$1:");a=a.replace(/,"[^"]*":([0-9]+|true|false)/gm,"");a=a.replace(/(sector|length|data|pattern):/gm,'"$1":');return a=a.replace(/([\]}]),/gm,"$1,\n")}; +function tv(a){var b=a.data,c=b.length;if(c<<2==a.length){for(var d=c-1,e=b[d],f=0;d--&&b[d]===e;)f++;f++&&(b.length=c-f,a.pattern=e)}}var Gu=0;function mv(a,b,c,d,e,f){this.sa=a;this.$b=c;this.Wg=d;this.aj=e;this.fe=f}function ev(a,b,c){var d;c=c||2;var e=b&511,f=Qu(a.sa,a.fe[b>>9]);if(f){if(e+c<=f.length)return Ru(a.sa,f,e,c);for(e=d=0;c--;)d|=ev(a,b++,1)<=e.gi&&a<=e.Ik){d=a-=e.gi;var f,g;for(g in e.ee){var h=e.ee[g],k=a-h[0];if(!k){c=this.Rf+"!"+h[1];break}b&&0'+b+"");a.innerHTML=b}};return!0;case "descDisk":case "listDrives":return this.na[b]=c,c.onchange=function(){var a=ga(c.value,10);null!=a&&vv(d,a)},!0;case "loadDisk":return this.na[b]=c,c.onclick=function(){var a=d.na.listDisks;a&&wv(d,a.options[a.selectedIndex].text,a.value)},!0;case "saveDisk":if(!this.M){c.parentNode.removeChild(c);break}this.na[b]=c;c.onclick=function(){var a=d.na.listDrives;a&&a.options&&d.A&&((a=d.A[ga(a.value, +10)||0])?(a=a.sa)?(a=Ma(sv(a),"octet-stream",!0,a.Jg.replace(".json",".img")),Wa(a)):d.Fa("No diskette loaded in drive."):d.Fa("No diskette drive selected."))};return!0;case "mountDisk":if(this.M)return this.na[b]=c,c.addEventListener("change",function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length}),c.onsubmit=function(a){if(a=a.currentTarget[1].files[0]){var b=a.name;wv(d,la(b,!0),b,a)}return!1},!0;c.parentNode.removeChild(c)}return!1}; +l.uc=function(a,b,c,d){this.ka=b;this.H=c;this.ba=d;this.pa=a;this.W=Jb(a,"ChipSet");if((this.G=hd(this.pa,"autoMount")||this.G)&&"string"==typeof this.G)try{this.G=eval("("+this.G+")")}catch(e){Wa("FDC auto-mount error: "+e.message+" ("+this.G+")"),this.G=null}xv(this);zc(b,this,yv);Dc(b,this,zv);Av(this,"None","",!0);this.M&&Av(this,"Local Disk","?");Av(this,"Remote Disk","??");Bv(this)||tb(this)}; +l.Xb=function(a,b){if(!b){if(!a){if(this.reset(),this.pa.O){this.B=[];for(a=0;ag.sa.restore(F)&&(h=!1);h&&g.sa&&void 0!==g.Sa&&(g.cb=g.sa.seek(g.Gb,g.Xa,g.kb));h||(e=!1)}a.I=b[c++]||0;a.Zb=b[c]||Jv;return e} +function Dv(a){var b=0,c=[];c[b++]=a.Ua;c[b++]=0;c[b++]=a.fa;c[b++]=a.F;c[b++]=a.D;c[b++]=a.C;c[b++]=a.J;for(var d=b++,e=0,f=[],g=0;gHv(a,e,b,c,!1,d)&&window.confirm("Click OK to reload the original disk.\n(WARNING: All disk changes will be discarded)");){var f=a,g=c,h;for(h=0;ha.ob||f[1]>a.ib)&&(this.Fa('Diskette "'+c+'" too large for drive '+String.fromCharCode(65+a.Ua)),b=null);b?(a.sa=b,a.Zk=c,a.te=d,Iv(this,c,d,b),f=b.info(),this.I|=Mv,this.Fa('Mounted diskette "'+c+'" in drive '+String.fromCharCode(65+a.Ua),a.ke||e),a.ug=f[0],a.Af=f[1],a.Bf=f[2],this.pa&&this.pa.ld()):a.Ne=!1;a.ke&&(a.ke=!1,--this.K||tb(this));vv(this,a.Ua)}; +function Av(a,b,c,d){if((a=a.na.listDisks)&&a.options){for(var e=0;e=this.C&&(this.fa&=~(Pv|Qv),this.D=this.C=0);return c}; +l.Rn=function(a,b,c){t(this)&&v(this,a,b,c,"DATA["+this.C+"]");this.C=Sv[a].Id){b=!1;this.D=0;a=Tv(this);var d,e,f,g,h=a&Rv;switch(h){case Uv:Tv(this);Tv(this);Vv(this);break;case Wv:c=Tv(this);this.Ua=c&3;d=this.A[this.Ua];Vv(this);Xv(this,(d.pb&Yv)>>>24);break;case Zv:case $v:c=Tv(this);b=c>>2&1;this.Ua=c&3;d=this.A[this.Ua];d.Xa=b;c=d.Gb=Tv(this);e=Tv(this);f=d.kb=Tv(this);g=Tv(this);d.ub=128<>2&1;this.Ua= +c&3;d=this.A[this.Ua];c=d.Gb;e=d.Xa=b;f=d.kb=1;g=0;d.pb=Lv;d.sa&&(d.cb=d.sa.seek(d.Gb,d.Xa,d.kb))?g=d.cb.length>>8:d.pb=aw|bw;dw(this,d,a,b,c,e,f,g);b=!0;break;case kw:c=Tv(this);b=c>>2&1;this.Ua=c&3;d=this.A[this.Ua];c=d.Gb;e=d.Xa=b;f=1;g=Tv(this);d.ub=128<>2&1,c=Tv(this),d.Gb+=c-d.Sd,0>d.Gb&&(d.Gb=0),d.Gb>=d.ob&&(d.Gb=d.ob-1),d.Sd=c,d.pb=fw,d.Gb||(d.pb|=gw),Vv(this),b=!0}0>>8);Xv(a,(b.pb&nw)>>>16);var k=0;if(e!=b.Gb||f!=b.Xa)k=g=1;c&ow&&(f^=k,d||(k=0));Xv(a,e+k);Xv(a,f);Xv(a,g);Xv(a,h)}function Tv(a){var b=a.F[a.D];a.D++;return b}function Vv(a){a.D=a.C=0}function Xv(a,b){a.F[a.C++]=b}l.jl=function(a,b,c){void 0===b||0>b?this.se(a,c):c(-1,!1)};l.kl=function(a,b){return void 0!==b&&0<=b?pw(a,b):-1}; +l.Cl=function(a,b){if(void 0!==b&&0<=b)a:if(a.pb)a=-1;else{a.$c[a.Ge++]=b;if(a.Ge==a.$c.length){a.Gb=a.$c[0];a.Xa=a.$c[1];a.kb=a.$c[2];a.ub=128<pw(a,a.Wi)){a=-1;break a}a.jg++}a.jg>=a.Td&&(b=-1);a=b}else a=-1;return a};l.se=function(a,b){var c=-1,d=null,e=0;if(!a.pb&&a.sa){do{if(a.cb&&(e=a.Sa,0<=(c=a.sa.read(a.cb,a.Sa++)))){d=a.cb;break}a.cb=a.sa.seek(a.Gb,a.Xa,a.kb);if(!a.cb){a.pb=qw|bw;break}a.Sa=0;rw(a)}while(1)}b(c,!1,d,e)}; +function pw(a,b){if(a.pb||!a.sa)return-1;do{if(a.cb&&a.sa.write(a.cb,a.Sa++,b))break;a.cb=a.sa.seek(a.Gb,a.Xa,a.kb);if(!a.cb){a.pb=sw|bw;b=-1;break}a.Sa=0;rw(a)}while(1);return b}function rw(a){a.kb++;a.kb>=a.Bf+1&&(a.kb=1,a.Xa++,a.Xa>=a.Af&&(a.Xa=0,a.Gb++))}var Gv="Floppy Drive",Nv=4,Ov=8,Qv=16,Pv=64,Ev=128,Uv=3,Wv=4,Zv=5,$v=6,ew=7,hw=8,jw=10,kw=13,lw=15,Rv=31,ow=128,Lv=0,aw=8,fw=32,bw=64,Fv=192,iw=255,cw=512,qw=1024,sw=8192,mw=65280,nw=16711680,gw=268435456,Yv=-16777216,Mv=128,Jv=0;aa={}; +var Sv={3:{Id:3,Ud:0,name:aa.Up},4:{Id:2,Ud:1,name:aa.Sp},5:{Id:9,Ud:7,name:aa.Yp},6:{Id:9,Ud:7,name:aa.Op},7:{Id:2,Ud:0,name:aa.Qp},8:{Id:1,Ud:2,name:aa.Tp},10:{Id:2,Ud:7,name:aa.Pp},13:{Id:6,Ud:7,name:aa.Lp},15:{Id:3,Ud:0,name:aa.Rp}},yv={1009:uv.prototype.rm,1012:uv.prototype.tm,1013:uv.prototype.qm,1015:uv.prototype.sm},zv={1010:uv.prototype.Sn,1013:uv.prototype.Rn,1015:uv.prototype.Qn}; +Ra(function(){for(var a=pb(document,"pcx86","fdc"),b=0;bk.sa.restore(g)&&(F=!1),F&&void 0!==k.Sa&&(k.cb=k.sa.seek(k.Od,k.Xa,k.kb+k.ig)));F||(e=!1);null!=a.O&&1>=d&&(a.O|=(f.type&3)<<(1-d<< +1))}0<=a.Ua&&(a.B=a.A[a.Ua]);return e} +function Bw(a){var b=0,c=[];a.M?(c[b++]=a.I,c[b++]=a.va,c[b++]=a.J,c[b++]=a.ga,c[b++]=a.da,c[b++]=a.aa,c[b++]=a.Y,c[b++]=a.fa,c[b++]=a.ha,c[b++]=[a.L,a.Ua]):(c[b++]=a.O,c[b++]=a.fa,c[b++]=a.F,c[b++]=a.D,c[b++]=a.C,c[b++]=a.ta,c[b++]=a.qa,c[b++]=a.oa,c[b++]=a.N);for(var d=0,e=[],f=0;f=this.C&&(this.D=this.C=0,this.fa&=~(Kw|Lw|Mw));return c};l.po=function(a,b,c){v(this,a,b,c,"DATA["+this.C+"]");this.C=a&&(this.fa|=Kw,this.fa&=~Ow,Pw(this))};l.Um=function(a,b){var c=this.fa;v(this,a,null,b,"STATUS",c);this.D=a.B.Na?(a.fa=Rw,a.se(a.B,function(b){0<=b?(Sw(a),a.W&&a.W.ca==jl&&(a.fa=0),a.fa=a.fa|Cw|Tw|Uw):(a.fa=Vw,a.I=Ww)},!1)):a.fa=Cw|Tw));return d}l.nl=function(a,b){return Qw(this,a,b)|Qw(this,a,b)<<8}; +function Xw(a,b,c,d){if(a.B&&a.B.ub>=a.B.Na)if(0>Yw(a.B,c))a.fa=Vw,a.I=Ww;else if(1==a.B.Sa||a.B.Sa==a.B.Na)t(a,1048832)&&v(a,b,c,d,"DATA["+a.B.Sa+"]"),1=a.B.Na&&(a.fa|=Uw))}l.yn=function(a,b,c){Xw(this,a,b&255,c);Xw(this,a,b>>8&255,c)};l.$l=function(a,b){var c=this.I;v(this,a,null,b,"ERROR",c);return c};l.Dn=function(a,b,c){v(this,a,b,c,"WPREC");this.va=b};l.bm=function(a,b){var c=this.J;v(this,a,null,b,"SECCNT",c);return c}; +l.Bn=function(a,b,c){v(this,a,b,c,"SECCNT");this.J=b};l.cm=function(a,b){var c=this.ga;v(this,a,null,b,"SECNUM",c);return c};l.Cn=function(a,b,c){v(this,a,b,c,"SECNUM");this.ga=b};l.Yl=function(a,b){var c=this.da;v(this,a,null,b,"CYLLO",c);return c};l.xn=function(a,b,c){v(this,a,b,c,"CYLLO");this.da=b};l.Xl=function(a,b){var c=this.aa;v(this,a,null,b,"CYLHI",c);return c};l.wn=function(a,b,c){v(this,a,b,c,"CYLHI");this.aa=b};l.Zl=function(a,b){var c=this.Y;v(this,a,null,b,"DRVHD",c);return c}; +l.zn=function(a,b,c){v(this,a,b,c,"DRVHD");this.Y=b;this.fa=this.A[this.Y&Zw?1:0]?this.fa|Cw|Tw:this.fa&~Cw};l.dm=function(a,b){var c=this.fa;v(this,a,null,b,"STATUS",c);this.fa&Cw&&(this.fa&=~Rw);return c};l.vn=function(a,b,c){v(this,a,b,c,"COMMAND");this.ha=b;this.W&&Gg(this.W,14);$w(this)};l.An=function(a,b,c){v(this,a,b,c,"FDR");this.L&ax&&!(b&ax)&&(this.I=bx);this.L=b}; +function $w(a){var b=!1,c=a.ha,d=a.Y&Zw?1:0,e=a.Y&cx,f=a.da|(a.aa&dx)<<8,g=a.ga,h=a.J||256;a.Ua=-1;a.B=null;a.I=ex;a.fa=Cw|Tw;var k=a.A[d];k?(k.Od=f,k.Xa=e,k.kb=g,k.ub=h*k.Na,c=c>=fx?c:c&gx,k.cb=null,k.Sa=0,k.errorCode=0,a.Ua=d,a.B=k):c=-1;switch(c&gx){case hx:b=!0;break;case ix:a.fa=Rw;a.se(k,function(b){0<=b&&a.W?(Sw(a),a.fa=Cw|Tw|Uw):(a.fa=Vw,a.I=Ww)},!1);break;case jx:a.fa=Uw;break;case kx:b=!0;break;case lx:b=!0;break;case fx:a.I=bx;b=!0;break;case mx:k.ib=e+1,k.Ya=h,b=!0}b&&Sw(a)} +function Sw(a){!a.W||a.L&nx||Ig(a.W,14,120)} +function Pw(a){a.D=0;var b=ox(a),c=ox(a),d=c&32,e=d>>5,f=c&31,g=ox(a),h=ox(a),k=g<<2&768|h,m=g&63,p=ox(a),x=ox(a),u=a.A[e];u&&(u.Od=k,u.Xa=f,u.kb=m,u.ub=p*u.Na);switch(b){case px:qx(a,u?u.errorCode:rx);sx(a,c);sx(a,g);sx(a,h);sx(a,tx|d);b=-1;break;case Nw:for(c=0;0<=(b=ox(a));)u&&cb?this.se(a,c):c(-1,!1)};l.ml=function(a,b){return void 0!==b&&0<=b?Yw(a,b):-1}; +l.Dl=function(a,b){void 0!==b&&0<=b?(a.SaYw(a,a.Wi)){a=-1;break a}a.jg++}a.jg>=a.Td&&(b=-1);a=b}else a=-1;return a}; +function Bx(a,b,c){b.errorCode=rx;if(b.sa&&(b.cb=null,a.W)){b.errorCode=Ew;vn(a.W,3,a,"dmaRead",b);mn(a.W,3,function(a){a||b.errorCode!=Ew||(b.errorCode=rx);c(b.errorCode?ux:tx)});return}c(b.errorCode?ux:tx)}function Dx(a,b,c){b.errorCode=rx;if(b.sa&&(b.cb=null,a.W)){b.errorCode=Ew;vn(a.W,3,a,"dmaWrite",b);mn(a.W,3,function(a){a||(b.errorCode==Ew&&(b.errorCode=rx),b.errorCode==Gx&&(b.errorCode=Ew));c(b.errorCode?ux:tx)});return}c(b.errorCode?ux:tx)} +function Fx(a,b,c){b.errorCode=rx;b.Ee&&b.Ee.length==b.ub||(b.Ee=Array(b.ub));b.Sa=0;a.W?(b.errorCode=Ew,vn(a.W,3,a,"dmaWriteBuffer",b),mn(a.W,3,function(a){a||b.errorCode!=Ew||(b.errorCode=rx);c(b.errorCode?ux:tx)})):c(b.errorCode?ux:tx)} +l.se=function(a,b,c){var d=-1,e=null,f=0;if(a.errorCode)return b&&b(d,!1,e,f),d;var g=!1!==c?1:0;if(a.cb&&(f=a.Sa,d=a.sa.read(a.cb,a.Sa),a.Sa+=g,0<=d))return e=a.cb,b&&b(d,!1,e,f),d;if(b){if(a.sa)return a.sa.seek(a.Od,a.Xa,a.kb+a.ig,!1,function(c,k){(a.cb=c)?(e=c,f=a.Sa=0,Hx(a),d=a.sa.read(a.cb,a.Sa),a.Sa+=g):a.errorCode=Gx;b(d,k,e,f)}),d;a.errorCode=Gx;b(d,!1,e,f)}return d}; +function Yw(a,b){if(a.errorCode)return-1;do{if(a.cb&&a.sa.write(a.cb,a.Sa++,b))break;a.sa&&a.sa.seek(a.Od,a.Xa,a.kb+a.ig,!0,function(b){a.cb=b});if(!a.cb){a.errorCode=Gx;b=-1;break}a.Sa=0;Hx(a)}while(1);return b}function Hx(a){a.kb++;var b=1-a.ig;a.kb>=a.Ya+b&&(a.kb=b,a.Xa++,a.Xa>=a.ib&&(a.Xa=0,a.Od++))}l.Vm=function(){var a=this.H.L&255;!(this.H.D>>8)&&128>8||!this.W)||(a=!(this.W.hc[0].od&64));return a?!0:!1}; +var Fw="Hard Drive",Iw=["XTC","ATC","COMPAQ"],Gw=[{0:[306,2],1:[375,8],2:[306,6],3:[306,4]},{1:[306,4],2:[615,4],3:[615,6],4:[940,8],5:[940,6],6:[615,4],7:[462,8],8:[733,5],9:[900,15],10:[820,3],11:[855,5],12:[855,7],13:[306,8],14:[733,7],16:[612,4],17:[977,5],18:[977,7],19:[1024,7],20:[733,5],21:[733,7],22:[733,5],23:[306,4]},{1:[306,4],2:[615,4],3:[615,6],4:[1023,8],5:[940,6],6:[697,5],7:[462,8],8:[925,5],9:[900,15],10:[980,5],11:[925,7],12:[925,9],13:[612,8],14:[980,4],16:[612,4],17:[980,5],18:[966, +6],19:[1023,8],20:[733,5],21:[733,7],22:[524,4,40],23:[924,8],24:[966,14],25:[966,16],26:[1023,14],27:[832,6,33],28:[1222,15,34],29:[1240,7,34],30:[615,4,25],31:[615,8,25],32:[905,9,25],33:[832,8,33],34:[966,7,34],35:[966,8,34],36:[966,9,34],37:[966,5,34],38:[612,16,63],39:[1023,11,33],40:[1023,15,34],41:[1630,15,52],42:[1023,16,63],43:[805,4,26],44:[805,2,26],45:[748,8,33],46:[748,6,33],47:[966,5,25]}],yw=496,bx=1,ex=0,Ww=16,dx=3,cx=15,Zw=16,Vw=1,Uw=8,Tw=16,Cw=64,Rw=128,hx=16,ix=32,jx=48,kx=64,lx= +112,fx=144,mx=145,gx=240,nx=2,ax=4,tx=0,ux=2,xx=0,yx=1,px=3,zx=5,Ax=8,Cx=10,Nw=12,Ex=15,vx=224,wx=228,Ew=0,rx=4,Gx=20,Dw=0,Ow=1,Kw=2,Lw=4,Mw=8,Jw=32,vw={800:tw.prototype.Tm,801:tw.prototype.Um,802:tw.prototype.Sm},uw={496:tw.prototype.nl,497:tw.prototype.$l,498:tw.prototype.bm,499:tw.prototype.cm,500:tw.prototype.Yl,501:tw.prototype.Xl,502:tw.prototype.Zl,503:tw.prototype.dm},xw={800:tw.prototype.po,801:tw.prototype.so,802:tw.prototype.ro,803:tw.prototype.qo,807:tw.prototype.hi,811:tw.prototype.hi, +815:tw.prototype.hi},ww={496:tw.prototype.yn,497:tw.prototype.Dn,498:tw.prototype.Bn,499:tw.prototype.Cn,500:tw.prototype.xn,501:tw.prototype.wn,502:tw.prototype.zn,503:tw.prototype.vn,1014:tw.prototype.An};Ra(function(){for(var a=pb(document,"pcx86","hdc"),b=0;bthis.A&&this.C.length&&(this.A=0);if(0>this.A||a!=this.C[this.A])this.C.splice(0,0,a),this.A=0;this.A--}else this.aa?a="end":a=this.C[this.A+1];b=[];if(a){a=a.replace(/""/g,"'");var d=0,e=null;c=c||";";for(var f=0;f<=a.length;f++){var g=a.charAt(f);if('"'==g||"'"==g)e?g==e&&(e=null):e=g;else if(g==c&&!e||!g)b.push(ra(a.substring(d,f))),d=f+1}}return b}; +function Jx(a,b,c){for(c=c||-1;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(d){case "*":d=f*e;break;case "/":if(!e)return!1;d=f/e;break;case "%":if(!e)return!1;d=f%e;break;case "+":d=f+e;break;case "-":d=f-e;break;case "<<":d=f<>":d=f>>e;break;case ">>>":d=f>>>e;break;case "<":d=f":d=f>e?1:0;break;case ">=":d=f>=e?1:0;break;case "==":d=f==e?1:0;break;case "!=":d=f!=e?1:0;break;case "&":d=f&e;break; +case "^":d=f^e;break;case "|":d=f|e;break;case "&&":d=f&&e?1:0;break;case "||":d=f||e?1:0;break;default:return!1}a.push(d|0)}return!0} +function Kx(a,b,c){var d;if(b){b=Lx(a,b);for(var e=0,f=!1,g=b,h=[],k=[],m=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);ec&&(d+=" '"+String.fromCharCode(c)+"'"));a.P((null!=b?b+": ":"")+d);return e}function Qx(a,b){if(b)return Ox(a,b,a.da[b]);var c=0;for(b in a.da)Ox(a,b,a.da[b]),c++;return 0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; +function Rx(a){Ix.call(this,a);this.oa=4;this.ha=5;this.wa=1048575;this.K=Sx(this);this.Ga=Sx(this);this.Z=Sx(this);this.D=[];this.B=this.Y=this.M=[];Tx(this);this.ta=0;Ux(this);this.za={};Vx(this,a.messages);this.Ca=a.commands;var b=this;window?void 0===window.pcx86&&(window.pcx86=function(a){return Wx(b,a)}):void 0===global.pcx86&&(global.pcx86=function(a){return Wx(b,a)})}ba(Rx,Ix);l=Rx.prototype; +l.uc=function(a,b,c,d){this.ka=b;this.H=c;this.pa=a;this.Za=Jb(a,"FDC");this.Ha=Jb(a,"HDC");this.Tc=Jb(a,"FPU");this.G=Jb(a,"Mouse");(a=hd(a,"messages"))&&Vx(this,a);this.ha=b.I>>2;this.wa=b.N;this.Ta=new Fd(this.H,7,"DBG");this.ma=Xx;80186<=this.H.ca&&(this.ma=Xx.slice(),this.ma[15]=Yx,80286<=this.H.ca&&(this.ma[15]=Zx,80386<=this.H.ca&&(this.oa=8)));ml(this,64,function(a){$x(d,d.H.sc,a[0])});ml(this,4,function(a){if(a=a[0]){var b=Mx(d,a);if(void 0===b)d.P("invalid selector: "+a);else if(a=ay(d, +b,by),d.P("dumpSel("+ka(a?a.U:b)+"): %"+q(a?a.Lb:null,d.ha)),a){var c,b=!1;if(a.type&4096)a.type&2048?(c="code"+(a.type&512?",readable":",execonly"),a.type&1024&&(c+=",conforming")):(c="data"+(a.type&512?",writable":",readonly"),a.type&1024&&(c+=",expdown")),a.type&256&&(c+=",accessed");else{var e=cy[a.type];e&&(c=e[0],b=e[1])}!c||a.jb&32768||(c+=",not present");d.P((b?"seg="+ka(a.ua&65535)+" off="+ka(a.Ka):"base="+q(a.ua,d.ha)+" limit="+dy(a.Ka))+" type="+r(a.type>>8)+" ("+c+") ext="+ka(a.ext&-65296)+ +" dpl="+r(a.qc))}}else d.P("no selector")});ml(this,134217728,function(a){var b;(a=a[0])&&(b=Mx(d,a));if(void 0===b)d.P("invalid MCB");else for(d.P("dumpMCB("+ka(b)+")");b;){a=Sx(d,0,b);var c=d.Ia(a,1),e=d.Yc(a,2),k=d.Yc(a,5);if(77!=c&&90!=c)break;d.P(ey(0,b)+": '"+String.fromCharCode(c)+"' PID="+ka(e)+" LEN="+ka(k)+' "'+fy(d,a,8)+'"');b+=1+k}});ml(this,128,function(a){$x(d,d.H.aa,a[0],d.H.aa!==d.H.sc)});ml(this,8,function(a){a:{if(a=a[0]){var b=Mx(d,a);if(void 0===b){d.P("invalid task selector: "+ +a);break a}a=ay(d,b,by)}else a=d.H.la;d.P("dumpTSS("+ka(a?a.U:b)+"): %"+q(a?a.ua:null,d.ha));if(a){var b="",c=a.type&-513,e=256==c?4:8,k=256==c?gy:hy,m,p,x,u;for(u in k)m=k[u],p=a.ua+m,x=ig(d.H,p,2),2304==c&&(x|=ig(d.H,p+2,2)<<16),b&&(b+="\n"),b+=ka(m)+" "+qa(u+":",11)+q(x,e);if(2304==c)for(u=0,m=x>>>16;mu;)p=a.ua+m,x=ig(d.H,p,2),b+="\n"+ka(m)+" ports "+ka(u)+"-"+ka(u+15)+": "+ia(x,2),u+=16,m+=2;d.P(b)}}});this.F=null;this.Da=0;this.Aa=!1;Ef(this.H,48,this.Ym.bind(this));Ef(this.H,65, +this.Zm.bind(this));this.O=null;Ef(this.H,104,this.$m.bind(this));tb(this)};function iy(a,b,c,d,e,f){b=fy(a,b);var g=ay(a,d),g=g?g.Ka+1:0,h=(e?"_CODE":"_DATA")+q(c,2);f&&t(a,128)&&a.message(b+" "+(e?"code":"data")+"("+q(c,4)+")=#"+q(d,4)+" len "+q(g));e=jy(a,b,c);e[b+h]=0;Np(a,b,c,d,0,null,g,e)} +function ky(a,b,c,d){var e=a.Yc(b,2),f=a.Yc(b,2),g=ly(a,b,4),h=ly(a,b,4),k=Sx(a,ly(a,b,4),a.Yc(b,2));b=Sx(a,ly(a,b,4),a.Yc(b,2));b=fy(a,b).toUpperCase();var k=fy(a,k).toUpperCase(),m=(c?"_CODE":"_DATA")+q(e,2);d&&t(a,128)&&a.message((b==k?"":b+"!")+k+" "+(c?"code":"data")+"("+q(e,4)+")="+q(f,4)+":"+q(g)+" len "+q(h));c=jy(a,k,e);c[k+m]=g;Np(a,k,e,f,g,null,h,c)}function my(a,b,c){c=fy(a,c).toUpperCase();ny(a,c,b)} +l.Ym=function(){var a=this.H;if(null!=this.F&&2752554==a.D){var b=a.L&65535,c=a.K&65535,d=Sx(this,z(a)+12,a.Y.U);switch(ly(this,d)){case 336:ky(this,Sx(this,a.G,b),!c,!!this.F)}}return!0}; +l.Zm=function(a){var b=this.H,c=b.D&65535,d=b.G&65535,e=b.I&65535,f=b.L&65535,g=b.K&65535,h=b.J&65535,k=b.oa.U;if(null==this.F)return 79==c&&Ff(b,a,function(a){return function(){62342!=(b.D&65535)?(b.D=b.D&-65536|62342,wb(a,"INT 0x41 handling enabled",128),a.F=!0):(wb(a,"INT 0x41 monitoring enabled",128),a.F=!1)}}(this)),!0;switch(c){case 79:this.F&&(b.D=b.D&-65536|62342,wb(this,"INT 0x41 handling enabled",128));break;case 80:iy(this,Sx(this,h,k),d+1,e,!(g&1),!!this.F);break;case 82:ny(this,null, +d);break;case 127:this.F&&(b.D=b.D&-65536|(this.Aa?0:1));break;case 131:this.F&&(a=Sx(this,b.L,e),this.Da++?(this.P("TRAPFAULT failed"),oy(this,this.B,a,!0,!0),this.Da=0,this.Jb()):(this.P("INT 0x41 TRAPFAULT: fault="+ka(d)+" error="+q(b.K,8,!0)+" addr="+py(a)),this.Gd(this.B,a,!0),Ux(this,!0)));break;case 141:this.F&&(b.D=b.D&-65536|1);break;case 336:ky(this,Sx(this,b.G,f),!g,!!this.F);break;case 338:my(this,d,Sx(this,b.J,f))}this.Aa=!1;return!this.F}; +l.$m=function(a){var b=this.H,c=b.D&255,d=b.D>>8&255,e=b.G&65535,f=b.I&65535,g=b.L&65535,h=b.J&65535,k=b.oa.U;if(null==this.O){if(67==d){if(609437257==b.ia((b.Z.U<<4)+10)||1111835735==b.ia((b.Z.U<<4)+95))return!0;Ff(b,a,function(a){return function(){62342!=(b.D&65535)?(b.D=b.D&-65536|62342,wb(a,"INT 0x68 handling enabled",128),a.F=a.O=!0):(wb(a,"INT 0x68 monitoring enabled",128),a.O=!1)}}(this))}return!0}switch(d){case 67:this.O&&(b.D=b.D&-65536|62342);break;case 68:this.O&&(a=Hd(b.Z,this.yl.bind(this)))&& +(b.J=a[0],ae(b,a[1]));break;case 72:ny(this,null,e);break;case 80:32==c?iy(this,Sx(this,h,k),0,f,!0,!!this.O):128>c?iy(this,Sx(this,h,k),e+1,c&64?g:f,!(c&1),!!this.O):ky(this,Sx(this,h,k),!(c&1),!!this.O),this.O&&(b.D=b.D&-256|1)}return!this.O};l.yl=function(){var a=this.H;5==(a.D&255)&&(a.I=a.K=0,a.D=a.D&-256|1);return!1}; +l.Cb=function(a,b,c){var d=this;switch(b){case "debugInput":return this.qa=this.na[b]=c,c.onkeydown=function(a){var b;if(13==a.keyCode)b=c.value,c.value="",Wx(d,b,!0);else if(27==a.keyCode)c.value=b="";else if(38==a.keyCode?(b=null,d.A>>0)+1;a.jb=f;a.type=g;a.ext=k;a.Lb=d;Gd(a,!0,!0,!1)}}return a}l.Sb=function(a,b,c){var d=a&&a.xa;if(null==d&&(d=-1,a)){var e=ay(this,a.U,a.type);e&&(b=a.Ja||0,c=c||1,d=e=-1===e.Lb||e.Oc&&(b>>>0)+c>e.Nb||!e.Oc&&(b>>>0)+c<=e.Nb?e.ua+b|0:-1,a.xa=d)}return d};l.Ia=function(a,b){var c=255,d=this.Sb(a,!1,1);-1!==d&&(c=ig(this.H,d,1,a.type==ty)|0,b&&uy(this,a,b));return c}; +l.hb=function(a,b){return a.Hb?ly(this,a,b?4:0):this.Yc(a,b?2:0)};l.Yc=function(a,b){var c=65535,d=this.Sb(a,!1,2);-1!==d&&(c=ig(this.H,d,2,a.type==ty)|0,b&&uy(this,a,b));return c};function ly(a,b,c){var d=-1,e=a.Sb(b,!1,4);-1!==e&&(d=ig(a.H,e,4,b.type==ty)|0,c&&uy(a,b,c));return d}l.fc=function(a,b,c,d){var e=this.Sb(a,!0,1);if(-1!==e){if(a.type!=ty)this.H.fc(e,b);else{var f=this.ka;f.aa[(e&f.C)>>>f.A].bf(e&f.D,b&255,e)}c&&uy(this,a,c);d||od(this.H,!0)}}; +l.il=function(a,b,c){var d=this.Sb(a,!0,2);-1!==d&&(a.type!=ty?this.H.fb(d,b):wc(this.ka,d,b),c&&uy(this,a,c),od(this.H,!0))};function Sx(a,b,c,d,e,f,g){return vy(a,{},b,c,d,e,f,g)}function vy(a,b,c,d,e,f,g,h){b.Ja=c||0;b.U=d;b.xa=e;b.type=f||(ry(a)?by:sy);b.Hb=null!=g?g:!(!a.H||4!=a.H.Z.V);b.dc=null!=h?h:!(!a.H||4!=a.H.Z.Jc);b.Jd=!1;return b}function wy(a){return[a.Ja,a.U,a.xa,a.Jd,a.Hb,a.dc,a.Fe,a.bh]}function xy(a){return{Ja:a[0],U:a[1],xa:a[2],Jd:a[3],Hb:a[4],dc:a[5],Fe:a[6],bh:a[7]}} +function yy(a,b,c){if(null!=b.U&&(a=ay(a,b.U,b.type))){var d=b.Ja&a.wa;if(!a.Oc){if(d>>>0>=a.Nb)return!1}else if(d>>>0f?null!=h?(g=Kx(a,b,void 0),f=null):(f=Kx(a,b,void 0),null==f&&(g=null)):(h=Kx(a,b.substring(0,f),void 0),g=Kx(a,b.substring(f+1),void 0),f=null)}null!=g&&(e=Sx(a,g,h,f,c),d||yy(a,e,!0)||(a.P("invalid offset: "+py(e)),e=null));return e}function Cy(a,b,c){c&&(c=c.match(/(['"])(.*?)\1/))&&(b.sl=a.Cg(b.Yk=c[2]))}l.Pk=function(a,b){var c=zy(this,b);return a.replace("["+b+"]",c?q(this.hb(c),c.Hb?8:4):"undefined")}; +function uy(a,b,c){c=c||1;null!=b.xa&&(b.xa+=c);null!=b.U&&(b.Ja+=c,yy(a,b)||(b.Ja=0,b.xa=null))}function ey(a,b,c){return null!=b?q(b,4)+":"+q(a,a&-65536||c?8:4):q(a)}function py(a){var b;switch(a.type){case sy:case Dy:b="&";break;case by:b="#";break;case By:b="%";break;case ty:b="%%";break;default:b=a.U?"":"%"}return a.type>=By||null==a.U?b+q(a.xa):b+ey(a.Ja,a.U,a.dc)} +function fy(a,b,c){var d="";for(c=c||256;d.length>>a.H.qb;g=1}a.P("blockid "+(d?"linear ":"physical")+" blockaddr used size type");a.P("-------- --------- ---------- ------ ------ ----");c=-1;for(var h=0;g--;)(d=b[f])&&d.type==Pc&&(d=bd(a.H,e,!1,!0)),d.type==c?h++||a.P("..."):(c=d.type,h=fc[c],c==Rc&&(d=d.pd,h+=" -> "+fc[d.type]),d&&a.P(q(d.id,8)+" %"+q(f<c&&(c=ya(Fy,a.substr(b,2))));return c}; +function Gy(a,b){var c=0,d=a.hh(b);if(null!=d)switch(b){case Hy:case Iy:case Jy:case Ky:case Ly:case My:case Ny:case Oy:c=2;break;case Py:case Qy:case Ry:case Sy:case Ty:case Uy:case Vy:case Wy:case Xy:case Yy+Zy:case Yy+$y:case Yy+az:case Yy+bz:case Yy+cz:case Yy+dz:c=4;break;case ez:case fz:case gz:case hz:case iz:case jz:case kz:case lz:case mz:case nz:case oz:case pz:case qz:c=8;break;case rz:c=a.oa}return c?q(d,c):"??"} +l.hh=function(a){var b;if(0<=a){var c=this.H;switch(a){case Hy:b=c.D&255;break;case Iy:b=c.I&255;break;case Jy:b=c.L&255;break;case Ky:b=c.G&255;break;case Ly:b=c.D>>8&255;break;case My:b=c.I>>8&255;break;case Ny:b=c.L>>8&255;break;case Oy:b=c.G>>8&255;break;case Py:b=c.D&65535;break;case Qy:b=c.I&65535;break;case Ry:b=c.L&65535;break;case Sy:b=c.G&65535;break;case Ty:b=z(c)&65535;break;case Uy:b=c.M&65535;break;case Vy:b=c.K&65535;break;case Wy:b=c.J&65535;break;case Xy:b=A(c)&65535;break;case rz:b= +de(c);break;case Yy+Zy:b=c.oa.U;break;case Yy+$y:b=c.Z.U;break;case Yy+az:b=c.Y.U;break;case Yy+bz:b=c.Ca.U;break;default:if(80286==this.H.ca)a==mz&&(b=c.qa);else if(80386<=this.H.ca)switch(a){case ez:b=c.D;break;case fz:b=c.I;break;case gz:b=c.L;break;case hz:b=c.G;break;case iz:b=z(c);break;case jz:b=c.M;break;case kz:b=c.K;break;case lz:b=c.J;break;case mz:b=c.qa;break;case nz:b=c.Og;break;case oz:b=c.Cd;break;case pz:b=c.Wc;break;case Yy+cz:b=c.Ga.U;break;case Yy+dz:b=c.Ha.U;break;case qz:b=A(c)}}}return b}; +function sz(a,b){b=Lx(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=a.gh(b,c+1),0<=e&&(b=b.substr(0,c)+Gy(a,e)+b.substr(c+1+Fy[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=ga(e,16),null!=d&&32<=d&&128>d?(d=e+" '"+String.fromCharCode(d)+"'",b=b.replace("#"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("$",c));)e=b.substr(c+1,9),(d=zy(a,e))?(d=e+' "'+fy(a,d)+'"',b=b.replace("$"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("^",c));)e=b.substr(c+1,9),(d=zy(a,e))?(uy(a,d),d= +e+' "'+fy(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}l.message=function(a,b){b&&(a+=" at "+py(Sx(this,A(this.H),this.H.Z.U))+" (%"+q(this.H.da)+")");this.va&&a==this.va||(this.va=a,this.ic&-2147483648&&(this.Jb(),a+=" (cpu halted)"),this.P(a),this.H&&(a=this.H,a.zc-=a.A,a.A=0,a.T.Ve=0,od(a)))}; +function Ik(a,b,c,d){var e,f;if(!d&&(d=t(a,1)&&0>tz.indexOf(b),!d)){var g=uz[b];g&&(d=t(a,g)?!0:524288==g&&t(a,g=1048576))}d&&(e=a.H.D>>8&255,f=a.H.L&255,33==b&&11==e||524288==g&&128<=f||1048576==g&&128>f)&&(d=!1);d&&((g=(g=Cb[b])&&g[e]||"")&&(g=" "+sz(a,g)),a.message("INT "+r(b)+": AH="+r(e)+" at "+ey(c-2-a.H.Z.ua,a.H.Z.U)+g));return d} +function yb(a,b,c,d,e,f,g,h){h|=256;if(null==e||(a.ic&h)==h)h=null,null!=e&&(h=a.H.Z.U,e-=a.H.Z.ua),a.message(b.be+"."+(null!=d?"outPort":"inPort")+"("+ka(c)+","+(f?f:"unknown")+(null!=d?","+r(d):"")+")"+(null!=g?": "+r(g):"")+(null!=e?" at "+ey(e,h):""))}l.ih=function(){this.P("Type ? for help with PCx86 Debugger commands");vz(this);if(this.Ca){var a=this.Ca;this.Ca=null;Wx(this,a)}}; +function Ux(a,b){var c;if(vg(a)){if(!a.N||!a.N.length){a.N=Array(wz);for(c=0;c>>f.qb].Gd(e&f.Db,a==this.M);g&&ec(f)}}d&&(a.push(b),c?(null!=b.xa&&(b.U=null),b.Jd=!0):(Dz(this,a,a.length-1,"set"),Ux(this)));return d}; +function oy(a,b,c,d,e){for(var f=!1,g=Ez(a,a.Sb(c)),h=1;h>3&7,F=(3>(g>>6&3)?0:48)+u;(217==f||219==f)&&52<=F&&(F=u<<4|g&7);(u=Mz[f])&&(x=u[F]);x&&(p=Nz,k=x,m=k[0])}m>=p.length&&(g=a.Ia(b,1),k=Oz[m-p.length][g>>3&7],m=k[0]);p=p[m];u=k.length-1;x="";b.Hb&&(m==Pz? +p="CWDE":m==Qz?p="CDQ":m>=Rz&&m<=Sz&&(p+="D"));if(164<=f&&167>=f||170<=f&&175>=f)u=0,b.Hb&&"W"==p.slice(-1)&&(p=p.slice(0,-1)+"D");for(var f=-1,F=!0,K=1;K<=u;K++){var H,I;H="";I=k[K];if(void 0!==I){0>f&&(f=I>>Tz);m==Uz&&(f==Vz?x="[%800]":f==Wz&&(x="ES:["+(b.dc?"E":"")+"DI]"));var T=I&Xz;if(T!=Yz)if(T==Zz)F=!1;else{var L=I&$z;if(L>=R)if(0>g&&(g=a.Ia(b,1)),L>6,za=g&7;if(3>xb){T=!p.indexOf("FI");if(!xb&&(!I.dc&&6==za||I.dc&&5==za))xb=2;else{if(I.dc)if(4!=za)za+= +8;else{var ca=L,cb=xb,Sa=I,rb=ca.Ia(Sa,1),db=rb>>6,rc=rb>>3&7,rb=rb&7,ib="";if(cb||5!=rb)ib=bA[rb+8];4!=rc&&(ib&&(ib+="+"),ib+=bA[rc+8],db&&(ib+="*"+(1<>24),2)):ca+("+"+q(L,2))):2==xb&&(ca&&(ca+="+"),I.dc?(L=ly(L,I,4),ca+=q(L)):(L=L.Yc(I,2),ca+=q(L,4)));ca="["+ca+"]";if(1==ua){L="";H&=Xz;H==S&&(H=I.Hb?cA:U);switch(H){case dA:L="FAR";break;case V:L="BYTE";break;case U:if(T){L="INT16"; +break}L="WORD";break;case cA:L="DWORD";break;case eA:if(T){L="INT32";break}case fA:L="REAL32";break;case gA:if(T){L="INT64";break}case hA:L="REAL64";break;case iA:L="REAL80";break;case jA:L="BCD80"}L&&(ca=L+" "+ca)}}else ca=kA(L,za,H,I);H=ca}else H=L==aA?kA(a,g&7,I,b):kA(a,g>>3&7,I,b);else if(L==lA)H="1";else if(L==W){H=a;T=I;L=b;I=" ";switch(T&Xz){case V:T&X&&(I=q(H.Ia(L,1),2));break;case mA:I=q(H.Ia(L,1)<<24>>24,L.Hb?8:4);break;case S:if(L.Hb){I=q(ly(H,L,4));break}case U:I=q(H.Yc(L,2),4);break; +case dA:L=Sx(H,H.hb(L,!0),H.Yc(L,2),null,L.type,L.Hb,L.dc);I=py(L);H=nA(H,L);H[0]&&(I+=" ("+H[0]+")");break;default:I="imm("+ka(T)+")"}H=I}else L==oA?(b.dc?(H=8,I=ly(a,b,4)):(H=4,I=a.Yc(b,2)),H="["+q(I,H)+"]"):L==pA?(H=T==V?a.Ia(b,1)<<24>>24:a.hb(b,!0),I=b.Ja+H&(b.Hb?-1:65535),H=q(I,b.Hb?8:4),I=nA(a,Sx(a,I,b.U)),I[0]&&(H+=" ("+I[0]+")")):L==Y?H=T==qA?"ST":T==rA?"ST("+(g&7)+")":kA(a,(I&sA)>>8,I,b):L==tA?H=kA(a,(I&sA)>>8,uA,b):L==vA?H="DS:[SI]":L==wA&&(H="ES:[DI]");if(!H||!H.length){x="INVALID";break}0< +x.length&&(x+=",");x+=H||"???"}}}g="";k=py(e)+" ";if(-1!==e.xa&&-1!==b.xa){do if(g+=q(a.Ia(e,1),2),null==e.xa)break;while(e.xa!=b.xa)}k+=qa(g,e.dc?24:16);k+=qa(p,8);x&&(k+=" "+x);a.H.cadz||b>=cz&&80386>a.H.ca)return"??";b+=Yy}else if(e==zA)b+=mz;else if(e==AA)b+=BA;else if(e==CA)b+=DA;else if(a=c&Xz,a>=U&&(b=Py&&b<=Wy&&4a.H.ca&&(d="\n"+d,c+=e,e="");c+="\n"+GA(a,a.H.Z,b)+" ";80386<=a.H.ca&&(e+="\n",c+=GA(a,a.H.Ga,b)+" "+GA(a,a.H.Ha,b)+"\n");c+=HA(a,"LD",a.H.Eb.U,a.H.Eb.ua,a.H.Eb.ua+a.H.Eb.Ka)+" "+HA(a,"GD",null,a.H.Kb,a.H.Pc)+" "+HA(a,"ID", +null,a.H.Pb,a.H.cd)+" ";c=c+(d+" "+e)+FA(a,mz);80386<=a.H.ca&&(c+=FA(a,oz)+FA(a,pz))}else 80386<=a.H.ca&&(c+=GA(a,a.H.Ga,b)+" "+GA(a,a.H.Ha,b)+" ");return c+=FA(a,rz)+EA(a,"V")+EA(a,"D")+EA(a,"I")+EA(a,"T")+EA(a,"S")+EA(a,"Z")+EA(a,"A")+EA(a,"P")+EA(a,"C")}l.gj=function(a,b){return a[0]>b[0]?1:a[0]>>0,p],H=ta(F,u,a.gj);0>H&&F.splice(-(H+1),0,u)}K&&(x.a=K.replace(/''/g,'"'))}a.D.push({Rf:b,nn:c,U:d,Ja:e,xa:f,cn:g,Fd:h,Pi:m})} +function ny(a,b,c){for(var d=0;d>>0,f=a.Sb(b)>>>0,g=0;g>>0,p=h.xa;null!=p&&(p>>>=0);var x=h.cn;48==k&&(k=40);if(k==b.U&&e>=m&&e=p&&fc?(a.P("out of data at address "+py(b)),p=!0):(a.fc(b,c,1,!0),m++)})})(a,g);od(a.H, +!0);a.P(m+" bytes read at "+b)}else a.P("sector "+e+" request out of range");else a.P("drive "+d+" not loaded");else a.P("invalid drive: "+d)}else a.P("disk controller not present")}}else a.P("load commands:"),a.P("\tl [address] [drive #] [sector #] [# sectors]")} +function zz(a,b){var c;if(b&&"?"==b[1])a.P("register commands:"),a.P("\tr\tdump registers"),a.Tc&&a.P("\trfp\tdump floating-point registers"),a.P("\trp\tdump all registers"),a.P("\trx [#]\tset flag or register x to [#]");else{var d;null==c&&(c=!0);if(b&&1f;f++){var g=c,e=null;if(f=a.oa&&(h=null);switch(h){case "AL":a.H.D= +a.H.D&-256|g&255;break;case "AH":a.H.D=a.H.D&-65281|g<<8&255;break;case "AX":a.H.D=a.H.D&-65536|g&65535;break;case "BL":a.H.G=a.H.G&-256|g&255;break;case "BH":a.H.G=a.H.G&-65281|g<<8&255;break;case "BX":a.H.G=a.H.G&-65536|g&65535;break;case "CL":a.H.I=a.H.I&-256|g&255;break;case "CH":a.H.I=a.H.I&-65281|g<<8&255;break;case "CX":a.H.I=a.H.I&-65536|g&65535;break;case "DL":a.H.L=a.H.L&-256|g&255;break;case "DH":a.H.L=a.H.L&-65281|g<<8&255;break;case "DX":a.H.L=a.H.L&-65536|g&65535;break;case "SP":Ud(a.H, +z(a.H)&-65536|g&65535);break;case "BP":a.H.M=a.H.M&-65536|g&65535;break;case "SI":a.H.K=a.H.K&-65536|g&65535;break;case "DI":a.H.J=a.H.J&-65536|g&65535;break;case "DS":$d(a.H,g);break;case "ES":ae(a.H,g);break;case "SS":Td(a.H,g);break;case "CS":Lf(a.H,g);a.K=Sx(a,A(a.H),a.H.Z.U);break;case "IP":case "EIP":C(a.H,g);a.K=Sx(a,A(a.H),a.H.Z.U);break;case "PC":case "PS":ee(a.H,g);break;case "C":g?Xf(a.H):Yf(a.H);break;case "P":g?(e=a.H,e.resultType&=-3,e.O|=4):(e=a.H,e.resultType&=-3,e.O&=-5);break;case "A":g? +eg(a.H):cg(a.H);break;case "Z":g?fg(a.H):dg(a.H);break;case "S":g?(e=a.H,e.resultType&=-17,e.O|=128):(e=a.H,e.resultType&=-17,e.O&=-129);break;case "I":g?(e=a.H,e.O|=512):(e=a.H,e.O&=-513);break;case "D":g?(e=a.H,e.O|=1024):(e=a.H,e.O&=-1025);break;case "V":g?Zf(a.H):$f(a.H);break;default:var k=!0;if(80286<=a.H.ca)switch(k=!1,h){case "MS":gg(a.H,g);break;case "TR":-1===a.H.la.load(g)&&(f=!1);break;default:if(k=!0,80386<=a.H.ca)switch(k=!1,h){case "EAX":a.H.D=g;break;case "EBX":a.H.G=g;break;case "ECX":a.H.I= +g;break;case "EDX":a.H.L=g;break;case "ESP":Ud(a.H,g);break;case "EBP":a.H.M=g;break;case "ESI":a.H.K=g;break;case "EDI":a.H.J=g;break;case "FS":a.H.Ga.load(g);break;case "GS":a.H.Ha.load(g);break;case "CR0":a.H.qa=g;Nj.call(a.H,g);break;case "CR2":a.H.Cd=g;break;case "CR3":a.H.Wc=g;ge.call(a.H,g);break;default:k=!0}}if(k){a.P("unknown register: "+e);return}}if(!f){a.P("invalid value: "+b);return}od(a.H);a.P("updated registers:")}}a.P(IA(a,d));c&&(a.K=Sx(a,A(a.H),a.H.Z.U),Az(a,py(a.K)))}} +function QA(a,b){b=ra(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.P(sz(a,c[2])):Kx(a,b,!0)}function RA(a,b,c){for(var d=null,e=b.Ja,f=e,g=1;6>=g&&e;g++){if(2h[0].indexOf("+"))){var m=h[0]+":";h[2]&&(m+=" "+h[2]);a.P(m)}h[3]&&(g=h[3],f=null);f=Hz(a,b,g,f);b.bh||d||d++;a.P(f);a.K=b;e-=b.xa-k;c++}}} +l.Cg=function(a,b,c){if(b)if(a){0>this.A&&this.C.length&&(this.A=0);if(0>this.A||a!=this.C[this.A])this.C.splice(0,0,a),this.A=0;this.A--}else a=this.C[this.A+1];b=[];if(a){a=a.toLowerCase().replace(/""/g,"'");var d=0,e=null;c=c||";";for(var f=0;f<=a.length;f++){var g=a.charAt(f);if('"'==g||"'"==g)e?g==e&&(e=null):e=g;else if(g==c&&!e||!g)b.push(ra(a.substring(d,f))),d=f+1}}return b}; +function Gz(a,b,c){var d=!0;try{if(!b.length||"end"==b)a.aa&&(a.P("ended assemble at "+py(a.Z)),a.K=a.Z,a.aa=!1),b="";else if(!c){var e=">> ";a.H.qa&1&&(e=a.H.O&131072?"-- ":"## ");a.P(e+b)}var f=b.charAt(0);if('"'==f||"'"==f)return!0;a.va=null;if(sb(a)&&0p||"z">>20;Qa.Ti=a.H.Wc+Qa.Jk;Qa.lb=nf.aa[(Qa.Ti&nf.C)>>>nf.A];Qa.Aj=Qa.lb.Nd(Qa.Jk);Qa.Kk=(Mg&4190208)>>>10;Qa.Ui=(Qa.Aj&-4096)+Qa.Kk;Qa.mb=nf.aa[(Qa.Ui&nf.C)>>>nf.A];Qa.Bj=Qa.mb.Nd(Qa.Kk);Qa.ul=(Qa.Bj&-4096)+(Mg&4095)}if(mf=Qa){a.P("linear PDE addr PDE PTE addr PTE physical");a.P("--------- ---------- -------- ---------- -------- ----------");var ve="%"+q(Mg),ve=ve+(" %%"+Ey(mf.Ti,mf.Aj)),ve= +ve+(" %%"+Ey(mf.Ui,mf.Bj,!0)),ve=ve+(" %%"+q(mf.ul));a.P(ve)}else a.P("unsupported operation")}}else a.P("missing address")}else{if("d"==za){if("disk"==cb){ca[0]="l";ca[1]="json";OA(a,ca);break a}for(xb in Db)if(ca[1]==xb){var jt=a.za[xb];jt?(ca.shift(),ca.shift(),jt(ca)):a.P("no dump registered for "+cb);break a}cb||(za=a.eb||"db")}else a.eb=za;if("dh"==za){var kt=cb,lt=Sa,mt="",nt=0,Lc=a.la,jd=a.N;if(jd.length){var uc=+kt||a.Ma,Ng=+lt||10;isNaN(uc)?uc=Ng:mt="more ";uc>jd.length&&(a.P("note: only "+ +jd.length+" available"),uc=jd.length);Lc-=uc;0>Lc&&(null==jd[jd.length-1].U?(uc=Lc+uc,Lc=0):Lc+=jd.length);var jm=[];"call"==lt&&(Ng=1E5,jm=["CALL"]);for(void 0!==kt&&a.P(uc+" instructions earlier:");0=jd.length&&(Lc=0);a.Ma=uc;nt++;Ng--}}nt||(a.P("no "+mt+"history available"),a.Ma= +void 0)}else if("di"==za){ca.shift();var km=ca[0];if(km){var Pg=Mx(a,km);if(void 0===Pg||0>Pg||255>>0,65536>4||1;LB--&&0Ti?String.fromCharCode(Ti):".";Si--}Qg&&(Qg+="\n");Qg+=cb+" "+mm+(Sg?"":" "+tt)}Qg&&a.P(Qg);a.Ga=of}}}}}break;case "e":if("else"==g[0])break;var Ui= +1,ut=255,vt=a.Ia,wt=a.fc;"ew"==g[0]&&(Ui=2,ut=65535,vt=a.Yc,wt=a.il);var xt=Ui<<1,yt=g[1];if(null==yt)a.P("edit memory commands:"),a.P("\teb [a] [...] edit bytes at address a"),a.P("\tew [a] [...] edit words at address a");else{var Vi=zy(a,yt);if(Vi)for(var Wi=2;Wism;){for(var kd=null,QB=256;Sd.Ja>>>0>>0;){Vg.Ja=a.hb(Sd,!0);if(null==Sd.xa||!QB--)break;Vg.U=At;if(kd=RA(a,Vg))break;Vg.U=a.hb(Sd);if(kd=RA(a,Vg,!0)){At=a.hb(Sd,!0);0\nLicense: GPL version 3 or later ");for(b=0;bnB){if(d.load(this.L)){this.F=new Jf(this,"1.33.0",xB);this.F.load()&&(yB(this,d),a=zB,AB(this.F));this.F.set(uB,va());BB(this.F);var e=this.A&&!this.I;if(a==vB||hb("Click OK to restore the previous PCx86 machine state, or CANCEL to reset the machine.")){if(c=tB(d)){var f=d.get("code"),g=d.get("data");f&&("ok"==f?d.load(g):("error"==f&&"no machine state"!= +g?(this.Fa("Error: "+g),"unable to verify user"==g&&(Ia(CB,""),this.B=null)):this.P(f+": "+g),AB(d),d.load()?(c=tB(d),e=!0):c=!1))}e&&rB(this,c?d:null)}else a==zB&&d.clear()}else rB(this);delete this.L;delete this.M}e=jb(this.id);for(f=0;fa[1];a=a[2];this.ga=!0;this.ea.Yb=!0;var d=this.na.power;d&&(d.textContent="Shutdown");this.H&&(DB(this,this.H,b,c,a),this.H.lf());this.Y&&(yB(this,b),b.clear());!c&&this.F&&(this.F.clear(),delete this.F);this.C=0}; +function yB(a,b){if(hb("There may be a problem with your PCx86 machine.\n\nTo help us diagnose it, click OK to send this PCx86 machine state to http://www.pcjs.org.")){var c=a.B||"";b=b.toString();var d={app:"PCx86",ver:"1.33.0"};d.url=a.da;d.user=c;d.type="bug";d.data=b;Ca("http://www.pcjs.org/api/v1/report",d,!0)}} +function TA(a,b,c){var d,e="none";if(a.C)return null;a.C--;var f=new Jf(a,"1.33.0"),g=new Jf(a,"1.33.0",sB),h=va();g.set(uB,h);f.set(uB,h);f.set(EB,"1.33.0");f.set(FB,window?window.location.href:null);f.set(GB,Ea());a.H&&a.H.Wb&&(c&&a.H.Jb(),d=a.H.Wb(b,c),"object"===typeof d&&f.set(a.H.id,d),c&&(a.H.ea.Yb=!1,!1===d&&(e=null)));for(var h=jb(a.id),k=0;k>>b.A;d=d+e-1>>>b.A;c.ah=0;for(c.Hd=0;f<=d;)e=b.aa[f],c.ah+=e.size,e.size&&(c.Rg.push(wa(Pb,f,0,0,e.type)),c.Hd++),f++;a.A=c;a.da=a.A.Hd*a.ka.B/(Ob*Yb);d=0;a.A.$i=0;a.A.kf||(a.A.kf=[]);e=-1;b=0;for(var g=-1,c=0;c>1),g=f.y+(f.A>>1),h=f.A,f.Nc>1,b.I+=(b.J>>1)-2,Vb(b,e),b.Y&&(b.D.restore(),b.Y=!1)}}else Vb(a,"This space intentionally left blank");a.context.drawImage(a.K,0,0,a.K.width,a.K.height,a.Ga,a.Ma,a.ya,a.Aa);a.oa=!1}}var xB="failsafe",sB="validate",uB="timestamp",EB="version",FB="url",GB="browser",CB="user",wB=-1,nB=0,vB=1,zB=2,IB=3; +Ra(function(){for(var a=pb(document,"pcx86-machine"),b=0;bf.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(f=window.location.pathname+f),d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(f?' url="'+f+'"':"")));e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1PCx86$2"), +a=a.replace(/().*?(<\/xsl:variable>)/,"$1pcx86$2"));f=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(f=new window.ActiveXObject("Microsoft.XMLDOM"),f.async=!1,f.loadXML(a)):f=(new window.DOMParser).parseFromString(a,"text/xml")}catch(p){f=null,a=p.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");Ca(e,null,!0,function(f,g,h){if(h||!g)c(a,"unable to resolve XML reference: "+d[0]+" ("+h+")");else{if(f=d[3])if(h=g.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var k=h[0],m,p=/( [a-z]+=)(['"])(.*?)\2/g;m=p.exec(f);)k=0>k.indexOf(m[1])?k.replace(">",m[0]+">"):k.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);h[0]!=k&&(g=g.replace(h[0],k))}else{c(a,"missing <"+d[1]+"> in "+e);return}g=g.replace(/<\?xml[^>]*>[\r\n]*/, +"");a=a.replace(d[0],g);ZB(a,b,c)}})}else c(a,null)} +function $B(a,b,c,d){function e(a){if(void 0===h){var b=g&&pb(g,"machine-warning");h=b&&b[0]||g}h&&(h.innerHTML=oa(a))}function f(a){e("Error: "+a);k&&(--WB||Xa(!0));k=!1}var g,h,k=!0;WB++;gb[a]={};try{if(g=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],x=document.createElement("style");x.type="text/css";x.styleSheet?x.styleSheet.cssText=m:x.appendChild(document.createTextNode(m));p.appendChild(x)}c|| +(c="/versions/pcx86/1.33.0/components.xsl");m=function(d,h){h?XB(c,null,null,!1,e,function(d,k){k?(eb(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window?(k=h.transformNode(k))?(g.outerHTML=k,--WB||Xa(!0)):f("transformNodeToObject failed"):document.implementation&&document.implementation.createDocument?(d=new XSLTProcessor,d.importStylesheet(k),(k=d.transformToFragment(h,document))?g.parentNode?(g.parentNode.replaceChild(k,g),--WB||Xa(!0)):f("invalid machine element: "+ +a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser")):f(d)}):f(d)};"<"!=b.charAt(0)?XB(b,a,d,!0,e,m):YB(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(u){f(u.message)}return k}function aC(a,b,c,d){Xa(!1);return $B(a,b,c,d)}window.embedPC=aC;window.embedPCx86=aC;window.findMachineComponent=function(a,b){return lb(b,a+".machine")};window.enableEvents=Xa;window.sendEvent=Za; +function bC(a,b,c,d){if(!c&&b){d.push(b);a=gb[d[0]];b=null;for(var e in a)if(na(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?Ca(b,null,!0,function(a,b){cC(b,d)}):cC(null,d)}else Wa("Error ("+c+") requesting "+a)} +function cC(a,b){var c,d,e,f=b[0],g=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var h=gb[f],k={},m;for(m in h){var p=h[m],x=ma(m);if("xml"==x){for(x=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=x.exec(h[m]);){var u=d[2];u&&(h[u]||(p=p.replace(d[0],"")))}d=m=la(m)}else"xsl"==x&&(e=m=la(m));k[m]=p}a&&(k[m="css"]=a);b[2]&&(k[m="parms"]=b[2]);b[3]&&(k[m="state"]=b[3]);d&&e?(a=JSON.stringify(k),g+=".js",c=c[1]+"var resources="+a+";"+c[2]+c[3],c=c.replace(/\u00A9/g, +"©"),a=Ma(c,"javascript",!1,g),a=a+(', copy it to your web server as "'+g+'", and then add the following to your web page:\n\n')+('
    \n')+"...\n",a=a+(' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + float: + + + + + + + js + + + +
    + + + + + + + + + + js + + + "" + + + + + +
    +
    + + + + + + + + + + + + + + + , + + + + + + + + + + + + + .machine + . + . + + + + + + + + + + + + + + + + + + + + ,comment:'' + + + + + + border:1px solid black;border-radius:15px; + border:; + + + + + + left:; + + + + + + top:; + + + + + + + + width:; + width:;max-width:; + width:auto;max-width:; + + + + + + + + height:; + + + + + + padding:; + + padding-top:; + padding-right:; + padding-bottom:; + padding-left:; + + + + + + float:left; + float:right; + margin:0 auto;clear:both; + position:; + position:relative; + + + + + overflow:auto;width:100%; + background-color:; + + + + - -component + +
    + + + + + + +
    + + + + + + + + --object -screen + + +
    +
    + +
    + +
    +
    + + + + +
    + + +
    [XML]
    + +
    + + +
    +
    +
    +
    + + + + + text-align:center; + + + +

    +
    + + +
    +
    + + + + + + +
    +
    + + + + type:'' + + + binding:'' + + + value:'' + + + + border:1px solid black; + border:; + + + + + + width:; + + + + + + height:; + + + + + + left:; + + + + + + top:; + + + + + + padding:; + + padding-top:; + padding-right:; + padding-bottom:; + padding-left:; + + + + + + float:left; + float:right; + margin:0 auto; + clear:both; + position:; + position:relative; + text-align:; + float:left; + + + + + + + + + + + + + + + + + + +
    + + + font-size:; + + + + + -label + + + + width:; + width:; + + + + + + + + text-align:right; + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    + + +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    + + + + +
    +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    +
    + + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + + + + + + + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + + + + + + + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + ; + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + desc:'' + + ,href:'' + + + + + + + + + + + + ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8088 + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + 1 + + + + + + + null + + + + + + 0 + + + + + + + -1 + + + + + + + -1 + + + + + + + -1 + + + + + + ,model:'',stepping:'',fpu:,cycles:,multiplier:,autoStart:,addrReset:,csStart:,csInterval:,csStop: + + + + + + + + + + + + + + + 8087 + + + + + + + + + + + + ,model:'',stepping:'' + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + true + + + + + + false + + + + + + {} + + + + + + + + + + + + + + + + + chipset + ,model:'',scaleTimers:,sw1:'',sw2:'',sound:,floppies:,monitor:'',rtcDate:'' + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + device + ,type:'',baudReceive:,baudTransmit:,autoMount:'' + + + + + + + + + + + + + + + + + + + + keyboard + ,model:'' + + + + + + + + + + + + + + + 0 + + + + + + + + + + + parallel + ,adapter:,binding:'' + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + + 0 + + + + + + + 0 + + + + + + + false + + + + + serial + ,adapter:,baudReceive:,baudTransmit:,binding:'',tabSize:,charBOL:,upperCase: + + + + + + + + + + + + + + + + + + + + mouse + ,serial:'' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fdc + ,autoMount:'',sortBy:'' + + + + + + + + + + + + + + + + + + + + + xt + + + + + hdc + ,drives:'',type:'' + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + null + + + + + + + + + + + + + + + + + rom + ,addr:,size:,alias:,file:'',notify:'' + + + + + + + + + + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + null + + + + + + null + + + + + + true + + + + + ram + ,addr:,size:,file:'',load:,exec:,test: + + + + + + + + + + + + + + + + + + + + + null + + + + + + + 256 + + + + + + + 224 + + + + + + + black + + + + + + 0 + + + + + + 0 + + + + + + false + + + + + + 1bpp + + + + + + 0 + + + + + + 0 + + + + + + 1 + + + + + + 0 + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + false + + + + + + 1 + + + + + + 1 + + + + + + + 80 + + + + + + + 25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + 0 + + + + + + null + + + + + + 0 + + + + + + 60 + + + + + video + ,model:'',mode:,screenWidth:,screenHeight:,screenColor:'',screenRotate:,bufferAddr:,bufferRAM:,bufferFormat:'',bufferCols:,bufferRows:,bufferBits:,bufferLeft:,bufferRotate:,memory:,switches:'',scale:,cellWidth:,cellHeight:,charCols:,charRows:,fontROM:'',fontColor:'',touchScreen:'',autoLock:,aspectRatio:,smoothing:,interruptRate:,refreshRate: + + + + + + + + + + + + + + + 16 + + + + + + + + + + + + + + + + + debugger + ,base:,commands:'',messages:'' + + + + + + + + + + + + + + panel + + + + + + + + + + + + + + + + + + + + + true + + + + + + + 0 + + + + + + 0 + + + + + + + + + + + + computer + ,autoPower:,busWidth:,resume:'',state:'' + + + + + + + + diff --git a/versions/pdpjs/1.33.0/document.css b/versions/pdpjs/1.33.0/document.css new file mode 100644 index 000000000..7072b406e --- /dev/null +++ b/versions/pdpjs/1.33.0/document.css @@ -0,0 +1,162 @@ +@CHARSET "UTF-8"; + +.page { + margin: 2% 2%; + padding: 2% 2%; + min-width: 30em; + overflow: auto; + font-size: large; + font-family: Helvetica, Arial, sans-serif; + background: #303030; + color: #ccc; + +} +.page-header { +} +.page-header-title { + text-align: center; + +} +.page a { + color: #7fc07f; + text-decoration: none; +} +a.footlink, a.paralink { + text-decoration: none; +} +a.footlink:link, a.paralink:link { + color: blue; +} +a.footlink:visited, a.paralink:visited { + color: blue; +} +.galleryitem { + float: left; + width: 200px; +} +.item { + float: left; + width: 2em; + text-indent: 1em; +} +.list { + margin-left: 3em; + text-indent: 0; + text-align: justify; +} +ul { + list-style: none; +} +div.pnumber { + float: left; + width: 2em; + text-indent: 1em; +} +div.pitem { + margin-left: 10em; +} +p.indent, .justified p { + text-indent: 2em; + text-align: justify; + line-height: 1.5em; +} +p.noindent { + text-indent: 0; + text-align: justify; +} +p.center, .center { + text-align: center; +} +li.para { + margin-top: 1em; + margin-bottom: 1em; +} +.left { + text-align: left; +} +.right { + text-align: right; +} +blockquote.tag { + font-size: small; + font-family: Monaco, Fixed, monospace; + margin-top: 0; + margin-bottom: 0; +} +.blockquote { + padding-left: 1em; + text-indent: 0; + text-align: justify; +} +.italics { + font-style: italic; +} +.medium { + font-size: medium; +} +.small { + font-size: x-small; +} +.smallcaps { + font-variant: small-caps; +} +.strike { + text-decoration: line-through; +} +.summation, .bracelist { + display: inline-block; + position: relative; + vertical-align: middle; + text-align: center; + margin-bottom: 0.5ex; + text-indent: 0; +} +.bracelist-symbol { + font-size: 3em; + vertical-align: -40%; +} +.summation .summation-lower, .summation .summation-upper, .bracelist-item { + display: block; + font-size: 75%; + text-align: center; +} +.summation .summation-upper { + margin-bottom: 0; + margin-left: 0.8ex; + font-style: italic; +} +.summation .summation-lower{ + margin-bottom: -0.6ex; + font-style: italic; +} +.summation .summation-symbol { + font-size: 2em; +} +p sup { + vertical-align: baseline; + position: relative; + bottom: .5em; + font-size: small; +} +p sub { + vertical-align: baseline; + position: relative; + bottom: -.5em; + font-size: small; +} +.footnote { + font-size: medium; + text-indent: 1em; + text-align: justify; + margin-top: .5em; +} +.image-right { + float: right; + margin-left: 1em; + margin-top: 1em; + margin-bottom: 1em; +} +.image-caption { + font-size: small; + text-align: center; +} \ No newline at end of file diff --git a/versions/pdpjs/1.33.0/document.xsl b/versions/pdpjs/1.33.0/document.xsl new file mode 100644 index 000000000..80fbe7a92 --- /dev/null +++ b/versions/pdpjs/1.33.0/document.xsl @@ -0,0 +1,452 @@ + + + + + +]> + + + + + + + + + +

    +
    + + + + + + + +

    +
    + +

    +
    +
    +
    + + + + + + +
    +
    + + +
    + +   + + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + +

    +
    + + +

    +
    + + +

    +
    + + +
    +
    + + +
    +
    + + + + + + + + + + + + + + +
    +
    + + +
    +
    + + +
  • +
    + + +
    image
    +
    + + +
    +
    + + + + +
    {.}
    +
    + +
    {.}
    +
    +
    +
    + + + + + + + + + + < + > + + + + × + + ÷ + σ + + + + + + + + + + + + { + + + + + + + + + + [] + + + + +
    + +
    +
    + + + , and + + + + + MDY + + + + + + + + + + + + + + + + + + + + January + February + March + April + May + June + July + August + September + October + November + December + + + , + + + + + +

    + +
    +
    + + +
    + {.}
    +
    +
    +
    + + + +

    Timeline

    +
    + +

    +
    +
    + +
    +
    + + + + + + + + + +

    +
    + +
    +
    +
    + + + +

    People

    +
    + +

    +
    +
    + +
    +
    + + +

    + +
    + + +

    +
      + +
    +
    + + + + + + + + + + +
  • + +
  • +
    + + + +

    +
    +

    + +

    +
    +
    + + + + false + + + + + + [Original] + + + + + + + + + + [] + + +
    by
    + + +
    + [Source: + + + + + + + ] +
    +
    +
    + + + +

    Resources

    +
    + +

    +
    +
    + +
    +
    + + +

    + +
    + + + +

    +
    +
      + +
    +
    + + +
  • +
    + + + +

    +
    +
    + +
    +
    + + + +

    +
    + +
    + + + +

    +
    +
      + +
    +
    + + + + + +
      + +
    +
    + + + + +
  • +
    + +
  • +
    + +
  • +
    +
    +
    + + +
  • +
    + + + + + + + + + + +
    + < ="" + + ></> + ></> + /> + +
    +
    + +
    diff --git a/versions/pdpjs/1.33.0/machine.xsl b/versions/pdpjs/1.33.0/machine.xsl new file mode 100644 index 000000000..04aad4828 --- /dev/null +++ b/versions/pdpjs/1.33.0/machine.xsl @@ -0,0 +1,61 @@ + + + + +]> + + + + + + + + + + + + + + + + + js + + + + + + <xsl:value-of select="$SITEHOST"/> + + + + +
    + +
    +

    +
    + + + + + , + +
    +
    + +
    + + + + -dbg + + + + + + +
    + +
    diff --git a/versions/pdpjs/1.33.0/manifest.xsl b/versions/pdpjs/1.33.0/manifest.xsl new file mode 100644 index 000000000..576e3311c --- /dev/null +++ b/versions/pdpjs/1.33.0/manifest.xsl @@ -0,0 +1,247 @@ + + + + +]> + + + + + + + + + + + <xsl:value-of select="$SITEHOST"/> + + + + +
    + +
    +

    Document Manifest

    +
    +
      + + + + None + + + + + + + + + + + + + + + + +
    +
    +
    +

    + +
    +
    +
    + + +
    + + + + + + + + + + + <xsl:value-of select="$SITEHOST"/> + + + + +
    + +
    +

    Software Manifest

    +
    +
      + + + + None + + + + + Unknown + + + + + None + + + + + None + + + + + + + + + + + + + UpdatedReleased + + Unknown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + +

    No default machine specified for '' in manifest.xml

    +
    + +
    +
    +
    + + + + -dbg + + + + + + +
    + + + + + Unknown + +
  • +
      + + + + + + + + +
    • + + + + + + + + + + + + + + + + + + + + + + + + + +
        + +
      • + + + + + + +
      • +
        +
      +
      +
    • +
      + + + + + + + + +
    +
  • +
    +
    + +
    diff --git a/versions/pdpjs/1.33.0/outline.xsl b/versions/pdpjs/1.33.0/outline.xsl new file mode 100644 index 000000000..d054f8f04 --- /dev/null +++ b/versions/pdpjs/1.33.0/outline.xsl @@ -0,0 +1,47 @@ + + + + +]> + + + + + + + + + + + + + + + + + + <xsl:value-of select="title"/><xsl:text> | </xsl:text><xsl:value-of select="$SITEHOST"/> + + + + + +
    +
    + +
    +
    + + + + -dbg + + + + + + +
    + +
    diff --git a/versions/pdpjs/1.33.0/pdp11-dbg.js b/versions/pdpjs/1.33.0/pdp11-dbg.js new file mode 100644 index 000000000..be2809dee --- /dev/null +++ b/versions/pdpjs/1.33.0/pdp11-dbg.js @@ -0,0 +1,375 @@ +(function(){/* + http://pcjs.org/modules/shared/lib/diskapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/dumpapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/reportapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/userapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/keys.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/strlib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/weblib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/messages.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/panel.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/device.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/cpu.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/rom.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/ram.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/keyboard.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/pc11.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/rk11.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/rl11.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/computer.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/state.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/embed.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/defines.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/component.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/usrlib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/defines.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/bus.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/memory.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/cpustate.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/cpuops.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/serial.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/disk.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/drive.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/debugger.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/debugger.js (C) Jeff Parsons 2012-2017 +*/ +var h,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},ba="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global?global:this;function ca(){ca=function(){};ba.Symbol||(ba.Symbol=da)}var ea=0;function da(a){return"jscomp_symbol_"+(a||"")+ea++} +function fa(){ca();var a=ba.Symbol.iterator;a||(a=ba.Symbol.iterator=ba.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&aa(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return ga(this)}});fa=function(){}}function ga(a){var b=0;return ha(function(){return b":62,"?":63,"@":64,nd:65,Fh:66,Ih:67,gi:68,E:69,mi:70,oi:71,Bi:72,Di:73,Ei:74,Fi:75,Gi:76,Ji:77,Li:78,Ni:79,Qi:80,Q:81,Si:82,Ui:83,bj:84,dj:85,fj:86,gj:87,kj:88,lj:89,Xe:90,"[":91,"\\":92,"]":93,"^":94,_:95,"`":96,mj:97,nj:98,qj:99,d:100,e:101,rj:102,sj:103,tj:104,uj:105,yj:106,k:107,zj:108,Aj:109,n:110,Bj:111,p:112,q:113,r:114,Cj:115,t:116,Fj:117,Gj:118,Hj:119,x:120,y:121,z:122,"{":123, +"|":124,"}":125,"~":126,oe:127};function q(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.Cd=b.comment;this.Ue=b;this.exports={};this.H=this.bindings={};a=this.id.indexOf(".");0>a?this.Eb=this.id:(this.pb=this.id.substr(0,a),this.Eb=this.id.substr(a+1));this.A={ready:!1,jb:!1,$c:!1,Z:!1,error:!1};this.yc=null;this.A.error=!1;this.fa=c||0;this.F=this.f=this.C=this.K=this.Qa=null;ua.push(this)}function va(a,b,c){xa[a]&&b&&(xa[a][b]=c)} +function ya(){return Date.now()||+new Date}function v(a){window&&window.alert(a)}function za(a){var b=!1;window&&(b=window.confirm(a));return b}function Aa(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b>=1,f--;return d}function E(a,b,c){var d="";b?11>=3;return(c?"0o":"")+d} +function Ra(a){var b=2,c="";b?10=e?48:55),d=String.fromCharCode(e)+d;a>>=4}return(c?"0x":"")+d}function Sa(a){return F(a,4,!0)} +function Ta(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0"']/g,function(a){return Xa[a]})}function Ya(a,b){return(a+" ").slice(0,b)} +function Za(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}var Xa={"&":"&","<":"<",">":">",'"':""","'":"'"},$a={0:"NUL",1:"SOH",2:"STX",3:"ETX",4:"EOT",5:"ENQ",6:"ACK",7:"BEL",8:"BS",9:"TAB",10:"LF",11:"VT",12:"FF",13:"CR",14:"SO",15:"SI",16:"DLE",17:"XON",18:"DC2",19:"XOFF",20:"DC4",21:"NAK",22:"SYN",23:"ETB",24:"CAN",25:"EM",26:"SUB",27:"ESC",28:"FS",29:"GS",30:"RS",31:"US"}; +function ab(a,b,c){var d=0,e=a.length,f=0;for(c||(c=function(a,b){return a>b?1:a>1,k;k=c(b,a[g]);0a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())} +function fb(a,b,c,d){c=void 0===c?!1:c;var e=0,f=null,g=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),g;var k=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(k.onreadystatechange=function(){4===k.readyState&&(f=k.responseText,200==k.status||!k.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=k.status||-1),d&&d(a, +f,e))});if(b&&"object"==typeof b){var l="",m;for(m in b)b.hasOwnProperty(m)&&(l&&(l+="&"),l+=m+"="+encodeURIComponent(b[m]));l=l.replace(/%20/g,"+");k.open("POST",a,c);k.setRequestHeader("Content-type","application/x-www-form-urlencoded");k.send(l)}else k.open("GET",a,c),"bytes"==b&&k.overrideMimeType("text/plain; charset=x-user-defined"),k.send();c||(f=k.responseText,200!=k.status&&(e=k.status||-1),d&&d(a,f,e),g=[f,e]);return g} +function gb(a,b){var c,d={ba:null,ea:null,xa:null,wa:null};if("["==b.charAt(0)||"{"==b.charAt(0))try{var e,f,g;if("<"==b.substr(0,1))throw Error(b);g=0>b.indexOf("0x")&&'["'!=b.substr(0,2)?JSON.parse(b.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+b+")");d.xa=g.load;d.wa=g.exec;if(e=g.bytes)d.ba=e;else if(e=g.words)for(d.ba=Array(2*e.length),f=c=0;c>8&255;else if(e=g.data)for(d.ba=Array(4*e.length),f=c=0;c>8&255,d.ba[f++]=e[c]>>16&255,d.ba[f++]=e[c]>>24&255;else d.ba=g;d.ea=g.symbols;d.ba.length?1==d.ba.length&&(v(d.ba[0]),d=null):(v("Empty resource: "+a),d=null)}catch(k){v("Resource data error ("+a+"): "+k.message),d=null}else{e=[];b=b.replace(/\n/gm," ").replace(/ +$/,"").split(" ");for(c=0;ca;a++)this.b["S"+a]=[0,0,!1,!1,this.pf,a];this.F=this.f=this.C=this.K=null;y(this)}p(Rb,q);h=Rb.prototype; +h.reset=function(a){this.stop();a&&Zb(this,this.Ta=0)}; +h.ua=function(a,b,c,d){if(this.K&&this.K.ua(a,b,c,d)||this.f&&this.f.ua(a,b,c,d)||this.F&&this.F.ua(a,b,c,d))return!0;switch(b){case "R0":case "R1":case "R2":case "R3":case "R4":case "R5":case "R6":case "R7":case "NF":case "ZF":case "VF":case "CF":case "PS":return this.H[b]=c,this.v++,!0;default:return"led"==a||"rled"==a?(this.H[b]=c,this.i[b]=d?1:0,this.v++,!0):"switch"==a?(void 0===this.b[b]&&(this.b[b]=[d?1:0,d?1:0]),this.H[b]=c,a=c.parentElement||c,a=a.parentElement||a,a.onmousedown=function(a, +b){return function(){$b(a,b)}}(this,b),a.onmouseup=a.onmouseout=function(a,b){return function(){ac(a,b)}}(this,b),a.ontouchstart=function(a,b){return function(c){$b(a,b);c.preventDefault()}}(this,b),a.ontouchend=function(a,b){return function(){ac(a,b)}}(this,b),!0):q.prototype.ua.call(this,a,b,c,d)}};h.za=function(a,b,c,d){this.K=a;this.C=b;this.f=c;this.F=d;bc(b,this,cc);dc(b,this.reset.bind(this));ec(this);fc(this)}; +h.Ca=function(a,b){if(!b)if(this.M&&gc(),!a)this.reset(!0);else if(!this.restore(a))return!1;return!0};h.Ba=function(a){return a?this.save():!0};h.save=function(){var a=new G(this);a.set(0,[this.da,this.Ta,this.Ua]);return a.data()};h.restore=function(a){if(a=a[0])hc(this,this.da=a[0]),Zb(this,this.Ta=a[1]),ic(this,a[2]);return!0};function jc(a,b,c){if(a=a.H[b])a.style.backgroundColor=c?"#ff0000":"#000000"}function ec(a,b){for(var c in a.i)jc(a,c,null!=b?b:a.i[c])} +function kc(a,b,c){if(a=a.H[b])a.style.marginTop=c?"0px":"20px",a.style.backgroundColor=c?"#00ff00":"#228B22"}function fc(a){for(var b in a.b)kc(a,b,a.b[b][1])}function lc(a,b,c,d){if(a.H[b]){var e=a.F&&a.F.Aa||8;c=c||0;c=8==e?E(c,d):F(c,d);a.H[b].textContent!=c&&(a.H[b].textContent=c)}}function $b(a,b){var c=a.b[b];kc(a,b,c[1]=1-c[1]);c[3]=!0;c[4]&&c[4].call(a,c[1],c[5]);b!=mc&&(a.G=b==nc,a.I=b==oc)} +function ac(a,b){var c=a.b[b];c[2]&&c[3]&&(kc(a,b,c[1]=c[0]),c[4]&&c[4].call(a,c[1],c[5]));c[3]=!1}h.mf=function(a){a||this.f.A.T||(a=this.f,a.C.reset(),pc(a),this.b[qc]&&this.b[qc][1]&&rc(this.f))};h.nf=function(){};h.hf=function(a){a||this.f.aa()}; +h.ff=function(a){if(!a&&!this.f.A.T)if(this.b[qc]&&this.b[qc][1])rc(this.f);else{if((a=this.F)&&!Ja(a,!0))Ka(a,!0),sc(a,0,null),Ka(a,!1);else try{var b=this.f.pc(1);0=a.f.ia?8:16,c=65472<=a.da&&a.da<65472+b,b=c?1:2,c=c?15:a.C.I;a.b[mc]&&a.b[mc][1]||(b=-b);hc(a,a.da&~c|a.da+b&c)} +function hc(a,b){a.da=b&a.C.I;if(a.B!==a.da){a.B=a.da;b=a.B;for(var c=0;22>c;c++)Mc(a,"A"+c,b&1<c;c++)Mc(a,"D"+c,b&1<c;c++)a.b["S"+c][1]=b&1<>2;this.i=this.j-1;this.G=this.M/this.j|0;this.U=this.G-1;this.Na=[];this.la=0;this.D=!1;this.N=[];this.Ye=[Sc,Tc,Uc,Vc];this.b=this.v=[];this.B=this.L=this.w=this.O=this.P=0;a=new J(this);Wc(a,this.F);this.b=Array(this.G);this.v=Array(this.G);for(b=0;b>>this.g;this.L=0;this.w=this.I;y(this)}p(Qc,q);function Zc(a,b){if(b!=a.L){for(var c=0;c>>a.g,a.v[a.P]=a.b[a.O])}}h=Qc.prototype;h.reset=function(){for(var a=0;a>>a.g;0g&&(n=g);if(!e&&l&&l.size){if(l.type==d){if(f+g<=l.J)return l.Ob+=l.J-f,l.J=f,!0;if(f>=l.J+l.Ob){n=l.size-(f-m);n>g&&(n=g);l.Ob=f-l.J+n;f=m+a.j;g-=n;k++;continue}}return ad(bd,f,g)}f=new J(a,f,n,a.j,d,e);Wc(f,a.F,l);a.b[k++]=f;f=m+a.j;g-=n}return 0>=g?(a.status("Added "+(c>>10)+"Kb "+cd[d]+" at "+E(b)),!0):ad(dd,b,c)}h.od=function(a){return this.v[(a&this.w)>>>this.g].xb(a&this.i,a)}; +h.oc=function(a){var b=a&this.i,c=(a&this.w)>>>this.g;return Lb||b!=this.i?this.v[c].na(b,a):this.v[c++].xb(b,a)|this.v[c&this.U].xb(0,a+1)<<8};h.pd=function(a,b){this.v[(a&this.w)>>>this.g].zb(a&this.i,b,a)};h.Sb=function(a,b){var c=a&this.i,d=(a&this.w)>>>this.g;Lb||c!=this.i?this.v[d].Ab(c,b,a):(this.v[d++].zb(c,b&255,a),this.v[d&this.U].zb(0,b>>8&255,a+1))};function ed(a,b){return a.b[(b&a.I)>>>a.g]} +function zc(a,b){var c;a.D=!1;a.la++;var d=b&a.i,e=ed(a,b);Lb||d!=a.i?c=e.B(d,b):c=e.K(d,b)|ed(a,b+1).K(0,b+1)<<8;a.la--;return c}function fd(a,b,c){a.D=!1;a.la++;ed(a,b).F(b&a.i,c&255,b);a.la--}function xc(a,b,c){a.D=!1;a.la++;var d=b&a.i,e=ed(a,b);Lb||d!=a.i?e.D(d,c&65535,b):(e.F(d,c&255,b),ed(a,b+1).F(0,c>>8&255,b+1));a.la--} +function $c(a){for(var b=0,c=[],d=0;da.f.ia)){var k=g[0]?g[0].bind(b):null,l=g[1]?g[1].bind(b):null,m=g[2]?g[2].bind(b):null,n=g[3]?g[3].bind(b):null;65472<=f&&65487>=f&&(!k&&m&&(k=function(a){return function(b){return a(b)&255}.bind(b)}(m)),!l&&n&&(l=function(a){return function(b,c){return a(b,c)}.bind(b)}(n)));for(var r=g[4],u=g[5]||1,t=0;t>8:e[2](f)&255):f&1&&(e=d.Na[a&-2])&&(e[2]?c=e[2](f&-2)>>8:e[0]&&(c=e[0](f)));if(0<=c)return this.f&&A(this.f,16|e[5])&&D(this.f,e[4]+".readByte("+K(this.f,b)+"): "+K(this.f,c),!0,!d.la),c;d.La(b,16,3);c=255;this.f&&A(this.f,16)&&D(this.f,"warning: unconverted read access to byte @"+K(this.f,b)+": "+K(this.f,c),!0,!d.la);return c} +function Tc(a,b,c){var d=!1,e=this.controller,f=e.Na[a],g=c&65535;if(f)if(f[1])f[1](b,g),d=!0;else{if(f[3]){a=f[2]?f[2](g,!0):0;if(g&1)f[3](a&255|b<<8,g&-2);else f[3](a&-256|b,g);d=!0}}else g&1&&(f=e.Na[a&-2])&&(f[3]?(g&=-2,a=f[2]?f[2](g,!0):0,f[3](a&255|b<<8,g),d=!0):f[1]&&(f[1](b,g),d=!0));d?this.f&&A(this.f,16|f[5])&&D(this.f,f[4]+".writeByte("+K(this.f,c)+","+K(this.f,b)+")",!0,!e.la):(e.La(c,16,5),this.f&&A(this.f,16)&&D(this.f,"warning: unconverted write access to byte @"+K(this.f,c)+": "+K(this.f, +b),!0,!e.la))}function Uc(a,b){var c=-1,d=this.controller;a=d.Na[a];var e=b&65535;a&&(a[2]?c=a[2](e):a[0]&&(c=a[0](e)|a[0](e+1)<<8));if(0<=c)return this.f&&A(this.f,16|a[5])&&D(this.f,a[4]+".readWord("+K(this.f,b)+"): "+K(this.f,c),!0,!d.la),c;d.La(b,16,2);c=65535;this.f&&A(this.f,16)&&D(this.f,"warning: unconverted read access to word @"+K(this.f,b)+": "+K(this.f,c),!0,!d.la);return c} +function Vc(a,b,c){var d=!1,e=this.controller;a=e.Na[a];var f=c&65535;a&&(a[3]?(a[3](b,f),d=!0):a[1]&&(a[1](b&255,f),a[1](b>>8,f+1),d=!0));d?this.f&&A(this.f,16|a[5])&&D(this.f,a[4]+".writeWord("+K(this.f,c)+","+K(this.f,b)+")",!0,!e.la):(e.La(c,16,4),this.f&&A(this.f,16)&&D(this.f,"warning: unconverted write access to word @"+K(this.f,c)+": "+K(this.f,b),!0,!e.la))}function L(a){q.call(this,"Device",a,256);this.b={bb:128,ld:-1}}p(L,q);h=L.prototype; +h.za=function(a,b,c,d){this.C=b;this.K=a;this.f=c;this.F=d;var e=this;this.b.ld=ld(c,function(){e.b.bb|=128;e.b.bb&64&&md(e.f,e.b.Lb);e.K&&I(e.K,1);nd(e.f,e.b.ld,1E3/60)});this.b.Lb=od(c,64,6,524288);bc(b,this,pd);dc(b,this.reset.bind(this));d&&qd(d,64,function(a){var b=e.f;rd(e,"KIPDR",b.B[0],0,a[0]);rd(e,"KDPDR",b.B[0],8,a[0]);rd(e,"KIPAR",b.M[0],0,a[0]);rd(e,"KDPAR",b.M[0],8,a[0],!0);rd(e,"SIPDR",b.B[1],0,a[0]);rd(e,"SDPDR",b.B[1],8,a[0]);rd(e,"SIPAR",b.M[1],0,a[0]);rd(e,"SDPAR",b.M[1],8,a[0], +!0);rd(e,"UIPDR",b.B[3],0,a[0]);rd(e,"UDPDR",b.B[3],8,a[0]);rd(e,"UIPAR",b.M[3],0,a[0]);rd(e,"UDPAR",b.M[3],8,a[0],!0);b.V&32&&rd(e,"UNIMAP",b.Fa,-1,a[0])});y(this)};function rd(a,b,c,d,e,f){a=a.F;if(!(e&&0>b.indexOf(e.toUpperCase()))){e=8;var g="",k=!1,l=0,m=8;0>d&&(e=c.length,d=0,k=!0,l=3,m=4);for(var n=0;n>1&63;var b=this.f.Fa[a>>1];return a&1?b>>16:b&65535};h.wh=function(a,b){b=b>>1&63;var c=b>>1;this.f.Fa[c]=b&1?this.f.Fa[c]&65535|(a&63)<<16:this.f.Fa[c]&-65536|a&65534};h.gg=function(a){return this.f.B[1][a>>1&7]};h.ph=function(a,b){this.f.B[1][b>>1&7]=a&65295};h.eg=function(a){return this.f.B[1][(a>>1&7)+8]};h.nh=function(a,b){this.f.B[1][(b>>1&7)+8]=a&65295};h.fg=function(a){return this.f.M[1][a>>1&7]}; +h.oh=function(a,b){b=b>>1&7;this.f.M[1][b]=a;this.f.B[1][b]&=65295};h.dg=function(a){return this.f.M[1][(a>>1&7)+8]};h.mh=function(a,b){b=(b>>1&7)+8;this.f.M[1][b]=a;this.f.B[1][b]&=65295};h.Af=function(a){return this.f.B[0][a>>1&7]};h.Kg=function(a,b){this.f.B[0][b>>1&7]=a&65295};h.yf=function(a){return this.f.B[0][(a>>1&7)+8]};h.Ig=function(a,b){this.f.B[0][(b>>1&7)+8]=a&65295};h.zf=function(a){return this.f.M[0][a>>1&7]};h.Jg=function(a,b){b=b>>1&7;this.f.M[0][b]=a;this.f.B[0][b]&=65295}; +h.xf=function(a){return this.f.M[0][(a>>1&7)+8]};h.Hg=function(a,b){b=(b>>1&7)+8;this.f.M[0][b]=a;this.f.B[0][b]&=65295};h.mg=function(a){return this.f.B[3][a>>1&7]};h.vh=function(a,b){this.f.B[3][b>>1&7]=a&65295};h.kg=function(a){return this.f.B[3][(a>>1&7)+8]};h.th=function(a,b){this.f.B[3][(b>>1&7)+8]=a&65295};h.lg=function(a){return this.f.M[3][a>>1&7]};h.uh=function(a,b){b=b>>1&7;this.f.M[3][b]=a;this.f.B[3][b]&=65295};h.jg=function(a){return this.f.M[3][(a>>1&7)+8]}; +h.sh=function(a,b){b=(b>>1&7)+8;this.f.M[3][b]=a;this.f.B[3][b]&=65295};h.Mb=function(a){a&=7;return this.f.w&2048?this.f.pa[a]:this.f.g[a]};h.Qb=function(a,b){b&=7;this.f.w&2048?this.f.pa[b]=a:this.f.g[b]=a};h.Lf=function(){return this.f.w&49152?this.f.W[0]:this.f.g[6]};h.Tg=function(a){this.f.w&49152?this.f.W[0]=a:this.f.g[6]=a};h.Of=function(){return this.f.g[7]};h.Wg=function(a){this.f.g[7]=a};h.Nb=function(a){a&=7;return this.f.w&2048?this.f.g[a]:this.f.pa[a]}; +h.Rb=function(a,b){b&=7;this.f.w&2048?this.f.g[b]=a:this.f.pa[b]=a};h.Mf=function(){return 1==(this.f.w&49152)>>14?this.f.g[6]:this.f.W[1]};h.Ug=function(a){1==(this.f.w&49152)>>14?this.f.g[6]=a:this.f.W[1]=a};h.Nf=function(){return 3==(this.f.w&49152)>>14?this.f.g[6]:this.f.W[3]};h.Vg=function(a){3==(this.f.w&49152)>>14?this.f.g[6]=a:this.f.W[3]=a};h.wf=function(a){return this.f.lc[a-65504>>1]};h.Gg=function(a,b){this.f.lc[b-65504>>1]=a};h.de=function(a){return 65520==a?(gd(this.C)>>6)-1:0}; +h.ie=function(){};h.ig=function(){return 1};h.rh=function(){};h.vf=function(){return this.f.P};h.Fg=function(){this.f.P=0};h.Cf=function(){return this.f.ic};h.Mg=function(a,b){b&1||(a&=255);this.f.ic=a};h.Hf=function(a,b){return b?0:this.f.$a};h.Pg=function(a){zd(this.f,a)};h.hg=function(a,b){return b?0:this.f.va&65280};h.qh=function(a){this.f.va=a|255};h.Kf=function(){return Ad(this.f)};h.Sg=function(a){Bd(this.f,a)};h.he=function(a,b){A(this)&&D(this,"writeIgnored("+E(b)+"): "+E(a),!0,!0)}; +var N={},pd=(N[61568]=[null,null,L.prototype.ng,L.prototype.wh,"UNIMAP",64,1170],N[62592]=[null,null,L.prototype.gg,L.prototype.ph,"SIPDR",8,1145,64],N[62608]=[null,null,L.prototype.eg,L.prototype.nh,"SDPDR",8,1145,64],N[62624]=[null,null,L.prototype.fg,L.prototype.oh,"SIPAR",8,1145,64],N[62640]=[null,null,L.prototype.dg,L.prototype.mh,"SDPAR",8,1145,64],N[62656]=[null,null,L.prototype.Af,L.prototype.Kg,"KIPDR",8,1140,64],N[62672]=[null,null,L.prototype.yf,L.prototype.Ig,"KDPDR",8,1145,64],N[62688]= +[null,null,L.prototype.zf,L.prototype.Jg,"KIPAR",8,1140,64],N[62704]=[null,null,L.prototype.xf,L.prototype.Hg,"KDPAR",8,1145,64],N[62798]=[null,null,L.prototype.Gf,L.prototype.Og,"MMR3",1,1145,64],N[65382]=[null,null,L.prototype.Bf,L.prototype.Lg,"LKS"],N[65402]=[null,null,L.prototype.Df,L.prototype.Ng,"MMR0",1,1140,64],N[65404]=[null,null,L.prototype.Ef,L.prototype.he,"MMR1",1,1145,64],N[65406]=[null,null,L.prototype.Ff,L.prototype.he,"MMR2",1,1140,64],N[65408]=[null,null,L.prototype.mg,L.prototype.vh, +"UIPDR",8,1140,64],N[65424]=[null,null,L.prototype.kg,L.prototype.th,"UDPDR",8,1145,64],N[65440]=[null,null,L.prototype.lg,L.prototype.uh,"UIPAR",8,1140,64],N[65456]=[null,null,L.prototype.jg,L.prototype.sh,"UDPAR",8,1145,64],N[65472]=[null,null,L.prototype.Mb,L.prototype.Qb,"R0SET0"],N[65473]=[null,null,L.prototype.Mb,L.prototype.Qb,"R1SET0"],N[65474]=[null,null,L.prototype.Mb,L.prototype.Qb,"R2SET0"],N[65475]=[null,null,L.prototype.Mb,L.prototype.Qb,"R3SET0"],N[65476]=[null,null,L.prototype.Mb, +L.prototype.Qb,"R4SET0"],N[65477]=[null,null,L.prototype.Mb,L.prototype.Qb,"R5SET0"],N[65478]=[null,null,L.prototype.Lf,L.prototype.Tg,"R6KERNEL"],N[65479]=[null,null,L.prototype.Of,L.prototype.Wg,"R7KERNEL"],N[65480]=[null,null,L.prototype.Nb,L.prototype.Rb,"R0SET1",1,1145],N[65481]=[null,null,L.prototype.Nb,L.prototype.Rb,"R1SET1",1,1145],N[65482]=[null,null,L.prototype.Nb,L.prototype.Rb,"R2SET1",1,1145],N[65483]=[null,null,L.prototype.Nb,L.prototype.Rb,"R3SET1",1,1145],N[65484]=[null,null,L.prototype.Nb, +L.prototype.Rb,"R4SET1",1,1145],N[65485]=[null,null,L.prototype.Nb,L.prototype.Rb,"R5SET1",1,1145],N[65486]=[null,null,L.prototype.Mf,L.prototype.Ug,"R6SUPER",1,1145],N[65487]=[null,null,L.prototype.Nf,L.prototype.Vg,"R6USER",1,1145],N[65504]=[null,null,L.prototype.wf,L.prototype.Gg,"CTRL",8,1170],N[65520]=[null,null,L.prototype.de,L.prototype.ie,"LSIZE",1,1170],N[65522]=[null,null,L.prototype.de,L.prototype.ie,"HSIZE",1,1170],N[65524]=[null,null,L.prototype.ig,L.prototype.rh,"SYSID",1,1170],N[65526]= +[null,null,L.prototype.vf,L.prototype.Fg,"ERR",1,1170],N[65528]=[null,null,L.prototype.Cf,L.prototype.Mg,"MBR",1,1170],N[65530]=[null,null,L.prototype.Hf,L.prototype.Pg,"PIR"],N[65532]=[null,null,L.prototype.hg,L.prototype.qh,"SLR"],N[65534]=[null,null,L.prototype.Kf,L.prototype.Sg,"PSW"],N); +yb(function(){for(var a=x(document,w,"device"),b=0;b>1),this.b=new Int32Array(this.v,0,this.size>>2),Hd(this,Id?Jd:Kd);else{a=this.b=Array(this.size>>2);for(f=0;f>2),b=0;b>8,c)};h.tf=function(a){return this.b[a>>2]>>>((a&3)<<3)&255};h.tg=function(a,b){Kb&&a&1&&this.C.La(b,64,2);b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8}; +h.Dg=function(a,b){var c=a>>2;a=(a&3)<<3;this.b[c]=this.b[c]&~(255<>2;a=(a&3)<<3;24>a?this.b[c]=this.b[c]&~(65535<>8);this.ab=!0};h.rf=function(a,b){this.f&&null!=this.J&&Zd(this.f,this.J+a);return this.K(a,b)};h.pg=function(a,b){this.f&&null!=this.J&&Zd(this.f,this.J+a,2);return this.B(a,b)}; +h.Bg=function(a,b,c){this.f&&null!=this.J&&$d(this.f,this.J+a);this.j?this.Pb(0,b,c):this.F(a,b,c)};h.yh=function(a,b,c){this.f&&null!=this.J&&$d(this.f,this.J+a,2);this.j?this.Pb(0,b,c):this.D(a,b,c)};h.qf=function(a){return this.g[a]};h.sf=function(a,b){a=this.g[a];this.f&&A(this.f,32)&&D(this.f,"Memory.readByte("+K(this.f,b)+"): "+K(this.f,a),!0);return a};h.og=function(a,b){Kb&&a&1&&this.C.La(b,64,2);return this.w.getUint16(a,!0)}; +h.sg=function(a,b){Kb&&a&1&&this.C.La(b,64,2);a=!Lb&&a&1?this.g[a]|this.g[a+1]<<8:this.G[a>>1];this.f&&A(this.f,32)&&D(this.f,"Memory.readWord("+K(this.f,b)+"): "+K(this.f,a),!0);return a};h.Ag=function(a,b){this.g[a]=b;this.ab=!0};h.Cg=function(a,b,c){this.g[a]=b;this.ab=!0;this.f&&A(this.f,32)&&D(this.f,"Memory.writeByte("+K(this.f,c)+","+K(this.f,b)+")",!0)};h.xh=function(a,b,c){Kb&&a&1&&this.C.La(c,64,4);this.w.setUint16(a,b,!0);this.ab=!0}; +h.zh=function(a,b,c){Kb&&a&1&&this.C.La(c,64,4);!Lb&&a&1?(this.g[a]=b,this.g[a+1]=b>>8):this.G[a>>1]=b;this.ab=!0;this.f&&A(this.f,32)&&D(this.f,"Memory.writeWord("+K(this.f,c)+","+K(this.f,b)+")",!0)};var Fd=0,hd=1,Gd=2,Yc=4,cd=["NONE","RAM","ROM","VID","H/W"],Ed=0,Md=[],Ld=[J.prototype.tf,J.prototype.Dg,J.prototype.tg,J.prototype.Ah],Xd=[J.prototype.rf,J.prototype.Bg,J.prototype.pg,J.prototype.yh]; +if(Gb)var Kd=[J.prototype.qf,J.prototype.Ag,J.prototype.og,J.prototype.xh],Jd=[J.prototype.sf,J.prototype.Cg,J.prototype.sg,J.prototype.zh];var ae;if(Gb){var be=new ArrayBuffer(2);(new DataView(be)).setUint16(0,256,!0);ae=256===(new Uint16Array(be))[0]}else ae=!1;var Id=ae; +function ce(a,b){q.call(this,"CPU",a,1);b=+a.cycles||b;var c=+a.multiplier||1;this.Kc=0;this.Ic=b;this.hb=c;this.Sc=Math.round(this.Ic/1E4)/100;this.sb=this.Sc*this.hb;this.Tc=this.dc=this.vb=this.Jc=0;this.A.T=this.A.Dc=!1;this.A.qa=a.autoStart;"string"==typeof this.A.qa&&(this.A.qa="true"==this.A.qa);this.A.Fb=!1;this.bc=this.Ib=0;this.cc=+a.csStart;this.Gb=+a.csInterval;this.Jb=+a.csStop;this.ha=[];this.Id=this.xg.bind(this);this.ib=this.Ia=this.gb=this.b=this.ja=this.Ha=this.ac=this.fb=this.Kb= +this.Uc=this.rb=0;this.ta=null;y(this)}p(ce,q);h=ce.prototype;h.za=function(a,b,c,d){this.K=a;this.C=b;this.F=d;this.ta=a.i;for(a=0;a=a.Ib&&(a.Ib+=a.Gb,c=!0);0<=a.Jb&&a.Jb<=ke(a)&&(a.Gb=a.Jb=-1,ge(a),a.aa(),c=!0);c&&a.u(ke(a)+" cycles: checksum="+F(a.bc))}} +h.ua=function(a,b,c){var d=this;switch(b){case "power":case "reset":return this.H[b]=c,!0;case "run":return this.H[b]=c,c.onclick=function(){var a;if(a=d.K)if(a=d.K,a.A.Z)a=!0;else{var b=null,c,k=Aa(a.id);for(c=0;ca.rb/a.sb?b=1:d=!0;a.hb=b;b=a.Sc*a.hb;if(a.sb!=b){a.sb=b;b=a.sb.toFixed(2)+"Mhz";var e=a.H.setSpeed;e&&(e.textContent=b);a.u("target speed: "+b)}c&&a.K&&oe(a.K)}uc(a,a.Ia);a.Ia=0;a.Ha=ya();a.fb=0;me(a);return d}function ld(a,b){var c=a.ha.length;a.ha.push([-1,b]);return c}function nd(a,b,c,d){0<=b&&ba.ha[b][0])&&(c=a.Ic*a.hb/1E3*c|0,a.A.T&&(c+=pe(a)),a.ha[b][0]=c)} +function qe(a,b){for(var c=a.ha.length-1;0<=c;c--){var d=a.ha[c];0>d[0]||b>d[0]&&(b=d[0])}return b}function re(a){for(var b=[],c=0;cd[0]||(d[0]-=b,0>=d[0]&&(d[0]=-1,d[1]()))}}function pe(a,b){var c=a.gb-=a.b;a.b=a.ja=0;b&&(a.gb=0);return c} +h.xg=function(){if(this.A.T){this.Jc>=this.Ic&&me(this,!0);this.Kb=0;this.ac=ya();if(this.fb){var a=this.ac-this.fb;a>this.Tc&&(this.Ha+=a,this.Ha>this.ac&&(this.Ha=this.ac))}try{do{var b=qe(this,this.A.Fb?1:this.dc);try{this.pc(b)}catch(e){if("number"!=typeof e)throw e;}b=pe(this,!0);this.Kb+=b;this.Ia+=b;vc(this,b);tc(this,b);this.vb-=b;if(0>=this.vb){this.vb+=this.dc;++this.Uc>=se&&(this.K&&I(this.K,void 0),this.Uc=0);break}}while(this.A.T)}catch(e){this.aa();this.K&&this.K.stop(ya(),ke(this)); +Ga(this,e.stack||e.message);return}if(this.A.T){a=setTimeout;b=this.Id;this.fb=ya();var c=this.Tc;this.Kb&&(c=Math.round(c*this.Kb/this.dc));var c=c-(this.fb-this.ac),d=this.fb-this.Ha;d&&(this.rb=Math.round(this.Ia/(10*d))/100,864E5<=d&&(this.ib=0,le(this)));if(0>c||this.rbc&&(this.Ha-=c),c=0;this.Jc+=this.Kb;this.fb+=c;a(b,c)}}}; +function rc(a,b){if(!Ha(a))if(a.A.T)a.u(a.toString()+" busy");else{le(a);a.A.T=!0;a.A.Dc=!0;var c=a.H.run;c&&(c.textContent="Halt");a.K&&(b&&oe(a.K,!0),a.K.start(a.Ha,ke(a)));a.F||a.status("Started");setTimeout(a.Id,0)}}h.pc=function(){return 0};h.aa=function(a){var b=!1;if(this.A.T){pe(this);uc(this,this.Ia);this.Ia=0;this.A.T=!1;if(b=this.H.run)b.textContent="Run";this.K&&this.K.stop(ya(),ke(this));b=!0;this.F||this.status("Stopped")}this.A.complete=a;return b};var ne=30,se=15,de=["power","reset"]; +function te(a){var b=+a.model||1170;ce.call(this,a,6666667);this.ia=b;this.Bd=+a.addrReset||0;this.Za=this.w=this.N=this.D=this.G=this.L=this.I=0;this.g=this.pa=this.W=[];this.M=this.B=this.Fa=this.lc=[];this.cb=this.O=this.zd=this.tb=this.ub=this.mb=this.eb=this.P=this.ic=this.$a=this.va=this.U=this.jc=this.kc=this.V=this.i=0;this.Ed=[4,2,0,1];this.mc=0;this.Fd=255;1120>=this.ia?(this.yd=ue.bind(this),this.Db=this.af,this.mc=8,this.Fd=-1,this.Md=255,this.Ld=0):(this.yd=ve.bind(this),this.Db=this.bf, +this.Md=~(1792|(1140>=this.ia?2048:0))&65535,this.Ld=1140e.yb&&(e.yb=c,c+=4)}return ce.prototype.Ca.call(this,a,b)}; +h.reset=function(){this.status("Model "+this.ia);this.A.T&&this.aa();this.D=65536;this.G=32768;this.L=65535;this.I=32768;this.w=15;this.g=[0,0,0,0,0,0,0,this.Bd,-1,-2,-3,-4,-5,-6,-7,-8];this.pa=[0,0,0,0,0,0];this.W=[0,0,0,0];this.M=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.B=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[65535,65535,65535,65535,65535,65535,65535,65535,65535, +65535,65535,65535,65535,65535,65535,65535],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.Fa=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.lc=[0,0,0,0,0,0,0,0];this.N=0;this.Za=-1;this.v=this.j=this.Hc=this.X=this.Y=this.i=this.ic=0;pc(this);fe(this);this.A.error=!1;ce.prototype.reset.call(this)};function pc(a){a.U=0;a.jc=0;a.kc=0;a.V=0;a.P=0;a.$a=0;a.va=255;a.tb=0;a.ub=0;a.mb=0;a.eb=262143;a.cb=a.g[7];a.O=0;a.R=null;a.C&&(we(a),a.zd=gd(a.C))} +function we(a){a.Xb=a.Lc;a.Yb=a.Mc;a.Ec=a.Nc;a.Zb=a.Qc;a.fc&&(a.Xb=a.Wd,a.Yb=a.ae);a.gc&&(a.Ec=a.fe,a.Zb=a.ge);a.tb?(a.Ga=65536,a.ob=a.V&16?4186112:253952,a.Ea=a.$d,a.na=a.fc?a.rg:a.gd,a.Ab=a.gc?a.Ch:a.md,Zc(a.C,a.V&16?22:18)):(a.Ga=0,a.ob=57344,a.Ea=a.df,a.na=a.fc?a.qg:a.ee,a.Ab=a.gc?a.Bh:a.je,Zc(a.C,16))}function td(a){var b=a.U;b&57344||(b=b&-3199|a.ub<<5|a.mb<<1);return b} +function ud(a,b){b&=-3073;if(a.U!=b){b&57344&&!(a.U&57344)&&(a.jc=a.O>>16&65535,a.kc=a.O&65535);a.U=b;a.ub=(b&96)>>5;a.mb=(b&30)>>1;var c=0;b&257&&(c=4,b&1&&(c|=2));a.tb!=c&&(a.tb=c,we(a))}}function wd(a){a.U&57344||(a.jc=a.O>>16&65535);a=a.jc;a&65280&&(a=(a<<8|a>>8)&65535);return a}function xd(a){a.U&57344||(a.kc=a.O&65535);return a.kc}function yd(a,b){1170>a.ia&&(b&=-49);a.V!=b&&(a.V=b,a.eb=b&16?4194303:262143,we(a))} +function xe(a,b,c){a.Bd=b;ye(a,b);Bd(a,0);a.C.reset();pc(a);if(c){for(b=2;5>=b;b++)a.g[b]=0;a.A.Z?a.A.T||rc(a):a.A.qa=!0}else a.F&&a.A.Z?a.aa()||(he(a.F),I(a.K,-1)):!1===c&&a.aa();!a.A.T&&a.ta&&a.ta.stop()}h.Xd=function(){return 0}; +h.save=function(){var a=new G(this);a.set(0,[this.g,this.pa,this.W,this.M,this.B,this.Fa,this.lc,this.P,this.ic,this.$a,this.va,this.ub,this.mb,this.cb,this.i,this.O,this.Za,this.nc,this.qc]);a.set(1,[Ad(this),td(this),wd(this),xd(this),this.V]);a.set(2,[this.ib,this.hb,this.A.qa]);a.set(3,ze(this));a.set(4,re(this));return a.data()}; +h.restore=function(a){var b=ja(a[0]);this.g=b.next().value;this.pa=b.next().value;this.W=b.next().value;this.M=b.next().value;this.B=b.next().value;this.Fa=b.next().value;this.lc=b.next().value;this.P=b.next().value;this.ic=b.next().value;this.$a=b.next().value;this.va=b.next().value;this.ub=b.next().value;this.mb=b.next().value;this.cb=b.next().value;this.i=b.next().value;this.O=b.next().value;this.Za=b.next().value;this.nc=b.next().value;this.qc=b.next().value;b=a[1];Bd(this,b[0]);ud(this,b[1]); +this.jc=b[2];this.kc=b[3];yd(this,b[4]);b=a[2];this.ib=b[0];le(this,b[1]);this.A.qa=b[2];for(var b=a[3],c=b.length-1;0<=c;c--){var d;a:{for(d=0;d>23)),a.b-=2);a.b-=3}function ye(a,b){a.g[7]=b&65535}function od(a,b,c,d){b={yb:b,kb:c,message:d||0,name:Pb[b],next:null};a.$b.push(b);return b}function Fe(a,b){var c=a.R;if(c==b)a.R=b.next;else for(;c;){var d=c.next;if(d==b){c.next=d.next;break}c=d}a.R&&(a.i|=1)} +function md(a,b){if(b){if(b!=a.R){var c=a.R;if(!c||c.kb<=b.kb)b.next=c,a.R=b;else{do{var d=c.next;if(!d||d.kb<=b.kb){b.next=d;c.next=b;break}c=d}while(c)}}a.i|=1;b.message&&A(a,b.message|8)&&D(a,"setIRQ(vector="+E(b.yb)+",priority="+b.kb+")",!0,!0)}}function sd(a,b){b&&(Fe(a,b),b.message&&A(a,b.message|8)&&D(a,"clearIRQ(vector="+E(b.yb)+",priority="+b.kb+")",!0,!0))}function ze(a){var b=[];for(a=a.R;a;)b.push(a.yb),a=a.next;return b} +function Ge(a){return a.i&64?(a.sa(168,64,-6),!0):a.i&32?(a.sa(4,32,-5),!0):a.i&16?(a.sa(12,16,-7),!0):!1}function Ad(a){return a.w=a.w&63728|De(a)|Ce(a)|Be(a)|Ae(a)}function Bd(a,b){b&=a.Md;a.I=b<<12;a.L=~b&4;a.G=b<<14;a.D=b<<16;if((b^a.w)&a.Ld)for(var c=a.pa.length;0<=--c;){var d=a.g[c];a.g[c]=a.pa[c];a.pa[c]=d}a.N=b>>14&3;c=a.w>>14&3;a.N!=c&&(a.W[c]=a.g[6],a.g[6]=a.W[a.N]);a.w=b;a.i&=-3;a.i|=a.R?2:1}function zd(a,b){if(b&=65024){var c=b>>9;do b+=34;while(c>>=1);a.i|=1}a.$a=b} +h.Da=function(a){this.I=this.L=a;this.G=0};h.lb=function(a,b){this.I=this.L=this.D=a;this.G=b||0};function He(a,b){a.I=a.L=a.D=b;a.G=a.I^a.D>>1}function Ie(a,b,c,d){a.I=a.L=a.D=b;a.G=(c^d)&(d^b)} +h.sa=function(a,b,c){if(!this.oa){0>this.Za?this.Za=Ad(this):this.N||(c=-4);-4==c&&(this.i&256&&(c=-1),this.i|=256,this.P|=4,this.g[6]=a=4);if(-1!=c){this.O=a|4143316992;this.N=0;var d=this.na(a|this.Ga),e=this.na(a+2&65535|this.Ga);Bd(this,e&-12289|this.Za>>2&12288);Je(this,this.Za);Je(this,this.g[7]);ye(this,d)}this.b-=5;this.i&=~(b|19);this.i|=129;this.Za=-1;this.nc=c;this.qc=a;-1==c&&this.aa();if(-4<=c)throw a;}}; +function Ke(a){var b=Le(a),c=Le(a);a.w&49152&&(c=c&-225|a.w&63712);ye(a,b);Bd(a,c);a.i&=-17}function Me(a,b){var c=b>>13&31;31>c&&(b=a.V&32?a.Fa[c]+(b&8191)&4194303:b&-3932161);return b} +function Ne(a,b,c){var d=[];if(c){c=Me(a,b);var e=b>>13&31;d.push(c);d.push(e);a.V&32&&(d.push(a.Fa[e]),d.push(b&8191))}else if(a.tb){var e=a.N<<1,f=b>>13;7>13;a.V&a.Ed[a.N]||(d&=7);e=a.B[a.N][d];f=(a.M[a.N][d]<<6)+(b&8191)&a.eb;3932160<=f&&(f=Me(a,f));if(a.oa)return f;f>=a.zd&&f>2&8128)&&(g|=16384):(b&8128)>(e>>2&8128)&& +(g|=16384));a.B[a.N][d]=e;if(f!=(4194170&a.eb)||a.N)a.ub=a.N,a.mb=d;g&&(g&57344&&(0<=a.Za&&(g|=128),a.U&57344||(g|=a.U&4096|a.ub<<5|a.mb<<1,ud(a,a.U&-61695|g&61694)),a.sa(168,64,-2)),a.U&61440||!(f<(4191360&a.eb)||f>(4194239&a.eb))||(a.U|=4096,a.U&512&&(a.i|=64)));return f}function Le(a){var b=a.na(a.g[6]|a.Ga);a.g[6]=a.g[6]+2&65535;return b}function Je(a,b){var c=a.g[6]-2&65535;a.g[6]=c;a.O=a.O&65535|(a.O&-65536)<<8|16121856;a.i&256||a.Db(4,-2,c);a.Ab(c,b)} +function Oe(a,b,c,d){var e,f,g=d&8?0:a.Ga;switch(b){case 0:return a.sa(4,0,-3),0;case 1:return 6==c&&a.Db(d,0,a.g[6]),a.b-=3,7==c?a.g[c]:a.g[c]|g;case 2:f=2;e=a.g[c];6==c&&a.Db(d,f,e);7!=c&&(e|=g,6>c&&d&1&&(f=1));a.b-=3;break;case 3:f=2;e=a.g[c];7!=c&&(e|=g);e=a.na(e);e|=g;a.b-=7;break;case 4:f=-2;6>c&&d&1&&(f=-1);e=a.g[c]+f&65535;6==c&&a.Db(d,f,e);7!=c&&(e|=g);a.b-=4;break;case 5:f=-2;e=a.g[c]-2&65535;7!=c&&(e|=g);e=a.na(e)|g;a.b-=8;break;case 6:return e=a.na(Ee(a,2)),e=e+a.g[c]&65535,6==c&&a.Db(d, +0,e),a.b-=6,e|g;case 7:return e=a.na(Ee(a,2)),e=e+a.g[c]&65535,e=a.na(e|a.Ga),a.b-=10,e|g}a.g[c]=a.g[c]+f&65535;a.O=a.O&65535|(a.O&-65536)<<8|(f<<3&248|c)<<16;return e}h.af=function(a,b,c){!this.N&&0>=b&&c<=this.va&&(this.i|=32)};h.bf=function(a,b,c){this.N||(65534<=c&&(c|=-65536),a&4&&c<=this.va&&(c<=this.va-32?this.sa(4,0,-4):(this.P|=8,this.i|=32)))};h.Wd=function(a){this.F&&Zd(this.F,a,1);return this.Lc(a)};h.ae=function(a){this.F&&Zd(this.F,a,2);return this.Mc(a)}; +h.fe=function(a,b){this.F&&$d(this.F,a,1);this.Nc(a,b)};h.ge=function(a,b){this.F&&$d(this.F,a,2);this.Qc(a,b)};function Ac(a,b){a.oa++;b=a.C.oc(yc(a,b,2));a.oa--;return b}function Pe(a,b){(b?--a.gc:--a.fc)||we(a)}h.df=function(a,b,c){return Oe(this,a,b,c)};h.$d=function(a,b,c){return yc(this,Oe(this,a,b,c),c)};h.ee=function(a){return this.C.oc(this.cb=a)};h.qg=function(a){this.F&&Zd(this.F,a,2);return this.ee(a)};h.gd=function(a){return this.C.oc(this.cb=yc(this,a,2))}; +h.rg=function(a){this.F&&Zd(this.F,a,2);return this.gd(a)};h.je=function(a,b){this.C.Sb(this.cb=a,b)};h.Bh=function(a,b){this.F&&$d(this.F,a,2);this.je(a,b)};h.md=function(a,b){this.C.Sb(this.cb=yc(this,a,4),b)};h.Ch=function(a,b){this.F&&$d(this.F,a,2);this.md(a,b)};function Qe(a,b,c){var d=a.j=b&7;(b=a.v=(b&56)>>3)?(d=Oe(a,b,d,2),c&65536||61440!==(a.w&61440)&&(d&=65535),a.N=a.w>>12&3,c=a.na(d|c&a.Ga),a.N=a.w>>14&3):c=6!=d||(a.w>>2&12288)===(a.w&12288)?a.g[d]:a.W[a.w>>12&3];return c} +function Re(a,b,c,d){a.O=a.O&65535|1441792;var e=a.j=b&7;(b=a.v=(b&56)>>3)?(e=Oe(a,b,e,4),c&65536||(e&=65535),a.N=a.w>>12&3,e=yc(a,e|c&65536,4),a.N=a.w>>14&3,a.Zb(e,d)):6!=e||(a.w>>2&12288)===(a.w&12288)?a.g[e]=d:a.W[a.w>>12&3]=d}function Se(a,b){b>>=6;var c=a.Y=b&7;return(b=a.X=(b&56)>>3)?a.Xb(a.Ea(b,c,3)):a.g[c+a.mc]&a.Fd}function Te(a,b){var c;b>>=6;var d=a.Y=b&7;(b=a.X=(b&56)>>3)?c=a.Yb(a.Ea(b,d,2)):c=a.g[d+a.mc];return c}function Ue(a,b){var c=a.j=b&7;b=a.v=(b&56)>>3;return Oe(a,b,c,8)} +function Ve(a,b){var c=a.j=b&7;return(b=a.v=(b&56)>>3)?a.Xb(a.Ea(b,c,3)):a.g[c]&255}function We(a,b){var c,d=a.j=b&7;(b=a.v=(b&56)>>3)?c=a.Yb(a.Ea(b,d,2)):c=a.g[d];return c}function Xe(a,b,c,d){var e=a.j=b&7;(b=a.v=(b&56)>>3)?(e=a.Hc=a.Ea(b,e,7),c=0>c?a.g[-c-1]&255:c,a.Ec(e,d.call(a,c,a.Xb(e))),e&1&&a.b--):(b=a.g[e],c=0>c?a.g[-c-1]&255:c,a.g[e]=b&65280|d.call(a,c,b&255))} +function R(a,b,c,d){var e=a.j=b&7;(b=a.v=(b&56)>>3)?(e=a.Ea(b,e,6),a.Zb(e,d.call(a,0>c?a.g[-c-1]:c,a.Yb(e)))):a.g[e]=d.call(a,0>c?a.g[-c-1]:c,a.g[e])}function tf(a,b,c,d,e){var f=a.j=b&7;(b=a.v=(b&56)>>3)?(d=a.Ea(b,f,5),e.call(a,(c=0>c?a.g[-c-1]&255:c)<<8),a.Ec(d,c),d&1&&a.b--):(c?(c=0>c?a.g[-c-1]&255:c,a.g[f]=a.g[f]&~d|c<<24>>24&d):a.g[f]&=~d,e.call(a,c<<8))} +function uf(a,b,c,d){var e=a.j=b&7;(b=a.v=(b&56)>>3)?(e=a.Ea(b,e,4),d.call(a,c=0>c?a.g[-c-1]:c),a.Zb(e,c)):(a.g[e]=c=0>c?a.g[-c-1]:c,d.call(a,c))} +h.pc=function(a){this.A.complete=!0;var b=this.F?vf(this.F)?1:this.A.Dc?-1:0:0,c=a?this.A.Dc?0:1:-1;this.A.Dc=!1;this.gb=this.b=a;this.i=this.i&-5|(b?4:0);do{if(this.i){if(this.i&4){if(wf(this.F,this.g[7],c)){this.aa();break}++b||(this.i&=-5);c||c++}if(a=this.i&11)if(a=!1,this.i&2){var d=160,e=(this.$a&224)>>5,f=this.R&&this.R.kb>e?this.R:null;f&&(d=f.yb,e=f.kb);e>(this.w&224)>>5?(this.i&8&&(Ee(this,2),this.i&=-9),this.sa(d,0,-10),e=!0):e=!1;e&&(f&&Fe(this,f),a=!0);this.R||this.$a||(this.i&=-3)}else this.i& +1&&this.i++;if(a){if(this.i&4&&wf(this.F,this.g[7],c)){this.aa();break}if(0>c)break}if(this.i&112&&Ge(this)){if(this.i&4&&wf(this.F,this.g[7],c)){this.aa();break}if(0>c)break}}this.i=this.i&15|this.w&16;a=this.O=this.g[7];f=this.na(a);this.g[7]=a+2&65535;this.yd(f)}while(0>1|b<<16;He(this,a);return a&65535}function Cf(a,b){a=b&128|b>>1|b<<8;He(this,a<<8);return a&255}function Df(a,b){a=b&~a;this.Da(a);return a}function Ef(a,b){a=b&~a;this.Da(a<<8);return a} +function Ff(a,b){a|=b;this.Da(a);return a}function Gf(a,b){a|=b;this.Da(a<<8);return a}function Hf(a,b){a=~b|65536;this.lb(a);return a&65535}function If(a,b){a=~b|256;this.lb(a<<8);return a&255}function Jf(a,b){this.I=this.L=a=b-a;this.G=b&(b^a);return a&65535}function Kf(a,b){a=b-a;var c=a<<8;b<<=8;this.I=this.L=c;this.G=b&(b^c);return a&255}function Lf(a,b){this.I=this.L=a=b+a;this.G=a&(b^a);return a&65535}function Mf(a,b){a=b+a;var c=a<<8;this.I=this.L=c;this.G=c&(b<<8^c);return a&255} +function Nf(a,b){a=-b;this.lb(a,a&b&32768);return a&65535}function Of(a,b){a=-b;this.lb(a<<8,(a&b&128)<<8);return a&255}function Pf(a,b){a=b<<1|this.D>>16&1;He(this,a);return a&65535}function Qf(a,b){a=b<<1|this.D>>16&1;He(this,a<<8);return a&255}function Rf(a,b){a=(this.D&65536|b)>>1|b<<16;He(this,a);return a&65535}function Sf(a,b){a=((this.D&65536)>>8|b)>>1|b<<8;He(this,a<<8);return a&255}function Tf(a,b){var c=b-a;Ie(this,c,a,b);return c&65535} +function Uf(a,b){var c=b-a;Ie(this,c<<8,a<<8,b<<8);return c&255}function Vf(a,b){this.I=this.L=b&65280;this.G=this.D=0;return(b<<8|b>>8)&65535}function Wf(a,b){a^=b;this.Da(a);return a&65535}function Xf(a){R(this,a,Te(this,a),xf);this.b-=this.v?9+(this.Y&&6<=this.j?1:0):(this.X?5:3)+(7==this.j?2:0)} +function Yf(a){var b=We(this,a);a=a>>6&7;var c=this.g[a];c&32768&&(c|=4294901760);this.D=this.G=0;b&=63;if(b&32)b=64-b,16>=b;else if(b)if(16>15&65535;d&&65535!==d&&(this.G=32768)}this.g[a]=c&65535;this.I=this.L=c;this.b-=(this.v?6:7)+b} +function Zf(a){var b=We(this,a);a=a>>6&7;var c=this.g[a]<<16|this.g[a|1];this.D=this.G=0;b&=63;if(b&32){b=64-b;32>b-1;this.D=d<<16;d>>=1;c&2147483648&&(d|=4294967295<<32-b)}else b?(d=c<>15,d<<=1,32>=32-b)&&4294967295!==(c|4294967295<>16&65535;this.g[a|1]=d&65535;this.I=d>>16;this.L=d>>16|d;this.b-=(this.v?6:7)+b}function $f(a){P(this,a,!Ae(this))}function ag(a){P(this,a,Ae(this))} +function bg(a){R(this,a,Te(this,a),Df);this.b-=this.v?9+(this.Y&&6<=this.j?1:0):(this.X?5:3)+(7==this.j?2:0)}function cg(a){Xe(this,a,Se(this,a),Ef);this.b-=this.v?9+(this.Y&&6<=this.j?1:0):(this.X?5:3)+(7==this.j?2:0)}function dg(a){R(this,a,Te(this,a),Ff);this.b-=this.v?9+(this.Y&&6<=this.j?1:0):(this.X?5:3)+(7==this.j?2:0)}function eg(a){Xe(this,a,Se(this,a),Gf);this.b-=this.v?9+(this.Y&&6<=this.j?1:0):(this.X?5:3)+(7==this.j?2:0)} +function fg(a){var b=Te(this,a);a=We(this,a);this.Da((0>b?this.g[-b-1]:b)&a);this.b-=this.v?4+(this.Y&&6<=this.j?1:0):(this.X?4:3)+(7==this.j?2:0)}function gg(a){var b=Se(this,a);a=Ve(this,a);this.Da(((0>b?this.g[-b-1]&255:b)&a)<<8);this.b-=this.v?4+(this.Y&&6<=this.j?1:0):(this.X?4:3)+(7==this.j?2:0)}function hg(a){P(this,a,Ce(this))}function ig(a){P(this,a,!De(this)==!Be(this))}function jg(a){P(this,a,!Ce(this)&&!De(this)==!Be(this))}function kg(a){P(this,a,!Ae(this)&&!Ce(this))} +function lg(a){P(this,a,Ce(this)||!De(this)!=!Be(this))}function mg(a){P(this,a,Ae(this)||Ce(this))}function ng(a){P(this,a,!De(this)!=!Be(this))}function og(a){P(this,a,De(this))}function pg(a){P(this,a,!Ce(this))}function qg(a){P(this,a,!De(this))}function rg(){this.sa(12,0,-9)}function sg(a){P(this,a,!0)}function tg(a){P(this,a,!Be(this))}function ug(a){P(this,a,Be(this))}function vg(a){a&1&&(this.D=0);a&2&&(this.G=0);a&4&&(this.L=1);a&8&&(this.I=0);this.b-=5} +function wg(a){var b=Te(this,a);a=We(this,a);var c=(b=0>b?this.g[-b-1]:b)-a;Ie(this,c,a,b);this.b-=this.v?4+(this.Y&&6<=this.j?1:0):(this.X?4:3)+(7==this.j?2:0)}function xg(a){var b=Se(this,a);a=Ve(this,a);var c=(b=(0>b?this.g[-b-1]&255:b)<<8)-(a<<=8);Ie(this,c,a,b);this.b-=this.v?4+(this.Y&&6<=this.j?1:0):(this.X?4:3)+(7==this.j?2:0)} +function yg(a){var b=We(this,a);if(b){a=a>>6&7;var c=this.g[a]<<16|this.g[a|1];this.D=this.G=0;b&32768&&(b|=-65536);var d=~~(c/b);-32768<=d&&32767>=d?(this.g[a]=d&65535,this.g[a|1]=c-d*b&65535,this.L=d>>16|d,this.I=d>>16):(this.G=32768,this.L=d>>15|d,this.I=c>>16,-1===b&&65534===this.g[a]&&(this.g[a]=this.g[a|1]=1));this.b-=53}else this.L=this.I=0,this.G=32768,this.D=65536,this.b-=7}function zg(){this.sa(24,0,-9);this.b-=20} +function Ag(){this.w&49152?(this.P|=128,this.sa(4,0,-8)):(this.ta&&1120==this.ia&&this.ta.setData(this.g[0],!0),this.F?Bg(this.F):this.aa());this.b-=7}function Cg(){this.sa(16,0,-9);this.b-=20}var Dg=[0,7,7,10,7,11,9,13];function Eg(a){this.ja=this.b;ye(this,Ue(this,a));this.b=this.ja-Dg[this.v]}var Fg=[0,14,14,17,14,18,16,20];function Gg(a){this.ja=this.b;var b=Ue(this,a);a=a>>6&7;Je(this,this.g[a]);this.g[a]=this.g[7];ye(this,b);this.b=this.ja-Fg[this.v]} +var Hg=[3,9,9,13,10,14,12,16,4,9,9,13,10,14,13,17];function Ig(a){var b=Te(this,a);this.ja=this.b;uf(this,a,b,this.Da);this.b=this.ja-Hg[(this.X?8:0)+this.v]+(7!=this.j||this.v?0:2)}function Jg(a){var b=Se(this,a);tf(this,a,b,65535,this.Da);this.b-=this.v?9+(this.Y&&6<=this.j?1:0):(this.X?5:3)+(7==this.j?2:0)}var Kg=[7,13,13,17,14,18,17,21]; +function Lg(a){var b=We(this,a);a=a>>6&7;b=(b<<16>>16)*(this.g[a]<<16>>16);this.g[a]=b>>16&65535;this.g[a|1]=b&65535;b|=0;this.I=b>>16;this.L=this.I|b;this.G=0;this.D=-32768>b||32767>6;if(this.g[b]=this.g[b]-1&65535)ye(this,this.g[7]-((a&63)<<1)),this.b+=1;this.b-=6}function Sg(a){R(this,a,Te(this,a),Tf);this.b-=this.v?9+(this.Y&&6<=this.j?1:0):(this.X?5:3)+(7==this.j?2:0)}function Tg(a){R(this,a,0,Vf);this.b-=this.v?9:3+(7==this.j?2:0)}function Ug(){this.sa(28,0,-9)} +function Vg(){this.ta&&(this.ta.kd(this.g[7],!0),this.ta.setData(this.g[0],!0));this.i|=8;Ee(this,-2);this.b-=3}function Wg(a){R(this,a,this.g[(a>>6&7)+this.mc],Wf);this.b-=this.v?9:3+(7==this.j?2:0)}function S(a){var b;if(b=this.F)b=this.F,A(b,1)?(D(b,"undefined opcode "+K(b,a),!0,!0),b=Bg(b)):b=!1;b||this.sa(8,0,-9)}function ue(a){Xg[a>>12].call(this,a)}function Yg(a){Zg[a>>6&3].call(this,a)}function $g(a){ah[a>>6&3].call(this,a)}function bh(a){ch[a>>6&3].call(this,a)} +function dh(a){eh[a&15].call(this,a)}function fh(a){gh[a&15].call(this,a)}function hh(a){ih[a>>6&3].call(this,a)}function jh(a){kh[a>>6&3].call(this,a)}function lh(a){mh[a>>6&3].call(this,a)} +var Xg=[function(a){nh[a>>8&15].call(this,a)},Ig,wg,fg,bg,dg,Xf,S,function(a){oh[a>>8&15].call(this,a)},Jg,xg,gg,cg,eg,Sg,S],nh=[function(a){ph[a>>4&15].call(this,a)},sg,pg,hg,ig,ng,jg,lg,Gg,Gg,Yg,$g,bh,S,S,S],Zg=[function(a){uf(this,a,0,this.lb);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){R(this,a,0,Hf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){R(this,a,1,Lf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){R(this,a,1,Jf);this.b-=this.v?9:3+(7==this.j?2:0)}],ah=[function(a){R(this,a,0,Nf); +this.b-=this.v?11:6},function(a){R(this,a,Ae(this)?1:0,xf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){R(this,a,Ae(this)?1:0,Tf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){a=We(this,a);this.lb(a);this.b-=this.v?4:3+(7==this.j?2:0)}],ch=[function(a){R(this,a,0,Rf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){R(this,a,0,Pf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){R(this,a,0,Bf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){R(this,a,0,zf);this.b-=this.v?9:3+(7==this.j?2:0)}],ph= +[function(a){qh[a&15].call(this,a)},S,S,S,Eg,Eg,Eg,Eg,Og,S,dh,fh,Tg,Tg,Tg,Tg],qh=[Ag,Vg,Pg,rg,Cg,Ng,S,S,S,S,S,S,S,S,S,S],eh=[Mg,function(){this.D=0;this.b-=5},function(){this.G=0;this.b-=5},vg,function(){this.L=1;this.b-=5},vg,vg,vg,function(){this.I=0;this.b-=5},vg,vg,vg,vg,vg,vg,vg],gh=[Mg,function(){this.D=65536;this.b-=5},function(){this.G=32768;this.b-=5},Qg,function(){this.L=0;this.b-=5},Qg,Qg,Qg,function(){this.I=32768;this.b-=5},Qg,Qg,Qg,Qg,Qg,Qg,Qg],oh=[qg,og,kg,mg,tg,ug,$f,ag,zg,Ug,hh,jh, +lh,S,S,S],ih=[function(a){tf(this,a,0,255,this.lb);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){Xe(this,a,0,If);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){Xe(this,a,1,Mf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){Xe(this,a,1,Kf);this.b-=this.v?9:3+(7==this.j?2:0)}],kh=[function(a){Xe(this,a,0,Of);this.b-=this.v?11:6},function(a){Xe(this,a,Ae(this)?1:0,yf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){Xe(this,a,Ae(this)?1:0,Uf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){a=Ve(this, +a);this.lb(a<<8);this.b-=this.v?4:3+(7==this.j?2:0)}],mh=[function(a){Xe(this,a,0,Sf);this.b-=this.v?9+(this.Hc&1):3+(7==this.j?2:0)},function(a){Xe(this,a,0,Qf);this.b-=this.v?9:3+(7==this.j?2:0)},function(a){Xe(this,a,0,Cf);this.b-=this.v?9+(this.Hc&1):3+(7==this.j?2:0)},function(a){Xe(this,a,0,Af);this.b-=this.v?9:3+(7==this.j?2:0)}];function ve(a){rh[a>>12].call(this,a)} +var rh=[function(a){sh[a>>8&15].call(this,a)},Ig,wg,fg,bg,dg,Xf,function(a){th[a>>8&15].call(this,a)},function(a){uh[a>>8&15].call(this,a)},Jg,xg,gg,cg,eg,Sg,S],sh=[function(a){vh[a>>4&15].call(this,a)},sg,pg,hg,ig,ng,jg,lg,Gg,Gg,Yg,$g,bh,function(a){wh[a>>6&3].call(this,a)},S,S],wh=[function(a){a=this.g[7]+((a&63)<<1)&65535;var b=this.na(a|this.Ga);ye(this,this.g[5]);this.g[6]=a+2&65535;this.g[5]=b;this.b-=8},function(a){a=Qe(this,a,0);this.Da(a);Je(this,a);this.b-=11},function(a){var b=Le(this); +this.ja=this.b;this.Da(b);Re(this,a,0,b);this.b=this.ja-Kg[this.v]},function(a){uf(this,a,De(this)?65535:0,this.Da);this.b-=this.v?9:3+(7==this.j?2:0)}],vh=[function(a){xh[a&15].call(this,a)},S,S,S,Eg,Eg,Eg,Eg,Og,function(a){!(a&8)||1145>this.ia?S.call(this,a):(this.w&49152||(this.w=this.w&-225|(a&7)<<5,this.i|=1,this.i&=-3),this.b-=5)},dh,fh,Tg,Tg,Tg,Tg],xh=[Ag,Vg,function(){Ke(this);this.i|=this.w&16;this.b-=13},rg,Cg,Ng,Pg,function(a){S.call(this,a)},S,S,S,S,S,S,S,S],th=[Lg,Lg,yg,yg,Yf,Yf,Zf,Zf, +Wg,Wg,S,S,S,S,Rg,Rg],uh=[qg,og,kg,mg,tg,ug,$f,ag,zg,Ug,hh,jh,lh,function(a){1145>this.ia?S.call(this,a):yh[a>>6&3].call(this,a)},S,S],yh=[function(a){S.call(this,a)},function(a){a=Qe(this,a,65536);this.Da(a);Je(this,a);this.b-=11},function(a){var b=Le(this);this.ja=this.b;this.Da(b);Re(this,a,65536,b);this.b=this.ja-Kg[this.v]},function(a){S.call(this,a)}]; +function zh(a){q.call(this,"ROM",a,128);this.ea=this.g=null;this.v=+a.addr;this.b=+a.size;this.w=!1;this.i=a.alias;"string"==typeof this.i&&(this.i=eval(this.i));this.j=a.file;this.B=Ta(this.j);if(this.j){a=this.j;var b=Ua(this.B);"json"!=b&&"hex"!=b&&(a=hb()+"/api/v1/dump?file="+this.j+"&format=bytes&decimal=true");var c=this;fb(a,null,!0,function(a,b,f){f?(c.S("Unable to load ROM resource (error "+f+": "+a+")"),c.j=null):(va(c.pb,a,b),(a=gb(a,b))?(c.g=a.ba,c.ea=a.ea):c.j=null);Ah(c)})}}p(zh,q); +h=zh.prototype;h.za=function(a,b,c,d){this.C=b;this.f=c;this.F=d;Ah(this)};h.Ca=function(){this.ea&&(this.F&&Bh(this.F,this.id,this.v,this.b,this.ea),delete this.ea);return!0};h.Ba=function(){return!0}; +function Ah(a){if(!Ia(a)){if(a.j){if(!a.g||!a.C)return;a.b||(a.b=a.g.length);if(a.g.length!=a.b)Ga(a,"ROM size ("+F(a.g.length,8,!0)+") does not match specified size ("+F(a.b,8,!0)+")");else{var b;a:{b=a.v;if(57344<=b&&b<57344+Rc){var c={},c=(c[b]=[zh.prototype.cg,zh.prototype.lh,null,null,null,a.b>>1],c);if(bc(a.C,a,c)){a.status("Added "+a.b+"-byte ROM at "+E(b));b=a.w=!0;break a}}else if(Xc(a.C,b,a.b,Gd)){for(c=0;c>>f.g;0>>=f.g;0>>a.g;0=b.length){D(a,"invalid block at offset "+Sa(n),4096);break}for(var l=l+2,r=b[l++]&255|(b[l++]&255)<<8,u=b[l++]&255|(b[l++]&255)<<8,m=m+((r&255)+(r>>8)+(u&255)+(u>>8)),t=l,C=r-=6;0=b.length){D(a,"insufficient data for block at offset "+Sa(n),4096); +break}m+=b[l++]&255;if(m&255){D(a,"invalid checksum ("+F(m,2,!0)+") for block at offset "+Sa(n),4096);break}if(C)for(D(a,"loading "+Sa(C)+" bytes at "+Sa(u)+"-"+Sa(u+C),4096);C--;)fd(a.C,u++,b[t++]&255);else u&1?g=!0:null==d&&(d=u),null!=d&&D(a,"starting address: "+Sa(d),4096);k=!0}else l++;else l+=2}if(!k&&(null==c&&(c=e),null!=c)){for(e=0;e=ta.nd&&c<=ta.Xe&&(b=c-(ta.nd-ta.le));b&&(a.preventDefault&&a.preventDefault(),d.Bc(b));return!0},c.onkeypress=function(a){a=a||window.event;if(!a.metaKey){var b=a.which||a.keyCode;a.altKey&&b==ta.ne&&(b=ta.me);d.Bc(b);a.preventDefault&&a.preventDefault()}return!0},c.onpaste=function(a){a.stopPropagation&&a.stopPropagation(); +a.preventDefault&&a.preventDefault();(a=a.clipboardData||window.clipboardData)&&d.Bc(a.getData("Text"))},c.removeAttribute("readonly"),!0}return!1}; +h.za=function(a,b,c,d){this.K=a;this.C=b;this.f=c;this.F=d;var e=this;this.P=od(this.f,this.M?-1:48,4,262144);this.R=ld(this.f,function(){var a;a=-1;e.i.length&&(a=e.i.shift()&255,D(e,"receiveByte("+F(a,2,!0)+")"),e.L&&97<=a&&122>a&&(a-=32),nd(e.f,e.R,1E3/Math.round(e.U/10)));0<=a&&(e.D=a,e.b&128?e.D|=49152:e.b|=128,e.b&64&&md(c,e.P))});this.N=od(this.f,this.M?-1:52,4,262144);this.X=ld(this.f,function(){e.g|=128;e.g&64&&md(c,e.N)});bc(b,this,Ih,this.M?64832+8*(this.M-1)-65392:0);dc(b,this.reset.bind(this)); +y(this)};h.be=function(a){if(!this.j){var b=ee(this.K,"connection");if(b){var c=b.split("->");if(2==c.length){var d=Za(c[0]);if(d!=this.Eb)return;c=Za(c[1]);if(this.j=Ba(c)){var e=this.j.exports;if(e){var f=e.connect;f&&f.call(this.j,this.I);if(this.G=e.receiveData){this.I=a;this.O=e.receiveStatus;this.status("Connected "+this.pb+"."+d+" to "+c);return}}}}this.status("Unable to establish connection: "+b)}}}; +h.Ca=function(a,b){if(!b)if(this.be(this.I),!a)this.reset();else if(!this.restore(a))return!1;return!0};h.Ba=function(a){return a?this.save():!0};h.reset=function(){Jh(this)};h.save=function(){var a=new G(this);a.set(0,[this.D,this.b,this.g,this.i]);return a.data()};h.restore=function(a){return Jh(this,a[0])};function Jh(a,b){b||(b=[0,8192,128,a.i]);b=ja(b);a.D=b.next().value;a.b=b.next().value;a.g=b.next().value;a.i=b.next().value;return!0} +h.Bc=function(a){if("number"==typeof a)this.i.push(a);else if("string"==typeof a)for(var b=0,c,d=0;d":String.fromCharCode(a);var c=b.length;32>a&&1==c&&(c=0);9==a&&(a=this.W||8,c=a-this.B%a,this.W&&(b=Ya("",c)));this.V&&!this.B&&c&&(b=String.fromCharCode(this.V)+b);this.v.value+=b;this.v.scrollTop=this.v.scrollHeight;this.B+=c}}else if(null!=this.w){if(10== +a||1024<=this.w.length)this.u(this.w),this.w="";10!=a&&(this.w+=String.fromCharCode(a))}nd(this.f,this.X,1E3/Math.round(this.Y/10));this.g&=-129};var Hh="buffer",Kh={},Ih=(Kh[65392]=[null,null,Gh.prototype.Qf,Gh.prototype.Yg,"RCSR"],Kh[65394]=[null,null,Gh.prototype.Pf,Gh.prototype.Xg,"RBUF"],Kh[65396]=[null,null,Gh.prototype.vg,Gh.prototype.Eh,"XCSR"],Kh[65398]=[null,null,Gh.prototype.ug,Gh.prototype.Dh,"XBUF"],Kh); +yb(function(){for(var a=x(document,w,"serial"),b=0;b'+b+"");a.innerHTML=b}},!0;case "descTape":return this.H[b]=c,!0;case "readTape":e=Oh;case "loadTape":return e||(e=Ph),this.H[b]=c,c.onclick= +function(){var a=d.H.listTapes;a&&Qh(d,a.options[a.selectedIndex].text,a.value,e)},!0;case "mountTape":if(!this.N){c.parentNode.removeChild(c);break}this.H[b]=c;c.addEventListener("change",function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length});c.onsubmit=function(a){if(a=a.currentTarget[1].files[0]){var b=a.name;Qh(d,Ta(b,!0),b,Ph,a)}return!1};return!0;case Rh:return this.H[b]=c,!0}return!1}; +h.za=function(a,b,c,d){this.K=a;this.C=b;this.f=c;this.F=d;this.I=Sh(a);var e=this;if(a=Lh(this,ee(this.K,"autoMount")))for(var f in a)"PTR"==f&&(this.M[f]=a[f]);this.G=od(this.f,56,4,4096);this.P=ld(this.f,function(){1==(e.b&32769)&&!(e.b&128)&&e.Bc.indexOf("/api/v1/dump")&&(e=Ua(c),f="json"==e||"gz"==e?encodeURI(c):hb()+"/api/v1/dump?path="+encodeURIComponent(c)+"&format=json");return!!fb(f,null,!0,function(e,f,g){var k=0>g&&!!a.K&&!a.K.A.Z;g?a.S('Unable to load tape "'+b+'" (error '+g+": "+e+")",k):(va(a.pb,e,f),(e=gb(e,f))&&ci(a,b,c,d,e.ba,e.xa, +e.wa));a.A.jb=!1;a.g&&(a.g--,a.g||y(a));$h(a)})}function Vh(a,b,c,d){if((a=a.H.listTapes)&&a.options){for(var e=0;e>2;var f=e=0,b=new DataView(b,0,d);a.b=Array(a.ca);for(d=0;dc.indexOf("/api/v1/dump")&&(b=Ua(c),"json"==b||"gz"==b?f=encodeURI(c):(d="path",e="&mbhd=10",!c.indexOf("http:")||!c.indexOf("ftp:")||0<="dsk ima img 360 720 12 144".split(" ").indexOf(b)?(d="disk",e="&mbhd=0"):Va(c,"/")&&(d="dir"),f=hb()+"/api/v1/dump?"+d+"="+encodeURIComponent(c)+(a.dd?"":e)+"&format=json"));return!!fb(f, +null,!0,function(b,c,d){ki(a,b,c,d)})} +function ki(a,b,c,d){var e=null,f=0>d&&!!a.K&&!a.K.A.Z;a.j=!1;if(d)a.controller.S('Unable to load disk "'+a.Va+'" (error '+d+": "+b+")",f);else{va(a.controller.pb,b,c);try{if(0g&&0c.indexOf("0x")&&'["'!=c.substr(0,2)?JSON.parse(c.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+ +c+")");if(k.length)if(1==k.length)v(k[0]);else{a.ca=k.length;a.ma=k[0].length;a.ga=k[0][0].length;var l=k[0][0][0];a.ya=l&&l.length||512;for(d=c=0;d>2,n=l.pattern;void 0===n&&(n=l.pattern=0);var r=l.data;if(void 0===r){var u=l.bytes;if(void 0!==u&&u.length){for(var t=m<<2,C=u.length;C>2,e=Array(d),f=0;f>2,c=(d>((b&3)<<3)&255;return c};h.write=function(a,b,c){if(this.j)return!1;if(b>2;b=(b&3)<<3;for(var g=d.length;g<=f;g++)d[g]=e;a.Ja?f=a.Sa+a.Ja&&(a.Ja+=f-(a.Sa+a.Ja)+1):(a.Sa=f,a.Ja=1);d[f]=d[f]&~(255<g)break;e|=g<=this.b.length||l>=this.b[k].length||m>=this.b[k][l].length){c="sector (CHS="+k+":"+l+":"+m+") out of range ("+ +b+" changes applied)";b=-1;break}if(this.j){c="unable to modify write-protected disk";b=-1;break}e=g[f++];f=g[f++];g=e+f.length;if(k=this.b[k][l][m]){for(l=k.data.length;lb&&-2!=b&&this.controller.S("Unable to restore disk '"+this.Va+": "+c);return b}; +h.toJSON=function(){var a;a=0;for(var b;b=mi(this,a++);)oi(b);a=JSON.stringify(this.b,function(a,b){if("file"!=a)return b});a=a.replace(/,"length":512/gm,"").replace(/,"pattern":0/gm,"");a=a.replace(/"(sector|length|data|pattern)":/gm,"$1:");a=a.replace(/,"[^"]*":([0-9]+|true|false)/gm,"");a=a.replace(/(sector|length|data|pattern):/gm,'"$1":');return a=a.replace(/([\]}]),/gm,"$1,\n")}; +function oi(a){var b=a.data,c=b.length;if(c<<2==a.length){for(var d=c-1,e=b[d],f=0;d--&&b[d]===e;)f++;f++&&(b.length=c-f,a.pattern=e)}}var gi=0;function Ii(a,b,c,d,e,f){q.call(this,a,b,c);this.L=Ki(this,b.autoMount);this.G=0;this.O=d;this.P=e;this.R=f;this.N=d.rd;this.g=Array(this.N);this.M=!mb("Mobi")&&window&&"FileReader"in window;this.v=[];this.Lb=null;this.exports={selectDrive:this.yg}}p(Ii,q); +function Ki(a,b){if(b&&"string"==typeof b)try{b=eval("("+b+")")}catch(c){v(a.type+" auto-mount error: "+c.message+" ("+b+")"),b=null}return b||{}}h=Ii.prototype; +h.ua=function(a,b,c){var d=this;switch(b){case "listDisks":return this.H[b]=c,c.onchange=function(){var a=d.H.descDisk,b=c.options&&c.options[c.selectedIndex];if(a&&b){var g={};if(b=b.getAttribute("data-value"))try{g=eval("("+b+")")}catch(k){v(d.type+" option error: "+k.message)}b=g.desc;void 0===b&&(b="");g=g.href;void 0!==g&&(b=''+b+"");a.innerHTML=b}},!0;case "descDisk":case "listDrives":return this.H[b]=c,c.onchange=function(){var a=La(c.value,10);null!=a&& +Li(d,a)},!0;case "loadDisk":return this.H[b]=c,c.onclick=function(){var a=d.H.listDisks;a&&a.options&&Mi(d,a.options[a.selectedIndex].text,a.value)},!0;case "bootDisk":return this.H[b]=c,c.onclick=function(){var a,b=d.H.listDrives,b=b&&La(b.value,10);null==b||0>b||b>=d.g.length||!(a=d.g[b])?d.S("Unable to boot the selected drive"):a.ra?(xe(d.f,0,!0),(a=d.hc(a,0,0,0,512,0,2))&&d.S("Unable to read the boot sector ("+a+")")):d.S("Load a disk into the drive first")},!0;case "saveDisk":if(!this.M){c.parentNode.removeChild(c); +break}this.H[b]=c;c.onclick=function(){var a=d.H.listDrives;if(a&&a.options&&d.g)if(a=d.g[La(a.value,10)||0])if(a=a.ra){var b;b="";for(var c=0,k;k=mi(a,c++);)for(var l=0,m=k.length;lg||9e||e>=a.g.length)a.S("Unable to load the selected drive");else if(c)if(c==Pi)a.S('Use "Choose File" and "Mount" to select and load a local disk.');else{if(c==Qi){c=window.prompt("Enter the URL of a remote disk image.","")||"";if(!c)return;b=Ta(c);a.status("Attempting to load "+c+' as "'+b+'"')}Wi(a,e,b,c,!1,d)}else Si(a,e)} +function Wi(a,b,c,d,e,f){var g=-1,k=a.g[b];k.Ma.toLowerCase()!=d.toLowerCase()&&(g++,Si(a,b,!0),k.cd?a.S(a.type+" busy"):(k.cd=!0,e&&(k.bd=!0,a.G++,A(a)&&D(a,"auto-loading disk: "+c)),k.Hb=!!f,ji(new fi(a,k,"preload"),c,d,f,a.Vd)&&g++));return g} +h.Vd=function(a,b,c,d,e){a.cd=!1;b&&(b.ca>a.ca||b.ma>a.ma)&&(this.S('Disk "'+c+'" too large for drive '+(this.type.substr(0,2)+a.zc)),b=null);b?(a.ra=b,a.Va=c,a.Ma=d,Xi(this,c,d,b),this.S('Loaded disk "'+c+'" in drive '+(this.type.substr(0,2)+a.zc),a.bd||e),this.K&&oe(this.K)):a.Hb=!1;a.bd&&(a.bd=!1,--this.G||y(this));Li(this,a.zc)}; +function Ni(a,b,c,d){if((a=a.H.listDisks)&&a.options){for(var e=0;e=a.ca){m=U.rc;break}n=a.seek(b,c,d+1);if(!n){m=U.Jd;break}r=0;++d>=a.ga&&(d=0,++c>=a.ma&&(c=0,++b))}var u,t;if(0>(u=a.read(n,r++))||0>(t=a.read(n,r++))){m=U.sc;break}if(!k&&(xc(this.C,Me(this.f,f),u|t<<8),kd(this.C))){m=U.Vb;break}r>=a.ya&&(n=null);f+=g;e--}return l?l(m,b,c,d,e,f):m}; +h.Fc=function(a,b,c,d,e,f,g,k,l){var m=0;a=a.ra;var n=null,r;a||(m=U.Ad,e=0);for(;e;){var u=zc(this.C,Me(this.f,f));if(kd(this.C)){m=U.Vb;break}if(!n){if(b>=a.ca){m=U.rc;break}n=a.seek(b,c,d+1,!0);if(!n){m=U.Jd;break}r=0;++d>=a.ga&&(d=0,++c>=a.ma&&(c=0,++b))}if(k){var t,C;if(0>(t=a.read(n,r++))||0>(C=a.read(n,r++))){m=U.sc;break}if(u!=(t|C<<8)){m=U.Od;break}}else if(!a.write(n,r++,u&255)||!a.write(n,r++,u>>8)){m=U.sc;break}r>=a.ya&&(n=null);f+=g;e--}return l?l(m,b,c,d,e,f):m}; +h.De=function(a,b,c,d,e,f){this.w=f&65535;this.b=this.b&~T.Cb|f>>16-T.ka.Cb&T.Cb;this.B=65536-e&65535;this.j=this.j&~aj.Xc|d&aj.Xc;this.i|=a;bj(this);return!0};function bj(a){a.b&=~T.Ub;a.i&&(a.i|=U.qe,a.b|=T.Ub,a.i&U.Oc&&(a.b|=T.Oc),A(a)&&D(a,a.type+": ERROR: "+E(a.i)))}h.Vf=function(){return this.I};h.dh=function(){};h.Wf=function(){return this.i};h.eh=function(){};h.Sf=function(){return this.b&T.Wc}; +h.$g=function(a){this.b=this.b&~T.qb|a&T.qb;if(this.b&T.vd){a=!0;var b,c,d="",e=(this.j&aj.nb)>>aj.ka.nb,f=this.g[e],g,k,l,m,n,r;this.b&=~(T.Xa|T.Yc);this.i&=~U.Oe;switch(c=this.b&T.Pa){case cj.ke:A(this)&&D(this,this.type+": CRESET("+e+")",!0);this.i=this.j=0;this.b=T.Xa;break;case cj.ze:d="RCHK";case cj.Be:d||(d="READ"),b=this.hc;case cj.Zc:d||(d="WCHK");case cj.We:d||(d="WRITE");b||(b=this.Fc);g=(this.j&aj.Tb)>>aj.ka.Tb;k=(this.j&aj.Pc)>>aj.ka.Pc;l=this.j&aj.Xc;m=65536-this.B&65535;n=(this.b&T.Cb)<< +16-T.ka.Cb|this.w;r=this.b&T.xe?0:2;A(this)&&D(this,this.type+": "+d+"("+g+":"+k+":"+l+") "+E(n)+"--"+E(n+(m<<1)),!0,!0);if(g>=f.ca){this.i|=U.rc;break}if(l>=f.ga){this.i|=U.sc;break}a=b.call(this,f,g,k,l,m,n,r,c>=cj.Zc,this.De.bind(this));break;case cj.xc:g=(this.j&aj.Tb)>>aj.ka.Tb;A(this)&&D(this,this.type+": SEEK("+g+")",!0);g(n=a.read(k,m++))||0>(r=a.read(k,m++))){g=fj.Ya;break}xc(this.C,Me(this.f,f),n|r<<8);if(kd(this.C)){g=fj.Vb;break}f+=2;e--;if(m>=a.ya&&(k=null,++d>=a.ga&&(d=0,++c>=a.ma&&(c=0,++b>=a.ca)))){g=fj.Ya;break}}return l?l(g,b,c,d,e,f):g}; +h.Fc=function(a,b,c,d,e,f,g,k,l){g=0;a=a.ra;k=null;var m;a||(g=fj.Ya,e=0);for(;e;){var n=zc(this.C,Me(this.f,f));if(kd(this.C)){g=fj.Vb;break}f+=2;e--;if(!k){k=a.seek(b,c,d+1,!0);if(!k){g=fj.Ya;break}m=0}if(!a.write(k,m++,n&255)||!a.write(k,m++,n>>8)){g=fj.Ya;break}if(m>=a.ya&&(k=null,++d>=a.ga&&(d=0,++c>=a.ma&&(c=0,++b>=a.ca)))){g=fj.Ya;break}}return l?l(g,b,c,d,e,f):g}; +h.Ie=function(a,b,c,d,e,f){this.D=f&65535;this.b=this.b&~V.Wa|f>>16-V.ka.Wa&V.Wa;this.w=f>>16&gj.Vc;this.j=this.i=b<>V.ka.Wa;if(!(this.b&V.Xa)){a=!0;var b,c="",d=this.g[(this.b&V.nb)>>V.ka.nb],e=d.ra,f,g,k;this.b&=~V.Bb;switch(this.b&V.Pa){case ij.Se:this.B&jj.wd&&(this.b&=V.Bb|V.Pa|V.Wa);this.B=d.status|this.j&hj.wc|(e&&512==e.ca?jj.ue:0);break;case ij.xc:(this.i&hj.te)==hj.Pe&&(b=this.i&hj.Wb,c=(this.i&hj.Re)<<2,this.j=this.i&hj.Qe?this.j+b:this.j-b,this.i=this.j=this.j&hj.Wb|c);break;case ij.Ce:this.B=this.j;break;case ij.Ae:c="READ",b=this.hc; +case ij.Ve:c||(c="WRITE"),b||(b=this.Fc),f=this.i>>hj.ka.Wb,g=this.i&hj.wc?1:0,k=this.i&hj.Hd,!e||f>=e.ca||k>=e.ga?this.b=this.b|fj.Ya|V.Ub:(a=65536-this.B&65535,e=(this.w&gj.Vc)<<16|this.D,A(this)&&D(this,this.type+": "+c+"("+f+":"+g+":"+k+") "+E(e)+"--"+E(e+(a<<1)),!0,!0),a=b.call(this,d,f,g,k,a,e,2,!1,this.Ie.bind(this)))}a&&(this.b=this.b|V.Bb|V.Xa,this.b&V.Rc&&md(this.f,this.Lb))}};h.Yf=function(){return this.D};h.gh=function(a){this.D=a&kj.qb};h.ag=function(){return this.i}; +h.jh=function(a){this.i=a};h.bg=function(){return this.B};h.kh=function(a){this.B=a};h.Zf=function(){return this.w};h.hh=function(a){this.w=a&gj.Vc;this.b=this.b&~V.Wa|(this.w&3)<a.v&&a.j.length&&(a.v=0);if(0>a.v||b!=a.j[a.v])a.j.splice(0,0,b),a.v=0;a.v--}else a.O?b="end":b=a.j[a.v+1];a=[];if(b){b=b.replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var g=b.charAt(f);if('"'==g||"'"==g)e?g==e&&(e=null):e=g;else if(g==d&&!e||!g)a.push(Za(b.substring(c,f))),c=f+1}}return a} +function oj(a,b,c){for(c=c||-1;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(d){case "*":d=f*e;break;case "/":if(!e)return!1;d=f/e;break;case "%":if(!e)return!1;d=f%e;break;case "+":d=f+e;break;case "-":d=f-e;break;case "<<":d=f<>":d=f>>e;break;case ">>>":d=f>>>e;break;case "<":d=f":d=f>e?1:0;break;case ">=":d=f>=e?1:0;break;case "==":d=f==e?1:0;break;case "!=":d=f!=e?1:0;break;case "&":d=f&e;break; +case "^":d=f^e;break;case "|":d=f|e;break;case "&&":d=f&&e?1:0;break;case "||":d=f||e?1:0;break;default:return!1}a.push(d|0)}return!0} +function pj(a,b,c){var d;if(b){b=qj(a,b);for(var e=0,f=!1,g=b,k=[],l=[],m=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=8;d=F(c,0,!0)+" "+c+". "+E(c,0,!0)+" "+("0b"+g);32<=c&&127>c&&(d+=" '"+String.fromCharCode(c)+"'")}a.u((null!=b?b+": ":"")+d);return e} +function uj(a,b){if(b)return tj(a,b,a.U[b]);var c=0;for(b in a.U)tj(a,b,a.U[b]),c++;return 0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; +function vj(a){mj.call(this,a);this.Ea=!1;this.ha=!0;this.G=W();this.va=W();this.N=W();this.B=[];this.g=this.L=this.D=[];wj(this);this.P=this.Y=0;this.i=[];this.oa=void 0;xj(this);this.F=this;this.ia={};this.fa=this.Sd=0;this.R=null;this.M=[];yj(this,a.messages);this.ta=a.commands;this.Ha=zj;this.W=[];this.I=0;this.Ia=this.pa=null;this.w=this.Ga=this.Fa=this.X=this.ja=0;this.b=this.V=null;var b=this;window?void 0===window[w]&&(window[w]=function(a){return je(b,a)}):void 0===global[w]&&(global[w]= +function(a){return je(b,a)})}p(vj,mj);function Aj(a){a=a&&a.J;null==a&&(a=-1);return a}function W(a,b,c){return{J:void 0===a?null:a,Ka:void 0===b?!1:b,Ra:!1,Aa:c}}h=vj.prototype;h.kd=function(a,b){a.J=b;a.Ra=!1;a.Aa=void 0;return a};function Bj(a){return[a.J,a.Ka,a.Aa,a.Ra,a.Cc]}function Cj(a,b){var c=W(b[0],b[1],b[2]);c.Ra=b[3];b[4]&&(c.Pd=nj(a,c.Cc=b[4]));return c} +h.za=function(a,b,c,d){this.C=b;this.K=a;this.f=c;this.b=a.i;(a=ee(a,"messages"))&&yj(this,a);1140>this.f.ia&&(this.W=this.W.concat(Dj));1145>this.f.ia&&(this.W=this.W.concat(Ej));qd(this,16,function(a){a:{var b=d.C.b,c=a[0],e=a=0,l=b.length;if(c){a=Aj(Fj(d,c));if(-1===a){d.u("invalid address: "+c);break a}e=a>>>d.C.g;l=1}d.u("blockid physical blockaddr used size type");d.u("-------- --------- --------- ------ ------ ----");for(var c=-1,m=0;l--;){var n=b[e];n.type==c?m++||d.u("..."): +(c=n.type,m=cd[c],n&&d.u(F(n.id,8)+" %"+F(e<d&&(d+=b.length);0>d&&(d=0);for(var e=b.length;db||7a?"R"+a:6==a?"SP":"PC"} +h.Zd=function(a){var b;if(0<=a)if(8>a)b=this.f.g[a];else if(16>a)b=this.f.pa[a-8];else if(20>a)b=this.f.W[a-16];else{var c=this.f,d=this.b;switch(a){case Lj:b=Ad(this.f);break;case Mj:b=c.$a;break;case Nj:b=c.P;break;case Oj:b=c.va&65280;break;case Pj:b=td(c);break;case Qj:b=wd(c);break;case Rj:b=xd(c);break;case Sj:b=c.V;break;case Tj:d&&(b=d.da);break;case Uj:d&&(b=d.Ta);break;case Vj:d&&Nc(d)&&(b=d.Ua)}}return b}; +h.message=function(a,b){b&&(a+=" @"+Ij(this,W(this.f.O&65535)));if(!this.R||a!=this.R)if(this.R=a,this.fa&1073741824)this.M.push(a);else{var c;if(this.fa&-2147483648&&this.f&&(c=this.f.A.T)||Ja(this,!0))this.aa(),c&&(a+=" (cpu halted)");this.u(a);this.f&&(a=this.f,pe(a),a.vb=0,a.K&&I(a.K,void 0))}}; +function xj(a){var b;if(!vf(a))a.i&&a.i.length&&a.u("instruction history buffer freed"),a.P=0,a.i=[];else if(!a.i||!a.i.length){a.i=Array(Wj);for(b=0;b>8;a.u("trapped to "+K(a,c&255,1)+" ("+(0>d?Mb[-d]:K(a,d))+")")}a.G=W(a.f.g[7]);b&&1!=a.I?ak(a):bk(a)}}function Yj(a,b){var c;(c=!a.f||!Ia(a.f))||(c=a.f,c.A.Z?c=!0:(c.u(c.toString()+" not powered"),c=!1),c=!c);return c||a.f.A.T?(b||a.u("cpu busy or unavailable, command ignored"),!1):!Ha(a.f)}h.Ca=function(a,b){return!b&&(this.reset(!0),a)?this.restore(a):!0}; +h.Ba=function(a,b){b&&this.u(a?"suspending":"shutting down");return a?this.save():!0};h.reset=function(a){xj(this);this.X=0;this.R=null;this.w=0;this.G=W(this.f.g[7]);this.A.T=!1;ck(this);a||he(this)};h.save=function(){var a=new G(this);a.set(0,Bj(this.G));a.set(1,Bj(this.N));a.set(2,[this.j,this.O,this.fa]);a.set(3,this.B);return a.data()}; +h.restore=function(a){var b=0;void 0!==a[2]&&(this.G=Cj(this,a[b++]),this.N=Cj(this,a[b++]),this.j=a[b][0],"string"==typeof this.j&&(this.j=[this.j]),this.O=a[b][1],this.fa|=a[b][2]);a[3]&&(this.B=a[3]);return!0};h.start=function(a,b){this.I||this.u("running");this.A.T=!0;this.Fa=a;this.Ga=b}; +h.stop=function(a,b){if(this.A.T){this.A.T=!1;this.w=b-this.Ga;if(!this.I){b="stopped";if(this.w){a-=this.Fa;var c=0d&&(d=Ac(a.f,b)),65535!=(d&65535)&&(a.kd(a.i[a.P],b),++a.P==a.i.length&&(a.P=0)));return!1}function Bg(a){var b=a.f;if(b.A.T)throw ye(b,a.f.O&65535),a.aa(),-1;return!1}function Zd(a,b,c){dk(a,b,c||1,a.L)&&a.aa(!1)}function $d(a,b,c){dk(a,b,c||1,a.D)&&a.aa(!1)} +function wj(a){var b,c,d;a.g=["bp"];if(a.L)for(b=1;b>>c.g],!1)):Pe(a.f,!1);a.L=["br"];if(a.D)for(b=1;b>>c.g],!0)):Pe(a.f,!0);a.D=["bw"];a.ja=0;a.Y=0} +h.wb=function(a,b,c){var d=!0;c||ek(this,a,b,!1,!0);if(a!=this.g){var e=Aj(b);if(-1===e)this.u("invalid address: "+Ij(this,b)),d=!1;else{var f=a==this.D;65535>>g.g].wb(e&g.i,f)}else e=this.f,(f?e.gc++:e.fc++)||we(e)}}d&&(a.push(b),c?b.Ra=!0:(fk(this,a,a.length-1,"set"),xj(this)));return d}; +function ek(a,b,c,d,e){var f=!1;c=Aj(c);for(var g=1;g>>d.g],b)):Pe(a.f,b));k.Ra||xj(a);break}}return f}function gk(a,b){for(var c=1;c>23)&65535,z=K(t,u);else if(B==mk)u=u.J-((f&63)<<1)&65535,z=K(t,u);else if(B==nk)z=K(t,f&7,1);else if(B==ok)z=K(t,f&63,1);else if(B==pk)z=K(t,f&255,1);else if(B=f&C,C&qk&&(B>>=6,C>>=6),C&Y){var C=null,H=B& +rk;switch(B&sk){case 0:z=Kj(H);break;case 8:z="@"+Kj(H);C=tk(t,t.f.g[H]);break;case 16:7>H?z="("+Kj(H)+")+":(B=t.Oa(u,2),z="#"+K(t,B,0,!0));break;case 24:7>H?z="@("+Kj(H)+")+":(B=t.Oa(u,2),z="@#"+K(t,B,0,!0),C=tk(t,B));break;case 32:z="-("+Kj(H)+")";break;case 40:z="@-("+Kj(H)+")";break;case 48:B=t.Oa(u,2);z=K(t,B,0,!0)+"("+Kj(H)+")";7==H&&(z=K(t,B=B+u.J&65535),C=tk(t,B));break;case 56:B=t.Oa(u,2),z="@"+K(t,B)+"("+Kj(H)+")",7==H&&(z="@"+K(t,B=B+u.J&65535),C=tk(t,Ac(t.f,B)))}C&&(z=[z,C])}t=z;if(!t|| +!t.length){k="INVALID";break}"string"!=typeof t&&(m=t[1],t=t[0]);0=a.f.ob&&b=c.B&&(b=c.Na[b&jd])&&(a=b[4]);return a}function uk(a,b){switch(b){case "N":a=De(a.f);break;case "Z":a=Ce(a.f);break;case "V":a=Be(a.f);break;case "C":a=Ae(a.f);break;default:a=0}return b.charAt(0)+(a?"1":"0")+" "} +function Z(a,b){var c="",d=a.f;if(8>b)c=Kj(b),c+="="+K(a,d.g[b]);else if(13>b)c="A"+(b-8)+"="+K(a,d.pa[b-8]);else if(16<=b&&20>b)c="S"+(b-16)+"="+K(a,d.W[b-16]);else switch(b){case Lj:c="PS="+K(a,Ad(d));break;case Mj:c="PI="+K(a,d.$a);break;case Nj:c="ER="+K(a,d.P);break;case Oj:c="SL="+K(a,d.va&65280);break;case Pj:c="M0="+K(a,td(d));break;case Qj:c="M1="+K(a,wd(d));break;case Rj:c="M2="+K(a,xd(d));break;case Sj:c="M3="+K(a,d.V);break;case Tj:a.b&&(c="AR="+K(a,a.b.da,3));break;case Uj:a.b&&(c="DR="+ +K(a,a.b.Ta));break;case Vj:a.b&&Nc(a.b)&&(c="SR="+K(a,a.b.Ua,3))}c&&(c+=" ");return c}function vk(a,b){var c,d="";for(c=0;6>c;c++)d+=Z(a,c);d=d+"\n"+(Z(a,6)+Z(a,7));d+=Z(a,Lj)+Z(a,Mj)+Z(a,Oj);d+=uk(a,"T")+uk(a,"N")+uk(a,"Z")+uk(a,"V")+uk(a,"C");b&&(b=d,c=""+(Z(a,Pj)+Z(a,Qj)),c+=Z(a,Rj)+Z(a,Sj)+Z(a,Nj),c=c+"\n"+(Z(a,Vj)+Z(a,Tj)+Z(a,Uj)),d=b+("\n"+c));return d}h.Td=function(a,b){return a[0]>b[0]?1:a[0]>>0,g],r=ab(n,l,a.Td);0>r&&n.splice(-(r+1),0,l)}m&&(k.a=m.replace(/''/g,'"'))}a.B.push({Dj:b,J:c,ef:d,ea:e,Qd:f})}function wk(a,b,c){var d=[],e=Aj(b)>>>0;for(b=0;b>>0,k=f.ef;if(e>=g&&eb)){e.g[b]= +g&65535;break}a.u("unknown register: "+f);return}I(a.K);a.u("updated registers:")}}a.u(vk(a,d));c&&(a.G=W(e.g[7]),bk(a,Ij(a,a.G)))}}function Ak(a,b){b=Za(b);var c=b.match(/^(['"])(.*?)\1$/);c?1k[0].indexOf("+"))){var m=k[0]+":";k[2]&&(m+=" "+k[2]);a.u(m)}k[3]&&(g=k[3],f=null);f=ik(a,b,g,f);a.u(f);a.G=b;e-=b.J-l;c++}}} +function hk(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.u(Zj+b):(a.O&&(a.u("ended assemble at "+Ij(a,a.N)),a.G=a.N,a.O=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.R=null;if(Ia(a)&&0n||"z"Na.length&&(a.u("note: only "+Na.length+" available"),wa=Na.length);Ca-=wa;0>Ca&&(null==Na[Na.length-1].J?(wa=Ca+wa,Ca=0):Ca+=Na.length);var af=[];"call"==ti&&(Bc=1E5,af=["CALL"]);for(void 0!==si&&a.u(wa+" instructions earlier:");0=Na.length&&(Ca=0);a.oa=wa;vi++;Bc--}}vi||(a.u("no "+ui+"history available"),a.oa=void 0)}else{var ia=Fj(a,Ma);if(ia)if("da"==bb){var bf=ia.Ka||65535M.length?(2qb&&(qb=0);65536ff?String.fromCharCode(ff):"."),Qd=Qd>>8}sb&&(sb+="\n");sb=cf?sb+(tb+","):sb+(Ma+": "+tb+(Pd?"":" "+ef))}sb&&a.u(sb);a.va=ia;a.Aa=dl}}}}break;case "e":if("else"== +g[0])break;var Wb,gf,hf,jf,kf=g[0],lf=g[1];"eb"==kf?(Wb=1,gf=255,hf=a.sd,jf=a.td):"e"==kf||"ew"==kf?(Wb=2,gf=65535,hf=a.Oa,jf=a.se):lf=null;if(null==lf)a.u("edit memory commands:"),a.u("\teb [a] [...] edit bytes at address a"),a.u("\tew [a] [...] edit words at address a");else{var Rd=Fj(a,lf);if(Rd)for(var Sd=2;Sdof;){for(var ub=null,hl=256;65536>Hc.J>>>0;){pf.J=a.Oa(Hc,2);if(null==Hc.J||!hl--)break;if(!(pf.J&1)){for(var il=a,Td=pf,Ai=null,Ic=Td.J,Bi=Ic,qf=1;6>=qf&&Ic;qf++){if(2> ";yb(function(){for(var a=x(document,w,"debugger"),b=0;b\nLicense: GPL version 3 or later ");this.u("Portions adapted from the PDP-11/70 Emulator by Paul Nankervis ");for(b=0;bIk){if(Jk(d,this.G)){this.v=new G(this,"1.33.0",Sk);Jk(this.v)&&(Tk(this,d),a=Uk,Vk(this.v));this.v.set(Pk,eb());Wk(this.v);var e=this.b&&!this.D;if(a==Qk||za("Click OK to restore the previous "+Hb+" machine state, or CANCEL to reset the machine.")){if(c=Ok(d)){var f=d.get("code"),g=d.get("data");f&&("ok"==f?Jk(d,g):("error"==f&&"no machine state"!= +g?(this.S("Error: "+g),"unable to verify user"==g&&(lb(Xk,""),this.g=null)):this.u(f+": "+g),Vk(d),Jk(d)?(c=Ok(d),e=!0):c=!1))}e&&Mk(this,c?d:null)}else a==Uk&&d.clear()}else Mk(this);delete this.G;delete this.B}e=Aa(this.id);for(f=0;fa[1];a=a[2];this.P=!0;this.A.Z=!0;var d=this.H.power;d&&(d.textContent="Shutdown");this.f&&(Yk(this,this.f,b,c,a),I(this,-2),this.f.qa());this.N&&(Tk(this,b),b.clear());!c&&this.v&&(this.v.clear(),delete this.v);this.j=0}; +function Tk(a,b){if(za("There may be a problem with your "+Hb+" machine.\n\nTo help us diagnose it, click OK to send this "+Hb+" machine state to http://www.pcjs.org.")){var c=a.V;a=a.g||"";b=b.toString();var d={};d.app=Hb;d.ver="1.33.0";d.url=c;d.user=a;d.type="bug";d.data=b;fb("http://www.pcjs.org/api/v1/report",d,!0)}} +function Ck(a,b,c){var d,e="none";if(a.j)return null;a.j--;var f=new G(a,"1.33.0"),g=new G(a,"1.33.0",Nk),k=eb();g.set(Pk,k);f.set(Pk,k);f.set(Zk,"1.33.0");f.set($k,window?window.location.href:null);f.set(cl,window?window.navigator.userAgent:"");a.f&&a.f.Ba&&(c&&(b&&(a.f.A.qa=a.f.A.T),a.f.aa()),d=a.f.Ba(b,c),"object"===typeof d&&f.set(a.f.id,d),c&&(a.f.A.Z=!1,!1===d&&(e=null)));for(var k=Aa(a.id),l=0;l=d||30<=(c.Kc+=d))&&(e.textContent=c.A.T?c.rb.toFixed(2)+"Mhz":"Stopped",c.Kc=0)}if(a.i&&(a=a.i,b=b||0,a.v)){c=a.f.A.T;d=!!(a.f.i&8);if(0>=b||60<=(a.j+=b)){for(e=0;eb?a.da=a.f.g[7]:0f.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(f=window.location.pathname+f),d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(f?' url="'+f+'"':"")));e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1PDPjs$2"), +a=a.replace(/().*?(<\/xsl:variable>)/,"$1pdp11$2"));f=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(f=new window.ActiveXObject("Microsoft.XMLDOM"),f.async=!1,f.loadXML(a)):f=(new window.DOMParser).parseFromString(a,"text/xml")}catch(n){f=null,a=n.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");fb(e,null,!0,function(f,g,k){if(k||!g)c(a,"unable to resolve XML reference: "+d[0]+" ("+k+")");else{if(f=d[3])if(k=g.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=k[0],m,n=/( [a-z]+=)(['"])(.*?)\2/g;m=n.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);k[0]!=l&&(g=g.replace(k[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}g=g.replace(/<\?xml[^>]*>[\r\n]*/, +"");a=a.replace(d[0],g);tl(a,b,c)}})}else c(a,null)} +function ul(a,b,c,d){function e(a){if(void 0===k){var b=g&&x(g,"machine-warning");k=b&&b[0]||g}k&&(k.innerHTML=Wa(a))}function f(a){e("Error: "+a);l&&(--ql||Cb(!0));l=!1}var g,k,l=!0;ql++;xa[a]={};try{if(g=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";r.styleSheet?r.styleSheet.cssText=m:r.appendChild(document.createTextNode(m));n.appendChild(r)}c|| +(c="/versions/pdpjs/1.33.0/components.xsl");m=function(d,k){k?rl(c,null,null,!1,e,function(d,l){l?(va(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window?(l=k.transformNode(l))?(g.outerHTML=l,--ql||Cb(!0)):f("transformNodeToObject failed"):document.implementation&&document.implementation.createDocument?(d=new XSLTProcessor,d.importStylesheet(l),(l=d.transformToFragment(k,document))?g.parentNode?(g.parentNode.replaceChild(l,g),--ql||Cb(!0)):f("invalid machine element: "+ +a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser")):f(d)}):f(d)};"<"!=b.charAt(0)?rl(b,a,d,!0,e,m):sl(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(u){f(u.message)}return l}window.embedPDP11=function(a,b,c,d){Cb(!1);return ul(a,b,c,d)};window.findMachineComponent=function(a,b){return Da(b,a+".machine")};window.enableEvents=Cb;window.sendEvent=Eb;})();//# sourceMappingURL=/tmp/pdpjs/1.33.0/pdp11-dbg.map diff --git a/versions/pdpjs/1.33.0/pdp11.js b/versions/pdpjs/1.33.0/pdp11.js new file mode 100644 index 000000000..1921431b4 --- /dev/null +++ b/versions/pdpjs/1.33.0/pdp11.js @@ -0,0 +1,284 @@ +(function(){/* + http://pcjs.org/modules/shared/lib/diskapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/dumpapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/reportapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/userapi.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/keys.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/strlib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/weblib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/messages.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/panel.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/device.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/cpu.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/rom.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/ram.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/keyboard.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/pc11.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/rk11.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/rl11.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/computer.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/state.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/embed.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/defines.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/component.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/usrlib.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/defines.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/bus.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/memory.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/cpustate.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/cpuops.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/serial.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/disk.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/drive.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/shared/lib/debugger.js (C) Jeff Parsons 2012-2017 + http://pcjs.org/modules/pdp11/lib/debugger.js (C) Jeff Parsons 2012-2017 +*/ +var h,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},ba="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global?global:this;function ca(){ca=function(){};ba.Symbol||(ba.Symbol=da)}var ea=0;function da(a){return"jscomp_symbol_"+(a||"")+ea++} +function ga(){ca();var a=ba.Symbol.iterator;a||(a=ba.Symbol.iterator=ba.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&aa(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return ha(this)}});ga=function(){}}function ha(a){var b=0;return ia(function(){return b":62,"?":63,"@":64,Nc:65,Ug:66,Xg:67,wh:68,E:69,Ch:70,Eh:71,Qh:72,Sh:73,Th:74,Uh:75,Vh:76,Yh:77,$h:78,bi:79,ei:80,Q:81,gi:82,ii:83,ri:84,ti:85,vi:86,wi:87,Ai:88,Bi:89,le:90,"[":91,"\\":92,"]":93,"^":94,_:95,"`":96,Ci:97,Di:98,Gi:99,d:100,e:101,Hi:102,Ii:103,Ji:104,Ki:105,Oi:106,k:107,Pi:108,Qi:109,n:110,Ri:111,p:112,q:113,r:114,Si:115,t:116,Ui:117,Vi:118,Wi:119,x:120,y:121,z:122,"{":123, +"|":124,"}":125,"~":126,Dd:127};function q(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.Zc=b.comment;this.he=b;this.exports={};this.m=this.bindings={};a=this.id.indexOf(".");0>a?this.$a=this.id:(this.Na=this.id.substr(0,a),this.$a=this.id.substr(a+1));this.j={ready:!1,Va:!1,Ac:!1,O:!1,error:!1};this.Ub=null;this.j.error=!1;this.Xc=c||0;this.F=this.c=this.u=this.A=this.gb=null;r.push(this)}function ta(a,b,c){ua[a]&&b&&(ua[a][b]=c)} +function va(){return Date.now()||+new Date}function u(a){window&&window.alert(a)}function wa(a){var b=!1;window&&(b=window.confirm(a));return b}function xa(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b>=3;return""+c}function Ea(a,b,c){var d="";b?8=e?48:55),d=String.fromCharCode(e)+d;a>>=4}return(c?"0x":"")+d} +function Fa(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0"']/g,function(a){return Ja[a]})}function Ka(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")} +var Ja={"&":"&","<":"<",">":">",'"':""","'":"'"},Ma={0:"NUL",1:"SOH",2:"STX",3:"ETX",4:"EOT",5:"ENQ",6:"ACK",7:"BEL",8:"BS",9:"TAB",10:"LF",11:"VT",12:"FF",13:"CR",14:"SO",15:"SI",16:"DLE",17:"XON",18:"DC2",19:"XOFF",20:"DC4",21:"NAK",22:"SYN",23:"ETB",24:"CAN",25:"EM",26:"SUB",27:"ESC",28:"FS",29:"GS",30:"RS",31:"US"}; +function Na(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())} +function Oa(a,b,c,d){c=void 0===c?!1:c;var e=0,f=null,g=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),g;var k=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(k.onreadystatechange=function(){4===k.readyState&&(f=k.responseText,200==k.status||!k.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=k.status||-1),d&&d(a, +f,e))});if(b&&"object"==typeof b){var l="",m;for(m in b)b.hasOwnProperty(m)&&(l&&(l+="&"),l+=m+"="+encodeURIComponent(b[m]));l=l.replace(/%20/g,"+");k.open("POST",a,c);k.setRequestHeader("Content-type","application/x-www-form-urlencoded");k.send(l)}else k.open("GET",a,c),"bytes"==b&&k.overrideMimeType("text/plain; charset=x-user-defined"),k.send();c||(f=k.responseText,200!=k.status&&(e=k.status||-1),d&&d(a,f,e),g=[f,e]);return g} +function Pa(a,b){var c,d={M:null,ga:null,ca:null,ba:null};if("["==b.charAt(0)||"{"==b.charAt(0))try{var e,f,g;if("<"==b.substr(0,1))throw Error(b);g=0>b.indexOf("0x")&&'["'!=b.substr(0,2)?JSON.parse(b.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+b+")");d.ca=g.load;d.ba=g.exec;if(e=g.bytes)d.M=e;else if(e=g.words)for(d.M=Array(2*e.length),f=c=0;c>8&255;else if(e=g.data)for(d.M=Array(4*e.length),f=c=0;c>8&255,d.M[f++]=e[c]>>16&255,d.M[f++]=e[c]>>24&255;else d.M=g;d.ga=g.symbols;d.M.length?1==d.M.length&&(u(d.M[0]),d=null):(u("Empty resource: "+a),d=null)}catch(k){u("Resource data error ("+a+"): "+k.message),d=null}else{e=[];b=b.replace(/\n/gm," ").replace(/ +$/,"").split(" ");for(c=0;ca;a++)this.a["S"+a]=[0,0,!1,!1,this.De,a];this.F=this.c=this.u=this.A=null;B(this)}n(lb,q);h=lb.prototype; +h.reset=function(a){this.stop();a&&nb(this,this.f=0)}; +h.ka=function(a,b,c,d){if(this.A&&this.A.ka(a,b,c,d)||this.c&&this.c.ka(a,b,c,d))return!0;switch(b){case "R0":case "R1":case "R2":case "R3":case "R4":case "R5":case "R6":case "R7":case "NF":case "ZF":case "VF":case "CF":case "PS":return this.m[b]=c,this.l++,!0;default:return"led"==a||"rled"==a?(this.m[b]=c,this.h[b]=d?1:0,this.l++,!0):"switch"==a?(void 0===this.a[b]&&(this.a[b]=[d?1:0,d?1:0]),this.m[b]=c,a=c.parentElement||c,a=a.parentElement||a,a.onmousedown=function(a,b){return function(){ob(a, +b)}}(this,b),a.onmouseup=a.onmouseout=function(a,b){return function(){pb(a,b)}}(this,b),a.ontouchstart=function(a,b){return function(c){ob(a,b);c.preventDefault()}}(this,b),a.ontouchend=function(a,b){return function(){pb(a,b)}}(this,b),!0):q.prototype.ka.call(this,a,b,c,d)}};h.ha=function(a,b,c,d){this.A=a;this.u=b;this.c=c;this.F=d;qb(b,this,rb);sb(b,this.reset.bind(this));tb(this);ub(this)};h.ja=function(a,b){if(!b)if(this.D&&vb(),!a)this.reset(!0);else if(!this.restore(a))return!1;return!0}; +h.ia=function(a){return a?this.save():!0};h.save=function(){var a=new E(this);a.set(0,[this.U,this.f,this.b]);return a.data()};h.restore=function(a){if(a=a[0])wb(this,this.U=a[0]),nb(this,this.f=a[1]),xb(this,a[2]);return!0};function yb(a,b,c){if(a=a.m[b])a.style.backgroundColor=c?"#ff0000":"#000000"}function tb(a,b){for(var c in a.h)yb(a,c,null!=b?b:a.h[c])}function zb(a,b,c){if(a=a.m[b])a.style.marginTop=c?"0px":"20px",a.style.backgroundColor=c?"#00ff00":"#228B22"} +function ub(a){for(var b in a.a)zb(a,b,a.a[b][1])}function Ab(a,b,c,d){if(a.m[b]){var e=a.F&&a.F.h||8;c=c||0;c=8==e?Da(c,d):Ea(c,d);a.m[b].textContent!=c&&(a.m[b].textContent=c)}}function ob(a,b){var c=a.a[b];zb(a,b,c[1]=1-c[1]);c[3]=!0;c[4]&&c[4].call(a,c[1],c[5]);b!=Bb&&(a.w=b==Cb,a.B=b==Db)}function pb(a,b){var c=a.a[b];c[2]&&c[3]&&(zb(a,b,c[1]=c[0]),c[4]&&c[4].call(a,c[1],c[5]));c[3]=!1}h.Be=function(a){a||this.c.j.L||(a=this.c,a.u.reset(),Eb(a),this.a[Fb]&&this.a[Fb][1]&&Gb(this.c))};h.Ce=function(){}; +h.xe=function(a){a||F(this.c)};h.ve=function(a){if(!a&&!this.c.j.L)if(this.a[Fb]&&this.a[Fb][1])Gb(this.c);else{a=this.F;var b;if(b=a)a.j.Va&&(a.j.Ac=!0),b=!a.j.Va;if(b)Ba(a,!0),a.f(0,null),Ba(a,!1);else try{var c=this.c.kc(1);0=a.c.pa?8:16,c=65472<=a.U&&a.U<65472+b,b=c?1:2,c=c?15:a.u.v;a.a[Bb]&&a.a[Bb][1]||(b=-b);wb(a,a.U&~c|a.U+b&c)}function wb(a,b){a.U=b&a.u.v;if(a.s!==a.U){a.s=a.U;b=a.s;for(var c=0;22>c;c++)Pb(a,"A"+c,b&1<c;c++)Pb(a,"D"+c,b&1<c;c++)a.a["S"+c][1]=b&1<>2;this.f=this.g-1;this.s=this.C/this.g|0;this.K=this.s-1;this.Ka=[];this.l=0;this.o=!1;this.D=[];this.me=[Ub,Vb,Wb,Xb];this.a=this.b=[];this.B=this.w=this.i=this.H=this.I=0;a=new G(this);Yb(a);this.a=Array(this.s);this.b=Array(this.s);for(b=0;b>>this.h;this.w=0;this.i=this.v;B(this)}n(Sb,q);function ac(a,b){if(b!=a.w){for(var c=0;c>>a.h,a.b[a.I]=a.a[a.H])}}h=Sb.prototype;h.reset=function(){for(var a=0;a>>a.h;0g&&(p=g);if(!e&&l&&l.size){if(l.type==d){if(f+g<=l.Ua)return l.Hb+=l.Ua-f,l.Ua=f,!0;if(f>=l.Ua+l.Hb){p=l.size-(f-m);p>g&&(p=g);l.Hb=f-l.Ua+p;f=m+a.g;g-=p;k++;continue}}return cc(dc,f,g)}f=new G(a,f,p,a.g,d,e);Yb(f,l);a.a[k++]=f;f=m+a.g;g-=p}return 0>=g?(a.status("Added "+(c>>10)+"Kb "+ec[d]+" at "+Da(b)),!0):cc(fc,b,c)}h.xd=function(a){return this.b[(a&this.i)>>>this.h].lb(a&this.f,a)}; +h.Kb=function(a){var b=a&this.f,c=(a&this.i)>>>this.h;return jb||b!=this.f?this.b[c].W(b,a):this.b[c++].lb(b,a)|this.b[c&this.K].lb(0,a+1)<<8};h.yd=function(a,b){this.b[(a&this.i)>>>this.h].ob(a&this.f,b,a)};h.Lb=function(a,b){var c=a&this.f,d=(a&this.i)>>>this.h;jb||c!=this.f?this.b[d].rb(c,b,a):(this.b[d++].ob(c,b&255,a),this.b[d&this.K].ob(0,b>>8&255,a+1))};function gc(a,b){return a.a[(b&a.v)>>>a.h]} +function Ob(a,b){var c;a.o=!1;a.l++;var d=b&a.f,e=gc(a,b);jb||d!=a.f?c=e.l(d,b):c=e.i(d,b)|gc(a,b+1).i(0,b+1)<<8;a.l--;return c}function hc(a,b,c){a.o=!1;a.l++;gc(a,b).m(b&a.f,c&255,b);a.l--}function Mb(a,b,c){a.o=!1;a.l++;var d=b&a.f,e=gc(a,b);jb||d!=a.f?e.F(d,c&65535,b):(e.m(d,c&255,b),gc(a,b+1).m(0,c>>8&255,b+1));a.l--} +function bc(a){for(var b=0,c=[],d=0;da.c.pa)){var k=g[0]?g[0].bind(b):null,l=g[1]?g[1].bind(b):null,m=g[2]?g[2].bind(b):null,p=g[3]?g[3].bind(b):null;65472<=f&&65487>=f&&(!k&&m&&(k=function(a){return function(b){return a(b)&255}.bind(b)}(m)),!l&&p&&(l=function(a){return function(b,c){return a(b,c)}.bind(b)}(p)));for(var t=g[4],z=g[5]||1,y=0;y>8:e[2](f)&255):f&1&&(e=d.Ka[a&-2])&&(e[2]?c=e[2](f&-2)>>8:e[0]&&(c=e[0](f)));if(0<=c)return c;H(d,b,16);return 255} +function Vb(a,b,c){var d=!1,e=this.controller,f=e.Ka[a],g=c&65535;if(f)if(f[1])f[1](b,g),d=!0;else{if(f[3]){a=f[2]?f[2](g,!0):0;if(g&1)f[3](a&255|b<<8,g&-2);else f[3](a&-256|b,g);d=!0}}else g&1&&(f=e.Ka[a&-2])&&(f[3]?(g&=-2,a=f[2]?f[2](g,!0):0,f[3](a&255|b<<8,g),d=!0):f[1]&&(f[1](b,g),d=!0));d||H(e,c,16)}function Wb(a,b){var c=-1,d=this.controller;a=d.Ka[a];var e=b&65535;a&&(a[2]?c=a[2](e):a[0]&&(c=a[0](e)|a[0](e+1)<<8));if(0<=c)return c;H(d,b,16);return 65535} +function Xb(a,b,c){var d=!1,e=this.controller;a=e.Ka[a];var f=c&65535;a&&(a[3]?(a[3](b,f),d=!0):a[1]&&(a[1](b&255,f),a[1](b>>8,f+1),d=!0));d||H(e,c,16)}function J(a){q.call(this,"Device",a,256);this.a={Da:128,Jc:-1}}n(J,q);h=J.prototype;h.ha=function(a,b,c,d){this.u=b;this.A=a;this.c=c;this.F=d;var e=this;this.a.Jc=nc(c,function(){e.a.Da|=128;e.a.Da&64&&oc(e.c,e.a.jb);e.A&&Kb(e.A,1);pc(e.c,e.a.Jc,1E3/60)});this.a.jb=qc(c,64,6,524288);qb(b,this,sc);sb(b,this.reset.bind(this));B(this)}; +h.ja=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};h.ia=function(a){return a?this.save():!0};h.reset=function(){this.a.Da=128;pc(this.c,this.a.Jc,1E3/60,!0)};h.save=function(){var a=new E(this);a.set(0,[this.a.Da]);return a.data()};h.restore=function(a){a=ja(a[0]);this.a.Da=a.next().value;return!0};h.Pe=function(){return this.a.Da};h.bg=function(a){this.a.Da=a&192;this.a.Da&64||(a=this.a.jb)&&tc(this.c,a)};h.Re=function(){return uc(this.c)}; +h.dg=function(a){vc(this.c,a&-129|this.c.J&128)};h.Se=function(){return wc(this.c)};h.Te=function(){return xc(this.c)};h.Ue=function(){return this.c.qa};h.eg=function(a){yc(this.c,a)};h.Df=function(a){a=a>>1&63;var b=this.c.Ja[a>>1];return a&1?b>>16:b&65535};h.Mg=function(a,b){b=b>>1&63;var c=b>>1;this.c.Ja[c]=b&1?this.c.Ja[c]&65535|(a&63)<<16:this.c.Ja[c]&-65536|a&65534};h.wf=function(a){return this.c.s[1][a>>1&7]};h.Fg=function(a,b){this.c.s[1][b>>1&7]=a&65295}; +h.uf=function(a){return this.c.s[1][(a>>1&7)+8]};h.Dg=function(a,b){this.c.s[1][(b>>1&7)+8]=a&65295};h.vf=function(a){return this.c.H[1][a>>1&7]};h.Eg=function(a,b){b=b>>1&7;this.c.H[1][b]=a;this.c.s[1][b]&=65295};h.tf=function(a){return this.c.H[1][(a>>1&7)+8]};h.Cg=function(a,b){b=(b>>1&7)+8;this.c.H[1][b]=a;this.c.s[1][b]&=65295};h.Oe=function(a){return this.c.s[0][a>>1&7]};h.ag=function(a,b){this.c.s[0][b>>1&7]=a&65295};h.Me=function(a){return this.c.s[0][(a>>1&7)+8]}; +h.Zf=function(a,b){this.c.s[0][(b>>1&7)+8]=a&65295};h.Ne=function(a){return this.c.H[0][a>>1&7]};h.$f=function(a,b){b=b>>1&7;this.c.H[0][b]=a;this.c.s[0][b]&=65295};h.Le=function(a){return this.c.H[0][(a>>1&7)+8]};h.Yf=function(a,b){b=(b>>1&7)+8;this.c.H[0][b]=a;this.c.s[0][b]&=65295};h.Cf=function(a){return this.c.s[3][a>>1&7]};h.Lg=function(a,b){this.c.s[3][b>>1&7]=a&65295};h.Af=function(a){return this.c.s[3][(a>>1&7)+8]};h.Jg=function(a,b){this.c.s[3][(b>>1&7)+8]=a&65295}; +h.Bf=function(a){return this.c.H[3][a>>1&7]};h.Kg=function(a,b){b=b>>1&7;this.c.H[3][b]=a;this.c.s[3][b]&=65295};h.zf=function(a){return this.c.H[3][(a>>1&7)+8]};h.Ig=function(a,b){b=(b>>1&7)+8;this.c.H[3][b]=a;this.c.s[3][b]&=65295};h.mb=function(a){a&=7;return this.c.i&2048?this.c.sa[a]:this.c.b[a]};h.pb=function(a,b){b&=7;this.c.i&2048?this.c.sa[b]=a:this.c.b[b]=a};h.Ze=function(){return this.c.i&49152?this.c.fa[0]:this.c.b[6]};h.jg=function(a){this.c.i&49152?this.c.fa[0]=a:this.c.b[6]=a}; +h.bf=function(){return this.c.b[7]};h.mg=function(a){this.c.b[7]=a};h.nb=function(a){a&=7;return this.c.i&2048?this.c.b[a]:this.c.sa[a]};h.qb=function(a,b){b&=7;this.c.i&2048?this.c.b[b]=a:this.c.sa[b]=a};h.$e=function(){return 1==(this.c.i&49152)>>14?this.c.b[6]:this.c.fa[1]};h.kg=function(a){1==(this.c.i&49152)>>14?this.c.b[6]=a:this.c.fa[1]=a};h.af=function(){return 3==(this.c.i&49152)>>14?this.c.b[6]:this.c.fa[3]};h.lg=function(a){3==(this.c.i&49152)>>14?this.c.b[6]=a:this.c.fa[3]=a}; +h.Ke=function(a){return this.c.Eb[a-65504>>1]};h.Xf=function(a,b){this.c.Eb[b-65504>>1]=a};h.sd=function(a){return 65520==a?(ic(this.u)>>6)-1:0};h.vd=function(){};h.yf=function(){return 1};h.Hg=function(){};h.Je=function(){return this.c.D};h.Wf=function(){this.c.D=0};h.Qe=function(){return this.c.Bb};h.cg=function(a,b){b&1||(a&=255);this.c.Bb=a};h.Ve=function(a,b){return b?0:this.c.Sa};h.fg=function(a){var b=this.c;if(a&=65024){var c=a>>9;do a+=34;while(c>>=1);b.g|=1}b.Sa=a}; +h.xf=function(a,b){return b?0:this.c.Ia&65280};h.Gg=function(a){this.c.Ia=a|255};h.Ye=function(){return zc(this.c)};h.ig=function(a){Ac(this.c,a)};h.ud=function(){}; +var K={},sc=(K[61568]=[null,null,J.prototype.Df,J.prototype.Mg,"UNIMAP",64,1170],K[62592]=[null,null,J.prototype.wf,J.prototype.Fg,"SIPDR",8,1145,64],K[62608]=[null,null,J.prototype.uf,J.prototype.Dg,"SDPDR",8,1145,64],K[62624]=[null,null,J.prototype.vf,J.prototype.Eg,"SIPAR",8,1145,64],K[62640]=[null,null,J.prototype.tf,J.prototype.Cg,"SDPAR",8,1145,64],K[62656]=[null,null,J.prototype.Oe,J.prototype.ag,"KIPDR",8,1140,64],K[62672]=[null,null,J.prototype.Me,J.prototype.Zf,"KDPDR",8,1145,64],K[62688]= +[null,null,J.prototype.Ne,J.prototype.$f,"KIPAR",8,1140,64],K[62704]=[null,null,J.prototype.Le,J.prototype.Yf,"KDPAR",8,1145,64],K[62798]=[null,null,J.prototype.Ue,J.prototype.eg,"MMR3",1,1145,64],K[65382]=[null,null,J.prototype.Pe,J.prototype.bg,"LKS"],K[65402]=[null,null,J.prototype.Re,J.prototype.dg,"MMR0",1,1140,64],K[65404]=[null,null,J.prototype.Se,J.prototype.ud,"MMR1",1,1145,64],K[65406]=[null,null,J.prototype.Te,J.prototype.ud,"MMR2",1,1140,64],K[65408]=[null,null,J.prototype.Cf,J.prototype.Lg, +"UIPDR",8,1140,64],K[65424]=[null,null,J.prototype.Af,J.prototype.Jg,"UDPDR",8,1145,64],K[65440]=[null,null,J.prototype.Bf,J.prototype.Kg,"UIPAR",8,1140,64],K[65456]=[null,null,J.prototype.zf,J.prototype.Ig,"UDPAR",8,1145,64],K[65472]=[null,null,J.prototype.mb,J.prototype.pb,"R0SET0"],K[65473]=[null,null,J.prototype.mb,J.prototype.pb,"R1SET0"],K[65474]=[null,null,J.prototype.mb,J.prototype.pb,"R2SET0"],K[65475]=[null,null,J.prototype.mb,J.prototype.pb,"R3SET0"],K[65476]=[null,null,J.prototype.mb, +J.prototype.pb,"R4SET0"],K[65477]=[null,null,J.prototype.mb,J.prototype.pb,"R5SET0"],K[65478]=[null,null,J.prototype.Ze,J.prototype.jg,"R6KERNEL"],K[65479]=[null,null,J.prototype.bf,J.prototype.mg,"R7KERNEL"],K[65480]=[null,null,J.prototype.nb,J.prototype.qb,"R0SET1",1,1145],K[65481]=[null,null,J.prototype.nb,J.prototype.qb,"R1SET1",1,1145],K[65482]=[null,null,J.prototype.nb,J.prototype.qb,"R2SET1",1,1145],K[65483]=[null,null,J.prototype.nb,J.prototype.qb,"R3SET1",1,1145],K[65484]=[null,null,J.prototype.nb, +J.prototype.qb,"R4SET1",1,1145],K[65485]=[null,null,J.prototype.nb,J.prototype.qb,"R5SET1",1,1145],K[65486]=[null,null,J.prototype.$e,J.prototype.kg,"R6SUPER",1,1145],K[65487]=[null,null,J.prototype.af,J.prototype.lg,"R6USER",1,1145],K[65504]=[null,null,J.prototype.Ke,J.prototype.Xf,"CTRL",8,1170],K[65520]=[null,null,J.prototype.sd,J.prototype.vd,"LSIZE",1,1170],K[65522]=[null,null,J.prototype.sd,J.prototype.vd,"HSIZE",1,1170],K[65524]=[null,null,J.prototype.yf,J.prototype.Hg,"SYSID",1,1170],K[65526]= +[null,null,J.prototype.Je,J.prototype.Wf,"ERR",1,1170],K[65528]=[null,null,J.prototype.Qe,J.prototype.cg,"MBR",1,1170],K[65530]=[null,null,J.prototype.Ve,J.prototype.fg,"PIR"],K[65532]=[null,null,J.prototype.xf,J.prototype.Gg,"SLR"],K[65534]=[null,null,J.prototype.Ye,J.prototype.ig,"PSW"],K); +Za(function(){for(var a=A(document,x,"device"),b=0;b>1),this.c=new Int32Array(this.f,0,this.size>>2),Fc(this,Gc?Hc:Ic);else{a=this.c=Array(this.size>>2);for(f=0;f>2),b=0;b>8,c)};h.He=function(a){return this.c[a>>2]>>>((a&3)<<3)&255};h.If=function(a,b){ib&&a&1&&H(this.b,b,64);b=a>>2;a=(a&3)<<3;var c=this.c[b]>>a;return 24>a?c&65535:c&255|(this.c[b+1]&255)<<8}; +h.Uf=function(a,b){var c=a>>2;a=(a&3)<<3;this.c[c]=this.c[c]&~(255<>2;a=(a&3)<<3;24>a?this.c[c]=this.c[c]&~(65535<>8);this.Ca=!0};h.Fe=function(a,b){return this.i(a,b)};h.Ff=function(a,b){return this.l(a,b)};h.Sf=function(a,b,c){this.A?this.Jb(0,0,c):this.m(a,b,c)};h.Og=function(a,b,c){this.A?this.Jb(0,0,c):this.F(a,b,c)};h.Ee=function(a){return this.a[a]}; +h.Ge=function(a){return this.a[a]};h.Ef=function(a,b){ib&&a&1&&H(this.b,b,64);return this.u.getUint16(a,!0)};h.Hf=function(a,b){ib&&a&1&&H(this.b,b,64);return!jb&&a&1?this.a[a]|this.a[a+1]<<8:this.o[a>>1]};h.Rf=function(a,b){this.a[a]=b;this.Ca=!0};h.Tf=function(a,b){this.a[a]=b;this.Ca=!0};h.Ng=function(a,b,c){ib&&a&1&&H(this.b,c,64);this.u.setUint16(a,b,!0);this.Ca=!0};h.Pg=function(a,b,c){ib&&a&1&&H(this.b,c,64);!jb&&a&1?(this.a[a]=b,this.a[a+1]=b>>8):this.o[a>>1]=b;this.Ca=!0}; +var Dc=0,jc=1,Ec=2,$b=4,ec=["NONE","RAM","ROM","VID","H/W"],Cc=0,Lc=[],Jc=[G.prototype.He,G.prototype.Uf,G.prototype.If,G.prototype.Qg],Oc=[G.prototype.Fe,G.prototype.Sf,G.prototype.Ff,G.prototype.Og];if(gb)var Ic=[G.prototype.Ee,G.prototype.Rf,G.prototype.Ef,G.prototype.Ng],Hc=[G.prototype.Ge,G.prototype.Tf,G.prototype.Hf,G.prototype.Pg];var Pc;if(gb){var Qc=new ArrayBuffer(2);(new DataView(Qc)).setUint16(0,256,!0);Pc=256===(new Uint16Array(Qc))[0]}else Pc=!1;var Gc=Pc; +function Rc(a,b){q.call(this,"CPU",a,1);b=+a.cycles||b;var c=+a.multiplier||1;this.Lc=0;this.ec=b;this.Ra=c;this.nc=Math.round(this.ec/1E4)/100;this.ab=this.nc*this.Ra;this.oc=this.Ab=this.eb=this.fc=0;this.j.L=this.j.Ic=!1;this.j.Y=a.autoStart;"string"==typeof this.j.Y&&(this.j.Y="true"==this.j.Y);this.j.Tb=!1;this.cc=this.cb=0;this.dc=+a.csStart;this.yb=+a.csInterval;this.zb=+a.csStop;this.X=[];this.bd=this.Mf.bind(this);this.Ha=this.Aa=this.Ga=this.a=this.aa=this.za=this.xb=this.Fa=this.fb=this.pc= +this.Oa=0;this.na=null;B(this)}n(Rc,q);h=Rc.prototype;h.ha=function(a,b,c,d){this.A=a;this.u=b;this.F=d;this.na=a.f;for(a=0;a=a.cb&&(a.cb+=a.yb,c=!0);0<=a.zb&&a.zb<=Wc(a)&&(a.yb=a.zb=-1,Vc(a),F(a),c=!0);c&&a.Z(Wc(a)+" cycles: checksum="+Ea(a.cc))}} +h.ka=function(a,b,c){var d=this;switch(b){case "power":case "reset":return this.m[b]=c,!0;case "run":return this.m[b]=c,c.onclick=function(){var a;if(a=d.A)if(a=d.A,a.j.O)a=!0;else{var b=null,c,k=xa(a.id);for(c=0;ca.Oa/a.ab&&(b=1);a.Ra=b;b=a.nc*a.Ra;if(a.ab!=b){a.ab=b;b=a.ab.toFixed(2)+"Mhz";var d=a.m.setSpeed;d&&(d.textContent=b);a.Z("target speed: "+b)}c&&a.A&&$c(a.A)}Ib(a,a.Aa);a.Aa=0;a.za=va();a.Fa=0;Yc(a)}function nc(a,b){var c=a.X.length;a.X.push([-1,b]);return c}function pc(a,b,c,d){0<=b&&ba.X[b][0])&&(c=a.ec*a.Ra/1E3*c|0,a.j.L&&(c+=ad(a)),a.X[b][0]=c)}function bd(a){for(var b=[],c=0;cd[0]||(d[0]-=b,0>=d[0]&&(d[0]=-1,d[1]()))}}function ad(a,b){var c=a.Ga-=a.a;a.a=a.aa=0;b&&(a.Ga=0);return c} +h.Mf=function(){if(this.j.L){this.fc>=this.ec&&Yc(this,!0);this.fb=0;this.xb=va();if(this.Fa){var a=this.xb-this.Fa;a>this.oc&&(this.za+=a,this.za>this.xb&&(this.za=this.xb))}try{do{for(var b,c=this.j.Tb?1:this.Ab,d=this.X.length-1;0<=d;d--){var e=this.X[d];0>e[0]||c>e[0]&&(c=e[0])}b=c;try{this.kc(b)}catch(f){if("number"!=typeof f)throw f;}b=ad(this,!0);this.fb+=b;this.Aa+=b;Jb(this,b);Hb(this,b);this.eb-=b;if(0>=this.eb){this.eb+=this.Ab;++this.pc>=cd&&(this.A&&Kb(this.A,void 0),this.pc=0);break}}while(this.j.L)}catch(f){F(this); +this.A&&this.A.stop(va(),Wc(this));a=f.stack||f.message;this.j.error=!0;this.G(a);return}if(this.j.L){a=setTimeout;b=this.bd;this.Fa=va();c=this.oc;this.fb&&(c=Math.round(c*this.fb/this.Ab));c-=this.Fa-this.xb;if(d=this.Fa-this.za)this.Oa=Math.round(this.Aa/(10*d))/100,864E5<=d&&(this.Ha=0,Xc(this));if(0>c||this.Oac&&(this.za-=c),c=0;this.fc+=this.fb;this.Fa+=c;a(b,c)}}}; +function Gb(a){var b;a.j.error?(a.Z(a.toString()+" error"),b=!0):b=!1;if(!b)if(a.j.L)a.Z(a.toString()+" busy");else{Xc(a);a.j.L=!0;a.j.Ic=!0;if(b=a.m.run)b.textContent="Halt";a.A&&a.A.start(a.za,Wc(a));a.F||a.status("Started");setTimeout(a.bd,0)}}h.kc=function(){return 0};function F(a){var b=!1;if(a.j.L){ad(a);Ib(a,a.Aa);a.Aa=0;a.j.L=!1;if(b=a.m.run)b.textContent="Run";a.A&&a.A.stop(va(),Wc(a));b=!0;a.F||a.status("Stopped")}a.j.complete=void 0;return b}var Zc=30,cd=15,Sc=["power","reset"]; +function dd(a){var b=+a.model||1170;Rc.call(this,a,6666667);this.pa=b;this.Wc=+a.addrReset||0;this.Ba=this.i=this.B=this.v=this.l=this.o=this.w=0;this.b=this.sa=this.fa=[];this.H=this.s=this.Ja=this.Eb=[];this.Ea=this.C=this.Vc=this.bb=this.Pa=this.Qa=this.Wa=this.D=this.Bb=this.Sa=this.Ia=this.J=this.Cb=this.Db=this.qa=this.g=0;this.ge=[4,2,0,1];this.hc=0;this.$c=255;1120>=this.pa?(this.Uc=ed.bind(this),this.Za=this.pe,this.hc=8,this.$c=-1,this.fd=255,this.cd=0):(this.Uc=fd.bind(this),this.Za=this.qe, +this.fd=~(1792|(1140>=this.pa?2048:0))&65535,this.cd=1140e.Ib&&(e.Ib=c,c+=4)}return Rc.prototype.ja.call(this,a,b)}; +h.reset=function(){this.status("Model "+this.pa);this.j.L&&F(this);this.v=65536;this.l=32768;this.o=65535;this.w=32768;this.i=15;this.b=[0,0,0,0,0,0,0,this.Wc,-1,-2,-3,-4,-5,-6,-7,-8];this.sa=[0,0,0,0,0,0];this.fa=[0,0,0,0];this.H=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.s=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, +65535,65535,65535,65535,65535,65535],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.Ja=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.Eb=[0,0,0,0,0,0,0,0];this.B=0;this.Ba=-1;this.h=this.f=this.bc=this.K=this.R=this.g=this.Bb=0;Eb(this);Uc(this);this.j.error=!1;Rc.prototype.reset.call(this)};function Eb(a){a.J=0;a.Cb=0;a.Db=0;a.qa=0;a.D=0;a.Sa=0;a.Ia=255;a.bb=0;a.Pa=0;a.Qa=0;a.Wa=262143;a.Ea=a.b[7];a.C=0;a.I=null;a.u&&(gd(a),a.Vc=ic(a.u))} +function gd(a){a.Yb=a.Mc;a.Zb=a.ic;a.jc=a.lc;a.$b=a.mc;a.bb?(a.xa=65536,a.Xb=a.qa&16?4186112:253952,a.oa=a.pd,a.W=a.td,a.rb=a.wd,ac(a.u,a.qa&16?22:18)):(a.xa=0,a.Xb=57344,a.oa=a.te,a.W=a.Gf,a.rb=a.Rg,ac(a.u,16))}function uc(a){var b=a.J;b&57344||(b=b&-3199|a.Pa<<5|a.Qa<<1);return b}function vc(a,b){b&=-3073;if(a.J!=b){b&57344&&!(a.J&57344)&&(a.Cb=a.C>>16&65535,a.Db=a.C&65535);a.J=b;a.Pa=(b&96)>>5;a.Qa=(b&30)>>1;var c=0;b&257&&(c=4,b&1&&(c|=2));a.bb!=c&&(a.bb=c,gd(a))}} +function wc(a){a.J&57344||(a.Cb=a.C>>16&65535);a=a.Cb;a&65280&&(a=(a<<8|a>>8)&65535);return a}function xc(a){a.J&57344||(a.Db=a.C&65535);return a.Db}function yc(a,b){1170>a.pa&&(b&=-49);a.qa!=b&&(a.qa=b,a.Wa=b&16?4194303:262143,gd(a))}function hd(a,b,c){a.Wc=b;id(a,b);Ac(a,0);a.u.reset();Eb(a);if(c){for(b=2;5>=b;b++)a.b[b]=0;a.j.O?a.j.L||Gb(a):a.j.Y=!0}else a.F&&a.j.O?F(a)||(a.F.g(),Kb(a.A,-1)):!1===c&&F(a);!a.j.L&&a.na&&a.na.stop()}h.od=function(){return 0}; +h.save=function(){var a=new E(this);a.set(0,[this.b,this.sa,this.fa,this.H,this.s,this.Ja,this.Eb,this.D,this.Bb,this.Sa,this.Ia,this.Pa,this.Qa,this.Ea,this.g,this.C,this.Ba,this.sc,this.uc]);a.set(1,[zc(this),uc(this),wc(this),xc(this),this.qa]);a.set(2,[this.Ha,this.Ra,this.j.Y]);a.set(3,jd(this));a.set(4,bd(this));return a.data()}; +h.restore=function(a){var b=ja(a[0]);this.b=b.next().value;this.sa=b.next().value;this.fa=b.next().value;this.H=b.next().value;this.s=b.next().value;this.Ja=b.next().value;this.Eb=b.next().value;this.D=b.next().value;this.Bb=b.next().value;this.Sa=b.next().value;this.Ia=b.next().value;this.Pa=b.next().value;this.Qa=b.next().value;this.Ea=b.next().value;this.g=b.next().value;this.C=b.next().value;this.Ba=b.next().value;this.sc=b.next().value;this.uc=b.next().value;b=a[1];Ac(this,b[0]);vc(this,b[1]); +this.Cb=b[2];this.Db=b[3];yc(this,b[4]);b=a[2];this.Ha=b[0];Xc(this,b[1]);this.j.Y=b[2];for(var b=a[3],c=b.length-1;0<=c;c--){var d;a:{for(d=0;d>23)),a.a-=2);a.a-=3}function id(a,b){a.b[7]=b&65535}function qc(a,b,c,d){b={Ib:b,kb:c,message:d||0,name:kb[b],next:null};a.wb.push(b);return b}function tc(a,b){var c=a.I;if(c==b)a.I=b.next;else for(;c;){var d=c.next;if(d==b){c.next=d.next;break}c=d}a.I&&(a.g|=1)}function oc(a,b){if(b){if(b!=a.I){var c=a.I;if(!c||c.kb<=b.kb)b.next=c,a.I=b;else{do{var d=c.next;if(!d||d.kb<=b.kb){b.next=d;c.next=b;break}c=d}while(c)}}a.g|=1}} +function jd(a){var b=[];for(a=a.I;a;)b.push(a.Ib),a=a.next;return b}function nd(a){return a.g&64?(I(a,168,64,-6),!0):a.g&32?(I(a,4,32,-5),!0):a.g&16?(I(a,12,16,-7),!0):!1}function zc(a){return a.i=a.i&63728|ld(a)|(a.o&65535?0:4)|(a.l&32768?2:0)|kd(a)}function Ac(a,b){b&=a.fd;a.w=b<<12;a.o=~b&4;a.l=b<<14;a.v=b<<16;if((b^a.i)&a.cd)for(var c=a.sa.length;0<=--c;){var d=a.b[c];a.b[c]=a.sa[c];a.sa[c]=d}a.B=b>>14&3;c=a.i>>14&3;a.B!=c&&(a.fa[c]=a.b[6],a.b[6]=a.fa[a.B]);a.i=b;a.g&=-3;a.g|=a.I?2:1} +h.ea=function(a){this.w=this.o=a;this.l=0};h.La=function(a,b){this.w=this.o=this.v=a;this.l=b||0};function od(a,b){a.w=a.o=a.v=b;a.l=a.w^a.v>>1}function pd(a,b,c,d){a.w=a.o=a.v=b;a.l=(c^d)&(d^b)} +function I(a,b,c,d){if(!a.hb){0>a.Ba?a.Ba=zc(a):a.B||(d=-4);-4==d&&(a.g&256&&(d=-1),a.g|=256,a.D|=4,a.b[6]=b=4);if(-1!=d){a.C=b|4143316992;a.B=0;var e=a.W(b|a.xa),f=a.W(b+2&65535|a.xa);Ac(a,f&-12289|a.Ba>>2&12288);qd(a,a.Ba);qd(a,a.b[7]);id(a,e)}a.a-=5;a.g&=~(c|19);a.g|=129;a.Ba=-1;a.sc=d;a.uc=b;-1==d&&F(a);if(-4<=d)throw b;}}function rd(a){var b=sd(a),c=sd(a);a.i&49152&&(c=c&-225|a.i&63712);id(a,b);Ac(a,c);a.g&=-17} +function td(a,b){var c=b>>13&31;31>c&&(b=a.qa&32?a.Ja[c]+(b&8191)&4194303:b&-3932161);return b} +function Nb(a,b,c){var d,e,f;if(!(c&a.bb))return f=b&65535,57344<=f&&(f|=a.Xb),f;d=b>>13;a.qa&a.ge[a.B]||(d&=7);e=a.s[a.B][d];f=(a.H[a.B][d]<<6)+(b&8191)&a.Wa;3932160<=f&&(f=td(a,f));if(a.hb)return f;f>=a.Vc&&f>2&8128)&&(g|=16384):(b&8128)>(e>>2&8128)&& +(g|=16384));a.s[a.B][d]=e;if(f!=(4194170&a.Wa)||a.B)a.Pa=a.B,a.Qa=d;g&&(g&57344&&(0<=a.Ba&&(g|=128),a.J&57344||(g|=a.J&4096|a.Pa<<5|a.Qa<<1,vc(a,a.J&-61695|g&61694)),I(a,168,64,-2)),a.J&61440||!(f<(4191360&a.Wa)||f>(4194239&a.Wa))||(a.J|=4096,a.J&512&&(a.g|=64)));return f}function sd(a){var b=a.W(a.b[6]|a.xa);a.b[6]=a.b[6]+2&65535;return b}function qd(a,b){var c=a.b[6]-2&65535;a.b[6]=c;a.C=a.C&65535|(a.C&-65536)<<8|16121856;a.g&256||a.Za(4,-2,c);a.rb(c,b)} +function ud(a,b,c,d){var e,f,g=d&8?0:a.xa;switch(b){case 0:return I(a,4,0,-3),0;case 1:return 6==c&&a.Za(d,0,a.b[6]),a.a-=3,7==c?a.b[c]:a.b[c]|g;case 2:f=2;e=a.b[c];6==c&&a.Za(d,f,e);7!=c&&(e|=g,6>c&&d&1&&(f=1));a.a-=3;break;case 3:f=2;e=a.b[c];7!=c&&(e|=g);e=a.W(e);e|=g;a.a-=7;break;case 4:f=-2;6>c&&d&1&&(f=-1);e=a.b[c]+f&65535;6==c&&a.Za(d,f,e);7!=c&&(e|=g);a.a-=4;break;case 5:f=-2;e=a.b[c]-2&65535;7!=c&&(e|=g);e=a.W(e)|g;a.a-=8;break;case 6:return e=a.W(md(a,2)),e=e+a.b[c]&65535,6==c&&a.Za(d,0, +e),a.a-=6,e|g;case 7:return e=a.W(md(a,2)),e=e+a.b[c]&65535,e=a.W(e|a.xa),a.a-=10,e|g}a.b[c]=a.b[c]+f&65535;a.C=a.C&65535|(a.C&-65536)<<8|(f<<3&248|c)<<16;return e}h.pe=function(a,b,c){!this.B&&0>=b&&c<=this.Ia&&(this.g|=32)};h.qe=function(a,b,c){this.B||(65534<=c&&(c|=-65536),a&4&&c<=this.Ia&&(c<=this.Ia-32?I(this,4,0,-4):(this.D|=8,this.g|=32)))};h.se=function(a){return this.Mc(a)};h.ue=function(a){return this.ic(a)};h.Of=function(a,b){this.lc(a,b)};h.Qf=function(a,b){this.mc(a,b)}; +h.te=function(a,b,c){return ud(this,a,b,c)};h.pd=function(a,b,c){return Nb(this,ud(this,a,b,c),c)};h.Gf=function(a){return this.u.Kb(this.Ea=a)};h.td=function(a){return this.u.Kb(this.Ea=Nb(this,a,2))};h.Rg=function(a,b){this.u.Lb(this.Ea=a,b)};h.wd=function(a,b){this.u.Lb(this.Ea=Nb(this,a,4),b)}; +function vd(a,b,c){var d=a.f=b&7;(b=a.h=(b&56)>>3)?(d=ud(a,b,d,2),c&65536||61440!==(a.i&61440)&&(d&=65535),a.B=a.i>>12&3,c=a.W(d|c&a.xa),a.B=a.i>>14&3):c=6!=d||(a.i>>2&12288)===(a.i&12288)?a.b[d]:a.fa[a.i>>12&3];return c}function wd(a,b,c,d){a.C=a.C&65535|1441792;var e=a.f=b&7;(b=a.h=(b&56)>>3)?(e=ud(a,b,e,4),c&65536||(e&=65535),a.B=a.i>>12&3,e=Nb(a,e|c&65536,4),a.B=a.i>>14&3,a.$b(e,d)):6!=e||(a.i>>2&12288)===(a.i&12288)?a.b[e]=d:a.fa[a.i>>12&3]=d} +function xd(a,b){b>>=6;var c=a.R=b&7;return(b=a.K=(b&56)>>3)?a.Yb(a.oa(b,c,3)):a.b[c+a.hc]&a.$c}function yd(a,b){var c;b>>=6;var d=a.R=b&7;(b=a.K=(b&56)>>3)?c=a.Zb(a.oa(b,d,2)):c=a.b[d+a.hc];return c}function zd(a,b){var c=a.f=b&7;b=a.h=(b&56)>>3;return ud(a,b,c,8)}function Ad(a,b){var c=a.f=b&7;return(b=a.h=(b&56)>>3)?a.Yb(a.oa(b,c,3)):a.b[c]&255}function Bd(a,b){var c,d=a.f=b&7;(b=a.h=(b&56)>>3)?c=a.Zb(a.oa(b,d,2)):c=a.b[d];return c} +function O(a,b,c,d){var e=a.f=b&7;(b=a.h=(b&56)>>3)?(e=a.bc=a.oa(b,e,7),c=0>c?a.b[-c-1]&255:c,a.jc(e,d.call(a,c,a.Yb(e))),e&1&&a.a--):(b=a.b[e],c=0>c?a.b[-c-1]&255:c,a.b[e]=b&65280|d.call(a,c,b&255))}function P(a,b,c,d){var e=a.f=b&7;(b=a.h=(b&56)>>3)?(e=a.oa(b,e,6),a.$b(e,d.call(a,0>c?a.b[-c-1]:c,a.Zb(e)))):a.b[e]=d.call(a,0>c?a.b[-c-1]:c,a.b[e])} +function Cd(a,b,c,d,e){var f=a.f=b&7;(b=a.h=(b&56)>>3)?(d=a.oa(b,f,5),e.call(a,(c=0>c?a.b[-c-1]&255:c)<<8),a.jc(d,c),d&1&&a.a--):(c?(c=0>c?a.b[-c-1]&255:c,a.b[f]=a.b[f]&~d|c<<24>>24&d):a.b[f]&=~d,e.call(a,c<<8))}function Dd(a,b,c,d){var e=a.f=b&7;(b=a.h=(b&56)>>3)?(e=a.oa(b,e,4),d.call(a,c=0>c?a.b[-c-1]:c),a.$b(e,c)):(a.b[e]=c=0>c?a.b[-c-1]:c,d.call(a,c))} +h.kc=function(a){this.j.complete=!0;var b=a?this.j.Ic?0:1:-1;this.j.Ic=!1;this.Ga=this.a=a;this.g=this.g&-5|0;do{if(this.g){if(a=this.g&11)if(a=!1,this.g&2){var c=160,d=(this.Sa&224)>>5,e=this.I&&this.I.kb>d?this.I:null;e&&(c=e.Ib,d=e.kb);d>(this.i&224)>>5?(this.g&8&&(md(this,2),this.g&=-9),I(this,c,0,-10),d=!0):d=!1;d&&(e&&tc(this,e),a=!0);this.I||this.Sa||(this.g&=-3)}else this.g&1&&this.g++;if(a){if(this.g&4&&this.F.b(this.b[7],b)){F(this);break}if(0>b)break}if(this.g&112&&nd(this)){if(this.g& +4&&this.F.b(this.b[7],b)){F(this);break}if(0>b)break}}this.g=this.g&15|this.i&16;a=this.C=this.b[7];e=this.W(a);this.b[7]=a+2&65535;this.Uc(e)}while(0>1|b<<16;od(this,a);return a&65535}function Jd(a,b){a=b&128|b>>1|b<<8;od(this,a<<8);return a&255}function Kd(a,b){a=b&~a;this.ea(a);return a}function Ld(a,b){a=b&~a;this.ea(a<<8);return a}function Md(a,b){a|=b;this.ea(a);return a}function Nd(a,b){a|=b;this.ea(a<<8);return a} +function Od(a,b){a=~b|65536;this.La(a);return a&65535}function Pd(a,b){a=~b|256;this.La(a<<8);return a&255}function Qd(a,b){this.w=this.o=a=b-a;this.l=b&(b^a);return a&65535}function Rd(a,b){a=b-a;var c=a<<8;b<<=8;this.w=this.o=c;this.l=b&(b^c);return a&255}function Sd(a,b){this.w=this.o=a=b+a;this.l=a&(b^a);return a&65535}function Td(a,b){a=b+a;var c=a<<8;this.w=this.o=c;this.l=c&(b<<8^c);return a&255}function Ud(a,b){a=-b;this.La(a,a&b&32768);return a&65535} +function Vd(a,b){a=-b;this.La(a<<8,(a&b&128)<<8);return a&255}function Wd(a,b){a=b<<1|this.v>>16&1;od(this,a);return a&65535}function Xd(a,b){a=b<<1|this.v>>16&1;od(this,a<<8);return a&255}function Yd(a,b){a=(this.v&65536|b)>>1|b<<16;od(this,a);return a&65535}function Zd(a,b){a=((this.v&65536)>>8|b)>>1|b<<8;od(this,a<<8);return a&255}function $d(a,b){var c=b-a;pd(this,c,a,b);return c&65535}function ae(a,b){var c=b-a;pd(this,c<<8,a<<8,b<<8);return c&255} +function be(a,b){this.w=this.o=b&65280;this.l=this.v=0;return(b<<8|b>>8)&65535}function ce(a,b){a^=b;this.ea(a);return a&65535}function de(a){P(this,a,yd(this,a),Ed);this.a-=this.h?9+(this.R&&6<=this.f?1:0):(this.K?5:3)+(7==this.f?2:0)} +function ee(a){var b=Bd(this,a);a=a>>6&7;var c=this.b[a];c&32768&&(c|=4294901760);this.v=this.l=0;b&=63;if(b&32)b=64-b,16>=b;else if(b)if(16>15&65535;d&&65535!==d&&(this.l=32768)}this.b[a]=c&65535;this.w=this.o=c;this.a-=(this.h?6:7)+b} +function fe(a){var b=Bd(this,a);a=a>>6&7;var c=this.b[a]<<16|this.b[a|1];this.v=this.l=0;b&=63;if(b&32){b=64-b;32>b-1;this.v=d<<16;d>>=1;c&2147483648&&(d|=4294967295<<32-b)}else b?(d=c<>15,d<<=1,32>=32-b)&&4294967295!==(c|4294967295<>16&65535;this.b[a|1]=d&65535;this.w=d>>16;this.o=d>>16|d;this.a-=(this.h?6:7)+b}function ge(a){N(this,a,!kd(this))}function he(a){N(this,a,kd(this))} +function ie(a){P(this,a,yd(this,a),Kd);this.a-=this.h?9+(this.R&&6<=this.f?1:0):(this.K?5:3)+(7==this.f?2:0)}function je(a){O(this,a,xd(this,a),Ld);this.a-=this.h?9+(this.R&&6<=this.f?1:0):(this.K?5:3)+(7==this.f?2:0)}function ke(a){P(this,a,yd(this,a),Md);this.a-=this.h?9+(this.R&&6<=this.f?1:0):(this.K?5:3)+(7==this.f?2:0)}function le(a){O(this,a,xd(this,a),Nd);this.a-=this.h?9+(this.R&&6<=this.f?1:0):(this.K?5:3)+(7==this.f?2:0)} +function me(a){var b=yd(this,a);a=Bd(this,a);this.ea((0>b?this.b[-b-1]:b)&a);this.a-=this.h?4+(this.R&&6<=this.f?1:0):(this.K?4:3)+(7==this.f?2:0)}function ne(a){var b=xd(this,a);a=Ad(this,a);this.ea(((0>b?this.b[-b-1]&255:b)&a)<<8);this.a-=this.h?4+(this.R&&6<=this.f?1:0):(this.K?4:3)+(7==this.f?2:0)}function oe(a){N(this,a,this.o&65535?0:4)}function pe(a){N(this,a,!ld(this)==!(this.l&32768))}function qe(a){N(this,a,!!(this.o&65535)&&!ld(this)==!(this.l&32768))} +function re(a){N(this,a,!kd(this)&&!!(this.o&65535))}function se(a){N(this,a,(this.o&65535?0:4)||!ld(this)!=!(this.l&32768))}function te(a){N(this,a,kd(this)||(this.o&65535?0:4))}function ue(a){N(this,a,!ld(this)!=!(this.l&32768))}function ve(a){N(this,a,ld(this))}function we(a){N(this,a,!!(this.o&65535))}function xe(a){N(this,a,!ld(this))}function ye(){I(this,12,0,-9)}function ze(a){N(this,a,!0)}function Ae(a){N(this,a,!(this.l&32768))}function Be(a){N(this,a,this.l&32768?2:0)} +function Q(a){a&1&&(this.v=0);a&2&&(this.l=0);a&4&&(this.o=1);a&8&&(this.w=0);this.a-=5}function Ce(a){var b=yd(this,a);a=Bd(this,a);var c=(b=0>b?this.b[-b-1]:b)-a;pd(this,c,a,b);this.a-=this.h?4+(this.R&&6<=this.f?1:0):(this.K?4:3)+(7==this.f?2:0)}function De(a){var b=xd(this,a);a=Ad(this,a);var c=(b=(0>b?this.b[-b-1]&255:b)<<8)-(a<<=8);pd(this,c,a,b);this.a-=this.h?4+(this.R&&6<=this.f?1:0):(this.K?4:3)+(7==this.f?2:0)} +function Ee(a){var b=Bd(this,a);if(b){a=a>>6&7;var c=this.b[a]<<16|this.b[a|1];this.v=this.l=0;b&32768&&(b|=-65536);var d=~~(c/b);-32768<=d&&32767>=d?(this.b[a]=d&65535,this.b[a|1]=c-d*b&65535,this.o=d>>16|d,this.w=d>>16):(this.l=32768,this.o=d>>15|d,this.w=c>>16,-1===b&&65534===this.b[a]&&(this.b[a]=this.b[a|1]=1));this.a-=53}else this.o=this.w=0,this.l=32768,this.v=65536,this.a-=7}function Fe(){I(this,24,0,-9);this.a-=20} +function Ge(){this.i&49152?(this.D|=128,I(this,4,0,-8)):(this.na&&1120==this.pa&&this.na.setData(this.b[0],!0),this.F?this.F.i():F(this));this.a-=7}function He(){I(this,16,0,-9);this.a-=20}var Ie=[0,7,7,10,7,11,9,13];function Je(a){this.aa=this.a;id(this,zd(this,a));this.a=this.aa-Ie[this.h]}var Ke=[0,14,14,17,14,18,16,20];function Le(a){this.aa=this.a;var b=zd(this,a);a=a>>6&7;qd(this,this.b[a]);this.b[a]=this.b[7];id(this,b);this.a=this.aa-Ke[this.h]} +var Me=[3,9,9,13,10,14,12,16,4,9,9,13,10,14,13,17];function Ne(a){var b=yd(this,a);this.aa=this.a;Dd(this,a,b,this.ea);this.a=this.aa-Me[(this.K?8:0)+this.h]+(7!=this.f||this.h?0:2)}function Oe(a){var b=xd(this,a);Cd(this,a,b,65535,this.ea);this.a-=this.h?9+(this.R&&6<=this.f?1:0):(this.K?5:3)+(7==this.f?2:0)}var Pe=[7,13,13,17,14,18,17,21]; +function Qe(a){var b=Bd(this,a);a=a>>6&7;b=(b<<16>>16)*(this.b[a]<<16>>16);this.b[a]=b>>16&65535;this.b[a|1]=b&65535;b|=0;this.w=b>>16;this.o=this.w|b;this.l=0;this.v=-32768>b||32767>6;if(this.b[b]=this.b[b]-1&65535)id(this,this.b[7]-((a&63)<<1)),this.a+=1;this.a-=6}function We(a){P(this,a,yd(this,a),$d);this.a-=this.h?9+(this.R&&6<=this.f?1:0):(this.K?5:3)+(7==this.f?2:0)}function Xe(a){P(this,a,0,be);this.a-=this.h?9:3+(7==this.f?2:0)}function Ye(){I(this,28,0,-9)} +function Ze(){this.na&&(this.na.U=this.b[7],this.na.setData(this.b[0],!0));this.g|=8;md(this,-2);this.a-=3}function $e(a){P(this,a,this.b[(a>>6&7)+this.hc],ce);this.a-=this.h?9:3+(7==this.f?2:0)}function S(){I(this,8,0,-9)}function ed(a){af[a>>12].call(this,a)}function bf(a){cf[a>>6&3].call(this,a)}function df(a){ef[a>>6&3].call(this,a)}function ff(a){gf[a>>6&3].call(this,a)}function hf(a){jf[a&15].call(this,a)}function kf(a){lf[a&15].call(this,a)}function mf(a){nf[a>>6&3].call(this,a)} +function of(a){pf[a>>6&3].call(this,a)}function qf(a){rf[a>>6&3].call(this,a)} +var af=[function(a){sf[a>>8&15].call(this,a)},Ne,Ce,me,ie,ke,de,S,function(a){tf[a>>8&15].call(this,a)},Oe,De,ne,je,le,We,S],sf=[function(a){uf[a>>4&15].call(this,a)},ze,we,oe,pe,ue,qe,se,Le,Le,bf,df,ff,S,S,S],cf=[function(a){Dd(this,a,0,this.La);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){P(this,a,0,Od);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){P(this,a,1,Sd);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){P(this,a,1,Qd);this.a-=this.h?9:3+(7==this.f?2:0)}],ef=[function(a){P(this,a,0,Ud); +this.a-=this.h?11:6},function(a){P(this,a,kd(this)?1:0,Ed);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){P(this,a,kd(this)?1:0,$d);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){a=Bd(this,a);this.La(a);this.a-=this.h?4:3+(7==this.f?2:0)}],gf=[function(a){P(this,a,0,Yd);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){P(this,a,0,Wd);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){P(this,a,0,Id);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){P(this,a,0,Gd);this.a-=this.h?9:3+(7==this.f?2:0)}],uf= +[function(a){vf[a&15].call(this,a)},S,S,S,Je,Je,Je,Je,Te,S,hf,kf,Xe,Xe,Xe,Xe],vf=[Ge,Ze,Ue,ye,He,Se,S,S,S,S,S,S,S,S,S,S],jf=[Re,function(){this.v=0;this.a-=5},function(){this.l=0;this.a-=5},Q,function(){this.o=1;this.a-=5},Q,Q,Q,function(){this.w=0;this.a-=5},Q,Q,Q,Q,Q,Q,Q],lf=[Re,function(){this.v=65536;this.a-=5},function(){this.l=32768;this.a-=5},R,function(){this.o=0;this.a-=5},R,R,R,function(){this.w=32768;this.a-=5},R,R,R,R,R,R,R],tf=[xe,ve,re,te,Ae,Be,ge,he,Fe,Ye,mf,of,qf,S,S,S],nf=[function(a){Cd(this, +a,0,255,this.La);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){O(this,a,0,Pd);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){O(this,a,1,Td);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){O(this,a,1,Rd);this.a-=this.h?9:3+(7==this.f?2:0)}],pf=[function(a){O(this,a,0,Vd);this.a-=this.h?11:6},function(a){O(this,a,kd(this)?1:0,Fd);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){O(this,a,kd(this)?1:0,ae);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){a=Ad(this,a);this.La(a<<8);this.a-=this.h?4:3+ +(7==this.f?2:0)}],rf=[function(a){O(this,a,0,Zd);this.a-=this.h?9+(this.bc&1):3+(7==this.f?2:0)},function(a){O(this,a,0,Xd);this.a-=this.h?9:3+(7==this.f?2:0)},function(a){O(this,a,0,Jd);this.a-=this.h?9+(this.bc&1):3+(7==this.f?2:0)},function(a){O(this,a,0,Hd);this.a-=this.h?9:3+(7==this.f?2:0)}];function fd(a){wf[a>>12].call(this,a)} +var wf=[function(a){xf[a>>8&15].call(this,a)},Ne,Ce,me,ie,ke,de,function(a){yf[a>>8&15].call(this,a)},function(a){zf[a>>8&15].call(this,a)},Oe,De,ne,je,le,We,S],xf=[function(a){Af[a>>4&15].call(this,a)},ze,we,oe,pe,ue,qe,se,Le,Le,bf,df,ff,function(a){Bf[a>>6&3].call(this,a)},S,S],Bf=[function(a){a=this.b[7]+((a&63)<<1)&65535;var b=this.W(a|this.xa);id(this,this.b[5]);this.b[6]=a+2&65535;this.b[5]=b;this.a-=8},function(a){a=vd(this,a,0);this.ea(a);qd(this,a);this.a-=11},function(a){var b=sd(this); +this.aa=this.a;this.ea(b);wd(this,a,0,b);this.a=this.aa-Pe[this.h]},function(a){Dd(this,a,ld(this)?65535:0,this.ea);this.a-=this.h?9:3+(7==this.f?2:0)}],Af=[function(a){Cf[a&15].call(this,a)},S,S,S,Je,Je,Je,Je,Te,function(a){!(a&8)||1145>this.pa?I(this,8,0,-9):(this.i&49152||(this.i=this.i&-225|(a&7)<<5,this.g|=1,this.g&=-3),this.a-=5)},hf,kf,Xe,Xe,Xe,Xe],Cf=[Ge,Ze,function(){rd(this);this.g|=this.i&16;this.a-=13},ye,He,Se,Ue,function(){I(this,8,0,-9)},S,S,S,S,S,S,S,S],yf=[Qe,Qe,Ee,Ee,ee,ee,fe,fe, +$e,$e,S,S,S,S,Ve,Ve],zf=[xe,ve,re,te,Ae,Be,ge,he,Fe,Ye,mf,of,qf,function(a){1145>this.pa?I(this,8,0,-9):Df[a>>6&3].call(this,a)},S,S],Df=[function(){I(this,8,0,-9)},function(a){a=vd(this,a,65536);this.ea(a);qd(this,a);this.a-=11},function(a){var b=sd(this);this.aa=this.a;this.ea(b);wd(this,a,65536,b);this.a=this.aa-Pe[this.h]},function(){I(this,8,0,-9)}]; +function Ef(a){q.call(this,"ROM",a,128);this.ga=this.b=null;this.h=+a.addr;this.a=+a.size;this.i=!1;this.f=a.alias;"string"==typeof this.f&&(this.f=eval(this.f));this.g=a.file;this.l=Fa(this.g);if(this.g){a=this.g;var b=Ga(this.l);"json"!=b&&"hex"!=b&&(a=Qa()+"/api/v1/dump?file="+this.g+"&format=bytes&decimal=true");var c=this;Oa(a,null,!0,function(a,b,f){f?(c.G("Unable to load ROM resource (error "+f+": "+a+")"),c.g=null):(ta(c.Na,a,b),(a=Pa(a,b))?(c.b=a.M,c.ga=a.ga):c.g=null);Ff(c)})}}n(Ef,q); +h=Ef.prototype;h.ha=function(a,b,c,d){this.u=b;this.c=c;this.F=d;Ff(this)};h.ja=function(){this.ga&&(this.F&&this.F.a(this.id,this.h,this.a,this.ga),delete this.ga);return!0};h.ia=function(){return!0}; +function Ff(a){if(!Aa(a)){if(a.g){if(!a.b||!a.u)return;a.a||(a.a=a.b.length);if(a.b.length!=a.a){var b="ROM size ("+Ea(a.b.length,8,!0)+") does not match specified size ("+Ea(a.a,8,!0)+")";a.j.error=!0;a.G(b)}else{a:{b=a.h;if(57344<=b&&b<57344+Tb){var c={},c=(c[b]=[Ef.prototype.sf,Ef.prototype.Bg,null,null,null,a.a>>1],c);if(qb(a.u,a,c)){a.status("Added "+a.a+"-byte ROM at "+Da(b));b=a.i=!0;break a}}else if(Zb(a.u,b,a.a,Ec)){for(c=0;c>>f.h;0>>=f.h;0>>a.h;0=b.length)break;for(var l=l+2,p=b[l++]&255|(b[l++]&255)<<8,t=b[l++]&255|(b[l++]&255)<<8,m=m+((p&255)+(p>>8)+(t&255)+(t>>8)),z=l,y=p-=6;0=b.length)break;m+=b[l++]&255;if(m&255)break;if(y)for(;y--;)hc(a.u,t++,b[z++]&255);else t&1?g=!0:null==d&&(d=t);k=!0}else l++;else l+=2}if(!k&&(null==c&&(c=e),null!=c)){for(e=0;e< +b.length;e++)hc(a.u,c+e,b[e]);k=!0}if(k){if(null==d||g)F(a.c),f=!1;null!=d&&hd(a.c,d,f)}return k}Za(function(){for(var a=A(document,x,"ram"),b=0;b=sa.Nc&&c<=sa.le&&(b=c-(sa.Nc-sa.Ad));b&&(a.preventDefault&&a.preventDefault(),d.ac(b));return!0},c.onkeypress=function(a){a=a||window.event;if(!a.metaKey){var b=a.which||a.keyCode;a.altKey&&b==sa.Cd&&(b=sa.Bd);d.ac(b);a.preventDefault&&a.preventDefault()}return!0},c.onpaste=function(a){a.stopPropagation&&a.stopPropagation(); +a.preventDefault&&a.preventDefault();(a=a.clipboardData||window.clipboardData)&&d.ac(a.getData("Text"))},c.removeAttribute("readonly"),!0}return!1}; +h.ha=function(a,b,c,d){this.A=a;this.u=b;this.c=c;this.F=d;var e=this;this.H=qc(this.c,this.B?-1:48,4,262144);this.I=nc(this.c,function(){var a;a=-1;e.f.length&&(a=e.f.shift()&255,e.w&&97<=a&&122>a&&(a-=32),pc(e.c,e.I,1E3/Math.round(e.J/10)));0<=a&&(e.o=a,e.a&128?e.o|=49152:e.a|=128,e.a&64&&oc(c,e.H))});this.C=qc(this.c,this.B?-1:52,4,262144);this.X=nc(this.c,function(){e.b|=128;e.b&64&&oc(c,e.C)});qb(b,this,Lf,this.B?64832+8*(this.B-1)-65392:0);sb(b,this.reset.bind(this));B(this)}; +h.qd=function(a){if(!this.g){var b=Tc(this.A,"connection");if(b){var c=b.split("->");if(2==c.length){var d=Ka(c[0]);if(d!=this.$a)return;c=Ka(c[1]);if(this.g=ya(c)){var e=this.g.exports;if(e){var f=e.connect;f&&f.call(this.g,this.v);if(this.s=e.receiveData){this.v=a;this.D=e.receiveStatus;this.status("Connected "+this.Na+"."+d+" to "+c);return}}}}this.status("Unable to establish connection: "+b)}}};h.ja=function(a,b){if(!b)if(this.qd(this.v),!a)this.reset();else if(!this.restore(a))return!1;return!0}; +h.ia=function(a){return a?this.save():!0};h.reset=function(){Mf(this)};h.save=function(){var a=new E(this);a.set(0,[this.o,this.a,this.b,this.f]);return a.data()};h.restore=function(a){return Mf(this,a[0])};function Mf(a,b){b||(b=[0,8192,128,a.f]);b=ja(b);a.o=b.next().value;a.a=b.next().value;a.b=b.next().value;a.f=b.next().value;return!0} +h.ac=function(a){if("number"==typeof a)this.f.push(a);else if("string"==typeof a)for(var b=0,c,d=0;d":String.fromCharCode(a);var c=b.length;32>a&&1==c&&(c=0);9==a&&(a=this.R||8,c=a-this.l%a,this.R&&(b=" ".slice(0,c)));this.K&&!this.l&&c&&(b=String.fromCharCode(this.K)+b);this.h.value+=b;this.h.scrollTop=this.h.scrollHeight;this.l+=c}}else if(null!= +this.i){if(10==a||1024<=this.i.length)this.Z(this.i),this.i="";10!=a&&(this.i+=String.fromCharCode(a))}pc(this.c,this.X,1E3/Math.round(this.aa/10));this.b&=-129};var Kf="buffer",Nf={},Lf=(Nf[65392]=[null,null,T.prototype.df,T.prototype.og,"RCSR"],Nf[65394]=[null,null,T.prototype.cf,T.prototype.ng,"RBUF"],Nf[65396]=[null,null,T.prototype.Kf,T.prototype.Tg,"XCSR"],Nf[65398]=[null,null,T.prototype.Jf,T.prototype.Sg,"XBUF"],Nf); +Za(function(){for(var a=A(document,x,"serial"),b=0;b'+b+"");a.innerHTML=b}},!0;case "descTape":return this.m[b]=c,!0;case "readTape":e=Rf;case "loadTape":return e||(e=Sf),this.m[b]=c,c.onclick= +function(){var a=d.m.listTapes;a&&Tf(d,a.options[a.selectedIndex].text,a.value,e)},!0;case "mountTape":if(!this.C){c.parentNode.removeChild(c);break}this.m[b]=c;c.addEventListener("change",function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length});c.onsubmit=function(a){if(a=a.currentTarget[1].files[0]){var b=a.name;Tf(d,Fa(b,!0),b,Sf,a)}return!1};return!0;case Uf:return this.m[b]=c,!0}return!1}; +h.ha=function(a,b,c,d){this.A=a;this.u=b;this.c=c;this.F=d;this.v=Vf(a);var e=this;if(a=Of(this,Tc(this.A,"autoMount")))for(var f in a)"PTR"==f&&(this.B[f]=a[f]);this.s=qc(this.c,56,4,4096);this.H=nc(this.c,function(){1==(e.a&32769)&&!(e.a&128)&&e.lc.indexOf("/api/v1/dump")&&(e=Ga(c),f="json"==e||"gz"==e?encodeURI(c):Qa()+"/api/v1/dump?path="+encodeURIComponent(c)+"&format=json");return!!Oa(f,null,!0,function(e,f,g){var k=0>g&&!!a.A&&!a.A.j.O;g?a.G('Unable to load tape "'+b+'" (error '+g+": "+e+")",k):(ta(a.Na,e,f),(e=Pa(e,f))&&fg(a,b,c,d,e.M,e.ca,e.ba)); +a.j.Va=!1;a.b&&(a.b--,a.b||B(a));cg(a)})}function Yf(a,b,c,d){if((a=a.m.listTapes)&&a.options){for(var e=0;e>2;var f=e=0,b=new DataView(b,0,d);a.a=Array(a.N);for(d=0;dc.indexOf("/api/v1/dump")&&(b=Ga(c),"json"==b||"gz"==b?f=encodeURI(c):(d="path",e="&mbhd=10",!c.indexOf("http:")||!c.indexOf("ftp:")||0<="dsk ima img 360 720 12 144".split(" ").indexOf(b)?(d="disk",e="&mbhd=0"):Ha(c,"/")&&(d="dir"),f=Qa()+"/api/v1/dump?"+d+"="+encodeURIComponent(c)+(a.Dc?"":e)+"&format=json"));return!!Oa(f, +null,!0,function(b,c,d){ng(a,b,c,d)})} +function ng(a,b,c,d){var e=null,f=0>d&&!!a.A&&!a.A.j.O;a.g=!1;if(d)a.controller.G('Unable to load disk "'+a.ua+'" (error '+d+": "+b+")",f);else{ta(a.controller.Na,b,c);try{if(0g&&0c.indexOf("0x")&&'["'!=c.substr(0,2)?JSON.parse(c.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+ +c+")");if(k.length)if(1==k.length)u(k[0]);else{a.N=k.length;a.T=k[0].length;a.P=k[0][0].length;var l=k[0][0][0];a.da=l&&l.length||512;for(d=c=0;d>2,p=l.pattern;void 0===p&&(p=l.pattern=0);var t=l.data;if(void 0===t){var z=l.bytes;if(void 0!==z&&z.length){for(var y=m<<2,fa=z.length;fa>2,e=Array(d),f=0;f>2,c=(d>((b&3)<<3)&255;return c};h.write=function(a,b,c){if(this.g)return!1;if(b>2;b=(b&3)<<3;for(var g=d.length;g<=f;g++)d[g]=e;a.la?f=a.ta+a.la&&(a.la+=f-(a.ta+a.la)+1):(a.ta=f,a.la=1);d[f]=d[f]&~(255<g)break;e|=g<=this.a.length||l>=this.a[k].length||m>=this.a[k][l].length){c="sector (CHS="+k+":"+l+":"+m+") out of range ("+ +b+" changes applied)";b=-1;break}if(this.g){c="unable to modify write-protected disk";b=-1;break}e=g[f++];f=g[f++];g=e+f.length;if(k=this.a[k][l][m]){for(l=k.data.length;lb&&-2!=b&&this.controller.G("Unable to restore disk '"+this.ua+": "+c);return b}; +h.toJSON=function(){var a;a=0;for(var b;b=pg(this,a++);)rg(b);a=JSON.stringify(this.a,function(a,b){if("file"!=a)return b});a=a.replace(/,"length":512/gm,"").replace(/,"pattern":0/gm,"");a=a.replace(/"(sector|length|data|pattern)":/gm,"$1:");a=a.replace(/,"[^"]*":([0-9]+|true|false)/gm,"");a=a.replace(/(sector|length|data|pattern):/gm,'"$1":');return a=a.replace(/([\]}]),/gm,"$1,\n")}; +function rg(a){var b=a.data,c=b.length;if(c<<2==a.length){for(var d=c-1,e=b[d],f=0;d--&&b[d]===e;)f++;f++&&(b.length=c-f,a.pattern=e)}}var jg=0;function sg(a,b,c,d,e,f){q.call(this,a,b,c);this.w=tg(this,b.autoMount);this.s=0;this.D=d;this.H=e;this.I=f;this.C=d.Pc;this.b=Array(this.C);this.B=!Va("Mobi")&&window&&"FileReader"in window;this.h=[];this.jb=null;this.exports={selectDrive:this.Nf}}n(sg,q); +function tg(a,b){if(b&&"string"==typeof b)try{b=eval("("+b+")")}catch(c){u(a.type+" auto-mount error: "+c.message+" ("+b+")"),b=null}return b||{}}h=sg.prototype; +h.ka=function(a,b,c){var d=this;switch(b){case "listDisks":return this.m[b]=c,c.onchange=function(){var a=d.m.descDisk,b=c.options&&c.options[c.selectedIndex];if(a&&b){var g={};if(b=b.getAttribute("data-value"))try{g=eval("("+b+")")}catch(k){u(d.type+" option error: "+k.message)}b=g.desc;void 0===b&&(b="");g=g.href;void 0!==g&&(b=''+b+"");a.innerHTML=b}},!0;case "descDisk":case "listDrives":return this.m[b]=c,c.onchange=function(){var a=Ca(c.value);null!=a&&ug(d, +a)},!0;case "loadDisk":return this.m[b]=c,c.onclick=function(){var a=d.m.listDisks;a&&a.options&&vg(d,a.options[a.selectedIndex].text,a.value)},!0;case "bootDisk":return this.m[b]=c,c.onclick=function(){var a,b=d.m.listDrives,b=b&&Ca(b.value);null==b||0>b||b>=d.b.length||!(a=d.b[b])?d.G("Unable to boot the selected drive"):a.V?(hd(d.c,0,!0),(a=d.Gb(a,0,0,0,512,0,2))&&d.G("Unable to read the boot sector ("+a+")")):d.G("Load a disk into the drive first")},!0;case "saveDisk":if(!this.B){c.parentNode.removeChild(c); +break}this.m[b]=c;c.onclick=function(){var a=d.m.listDrives;if(a&&a.options&&d.b)if(a=d.b[Ca(a.value)||0])if(a=a.V){var b;b="";for(var c=0,k;k=pg(a,c++);)for(var l=0,m=k.length;lg||9e||e>=a.b.length)a.G("Unable to load the selected drive");else if(c)if(c==yg)a.G('Use "Choose File" and "Mount" to select and load a local disk.');else{if(c==zg){c=window.prompt("Enter the URL of a remote disk image.","")||"";if(!c)return;b=Fa(c);a.status("Attempting to load "+c+' as "'+b+'"')}Fg(a,e,b,c,!1,d)}else Bg(a,e)} +function Fg(a,b,c,d,e,f){var g=-1,k=a.b[b];k.ma.toLowerCase()!=d.toLowerCase()&&(g++,Bg(a,b,!0),k.Cc?a.G(a.type+" busy"):(k.Cc=!0,e&&(k.Bc=!0,a.s++),k.ib=!!f,mg(new ig(a,k,"preload"),c,d,f,a.nd)&&g++));return g} +h.nd=function(a,b,c,d,e){a.Cc=!1;b&&(b.N>a.N||b.T>a.T)&&(this.G('Disk "'+c+'" too large for drive '+(this.type.substr(0,2)+a.Vb)),b=null);b?(a.V=b,a.ua=c,a.ma=d,Gg(this,c,d,b),this.G('Loaded disk "'+c+'" in drive '+(this.type.substr(0,2)+a.Vb),a.Bc||e),this.A&&$c(this.A)):a.ib=!1;a.Bc&&(a.Bc=!1,--this.s||B(this));ug(this,a.Vb)}; +function wg(a,b,c,d){if((a=a.m.listDisks)&&a.options){for(var e=0;e=a.N){m=V.Mb;break}p=a.seek(b,c,d+1);if(!p){m=V.gd;break}t=0;++d>=a.P&&(d=0,++c>=a.T&&(c=0,++b))}var z,y;if(0>(z=a.read(p,t++))||0>(y=a.read(p,t++))){m=V.Nb;break}if(!k&&(Mb(this.u,td(this.c,f),z|y<<8),mc(this.u))){m=V.ub;break}t>=a.da&&(p=null);f+=g;e--}return l?l(m,b,c,d,e,f):m}; +h.gc=function(a,b,c,d,e,f,g,k,l){var m=0;a=a.V;var p=null,t;a||(m=V.Yc,e=0);for(;e;){var z=Ob(this.u,td(this.c,f));if(mc(this.u)){m=V.ub;break}if(!p){if(b>=a.N){m=V.Mb;break}p=a.seek(b,c,d+1,!0);if(!p){m=V.gd;break}t=0;++d>=a.P&&(d=0,++c>=a.T&&(c=0,++b))}if(k){var y,fa;if(0>(y=a.read(p,t++))||0>(fa=a.read(p,t++))){m=V.Nb;break}if(z!=(y|fa<<8)){m=V.kd;break}}else if(!a.write(p,t++,z&255)||!a.write(p,t++,z>>8)){m=V.Nb;break}t>=a.da&&(p=null);f+=g;e--}return l?l(m,b,c,d,e,f):m}; +h.Rd=function(a,b,c,d,e,f){this.i=f&65535;this.a=this.a&~U.Ya|f>>16-U.S.Ya&U.Ya;this.l=65536-e&65535;this.g=this.g&~W.xc|d&W.xc;this.f|=a;Kg(this);return!0};function Kg(a){a.a&=~U.tb;a.f&&(a.f|=V.Fd,a.a|=U.tb,a.f&V.qc&&(a.a|=U.qc))}h.jf=function(){return this.v};h.tg=function(){};h.kf=function(){return this.f};h.ug=function(){};h.ff=function(){return this.a&U.wc}; +h.qg=function(a){this.a=this.a&~U.Ta|a&U.Ta;if(this.a&U.Rc){a=!0;var b,c,d=(this.g&W.Ma)>>W.S.Ma,e=this.b[d],f,g,k,l,m,p;this.a&=~(U.wa|U.yc);this.f&=~V.be;switch(c=this.a&U.ra){case Lg.zd:this.f=this.g=0;this.a=U.wa;break;case Lg.Nd:case Lg.Pd:b=this.Gb;case Lg.zc:case Lg.ke:b||(b=this.gc);f=(this.g&W.sb)>>W.S.sb;g=(this.g&W.rc)>>W.S.rc;k=this.g&W.xc;l=65536-this.l&65535;m=(this.a&U.Ya)<<16-U.S.Ya|this.i;p=this.a&U.Ld?0:2;if(f>=e.N){this.f|=V.Mb;break}if(k>=e.P){this.f|=V.Nb;break}a=b.call(this, +e,f,g,k,l,m,p,c>=Lg.zc,this.Rd.bind(this));break;case Lg.Sb:f=(this.g&W.sb)>>W.S.sb;f(p=a.read(k,m++))||0>(t=a.read(k,m++))){g=Y.ya;break}Mb(this.u,td(this.c,f),p|t<<8);if(mc(this.u)){g=Y.ub;break}f+=2;e--;if(m>=a.da&&(k=null,++d>=a.P&&(d=0,++c>=a.T&&(c=0,++b>=a.N)))){g=Y.ya;break}}return l?l(g,b,c,d,e,f):g}; +h.gc=function(a,b,c,d,e,f,g,k,l){g=0;a=a.V;k=null;var m;a||(g=Y.ya,e=0);for(;e;){var p=Ob(this.u,td(this.c,f));if(mc(this.u)){g=Y.ub;break}f+=2;e--;if(!k){k=a.seek(b,c,d+1,!0);if(!k){g=Y.ya;break}m=0}if(!a.write(k,m++,p&255)||!a.write(k,m++,p>>8)){g=Y.ya;break}if(m>=a.da&&(k=null,++d>=a.P&&(d=0,++c>=a.T&&(c=0,++b>=a.N)))){g=Y.ya;break}}return l?l(g,b,c,d,e,f):g}; +h.Wd=function(a,b,c,d,e,f){this.o=f&65535;this.a=this.a&~X.va|f>>16-X.S.va&X.va;this.i=f>>16&Og.vc;this.g=this.f=b<>X.S.va;if(!(this.a&X.wa)){a=!0;var b,c=this.b[(this.a&X.Ma)>>X.S.Ma],d=c.V,e,f,g;this.a&=~X.Xa;switch(this.a&X.ra){case Pg.fe:this.l&Qg.Sc&&(this.a&=X.Xa|X.ra|X.va);this.l=c.status|this.g&Z.Rb|(d&&512==d.N?Qg.Id:0);break;case Pg.Sb:(this.f&Z.Hd)==Z.ce&&(b=this.f&Z.vb,c=(this.f&Z.ee)<<2,this.g=this.f&Z.de?this.g+b:this.g-b,this.f=this.g=this.g&Z.vb|c);break;case Pg.Qd:this.l=this.g;break;case Pg.Od:b=this.Gb;case Pg.je:b||(b=this.gc), +e=this.f>>Z.S.vb,f=this.f&Z.Rb?1:0,g=this.f&Z.ed,!d||e>=d.N||g>=d.P?this.a=this.a|Y.ya|X.tb:(a=65536-this.l&65535,d=(this.i&Og.vc)<<16|this.o,a=b.call(this,c,e,f,g,a,d,2,!1,this.Wd.bind(this)))}a&&(this.a=this.a|X.Xa|X.wa,this.a&X.tc&&oc(this.c,this.jb))}};h.mf=function(){return this.o};h.wg=function(a){this.o=a&Rg.Ta};h.qf=function(){return this.f};h.zg=function(a){this.f=a};h.rf=function(){return this.l};h.Ag=function(a){this.l=a};h.nf=function(){return this.i}; +h.xg=function(a){this.i=a&Og.vc;this.a=this.a&~X.va|(this.i&3)<\nLicense: GPL version 3 or later ");this.Z("Portions adapted from the PDP-11/70 Emulator by Paul Nankervis ");for(b=0;bWg){if(Xg(d,this.s)){this.h=new E(this,"1.33.0",fh);Xg(this.h)&&(ih(this,d),a=jh,kh(this.h));this.h.set(ch,Na());lh(this.h);var e=this.a&&!this.o;if(a==dh||wa("Click OK to restore the previous "+hb+" machine state, or CANCEL to reset the machine.")){if(c=bh(d)){var f=d.get("code"),g=d.get("data");f&&("ok"==f?Xg(d,g):("error"==f&&"no machine state"!= +g?(this.G("Error: "+g),"unable to verify user"==g&&(Ua(mh,""),this.b=null)):this.Z(f+": "+g),kh(d),Xg(d)?(c=bh(d),e=!0):c=!1))}e&&$g(this,c?d:null)}else a==jh&&d.clear()}else $g(this);delete this.s;delete this.l}e=xa(this.id);for(f=0;fa[1];a=a[2];this.H=!0;this.j.O=!0;var d=this.m.power;d&&(d.textContent="Shutdown");this.c&&(nh(this,this.c,b,c,a),Kb(this,-2),this.c.Y());this.C&&(ih(this,b),b.clear());!c&&this.h&&(this.h.clear(),delete this.h);this.g=0}; +function ih(a,b){if(wa("There may be a problem with your "+hb+" machine.\n\nTo help us diagnose it, click OK to send this "+hb+" machine state to http://www.pcjs.org.")){var c=a.K;a=a.b||"";b=b.toString();var d={};d.app=hb;d.ver="1.33.0";d.url=c;d.user=a;d.type="bug";d.data=b;Oa("http://www.pcjs.org/api/v1/report",d,!0)}} +function oh(a,b,c){var d,e="none";if(a.g)return null;a.g--;var f=new E(a,"1.33.0"),g=new E(a,"1.33.0",ah),k=Na();g.set(ch,k);f.set(ch,k);f.set(ph,"1.33.0");f.set(qh,window?window.location.href:null);f.set(rh,window?window.navigator.userAgent:"");a.c&&a.c.ia&&(c&&(b&&(a.c.j.Y=a.c.j.L),F(a.c)),d=a.c.ia(b,c),"object"===typeof d&&f.set(a.c.id,d),c&&(a.c.j.O=!1,!1===d&&(e=null)));for(var k=xa(a.id),l=0;l=d||30<=(c.Lc+=d))&&(e.textContent=c.j.L?c.Oa.toFixed(2)+"Mhz":"Stopped",c.Lc=0)}if(a.f&&(a=a.f,b=b||0,a.l)){c=a.c.j.L;d=!!(a.c.g&8);if(0>=b||60<=(a.i+=b)){for(e=0;eb?a.U=a.c.b[7]:0f.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(f=window.location.pathname+f),d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(f?' url="'+f+'"':"")));e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1PDPjs$2"), +a=a.replace(/().*?(<\/xsl:variable>)/,"$1pdp11$2"));f=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(f=new window.ActiveXObject("Microsoft.XMLDOM"),f.async=!1,f.loadXML(a)):f=(new window.DOMParser).parseFromString(a,"text/xml")}catch(p){f=null,a=p.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");Oa(e,null,!0,function(f,g,k){if(k||!g)c(a,"unable to resolve XML reference: "+d[0]+" ("+k+")");else{if(f=d[3])if(k=g.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=k[0],m,p=/( [a-z]+=)(['"])(.*?)\2/g;m=p.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);k[0]!=l&&(g=g.replace(k[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}g=g.replace(/<\?xml[^>]*>[\r\n]*/, +"");a=a.replace(d[0],g);zh(a,b,c)}})}else c(a,null)} +function Ah(a,b,c,d){function e(a){if(void 0===k){var b=g&&A(g,"machine-warning");k=b&&b[0]||g}k&&(k.innerHTML=Ia(a))}function f(a){e("Error: "+a);l&&(--wh||cb(!0));l=!1}var g,k,l=!0;wh++;ua[a]={};try{if(g=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css";t.styleSheet?t.styleSheet.cssText=m:t.appendChild(document.createTextNode(m));p.appendChild(t)}c|| +(c="/versions/pdpjs/1.33.0/components.xsl");m=function(d,k){k?xh(c,null,null,!1,e,function(d,l){l?(ta(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window?(l=k.transformNode(l))?(g.outerHTML=l,--wh||cb(!0)):f("transformNodeToObject failed"):document.implementation&&document.implementation.createDocument?(d=new XSLTProcessor,d.importStylesheet(l),(l=d.transformToFragment(k,document))?g.parentNode?(g.parentNode.replaceChild(l,g),--wh||cb(!0)):f("invalid machine element: "+ +a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser")):f(d)}):f(d)};"<"!=b.charAt(0)?xh(b,a,d,!0,e,m):yh(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(z){f(z.message)}return l}window.embedPDP11=function(a,b,c,d){cb(!1);return Ah(a,b,c,d)};window.findMachineComponent=function(a,b){return za(b,a+".machine")};window.enableEvents=cb;window.sendEvent=eb;})();//# sourceMappingURL=/tmp/pdpjs/1.33.0/pdp11.map