diff --git a/modules/pc8080/lib/cpu.js b/modules/pc8080/lib/cpu.js index 080676351..316113f20 100644 --- a/modules/pc8080/lib/cpu.js +++ b/modules/pc8080/lib/cpu.js @@ -122,6 +122,11 @@ function CPU(parmsCPU, nCyclesDefault) this.aCounts.nCyclesChecksumInterval = parmsCPU["csInterval"]; this.aCounts.nCyclesChecksumStop = parmsCPU["csStop"]; + /* + * Array of countdown timers managed by addTimer() and setTimer(). + */ + this.aTimers = []; + this.onRunTimeout = this.runCPU.bind(this); // function onRunTimeout() { cpu.runCPU(); }; this.setReady(); @@ -536,6 +541,9 @@ CPU.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) * in anticipation of the timer requiring an update sooner than the normal nCyclesPerYield * period in runCPU() would normally provide. * + * NOTE: In this context, "timer" refers to a timer chip (eg, an Intel 8253) being emulated by + * by the ChipSet component, not the timers managed by the CPU (eg, addTimer(), setTimer(), etc). + * * @this {CPU} * @param {number} nCycles is the target number of cycles to drop the current burst to * @return {boolean} @@ -754,14 +762,14 @@ CPU.prototype.getSpeedTarget = function() * * NOTE: This used to return the target speed, in mhz, but no callers appear to care at this point. * + * @desc Whenever the speed is changed, the running cycle count and corresponding start time must be reset, + * so that the next effective speed calculation obtains sensible results. In fact, when runCPU() initially calls + * setSpeed() with no parameters, that's all this function does (it doesn't change the current speed setting). + * * @this {CPU} * @param {number} [nMultiplier] is the new proposed multiplier (reverts to 1 if the target was too high) * @param {boolean} [fUpdateFocus] is true to update Computer focus * @return {boolean} true if successful, false if not - * - * @desc Whenever the speed is changed, the running cycle count and corresponding start time must be reset, - * so that the next effective speed calculation obtains sensible results. In fact, when runCPU() initially calls - * setSpeed() with no parameters, that's all this function does (it doesn't change the current speed setting). */ CPU.prototype.setSpeed = function(nMultiplier, fUpdateFocus) { @@ -939,6 +947,104 @@ CPU.prototype.calcRemainingTime = function() return msRemainsThisRun; }; +/** + * addTimer(callBack) + * + * Components that want to have timers that periodically fire after some number of milliseconds call + * addTimer() to create the timer, and then setTimer() every time they want to arm it. There is currently + * no removeTimer() because these are generally used for the entire lifetime of a component. + * + * Internally, each timer entry is a preallocated Array with two entries: a cycle countdown in element [0] + * and a callback function in element [1]. A timer is initially dormant; dormant timers have a countdown + * value of -1 (although any negative number will suffice) and active timers have a non-negative value. + * + * Why not use JavaScript's setTimeout() instead? Good question. For a good answer, see setTimer() below. + * + * @this {CPU} + * @param {function()} callBack + * @return {number} timer index + */ +CPU.prototype.addTimer = function(callBack) +{ + var iTimer = this.aTimers.length; + this.aTimers.push([-1, callBack]); + return iTimer; +}; + +/** + * setTimer(iTimer, ms) + * + * Using the timer index from a previous addTimer() call, this sets that timer to fire after the + * specified number of milliseconds. + * + * This is preferred over JavaScript's setTimeout(), because all our timers are effectively paused when + * the CPU is paused (eg, when the Debugger halts execution). Moreover, setTimeout() handlers only run after + * runCPU() yields, which is far too granular for some components (eg, when the SerialPort tries to simulate + * receiver interrupts at 9600 baud). + * + * Ideally, the only function that would use setTimeout() is runCPU(), while the rest of the components would + * use setTimer(); however, due to legacy code (ie, code that predates these functions) and/or laziness, + * that's currently not the case. TODO: Fix. + * + * @this {CPU} + * @param {number} iTimer + * @param {number} ms (converted into a cycle countdown internally) + * @return {number} (number of cycles used to arm timer, or -1 if error) + */ +CPU.prototype.setTimer = function(iTimer, ms) +{ + var nCycles = -1; + if (iTimer >= 0 && iTimer < this.aTimers.length) { + nCycles = (this.aCounts.nCyclesPerSecond * this.aCounts.nCyclesMultiplier) / 1000 * ms; + this.aTimers[iTimer][0] = nCycles; + } + return nCycles; +}; + +/** + * getTimerBurst(nCycles) + * + * Used by runCPU() to either accept or shorten the current burst if any timers need to fire soon. + * + * @this {CPU} + * @param {number} nCycles (number of cycles about to execute) + * @return {number} (either nCycles or less if a timer needs to fire) + */ +CPU.prototype.getTimerBurst = function(nCycles) +{ + for (var i = 0; i < this.aTimers.length; i++) { + var timer = this.aTimers[i]; + if (timer[0] < 0) continue; + if (nCycles > timer[0]) { + nCycles = timer[0]; + } + } + return nCycles; +}; + +/** + * updateTimers(nCycles) + * + * Used by runCPU() to reduce all active timer countdown values by the number of cycles just executed; + * this is the function that actually "fires" any timer(s) whose countdown has reached (or dropped below) + * zero, invoking their callback function. + * + * @this {CPU} + * @param {number} nCycles (number of cycles actually executed) + */ +CPU.prototype.updateTimers = function(nCycles) +{ + for (var i = 0; i < this.aTimers.length; i++) { + var timer = this.aTimers[i]; + if (timer[0] < 0) continue; + timer[0] -= nCycles; + if (timer[0] <= 0) { + timer[0] = -1; // zero is technically an "active" value, so ensure the timer is dormant now + timer[1](); // safe to invoke the callback function now + } + } +}; + /** * runCPU(fUpdateFocus) * @@ -962,22 +1068,37 @@ CPU.prototype.runCPU = function(fUpdateFocus) this.calcStartTime(); try { do { - var nCyclesPerBurst = (this.flags.fChecksum? 1 : this.aCounts.nCyclesPerBurst); - /* * nCyclesPerBurst is how many cycles we WANT to run on each iteration of stepCPU(), but it may run * significantly less (or slightly more, since we can't execute partial instructions). */ + var nCyclesPerBurst = (this.flags.fChecksum? 1 : this.aCounts.nCyclesPerBurst); + + /* + * Adjust nCyclesPerBurst if there are any CPU timers that need to fire within the current burst. + */ + nCyclesPerBurst = this.getTimerBurst(nCyclesPerBurst); + + /* + * Execute the burst. + */ this.stepCPU(nCyclesPerBurst); /* - * nBurstCycles, less any remaining nStepCycles, is how many cycles stepCPU() ACTUALLY ran (nCycles). - * We add that to nCyclesThisRun, as well as nRunCycles, which is the cycle count since the CPU first - * started running. + * nCycles is how many cycles stepCPU() actually ran (nBurstCycles less any remaining nStepCycles). */ var nCycles = this.nBurstCycles - this.nStepCycles; - this.nRunCycles += nCycles; + + /* + * Update any/all timers, firing those whose cycle countdowns have reached (or dropped below) zero. + */ + this.updateTimers(nCycles); + + /* + * Add nCycles to nCyclesThisRun, as well as nRunCycles (the cycle count since the CPU first started). + */ this.aCounts.nCyclesThisRun += nCycles; + this.nRunCycles += nCycles; this.addCycles(0, true); this.updateChecksum(nCycles); diff --git a/modules/pc8080/lib/cpudef.js b/modules/pc8080/lib/cpudef.js index 0eede2a51..f775a43c7 100644 --- a/modules/pc8080/lib/cpudef.js +++ b/modules/pc8080/lib/cpudef.js @@ -60,17 +60,17 @@ var CPUDef = { * Processor Status flag definitions (stored in regPS) */ PS: { - CF: 0x0001, // bit 0: Carry flag + CF: 0x0001, // bit 0: Carry Flag BIT1: 0x0002, // bit 1: reserved, always set - PF: 0x0004, // bit 2: Parity flag + PF: 0x0004, // bit 2: Parity Flag BIT3: 0x0008, // bit 3: reserved, always clear - AF: 0x0010, // bit 4: Auxiliary Carry flag + AF: 0x0010, // bit 4: Auxiliary Carry Flag BIT5: 0x0020, // bit 5: reserved, always clear - ZF: 0x0040, // bit 6: Zero flag - SF: 0x0080, // bit 7: Sign flag + ZF: 0x0040, // bit 6: Zero Flag + SF: 0x0080, // bit 7: Sign Flag ALL: 0x00D5, // all "arithmetic" flags (CF, PF, AF, ZF, SF) MASK: 0x00FF, // - IF: 0x0200 // bit 9: Interrupt flag (set if interrupts enabled; for internal use only) + IF: 0x0200 // bit 9: Interrupt Flag (set if interrupts enabled; Intel calls this the INTE bit) }, PARITY: [ // 256-byte array with a 1 wherever the number of set bits of the array index is EVEN 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, @@ -94,10 +94,9 @@ var CPUDef = { * Interrupt-related flags (stored in intFlags) */ INTFLAG: { - NONE: 0x00, - INTL: 0x07, // last interrupt level requested - INTR: 0x08, // set if interrupt has been requested - HALT: 0x10 // halt requested; see opHLT() + NONE: 0x0000, + INTR: 0x00ff, // mask for 8 bits, representing interrupt levels 0-7 + HALT: 0x0100 // halt requested; see opHLT() }, /* * Opcode definitions diff --git a/modules/pc8080/lib/cpustate.js b/modules/pc8080/lib/cpustate.js index 8803b193d..81487718d 100644 --- a/modules/pc8080/lib/cpustate.js +++ b/modules/pc8080/lib/cpustate.js @@ -938,47 +938,50 @@ CPUState.prototype.pushWord = function(w) CPUState.prototype.checkINTR = function() { if ((this.intFlags & CPUDef.INTFLAG.INTR) && this.getIF()) { - var bRST = CPUDef.OPCODE.RST0 | ((this.intFlags & CPUDef.INTFLAG.INTL) << 3); - this.intFlags &= ~CPUDef.INTFLAG.HALT; - this.clearINTR(); + for (var nLevel = 0; nLevel < 8; nLevel++) { + if (this.intFlags & (1 << nLevel)) break; + } + this.clearINTR(nLevel); this.clearIF(); - this.aOps[bRST].call(this); + this.intFlags &= ~CPUDef.INTFLAG.HALT; + this.aOps[CPUDef.OPCODE.RST0 | (nLevel << 3)].call(this); return true; } return false; }; /** - * clearINTR() + * clearINTR(nLevel) + * + * Clear the corresponding interrupt level. + * + * nLevel can either be a valid interrupt level (0-7), or -1 to clear all pending interrupts + * (eg, in the event of a system-wide reset). * * @this {CPUState} + * @param {number} nLevel (0-7, or -1 for all) */ -CPUState.prototype.clearINTR = function() +CPUState.prototype.clearINTR = function(nLevel) { - this.intFlags &= ~(CPUDef.INTFLAG.INTL | CPUDef.INTFLAG.INTR); + var bitsClear = nLevel < 0? 0xff : (1 << nLevel); + this.intFlags &= ~bitsClear; }; /** * requestINTR(nLevel) * - * This is called by any component that wants to request a h/w interrupt. + * Request the corresponding interrupt level. * - * NOTE: We allow INTR to be set regardless of the current state of interrupt flag (IF), on the theory - * that if/when the CPU briefly turns interrupts off, it shouldn't lose the last h/w interrupt requested. - * So instead of ignoring INTR here, checkINTR() ignores INTR as long as the interrupt flag (IF) is clear. - * - * The downside is that, as long as the CPU has interrupts disabled, an active INTR state will slow stepCPU() - * down slightly. We could avoid that by introducing a two-stage interrupt tracking system, where a separate - * variable keeps track of the last interrupt requested whenever the interrupt flag (IF) is clear, and when - * setIF() finally occurs, that interrupt is propagated to intFlags. But for now, we're going to assume that - * scenario is rare. + * Each interrupt level (0-7) has its own intFlags bit (0-7). If one or more of those bits are set, + * and the Interrupt Flag (IF) is also set, indicating that interrupts are enabled, then checkINTR() + * chooses one of those bits, clears it, clears IF, and executes the corresponding RST opcode. * * @this {CPUState} * @param {number} nLevel (0-7) */ CPUState.prototype.requestINTR = function(nLevel) { - this.intFlags = (this.intFlags & ~CPUDef.INTFLAG.INTL) | nLevel | CPUDef.INTFLAG.INTR; + this.intFlags |= (1 << nLevel); }; /** diff --git a/modules/pc8080/lib/serialport.js b/modules/pc8080/lib/serialport.js index 4e8e6d720..01acc0d5b 100644 --- a/modules/pc8080/lib/serialport.js +++ b/modules/pc8080/lib/serialport.js @@ -115,15 +115,6 @@ function SerialPort(parmsSerial) { Component.bindExternalControl(this, sBinding, SerialPort.sIOBuffer); } - /* - * Define a setTimeout() function that receiveData() can use when there's more data to receive. - */ - this.fnCheckDataReceived = function(serial) { - return function() { - serial.receiveData(); - } - }(this); - /* * No connection until initBus() invokes initConnection(). */ @@ -368,10 +359,20 @@ SerialPort.prototype.initBus = function(cmp, bus, cpu, dbg) this.bus = bus; this.cpu = cpu; this.dbg = dbg; + + var serial = this; + this.timerReceiveData = this.cpu.addTimer(function() { + serial.printMessage("timerReceiveData()"); + serial.receiveData() + }); + this.chipset = /** @type {ChipSet} */ (cmp.getMachineComponent("ChipSet")); + bus.addPortInputTable(this, SerialPort.aPortInput, this.portBase); bus.addPortOutputTable(this, SerialPort.aPortOutput, this.portBase); + this.initConnection(); + this.setReady(); }; @@ -555,9 +556,11 @@ SerialPort.prototype.getBaudTimeout = function(maskRate) */ SerialPort.prototype.receiveByte = function(b) { + this.printMessage("receiveByte(" + str.toHexByte(b) + "): " + str.toHexByte(this.bStatus)); if (!(this.bStatus & SerialPort.UART8251.STATUS.RECV_FULL)) { this.bDataIn = b; this.bStatus |= SerialPort.UART8251.STATUS.RECV_FULL; + this.printMessage("receiveByte(" + str.toHexByte(b) + "): " + str.toHexByte(this.bStatus) + " (requesting interrupt)"); this.cpu.requestINTR(this.nIRQ); return true; } @@ -575,21 +578,8 @@ SerialPort.prototype.receiveData = function() if (this.receiveByte(this.sDataReceived.charCodeAt(0))) { this.sDataReceived = this.sDataReceived.substr(1); } - /* - * TODO: If data has become undeliverable for some reason (eg, the Debugger has paused execution), - * we should stop setting timeouts, and add one or more notification mechanisms to kickstart it again. - */ - if (this.sDataReceived) { - /* - * TODO: setTimeout() is a less-than-ideal solution, because it's too slow; timeouts won't fire until - * the end of a CPU burst. So instead of calculating a number of milliseconds, we should calculate a - * number of CPU cycles, and create a CPU notification mechanism that calls us back after that many cycles - * have elapsed (and which will automatically shorten the current CPU burst as needed). - * - * This will also solve the other issue noted above, because if the CPU has been halted, it won't be - * generating any notifications either. - */ - setTimeout(this.fnCheckDataReceived, this.getBaudTimeout(SerialPort.UART8251.BAUDRATES.RECV_RATE)); + if (this.sDataReceived && this.cpu) { + this.cpu.setTimer(this.timerReceiveData, this.getBaudTimeout(SerialPort.UART8251.BAUDRATES.RECV_RATE)); } } }; diff --git a/versions/pc8080/1.23.3/pc8080-dbg.js b/versions/pc8080/1.23.3/pc8080-dbg.js index 20c99afb5..cf8843eff 100644 --- a/versions/pc8080/1.23.3/pc8080-dbg.js +++ b/versions/pc8080/1.23.3/pc8080-dbg.js @@ -1,247 +1,249 @@ -(function(){var m;function ca(a,b){var c;if(a){b||(b=16);if("$"==a.charAt(0))b=16,a=a.substr(1);else if("0x"==a.substr(0,2))b=16,a=a.substr(2);else{var d=a.charAt(a.length-1).toLowerCase();"h"==d?(b=16,d=null):"."==d&&(b=10,d=null);null==d&&(a=a.substr(0,a.length-1))}var e,d=a,f=b;(f&&10!=f?16==f?null!==d.match(/^[0-9a-f]+$/i):2==f&&null!==d.match(/^[01]+$/i):null!==d.match(/^[0-9]+$/))&&!isNaN(e=parseInt(a,b))&&(c=e|0)}return c} -function n(a,b){var c="";void 0===b?b=8:8=d?48:55),c=String.fromCharCode(d)+c;a>>=4}return c}function t(a){return"0x"+n(a,4)}function da(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0":">",'"':""","'":"'"};function ia(a){return a.replace(/[&<>"']/g,function(a){return ha[a]})}function ja(a,b){return(a+" ").slice(0,b)}function ka(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")} -function la(a,b,c){var d=0,e=a.length,f=0;for(void 0===c&&(c=function(a,b){return a>b?1:a>1,g;g=c(b,a[h]);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 oa(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;c=d?48:55),c=String.fromCharCode(d)+c;a>>=4}return c}function da(a){return"0x"+n(a,2)}function t(a){return"0x"+n(a,4)}function ea(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0":">",'"':""","'":"'"};function ja(a){return a.replace(/[&<>"']/g,function(a){return ia[a]})}function ka(a,b){return(a+" ").slice(0,b)}function la(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")} +function ma(a,b,c){var d=0,e=a.length,f=0;for(void 0===c&&(c=function(a,b){return a>b?1:a>1,g;g=c(b,a[h]);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 pa(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;c=this.H?10:20>=this.H?12:24>=this.H?14:15;this.Ga=1<>2;this.w=this.Ga-1;this.K=this.N/this.Ga|0;this.L=this.K-1;this.A=[];this.u=[];this.J=this.F=!1;this.P=[];this.X=[];a=new F;wb(a,this.I);this.Y=Array(this.K);for(b=0;b>>a.pa;0f&&(l=f);if(g&&g.size){if(g.type==d){if(e+f<=g.G)return g.Ib+=g.G-e,g.G=e,!0;if(e>=g.G+g.Ib){l=g.size-(e-k);l>f&&(l=f);g.Ib=e-g.G+l;e=k+a.Ga;f-=l;h++;continue}}return yb(1,e,f)}e=new F(e,l,a.Ga,d);wb(e,a.I,g);a.Y[h++]=e;e=k+a.Ga;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+zb[d]+" at "+t(b)),!0):yb(2,b,c)}m.aa=function(a){return this.Y[(a&this.B)>>>this.pa].tb(a&this.w,a)}; -function Ab(a,b){return a.Y[(b&a.B)>>>a.pa].Hb(b&a.w,b)}m.Sa=function(a){var b=a&this.w,c=(a&this.B)>>>this.pa;return b!=this.w?this.Y[c].Lc(b,a):this.Y[c++].tb(b,a)|this.Y[c&this.L].tb(0,a+1)<<8};function Bb(a,b){var c=b&a.w,d=(b&a.B)>>>a.pa;return c!=a.w?a.Y[d].fc(c,b):a.Y[d++].Hb(c,b)|a.Y[d&a.L].Hb(0,b+1)<<8}m.ta=function(a,b){this.Y[(a&this.B)>>>this.pa].vb(a&this.w,b&255,a)};function Cb(a,b,c){a.Y[(b&a.B)>>>a.pa].Jb(b&a.w,c&255,b)} -m.Ub=function(a,b){var c=a&this.w,d=(a&this.B)>>>this.pa;c!=this.w?this.Y[d].Oc(c,b&65535,a):(this.Y[d++].vb(c,b&255,a),this.Y[d&this.L].vb(0,b>>8&255,a+1))};function Db(a,b){if(void 0===b)return a.J=!a.J,a.J;void 0===a.A[b]&&(a.A[b]=[null,!1]);a.A[b][1]=!a.A[b][1];return a.A[b][1]}function Eb(a,b,c,d){void 0===d&&(d=0);if(c)for(var e in c){var f=a,h=+e+d,g=c[e].bind(b);if(void 0!==g)for(var k=+e+d;k<=h;k++)void 0!==f.A[k]?u("Input port "+t(k)+" already registered"):f.A[k]=[g,!1]}} -function Fb(a,b,c){for(var d=1,e=0,f=0;0>>=f)&k;if(void 0!==h){if(h[0])h[0](b,k,d);a.I&&a.F!=h[1]&&Tb(a.I,b,k)}else a.I&&(hb(a.I,a,b,k,d),a.F&&Tb(a.I,b,k));f+=g<<3;b+=g;e-=g}} -function yb(a,b,c){u("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Ub;if(qb){var Vb=new ArrayBuffer(2);(new DataView(Vb)).setUint16(0,256,!0);Ub=256===(new Uint16Array(Vb))[0]}else Ub=!1;var Wb=Ub; -function F(a,b,c,d){this.id=Xb+=2;this.b=null;this.G=a;this.Ib=b;this.size=c||0;this.type=d||Yb;this.A=d==Zb;wb(this);this.Oa=this.vc=!1;if(c)if(qb)this.J=new ArrayBuffer(c),this.F=new DataView(this.J,0,c),this.w=new Uint8Array(this.J,0,c),this.L=new Uint16Array(this.J,0,c>>1),this.b=new Int32Array(this.J,0,c>>2),$b(this,Wb?ac:bc);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},ca:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ha:function(a){var 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},ya:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<>8);this.Oa=!0},P:function(a,b){if(this.I&&null!=this.G){var c=this.I;gc(c,this.G+a,1,c.P)&&c.na(!0)}return this.Hb(a,b)},ea:function(a,b){if(this.I&&null!=this.G){var c=this.I;gc(c,this.G+a,2,c.P)&&c.na(!0)}return this.fc(a,b)},qa:function(a,b,c){if(this.I&&null!=this.G){var d=this.I;gc(d,this.G+a,1,d.F)&&d.na(!0)}this.A?this.B(a,b,c):this.Jb(a,b,c)},Xa:function(a, -b,c){if(this.I&&null!=this.G){var d=this.I;gc(d,this.G+a,2,d.F)&&d.na(!0)}this.A?this.B(a,b,c):this.hc(a,b,c)},O:function(a){return this.w[a]},X:function(a){return this.w[a]},da:function(a){return this.F.getUint16(a,!0)},ga:function(a){return a&1?this.w[a]|this.w[a+1]<<8:this.L[a>>1]},ia:function(a,b){this.w[a]=b;this.Oa=!0},ra:function(a,b){this.w[a]=b;this.Oa=!0},za:function(a,b){this.F.setUint16(a,b,!0);this.Oa=!0},Ca:function(a,b){a&1?(this.w[a]=b,this.w[a+1]=b>>8):this.L[a>>1]=b;this.Oa=!0}}; -function wb(a,b,c){a.I=b;a.M=a.u=0;c&&((a.M=c.M)&&fc(a,ec,!1),(a.u=c.u)&&dc(a,ec,!1))}function hc(a,b){b?0===--a.u&&(a.vb=a.A?a.B:a.Jb,a.Oc=a.A?a.H:a.hc):0===--a.M&&(a.tb=a.Hb,a.Lc=a.fc)}function dc(a,b,c){c&&a.u||(a.vb=!a.A&&b[2]||a.B,a.Oc=!a.A&&b[3]||a.H);if(c||void 0===c)a.Jb=b[2]||a.B,a.hc=b[3]||a.H}function fc(a,b,c){c&&a.M||(a.tb=b[0]||a.K,a.Lc=b[1]||a.N);if(c||void 0===c)a.Hb=b[0]||a.K,a.fc=b[1]||a.N}function $b(a,b){b||(b=ic);fc(a,b,void 0);dc(a,b,void 0)} -var ic=[],cc=[F.prototype.ca,F.prototype.ha,F.prototype.ya,F.prototype.Da],ec=[F.prototype.P,F.prototype.ea,F.prototype.qa,F.prototype.Xa];if(qb)var bc=[F.prototype.O,F.prototype.da,F.prototype.ia,F.prototype.za],ac=[F.prototype.X,F.prototype.ga,F.prototype.ra,F.prototype.Ca]; -function jc(a,b){x.call(this,"CPU",a,jc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.sb=c;this.i.Qb=0;this.i.eb=d;this.i.bc=Math.round(this.i.sb/1E4)/100;this.i.bb=this.i.bc*this.i.eb;this.D.xa=!1;this.D.Xb=!1;this.D.uc=a.autoStart;this.D.wc=!1;this.D.lb=!1;this.i.Bb=this.i.pb=0;this.i.Cb=a.csStart;this.i.ob=a.csInterval;this.i.qb=a.csStop;this.X=this.fb.bind(this);E(this)}Xa(jc);var kc=["power","reset"];m=jc.prototype; -m.Qa=function(a,b,c,d){this.A=a;this.w=b;this.I=d;for(b=0;b=a.i.pb&&(a.i.pb+=a.i.ob,c=!0);0<=a.i.qb&&a.i.qb<=Ec(a)&&(a.i.ob=a.i.qb=-1,nc(a),a.na(),c=!0);c&&a.g(Ec(a)+" cycles: checksum="+n(a.i.Bb))}} -m.ma=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.M[b]=c;a=!0;break;case "run":this.M[b]=c;c.onclick=function(){var a;if(a=d.A)if(a=d.A,a.D.ua)a=!0;else{var b=null,c,g=bb(a.id);for(c=0;cc&&(c=2);var d=1;b&&1a.i.ab/a.i.bb?b=1:d=!0;a.i.eb=b;b=a.i.bc*a.i.eb;if(a.i.bb!=b){a.i.bb=b;b=a.i.bb.toFixed(2)+"Mhz";var e=a.M.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.A&&a.A.gb()}Gc(a,a.F);a.F=0;a.i.nb=ma();a.i.cb=0;Hc(a);return d} -m.fb=function(a){if(kb(this,!0)){if(!this.D.xa){Fc(this);this.A&&this.A.start(this.i.nb,Ec(this));this.D.xa=!0;this.D.Xb=!0;this.J&&this.J.start();var b=this.M.run;b&&(b.textContent="Halt");this.A&&(this.A.Ia(!0),a&&this.A.gb(!0))}this.i.ec>=this.i.sb&&Hc(this,!0);this.i.Fb=0;this.i.Pb=ma();this.i.cb&&(a=this.i.Pb-this.i.cb,a>this.i.Cc&&(this.i.nb+=a,this.i.nb>this.i.Pb&&(this.i.nb=this.i.Pb)));try{do{this.ub(this.D.lb?1:this.i.Hd);var c=this.B-this.b;this.F+=c;this.i.Fb+=c;Gc(this,0,!0);Dc(this, -c);this.i.Eb-=c;0>=this.i.Eb&&(this.i.Eb+=this.i.Ec,this.A&&Ic(this.A,this.i.Qb++),this.i.Qb>this.K&&(this.i.Qb=0));this.i.Db-=c;0>=this.i.Db&&(this.i.Db+=this.i.Dc,this.A&&this.A.Ia());this.i.rb-=c;if(0>=this.i.rb){this.i.rb+=this.i.dc;break}}while(this.D.xa)}catch(e){this.na();Bc(this);this.A&&this.A.stop(ma(),Ec(this));kb(this,!1);nb(this,e.stack||e.message);return}c=setTimeout;a=this.X;this.i.cb=ma();b=this.i.Cc;this.i.Fb&&(b=Math.round(b*this.i.Fb/this.i.dc));var b=b-(this.i.cb-this.i.Pb),d= -this.i.cb-this.i.nb;d&&(this.i.ab=Math.round(this.F/(10*d))/100,864E5<=d&&(this.H=0,Fc(this)));if(0>b||this.i.ab>8&255;a.T=b&255}function Sc(a){return a.U<<8|a.V}function Tc(a,b){a.U=b>>8&255;a.V=b&255}function J(a){return a.W<<8|a.Z} -function Uc(a,b){a.W=b>>8&255;a.Z=b&255}function G(a,b){a.R=b&65535}function Vc(a){return a.ba&256?1:0}function Wc(a,b){a.ba=a.ba&255|b}function Xc(a){return rb[a.fa&255]?4:0}function Yc(a){return(a.fa^a.wa)&16?16:0}function Zc(a){return a.ba&255?0:64}function $c(a){return a.fa&128?128:0}function Pc(a){return a.va&-214|$c(a)|Zc(a)|Yc(a)|Xc(a)|Vc(a)}function Nc(a,b){a.ba=a.fa=a.wa=0;b&1&&(a.ba|=256);b&4||(a.fa|=1);b&16&&(a.wa|=16);b&64||(a.ba|=255);b&128&&(a.fa^=192);a.va=a.va&-726|b&512|2} -function ad(a,b){a.wa=a.j^b;return a.fa=(a.ba=a.j+b)&255}function bd(a,b){a.wa=a.j^b;return a.fa=(a.ba=a.j+b+(a.ba&256?1:0))&255}function cd(a,b){a.ba=a.fa=a.wa=a.j&b;(a.j|b)&8&&(a.wa^=16);return a.ba}function dd(a,b){a.wa=b^255;b=a.fa=b+255&255;a.ba=a.ba&-256|b;return b}function ed(a,b){a.wa=b;b=a.fa=b+1&255;a.ba=a.ba&-256|b;return b}function fd(a,b){return a.fa=a.ba=a.wa=a.j|b}function K(a,b){b^=255;a.wa=a.j^b;return a.fa=(a.ba=a.j+b+1^256)&255} -function zd(a,b){b^=255;a.wa=a.j^b;return a.fa=(a.ba=a.j+b+(a.ba&256?0:1)^256)&255}function Ad(a,b){return a.fa=a.ba=a.wa=a.j^b}m.aa=function(a){return this.w.aa(a)};m.ta=function(a,b){this.w.ta(a,b)};function L(a){var b=a.aa(a.R);G(a,a.R+1);return b}function M(a){var b=a.w.Sa(a.R);G(a,a.R+2);return b}function O(a){var b=a.w.Sa(a.la);a.la=a.la+2&65535;return b}function P(a,b){a.la=a.la-2&65535;a.w.Ub(a.la,b)}function Bd(a,b){a.u=a.u&-8|b|8} -function R(a,b,c,d){d=d||2;a.M[b]&&(void 0===c&&(nb(a,"Value for "+b+" is invalid"),a.na()),c=!a.D.xa||a.D.wc?n(c,d):"--------".substr(0,d),a.M[b].textContent!=c&&(a.M[b].textContent=c))} -m.Ia=function(a){this.P&&(a||!this.D.xa||this.D.wc)&&(R(this,"A",this.j),R(this,"B",this.S),R(this,"C",this.T),R(this,"BC",Qc(this),4),R(this,"D",this.U),R(this,"E",this.V),R(this,"DE",Sc(this),4),R(this,"H",this.W),R(this,"L",this.Z),R(this,"HL",J(this),4),R(this,"SP",this.la,4),R(this,"PC",this.R,4),a=Pc(this),R(this,"PS",a,4),R(this,"IF",a&512?1:0,1),R(this,"SF",a&128?1:0,1),R(this,"ZF",a&64?1:0,1),R(this,"AF",a&16?1:0,1),R(this,"PF",a&4?1:0,1),R(this,"CF",a&1?1:0,1));if(a=this.M.speed)a.textContent= -this.D.xa&&this.i.ab?this.i.ab.toFixed(2)+"Mhz":"Stopped"};m.ub=function(a){this.D.Nb=!0;var b=this.D.xd=this.I&&Cd(this.I),c=a?this.D.Xb?0:1:-1;this.D.Xb=!1;this.B=this.b=a;do{if(this.u){if(a&&this.u&8&&this.va&512){var d=199|(this.u&7)<<3;this.u&=-17;this.u&=-16;this.va&=-513;this.N[d].call(this)}if(this.u&16){this.b=0;break}}if(b){if(Dd(this.I,this.R,c)){this.na();break}c=1}this.N[L(this)].call(this)}while(0>8;Wc(this,a&256);this.b-=4},Ed,function(){var a;Uc(this,a=J(this)+Qc(this));Wc(this,a>>8&256);this.b-=10},function(){this.j=this.aa(Qc(this));this.b-=7},function(){Rc(this,Qc(this)-1);this.b-= -5},function(){this.T=ed(this,this.T);this.b-=5},function(){this.T=dd(this,this.T);this.b-=5},function(){this.T=L(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;Wc(this,a);this.b-=4},Ed,function(){Tc(this,M(this));this.b-=10},function(){this.ta(Sc(this),this.j);this.b-=7},function(){Tc(this,Sc(this)+1);this.b-=5},function(){this.U=ed(this,this.U);this.b-=5},function(){this.U=dd(this,this.U);this.b-=5},function(){this.U=L(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255| -Vc(this);Wc(this,a&256);this.b-=4},Ed,function(){var a;Uc(this,a=J(this)+Sc(this));Wc(this,a>>8&256);this.b-=10},function(){this.j=this.aa(Sc(this));this.b-=7},function(){Tc(this,Sc(this)-1);this.b-=5},function(){this.V=ed(this,this.V);this.b-=5},function(){this.V=dd(this,this.V);this.b-=5},function(){this.V=L(this);this.b-=7},function(){var a=this.j<<8;this.j=(Vc(this)<<8|this.j)>>1;Wc(this,a&256);this.b-=4},Ed,function(){Uc(this,M(this));this.b-=10},function(){var a=M(this);this.w.Ub(a,J(this)); -this.b-=16},function(){Uc(this,J(this)+1);this.b-=5},function(){this.W=ed(this,this.W);this.b-=5},function(){this.W=dd(this,this.W);this.b-=5},function(){this.W=L(this);this.b-=7},function(){var a=0,b=Vc(this);if(Yc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=ad(this,a);Wc(this,b?256:0);this.b-=4},Ed,function(){var a;Uc(this,a=J(this)+J(this));Wc(this,a>>8&256);this.b-=10},function(){var a;a=M(this);a=this.w.Sa(a);Uc(this,a);this.b-=16},function(){Uc(this,J(this)-1);this.b-=5},function(){this.Z= -ed(this,this.Z);this.b-=5},function(){this.Z=dd(this,this.Z);this.b-=5},function(){this.Z=L(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},Ed,function(){this.la=M(this)&65535;this.b-=10},function(){this.ta(M(this),this.j);this.b-=13},function(){this.la=this.la+1&65535;this.b-=5},function(){var a=J(this);this.ta(a,ed(this,this.aa(a)));this.b-=10},function(){var a=J(this);this.ta(a,dd(this,this.aa(a)));this.b-=10},function(){this.ta(J(this),L(this));this.b-=10},function(){this.ba|=256;this.b-= -4},Ed,function(){var a;Uc(this,a=J(this)+this.la);Wc(this,a>>8&256);this.b-=10},function(){this.j=this.aa(M(this));this.b-=13},function(){this.la=this.la-1&65535;this.b-=5},function(){this.j=ed(this,this.j);this.b-=5},function(){this.j=dd(this,this.j);this.b-=5},function(){this.j=L(this);this.b-=7},function(){Wc(this,Vc(this)?0:256);this.b-=4},function(){this.b-=5},function(){this.S=this.T;this.b-=5},function(){this.S=this.U;this.b-=5},function(){this.S=this.V;this.b-=5},function(){this.S=this.W; -this.b-=5},function(){this.S=this.Z;this.b-=5},function(){this.S=this.aa(J(this));this.b-=7},function(){this.S=this.j;this.b-=5},function(){this.T=this.S;this.b-=5},function(){this.b-=5},function(){this.T=this.U;this.b-=5},function(){this.T=this.V;this.b-=5},function(){this.T=this.W;this.b-=5},function(){this.T=this.Z;this.b-=5},function(){this.T=this.aa(J(this));this.b-=7},function(){this.T=this.j;this.b-=5},function(){this.U=this.S;this.b-=5},function(){this.U=this.T;this.b-=5},function(){this.b-= -5},function(){this.U=this.V;this.b-=5},function(){this.U=this.W;this.b-=5},function(){this.U=this.Z;this.b-=5},function(){this.U=this.aa(J(this));this.b-=7},function(){this.U=this.j;this.b-=5},function(){this.V=this.S;this.b-=5},function(){this.V=this.T;this.b-=5},function(){this.V=this.U;this.b-=5},function(){this.b-=5},function(){this.V=this.W;this.b-=5},function(){this.V=this.Z;this.b-=5},function(){this.V=this.aa(J(this));this.b-=7},function(){this.V=this.j;this.b-=5},function(){this.W=this.S; -this.b-=5},function(){this.W=this.T;this.b-=5},function(){this.W=this.U;this.b-=5},function(){this.W=this.V;this.b-=5},function(){this.b-=5},function(){this.W=this.Z;this.b-=5},function(){this.W=this.aa(J(this));this.b-=7},function(){this.W=this.j;this.b-=5},function(){this.Z=this.S;this.b-=5},function(){this.Z=this.T;this.b-=5},function(){this.Z=this.U;this.b-=5},function(){this.Z=this.V;this.b-=5},function(){this.Z=this.W;this.b-=5},function(){this.b-=5},function(){this.Z=this.aa(J(this));this.b-= -7},function(){this.Z=this.j;this.b-=5},function(){this.ta(J(this),this.S);this.b-=7},function(){this.ta(J(this),this.T);this.b-=7},function(){this.ta(J(this),this.U);this.b-=7},function(){this.ta(J(this),this.V);this.b-=7},function(){this.ta(J(this),this.W);this.b-=7},function(){this.ta(J(this),this.Z);this.b-=7},function(){var a=this.R-1;if(this.L.length)for(var b=0;b>8;this.b-=10},function(){var a=M(this);$c(this)||G(this,a);this.b-=10},function(){this.va&=-513;this.b-=4},function(){var a=M(this);$c(this)||(P(this,this.R),G(this,a),this.b-=6);this.b-=11},function(){P(this,Pc(this)&255|this.j<<8);this.b-=11},function(){this.j=fd(this,L(this));this.b-=7},function(){P(this,this.R);G(this,48);this.b-=11},function(){$c(this)&&(G(this, -O(this)),this.b-=6);this.b-=5},function(){this.la=J(this)&65535;this.b-=5},function(){var a=M(this);$c(this)&&G(this,a);this.b-=10},function(){this.va|=512;this.b-=4},function(){var a=M(this);$c(this)&&(P(this,this.R),G(this,a),this.b-=6);this.b-=11},Hd,function(){K(this,L(this));this.b-=7},function(){P(this,this.R);G(this,56);this.b-=11}]; -function S(a){x.call(this,"ChipSet",a,S,32768);var b=a.model;b&&!Id[b]&&La("Unrecognized ChipSet model: "+b);this.B=Id[b]||{};a.sound&&(this.ha=null,window&&(this.ha=window.AudioContext||window.webkitAudioContext),this.ha&&new this.ha);E(this)}Xa(S); -var T={Aa:1978.1,sd:{Ba:0,ee:1,ie:16,pe:32,ye:64,xe:128,wb:14},Wa:{Ba:1,Tc:1,md:2,hd:4,jd:16,kd:32,ld:64,wb:8},td:{Ba:2,de:3,Ge:4,fe:8,te:16,ue:32,ve:64,ge:128,wb:0},Ce:{Ba:3},Ae:{Ba:2,qe:7},Ee:{Ba:3,He:1,De:2,we:4,ne:8,he:16,ae:32},Be:{Ba:4},Fe:{Ba:5,je:1,ke:2,le:4,me:8,Ie:16}},U={Aa:100,Ja:{Ba:66,rc:1,nc:2,gd:4,se:8,re:16,pc:32,oc:64,kc:128},Sc:{Ba:66,INIT:0},Ua:{Ba:194,ce:0,jc:16,nd:32,qc:48,Xc:0,Yc:32},Kb:{Ba:162,ze:0,$c:0,Wc:0,Zc:0,Vc:0},Ka:{oe:{Ba:98},Ta:{Qc:0,Pc:1,pd:2,ud:4,Uc:5,od:6,qd:7}, -Lb:16383}},Id={SI1978:T,VT100:U};S.prototype.ma=function(){return!1};S.prototype.Qa=function(a,b,c,d){this.w=b;this.b=c;this.I=d;this.A=a;this.L=tb(a,"Keyboard");this.Na=tb(a,"SerialPort");this.video=tb(a,"Video");Eb(b,this,this.B.Rb);Jb(b,this,this.B.Sb)};S.prototype.Ea=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};S.prototype.Ha=function(a){return a?this.save():!0};T.INIT=[[T.sd.wb,T.Wa.wb,T.td.wb,0,0,0,0]]; -U.INIT=[[U.Sc.INIT,U.Ja.nc|U.Ja.gd],[U.Ua.Xc,U.Ua.Yc],[U.Kb.$c,U.Kb.Wc,U.Kb.Zc,U.Kb.Vc],[0,0,0,0,[11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11776,11784,11918,11776,11856,11824,11840,11808,11776,12E3,12E3,11857,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]]]; -m=S.prototype;m.reset=function(){this.B.INIT&&!this.restore(this.B.INIT)&&this.ja("reset error")};m.save=function(){var a=new H(this);switch(this.B.Aa){case T.Aa:I(a,0,[this.Ca,this.F,this.Da,this.ca,this.ga,this.ya,this.za]);break;case U.Aa:I(a,0,[this.ia,this.H]),I(a,1,[this.N,this.O]),I(a,2,[this.J,this.da,this.ra,this.qa]),I(a,3,[this.X,this.u,this.P,this.ea,this.K])}return a.data()}; -m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.B.Aa){case T.Aa:return this.Ca=b[0],this.F=b[1],this.Da=b[2],this.ca=b[3],this.ga=b[4],this.ya=b[5],this.za=b[6],!0;case U.Aa:return this.ia=b[0],this.H=b[1],b=a[1],this.N=b[0],this.O=b[1],b=a[2],this.J=b[0],this.da=b[1],this.ra=b[2],this.qa=b[3],b=a[3],this.X=b[0],this.u=b[1],this.P=b[2],this.ea=b[3],this.K=b[4],!0}return!1};m.start=function(){};m.stop=function(){};m.Bd=function(a,b){var c=this.Ca;D(this,a,null,b,"STATUS0",c,!0);return c}; -m.Cd=function(a,b){var c=this.F;D(this,a,null,b,"STATUS1",c,!0);return c};m.Dd=function(a,b){var c=this.Da;D(this,a,null,b,"STATUS2",c,!0);return c};m.Ad=function(a,b){var c=this.ca>>8-this.ga&255;D(this,a,null,b,"SHIFT.RESULT",c,!0);return c};m.Ld=function(a,b,c){D(this,a,b,c,"SHIFT.COUNT",null,!0);this.ga=b};m.Nd=function(a,b,c){D(this,a,b,c,"SOUND1",null,!0);this.ya=b};m.Md=function(a,b,c){D(this,a,b,c,"SHIFT.DATA",null,!0);this.ca=b<<8|this.ca>>8}; -m.Od=function(a,b,c){D(this,a,b,c,"SOUND2",null,!0);this.za=b};m.Pd=function(a,b,c){D(this,a,b,c,"WATCHDOG",null,!0)};function Jd(a){var b=0,c=0,d=~a.X;for(a=0;10>a;a++)d&1&&(b=9-a),d>>=1;for(a=0;10>a;a++)d&1&&(c=9-a),d>>=1;return 10*b+c} -m.Ed=function(a,b){var c=this.H,c=c&~U.Ja.oc;if((Ec(this.b)&64)<<1&&(c|=U.Ja.oc,c!=this.H)){var d,e;d=this.P&1;e=this.P>>1&7;switch(e){case U.Ka.Ta.qd:break;case U.Ka.Ta.Pc:this.X=this.X<<1|d;break;case U.Ka.Ta.Uc:d=Jd(this);this.K[d]=U.Ka.Lb;ib(this,"doNVRCommand(): erase data at addr "+t(d));break;case U.Ka.Ta.Qc:this.u=this.u<<1|d;break;case U.Ka.Ta.ud:d=Jd(this);e=this.u&U.Ka.Lb;this.K[d]=e;ib(this,"doNVRCommand(): write data "+t(e)+" to addr "+t(d));break;case U.Ka.Ta.od:d=Jd(this);e=this.K[d]; -null==e&&(e=U.Ka.Lb);this.u=e;ib(this,"doNVRCommand(): read data "+t(e)+" from addr "+t(d));break;case U.Ka.Ta.pd:this.u<<=1;this.ea=this.u&U.Ka.Lb+1;break;default:ib(this,"doNVRCommand(): unrecognized command 0x"+n(e,2))}}c&=~U.Ja.pc;this.ea&&(c|=U.Ja.pc);c&=~U.Ja.kc;this.L&&this.L.$b()&&(c|=U.Ja.kc);c&=~U.Ja.rc;this.Na&&this.Na.$b()&&(c|=U.Ja.rc);this.H=c;D(this,a,null,b,"FLAGS",c);return c};m.Qd=function(a,b,c){D(this,a,b,c,"BRIGHTNESS");this.ia=b}; -m.Td=function(a,b,c){D(this,a,b,c,"NVR.LATCH");this.P=b};m.Sd=function(a,b,c){D(this,a,b,c,"DC012");a=b&3;switch(b>>2&3){case 0:this.J=this.J&-4|a;break;case 1:this.J=this.J&-13|a<<2;this.video&&(b=this.video,a=this.J,ib(b,"updateScrollOffset("+a+")"),b.hb!==a&&((b.hb=a)?Kd(b,-1):b.yb=!0));break;case 2:switch(a){case 0:this.da=~this.da;break;case 2:case 3:this.ra=3-a}break;case 3:this.qa=a}}; -m.Rd=function(a,b,c){D(this,a,b,c,"DC011");b&U.Ua.nd?(b&=U.Ua.qc,this.O!=b&&(this.O=b,this.video&&(a=this.video,b=this.O==U.Ua.qc?50:60,ib(a,"updateRate("+b+")"),a.ac=b))):(b&=U.Ua.jc,this.N!=b&&(this.N=b,this.video&&(a=this.N==U.Ua.jc?132:80,b=this.video,ib(b,"updateDimensions("+a+","+(80>>0,h],q=la(p,k,a.Ya);0>q&&p.splice(-(q+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.H.push({Je:b,G:c,Gd:d,Ra:e,sc:f})}delete this.Ra}return!0};Nd.prototype.Ha=function(){return!0}; -function Od(a,b,c,d){if(d)a.ja("Unable to load system ROM (error "+d+": "+b+")");else{ab(a.Yb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.A=f;else if(h)for(a.A=Array(4*h.length),d=c=0;c>8&255,a.A[d++]=h[c]>>16&255,a.A[d++]=h[c]>>24&255;else a.A=e;a.Ra=e.symbols;if(!a.A.length){u("Empty ROM: "+b);return}if(1==a.A.length){u(a.A[0]);return}}catch(g){a.ja("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm, -" ").replace(/ +$/,"").split(" "),a.A=Array(b.length),e=0;e>>f.pa;0>>=f.pa;0=this.H?10:20>=this.H?12:24>=this.H?14:15;this.Ga=1<>2;this.w=this.Ga-1;this.L=this.M/this.Ga|0;this.K=this.L-1;this.A=[];this.u=[];this.F=this.J=!1;this.P=[];this.S=[];a=new G;ub(a,this.I);this.Y=Array(this.L);for(b=0;b>>a.pa;0f&&(l=f);if(g&&g.size){if(g.type==d){if(e+f<=g.G)return g.Ib+=g.G-e,g.G=e,!0;if(e>=g.G+g.Ib){l=g.size-(e-k);l>f&&(l=f);g.Ib=e-g.G+l;e=k+a.Ga;f-=l;h++;continue}}return wb(1,e,f)}e=new G(e,l,a.Ga,d);ub(e,a.I,g);a.Y[h++]=e;e=k+a.Ga;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+xb[d]+" at "+t(b)),!0):wb(2,b,c)}m.aa=function(a){return this.Y[(a&this.B)>>>this.pa].tb(a&this.w,a)}; +function yb(a,b){return a.Y[(b&a.B)>>>a.pa].Hb(b&a.w,b)}m.Sa=function(a){var b=a&this.w,c=(a&this.B)>>>this.pa;return b!=this.w?this.Y[c].Lc(b,a):this.Y[c++].tb(b,a)|this.Y[c&this.K].tb(0,a+1)<<8};function zb(a,b){var c=b&a.w,d=(b&a.B)>>>a.pa;return c!=a.w?a.Y[d].fc(c,b):a.Y[d++].Hb(c,b)|a.Y[d&a.K].Hb(0,b+1)<<8}m.ta=function(a,b){this.Y[(a&this.B)>>>this.pa].vb(a&this.w,b&255,a)};function Ab(a,b,c){a.Y[(b&a.B)>>>a.pa].Jb(b&a.w,c&255,b)} +m.Ub=function(a,b){var c=a&this.w,d=(a&this.B)>>>this.pa;c!=this.w?this.Y[d].Oc(c,b&65535,a):(this.Y[d++].vb(c,b&255,a),this.Y[d&this.K].vb(0,b>>8&255,a+1))};function Bb(a,b){if(void 0===b)return a.F=!a.F,a.F;void 0===a.A[b]&&(a.A[b]=[null,!1]);a.A[b][1]=!a.A[b][1];return a.A[b][1]}function Cb(a,b,c,d){void 0===d&&(d=0);if(c)for(var e in c){var f=a,h=+e+d,g=c[e].bind(b);if(void 0!==g)for(var k=+e+d;k<=h;k++)void 0!==f.A[k]?u("Input port "+t(k)+" already registered"):f.A[k]=[g,!1]}} +function Db(a,b,c){for(var d=1,e=0,f=0;0>>=f)&k;if(void 0!==h){if(h[0])h[0](b,k,d);a.I&&a.J!=h[1]&&Jb(a.I,b,k)}else a.I&&(gb(a.I,a,b,k,d),a.J&&Jb(a.I,b,k));f+=g<<3;b+=g;e-=g}} +function wb(a,b,c){u("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Kb;if(mb){var Lb=new ArrayBuffer(2);(new DataView(Lb)).setUint16(0,256,!0);Kb=256===(new Uint16Array(Lb))[0]}else Kb=!1;var Ub=Kb; +function G(a,b,c,d){this.id=Vb+=2;this.b=null;this.G=a;this.Ib=b;this.size=c||0;this.type=d||Wb;this.A=d==Xb;ub(this);this.Oa=this.vc=!1;if(c)if(mb)this.F=new ArrayBuffer(c),this.J=new DataView(this.F,0,c),this.w=new Uint8Array(this.F,0,c),this.K=new Uint16Array(this.F,0,c>>1),this.b=new Int32Array(this.F,0,c>>2),Yb(this,Ub?Zb:$b);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},ba:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ha:function(a){var 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},ya:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<>8);this.Oa=!0},P:function(a,b){if(this.I&&null!=this.G){var c=this.I;ec(c,this.G+a,1,c.P)&&c.na(!0)}return this.Hb(a,b)},ea:function(a,b){if(this.I&&null!=this.G){var c=this.I;ec(c,this.G+a,2,c.P)&&c.na(!0)}return this.fc(a,b)},qa:function(a,b,c){if(this.I&&null!=this.G){var d=this.I;ec(d,this.G+a,1,d.J)&&d.na(!0)}this.A?this.B(a,b,c):this.Jb(a,b,c)},Ya:function(a, +b,c){if(this.I&&null!=this.G){var d=this.I;ec(d,this.G+a,2,d.J)&&d.na(!0)}this.A?this.B(a,b,c):this.hc(a,b,c)},O:function(a){return this.w[a]},S:function(a){return this.w[a]},da:function(a){return this.J.getUint16(a,!0)},ga:function(a){return a&1?this.w[a]|this.w[a+1]<<8:this.K[a>>1]},ia:function(a,b){this.w[a]=b;this.Oa=!0},ra:function(a,b){this.w[a]=b;this.Oa=!0},za:function(a,b){this.J.setUint16(a,b,!0);this.Oa=!0},Ca:function(a,b){a&1?(this.w[a]=b,this.w[a+1]=b>>8):this.K[a>>1]=b;this.Oa=!0}}; +function ub(a,b,c){a.I=b;a.N=a.u=0;c&&((a.N=c.N)&&dc(a,cc,!1),(a.u=c.u)&&bc(a,cc,!1))}function fc(a,b){b?0===--a.u&&(a.vb=a.A?a.B:a.Jb,a.Oc=a.A?a.H:a.hc):0===--a.N&&(a.tb=a.Hb,a.Lc=a.fc)}function bc(a,b,c){c&&a.u||(a.vb=!a.A&&b[2]||a.B,a.Oc=!a.A&&b[3]||a.H);if(c||void 0===c)a.Jb=b[2]||a.B,a.hc=b[3]||a.H}function dc(a,b,c){c&&a.N||(a.tb=b[0]||a.L,a.Lc=b[1]||a.M);if(c||void 0===c)a.Hb=b[0]||a.L,a.fc=b[1]||a.M}function Yb(a,b){b||(b=gc);dc(a,b,void 0);bc(a,b,void 0)} +var gc=[],ac=[G.prototype.ba,G.prototype.ha,G.prototype.ya,G.prototype.Da],cc=[G.prototype.P,G.prototype.ea,G.prototype.qa,G.prototype.Ya];if(mb)var $b=[G.prototype.O,G.prototype.da,G.prototype.ia,G.prototype.za],Zb=[G.prototype.S,G.prototype.ga,G.prototype.ra,G.prototype.Ca]; +function hc(a,b){x.call(this,"CPU",a,hc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.fb=c;this.i.Qb=0;this.i.Ta=d;this.i.bc=Math.round(this.i.fb/1E4)/100;this.i.cb=this.i.bc*this.i.Ta;this.D.xa=!1;this.D.Xb=!1;this.D.uc=a.autoStart;this.D.wc=!1;this.D.mb=!1;this.i.Bb=this.i.qb=0;this.i.Cb=a.csStart;this.i.pb=a.csInterval;this.i.rb=a.csStop;this.F=[];this.ba=this.gb.bind(this);F(this)}Ya(hc);var ic=["power","reset"];m=hc.prototype; +m.Qa=function(a,b,c,d){this.A=a;this.w=b;this.I=d;for(b=0;b=a.i.qb&&(a.i.qb+=a.i.pb,c=!0);0<=a.i.rb&&a.i.rb<=Cc(a)&&(a.i.pb=a.i.rb=-1,lc(a),a.na(),c=!0);c&&a.g(Cc(a)+" cycles: checksum="+n(a.i.Bb))}} +m.ma=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.N[b]=c;a=!0;break;case "run":this.N[b]=c;c.onclick=function(){var a;if(a=d.A)if(a=d.A,a.D.ua)a=!0;else{var b=null,c,g=cb(a.id);for(c=0;cc&&(c=2);var d=1;b&&1a.i.bb/a.i.cb?b=1:d=!0;a.i.Ta=b;b=a.i.bc*a.i.Ta;if(a.i.cb!=b){a.i.cb=b;b=a.i.cb.toFixed(2)+"Mhz";var e=a.N.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.A&&a.A.hb()}Ec(a,a.H);a.H=0;a.i.ob=na();a.i.eb=0;Fc(a);return d}function Gc(a,b){var c=a.F.length;a.F.push([-1,b]);return c} +m.gb=function(a){if(ib(this,!0)){if(!this.D.xa){Dc(this);this.A&&this.A.start(this.i.ob,Cc(this));this.D.xa=!0;this.D.Xb=!0;this.J&&this.J.start();var b=this.N.run;b&&(b.textContent="Halt");this.A&&(this.A.Ia(!0),a&&this.A.hb(!0))}this.i.ec>=this.i.fb&&Fc(this,!0);this.i.Fb=0;this.i.Pb=na();this.i.eb&&(a=this.i.Pb-this.i.eb,a>this.i.Cc&&(this.i.ob+=a,this.i.ob>this.i.Pb&&(this.i.ob=this.i.Pb)));try{do{var c=this.D.mb?1:this.i.Hd;a=c;for(b=0;bd[0]||a>d[0]&&(a= +d[0])}c=a;this.ub(c);var e=this.B-this.b;a=e;for(b=0;bf[0]||(f[0]-=a,0>=f[0]&&(f[0]=-1,f[1]()))}this.i.Fb+=e;this.H+=e;Ec(this,0,!0);pc(this,e);this.i.Eb-=e;0>=this.i.Eb&&(this.i.Eb+=this.i.Ec,this.A&&Hc(this.A,this.i.Qb++),this.i.Qb>this.M&&(this.i.Qb=0));this.i.Db-=e;0>=this.i.Db&&(this.i.Db+=this.i.Dc,this.A&&this.A.Ia());this.i.sb-=e;if(0>=this.i.sb){this.i.sb+=this.i.dc;break}}while(this.D.xa)}catch(h){this.na();nc(this);this.A&&this.A.stop(na(),Cc(this)); +ib(this,!1);lb(this,h.stack||h.message);return}c=setTimeout;d=this.ba;this.i.eb=na();e=this.i.Cc;this.i.Fb&&(e=Math.round(e*this.i.Fb/this.i.dc));e-=this.i.eb-this.i.Pb;if(f=this.i.eb-this.i.ob)this.i.bb=Math.round(this.H/(10*f))/100,864E5<=f&&(this.K=0,Dc(this));if(0>e||this.i.bb>8&255;a.U=b&255}function Sc(a){return a.V<<8|a.W}function Tc(a,b){a.V=b>>8&255;a.W=b&255}function J(a){return a.X<<8|a.Z} +function Uc(a,b){a.X=b>>8&255;a.Z=b&255}function H(a,b){a.R=b&65535}function Vc(a){return a.ca&256?1:0}function Wc(a,b){a.ca=a.ca&255|b}function Xc(a){return nb[a.fa&255]?4:0}function Yc(a){return(a.fa^a.wa)&16?16:0}function Zc(a){return a.ca&255?0:64}function $c(a){return a.fa&128?128:0}function Oc(a){return a.va&-214|$c(a)|Zc(a)|Yc(a)|Xc(a)|Vc(a)}function Mc(a,b){a.ca=a.fa=a.wa=0;b&1&&(a.ca|=256);b&4||(a.fa|=1);b&16&&(a.wa|=16);b&64||(a.ca|=255);b&128&&(a.fa^=192);a.va=a.va&-726|b&512|2} +function ad(a,b){a.wa=a.j^b;return a.fa=(a.ca=a.j+b)&255}function bd(a,b){a.wa=a.j^b;return a.fa=(a.ca=a.j+b+(a.ca&256?1:0))&255}function cd(a,b){a.ca=a.fa=a.wa=a.j&b;(a.j|b)&8&&(a.wa^=16);return a.ca}function dd(a,b){a.wa=b^255;b=a.fa=b+255&255;a.ca=a.ca&-256|b;return b}function ed(a,b){a.wa=b;b=a.fa=b+1&255;a.ca=a.ca&-256|b;return b}function fd(a,b){return a.fa=a.ca=a.wa=a.j|b}function K(a,b){b^=255;a.wa=a.j^b;return a.fa=(a.ca=a.j+b+1^256)&255} +function gd(a,b){b^=255;a.wa=a.j^b;return a.fa=(a.ca=a.j+b+(a.ca&256?0:1)^256)&255}function Ad(a,b){return a.fa=a.ca=a.wa=a.j^b}m.aa=function(a){return this.w.aa(a)};m.ta=function(a,b){this.w.ta(a,b)};function L(a){var b=a.aa(a.R);H(a,a.R+1);return b}function M(a){var b=a.w.Sa(a.R);H(a,a.R+2);return b}function O(a){var b=a.w.Sa(a.la);a.la=a.la+2&65535;return b}function P(a,b){a.la=a.la-2&65535;a.w.Ub(a.la,b)}function Bd(a,b){a.u|=1<d&&!(this.u&1<d?255:1<>8;Wc(this,a&256);this.b-=4},Ed,function(){var a;Uc(this,a=J(this)+Qc(this));Wc(this,a>>8&256);this.b-=10},function(){this.j=this.aa(Qc(this));this.b-=7},function(){Rc(this,Qc(this)-1);this.b-= +5},function(){this.U=ed(this,this.U);this.b-=5},function(){this.U=dd(this,this.U);this.b-=5},function(){this.U=L(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;Wc(this,a);this.b-=4},Ed,function(){Tc(this,M(this));this.b-=10},function(){this.ta(Sc(this),this.j);this.b-=7},function(){Tc(this,Sc(this)+1);this.b-=5},function(){this.V=ed(this,this.V);this.b-=5},function(){this.V=dd(this,this.V);this.b-=5},function(){this.V=L(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255| +Vc(this);Wc(this,a&256);this.b-=4},Ed,function(){var a;Uc(this,a=J(this)+Sc(this));Wc(this,a>>8&256);this.b-=10},function(){this.j=this.aa(Sc(this));this.b-=7},function(){Tc(this,Sc(this)-1);this.b-=5},function(){this.W=ed(this,this.W);this.b-=5},function(){this.W=dd(this,this.W);this.b-=5},function(){this.W=L(this);this.b-=7},function(){var a=this.j<<8;this.j=(Vc(this)<<8|this.j)>>1;Wc(this,a&256);this.b-=4},Ed,function(){Uc(this,M(this));this.b-=10},function(){var a=M(this);this.w.Ub(a,J(this)); +this.b-=16},function(){Uc(this,J(this)+1);this.b-=5},function(){this.X=ed(this,this.X);this.b-=5},function(){this.X=dd(this,this.X);this.b-=5},function(){this.X=L(this);this.b-=7},function(){var a=0,b=Vc(this);if(Yc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=ad(this,a);Wc(this,b?256:0);this.b-=4},Ed,function(){var a;Uc(this,a=J(this)+J(this));Wc(this,a>>8&256);this.b-=10},function(){var a;a=M(this);a=this.w.Sa(a);Uc(this,a);this.b-=16},function(){Uc(this,J(this)-1);this.b-=5},function(){this.Z= +ed(this,this.Z);this.b-=5},function(){this.Z=dd(this,this.Z);this.b-=5},function(){this.Z=L(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},Ed,function(){this.la=M(this)&65535;this.b-=10},function(){this.ta(M(this),this.j);this.b-=13},function(){this.la=this.la+1&65535;this.b-=5},function(){var a=J(this);this.ta(a,ed(this,this.aa(a)));this.b-=10},function(){var a=J(this);this.ta(a,dd(this,this.aa(a)));this.b-=10},function(){this.ta(J(this),L(this));this.b-=10},function(){this.ca|=256;this.b-= +4},Ed,function(){var a;Uc(this,a=J(this)+this.la);Wc(this,a>>8&256);this.b-=10},function(){this.j=this.aa(M(this));this.b-=13},function(){this.la=this.la-1&65535;this.b-=5},function(){this.j=ed(this,this.j);this.b-=5},function(){this.j=dd(this,this.j);this.b-=5},function(){this.j=L(this);this.b-=7},function(){Wc(this,Vc(this)?0:256);this.b-=4},function(){this.b-=5},function(){this.T=this.U;this.b-=5},function(){this.T=this.V;this.b-=5},function(){this.T=this.W;this.b-=5},function(){this.T=this.X; +this.b-=5},function(){this.T=this.Z;this.b-=5},function(){this.T=this.aa(J(this));this.b-=7},function(){this.T=this.j;this.b-=5},function(){this.U=this.T;this.b-=5},function(){this.b-=5},function(){this.U=this.V;this.b-=5},function(){this.U=this.W;this.b-=5},function(){this.U=this.X;this.b-=5},function(){this.U=this.Z;this.b-=5},function(){this.U=this.aa(J(this));this.b-=7},function(){this.U=this.j;this.b-=5},function(){this.V=this.T;this.b-=5},function(){this.V=this.U;this.b-=5},function(){this.b-= +5},function(){this.V=this.W;this.b-=5},function(){this.V=this.X;this.b-=5},function(){this.V=this.Z;this.b-=5},function(){this.V=this.aa(J(this));this.b-=7},function(){this.V=this.j;this.b-=5},function(){this.W=this.T;this.b-=5},function(){this.W=this.U;this.b-=5},function(){this.W=this.V;this.b-=5},function(){this.b-=5},function(){this.W=this.X;this.b-=5},function(){this.W=this.Z;this.b-=5},function(){this.W=this.aa(J(this));this.b-=7},function(){this.W=this.j;this.b-=5},function(){this.X=this.T; +this.b-=5},function(){this.X=this.U;this.b-=5},function(){this.X=this.V;this.b-=5},function(){this.X=this.W;this.b-=5},function(){this.b-=5},function(){this.X=this.Z;this.b-=5},function(){this.X=this.aa(J(this));this.b-=7},function(){this.X=this.j;this.b-=5},function(){this.Z=this.T;this.b-=5},function(){this.Z=this.U;this.b-=5},function(){this.Z=this.V;this.b-=5},function(){this.Z=this.W;this.b-=5},function(){this.Z=this.X;this.b-=5},function(){this.b-=5},function(){this.Z=this.aa(J(this));this.b-= +7},function(){this.Z=this.j;this.b-=5},function(){this.ta(J(this),this.T);this.b-=7},function(){this.ta(J(this),this.U);this.b-=7},function(){this.ta(J(this),this.V);this.b-=7},function(){this.ta(J(this),this.W);this.b-=7},function(){this.ta(J(this),this.X);this.b-=7},function(){this.ta(J(this),this.Z);this.b-=7},function(){var a=this.R-1;if(this.L.length)for(var b=0;b>8;this.b-=10},function(){var a=M(this);$c(this)||H(this,a);this.b-=10},function(){this.va&=-513;this.b-=4},function(){var a=M(this);$c(this)||(P(this,this.R),H(this,a),this.b-=6);this.b-=11},function(){P(this,Oc(this)&255|this.j<<8);this.b-=11},function(){this.j=fd(this,L(this));this.b-=7},function(){P(this,this.R);H(this,48);this.b-=11},function(){$c(this)&&(H(this, +O(this)),this.b-=6);this.b-=5},function(){this.la=J(this)&65535;this.b-=5},function(){var a=M(this);$c(this)&&H(this,a);this.b-=10},function(){this.va|=512;this.b-=4},function(){var a=M(this);$c(this)&&(P(this,this.R),H(this,a),this.b-=6);this.b-=11},Hd,function(){K(this,L(this));this.b-=7},function(){P(this,this.R);H(this,56);this.b-=11}]; +function S(a){x.call(this,"ChipSet",a,S,32768);var b=a.model;b&&!Id[b]&&Ma("Unrecognized ChipSet model: "+b);this.B=Id[b]||{};a.sound&&(this.ha=null,window&&(this.ha=window.AudioContext||window.webkitAudioContext),this.ha&&new this.ha);F(this)}Ya(S); +var T={Aa:1978.1,sd:{Ba:0,ee:1,ie:16,pe:32,ye:64,xe:128,wb:14},Xa:{Ba:1,Tc:1,md:2,hd:4,jd:16,kd:32,ld:64,wb:8},td:{Ba:2,de:3,Ge:4,fe:8,te:16,ue:32,ve:64,ge:128,wb:0},Ce:{Ba:3},Ae:{Ba:2,qe:7},Ee:{Ba:3,He:1,De:2,we:4,ne:8,he:16,ae:32},Be:{Ba:4},Fe:{Ba:5,je:1,ke:2,le:4,me:8,Ie:16}},U={Aa:100,Ja:{Ba:66,rc:1,nc:2,gd:4,se:8,re:16,pc:32,oc:64,kc:128},Sc:{Ba:66,INIT:0},Va:{Ba:194,ce:0,jc:16,nd:32,qc:48,Xc:0,Yc:32},Kb:{Ba:162,ze:0,$c:0,Wc:0,Zc:0,Vc:0},Ka:{oe:{Ba:98},Ua:{Qc:0,Pc:1,pd:2,ud:4,Uc:5,od:6,qd:7}, +Lb:16383}},Id={SI1978:T,VT100:U};S.prototype.ma=function(){return!1};S.prototype.Qa=function(a,b,c,d){this.w=b;this.b=c;this.I=d;this.A=a;this.K=rb(a,"Keyboard");this.Na=rb(a,"SerialPort");this.video=rb(a,"Video");Cb(b,this,this.B.Rb);Gb(b,this,this.B.Sb)};S.prototype.Ea=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};S.prototype.Ha=function(a){return a?this.save():!0};T.INIT=[[T.sd.wb,T.Xa.wb,T.td.wb,0,0,0,0]]; +U.INIT=[[U.Sc.INIT,U.Ja.nc|U.Ja.gd],[U.Va.Xc,U.Va.Yc],[U.Kb.$c,U.Kb.Wc,U.Kb.Zc,U.Kb.Vc],[0,0,0,0,[11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11776,11784,11918,11776,11856,11824,11840,11808,11776,12E3,12E3,11857,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]]]; +m=S.prototype;m.reset=function(){this.B.INIT&&!this.restore(this.B.INIT)&&this.ja("reset error")};m.save=function(){var a=new Pc(this);switch(this.B.Aa){case T.Aa:I(a,0,[this.Ca,this.J,this.Da,this.ba,this.ga,this.ya,this.za]);break;case U.Aa:I(a,0,[this.ia,this.H]),I(a,1,[this.M,this.O]),I(a,2,[this.F,this.da,this.ra,this.qa]),I(a,3,[this.S,this.u,this.P,this.ea,this.L])}return a.data()}; +m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.B.Aa){case T.Aa:return this.Ca=b[0],this.J=b[1],this.Da=b[2],this.ba=b[3],this.ga=b[4],this.ya=b[5],this.za=b[6],!0;case U.Aa:return this.ia=b[0],this.H=b[1],b=a[1],this.M=b[0],this.O=b[1],b=a[2],this.F=b[0],this.da=b[1],this.ra=b[2],this.qa=b[3],b=a[3],this.S=b[0],this.u=b[1],this.P=b[2],this.ea=b[3],this.L=b[4],!0}return!1};m.start=function(){};m.stop=function(){};m.Bd=function(a,b){var c=this.Ca;D(this,a,null,b,"STATUS0",c,!0);return c}; +m.Cd=function(a,b){var c=this.J;D(this,a,null,b,"STATUS1",c,!0);return c};m.Dd=function(a,b){var c=this.Da;D(this,a,null,b,"STATUS2",c,!0);return c};m.Ad=function(a,b){var c=this.ba>>8-this.ga&255;D(this,a,null,b,"SHIFT.RESULT",c,!0);return c};m.Ld=function(a,b,c){D(this,a,b,c,"SHIFT.COUNT",null,!0);this.ga=b};m.Nd=function(a,b,c){D(this,a,b,c,"SOUND1",null,!0);this.ya=b};m.Md=function(a,b,c){D(this,a,b,c,"SHIFT.DATA",null,!0);this.ba=b<<8|this.ba>>8}; +m.Od=function(a,b,c){D(this,a,b,c,"SOUND2",null,!0);this.za=b};m.Pd=function(a,b,c){D(this,a,b,c,"WATCHDOG",null,!0)};function Jd(a){var b=0,c=0,d=~a.S;for(a=0;10>a;a++)d&1&&(b=9-a),d>>=1;for(a=0;10>a;a++)d&1&&(c=9-a),d>>=1;return 10*b+c} +m.Ed=function(a,b){var c=this.H,c=c&~U.Ja.oc;if((Cc(this.b)&64)<<1&&(c|=U.Ja.oc,c!=this.H)){var d,e;d=this.P&1;e=this.P>>1&7;switch(e){case U.Ka.Ua.qd:break;case U.Ka.Ua.Pc:this.S=this.S<<1|d;break;case U.Ka.Ua.Uc:d=Jd(this);this.L[d]=U.Ka.Lb;E(this,"doNVRCommand(): erase data at addr "+t(d));break;case U.Ka.Ua.Qc:this.u=this.u<<1|d;break;case U.Ka.Ua.ud:d=Jd(this);e=this.u&U.Ka.Lb;this.L[d]=e;E(this,"doNVRCommand(): write data "+t(e)+" to addr "+t(d));break;case U.Ka.Ua.od:d=Jd(this);e=this.L[d]; +null==e&&(e=U.Ka.Lb);this.u=e;E(this,"doNVRCommand(): read data "+t(e)+" from addr "+t(d));break;case U.Ka.Ua.pd:this.u<<=1;this.ea=this.u&U.Ka.Lb+1;break;default:E(this,"doNVRCommand(): unrecognized command "+da(e))}}c&=~U.Ja.pc;this.ea&&(c|=U.Ja.pc);c&=~U.Ja.kc;this.K&&this.K.$b()&&(c|=U.Ja.kc);c&=~U.Ja.rc;this.Na&&this.Na.$b()&&(c|=U.Ja.rc);this.H=c;D(this,a,null,b,"FLAGS",c);return c};m.Qd=function(a,b,c){D(this,a,b,c,"BRIGHTNESS");this.ia=b}; +m.Td=function(a,b,c){D(this,a,b,c,"NVR.LATCH");this.P=b};m.Sd=function(a,b,c){D(this,a,b,c,"DC012");a=b&3;switch(b>>2&3){case 0:this.F=this.F&-4|a;break;case 1:this.F=this.F&-13|a<<2;this.video&&(b=this.video,a=this.F,E(b,"updateScrollOffset("+a+")"),b.ib!==a&&((b.ib=a)?Kd(b,-1):b.yb=!0));break;case 2:switch(a){case 0:this.da=~this.da;break;case 2:case 3:this.ra=3-a}break;case 3:this.qa=a}}; +m.Rd=function(a,b,c){D(this,a,b,c,"DC011");b&U.Va.nd?(b&=U.Va.qc,this.O!=b&&(this.O=b,this.video&&(a=this.video,b=this.O==U.Va.qc?50:60,E(a,"updateRate("+b+")"),a.ac=b))):(b&=U.Va.jc,this.M!=b&&(this.M=b,this.video&&(a=this.M==U.Va.jc?132:80,b=this.video,E(b,"updateDimensions("+a+","+(80>>0,h],q=ma(p,k,a.Za);0>q&&p.splice(-(q+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.H.push({Je:b,G:c,Gd:d,Ra:e,sc:f})}delete this.Ra}return!0};Nd.prototype.Ha=function(){return!0}; +function Od(a,b,c,d){if(d)a.ja("Unable to load system ROM (error "+d+": "+b+")");else{bb(a.Yb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.A=f;else if(h)for(a.A=Array(4*h.length),d=c=0;c>8&255,a.A[d++]=h[c]>>16&255,a.A[d++]=h[c]>>24&255;else a.A=e;a.Ra=e.symbols;if(!a.A.length){u("Empty ROM: "+b);return}if(1==a.A.length){u(a.A[0]);return}}catch(g){a.ja("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm, +" ").replace(/ +$/,"").split(" "),a.A=Array(b.length),e=0;e>>f.pa;0>>=f.pa;0d?a.u.push({gc:b,cc:Date.now(),Mb:!1}):(a.u[d].cc=Date.now(),a.u[d].Mb=!1);else if(0<=d){if(!a.u[d].Mb){var e=a.u[d].cc;if(e&&100>Date.now()-e)return a.u[d].Mb=!0,$d(a),!0}a.u.splice(d,1)}if(a.J){d=0;switch(b){case "1p":d=T.Wa.hd;break;case "2p":d=T.Wa.md;break;case "coin":d=T.Wa.Tc;break;case "left":d=T.Wa.kd;break;case "right":d=T.Wa.ld;break;case "fire":d=T.Wa.jd}d&&(a=a.J,b=d,a.F&=~b,c&&(a.F|=b))}return!0} +Ud.prototype.ma=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.N[e]){if("led"==a&&this.w.xb[b])return this.N[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return Xd(d,a,!0)},c.onkeyup=function(a){return Xd(d,a,!1)},!0;default:if(this.w.Wa&&void 0!==this.w.Wa[b])return this.N[e]=c,a=function(a,b){return function(){Yd(a,b,!0)}}(this,this.w.Wa[b]),b=function(a,b){return function(){Yd(a,b,!1);a.A&&a.A.hb()}}(this,this.w.Wa[b]),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend= +b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};Ud.prototype.Qa=function(a,b,c,d){this.A=a;this.b=c;this.I=d;this.J=rb(a,"ChipSet");Cb(b,this,this.w.Rb);Gb(b,this,this.w.Sb)};Ud.prototype.Ea=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};Ud.prototype.Ha=function(a){return a?this.save():!0};V.INIT=[[V.La.INIT,V.Rc.INIT,-1]];m=Ud.prototype;m.reset=function(){this.u=[];this.w.INIT&&!this.restore(this.w.INIT)&&this.ja("reset error")}; +m.save=function(){var a=new Pc(this);switch(this.w.Aa){case V.Aa:I(a,0,[this.H,this.F,-1])}return a.data()};m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.w.Aa){case Wd.Aa:return!0;case V.Aa:return this.H=b[0],Zd(this,this.H&V.La.lc),this.F=b[1],this.B=b[2],!0}return!1};function Zd(a,b){for(var c in a.w.xb){var d=a.N["led-"+c];if(d){var e=a.w.xb[c],f=!!(b&e);e&e-1&&(f=!(b&~e));d.style.backgroundColor=f?"#ff0000":"#000000"}}} +function Xd(a,b,c){var d=!0,e;a:if(e=b.keyCode,e=a.w.ic[e]||e,!a.w.C[e]){for(var f in a.w.Wa)if(a.w.Wa[f]===e){e=f;break a}e=null}e&&(d=Yd(a,e,c),b.preventDefault());return d} +function Yd(a,b,c){var d;a:{for(d=0;dd?a.u.push({gc:b,cc:Date.now(),Mb:!1}):(a.u[d].cc=Date.now(),a.u[d].Mb=!1);else if(0<=d){if(!a.u[d].Mb){var e=a.u[d].cc;if(e&&100>Date.now()-e)return a.u[d].Mb=!0,$d(a),!0}a.u.splice(d,1)}if(a.J){d=0;switch(b){case "1p":d=T.Xa.hd;break;case "2p":d=T.Xa.md;break;case "coin":d=T.Xa.Tc;break;case "left":d=T.Xa.kd;break;case "right":d=T.Xa.ld;break;case "fire":d=T.Xa.jd}d&&(a=a.J,b=d,a.J&=~b,c&&(a.J|=b))}return!0} function $d(a){for(var b=0,c=-1;bc||c>e)c=e}else{Yd(a,d,!1);b=0;continue}}b++}0<=c&&setTimeout(function(){$d(a)},c)}m.$b=function(){return!0};m.Fd=function(a,b){var c=this.F;0<=this.B&&(this.B>3)*a.da,!xb(a.w,a.ya,a.X,3)))return!1;a.X?(a.Jc=a.J.createImageData(b,c),a.Nc=16/a.$a|0,fe(a,a.X>>1)):fe(a,(a.ea+1)*a.ha);a.N=document.createElement("canvas");a.N.width=b;a.N.height=c;a.ib=a.N.getContext("2d");a.qa={};a.Da=1<>3)*a.da,!vb(a.w,a.ya,a.S,3)))return!1;a.S?(a.Jc=a.F.createImageData(b,c),a.Nc=16/a.ab|0,fe(a,a.S>>1)):fe(a,(a.ea+1)*a.ha);a.M=document.createElement("canvas");a.M.width=b;a.M.height=c;a.jb=a.M.getContext("2d");a.qa={};a.Da=1<=a.zc?8:16,f=8>(7=a.zc?8:16,f=8>(7>4)*c)}return k} -ae.prototype.Ea=function(){if(2==this.ga){for(var a={0:[32,"SET-UP A"],2:[64,'TO EXIT PRESS "SET-UP"'],22:[96," T T T T T T T T T"],23:[96,"1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890"],24:[]},b=this.ya,c=-1,d=-1,e,f=-(60==this.ac?2:5);f>8&15|16;Cb(this.w,b++,e);Cb(this.w,b++, -c&255);if(g)break}if(h)for(c=0,e=1;ec&&(a=Math.round(c/b*100)+"%")}this.Hc?(this.O.style.width=a,this.O.style.width=a,this.O.style.display="block",this.O.style.margin="auto"):(this.u.style.width=a,this.u.style.height="auto");this.u.style.backgroundColor="black";this.u.jb();a=!0}this.Ca&&this.Ca.focus()}return a}; -function de(a,b){!b&&a.u&&(a.Hc?a.O.style.width=a.O.style.height="":a.u.style.width=a.u.style.height="");ib(a,"notifyFullScreen("+b+")")}function fe(a,b){a.Kc=b;a.za=!1;if(void 0===a.H||a.H.length!=a.Kc)a.H=Array(a.Kc)}function he(a,b,c,d,e){d=a.B?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.ga&&(208<=c&&236>c?e=a.Da+0:28<=c&&72>c&&(e=a.Da+1));a=a.ra[e];d*=a.length;b.data[d]=a[0];b.data[d+1]=a[1];b.data[d+2]=a[2];b.data[d+3]=a[3]} -function ie(a,b){for(var c=a.ya,d=-1,e=0,f=60==a.ac?2:5,h=0,g=0,k=-1;e>=1);;){var w=Ab(a.w,p++);if(127==(w&127)){var r=Ab(a.w,p++),d=r&96,c=(r&15)<<8|Ab(a.w,p),c=c+(r&16?8192:16384);break}if(l>4)*w.ka,A=void 0,Q=void 0, -aa=void 0,Y=void 0,va=w.oa,Hb=w.ka;C?(A=v*r.oa,Q=e*r.ka,aa=r.oa,Y=r.ka):(A=v*r.Ac,Q=e*r.Fc,aa=r.Ac,Y=r.Fc);w.oa>r.oa&&(A*=2,aa*=2);w.ka>r.ka&&(0==q&&(z+=r.ka),Hb=r.ka);C?C.drawImage(w.canvas,X,z,va,Hb,A,Q,aa,Y):(A+=0,Q+=0,r.J.drawImage(w.canvas,X,z,va,Hb,A,Q,aa,Y))}g++}h++}e++}}a.za=!0;!b&&a.yb&&1==g&&(a.H[k]=-1,g=0);a.yb=!1;(g||b)&&a.ib&&a.J.drawImage(a.N,0,a.hb,a.K,a.da-a.ka,0,0,a.Vd,a.Wd)} -function Kd(a,b){var c=!0,d=!0;if(0<=b){d=!1;a.Zb&&(120==a.Zb?b&1?(Bd(a.b,2),c=!1):Bd(a.b,1):Bd(a.b,4));var e;if(e=c&&a.za&&a.X){e=a.w;for(var f=a.X,h=!0,g=a.ya>>>e.pa;0>8|(r&255)<<8);k>C&w;he(a,a.Jc,k++,l,X);C+=v}k>p&&(p=k);l=e&&(e=l+1)}f+=2;g++;if(k>=a.K&&(k=0,l++,l>a.da))break}a.za=!0;cMissing <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<=ra().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||Sa.aspect);f&&.3<=f&&3.33>=f&&(Ia("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");ya("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new ae(d,e,h,f,c);gb(d,c)}}); -function je(a){this.ga=+a.adapter;switch(this.ga){case 0:this.ha=0;this.ra=2;break;default:u("Unrecognized serial adapter #"+this.ga);return}this.B=this.F=null;this.ia=a.tabSize;this.ea=a.charBOL;this.H=0;x.call(this,"SerialPort",a,je,8388608);a=a.binding;"console"==a?this.F="":eb(this,a);this.qa=function(a){return function(){ke(a)}}(this);this.N=this.ca=null;this.exports={receiveByte:this.Tb}}Xa(je); -var le=[50,75,110,134.5,150,200,300,600,1200,1800,2E3,2400,3600,4800,9600,19200],me=[!1,0,0,133,142,39,238],fb="buffer";m=je.prototype; -m.ma=function(a,b,c,d){var e=this;switch(b){case fb:return this.M[b]=this.B=c,c.onkeydown=function(a){a=a||window.event;var b=a.keyCode;if(8===b||a.ctrlKey&&65<=b&&90>=b)a.preventDefault&&a.preventDefault(),64>2)+6;a.L&16&&c++;c+=((a.L&192)>>6)+1>>1;setTimeout(a.qa,1E3/Math.round(b/c))}}m.$b=function(){return!!(this.u&1)};m.zd=function(a,b){var c=this.X;D(this,a,null,b,"DATA",c);this.u&=-3;return c};m.yd=function(a,b){var c=this.u;D(this,a,null,b,"STATUS",c);return c}; -m.Kd=function(a,b,c){D(this,a,b,c,"DATA");this.da=b;this.u&=-6;a=!1;this.ca&&this.ca.call(this.N,b)&&(a=!0);if(this.B)13==b?this.H=0:8==b?(this.B.value=this.B.value.slice(0,-1),0>8&15|16;Ab(this.w,b++,e);Ab(this.w,b++, +c&255);if(g)break}if(h)for(c=0,e=1;ec&&(a=Math.round(c/b*100)+"%")}this.Hc?(this.O.style.width=a,this.O.style.width=a,this.O.style.display="block",this.O.style.margin="auto"):(this.u.style.width=a,this.u.style.height="auto");this.u.style.backgroundColor="black";this.u.kb();a=!0}this.Ca&&this.Ca.focus()}return a}; +function de(a,b){!b&&a.u&&(a.Hc?a.O.style.width=a.O.style.height="":a.u.style.width=a.u.style.height="");E(a,"notifyFullScreen("+b+")")}function fe(a,b){a.Kc=b;a.za=!1;if(void 0===a.H||a.H.length!=a.Kc)a.H=Array(a.Kc)}function he(a,b,c,d,e){d=a.B?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.ga&&(208<=c&&236>c?e=a.Da+0:28<=c&&72>c&&(e=a.Da+1));a=a.ra[e];d*=a.length;b.data[d]=a[0];b.data[d+1]=a[1];b.data[d+2]=a[2];b.data[d+3]=a[3]} +function ie(a,b){for(var c=a.ya,d=-1,e=0,f=60==a.ac?2:5,h=0,g=0,k=-1;e>=1);;){var w=yb(a.w,p++);if(127==(w&127)){var r=yb(a.w,p++),d=r&96,c=(r&15)<<8|yb(a.w,p),c=c+(r&16?8192:16384);break}if(l>4)*w.ka,A=void 0,Q=void 0, +ba=void 0,Y=void 0,wa=w.oa,Ib=w.ka;C?(A=v*r.oa,Q=e*r.ka,ba=r.oa,Y=r.ka):(A=v*r.Ac,Q=e*r.Fc,ba=r.Ac,Y=r.Fc);w.oa>r.oa&&(A*=2,ba*=2);w.ka>r.ka&&(0==q&&(y+=r.ka),Ib=r.ka);C?C.drawImage(w.canvas,X,y,wa,Ib,A,Q,ba,Y):(A+=0,Q+=0,r.F.drawImage(w.canvas,X,y,wa,Ib,A,Q,ba,Y))}g++}h++}e++}}a.za=!0;!b&&a.yb&&1==g&&(a.H[k]=-1,g=0);a.yb=!1;(g||b)&&a.jb&&a.F.drawImage(a.M,0,a.ib,a.L,a.da-a.ka,0,0,a.Vd,a.Wd)} +function Kd(a,b){var c=!0,d=!0;if(0<=b){d=!1;a.Zb&&(120==a.Zb?b&1?(Bd(a.b,2),c=!1):Bd(a.b,1):Bd(a.b,4));var e;if(e=c&&a.za&&a.S){e=a.w;for(var f=a.S,h=!0,g=a.ya>>>e.pa;0>8|(r&255)<<8);k>C&w;he(a,a.Jc,k++,l,X);C+=v}k>p&&(p=k);l=e&&(e=l+1)}f+=2;g++;if(k>=a.L&&(k=0,l++,l>a.da))break}a.za=!0;cMissing <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<=sa().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||Ta.aspect);f&&.3<=f&&3.33>=f&&(Ja("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");za("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new ae(d,e,h,f,c);fb(d,c)}}); +function je(a){this.ga=+a.adapter;switch(this.ga){case 0:this.ha=0;this.qa=2;break;default:u("Unrecognized serial adapter #"+this.ga);return}this.B=this.F=null;this.ia=a.tabSize;this.ea=a.charBOL;this.H=0;x.call(this,"SerialPort",a,je,8388608);var b=a.binding;if("console"==b)this.F="";else{var c;a=ke;b&&(void 0===c&&(c="Panel"),(c=eb(c,this.id))&&(b=c.N[b])&&this.ma(null,a,b))}this.M=this.ba=null;this.exports={receiveByte:this.Tb}}Ya(je); +var le=[50,75,110,134.5,150,200,300,600,1200,1800,2E3,2400,3600,4800,9600,19200],me=[!1,0,0,133,142,39,238],ke="buffer";m=je.prototype; +m.ma=function(a,b,c,d){var e=this;switch(b){case ke:return this.N[b]=this.B=c,c.onkeydown=function(a){a=a||window.event;var b=a.keyCode;if(8===b||a.ctrlKey&&65<=b&&90>=b)a.preventDefault&&a.preventDefault(),64>2)+6;a.K&16&&c++;c+=((a.K&192)>>6)+1>>1;b=1E3/Math.round(b/c);c=a.b;a=a.ra;var d=-1;0<=a&&a>>d.w.pa;k=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;k--;){var p=b[g];p.type==c?l++||d.g("..."):(c=p.type,l=zb[c],p&&d.g(n(p.id)+" %"+n(g<>>e.pa;f!=e.w?e.Y[h].hc(f,b&65535,d):(e.Y[h++].Jb(f,b&255,d),e.Y[h&e.L].Jb(0,b>>8&255,d+1));c&&Ee(a,c);Bc(this.b,!0)}};function W(a){return{G:a,Pa:!1}}function Fe(a){return[a.G,a.Pa]}function Ge(a){return{G:a[0],Pa:a[1]}} -function De(a,b,c){var d;c=(c?a.O:a.$a).G;if(void 0!==b){d=b=He(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=oa(ye,a.substr(b,1))));return c}function Ne(a,b){var c=0,d=Oe(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 6:c=2;break;case 8:case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"} -function Oe(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.S;break;case 1:c=d.T;break;case 8:c=Qc(d);break;case 2:c=d.U;break;case 3:c=d.V;break;case 9:c=Sc(d);break;case 4:c=d.W;break;case 5:c=d.Z;break;case 10:c=J(d);break;case 6:c=d.aa(J(d));break;case 11:c=d.la;break;case 12:c=d.R;break;case 13:c=Pc(d);break;case 14:c=Pc(d)&255|d.j<<8}}return c} -function Pe(a,b){b=He(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=Me(b,c+1),0<=e&&(b=b.substr(0,c)+Ne(a,e)+b.substr(c+1+ye[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=ca(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=De(a,e))?(d=e+' "'+Le(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=De(a,e))?(Ee(d),d=e+' "'+ -Le(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}m.message=function(a,b){b&&(a+=" at "+Z(W(this.b.R).G));if(this.sa&1073741824)this.ya.push(a);else if(!this.ra||a!=this.ra)if(this.ra=a,this.sa&-2147483648&&(this.na(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.rb=0;c.B-=c.b;c.b=0;Bc(c)}}; -function hb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.sa&g)!=g||a.message(b.Xa+"."+(null!=d?"outPort":"inPort")+"("+t(c)+","+(f?f:"unknown")+(null!=d?",0x"+n(d,2):"")+")"+(null!=h?": 0x"+n(h,2):"")+(null!=e?" at "+Z(e):""))} -function te(a){var b;if(Cd(a)){if(!a.N||!a.N.length){a.N=Array(1E3);for(b=0;b>>d.pa],!1)}a.P=["br"];if(void 0!==a.F)for(b=1;b>>d.pa],!0);a.F=["bw"];a.hb=0}m.Za=function(a,b,c){var d=!0;c||sf(this,a,b,!1,!0);if(a!=this.u){var e=Ce(b);if(-1===e)this.g("invalid address: "+Z(b.G)),d=!1;else{var f=this.w;f.Y[e>>>f.pa].Za(e&f.w,a==this.F)}}d&&(a.push(b),c?b.Pa=!0:(tf(this,a,a.length-1,"set"),te(this)));return d}; -function sf(a,b,c,d,e){var f=!1;c=Ce(c);for(var h=1;h>>d.pa],b==a.F));g.Pa||te(a);break}}return f}function uf(a,b){for(var c=1;c>24,4);break;case 3:z=n(w.Sa(C,2),4);break;default:w="imm("+t(r)+")";break a}8086==w.style&&r&64?z="["+z+"]":r&16||(z=(w.style==re?"$":"0x")+z);w=z}else r& -16?(w=(q&3840)>>8,r=ye[w],8086==a.style&&q&64&&(6==w&&(r="HL"),r="["+r+"]"),w=r):r&128&&(w=(f>>3&7).toString());if(!w||!w.length){g="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; -function Bf(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; +18193,33],[65,128],[59],[50,3603],[35,51],[24],[12,51],[51,3603],[47,18193,33],[65,128],[56],[69,19219,18963],[32,51],[25],[9,51],[7,32819],[19,18193,33],[65,128]],Ce={cpu:1,bus:64,mem:128,port:256,chipset:32768,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:268435456,warn:536870912,buffer:1073741824,halt:-2147483648};m=se.prototype; +m.Qa=function(a,b,c,d){this.w=b;this.b=c;this.A=a;(a=jc(a,"messages"))&&we(this,a);this.Na=Be;De(this,function(a){a:{var b=d.w.Y,c=a[0],g=a=0,k=b.length;if(c){a=Ee(Fe(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.w.pa;k=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;k--;){var p=b[g];p.type==c?l++||d.g("..."):(c=p.type,l=xb[c],p&&d.g(n(p.id)+" %"+n(g<>>e.pa;f!=e.w?e.Y[h].hc(f,b&65535,d):(e.Y[h++].Jb(f,b&255,d),e.Y[h&e.K].Jb(0,b>>8&255,d+1));c&&Ge(a,c);nc(this.b,!0)}};function W(a){return{G:a,Pa:!1}}function He(a){return[a.G,a.Pa]}function Ie(a){return{G:a[0],Pa:a[1]}} +function Fe(a,b,c){var d;c=(c?a.O:a.ab).G;if(void 0!==b){d=b=Je(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=pa(Ae,a.substr(b,1))));return c}function Pe(a,b){var c=0,d=Qe(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 6:c=2;break;case 8:case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"} +function Qe(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.T;break;case 1:c=d.U;break;case 8:c=Qc(d);break;case 2:c=d.V;break;case 3:c=d.W;break;case 9:c=Sc(d);break;case 4:c=d.X;break;case 5:c=d.Z;break;case 10:c=J(d);break;case 6:c=d.aa(J(d));break;case 11:c=d.la;break;case 12:c=d.R;break;case 13:c=Oc(d);break;case 14:c=Oc(d)&255|d.j<<8}}return c} +function Re(a,b){b=Je(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=Oe(b,c+1),0<=e&&(b=b.substr(0,c)+Pe(a,e)+b.substr(c+1+Ae[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=aa(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=Fe(a,e))?(d=e+' "'+Ne(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=Fe(a,e))?(Ge(d),d=e+' "'+ +Ne(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}m.message=function(a,b){b&&(a+=" at "+Z(W(this.b.R).G));if(this.sa&1073741824)this.ya.push(a);else if(!this.ra||a!=this.ra)if(this.ra=a,this.sa&-2147483648&&(this.na(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.sb=0;c.B-=c.b;c.b=0;nc(c)}}; +function gb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.sa&g)!=g||a.message(b.Ya+"."+(null!=d?"outPort":"inPort")+"("+t(c)+","+(f?f:"unknown")+(null!=d?","+da(d):"")+")"+(null!=h?": "+da(h):"")+(null!=e?" at "+Z(e):""))} +function ve(a){var b;if(Cd(a)){if(!a.M||!a.M.length){a.M=Array(1E3);for(b=0;b>>d.pa],!1)}a.P=["br"];if(void 0!==a.J)for(b=1;b>>d.pa],!0);a.J=["bw"];a.ib=0}m.$a=function(a,b,c){var d=!0;c||uf(this,a,b,!1,!0);if(a!=this.u){var e=Ee(b);if(-1===e)this.g("invalid address: "+Z(b.G)),d=!1;else{var f=this.w;f.Y[e>>>f.pa].$a(e&f.w,a==this.J)}}d&&(a.push(b),c?b.Pa=!0:(vf(this,a,a.length-1,"set"),ve(this)));return d}; +function uf(a,b,c,d,e){var f=!1;c=Ee(c);for(var h=1;h>>d.pa],b==a.J));g.Pa||ve(a);break}}return f}function wf(a,b){for(var c=1;c>24,4);break;case 3:y=n(w.Sa(C,2),4);break;default:w="imm("+t(r)+")";break a}8086==w.style&&r&64?y="["+y+"]":r&16||(y=(w.style==te?"$":"0x")+y);w=y}else r& +16?(w=(q&3840)>>8,r=Ae[w],8086==a.style&&q&64&&(6==w&&(r="HL"),r="["+r+"]"),w=r):r&128&&(w=(f>>3&7).toString());if(!w||!w.length){g="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; +function Df(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 Ie(a,b,c){var d;if(b){b=He(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;h=p+"b"+h;d>>=8}d="0x"+n(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function Ef(a,b){if(b)return Df(a,b,a.ga[b]);var c=0;for(b in a.ga)Df(a,b,a.ga[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,g=f.Gd;if(e>=h&&e>8&255;case "C":d.T=g&255;break;case "D":d.U= -g&255;break;case "DE":d.U=g>>8&255;case "E":d.V=g&255;break;case "H":d.W=g&255;break;case "HL":d.W=g>>8&255;case "L":d.Z=g&255;break;case "SP":d.la=g&65535;break;case "PC":G(d,g);a.O=W(d.R);break;case "PS":Nc(d,g);break;case "PSW":Nc(d,g&255|d.va&-256);d.j=g>>8;break;case "CF":d.ba=g?d.ba|256:d.ba&255;break;case "PF":g?Xc(d)||(d.fa^=1):Xc(d)&&(d.fa^=1);break;case "AF":d.wa=g?~d.fa&16|d.wa&-17:d.fa&16|d.wa&-17;break;case "ZF":d.ba=g?d.ba&-256:d.ba|255;break;case "SF":g?$c(d)||(d.fa^=192):$c(d)&&(d.fa^= -192);break;case "IF":d.va=g?d.va|512:d.va&-513;break;default:a.g("unknown register: "+e);return}if(!h){a.g("invalid value: "+f);return}Bc(d);a.g("updated registers:")}a.g(zf(a));c&&(a.O=W(d.R),Se(a,Z(a.O.G)))}}function Lf(a,b){b=ka(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(Pe(a,c[2])):Ie(a,b,!0)}function Mf(a,b,c){var d="t"!=b;c=Cf(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);za(c,function(){return kb(a,!0)&&a.ub(e,d,!1)},function(){Bc(a.b);kb(a,!1)})} -function Se(a,b,c,d){if(b=De(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=De(a,c,!0);if(!d||d.Gg[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=wf(a,b,h,f);a.g(f);a.O=b;e-=b.G-k;c++}}} -function Ke(a,b,c,d){if(c)if(b){0>a.J&&a.B.length&&(a.J=0);if(0>a.J||b!=a.B[a.J])a.B.splice(0,0,b),a.J=0;a.J--}else a.ea?b="end":b=a.B[a.J+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var h=b.charAt(f);if('"'==h||"'"==h)e?h==e&&(e=null):e=h;else if(h==d&&!e||!h)a.push(ka(b.substring(c,f))),c=f+1}}return a} -function vf(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ea&&(a.g("ended assemble at "+Z(a.da.G)),a.O=a.da,a.ea=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.ra=null;if(mb(a)&&0l||"z"Fa.length&&(a.g("note: only "+Fa.length+" available"),ga=Fa.length);ba-=ga;0>ba&&(null==Fa[Fa.length-1].G?(ga=ba+ga,ba=0):ba+=Fa.length);var id=[];"call"== -Ye&&(pb=1E5,id=["CALL"]);for(void 0!==Xe&&a.g(ga+" instructions earlier:");0=Fa.length&&(ba=0);a.ib=ga;$e++;pb--}}$e||(a.g("no "+Ze+"history available"),a.ib=void 0)}else{var pc=De(a,Y);if(pc){var qc=0;va&&("l"==va.charAt(0)&&(va=va.substr(1)||Hb),qc=Cf(a,va)>>>0,65536>4||1;hg--&&0uc?String.fromCharCode(uc):".";sc--}Ya&&(Ya+="\n");Ya+=Y+" "+Nb+(0==Mb?" "+kd:"")}Ya&&a.g(Ya);a.$a=pc}}}}break;case "e":if("else"==f[0])break;var vc=1,cf=255,df=a.aa,ef=a.ta;"ew"==f[0]&&(vc=2,cf=65535,df=a.Sa,ef=a.Ub);var ff=vc<<1,gf=f[1];if(null==gf)a.g("edit memory commands:"), -a.g("\teb [a] [...] edit bytes at address a"),a.g("\tew [a] [...] edit words at address a");else{var wc=De(a,gf);if(wc)for(var xc=2;xcrd;){for(var Za=null,ng=256;65536>Qb.G>>>0;){jf.G= -a.Sa(Qb,2);if(null==Qb.G||!ng--)break;for(var og=a,zc=jf,kf=null,Rb=zc.G,lf=Rb,sd=1;6>=sd&&Rb;sd++){if(2\nLicense: GPL version 3 or later ");for(b=0;bWf){if(Sf(d,this.O)){this.F=new H(this,"1.23.3","failsafe");Sf(this.F)&&(ag(this,d),a=2,Pf(this.F));I(this.F,"timestamp",na());Qf(this.F);var e=this.A&&!this.L;if(1==a||sa("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Rf(d)){var f=Tf(d,"code"),h=Tf(d,"data");f&&("ok"==f?Sf(d,h):("error"==f&& -"no machine state"!=h?(this.ja("Error: "+h),"unable to verify user"==h&&(xa("user",""),this.u=null)):this.g(f+": "+h),Pf(d),Sf(d)?(c=Rf(d),e=!0):c=!1))}e&&$f(this,c?d:null)}else 2==a&&d.clear()}else $f(this);delete this.O;delete this.P}e=bb(this.id);for(f=0;fa[1];a=a[2];this.ia=!0;this.D.ua=!0;var d=this.M.power;d&&(d.textContent="Shutdown");this.b&&(bg(this,this.b,b,c,a),Cc(this.b));this.da&&(ag(this,b),b.clear());!c&&this.F&&(this.F.clear(),delete this.F);this.B=0}; -function ag(a,b){if(sa("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.u||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.ha;e.user=c;e.type="bug";e.data=d;pa("http://www.pcjs.org/api/v1/report",e,!0)}} -function Nf(a,b,c){var d,e="none";if(a.B)return null;a.B--;var f=new H(a,"1.23.3"),h=new H(a,"1.23.3","validate"),g=na();I(h,"timestamp",g);I(f,"timestamp",g);I(f,"version","1.23.3");I(f,"url",window?window.location.href:null);I(f,"browser",ra());a.b&&a.b.Ha&&(c&&a.b.na(),d=a.b.Ha(b,c),"object"===typeof d&&I(f,a.b.id,d),c&&(a.b.D.ua=!1,!1===d&&(e=null)));for(var g=bb(a.id),k=0;kg.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1pc8080$2")); -g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(q){g=null,a=q.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");pa(e,null,!0,function(f,h,g){if(g||!h)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=h.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var k=g[0],l,p=/( [a-z]+=)(['"])(.*?)\2/g;l=p.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/, -"");a=a.replace(d[0],h);ug(a,b,c)}})}else c(a,null)} -function vg(a,b,c,d){function e(a){if(void 0===g){var b=h&&B(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ia(a))}function f(a){e("Error: "+a);k&&(--eg||Ma(!0));k=!1}var h,g,k=!0;eg++;$a[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=l:q.appendChild(document.createTextNode(l));p.appendChild(q)}c|| -(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?fg(c,null,null,!1,e,function(d,k){if(k)if(ab(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--eg||Ma(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--eg||Ma(!0)):f("invalid machine element: "+ -a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?fg(b,a,d,!0,e,l):tg(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(v){f(v.message)}return k}window.embedPC8080=function(a,b,c,d){Ma(!1);return vg(a,b,c,d)};window.enableEvents=Ma;window.sendEvent=Na; -function wg(a,b,c,d){if(!c&&b){d.push(b);a=$a[d[0]];b=null;for(var e in a)if(fa(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?pa(b,null,!0,function(a,b){xg(b,d)}):xg(null,d)}else u("Error ("+c+") requesting "+a)} -function xg(a,b){var c,d,e,f=b[0],h=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var g=$a[f],k={},l;for(l in g){var p=g[l],q=ea(l);if("xml"==q){for(q=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=q.exec(g[l]);){var v=d[2];v&&(g[v]||(p=p.replace(d[0],"")))}d=l=da(l)}else"xsl"==q&&(e=l=da(l));k[l]=p}a&&(k[l="css"]=a);b[2]&&(k[l="parms"]=b[2]);b[3]&&(k[l="state"]=b[3]);d&&e?(l=JSON.stringify(k),h+=".js",c=c[1]+"var resources="+l+";"+c[2]+c[3],c=c.replace(/\u00A9/g, -"©"),l=h,g=null,k="data:application/javascript,",k=ya("Firefox")?k+encodeURIComponent(c):k+encodeURI(c),l&&(g=document.createElement("a"),"string"!=typeof g.download&&(g=null)),g?(g.href=k,g.download=l,document.body.appendChild(g),g.click(),document.body.removeChild(g),c="Check your Downloads folder for "+l+"."):(window.open(k),c="Check your browser for a new window/tab containing the requested data"+(l?" ("+l+")":"")+"."),c+=', copy it to your web server as "'+h+'", and then add the following to your web page:\n\n', +function Ke(a,b,c){var d;if(b){b=Je(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;h=p+"b"+h;d>>=8}d="0x"+n(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function Gf(a,b){if(b)return Ff(a,b,a.ga[b]);var c=0;for(b in a.ga)Ff(a,b,a.ga[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,g=f.Gd;if(e>=h&&e>8&255;case "C":d.U=g&255;break;case "D":d.V= +g&255;break;case "DE":d.V=g>>8&255;case "E":d.W=g&255;break;case "H":d.X=g&255;break;case "HL":d.X=g>>8&255;case "L":d.Z=g&255;break;case "SP":d.la=g&65535;break;case "PC":H(d,g);a.O=W(d.R);break;case "PS":Mc(d,g);break;case "PSW":Mc(d,g&255|d.va&-256);d.j=g>>8;break;case "CF":d.ca=g?d.ca|256:d.ca&255;break;case "PF":g?Xc(d)||(d.fa^=1):Xc(d)&&(d.fa^=1);break;case "AF":d.wa=g?~d.fa&16|d.wa&-17:d.fa&16|d.wa&-17;break;case "ZF":d.ca=g?d.ca&-256:d.ca|255;break;case "SF":g?$c(d)||(d.fa^=192):$c(d)&&(d.fa^= +192);break;case "IF":d.va=g?d.va|512:d.va&-513;break;default:a.g("unknown register: "+e);return}if(!h){a.g("invalid value: "+f);return}nc(d);a.g("updated registers:")}a.g(Bf(a));c&&(a.O=W(d.R),sf(a,Z(a.O.G)))}}function Nf(a,b){b=la(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(Re(a,c[2])):Ke(a,b,!0)}function Of(a,b,c){var d="t"!=b;c=Ef(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);Aa(c,function(){return ib(a,!0)&&a.ub(e,d,!1)},function(){nc(a.b);ib(a,!1)})} +function sf(a,b,c,d){if(b=Fe(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=Fe(a,c,!0);if(!d||d.Gg[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=yf(a,b,h,f);a.g(f);a.O=b;e-=b.G-k;c++}}} +function Me(a,b,c,d){if(c)if(b){0>a.F&&a.B.length&&(a.F=0);if(0>a.F||b!=a.B[a.F])a.B.splice(0,0,b),a.F=0;a.F--}else a.ea?b="end":b=a.B[a.F+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var h=b.charAt(f);if('"'==h||"'"==h)e?h==e&&(e=null):e=h;else if(h==d&&!e||!h)a.push(la(b.substring(c,f))),c=f+1}}return a} +function xf(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ea&&(a.g("ended assemble at "+Z(a.da.G)),a.O=a.da,a.ea=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.ra=null;if(kb(a)&&0l||"z"Ga.length&&(a.g("note: only "+Ga.length+" available"),ha=Ga.length);ca-=ha;0>ca&&(null==Ga[Ga.length-1].G?(ha=ca+ha,ca=0):ca+=Ga.length);var jd=[];"call"== +Ze&&(qb=1E5,jd=["CALL"]);for(void 0!==Ye&&a.g(ha+" instructions earlier:");0=Ga.length&&(ca=0);a.jb=ha;af++;qb--}}af||(a.g("no "+$e+"history available"),a.jb=void 0)}else{var qc=Fe(a,Y);if(qc){var rc=0;wa&&("l"==wa.charAt(0)&&(wa=wa.substr(1)||Ib),rc=Ef(a,wa)>>>0,65536>4||1;jg--&&0vc?String.fromCharCode(vc):".";tc--}Za&&(Za+="\n");Za+=Y+" "+Ob+(0==Nb?" "+ld:"")}Za&&a.g(Za);a.ab=qc}}}}break;case "e":if("else"==f[0])break;var wc=1,df=255,ef=a.aa,ff=a.ta;"ew"==f[0]&&(wc=2,df=65535,ef=a.Sa,ff=a.Ub);var gf=wc<<1,hf=f[1];if(null==hf)a.g("edit memory commands:"), +a.g("\teb [a] [...] edit bytes at address a"),a.g("\tew [a] [...] edit words at address a");else{var xc=Fe(a,hf);if(xc)for(var yc=2;ycsd;){for(var $a=null,pg=256;65536>Rb.G>>>0;){kf.G= +a.Sa(Rb,2);if(null==Rb.G||!pg--)break;for(var qg=a,Ac=kf,lf=null,Sb=Ac.G,mf=Sb,td=1;6>=td&&Sb;td++){if(2\nLicense: GPL version 3 or later ");for(b=0;bYf){if(Uf(d,this.O)){this.J=new Pc(this,"1.23.3","failsafe");Uf(this.J)&&(cg(this,d),a=2,Rf(this.J));I(this.J,"timestamp",oa());Sf(this.J);var e=this.A&&!this.K;if(1==a||ta("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Tf(d)){var f=Vf(d,"code"),h=Vf(d,"data");f&&("ok"==f?Uf(d,h):("error"== +f&&"no machine state"!=h?(this.ja("Error: "+h),"unable to verify user"==h&&(ya("user",""),this.u=null)):this.g(f+": "+h),Rf(d),Uf(d)?(c=Tf(d),e=!0):c=!1))}e&&bg(this,c?d:null)}else 2==a&&d.clear()}else bg(this);delete this.O;delete this.P}e=cb(this.id);for(f=0;fa[1];a=a[2];this.ia=!0;this.D.ua=!0;var d=this.N.power;d&&(d.textContent="Shutdown");this.b&&(dg(this,this.b,b,c,a),oc(this.b));this.da&&(cg(this,b),b.clear());!c&&this.J&&(this.J.clear(),delete this.J);this.B=0}; +function cg(a,b){if(ta("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.u||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.ha;e.user=c;e.type="bug";e.data=d;qa("http://www.pcjs.org/api/v1/report",e,!0)}} +function Pf(a,b,c){var d,e="none";if(a.B)return null;a.B--;var f=new Pc(a,"1.23.3"),h=new Pc(a,"1.23.3","validate"),g=oa();I(h,"timestamp",g);I(f,"timestamp",g);I(f,"version","1.23.3");I(f,"url",window?window.location.href:null);I(f,"browser",sa());a.b&&a.b.Ha&&(c&&a.b.na(),d=a.b.Ha(b,c),"object"===typeof d&&I(f,a.b.id,d),c&&(a.b.D.ua=!1,!1===d&&(e=null)));for(var g=cb(a.id),k=0;kg.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1pc8080$2")); +g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(q){g=null,a=q.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");qa(e,null,!0,function(f,h,g){if(g||!h)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=h.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var k=g[0],l,p=/( [a-z]+=)(['"])(.*?)\2/g;l=p.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/, +"");a=a.replace(d[0],h);wg(a,b,c)}})}else c(a,null)} +function xg(a,b,c,d){function e(a){if(void 0===g){var b=h&&B(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ja(a))}function f(a){e("Error: "+a);k&&(--gg||Na(!0));k=!1}var h,g,k=!0;gg++;ab[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=l:q.appendChild(document.createTextNode(l));p.appendChild(q)}c|| +(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?hg(c,null,null,!1,e,function(d,k){if(k)if(bb(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--gg||Na(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--gg||Na(!0)):f("invalid machine element: "+ +a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?hg(b,a,d,!0,e,l):vg(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(v){f(v.message)}return k}window.embedPC8080=function(a,b,c,d){Na(!1);return xg(a,b,c,d)};window.enableEvents=Na;window.sendEvent=Oa; +function yg(a,b,c,d){if(!c&&b){d.push(b);a=ab[d[0]];b=null;for(var e in a)if(ga(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?qa(b,null,!0,function(a,b){zg(b,d)}):zg(null,d)}else u("Error ("+c+") requesting "+a)} +function zg(a,b){var c,d,e,f=b[0],h=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var g=ab[f],k={},l;for(l in g){var p=g[l],q=fa(l);if("xml"==q){for(q=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=q.exec(g[l]);){var v=d[2];v&&(g[v]||(p=p.replace(d[0],"")))}d=l=ea(l)}else"xsl"==q&&(e=l=ea(l));k[l]=p}a&&(k[l="css"]=a);b[2]&&(k[l="parms"]=b[2]);b[3]&&(k[l="state"]=b[3]);d&&e?(l=JSON.stringify(k),h+=".js",c=c[1]+"var resources="+l+";"+c[2]+c[3],c=c.replace(/\u00A9/g, +"©"),l=h,g=null,k="data:application/javascript,",k=za("Firefox")?k+encodeURIComponent(c):k+encodeURI(c),l&&(g=document.createElement("a"),"string"!=typeof g.download&&(g=null)),g?(g.href=k,g.download=l,document.body.appendChild(g),g.click(),document.body.removeChild(g),c="Check your Downloads folder for "+l+"."):(window.open(k),c="Check your browser for a new window/tab containing the requested data"+(l?" ("+l+")":"")+"."),c+=', copy it to your web server as "'+h+'", and then add the following to your web page:\n\n', c+='
\n',c+="...\n",c+='