diff --git a/devices/pc8080/machine/vt100/README.md b/devices/pc8080/machine/vt100/README.md index 6e40a91c0..64e69f098 100644 --- a/devices/pc8080/machine/vt100/README.md +++ b/devices/pc8080/machine/vt100/README.md @@ -15,12 +15,41 @@ This is a PCjs work-in-progress emulation of another 8080-based machine: the VT1 Unlike other VT100 emulators, it is not simply an emulation of VT100 protocols. It is a simulation of the original VT100 machine, running the [VT100 Firmware](/devices/pc8080/rom/vt100/) inside the [PC8080](/modules/pc8080/) CPU emulator. +A [Debugger Configuration](/devices/pc8080/machine/vt100/debugger/) is also available. Admittedly, terminals aren't that useful in isolation, since they're designed to be connected to other (host) machines. But once this PCjs VT100 Terminal simulation is fully operational, you can expect to see it used in conjunction with a variety of other PCjs machines. -For now, play with the [Debugger Configuration](/devices/pc8080/machine/vt100/debugger/), which also provides information -about VT100 internals and links to other technical resources. - {% include machine.html id="vt100" %} + +VT100 Keys +---------- + +Function keys are mapped as follows: + +- F1: PF1 +- F2: PF2 +- F3: PF3 +- F4: PF4 +- F6: BREAK +- F7: LINE FEED +- F8: NO SCROLL +- F9: SET-UP + +From the SET-UP screen, you can press **4** to switch to LOCAL mode and verify local operation of most VT100 +keys. The following keys have special meaning inside SET-UP Mode. + +### SET-UP Mode Keys + +- 0: RESET +- 2: SET/CLEAR TAB +- 3: CLEAR ALL TABS +- 4: ONLINE/LOCAL +- 5: SET-UP A/B +- 6: TOGGLE FEATURE +- 7: TRANSMIT SPEED +- 8: RECEIVE SPEED +- 9: 80/132 COLUMNS +- SHIFT-S: Save SET-UP Features +- SHIFT-R: Restore SET-UP Features diff --git a/devices/pc8080/machine/vt100/debugger/README.md b/devices/pc8080/machine/vt100/debugger/README.md index f2dea50a6..6c1844423 100644 --- a/devices/pc8080/machine/vt100/debugger/README.md +++ b/devices/pc8080/machine/vt100/debugger/README.md @@ -12,10 +12,17 @@ DEC VT100 Terminal with Debugger -------------------------------- The [PC8080](/modules/pc8080/) machine below is configured to simulate a [VT100 Terminal](/devices/pc8080/machine/vt100/) -with a Control Panel and Debugger. It is running the original [VT100 Firmware](/devices/pc8080/rom/vt100/) inside the -[PC8080](/modules/pc8080/) CPU emulator. You'll also find assorted [Hardware Notes](#vt100-memory-usage) below. +with a Control Panel and Debugger. When you press the "Run" button, it will start running the original +[VT100 Firmware](/devices/pc8080/rom/vt100/) inside the [PC8080](/modules/pc8080/) CPU emulator. -Click the "Run" button to start the simulation. The VT100 KEYMAP table in [keyboard.js](/modules/pc8080/lib/keyboard.js) +Information about [VT100 Keys](#vt100-keys) along with assorted [Hardware Notes](#vt100-memory-usage) are provided below. + +{% include machine.html id="vt100" %} + +VT100 Keys +---------- + +The VT100 KEYMAP table in [keyboard.js](/modules/pc8080/lib/keyboard.js) maps modern keys to VT100 key addresses, and most of the mappings are 1-1. Function keys are mapped as follows: - F1: PF1 @@ -27,10 +34,22 @@ maps modern keys to VT100 key addresses, and most of the mappings are 1-1. Func - F8: NO SCROLL - F9: SET-UP -The simulation is not fully operational yet, but it is now possible to access the SET-UP screen, press 4 to switch to LOCAL -mode, and verify that most VT100 keys work properly. +From the SET-UP screen, you can press **4** to switch to LOCAL mode and verify local operation of most VT100 +keys. The following keys have special meaning inside SET-UP Mode. -{% include machine.html id="vt100" %} +### SET-UP Mode Keys + +- 0: RESET +- 2: SET/CLEAR TAB +- 3: CLEAR ALL TABS +- 4: ONLINE/LOCAL +- 5: SET-UP A/B +- 6: TOGGLE FEATURE +- 7: TRANSMIT SPEED +- 8: RECEIVE SPEED +- 9: 80/132 COLUMNS +- SHIFT-S: Save SET-UP Features +- SHIFT-R: Restore SET-UP Features VT100 Memory Usage ------------------ @@ -227,6 +246,37 @@ Some additional observations: set in the keyboard STATUS port (0x82), generating a "bell" (beep). The NVR checksum test used to fail when we initialized all NVR words with the freshly-erased value of 0x3fff; now we initialize them with canned values (see ChipSet.VT100.INIT). +### SET-UP Mode + +From "PART 2: SET-UP MODE", p. 2-6, of the VT100 Technical Manual (July 1982): + +> Unlike most terminals, the VT100 does not use switches or jumpers to individually turn the built-in terminal features on +or off. Instead, the VT100 uses a nonvolatile memory (NVR) that always remembers what features have been selected, as if a +swiitch had been set. + +> Selection and storage of built-in terminal features is performed in a special mode of operation called SET-UP mode. +When you enter SET-UP mode, the status of features stored in temporary memory shows on the screen. You can then change the +features and store any new feature selections either temporarily, by leaving SET-UP mode; or on a fixed basis, by performing +a Save operation. In either case, terminal operation reflects the new feature selection. If a recall operation is performed, +or the terminal is reset, or terminal power is turned off, all temporary feature settings are replaced by features that have +been stored on a fixed basis. + +> ### SET-UP Features + +> SET-UP mode provides two brief summaries of the current feature status. The first presentation - SET-UP A - displays +the location of tab stops set and a visual ruler that numbers each character position on the line. The second presentation - +SET-UP B - summarizes the status of the other terminal features. + +> **SET-UP A** - To enter SET-UP A, press the **SET-UP** key. The display has a presentation similar to Figure 2-3. The bottom +line of the display consists of a "ruler" that numbers each character position available on a line. Each tab stop is shown by +a "T" above the ruler. If the tab stop(s) set are those desired, you may exit **SET-UP** mode by pressing the SET-UP key again +or you may now change the tabs to meet your requirements. + +> **SET-UP B** - SET-UP B mode may only be entered from SET-UP A mode. To enter SET-UP B, from SET-UP A press the **5** key on +the main keyboard. The display looks like Figure 2-4. Figure 2-5 summarizes the SET-UP B presentation. This summary allows you +to quickly determine what features are enabled. For additional information on a feature refer to in Part 3, SET-UP Feature +Definitions. + Additional VT100 Resources -------------------------- diff --git a/devices/pc8080/machine/vt100/debugger/machine.xml b/devices/pc8080/machine/vt100/debugger/machine.xml index 876e6ccc4..a4349b299 100644 --- a/devices/pc8080/machine/vt100/debugger/machine.xml +++ b/devices/pc8080/machine/vt100/debugger/machine.xml @@ -24,8 +24,12 @@ - - + + SET-UP + + + TEST RECEIVER + diff --git a/devices/pc8080/machine/vt100/machine.xml b/devices/pc8080/machine/vt100/machine.xml index b47d52e02..378bca98e 100644 --- a/devices/pc8080/machine/vt100/machine.xml +++ b/devices/pc8080/machine/vt100/machine.xml @@ -24,5 +24,10 @@ - + + SET-UP + + + TEST RECEIVER + diff --git a/modules/pc8080/lib/chipset.js b/modules/pc8080/lib/chipset.js index c70b044d7..67cdff3ab 100644 --- a/modules/pc8080/lib/chipset.js +++ b/modules/pc8080/lib/chipset.js @@ -235,24 +235,52 @@ ChipSet.VT100 = { PORT: 0x42, // write-only INIT: 0x00 // for lack of a better guess }, - NVR: { - LATCH: { - PORT: 0x62 // write-only - }, - CMD: { - ACCEPT_DATA: 0x0, - ACCEPT_ADDR: 0x1, - SHIFT_OUT: 0x2, - WRITE: 0x4, - ERASE: 0x5, - READ: 0x6, - STANDBY: 0x7 - }, - WORDMASK: 0x3fff // NVR words are 14-bit - /* - * The Technical Manual, p. 4-18, also notes that "Early VT100s can disable the receiver interrupt by - * programming D4 in the NVR latch. However, this is never used by the VT100." - */ + /* + * DC011 is referred to as a Timing Chip. + * + * As p. 4-55 (105) of the VT100 Technical Manual (July 1982) explains: + * + * The DCO11 is a custom designed bipolar circuit that provides most of the timing signals required by the + * video processor. Internal counters divide the output of a 24.0734 MHz oscillator (located elsewhere on the + * terminal controller module) into the lower frequencies that define dot, character, scan, and frame timing. + * The counters are programmable through various input pins to control the number of characters per line, + * the frequency at which the screen is refreshed, and whether the display is interlaced or noninterlaced. + * These parameters can be controlled through SET-UP mode or by the host. + * + * Table 4-6-1: Video Mode Selection (Write Address 0xC2) + * + * D5 D4 Configuration + * -- -- ------------- + * 0 0 80-column mode, interlaced + * 0 1 132-column mode, interlaced + * 1 0 60Hz, non-interlaced + * 1 1 50Hz, non-interlaced + * + * On p. 4-56, the DC011 Block Diagram shows 8 outputs labeled LBA0 through LBA7. From p. 4-61: + * + * Several of the LBAs are used as general purpose clocks in the VT100. LBA 3 and LBA 4 are used to generate + * timing for the keyboard. These signals satisfy the keyboard's requirement of two square-waves, one twice the + * frequency of the other, even though every 16th transition is delayed (the second stage of the horizontal + * counter divides by 17, not 16). LBA 7 is used by the nonvolatile RAM. + * + * And on p. 4-62, timings are provided for the LBA0 through LBA7 when the VT100 is in 80-column mode; in particular: + * + * LBA6: 16.82353us (when LBA6 is low, for a period of 33.64706us) + * LBA7: 31.77778us (when LBA7 is high, for a period of 63.55556us) + * + * If we assume that the CPU cycle count increments once every 361.69ns, it will increment roughly 88 times every + * time LBA7 toggles. So we can divide the CPU cycle count by 88 and set LBA to the low bit of that truncated + * result. An even faster (but less accurate) solution would be to mask bit 6 of the CPU cycle count, which will + * doesn't change until the count has been incremented 64 times. See getVT100LBA() for the chosen implementation. + */ + DC011: { // generates Line Buffer Addresses (LBAs) for the Video Processor + PORT: 0xC2, // write-only + COLS80: 0x00, + COLS132: 0x10, + RATE60: 0x20, + RATE50: 0x30, + INITCOLS: 0x00, // ie, COLS80 + INITRATE: 0x20 // ie, RATE60 }, /* * DC012 is referred to as a Control Chip. @@ -302,40 +330,33 @@ ChipSet.VT100 = { */ DC012: { // generates scan counts for the Video Processor PORT: 0xA2, // write-only - INIT: 0x00 // for lack of a better guess + SCROLL_LO: 0x00, + INITSCROLL: 0x00, + INITBLINK: 0x00, + INITREVERSE:0x00, + INITATTR: 0x00 }, /* - * DC011 is referred to as a Timing Chip. - * - * As p. 4-55 (105) of the VT100 Technical Manual (July 1982) explains: - * - * The DCO11 is a custom designed bipolar circuit that provides most of the timing signals required by the - * video processor. Internal counters divide the output of a 24.0734 MHz oscillator (located elsewhere on the - * terminal controller module) into the lower frequencies that define dot, character, scan, and frame timing. - * The counters are programmable through various input pins to control the number of characters per line, - * the frequency at which the screen is refreshed, and whether the display is interlaced or noninterlaced. - * These parameters can be controlled through SET-UP mode or by the host. - * - * On p. 4-56, the DC011 Block Diagram shows 8 outputs labeled LBA0 through LBA7. From p. 4-61: - * - * Several of the LBAs are used as general purpose clocks in the VT100. LBA 3 and LBA 4 are used to generate - * timing for the keyboard. These signals satisfy the keyboard's requirement of two square-waves, one twice the - * frequency of the other, even though every 16th transition is delayed (the second stage of the horizontal - * counter divides by 17, not 16). LBA 7 is used by the nonvolatile RAM. - * - * And on p. 4-62, timings are provided for the LBA0 through LBA7 when the VT100 is in 80-column mode; in particular: - * - * LBA6: 16.82353us (when LBA6 is low, for a period of 33.64706us) - * LBA7: 31.77778us (when LBA7 is high, for a period of 63.55556us) - * - * If we assume that the CPU cycle count increments once every 361.69ns, it will increment roughly 88 times every - * time LBA7 toggles. So we can divide the CPU cycle count by 88 and set LBA to the low bit of that truncated - * result. An even faster (but less accurate) solution would be to mask bit 6 of the CPU cycle count, which will - * doesn't change until the count has been incremented 64 times. See getVT100LBA() for the chosen implementation. + * ER1400 Non-Volatile RAM (NVR) Chip Definitions */ - DC011: { // generates Line Buffer Addresses (LBAs) for the Video Processor - PORT: 0xC2, // write-only - INIT: 0x00 // for lack of a better guess + NVR: { + LATCH: { + PORT: 0x62 // write-only + }, + CMD: { + ACCEPT_DATA: 0x0, + ACCEPT_ADDR: 0x1, + SHIFT_OUT: 0x2, + WRITE: 0x4, + ERASE: 0x5, + READ: 0x6, + STANDBY: 0x7 + }, + WORDMASK: 0x3fff // NVR words are 14-bit + /* + * The Technical Manual, p. 4-18, also notes that "Early VT100s can disable the receiver interrupt by + * programming D4 in the NVR latch. However, this is never used by the VT100." + */ } }; @@ -402,7 +423,8 @@ ChipSet.prototype.initBus = function(cmp, bus, cpu, dbg) this.cpu = cpu; this.dbg = dbg; this.cmp = cmp; - this.kbd = cmp.getMachineComponent("Keyboard"); + this.kbd = /** @type {Keyboard} */ (cmp.getMachineComponent("Keyboard")); + this.video = /** @type {Video} */ (cmp.getMachineComponent("Video")); bus.addPortInputTable(this, this.config.portsInput); bus.addPortOutputTable(this, this.config.portsOutput); }; @@ -452,9 +474,17 @@ ChipSet.SI1978.INIT = [ ChipSet.VT100.INIT = [ [ ChipSet.VT100.BRIGHTNESS.INIT, - ChipSet.VT100.FLAGS_BUFFER.NO_AVO | ChipSet.VT100.FLAGS_BUFFER.NO_GFX, - ChipSet.VT100.DC012.INIT, - ChipSet.VT100.DC011.INIT + ChipSet.VT100.FLAGS_BUFFER.NO_AVO | ChipSet.VT100.FLAGS_BUFFER.NO_GFX + ], + [ + ChipSet.VT100.DC011.INITCOLS, + ChipSet.VT100.DC011.INITRATE + ], + [ + ChipSet.VT100.DC012.INITSCROLL, + ChipSet.VT100.DC012.INITBLINK, + ChipSet.VT100.DC012.INITREVERSE, + ChipSet.VT100.DC012.INITATTR ], [ 0, 0, 0, 0, @@ -501,8 +531,10 @@ ChipSet.prototype.save = function() state.set(0, [this.bStatus0, this.bStatus1, this.bStatus2, this.wShiftData, this.bShiftCount, this.bSound1, this.bSound2]); break; case ChipSet.VT100.MODEL: - state.set(0, [this.bBrightness, this.bFlagsBuffer, this.bDC012, this.bDC011]); - state.set(1, [this.dNVRAddr, this.wNVRData, this.bNVRLatch, this.bNVROut, this.aNVRWords]); + state.set(0, [this.bBrightness, this.bFlagsBuffer]); + state.set(1, [this.bDC011Cols, this.bDC011Rate]); + state.set(2, [this.bDC012Scroll, this.bDC012Blink, this.bDC012Reverse, this.bDC012Attr]); + state.set(3, [this.dNVRAddr, this.wNVRData, this.bNVRLatch, this.bNVROut, this.aNVRWords]); break; } return state.data(); @@ -534,9 +566,15 @@ ChipSet.prototype.restore = function(data) case ChipSet.VT100.MODEL: this.bBrightness = a[0]; this.bFlagsBuffer = a[1]; - this.bDC012 = a[2]; - this.bDC011 = a[3]; a = data[1]; + this.bDC011Cols = a[0]; + this.bDC011Rate = a[1]; + a = data[2]; + this.bDC012Scroll = a[0]; + this.bDC012Blink = a[1]; + this.bDC012Reverse = a[2]; + this.bDC012Attr = a[3]; + a = data[3]; this.dNVRAddr = a[0]; // 20-bit address this.wNVRData = a[1]; // 14-bit word this.bNVRLatch = a[2]; // 1 byte @@ -909,9 +947,8 @@ ChipSet.prototype.outVT100NVRLatch = function(port, b, addrFrom) /** * outVT100DC012(port, b, addrFrom) * - * TODO: Consider whether we should disable any interrupts (eg, vertical retrace) until the - * this port is initialized at runtime. We initialize it ourselves at start-up, but our initial - * value is just a guess. + * TODO: Consider whether we should disable any interrupts (eg, vertical retrace) until + * this port is initialized at runtime. * * @this {ChipSet} * @param {number} port (0xA2) @@ -921,7 +958,34 @@ ChipSet.prototype.outVT100NVRLatch = function(port, b, addrFrom) ChipSet.prototype.outVT100DC012 = function(port, b, addrFrom) { this.printMessageIO(port, b, addrFrom, "DC012"); - this.bDC012 = b; + + var bOpt = b & 0x3; + var bCmd = (b >> 2) & 0x3; + switch(bCmd) { + case 0x0: + this.bDC012Scroll = (this.bDC012Scroll & ~0x3) | bOpt; + break; + case 0x1: + this.bDC012Scroll = (this.bDC012Scroll & ~0xC) | (bOpt << 2); + break; + case 0x2: + switch(bOpt) { + case 0x0: + this.bDC012Blink = ~this.bDC012Blink; + break; + case 0x1: + // TODO: Clear vertical frequency interrupt + break; + case 0x2: + case 0x3: + this.bDC012Reverse = 0x3 - bOpt; + break; + } + break; + case 0x3: + this.bDC012Attr = bOpt; + break; + } }; /** @@ -935,7 +999,25 @@ ChipSet.prototype.outVT100DC012 = function(port, b, addrFrom) ChipSet.prototype.outVT100DC011 = function(port, b, addrFrom) { this.printMessageIO(port, b, addrFrom, "DC011"); - this.bDC011 = b; + if (b & ChipSet.VT100.DC011.RATE60) { + b &= ChipSet.VT100.DC011.RATE50; + if (this.bDC011Rate != b) { + this.bDC011Rate = b; + if (this.video) { + this.video.updateRate(this.bDC011Rate == ChipSet.VT100.DC011.RATE50? 50 : 60); + } + } + } else { + b &= ChipSet.VT100.DC011.COLS132; + if (this.bDC011Cols != b) { + this.bDC011Cols = b; + if (this.video) { + var nCols = (this.bDC011Cols == ChipSet.VT100.DC011.COLS132? 132 : 80); + var nRows = (nCols > 80 && (this.bFlagsBuffer & ChipSet.VT100.FLAGS_BUFFER.NO_AVO)? 14 : 24); + this.video.updateDimensions(nCols, nRows); + } + } + } }; /* diff --git a/modules/pc8080/lib/cpu.js b/modules/pc8080/lib/cpu.js index 9da44e78d..080676351 100644 --- a/modules/pc8080/lib/cpu.js +++ b/modules/pc8080/lib/cpu.js @@ -176,13 +176,13 @@ CPU.prototype.initBus = function(cmp, bus, cpu, dbg) /* * We need to know the refresh rate (and corresponding interrupt rate, if any) of the Video component. */ - var video = cmp.getMachineComponent("Video"); + var video = /** @type {Video} */ (cmp.getMachineComponent("Video")); this.refreshRate = video && video.getRefreshRate() || CPU.VIDEO_UPDATES_PER_SECOND; /* * Attach the ChipSet component to the CPU so that it can be notified whenever the CPU stops and starts. */ - this.chipset = cmp.getMachineComponent("ChipSet"); + this.chipset = /** @type {ChipSet} */ (cmp.getMachineComponent("ChipSet")); /* * We've already saved the parmsCPU 'autoStart' setting, but there may be a machine (or URL) override. diff --git a/modules/pc8080/lib/keyboard.js b/modules/pc8080/lib/keyboard.js index bc06ceea4..3daed04d3 100644 --- a/modules/pc8080/lib/keyboard.js +++ b/modules/pc8080/lib/keyboard.js @@ -72,9 +72,9 @@ Component.subclass(Keyboard); /** * Alphanumeric and other common (printable) ASCII codes. * - * TODO: Determine what we can do to get ALL constants like these inlined (enum doesn't seem to - * get the job done); the problem seems to be limited to property references that use quotes, which - * is why I've 'unquoted' as many of them as possible. + * TODO: Determine what we can do to get ALL constants like these inlined by the Closure Compiler + * (enum doesn't seem to get the job done); the problem seems to be limited to property references + * that use quotes, which is why I've 'unquoted' as many of them as possible. * * @enum {number} */ @@ -101,8 +101,8 @@ Keyboard.ASCII = { * * keyCodes for most common ASCII keys can simply use the appropriate ASCII code above. * - * Most of these represent non-ASCII keys (eg, the LEFT arrow key), yet for some reason, browsers defined - * them using ASCII codes (eg, the LEFT arrow key uses the ASCII code for '%' or 37). + * Most of these represent non-ASCII characters (eg, the LEFT arrow key), yet for some reason, browsers + * defined them using ASCII codes (eg, the LEFT arrow key uses 37, which is the ASCII code for '%'). * * @enum {number} */ @@ -282,13 +282,15 @@ Keyboard.VT100 = { KEYMAP: {}, ALTCODES: {}, LEDCODES: {}, - SOFTCODES: {}, + SOFTCODES: { + 'setup': Keyboard.KEYCODE.F9 + }, /* * Reading port 0x82 returns a key address from the VT100 keyboard's UART data output. * * Every time a keyboard scan is initiated (by setting the START bit of the status byte), - * an internal address index is reset to zero, and an interrupt is generated for each entry - * in the aKeysActive array, along with a final interrupt for KEYLAST. + * our internal address index (iKeyNext) is set to zero, and an interrupt is generated for + * each entry in the aKeysActive array, along with a final interrupt for KEYLAST. */ ADDRESS: { PORT: 0x82, @@ -320,9 +322,12 @@ Keyboard.VT100 = { CLICK: 0x80, INIT: 0x00 }, - KEYLAST: 0x7F + KEYLAST: 0x7F // special end-of-scan key address (all valid key addresses are < KEYLAST) }; +/* + * Table to map host key codes to VT100 key addresses (ie, unique 7-bit values representing key positions on the VT100) + */ Keyboard.VT100.KEYMAP[Keyboard.KEYCODE.DEL] = 0x03; Keyboard.VT100.KEYMAP[Keyboard.ASCII.P] = 0x05; Keyboard.VT100.KEYMAP[Keyboard.ASCII.O] = 0x06; @@ -486,16 +491,25 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) default: if (this.config.SOFTCODES && this.config.SOFTCODES[sBinding] !== undefined) { this.bindings[id] = control; - var fnDown = function(kbd, sSoftCode) { - return function onMouseOrTouchDownKeyboard(event) { - kbd.onSoftKeyDown(sSoftCode, true); + var fnDown = function(kbd, softCode) { + return function onKeyboardBindingDown(event) { + kbd.onSoftKeyDown(softCode, true); + /* + * I'm assuming we only need to give focus back on the "up" event... + * + * if (kbd.cmp) kbd.cmp.updateFocus(); + */ }; - }(this, sBinding); - var fnUp = function (kbd, sSoftCode) { - return function onMouseOrTouchUpKeyboard(event) { - kbd.onSoftKeyDown(sSoftCode, false); + }(this, this.config.SOFTCODES[sBinding]); + var fnUp = function (kbd, softCode) { + return function onKeyboardBindingUp(event) { + kbd.onSoftKeyDown(softCode, false); + /* + * Give focus back to the machine (since clicking the button takes focus away). + */ + if (kbd.cmp) kbd.cmp.updateFocus(); }; - }(this, sBinding); + }(this, this.config.SOFTCODES[sBinding]); if ('ontouchstart' in window) { control.ontouchstart = fnDown; control.ontouchend = fnUp; @@ -522,9 +536,10 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) */ Keyboard.prototype.initBus = function(cmp, bus, cpu, dbg) { + this.cmp = cmp; this.cpu = cpu; this.dbg = dbg; // NOTE: The "dbg" property must be set for the message functions to work - this.chipset = cmp.getMachineComponent("ChipSet"); + this.chipset = /** @type {ChipSet} */ (cmp.getMachineComponent("ChipSet")); bus.addPortInputTable(this, this.config.portsInput); bus.addPortOutputTable(this, this.config.portsOutput); }; @@ -873,8 +888,8 @@ Keyboard.prototype.checkBusy = function() * * We take our cue from iKeyNext. If it's -1 (default), we simply return the last value latched * in bVT100Address. Otherwise, if iKeyNext is a valid index into aKeysActive, we look up the key - * in the VT100.KEYMAP, latch it, and increment iKeyNext, else we latch Keyboard.VT100.KEYLAST - * and set iKeyNext to -1 again. + * in the VT100.KEYMAP, latch it, and increment iKeyNext. Failing that, we latch Keyboard.VT100.KEYLAST + * and reset iKeyNext to -1. * * @this {Keyboard} * @param {number} port (0x82) @@ -893,8 +908,8 @@ Keyboard.prototype.inVT100UARTAddress = function(port, addrFrom) /* * In MAXDEBUG builds, this code removes the key as soon as it's been reported, because * when debugging, it's easy for the window to lose focus and never receive the keyUp event, - * thereby leaving us with a stuck key. However, this causes more problems than it solves, - * and seems to illustrate that key presses need to be persist for more than a single poll. + * thereby leaving us with a stuck key. However, this may cause more problems than it solves, + * because the VT100's ROM seems to require that key presses persist for more than a single poll. */ this.aKeysActive.splice(this.iKeyNext, 1); } diff --git a/modules/pc8080/lib/panel.js b/modules/pc8080/lib/panel.js index 892aa2a73..de1c1b6b6 100644 --- a/modules/pc8080/lib/panel.js +++ b/modules/pc8080/lib/panel.js @@ -95,7 +95,7 @@ Panel.prototype.initBus = function(cmp, bus, cpu, dbg) this.bus = bus; this.cpu = cpu; this.dbg = dbg; - this.kbd = cmp.getMachineComponent("Keyboard"); + this.kbd = /** @type {Keyboard} */ (cmp.getMachineComponent("Keyboard")); }; /** diff --git a/modules/pc8080/lib/serialport.js b/modules/pc8080/lib/serialport.js index 226735532..36a781cea 100644 --- a/modules/pc8080/lib/serialport.js +++ b/modules/pc8080/lib/serialport.js @@ -136,6 +136,90 @@ function SerialPort(parmsSerial) { Component.subclass(SerialPort); +SerialPort.UART8251 = { + /* + * Format of MODE byte written to CONTROL port 0x1 + */ + MODE: { + BAUD_FACTOR: 0x03, // 00=SYNC, 01=1x, 10=16x, 11=64x + DATA_BITS: 0x0C, // 00=5, 01=6, 10=7, 11=8 + PARITY_ENABLE: 0x10, + EVEN_PARITY: 0x20, + STOP_BITS: 0xC0, // 00=invalid, 01=1, 10=1.5, 11=2 + INIT: 0x8E // 16x baudrate, 8 data bits, no parity, 1.5 stop bits + }, + /* + * Format of COMMAND byte written to CONTROL port 0x1 + */ + COMMAND: { + XMIT_ENABLE: 0x01, + DTR: 0x02, // Data Terminal Ready + RECV_ENABLE: 0x04, + SEND_BREAK: 0x08, + ERROR_RESET: 0x10, + RTS: 0x20, // Request To Send + INTERNAL_RESET: 0x40, + HUNT_MODE: 0x80, + INIT: 0x27 // XMIT_ENABLE | DTR | RECV_ENABLE | RTS + }, + /* + * Format of STATUS byte read from CONTROL port 0x1 + */ + STATUS: { + XMIT_READY: 0x01, + RECV_FULL: 0x02, + XMIT_EMPTY: 0x04, + PARITY_ERROR: 0x08, + OVERRUN_ERROR: 0x10, + FRAMING_ERROR: 0x20, + BREAK_DETECT: 0x40, + DSR: 0x80, // Data Set Ready + INIT: 0x85 // XMIT_READY | XMIT_EMPTY | DSR + }, + /* + * Format of BAUDRATE byte written to port 0x2 + * + * Each nibble is an index (0x0-0xF) into a set internal CPU clock divisors that yield the following baud rates: + * + * Index Divisor Baud Rate + * ----- ------- --------- + * 0x0 3456 50 + * 0x1 2304 75 + * 0x2 1571 110 + * 0x3 1285 134.5 + * 0x4 1152 150 + * 0x5 864 200 + * 0x6 576 300 + * 0x7 288 600 + * 0x8 144 1200 + * 0x9 96 1800 + * 0xA 86 2000 + * 0xB 72 2400 + * 0xC 48 3600 + * 0xD 36 4800 + * 0xE 18 9600 (default) + * 0xF 9 19200 + * + * TODO: I'm not really sure at this point which nibble is for the XMIT rate and which is for the RECV + * rate; I just made a random guess. + */ + BAUDRATE: { + XMIT_RATE: 0x0F, + RECV_RATE: 0xF0, + INIT: 0xEE // default to 9600 (0xE) for both XMIT and RECV + } +}; + +SerialPort.UART8251.INIT = [ + false, + 0, + 0, + SerialPort.UART8251.STATUS.INIT, + SerialPort.UART8251.MODE.INIT, + SerialPort.UART8251.COMMAND.INIT, + SerialPort.UART8251.BAUDRATE.INIT +]; + /* * Internal name used for the I/O buffer control, if any, that we bind to the SerialPort. * @@ -188,7 +272,7 @@ SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) if (keyCode === 0x08 || event.ctrlKey && keyCode >= 0x41 && keyCode <= 0x5A) { if (event.preventDefault) event.preventDefault(); if (keyCode > 0x40) keyCode -= 0x40; - // serial.sendRBR([keyCode]); + serial.sendByteIn(keyCode); } return true; }; @@ -218,10 +302,31 @@ SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) * so that the soft keyboard will activate, but it shouldn't hurt to remove the attribute for all browsers. */ control.removeAttribute("readonly"); - return true; default: + if (sValue) { + /* + * Instead of just having a dedicated "test" control, we now treat any unrecognized control with + * a "value" attribute as a test control. The only caveat is that such controls must have binding IDs + * that do not conflict with predefined controls (which, of course, is the only way you can get here). + */ + this.bindings[sBinding] = control; + /* + * Convert any "backslashed" sequences into the appropriate control characters. + */ + sValue = sValue.replace(/\\n/g, "\n").replace(/\\r/g, "\r"); + control.onclick = function onClickTest(event) { + serial.sDataIn = sValue; + serial.sendDataIn(); + /* + * Give focus back to the machine (since clicking the button takes focus away). + */ + if (serial.cmp) serial.cmp.updateFocus(); + return true; + }; + return true; + } break; } return false; @@ -238,10 +343,11 @@ SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) */ SerialPort.prototype.initBus = function(cmp, bus, cpu, dbg) { + this.cmp = cmp; this.bus = bus; this.cpu = cpu; this.dbg = dbg; - this.chipset = cmp.getMachineComponent("ChipSet"); + this.chipset = /** @type {ChipSet} */ (cmp.getMachineComponent("ChipSet")); bus.addPortInputTable(this, SerialPort.aPortInput, this.portBase); bus.addPortOutputTable(this, SerialPort.aPortOutput, this.portBase); this.setReady(); @@ -330,11 +436,15 @@ SerialPort.prototype.initState = function(data) { var i = 0; if (data === undefined) { - data = [0, 0, 0]; + data = SerialPort.UART8251.INIT; } - this.bData = data[i++]; - this.bCommand = data[i++]; - this.bBaudRate = data[i++]; + this.fReady = data[i++]; + this.bDataIn = data[i++]; + this.bDataOut = data[i++]; + this.bStatus = data[i++]; + this.bMode = data[i++]; + this.bCommand = data[i++]; + this.bBaudRate = data[i]; return true; }; @@ -348,82 +458,46 @@ SerialPort.prototype.saveRegisters = function() { var i = 0; var data = []; - data[i++] = this.bData; + data[i++] = this.fReady; + data[i++] = this.bDataIn; + data[i++] = this.bDataOut; + data[i++] = this.bStatus; + data[i++] = this.bMode; data[i++] = this.bCommand; - data[i++] = this.bBaudRate; + data[i] = this.bBaudRate; return data; }; /** - * inData(port, addrFrom) + * sendByteIn(b) * * @this {SerialPort} - * @param {number} port (0x0) - * @param {number} [addrFrom] (not defined whenever the Debugger tries to read the specified port) - * @return {number} simulated port value + * @param {number} b + * @return {boolean} */ -SerialPort.prototype.inData = function(port, addrFrom) +SerialPort.prototype.sendByteIn = function(b) { - var b = this.bData; - this.printMessageIO(port, null, addrFrom, "DATA", b); - return b; + if (!(this.bStatus & SerialPort.UART8251.STATUS.RECV_FULL)) { + this.bDataIn = b; + this.bStatus |= SerialPort.UART8251.STATUS.RECV_FULL; + this.cpu.requestINTR(this.nIRQ); + return true; + } + return false; }; /** - * inCommand(port, addrFrom) + * sendDataIn() * * @this {SerialPort} - * @param {number} port (0x1) - * @param {number} [addrFrom] (not defined whenever the Debugger tries to read the specified port) - * @return {number} simulated port value */ -SerialPort.prototype.inCommand = function(port, addrFrom) +SerialPort.prototype.sendDataIn = function() { - var b = this.bCommand; - this.printMessageIO(port, null, addrFrom, "COMMAND", b); - return b; -}; - -/** - * outData(port, bOut, addrFrom) - * - * @this {SerialPort} - * @param {number} port (0x0) - * @param {number} bOut - * @param {number} [addrFrom] (not defined whenever the Debugger tries to write the specified port) - */ -SerialPort.prototype.outData = function(port, bOut, addrFrom) -{ - this.printMessageIO(port, bOut, addrFrom, "DATA"); - this.bData = bOut; -}; - -/** - * outCommand(port, bOut, addrFrom) - * - * @this {SerialPort} - * @param {number} port (0x1) - * @param {number} bOut - * @param {number} [addrFrom] (not defined whenever the Debugger tries to write the specified port) - */ -SerialPort.prototype.outCommand = function(port, bOut, addrFrom) -{ - this.printMessageIO(port, bOut, addrFrom, "COMMAND"); - this.bCommand = bOut; -}; - -/** - * outBaudRate(port, bOut, addrFrom) - * - * @this {SerialPort} - * @param {number} port (0x2) - * @param {number} bOut - * @param {number} [addrFrom] (not defined whenever the Debugger tries to write the specified port) - */ -SerialPort.prototype.outBaudRate = function(port, bOut, addrFrom) -{ - this.printMessageIO(port, bOut, addrFrom, "BAUDRATE"); - this.bBaudRate = bOut; + if (this.sDataIn) { + if (this.sendByteIn(this.sDataIn.charCodeAt(0))) { + this.sDataIn = this.sDataIn.substr(1); + } + } }; /** @@ -474,12 +548,99 @@ SerialPort.prototype.echoByte = function(b) return false; }; +/** + * inData(port, addrFrom) + * + * @this {SerialPort} + * @param {number} port (0x0) + * @param {number} [addrFrom] (not defined whenever the Debugger tries to read the specified port) + * @return {number} simulated port value + */ +SerialPort.prototype.inData = function(port, addrFrom) +{ + var b = this.bDataIn; + this.printMessageIO(port, null, addrFrom, "DATA", b); + this.bStatus &= ~SerialPort.UART8251.STATUS.RECV_FULL; + this.sendDataIn(); // if there is still queued incoming data, send another byte + return b; +}; + +/** + * inControl(port, addrFrom) + * + * @this {SerialPort} + * @param {number} port (0x1) + * @param {number} [addrFrom] (not defined whenever the Debugger tries to read the specified port) + * @return {number} simulated port value + */ +SerialPort.prototype.inControl = function(port, addrFrom) +{ + var b = this.bStatus; + this.printMessageIO(port, null, addrFrom, "STATUS", b); + return b; +}; + +/** + * outData(port, bOut, addrFrom) + * + * @this {SerialPort} + * @param {number} port (0x0) + * @param {number} bOut + * @param {number} [addrFrom] (not defined whenever the Debugger tries to write the specified port) + */ +SerialPort.prototype.outData = function(port, bOut, addrFrom) +{ + this.printMessageIO(port, bOut, addrFrom, "DATA"); + this.bDataOut = bOut; +}; + +/** + * outControl(port, bOut, addrFrom) + * + * Writes to the CONTROL port (0x1) are either MODE or COMMAND bytes. If the device has just + * been powered or reset, it is in a "not ready" state and is waiting for a MODE byte. Once it + * has received that initial byte, the device is marked "ready", and all further bytes are + * interpreted as COMMAND bytes (until/unless a COMMAND byte with the INTERNAL_RESET bit is set). + * + * @this {SerialPort} + * @param {number} port (0x1) + * @param {number} bOut + * @param {number} [addrFrom] (not defined whenever the Debugger tries to write the specified port) + */ +SerialPort.prototype.outControl = function(port, bOut, addrFrom) +{ + this.printMessageIO(port, bOut, addrFrom, "CONTROL"); + if (!this.fReady) { + this.bMode = bOut; + this.fReady = true; + } else { + this.bCommand = bOut; + if (this.bCommand & SerialPort.UART8251.COMMAND.INTERNAL_RESET) { + this.fReady = false; + } + } +}; + +/** + * outBaudRate(port, bOut, addrFrom) + * + * @this {SerialPort} + * @param {number} port (0x2) + * @param {number} bOut + * @param {number} [addrFrom] (not defined whenever the Debugger tries to write the specified port) + */ +SerialPort.prototype.outBaudRate = function(port, bOut, addrFrom) +{ + this.printMessageIO(port, bOut, addrFrom, "BAUDRATE"); + this.bBaudRate = bOut; +}; + /* * Port input notification table */ SerialPort.aPortInput = { 0x0: SerialPort.prototype.inData, - 0x1: SerialPort.prototype.inCommand + 0x1: SerialPort.prototype.inControl }; @@ -488,7 +649,7 @@ SerialPort.aPortInput = { */ SerialPort.aPortOutput = { 0x0: SerialPort.prototype.outData, - 0x1: SerialPort.prototype.outCommand, + 0x1: SerialPort.prototype.outControl, 0x2: SerialPort.prototype.outBaudRate }; diff --git a/modules/pc8080/lib/video.js b/modules/pc8080/lib/video.js index db554b905..e9cabed5b 100644 --- a/modules/pc8080/lib/video.js +++ b/modules/pc8080/lib/video.js @@ -152,7 +152,7 @@ function Video(parmsVideo, canvas, context, textarea, container) /* * Now that we've finished using nRowsBuffer to help define the screen size, we add one more - * row for text modes, to simplify smooth-scrolling down the road. + * row for text modes, to account for the VT100's scroll line buffer (used for smooth scrolling). */ if (this.cyCell > 1) this.nRowsBuffer++; @@ -292,6 +292,9 @@ Video.VT100 = { /** * initBuffers() + * + * @this {Video} + * @return {boolean} */ Video.prototype.initBuffers = function() { @@ -308,10 +311,11 @@ Video.prototype.initBuffers = function() cyBuffer = this.cxBuffer; } - this.sizeBuffer = ((this.cxBuffer * this.nBitsPerPixel) >> 3) * this.cyBuffer; + this.sizeBuffer = 0; if (!this.fUseRAM) { + this.sizeBuffer = ((this.cxBuffer * this.nBitsPerPixel) >> 3) * this.cyBuffer; if (!this.bus.addMemory(this.addrBuffer, this.sizeBuffer, Memory.TYPE.VIDEO)) { - return; + return false; } } @@ -319,15 +323,15 @@ Video.prototype.initBuffers = function() * imageBuffer is only used for graphics modes. For text modes, we create a canvas * for each font and draw characters by drawing from the font canvas to the target canvas. */ - if (this.cxCell > 1) { + if (this.sizeBuffer) { + this.imageBuffer = this.contextScreen.createImageData(cxBuffer, cyBuffer); + this.nPixelsPerCell = (16 / this.nBitsPerPixel)|0; + this.initCellCache(this.sizeBuffer >> 1); + } else { /* * We add an extra column per row to store the visible line length at the start of every row. */ this.initCellCache((this.nColsBuffer + 1) * this.nRowsBuffer); - } else { - this.imageBuffer = this.contextScreen.createImageData(cxBuffer, cyBuffer); - this.nPixelsPerCell = (16 / this.nBitsPerPixel)|0; - this.initCellCache(this.sizeBuffer >> 1); } this.canvasBuffer = document.createElement("canvas"); @@ -383,6 +387,7 @@ Video.prototype.initBuffers = function() this.abLineBuffer = new Array(this.nColsBuffer); } + return true; }; /** @@ -410,7 +415,7 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg) * If we have an associated keyboard, then ensure that the keyboard will be notified * whenever the canvas gets focus and receives input. */ - this.kbd = cmp.getMachineComponent("Keyboard"); + this.kbd = /** @type {Keyboard} */ (cmp.getMachineComponent("Keyboard")); if (this.kbd) { for (var s in this.ledBindings) { this.kbd.setBinding("led", s, this.ledBindings[s]); @@ -461,7 +466,8 @@ Video.prototype.doneLoad = function(sURL, sFontData, nErrorCode) * Minimal font data validation, just to make sure we're not getting garbage from the server. */ if (abFontData.length == 2048) { - this.createFonts(abFontData); + this.abFontData = abFontData; + this.createFonts(); } else { this.notice("Unrecognized font data length (" + abFontData.length + ")"); @@ -484,30 +490,33 @@ Video.prototype.doneLoad = function(sURL, sFontData, nErrorCode) }; /** - * createFonts(abFontData) + * createFonts() * * @this {Video} - * @param {Array.} abFontData + * @return {boolean} */ -Video.prototype.createFonts = function(abFontData) +Video.prototype.createFonts = function() { /* * We retain abFontData in case we have to rebuild the fonts (eg, when we switch from 80 to 132 columns) */ - this.abFontData = abFontData; - this.fDotStretcher = (this.nFormat == Video.FORMAT.VT100); - this.aFonts[Video.VT100.FONT.NORML] = [ - this.createFontVariation(this.cxCell, this.cyCell), - this.createFontVariation(this.cxCell, this.cyCell, this.fUnderline) - ]; - this.aFonts[Video.VT100.FONT.DWIDE] = [ - this.createFontVariation(this.cxCell*2, this.cyCell), - this.createFontVariation(this.cxCell*2, this.cyCell, this.fUnderline) - ]; - this.aFonts[Video.VT100.FONT.DHIGH] = this.aFonts[Video.VT100.FONT.DHIGH_BOT] = [ - this.createFontVariation(this.cxCell*2, this.cyCell*2), - this.createFontVariation(this.cxCell*2, this.cyCell*2, this.fUnderline) - ]; + if (this.abFontData) { + this.fDotStretcher = (this.nFormat == Video.FORMAT.VT100); + this.aFonts[Video.VT100.FONT.NORML] = [ + this.createFontVariation(this.cxCell, this.cyCell), + this.createFontVariation(this.cxCell, this.cyCell, this.fUnderline) + ]; + this.aFonts[Video.VT100.FONT.DWIDE] = [ + this.createFontVariation(this.cxCell*2, this.cyCell), + this.createFontVariation(this.cxCell*2, this.cyCell, this.fUnderline) + ]; + this.aFonts[Video.VT100.FONT.DHIGH] = this.aFonts[Video.VT100.FONT.DHIGH_BOT] = [ + this.createFontVariation(this.cxCell*2, this.cyCell*2), + this.createFontVariation(this.cxCell*2, this.cyCell*2, this.fUnderline) + ]; + return true; + } + return false; }; /** @@ -712,6 +721,47 @@ Video.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) return false; }; +/** + * updateDimensions(nCols, nRows) + * + * Called from the ChipSet component whenever the screen dimensions have been dynamically altered. + * + * @this {Video} + * @param {number} nCols (should be either 80 or 132; 80 is the default) + * @param {number} nRows (should be either 24 or 14; 24 is the default) + */ +Video.prototype.updateDimensions = function(nCols, nRows) +{ + this.printMessage("updateDimensions(" + nCols + "," + nRows + ")"); + this.nColsBuffer = nCols; + /* + * Even when the number of effective rows is 14 (or 15 counting the scroll line buffer), we want + * to leave the number of rows at 24 (or 25 counting the scroll line buffer), because the VT100 doesn't + * actually change character height (only character width). + * + * this.nRowsBuffer = nRows+1; // +1 for scroll line buffer + */ + this.cxCell = this.cxCellDefault; + if (nCols > 80) this.cxCell--; // VT100 font cells are 9x10 instead of 10x10 in 132-column mode + if (this.initBuffers()) { + this.createFonts(); + } +}; + +/** + * updateRate(nRate) + * + * Called from the ChipSet component whenever the monitor refresh rate has been dynamically altered. + * + * @this {Video} + * @param {number} nRate (should be either 50 or 60; 60 is the default) + */ +Video.prototype.updateRate = function(nRate) +{ + this.printMessage("updateRate(" + nRate + ")"); + this.rateMonitor = nRate; +}; + /** * doFullScreen() * @@ -796,7 +846,7 @@ Video.prototype.notifyFullScreen = function(fFullScreen) this.canvasScreen.style.width = this.canvasScreen.style.height = ""; } } - this.printMessage("notifyFullScreen(" + fFullScreen + ")", true); + this.printMessage("notifyFullScreen(" + fFullScreen + ")"); }; /** @@ -1057,8 +1107,8 @@ Video.prototype.updateVT100 = function(fForced) if (cUpdated && this.contextBuffer) { /* - * NOTE: We must subtract cyCell from cyBuffer to avoid displaying the extra row that we normally buffer - * in support of smooth-scrolling. + * NOTE: We must subtract cyCell from cyBuffer to avoid displaying the extra "scroll line" that we normally + * buffer to support smooth-scrolling. */ this.contextScreen.drawImage(this.canvasBuffer, 0, 0, this.cxBuffer, this.cyBuffer - this.cyCell, this.xScreenOffset, this.yScreenOffset, this.cxScreenOffset, this.cyScreenOffset); } @@ -1111,9 +1161,10 @@ Video.prototype.updateScreen = function(n) } /* - * Since this is not a forced update, if our cell cache is valid AND the buffer is clean, then do nothing. + * Since this is not a forced update, if our cell cache is valid AND we allocated our own buffer AND the buffer + * is clean, then there's nothing to do. */ - if (fUpdate && this.fCellCacheValid) { + if (fUpdate && this.fCellCacheValid && this.sizeBuffer) { if ((fClean = this.bus.cleanMemory(this.addrBuffer, this.sizeBuffer))) { fUpdate = false; } diff --git a/modules/pcx86/lib/keyboard.js b/modules/pcx86/lib/keyboard.js index 3e6315041..3f5fcba46 100644 --- a/modules/pcx86/lib/keyboard.js +++ b/modules/pcx86/lib/keyboard.js @@ -1220,7 +1220,7 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) if (Keyboard.CLICKCODES[sCode] !== undefined && sHTMLType == "button") { this.bindings[id] = control; control.onclick = function(kbd, sKey, simCode) { - return function onClickKeyboard(event) { + return function onKeyboardBindingClick(event) { if (!COMPILED && kbd.messageEnabled()) kbd.printMessage(sKey + " clicked", Messages.KEYS); if (kbd.cmp) kbd.cmp.updateFocus(); kbd.updateShiftState(simCode, true); // future-proofing if/when any LOCK keys are added to CLICKCODES @@ -1233,12 +1233,12 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) this.cSoftCodes++; this.bindings[id] = control; var fnDown = function(kbd, sKey, simCode) { - return function onMouseOrTouchDownKeyboard(event) { + return function onKeyboardBindingDown(event) { kbd.addActiveKey(simCode); }; }(this, sBinding, Keyboard.SOFTCODES[sBinding]); var fnUp = function (kbd, sKey, simCode) { - return function onMouseOrTouchUpKeyboard(event) { + return function onKeyboardBindingUp(event) { kbd.removeActiveKey(simCode); }; }(this, sBinding, Keyboard.SOFTCODES[sBinding]); @@ -1254,8 +1254,8 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) else if (sValue) { /* * Instead of just having a dedicated "test" control, we now treat any unrecognized control with - * a data value as a test control. The only caveat is that such controls must have binding IDs that - * do not conflict with predefined controls (which, of course, is the only way you can get here). + * a "value" attribute as a test control. The only caveat is that such controls must have binding IDs + * that do not conflict with predefined controls (which, of course, is the only way you can get here). */ this.bindings[id] = control; control.onclick = function onClickTest(event) { diff --git a/versions/pc8080/1.23.3/pc8080-dbg.js b/versions/pc8080/1.23.3/pc8080-dbg.js index 2fd69da0b..6f67e0441 100644 --- a/versions/pc8080/1.23.3/pc8080-dbg.js +++ b/versions/pc8080/1.23.3/pc8080-dbg.js @@ -7,235 +7,238 @@ function oa(a,b,c,d){var e=0,f=null,h=null;if("object"==typeof resources&&(f=res typeof b){var k="",l;for(l in b)b.hasOwnProperty(l)&&(k&&(k+="&"),k+=l+"="+encodeURIComponent(b[l]));k=k.replace(/%20/g,"+");g.open("POST",a,!!c);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.send(k)}else g.open("GET",a,!!c),"bytes"==b&&g.overrideMimeType("text/plain; charset=x-user-defined"),g.send();c||(f=g.responseText,200!=g.status&&(e=g.status||-1),d&&d(a,f,e),h=[f,e]);return h}function pa(){return"http://"+(window?window.location.host:"www.pcjs.org")} function qa(){return window?window.navigator.userAgent:""}function u(a){window&&window.alert(a)}function ra(a){var b=!1;window&&(b=window.confirm(a));return b}var sa=null;function ta(){if(null==sa){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}sa=a}return sa} function ua(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}function va(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function wa(a){if(window){var b=qa();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 xa(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0=this.J?10:20>=this.J?12:24>=this.J?14:15;this.Ea=1<>2;this.A=this.Ea-1;this.M=this.O/this.Ea|0;this.K=this.M-1;this.u=[];this.w=[];this.I=this.G=!1;this.Z=[];this.ba=[];a=new E;tb(a,this.H);this.W=Array(this.M);for(b=0;b>>a.na;0f&&(l=f);if(g&&g.size){if(g.type==d){if(e+f<=g.F)return g.Fb+=g.F-e,g.F=e,!0;if(e>=g.F+g.Fb){l=g.size-(e-k);l>f&&(l=f);g.Fb=e-g.F+l;e=k+a.Ea;f-=l;h++;continue}}return vb(1,e,f)}e=new E(e,l,a.Ea,d);tb(e,a.H,g);a.W[h++]=e;e=k+a.Ea;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+wb[d]+" at "+t(b)),!0):vb(2,b,c)}m.Y=function(a){return this.W[(a&this.C)>>>this.na].qb(a&this.A,a)}; -function xb(a,b){return a.W[(b&a.C)>>>a.na].Db(b&a.A,b)}m.Qa=function(a){var b=a&this.A,c=(a&this.C)>>>this.na;return b!=this.A?this.W[c].Bc(b,a):this.W[c++].qb(b,a)|this.W[c&this.K].qb(0,a+1)<<8};function yb(a,b){var c=b&a.A,d=(b&a.C)>>>a.na;return c!=a.A?a.W[d].ac(c,b):a.W[d++].Db(c,b)|a.W[d&a.K].Db(0,b+1)<<8}m.ra=function(a,b){this.W[(a&this.C)>>>this.na].sb(a&this.A,b&255,a)};function zb(a,b,c){a.W[(b&a.C)>>>a.na].Gb(b&a.A,c&255,b)} -m.Rb=function(a,b){var c=a&this.A,d=(a&this.C)>>>this.na;c!=this.A?this.W[d].Dc(c,b&65535,a):(this.W[d++].sb(c,b&255,a),this.W[d&this.K].sb(0,b>>8&255,a+1))};function Ab(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 Bb(a,b,c,d){void 0===d&&(d=0);if(c)for(var e in c){var f=a,h=+e+d,g=c[e].bind(b);if(void 0!==g)for(var k=+e+d;k<=h;k++)void 0!==f.u[k]?u("Input port "+t(k)+" already registered"):f.u[k]=[g,!1]}} -function Cb(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.H&&a.G!=h[1]&&Hb(a.H,b,k)}else a.H&&(eb(a.H,a,b,k,d),a.G&&Hb(a.H,b,k));f+=g<<3;b+=g;e-=g}} +0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1];function pb(a){x.call(this,"Panel",a,pb)}Za(pb);m=pb.prototype;m.la=function(a,b,c,d){return this.A&&this.A.la(a,b,c,d)||this.b&&this.b.la(a,b,c,d)||this.M&&this.M.la(a,b,c,d)||this.H&&this.H.la(a,b,c,d)?!0:this.parent.la.call(this,a,b,c,d)};m.Oa=function(a,b,c,d){this.A=a;this.w=b;this.b=c;this.H=d;this.M=qb(a,"Keyboard")};m.Ea=function(a,b){b||rb();return!0};m.Ha=function(){return!0};m.Ia=function(){}; +function rb(){for(var a=!1,b=B(document,"pc8080","panel"),c=0;c=this.J?10:20>=this.J?12:24>=this.J?14:15;this.Ga=1<>2;this.w=this.Ga-1;this.M=this.N/this.Ga|0;this.K=this.M-1;this.A=[];this.u=[];this.I=this.F=!1;this.R=[];this.aa=[];a=new E;tb(a,this.H);this.X=Array(this.M);for(b=0;b>>a.pa;0f&&(l=f);if(g&&g.size){if(g.type==d){if(e+f<=g.G)return g.Hb+=g.G-e,g.G=e,!0;if(e>=g.G+g.Hb){l=g.size-(e-k);l>f&&(l=f);g.Hb=e-g.G+l;e=k+a.Ga;f-=l;h++;continue}}return vb(1,e,f)}e=new E(e,l,a.Ga,d);tb(e,a.H,g);a.X[h++]=e;e=k+a.Ga;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+wb[d]+" at "+t(b)),!0):vb(2,b,c)}m.Z=function(a){return this.X[(a&this.B)>>>this.pa].sb(a&this.w,a)}; +function xb(a,b){return a.X[(b&a.B)>>>a.pa].Gb(b&a.w,b)}m.Sa=function(a){var b=a&this.w,c=(a&this.B)>>>this.pa;return b!=this.w?this.X[c].Hc(b,a):this.X[c++].sb(b,a)|this.X[c&this.K].sb(0,a+1)<<8};function yb(a,b){var c=b&a.w,d=(b&a.B)>>>a.pa;return c!=a.w?a.X[d].bc(c,b):a.X[d++].Gb(c,b)|a.X[d&a.K].Gb(0,b+1)<<8}m.ra=function(a,b){this.X[(a&this.B)>>>this.pa].ub(a&this.w,b&255,a)};function zb(a,b,c){a.X[(b&a.B)>>>a.pa].Ib(b&a.w,c&255,b)} +m.Tb=function(a,b){var c=a&this.w,d=(a&this.B)>>>this.pa;c!=this.w?this.X[d].Jc(c,b&65535,a):(this.X[d++].ub(c,b&255,a),this.X[d&this.K].ub(0,b>>8&255,a+1))};function Ab(a,b){if(void 0===b)return a.I=!a.I,a.I;void 0===a.A[b]&&(a.A[b]=[null,!1]);a.A[b][1]=!a.A[b][1];return a.A[b][1]}function Bb(a,b,c,d){void 0===d&&(d=0);if(c)for(var e in c){var f=a,h=+e+d,g=c[e].bind(b);if(void 0!==g)for(var k=+e+d;k<=h;k++)void 0!==f.A[k]?u("Input port "+t(k)+" already registered"):f.A[k]=[g,!1]}} +function Cb(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.H&&a.F!=h[1]&&Hb(a.H,b,k)}else a.H&&(eb(a.H,a,b,k,d),a.F&&Hb(a.H,b,k));f+=g<<3;b+=g;e-=g}} function vb(a,b,c){u("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Ib;if(nb){var Jb=new ArrayBuffer(2);(new DataView(Jb)).setUint16(0,256,!0);Ib=256===(new Uint16Array(Jb))[0]}else Ib=!1;var Sb=Ib; -function E(a,b,c,d){this.id=Tb+=2;this.b=null;this.F=a;this.Fb=b;this.size=c||0;this.type=d||Ub;this.L=d==Vb;tb(this);this.La=this.mc=!1;if(c)if(nb)this.I=new ArrayBuffer(c),this.G=new DataView(this.I,0,c),this.A=new Uint8Array(this.I,0,c),this.K=new Uint16Array(this.I,0,c>>1),this.b=new Int32Array(this.I,0,c>>2),Wb(this,Sb?Xb:Yb);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},da:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ma: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},Ba: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.La=!0},Z:function(a,b){if(this.H&&null!=this.F){var c=this.H;cc(c,this.F+a,1,c.Z)&&c.la(!0)}return this.Db(a,b)},fa:function(a,b){if(this.H&&null!=this.F){var c=this.H;cc(c,this.F+a,2,c.Z)&&c.la(!0)}return this.ac(a,b)},va:function(a,b,c){if(this.H&&null!=this.F){var d=this.H;cc(d,this.F+a,1,d.G)&&d.la(!0)}this.L?this.C(a,b,c):this.Gb(a,b,c)},Ja:function(a, -b,c){if(this.H&&null!=this.F){var d=this.H;cc(d,this.F+a,2,d.G)&&d.la(!0)}this.L?this.C(a,b,c):this.cc(a,b,c)},P:function(a){return this.A[a]},ba:function(a){return this.A[a]},ea:function(a){return this.G.getUint16(a,!0)},ha:function(a){return a&1?this.A[a]|this.A[a+1]<<8:this.K[a>>1]},oa:function(a,b){this.A[a]=b;this.La=!0},wa:function(a,b){this.A[a]=b;this.La=!0},Ca:function(a,b){this.G.setUint16(a,b,!0);this.La=!0},Ka:function(a,b){a&1?(this.A[a]=b,this.A[a+1]=b>>8):this.K[a>>1]=b;this.La=!0}}; -function tb(a,b,c){a.H=b;a.u=a.w=0;c&&((a.u=c.u)&&bc(a,ac,!1),(a.w=c.w)&&$b(a,ac,!1))}function dc(a,b){b?0===--a.w&&(a.sb=a.L?a.C:a.Gb,a.Dc=a.L?a.J:a.cc):0===--a.u&&(a.qb=a.Db,a.Bc=a.ac)}function $b(a,b,c){c&&a.w||(a.sb=!a.L&&b[2]||a.C,a.Dc=!a.L&&b[3]||a.J);if(c||void 0===c)a.Gb=b[2]||a.C,a.cc=b[3]||a.J}function bc(a,b,c){c&&a.u||(a.qb=b[0]||a.M,a.Bc=b[1]||a.O);if(c||void 0===c)a.Db=b[0]||a.M,a.ac=b[1]||a.O}function Wb(a,b){b||(b=ec);bc(a,b,void 0);$b(a,b,void 0)} -var ec=[],Zb=[E.prototype.da,E.prototype.ma,E.prototype.Ba,E.prototype.ab],ac=[E.prototype.Z,E.prototype.fa,E.prototype.va,E.prototype.Ja];if(nb)var Yb=[E.prototype.P,E.prototype.ea,E.prototype.oa,E.prototype.Ca],Xb=[E.prototype.ba,E.prototype.ha,E.prototype.wa,E.prototype.Ka]; -function fc(a,b){x.call(this,"CPU",a,fc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.pb=c;this.i.Ob=0;this.i.Za=d;this.i.Xb=Math.round(this.i.pb/1E4)/100;this.i.Xa=this.i.Xb*this.i.Za;this.D.xa=!1;this.D.Vb=!1;this.D.lc=a.autoStart;this.D.nc=!1;this.D.hb=!1;this.i.xb=this.i.mb=0;this.i.yb=a.csStart;this.i.lb=a.csInterval;this.i.nb=a.csStop;this.ba=this.$a.bind(this);D(this)}Za(fc);var gc=["power","reset"];m=fc.prototype; -m.Na=function(a,b,c,d){this.u=a;this.A=b;this.H=d;for(b=0;b=a.i.mb&&(a.i.mb+=a.i.lb,c=!0);0<=a.i.nb&&a.i.nb<=Ac(a)&&(a.i.lb=a.i.nb=-1,jc(a),a.la(),c=!0);c&&a.g(Ac(a)+" cycles: checksum="+n(a.i.xb))}} -m.ka=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.L[b]=c;a=!0;break;case "run":this.L[b]=c;c.onclick=function(){var a;if(a=d.u)if(a=d.u,a.D.sa)a=!0;else{var b=null,c,g=bb(a.id);for(c=0;cc&&(c=2);var d=1;b&&1a.i.Wa/a.i.Xa?b=1:d=!0;a.i.Za=b;b=a.i.Xb*a.i.Za;if(a.i.Xa!=b){a.i.Xa=b;b=a.i.Xa.toFixed(2)+"Mhz";var e=a.L.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.u&&a.u.Eb()}Cc(a,a.G);a.G=0;a.i.kb=la();a.i.Ya=0;Dc(a);return d} -m.$a=function(a){if(hb(this,!0)){if(!this.D.xa){Bc(this);this.u&&this.u.start(this.i.kb,Ac(this));this.D.xa=!0;this.D.Vb=!0;this.I&&this.I.start();var b=this.L.run;b&&(b.textContent="Halt");this.u&&(this.u.Ga(!0),a&&this.u.Eb(!0))}this.i.$b>=this.i.pb&&Dc(this,!0);this.i.Bb=0;this.i.Nb=la();this.i.Ya&&(a=this.i.Nb-this.i.Ya,a>this.i.uc&&(this.i.kb+=a,this.i.kb>this.i.Nb&&(this.i.kb=this.i.Nb)));try{do{this.rb(this.D.hb?1:this.i.sd);var c=this.C-this.b;this.G+=c;this.i.Bb+=c;Cc(this,0,!0);nc(this, -c);this.i.Ab-=c;0>=this.i.Ab&&(this.i.Ab+=this.i.wc,this.u&&Ec(this.u,this.i.Ob++),this.i.Ob>this.M&&(this.i.Ob=0));this.i.zb-=c;0>=this.i.zb&&(this.i.zb+=this.i.vc,this.u&&this.u.Ga());this.i.ob-=c;if(0>=this.i.ob){this.i.ob+=this.i.Zb;break}}while(this.D.xa)}catch(e){this.la();lc(this);this.u&&this.u.stop(la(),Ac(this));hb(this,!1);kb(this,e.stack||e.message);return}c=setTimeout;a=this.ba;this.i.Ya=la();b=this.i.uc;this.i.Bb&&(b=Math.round(b*this.i.Bb/this.i.Zb));var b=b-(this.i.Ya-this.i.Nb),d= -this.i.Ya-this.i.kb;d&&(this.i.Wa=Math.round(this.G/(10*d))/100,864E5<=d&&(this.J=0,Bc(this)));if(0>b||this.i.Wa>8&255;a.S=b&255}function Oc(a){return a.T<<8|a.U}function Pc(a,b){a.T=b>>8&255;a.U=b&255}function K(a){return a.V<<8|a.X} -function Qc(a,b){a.V=b>>8&255;a.X=b&255}function F(a,b){a.N=b&65535}function Rc(a){return a.aa&256?1:0}function Sc(a,b){a.aa=a.aa&255|b}function Tc(a){return ob[a.ca&255]?4:0}function Uc(a){return(a.ca^a.ua)&16?16:0}function Vc(a){return a.aa&255?0:64}function Wc(a){return a.ca&128?128:0}function Lc(a){return a.ta&-214|Wc(a)|Vc(a)|Uc(a)|Tc(a)|Rc(a)}function Jc(a,b){a.aa=a.ca=a.ua=0;b&1&&(a.aa|=256);b&4||(a.ca|=1);b&16&&(a.ua|=16);b&64||(a.aa|=255);b&128&&(a.ca^=192);a.ta=a.ta&-726|b&512|2} -function Xc(a,b){a.ua=a.j^b;return a.ca=(a.aa=a.j+b)&255}function Yc(a,b){a.ua=a.j^b;return a.ca=(a.aa=a.j+b+(a.aa&256?1:0))&255}function Zc(a,b){a.aa=a.ca=a.ua=a.j&b;(a.j|b)&8&&(a.ua^=16);return a.aa}function $c(a,b){a.ua=b^255;b=a.ca=b+255&255;a.aa=a.aa&-256|b;return b}function ad(a,b){a.ua=b;b=a.ca=b+1&255;a.aa=a.aa&-256|b;return b}function bd(a,b){return a.ca=a.aa=a.ua=a.j|b}function L(a,b){b^=255;a.ua=a.j^b;return a.ca=(a.aa=a.j+b+1^256)&255} -function cd(a,b){b^=255;a.ua=a.j^b;return a.ca=(a.aa=a.j+b+(a.aa&256?0:1)^256)&255}function dd(a,b){return a.ca=a.aa=a.ua=a.j^b}m.Y=function(a){return this.A.Y(a)};m.ra=function(a,b){this.A.ra(a,b)};function M(a){var b=a.Y(a.N);F(a,a.N+1);return b}function N(a){var b=a.A.Qa(a.N);F(a,a.N+2);return b}function P(a){var b=a.A.Qa(a.ja);a.ja=a.ja+2&65535;return b}function Q(a,b){a.ja=a.ja-2&65535;a.A.Rb(a.ja,b)}function ed(a,b){a.w=a.w&-8|b|8} -function S(a,b,c,d){d=d||2;a.L[b]&&(void 0===c&&(kb(a,"Value for "+b+" is invalid"),a.la()),c=!a.D.xa||a.D.nc?n(c,d):"--------".substr(0,d),a.L[b].textContent!=c&&(a.L[b].textContent=c))} -m.Ga=function(a){this.Z&&(a||!this.D.xa||this.D.nc)&&(S(this,"A",this.j),S(this,"B",this.R),S(this,"C",this.S),S(this,"BC",Mc(this),4),S(this,"D",this.T),S(this,"E",this.U),S(this,"DE",Oc(this),4),S(this,"H",this.V),S(this,"L",this.X),S(this,"HL",K(this),4),S(this,"SP",this.ja,4),S(this,"PC",this.N,4),a=Lc(this),S(this,"PS",a,4),S(this,"IF",a&512?1:0,1),S(this,"SF",a&128?1:0,1),S(this,"ZF",a&64?1:0,1),S(this,"AF",a&16?1:0,1),S(this,"PF",a&4?1:0,1),S(this,"CF",a&1?1:0,1));if(a=this.L.speed)a.textContent= -this.D.xa&&this.i.Wa?this.i.Wa.toFixed(2)+"Mhz":"Stopped"};m.rb=function(a){this.D.Jb=!0;var b=this.D.hd=this.H&&yd(this.H),c=a?this.D.Vb?0:1:-1;this.D.Vb=!1;this.C=this.b=a;do{if(this.w){if(a&&this.w&8&&this.ta&512){var d=199|(this.w&7)<<3;this.w&=-17;this.w&=-16;this.ta&=-513;this.O[d].call(this)}if(this.w&16){this.b=0;break}}if(b){if(zd(this.H,this.N,c)){this.la();break}c=1}this.O[M(this)].call(this)}while(0>8;Sc(this,a&256);this.b-=4},Ad,function(){var a;Qc(this,a=K(this)+Mc(this));Sc(this,a>>8&256);this.b-=10},function(){this.j=this.Y(Mc(this));this.b-=7},function(){Nc(this,Mc(this)-1);this.b-= -5},function(){this.S=ad(this,this.S);this.b-=5},function(){this.S=$c(this,this.S);this.b-=5},function(){this.S=M(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;Sc(this,a);this.b-=4},Ad,function(){Pc(this,N(this));this.b-=10},function(){this.ra(Oc(this),this.j);this.b-=7},function(){Pc(this,Oc(this)+1);this.b-=5},function(){this.T=ad(this,this.T);this.b-=5},function(){this.T=$c(this,this.T);this.b-=5},function(){this.T=M(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255| -Rc(this);Sc(this,a&256);this.b-=4},Ad,function(){var a;Qc(this,a=K(this)+Oc(this));Sc(this,a>>8&256);this.b-=10},function(){this.j=this.Y(Oc(this));this.b-=7},function(){Pc(this,Oc(this)-1);this.b-=5},function(){this.U=ad(this,this.U);this.b-=5},function(){this.U=$c(this,this.U);this.b-=5},function(){this.U=M(this);this.b-=7},function(){var a=this.j<<8;this.j=(Rc(this)<<8|this.j)>>1;Sc(this,a&256);this.b-=4},Ad,function(){Qc(this,N(this));this.b-=10},function(){var a=N(this);this.A.Rb(a,K(this)); -this.b-=16},function(){Qc(this,K(this)+1);this.b-=5},function(){this.V=ad(this,this.V);this.b-=5},function(){this.V=$c(this,this.V);this.b-=5},function(){this.V=M(this);this.b-=7},function(){var a=0,b=Rc(this);if(Uc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=Xc(this,a);Sc(this,b?256:0);this.b-=4},Ad,function(){var a;Qc(this,a=K(this)+K(this));Sc(this,a>>8&256);this.b-=10},function(){var a;a=N(this);a=this.A.Qa(a);Qc(this,a);this.b-=16},function(){Qc(this,K(this)-1);this.b-=5},function(){this.X= -ad(this,this.X);this.b-=5},function(){this.X=$c(this,this.X);this.b-=5},function(){this.X=M(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},Ad,function(){this.ja=N(this)&65535;this.b-=10},function(){this.ra(N(this),this.j);this.b-=13},function(){this.ja=this.ja+1&65535;this.b-=5},function(){var a=K(this);this.ra(a,ad(this,this.Y(a)));this.b-=10},function(){var a=K(this);this.ra(a,$c(this,this.Y(a)));this.b-=10},function(){this.ra(K(this),M(this));this.b-=10},function(){this.aa|=256;this.b-= -4},Ad,function(){var a;Qc(this,a=K(this)+this.ja);Sc(this,a>>8&256);this.b-=10},function(){this.j=this.Y(N(this));this.b-=13},function(){this.ja=this.ja-1&65535;this.b-=5},function(){this.j=ad(this,this.j);this.b-=5},function(){this.j=$c(this,this.j);this.b-=5},function(){this.j=M(this);this.b-=7},function(){Sc(this,Rc(this)?0:256);this.b-=4},function(){this.b-=5},function(){this.R=this.S;this.b-=5},function(){this.R=this.T;this.b-=5},function(){this.R=this.U;this.b-=5},function(){this.R=this.V;this.b-= -5},function(){this.R=this.X;this.b-=5},function(){this.R=this.Y(K(this));this.b-=7},function(){this.R=this.j;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.U;this.b-=5},function(){this.S=this.V;this.b-=5},function(){this.S=this.X;this.b-=5},function(){this.S=this.Y(K(this));this.b-=7},function(){this.S=this.j;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.U;this.b-=5},function(){this.T=this.V;this.b-=5},function(){this.T=this.X;this.b-=5},function(){this.T=this.Y(K(this));this.b-=7},function(){this.T=this.j;this.b-=5},function(){this.U=this.R;this.b-=5},function(){this.U=this.S;this.b-=5},function(){this.U=this.T;this.b-=5},function(){this.b-=5},function(){this.U=this.V;this.b-=5},function(){this.U=this.X;this.b-=5},function(){this.U=this.Y(K(this));this.b-=7},function(){this.U=this.j;this.b-=5},function(){this.V=this.R;this.b-=5},function(){this.V= -this.S;this.b-=5},function(){this.V=this.T;this.b-=5},function(){this.V=this.U;this.b-=5},function(){this.b-=5},function(){this.V=this.X;this.b-=5},function(){this.V=this.Y(K(this));this.b-=7},function(){this.V=this.j;this.b-=5},function(){this.X=this.R;this.b-=5},function(){this.X=this.S;this.b-=5},function(){this.X=this.T;this.b-=5},function(){this.X=this.U;this.b-=5},function(){this.X=this.V;this.b-=5},function(){this.b-=5},function(){this.X=this.Y(K(this));this.b-=7},function(){this.X=this.j; -this.b-=5},function(){this.ra(K(this),this.R);this.b-=7},function(){this.ra(K(this),this.S);this.b-=7},function(){this.ra(K(this),this.T);this.b-=7},function(){this.ra(K(this),this.U);this.b-=7},function(){this.ra(K(this),this.V);this.b-=7},function(){this.ra(K(this),this.X);this.b-=7},function(){var a=this.N-1;if(this.K.length)for(var b=0;b>8;this.b-=10},function(){var a=N(this);Wc(this)||F(this,a);this.b-=10},function(){this.ta&=-513;this.b-=4},function(){var a=N(this);Wc(this)||(Q(this,this.N),F(this,a),this.b-=6);this.b-=11},function(){Q(this,Lc(this)&255|this.j<<8);this.b-=11},function(){this.j=bd(this,M(this));this.b-=7},function(){Q(this,this.N);F(this,48);this.b-=11},function(){Wc(this)&&(F(this,P(this)), -this.b-=6);this.b-=5},function(){this.ja=K(this)&65535;this.b-=5},function(){var a=N(this);Wc(this)&&F(this,a);this.b-=10},function(){this.ta|=512;this.b-=4},function(){var a=N(this);Wc(this)&&(Q(this,this.N),F(this,a),this.b-=6);this.b-=11},Dd,function(){L(this,M(this));this.b-=7},function(){Q(this,this.N);F(this,56);this.b-=11}]; -function T(a){x.call(this,"ChipSet",a,T,32768);var b=a.model;b&&!Ed[b]&&Ka("Unrecognized ChipSet model: "+b);this.C=Ed[b]||{};a.sound&&(this.da=null,window&&(this.da=window.AudioContext||window.webkitAudioContext),this.da&&new this.da);D(this)}Za(T); -var U={ya:1978.1,cd:{za:0,Qd:1,Ud:16,ae:32,je:64,ie:128,tb:14},Sa:{za:1,Ic:1,Yc:2,Uc:4,Vc:16,Wc:32,Xc:64,tb:8},dd:{za:2,Pd:3,qe:4,Rd:8,ee:16,fe:32,ge:64,Sd:128,tb:0},me:{za:3},ke:{za:2,be:7},oe:{za:3,re:1,ne:2,he:4,Zd:8,Td:16,Nd:32},le:{za:4},pe:{za:5,Vd:1,Wd:2,Xd:4,Yd:8,se:16}},V={ya:100,Pa:{za:66,te:1,Sc:2,Tc:4,de:8,ce:16,ic:32,hc:64,ec:128},Hc:{za:66,INIT:0},Ha:{$d:{za:98},Ra:{Fc:0,Ec:1,$c:2,ed:4,Lc:5,Zc:6,ad:7},Hb:16383},Kc:{za:162,INIT:0},Jc:{za:194,INIT:0}},Ed={SI1978:U,VT100:V}; -T.prototype.ka=function(){return!1};T.prototype.Na=function(a,b,c,d){this.A=b;this.b=c;this.H=d;this.u=a;this.M=qb(a,"Keyboard");Bb(b,this,this.C.Pb);Fb(b,this,this.C.Qb)};T.prototype.Aa=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};T.prototype.Fa=function(a){return a?this.save():!0};U.INIT=[[U.cd.tb,U.Sa.tb,U.dd.tb,0,0,0,0]]; -V.INIT=[[V.Hc.INIT,V.Pa.Sc|V.Pa.Tc,V.Kc.INIT,V.Jc.INIT],[0,0,0,0,[11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11776,11784,11918,11776,11856,11824,11840,11808,11776,12E3,12E3,11857,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]];m=T.prototype; -m.reset=function(){this.C.INIT&&!this.restore(this.C.INIT)&&this.ga("reset error")};m.save=function(){var a=new G(this);switch(this.C.ya){case U.ya:H(a,0,[this.va,this.I,this.wa,this.P,this.ba,this.ma,this.oa]);break;case V.ya:H(a,0,[this.ea,this.J,this.ha,this.fa]),H(a,1,[this.O,this.w,this.K,this.Z,this.G])}return a.data()}; -m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.C.ya){case U.ya:return this.va=b[0],this.I=b[1],this.wa=b[2],this.P=b[3],this.ba=b[4],this.ma=b[5],this.oa=b[6],!0;case V.ya:return this.ea=b[0],this.J=b[1],this.ha=b[2],this.fa=b[3],b=a[1],this.O=b[0],this.w=b[1],this.K=b[2],this.Z=b[3],this.G=b[4],!0}return!1};m.start=function(){};m.stop=function(){};m.md=function(a,b){var c=this.va;C(this,a,null,b,"STATUS0",c,!0);return c}; -m.nd=function(a,b){var c=this.I;C(this,a,null,b,"STATUS1",c,!0);return c};m.od=function(a,b){var c=this.wa;C(this,a,null,b,"STATUS2",c,!0);return c};m.ld=function(a,b){var c=this.P>>8-this.ba&255;C(this,a,null,b,"SHIFT.RESULT",c,!0);return c};m.wd=function(a,b,c){C(this,a,b,c,"SHIFT.COUNT",null,!0);this.ba=b};m.yd=function(a,b,c){C(this,a,b,c,"SOUND1",null,!0);this.ma=b};m.xd=function(a,b,c){C(this,a,b,c,"SHIFT.DATA",null,!0);this.P=b<<8|this.P>>8}; -m.zd=function(a,b,c){C(this,a,b,c,"SOUND2",null,!0);this.oa=b};m.Ad=function(a,b,c){C(this,a,b,c,"WATCHDOG",null,!0)};function Fd(a){var b=0,c=0,d=~a.O;for(a=0;10>a;a++)d&1&&(b=9-a),d>>=1;for(a=0;10>a;a++)d&1&&(c=9-a),d>>=1;return 10*b+c} -m.pd=function(a,b){var c=this.J,c=c&~V.Pa.hc;if((Ac(this.b)&64)<<1&&(c|=V.Pa.hc,c!=this.J)){var d,e;d=this.K&1;e=this.K>>1&7;switch(e){case V.Ha.Ra.ad:break;case V.Ha.Ra.Ec:this.O=this.O<<1|d;break;case V.Ha.Ra.Lc:d=Fd(this);this.G[d]=V.Ha.Hb;fb(this,"doNVRCommand(): erase data at addr "+t(d));break;case V.Ha.Ra.Fc:this.w=this.w<<1|d;break;case V.Ha.Ra.ed:d=Fd(this);e=this.w&V.Ha.Hb;this.G[d]=e;fb(this,"doNVRCommand(): write data "+t(e)+" to addr "+t(d));break;case V.Ha.Ra.Zc:d=Fd(this);e=this.G[d]; -null==e&&(e=V.Ha.Hb);this.w=e;fb(this,"doNVRCommand(): read data "+t(e)+" from addr "+t(d));break;case V.Ha.Ra.$c:this.w<<=1;this.Z=this.w&V.Ha.Hb+1;break;default:fb(this,"doNVRCommand(): unrecognized command 0x"+n(e,2))}}c&=~V.Pa.ic;this.Z&&(c|=V.Pa.ic);c&=~V.Pa.ec;this.M&&(c|=V.Pa.ec);this.J=c;C(this,a,null,b,"FLAGS.BUFFER",c);return c};m.Bd=function(a,b,c){C(this,a,b,c,"BRIGHTNESS");this.ea=b};m.Ed=function(a,b,c){C(this,a,b,c,"NVR.LATCH");this.K=b}; -m.Dd=function(a,b,c){C(this,a,b,c,"DC012");this.ha=b};m.Cd=function(a,b,c){C(this,a,b,c,"DC011");this.fa=b};U.Pb={0:T.prototype.md,1:T.prototype.nd,2:T.prototype.od,3:T.prototype.ld};U.Qb={2:T.prototype.wd,3:T.prototype.yd,4:T.prototype.xd,5:T.prototype.zd,6:T.prototype.Ad};V.Pb={66:T.prototype.pd};V.Qb={66:T.prototype.Bd,98:T.prototype.Ed,162:T.prototype.Dd,194:T.prototype.Cd};Ia(function(){for(var a=B(document,"pc8080","chipset"),b=0;b>>0,h],q=ka(p,k,a.Ua);0>q&&p.splice(-(q+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.J.push({ue:b,F:c,rd:d,Oa:e,jc:f})}delete this.Oa}return!0};Gd.prototype.Fa=function(){return!0}; -function Hd(a,b,c,d){if(d)a.ga("Unable to load system ROM (error "+d+": "+b+")");else{ab(a.Tb,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.Oa=e.symbols;if(!a.u.length){u("Empty ROM: "+b);return}if(1==a.u.length){u(a.u[0]);return}}catch(g){a.ga("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm, -" ").replace(/ +$/,"").split(" "),a.u=Array(b.length),e=0;e>>f.na;0>>=f.na;0d?a.u.push({bc:b,Yb:Date.now(),Ib:!1}):(a.u[d].Yb=Date.now(),a.u[d].Ib=!1);else if(0<=d){if(!a.u[d].Ib){var e=a.u[d].Yb;if(e&&100>Date.now()-e)return a.u[d].Ib=!0,Td(a),!0}a.u.splice(d,1)}if(a.I){d=0;switch(b){case "1p":d=U.Sa.Uc;break;case "2p":d=U.Sa.Yc;break;case "coin":d=U.Sa.Ic;break;case "left":d=U.Sa.Wc;break;case "right":d=U.Sa.Xc;break;case "fire":d=U.Sa.Vc}d&&(a=a.I,b=d,a.I&=~b,c&&(a.I|=b))}return!0} -function Td(a){for(var b=0,c=-1;bc||c>e)c=e}else{Rd(a,d,!1);b=0;continue}}b++}0<=c&&setTimeout(function(){Td(a)},c)}m.qd=function(a,b){var c=this.C;0<=this.w&&(this.w>3)*this.da;if(this.Jd||ub(this.A,this.va,this.Ua,3))1>1)),this.O=document.createElement("canvas"),this.O.width=b,this.O.height=c,this.cb=this.O.getContext("2d"),this.ma={},this.Ca=1<=a.Gd?8:16,f=8>(7>1),this.b=new Int32Array(this.I,0,c>>2),Wb(this,Sb?Xb:Yb);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},da:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ha:function(a){var b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8},ya:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<>8);this.Ma=!0},R:function(a,b){if(this.H&&null!=this.G){var c=this.H;cc(c,this.G+a,1,c.R)&&c.ma(!0)}return this.Gb(a,b)},fa:function(a,b){if(this.H&&null!=this.G){var c=this.H;cc(c,this.G+a,2,c.R)&&c.ma(!0)}return this.bc(a,b)},va:function(a,b,c){if(this.H&&null!=this.G){var d=this.H;cc(d,this.G+a,1,d.F)&&d.ma(!0)}this.A?this.B(a,b,c):this.Ib(a,b,c)},Ca:function(a, +b,c){if(this.H&&null!=this.G){var d=this.H;cc(d,this.G+a,2,d.F)&&d.ma(!0)}this.A?this.B(a,b,c):this.dc(a,b,c)},O:function(a){return this.w[a]},aa:function(a){return this.w[a]},ea:function(a){return this.F.getUint16(a,!0)},ga:function(a){return a&1?this.w[a]|this.w[a+1]<<8:this.K[a>>1]},na:function(a,b){this.w[a]=b;this.Ma=!0},wa:function(a,b){this.w[a]=b;this.Ma=!0},za:function(a,b){this.F.setUint16(a,b,!0);this.Ma=!0},Da:function(a,b){a&1?(this.w[a]=b,this.w[a+1]=b>>8):this.K[a>>1]=b;this.Ma=!0}}; +function tb(a,b,c){a.H=b;a.L=a.u=0;c&&((a.L=c.L)&&bc(a,ac,!1),(a.u=c.u)&&$b(a,ac,!1))}function dc(a,b){b?0===--a.u&&(a.ub=a.A?a.B:a.Ib,a.Jc=a.A?a.J:a.dc):0===--a.L&&(a.sb=a.Gb,a.Hc=a.bc)}function $b(a,b,c){c&&a.u||(a.ub=!a.A&&b[2]||a.B,a.Jc=!a.A&&b[3]||a.J);if(c||void 0===c)a.Ib=b[2]||a.B,a.dc=b[3]||a.J}function bc(a,b,c){c&&a.L||(a.sb=b[0]||a.M,a.Hc=b[1]||a.N);if(c||void 0===c)a.Gb=b[0]||a.M,a.bc=b[1]||a.N}function Wb(a,b){b||(b=ec);bc(a,b,void 0);$b(a,b,void 0)} +var ec=[],Zb=[E.prototype.da,E.prototype.ha,E.prototype.ya,E.prototype.Qa],ac=[E.prototype.R,E.prototype.fa,E.prototype.va,E.prototype.Ca];if(nb)var Yb=[E.prototype.O,E.prototype.ea,E.prototype.na,E.prototype.za],Xb=[E.prototype.aa,E.prototype.ga,E.prototype.wa,E.prototype.Da]; +function fc(a,b){x.call(this,"CPU",a,fc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.rb=c;this.i.Qb=0;this.i.cb=d;this.i.Yb=Math.round(this.i.rb/1E4)/100;this.i.ab=this.i.Yb*this.i.cb;this.D.xa=!1;this.D.Xb=!1;this.D.pc=a.autoStart;this.D.rc=!1;this.D.kb=!1;this.i.Ab=this.i.ob=0;this.i.Bb=a.csStart;this.i.nb=a.csInterval;this.i.pb=a.csStop;this.aa=this.eb.bind(this);D(this)}Za(fc);var gc=["power","reset"];m=fc.prototype; +m.Oa=function(a,b,c,d){this.A=a;this.w=b;this.H=d;for(b=0;b=a.i.ob&&(a.i.ob+=a.i.nb,c=!0);0<=a.i.pb&&a.i.pb<=Ac(a)&&(a.i.nb=a.i.pb=-1,jc(a),a.ma(),c=!0);c&&a.g(Ac(a)+" cycles: checksum="+n(a.i.Ab))}} +m.la=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.L[b]=c;a=!0;break;case "run":this.L[b]=c;c.onclick=function(){var a;if(a=d.A)if(a=d.A,a.D.sa)a=!0;else{var b=null,c,g=bb(a.id);for(c=0;cc&&(c=2);var d=1;b&&1a.i.$a/a.i.ab?b=1:d=!0;a.i.cb=b;b=a.i.Yb*a.i.cb;if(a.i.ab!=b){a.i.ab=b;b=a.i.ab.toFixed(2)+"Mhz";var e=a.L.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.A&&a.A.fb()}Cc(a,a.F);a.F=0;a.i.mb=la();a.i.bb=0;Dc(a);return d} +m.eb=function(a){if(hb(this,!0)){if(!this.D.xa){Bc(this);this.A&&this.A.start(this.i.mb,Ac(this));this.D.xa=!0;this.D.Xb=!0;this.I&&this.I.start();var b=this.L.run;b&&(b.textContent="Halt");this.A&&(this.A.Ia(!0),a&&this.A.fb(!0))}this.i.ac>=this.i.rb&&Dc(this,!0);this.i.Eb=0;this.i.Pb=la();this.i.bb&&(a=this.i.Pb-this.i.bb,a>this.i.zc&&(this.i.mb+=a,this.i.mb>this.i.Pb&&(this.i.mb=this.i.Pb)));try{do{this.tb(this.D.kb?1:this.i.Cd);var c=this.B-this.b;this.F+=c;this.i.Eb+=c;Cc(this,0,!0);nc(this, +c);this.i.Db-=c;0>=this.i.Db&&(this.i.Db+=this.i.Bc,this.A&&Ec(this.A,this.i.Qb++),this.i.Qb>this.M&&(this.i.Qb=0));this.i.Cb-=c;0>=this.i.Cb&&(this.i.Cb+=this.i.Ac,this.A&&this.A.Ia());this.i.qb-=c;if(0>=this.i.qb){this.i.qb+=this.i.$b;break}}while(this.D.xa)}catch(e){this.ma();lc(this);this.A&&this.A.stop(la(),Ac(this));hb(this,!1);kb(this,e.stack||e.message);return}c=setTimeout;a=this.aa;this.i.bb=la();b=this.i.zc;this.i.Eb&&(b=Math.round(b*this.i.Eb/this.i.$b));var b=b-(this.i.bb-this.i.Pb),d= +this.i.bb-this.i.mb;d&&(this.i.$a=Math.round(this.F/(10*d))/100,864E5<=d&&(this.J=0,Bc(this)));if(0>b||this.i.$a>8&255;a.T=b&255}function Oc(a){return a.U<<8|a.V}function Pc(a,b){a.U=b>>8&255;a.V=b&255}function K(a){return a.W<<8|a.Y} +function Qc(a,b){a.W=b>>8&255;a.Y=b&255}function F(a,b){a.P=b&65535}function Rc(a){return a.ba&256?1:0}function Sc(a,b){a.ba=a.ba&255|b}function Tc(a){return ob[a.ca&255]?4:0}function Uc(a){return(a.ca^a.ua)&16?16:0}function Vc(a){return a.ba&255?0:64}function Wc(a){return a.ca&128?128:0}function Lc(a){return a.ta&-214|Wc(a)|Vc(a)|Uc(a)|Tc(a)|Rc(a)}function Jc(a,b){a.ba=a.ca=a.ua=0;b&1&&(a.ba|=256);b&4||(a.ca|=1);b&16&&(a.ua|=16);b&64||(a.ba|=255);b&128&&(a.ca^=192);a.ta=a.ta&-726|b&512|2} +function Xc(a,b){a.ua=a.j^b;return a.ca=(a.ba=a.j+b)&255}function Yc(a,b){a.ua=a.j^b;return a.ca=(a.ba=a.j+b+(a.ba&256?1:0))&255}function Zc(a,b){a.ba=a.ca=a.ua=a.j&b;(a.j|b)&8&&(a.ua^=16);return a.ba}function $c(a,b){a.ua=b^255;b=a.ca=b+255&255;a.ba=a.ba&-256|b;return b}function ad(a,b){a.ua=b;b=a.ca=b+1&255;a.ba=a.ba&-256|b;return b}function bd(a,b){return a.ca=a.ba=a.ua=a.j|b}function L(a,b){b^=255;a.ua=a.j^b;return a.ca=(a.ba=a.j+b+1^256)&255} +function cd(a,b){b^=255;a.ua=a.j^b;return a.ca=(a.ba=a.j+b+(a.ba&256?0:1)^256)&255}function dd(a,b){return a.ca=a.ba=a.ua=a.j^b}m.Z=function(a){return this.w.Z(a)};m.ra=function(a,b){this.w.ra(a,b)};function M(a){var b=a.Z(a.P);F(a,a.P+1);return b}function N(a){var b=a.w.Sa(a.P);F(a,a.P+2);return b}function P(a){var b=a.w.Sa(a.ka);a.ka=a.ka+2&65535;return b}function Q(a,b){a.ka=a.ka-2&65535;a.w.Tb(a.ka,b)}function ed(a,b){a.u=a.u&-8|b|8} +function S(a,b,c,d){d=d||2;a.L[b]&&(void 0===c&&(kb(a,"Value for "+b+" is invalid"),a.ma()),c=!a.D.xa||a.D.rc?n(c,d):"--------".substr(0,d),a.L[b].textContent!=c&&(a.L[b].textContent=c))} +m.Ia=function(a){this.R&&(a||!this.D.xa||this.D.rc)&&(S(this,"A",this.j),S(this,"B",this.S),S(this,"C",this.T),S(this,"BC",Mc(this),4),S(this,"D",this.U),S(this,"E",this.V),S(this,"DE",Oc(this),4),S(this,"H",this.W),S(this,"L",this.Y),S(this,"HL",K(this),4),S(this,"SP",this.ka,4),S(this,"PC",this.P,4),a=Lc(this),S(this,"PS",a,4),S(this,"IF",a&512?1:0,1),S(this,"SF",a&128?1:0,1),S(this,"ZF",a&64?1:0,1),S(this,"AF",a&16?1:0,1),S(this,"PF",a&4?1:0,1),S(this,"CF",a&1?1:0,1));if(a=this.L.speed)a.textContent= +this.D.xa&&this.i.$a?this.i.$a.toFixed(2)+"Mhz":"Stopped"};m.tb=function(a){this.D.Nb=!0;var b=this.D.sd=this.H&&yd(this.H),c=a?this.D.Xb?0:1:-1;this.D.Xb=!1;this.B=this.b=a;do{if(this.u){if(a&&this.u&8&&this.ta&512){var d=199|(this.u&7)<<3;this.u&=-17;this.u&=-16;this.ta&=-513;this.N[d].call(this)}if(this.u&16){this.b=0;break}}if(b){if(zd(this.H,this.P,c)){this.ma();break}c=1}this.N[M(this)].call(this)}while(0>8;Sc(this,a&256);this.b-=4},Ad,function(){var a;Qc(this,a=K(this)+Mc(this));Sc(this,a>>8&256);this.b-=10},function(){this.j=this.Z(Mc(this));this.b-=7},function(){Nc(this,Mc(this)-1);this.b-= +5},function(){this.T=ad(this,this.T);this.b-=5},function(){this.T=$c(this,this.T);this.b-=5},function(){this.T=M(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;Sc(this,a);this.b-=4},Ad,function(){Pc(this,N(this));this.b-=10},function(){this.ra(Oc(this),this.j);this.b-=7},function(){Pc(this,Oc(this)+1);this.b-=5},function(){this.U=ad(this,this.U);this.b-=5},function(){this.U=$c(this,this.U);this.b-=5},function(){this.U=M(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255| +Rc(this);Sc(this,a&256);this.b-=4},Ad,function(){var a;Qc(this,a=K(this)+Oc(this));Sc(this,a>>8&256);this.b-=10},function(){this.j=this.Z(Oc(this));this.b-=7},function(){Pc(this,Oc(this)-1);this.b-=5},function(){this.V=ad(this,this.V);this.b-=5},function(){this.V=$c(this,this.V);this.b-=5},function(){this.V=M(this);this.b-=7},function(){var a=this.j<<8;this.j=(Rc(this)<<8|this.j)>>1;Sc(this,a&256);this.b-=4},Ad,function(){Qc(this,N(this));this.b-=10},function(){var a=N(this);this.w.Tb(a,K(this)); +this.b-=16},function(){Qc(this,K(this)+1);this.b-=5},function(){this.W=ad(this,this.W);this.b-=5},function(){this.W=$c(this,this.W);this.b-=5},function(){this.W=M(this);this.b-=7},function(){var a=0,b=Rc(this);if(Uc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=Xc(this,a);Sc(this,b?256:0);this.b-=4},Ad,function(){var a;Qc(this,a=K(this)+K(this));Sc(this,a>>8&256);this.b-=10},function(){var a;a=N(this);a=this.w.Sa(a);Qc(this,a);this.b-=16},function(){Qc(this,K(this)-1);this.b-=5},function(){this.Y= +ad(this,this.Y);this.b-=5},function(){this.Y=$c(this,this.Y);this.b-=5},function(){this.Y=M(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},Ad,function(){this.ka=N(this)&65535;this.b-=10},function(){this.ra(N(this),this.j);this.b-=13},function(){this.ka=this.ka+1&65535;this.b-=5},function(){var a=K(this);this.ra(a,ad(this,this.Z(a)));this.b-=10},function(){var a=K(this);this.ra(a,$c(this,this.Z(a)));this.b-=10},function(){this.ra(K(this),M(this));this.b-=10},function(){this.ba|=256;this.b-= +4},Ad,function(){var a;Qc(this,a=K(this)+this.ka);Sc(this,a>>8&256);this.b-=10},function(){this.j=this.Z(N(this));this.b-=13},function(){this.ka=this.ka-1&65535;this.b-=5},function(){this.j=ad(this,this.j);this.b-=5},function(){this.j=$c(this,this.j);this.b-=5},function(){this.j=M(this);this.b-=7},function(){Sc(this,Rc(this)?0:256);this.b-=4},function(){this.b-=5},function(){this.S=this.T;this.b-=5},function(){this.S=this.U;this.b-=5},function(){this.S=this.V;this.b-=5},function(){this.S=this.W;this.b-= +5},function(){this.S=this.Y;this.b-=5},function(){this.S=this.Z(K(this));this.b-=7},function(){this.S=this.j;this.b-=5},function(){this.T=this.S;this.b-=5},function(){this.b-=5},function(){this.T=this.U;this.b-=5},function(){this.T=this.V;this.b-=5},function(){this.T=this.W;this.b-=5},function(){this.T=this.Y;this.b-=5},function(){this.T=this.Z(K(this));this.b-=7},function(){this.T=this.j;this.b-=5},function(){this.U=this.S;this.b-=5},function(){this.U=this.T;this.b-=5},function(){this.b-=5},function(){this.U= +this.V;this.b-=5},function(){this.U=this.W;this.b-=5},function(){this.U=this.Y;this.b-=5},function(){this.U=this.Z(K(this));this.b-=7},function(){this.U=this.j;this.b-=5},function(){this.V=this.S;this.b-=5},function(){this.V=this.T;this.b-=5},function(){this.V=this.U;this.b-=5},function(){this.b-=5},function(){this.V=this.W;this.b-=5},function(){this.V=this.Y;this.b-=5},function(){this.V=this.Z(K(this));this.b-=7},function(){this.V=this.j;this.b-=5},function(){this.W=this.S;this.b-=5},function(){this.W= +this.T;this.b-=5},function(){this.W=this.U;this.b-=5},function(){this.W=this.V;this.b-=5},function(){this.b-=5},function(){this.W=this.Y;this.b-=5},function(){this.W=this.Z(K(this));this.b-=7},function(){this.W=this.j;this.b-=5},function(){this.Y=this.S;this.b-=5},function(){this.Y=this.T;this.b-=5},function(){this.Y=this.U;this.b-=5},function(){this.Y=this.V;this.b-=5},function(){this.Y=this.W;this.b-=5},function(){this.b-=5},function(){this.Y=this.Z(K(this));this.b-=7},function(){this.Y=this.j; +this.b-=5},function(){this.ra(K(this),this.S);this.b-=7},function(){this.ra(K(this),this.T);this.b-=7},function(){this.ra(K(this),this.U);this.b-=7},function(){this.ra(K(this),this.V);this.b-=7},function(){this.ra(K(this),this.W);this.b-=7},function(){this.ra(K(this),this.Y);this.b-=7},function(){var a=this.P-1;if(this.K.length)for(var b=0;b>8;this.b-=10},function(){var a=N(this);Wc(this)||F(this,a);this.b-=10},function(){this.ta&=-513;this.b-=4},function(){var a=N(this);Wc(this)||(Q(this,this.P),F(this,a),this.b-=6);this.b-=11},function(){Q(this,Lc(this)&255|this.j<<8);this.b-=11},function(){this.j=bd(this,M(this));this.b-=7},function(){Q(this,this.P);F(this,48);this.b-=11},function(){Wc(this)&&(F(this,P(this)), +this.b-=6);this.b-=5},function(){this.ka=K(this)&65535;this.b-=5},function(){var a=N(this);Wc(this)&&F(this,a);this.b-=10},function(){this.ta|=512;this.b-=4},function(){var a=N(this);Wc(this)&&(Q(this,this.P),F(this,a),this.b-=6);this.b-=11},Dd,function(){L(this,M(this));this.b-=7},function(){Q(this,this.P);F(this,56);this.b-=11}]; +function T(a){x.call(this,"ChipSet",a,T,32768);var b=a.model;b&&!Ed[b]&&Ka("Unrecognized ChipSet model: "+b);this.B=Ed[b]||{};a.sound&&(this.ha=null,window&&(this.ha=window.AudioContext||window.webkitAudioContext),this.ha&&new this.ha);D(this)}Za(T); +var U={Aa:1978.1,nd:{Ba:0,$d:1,de:16,ke:32,te:64,se:128,vb:14},Wa:{Ba:1,Oc:1,gd:2,cd:4,dd:16,ed:32,fd:64,vb:8},od:{Ba:2,Zd:3,Be:4,ae:8,oe:16,pe:32,qe:64,be:128,vb:0},xe:{Ba:3},ve:{Ba:2,le:7},ze:{Ba:3,Ce:1,ye:2,re:4,ie:8,ce:16,Wd:32},we:{Ba:4},Ae:{Ba:5,ee:1,fe:2,ge:4,he:8,De:16}},V={Aa:100,Pa:{Ba:66,Ee:1,jc:2,bd:4,ne:8,me:16,lc:32,kc:64,gc:128},Nc:{Ba:66,INIT:0},Ua:{Ba:194,Yd:0,fc:16,hd:32,mc:48,Sc:0,Tc:32},Jb:{Ba:162,ue:0,Vc:0,Rc:0,Uc:0,Qc:0},Ja:{je:{Ba:98},Ta:{Lc:0,Kc:1,kd:2,pd:4,Pc:5,jd:6,ld:7}, +Kb:16383}},Ed={SI1978:U,VT100:V};T.prototype.la=function(){return!1};T.prototype.Oa=function(a,b,c,d){this.w=b;this.b=c;this.H=d;this.A=a;this.M=qb(a,"Keyboard");this.video=qb(a,"Video");Bb(b,this,this.B.Rb);Fb(b,this,this.B.Sb)};T.prototype.Ea=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};T.prototype.Ha=function(a){return a?this.save():!0};U.INIT=[[U.nd.vb,U.Wa.vb,U.od.vb,0,0,0,0]]; +V.INIT=[[V.Nc.INIT,V.Pa.jc|V.Pa.bd],[V.Ua.Sc,V.Ua.Tc],[V.Jb.Vc,V.Jb.Rc,V.Jb.Uc,V.Jb.Qc],[0,0,0,0,[11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11776,11784,11918,11776,11856,11824,11840,11808,11776,12E3,12E3,11857,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]]; +m=T.prototype;m.reset=function(){this.B.INIT&&!this.restore(this.B.INIT)&&this.ia("reset error")};m.save=function(){var a=new G(this);switch(this.B.Aa){case U.Aa:H(a,0,[this.Ca,this.I,this.Da,this.da,this.ga,this.ya,this.za]);break;case V.Aa:H(a,0,[this.na,this.J]),H(a,1,[this.N,this.O]),H(a,2,[this.F,this.ea,this.wa,this.va]),H(a,3,[this.aa,this.u,this.R,this.fa,this.K])}return a.data()}; +m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.B.Aa){case U.Aa:return this.Ca=b[0],this.I=b[1],this.Da=b[2],this.da=b[3],this.ga=b[4],this.ya=b[5],this.za=b[6],!0;case V.Aa:return this.na=b[0],this.J=b[1],b=a[1],this.N=b[0],this.O=b[1],b=a[2],this.F=b[0],this.ea=b[1],this.wa=b[2],this.va=b[3],b=a[3],this.aa=b[0],this.u=b[1],this.R=b[2],this.fa=b[3],this.K=b[4],!0}return!1};m.start=function(){};m.stop=function(){};m.wd=function(a,b){var c=this.Ca;C(this,a,null,b,"STATUS0",c,!0);return c}; +m.xd=function(a,b){var c=this.I;C(this,a,null,b,"STATUS1",c,!0);return c};m.yd=function(a,b){var c=this.Da;C(this,a,null,b,"STATUS2",c,!0);return c};m.vd=function(a,b){var c=this.da>>8-this.ga&255;C(this,a,null,b,"SHIFT.RESULT",c,!0);return c};m.Gd=function(a,b,c){C(this,a,b,c,"SHIFT.COUNT",null,!0);this.ga=b};m.Id=function(a,b,c){C(this,a,b,c,"SOUND1",null,!0);this.ya=b};m.Hd=function(a,b,c){C(this,a,b,c,"SHIFT.DATA",null,!0);this.da=b<<8|this.da>>8}; +m.Jd=function(a,b,c){C(this,a,b,c,"SOUND2",null,!0);this.za=b};m.Kd=function(a,b,c){C(this,a,b,c,"WATCHDOG",null,!0)};function Fd(a){var b=0,c=0,d=~a.aa;for(a=0;10>a;a++)d&1&&(b=9-a),d>>=1;for(a=0;10>a;a++)d&1&&(c=9-a),d>>=1;return 10*b+c} +m.zd=function(a,b){var c=this.J,c=c&~V.Pa.kc;if((Ac(this.b)&64)<<1&&(c|=V.Pa.kc,c!=this.J)){var d,e;d=this.R&1;e=this.R>>1&7;switch(e){case V.Ja.Ta.ld:break;case V.Ja.Ta.Kc:this.aa=this.aa<<1|d;break;case V.Ja.Ta.Pc:d=Fd(this);this.K[d]=V.Ja.Kb;fb(this,"doNVRCommand(): erase data at addr "+t(d));break;case V.Ja.Ta.Lc:this.u=this.u<<1|d;break;case V.Ja.Ta.pd:d=Fd(this);e=this.u&V.Ja.Kb;this.K[d]=e;fb(this,"doNVRCommand(): write data "+t(e)+" to addr "+t(d));break;case V.Ja.Ta.jd:d=Fd(this);e=this.K[d]; +null==e&&(e=V.Ja.Kb);this.u=e;fb(this,"doNVRCommand(): read data "+t(e)+" from addr "+t(d));break;case V.Ja.Ta.kd:this.u<<=1;this.fa=this.u&V.Ja.Kb+1;break;default:fb(this,"doNVRCommand(): unrecognized command 0x"+n(e,2))}}c&=~V.Pa.lc;this.fa&&(c|=V.Pa.lc);c&=~V.Pa.gc;this.M&&(c|=V.Pa.gc);this.J=c;C(this,a,null,b,"FLAGS.BUFFER",c);return c};m.Ld=function(a,b,c){C(this,a,b,c,"BRIGHTNESS");this.na=b};m.Od=function(a,b,c){C(this,a,b,c,"NVR.LATCH");this.R=b}; +m.Nd=function(a,b,c){C(this,a,b,c,"DC012");a=b&3;switch(b>>2&3){case 0:this.F=this.F&-4|a;break;case 1:this.F=this.F&-13|a<<2;break;case 2:switch(a){case 0:this.ea=~this.ea;break;case 2:case 3:this.wa=3-a}break;case 3:this.va=a}}; +m.Md=function(a,b,c){C(this,a,b,c,"DC011");b&V.Ua.hd?(b&=V.Ua.mc,this.O!=b&&(this.O=b,this.video&&(a=this.video,b=this.O==V.Ua.mc?50:60,fb(a,"updateRate("+b+")"),a.zb=b))):(b&=V.Ua.fc,this.N!=b&&(this.N=b,this.video&&(a=this.N==V.Ua.fc?132:80,b=this.video,fb(b,"updateDimensions("+a+","+(80>>0,h],q=ka(p,k,a.Xa);0>q&&p.splice(-(q+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.J.push({Fe:b,G:c,Bd:d,Ra:e,nc:f})}delete this.Ra}return!0};Id.prototype.Ha=function(){return!0}; +function Jd(a,b,c,d){if(d)a.ia("Unable to load system ROM (error "+d+": "+b+")");else{ab(a.Vb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.A=f;else if(h)for(a.A=Array(4*h.length),d=c=0;c>8&255,a.A[d++]=h[c]>>16&255,a.A[d++]=h[c]>>24&255;else a.A=e;a.Ra=e.symbols;if(!a.A.length){u("Empty ROM: "+b);return}if(1==a.A.length){u(a.A[0]);return}}catch(g){a.ia("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm, +" ").replace(/ +$/,"").split(" "),a.A=Array(b.length),e=0;e>>f.pa;0>>=f.pa;0d?a.u.push({cc:b,Zb:Date.now(),Mb:!1}):(a.u[d].Zb=Date.now(),a.u[d].Mb=!1);else if(0<=d){if(!a.u[d].Mb){var e=a.u[d].Zb;if(e&&100>Date.now()-e)return a.u[d].Mb=!0,Vd(a),!0}a.u.splice(d,1)}if(a.I){d=0;switch(b){case "1p":d=U.Wa.cd;break;case "2p":d=U.Wa.gd;break;case "coin":d=U.Wa.Oc;break;case "left":d=U.Wa.ed;break;case "right":d=U.Wa.fd;break;case "fire":d=U.Wa.dd}d&&(a=a.I,b=d,a.I&=~b,c&&(a.I|=b))}return!0} +function Vd(a){for(var b=0,c=-1;bc||c>e)c=e}else{Td(a,d,!1);b=0;continue}}b++}0<=c&&setTimeout(function(){Vd(a)},c)}m.Ad=function(a,b){var c=this.F;0<=this.B&&(this.B>3)*a.ea,!ub(a.w,a.ya,a.aa,3)))return!1;a.aa?(a.Dc=a.I.createImageData(b,c),a.Gc=16/a.Za|0,ae(a,a.aa>>1)):ae(a,(a.fa+1)*a.ha);a.N=document.createElement("canvas");a.N.width=b;a.N.height=c;a.gb=a.N.getContext("2d");a.va={};a.Da=1<=a.uc?8:16,f=8>(7>4)*c)}return k} -Ud.prototype.Aa=function(){if(2==this.ea){for(var a={0:[32,"SET-UP A"],2:[64,'TO EXIT PRESS "SET-UP"'],22:[96," T T T T T T T T T"],23:[96,"1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890"],24:[]},b=this.va,c=-1,d=-1,e,f=-(60==this.zc?2:5);f>8&15|16;zb(this.A,b++,e);zb(this.A,b++, -c&255);if(g)break}if(h)for(c=0,e=1;ec&&(a=Math.round(c/b*100)+"%")}this.rc?(this.P.style.width=a,this.P.style.width=a,this.P.style.display="block",this.P.style.margin="auto"):(this.w.style.width=a,this.w.style.height="auto");this.w.style.backgroundColor="black";this.w.fb();a=!0}this.Ba&&this.Ba.focus()}return a}; -function Xd(a,b){!b&&a.w&&(a.rc?a.P.style.width=a.P.style.height="":a.w.style.width=a.w.style.height="");fb(a,"notifyFullScreen("+b+")",!0)}function Zd(a,b){a.xc=b;a.wa=!1;if(void 0===a.J||a.J.length!=a.xc)a.J=Array(a.xc)}function be(a,b,c,d,e){d=a.C?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.ea&&(208<=c&&236>c?e=a.Ca+0:28<=c&&72>c&&(e=a.Ca+1));a=a.oa[e];d*=a.length;b.data[d]=a[0];b.data[d+1]=a[1];b.data[d+2]=a[2];b.data[d+3]=a[3]} -function ce(a){for(var b=a.va,c=-1,d=0,e=60==a.zc?2:5,f=0,h=0;d>=1);;){var q=xb(a.A,k++);if(127==(q&127)){var r=xb(a.A,k++),c=r&96,b=(r&15)<<8|xb(a.A,k),b=b+(r&16?8192:16384);break}if(g>4)*q.ia,w=void 0,J=void 0,A=void 0, -R=void 0,za=q.qa,Z=q.ia;y?(w=p*r.qa,J=d*r.ia,A=r.qa,R=r.ia):(w=p*r.Lb,J=d*r.Mb,A=r.Lb,R=r.Mb);q.qa>r.qa&&(w*=2,A*=2);q.ia>r.ia&&(0==l&&(v+=r.ia),Z=r.ia);y?y.drawImage(q.canvas,I,v,za,Z,w,J,A,R):(w+=0,J+=0,r.I.drawImage(q.canvas,I,v,za,Z,w,J,A,R))}h++}f++}d++}}a.wa=!0;h&&a.cb&&a.I.drawImage(a.O,0,0,a.K,a.da-a.ia,0,0,a.Hd,a.Id)} -Ia(function(){for(var a=B(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<=qa().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");wa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new Ud(d,e,h,f,c);db(d,c)}}); -function de(a){this.G=+a.adapter;switch(this.G){case 0:this.J=0;break;default:u("Unrecognized serial adapter #"+this.G);return}x.call(this,"SerialPort",a,de,8388608);var b=a.binding;if("console"!=b){var c;a=ee;b&&(void 0===c&&(c="Panel"),(c=cb(c,this.id))&&(b=c.L[b])&&this.ka(null,a,b))}}Za(de);var ee="buffer";m=de.prototype; -m.ka=function(a,b,c){switch(b){case ee:return this.L[b]=c,c.onkeydown=function(a){a=a||window.event;var b=a.keyCode;(8===b||a.ctrlKey&&65<=b&&90>=b)&&a.preventDefault&&a.preventDefault();return!0},c.onkeypress=function(a){a=a||window.event;a.preventDefault&&a.preventDefault();return!0},c.removeAttribute("readonly"),!0}return!1};m.Na=function(a,b,c,d){this.A=b;this.b=c;this.H=d;this.I=qb(a,"ChipSet");Bb(b,this,fe,this.J);Fb(b,this,ge,this.J);D(this)}; -m.Aa=function(a,b){if(!b)if(!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};m.Fa=function(a){return a?this.save():!0};m.reset=function(){he(this)};m.save=function(){var a=new G(this),b=0,c=[];c[b++]=this.w;c[b++]=this.u;c[b++]=this.C;H(a,0,c);return a.data()};m.restore=function(a){return he(this,a[0])};function he(a,b){var c=0;void 0===b&&(b=[0,0,0]);a.w=b[c++];a.u=b[c++];a.C=b[c++];return!0}m.kd=function(a,b){var c=this.w;C(this,a,null,b,"DATA",c);return c}; -m.jd=function(a,b){var c=this.u;C(this,a,null,b,"COMMAND",c);return c};m.vd=function(a,b,c){C(this,a,b,c,"DATA");this.w=b};m.ud=function(a,b,c){C(this,a,b,c,"COMMAND");this.u=b};m.td=function(a,b,c){C(this,a,b,c,"BAUDRATE");this.C=b};var fe={0:de.prototype.kd,1:de.prototype.jd},ge={0:de.prototype.vd,1:de.prototype.ud,2:de.prototype.td};Ia(function(){for(var a=B(document,"pc8080","serial"),b=0;b>8&15|16;zb(this.w,b++,e);zb(this.w,b++, +c&255);if(g)break}if(h)for(c=0,e=1;ec&&(a=Math.round(c/b*100)+"%")}this.Cc?(this.O.style.width=a,this.O.style.width=a,this.O.style.display="block",this.O.style.margin="auto"):(this.u.style.width=a,this.u.style.height="auto");this.u.style.backgroundColor="black";this.u.ib();a=!0}this.Ca&&this.Ca.focus()}return a}; +function Zd(a,b){!b&&a.u&&(a.Cc?a.O.style.width=a.O.style.height="":a.u.style.width=a.u.style.height="");fb(a,"notifyFullScreen("+b+")")}function ae(a,b){a.Ec=b;a.za=!1;if(void 0===a.J||a.J.length!=a.Ec)a.J=Array(a.Ec)}function ce(a,b,c,d,e){d=a.B?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.ga&&(208<=c&&236>c?e=a.Da+0:28<=c&&72>c&&(e=a.Da+1));a=a.wa[e];d*=a.length;b.data[d]=a[0];b.data[d+1]=a[1];b.data[d+2]=a[2];b.data[d+3]=a[3]} +function de(a){for(var b=a.ya,c=-1,d=0,e=60==a.zb?2:5,f=0,h=0;d>=1);;){var q=xb(a.w,k++);if(127==(q&127)){var r=xb(a.w,k++),c=r&96,b=(r&15)<<8|xb(a.w,k),b=b+(r&16?8192:16384);break}if(g>4)*q.ja,w=void 0,J=void 0,A=void 0, +R=void 0,Ba=q.oa,Z=q.ja;z?(w=p*r.oa,J=d*r.ja,A=r.oa,R=r.ja):(w=p*r.vc,J=d*r.wc,A=r.vc,R=r.wc);q.oa>r.oa&&(w*=2,A*=2);q.ja>r.ja&&(0==l&&(v+=r.ja),Z=r.ja);z?z.drawImage(q.canvas,I,v,Ba,Z,w,J,A,R):(w+=0,J+=0,r.I.drawImage(q.canvas,I,v,Ba,Z,w,J,A,R))}h++}f++}d++}}a.za=!0;h&&a.gb&&a.I.drawImage(a.N,0,0,a.K,a.ea-a.ja,0,0,a.Qd,a.Rd)} +Ia(function(){for(var a=B(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<=qa().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");wa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new Wd(d,e,h,f,c);db(d,c)}}); +function ee(a){this.O=+a.adapter;switch(this.O){case 0:this.R=0;this.aa=2;break;default:u("Unrecognized serial adapter #"+this.O);return}x.call(this,"SerialPort",a,ee,8388608);var b=a.binding;if("console"!=b){var c;a=fe;b&&(void 0===c&&(c="Panel"),(c=cb(c,this.id))&&(b=c.L[b])&&this.la(null,a,b))}}Za(ee);var ge=[!1,0,0,133,142,39,238],fe="buffer";m=ee.prototype; +m.la=function(a,b,c,d){var e=this;switch(b){case fe:return this.L[b]=c,c.onkeydown=function(a){a=a||window.event;var b=a.keyCode;if(8===b||a.ctrlKey&&65<=b&&90>=b)a.preventDefault&&a.preventDefault(),64>>d.A.na;k=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;k--;){var p=b[g];p.type==c?l++||d.g("..."):(c=p.type,l=wb[c],p&&d.g(n(p.id)+" %"+n(g<>>e.na;f!=e.A?e.W[h].cc(f,b&65535,d):(e.W[h++].Gb(f,b&255,d),e.W[h&e.K].Gb(0,b>>8&255,d+1));c&&we(a,c);lc(this.b,!0)}};function X(a){return{F:a,Ma:!1}}function xe(a){return[a.F,a.Ma]}function ye(a){return{F:a[0],Ma:a[1]}} -function ve(a,b,c){var d;c=(c?a.P:a.bb).F;if(void 0!==b){d=b=ze(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=na(qe,a.substr(b,1))));return c}function Fe(a,b){var c=0,d=Ge(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 6:c=2;break;case 8:case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"} -function Ge(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.R;break;case 1:c=d.S;break;case 8:c=Mc(d);break;case 2:c=d.T;break;case 3:c=d.U;break;case 9:c=Oc(d);break;case 4:c=d.V;break;case 5:c=d.X;break;case 10:c=K(d);break;case 6:c=d.Y(K(d));break;case 11:c=d.ja;break;case 12:c=d.N;break;case 13:c=Lc(d);break;case 14:c=Lc(d)&255|d.j<<8}}return c} -function He(a,b){b=ze(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=Ee(b,c+1),0<=e&&(b=b.substr(0,c)+Fe(a,e)+b.substr(c+1+qe[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=ba(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=ve(a,e))?(d=e+' "'+De(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=ve(a,e))?(we(d),d=e+' "'+ -De(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}m.message=function(a,b){b&&(a+=" at "+Y(X(this.b.N).F));if(this.pa&1073741824)this.Ba.push(a);else if(!this.wa||a!=this.wa)if(this.wa=a,this.pa&-2147483648&&(this.la(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.ob=0;c.C-=c.b;c.b=0;lc(c)}}; -function eb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.pa&g)!=g||a.message(b.ab+"."+(null!=d?"outPort":"inPort")+"("+t(c)+","+(f?f:"unknown")+(null!=d?",0x"+n(d,2):"")+")"+(null!=h?": 0x"+n(h,2):"")+(null!=e?" at "+Y(e):""))} -function le(a){var b;if(yd(a)){if(!a.O||!a.O.length){a.O=Array(1E3);for(b=0;b>>d.na],!1)}a.Z=["br"];if(void 0!==a.G)for(b=1;b>>d.na],!0);a.G=["bw"];a.cb=0}m.Va=function(a,b,c){var d=!0;c||Me(this,a,b,!1,!0);if(a!=this.w){var e=ue(b);if(-1===e)this.g("invalid address: "+Y(b.F)),d=!1;else{var f=this.A;f.W[e>>>f.na].Va(e&f.A,a==this.G)}}d&&(a.push(b),c?b.Ma=!0:(lf(this,a,a.length-1,"set"),le(this)));return d}; -function Me(a,b,c,d,e){var f=!1;c=ue(c);for(var h=1;h>>d.na],b==a.G));g.Ma||le(a);break}}return f}function mf(a,b){for(var c=1;c>24,4);break;case 3:w=n(y.Qa(I,2),4);break;default:y="imm("+t(v)+")";break a}8086==y.style&&v&64?w="["+w+"]":v&16||(w=(y.style==je?"$":"0x")+w);y=w}else v& -16?(y=(q&3840)>>8,v=qe[y],8086==a.style&&q&64&&(6==y&&(v="HL"),v="["+v+"]"),y=v):v&128&&(y=(f>>3&7).toString());if(!y||!y.length){g="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; -function tf(a,b,c){for(c=c||-1;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(d){case "*":d=f*e;break;case "/":if(!e)return!1;d=f/e;break;case "%":if(!e)return!1;d=f%e;break;case "+":d=f+e;break;case "-":d=f-e;break;case "<<":d=f<>":d=f>>e;break;case ">>>":d=f>>>e;break;case "<":d=f":d=f>e?1:0;break;case ">=":d=f>=e?1:0;break;case "==":d=f==e?1:0;break;case "!=":d=f!=e?1:0;break;case "&":d=f&e;break; +18193,33],[65,128],[59],[50,3603],[35,51],[24],[12,51],[51,3603],[47,18193,33],[65,128],[56],[69,19219,18963],[32,51],[25],[9,51],[7,32819],[19,18193,33],[65,128]],we={cpu:1,bus:64,mem:128,port:256,chipset:32768,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:268435456,warn:536870912,buffer:1073741824,halt:-2147483648};m=me.prototype; +m.Oa=function(a,b,c,d){this.w=b;this.b=c;this.A=a;(a=hc(a,"messages"))&&qe(this,a);this.Qa=ve;xe(this,function(a){a:{var b=d.w.X,c=a[0],g=a=0,k=b.length;if(c){a=ye(ze(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.w.pa;k=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;k--;){var p=b[g];p.type==c?l++||d.g("..."):(c=p.type,l=wb[c],p&&d.g(n(p.id)+" %"+n(g<>>e.pa;f!=e.w?e.X[h].dc(f,b&65535,d):(e.X[h++].Ib(f,b&255,d),e.X[h&e.K].Ib(0,b>>8&255,d+1));c&&Ae(a,c);lc(this.b,!0)}};function X(a){return{G:a,Na:!1}}function Be(a){return[a.G,a.Na]}function Ce(a){return{G:a[0],Na:a[1]}} +function ze(a,b,c){var d;c=(c?a.O:a.Za).G;if(void 0!==b){d=b=De(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=na(ue,a.substr(b,1))));return c}function Je(a,b){var c=0,d=Ke(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 6:c=2;break;case 8:case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"} +function Ke(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.S;break;case 1:c=d.T;break;case 8:c=Mc(d);break;case 2:c=d.U;break;case 3:c=d.V;break;case 9:c=Oc(d);break;case 4:c=d.W;break;case 5:c=d.Y;break;case 10:c=K(d);break;case 6:c=d.Z(K(d));break;case 11:c=d.ka;break;case 12:c=d.P;break;case 13:c=Lc(d);break;case 14:c=Lc(d)&255|d.j<<8}}return c} +function Le(a,b){b=De(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=Ie(b,c+1),0<=e&&(b=b.substr(0,c)+Je(a,e)+b.substr(c+1+ue[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=ba(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=ze(a,e))?(d=e+' "'+He(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=ze(a,e))?(Ae(d),d=e+' "'+ +He(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}m.message=function(a,b){b&&(a+=" at "+Y(X(this.b.P).G));if(this.qa&1073741824)this.ya.push(a);else if(!this.wa||a!=this.wa)if(this.wa=a,this.qa&-2147483648&&(this.ma(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.qb=0;c.B-=c.b;c.b=0;lc(c)}}; +function eb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.qa&g)!=g||a.message(b.Lb+"."+(null!=d?"outPort":"inPort")+"("+t(c)+","+(f?f:"unknown")+(null!=d?",0x"+n(d,2):"")+")"+(null!=h?": 0x"+n(h,2):"")+(null!=e?" at "+Y(e):""))} +function pe(a){var b;if(yd(a)){if(!a.N||!a.N.length){a.N=Array(1E3);for(b=0;b>>d.pa],!1)}a.R=["br"];if(void 0!==a.F)for(b=1;b>>d.pa],!0);a.F=["bw"];a.gb=0}m.Ya=function(a,b,c){var d=!0;c||Qe(this,a,b,!1,!0);if(a!=this.u){var e=ye(b);if(-1===e)this.g("invalid address: "+Y(b.G)),d=!1;else{var f=this.w;f.X[e>>>f.pa].Ya(e&f.w,a==this.F)}}d&&(a.push(b),c?b.Na=!0:(pf(this,a,a.length-1,"set"),pe(this)));return d}; +function Qe(a,b,c,d,e){var f=!1;c=ye(c);for(var h=1;h>>d.pa],b==a.F));g.Na||pe(a);break}}return f}function qf(a,b){for(var c=1;c>24,4);break;case 3:w=n(z.Sa(I,2),4);break;default:z="imm("+t(v)+")";break a}8086==z.style&&v&64?w="["+w+"]":v&16||(w=(z.style==ne?"$":"0x")+w);z=w}else v& +16?(z=(q&3840)>>8,v=ue[z],8086==a.style&&q&64&&(6==z&&(v="HL"),v="["+v+"]"),z=v):v&128&&(z=(f>>3&7).toString());if(!z||!z.length){g="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; +function xf(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 Ae(a,b,c){var d;if(b){b=ze(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;h=p+"b"+h;d>>=8}d="0x"+n(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function wf(a,b){if(b)return vf(a,b,a.ha[b]);var c=0;for(b in a.ha)vf(a,b,a.ha[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,g=f.rd;if(e>=h&&e>8&255;case "C":d.S=g&255;break;case "D":d.T= -g&255;break;case "DE":d.T=g>>8&255;case "E":d.U=g&255;break;case "H":d.V=g&255;break;case "HL":d.V=g>>8&255;case "L":d.X=g&255;break;case "SP":d.ja=g&65535;break;case "PC":F(d,g);a.P=X(d.N);break;case "PS":Jc(d,g);break;case "PSW":Jc(d,g&255|d.ta&-256);d.j=g>>8;break;case "CF":d.aa=g?d.aa|256:d.aa&255;break;case "PF":g?Tc(d)||(d.ca^=1):Tc(d)&&(d.ca^=1);break;case "AF":d.ua=g?~d.ca&16|d.ua&-17:d.ca&16|d.ua&-17;break;case "ZF":d.aa=g?d.aa&-256:d.aa|255;break;case "SF":g?Wc(d)||(d.ca^=192):Wc(d)&&(d.ca^= -192);break;case "IF":d.ta=g?d.ta|512:d.ta&-513;break;default:a.g("unknown register: "+e);return}if(!h){a.g("invalid value: "+f);return}lc(d);a.g("updated registers:")}a.g(rf(a));c&&(a.P=X(d.N),Ke(a,Y(a.P.F)))}}function Df(a,b){b=ja(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(He(a,c[2])):Ae(a,b,!0)}function Ef(a,b,c){var d="t"!=b;c=uf(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);xa(c,function(){return hb(a,!0)&&a.rb(e,d,!1)},function(){lc(a.b);hb(a,!1)})} -function Ke(a,b,c,d){if(b=ve(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=ve(a,c,!0);if(!d||d.Fg[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=of(a,b,h,f);a.g(f);a.P=b;e-=b.F-k;c++}}} -function Ce(a,b,c,d){if(c)if(b){0>a.I&&a.C.length&&(a.I=0);if(0>a.I||b!=a.C[a.I])a.C.splice(0,0,b),a.I=0;a.I--}else a.fa?b="end":b=a.C[a.I+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(ja(b.substring(c,f))),c=f+1}}return a} -function nf(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.fa&&(a.g("ended assemble at "+Y(a.ea.F)),a.P=a.ea,a.fa=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.wa=null;if(jb(a)&&0l||"z"Ca.length&&(a.g("note: only "+Ca.length+" available"),fa=Ca.length);aa-=fa;0>aa&&(null==Ca[Ca.length-1].F?(fa=aa+fa,aa=0):aa+=Ca.length);var hd=[];"call"== -Se&&(mb=1E5,hd=["CALL"]);for(void 0!==Re&&a.g(fa+" instructions earlier:");0=Ca.length&&(aa=0);a.eb=fa;Ue++;mb--}}Ue||(a.g("no "+Te+"history available"),a.eb=void 0)}else{var oc=ve(a,Z);if(oc){var pc=0;Va&&("l"==Va.charAt(0)&&(Va=Va.substr(1)||Zf),pc=uf(a,Va)>>>0,65536>4||1;ag--&&0tc?String.fromCharCode(tc):".";rc--}Wa&&(Wa+="\n");Wa+=Z+" "+Mb+(0==Lb?" "+jd:"")}Wa&&a.g(Wa);a.bb=oc}}}}break;case "e":if("else"==f[0])break;var uc=1,Xe=255,Ye=a.Y,Ze=a.ra;"ew"==f[0]&&(uc=2,Xe=65535,Ye=a.Qa,Ze=a.Rb);var $e=uc<<1,af=f[1];if(null==af)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 vc=ve(a,af);if(vc)for(var wc=2;wcqd;){for(var Xa=null,gg=256;65536>Pb.F>>>0;){cf.F= -a.Qa(Pb,2);if(null==Pb.F||!gg--)break;for(var hg=a,yc=cf,df=null,Qb=yc.F,ef=Qb,rd=1;6>=rd&&Qb;rd++){if(2\nLicense: GPL version 3 or later ");for(b=0;bOf){if(Kf(d,this.P)){this.G=new G(this,"1.23.3","failsafe");Kf(this.G)&&(Tf(this,d),a=2,Hf(this.G));H(this.G,"timestamp",ma());If(this.G);var e=this.u&&!this.K;if(1==a||ra("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Jf(d)){var f=Lf(d,"code"),h=Lf(d,"data");f&&("ok"==f?Kf(d,h):("error"==f&& -"no machine state"!=h?(this.ga("Error: "+h),"unable to verify user"==h&&(va("user",""),this.w=null)):this.g(f+": "+h),Hf(d),Kf(d)?(c=Jf(d),e=!0):c=!1))}e&&Sf(this,c?d:null)}else 2==a&&d.clear()}else Sf(this);delete this.P;delete this.Z}e=bb(this.id);for(f=0;fa[1];a=a[2];this.oa=!0;this.D.sa=!0;var d=this.L.power;d&&(d.textContent="Shutdown");this.b&&(Uf(this,this.b,b,c,a),mc(this.b));this.ea&&(Tf(this,b),b.clear());!c&&this.G&&(this.G.clear(),delete this.G);this.C=0}; -function Tf(a,b){if(ra("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.w||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.ma;e.user=c;e.type="bug";e.data=d;oa("http://www.pcjs.org/api/v1/report",e,!0)}} -function Ff(a,b,c){var d,e="none";if(a.C)return null;a.C--;var f=new G(a,"1.23.3"),h=new G(a,"1.23.3","validate"),g=ma();H(h,"timestamp",g);H(f,"timestamp",g);H(f,"version","1.23.3");H(f,"url",window?window.location.href:null);H(f,"browser",qa());a.b&&a.b.Fa&&(c&&a.b.la(),d=a.b.Fa(b,c),"object"===typeof d&&H(f,a.b.id,d),c&&(a.b.D.sa=!1,!1===d&&(e=null)));for(var g=bb(a.id),k=0;k=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;h=p+"b"+h;d>>=8}d="0x"+n(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function Af(a,b){if(b)return zf(a,b,a.ga[b]);var c=0;for(b in a.ga)zf(a,b,a.ga[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,g=f.Bd;if(e>=h&&e>8&255;case "C":d.T=g&255;break;case "D":d.U= +g&255;break;case "DE":d.U=g>>8&255;case "E":d.V=g&255;break;case "H":d.W=g&255;break;case "HL":d.W=g>>8&255;case "L":d.Y=g&255;break;case "SP":d.ka=g&65535;break;case "PC":F(d,g);a.O=X(d.P);break;case "PS":Jc(d,g);break;case "PSW":Jc(d,g&255|d.ta&-256);d.j=g>>8;break;case "CF":d.ba=g?d.ba|256:d.ba&255;break;case "PF":g?Tc(d)||(d.ca^=1):Tc(d)&&(d.ca^=1);break;case "AF":d.ua=g?~d.ca&16|d.ua&-17:d.ca&16|d.ua&-17;break;case "ZF":d.ba=g?d.ba&-256:d.ba|255;break;case "SF":g?Wc(d)||(d.ca^=192):Wc(d)&&(d.ca^= +192);break;case "IF":d.ta=g?d.ta|512:d.ta&-513;break;default:a.g("unknown register: "+e);return}if(!h){a.g("invalid value: "+f);return}lc(d);a.g("updated registers:")}a.g(vf(a));c&&(a.O=X(d.P),Oe(a,Y(a.O.G)))}}function Hf(a,b){b=ja(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(Le(a,c[2])):Ee(a,b,!0)}function If(a,b,c){var d="t"!=b;c=yf(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);xa(c,function(){return hb(a,!0)&&a.tb(e,d,!1)},function(){lc(a.b);hb(a,!1)})} +function Oe(a,b,c,d){if(b=ze(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=ze(a,c,!0);if(!d||d.Gg[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=sf(a,b,h,f);a.g(f);a.O=b;e-=b.G-k;c++}}} +function Ge(a,b,c,d){if(c)if(b){0>a.I&&a.B.length&&(a.I=0);if(0>a.I||b!=a.B[a.I])a.B.splice(0,0,b),a.I=0;a.I--}else a.fa?b="end":b=a.B[a.I+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(ja(b.substring(c,f))),c=f+1}}return a} +function rf(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.fa&&(a.g("ended assemble at "+Y(a.ea.G)),a.O=a.ea,a.fa=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.wa=null;if(jb(a)&&0l||"z"Ea.length&&(a.g("note: only "+Ea.length+" available"),fa=Ea.length);aa-=fa;0>aa&&(null==Ea[Ea.length-1].G?(fa=aa+fa,aa=0):aa+=Ea.length);var hd=[];"call"== +We&&(mb=1E5,hd=["CALL"]);for(void 0!==Ve&&a.g(fa+" instructions earlier:");0=Ea.length&&(aa=0);a.hb=fa;Ye++;mb--}}Ye||(a.g("no "+Xe+"history available"),a.hb=void 0)}else{var oc=ze(a,Z);if(oc){var pc=0;Wa&&("l"==Wa.charAt(0)&&(Wa=Wa.substr(1)||cg),pc=yf(a,Wa)>>>0,65536>4||1;eg--&&0tc?String.fromCharCode(tc):".";rc--}Xa&&(Xa+="\n");Xa+=Z+" "+Mb+(0==Lb?" "+jd:"")}Xa&&a.g(Xa);a.Za=oc}}}}break;case "e":if("else"==f[0])break;var uc=1,af=255,bf=a.Z,cf=a.ra;"ew"==f[0]&&(uc=2,af=65535,bf=a.Sa,cf=a.Tb);var df=uc<<1,ef=f[1];if(null==ef)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 vc=ze(a,ef);if(vc)for(var wc=2;wcqd;){for(var Ya=null,kg=256;65536>Pb.G>>>0;){gf.G= +a.Sa(Pb,2);if(null==Pb.G||!kg--)break;for(var lg=a,yc=gf,hf=null,Qb=yc.G,jf=Qb,rd=1;6>=rd&&Qb;rd++){if(2\nLicense: GPL version 3 or later ");for(b=0;bSf){if(Of(d,this.O)){this.F=new G(this,"1.23.3","failsafe");Of(this.F)&&(Xf(this,d),a=2,Lf(this.F));H(this.F,"timestamp",ma());Mf(this.F);var e=this.A&&!this.K;if(1==a||ra("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Nf(d)){var f=Pf(d,"code"),h=Pf(d,"data");f&&("ok"==f?Of(d,h):("error"==f&& +"no machine state"!=h?(this.ia("Error: "+h),"unable to verify user"==h&&(va("user",""),this.u=null)):this.g(f+": "+h),Lf(d),Of(d)?(c=Nf(d),e=!0):c=!1))}e&&Wf(this,c?d:null)}else 2==a&&d.clear()}else Wf(this);delete this.O;delete this.R}e=bb(this.id);for(f=0;fa[1];a=a[2];this.na=!0;this.D.sa=!0;var d=this.L.power;d&&(d.textContent="Shutdown");this.b&&(Yf(this,this.b,b,c,a),mc(this.b));this.ea&&(Xf(this,b),b.clear());!c&&this.F&&(this.F.clear(),delete this.F);this.B=0}; +function Xf(a,b){if(ra("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.u||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.ha;e.user=c;e.type="bug";e.data=d;oa("http://www.pcjs.org/api/v1/report",e,!0)}} +function Jf(a,b,c){var d,e="none";if(a.B)return null;a.B--;var f=new G(a,"1.23.3"),h=new G(a,"1.23.3","validate"),g=ma();H(h,"timestamp",g);H(f,"timestamp",g);H(f,"version","1.23.3");H(f,"url",window?window.location.href:null);H(f,"browser",qa());a.b&&a.b.Ha&&(c&&a.b.ma(),d=a.b.Ha(b,c),"object"===typeof d&&H(f,a.b.id,d),c&&(a.b.D.sa=!1,!1===d&&(e=null)));for(var g=bb(a.id),k=0;k>>f.na;0>8|(w&255)<<8);p>J&I;be(d,d.sc,p++,q,R);J+=v}p>r&&(r=p);q=h&&(h=q+1)}g+=2;l++;if(p>=d.K&&(p=0,q++,q>d.da))break}d.wa=!0;eg.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1pc8080$2")); -g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(q){g=null,a=q.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");oa(e,null,!0,function(f,h,g){if(g||!h)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=h.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var k=g[0],l,p=/( [a-z]+=)(['"])(.*?)\2/g;l=p.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/, -"");a=a.replace(d[0],h);ng(a,b,c)}})}else c(a,null)} -function og(a,b,c,d){function e(a){if(void 0===g){var b=h&&B(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ha(a))}function f(a){e("Error: "+a);k&&(--Xf||La(!0));k=!1}var h,g,k=!0;Xf++;$a[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=l:q.appendChild(document.createTextNode(l));p.appendChild(q)}c|| -(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?Yf(c,null,null,!1,e,function(d,k){if(k)if(ab(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--Xf||La(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--Xf||La(!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,l):mg(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(r){f(r.message)}return k}window.embedPC8080=function(a,b,c,d){La(!1);return og(a,b,c,d)};window.enableEvents=La;window.sendEvent=Ma; -function pg(a,b,c,d){if(!c&&b){d.push(b);a=$a[d[0]];b=null;for(var e in a)if(ea(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?oa(b,null,!0,function(a,b){qg(b,d)}):qg(null,d)}else u("Error ("+c+") requesting "+a)} -function qg(a,b){var c,d,e,f=b[0],h=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var g=$a[f],k={},l;for(l in g){var p=g[l],q=da(l);if("xml"==q){for(q=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=q.exec(g[l]);){var r=d[2];r&&(g[r]||(p=p.replace(d[0],"")))}d=l=ca(l)}else"xsl"==q&&(e=l=ca(l));k[l]=p}a&&(k[l="css"]=a);b[2]&&(k[l="parms"]=b[2]);b[3]&&(k[l="state"]=b[3]);d&&e?(l=JSON.stringify(k),h+=".js",c=c[1]+"var resources="+l+";"+c[2]+c[3],c=c.replace(/\u00A9/g, +m.la=function(a,b,c){var d=this;switch(b){case "power":return this.L[b]=c,c.onclick=function(){d.B||(d.D.sa?Jf(d,!1,!0):Vf(d,d.Fb))},!0;case "reset":return this.L[b]=c,c.onclick=function(){if(d.D.sa&&!d.B)if(d.A&&!d.N){var a=ra("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Jf(d,a,!0);!a&&d.da?window&&window.location.reload():d.Fb(Sf)}else d.reset(),d.b&&mc(d.b)},!0;case "save":if(ea(pa(),"pcjs.org")){c.parentNode.removeChild(c); +break}this.L[b]=c;c.onclick=function(){var a=Tf(d,!0);if(a){var b=!!(d.A&&!d.N||d.da),c=Jf(d,b);b?Zf(d,a,c):d.ia("Resume disabled, machine state not saved")}};return!0}return!1}; +function Tf(a,b){var c=a.u;c||(c=ua("user"),void 0!==c?!c&&b&&(c=null,window&&(c=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c&&((c=$f(a,c))||a.ia("The user ID is invalid."))):b&&a.ia("Browser local storage is not available"));return c} +function $f(a,b){a.u=null;var c=oa(pa()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(va("user",c.data),a.u=c.data)}catch(e){u(e.message+" ("+d+")")}return a.u}function Uf(a){var b=null;a.u&&(b=pa()+"/api/v1/user?req=load&user="+a.u+"&state="+Kf(a,"1.23.3"));return b} +function Zf(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Kf(a,"1.23.3");d.data=c;b=oa(pa()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0>>f.pa;0>8|(w&255)<<8);p>J&I;ce(d,d.Dc,p++,q,R);J+=v}p>r&&(r=p);q=h&&(h=q+1)}g+=2;l++;if(p>=d.K&&(p=0,q++,q>d.ea))break}d.za=!0;eg.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1pc8080$2")); +g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(q){g=null,a=q.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");oa(e,null,!0,function(f,h,g){if(g||!h)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=h.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var k=g[0],l,p=/( [a-z]+=)(['"])(.*?)\2/g;l=p.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/, +"");a=a.replace(d[0],h);rg(a,b,c)}})}else c(a,null)} +function sg(a,b,c,d){function e(a){if(void 0===g){var b=h&&B(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ha(a))}function f(a){e("Error: "+a);k&&(--ag||La(!0));k=!1}var h,g,k=!0;ag++;$a[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=l:q.appendChild(document.createTextNode(l));p.appendChild(q)}c|| +(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?bg(c,null,null,!1,e,function(d,k){if(k)if(ab(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--ag||La(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--ag||La(!0)):f("invalid machine element: "+ +a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?bg(b,a,d,!0,e,l):qg(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(r){f(r.message)}return k}window.embedPC8080=function(a,b,c,d){La(!1);return sg(a,b,c,d)};window.enableEvents=La;window.sendEvent=Ma; +function tg(a,b,c,d){if(!c&&b){d.push(b);a=$a[d[0]];b=null;for(var e in a)if(ea(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?oa(b,null,!0,function(a,b){ug(b,d)}):ug(null,d)}else u("Error ("+c+") requesting "+a)} +function ug(a,b){var c,d,e,f=b[0],h=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var g=$a[f],k={},l;for(l in g){var p=g[l],q=da(l);if("xml"==q){for(q=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=q.exec(g[l]);){var r=d[2];r&&(g[r]||(p=p.replace(d[0],"")))}d=l=ca(l)}else"xsl"==q&&(e=l=ca(l));k[l]=p}a&&(k[l="css"]=a);b[2]&&(k[l="parms"]=b[2]);b[3]&&(k[l="state"]=b[3]);d&&e?(l=JSON.stringify(k),h+=".js",c=c[1]+"var resources="+l+";"+c[2]+c[3],c=c.replace(/\u00A9/g, "©"),l=h,g=null,k="data:application/javascript,",k=wa("Firefox")?k+encodeURIComponent(c):k+encodeURI(c),l&&(g=document.createElement("a"),"string"!=typeof g.download&&(g=null)),g?(g.href=k,g.download=l,document.body.appendChild(g),g.click(),document.body.removeChild(g),c="Check your Downloads folder for "+l+"."):(window.open(k),c="Check your browser for a new window/tab containing the requested data"+(l?" ("+l+")":"")+"."),c+=', copy it to your web server as "'+h+'", and then add the following to your web page:\n\n', c+='
\n',c+="...\n",c+='