From 425f565b111a16d93f456557e393c09d616df494 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Thu, 21 Apr 2016 15:41:58 -0700 Subject: [PATCH] Simplified flag management --- devices/pc8080/panel/default.xml | 12 +- modules/pc8080/lib/cpudef.js | 26 +-- modules/pc8080/lib/cpuops.js | 101 ++++++++- modules/pc8080/lib/cpusim.js | 306 +++++++++++++-------------- modules/shared/lib/embed.js | 2 +- versions/pc8080/1.21.7/pc8080-dbg.js | 235 ++++++++++---------- versions/pc8080/1.21.7/pc8080.js | 145 ++++++------- 7 files changed, 444 insertions(+), 383 deletions(-) diff --git a/devices/pc8080/panel/default.xml b/devices/pc8080/panel/default.xml index 96e857114..ea9f08d02 100644 --- a/devices/pc8080/panel/default.xml +++ b/devices/pc8080/panel/default.xml @@ -16,12 +16,12 @@ 0000 0000 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 Speed: Stopped diff --git a/modules/pc8080/lib/cpudef.js b/modules/pc8080/lib/cpudef.js index dd362b52f..b692c2aac 100644 --- a/modules/pc8080/lib/cpudef.js +++ b/modules/pc8080/lib/cpudef.js @@ -71,25 +71,7 @@ var CPUDef = { SF: 0x0080, // bit 7: Sign flag ALL: 0x00D5, // CF, PF, AF, ZF, SF MASK: 0x00FF, // - IF: 0x0200, // bit 9: Interrupt flag (for internal use only) - OF: 0x0800 // bit 11: Overflow flag (for internal use only) - }, - RESULT: { - /* - * Flags are computed using the following internal registers: - * - * CF: resultZeroCarry & resultSize (ie, 0x100 or 0x10000) - * PF: resultParitySign & 0xff - * AF: (resultParitySign ^ resultAuxOverflow) & 0x0010 - * ZF: resultZeroCarry & (resultSize - 1) - * SF: resultParitySign & (resultSize >> 1) - * OF: (resultParitySign ^ resultAuxOverflow ^ (resultParitySign >> 1)) & (resultSize >> 1) - */ - SIZE_BYTE: 0x00100, // mask for byte arithmetic instructions (after subtracting 1) - SIZE_WORD: 0x10000, // mask for word arithmetic instructions (after subtracting 1) - AUXOVF_AF: 0x00010, - AUXOVF_OF: 0x08080, - AUXOVF_CF: 0x10100 + IF: 0x0200 // bit 9: Interrupt flag (for internal use only) }, 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, @@ -132,10 +114,6 @@ var CPUDef = { ACI: 0xCE, // PS.ALL CALL: 0xCD // to be continued.... - }, - CYCLES: { - ACI: 7 // 2 cycles, 7 states - // to be continued.... } }; @@ -148,7 +126,7 @@ CPUDef.PS.DIRECT = (CPUDef.PS.IF); * However, PS "arithmetic" flags are NOT stored in regPS; they are maintained across * separate result registers, hence the "indirect" designation. */ -CPUDef.PS.INDIRECT = (CPUDef.PS.CF | CPUDef.PS.PF | CPUDef.PS.AF | CPUDef.PS.ZF | CPUDef.PS.SF | CPUDef.PS.OF); +CPUDef.PS.INDIRECT = (CPUDef.PS.CF | CPUDef.PS.PF | CPUDef.PS.AF | CPUDef.PS.ZF | CPUDef.PS.SF); /* * These are the default "always set" PS bits for the 8080. diff --git a/modules/pc8080/lib/cpuops.js b/modules/pc8080/lib/cpuops.js index ffea89c91..ca233b01c 100644 --- a/modules/pc8080/lib/cpuops.js +++ b/modules/pc8080/lib/cpuops.js @@ -55,11 +55,102 @@ CPUDef.opNOP = function() */ CPUDef.opLXIB = function() { - this.regC = this.getPCByte(); - this.regB = this.getPCByte(); + this.setBC(this.getPCWord()); this.nStepCycles -= 10; }; +/** + * op=0x02 (STAX B) + * + * @this {CPUSim} + */ +CPUDef.opSTAXB = function() +{ + this.setByte(this.getBC(), this.regA); + this.nStepCycles -= 7; +}; + +/** + * op=0x03 (INX B) + * + * @this {CPUSim} + */ +CPUDef.opINXB = function() +{ + this.setBC(this.getBC() + 1); + this.nStepCycles -= 5; +}; + +/** + * op=0x04 (INR B) + * + * @this {CPUSim} + */ +CPUDef.opINRB = function() +{ + this.regB = this.incByte(this.regB); + this.nStepCycles -= 5; +}; + +/** + * op=0x05 (DCR B) + * + * @this {CPUSim} + */ +CPUDef.opDCRB = function() +{ + this.regB = this.decByte(this.regB); + this.nStepCycles -= 5; +}; + +/** + * op=0x06 (MVI B,d8) + * + * @this {CPUSim} + */ +CPUDef.opMVIB = function() +{ + this.regB = this.getPCByte(); + this.nStepCycles -= 7; +}; + +/** + * op=0x07 (RLC) + * + * @this {CPUSim} + */ +CPUDef.opRLC = function() +{ + var b = this.regA << 1; + this.regA = (b & 0xff) | (b >> 8); + this.resultZeroCarry = (this.resultZeroCarry & 0xff) | (b & 0x100); + this.nStepCycles -= 4; +}; + +/** + * op=0x09 (DAD B) + * + * @this {CPUSim} + */ +CPUDef.opDADB = function() +{ + var w; + this.setHL(w = this.getHL() + this.getBC()); + this.resultZeroCarry = (this.resultZeroCarry & 0xff) | ((w >> 8) & 0x100); + this.nStepCycles -= 10; +}; + +/** + * op=0x0A (LDAX B) + * + * @this {CPUSim} + */ +CPUDef.opLDAXB = function() +{ + this.regA = this.getByte(this.getBC()); + this.nStepCycles -= 7; +}; + /** * opTBD() * @@ -80,9 +171,9 @@ CPUDef.opTBD = function() * money on array lookup. */ CPUDef.aOps = [ - /* 0x00-0x03 */ CPUDef.opNOP, CPUDef.opLXIB, CPUDef.opTBD, CPUDef.opTBD, - /* 0x04-0x07 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, - /* 0x08-0x0B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, + /* 0x00-0x03 */ CPUDef.opNOP, CPUDef.opLXIB, CPUDef.opSTAXB, CPUDef.opINXB, + /* 0x04-0x07 */ CPUDef.opINRB, CPUDef.opDCRB, CPUDef.opMVIB, CPUDef.opRLC, + /* 0x08-0x0B */ CPUDef.opNOP, CPUDef.opDADB, CPUDef.opLDAXB, CPUDef.opTBD, /* 0x0C-0x0F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, /* 0x10-0x13 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, /* 0x14-0x17 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, diff --git a/modules/pc8080/lib/cpusim.js b/modules/pc8080/lib/cpusim.js index 695d5a1dc..6afaf34b2 100644 --- a/modules/pc8080/lib/cpusim.js +++ b/modules/pc8080/lib/cpusim.js @@ -212,7 +212,6 @@ CPUSim.prototype.removeMemCheck = function(addr, fWrite) */ CPUSim.prototype.initProcessor = function() { - this.cycleCounts = CPUDef.CYCLES; this.aOps = CPUDef.aOps; }; @@ -323,37 +322,113 @@ CPUSim.prototype.restore = function(data) }; /** - * getPC() + * setBinding(sHTMLType, sBinding, control, sValue) + * + * @this {CPUSim} + * @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas") + * @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "AX") + * @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement) + * @param {string} [sValue] optional data value + * @return {boolean} true if binding was successful, false if unrecognized binding request + */ +CPUSim.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) +{ + var fBound = false; + switch (sBinding) { + case "A": + case "B": + case "C": + case "D": + case "E": + case "H": + case "L": + case "SP": + case "PC": + case "F": + case "CF": + case "PF": + case "AF": + case "ZF": + case "SF": + case "VF": + this.bindings[sBinding] = control; + this.cLiveRegs++; + fBound = true; + break; + default: + fBound = this.parent.setBinding.call(this, sHTMLType, sBinding, control); + break; + } + return fBound; +}; + +/** + * getBC() * * @this {CPUSim} * @return {number} */ -CPUSim.prototype.getPC = function() +CPUSim.prototype.getBC = function() { - return this.regPC; + return (this.regB << 8) | this.regC; }; /** - * setPC(off) + * setBC(w) * * @this {CPUSim} - * @param {number} off + * @param {number} w */ -CPUSim.prototype.setPC = function(off) +CPUSim.prototype.setBC = function(w) { - this.regPC = off & 0xffff; + this.regB = (w >> 8) & 0xff; + this.regC = w & 0xff; }; /** - * checkPC(inc) + * getDE() * * @this {CPUSim} - * @param {number} inc (positive) - * @return {number} new PC + * @return {number} */ -CPUSim.prototype.checkPC = function(inc) +CPUSim.prototype.getDE = function() { - return (this.regPC + inc)|0; + return (this.regD << 8) | this.regE; +}; + +/** + * setDE(w) + * + * @this {CPUSim} + * @param {number} w + */ +CPUSim.prototype.setDE = function(w) +{ + this.regD = (w >> 8) & 0xff; + this.regE = w & 0xff; +}; + +/** + * getHL() + * + * @this {CPUSim} + * @return {number} + */ +CPUSim.prototype.getHL = function() +{ + return (this.regH << 8) | this.regL; +}; + +/** + * setHL(w) + * + * @this {CPUSim} + * @param {number} w + */ +CPUSim.prototype.setHL = function(w) +{ + this.regH = (w >> 8) & 0xff; + this.regL = w & 0xff; }; /** @@ -379,14 +454,25 @@ CPUSim.prototype.setSP = function(off) }; /** - * getCarry() + * getPC() * * @this {CPUSim} - * @return {number} 0 or 1, depending on whether CF is clear or set + * @return {number} */ -CPUSim.prototype.getCarry = function() +CPUSim.prototype.getPC = function() { - return this.getCF()? 1 : 0; + return this.regPC; +}; + +/** + * setPC(off) + * + * @this {CPUSim} + * @param {number} off + */ +CPUSim.prototype.setPC = function(off) +{ + this.regPC = off & 0xffff; }; /** @@ -397,7 +483,7 @@ CPUSim.prototype.getCarry = function() */ CPUSim.prototype.getCF = function() { - return (this.resultValue & this.resultSize)? CPUDef.PS.CF : 0; + return (this.resultZeroCarry & 0x100)? CPUDef.PS.CF : 0; }; /** @@ -419,7 +505,7 @@ CPUSim.prototype.getPF = function() */ CPUSim.prototype.getAF = function() { - return ((this.resultParitySign ^ this.resultAuxOverflow) & CPUDef.RESULT.AUXOVF_AF)? CPUDef.PS.AF : 0; + return ((this.resultParitySign ^ this.resultAuxOverflow) & 0x10)? CPUDef.PS.AF : 0; }; /** @@ -430,7 +516,7 @@ CPUSim.prototype.getAF = function() */ CPUSim.prototype.getZF = function() { - return (this.resultValue & (this.resultSize - 1))? 0 : CPUDef.PS.ZF; + return (this.resultZeroCarry & 0xff)? 0 : CPUDef.PS.ZF; }; /** @@ -441,7 +527,7 @@ CPUSim.prototype.getZF = function() */ CPUSim.prototype.getSF = function() { - return (this.resultParitySign & (this.resultSize >> 1))? CPUDef.PS.SF : 0; + return (this.resultParitySign & 0x80)? CPUDef.PS.SF : 0; }; /** @@ -455,17 +541,6 @@ CPUSim.prototype.getIF = function() return (this.regPS & CPUDef.PS.IF); }; -/** - * getOF() - * - * @this {CPUSim} - * @return {number} 0 or CPUDef.PS.OF - */ -CPUSim.prototype.getOF = function() -{ - return ((this.resultParitySign ^ this.resultAuxOverflow ^ (this.resultParitySign >> 1)) & (this.resultSize >> 1))? CPUDef.PS.OF : 0; -}; - /** * clearCF() * @@ -473,7 +548,7 @@ CPUSim.prototype.getOF = function() */ CPUSim.prototype.clearCF = function() { - this.resultValue &= ~this.resultSize; + this.resultZeroCarry &= 0xff; }; /** @@ -493,7 +568,7 @@ CPUSim.prototype.clearPF = function() */ CPUSim.prototype.clearAF = function() { - this.resultAuxOverflow = (this.resultParitySign & CPUDef.RESULT.AUXOVF_AF) | (this.resultAuxOverflow & ~CPUDef.RESULT.AUXOVF_AF); + this.resultAuxOverflow = (this.resultParitySign & 0x10) | (this.resultAuxOverflow & ~0x10); }; /** @@ -503,7 +578,7 @@ CPUSim.prototype.clearAF = function() */ CPUSim.prototype.clearZF = function() { - this.resultValue |= (this.resultSize - 1); + this.resultZeroCarry |= 0xff; }; /** @@ -513,10 +588,7 @@ CPUSim.prototype.clearZF = function() */ CPUSim.prototype.clearSF = function() { - if (this.getSF()) { - this.resultParitySign ^= (this.resultSize >> 1) | (this.resultSize >> 2); - this.resultAuxOverflow ^= CPUDef.RESULT.AUXOVF_OF; - } + if (this.getSF()) this.resultParitySign ^= 0xc0; }; /** @@ -529,17 +601,6 @@ CPUSim.prototype.clearIF = function() this.regPS &= ~CPUDef.PS.IF; }; -/** - * clearOF() - * - * @this {CPUSim} - */ -CPUSim.prototype.clearOF = function() -{ - this.resultParitySign &= ~this.resultSize; - this.resultAuxOverflow = (this.resultParitySign & CPUDef.RESULT.AUXOVF_OF) | (this.resultAuxOverflow & ~CPUDef.RESULT.AUXOVF_OF); -}; - /** * setCF() * @@ -547,7 +608,7 @@ CPUSim.prototype.clearOF = function() */ CPUSim.prototype.setCF = function() { - this.resultValue |= this.resultSize; + this.resultZeroCarry |= 0x100; }; /** @@ -567,7 +628,7 @@ CPUSim.prototype.setPF = function() */ CPUSim.prototype.setAF = function() { - this.resultAuxOverflow = ~(this.resultParitySign & CPUDef.RESULT.AUXOVF_AF) & CPUDef.RESULT.AUXOVF_AF | (this.resultAuxOverflow & ~CPUDef.RESULT.AUXOVF_AF); + this.resultAuxOverflow = (~this.resultParitySign & 0x10) | (this.resultAuxOverflow & ~0x10); }; /** @@ -577,7 +638,7 @@ CPUSim.prototype.setAF = function() */ CPUSim.prototype.setZF = function() { - this.resultValue &= ~(this.resultSize - 1); + this.resultZeroCarry &= ~0xff; }; /** @@ -587,10 +648,7 @@ CPUSim.prototype.setZF = function() */ CPUSim.prototype.setSF = function() { - if (!this.getSF()) { - this.resultParitySign ^= (this.resultSize >> 1) | (this.resultSize >> 2); - this.resultAuxOverflow ^= CPUDef.RESULT.AUXOVF_OF; - } + if (!this.getSF()) this.resultParitySign ^= 0xc0; }; /** @@ -603,17 +661,6 @@ CPUSim.prototype.setIF = function() this.regPS |= CPUDef.PS.IF; }; -/** - * setOF() - * - * @this {CPUSim} - */ -CPUSim.prototype.setOF = function() -{ - this.resultParitySign |= this.resultSize; - this.resultAuxOverflow = (this.resultParitySign & CPUDef.RESULT.AUXOVF_OF) | (this.resultAuxOverflow & ~CPUDef.RESULT.AUXOVF_OF); -}; - /** * getPS() * @@ -622,7 +669,7 @@ CPUSim.prototype.setOF = function() */ CPUSim.prototype.getPS = function() { - return (this.regPS & ~CPUDef.PS.INDIRECT) | (this.getCF() | this.getPF() | this.getAF() | this.getZF() | this.getSF()); + return (this.regPS & ~CPUDef.PS.INDIRECT) | (this.getSF() | this.getZF() | this.getAF() | this.getPF() | this.getCF()); }; /** @@ -630,82 +677,52 @@ CPUSim.prototype.getPS = function() * * @this {CPUSim} * @param {number} regPS - * @param {number} [cpl] */ -CPUSim.prototype.setPS = function(regPS, cpl) +CPUSim.prototype.setPS = function(regPS) { - this.resultSize = CPUDef.RESULT.SIZE_BYTE; - this.resultValue = this.resultParitySign = this.resultAuxOverflow = 0; - - if (regPS & CPUDef.PS.CF) { - this.setCF(); - } - if (!(regPS & CPUDef.PS.PF)) { - this.resultParitySign |= 0x1; - } - if (regPS & CPUDef.PS.AF) { - this.resultAuxOverflow |= CPUDef.RESULT.AUXOVF_AF; - } - if (!(regPS & CPUDef.PS.ZF)) { - this.clearZF(); - } - if (regPS & CPUDef.PS.SF) { - this.setSF(); - } + this.resultZeroCarry = this.resultParitySign = this.resultAuxOverflow = 0; + if (regPS & CPUDef.PS.CF) this.resultZeroCarry |= 0x100; + if (!(regPS & CPUDef.PS.PF)) this.resultParitySign |= 0x01; + if (regPS & CPUDef.PS.AF) this.resultAuxOverflow |= 0x10; + if (!(regPS & CPUDef.PS.ZF)) this.resultZeroCarry |= 0xff; + if (regPS & CPUDef.PS.SF) this.resultParitySign ^= 0xc0; this.regPS = (this.regPS & ~CPUDef.PS.DIRECT) | (regPS & CPUDef.PS.DIRECT) | CPUDef.PS.SET; - /* - * Assert that all requested flag bits now agree with our simulated (PS_INDIRECT) bits - */ Component.assert((regPS & CPUDef.PS.INDIRECT) == (this.getPS() & CPUDef.PS.INDIRECT)); }; /** - * setBinding(sHTMLType, sBinding, control, sValue) + * incByte(b) * * @this {CPUSim} - * @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas") - * @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "AX") - * @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement) - * @param {string} [sValue] optional data value - * @return {boolean} true if binding was successful, false if unrecognized binding request + * @param {number} b + * @return {number} */ -CPUSim.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) +CPUSim.prototype.incByte = function(b) { - var fBound = false; - switch (sBinding) { - case "A": - case "B": - case "C": - case "D": - case "E": - case "H": - case "L": - case "SP": - case "PC": - case "F": - case "C": - case "P": - case "A": - case "Z": - case "S": - case "V": - this.bindings[sBinding] = control; - this.cLiveRegs++; - fBound = true; - break; - default: - fBound = this.parent.setBinding.call(this, sHTMLType, sBinding, control); - break; - } - return fBound; + this.resultAuxOverflow = b; + b = (this.resultParitySign = b + 1) & 0xff; + this.resultZeroCarry = (this.resultZeroCarry & ~0xff) | b; + return b; +}; + +/** + * decByte(b) + * + * @this {CPUSim} + * @param {number} b + * @return {number} + */ +CPUSim.prototype.decByte = function(b) +{ + this.resultAuxOverflow = b; + b = (this.resultParitySign = b - 1) & 0xff; + this.resultZeroCarry = (this.resultZeroCarry & ~0xff) | b; + return b; }; /** * getByte(addr) * - * Use bus.getByte() for physical addresses, and cpu.getByte() for linear addresses; the latter takes care - * of cycle counts, if any. - * * @this {CPUSim} * @param {number} addr is a linear address * @return {number} byte (8-bit) value at that address @@ -773,9 +790,8 @@ CPUSim.prototype.setWord = function(addr, w) */ CPUSim.prototype.getPCByte = function() { - var newPC = this.checkPC(1); var b = this.getByte(this.regPC); - this.regPC = newPC; + this.setPC(this.regPC + 1); return b; }; @@ -787,37 +803,11 @@ CPUSim.prototype.getPCByte = function() */ CPUSim.prototype.getPCWord = function() { - var newPC = this.checkPC(2); var w = this.getWord(this.regPC); - this.regPC = newPC; + this.setPC(this.regPC + 2); return w; }; -/** - * getPCDisp() - * - * @this {CPUSim} - * @return {number} sign-extended (32-bit) value from the byte at the current PC; PC advanced by 1 - */ -CPUSim.prototype.getPCDisp = function() -{ - var newPC = this.checkPC(1); - var w = ((this.getByte(this.regPC)) << 24) >> 24; - this.regPC = newPC; - return w; -}; - -/** - * peekPCByte() - * - * @this {CPUSim} - * @return {number} byte at the current PC - */ -CPUSim.prototype.peekPCByte = function() -{ - return this.getByte(this.regPC); -}; - /** * popWord() * diff --git a/modules/shared/lib/embed.js b/modules/shared/lib/embed.js index 7107a86be..ec8788608 100644 --- a/modules/shared/lib/embed.js +++ b/modules/shared/lib/embed.js @@ -165,7 +165,7 @@ function parseXML(sXML, sXMLFile, idMachine, sAppClass, sParms, fResolve, displa if (!fResolve) { /* * I'm trying to switch to a shared components.xsl (at least for all PC-class machines), - * but in the interim, that means hacking the XSL file on the fly to reflect the chosen class. + * but in the interim, that means hacking the XSL file on the fly to reflect the actual class. */ sXML = sXML.replace(/().*?(<\/xsl:variable>)/, "$1" + sAppClass + "$2"); diff --git a/versions/pc8080/1.21.7/pc8080-dbg.js b/versions/pc8080/1.21.7/pc8080-dbg.js index 1cf4e251b..d441d8a0a 100644 --- a/versions/pc8080/1.21.7/pc8080-dbg.js +++ b/versions/pc8080/1.21.7/pc8080-dbg.js @@ -9,60 +9,61 @@ function ya(){return window?window.navigator.userAgent:""}function v(a){window&& function Ha(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}function Ia(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Ja(a){if(window){var b=ya();return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}function Ka(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0=this.J?12:24>=this.J?14:15;this.X=1<>2;this.s=this.X-1;this.I=this.L/this.X|0;this.K=this.I-1;this.A=[];this.D=[];this.F=this.G=!1;this.P=[];this.T=[];a=new H;zb(a,this.C);this.B=Array(this.I);for(b=0;b>>a.O;0a.X?a.X:c;if(f&&f.size){if(f.type==d){if(b+c<=f.w)return f.eb+=f.w-b,f.w=b,!0;if(b>=f.w+f.eb){h=f.size-(b-k);h>c&&(h=c);f.eb=b-f.w+h;c-=h;b=k+a.X;continue}}return Bb(1,b,c)}f=a.B[e];b=new H(b,h,a.X,d);zb(b,a.C,f);a.B[e++]=b;b=k+a.X;c-=h}return 0>=c?!0:Bb(2,b,c)}function Cb(a,b){return a.B[(b&a.u)>>>a.O].bb(b&a.s,b)} -function Db(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 Eb(a,b){if(void 0===b)return a.G=!a.G,a.G;void 0===a.D[b]&&(a.D[b]=[null,!1]);a.D[b][1]=!a.D[b][1];return a.D[b][1]}function Bb(a,b,c){v("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Rb;if(tb){var Sb=new ArrayBuffer(2);(new DataView(Sb)).setUint16(0,256,!0);Rb=256===(new Uint16Array(Sb))[0]}else Rb=!1;var Tb=Rb; -function H(a,b,c,d){this.id=Ub+=2;this.b=null;this.w=a;this.eb=b;this.size=c||0;this.type=d||Vb;this.F=d==Wb;zb(this);this.ma=this.Rb=!1;if(c)if(tb)this.A=new ArrayBuffer(c),this.D=new DataView(this.A,0,c),this.H=new Uint8Array(this.A,0,c),this.I=new Uint16Array(this.A,0,c>>1),this.b=new Int32Array(this.A,0,c>>2),Xb(this,Tb?Yb:Zb);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},P:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ea: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},Fa: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.ma=!0},L:function(a,b){if(this.C&&null!=this.w){var c=this.C;ec(c,this.w+a,1,c.M)&&c.S(!0)}return this.bb(a,b)},Y:function(a,b){if(this.C&&null!=this.w){var c=this.C;ec(c,this.w+a,2,c.M)&&c.S(!0)}return this.Ib(a,b)},qa:function(a,b,c){if(this.C&&null!=this.w){var d=this.C;ec(d,this.w+a,1,d.F)&&d.S(!0)}this.F?this.u(a,b,c):this.Sa(a,b,c)},Ua:function(a,b,c){if(this.C&& -null!=this.w){var d=this.C;ec(d,this.w+a,2,d.F)&&d.S(!0)}this.F?this.u(a,b,c):this.Lb(a,b,c)},K:function(a){return this.H[a]},M:function(a){return this.H[a]},T:function(a){return this.D.getUint16(a,!0)},da:function(a){return a&1?this.H[a]|this.H[a+1]<<8:this.I[a>>1]},ga:function(a,b){this.H[a]=b;this.ma=!0},ra:function(a,b){this.H[a]=b;this.ma=!0},Ta:function(a,b){this.D.setUint16(a,b,!0);this.ma=!0},gb:function(a,b){a&1?(this.H[a]=b,this.H[a+1]=b>>8):this.I[a>>1]=b;this.ma=!0}}; -function zb(a,b,c){a.C=b;a.B=a.s=0;c&&((a.B=c.B)&&dc(a,cc,!1),(a.s=c.s)&&bc(a,cc,!1))}function fc(a,b){b?0===--a.s&&(a.G=a.F?a.u:a.Sa):0===--a.B&&(a.lb=a.bb)}function bc(a,b,c){c&&a.s||(a.G=!a.F&&b[2]||a.u);if(c||void 0===c)a.Sa=b[2]||a.u,a.Lb=b[3]||a.Va}function dc(a,b,c){c&&a.B||(a.lb=b[0]||a.J);if(c||void 0===c)a.bb=b[0]||a.J,a.Ib=b[1]||a.aa}function Xb(a,b){b||(b=gc);dc(a,b,void 0);bc(a,b,void 0)} -var gc=[],$b=[H.prototype.P,H.prototype.ea,H.prototype.Fa,H.prototype.hb],cc=[H.prototype.L,H.prototype.Y,H.prototype.qa,H.prototype.Ua];if(tb)var Zb=[H.prototype.K,H.prototype.T,H.prototype.ga,H.prototype.Ta],Yb=[H.prototype.M,H.prototype.da,H.prototype.ra,H.prototype.gb]; -function hc(a,b){x.call(this,"CPU",a,hc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Qa=c;this.i.ya=d;this.i.pb=Math.round(this.i.Qa/1E4)/100;this.i.wa=this.i.pb*this.i.ya;this.j.V=!1;this.j.ob=!1;this.j.Ab=a.autoStart;this.j.Bb=!1;this.j.Ha=!1;this.i.Wa=this.i.Na=0;this.i.Xa=a.csStart;this.i.Ma=a.csInterval;this.i.Oa=a.csStop;this.aa=this.Ea.bind(this);G(this)}z(hc);var ic=["power","reset"];g=hc.prototype; -g.Ka=function(a,b,c,d){this.s=a;this.B=b;this.C=d;for(b=0;b=a.i.Na&&(a.i.Na+=a.i.Ma,c=!0);0<=a.i.Oa&&a.i.Oa<=pc(a)&&(a.i.Ma=a.i.Oa=-1,lc(a),a.S(),c=!0);c&&a.g(pc(a)+" cycles: checksum="+n(a.i.Wa))}} -g.ba=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.H[b]=c;a=!0;break;case "run":this.H[b]=c;c.onclick=function(){var a;if(a=d.s)if(a=d.s,a.j.U)a=!0;else{var b=null,c,h=C(a.id);for(c=0;cc&&(c=60);2>c&&(c=2);var d=1;b&&1a.i.va/a.i.wa?b=1:d=!0;a.i.ya=b;b=a.i.pb*a.i.ya;if(a.i.wa!=b){a.i.wa=b;b=a.i.wa.toFixed(2)+"Mhz";var e=a.H.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.s&&a.s.cb()}rc(a,a.I);a.I=0;a.i.La=ua();a.i.xa=0;sc(a);return d} -g.Ea=function(a){if(pb(this,!0)){if(!this.j.V){qc(this);this.s&&this.s.start(this.i.La,pc(this));this.j.V=!0;this.j.ob=!0;this.D&&this.D.Wb();var b=this.H.run;b&&(b.textContent="Halt");this.s&&(this.s.ca(!0),a&&this.s.cb(!0))}this.i.rb>=this.i.Qa&&sc(this,!0);this.i.$a=0;this.i.kb=ua();this.i.xa&&(a=this.i.kb-this.i.xa,a>this.i.Eb&&(this.i.La+=a,this.i.La>this.i.kb&&(this.i.La=this.i.kb)));try{do{var c=this.j.Ha?1:this.i.Vb;this.D&&(this.D.Kb(),c=this.D.Yb(0,c),c=this.D.Xb(c));try{this.Ra(c)}catch(e){if("number"!= -typeof e)throw e;}var d=this.G-this.u;this.I+=d;this.i.$a+=d;rc(this,0,!0);oc(this,d);this.i.Za-=d;0>=this.i.Za&&(this.i.Za+=this.i.Gb);this.i.Ya-=d;0>=this.i.Ya&&(this.i.Ya+=this.i.Fb,this.s&&this.s.ca());this.i.Pa-=d;if(0>=this.i.Pa){this.i.Pa+=this.i.qb;break}}while(this.j.V)}catch(e){this.S();I(this);this.s&&this.s.stop(ua(),pc(this));pb(this,!1);sb(this,e.stack||e.message);return}c=setTimeout;d=this.aa;this.i.xa=ua();a=this.i.Eb;this.i.$a&&(a=Math.round(a*this.i.$a/this.i.qb));a-=this.i.xa-this.i.kb; -if(b=this.i.xa-this.i.La)this.i.va=Math.round(this.I/(10*b))/100,864E5<=b&&(this.J=0,this.D&&this.D.Kb(!0),qc(this));if(0>a||this.i.va>1?128:0}function Yc(a){Xc(a)||(a.R^=a.A>>1|a.A>>2,a.F^=32896)}function Wc(a){return a.Ca&-2262|(a.b&a.A?1:0)|(ub[a.R&255]?4:0)|((a.R^a.F)&16?16:0)|(a.b&a.A-1?0:64)|Xc(a)}function Vc(a,b){a.A=256;a.b=a.R=a.F=0;b&1&&(a.b|=a.A);b&4||(a.R|=1);b&16&&(a.F|=16);b&64||(a.b|=a.A-1);b&128&&Yc(a);a.Ca=a.Ca&-513|b&512|2} -g.ba=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "D":case "E":case "H":case "L":case "SP":case "PC":case "F":case "C":case "P":case "A":case "Z":case "S":case "V":this.H[b]=c;this.T++;d=!0;break;default:d=this.parent.ba.call(this,a,b,c)}return d};function Zc(a){var b;b=a.N+1|0;var c;c=a.N;c=a.sa[(c&a.P)>>>a.O].lb(c&a.M,c);a.N=b;return c} -function N(a,b,c,d){d=d||2;a.H[b]&&(void 0===c&&(sb(a,"Value for "+b+" is invalid"),a.S()),c=!a.j.V||a.j.Bb?n(c,d):"--------".substr(0,d),a.H[b].textContent!=c&&(a.H[b].textContent=c))} -g.ca=function(a){this.T&&(a||!this.j.V||this.j.Bb)&&(N(this,"A",this.za),N(this,"B",this.ka),N(this,"C",this.na),N(this,"D",this.oa),N(this,"E",this.Aa),N(this,"H",this.pa),N(this,"L",this.Ba),N(this,"SP",this.Da,4),N(this,"PC",this.N,4),a=Wc(this),N(this,"F",a,2),N(this,"S",a&128,1),N(this,"Z",a&64,1),N(this,"A",a&16,1),N(this,"P",a&4,1),N(this,"C",a&1,1));if(a=this.H.speed)a.textContent=this.j.V&&this.i.va?this.i.va.toFixed(2)+"Mhz":"Stopped"}; -g.Ra=function(a){this.j.ib=!0;var b=this.j.Qb=this.C&&$c(this.C),c=a?this.j.ob?0:1:-1;this.j.ob=!1;this.G=this.u=a;this.D&&!a&&this.D.Kb();a||(this.K|=4);do{if(this.L&&this.L&4){this.K=this.u=0;break}if(b){if(ad(this.C,this.N,c)){this.S();break}c=1}this.K=0;this.Y[Zc(this)].call(this)}while(0>>0,k],r=ta(p,l,a.tb);0>r&&p.splice(-(r+1),0,l)}m&&(h.a=m.replace(/''/g,'"'))}a.G.push({Zb:b,w:c,Ub:d,ha:e,ub:f})}delete this.ha}return!0};bd.prototype.ia=function(){return!0}; -function cd(a,b,c,d){if(d)a.Z("Unable to load system ROM (error "+d+": "+b+")");else{kb(a.wb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,k=e.data;if(f)a.s=f;else if(k)for(a.s=Array(4*k.length),d=c=0;c>8&255,a.s[d++]=k[c]>>16&255,a.s[d++]=k[c]>>24&255;else a.s=e;a.ha=e.symbols;if(!a.s.length){v("Empty ROM: "+b);return}if(1==a.s.length){v(a.s[0]);return}}catch(h){a.Z("ROM data error: "+h.message);return}else for(b=c.replace(/\n/gm, +function yb(a,b,c){x.call(this,"Bus",a,yb);this.b=b;this.B=c;this.J=a.buswidth||16;this.M=Math.pow(2,this.J);this.w=this.M-1|0;this.P=20>=this.J?12:24>=this.J?14:15;this.Z=1<>2;this.s=this.Z-1;this.I=this.M/this.Z|0;this.L=this.I-1;this.C=[];this.D=[];this.F=this.H=!1;this.S=[];this.V=[];a=new H;zb(a,this.B);this.A=Array(this.I);for(b=0;b>>a.P;0a.Z?a.Z:c;if(f&&f.size){if(f.type==d){if(b+c<=f.u)return f.gb+=f.u-b,f.u=b,!0;if(b>=f.u+f.gb){h=f.size-(b-k);h>c&&(h=c);f.gb=b-f.u+h;c-=h;b=k+a.Z;continue}}return Bb(1,b,c)}f=a.A[e];b=new H(b,h,a.Z,d);zb(b,a.B,f);a.A[e++]=b;b=k+a.Z;c-=h}return 0>=c?!0:Bb(2,b,c)}function Cb(a,b){return a.A[(b&a.w)>>>a.P].eb(b&a.s,b)} +function Db(a,b){if(void 0===b)return a.F=!a.F,a.F;void 0===a.C[b]&&(a.C[b]=[null,!1]);a.C[b][1]=!a.C[b][1];return a.C[b][1]}function Qb(a,b){if(void 0===b)return a.H=!a.H,a.H;void 0===a.D[b]&&(a.D[b]=[null,!1]);a.D[b][1]=!a.D[b][1];return a.D[b][1]}function Bb(a,b,c){v("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Rb;if(tb){var Sb=new ArrayBuffer(2);(new DataView(Sb)).setUint16(0,256,!0);Rb=256===(new Uint16Array(Sb))[0]}else Rb=!1;var Tb=Rb; +function H(a,b,c,d){this.id=Ub+=2;this.b=null;this.u=a;this.gb=b;this.size=c||0;this.type=d||Vb;this.F=d==Wb;zb(this);this.sa=this.Ub=!1;if(c)if(tb)this.C=new ArrayBuffer(c),this.D=new DataView(this.C,0,c),this.G=new Uint8Array(this.C,0,c),this.H=new Uint16Array(this.C,0,c>>1),this.b=new Int32Array(this.C,0,c>>2),Xb(this,Tb?Yb:Zb);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},S:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ia: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},va: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.sa=!0},M:function(a,b){if(this.B&&null!=this.u){var c=this.B;ec(c,this.u+a,1,c.R)&&c.U(!0)}return this.eb(a,b)},aa:function(a,b){if(this.B&&null!=this.u){var c=this.B;ec(c,this.u+a,2,c.R)&&c.U(!0)}return this.tb(a,b)},ma:function(a,b,c){if(this.B&&null!=this.u){var d=this.B;ec(d,this.u+a,1,d.F)&&d.U(!0)}this.F?this.w(a,b,c):this.Ua(a,b,c)},Va:function(a,b, +c){if(this.B&&null!=this.u){var d=this.B;ec(d,this.u+a,2,d.F)&&d.U(!0)}this.F?this.w(a,b,c):this.Ob(a,b,c)},L:function(a){return this.G[a]},R:function(a){return this.G[a]},V:function(a){return this.D.getUint16(a,!0)},ca:function(a){return a&1?this.G[a]|this.G[a+1]<<8:this.H[a>>1]},ja:function(a,b){this.G[a]=b;this.sa=!0},ua:function(a,b){this.G[a]=b;this.sa=!0},Ga:function(a,b){this.D.setUint16(a,b,!0);this.sa=!0},Xa:function(a,b){a&1?(this.G[a]=b,this.G[a+1]=b>>8):this.H[a>>1]=b;this.sa=!0}}; +function zb(a,b,c){a.B=b;a.A=a.s=0;c&&((a.A=c.A)&&dc(a,cc,!1),(a.s=c.s)&&bc(a,cc,!1))}function fc(a,b){b?0===--a.s&&(a.mb=a.F?a.w:a.Ua):0===--a.A&&(a.Sa=a.eb,a.Lb=a.tb)}function bc(a,b,c){c&&a.s||(a.mb=!a.F&&b[2]||a.w);if(c||void 0===c)a.Ua=b[2]||a.w,a.Ob=b[3]||a.Wa}function dc(a,b,c){c&&a.A||(a.Sa=b[0]||a.I,a.Lb=b[1]||a.J);if(c||void 0===c)a.eb=b[0]||a.I,a.tb=b[1]||a.J}function Xb(a,b){b||(b=gc);dc(a,b,void 0);bc(a,b,void 0)} +var gc=[],$b=[H.prototype.S,H.prototype.ia,H.prototype.va,H.prototype.ib],cc=[H.prototype.M,H.prototype.aa,H.prototype.ma,H.prototype.Va];if(tb)var Zb=[H.prototype.L,H.prototype.V,H.prototype.ja,H.prototype.Ga],Yb=[H.prototype.R,H.prototype.ca,H.prototype.ua,H.prototype.Xa]; +function hc(a,b){x.call(this,"CPU",a,hc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Ra=c;this.i.Ba=d;this.i.qb=Math.round(this.i.Ra/1E4)/100;this.i.za=this.i.qb*this.i.Ba;this.j.X=!1;this.j.pb=!1;this.j.Db=a.autoStart;this.j.Eb=!1;this.j.Ia=!1;this.i.Ya=this.i.Oa=0;this.i.Za=a.csStart;this.i.Na=a.csInterval;this.i.Pa=a.csStop;this.ca=this.Fa.bind(this);G(this)}z(hc);var ic=["power","reset"];g=hc.prototype; +g.La=function(a,b,c,d){this.s=a;this.A=b;this.B=d;for(b=0;b=a.i.Oa&&(a.i.Oa+=a.i.Na,c=!0);0<=a.i.Pa&&a.i.Pa<=pc(a)&&(a.i.Na=a.i.Pa=-1,lc(a),a.U(),c=!0);c&&a.g(pc(a)+" cycles: checksum="+n(a.i.Ya))}} +g.ea=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.G[b]=c;a=!0;break;case "run":this.G[b]=c;c.onclick=function(){var a;if(a=d.s)if(a=d.s,a.j.W)a=!0;else{var b=null,c,h=C(a.id);for(c=0;cc&&(c=60);2>c&&(c=2);var d=1;b&&1a.i.ya/a.i.za?b=1:d=!0;a.i.Ba=b;b=a.i.qb*a.i.Ba;if(a.i.za!=b){a.i.za=b;b=a.i.za.toFixed(2)+"Mhz";var e=a.G.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.s&&a.s.fb()}Qc(a,a.F);a.F=0;a.i.Ma=ua();a.i.Aa=0;Rc(a);return d} +g.Fa=function(a){if(pb(this,!0)){if(!this.j.X){qc(this);this.s&&this.s.start(this.i.Ma,pc(this));this.j.X=!0;this.j.pb=!0;this.w&&this.w.Zb();var b=this.G.run;b&&(b.textContent="Halt");this.s&&(this.s.fa(!0),a&&this.s.fb(!0))}this.i.sb>=this.i.Ra&&Rc(this,!0);this.i.bb=0;this.i.lb=ua();this.i.Aa&&(a=this.i.lb-this.i.Aa,a>this.i.Hb&&(this.i.Ma+=a,this.i.Ma>this.i.lb&&(this.i.Ma=this.i.lb)));try{do{var c=this.j.Ia?1:this.i.Yb;this.w&&(this.w.Nb(),c=this.w.ac(0,c),c=this.w.$b(c));try{this.Ta(c)}catch(e){if("number"!= +typeof e)throw e;}var d=this.D-this.b;this.F+=d;this.i.bb+=d;Qc(this,0,!0);oc(this,d);this.i.ab-=d;0>=this.i.ab&&(this.i.ab+=this.i.Jb);this.i.$a-=d;0>=this.i.$a&&(this.i.$a+=this.i.Ib,this.s&&this.s.fa());this.i.Qa-=d;if(0>=this.i.Qa){this.i.Qa+=this.i.rb;break}}while(this.j.X)}catch(e){this.U();I(this);this.s&&this.s.stop(ua(),pc(this));pb(this,!1);sb(this,e.stack||e.message);return}c=setTimeout;d=this.ca;this.i.Aa=ua();a=this.i.Hb;this.i.bb&&(a=Math.round(a*this.i.bb/this.i.rb));a-=this.i.Aa-this.i.lb; +if(b=this.i.Aa-this.i.Ma)this.i.ya=Math.round(this.F/(10*b))/100,864E5<=b&&(this.H=0,this.w&&this.w.Nb(!0),qc(this));if(0>a||this.i.ya>>a.P].Sa(b&a.I,b)}function Yc(a){var b=Xc(a,a.N);a.N=a.N+1&65535;return b}function N(a,b,c,d){d=d||2;a.G[b]&&(void 0===c&&(sb(a,"Value for "+b+" is invalid"),a.U()),c=!a.j.X||a.j.Eb?n(c,d):"--------".substr(0,d),a.G[b].textContent!=c&&(a.G[b].textContent=c))} +g.fa=function(a){this.V&&(a||!this.j.X||this.j.Eb)&&(N(this,"A",this.ha),N(this,"B",this.T),N(this,"C",this.da),N(this,"D",this.ta),N(this,"E",this.Ca),N(this,"H",this.la),N(this,"L",this.qa),N(this,"SP",this.Ea,4),N(this,"PC",this.N,4),a=Wc(this),N(this,"F",a,2),N(this,"S",a&128,1),N(this,"Z",a&64,1),N(this,"A",a&16,1),N(this,"P",a&4,1),N(this,"C",a&1,1));if(a=this.G.speed)a.textContent=this.j.X&&this.i.ya?this.i.ya.toFixed(2)+"Mhz":"Stopped"}; +g.Ta=function(a){this.j.jb=!0;var b=this.j.Tb=this.B&&Zc(this.B),c=a?this.j.pb?0:1:-1;this.j.pb=!1;this.D=this.b=a;this.w&&!a&&this.w.Nb();a||(this.J|=4);do{if(this.M&&this.M&4){this.J=this.b=0;break}if(b){if($c(this.B,this.N,c)){this.U();break}c=1}this.J=0;this.aa[Yc(this)].call(this)}while(0>>this.P;b>8&255;this.da=a&255;this.b-=10},function(){var a=this.T<<8|this.da;this.ga[(a&this.L)>>>this.P].mb(a&this.I,this.ha&255,a);this.b-=7},function(){var a=(this.T<<8|this.da)+1;this.T=a>>8&255;this.da=a&255;this.b-=5},function(){var a=this.T;this.C=a;a=(this.K=a+1)&255;this.O=this.O&-256|a;this.T=a;this.b-= +5},function(){var a=this.T;this.C=a;a=(this.K=a-1)&255;this.O=this.O&-256|a;this.T=a;this.b-=5},function(){this.T=Yc(this);this.b-=7},function(){var a=this.ha<<1;this.ha=a&255|a>>8;this.O=this.O&255|a&256;this.b-=4},ad,function(){var a,b=a=(this.la<<8|this.qa)+(this.T<<8|this.da);this.la=b>>8&255;this.qa=b&255;this.O=this.O&255|a>>8&256;this.b-=10},function(){this.ha=Xc(this,this.T<<8|this.da);this.b-=7},O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O, +O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O]; +function bd(a){x.call(this,"ROM",a,bd);this.s=null;this.F=a.addr;this.w=a.size;this.C=a.alias;this.D=a.file;this.H=ea(this.D);if(this.D){a=this.D;var b=fa(this.H);"json"!=b&&"hex"!=b&&(a=xa()+"/api/v1/dump?file="+this.D+"&format=bytes&decimal=true");var c=this;u(a,null,!0,function(a,b,f){cd(c,a,b,f)})}}z(bd);bd.prototype.La=function(a,b,c,d){this.A=b;this.b=c;this.B=d;dd(this)}; +bd.prototype.pa=function(){if(this.na){if(this.B){var a=this.B,b=this.id,c=this.F,d=this.w,e=this.na,f=[],k;for(k in e){var h=e[k];"number"==typeof h&&(e[k]=h={o:h});var l=h.o,m=h.a;if(void 0!==l){var p=f,l=[l>>>0,k],r=ta(p,l,a.wb);0>r&&p.splice(-(r+1),0,l)}m&&(h.a=m.replace(/''/g,'"'))}a.H.push({bc:b,u:c,Xb:d,na:e,xb:f})}delete this.na}return!0};bd.prototype.oa=function(){return!0}; +function cd(a,b,c,d){if(d)a.ba("Unable to load system ROM (error "+d+": "+b+")");else{kb(a.zb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,k=e.data;if(f)a.s=f;else if(k)for(a.s=Array(4*k.length),d=c=0;c>8&255,a.s[d++]=k[c]>>16&255,a.s[d++]=k[c]>>24&255;else a.s=e;a.na=e.symbols;if(!a.s.length){v("Empty ROM: "+b);return}if(1==a.s.length){v(a.s[0]);return}}catch(h){a.ba("ROM data error: "+h.message);return}else for(b=c.replace(/\n/gm, " ").replace(/ +$/,"").split(" "),a.s=Array(b.length),e=0;e>>d.O].Sa(e&d.s,a.s[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.A?b.push(a.A):null!=a.A&&a.A.length&&(b=a.A);for(c=0;c>>e.O;0>>=e.O;0>>d.P].Ua(e&d.s,a.s[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.C?b.push(a.C):null!=a.C&&a.C.length&&(b=a.C);for(c=0;c>>e.P;0>>=e.P;0Missing <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<=ya().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||Va.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"));c.appendChild(f);e.getContext("2d");d=new gd(d);mb(d,c)}}); -function hd(a){x.call(this,"Debugger",a,hd);this.T=this.Fa=this.J=0;this.L=P();this.vb=P();this.D=-1;this.A=[];this.da=!1;this.Y=P();this.G=[];this.aa={};this.u=this.M=this.F=[];id(this);this.qa=0;jd(this);this.Ta=[];kd(this,a.messages);this.Va=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return mc(b,a)}):void 0===global.$&&(global.$=function(a){return mc(b,a)})}z(hd); +function hd(a){x.call(this,"Debugger",a,hd);this.V=this.Ga=this.J=0;this.M=P();this.yb=P();this.D=-1;this.C=[];this.ia=!1;this.aa=P();this.H=[];this.ca={};this.w=this.R=this.F=[];id(this);this.ua=0;jd(this);this.Va=[];kd(this,a.messages);this.Xa=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return mc(b,a)}):void 0===global.$&&(global.$=function(a){return mc(b,a)})}z(hd); var ld={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory",f:"frequencies","g [#]":"go [to #]",h:"halt","i [#]":"input port #","if":"eval expression",k:"stack trace",ln:"list nearest symbol(s)",m:"messages","o [#]":"output port #",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine","t [#]":"trace","u [#]":"unassemble",x:"execution options",v:"print version","var":"assign variable"},md="NONE ACI ADC ADD ADI ANA ANI CALL CC CM CNC CNZ CP CPE CPO CZ CMA CMC CMP CPI DAA DAD DCR DCX DI EI HLT IN INR INX JMP JC JM JNC JNZ JP JPE JPO JZ LDA LDAX LHLD LXI MOV MVI NOP ORA ORI OUT PCHL POP PUSH RAL RAR RET RC RM RNC RNZ RP RPE RPO RZ RLC RRC RST SBB SBI SHLD SPHL STA STAX STC SUB SUI XCHG XRA XRI XTHL".split(" "), nd="B C D E H L M A F BC DE HL PSW SP PC".split(" "),od=[[45],[42,2323,32],[71,2387],[29,2323],[28,17],[22,17],[44,17,32],[63],[45,32768],[21,6419],[40,2387],[23,2323],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2579,32],[71,2643],[29,2579],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,6675],[40,2643],[23,2579],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2835,32],[68,99],[29,2835],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,6931],[41,99],[23,2835],[28,1297],[22,1297],[44, 1297,32],[16],[45,32768],[42,3347,32],[70,97],[29,3347],[28,1553],[22,1553],[44,1553,32],[72],[45,32768],[21,7443],[39,97],[23,3347],[28,1809],[22,1809],[44,1809,32],[17],[43,17,17],[43,17,273],[43,17,529],[43,17,785],[43,17,1041],[43,17,1297],[43,17,1553],[43,17,1809],[43,273,17],[43,273,273],[43,273,529],[43,273,785],[43,273,1041],[43,273,1297],[43,273,1553],[43,273,1809],[43,529,17],[43,529,273],[43,529,529],[43,529,785],[43,529,1041],[43,529,1297],[43,529,1553],[43,529,1809],[43,785,17],[43,785, @@ -70,87 +71,87 @@ nd="B C D E H L M A F BC DE HL PSW SP PC".split(" "),od=[[45],[42,2323,32],[71,2 [43,1809,1297],[43,1809,1553],[43,1809,1809],[3,17],[3,273],[3,529],[3,785],[3,1041],[3,1297],[3,1553],[3,1809],[2,17],[2,273],[2,529],[2,785],[2,1041],[2,1297],[2,1553],[2,1809],[73,17],[73,273],[73,529],[73,785],[73,1041],[73,1297],[73,1553],[73,1809],[66,17],[66,273],[66,529],[66,785],[66,1041],[66,1297],[66,1553],[66,1809],[5,17],[5,273],[5,529],[5,785],[5,1041],[5,1297],[5,1553],[5,1809],[76,17],[76,273],[76,529],[76,785],[76,1041],[76,1297],[76,1553],[76,1809],[46,17],[46,273],[46,529],[46, 785],[46,1041],[46,1297],[46,1553],[46,1809],[18,17],[18,273],[18,529],[18,785],[18,1041],[18,1297],[18,1553],[18,1809],[58],[50,2323],[34,35],[30,35],[11,35],[51,2323],[4,33],[65],[62],[54],[38,35],[30,32803],[15,35],[7,35],[1,33],[65],[57],[50,2579],[33,35],[48,33],[10,35],[51,2579],[74,33],[65],[55],[54,32768],[31,35],[27,33],[8,35],[7,32803],[67,33],[65],[61],[50,2835],[37,35],[78],[14,35],[51,2835],[6,33],[65],[60],[49],[36,35],[75],[13,35],[7,32803],[77,33],[65],[59],[50,3091],[35,35],[24], [12,35],[51,3091],[47,33],[65],[56],[69],[32,35],[25],[9,35],[7,32803],[19,33],[65]],Q={cpu:1,bus:64,mem:128,port:256,timer:2048,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:536870912,warn:1073741824,halt:-2147483648};g=hd.prototype; -g.Ka=function(a,b,c,d){this.B=b;this.b=c;this.s=a;(a=jc(a,"messages"))&&kd(this,a);this.gb=od;pd(this,function(a){a:{var b=d.b.sa,c=a[0],h=a=0,l=b.length;if(c){a=T(U(d,c));if(-1===a){d.g("invalid address: "+c);break a}h=a>>>d.b.O;l=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,m=0;l--;){var p=b[h];p.type==c?m++||d.g("..."):(c=p.type,m=ac[c],p&&d.g(n(p.id)+" %"+n(h<>>c.O,c=e!=c.s?c.B[f].Ib(e,d):c.B[f++].bb(e,d)|c.B[f&c.K].bb(0,d+1)<<8;b&&qd(a,b)}return c}; -g.sb=function(a,b,c){var d=T(a);if(-1!==d){var e=this.B;e.B[(d&e.u)>>>e.O].Sa(d&e.s,b&255,d);c&&qd(a,c);I(this.b,!0)}};g.Mb=function(a,b,c){var d=T(a);if(-1!==d){var e=this.B,f=d&e.s,k=(d&e.u)>>>e.O;f!=e.s?e.B[k].Lb(f,b&65535,d):(e.B[k++].Sa(f,b&255,d),e.B[k&e.K].Sa(0,b>>8&255,d+1));c&&qd(a,c);I(this.b,!0)}};function P(a){return{w:a||0,fa:!1}}function rd(a){return[a.w,a.fa]}function sd(a){return{w:a[0],fa:a[1]}} -function U(a,b,c){var d;c=(c?a.L:a.vb).w;if(void 0!==b){d=b=td(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;c>>d.b.P;l=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,m=0;l--;){var p=b[h];p.type==c?m++||d.g("..."):(c=p.type,m=ac[c],p&&d.g(n(p.id)+" %"+n(h<>>c.P,c=e!=c.s?c.A[f].tb(e,d):c.A[f++].eb(e,d)|c.A[f&c.L].eb(0,d+1)<<8;b&&qd(a,b)}return c}; +g.ub=function(a,b,c){var d=T(a);if(-1!==d){var e=this.A;e.A[(d&e.w)>>>e.P].Ua(d&e.s,b&255,d);c&&qd(a,c);I(this.b,!0)}};g.Pb=function(a,b,c){var d=T(a);if(-1!==d){var e=this.A,f=d&e.s,k=(d&e.w)>>>e.P;f!=e.s?e.A[k].Ob(f,b&65535,d):(e.A[k++].Ua(f,b&255,d),e.A[k&e.L].Ua(0,b>>8&255,d+1));c&&qd(a,c);I(this.b,!0)}};function P(a){return{u:a||0,ka:!1}}function rd(a){return[a.u,a.ka]}function sd(a){return{u:a[0],ka:a[1]}} +function U(a,b,c){var d;c=(c?a.M:a.yb).u;if(void 0!==b){d=b=td(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=wa(nd,a.substr(b,2))));return c}function zd(a,b){var c=0,d=Ad(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 8:c=2;break;case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"} -function Ad(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.za;break;case 8:c=Wc(d)&255;break;case 0:c=d.ka;break;case 1:c=d.na;break;case 9:c=d.ka<<8|d.na;break;case 2:c=d.oa;break;case 3:c=d.Aa;break;case 10:c=d.oa<<8|d.Aa;break;case 4:c=d.pa;break;case 5:c=d.Ba;break;case 11:c=d.pa<<8|d.Ba;break;case 12:c=d.za<<8|Wc(d)&255;break;case 13:c=d.Da;break;case 14:c=d.N}}return c} +function Ad(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.ha;break;case 8:c=Wc(d)&255;break;case 0:c=d.T;break;case 1:c=d.da;break;case 9:c=d.T<<8|d.da;break;case 2:c=d.ta;break;case 3:c=d.Ca;break;case 10:c=d.ta<<8|d.Ca;break;case 4:c=d.la;break;case 5:c=d.qa;break;case 11:c=d.la<<8|d.qa;break;case 12:c=d.ha<<8|Wc(d)&255;break;case 13:c=d.Ea;break;case 14:c=d.N}}return c} function Bd(a,b){b=td(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=yd(b,c+1),0<=e&&(b=b.substr(0,c)+zd(a,e)+b.substr(c+1+nd[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=da(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=U(a,e))?(d=e+' "'+xd(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=U(a,e))?(qd(d),d=e+' "'+ -xd(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}g.message=function(a,b){b&&(a+=" at "+n(P(this.b.N).w,4));if(!this.ra||a!=this.ra)if(this.ra=a,this.W&-2147483648&&(this.S(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Pa=0;c.G-=c.u;c.u=0;I(c)}};function Cd(a,b,c,d){a.message(b.Ua+"."+(null!=d?"outPort":"inPort")+"("+q(c)+",unknown"+(null!=d?",0x"+n(d,2):"")+")")} -function jd(a){var b;if($c(a)){if(!a.K||!a.K.length){a.K=Array(1E3);for(b=0;b>>d.O],!1)}a.M=["br"];if(void 0!==a.F)for(b=1;b>>d.O],!0);a.F=["bw"];a.xb=0}g.ta=function(a,b,c){var d=!0;c||Jd(this,a,b,!1,!0);if(a!=this.u){var e=T(b);if(-1===e)this.g("invalid address: "+n(b.w,4)),d=!1;else{var f=this.b;f.sa[e>>>f.O].ta(e&f.M,a==this.F)}}d&&(a.push(b),c?b.fa=!0:(Kd(this,a,a.length-1,"set"),jd(this)));return d}; -function Jd(a,b,c,d,e){var f=!1;c=T(c);for(var k=1;k>>d.O],b==a.F));h.fa||jd(a);break}}return f}function Ld(a,b){for(var c=1;c>24,4);break;case 3:B=n(r.fb(K,2),4);break;default:B="imm("+q(t)+")"}r=B}else 16==K&&(r=nd[(t&3840)>>8]);if(!r||!r.length){f="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; +xd(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}g.message=function(a,b){b&&(a+=" at "+n(P(this.b.N).u,4));if(!this.va||a!=this.va)if(this.va=a,this.Y&-2147483648&&(this.U(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Qa=0;c.D-=c.b;c.b=0;I(c)}};function Cd(a,b,c,d){a.message(b.Wa+"."+(null!=d?"outPort":"inPort")+"("+q(c)+",unknown"+(null!=d?",0x"+n(d,2):"")+")")} +function jd(a){var b;if(Zc(a)){if(!a.L||!a.L.length){a.L=Array(1E3);for(b=0;b>>d.P],!1)}a.R=["br"];if(void 0!==a.F)for(b=1;b>>d.P],!0);a.F=["bw"];a.Ab=0}g.wa=function(a,b,c){var d=!0;c||Jd(this,a,b,!1,!0);if(a!=this.w){var e=T(b);if(-1===e)this.g("invalid address: "+n(b.u,4)),d=!1;else{var f=this.b;f.ga[e>>>f.P].wa(e&f.I,a==this.F)}}d&&(a.push(b),c?b.ka=!0:(Kd(this,a,a.length-1,"set"),jd(this)));return d}; +function Jd(a,b,c,d,e){var f=!1;c=T(c);for(var k=1;k>>d.P],b==a.F));h.ka||jd(a);break}}return f}function Ld(a,b){for(var c=1;c>24,4);break;case 3:B=n(r.hb(K,2),4);break;default:B="imm("+q(t)+")"}r=B}else 16==K&&(r=nd[(t&3840)>>8]);if(!r||!r.length){f="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; function Qd(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 ud(a,b,c){var d;if(b){b=td(a,b);for(var e=0,f=!1,k=b,h=[],l=[],m=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;k=p+"b"+k;d>>=8}d="0x"+n(c)+" "+c+". ("+k+")"}a.g((null!=b?b+": ":"")+d);return e}function se(a,b){if(b)return re(a,b,a.aa[b]);var c=0;for(b in a.aa)re(a,b,a.aa[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,h=f.Ub;if(e>=k&&e>1|d.A>>2,d.F^=32896));break;case "I":k?(d=a.b,d.Ca|=512):(d=a.b,d.Ca&=-513);break;default:a.g("unknown register: "+d);return}}if(!f){a.g("invalid value: "+e);return}I(a.b);a.g("updated registers:")}a.g(V(a,7)+V(a,8)+V(a,0)+V(a,1)+V(a,2)+V(a,3)+V(a,4)+V(a,5)+V(a,13)+Od(a,"I")+Od(a,"S")+Od(a,"Z")+Od(a,"A")+Od(a,"P")+Od(a,"C"));c&&(a.L=P(a.b.N),Fd(a,n(a.L.w,4)))}} -function ye(a,b){b=sa(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(Bd(a,c[2])):ud(a,b,!0)}function ze(a,b,c){var d="t"!=b;c=Rd(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);Ka(c,function(){return pb(a,!0)&&a.Ra(e,d,!1)},function(){I(a.b);pb(a,!1)})} -function Fd(a,b,c,d){if(b=U(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=U(a,c,!0);if(!d||d.wh[0].indexOf("+"))){var m=h[0]+":";h[2]&&(m+=" "+h[2]);a.g(m)}h[3]&&(k=h[3],f=null);f=Nd(a,b,k,f);a.g(f);a.L=b;e-=b.w-l;c++}}} -function wd(a,b,c,d){if(c)if(b){0>a.D&&a.A.length&&(a.D=0);if(0>a.D||b!=a.A[a.D])a.A.splice(0,0,b),a.D=0;a.D--}else b=a.A[a.D+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 k=b.charAt(f);if('"'==k||"'"==k)e?k==e&&(e=null):e=k;else if(k==d&&!e||!k)a.push(sa(b.substring(c,f))),c=f+1}}return a} -function Md(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.da&&(a.g("ended assemble at "+n(a.Y.w,4)),a.L=a.Y,a.da=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.ra=null;if(rb(a)&&0m||"z"aa.length&&(a.g("note: only "+aa.length+" available"),L=aa.length);D-=L;0>D&&(null==aa[aa.length-1].w?(L=D+L,D=0):D+=aa.length);var vc=[];"call"==Xd&& -(Ga=1E5,vc=["CALL"]);for(void 0!==Wd&&a.g(L+" instructions earlier:");0=aa.length&&(D=0);a.yb=L;Zd++;Ga--}}Zd||(a.g("no "+Yd+"history available"),a.yb=void 0)}else{var Fb=U(a,Y);if(Fb){var Gb=0;na&&("l"==na.charAt(0)&&(na=na.substr(1)||Ve),Gb=Rd(a,na)>>>0,65536>4||1,wc="dd"== -Da?4:"dw"==Da?2:1,be=0;bezc;zc++){var Ib=a.la(Fb,1),Hb=Hb|Ib<<(xc++<<3);xc==wc&&($a+=n(Hb,2*wc),$a+=1==wc?7==zc?"-":" ":" ",Hb=xc=0);yc+=32<=Ib&&128>Ib?String.fromCharCode(Ib):"."}oa&&(oa+="\n");oa+=Y+" "+$a+" "+yc}oa&&a.g(oa);a.vb=Fb}}}}break;case "e":if("else"==f[0])break;var Jb=1,ce=255,de=a.la,ee=a.sb;"ew"==f[0]&&(Jb=2,ce=65535,de=a.fb,ee=a.Mb);var fe=Jb<<1,ge=f[1];if(null==ge)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 Kb=U(a,ge);if(Kb)for(var Lb=2;LbJc;){for(var pa=null,af=256;65536>db.w>>>0;){ie.w=a.fb(db,2);if(null==db.w||!af--)break; -for(var bf=a,Nb=ie,je=null,eb=Nb.w,ke=eb,Kc=1;6>=Kc&&eb;Kc++){if(2>>=Pc)&ff;if(void 0!==Pb){if(Pb[0])Pb[0](ja,Qb,void 0);S.C&&S.G!=Pb[1]&&Id(S.C,ja,Qb)}else S.C&& -(Cd(S.C,S,ja,Qb),S.G&&Id(S.C,ja,Qb));Pc+=fb<<3;ja+=fb;Oc-=fb}a.g(q(Mc)+": "+("0x"+n(Nc,2)))}}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){ye(a,b.substr(5));break}var pe="pr"==f[0]?1:0,gf=1+pe;if(a.P)a.g("step in progress");else{var Qc=P(a.b.N);switch(a.la(Qc)){case 205:a.P=gf,qd(Qc,3)}a.P?(a.ta(a.u,Qc,!0),a.Ea()||(a.s&&a.s.cb(),a.P=0)):ze(a,pe?"tr":"t")}break;case "r":if("reset"== -b){a.s&&a.s.reset();break}Ed(a,f);break;case "t":ze(a,f[0],f[1]);break;case "u":Fd(a,f[1],f[2],8);break;case "v":if("var"==f[0]){we(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.21.7 ("+a.b.Db+",RELEASE"+(tb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(ya());break;case "x":a:if(f[1]&&"?"!=f[1])switch(f[1]){case "cs":var gb;void 0!==f[3]&&(gb=+f[3]);switch(f[2]){case "int":a.b.i.Ma=gb;break;case "start":a.b.i.Xa=gb;break;case "stop":a.b.i.Oa=gb;break;default:a.g("unknown cs option");break a}void 0!== -gb&&lc(a.b);a.g("checksums "+(a.b.j.Ha?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(qc(a.b,+f[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.wa.toFixed(2)+"Mhz")+" ("+a.b.i.ya+"x)");break;default:a.g("unknown option: "+f[1])}else a.g("execution options:"),a.g("\tcs int #\tset checksum cycle interval to #"),a.g("\tcs start #\tset checksum cycle start count to #"),a.g("\tcs stop #\tset checksum cycle stop count to #"),a.g("\tsp #\t\tset speed multiplier to #"); -break;case "?":if(f[1]){ye(a,b.substr(1));break}var hb="commands:",Rc;for(Rc in ld)hb+="\n"+ra(Rc,7)+ld[Rc];$c(a)||(hb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(hb);break;default:a.g("unknown command: "+b),d=!1}}}catch(qe){a.g("debugger error: "+(qe.stack||qe.message)),d=!1}return d}function mc(a,b,c){b=wd(a,b,c);for(var d in b)if(!Md(a,b[d]))return!1;return!0}Qa(function(){for(var a=F(document,"pc8080","debugger"),b=0;b>=1;k=p+"b"+k;d>>=8}d="0x"+n(c)+" "+c+". ("+k+")"}a.g((null!=b?b+": ":"")+d);return e}function se(a,b){if(b)return re(a,b,a.ca[b]);var c=0;for(b in a.ca)re(a,b,a.ca[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,h=f.Xb;if(e>=k&&eh[0].indexOf("+"))){var m=h[0]+":";h[2]&&(m+=" "+h[2]);a.g(m)}h[3]&&(k=h[3],f=null);f=Nd(a,b,k,f);a.g(f);a.M=b;e-=b.u-l;c++}}} +function wd(a,b,c,d){if(c)if(b){0>a.D&&a.C.length&&(a.D=0);if(0>a.D||b!=a.C[a.D])a.C.splice(0,0,b),a.D=0;a.D--}else b=a.C[a.D+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 k=b.charAt(f);if('"'==k||"'"==k)e?k==e&&(e=null):e=k;else if(k==d&&!e||!k)a.push(sa(b.substring(c,f))),c=f+1}}return a} +function Md(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ia&&(a.g("ended assemble at "+n(a.aa.u,4)),a.M=a.aa,a.ia=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.va=null;if(rb(a)&&0m||"z"aa.length&&(a.g("note: only "+aa.length+" available"),L=aa.length);D-=L;0>D&&(null==aa[aa.length-1].u?(L=D+L,D=0):D+=aa.length);var tc=[];"call"==Xd&& +(Ga=1E5,tc=["CALL"]);for(void 0!==Wd&&a.g(L+" instructions earlier:");0=aa.length&&(D=0);a.Bb=L;Zd++;Ga--}}Zd||(a.g("no "+Yd+"history available"),a.Bb=void 0)}else{var Eb=U(a,Y);if(Eb){var Fb=0;na&&("l"==na.charAt(0)&&(na=na.substr(1)||Ve),Fb=Rd(a,na)>>>0,65536>4||1,uc="dd"== +Da?4:"dw"==Da?2:1,be=0;bexc;xc++){var Hb=a.ra(Eb,1),Gb=Gb|Hb<<(vc++<<3);vc==uc&&($a+=n(Gb,2*uc),$a+=1==uc?7==xc?"-":" ":" ",Gb=vc=0);wc+=32<=Hb&&128>Hb?String.fromCharCode(Hb):"."}oa&&(oa+="\n");oa+=Y+" "+$a+" "+wc}oa&&a.g(oa);a.yb=Eb}}}}break;case "e":if("else"==f[0])break;var Ib=1,ce=255,de=a.ra,ee=a.ub;"ew"==f[0]&&(Ib=2,ce=65535,de=a.hb,ee=a.Pb);var fe=Ib<<1,ge=f[1];if(null==ge)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 Jb=U(a,ge);if(Jb)for(var Kb=2;KbHc;){for(var pa=null,af=256;65536>db.u>>>0;){ie.u=a.hb(db,2);if(null==db.u||!af--)break; +for(var bf=a,Mb=ie,je=null,eb=Mb.u,ke=eb,Ic=1;6>=Ic&&eb;Ic++){if(2>>=Nc)&ff;if(void 0!==Ob){if(Ob[0])Ob[0](ja,Pb,void 0);S.B&&S.H!=Ob[1]&&Id(S.B,ja,Pb)}else S.B&& +(Cd(S.B,S,ja,Pb),S.H&&Id(S.B,ja,Pb));Nc+=fb<<3;ja+=fb;Mc-=fb}a.g(q(Kc)+": "+("0x"+n(Lc,2)))}}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){ye(a,b.substr(5));break}var pe="pr"==f[0]?1:0,gf=1+pe;if(a.S)a.g("step in progress");else{var Oc=P(a.b.N);switch(a.ra(Oc)){case 205:a.S=gf,qd(Oc,3)}a.S?(a.wa(a.w,Oc,!0),a.Fa()||(a.s&&a.s.fb(),a.S=0)):ze(a,pe?"tr":"t")}break;case "r":if("reset"== +b){a.s&&a.s.reset();break}Ed(a,f);break;case "t":ze(a,f[0],f[1]);break;case "u":Fd(a,f[1],f[2],8);break;case "v":if("var"==f[0]){we(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.21.7 ("+a.b.Gb+",RELEASE"+(tb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(ya());break;case "x":a:if(f[1]&&"?"!=f[1])switch(f[1]){case "cs":var gb;void 0!==f[3]&&(gb=+f[3]);switch(f[2]){case "int":a.b.i.Na=gb;break;case "start":a.b.i.Za=gb;break;case "stop":a.b.i.Pa=gb;break;default:a.g("unknown cs option");break a}void 0!== +gb&&lc(a.b);a.g("checksums "+(a.b.j.Ia?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(qc(a.b,+f[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.za.toFixed(2)+"Mhz")+" ("+a.b.i.Ba+"x)");break;default:a.g("unknown option: "+f[1])}else a.g("execution options:"),a.g("\tcs int #\tset checksum cycle interval to #"),a.g("\tcs start #\tset checksum cycle start count to #"),a.g("\tcs stop #\tset checksum cycle stop count to #"),a.g("\tsp #\t\tset speed multiplier to #"); +break;case "?":if(f[1]){ye(a,b.substr(1));break}var hb="commands:",Pc;for(Pc in ld)hb+="\n"+ra(Pc,7)+ld[Pc];Zc(a)||(hb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(hb);break;default:a.g("unknown command: "+b),d=!1}}}catch(qe){a.g("debugger error: "+(qe.stack||qe.message)),d=!1}return d}function mc(a,b,c){b=wd(a,b,c);for(var d in b)if(!Md(a,b[d]))return!1;return!0}Qa(function(){for(var a=F(document,"pc8080","debugger"),b=0;bJe){if(Fe(d,this.K)){this.F=new J(this,W,"failsafe");Fe(this.F)&&(Oe(this,d),a=2,Ce(this.F));M(this.F,"timestamp",va());De(this.F);var e=this.s&&!this.G;if(1==a||za("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Ee(d)){var f=Ge(d,"code"),k=Ge(d,"data");f&&("ok"==f?Fe(d,k):("error"==f&&"no machine state"!= -k?(this.Z("Error: "+k),"unable to verify user"==k&&(Ia("user",""),this.u=null)):this.g(f+": "+k),Ce(d),Fe(d)?(c=Ee(d),e=!0):c=!1))}e&&Ne(this,c?d:null)}else 2==a&&d.clear()}else Ne(this);delete this.K;delete this.L}e=C(this.id);for(f=0;fa[1];a=a[2];this.j.U=!0;var d=this.H.power;d&&(d.textContent="Shutdown");this.T||(this.g("PC8080 v"+W+"\nCopyright \u00a9 2012-2016 Jeff Parsons \nLicense: GPL version 3 or later "),this.T=!0);this.b&&(Pe(this,this.b,b,c,a),nc(this.b));this.Y&&(Oe(this,b),b.clear());!c&&this.F&&(this.F.clear(),delete this.F);this.A=0}; -function Oe(a,b){if(za("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.ea,d=a.u||"",e=b.toString(),f={app:"PC8080"};f.ver=W;f.url=c;f.user=d;f.type="bug";f.data=e;u("http://www.pcjs.org/api/v1/report",f,!0)}} -function Ae(a,b,c){var d,e="none";if(a.A)return null;a.A--;var f=new J(a,W),k=new J(a,W,"validate"),h=va();M(k,"timestamp",h);M(f,"timestamp",h);M(f,"version","1.21.7");M(f,"url",window?window.location.href:null);M(f,"browser",ya());a.b&&a.b.ia&&(c&&a.b.S(),d=a.b.ia(b,c),"object"===typeof d&&M(f,a.b.id,d),c&&(a.b.j.U=!1,!1===d&&(e=null)));for(var h=C(a.id),l=0;lJe){if(Fe(d,this.L)){this.F=new J(this,W,"failsafe");Fe(this.F)&&(Oe(this,d),a=2,Ce(this.F));M(this.F,"timestamp",va());De(this.F);var e=this.s&&!this.H;if(1==a||za("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Ee(d)){var f=Ge(d,"code"),k=Ge(d,"data");f&&("ok"==f?Fe(d,k):("error"==f&&"no machine state"!= +k?(this.ba("Error: "+k),"unable to verify user"==k&&(Ia("user",""),this.w=null)):this.g(f+": "+k),Ce(d),Fe(d)?(c=Ee(d),e=!0):c=!1))}e&&Ne(this,c?d:null)}else 2==a&&d.clear()}else Ne(this);delete this.L;delete this.M}e=C(this.id);for(f=0;fa[1];a=a[2];this.j.W=!0;var d=this.G.power;d&&(d.textContent="Shutdown");this.V||(this.g("PC8080 v"+W+"\nCopyright \u00a9 2012-2016 Jeff Parsons \nLicense: GPL version 3 or later "),this.V=!0);this.b&&(Pe(this,this.b,b,c,a),nc(this.b));this.aa&&(Oe(this,b),b.clear());!c&&this.F&&(this.F.clear(),delete this.F);this.C=0}; +function Oe(a,b){if(za("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.ja,d=a.w||"",e=b.toString(),f={app:"PC8080"};f.ver=W;f.url=c;f.user=d;f.type="bug";f.data=e;u("http://www.pcjs.org/api/v1/report",f,!0)}} +function Ae(a,b,c){var d,e="none";if(a.C)return null;a.C--;var f=new J(a,W),k=new J(a,W,"validate"),h=va();M(k,"timestamp",h);M(f,"timestamp",h);M(f,"version","1.21.7");M(f,"url",window?window.location.href:null);M(f,"browser",ya());a.b&&a.b.oa&&(c&&a.b.U(),d=a.b.oa(b,c),"object"===typeof d&&M(f,a.b.id,d),c&&(a.b.j.W=!1,!1===d&&(e=null)));for(var h=C(a.id),l=0;lh.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(h=window.location.pathname+h);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(h?' url="'+h+'"':""))}e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1pc8080$2")); h=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(h=new window.ActiveXObject("Microsoft.XMLDOM"),h.async=!1,h.loadXML(a)):h=(new window.DOMParser).parseFromString(a,"text/xml")}catch(r){h=null,a=r.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");u(e,null,!0,function(f,k,h){if(h||!k)c(a,"unable to resolve XML reference: "+d[0]+" ("+h+")");else{if(f=d[3])if(h=k.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=h[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]);h[0]!=l&&(k=k.replace(h[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}k=k.replace(/<\?xml[^>]*>[\r\n]*/, @@ -162,4 +163,4 @@ function lf(a,b,c,d){if(!c&&b){d.push(b);a=jb[d[0]];b=null;for(var e in a)if(ka( function mf(a,b){var c,d,e,f=b[0],k=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var h=jb[f],l={},m;for(m in h){var p=h[m],r=fa(m);if("xml"==r){for(r=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=r.exec(h[m]);){var t=d[2];t&&(h[t]||(p=p.replace(d[0],"")))}d=m=ea(m)}else"xsl"==r&&(e=m=ea(m));l[m]=p}a&&(l[m="css"]=a);b[2]&&(l[m="parms"]=b[2]);b[3]&&(l[m="state"]=b[3]);d&&e?(m=JSON.stringify(l),k+=".js",c=c[1]+"var resources="+m+";"+c[2]+c[3],c=c.replace(/\u00A9/g, "©"),m=k,h=null,l="data:application/javascript,",l=Ja("Firefox")?l+encodeURIComponent(c):l+encodeURI(c),m&&(h=document.createElement("a"),"string"!=typeof h.download&&(h=null)),h?(h.href=l,h.download=m,document.body.appendChild(h),h.click(),document.body.removeChild(h),c="Check your Downloads folder for "+m+"."):(window.open(l),c="Check your browser for a new window/tab containing the requested data"+(m?" ("+m+")":"")+"."),c+=', copy it to your web server as "'+k+'", and then add the following to your web page:\n\n', c+='
\n',c+="...\n",c+='