-
Control Panel
-
-
-
-
- Enter
- Clear
-
-
-
+```xml
+
+ Control Panel
+
+
+
+ control type="text" class="input" binding="debugInput" width="360px"/>
+ Enter
+ Clear
+
+
+
+```
See [/devices/pc/panel/default.xml](/devices/pc/panel/default.xml) for a more complete example.
Output
---
-
+```html
+
+```
Also, if any controls are defined, another <div> of class="pc-controls" is created in the container <div>,
with each control inside a <div> of class="pc-control".
diff --git a/docs/pcjs/parallel/README.md b/docs/pcjs/parallel/README.md
index 2f7e94887..28ae438c2 100644
--- a/docs/pcjs/parallel/README.md
+++ b/docs/pcjs/parallel/README.md
@@ -9,7 +9,9 @@ PCjs ParallelPort Component
Format
---
-
...
+```xml
+
...
+```
Purpose
---
@@ -39,14 +41,19 @@ Bindings
Example
---
-
+```xml
+
+```
Output
---
-
+```html
+
+```
[Return to [PCjs Documentation](..)]
diff --git a/docs/pcjs/ram/README.md b/docs/pcjs/ram/README.md
index 726b4d02e..5984b7975 100644
--- a/docs/pcjs/ram/README.md
+++ b/docs/pcjs/ram/README.md
@@ -9,7 +9,9 @@ PCjs Random-Access Memory (RAM) Component
Format
---
-
...
+```xml
+
...
+```
Purpose
---
@@ -43,15 +45,20 @@ Bindings
Example
---
-
+```xml
+
+```
Output
---
-
+```html
+
+```
Also, if any controls are defined, another <div> of class="pc-controls" is created in the container <div>,
with each control inside a <div> of class="pc-control".
diff --git a/docs/pcjs/rom/README.md b/docs/pcjs/rom/README.md
index 9f6f925d4..9f311186b 100644
--- a/docs/pcjs/rom/README.md
+++ b/docs/pcjs/rom/README.md
@@ -9,7 +9,9 @@ PCjs Read-Only Memory (ROM) Component
Format
---
-
...
+```xml
+
...
+```
Purpose
---
@@ -43,14 +45,19 @@ None.
Example
---
-
+```xml
+
+```
Output
---
-
+```html
+
+```
[Return to [PCjs Documentation](..)]
diff --git a/docs/pcjs/serial/README.md b/docs/pcjs/serial/README.md
index 0f6c0837d..5c799f32d 100644
--- a/docs/pcjs/serial/README.md
+++ b/docs/pcjs/serial/README.md
@@ -9,7 +9,9 @@ PCjs SerialPort Component
Format
---
-
...
+```xml
+
...
+```
Purpose
---
@@ -39,14 +41,19 @@ Bindings
Example
---
-
+```xml
+
+```
Output
---
-
+```html
+
+```
[Return to [PCjs Documentation](..)]
diff --git a/docs/pcjs/video/README.md b/docs/pcjs/video/README.md
index 2770db62f..6a7d5512c 100644
--- a/docs/pcjs/video/README.md
+++ b/docs/pcjs/video/README.md
@@ -9,7 +9,9 @@ PCjs Video Component
Format
---
-
+```xml
+
+```
Purpose
---
@@ -22,24 +24,6 @@ Creates an instance of the Video component. This component is responsible for:
Attributes
---
- * *addr* (required)
-
- The ROM starting address (e.g., 0xfe000).
-
- * *size* (required)
-
- The length of ROM, in bytes (e.g., 0x02000 for an 8Kb ROM). This must match the length of the ROM image file.
-
- * *file* (required)
-
- URL of the ROM image file to load at the specified addr.
-
- * *notify* (optional)
-
- The *id* of a component to notify when *file* has been loaded. For example, the Video component may need
- to know when an external video ROM has been loaded. Any component can load its own files, including ROM image files,
- but it's simpler to use the ROM component and request notification.
-
* *model* (optional)
* "mda" (Monochrome Display Adapter)
@@ -49,17 +33,13 @@ Attributes
If *model* is not set, the SW1 switch block settings from the [ChipSet](/docs/pcjs/chipset/) component will
determine the video model to use ("mda" or "cga" only).
- * *scale* (optional; default is false)
-
- true scales text modes to fill the canvas;
- false centers text modes on the canvas (this generally provides the sharpest rendering).
-
- * *screenwidth*, *screenheight* (required)
+ * *screenWidth*, *screenHeight* (required)
The width and height of the canvas, in pixels (these are numbers, not style attributes, so do not include
- a "px" suffix).
+ a "px" suffix); the canvas resolution does not need to match the *model* resolution (in fact, it should probably
+ be closer to the resolution of modern monitors, but still proportional to the resolution of the *model* being used).
- * *fontrom* (formerly *charset*; required for models "mda" and "cga")
+ * *fontROM* (formerly *charset*; required for models "mda" and "cga")
The name of a character generator (font ROM) file. The MDA and CGA adapters did not contain a separate
system ROM, but they did contain on-board font data in ROM that the adapter used internally to generate character
@@ -67,6 +47,11 @@ Attributes
The EGA uses font data stored in its system ROM, which is loaded by the ROM component, so do not use this
setting with model "ega".
+
+ * *scale* (optional; default is false)
+
+ true scales text modes to fill the canvas;
+ false centers text modes on the canvas (this generally provides the sharpest rendering).
Also supports the attributes of *[Component](/docs/pcjs/component/)*.
@@ -79,17 +64,22 @@ Bindings
Example
---
-
+```xml
+
+```
Output
---
-
+```html
+
+```
Also, if any controls are defined, another <div> of class="pc-controls" is created in the container <div>,
with each control inside a <div> of class="pc-control".
diff --git a/modules/pc8080/lib/cpusim.js b/modules/pc8080/lib/cpusim.js
index d707fb6e8..ceca098d8 100644
--- a/modules/pc8080/lib/cpusim.js
+++ b/modules/pc8080/lib/cpusim.js
@@ -1091,11 +1091,11 @@ CPUSim.prototype.updateStatus = function(fForce)
this.updateReg("PC", this.getPC(), 4);
var regPS = this.getPS();
this.updateReg("PS", regPS, 4);
- this.updateReg("SF", (regPS & CPUDef.PS.SF), 1);
- this.updateReg("ZF", (regPS & CPUDef.PS.ZF), 1);
- this.updateReg("AF", (regPS & CPUDef.PS.AF), 1);
- this.updateReg("PF", (regPS & CPUDef.PS.PF), 1);
- this.updateReg("CF", (regPS & CPUDef.PS.CF), 1);
+ this.updateReg("SF", (regPS & CPUDef.PS.SF)? 1 : 0, 1);
+ this.updateReg("ZF", (regPS & CPUDef.PS.ZF)? 1 : 0, 1);
+ this.updateReg("AF", (regPS & CPUDef.PS.AF)? 1 : 0, 1);
+ this.updateReg("PF", (regPS & CPUDef.PS.PF)? 1 : 0, 1);
+ this.updateReg("CF", (regPS & CPUDef.PS.CF)? 1 : 0, 1);
}
}
var controlSpeed = this.bindings["speed"];
diff --git a/modules/pc8080/lib/video.js b/modules/pc8080/lib/video.js
index d33645db4..85cb3d923 100644
--- a/modules/pc8080/lib/video.js
+++ b/modules/pc8080/lib/video.js
@@ -55,7 +55,7 @@ if (NODE) {
* bufferAddr: the starting address of the frame buffer (eg, 0x2400)
* bufferCols: the width of a single frame buffer row, in pixels (eg, 256)
* bufferRows: the number of frame buffer rows (eg, 224)
- * bufferBits: the number of bits per pixel (eg, 1)
+ * bufferBits: the number of bits per pixel (default is 1 if omitted)
* interruptRate: normally the same as (or some multiple of) the refreshRate (eg, 120)
* refreshRate: how many times updateScreen() should be called per second (eg, 60)
*
@@ -75,9 +75,35 @@ if (NODE) {
function Video(parmsVideo, canvas, context, textarea, container)
{
Component.call(this, "Video", parmsVideo, Video, Messages.VIDEO);
+
+ this.cxScreen = parmsVideo['screenWidth'];
+ this.cyScreen = parmsVideo['screenHeight'];
+
+ this.addrBuffer = parmsVideo['bufferAddr'];
+ this.cxBuffer = parmsVideo['bufferCols'];
+ this.cyBuffer = parmsVideo['bufferRows'];
+ this.nBitsPerPixel = parmsVideo['bufferBits'] || 1;
+
this.interruptRate = parmsVideo['interruptRate'];
this.refreshRate = parmsVideo['refreshRate'] || 60;
- this.setReady();
+
+ this.canvasScreen = canvas;
+ this.contextScreen = context;
+ this.textareaScreen = textarea;
+ this.inputScreen = textarea || canvas || null;
+
+ this.initColors();
+
+ /*
+ * Allocate off-screen buffers.
+ *
+ * TODO: Do this only if there is a mismatch between the screen's (canvas) dimensions and the frame buffer's.
+ */
+ this.imageBuffer = this.contextScreen.createImageData(this.cxBuffer, this.cyBuffer);
+ this.canvasBuffer = document.createElement("canvas");
+ this.canvasBuffer.width = this.cxBuffer;
+ this.canvasBuffer.height = this.cyBuffer;
+ this.contextBuffer = this.canvasBuffer.getContext("2d");
}
Component.subclass(Video);
@@ -97,6 +123,20 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg)
this.bus = bus;
this.cpu = cpu;
this.dbg = dbg;
+
+ /*
+ * Compute the size of the frame buffer and allocate.
+ */
+ this.sizeBuffer = ((this.cxBuffer * this.nBitsPerPixel) >> 3) * this.cyBuffer;
+ if (this.bus.addMemory(this.addrBuffer, this.sizeBuffer, Memory.TYPE.VIDEO)) {
+ /*
+ * Compute the number of cells and initialize the cell cache.
+ */
+ this.nCellCache = this.sizeBuffer >> 1;
+ this.nPixelsPerCell = (16 / this.nBitsPerPixel)|0;
+ this.initCache();
+ }
+ this.setReady();
};
/**
@@ -110,6 +150,62 @@ Video.prototype.getRefreshRate = function()
return Math.max(this.refreshRate, this.interruptRate);
};
+/**
+ * initCache()
+ *
+ * Initializes the contents of our internal cell cache.
+ *
+ * @this {Video}
+ */
+Video.prototype.initCache = function()
+{
+ this.fCellCacheValid = false;
+ if (this.aCellCache === undefined || this.aCellCache.length != this.nCellCache) {
+ this.aCellCache = new Array(this.nCellCache);
+ }
+};
+
+/**
+ * initColors()
+ *
+ * @this {Video}
+ */
+Video.prototype.initColors = function()
+{
+ this.aRGB = [
+ [0x00, 0x00, 0x00, 0xff], // black
+ [0xff, 0xff, 0xff, 0xff] // white
+ ];
+};
+
+/**
+ * getColors()
+ *
+ * @this {Video}
+ */
+Video.prototype.getColors = function()
+{
+ return this.aRGB;
+};
+
+/**
+ * setPixel(imageData, x, y, rgb)
+ *
+ * @this {Video}
+ * @param {Object} imageData
+ * @param {number} x
+ * @param {number} y
+ * @param {Array.
} rgb is a 4-element array containing the red, green, blue and alpha values
+ */
+Video.prototype.setPixel = function(imageData, x, y, rgb)
+{
+ var index = (x + y * imageData.width) * rgb.length;
+ imageData.data[index] = rgb[0];
+ imageData.data[index+1] = rgb[1];
+ imageData.data[index+2] = rgb[2];
+ imageData.data[index+3] = rgb[3];
+};
+
/**
* updateScreen(n)
*
@@ -126,18 +222,100 @@ Video.prototype.getRefreshRate = function()
*/
Video.prototype.updateScreen = function(n)
{
- if (!(n & 1)) {
+ if (n >= 0) {
+ if (!(n & 1)) {
+ /*
+ * On even updates, call cpu.requestINTR(1), and also update our copy of the screen.
+ */
+ this.cpu.requestINTR(1);
+ } else {
+ /*
+ * On odd updates, call cpu.requestINTR(2), but do NOT update our copy of the screen, because
+ * the machine has presumably only updated the top half of the frame buffer at this point; it will
+ * update the bottom half of the frame buffer after acknowledging this interrupt.
+ */
+ this.cpu.requestINTR(2);
+ return;
+ }
+
/*
- * On even updates, call cpu.requestINTR(1), and also update our copy of the screen.
+ * Since this is not a forced update, if our cell cache is valid AND the buffer is clean, then do nothing.
*/
- this.cpu.requestINTR(1);
- } else {
+ if (this.fCellCacheValid && this.bus.cleanMemory(this.addrBuffer, this.sizeBuffer)) {
+ return;
+ }
+ }
+
+ /*
+ * If we're still here, then either this is a forced update, or our cell cache hasn't been filled yet, or
+ * the frame buffer is dirty. Time to actually update the screen.
+ */
+
+ var addr = this.addrBuffer;
+ var addrLimit = addr + this.sizeBuffer;
+
+ var iCell = 0;
+ var wPixelMask = 0x10000;
+ var nPixelShift = 1;
+ var aPixelColors = this.getColors();
+
+ var x = 0, y = 0;
+ var xDirty = this.cxBuffer, xMaxDirty = 0, yDirty = this.cyBuffer, yMaxDirty = 0;
+
+ while (addr < addrLimit) {
+ var data = this.bus.getShortDirect(addr);
+ this.assert(iCell < this.aCellCache.length);
+ if (this.fCellCacheValid && data === this.aCellCache[iCell]) {
+ x += this.nPixelsPerCell;
+ } else {
+ this.aCellCache[iCell] = data;
+ var wPixels = (data >> 8) | ((data & 0xff) << 8);
+ var wMask = wPixelMask, nShift = 16;
+ if (x < xDirty) xDirty = x;
+ for (var iPixel = 0; iPixel < this.nPixelsPerCell; iPixel++) {
+ var bPixel = (wPixels & (wMask >>= nPixelShift)) >> (nShift -= nPixelShift);
+ this.setPixel(this.imageBuffer, x++, y, aPixelColors[bPixel]);
+ }
+ if (x > xMaxDirty) xMaxDirty = x;
+ if (y < yDirty) yDirty = y;
+ if (y >= yMaxDirty) yMaxDirty = y + 1;
+ }
+ addr += 2;
+ iCell++;
+ if (x >= this.cxBuffer) {
+ x = 0;
+ y++;
+ if (y > this.cyBuffer) break;
+ }
+ }
+
+ this.fCellCacheValid = true;
+
+ /*
+ * Instead of blasting the ENTIRE imageBuffer into contextBuffer, and then blasting the ENTIRE
+ * canvasBuffer onto contextScreen, even for the smallest change, let's try to be a bit smarter about
+ * the update (well, to the extent that the canvas APIs permit).
+ */
+ if (xDirty < this.cxBuffer) {
+ var cxDirty = xMaxDirty - xDirty;
+ var cyDirty = yMaxDirty - yDirty;
+ // this.contextBuffer.putImageData(this.imageBuffer, 0, 0);
+ this.contextBuffer.putImageData(this.imageBuffer, 0, 0, xDirty, yDirty, cxDirty, cyDirty);
/*
- * On odd updates, call cpu.requestINTR(2), but do NOT update our copy of the screen, because
- * the machine has presumably only updated the top half of the frame buffer at this point; it will
- * update the bottom half of the frame buffer after acknowledging this interrupt.
+ * While ideally I would draw only the dirty portion of canvasBuffer, there usually isn't a 1-1 pixel mapping
+ * between canvasBuffer and contextScreen. In fact, the WHOLE POINT of the canvasBuffer is to leverage
+ * drawImage()'s scaling ability; for example, a CGA graphics mode might be 640x200, whereas the canvas representing
+ * the screen might be 960x400. In those situations, if we draw interior rectangles, we often end up with subpixel
+ * artifacts along the edges of those rectangles. So it appears I must continue to redraw the entire canvasBuffer
+ * on every change.
+ *
+ var xScreen = (((xDirty * this.cxScreen) / this.cxBuffer) | 0);
+ var yScreen = (((yDirty * this.cyScreen) / this.cyBuffer) | 0);
+ var cxScreen = (((cxDirty * this.cxScreen) / this.cxBuffer) | 0);
+ var cyScreen = (((cyDirty * this.cyScreen) / this.cyBuffer) | 0);
+ this.contextScreen.drawImage(this.canvasBuffer, xDirty, yDirty, cxDirty, cyDirty, xScreen, yScreen, cxScreen, cyScreen);
*/
- this.cpu.requestINTR(2);
+ this.contextScreen.drawImage(this.canvasBuffer, 0, 0, this.cxBuffer, this.cyBuffer, 0, 0, this.cxScreen, this.cyScreen);
}
};
diff --git a/versions/pc8080/1.22.0/pc8080-dbg.js b/versions/pc8080/1.22.0/pc8080-dbg.js
index 822567e77..6eb276555 100644
--- a/versions/pc8080/1.22.0/pc8080-dbg.js
+++ b/versions/pc8080/1.22.0/pc8080-dbg.js
@@ -1,202 +1,206 @@
(function(){var m;function aa(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 q(a,b){var c="";void 0===b?b=8:8=d?48:55),c=String.fromCharCode(d)+c;a>>=4}return c}function r(a){return"0x"+q(a,4)}function ba(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0":">",'"':""","'":"'"};function fa(a){return a.replace(/[&<>"']/g,function(a){return ea[a]})}function ga(a,b){return(a+" ").slice(0,b)}function ha(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}
-function ia(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 la(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.U?10:20>=this.U?12:24>=this.U?14:15;this.ma=1<>2;this.F=this.ma-1;this.L=this.Y/this.ma|0;this.W=this.L-1;this.u=[];this.A=[];this.I=this.J=!1;this.ba=[];this.ea=[];a=new C;sb(a,this.C);this.D=Array(this.L);for(b=0;b>>a.Z;0c&&(g=c);if(f&&f.size){if(f.type==d){if(b+c<=f.B)return f.kb+=f.B-b,f.B=b,!0;if(b>=f.B+f.kb){g=f.size-(b-h);g>c&&(g=c);f.kb=b-f.B+g;b=h+a.ma;c-=g;e++;continue}}return ub(1,b,c)}b=new C(b,g,a.ma,d);sb(b,a.C,f);a.D[e++]=b;b=h+a.ma;c-=g}return 0>=c?!0:ub(2,b,c)}
-rb.prototype.V=function(a){return this.D[(a&this.H)>>>this.Z].Ka(a&this.F,a)};function vb(a,b){return a.D[(b&a.H)>>>a.Z].ib(b&a.F,b)}function wb(a,b,c){a.D[(b&a.H)>>>a.Z].lb(b&a.F,c&255,b)}function xb(a,b){if(void 0===b)return a.I=!a.I,a.I;void 0===a.u[b]&&(a.u[b]=[null,!1]);a.u[b][1]=!a.u[b][1];return a.u[b][1]}
-function Gb(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.C&&a.J!=h[1]&&Kb(a.C,b,k)}else a.C&&(gb(a.C,a,b,k,d),a.J&&Kb(a.C,b,k));f+=g<<3;b+=g;e-=g}}function ub(a,b,c){t("Memory block error ("+a+": "+q(b)+","+q(c)+")");return!1}var Lb;if(mb){var Mb=new ArrayBuffer(2);(new DataView(Mb)).setUint16(0,256,!0);Lb=256===(new Uint16Array(Mb))[0]}else Lb=!1;var Nb=Lb;
-function C(a,b,c,d){this.id=Ob+=2;this.b=null;this.B=a;this.kb=b;this.size=c||0;this.type=d||Pb;this.u=d==Qb;sb(this);this.Aa=this.Yb=!1;if(c)if(mb)this.H=new ArrayBuffer(c),this.I=new DataView(this.H,0,c),this.D=new Uint8Array(this.H,0,c),this.L=new Uint16Array(this.H,0,c>>1),this.b=new Int32Array(this.H,0,c>>2),Rb(this,Nb?Sb:Tb);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},ea:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ta: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},Da: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.Aa=!0},aa:function(a,b){if(this.C&&null!=this.B){var c=this.C;Zb(c,this.B+a,1,c.ba)&&c.da(!0)}return this.ib(a,b)},ka:function(a,b){if(this.C&&null!=this.B){var c=this.C;Zb(c,this.B+a,2,c.ba)&&c.da(!0)}return this.yb(a,b)},za:function(a,b,c){if(this.C&&null!=this.B){var d=this.C;Zb(d,this.B+a,1,d.I)&&d.da(!0)}this.u?this.F(a,b,c):this.lb(a,b,c)},Ma:function(a,
-b,c){if(this.C&&null!=this.B){var d=this.C;Zb(d,this.B+a,2,d.I)&&d.da(!0)}this.u?this.F(a,b,c):this.zb(a,b,c)},Y:function(a){return this.D[a]},ba:function(a){return this.D[a]},ja:function(a){return this.I.getUint16(a,!0)},qa:function(a){return a&1?this.D[a]|this.D[a+1]<<8:this.L[a>>1]},ua:function(a,b){this.D[a]=b;this.Aa=!0},Ca:function(a,b){this.D[a]=b;this.Aa=!0},Ea:function(a,b){this.I.setUint16(a,b,!0);this.Aa=!0},$a:function(a,b){a&1?(this.D[a]=b,this.D[a+1]=b>>8):this.L[a>>1]=b;this.Aa=!0}};
-function sb(a,b,c){a.C=b;a.T=a.A=0;c&&((a.T=c.T)&&Yb(a,Xb,!1),(a.A=c.A)&&Wb(a,Xb,!1))}function $b(a,b){b?0===--a.A&&(a.Za=a.u?a.F:a.lb,a.Tb=a.u?a.J:a.zb):0===--a.T&&(a.Ka=a.ib,a.Rb=a.yb)}function Wb(a,b,c){c&&a.A||(a.Za=!a.u&&b[2]||a.F,a.Tb=!a.u&&b[3]||a.J);if(c||void 0===c)a.lb=b[2]||a.F,a.zb=b[3]||a.J}function Yb(a,b,c){c&&a.T||(a.Ka=b[0]||a.U,a.Rb=b[1]||a.W);if(c||void 0===c)a.ib=b[0]||a.U,a.yb=b[1]||a.W}function Rb(a,b){b||(b=ac);Yb(a,b,void 0);Wb(a,b,void 0)}
-var ac=[],Ub=[C.prototype.ea,C.prototype.ta,C.prototype.Da,C.prototype.ab],Xb=[C.prototype.aa,C.prototype.ka,C.prototype.za,C.prototype.Ma];if(mb)var Tb=[C.prototype.Y,C.prototype.ja,C.prototype.ua,C.prototype.Ea],Sb=[C.prototype.ba,C.prototype.qa,C.prototype.Ca,C.prototype.$a];
-function bc(a,b){u.call(this,"CPU",a,bc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Xa=c;this.i.qb=0;this.i.Ja=d;this.i.vb=Math.round(this.i.Xa/1E4)/100;this.i.Ha=this.i.vb*this.i.Ja;this.w.ia=!1;this.w.ub=!1;this.w.Ib=a.autoStart;this.w.Jb=!1;this.w.Oa=!1;this.i.bb=this.i.Ua=0;this.i.cb=a.csStart;this.i.Ta=a.csInterval;this.i.Va=a.csStop;this.ka=this.La.bind(this);B(this)}x(bc);var cc=["power","reset"];m=bc.prototype;
-m.Ba=function(a,b,c,d){this.u=a;this.D=b;this.C=d;for(b=0;b=a.i.Ua&&(a.i.Ua+=a.i.Ta,c=!0);0<=a.i.Va&&a.i.Va<=vc(a)&&(a.i.Ta=a.i.Va=-1,qc(a),a.da(),c=!0);c&&a.g(vc(a)+" cycles: checksum="+q(a.i.bb))}}
-m.pa=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.T[b]=c;a=!0;break;case "run":this.T[b]=c;c.onclick=function(){var a;if(a=d.u)if(a=d.u,a.w.ga)a=!0;else{var b=null,c,g=ab(a.id);for(c=0;cc&&(c=2);var d=1;b&&1a.i.Ga/a.i.Ha?b=1:d=!0;a.i.Ja=b;b=a.i.vb*a.i.Ja;if(a.i.Ha!=b){a.i.Ha=b;b=a.i.Ha.toFixed(2)+"Mhz";var e=a.T.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.u&&a.u.jb()}xc(a,a.I);a.I=0;a.i.Sa=ja();a.i.Ia=0;yc(a);return d}
-m.La=function(a){if(ib(this,!0)){if(!this.w.ia){wc(this);this.u&&this.u.start(this.i.Sa,vc(this));this.w.ia=!0;this.w.ub=!0;this.W&&this.W.start();var b=this.T.run;b&&(b.textContent="Halt");this.u&&(this.u.sa(!0),a&&this.u.jb(!0))}this.i.xb>=this.i.Xa&&yc(this,!0);this.i.gb=0;this.i.pb=ja();this.i.Ia&&(a=this.i.pb-this.i.Ia,a>this.i.Nb&&(this.i.Sa+=a,this.i.Sa>this.i.pb&&(this.i.Sa=this.i.pb)));try{do{var c=this.w.Oa?1:this.i.hc;try{this.Ya(c)}catch(e){if("number"!=typeof e)throw e;}var d=this.F-
-this.b;this.I+=d;this.i.gb+=d;xc(this,0,!0);uc(this,d);this.i.fb-=d;0>=this.i.fb&&(this.i.fb+=this.i.Pb,this.u&&zc(this.u,this.i.qb++),this.i.qb>this.za&&(this.i.qb=0));this.i.eb-=d;0>=this.i.eb&&(this.i.eb+=this.i.Ob,this.u&&this.u.sa());this.i.Wa-=d;if(0>=this.i.Wa){this.i.Wa+=this.i.wb;break}}while(this.w.ia)}catch(e){this.da();sc(this);this.u&&this.u.stop(ja(),vc(this));ib(this,!1);lb(this,e.stack||e.message);return}c=setTimeout;d=this.ka;this.i.Ia=ja();a=this.i.Nb;this.i.gb&&(a=Math.round(a*
-this.i.gb/this.i.wb));a-=this.i.Ia-this.i.pb;if(b=this.i.Ia-this.i.Sa)this.i.Ga=Math.round(this.I/(10*b))/100,864E5<=b&&(this.J=0,wc(this));if(0>a||this.i.Ga>8&255;a.N=b&255}function Jc(a){return a.O<<8|a.P}function Kc(a,b){a.O=b>>8&255;a.P=b&255}function J(a){return a.R<<8|a.S}
-function L(a,b){a.R=b>>8&255;a.S=b&255}function G(a,b){a.K=b&65535}function Lc(a){return a.G&256?1:0}function Mc(a){return nb[a.X&255]?4:0}function Nc(a){return(a.X^a.ha)&16?16:0}function Oc(a){return a.G&255?0:64}function Pc(a){return a.X&128?128:0}function Gc(a){return a.oa&-214|Pc(a)|Oc(a)|Nc(a)|Mc(a)|Lc(a)}function Ec(a,b){a.G=a.X=a.ha=0;b&1&&(a.G|=256);b&4||(a.X|=1);b&16&&(a.ha|=16);b&64||(a.G|=255);b&128&&(a.X^=192);a.oa=a.oa&-513|b&512|2}
-function Qc(a,b){a.ha=a.j^b;return a.X=(a.G=a.j+b)&255}function Rc(a,b){a.ha=a.j^b;return a.X=(a.G=a.j+b+(a.G&256?1:0))&255}function Sc(a,b){a.G=a.X=a.ha=a.j&b;(a.j|b)&8&&(a.ha^=16);return a.G}function jd(a,b){a.ha=b^255;b=a.X=b+255&255;a.G=a.G&-256|b;return b}function kd(a,b){a.ha=b;b=a.X=b+1&255;a.G=a.G&-256|b;return b}function ld(a,b){return a.X=a.G=a.ha=a.j|b}function M(a,b){b^=255;a.ha=a.j^b;return a.X=(a.G=a.j+b+1^256)&255}
-function md(a,b){b^=255;a.ha=a.j^b;return a.X=(a.G=a.j+b+(a.G&256?0:1)^256)&255}function nd(a,b){return a.X=a.G=a.ha=a.j^b}m.V=function(a){return this.la[(a&this.L)>>>this.Z].Ka(a&this.H,a)};function od(a,b){var c=b&a.H,d=(b&a.L)>>>a.Z;if(c>>a.Z].Za(b&a.H,c&255,b)}
-function pd(a,b,c){var d=b&a.H,e=(b&a.L)>>>a.Z;d>8&255,b+1))}function O(a){var b=a.V(a.K);G(a,a.K+1);return b}function P(a){var b=od(a,a.K);G(a,a.K+2);return b}function Q(a){var b=od(a,a.ca);a.ca=a.ca+2&65535;return b}function R(a,b){a.ca=a.ca-2&65535;pd(a,a.ca,b)}
-function T(a,b,c,d){d=d||2;a.T[b]&&(void 0===c&&(lb(a,"Value for "+b+" is invalid"),a.da()),c=!a.w.ia||a.w.Jb?q(c,d):"--------".substr(0,d),a.T[b].textContent!=c&&(a.T[b].textContent=c))}
-m.sa=function(a){this.ja&&(a||!this.w.ia||this.w.Jb)&&(T(this,"A",this.j),T(this,"B",this.M),T(this,"C",this.N),T(this,"BC",Hc(this),4),T(this,"D",this.O),T(this,"E",this.P),T(this,"DE",Jc(this),4),T(this,"H",this.R),T(this,"L",this.S),T(this,"HL",J(this),4),T(this,"SP",this.ca,4),T(this,"PC",this.K,4),a=Gc(this),T(this,"PS",a,4),T(this,"SF",a&128,1),T(this,"ZF",a&64,1),T(this,"AF",a&16,1),T(this,"PF",a&4,1),T(this,"CF",a&1,1));if(a=this.T.speed)a.textContent=this.w.ia&&this.i.Ga?this.i.Ga.toFixed(2)+
-"Mhz":"Stopped"};m.Ya=function(a){this.w.nb=!0;var b=this.w.Xb=this.C&&qd(this.C),c=a?this.w.ub?0:1:-1;this.w.ub=!1;this.F=this.b=a;do{if(this.A){var d;this.A&8&&this.oa&512?(d=199|(this.A&7)<<3,this.A&=-16,this.oa&=-513,this.ba[d].call(this),d=!0):d=!1;if(d){if(!a){this.g("interrupt dispatched");break}}else if(this.A&16){this.b=0;break}}if(b){if(rd(this.C,this.K,c)){this.da();break}c=1}this.ba[O(this)].call(this)}while(0>8;this.G=this.G&255|a&256;this.b-=4},sd,function(){var a;L(this,a=J(this)+Hc(this));this.G=this.G&255|a>>8&256;this.b-=10},function(){this.j=this.V(Hc(this));this.b-=7},function(){Ic(this,Hc(this)-
-1);this.b-=5},function(){this.N=kd(this,this.N);this.b-=5},function(){this.N=jd(this,this.N);this.b-=5},function(){this.N=O(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;this.G=this.G&255|a;this.b-=4},sd,function(){Kc(this,P(this));this.b-=10},function(){N(this,Jc(this),this.j);this.b-=7},function(){Kc(this,Jc(this)+1);this.b-=5},function(){this.O=kd(this,this.O);this.b-=5},function(){this.O=jd(this,this.O);this.b-=5},function(){this.O=O(this);this.b-=7},function(){var a=this.j<<
-1;this.j=a&255|this.G>>8;this.G=this.G&255|a&256;this.b-=4},sd,function(){var a;L(this,a=J(this)+Jc(this));this.G=this.G&255|a>>8&256;this.b-=10},function(){this.j=this.V(Jc(this));this.b-=7},function(){Kc(this,Jc(this)-1);this.b-=5},function(){this.P=kd(this,this.P);this.b-=5},function(){this.P=jd(this,this.P);this.b-=5},function(){this.P=O(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(this.G&256|this.j)>>1;this.G=this.G&255|a;this.b-=4},sd,function(){L(this,P(this));this.b-=10},function(){pd(this,
-P(this),J(this));this.b-=16},function(){L(this,J(this)+1);this.b-=5},function(){this.R=kd(this,this.R);this.b-=5},function(){this.R=jd(this,this.R);this.b-=5},function(){this.R=O(this);this.b-=7},function(){var a=0,b=Lc(this);if(Nc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=Qc(this,a);this.G=b?this.G|256:this.G&-257;this.b-=4},sd,function(){var a;L(this,a=J(this)+J(this));this.G=this.G&255|a>>8&256;this.b-=10},function(){L(this,od(this,P(this)));this.b-=16},function(){L(this,J(this)-
-1);this.b-=5},function(){this.S=kd(this,this.S);this.b-=5},function(){this.S=jd(this,this.S);this.b-=5},function(){this.S=O(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},sd,function(){this.ca=P(this)&65535;this.b-=10},function(){N(this,P(this),this.j);this.b-=13},function(){this.ca=this.ca+1&65535;this.b-=5},function(){var a=J(this);N(this,a,kd(this,this.V(a)));this.b-=10},function(){var a=J(this);N(this,a,jd(this,this.V(a)));this.b-=10},function(){N(this,J(this),O(this));this.b-=10},
-function(){this.G|=256;this.b-=4},sd,function(){var a;L(this,a=J(this)+this.ca);this.G=this.G&255|a>>8&256;this.b-=10},function(){this.j=this.V(P(this));this.b-=13},function(){this.ca=this.ca-1&65535;this.b-=5},function(){this.j=kd(this,this.j);this.b-=5},function(){this.j=jd(this,this.j);this.b-=5},function(){this.j=O(this);this.b-=7},function(){this.G=Lc(this)?this.G&-257:this.G|256;this.b-=4},function(){this.b-=5},function(){this.M=this.N;this.b-=5},function(){this.M=this.O;this.b-=5},function(){this.M=
-this.P;this.b-=5},function(){this.M=this.R;this.b-=5},function(){this.M=this.S;this.b-=5},function(){this.M=this.V(J(this));this.b-=7},function(){this.M=this.j;this.b-=5},function(){this.N=this.M;this.b-=5},function(){this.b-=5},function(){this.N=this.O;this.b-=5},function(){this.N=this.P;this.b-=5},function(){this.N=this.R;this.b-=5},function(){this.N=this.S;this.b-=5},function(){this.N=this.V(J(this));this.b-=7},function(){this.N=this.j;this.b-=5},function(){this.O=this.M;this.b-=5},function(){this.O=
-this.N;this.b-=5},function(){this.b-=5},function(){this.O=this.P;this.b-=5},function(){this.O=this.R;this.b-=5},function(){this.O=this.S;this.b-=5},function(){this.O=this.V(J(this));this.b-=7},function(){this.O=this.j;this.b-=5},function(){this.P=this.M;this.b-=5},function(){this.P=this.N;this.b-=5},function(){this.P=this.O;this.b-=5},function(){this.b-=5},function(){this.P=this.R;this.b-=5},function(){this.P=this.S;this.b-=5},function(){this.P=this.V(J(this));this.b-=7},function(){this.P=this.j;
-this.b-=5},function(){this.R=this.M;this.b-=5},function(){this.R=this.N;this.b-=5},function(){this.R=this.O;this.b-=5},function(){this.R=this.P;this.b-=5},function(){this.b-=5},function(){this.R=this.S;this.b-=5},function(){this.R=this.V(J(this));this.b-=7},function(){this.R=this.j;this.b-=5},function(){this.S=this.M;this.b-=5},function(){this.S=this.N;this.b-=5},function(){this.S=this.O;this.b-=5},function(){this.S=this.P;this.b-=5},function(){this.S=this.R;this.b-=5},function(){this.b-=5},function(){this.S=
-this.V(J(this));this.b-=7},function(){this.S=this.j;this.b-=5},function(){N(this,J(this),this.M);this.b-=7},function(){N(this,J(this),this.N);this.b-=7},function(){N(this,J(this),this.O);this.b-=7},function(){N(this,J(this),this.P);this.b-=7},function(){N(this,J(this),this.R);this.b-=7},function(){N(this,J(this),this.S);this.b-=7},function(){var a=this.K-1;if(this.U.length)for(var b=0;b>8;this.b-=10},function(){var a=P(this);Pc(this)||G(this,a);this.b-=10},function(){this.oa&=-513;this.b-=4},function(){var a=P(this);Pc(this)||(R(this,this.K),G(this,a),this.b-=6);this.b-=11},function(){R(this,Gc(this)&255|this.j<<8);this.b-=11},function(){this.j=ld(this,O(this));this.b-=7},function(){R(this,this.K);G(this,48);this.b-=11},function(){Pc(this)&&(G(this,
-Q(this)),this.b-=6);this.b-=5},function(){this.ca=J(this)&65535;this.b-=5},function(){var a=P(this);Pc(this)&&G(this,a);this.b-=10},function(){this.oa|=512;this.b-=4},function(){var a=P(this);Pc(this)&&(R(this,this.K),G(this,a),this.b-=6);this.b-=11},vd,function(){M(this,O(this));this.b-=7},function(){R(this,this.K);G(this,56);this.b-=11}];
-function U(a){u.call(this,"ChipSet",a,U,32768);var b=a.model;b&&!wd[b]&&t("Unrecognized ChipSet model: "+b);this.Ra=wd[b]||xd;a.sound&&(this.W=null,window&&(this.W=window.AudioContext||window.webkitAudioContext),this.W&&new this.W);B(this)}x(U);var xd=1978.1,wd={SI1978:xd};m=U.prototype;m.pa=function(){return!1};
-m.Ba=function(a,b,c,d){this.D=b;this.b=c;this.C=d;this.u=a;if(this.Ra==xd){var e;a=yd;void 0===e&&(e=0);for(var f in a){c=b;d=+f+e;var h=a[f].bind(this);if(void 0!==h)for(var g=+f+e;g<=d;g++)void 0!==c.u[g]?t("Input port "+r(g)+" already registered"):c.u[g]=[h,!1]}var k;e=zd;void 0===k&&(k=0);for(var l in e)if(f=b,a=+l+k,c=e[l].bind(this),void 0!==c)for(d=+l+k;d<=a;d++)void 0!==f.A[d]?t("Output port "+r(d)+" already registered"):f.A[d]=[c,!1]}};
-m.xa=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};m.wa=function(a){return a?this.save():!0};m.reset=function(){this.H=this.I=this.F=this.A=this.U=this.L=this.J=0};m.save=function(){var a=new H(this);this.Ra==xd&&I(a,0,[this.J,this.L,this.U,this.A,this.F,this.H,this.I]);return a.data()};m.restore=function(a){a=a[0];this.Ra==xd&&(this.J=a[0],this.L=a[1],this.U=a[2],this.A=a[3],this.F=a[4],this.H=a[5],this.I=a[6]);return!0};m.start=function(){};m.stop=function(){};
-m.bc=function(a,b){var c=this.J;fb(this,a,null,b,"STATUS0",c);return c};m.cc=function(a,b){var c=this.L;fb(this,a,null,b,"STATUS1",c);return c};m.dc=function(a,b){var c=this.U;fb(this,a,null,b,"STATUS2",c);return c};m.ac=function(a,b){var c=this.A>>8-this.F&255;fb(this,a,null,b,"SHIFT.RESULT",c);return c};m.ic=function(a,b,c){fb(this,a,b,c,"SHIFT.COUNT",null);this.F=b};m.kc=function(a,b,c){fb(this,a,b,c,"SOUND1",null);this.H=b};
-m.jc=function(a,b,c){fb(this,a,b,c,"SHIFT.DATA",null);this.A=b<<8|this.A>>8};m.lc=function(a,b,c){fb(this,a,b,c,"SOUND2",null);this.I=b};m.mc=function(a,b,c){fb(this,a,b,c,"WATCHDOG",null)};var yd={0:U.prototype.bc,1:U.prototype.cc,2:U.prototype.dc,3:U.prototype.ac},zd={2:U.prototype.ic,3:U.prototype.kc,4:U.prototype.jc,5:U.prototype.lc,6:U.prototype.mc};Ma(function(){for(var a=A(document,"pc8080","chipset"),b=0;b>>0,h],p=ia(n,k,a.Eb);0>p&&n.splice(-(p+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.J.push({nc:b,B:c,gc:d,ya:e,Bb:f})}delete this.ya}return!0};Ad.prototype.wa=function(){return!0};
-function Bd(a,b,c,d){if(d)a.na("Unable to load system ROM (error "+d+": "+b+")");else{Xa(a.Hb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.u=f;else if(h)for(a.u=Array(4*h.length),d=c=0;c>8&255,a.u[d++]=h[c]>>16&255,a.u[d++]=h[c]>>24&255;else a.u=e;a.ya=e.symbols;if(!a.u.length){t("Empty ROM: "+b);return}if(1==a.u.length){t(a.u[0]);return}}catch(g){a.na("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
-" ").replace(/ +$/,"").split(" "),a.u=Array(b.length),e=0;e>>f.Z;0>>=f.Z;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<=oa().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||Ra.aspect);f&&.3<=f&&3.33>=f&&(Ha("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);e.getContext("2d");d=new Id(d);eb(d,c)}});
-function Jd(a){u.call(this,"Debugger",a,Jd);this.aa=Kd;this.ja=this.Ma=this.U=0;this.Y=W();this.Fb=W();this.H=-1;this.F=[];this.qa=!1;this.ka=W();this.J=[];this.ta={};this.A=this.ba=this.I=[];Ld(this);this.Da=0;Md(this);this.$a=[];Nd(this,a.messages);this.rb=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return rc(b,a)}):void 0===global.$&&(global.$=function(a){return rc(b,a)})}x(Jd);
-var Od={"?":"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",s:"set options","t [#]":"trace","u [#]":"unassemble",v:"print version","var":"assign variable"},Kd=8080,Pd="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(" "),
-Qd="NONE ADC ADC ADD ADD AND AND CALL CALLC CALLS CALLNC CALLNZ CALLNS CALLP CALLNP CALLZ NOT CMC CMP CMP DAA ADD DEC DEC CLI STI HLT IN INC INC JMP JC JS JNC JNZ JNS JP JNP JZ MOV MOV MOV MOV MOV MOV NOP OR OR OUT JMP POP PUSH RCL RCR RET RETC RETS RETNC RETNZ RETNS RETP RETNP RETZ ROL ROR RST SBB SBB MOV MOV MOV MOV STC SUB SUB XCHG XOR XOR XCHG".split(" "),Rd="B C D E H L M A BC DE HL SP PC PSW".split(" "),Sd=[[45],[42,2067,32],[71,2131,18193],[29,2067],[28,17],[22,17],[44,17,32],[63],[45,32768],
+function q(a,b){var c="";void 0===b?b=8:8=d?48:55),c=String.fromCharCode(d)+c;a>>=4}return c}function r(a){return"0x"+q(a,4)}function ba(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0":">",'"':""","'":"'"};function ga(a){return a.replace(/[&<>"']/g,function(a){return fa[a]})}function ha(a,b){return(a+" ").slice(0,b)}function ia(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}
+function ja(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 ma(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.M?10:20>=this.M?12:24>=this.M?14:15;this.la=1<>2;this.D=this.la-1;this.K=this.X/this.la|0;this.V=this.K-1;this.w=[];this.u=[];this.H=this.J=!1;this.ba=[];this.ca=[];a=new F;qb(a,this.F);this.B=Array(this.K);for(b=0;b>>a.aa;0c&&(g=c);if(f&&f.size){if(f.type==d){if(b+c<=f.C)return f.kb+=f.C-b,f.C=b,!0;if(b>=f.C+f.kb){g=f.size-(b-h);g>c&&(g=c);f.kb=b-f.C+g;b=h+a.la;c-=g;e++;continue}}return sb(1,b,c)}b=new F(b,g,a.la,d);qb(b,a.F,f);a.B[e++]=b;b=h+a.la;c-=g}return 0>=c?!0:sb(2,b,c)}
+pb.prototype.W=function(a){return this.B[(a&this.G)>>>this.aa].Ka(a&this.D,a)};function tb(a,b){return a.B[(b&a.G)>>>a.aa].ib(b&a.D,b)}function ub(a,b){var c=b&a.D,d=(b&a.G)>>>a.aa;return c!=a.D?a.B[d].yb(c,b):a.B[d++].ib(c,b)|a.B[d&a.V].ib(0,b+1)<<8}function vb(a,b,c){a.B[(b&a.G)>>>a.aa].lb(b&a.D,c&255,b)}function wb(a,b){if(void 0===b)return a.H=!a.H,a.H;void 0===a.w[b]&&(a.w[b]=[null,!1]);a.w[b][1]=!a.w[b][1];return a.w[b][1]}
+function xb(a,b,c){for(var d=1,e=0,f=0;0>>=f)&l;if(void 0!==h){if(h[0])h[0](b,l,d);a.F&&a.J!=h[1]&&Jb(a.F,b,l)}else a.F&&(eb(a.F,a,b,l,d),a.J&&Jb(a.F,b,l));f+=g<<3;b+=g;e-=g}}function sb(a,b,c){t("Memory block error ("+a+": "+q(b)+","+q(c)+")");return!1}var Kb;if(kb){var Lb=new ArrayBuffer(2);(new DataView(Lb)).setUint16(0,256,!0);Kb=256===(new Uint16Array(Lb))[0]}else Kb=!1;var Mb=Kb;
+function F(a,b,c,d){this.id=Nb+=2;this.b=null;this.C=a;this.kb=b;this.size=c||0;this.type=d||Ob;this.w=d==Pb;qb(this);this.va=this.Jb=!1;if(c)if(kb)this.G=new ArrayBuffer(c),this.H=new DataView(this.G,0,c),this.B=new Uint8Array(this.G,0,c),this.K=new Uint16Array(this.G,0,c>>1),this.b=new Int32Array(this.G,0,c>>2),Qb(this,Mb?Rb:Sb);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},ra: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},Da: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.va=!0},Z:function(a,b){if(this.F&&null!=this.C){var c=this.F;Yb(c,this.C+a,1,c.ba)&&c.ea(!0)}return this.ib(a,b)},ja:function(a,b){if(this.F&&null!=this.C){var c=this.F;Yb(c,this.C+a,2,c.ba)&&c.ea(!0)}return this.yb(a,b)},Aa:function(a,b,c){if(this.F&&null!=this.C){var d=this.F;Yb(d,this.C+a,1,d.H)&&d.ea(!0)}this.w?this.D(a,b,c):this.lb(a,b,c)},Ma:function(a,
+b,c){if(this.F&&null!=this.C){var d=this.F;Yb(d,this.C+a,2,d.H)&&d.ea(!0)}this.w?this.D(a,b,c):this.zb(a,b,c)},X:function(a){return this.B[a]},ba:function(a){return this.B[a]},fa:function(a){return this.H.getUint16(a,!0)},ma:function(a){return a&1?this.B[a]|this.B[a+1]<<8:this.K[a>>1]},ua:function(a,b){this.B[a]=b;this.va=!0},Ca:function(a,b){this.B[a]=b;this.va=!0},Ea:function(a,b){this.H.setUint16(a,b,!0);this.va=!0},$a:function(a,b){a&1?(this.B[a]=b,this.B[a+1]=b>>8):this.K[a>>1]=b;this.va=!0}};
+function qb(a,b,c){a.F=b;a.U=a.u=0;c&&((a.U=c.U)&&Xb(a,Wb,!1),(a.u=c.u)&&Vb(a,Wb,!1))}function Zb(a,b){b?0===--a.u&&(a.Za=a.w?a.D:a.lb,a.Ub=a.w?a.J:a.zb):0===--a.U&&(a.Ka=a.ib,a.Sb=a.yb)}function Vb(a,b,c){c&&a.u||(a.Za=!a.w&&b[2]||a.D,a.Ub=!a.w&&b[3]||a.J);if(c||void 0===c)a.lb=b[2]||a.D,a.zb=b[3]||a.J}function Xb(a,b,c){c&&a.U||(a.Ka=b[0]||a.M,a.Sb=b[1]||a.V);if(c||void 0===c)a.ib=b[0]||a.M,a.yb=b[1]||a.V}function Qb(a,b){b||(b=$b);Xb(a,b,void 0);Vb(a,b,void 0)}
+var $b=[],Tb=[F.prototype.ca,F.prototype.ra,F.prototype.Da,F.prototype.ab],Wb=[F.prototype.Z,F.prototype.ja,F.prototype.Aa,F.prototype.Ma];if(kb)var Sb=[F.prototype.X,F.prototype.fa,F.prototype.ua,F.prototype.Ea],Rb=[F.prototype.ba,F.prototype.ma,F.prototype.Ca,F.prototype.$a];
+function ac(a,b){v.call(this,"CPU",a,ac,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Xa=c;this.i.qb=0;this.i.Ja=d;this.i.vb=Math.round(this.i.Xa/1E4)/100;this.i.Ha=this.i.vb*this.i.Ja;this.A.ka=!1;this.A.ub=!1;this.A.Ib=a.autoStart;this.A.Kb=!1;this.A.Oa=!1;this.i.bb=this.i.Ua=0;this.i.cb=a.csStart;this.i.Ta=a.csInterval;this.i.Va=a.csStop;this.ja=this.La.bind(this);E(this)}z(ac);var bc=["power","reset"];m=ac.prototype;
+m.Ba=function(a,b,c,d){this.w=a;this.B=b;this.F=d;for(b=0;b=a.i.Ua&&(a.i.Ua+=a.i.Ta,c=!0);0<=a.i.Va&&a.i.Va<=uc(a)&&(a.i.Ta=a.i.Va=-1,pc(a),a.ea(),c=!0);c&&a.g(uc(a)+" cycles: checksum="+q(a.i.bb))}}
+m.qa=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.U[b]=c;a=!0;break;case "run":this.U[b]=c;c.onclick=function(){var a;if(a=d.w)if(a=d.w,a.A.ha)a=!0;else{var b=null,c,g=Za(a.id);for(c=0;cc&&(c=2);var d=1;b&&1a.i.Ga/a.i.Ha?b=1:d=!0;a.i.Ja=b;b=a.i.vb*a.i.Ja;if(a.i.Ha!=b){a.i.Ha=b;b=a.i.Ha.toFixed(2)+"Mhz";var e=a.U.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.w&&a.w.jb()}wc(a,a.H);a.H=0;a.i.Sa=ka();a.i.Ia=0;xc(a);return d}
+m.La=function(a){if(gb(this,!0)){if(!this.A.ka){vc(this);this.w&&this.w.start(this.i.Sa,uc(this));this.A.ka=!0;this.A.ub=!0;this.V&&this.V.start();var b=this.U.run;b&&(b.textContent="Halt");this.w&&(this.w.ta(!0),a&&this.w.jb(!0))}this.i.xb>=this.i.Xa&&xc(this,!0);this.i.gb=0;this.i.pb=ka();this.i.Ia&&(a=this.i.pb-this.i.Ia,a>this.i.Ob&&(this.i.Sa+=a,this.i.Sa>this.i.pb&&(this.i.Sa=this.i.pb)));try{do{var c=this.A.Oa?1:this.i.hc;try{this.Ya(c)}catch(e){if("number"!=typeof e)throw e;}var d=this.D-
+this.b;this.H+=d;this.i.gb+=d;wc(this,0,!0);tc(this,d);this.i.fb-=d;0>=this.i.fb&&(this.i.fb+=this.i.Qb,this.w&&yc(this.w,this.i.qb++),this.i.qb>this.Aa&&(this.i.qb=0));this.i.eb-=d;0>=this.i.eb&&(this.i.eb+=this.i.Pb,this.w&&this.w.ta());this.i.Wa-=d;if(0>=this.i.Wa){this.i.Wa+=this.i.wb;break}}while(this.A.ka)}catch(e){this.ea();rc(this);this.w&&this.w.stop(ka(),uc(this));gb(this,!1);jb(this,e.stack||e.message);return}c=setTimeout;d=this.ja;this.i.Ia=ka();a=this.i.Ob;this.i.gb&&(a=Math.round(a*
+this.i.gb/this.i.wb));a-=this.i.Ia-this.i.pb;if(b=this.i.Ia-this.i.Sa)this.i.Ga=Math.round(this.H/(10*b))/100,864E5<=b&&(this.J=0,vc(this));if(0>a||this.i.Ga>8&255;a.O=b&255}function Jc(a){return a.P<<8|a.R}function Kc(a,b){a.P=b>>8&255;a.R=b&255}function J(a){return a.S<<8|a.T}
+function Lc(a,b){a.S=b>>8&255;a.T=b&255}function H(a,b){a.L=b&65535}function Mc(a){return a.I&256?1:0}function Nc(a){return lb[a.Y&255]?4:0}function Oc(a){return(a.Y^a.ia)&16?16:0}function Pc(a){return a.I&255?0:64}function Qc(a){return a.Y&128?128:0}function Fc(a){return a.pa&-214|Qc(a)|Pc(a)|Oc(a)|Nc(a)|Mc(a)}function Dc(a,b){a.I=a.Y=a.ia=0;b&1&&(a.I|=256);b&4||(a.Y|=1);b&16&&(a.ia|=16);b&64||(a.I|=255);b&128&&(a.Y^=192);a.pa=a.pa&-513|b&512|2}
+function Rc(a,b){a.ia=a.j^b;return a.Y=(a.I=a.j+b)&255}function Sc(a,b){a.ia=a.j^b;return a.Y=(a.I=a.j+b+(a.I&256?1:0))&255}function Tc(a,b){a.I=a.Y=a.ia=a.j&b;(a.j|b)&8&&(a.ia^=16);return a.I}function kd(a,b){a.ia=b^255;b=a.Y=b+255&255;a.I=a.I&-256|b;return b}function ld(a,b){a.ia=b;b=a.Y=b+1&255;a.I=a.I&-256|b;return b}function md(a,b){return a.Y=a.I=a.ia=a.j|b}function K(a,b){b^=255;a.ia=a.j^b;return a.Y=(a.I=a.j+b+1^256)&255}
+function nd(a,b){b^=255;a.ia=a.j^b;return a.Y=(a.I=a.j+b+(a.I&256?0:1)^256)&255}function od(a,b){return a.Y=a.I=a.ia=a.j^b}m.W=function(a){return this.na[(a&this.K)>>>this.aa].Ka(a&this.G,a)};function pd(a,b){var c=b&a.G,d=(b&a.K)>>>a.aa;if(c>>a.aa].Za(b&a.G,c&255,b)}
+function qd(a,b,c){var d=b&a.G,e=(b&a.K)>>>a.aa;d>8&255,b+1))}function M(a){var b=a.W(a.L);H(a,a.L+1);return b}function N(a){var b=pd(a,a.L);H(a,a.L+2);return b}function O(a){var b=pd(a,a.da);a.da=a.da+2&65535;return b}function P(a,b){a.da=a.da-2&65535;qd(a,a.da,b)}
+function Q(a,b,c,d){d=d||2;a.U[b]&&(void 0===c&&(jb(a,"Value for "+b+" is invalid"),a.ea()),c=!a.A.ka||a.A.Kb?q(c,d):"--------".substr(0,d),a.U[b].textContent!=c&&(a.U[b].textContent=c))}
+m.ta=function(a){this.fa&&(a||!this.A.ka||this.A.Kb)&&(Q(this,"A",this.j),Q(this,"B",this.N),Q(this,"C",this.O),Q(this,"BC",Hc(this),4),Q(this,"D",this.P),Q(this,"E",this.R),Q(this,"DE",Jc(this),4),Q(this,"H",this.S),Q(this,"L",this.T),Q(this,"HL",J(this),4),Q(this,"SP",this.da,4),Q(this,"PC",this.L,4),a=Fc(this),Q(this,"PS",a,4),Q(this,"SF",a&128?1:0,1),Q(this,"ZF",a&64?1:0,1),Q(this,"AF",a&16?1:0,1),Q(this,"PF",a&4?1:0,1),Q(this,"CF",a&1?1:0,1));if(a=this.U.speed)a.textContent=this.A.ka&&this.i.Ga?
+this.i.Ga.toFixed(2)+"Mhz":"Stopped"};
+m.Ya=function(a){this.A.nb=!0;var b=this.A.Yb=this.F&&rd(this.F),c=a?this.A.ub?0:1:-1;this.A.ub=!1;this.D=this.b=a;do{if(this.u){var d;this.u&8&&this.pa&512?(d=199|(this.u&7)<<3,this.u&=-16,this.pa&=-513,this.ba[d].call(this),d=!0):d=!1;if(d){if(!a){this.g("interrupt dispatched");break}}else if(this.u&16){this.b=0;break}}if(b){if(sd(this.F,this.L,c)){this.ea();break}c=1}this.ba[M(this)].call(this)}while(0>8;this.I=this.I&255|a&256;this.b-=4},td,function(){var a;Lc(this,a=J(this)+Hc(this));this.I=this.I&255|a>>8&256;this.b-=10},function(){this.j=this.W(Hc(this));this.b-=7},function(){Ic(this,Hc(this)-
+1);this.b-=5},function(){this.O=ld(this,this.O);this.b-=5},function(){this.O=kd(this,this.O);this.b-=5},function(){this.O=M(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;this.I=this.I&255|a;this.b-=4},td,function(){Kc(this,N(this));this.b-=10},function(){L(this,Jc(this),this.j);this.b-=7},function(){Kc(this,Jc(this)+1);this.b-=5},function(){this.P=ld(this,this.P);this.b-=5},function(){this.P=kd(this,this.P);this.b-=5},function(){this.P=M(this);this.b-=7},function(){var a=this.j<<
+1;this.j=a&255|this.I>>8;this.I=this.I&255|a&256;this.b-=4},td,function(){var a;Lc(this,a=J(this)+Jc(this));this.I=this.I&255|a>>8&256;this.b-=10},function(){this.j=this.W(Jc(this));this.b-=7},function(){Kc(this,Jc(this)-1);this.b-=5},function(){this.R=ld(this,this.R);this.b-=5},function(){this.R=kd(this,this.R);this.b-=5},function(){this.R=M(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(this.I&256|this.j)>>1;this.I=this.I&255|a;this.b-=4},td,function(){Lc(this,N(this));this.b-=10},function(){qd(this,
+N(this),J(this));this.b-=16},function(){Lc(this,J(this)+1);this.b-=5},function(){this.S=ld(this,this.S);this.b-=5},function(){this.S=kd(this,this.S);this.b-=5},function(){this.S=M(this);this.b-=7},function(){var a=0,b=Mc(this);if(Oc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=Rc(this,a);this.I=b?this.I|256:this.I&-257;this.b-=4},td,function(){var a;Lc(this,a=J(this)+J(this));this.I=this.I&255|a>>8&256;this.b-=10},function(){Lc(this,pd(this,N(this)));this.b-=16},function(){Lc(this,
+J(this)-1);this.b-=5},function(){this.T=ld(this,this.T);this.b-=5},function(){this.T=kd(this,this.T);this.b-=5},function(){this.T=M(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},td,function(){this.da=N(this)&65535;this.b-=10},function(){L(this,N(this),this.j);this.b-=13},function(){this.da=this.da+1&65535;this.b-=5},function(){var a=J(this);L(this,a,ld(this,this.W(a)));this.b-=10},function(){var a=J(this);L(this,a,kd(this,this.W(a)));this.b-=10},function(){L(this,J(this),M(this));this.b-=
+10},function(){this.I|=256;this.b-=4},td,function(){var a;Lc(this,a=J(this)+this.da);this.I=this.I&255|a>>8&256;this.b-=10},function(){this.j=this.W(N(this));this.b-=13},function(){this.da=this.da-1&65535;this.b-=5},function(){this.j=ld(this,this.j);this.b-=5},function(){this.j=kd(this,this.j);this.b-=5},function(){this.j=M(this);this.b-=7},function(){this.I=Mc(this)?this.I&-257:this.I|256;this.b-=4},function(){this.b-=5},function(){this.N=this.O;this.b-=5},function(){this.N=this.P;this.b-=5},function(){this.N=
+this.R;this.b-=5},function(){this.N=this.S;this.b-=5},function(){this.N=this.T;this.b-=5},function(){this.N=this.W(J(this));this.b-=7},function(){this.N=this.j;this.b-=5},function(){this.O=this.N;this.b-=5},function(){this.b-=5},function(){this.O=this.P;this.b-=5},function(){this.O=this.R;this.b-=5},function(){this.O=this.S;this.b-=5},function(){this.O=this.T;this.b-=5},function(){this.O=this.W(J(this));this.b-=7},function(){this.O=this.j;this.b-=5},function(){this.P=this.N;this.b-=5},function(){this.P=
+this.O;this.b-=5},function(){this.b-=5},function(){this.P=this.R;this.b-=5},function(){this.P=this.S;this.b-=5},function(){this.P=this.T;this.b-=5},function(){this.P=this.W(J(this));this.b-=7},function(){this.P=this.j;this.b-=5},function(){this.R=this.N;this.b-=5},function(){this.R=this.O;this.b-=5},function(){this.R=this.P;this.b-=5},function(){this.b-=5},function(){this.R=this.S;this.b-=5},function(){this.R=this.T;this.b-=5},function(){this.R=this.W(J(this));this.b-=7},function(){this.R=this.j;
+this.b-=5},function(){this.S=this.N;this.b-=5},function(){this.S=this.O;this.b-=5},function(){this.S=this.P;this.b-=5},function(){this.S=this.R;this.b-=5},function(){this.b-=5},function(){this.S=this.T;this.b-=5},function(){this.S=this.W(J(this));this.b-=7},function(){this.S=this.j;this.b-=5},function(){this.T=this.N;this.b-=5},function(){this.T=this.O;this.b-=5},function(){this.T=this.P;this.b-=5},function(){this.T=this.R;this.b-=5},function(){this.T=this.S;this.b-=5},function(){this.b-=5},function(){this.T=
+this.W(J(this));this.b-=7},function(){this.T=this.j;this.b-=5},function(){L(this,J(this),this.N);this.b-=7},function(){L(this,J(this),this.O);this.b-=7},function(){L(this,J(this),this.P);this.b-=7},function(){L(this,J(this),this.R);this.b-=7},function(){L(this,J(this),this.S);this.b-=7},function(){L(this,J(this),this.T);this.b-=7},function(){var a=this.L-1;if(this.M.length)for(var b=0;b>8;this.b-=10},function(){var a=N(this);Qc(this)||H(this,a);this.b-=10},function(){this.pa&=-513;this.b-=4},function(){var a=N(this);Qc(this)||(P(this,this.L),H(this,a),this.b-=6);this.b-=11},function(){P(this,Fc(this)&255|this.j<<8);this.b-=11},function(){this.j=md(this,M(this));this.b-=7},function(){P(this,this.L);H(this,48);this.b-=11},function(){Qc(this)&&(H(this,
+O(this)),this.b-=6);this.b-=5},function(){this.da=J(this)&65535;this.b-=5},function(){var a=N(this);Qc(this)&&H(this,a);this.b-=10},function(){this.pa|=512;this.b-=4},function(){var a=N(this);Qc(this)&&(P(this,this.L),H(this,a),this.b-=6);this.b-=11},wd,function(){K(this,M(this));this.b-=7},function(){P(this,this.L);H(this,56);this.b-=11}];
+function R(a){v.call(this,"ChipSet",a,R,32768);var b=a.model;b&&!xd[b]&&t("Unrecognized ChipSet model: "+b);this.Ra=xd[b]||yd;a.sound&&(this.V=null,window&&(this.V=window.AudioContext||window.webkitAudioContext),this.V&&new this.V);E(this)}z(R);var yd=1978.1,xd={SI1978:yd};m=R.prototype;m.qa=function(){return!1};
+m.Ba=function(a,b,c,d){this.B=b;this.b=c;this.F=d;this.w=a;if(this.Ra==yd){var e;a=zd;void 0===e&&(e=0);for(var f in a){c=b;d=+f+e;var h=a[f].bind(this);if(void 0!==h)for(var g=+f+e;g<=d;g++)void 0!==c.w[g]?t("Input port "+r(g)+" already registered"):c.w[g]=[h,!1]}var l;e=Ad;void 0===l&&(l=0);for(var k in e)if(f=b,a=+k+l,c=e[k].bind(this),void 0!==c)for(d=+k+l;d<=a;d++)void 0!==f.u[d]?t("Output port "+r(d)+" already registered"):f.u[d]=[c,!1]}};
+m.ya=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};m.xa=function(a){return a?this.save():!0};m.reset=function(){this.G=this.H=this.D=this.u=this.M=this.K=this.J=0};m.save=function(){var a=new Gc(this);this.Ra==yd&&I(a,0,[this.J,this.K,this.M,this.u,this.D,this.G,this.H]);return a.data()};m.restore=function(a){a=a[0];this.Ra==yd&&(this.J=a[0],this.K=a[1],this.M=a[2],this.u=a[3],this.D=a[4],this.G=a[5],this.H=a[6]);return!0};m.start=function(){};m.stop=function(){};
+m.bc=function(a,b){var c=this.J;db(this,a,null,b,"STATUS0",c);return c};m.cc=function(a,b){var c=this.K;db(this,a,null,b,"STATUS1",c);return c};m.dc=function(a,b){var c=this.M;db(this,a,null,b,"STATUS2",c);return c};m.ac=function(a,b){var c=this.u>>8-this.D&255;db(this,a,null,b,"SHIFT.RESULT",c);return c};m.ic=function(a,b,c){db(this,a,b,c,"SHIFT.COUNT",null);this.D=b};m.kc=function(a,b,c){db(this,a,b,c,"SOUND1",null);this.G=b};
+m.jc=function(a,b,c){db(this,a,b,c,"SHIFT.DATA",null);this.u=b<<8|this.u>>8};m.lc=function(a,b,c){db(this,a,b,c,"SOUND2",null);this.H=b};m.mc=function(a,b,c){db(this,a,b,c,"WATCHDOG",null)};var zd={0:R.prototype.bc,1:R.prototype.cc,2:R.prototype.dc,3:R.prototype.ac},Ad={2:R.prototype.ic,3:R.prototype.kc,4:R.prototype.jc,5:R.prototype.lc,6:R.prototype.mc};Ja(function(){for(var a=D(document,"pc8080","chipset"),b=0;b>>0,h],p=ja(n,l,a.Eb);0>p&&n.splice(-(p+1),0,l)}k&&(g.a=k.replace(/''/g,'"'))}a.J.push({nc:b,C:c,gc:d,za:e,Bb:f})}delete this.za}return!0};Bd.prototype.xa=function(){return!0};
+function Cd(a,b,c,d){if(d)a.oa("Unable to load system ROM (error "+d+": "+b+")");else{Ya(a.Hb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.w=f;else if(h)for(a.w=Array(4*h.length),d=c=0;c>8&255,a.w[d++]=h[c]>>16&255,a.w[d++]=h[c]>>24&255;else a.w=e;a.za=e.symbols;if(!a.w.length){t("Empty ROM: "+b);return}if(1==a.w.length){t(a.w[0]);return}}catch(g){a.oa("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
+" ").replace(/ +$/,"").split(" "),a.w=Array(b.length),e=0;e>>f.aa;0>>=f.aa;0>3)*this.D;rb(this.B,this.K,this.J,3)&&(this.ba=this.J>>1,this.ca=16/this.Z|0,this.M=!1,void 0===this.G||this.G.length!=this.ba)&&(this.G=Array(this.ba));E(this)};
+Ja(function(){for(var a=D(document,"pc8080","video"),b=0;bMissing <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<=pa().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");Ba("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);e=e.getContext("2d");d=new Jd(d,0,e);ab(d,c)}});
+function Kd(a){v.call(this,"Debugger",a,Kd);this.Z=Ld;this.fa=this.Ma=this.M=0;this.X=U();this.Fb=U();this.G=-1;this.D=[];this.ma=!1;this.ja=U();this.J=[];this.ra={};this.u=this.ba=this.H=[];Md(this);this.Da=0;Nd(this);this.$a=[];Od(this,a.messages);this.rb=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return qc(b,a)}):void 0===global.$&&(global.$=function(a){return qc(b,a)})}z(Kd);
+var Pd={"?":"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",s:"set options","t [#]":"trace","u [#]":"unassemble",v:"print version","var":"assign variable"},Ld=8080,Qd="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(" "),
+Rd="NONE ADC ADC ADD ADD AND AND CALL CALLC CALLS CALLNC CALLNZ CALLNS CALLP CALLNP CALLZ NOT CMC CMP CMP DAA ADD DEC DEC CLI STI HLT IN INC INC JMP JC JS JNC JNZ JNS JP JNP JZ MOV MOV MOV MOV MOV MOV NOP OR OR OUT JMP POP PUSH RCL RCR RET RETC RETS RETNC RETNZ RETNS RETP RETNP RETZ ROL ROR RST SBB SBB MOV MOV MOV MOV STC SUB SUB XCHG XOR XOR XCHG".split(" "),Sd="B C D E H L M A BC DE HL SP PC PSW".split(" "),Td=[[45],[42,2067,32],[71,2131,18193],[29,2067],[28,17],[22,17],[44,17,32],[63],[45,32768],
[21,18963,2067],[40,18193,2131],[23,2067],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2323,32],[71,2387,18193],[29,2323],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,18963,2323],[40,18193,2387],[23,2323],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2579,32],[68,115,18963],[29,2579],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,18963,2579],[41,18963,115],[23,2579],[28,1297],[22,1297],[44,1297,32],[16,18193],[45,32768],[42,2835,32],[70,115,18193],[29,2835],[28,1617],[22,1617],
[44,1617,32],[72],[45,32768],[21,18963,2835],[39,18193,115],[23,2835],[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,1617],[43,17,1809],[43,273,17],[43,273,273],[43,273,529],[43,273,785],[43,273,1041],[43,273,1297],[43,273,1617],[43,273,1809],[43,529,17],[43,529,273],[43,529,529],[43,529,785],[43,529,1041],[43,529,1297],[43,529,1617],[43,529,1809],[43,785,17],[43,785,273],[43,785,529],[43,785,785],[43,785,1041],[43,785,1297],[43,
785,1617],[43,785,1809],[43,1041,17],[43,1041,273],[43,1041,529],[43,1041,785],[43,1041,1041],[43,1041,1297],[43,1041,1617],[43,1041,1809],[43,1297,17],[43,1297,273],[43,1297,529],[43,1297,785],[43,1297,1041],[43,1297,1297],[43,1297,1617],[43,1297,1809],[43,1617,17],[43,1617,273],[43,1617,529],[43,1617,785],[43,1617,1041],[43,1617,1297],[26],[43,1617,1809],[43,1809,17],[43,1809,273],[43,1809,529],[43,1809,785],[43,1809,1041],[43,1809,1297],[43,1809,1617],[43,1809,1809],[3,18193,17],[3,18193,273],
[3,18193,529],[3,18193,785],[3,18193,1041],[3,18193,1297],[3,18193,1617],[3,18193,1809],[2,18193,17],[2,18193,273],[2,18193,529],[2,18193,785],[2,18193,1041],[2,18193,1297],[2,18193,1617],[2,18193,1809],[73,18193,17],[73,18193,273],[73,18193,529],[73,18193,785],[73,18193,1041],[73,18193,1297],[73,18193,1617],[73,18193,1809],[66,18193,17],[66,18193,273],[66,18193,529],[66,18193,785],[66,18193,1041],[66,18193,1297],[66,18193,1617],[66,18193,1809],[5,18193,17],[5,18193,273],[5,18193,529],[5,18193,785],
[5,18193,1041],[5,18193,1297],[5,18193,1617],[5,18193,1809],[76,18193,17],[76,18193,273],[76,18193,529],[76,18193,785],[76,18193,1041],[76,18193,1297],[76,18193,1617],[76,18193,1809],[46,18193,17],[46,18193,273],[46,18193,529],[46,18193,785],[46,18193,1041],[46,18193,1297],[46,18193,1617],[46,18193,1809],[18,18193,17],[18,18193,273],[18,18193,529],[18,18193,785],[18,18193,1041],[18,18193,1297],[18,18193,1617],[18,18193,1809],[58],[50,2067],[34,51],[30,51],[11,51],[51,2067],[4,18193,33],[65,128],[62],
[54],[38,51],[30,32819],[15,51],[7,51],[1,18193,33],[65,128],[57],[50,2323],[33,51],[48,33,18193],[10,51],[51,2323],[74,18193,33],[65,128],[55],[54,32768],[31,51],[27,18193,33],[8,51],[7,32819],[67,18193,33],[65,128],[61],[50,2579],[37,51],[78,19283,18963],[14,51],[51,2579],[6,18193,33],[65,128],[60],[49,2579],[36,51],[75,18963,18707],[13,51],[7,32819],[77,18193,33],[65,128],[59],[50,3347],[35,51],[24],[12,51],[51,3347],[47,18193,33],[65,128],[56],[69,19219,18963],[32,51],[25],[9,51],[7,32819],[19,
-18193,33],[65,128]],Td={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:536870912,warn:1073741824,halt:-2147483648};m=Jd.prototype;
-m.Ba=function(a,b,c,d){this.D=b;this.b=c;this.u=a;(a=oc(a,"messages"))&&Nd(this,a);this.Cb=Sd;Ud(this,function(a){a:{var b=d.b.la,c=a[0],g=a=0,k=b.length;if(c){a=X(Y(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.b.Z;k=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;k--;){var n=b[g];n.type==c?l++||d.g("..."):(c=n.type,l=Vb[c],n&&d.g(q(n.id)+" %"+q(g<>>c.Z,c=e!=c.F?c.D[f].yb(e,d):c.D[f++].ib(e,d)|c.D[f&c.W].ib(0,d+1)<<8;b&&Vd(a,b)}return c};
-m.Ab=function(a,b,c){var d=X(a);-1!==d&&(wb(this.D,d,b),c&&Vd(a,c),sc(this.b,!0))};m.Ub=function(a,b,c){var d=X(a);if(-1!==d){var e=this.D,f=d&e.F,h=(d&e.H)>>>e.Z;f!=e.F?e.D[h].zb(f,b&65535,d):(e.D[h++].lb(f,b&255,d),e.D[h&e.W].lb(0,b>>8&255,d+1));c&&Vd(a,c);sc(this.b,!0)}};function W(a){return{B:a,va:!1}}function Wd(a){return[a.B,a.va]}function Xd(a){return{B:a[0],va:a[1]}}
-function Y(a,b,c){var d;c=(c?a.Y:a.Fb).B;if(void 0!==b){d=b=Yd(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=la(Rd,a.substr(b,2))));return c}function de(a,b){var c=0,d=ee(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:c=4}return c?q(d,c):"??"}
-function ee(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.M;break;case 1:c=d.N;break;case 8:c=Hc(d);break;case 2:c=d.O;break;case 3:c=d.P;break;case 9:c=Jc(d);break;case 4:c=d.R;break;case 5:c=d.S;break;case 10:c=J(d);break;case 6:c=d.V(J(d));break;case 11:c=d.ca;break;case 12:c=d.K;break;case 13:c=d.j<<8|Gc(d)&255}}return c}
-function fe(a,b){b=Yd(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=ce(b,c+1),0<=e&&(b=b.substr(0,c)+de(a,e)+b.substr(c+1+Rd[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=Y(a,e))?(d=e+' "'+be(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=Y(a,e))?(Vd(d),d=e+' "'+
-be(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.K).B));if(!this.Ea||a!=this.Ea)if(this.Ea=a,this.fa&-2147483648&&(this.da(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Wa=0;c.F-=c.b;c.b=0;sc(c)}};function gb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.fa&g)!=g||a.message(b.ab+"."+(null!=d?"outPort":"inPort")+"("+r(c)+","+(f?f:"unknown")+(null!=d?",0x"+q(d,2):"")+")"+(null!=h?": 0x"+q(h,2):"")+(null!=e?" at "+Z(e):""))}
-function Md(a){var b;if(qd(a)){if(!a.W||!a.W.length){a.W=Array(1E3);for(b=0;b>>d.Z],!1)}a.ba=["br"];if(void 0!==a.I)for(b=1;b>>d.Z],!0);a.I=["bw"];a.Kb=0}m.Fa=function(a,b,c){var d=!0;c||ke(this,a,b,!1,!0);if(a!=this.A){var e=X(b);if(-1===e)this.g("invalid address: "+Z(b.B)),d=!1;else{var f=this.b;f.la[e>>>f.Z].Fa(e&f.H,a==this.I)}}d&&(a.push(b),c?b.va=!0:(le(this,a,a.length-1,"set"),Md(this)));return d};
-function ke(a,b,c,d,e){var f=!1;c=X(c);for(var h=1;h>>d.Z],b==a.I));g.va||Md(a);break}}return f}function me(a,b){for(var c=1;c>24,4);break;case 3:E=q(D.mb(Da,2),4);break;default:D="imm("+r(v)+")";break a}8086==D.aa&&v&64?E="["+E+"]":v&16||(E=(D.aa==Kd?"$":"0x")+E);D=E}else v&
-16?(D=(p&3840)>>8,v=Rd[D],8086==a.aa&&p&64&&(6==D&&(v="HL"),v="["+v+"]"),D=v):v&128&&(D=(f>>3&7).toString());if(!D||!D.length){g="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
-function Re(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]],Ud={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:536870912,warn:1073741824,halt:-2147483648};m=Kd.prototype;
+m.Ba=function(a,b,c,d){this.B=b;this.b=c;this.w=a;(a=cc(a,"messages"))&&Od(this,a);this.Cb=Td;Vd(this,function(a){a:{var b=d.b.na,c=a[0],g=a=0,l=b.length;if(c){a=V(Y(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.b.aa;l=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,k=0;l--;){var n=b[g];n.type==c?k++||d.g("..."):(c=n.type,k=Ub[c],n&&d.g(q(n.id)+" %"+q(g<>>e.aa;f!=e.D?e.B[h].zb(f,b&65535,d):(e.B[h++].lb(f,b&255,d),e.B[h&e.V].lb(0,b>>8&255,d+1));c&&Wd(a,c);rc(this.b,!0)}};function U(a){return{C:a,wa:!1}}function Xd(a){return[a.C,a.wa]}function Yd(a){return{C:a[0],wa:a[1]}}
+function Y(a,b,c){var d;c=(c?a.X:a.Fb).C;if(void 0!==b){d=b=Zd(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=ma(Sd,a.substr(b,2))));return c}function ee(a,b){var c=0,d=fe(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:c=4}return c?q(d,c):"??"}
+function fe(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.N;break;case 1:c=d.O;break;case 8:c=Hc(d);break;case 2:c=d.P;break;case 3:c=d.R;break;case 9:c=Jc(d);break;case 4:c=d.S;break;case 5:c=d.T;break;case 10:c=J(d);break;case 6:c=d.W(J(d));break;case 11:c=d.da;break;case 12:c=d.L;break;case 13:c=d.j<<8|Fc(d)&255}}return c}
+function ge(a,b){b=Zd(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=de(b,c+1),0<=e&&(b=b.substr(0,c)+ee(a,e)+b.substr(c+1+Sd[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=Y(a,e))?(d=e+' "'+ce(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=Y(a,e))?(Wd(d),d=e+' "'+
+ce(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}m.message=function(a,b){b&&(a+=" at "+Z(U(this.b.L).C));if(!this.Ea||a!=this.Ea)if(this.Ea=a,this.ga&-2147483648&&(this.ea(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Wa=0;c.D-=c.b;c.b=0;rc(c)}};function eb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.ga&g)!=g||a.message(b.ab+"."+(null!=d?"outPort":"inPort")+"("+r(c)+","+(f?f:"unknown")+(null!=d?",0x"+q(d,2):"")+")"+(null!=h?": 0x"+q(h,2):"")+(null!=e?" at "+Z(e):""))}
+function Nd(a){var b;if(rd(a)){if(!a.V||!a.V.length){a.V=Array(1E3);for(b=0;b>>d.aa],!1)}a.ba=["br"];if(void 0!==a.H)for(b=1;b>>d.aa],!0);a.H=["bw"];a.Lb=0}m.Fa=function(a,b,c){var d=!0;c||le(this,a,b,!1,!0);if(a!=this.u){var e=V(b);if(-1===e)this.g("invalid address: "+Z(b.C)),d=!1;else{var f=this.b;f.na[e>>>f.aa].Fa(e&f.G,a==this.H)}}d&&(a.push(b),c?b.wa=!0:(me(this,a,a.length-1,"set"),Nd(this)));return d};
+function le(a,b,c,d,e){var f=!1;c=V(c);for(var h=1;h>>d.aa],b==a.H));g.wa||Nd(a);break}}return f}function ne(a,b){for(var c=1;c>24,4);break;case 3:C=q(A.mb(ca,2),4);break;default:A="imm("+r(u)+")";break a}8086==A.Z&&u&64?C="["+C+"]":u&16||(C=(A.Z==Ld?"$":"0x")+C);A=C}else u&16?(A=
+(p&3840)>>8,u=Sd[A],8086==a.Z&&p&64&&(6==A&&(u="HL"),u="["+u+"]"),A=u):u&128&&(A=(f>>3&7).toString());if(!A||!A.length){g="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
+function Se(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 Zd(a,b,c){var d;if(b){b=Yd(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;h=n+"b"+h;d>>=8}d="0x"+q(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function Ue(a,b){if(b)return Te(a,b,a.ta[b]);var c=0;for(b in a.ta)Te(a,b,a.ta[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,g=f.gc;if(e>=h&&e>8&255;case "C":d.N=g&255;break;case "D":d.O=
-g&255;break;case "DE":d.O=g>>8&255;case "E":d.P=g&255;break;case "H":d.R=g&255;break;case "HL":d.R=g>>8&255;case "L":d.S=g&255;break;case "SP":d.ca=g&65535;break;case "PC":G(d,g);a.Y=W(d.K);break;case "PS":Ec(d,g);break;case "C":d.G=g?d.G|256:d.G&255;break;case "P":g?Mc(d)||(d.X^=1):Mc(d)&&(d.X^=1);break;case "A":d.ha=g?~d.X&16|d.ha&-17:d.X&16|d.ha&-17;break;case "Z":d.G=g?d.G&-256:d.G|255;break;case "S":g?Pc(d)||(d.X^=192):Pc(d)&&(d.X^=192);break;case "I":d.oa=g?d.oa|512:d.oa&-513;break;default:a.g("unknown register: "+
-e);return}if(!h){a.g("invalid value: "+f);return}sc(d);a.g("updated registers:")}a.g(Pe(a));c&&(a.Y=W(d.K),ie(a,Z(a.Y.B)))}}function af(a,b){b=ha(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(fe(a,c[2])):Zd(a,b,!0)}function bf(a,b,c){var d="t"!=b;c=Se(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.Ya(e,d,!1)},function(){sc(a.b);ib(a,!1)})}
-function ie(a,b,c,d){if(b=Y(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=Y(a,c,!0);if(!d||d.Bg[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=oe(a,b,h,f);a.g(f);a.Y=b;e-=b.B-k;c++}}}
-function ae(a,b,c,d){if(c)if(b){0>a.H&&a.F.length&&(a.H=0);if(0>a.H||b!=a.F[a.H])a.F.splice(0,0,b),a.H=0;a.H--}else a.qa?b="end":b=a.F[a.H+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(ha(b.substring(c,f))),c=f+1}}return a}
-function ne(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.qa&&(a.g("ended assemble at "+Z(a.ka.B)),a.Y=a.ka,a.qa=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.Ea=null;if(kb(a)&&0l||"z"ua.length&&(a.g("note: only "+ua.length+" available"),V=ua.length);S-=V;0>S&&(null==ua[ua.length-1].B?(V=S+V,S=0):
-S+=ua.length);var Vc=[];"call"==ue&&(cb=1E5,Vc=["CALL"]);for(void 0!==te&&a.g(V+" instructions earlier:");0=ua.length&&(S=0);a.Lb=V;we++;cb--}}we||(a.g("no "+ve+"history available"),a.Lb=void 0)}else{var dc=Y(a,sa);if(dc){var ec=0;Ia&&("l"==Ia.charAt(0)&&(Ia=Ia.substr(1)||yf),ec=Se(a,Ia)>>>0,65536>4||1;Af--&&0ic?String.fromCharCode(ic):".";gc--}Ja&&(Ja+="\n");Ja+=sa+" "+Ab+(0==zb?" "+Xc:"")}Ja&&a.g(Ja);a.Fb=dc}}}}break;case "e":if("else"==f[0])break;var jc=1,ze=255,Ae=a.V,Be=a.Ab;"ew"==f[0]&&(jc=2,ze=65535,Ae=a.mb,Be=a.Ub);var Ce=jc<<1,De=f[1];if(null==
-De)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 kc=Y(a,De);if(kc)for(var lc=2;lccd;){for(var Ka=null,Ff=256;65536>Db.B>>>0;){Fe.B=a.mb(Db,2);if(null==Db.B||!Ff--)break;for(var Gf=a,mc=Fe,Ge=null,Eb=mc.B,He=Eb,dd=1;6>=dd&&Eb;dd++){if(2mf){if(hf(d,this.W)){this.I=new H(this,of,"failsafe");hf(this.I)&&(sf(this,d),a=2,ef(this.I));I(this.I,"timestamp",ka());ff(this.I);var e=this.u&&!this.J;if(1==a||pa("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=gf(d)){var f=jf(d,"code"),h=jf(d,"data");f&&("ok"==f?hf(d,h):("error"==f&&"no machine state"!=
-h?(this.na("Error: "+h),"unable to verify user"==h&&(ya("user",""),this.A=null)):this.g(f+": "+h),ef(d),hf(d)?(c=gf(d),e=!0):c=!1))}e&&rf(this,c?d:null)}else 2==a&&d.clear()}else rf(this);delete this.W;delete this.Y}e=ab(this.id);for(f=0;fa[1];a=a[2];this.w.ga=!0;var d=this.T.power;d&&(d.textContent="Shutdown");this.ja||(this.g("PC8080 v"+of+"\nCopyright \u00a9 2012-2016 Jeff Parsons \nLicense: GPL version 3 or later "),this.ja=!0);this.b&&(tf(this,this.b,b,c,a),tc(this.b));this.ka&&(sf(this,b),b.clear());!c&&this.I&&(this.I.clear(),delete this.I);this.F=0};
-function sf(a,b){if(pa("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.ua,d=a.A||"",e=b.toString(),f={app:"PC8080"};f.ver=of;f.url=c;f.user=d;f.type="bug";f.data=e;ma("http://www.pcjs.org/api/v1/report",f,!0)}}
-function cf(a,b,c){var d,e="none";if(a.F)return null;a.F--;var f=new H(a,of),h=new H(a,of,"validate"),g=ka();I(h,"timestamp",g);I(f,"timestamp",g);I(f,"version","1.22.0");I(f,"url",window?window.location.href:null);I(f,"browser",oa());a.b&&a.b.wa&&(c&&a.b.da(),d=a.b.wa(b,c),"object"===typeof d&&I(f,a.b.id,d),c&&(a.b.w.ga=!1,!1===d&&(e=null)));for(var g=ab(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(p){g=null,a=p.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");ma(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,n=/( [a-z]+=)(['"])(.*?)\2/g;l=n.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);Mf(a,b,c)}})}else c(a,null)}
-function Nf(a,b,c,d){function e(a){if(void 0===g){var b=h&&A(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=fa(a))}function f(a){e("Error: "+a);k&&(--wf||Oa(!0));k=!1}var h,g,k=!0;wf++;Wa[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var n=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css";p.styleSheet?p.styleSheet.cssText=l:p.appendChild(document.createTextNode(l));n.appendChild(p)}c||
-(c="/versions/pc8080/1.22.0/components.xsl");l=function(d,g){g?xf(c,null,null,!1,e,function(d,l){if(l)if(Xa(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var k=g.transformNode(l);k?(h.outerHTML=k,--wf||Oa(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(k=new XSLTProcessor,k.importStylesheet(l),(k=k.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(k,h),--wf||Oa(!0)):f("invalid machine element: "+
-a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?xf(b,a,d,!0,e,l):Lf(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(z){f(z.message)}return k}window.embedPC8080=function(a,b,c,d){Oa(!1);return Nf(a,b,c,d)};window.enableEvents=Oa;window.sendEvent=Pa;
-function Of(a,b,c,d){if(!c&&b){d.push(b);a=Wa[d[0]];b=null;for(var e in a)if(da(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?ma(b,null,!0,function(a,b){Pf(b,d)}):Pf(null,d)}else t("Error ("+c+") requesting "+a)}
-function Pf(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=Wa[f],k={},l;for(l in g){var n=g[l],p=ca(l);if("xml"==p){for(p=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=p.exec(g[l]);){var z=d[2];z&&(g[z]||(n=n.replace(d[0],"")))}d=l=ba(l)}else"xsl"==p&&(e=l=ba(l));k[l]=n}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',
+function $d(a,b,c){var d;if(b){b=Zd(a,b);for(var e=0,f=!1,h=b,g=[],l=[],k=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;h=n+"b"+h;d>>=8}d="0x"+q(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function Ve(a,b){if(b)return Ue(a,b,a.ra[b]);var c=0;for(b in a.ra)Ue(a,b,a.ra[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,g=f.gc;if(e>=h&&e>8&255;case "C":d.O=g&255;break;case "D":d.P=
+g&255;break;case "DE":d.P=g>>8&255;case "E":d.R=g&255;break;case "H":d.S=g&255;break;case "HL":d.S=g>>8&255;case "L":d.T=g&255;break;case "SP":d.da=g&65535;break;case "PC":H(d,g);a.X=U(d.L);break;case "PS":Dc(d,g);break;case "C":d.I=g?d.I|256:d.I&255;break;case "P":g?Nc(d)||(d.Y^=1):Nc(d)&&(d.Y^=1);break;case "A":d.ia=g?~d.Y&16|d.ia&-17:d.Y&16|d.ia&-17;break;case "Z":d.I=g?d.I&-256:d.I|255;break;case "S":g?Qc(d)||(d.Y^=192):Qc(d)&&(d.Y^=192);break;case "I":d.pa=g?d.pa|512:d.pa&-513;break;default:a.g("unknown register: "+
+e);return}if(!h){a.g("invalid value: "+f);return}rc(d);a.g("updated registers:")}a.g(Qe(a));c&&(a.X=U(d.L),je(a,Z(a.X.C)))}}function bf(a,b){b=ia(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(ge(a,c[2])):$d(a,b,!0)}function cf(a,b,c){var d="t"!=b;c=Te(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);Ca(c,function(){return gb(a,!0)&&a.Ya(e,d,!1)},function(){rc(a.b);gb(a,!1)})}
+function je(a,b,c,d){if(b=Y(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=Y(a,c,!0);if(!d||d.Cg[0].indexOf("+"))){var k=g[0]+":";g[2]&&(k+=" "+g[2]);a.g(k)}g[3]&&(h=g[3],f=null);f=pe(a,b,h,f);a.g(f);a.X=b;e-=b.C-l;c++}}}
+function be(a,b,c,d){if(c)if(b){0>a.G&&a.D.length&&(a.G=0);if(0>a.G||b!=a.D[a.G])a.D.splice(0,0,b),a.G=0;a.G--}else a.ma?b="end":b=a.D[a.G+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(ia(b.substring(c,f))),c=f+1}}return a}
+function oe(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ma&&(a.g("ended assemble at "+Z(a.ja.C)),a.X=a.ja,a.ma=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.Ea=null;if(ib(a)&&0k||"z"ya.length&&(a.g("note: only "+ya.length+" available"),X=ya.length);T-=X;0>T&&(null==ya[ya.length-1].C?(X=T+X,T=0):T+=ya.length);
+var Wc=[];"call"==ve&&(cb=1E5,Wc=["CALL"]);for(void 0!==ue&&a.g(X+" instructions earlier:");0=ya.length&&(T=0);a.Mb=X;xe++;cb--}}xe||(a.g("no "+we+"history available"),a.Mb=void 0)}else{var dc=Y(a,wa);if(dc){var ec=0;La&&("l"==La.charAt(0)&&(La=La.substr(1)||zf),ec=Te(a,La)>>>0,65536>4||1;Bf--&&0ic?String.fromCharCode(ic):".";gc--}Ma&&(Ma+="\n");Ma+=wa+" "+Ab+(0==zb?" "+Yc:"")}Ma&&a.g(Ma);a.Fb=dc}}}}break;case "e":if("else"==f[0])break;var jc=1,Ae=255,Be=a.W,Ce=a.Ab;"ew"==f[0]&&(jc=2,Ae=65535,Be=a.mb,Ce=a.Vb);var De=jc<<1,Ee=f[1];if(null==Ee)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 kc=Y(a,Ee);if(kc)for(var lc=2;lcdd;){for(var Na=null,Gf=256;65536>Db.C>>>0;){Ge.C=a.mb(Db,2);if(null==Db.C||!Gf--)break;for(var Hf=a,mc=Ge,He=null,Eb=mc.C,Ie=Eb,ed=1;6>=ed&&Eb;ed++){if(2nf){if(jf(d,this.V)){this.H=new Gc(this,pf,"failsafe");jf(this.H)&&(tf(this,d),a=2,ff(this.H));I(this.H,"timestamp",la());gf(this.H);var e=this.w&&!this.J;if(1==a||qa("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=hf(d)){var f=kf(d,"code"),h=kf(d,"data");f&&("ok"==f?jf(d,h):("error"==f&&"no machine state"!=
+h?(this.oa("Error: "+h),"unable to verify user"==h&&(ua("user",""),this.u=null)):this.g(f+": "+h),ff(d),jf(d)?(c=hf(d),e=!0):c=!1))}e&&sf(this,c?d:null)}else 2==a&&d.clear()}else sf(this);delete this.V;delete this.X}e=Za(this.id);for(f=0;fa[1];a=a[2];this.A.ha=!0;var d=this.U.power;d&&(d.textContent="Shutdown");this.fa||(this.g("PC8080 v"+pf+"\nCopyright \u00a9 2012-2016 Jeff Parsons \nLicense: GPL version 3 or later "),this.fa=!0);this.b&&(uf(this,this.b,b,c,a),sc(this.b));this.ja&&(tf(this,b),b.clear());!c&&this.H&&(this.H.clear(),delete this.H);this.D=0};
+function tf(a,b){if(qa("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.ua,d=a.u||"",e=b.toString(),f={app:"PC8080"};f.ver=pf;f.url=c;f.user=d;f.type="bug";f.data=e;na("http://www.pcjs.org/api/v1/report",f,!0)}}
+function df(a,b,c){var d,e="none";if(a.D)return null;a.D--;var f=new Gc(a,pf),h=new Gc(a,pf,"validate"),g=la();I(h,"timestamp",g);I(f,"timestamp",g);I(f,"version","1.22.0");I(f,"url",window?window.location.href:null);I(f,"browser",pa());a.b&&a.b.xa&&(c&&a.b.ea(),d=a.b.xa(b,c),"object"===typeof d&&I(f,a.b.id,d),c&&(a.b.A.ha=!1,!1===d&&(e=null)));for(var g=Za(a.id),l=0;l>>e.aa;0>8|(u&255)<<8,ca=65536,C=16;l>=1))>>--C,W=d.X,S=l++,
+x=g[x],S=(S+k*W.width)*x.length;W.data[S]=x[0];W.data[S+1]=x[1];W.data[S+2]=x[2];W.data[S+3]=x[3]}l>p&&(p=l);k=A&&(A=k+1)}e+=2;h++;if(l>=d.u&&(l=0,k++,k>d.D))break}d.M=!0;ng.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(p){g=null,a=p.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");na(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 l=g[0],k,n=/( [a-z]+=)(['"])(.*?)\2/g;k=n.exec(f);)l=0>l.indexOf(k[1])?l.replace(">",k[0]+">"):l.replace(new RegExp(k[1]+"(['\"])(.*?)\\1"),k[0]);g[0]!=l&&(h=h.replace(g[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
+"");a=a.replace(d[0],h);Nf(a,b,c)}})}else c(a,null)}
+function Of(a,b,c,d){function e(a){if(void 0===g){var b=h&&D(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ga(a))}function f(a){e("Error: "+a);l&&(--xf||Pa(!0));l=!1}var h,g,l=!0;xf++;Xa[a]={};try{if(h=document.getElementById(a)){var k;if("object"==typeof resources&&(k=resources.css)){var n=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css";p.styleSheet?p.styleSheet.cssText=k:p.appendChild(document.createTextNode(k));n.appendChild(p)}c||
+(c="/versions/pc8080/1.22.0/components.xsl");k=function(d,g){g?yf(c,null,null,!1,e,function(d,l){if(l)if(Ya(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var k=g.transformNode(l);k?(h.outerHTML=k,--xf||Pa(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(k=new XSLTProcessor,k.importStylesheet(l),(k=k.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(k,h),--xf||Pa(!0)):f("invalid machine element: "+
+a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?yf(b,a,d,!0,e,k):Mf(b,null,a,d,!1,e,k)}else f("missing machine element: "+a)}catch(w){f(w.message)}return l}window.embedPC8080=function(a,b,c,d){Pa(!1);return Of(a,b,c,d)};window.enableEvents=Pa;window.sendEvent=Qa;
+function Pf(a,b,c,d){if(!c&&b){d.push(b);a=Xa[d[0]];b=null;for(var e in a)if(ea(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?na(b,null,!0,function(a,b){Qf(b,d)}):Qf(null,d)}else t("Error ("+c+") requesting "+a)}
+function Qf(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=Xa[f],l={},k;for(k in g){var n=g[k],p=da(k);if("xml"==p){for(p=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=p.exec(g[k]);){var w=d[2];w&&(g[w]||(n=n.replace(d[0],"")))}d=k=ba(k)}else"xsl"==p&&(e=k=ba(k));l[k]=n}a&&(l[k="css"]=a);b[2]&&(l[k="parms"]=b[2]);b[3]&&(l[k="state"]=b[3]);d&&e?(k=JSON.stringify(l),h+=".js",c=c[1]+"var resources="+k+";"+c[2]+c[3],c=c.replace(/\u00A9/g,
+"©"),k=h,g=null,l="data:application/javascript,",l=Ba("Firefox")?l+encodeURIComponent(c):l+encodeURI(c),k&&(g=document.createElement("a"),"string"!=typeof g.download&&(g=null)),g?(g.href=l,g.download=k,document.body.appendChild(g),g.click(),document.body.removeChild(g),c="Check your Downloads folder for "+k+"."):(window.open(l),c="Check your browser for a new window/tab containing the requested data"+(k?" ("+k+")":"")+"."),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+='