Merge branch 'next-release'

This commit is contained in:
Jeff Parsons 2016-08-06 14:28:43 -07:00
commit f1a46a2120
16 changed files with 2011 additions and 564 deletions

View file

@ -5,14 +5,15 @@ permalink: /devices/pc8080/machine/invaders/
machines:
- type: pc8080
id: invaders
debugger: true
---
Space Invaders (1978)
---
This is a test of [PC8080](/modules/pc8080/), a new 8080-based machine emulator recently added to the
PCjs Project. It is currently playable only in desktop browsers and uses the following hard-coded key mappings:
PCjs Project.
It is currently playable only in desktop browsers and uses the following hard-coded key mappings:
- 1: One Player
- 2: Two Player
@ -21,71 +22,7 @@ PCjs Project. It is currently playable only in desktop browsers and uses the fo
- D: Move Right
- L: Fire Missile
Assorted [Space Invaders Hardware Notes](#space-invaders-hardware-notes) are collected below.
See the [Debugger Configuration](/devices/pc8080/machine/invaders/debugger/) for more control of the machine, along
with assorted [Space Invaders Hardware Notes](/devices/pc8080/machine/invaders/debugger/#space-invaders-hardware-notes).
{% include machine.html id="invaders" %}
Space Invaders Hardware Notes
---
### Memory Map
0000-1FFF r ROM code
2000-23FF rw RAM
2400-3FFF rw bitmapped screen (224x256)
### I/O Map
00 r
01 r control inputs
bit 7
bit 6 right
bit 5 left
bit 4 fire
bit 3
bit 2 1 player start
bit 1 2 player start
bit 0 coin slot
02 r control inputs
bit 7 0=display coin info
bit 6 right 2
bit 5 left 2
bit 4 fire 2
bit 3 bonus (1500,1000) / preset mode
bit 2 1=tilt
bit 0-1 initial lives (3,4,5,6) / (3,4)
02 w shift count (0-7)
03 r shifted value (low then high)
03 w sound
bit 4 bonus base
bit 3 invader hit
bit 2 base hit
bit 1 base fire
bit 0 saucer
04 w value to shift
05 w sound
bit 5 flip video
bit 4 saucer hit
bit 3 invader movement 4
bit 2 invader movement 3
bit 1 invader movement 2
bit 0 invader movement 1
06 w watchdog timer clear
Note that, unlike most emulators, PC8080 (like PCx86) has a *[Bus](/modules/pc8080/lib/bus.js)* architecture,
allowing components to "plug in" different kinds of memory or memory-mapped devices at different addresses,
and to register specific functions for specific I/O ports.
For example, Space Invaders has 8Kb of ROM at addresses 0x0000 through 0x1FFF, which means that if any 8080 code
attempts to write to those addresses, nothing should happen. Unfortunately, most emulators treat the entire address
space as one contiguous array of bytes. Which means either that the ROM is susceptible to corruption *or* that every
write operation must check the address to determine its validity, which hurts the performance of *all* writes.
In PC8080 (and PCx86), all writes are equally fast, and all ROMs are fully protected. An exception is made for the
Debugger, which allows you to use the "e" command to modify ("patch") ROM code on the fly, but that is completely
outside and independent of the 8080 code being emulated.
### Other Online References
See [Computer Archeology](http://www.computerarcheology.com/Arcade/SpaceInvaders/) for an excellent collection
of materials on the original Space Invaders, including commented ROM disassemblies.

View file

@ -0,0 +1,94 @@
---
layout: page
title: Space Invaders (1978) with Debugger
permalink: /devices/pc8080/machine/invaders/debugger/
machines:
- type: pc8080
id: invaders
debugger: true
---
Space Invaders (1978) with Debugger
-----------------------------------
The [PC8080](/modules/pc8080/) machine below is configured to run [Space Invaders](/devices/pc8080/machine/invaders/)
with a Control Panel and Debugger.
It is currently playable only in desktop browsers and uses the following hard-coded key mappings:
- 1: One Player
- 2: Two Player
- 3: Insert Coin
- A: Move Left
- D: Move Right
- L: Fire Missile
Click the "Run" button to start the simulation. You'll also find assorted
[Space Invaders Hardware Notes](#space-invaders-hardware-notes) below.
{% include machine.html id="invaders" %}
Space Invaders Hardware Notes
-----------------------------
### Memory Map
0000-1FFF r ROM code
2000-23FF rw RAM
2400-3FFF rw bitmapped screen (224x256)
### I/O Map
00 r
01 r control inputs
bit 7
bit 6 right
bit 5 left
bit 4 fire
bit 3
bit 2 1 player start
bit 1 2 player start
bit 0 coin slot
02 r control inputs
bit 7 0=display coin info
bit 6 right 2
bit 5 left 2
bit 4 fire 2
bit 3 bonus (1500,1000) / preset mode
bit 2 1=tilt
bit 0-1 initial lives (3,4,5,6) / (3,4)
02 w shift count (0-7)
03 r shifted value (low then high)
03 w sound
bit 4 bonus base
bit 3 invader hit
bit 2 base hit
bit 1 base fire
bit 0 saucer
04 w value to shift
05 w sound
bit 5 flip video
bit 4 saucer hit
bit 3 invader movement 4
bit 2 invader movement 3
bit 1 invader movement 2
bit 0 invader movement 1
06 w watchdog timer clear
Note that, unlike most emulators, PC8080 (like PCx86) has a *[Bus](/modules/pc8080/lib/bus.js)* architecture,
allowing components to "plug in" different kinds of memory or memory-mapped devices at different addresses,
and to register specific functions for specific I/O ports.
For example, Space Invaders has 8Kb of ROM at addresses 0x0000 through 0x1FFF, which means that if any 8080 code
attempts to write to those addresses, nothing should happen. Unfortunately, most emulators treat the entire address
space as one contiguous array of bytes. Which means either that the ROM is susceptible to corruption *or* that every
write operation must check the address to determine its validity, which hurts the performance of *all* writes.
In PC8080 (and PCx86), all writes are equally fast, and all ROMs are fully protected. An exception is made for the
Debugger, which allows you to use the "e" command to modify ("patch") ROM code on the fly, but that is completely
outside and independent of the 8080 code being emulated.
### Other Online References
See [Computer Archeology](http://www.computerarcheology.com/Arcade/SpaceInvaders/) for an excellent collection
of materials on the original Space Invaders, including commented ROM disassemblies.

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/versions/pc8080/1.23.3/machine.xsl"?>
<machine id="invaders" class="pc8080" border="1" pos="center" background="#FAEBD7">
<name pos="center">Space Invaders</name>
<computer id="computer" busWidth="16"/>
<cpu id="cpu8080" model="8080" cycles="2000000" autoStart="true"/>
<rom id="romH" addr="0x0000" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-H.json"/>
<rom id="romG" addr="0x0800" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-G.json"/>
<rom id="romF" addr="0x1000" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-F.json"/>
<rom id="romE" addr="0x1800" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-E.json"/>
<ram id="ram" addr="0x2000" size="0x0400"/>
<video id="video" screenWidth="896" screenHeight="1024" bufferRotate="-90" smoothing="false" bufferAddr="0x2400" bufferCols="256" bufferRows="224" bufferBits="1" bufferLeft="0" interruptRate="120" width="40%" pos="left" padding="8px">
<menu>
<title>224x256 Screen (Rotated)</title>
<control type="container" pos="right">
<control type="button" binding="fullScreen" padleft="8px;line-height:1em">Full Screen</control>
</control>
</menu>
</video>
<chipset id="chipset" model="SI1978"/>
<keyboard id="keyboard"/>
<panel ref="/devices/pc8080/panel/left.xml"/>
<debugger id="debugger" commands="s 8086"/>
</machine>

View file

@ -9,7 +9,7 @@
<rom id="romF" addr="0x1000" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-F.json"/>
<rom id="romE" addr="0x1800" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-E.json"/>
<ram id="ram" addr="0x2000" size="0x0400"/>
<video id="video" screenWidth="896" screenHeight="1024" bufferRotate="-90" smoothing="false" bufferAddr="0x2400" bufferCols="256" bufferRows="224" bufferBits="1" bufferLeft="0" interruptRate="120" width="40%" pos="left" padding="8px">
<video id="video" screenWidth="896" screenHeight="1024" bufferRotate="-90" smoothing="false" bufferAddr="0x2400" bufferCols="256" bufferRows="224" bufferBits="1" bufferLeft="0" interruptRate="120" padding="8px">
<menu>
<title>224x256 Screen (Rotated)</title>
<control type="container" pos="right">
@ -19,6 +19,4 @@
</video>
<chipset id="chipset" model="SI1978"/>
<keyboard id="keyboard"/>
<panel ref="/devices/pc8080/panel/left.xml"/>
<debugger id="debugger" commands="s 8086"/>
</machine>

View file

@ -11,121 +11,16 @@ machines:
DEC VT100 Terminal
------------------
This is a work-in-progress emulation of another 8080-based machine: the VT100 Terminal.
This is a PCjs work-in-progress emulation of another 8080-based machine: the VT100 Terminal.
Unlike other VT100 emulators, this is not simply an emulation of VT100 protocols. It is a simulation of the original VT100
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.
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 Memory Usage
------------------
As described in the [Technical Manual (July 1982)](http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/terminal/vt100/EK-VT100-TM-003_VT100_Technical_Manual_Jul82.pdf),
p. 4-15, 8Kb (0x2000) of ROM is located at 0x0000, and 3Kb (0x0C00) of RAM immediately follows it at 0x2000. The ROM at
0x0000 contains all the VT100's 8080 code. The VT100 also contains a 2Kb character generator ROM, but that ROM is not
addressable by the CPU; it is used directly by the Video Processor.
See [DEC VT100 ROMs](/devices/pc8080/rom/vt100/) for more information about the ROMs.
[vt100romhax](http://vt100romhax.tumblr.com/post/90697428973/the-vt100-memory-map-and-8080-disassembly)
(aka [phooky](https://github.com/phooky) aka Adam Mayer) further explains VT100 memory usage:
Start End Size Description
0x0000 0x1fff 8K Basic ROM
0x2000 0x2012 18B Blank lines for refresh (6 x 3B)
0x2012 0x204f 61B Stack area (grows down from 0x204e)
0x204f 0x22d0 641B Scratch Pad/Setup Area(?)
0x22d0 0x2c00 2352B Screen RAM
VT100 I/O Ports
---------------
From p. 4-17 of the Technical Manual:
READ OR WRITE
00H PUSART data bus
01H PUSART command port
WRITE ONLY (Decoded with I/O WR L)
02H Baud rate generator
42H Brightness D/A latch
62H NVR latch
82H Keyboard UART data input
A2H Video processor DC012
C2H Video processor DC011
E2H Graphics port
READ ONLY (Decoded with I/O RD L)
22H Modem buffer
42H Flags buffer
82H Keyboard UART data output
The PC8080 ChipSet component deals with the ER1400's Non-volatile RAM (NVR) ports, the Flags buffer, and the
DC011 and DC012 circuits, while the Keyboard component deals with the Keyboard UART.
You might wonder why the PC8080 Video component doesn't manage the DC011 and DC012. In fact, the above labels are misleading.
If you look at the Functional Diagram on p. 4-53 of the Technical Manual, you'll see that DC011 and DC012 are really
peripheral components providing inputs to the Video Processor. Moreover, they are not exclusive to the Video Processor.
For example, the LBA7 output of the DC011 is also used to clock the NVR chip.
In most respects, the VT100 Technical Manual provides a phenomenal amount of detail.
However, documentation for some of the above ports is almost non-existent. It's only thanks to
[third parties](https://github.com/phooky/VT100-Hax/blob/master/Platform%20Notes.md) that we have, for example, the following
information about the Flags buffer (port 0x42):
Bit Active? Description
7 H KBD Transmit Buffer Empty
6 H LBA 7(?) (It's a pin on the backplane connector...) - used to clock NVR - line buffer address
5 H NVR DATA
4 L EVEN FIELD (comes out of the video timing generator)
3 H OPTION PRESENT (terminal output option???)
2 L GRAPHICS FLAG (is VT52 graphics card present) [I think he meant VT125 -JP]
1 L ADVANCED VIDEO (is AVO present)
0 H XMIT FLAG
VT100 Video Processor
---------------------
Normally, the PC8080 Video component allocates its own video buffer, based on the specified buffer address
(*bufferAddr*) and other dimensions (eg, *bufferCols* and *bufferRows*), but the VT100 is a little unusual:
it has a custom Video Processor that uses DMA to request character data from any region of RAM, one line at a time.
It always defaults to address 0x2000 for the first line of character data, but each line terminates with 3 bytes
containing the attributes and address of the next line, so the location of subsequent lines will vary, depending
on the type of line:
- Single-wide characters (80 or 132 columns)
- Double-wide characters (40 or 66 columns)
In addition to single-wide vs. double-wide, line attributes can also specify double-high, along with whether the
top or bottom halves of the double-high characters should be displayed, because double-high always implies double-wide
(ie, there is no support for double-high, single-wide characters).
Conssequently, a VT100 [machine XML file](machine.xml) must set the Video component's *bufferRAM* property
to "true", indicating that existing RAM should be used, and a new property, *bufferFormat* must be set to "vt100",
enabling support for the VT100's line data format; eg:
<ram id="ram" addr="0x2000" size="0x0C00"/>
<video id="video" screenWidth="1600" screenHeight="960" bufferAddr="0x2000" bufferRAM="true" bufferFormat="vt100" bufferCols="80" bufferRows="24" ...>
VT100 Screen and Character Dimensions
-------------------------------------
Ordinarily, the VT100 screen displays 800 dots per horizontal scan, and a total of 240 horizontal scans, and by default,
it uses a 10x10 character cell, for a total of 80 columns and 24 rows of characters. However, in 132-column mode, it
uses a 9x10 character cell instead, implying a total of 1188 dots displayed per horizontal scan. This means we will have
to dynamically reallocate our internal buffers whenever the horizontal dimensions change. Also, if no AVO expansion
card is present, there is only enough RAM available for 14 rows of characters in 132-column mode.
For optimum scaling, I define the virtual screen size using multiples of the VT100's default "dot" dimensions; eg, 1600x960
(a horizontal multiplier of 2 and a vertical multiplier of 4). That gives us a virtual screen aspect ratio of 1.67.
According to the Technical Manual, a physical VT100 screen measures 12 inches diagonally, and in 80-column mode, characters
measure 2.0mm x 3.35mm (in 132-column mode, they measure 1.3mm x 3.35mm), which suggests that the text area of the screen is
roughly 160mm x 80mm, implying a screen aspect ratio of 2.0. However, after visually comparing the Technical Manual's SET-UP
screenshots to our test screens, 1.67 appears to be closer to reality than 2.0. I'll revisit this issue at a later date.
Additional VT100 Resources
--------------------------
[VT100 Publications](/pubs/dec/vt100/)

View file

@ -0,0 +1,134 @@
---
layout: page
title: DEC VT100 Terminal
permalink: /devices/pc8080/machine/vt100/debugger/
machines:
- type: pc8080
id: vt100
debugger: true
---
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.
Click the "Run" button to start the simulation. You'll also find assorted
[Hardware Notes](#vt100-memory-usage) below.
{% include machine.html id="vt100" %}
VT100 Memory Usage
------------------
As described in the [Technical Manual (July 1982)](http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/terminal/vt100/EK-VT100-TM-003_VT100_Technical_Manual_Jul82.pdf),
p. 4-15, 8Kb (0x2000) of ROM is located at 0x0000, and 3Kb (0x0C00) of RAM immediately follows it at 0x2000. The ROM at
0x0000 contains all the VT100's 8080 code. The VT100 also contains a 2Kb character generator ROM, but that ROM is not
addressable by the CPU; it is used directly by the Video Processor.
See [DEC VT100 ROMs](/devices/pc8080/rom/vt100/) for more information about the ROMs.
[vt100romhax](http://vt100romhax.tumblr.com/post/90697428973/the-vt100-memory-map-and-8080-disassembly)
(aka [phooky](https://github.com/phooky) aka Adam Mayer) further explains VT100 memory usage:
Start End Size Description
0x0000 0x1fff 8K Basic ROM
0x2000 0x2012 18B Blank lines for refresh (6 x 3B)
0x2012 0x204f 61B Stack area (grows down from 0x204e)
0x204f 0x22d0 641B Scratch Pad/Setup Area(?)
0x22d0 0x2c00 2352B Screen RAM
VT100 I/O Ports
---------------
From p. 4-17 of the Technical Manual:
READ OR WRITE
00H PUSART data bus
01H PUSART command port
WRITE ONLY (Decoded with I/O WR L)
02H Baud rate generator
42H Brightness D/A latch
62H NVR latch
82H Keyboard UART data input
A2H Video processor DC012
C2H Video processor DC011
E2H Graphics port
READ ONLY (Decoded with I/O RD L)
22H Modem buffer
42H Flags buffer
82H Keyboard UART data output
The PC8080 ChipSet component deals with the ER1400's Non-volatile RAM (NVR) ports, the Flags buffer, and the
DC011 and DC012 circuits, while the Keyboard component deals with the Keyboard UART.
You might wonder why the PC8080 Video component doesn't manage the DC011 and DC012. In fact, the above labels are misleading.
If you look at the Functional Diagram on p. 4-53 of the Technical Manual, you'll see that DC011 and DC012 are really
peripheral components providing inputs to the Video Processor. Moreover, they are not exclusive to the Video Processor.
For example, the LBA7 output of the DC011 is also used to clock the NVR chip.
In most respects, the VT100 Technical Manual provides a phenomenal amount of detail.
However, documentation for some of the above ports is almost non-existent. It's only thanks to
[third parties](https://github.com/phooky/VT100-Hax/blob/master/Platform%20Notes.md) that we have, for example, the following
information about the Flags buffer (port 0x42):
Bit Active? Description
7 H KBD Transmit Buffer Empty
6 H LBA 7(?) (It's a pin on the backplane connector...) - used to clock NVR - line buffer address
5 H NVR DATA
4 L EVEN FIELD (comes out of the video timing generator)
3 H OPTION PRESENT (terminal output option???)
2 L GRAPHICS FLAG (is VT52 graphics card present) [I think he meant VT125 -JP]
1 L ADVANCED VIDEO (is AVO present)
0 H XMIT FLAG
VT100 Video Processor
---------------------
Normally, the PC8080 Video component allocates its own video buffer, based on the specified buffer address
(*bufferAddr*) and other dimensions (eg, *bufferCols* and *bufferRows*), but the VT100 is a little unusual:
it has a custom Video Processor that uses DMA to request character data from any region of RAM, one line at a time.
It always defaults to address 0x2000 for the first line of character data, but each line terminates with 3 bytes
containing the attributes and address of the next line, so the location of subsequent lines will vary, depending
on the type of line:
- Single-wide characters (80 or 132 columns)
- Double-wide characters (40 or 66 columns)
In addition to single-wide vs. double-wide, line attributes can also specify double-high, along with whether the
top or bottom halves of the double-high characters should be displayed, because double-high always implies double-wide
(ie, there is no support for double-high, single-wide characters).
Conssequently, a VT100 [machine XML file](machine.xml) must set the Video component's *bufferRAM* property
to "true", indicating that existing RAM should be used, and a new property, *bufferFormat* must be set to "vt100",
enabling support for the VT100's line data format; eg:
<ram id="ram" addr="0x2000" size="0x0C00"/>
<video id="video" screenWidth="1600" screenHeight="960" bufferAddr="0x2000" bufferRAM="true" bufferFormat="vt100" bufferCols="80" bufferRows="24" ...>
VT100 Screen and Character Dimensions
-------------------------------------
Ordinarily, the VT100 screen displays 800 dots per horizontal scan, and a total of 240 horizontal scans, and by default,
it uses a 10x10 character cell, for a total of 80 columns and 24 rows of characters. However, in 132-column mode, it
uses a 9x10 character cell instead, implying a total of 1188 dots displayed per horizontal scan. This means we will have
to dynamically reallocate our internal buffers whenever the horizontal dimensions change. Also, if no AVO expansion
card is present, there is only enough RAM available for 14 rows of characters in 132-column mode.
For optimum scaling, I define the virtual screen size using multiples of the VT100's default "dot" dimensions; eg, 1600x960
(a horizontal multiplier of 2 and a vertical multiplier of 4). That gives us a virtual screen aspect ratio of 1.67.
According to the Technical Manual, a physical VT100 screen measures 12 inches diagonally, and in 80-column mode, characters
measure 2.0mm x 3.35mm (in 132-column mode, they measure 1.3mm x 3.35mm), which suggests that the text area of the screen is
roughly 160mm x 80mm, implying a screen aspect ratio of 2.0. However, after visually comparing the Technical Manual's SET-UP
screenshots to our test screens, 1.67 appears to be closer to reality than 2.0. I'll revisit this issue at a later date.
Additional VT100 Resources
--------------------------
[VT100 Publications](/pubs/dec/vt100/)

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/versions/pc8080/1.23.3/machine.xsl"?>
<machine id="vt100" class="pc8080" border="1" pos="center" background="#FAEBD7">
<name pos="center">VT100 Terminal</name>
<computer id="computer" busWidth="16"/>
<cpu id="cpu8080" model="8080" cycles="2764800"/>
<rom id="rom" addr="0x0000" size="0x2000" file="/devices/pc8080/rom/vt100/VT100.json"/>
<ram id="ram" addr="0x2000" size="0x0C00"/>
<video id="video" screenWidth="1600" screenHeight="960" smoothing="false"
fontROM="/devices/pc8080/rom/vt100/23-018E2.json" fontColor="white" cellWidth="10" cellHeight="10"
bufferAddr="0x2000" bufferRAM="true" bufferFormat="vt100" bufferCols="80" bufferRows="24" pos="left" padding="8px">
<menu>
<title>VT100 Screen</title>
<control type="container" pos="right">
<control type="rled" label="ON LINE" binding="online" padleft="8px"/>
<control type="rled" label="LOCAL" binding="local" padleft="8px"/>
<control type="rled" label="LOCKED" binding="locked" padleft="8px"/>
<control type="rled" label="L1" binding="l1" padleft="8px"/>
<control type="rled" label="L2" binding="l2" padleft="8px"/>
<control type="rled" label="L3" binding="l3" padleft="8px"/>
<control type="rled" label="L4" binding="l4" padleft="8px"/>
<control type="button" binding="fullScreen" padleft="8px;line-height:1em">Full Screen</control>
</control>
</menu>
</video>
<chipset id="chipset" model="VT100"/>
<keyboard id="keyboard"/>
<panel ref="/devices/pc8080/panel/wide.xml"/>
<debugger id="debugger" messages="mem" commands="s 8086"/>
</machine>

View file

@ -3,12 +3,12 @@
<machine id="vt100" class="pc8080" border="1" pos="center" background="#FAEBD7">
<name pos="center">VT100 Terminal</name>
<computer id="computer" busWidth="16"/>
<cpu id="cpu8080" model="8080" cycles="2764798"/>
<cpu id="cpu8080" model="8080" cycles="2764800"/>
<rom id="rom" addr="0x0000" size="0x2000" file="/devices/pc8080/rom/vt100/VT100.json"/>
<ram id="ram" addr="0x2000" size="0x0C00"/>
<video id="video" screenWidth="1600" screenHeight="960" smoothing="false"
fontROM="/devices/pc8080/rom/vt100/23-018E2.json" fontColor="white" cellWidth="10" cellHeight="10"
bufferAddr="0x2000" bufferRAM="true" bufferFormat="vt100" bufferCols="80" bufferRows="24" pos="left" padding="8px">
bufferAddr="0x2000" bufferRAM="true" bufferFormat="vt100" bufferCols="80" bufferRows="24" padding="8px">
<menu>
<title>VT100 Screen</title>
<control type="container" pos="right">
@ -25,6 +25,4 @@
</video>
<chipset id="chipset" model="VT100"/>
<keyboard id="keyboard"/>
<panel ref="/devices/pc8080/panel/wide.xml"/>
<debugger id="debugger" messages="port|mem" commands="s 8086"/>
</machine>

View file

@ -64,6 +64,8 @@ and passed on to the PC8080 Debugger. Here are the rebuild steps:
grep -E "[0-9]+ [0-9A-D]+.*;;" VT100.lst | sed -E "s/ *[0-9]+ ([0-9A-F]+).*;(;.*)/ \1 . \2/" > VT100.map
filedump --file=VT100.bin --format=bytes --output=VT100.json --comments --overwrite
You can omit `--comments` to reduce the size of the [VT100.json](VT100.json) file.
Some [VT100.asm](VT100.asm) clean-up remains, because there are still chunks of data that were incorrectly disassembled as code.
From a reassembly standpoint, it doesn't matter too much, because such instructions get reassembled into the same original binary
patterns, but from a readability standpoint, it's a nuisance.

View file

@ -3703,8 +3703,8 @@ X18d7: in 42h
jnz X18d7
mvi a,2fh ;; Write 0x2fh (standby) to nvr latch
out 62h
lxi h,X21d3 ;; HL=X21d3
mvi b,0eh ;; B= 14 -- we're reading 14 bits
lxi h,X21d3 ;; HL = X21d3
mvi b,0eh ;; B = 14 -- we're reading 14 bits
X18e6: in 42h
ana c
jz X18e6
@ -3726,7 +3726,7 @@ X1900: in 42h
jnz X18f6 ;; read next bit
mvi a,2fh ;; send standby
out 62h
lxi d,X21d3 ;; DE=0x21d3
lxi d,X21d3 ;; DE = 0x21d3
mvi b,0eh ;; B = 14
lxi h,X0000 ;; HL = 0
X1916: dad h ;;

File diff suppressed because one or more lines are too long

View file

@ -631,7 +631,7 @@ FileDump.prototype.loadMap = function(sMapFile, done)
done(new Error("unrecognized line (" + s + ") in MAP file: " + sMapName), null);
return;
}
sMapData = JSON.stringify(aSymbols);
sMapData = obj.fJSONComments? JSON.stringify(aSymbols, null, 2) : JSON.stringify(aSymbols);
if (sMapData) {
obj.json = '{' + obj.json + ',"symbols":' + sMapData + '}';
}

View file

@ -171,10 +171,10 @@ ChipSet.SI1978 = {
* to yield a 361.69ns clock period for the 8080 CPU, which means the CPU is running at 2.76Mhz (cycles per second).
* Hence the CPU component in the VT100's machine.xml is defined as:
*
* <cpu id="cpu8080" model="8080" cycles="2764798"/>
* <cpu id="cpu8080" model="8080" cycles="2764800"/>
*
* Beyond that, we don't really care about that particular 8224. I only mention it because knowing the CPU frequency
* is helpful for simulating some of the other circuits below that we DO care about.
* where 2764800 = 24883200 / 9. Beyond that, we don't really care about that particular 8224. I only mention it
* because knowing the CPU frequency is helpful for simulating some of the other circuits below that we DO care about.
*/
ChipSet.VT100 = {
MODEL: 100.0,
@ -189,13 +189,24 @@ ChipSet.VT100 = {
NVR_CLK: 0x40, // NVR CLOCK if SET
KBD_XMIT: 0x80 // KBD XMIT BUFFER empty if SET
},
BRIGHTNESS_LATCH: {
BRIGHTNESS: {
PORT: 0x42, // write-only
INIT: 0x00 // for lack of a better guess
},
NVR_LATCH: {
PORT: 0x62, // 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
},
DC012: { // generates scan counts for the Video Processor
PORT: 0xA2, // write-only
@ -220,8 +231,8 @@ ChipSet.VT100 = {
*
* 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 is 33.64706us)
* LBA7: 31.77778us (when LBA7 is high, for a period is 63.55556us)
* 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
@ -345,11 +356,13 @@ ChipSet.SI1978.init = [
ChipSet.VT100.init = [
[
ChipSet.VT100.BRIGHTNESS_LATCH.INIT,
ChipSet.VT100.NVR_LATCH.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
],
[
0, 0, 0, 0, new Array(100)
]
];
@ -381,7 +394,8 @@ 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.bBrightnessLatch, this.bNVRLatch, this.bFlagsBuffer, this.bDC012, this.bDC011]);
state.set(0, [this.bBrightness, this.bFlagsBuffer, this.bDC012, this.bDC011]);
state.set(1, [this.dNVRAddr, this.wNVRData, this.bNVRLatch, this.bNVROut, this.aNVRWords]);
break;
}
return state.data();
@ -411,11 +425,16 @@ ChipSet.prototype.restore = function(data)
this.bSound2 = a[6];
return true;
case ChipSet.VT100.MODEL:
this.bBrightnessLatch = a[0];
this.bNVRLatch = a[1];
this.bBrightness = a[0];
this.bFlagsBuffer = a[2];
this.bDC012 = a[3];
this.bDC011 = a[4];
a = data[1];
this.dNVRAddr = a[0]; // 20-bit address
this.wNVRData = a[1]; // 14-bit word
this.bNVRLatch = a[2]; // 1 byte
this.bNVROut = a[3]; // 1 bit
this.aNVRWords = a[4]; // 100 14-bit words
return true;
}
}
@ -636,6 +655,88 @@ ChipSet.prototype.getVT100LBA = function(nBit)
return (this.cpu.getCycles() & (1 << (nBit - 1))) << 1;
};
/**
* getNVRAddr()
*
* @return {number}
*/
ChipSet.prototype.getNVRAddr = function()
{
var i;
var tens = 0, ones = 0;
var addr = ~this.dNVRAddr;
for (i = 0; i < 10; i++) {
if (addr & 0x1) tens = 9-i;
addr >>= 1;
}
for (i = 0; i < 10; i++) {
if (addr & 0x1) ones = 9-i;
addr >>= 1;
}
addr = tens*10 + ones;
this.assert(addr >= 0 && addr < this.aNVRWords.length);
return addr;
};
/**
* doNVRCommand()
*/
ChipSet.prototype.doNVRCommand = function()
{
var addr, data;
var bit = this.bNVRLatch & 0x1;
var bCmd = (this.bNVRLatch >> 1) & 0x7;
switch(bCmd) {
case ChipSet.VT100.NVR.CMD.STANDBY:
break;
case ChipSet.VT100.NVR.CMD.ACCEPT_ADDR:
this.dNVRAddr = (this.dNVRAddr << 1) | bit;
break;
case ChipSet.VT100.NVR.CMD.ERASE:
addr = this.getNVRAddr();
this.aNVRWords[addr] = ChipSet.VT100.NVR.WORDMASK;
this.printMessage("doNVRCommand(): erase data at addr " + str.toHexWord(addr));
break;
case ChipSet.VT100.NVR.CMD.ACCEPT_DATA:
this.wNVRData = (this.wNVRData << 1) | bit;
break;
case ChipSet.VT100.NVR.CMD.WRITE:
addr = this.getNVRAddr();
data = this.wNVRData & ChipSet.VT100.NVR.WORDMASK;
this.aNVRWords[addr] = data;
this.printMessage("doNVRCommand(): write data " + str.toHexWord(data) + " to addr " + str.toHexWord(addr));
break;
case ChipSet.VT100.NVR.CMD.READ:
addr = this.getNVRAddr();
data = this.aNVRWords[addr];
/*
* Since we don't explicitly initialize aNVRWords[], we pretend any uninitialized words contains WORDMASK.
*/
if (data == null) data = ChipSet.VT100.NVR.WORDMASK;
this.wNVRData = data;
this.printMessage("doNVRCommand(): read data " + str.toHexWord(data) + " from addr " + str.toHexWord(addr));
break;
case ChipSet.VT100.NVR.CMD.SHIFT_OUT:
this.wNVRData <<= 1;
/*
* Since WORDMASK is 0x3fff, this will mask the shifted data with 0x4000, which is the bit we want to isolate.
*/
this.bNVROut = this.wNVRData & (ChipSet.VT100.NVR.WORDMASK + 1);
break;
default:
this.printMessage("doNVRCommand(): unrecognized command " + str.toHexByte(bCmd));
break;
}
};
/**
* inVT100FlagsBuffer(port, addrFrom)
*
@ -649,23 +750,35 @@ ChipSet.prototype.inVT100FlagsBuffer = function(port, addrFrom)
/*
* The NVR_CLK bit is driven by LBA7 (ie, bit 7 from Line Buffer Address generation); see the DC011 discussion above.
*/
var b = this.bFlagsBuffer = (this.bFlagsBuffer & ~ChipSet.VT100.FLAGS_BUFFER.NVR_CLK) | (this.getVT100LBA(7)? ChipSet.VT100.FLAGS_BUFFER.NVR_CLK : 0);
var b = this.bFlagsBuffer;
b &= ~ChipSet.VT100.FLAGS_BUFFER.NVR_CLK;
if (this.getVT100LBA(7)) {
b |= ChipSet.VT100.FLAGS_BUFFER.NVR_CLK;
if (b != this.bFlagsBuffer) {
this.doNVRCommand();
}
}
b &= ~ChipSet.VT100.FLAGS_BUFFER.NVR_DATA;
if (this.bNVROut) {
b |= ChipSet.VT100.FLAGS_BUFFER.NVR_DATA;
}
this.bFlagsBuffer = b;
this.printMessageIO(port, null, addrFrom, "FLAGS.BUFFER", b, true);
return b;
};
/**
* outVT100BrightnessLatch(port, b, addrFrom)
* outVT100Brightness(port, b, addrFrom)
*
* @this {ChipSet}
* @param {number} port (0x42)
* @param {number} b
* @param {number} [addrFrom] (not defined if the Debugger is trying to write the specified port)
*/
ChipSet.prototype.outVT100BrightnessLatch = function(port, b, addrFrom)
ChipSet.prototype.outVT100Brightness = function(port, b, addrFrom)
{
this.printMessageIO(port, b, addrFrom, "BRIGHTNESS.LATCH", null, true);
this.bBrightnessLatch = b;
this.printMessageIO(port, b, addrFrom, "BRIGHTNESS", null, true);
this.bBrightness = b;
};
/**
@ -733,7 +846,7 @@ ChipSet.VT100.portsInput = {
};
ChipSet.VT100.portsOutput = {
0x42: ChipSet.prototype.outVT100BrightnessLatch,
0x42: ChipSet.prototype.outVT100Brightness,
0x62: ChipSet.prototype.outVT100NVRLatch,
0xA2: ChipSet.prototype.outVT100DC012,
0xC2: ChipSet.prototype.outVT100DC011

View file

@ -230,30 +230,31 @@ if (DEBUGGER) {
*/
Debugger.COMMANDS = {
'?': "help/print",
'a [#]': "assemble", // TODO: Implement this command someday
'b [#]': "breakpoint", // multiple variations (use b? to list them)
'c': "clear output",
'd [#]': "dump memory", // additional syntax: d [#] [l#], where l# is a number of bytes to dump
'e [#]': "edit memory",
'f': "frequencies",
'g [#]': "go [to #]",
'h': "halt",
'i [#]': "input port #",
'if': "eval expression",
'k': "stack trace",
"ln": "list nearest symbol(s)",
'm': "messages",
'o [#]': "output port #",
'p': "step over", // other variations: pr (step and dump registers)
'print': "print expression",
'r': "dump/set registers",
'reset': "reset machine",
's': "set options",
't [#]': "trace", // other variations: tr (trace and dump registers)
'u [#]': "unassemble",
'v': "print version",
'var': "assign variable"
'?': "help/print",
'a [#]': "assemble", // TODO: Implement this command someday
'b [#]': "breakpoint", // multiple variations (use b? to list them)
'c': "clear output",
'd [#]': "dump memory", // additional syntax: d [#] [l#], where l# is a number of bytes to dump
'e [#]': "edit memory",
'f': "frequencies",
'g [#]': "go [to #]",
'h': "halt",
'i [#]': "input port #",
'if': "eval expression",
'int [#]': "request interrupt",
'k': "stack trace",
"ln": "list nearest symbol(s)",
'm': "messages",
'o [#]': "output port #",
'p': "step over", // other variations: pr (step and dump registers)
'print': "print expression",
'r': "dump/set registers",
'reset': "reset machine",
's': "set options",
't [#]': "trace", // other variations: tr (trace and dump registers)
'u [#]': "unassemble",
'v': "print version",
'var': "assign variable"
};
Debugger.STYLE_8080 = 8080;
@ -3288,7 +3289,7 @@ if (DEBUGGER) {
{
var s = "commands:";
for (var sCommand in Debugger.COMMANDS) {
s += '\n' + str.pad(sCommand, 7) + Debugger.COMMANDS[sCommand];
s += '\n' + str.pad(sCommand, 9) + Debugger.COMMANDS[sCommand];
}
if (!this.checksEnabled()) s += "\nnote: frequency/history disabled if no exec breakpoints";
this.println(s);
@ -3799,6 +3800,26 @@ if (DEBUGGER) {
}
};
/**
* doInt(sLevel)
*
* @this {Debugger}
* @param {string} sLevel
* @return {boolean} true if success, false if error
*/
Debugger.prototype.doInt = function(sLevel)
{
if (!this.cpu.getIF()) {
this.println("interrupts disabled (use rif=1 to enable)");
return false;
}
var nLevel = this.parseExpression(sLevel);
if (nLevel == null) return false;
this.println("requesting interrupt level " + nLevel);
this.cpu.requestINTR(nLevel);
return true;
};
/**
* doVar(sCmd)
*
@ -4686,6 +4707,12 @@ if (DEBUGGER) {
}
break;
}
if (asArgs[0] == "int") {
if (!this.doInt(asArgs[1])) {
result = false;
}
break;
}
this.doInput(asArgs[1]);
break;
case 'k':

View file

@ -8,224 +8,227 @@ typeof b){var k="",l;for(l in b)b.hasOwnProperty(l)&&(k&&(k+="&"),k+=l+"="+encod
function ra(){return window?window.navigator.userAgent:""}function v(a){window&&window.alert(a)}function sa(a){var b=!1;window&&(b=window.confirm(a));return b}var ta=null;function ua(){if(null==ta){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}ta=a}return ta}
function va(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}function wa(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function xa(a){if(window){var b=ra();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 ya(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(d,0):c()}d()}
function Ea(a,b){function c(){b(100===d)&&(e=setTimeout(c,d),d=100)}var d=0,e=null,f=!1;a.onmousedown=function(){f||e||(d=500,c())};a.ontouchstart=function(){e||(d=500,c())};a.onmouseup=a.onmouseout=function(){e&&(clearTimeout(e),e=null)};a.ontouchend=a.ontouchcancel=function(){e&&(clearTimeout(e),e=null);f=!0}}var Fa={init:[],show:[],exit:[]},Ga=!1,Ha=!0;function Ia(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function Ja(a){Fa.init.push(a)}
function Ma(a){if(Ha)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){v(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function Na(a){!Ha&&a?(Ha=!0,Ga&&Oa("init")):Ha=a}function Oa(a){Fa[a]&&Ma(Fa[a])}Ia("onload",function(){Ga=!0;Ma(Fa.init)});Ia("onpageshow",function(){Ma(Fa.show)});Ia(xa("Opera")||xa("iOS")?"onunload":"onbeforeunload",function(){Ma(Fa.exit)});
function y(a,b,c,d){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.dc=b.comment;this.oc=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.Qb=this.id.substr(0,b),this.$a=this.id.substr(b+1)):this.$a=this.id;this[a]=c;this.B={hb:!1,eb:!1,Ob:!1,pa:!1,gb:!1};this.Gb=null;this.B.gb=!1;this.K={};this.G=null;this.ka=d||0;Pa.push(this)}var Qa=void 0,Ra={};
if(window){Qa||(Qa=window.location.search.substr(1));for(var Sa,Wa=/\+/g,Xa=/([^&=]+)=?([^&]*)/g;Sa=Xa.exec(Qa);)Ra[decodeURIComponent(Sa[1].replace(Wa," "))]=decodeURIComponent(Sa[2].replace(Wa," "))}function Ya(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
function Ka(a){if(Ha)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){v(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function Na(a){!Ha&&a?(Ha=!0,Ga&&Oa("init")):Ha=a}function Oa(a){Fa[a]&&Ka(Fa[a])}Ia("onload",function(){Ga=!0;Ka(Fa.init)});Ia("onpageshow",function(){Ka(Fa.show)});Ia(xa("Opera")||xa("iOS")?"onunload":"onbeforeunload",function(){Ka(Fa.exit)});
function y(a,b,c,d){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.hc=b.comment;this.sc=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.Tb=this.id.substr(0,b),this.cb=this.id.substr(b+1)):this.cb=this.id;this[a]=c;this.B={kb:!1,hb:!1,Rb:!1,ra:!1,jb:!1};this.Jb=null;this.B.jb=!1;this.L={};this.G=null;this.na=d||0;Pa.push(this)}var Qa=void 0,Ra={};
if(window){Qa||(Qa=window.location.search.substr(1));for(var Sa,Ta=/\+/g,Xa=/([^&=]+)=?([^&]*)/g;Sa=Xa.exec(Qa);)Ra[decodeURIComponent(Sa[1].replace(Ta," "))]=decodeURIComponent(Sa[2].replace(Ta," "))}function Ya(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
function Za(a,b){b||(b=y);a.prototype=Ya(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}var Pa=[],$a={};function ab(a,b,c){$a[a]&&b&&($a[a][b]=c)}function bb(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<Pa.length;b++){var d=Pa[b];a&&d.id.indexOf(a)||c.push(d)}return c}
function cb(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<Pa.length;d++)if(c)c==Pa[d]&&(c=null);else if(!(a!=Pa[d].type||b&&Pa[d].id.indexOf(b)))return Pa[d]}return null}function B(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){v(c.message+" ("+a+")")}return b}
function db(a,b){for(var c=C(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var e=c[d].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var k=g.split(" "),l=0;l<k.length;l++)switch(g=k[l],g){case "pc8080-binding":(g=B(h))&&g.binding&&a.ma(g.type,g.binding,h,g.value),l=k.length}}}}
function cb(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<Pa.length;d++)if(c)c==Pa[d]&&(c=null);else if(!(a!=Pa[d].type||b&&Pa[d].id.indexOf(b)))return Pa[d]}return null}function z(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){v(c.message+" ("+a+")")}return b}
function db(a,b){for(var c=C(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var e=c[d].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var k=g.split(" "),l=0;l<k.length;l++)switch(g=k[l],g){case "pc8080-binding":(g=z(h))&&g.binding&&a.pa(g.type,g.binding,h,g.value),l=k.length}}}}
function C(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
y.prototype={constructor:y,parent:null,toString:function(){return this.name?this.name:this.id||this.type},ma:function(a,b,c){switch(b){case "clear":return this.K[b]||(this.K[b]=c,c.onclick=function(a){return function(){a.K.print&&(a.K.print.value="")}}(this)),!0;case "print":return this.K[b]||(this.Aa=this.K[b]=c,c.value="",this.g=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
this.fa=function(a){this.g(a,this.$a)}),!0;default:return!1}},log:function(){},g:function(){},status:function(a){this.g(this.$a+": "+a)},fa:function(a,b,c){c=c||this.type;b||v((c?c+": ":"")+a)},Ca:function(){return this.B.pa=!0},Ia:function(a,b){b&&(this.B.pa=!1);return!0}};function D(a,b,c,d,e,f){var h=!0;a.G&&(!0===h?h=0:null==h&&(h=a.ka),eb(a.G,a,b,c,d,e,f,h))}function fb(a,b,c){a.G&&(!0===c||gb(a,c|0))&&a.G.message(b,void 0)}
function gb(a,b){if(a.G){a===a.G?b|=0:b=b||a.ka;var c=a.G.ka&b;return!!b&&c===b||!!(c&a.G.Mc)}return!1}function hb(a,b){if(a.B.Ob)return a.B.eb&&(a.B.eb=!1),a.B.Ob=!1;if(a.B.gb)return a.g(a.toString()+" error"),!1;a.B.eb=b;return a.B.eb}function ib(a,b){a.B.eb&&(b?a.B.Ob=!0:void 0===b&&a.g(a.toString()+" busy"));return a.B.eb}function F(a){if(!a.B.gb&&(a.B.hb=!0,a.B.hb)){var b=a.Gb;a.Gb=null;b&&b()}}function lb(a,b){b&&(a.B.hb?b():a.Gb=b);return a.B.hb}function mb(a,b){a.B.gb=!0;a.fa(b)}
y.prototype={constructor:y,parent:null,toString:function(){return this.name?this.name:this.id||this.type},pa:function(a,b,c){switch(b){case "clear":return this.L[b]||(this.L[b]=c,c.onclick=function(a){return function(){a.L.print&&(a.L.print.value="")}}(this)),!0;case "print":return this.L[b]||(this.Aa=this.L[b]=c,c.value="",this.g=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
this.fa=function(a){this.g(a,this.cb)}),!0;default:return!1}},log:function(){},g:function(){},status:function(a){this.g(this.cb+": "+a)},fa:function(a,b,c){c=c||this.type;b||v((c?c+": ":"")+a)},Ca:function(){return this.B.ra=!0},Ja:function(a,b){b&&(this.B.ra=!1);return!0}};function D(a,b,c,d,e,f){var h=!0;a.G&&(!0===h?h=0:null==h&&(h=a.na),eb(a.G,a,b,c,d,e,f,h))}function fb(a,b,c){a.G&&(!0===c||gb(a,c|0))&&a.G.message(b,void 0)}
function gb(a,b){if(a.G){a===a.G?b|=0:b=b||a.na;var c=a.G.na&b;return!!b&&c===b||!!(c&a.G.Wc)}return!1}function hb(a,b){if(a.B.Rb)return a.B.hb&&(a.B.hb=!1),a.B.Rb=!1;if(a.B.jb)return a.g(a.toString()+" error"),!1;a.B.hb=b;return a.B.hb}function ib(a,b){a.B.hb&&(b?a.B.Rb=!0:void 0===b&&a.g(a.toString()+" busy"));return a.B.hb}function E(a){if(!a.B.jb&&(a.B.kb=!0,a.B.kb)){var b=a.Jb;a.Jb=null;b&&b()}}function jb(a,b){b&&(a.B.kb?b():a.Jb=b);return a.B.kb}function mb(a,b){a.B.jb=!0;a.fa(b)}
var nb="undefined"!==typeof ArrayBuffer,ob=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,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,0,1,1,0,1,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,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,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,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,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,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
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){y.call(this,"Panel",a,pb)}Za(pb);m=pb.prototype;m.ma=function(a,b,c,d){return this.u&&this.u.ma(a,b,c,d)||this.b&&this.b.ma(a,b,c,d)||this.da&&this.da.ma(a,b,c,d)||this.G&&this.G.ma(a,b,c,d)?!0:this.parent.ma.call(this,a,b,c,d)};m.Ma=function(a,b,c,d){this.u=a;this.w=b;this.b=c;this.G=d;this.da=qb(a,"Keyboard")};m.Ca=function(a,b){b||rb();return!0};m.Ia=function(){return!0};m.Da=function(){};
function rb(){for(var a=!1,b=C(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=B(d),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<Pa.length;h++)if(Pa[h].id===f){f=Pa[h];break a}f=null}f||(a=!0,f=new pb(e));db(f,d);a&&F(f)}}Ja(rb);
function sb(a,b,c){y.call(this,"Bus",a,sb);this.b=b;this.G=c;this.I=a.busWidth||16;this.T=Math.pow(2,this.I);this.A=this.T-1|0;this.ja=16>=this.I?10:20>=this.I?12:24>=this.I?14:15;this.Ba=1<<this.ja;this.W=this.Ba>>2;this.w=this.Ba-1;this.L=this.T/this.Ba|0;this.J=this.L-1;this.u=[];this.C=[];this.F=this.H=!1;this.Y=[];this.aa=[];a=new G;tb(a,this.G);this.U=Array(this.L);for(b=0;b<this.L;b++)this.U[b]=a;F(this)}Za(sb);m=sb.prototype;m.reset=function(){};m.Ca=function(a,b){b||this.reset();return!0};
function ub(a,b,c,d){for(var e=b,f=c,h=e>>>a.ja;0<f&&h<a.U.length;){var g=a.U[h],k=h*a.Ba,l=a.Ba-(e-k);l>f&&(l=f);if(g&&g.size){if(g.type==d){if(e+f<=g.D)return g.Cb+=g.D-e,g.D=e,!0;if(e>=g.D+g.Cb){l=g.size-(e-k);l>f&&(l=f);g.Cb=e-g.D+l;e=k+a.Ba;f-=l;h++;continue}}return vb(1,e,f)}e=new G(e,l,a.Ba,d);tb(e,a.G,g);a.U[h++]=e;e=k+a.Ba;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+wb[d]+" at "+r(b)),!0):vb(2,b,c)}m.X=function(a){return this.U[(a&this.A)>>>this.ja].ob(a&this.w,a)};
function xb(a,b){return a.U[(b&a.A)>>>a.ja].Ab(b&a.w,b)}m.Na=function(a){var b=a&this.w,c=(a&this.A)>>>this.ja;return b!=this.w?this.U[c].pc(b,a):this.U[c++].ob(b,a)|this.U[c&this.J].ob(0,a+1)<<8};function yb(a,b){var c=b&a.w,d=(b&a.A)>>>a.ja;return c!=a.w?a.U[d].Ub(c,b):a.U[d++].Ab(c,b)|a.U[d&a.J].Ab(0,b+1)<<8}m.na=function(a,b){this.U[(a&this.A)>>>this.ja].qb(a&this.w,b&255,a)};function zb(a,b,c){a.U[(b&a.A)>>>a.ja].Db(b&a.w,c&255,b)}
m.Mb=function(a,b){var c=a&this.w,d=(a&this.A)>>>this.ja;c!=this.w?this.U[d].rc(c,b&65535,a):(this.U[d++].qb(c,b&255,a),this.U[d&this.J].qb(0,b>>8&255,a+1))};function Ab(a,b){if(void 0===b)return a.F=!a.F,a.F;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){var 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]?v("Input port "+r(k)+" already registered"):f.u[k]=[g,!1]}}
function Cb(a,b,c){for(var d=1,e=0,f=0;0<d;){var h=a.u[b],g=a.Y[b]||1,k=1==g?255:2==g?65535:-1,l=k;void 0!==h?(h[0]&&(l=h[0](b,c),void 0===l?l=k:l&=k),a.G&&a.F!=h[1]&&Db(a.G,b,l)):a.G&&(eb(a.G,a,b,null,c),a.F&&Db(a.G,b,l));e|=l<<f;f+=g<<3;b+=g;d-=g}return e}function Eb(a,b){if(void 0===b)return a.H=!a.H,a.H;void 0===a.C[b]&&(a.C[b]=[null,!1]);a.C[b][1]=!a.C[b][1];return a.C[b][1]}
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){y.call(this,"Panel",a,pb)}Za(pb);m=pb.prototype;m.pa=function(a,b,c,d){return this.u&&this.u.pa(a,b,c,d)||this.b&&this.b.pa(a,b,c,d)||this.da&&this.da.pa(a,b,c,d)||this.G&&this.G.pa(a,b,c,d)?!0:this.parent.pa.call(this,a,b,c,d)};m.Na=function(a,b,c,d){this.u=a;this.A=b;this.b=c;this.G=d;this.da=qb(a,"Keyboard")};m.Ca=function(a,b){b||rb();return!0};m.Ja=function(){return!0};m.Da=function(){};
function rb(){for(var a=!1,b=C(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=z(d),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<Pa.length;h++)if(Pa[h].id===f){f=Pa[h];break a}f=null}f||(a=!0,f=new pb(e));db(f,d);a&&E(f)}}Ja(rb);
function sb(a,b,c){y.call(this,"Bus",a,sb);this.b=b;this.G=c;this.I=a.busWidth||16;this.N=Math.pow(2,this.I);this.w=this.N-1|0;this.la=16>=this.I?10:20>=this.I?12:24>=this.I?14:15;this.Ba=1<<this.la;this.U=this.Ba>>2;this.A=this.Ba-1;this.K=this.N/this.Ba|0;this.J=this.K-1;this.u=[];this.C=[];this.D=this.H=!1;this.Y=[];this.aa=[];a=new G;tb(a,this.G);this.V=Array(this.K);for(b=0;b<this.K;b++)this.V[b]=a;E(this)}Za(sb);m=sb.prototype;m.reset=function(){};m.Ca=function(a,b){b||this.reset();return!0};
function ub(a,b,c,d){for(var e=b,f=c,h=e>>>a.la;0<f&&h<a.V.length;){var g=a.V[h],k=h*a.Ba,l=a.Ba-(e-k);l>f&&(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.Ba;f-=l;h++;continue}}return vb(1,e,f)}e=new G(e,l,a.Ba,d);tb(e,a.G,g);a.V[h++]=e;e=k+a.Ba;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+wb[d]+" at "+r(b)),!0):vb(2,b,c)}m.X=function(a){return this.V[(a&this.w)>>>this.la].rb(a&this.A,a)};
function xb(a,b){return a.V[(b&a.w)>>>a.la].Db(b&a.A,b)}m.Oa=function(a){var b=a&this.A,c=(a&this.w)>>>this.la;return b!=this.A?this.V[c].tc(b,a):this.V[c++].rb(b,a)|this.V[c&this.J].rb(0,a+1)<<8};function yb(a,b){var c=b&a.A,d=(b&a.w)>>>a.la;return c!=a.A?a.V[d].Xb(c,b):a.V[d++].Db(c,b)|a.V[d&a.J].Db(0,b+1)<<8}m.qa=function(a,b){this.V[(a&this.w)>>>this.la].tb(a&this.A,b&255,a)};function zb(a,b,c){a.V[(b&a.w)>>>a.la].Gb(b&a.A,c&255,b)}
m.Pb=function(a,b){var c=a&this.A,d=(a&this.w)>>>this.la;c!=this.A?this.V[d].vc(c,b&65535,a):(this.V[d++].tb(c,b&255,a),this.V[d&this.J].tb(0,b>>8&255,a+1))};function Ab(a,b){if(void 0===b)return a.D=!a.D,a.D;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){var 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]?v("Input port "+r(k)+" already registered"):f.u[k]=[g,!1]}}
function Cb(a,b,c){for(var d=1,e=0,f=0;0<d;){var h=a.u[b],g=a.Y[b]||1,k=1==g?255:2==g?65535:-1,l=k;void 0!==h?(h[0]&&(l=h[0](b,c),void 0===l?l=k:l&=k),a.G&&a.D!=h[1]&&Db(a.G,b,l)):a.G&&(eb(a.G,a,b,null,c),a.D&&Db(a.G,b,l));e|=l<<f;f+=g<<3;b+=g;d-=g}return e}function Eb(a,b){if(void 0===b)return a.H=!a.H,a.H;void 0===a.C[b]&&(a.C[b]=[null,!1]);a.C[b][1]=!a.C[b][1];return a.C[b][1]}
function Fb(a,b,c){var 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.C[k]?v("Output port "+r(k)+" already registered"):f.C[k]=[g,!1]}}function Gb(a,b,c,d){for(var e=1,f=0;0<e;){var h=a.C[b],g=a.aa[b]||1,k=1==g?255:2==g?65535:-1,k=(c>>>=f)&k;if(void 0!==h){if(h[0])h[0](b,k,d);a.G&&a.H!=h[1]&&Hb(a.G,b,k)}else a.G&&(eb(a.G,a,b,k,d),a.H&&Hb(a.G,b,k));f+=g<<3;b+=g;e-=g}}
function vb(a,b,c){v("Memory block error ("+a+": "+q(b)+","+q(c)+")");return!1}var Qb;if(nb){var Rb=new ArrayBuffer(2);(new DataView(Rb)).setUint16(0,256,!0);Qb=256===(new Uint16Array(Rb))[0]}else Qb=!1;var Sb=Qb;
function G(a,b,c,d){this.id=Tb+=2;this.b=null;this.D=a;this.Cb=b;this.size=c||0;this.type=d||Ub;this.K=d==Vb;tb(this);this.Ja=this.ac=!1;if(c)if(nb)this.F=new ArrayBuffer(c),this.H=new DataView(this.F,0,c),this.w=new Uint8Array(this.F,0,c),this.J=new Uint16Array(this.F,0,c>>1),this.b=new Int32Array(this.F,0,c>>2),Wb(this,Sb?Xb:Yb);else{this.b=Array(c>>2);for(a=0;a<this.b.length;a++)this.b[a]=0;Wb(this,Zb)}else Wb(this)}var Ub=0,Vb=2,wb=["NONE","RAM","ROM","VID","H/W"],Tb=0;
G.prototype={constructor:G,parent:null,Ua:function(a){this.D=a},save:function(){var a,b;if(nb)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.H.getInt32(b<<2,!0);else a=this.b;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(nb)for(b=0;b<a.length;b++)this.H.setInt32(b<<2,a[b],!0);else this.b=a;return this.Ja=!0}return!1},Sa:function(a,b){b?0===this.C++&&$b(this,ac,!1):0===this.u++&&bc(this,ac,!1)},L:function(){this.G&&gb(this.G,129)&&this.G.message("attempt to read invalid block %"+
q(this.D),!0);return 255},A:function(a,b){this.G&&gb(this.G,129)&&this.G.message("attempt to write "+r(b)+" to invalid block %"+q(this.D),!0)},T:function(a,b){return this.ob(a++,b++)|this.ob(a,b)<<8},I:function(a,b,c){this.qb(a++,b&255,c++);this.qb(a,b>>8,c)},ca:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ra:function(a){var b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8},ya:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<<d)|b<<d;this.Ja=!0},
$a:function(a,b){var c=a>>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<<d)|b<<d:(this.b[c]=this.b[c]&16777215|b<<24,c++,this.b[c]=this.b[c]&-256|b>>8);this.Ja=!0},Y:function(a,b){if(this.G&&null!=this.D){var c=this.G;cc(c,this.D+a,1,c.Y)&&c.ia(!0)}return this.Ab(a,b)},ea:function(a,b){if(this.G&&null!=this.D){var c=this.G;cc(c,this.D+a,2,c.Y)&&c.ia(!0)}return this.Ub(a,b)},wa:function(a,b,c){if(this.G&&null!=this.D){var d=this.G;cc(d,this.D+a,1,d.H)&&d.ia(!0)}this.K?this.A(a,b,c):this.Db(a,b,c)},
Fa:function(a,b,c){if(this.G&&null!=this.D){var d=this.G;cc(d,this.D+a,2,d.H)&&d.ia(!0)}this.K?this.A(a,b,c):this.Vb(a,b,c)},W:function(a){return this.w[a]},aa:function(a){return this.w[a]},da:function(a){return this.H.getUint16(a,!0)},oa:function(a){return a&1?this.w[a]|this.w[a+1]<<8:this.J[a>>1]},ua:function(a,b){this.w[a]=b;this.Ja=!0},xa:function(a,b){this.w[a]=b;this.Ja=!0},za:function(a,b){this.H.setUint16(a,b,!0);this.Ja=!0},Ga:function(a,b){a&1?(this.w[a]=b,this.w[a+1]=b>>8):this.J[a>>1]=
b;this.Ja=!0}};function tb(a,b,c){a.G=b;a.u=a.C=0;c&&((a.u=c.u)&&bc(a,ac,!1),(a.C=c.C)&&$b(a,ac,!1))}function dc(a,b){b?0===--a.C&&(a.qb=a.K?a.A:a.Db,a.rc=a.K?a.I:a.Vb):0===--a.u&&(a.ob=a.Ab,a.pc=a.Ub)}function $b(a,b,c){c&&a.C||(a.qb=!a.K&&b[2]||a.A,a.rc=!a.K&&b[3]||a.I);if(c||void 0===c)a.Db=b[2]||a.A,a.Vb=b[3]||a.I}function bc(a,b,c){c&&a.u||(a.ob=b[0]||a.L,a.pc=b[1]||a.T);if(c||void 0===c)a.Ab=b[0]||a.L,a.Ub=b[1]||a.T}function Wb(a,b){b||(b=ec);bc(a,b,void 0);$b(a,b,void 0)}
var ec=[],Zb=[G.prototype.ca,G.prototype.ra,G.prototype.ya,G.prototype.$a],ac=[G.prototype.Y,G.prototype.ea,G.prototype.wa,G.prototype.Fa];if(nb)var Yb=[G.prototype.W,G.prototype.da,G.prototype.ua,G.prototype.za],Xb=[G.prototype.aa,G.prototype.oa,G.prototype.xa,G.prototype.Ga];
function fc(a,b){y.call(this,"CPU",a,fc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.nb=c;this.i.Jb=0;this.i.Ya=d;this.i.Rb=Math.round(this.i.nb/1E4)/100;this.i.Wa=this.i.Rb*this.i.Ya;this.B.sa=!1;this.B.Pb=!1;this.B.$b=a.autoStart;this.B.bc=!1;this.B.fb=!1;this.i.ub=this.i.kb=0;this.i.vb=a.csStart;this.i.jb=a.csInterval;this.i.lb=a.csStop;this.aa=this.Za.bind(this);F(this)}Za(fc);var gc=["power","reset"];m=fc.prototype;
m.Ma=function(a,b,c,d){this.u=a;this.w=b;this.G=d;for(b=0;b<gc.length;b++)(c=this.K[gc[b]])&&this.u.ma(null,gc[b],c);this.L=(b=qb(a,"Video"))&&Math.max(b.jd,b.mc)||60;this.C=qb(a,"ChipSet");a=hc(a,"autoStart");null!=a&&(this.B.$b="true"==a?!0:"false"==a?!1:!!a);F(this)};m.reset=function(){this.i.Jb=0};m.save=function(){return null};m.restore=function(){return!1};
m.Ca=function(a,b){if(!b){if(a&&this.restore){ic(this);if(!this.restore(a))return!1;jc(this)}else this.reset();this.G?this.G.Ua():this.g("No debugger detected")}kc(this);return!0};m.Ia=function(a){return a?this.save():!0};function wc(a){(a.B.$b||!a.G&&void 0===a.K.run)&&a.Za(!0)}m.cc=function(){return 0};function jc(a){void 0===a.i.vb&&(a.i.vb=0);void 0===a.i.jb&&(a.i.jb=-1);void 0===a.i.lb&&(a.i.lb=-1);a.B.fb=0<=a.i.vb&&0<a.i.jb;a.B.fb&&(a.i.ub=0,a.i.kb=a.i.vb-a.I)}
function xc(a,b){if(a.B.fb){var c=!1;a.i.ub=a.i.ub+a.cc()|0;a.i.kb-=b;0>=a.i.kb&&(a.i.kb+=a.i.jb,c=!0);0<=a.i.lb&&a.i.lb<=yc(a)&&(a.i.jb=a.i.lb=-1,jc(a),a.ia(),c=!0);c&&a.g(yc(a)+" cycles: checksum="+q(a.i.ub))}}
m.ma=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.K[b]=c;a=!0;break;case "run":this.K[b]=c;c.onclick=function(){var a;if(a=d.u)if(a=d.u,a.B.pa)a=!0;else{var b=null,c,g=bb(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.B.hb);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.B.pa);c++);c==g.length&&(b=a);v("The "+b.type+" component ("+b.id+") is not "+(b.B.hb?"powered yet":"ready yet"+(b.Gb?" (waiting for notification)":""))+".");a=!1}a&&(d.B.sa?d.ia(!0):d.Za(!0))};a=
!0;break;case "speed":this.K[b]=c;a=!0;break;case "setSpeed":this.K[b]=c,c.onclick=function(){zc(d,d.i.Ya<<1,!0)},c.textContent=this.i.Wa.toFixed(2)+"Mhz",a=!0}return a};function Ac(a,b,c){a.I+=b;c&&(a.F=a.b=0)}
function Bc(a,b){var c=30;c<a.L&&(c=a.L);2>c&&(c=2);var d=1;b&&1<a.i.Ya&&a.i.Va&&(d=a.i.Va/a.i.Rb);a.i.ic=Math.round(1E3/30);a.i.Uc=Math.floor(a.i.nb/c*d);a.i.Sb=Math.floor(a.i.nb/30*d);a.i.kc=Math.floor(a.i.nb/a.L*d);a.i.jc=Math.floor(a.i.nb/2*d);b||(a.i.mb=a.i.Sb,a.i.xb=a.i.kc,a.i.wb=a.i.jc);a.i.Tb=0}function yc(a){return a.I+a.H+a.F-a.b}function ic(a){a.i.Va=0;a.I=a.H=a.F=a.b=0;jc(a);zc(a,1)}
function zc(a,b,c){var d=!1;if(void 0!==b){.8>a.i.Va/a.i.Wa?b=1:d=!0;a.i.Ya=b;b=a.i.Rb*a.i.Ya;if(a.i.Wa!=b){a.i.Wa=b;b=a.i.Wa.toFixed(2)+"Mhz";var e=a.K.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.u&&a.u.Bb()}Ac(a,a.H);a.H=0;a.i.ib=la();a.i.Xa=0;Bc(a);return d}
m.Za=function(a){if(hb(this,!0)){if(!this.B.sa){zc(this);this.u&&this.u.start(this.i.ib,yc(this));this.B.sa=!0;this.B.Pb=!0;this.C&&this.C.start();var b=this.K.run;b&&(b.textContent="Halt");this.u&&(this.u.Da(!0),a&&this.u.Bb(!0))}this.i.Tb>=this.i.nb&&Bc(this,!0);this.i.yb=0;this.i.Ib=la();this.i.Xa&&(a=this.i.Ib-this.i.Xa,a>this.i.ic&&(this.i.ib+=a,this.i.ib>this.i.Ib&&(this.i.ib=this.i.Ib)));try{do{this.pb(this.B.fb?1:this.i.Uc);var c=this.F-this.b;this.H+=c;this.i.yb+=c;Ac(this,0,!0);xc(this,
c);this.i.xb-=c;0>=this.i.xb&&(this.i.xb+=this.i.kc,this.u&&Cc(this.u,this.i.Jb++),this.i.Jb>this.L&&(this.i.Jb=0));this.i.wb-=c;0>=this.i.wb&&(this.i.wb+=this.i.jc,this.u&&this.u.Da());this.i.mb-=c;if(0>=this.i.mb){this.i.mb+=this.i.Sb;break}}while(this.B.sa)}catch(e){this.ia();kc(this);this.u&&this.u.stop(la(),yc(this));hb(this,!1);mb(this,e.stack||e.message);return}c=setTimeout;a=this.aa;this.i.Xa=la();b=this.i.ic;this.i.yb&&(b=Math.round(b*this.i.yb/this.i.Sb));var b=b-(this.i.Xa-this.i.Ib),d=
this.i.Xa-this.i.ib;d&&(this.i.Va=Math.round(this.H/(10*d))/100,864E5<=d&&(this.I=0,zc(this)));if(0>b||this.i.Va<this.i.Wa)b=0;this.i.Tb+=this.i.yb;this.i.Xa+=b;c(a,b)}else kc(this),this.u&&this.u.stop(la(),yc(this))};m.pb=function(){return 0};m.ia=function(a){ib(this,!0);this.F-=this.b;this.b=0;Ac(this,this.H);this.H=0;if(this.B.sa){this.B.sa=!1;this.C&&this.C.stop();var b=this.K.run;b&&(b.textContent="Run")}this.B.Fb=a};function kc(a,b){a.u&&(Cc(a.u,-1),a.u.Da(b))}
function Dc(a){this.Ha=+a.model||8080;fc.call(this,a,1E6);this.T=Ec;ic(this);this.B.Fb=this.B.Nc=!1;this.Y=0;this.J=[];this.W=0;Fc(this)}Za(Dc,fc);function Gc(a,b){a.J.push(b)}m=Dc.prototype;m.reset=function(){this.B.sa&&this.ia();Fc(this);ic(this);this.B.gb=!1;this.parent.reset.call(this)};function Fc(a){a.j=0;a.N=0;a.O=0;a.P=0;a.R=0;a.S=0;a.V=0;a.ha=0;H(a,a.W);Hc(a,0);a.A=0}function Ic(a,b){a.W=b;H(a,b)}
m.cc=function(){var a=this.j+this.N+this.O+this.P+this.R+this.S+this.V|0;return a=a+this.ha+this.M+Jc(this)|0};
m.save=function(){var a=new I(this);J(a,0,[this.j,this.N,this.O,this.P,this.R,this.S,this.V,this.ha,this.M,Jc(this)]);J(a,1,[this.A,this.I,this.i.Ya]);for(var b=this.w,c=0,d=[],e=0;e<b.L;e++){var f=b.U[e];if(f.Ja||f.ac){d[c++]=e;var h=c++;a:if(f=f.save()){for(var g=0,k=0,l=[];g<f.length;){for(var n=f[g],p=g+1;p<f.length&&f[p]===n;)p++;l[k++]=p-g;l[k++]=n;g=p}if(l.length<f.length){f=l;break a}}d[h]=f}}J(a,2,d);return a.data()};
m.restore=function(a){var b=a[0];this.j=b[0];this.N=b[1];this.O=b[2];this.P=b[3];this.R=b[4];this.S=b[5];this.V=b[6];this.ha=b[7]&65535;H(this,b[8]);Hc(this,b[9]);b=a[1];this.A=b[0];this.I=b[1];zc(this,b[3]);a:{b=this.w;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.W){for(var f=0,h=Array(b.W),g=0;g<e.length-1;)for(var k=e[g++],l=e[g++];k--;)h[f++]=l;e=h}f=b.U[d];if(!f||!f.restore(e)){v("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
m.ma=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "BC":case "D":case "E":case "DE":case "H":case "L":case "HL":case "SP":case "PC":case "PS":case "IF":case "SF":case "ZF":case "AF":case "PF":case "CF":this.K[b]=c;this.Y++;d=!0;break;default:d=this.parent.ma.call(this,a,b,c)}return d};function Kc(a){return a.N<<8|a.O}function Lc(a,b){a.N=b>>8&255;a.O=b&255}function Mc(a){return a.P<<8|a.R}function Nc(a,b){a.P=b>>8&255;a.R=b&255}function K(a){return a.S<<8|a.V}
function Oc(a,b){a.S=b>>8&255;a.V=b&255}function H(a,b){a.M=b&65535}function M(a){return a.Z&256?1:0}function Pc(a,b){a.Z=a.Z&255|b}function Qc(a){return ob[a.ba&255]?4:0}function Rc(a){return(a.ba^a.qa)&16?16:0}function Sc(a){return a.Z&255?0:64}function Tc(a){return a.ba&128?128:0}function Jc(a){return a.ta&-214|Tc(a)|Sc(a)|Rc(a)|Qc(a)|M(a)}function Hc(a,b){a.Z=a.ba=a.qa=0;b&1&&(a.Z|=256);b&4||(a.ba|=1);b&16&&(a.qa|=16);b&64||(a.Z|=255);b&128&&(a.ba^=192);a.ta=a.ta&-726|b&512|2}
function Uc(a,b){a.qa=a.j^b;return a.ba=(a.Z=a.j+b)&255}function Vc(a,b){a.qa=a.j^b;return a.ba=(a.Z=a.j+b+(a.Z&256?1:0))&255}function Wc(a,b){a.Z=a.ba=a.qa=a.j&b;(a.j|b)&8&&(a.qa^=16);return a.Z}function Xc(a,b){a.qa=b^255;b=a.ba=b+255&255;a.Z=a.Z&-256|b;return b}function Yc(a,b){a.qa=b;b=a.ba=b+1&255;a.Z=a.Z&-256|b;return b}function Zc(a,b){return a.ba=a.Z=a.qa=a.j|b}function N(a,b){b^=255;a.qa=a.j^b;return a.ba=(a.Z=a.j+b+1^256)&255}
function $c(a,b){b^=255;a.qa=a.j^b;return a.ba=(a.Z=a.j+b+(a.Z&256?0:1)^256)&255}function ad(a,b){return a.ba=a.Z=a.qa=a.j^b}m.X=function(a){return this.w.X(a)};m.na=function(a,b){this.w.na(a,b)};function O(a){var b=a.X(a.M);H(a,a.M+1);return b}function P(a){var b=a.w.Na(a.M);H(a,a.M+2);return b}function Q(a){var b=a.w.Na(a.ha);a.ha=a.ha+2&65535;return b}function R(a,b){a.ha=a.ha-2&65535;a.w.Mb(a.ha,b)}
function S(a,b,c,d){d=d||2;a.K[b]&&(void 0===c&&(mb(a,"Value for "+b+" is invalid"),a.ia()),c=!a.B.sa||a.B.bc?q(c,d):"--------".substr(0,d),a.K[b].textContent!=c&&(a.K[b].textContent=c))}
m.Da=function(a){this.Y&&(a||!this.B.sa||this.B.bc)&&(S(this,"A",this.j),S(this,"B",this.N),S(this,"C",this.O),S(this,"BC",Kc(this),4),S(this,"D",this.P),S(this,"E",this.R),S(this,"DE",Mc(this),4),S(this,"H",this.S),S(this,"L",this.V),S(this,"HL",K(this),4),S(this,"SP",this.ha,4),S(this,"PC",this.M,4),a=Jc(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.K.speed)a.textContent=
this.B.sa&&this.i.Va?this.i.Va.toFixed(2)+"Mhz":"Stopped"};
m.pb=function(a){this.B.Fb=!0;var b=this.B.Nc=this.G&&td(this.G),c=a?this.B.Pb?0:1:-1;this.B.Pb=!1;this.F=this.b=a;do{if(this.A){var d;this.A&8&&this.ta&512?(d=199|(this.A&7)<<3,this.A&=-16,this.ta&=-513,this.T[d].call(this),d=!0):d=!1;if(d){if(!a){this.g("interrupt dispatched");break}}else if(this.A&16){this.b=0;break}}if(b){if(ud(this.G,this.M,c)){this.ia();break}c=1}this.T[O(this)].call(this)}while(0<this.b);return this.B.Fb?this.F-this.b:void 0===this.B.Fb?0:-1};
Ja(function(){for(var a=C(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new Dc(d);db(d,c)}});function vd(){this.b-=4}function wd(){H(this,P(this));this.b-=10}function xd(){H(this,Q(this));this.b-=10}function yd(){var a=P(this);R(this,this.M);H(this,a);this.b-=17}
var Ec=[vd,function(){Lc(this,P(this));this.b-=10},function(){this.na(Kc(this),this.j);this.b-=7},function(){Lc(this,Kc(this)+1);this.b-=5},function(){this.N=Yc(this,this.N);this.b-=5},function(){this.N=Xc(this,this.N);this.b-=5},function(){this.N=O(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255|a>>8;Pc(this,a&256);this.b-=4},vd,function(){var a;Oc(this,a=K(this)+Kc(this));Pc(this,a>>8&256);this.b-=10},function(){this.j=this.X(Kc(this));this.b-=7},function(){Lc(this,Kc(this)-1);this.b-=
5},function(){this.O=Yc(this,this.O);this.b-=5},function(){this.O=Xc(this,this.O);this.b-=5},function(){this.O=O(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;Pc(this,a);this.b-=4},vd,function(){Nc(this,P(this));this.b-=10},function(){this.na(Mc(this),this.j);this.b-=7},function(){Nc(this,Mc(this)+1);this.b-=5},function(){this.P=Yc(this,this.P);this.b-=5},function(){this.P=Xc(this,this.P);this.b-=5},function(){this.P=O(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255|
M(this);Pc(this,a&256);this.b-=4},vd,function(){var a;Oc(this,a=K(this)+Mc(this));Pc(this,a>>8&256);this.b-=10},function(){this.j=this.X(Mc(this));this.b-=7},function(){Nc(this,Mc(this)-1);this.b-=5},function(){this.R=Yc(this,this.R);this.b-=5},function(){this.R=Xc(this,this.R);this.b-=5},function(){this.R=O(this);this.b-=7},function(){var a=this.j<<8;this.j=(M(this)<<8|this.j)>>1;Pc(this,a&256);this.b-=4},vd,function(){Oc(this,P(this));this.b-=10},function(){var a=P(this);this.w.Mb(a,K(this));this.b-=
16},function(){Oc(this,K(this)+1);this.b-=5},function(){this.S=Yc(this,this.S);this.b-=5},function(){this.S=Xc(this,this.S);this.b-=5},function(){this.S=O(this);this.b-=7},function(){var a=0,b=M(this);if(Rc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=Uc(this,a);Pc(this,b?256:0);this.b-=4},vd,function(){var a;Oc(this,a=K(this)+K(this));Pc(this,a>>8&256);this.b-=10},function(){var a;a=P(this);a=this.w.Na(a);Oc(this,a);this.b-=16},function(){Oc(this,K(this)-1);this.b-=5},function(){this.V=
Yc(this,this.V);this.b-=5},function(){this.V=Xc(this,this.V);this.b-=5},function(){this.V=O(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},vd,function(){this.ha=P(this)&65535;this.b-=10},function(){this.na(P(this),this.j);this.b-=13},function(){this.ha=this.ha+1&65535;this.b-=5},function(){var a=K(this);this.na(a,Yc(this,this.X(a)));this.b-=10},function(){var a=K(this);this.na(a,Xc(this,this.X(a)));this.b-=10},function(){this.na(K(this),O(this));this.b-=10},function(){this.Z|=256;this.b-=
4},vd,function(){var a;Oc(this,a=K(this)+this.ha);Pc(this,a>>8&256);this.b-=10},function(){this.j=this.X(P(this));this.b-=13},function(){this.ha=this.ha-1&65535;this.b-=5},function(){this.j=Yc(this,this.j);this.b-=5},function(){this.j=Xc(this,this.j);this.b-=5},function(){this.j=O(this);this.b-=7},function(){Pc(this,M(this)?0:256);this.b-=4},function(){this.b-=5},function(){this.N=this.O;this.b-=5},function(){this.N=this.P;this.b-=5},function(){this.N=this.R;this.b-=5},function(){this.N=this.S;this.b-=
5},function(){this.N=this.V;this.b-=5},function(){this.N=this.X(K(this));this.b-=7},function(){this.N=this.j;this.b-=5},function(){this.O=this.N;this.b-=5},function(){this.b-=5},function(){this.O=this.P;this.b-=5},function(){this.O=this.R;this.b-=5},function(){this.O=this.S;this.b-=5},function(){this.O=this.V;this.b-=5},function(){this.O=this.X(K(this));this.b-=7},function(){this.O=this.j;this.b-=5},function(){this.P=this.N;this.b-=5},function(){this.P=this.O;this.b-=5},function(){this.b-=5},function(){this.P=
this.R;this.b-=5},function(){this.P=this.S;this.b-=5},function(){this.P=this.V;this.b-=5},function(){this.P=this.X(K(this));this.b-=7},function(){this.P=this.j;this.b-=5},function(){this.R=this.N;this.b-=5},function(){this.R=this.O;this.b-=5},function(){this.R=this.P;this.b-=5},function(){this.b-=5},function(){this.R=this.S;this.b-=5},function(){this.R=this.V;this.b-=5},function(){this.R=this.X(K(this));this.b-=7},function(){this.R=this.j;this.b-=5},function(){this.S=this.N;this.b-=5},function(){this.S=
this.O;this.b-=5},function(){this.S=this.P;this.b-=5},function(){this.S=this.R;this.b-=5},function(){this.b-=5},function(){this.S=this.V;this.b-=5},function(){this.S=this.X(K(this));this.b-=7},function(){this.S=this.j;this.b-=5},function(){this.V=this.N;this.b-=5},function(){this.V=this.O;this.b-=5},function(){this.V=this.P;this.b-=5},function(){this.V=this.R;this.b-=5},function(){this.V=this.S;this.b-=5},function(){this.b-=5},function(){this.V=this.X(K(this));this.b-=7},function(){this.V=this.j;
this.b-=5},function(){this.na(K(this),this.N);this.b-=7},function(){this.na(K(this),this.O);this.b-=7},function(){this.na(K(this),this.P);this.b-=7},function(){this.na(K(this),this.R);this.b-=7},function(){this.na(K(this),this.S);this.b-=7},function(){this.na(K(this),this.V);this.b-=7},function(){var a=this.M-1;if(this.J.length)for(var b=0;b<this.J.length;b++)if(this.J[b](a))return;this.A|=16;this.b-=7;this.G&&gb(this,-2147483648)?(H(this,a),this.G.ia()):this.ta&512||(this.G&&H(this,a),this.ia())},
function(){this.na(K(this),this.j);this.b-=7},function(){this.j=this.N;this.b-=5},function(){this.j=this.O;this.b-=5},function(){this.j=this.P;this.b-=5},function(){this.j=this.R;this.b-=5},function(){this.j=this.S;this.b-=5},function(){this.j=this.V;this.b-=5},function(){this.j=this.X(K(this));this.b-=7},function(){this.b-=5},function(){this.j=Uc(this,this.N);this.b-=4},function(){this.j=Uc(this,this.O);this.b-=4},function(){this.j=Uc(this,this.P);this.b-=4},function(){this.j=Uc(this,this.R);this.b-=
4},function(){this.j=Uc(this,this.S);this.b-=4},function(){this.j=Uc(this,this.V);this.b-=4},function(){this.j=Uc(this,this.X(K(this)));this.b-=7},function(){this.j=Uc(this,this.j);this.b-=4},function(){this.j=Vc(this,this.N);this.b-=4},function(){this.j=Vc(this,this.O);this.b-=4},function(){this.j=Vc(this,this.P);this.b-=4},function(){this.j=Vc(this,this.R);this.b-=4},function(){this.j=Vc(this,this.S);this.b-=4},function(){this.j=Vc(this,this.V);this.b-=4},function(){this.j=Vc(this,this.X(K(this)));
this.b-=7},function(){this.j=Vc(this,this.j);this.b-=4},function(){this.j=N(this,this.N);this.b-=4},function(){this.j=N(this,this.O);this.b-=4},function(){this.j=N(this,this.P);this.b-=4},function(){this.j=N(this,this.R);this.b-=4},function(){this.j=N(this,this.S);this.b-=4},function(){this.j=N(this,this.V);this.b-=4},function(){this.j=N(this,this.X(K(this)));this.b-=7},function(){this.j=N(this,this.j);this.b-=4},function(){this.j=$c(this,this.N);this.b-=4},function(){this.j=$c(this,this.O);this.b-=
4},function(){this.j=$c(this,this.P);this.b-=4},function(){this.j=$c(this,this.R);this.b-=4},function(){this.j=$c(this,this.S);this.b-=4},function(){this.j=$c(this,this.V);this.b-=4},function(){this.j=$c(this,this.X(K(this)));this.b-=7},function(){this.j=$c(this,this.j);this.b-=4},function(){this.j=Wc(this,this.N);this.b-=4},function(){this.j=Wc(this,this.O);this.b-=4},function(){this.j=Wc(this,this.P);this.b-=4},function(){this.j=Wc(this,this.R);this.b-=4},function(){this.j=Wc(this,this.S);this.b-=
4},function(){this.j=Wc(this,this.V);this.b-=4},function(){this.j=Wc(this,this.X(K(this)));this.b-=7},function(){this.j=Wc(this,this.j);this.b-=4},function(){this.j=ad(this,this.N);this.b-=4},function(){this.j=ad(this,this.O);this.b-=4},function(){this.j=ad(this,this.P);this.b-=4},function(){this.j=ad(this,this.R);this.b-=4},function(){this.j=ad(this,this.S);this.b-=4},function(){this.j=ad(this,this.V);this.b-=4},function(){this.j=ad(this,this.X(K(this)));this.b-=7},function(){this.j=ad(this,this.j);
this.b-=4},function(){this.j=Zc(this,this.N);this.b-=4},function(){this.j=Zc(this,this.O);this.b-=4},function(){this.j=Zc(this,this.P);this.b-=4},function(){this.j=Zc(this,this.R);this.b-=4},function(){this.j=Zc(this,this.S);this.b-=4},function(){this.j=Zc(this,this.V);this.b-=4},function(){this.j=Zc(this,this.X(K(this)));this.b-=7},function(){this.j=Zc(this,this.j);this.b-=4},function(){N(this,this.N);this.b-=4},function(){N(this,this.O);this.b-=4},function(){N(this,this.P);this.b-=4},function(){N(this,
this.R);this.b-=4},function(){N(this,this.S);this.b-=4},function(){N(this,this.V);this.b-=4},function(){N(this,this.X(K(this)));this.b-=7},function(){N(this,this.j);this.b-=4},function(){Sc(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){Lc(this,Q(this));this.b-=10},function(){var a=P(this);Sc(this)||H(this,a);this.b-=10},wd,function(){var a=P(this);Sc(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,Kc(this));this.b-=11},function(){this.j=Uc(this,O(this));this.b-=
7},function(){R(this,this.M);H(this,0);this.b-=11},function(){Sc(this)&&(H(this,Q(this)),this.b-=6);this.b-=5},xd,function(){var a=P(this);Sc(this)&&H(this,a);this.b-=10},wd,function(){var a=P(this);Sc(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},yd,function(){this.j=Vc(this,O(this));this.b-=7},function(){R(this,this.M);H(this,8);this.b-=11},function(){M(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){Nc(this,Q(this));this.b-=10},function(){var a=P(this);M(this)||H(this,a);this.b-=
10},function(){var a=O(this);Gb(this.w,a,this.j,this.M+-2&65535);this.b-=10},function(){var a=P(this);M(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,Mc(this));this.b-=11},function(){this.j=N(this,O(this));this.b-=7},function(){R(this,this.M);H(this,16);this.b-=11},function(){M(this)&&(H(this,Q(this)),this.b-=6);this.b-=5},xd,function(){var a=P(this);M(this)&&H(this,a);this.b-=10},function(){var a=O(this);this.j=Cb(this.w,a,this.M+-2&65535)&255;this.b-=10},function(){var a=
P(this);M(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},yd,function(){this.j=$c(this,O(this));this.b-=7},function(){R(this,this.M);H(this,24);this.b-=11},function(){Qc(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){Oc(this,Q(this));this.b-=10},function(){var a=P(this);Qc(this)||H(this,a);this.b-=10},function(){var a=Q(this);R(this,K(this));Oc(this,a);this.b-=18},function(){var a=P(this);Qc(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,K(this));this.b-=
11},function(){this.j=Wc(this,O(this));this.b-=7},function(){R(this,this.M);H(this,32);this.b-=11},function(){Qc(this)&&(H(this,Q(this)),this.b-=6);this.b-=5},function(){H(this,K(this));this.b-=5},function(){var a=P(this);Qc(this)&&H(this,a);this.b-=10},function(){var a=K(this);Oc(this,Mc(this));Nc(this,a);this.b-=5},function(){var a=P(this);Qc(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},yd,function(){this.j=ad(this,O(this));this.b-=7},function(){R(this,this.M);H(this,40);this.b-=11},
function(){Tc(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){var a=Q(this);Hc(this,a&255|this.ta&-256);this.j=a>>8;this.b-=10},function(){var a=P(this);Tc(this)||H(this,a);this.b-=10},function(){this.ta&=-513;this.b-=4},function(){var a=P(this);Tc(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,Jc(this)&255|this.j<<8);this.b-=11},function(){this.j=Zc(this,O(this));this.b-=7},function(){R(this,this.M);H(this,48);this.b-=11},function(){Tc(this)&&(H(this,Q(this)),
this.b-=6);this.b-=5},function(){this.ha=K(this)&65535;this.b-=5},function(){var a=P(this);Tc(this)&&H(this,a);this.b-=10},function(){this.ta|=512;this.b-=4},function(){var a=P(this);Tc(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},yd,function(){N(this,O(this));this.b-=7},function(){R(this,this.M);H(this,56);this.b-=11}];
function T(a){y.call(this,"ChipSet",a,T,32768);var b=a.model;b&&!zd[b]&&v("Unrecognized ChipSet model: "+b);this.A=zd[b]||U;this.Ha=this.A.Ea;a.sound&&(this.J=null,window&&(this.J=window.AudioContext||window.webkitAudioContext),this.J&&new this.J);F(this)}Za(T);
var U={Ea:1978.1,Jc:{va:0,od:1,sd:16,zd:32,Jd:64,Id:128,rb:14},Pa:{va:1,tc:1,Ic:2,Ec:4,Fc:16,Gc:32,Hc:64,rb:8},Kc:{va:2,nd:3,Rd:4,pd:8,Ed:16,Fd:32,Gd:64,qd:128,rb:0},Md:{va:3},Kd:{va:2,Ad:7},Od:{va:3,Sd:1,Nd:2,Hd:4,xd:8,rd:16,ld:32},Ld:{va:4},Pd:{va:5,td:1,ud:2,vd:4,wd:8,Td:16}},V={Ea:100,Eb:{va:66,Ud:1,Bc:2,Cc:4,Dd:8,Bd:16,Cd:32,Wb:64,yd:128},sc:{va:66,INIT:0},Dc:{va:98,INIT:0},vc:{va:162,INIT:0},uc:{va:194,INIT:0}},zd={SI1978:U,VT100:V};T.prototype.ma=function(){return!1};
T.prototype.Ma=function(a,b,c,d){this.w=b;this.b=c;this.G=d;this.u=a;Bb(b,this,this.A.Kb);Fb(b,this,this.A.Lb)};T.prototype.Ca=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};T.prototype.Ia=function(a){return a?this.save():!0};U.Ua=[[U.Jc.rb,U.Pa.rb,U.Kc.rb,0,0,0,0]];V.Ua=[[V.sc.INIT,V.Dc.INIT,V.Eb.Bc|V.Eb.Cc,V.vc.INIT,V.uc.INIT]];m=T.prototype;m.reset=function(){this.restore(this.A.Ua)||this.fa("reset error")};
m.save=function(){var a=new I(this);switch(this.Ha){case U.Ea:J(a,0,[this.da,this.C,this.ea,this.F,this.I,this.aa,this.ca]);break;case V.Ea:J(a,0,[this.L,this.Y,this.H,this.W,this.T])}return a.data()};m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.Ha){case U.Ea:return this.da=b[0],this.C=b[1],this.ea=b[2],this.F=b[3],this.I=b[4],this.aa=b[5],this.ca=b[6],!0;case V.Ea:return this.L=b[0],this.Y=b[1],this.H=b[2],this.W=b[3],this.T=b[4],!0}return!1};m.start=function(){};m.stop=function(){};
function Ad(a,b,c){a.C&=~b;c&&(a.C|=b)}m.Pc=function(a,b){var c=this.da;D(this,a,null,b,"STATUS0",c);return c};m.Qc=function(a,b){var c=this.C;D(this,a,null,b,"STATUS1",c);return c};m.Rc=function(a,b){var c=this.ea;D(this,a,null,b,"STATUS2",c);return c};m.Oc=function(a,b){var c=this.F>>8-this.I&255;D(this,a,null,b,"SHIFT.RESULT",c);return c};m.Vc=function(a,b,c){D(this,a,b,c,"SHIFT.COUNT",null);this.I=b};m.Xc=function(a,b,c){D(this,a,b,c,"SOUND1",null);this.aa=b};
m.Wc=function(a,b,c){D(this,a,b,c,"SHIFT.DATA",null);this.F=b<<8|this.F>>8};m.Yc=function(a,b,c){D(this,a,b,c,"SOUND2",null);this.ca=b};m.Zc=function(a,b,c){D(this,a,b,c,"WATCHDOG",null)};m.Sc=function(a,b){var c=this.H=this.H&~V.Eb.Wb|((yc(this.b)&64)<<1?V.Eb.Wb:0);D(this,a,null,b,"FLAGS.BUFFER",c);return c};m.$c=function(a,b,c){D(this,a,b,c,"BRIGHTNESS.LATCH",null);this.L=b};m.cd=function(a,b,c){D(this,a,b,c,"NVR.LATCH",null);this.Y=b};m.bd=function(a,b,c){D(this,a,b,c,"DC012",null);this.W=b};
m.ad=function(a,b,c){D(this,a,b,c,"DC011",null);this.T=b};U.Kb={0:T.prototype.Pc,1:T.prototype.Qc,2:T.prototype.Rc,3:T.prototype.Oc};U.Lb={2:T.prototype.Vc,3:T.prototype.Xc,4:T.prototype.Wc,5:T.prototype.Yc,6:T.prototype.Zc};V.Kb={66:T.prototype.Sc};V.Lb={66:T.prototype.$c,98:T.prototype.cd,162:T.prototype.bd,194:T.prototype.ad};Ja(function(){for(var a=C(document,"pc8080","chipset"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new T(d);db(d,c)}});
function Bd(a){y.call(this,"ROM",a,Bd);this.u=null;this.H=a.addr;this.C=a.size;this.I=a.writable;this.A=a.alias;this.F=a.file;this.J=ba(this.F);if(this.F){a=this.F;var b=da(this.J);"json"!=b&&"hex"!=b&&(a=qa()+"/api/v1/dump?file="+this.F+"&format=bytes&decimal=true");var c=this;oa(a,null,!0,function(a,b,f){Cd(c,a,b,f)})}}Za(Bd);var Dd=[0,5];Bd.prototype.Ma=function(a,b,c,d){this.w=b;this.b=c;this.G=d;Ed(this)};
Bd.prototype.Ca=function(){if(this.La){if(this.G){var a=this.G,b=this.id,c=this.H,d=this.C,e=this.La,f=[],h;for(h in e){var g=e[h];"number"==typeof g&&(e[h]=g={o:g});var k=g.o,l=g.a;if(void 0!==k){var n=f,k=[k>>>0,h],p=ka(n,k,a.Ra);0>p&&n.splice(-(p+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.I.push({Vd:b,D:c,Tc:d,La:e,Yb:f})}delete this.La}return!0};Bd.prototype.Ia=function(){return!0};
function Cd(a,b,c,d){if(d)a.fa("Unable to load system ROM (error "+d+": "+b+")");else{ab(a.Qb,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<h.length;c++)a.u[d++]=h[c]&255,a.u[d++]=h[c]>>8&255,a.u[d++]=h[c]>>16&255,a.u[d++]=h[c]>>24&255;else a.u=e;a.La=e.symbols;if(!a.u.length){v("Empty ROM: "+b);return}if(1==a.u.length){v(a.u[0]);return}}catch(g){a.fa("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
" ").replace(/ +$/,"").split(" "),a.u=Array(b.length),e=0;e<b.length;e++)a.u[e]=aa(b[e],16);Ed(a)}}
function Ed(a){if(!lb(a))if(!a.F)F(a);else if(a.u&&a.w){a.C||(a.C=a.u.length);if(a.u.length!=a.C)mb(a,"ROM size (0x"+q(a.u.length)+") does not match specified size ("+("0x"+q(a.C))+")");else if(Fd(a,a.H)){var b=[];"number"==typeof a.A?b.push(a.A):null!=a.A&&a.A.length&&(b=a.A);for(var c=0;c<b.length;c++){for(var d=a,e=b[c],f=d.w,h=d.C,g=[],k=d.H>>>f.ja;0<h&&k<f.U.length;)g.push(f.U[k++]),h-=f.Ba;f=d.w;d=d.C;h=0;for(e>>>=f.ja;0<d&&e<f.U.length;){k=g[h++];if(!k)break;f.U[e++]=k;d-=f.Ba}}delete a.u}F(a)}}
function Fd(a,b){if(ub(a.w,b,a.C,a.I?1:Vb)){var c;for(c=0;c<a.u.length;c++)zb(a.w,b+c,a.u[c]);if(a.I&&256==b){for(c=0;c<Dd.length;c++)zb(a.w,Dd[c],118);Gc(a.b,function(a){return function(b){if(0<=Dd.indexOf(b)){var c=!1,h=a.b,g=a.G;if(5==b)switch(c=!0,h.O){case 2:Gd(a,String.fromCharCode(h.R));break;case 9:for(var k=Mc(h),l="",n=255;n--;){var p=a.b.X(k++);if(36==p)break;l+=String.fromCharCode(p)}Gd(a,l);break;default:c=!1}c?xd.call(h):g&&(a.g("\nCP/M vector "+r(b)),H(h,b),g.ia());b=!0}else b=!1;return b}}(a));
Ic(a.b,b)}return!0}return!1}function Gd(a,b){b=b.replace(/\r/g,"");a.Aa&&(a.Aa.value+=b,a.Aa.scrollTop=a.Aa.scrollHeight)}Ja(function(){for(var a=C(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new Bd(d);db(d,c)}});function Hd(a){y.call(this,"RAM",a,Hd);this.A=a.addr;this.C=a.size;this.u=!1}Za(Hd);m=Hd.prototype;m.Ma=function(a,b,c,d){this.w=b;this.b=c;this.G=d;F(this)};m.Ca=function(a,b){b||this.reset();return!0};m.Ia=function(a){return a?this.save():!0};
m.reset=function(){!this.u&&this.C&&ub(this.w,this.A,this.C,1)&&(this.u=!0);this.u||v("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};Ja(function(){for(var a=C(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new Hd(d);db(d,c)}});function X(a){y.call(this,"Keyboard",a,X,65536);this.reset();F(this)}Za(X);
var Id={Oa:{va:130,zc:1,yc:2,xc:4,wc:8,Ac:16,Xb:32,Qd:64,md:128}},Jd={"1p":49,"2p":50,coin:51,left:37,right:39,fire:32},Kd={65:37,68:39,76:32},Ld={l4:Id.Oa.zc,l3:Id.Oa.yc,l2:Id.Oa.xc,l1:Id.Oa.wc,locked:Id.Oa.Ac,online:Id.Oa.Xb,local:~Id.Oa.Xb};
X.prototype.ma=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.K[e]){if("led"==a&&Ld[b])return this.K[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return Md(d,a,!0)},c.onkeyup=function(a){return Md(d,a,!1)},!0;default:if(void 0!==Jd[b])return this.K[e]=c,a=function(a,b){return function(){Nd(a,b,!0)}}(this,b),b=function(a,b){return function(){Nd(a,b,!1)}}(this,b),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend=b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};
X.prototype.Ma=function(a,b,c,d){this.G=d;this.C=qb(a,"ChipSet");this.Ha=this.C.Ha;switch(this.Ha){case V.Ea:this.A=Id}this.A&&(Bb(b,this,this.A.Kb),Fb(b,this,this.A.Lb))};X.prototype.Ca=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};X.prototype.Ia=function(a){return a?this.save():!0};Id.Ua=[[0]];X.prototype.reset=function(){this.u={};this.b={};this.A&&!this.restore(this.A.Ua)&&this.fa("reset error")};
X.prototype.save=function(){var a=new I(this);switch(this.Ha){case V.Ea:J(a,0,[this.w])}return a.data()};X.prototype.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.Ha){case U.Ea:return!0;case V.Ea:return this.w=b[0],Od(this),!0}return!1};function Od(a){for(var b in Ld){var c=a.K["led-"+b];if(c){var d=Ld[b],e=!!(a.w&d);d&d-1&&(e=!(a.w&~d));c.style.backgroundColor=e?"#ff0000":"#000000"}}}
function Md(a,b,c){var d=!0,e;a:{e=b.keyCode;e=Kd[e]||e;for(var f in Jd)if(Jd[f]===e){e=f;break a}e=null}e&&(d=Nd(a,e,c),b.preventDefault());return d}
function Nd(a,b,c){if(c)a.u[b]=Date.now(),delete a.b[b];else{var d=a.u[b];if(d&&100>Date.now()-d)return a.b[b]=d,Pd(a),!0;delete a.u[b]}if(a.C)switch(b){case "1p":Ad(a.C,U.Pa.Ec,c);break;case "2p":Ad(a.C,U.Pa.Ic,c);break;case "coin":Ad(a.C,U.Pa.tc,c);break;case "left":Ad(a.C,U.Pa.Gc,c);break;case "right":Ad(a.C,U.Pa.Hc,c);break;case "fire":Ad(a.C,U.Pa.Fc,c)}return!0}
function Pd(a){for(var b=-1,c=Object.keys(a.b),d=0;d<c.length;d++){var e=c[d],f=100-(Date.now()-a.b[e]);if(0<f){if(0>b||b>f)b=f}else delete a.b[e],Nd(a,e,!1)}0<=b&&setTimeout(function(){Pd(a)},b)}X.prototype.F=function(a,b,c){D(this,a,b,c,"KBDUART.STATUS",null);this.w=b;Od(this)};Id.Kb={};Id.Lb={130:X.prototype.F};Ja(function(){for(var a=C(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new X(d);db(d,c)}});
function Qd(a,b,c,d,e){var f=this;this.fc=xa("Gecko/");var h=["","moz","ms","webkit"];y.call(this,"Video",a,Qd,262144);this.aa=a.screenWidth;this.W=a.screenHeight;this.ya=a.bufferAddr;this.gd=a.bufferRAM;var g=a.bufferFormat;this.Y=g&&Rd[g.toLowerCase()]||Sd;this.Ra=a.bufferCols;this.ea=a.bufferRows;this.dd=this.la=a.cellWidth||1;this.ga=a.cellHeight||1;this.ab=null;this.Qa=a.bufferBits||1;this.hd=a.bufferLeft||0;if(this.F=a.bufferRotate)this.F=this.F%360,0<this.F&&(this.F-=360),-90!=this.F&&(this.fa("unsupported buffer rotation: "+
this.F),this.F=0);this.mc=a.interruptRate;this.jd=a.refreshRate||60;this.T=b;this.H=c;this.Fa=(this.kd=d)||b||null;this.ed=this.aa;this.fd=this.W;this.Hb=this.aa/this.Ra|0;this.ec=this.W/this.ea|0;1<this.ga&&this.ea++;b=a.smoothing;(c=Ra.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)if(d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.H[d]){this.H[d]=b;break}if(this.I=a.screenRotate)this.I=this.I%360,0<this.I&&(this.I-=360),-90!=this.I?(this.fa("unsupported screen rotation: "+
this.I),this.I=0):(this.H.translate(0,this.W),this.H.rotate(this.I*Math.PI/180),this.H.scale(this.W/this.aa,this.aa/this.W));if(this.A=e)if(this.A.cb=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.A.cb){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){Td(f,document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},
!1);break}for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenerror","on"+d in document){document.addEventListener(d,function(){Td(f,null)},!1);break}}if(this.oa=a.fontROM)"json"!=da(this.oa)&&(this.oa=qa()+"/api/v1/dump?file="+this.oa+"&format=bytes"),oa(this.oa,null,!0,function(a,b,c){Ud(f,a,b,c)});this.tb={}}Za(Qd);var Sd=0,Rd={vt100:2};
Qd.prototype.Ma=function(a,b,c,d){this.u=a;this.w=b;this.b=c;this.G=d;this.C=qb(a,"ChipSet");!this.Y&&this.C&&this.C.Ha==U.Ea&&(this.Y=1);this.J=this.Ra*this.la;this.ca=this.ea*this.ga;b=this.J;c=this.ca;this.F&&(b=this.ca,c=this.J);this.Ta=(this.J*this.Qa>>3)*this.ca;if(this.gd||ub(this.w,this.ya,this.Ta,3))1<this.la?Vd(this,this.Ra*this.ea):(this.gc=this.H.createImageData(b,c),this.lc=16/this.Qa|0,Vd(this,this.Ta>>1)),this.L=document.createElement("canvas"),this.L.width=b,this.L.height=c,this.bb=
this.L.getContext("2d"),this.ua={},this.Ga=1<<this.Qa,this.wa=Array(this.Ga+2),this.wa[0]=[0,0,0,255],this.wa[1]=[255,255,255,255],1==this.Y&&(this.wa[this.Ga+0]=[255,255,0,255],this.wa[this.Ga+1]=[0,255,0,255]),2==this.Y&&(this.nc=60,this.sb=!1,this.xa=Array(this.Ra));if(this.da=qb(a,"Keyboard")){for(var e in this.tb)this.da.ma("led",e,this.tb[e]);this.T&&this.da.ma(this.kd?"textarea":"canvas","kbd",this.Fa)}this.oa||F(this)};
function Ud(a,b,c,d){if(d)a.fa("Unable to load font ROM (error "+d+": "+b+")");else{ab(a.Qb,b,c);try{var e=eval("("+c+")"),f=e.bytes||e;if(!f||!f.length){v("Empty font ROM: "+b);return}if(1==f.length){v(f[0]);return}if(2048==f.length)Wd(a,f);else{a.fa("Unrecognized font data length ("+f.length+")");return}}catch(h){a.fa("Font ROM data error: "+h.message);return}(a.H||a.G)&&F(a)}}
function Wd(a,b){a.ab=b;a.ua[96]=[Xd(a,a.la,a.ga),Xd(a,a.la,a.ga,a.sb)];a.ua[64]=[Xd(a,2*a.la,a.ga),Xd(a,2*a.la,a.ga,a.sb)];a.ua[32]=a.ua[0]=[Xd(a,2*a.la,2*a.ga),Xd(a,2*a.la,2*a.ga,a.sb)]}
function Xd(a,b,c,d){var e=8>=a.dd?8:16,f=8<e?15:0,h=a.ab.length/e,g=!1===d,k={la:b,ga:c};k.canvas=document.createElement("canvas");k.canvas.width=16*b;k.canvas.height=h/16*c;k.context=k.canvas.getContext("2d");for(var l=k.context.createImageData(b,c),n=0;n<h;n++){for(var p=0,x=p;p<a.ga;p++)for(var w=n*e+(f+p&e-1),w=d&&8==p?255:a.ab[w],t=0;t<c/a.ga;t++){for(var z=0,u=z;z<a.la;z++)for(var E=w&128>>(7<z?7:z),A=0;A<b/a.la;A++)g&&(E=!E),Yd(a,l,u,x,E?1:0),u++;x++}k.context.putImageData(l,(n&15)*b,(n>>
function vb(a,b,c){v("Memory block error ("+a+": "+q(b)+","+q(c)+")");return!1}var Ib;if(nb){var Rb=new ArrayBuffer(2);(new DataView(Rb)).setUint16(0,256,!0);Ib=256===(new Uint16Array(Rb))[0]}else Ib=!1;var Sb=Ib;
function G(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.Ka=this.ec=!1;if(c)if(nb)this.D=new ArrayBuffer(c),this.H=new DataView(this.D,0,c),this.A=new Uint8Array(this.D,0,c),this.J=new Uint16Array(this.D,0,c>>1),this.b=new Int32Array(this.D,0,c>>2),Wb(this,Sb?Xb:Yb);else{this.b=Array(c>>2);for(a=0;a<this.b.length;a++)this.b[a]=0;Wb(this,Zb)}else Wb(this)}var Ub=0,Vb=2,wb=["NONE","RAM","ROM","VID","H/W"],Tb=0;
G.prototype={constructor:G,parent:null,Wa:function(a){this.F=a},save:function(){var a,b;if(nb)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.H.getInt32(b<<2,!0);else a=this.b;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(nb)for(b=0;b<a.length;b++)this.H.setInt32(b<<2,a[b],!0);else this.b=a;return this.Ka=!0}return!1},Ua:function(a,b){b?0===this.C++&&$b(this,ac,!1):0===this.u++&&bc(this,ac,!1)},K:function(){this.G&&gb(this.G,129)&&this.G.message("attempt to read invalid block %"+
q(this.F),!0);return 255},w:function(a,b){this.G&&gb(this.G,129)&&this.G.message("attempt to write "+r(b)+" to invalid block %"+q(this.F),!0)},N:function(a,b){return this.rb(a++,b++)|this.rb(a,b)<<8},I:function(a,b,c){this.tb(a++,b&255,c++);this.tb(a,b>>8,c)},ca:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ka: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<<d)|b<<d;this.Ka=!0},
cb:function(a,b){var c=a>>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<<d)|b<<d:(this.b[c]=this.b[c]&16777215|b<<24,c++,this.b[c]=this.b[c]&-256|b>>8);this.Ka=!0},Y:function(a,b){if(this.G&&null!=this.F){var c=this.G;cc(c,this.F+a,1,c.Y)&&c.ja(!0)}return this.Db(a,b)},ea:function(a,b){if(this.G&&null!=this.F){var c=this.G;cc(c,this.F+a,2,c.Y)&&c.ja(!0)}return this.Xb(a,b)},ua:function(a,b,c){if(this.G&&null!=this.F){var d=this.G;cc(d,this.F+a,1,d.H)&&d.ja(!0)}this.L?this.w(a,b,c):this.Gb(a,b,c)},
Ga:function(a,b,c){if(this.G&&null!=this.F){var d=this.G;cc(d,this.F+a,2,d.H)&&d.ja(!0)}this.L?this.w(a,b,c):this.Yb(a,b,c)},U:function(a){return this.A[a]},aa:function(a){return this.A[a]},da:function(a){return this.H.getUint16(a,!0)},ga:function(a){return a&1?this.A[a]|this.A[a+1]<<8:this.J[a>>1]},ma:function(a,b){this.A[a]=b;this.Ka=!0},xa:function(a,b){this.A[a]=b;this.Ka=!0},za:function(a,b){this.H.setUint16(a,b,!0);this.Ka=!0},Ha:function(a,b){a&1?(this.A[a]=b,this.A[a+1]=b>>8):this.J[a>>1]=
b;this.Ka=!0}};function tb(a,b,c){a.G=b;a.u=a.C=0;c&&((a.u=c.u)&&bc(a,ac,!1),(a.C=c.C)&&$b(a,ac,!1))}function dc(a,b){b?0===--a.C&&(a.tb=a.L?a.w:a.Gb,a.vc=a.L?a.I:a.Yb):0===--a.u&&(a.rb=a.Db,a.tc=a.Xb)}function $b(a,b,c){c&&a.C||(a.tb=!a.L&&b[2]||a.w,a.vc=!a.L&&b[3]||a.I);if(c||void 0===c)a.Gb=b[2]||a.w,a.Yb=b[3]||a.I}function bc(a,b,c){c&&a.u||(a.rb=b[0]||a.K,a.tc=b[1]||a.N);if(c||void 0===c)a.Db=b[0]||a.K,a.Xb=b[1]||a.N}function Wb(a,b){b||(b=ec);bc(a,b,void 0);$b(a,b,void 0)}
var ec=[],Zb=[G.prototype.ca,G.prototype.ka,G.prototype.ya,G.prototype.cb],ac=[G.prototype.Y,G.prototype.ea,G.prototype.ua,G.prototype.Ga];if(nb)var Yb=[G.prototype.U,G.prototype.da,G.prototype.ma,G.prototype.za],Xb=[G.prototype.aa,G.prototype.ga,G.prototype.xa,G.prototype.Ha];
function fc(a,b){y.call(this,"CPU",a,fc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.qb=c;this.i.Mb=0;this.i.$a=d;this.i.Ub=Math.round(this.i.qb/1E4)/100;this.i.Ya=this.i.Ub*this.i.$a;this.B.va=!1;this.B.Sb=!1;this.B.dc=a.autoStart;this.B.fc=!1;this.B.ib=!1;this.i.xb=this.i.nb=0;this.i.yb=a.csStart;this.i.mb=a.csInterval;this.i.ob=a.csStop;this.aa=this.ab.bind(this);E(this)}Za(fc);var gc=["power","reset"];m=fc.prototype;
m.Na=function(a,b,c,d){this.u=a;this.A=b;this.G=d;for(b=0;b<gc.length;b++)(c=this.L[gc[b]])&&this.u.pa(null,gc[b],c);this.K=(b=qb(a,"Video"))&&Math.max(b.td,b.qc)||60;this.C=qb(a,"ChipSet");a=hc(a,"autoStart");null!=a&&(this.B.dc="true"==a?!0:"false"==a?!1:!!a);E(this)};m.reset=function(){this.i.Mb=0};m.save=function(){return null};m.restore=function(){return!1};
m.Ca=function(a,b){if(!b){if(a&&this.restore){ic(this);if(!this.restore(a))return!1;jc(this)}else this.reset();this.G?this.G.Wa():this.g("No debugger detected")}kc(this);return!0};m.Ja=function(a){return a?this.save():!0};function lc(a){(a.B.dc||!a.G&&void 0===a.L.run)&&a.ab(!0)}m.gc=function(){return 0};function jc(a){void 0===a.i.yb&&(a.i.yb=0);void 0===a.i.mb&&(a.i.mb=-1);void 0===a.i.ob&&(a.i.ob=-1);a.B.ib=0<=a.i.yb&&0<a.i.mb;a.B.ib&&(a.i.xb=0,a.i.nb=a.i.yb-a.I)}
function yc(a,b){if(a.B.ib){var c=!1;a.i.xb=a.i.xb+a.gc()|0;a.i.nb-=b;0>=a.i.nb&&(a.i.nb+=a.i.mb,c=!0);0<=a.i.ob&&a.i.ob<=zc(a)&&(a.i.mb=a.i.ob=-1,jc(a),a.ja(),c=!0);c&&a.g(zc(a)+" cycles: checksum="+q(a.i.xb))}}
m.pa=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.B.ra)a=!0;else{var b=null,c,g=bb(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.B.kb);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.B.ra);c++);c==g.length&&(b=a);v("The "+b.type+" component ("+b.id+") is not "+(b.B.kb?"powered yet":"ready yet"+(b.Jb?" (waiting for notification)":""))+".");a=!1}a&&(d.B.va?d.ja(!0):d.ab(!0))};a=
!0;break;case "speed":this.L[b]=c;a=!0;break;case "setSpeed":this.L[b]=c,c.onclick=function(){Ac(d,d.i.$a<<1,!0)},c.textContent=this.i.Ya.toFixed(2)+"Mhz",a=!0}return a};function Bc(a,b,c){a.I+=b;c&&(a.D=a.b=0)}
function Cc(a,b){var c=30;c<a.K&&(c=a.K);2>c&&(c=2);var d=1;b&&1<a.i.$a&&a.i.Xa&&(d=a.i.Xa/a.i.Ub);a.i.mc=Math.round(1E3/30);a.i.dd=Math.floor(a.i.qb/c*d);a.i.Vb=Math.floor(a.i.qb/30*d);a.i.oc=Math.floor(a.i.qb/a.K*d);a.i.nc=Math.floor(a.i.qb/2*d);b||(a.i.pb=a.i.Vb,a.i.Ab=a.i.oc,a.i.zb=a.i.nc);a.i.Wb=0}function zc(a){return a.I+a.H+a.D-a.b}function ic(a){a.i.Xa=0;a.I=a.H=a.D=a.b=0;jc(a);Ac(a,1)}
function Ac(a,b,c){var d=!1;if(void 0!==b){.8>a.i.Xa/a.i.Ya?b=1:d=!0;a.i.$a=b;b=a.i.Ub*a.i.$a;if(a.i.Ya!=b){a.i.Ya=b;b=a.i.Ya.toFixed(2)+"Mhz";var e=a.L.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.u&&a.u.Eb()}Bc(a,a.H);a.H=0;a.i.lb=la();a.i.Za=0;Cc(a);return d}
m.ab=function(a){if(hb(this,!0)){if(!this.B.va){Ac(this);this.u&&this.u.start(this.i.lb,zc(this));this.B.va=!0;this.B.Sb=!0;this.C&&this.C.start();var b=this.L.run;b&&(b.textContent="Halt");this.u&&(this.u.Da(!0),a&&this.u.Eb(!0))}this.i.Wb>=this.i.qb&&Cc(this,!0);this.i.Bb=0;this.i.Lb=la();this.i.Za&&(a=this.i.Lb-this.i.Za,a>this.i.mc&&(this.i.lb+=a,this.i.lb>this.i.Lb&&(this.i.lb=this.i.Lb)));try{do{this.sb(this.B.ib?1:this.i.dd);var c=this.D-this.b;this.H+=c;this.i.Bb+=c;Bc(this,0,!0);yc(this,
c);this.i.Ab-=c;0>=this.i.Ab&&(this.i.Ab+=this.i.oc,this.u&&Dc(this.u,this.i.Mb++),this.i.Mb>this.K&&(this.i.Mb=0));this.i.zb-=c;0>=this.i.zb&&(this.i.zb+=this.i.nc,this.u&&this.u.Da());this.i.pb-=c;if(0>=this.i.pb){this.i.pb+=this.i.Vb;break}}while(this.B.va)}catch(e){this.ja();kc(this);this.u&&this.u.stop(la(),zc(this));hb(this,!1);mb(this,e.stack||e.message);return}c=setTimeout;a=this.aa;this.i.Za=la();b=this.i.mc;this.i.Bb&&(b=Math.round(b*this.i.Bb/this.i.Vb));var b=b-(this.i.Za-this.i.Lb),d=
this.i.Za-this.i.lb;d&&(this.i.Xa=Math.round(this.H/(10*d))/100,864E5<=d&&(this.I=0,Ac(this)));if(0>b||this.i.Xa<this.i.Ya)b=0;this.i.Wb+=this.i.Bb;this.i.Za+=b;c(a,b)}else kc(this),this.u&&this.u.stop(la(),zc(this))};m.sb=function(){return 0};m.ja=function(a){ib(this,!0);this.D-=this.b;this.b=0;Bc(this,this.H);this.H=0;if(this.B.va){this.B.va=!1;this.C&&this.C.stop();var b=this.L.run;b&&(b.textContent="Run")}this.B.Ib=a};function kc(a,b){a.u&&(Dc(a.u,-1),a.u.Da(b))}
function Ec(a){this.Ia=+a.model||8080;fc.call(this,a,1E6);this.N=Fc;ic(this);this.B.Ib=this.B.Xc=!1;this.Y=0;this.J=[];this.U=0;Gc(this)}Za(Ec,fc);function Hc(a,b){a.J.push(b)}m=Ec.prototype;m.reset=function(){this.B.va&&this.ja();Gc(this);ic(this);this.B.jb=!1;this.parent.reset.call(this)};function Gc(a){a.j=0;a.O=0;a.P=0;a.R=0;a.S=0;a.T=0;a.W=0;a.ia=0;H(a,a.U);Ic(a,0);a.w=0}function Jc(a,b){a.U=b;H(a,b)}
m.gc=function(){var a=this.j+this.O+this.P+this.R+this.S+this.T+this.W|0;return a=a+this.ia+this.M+Kc(this)|0};
m.save=function(){var a=new I(this);J(a,0,[this.j,this.O,this.P,this.R,this.S,this.T,this.W,this.ia,this.M,Kc(this)]);J(a,1,[this.w,this.I,this.i.$a]);for(var b=this.A,c=0,d=[],e=0;e<b.K;e++){var f=b.V[e];if(f.Ka||f.ec){d[c++]=e;var h=c++;a:if(f=f.save()){for(var g=0,k=0,l=[];g<f.length;){for(var n=f[g],p=g+1;p<f.length&&f[p]===n;)p++;l[k++]=p-g;l[k++]=n;g=p}if(l.length<f.length){f=l;break a}}d[h]=f}}J(a,2,d);return a.data()};
m.restore=function(a){var b=a[0];this.j=b[0];this.O=b[1];this.P=b[2];this.R=b[3];this.S=b[4];this.T=b[5];this.W=b[6];this.ia=b[7]&65535;H(this,b[8]);Ic(this,b[9]);b=a[1];this.w=b[0];this.I=b[1];Ac(this,b[3]);a:{b=this.A;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.U){for(var f=0,h=Array(b.U),g=0;g<e.length-1;)for(var k=e[g++],l=e[g++];k--;)h[f++]=l;e=h}f=b.V[d];if(!f||!f.restore(e)){v("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
m.pa=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "BC":case "D":case "E":case "DE":case "H":case "L":case "HL":case "SP":case "PC":case "PS":case "IF":case "SF":case "ZF":case "AF":case "PF":case "CF":this.L[b]=c;this.Y++;d=!0;break;default:d=this.parent.pa.call(this,a,b,c)}return d};function Lc(a){return a.O<<8|a.P}function Mc(a,b){a.O=b>>8&255;a.P=b&255}function Nc(a){return a.R<<8|a.S}function Oc(a,b){a.R=b>>8&255;a.S=b&255}function K(a){return a.T<<8|a.W}
function Pc(a,b){a.T=b>>8&255;a.W=b&255}function H(a,b){a.M=b&65535}function L(a){return a.Z&256?1:0}function Qc(a,b){a.Z=a.Z&255|b}function Rc(a){return ob[a.ba&255]?4:0}function Sc(a){return(a.ba^a.ta)&16?16:0}function Tc(a){return a.Z&255?0:64}function Uc(a){return a.ba&128?128:0}function Kc(a){return a.sa&-214|Uc(a)|Tc(a)|Sc(a)|Rc(a)|L(a)}function Ic(a,b){a.Z=a.ba=a.ta=0;b&1&&(a.Z|=256);b&4||(a.ba|=1);b&16&&(a.ta|=16);b&64||(a.Z|=255);b&128&&(a.ba^=192);a.sa=a.sa&-726|b&512|2}
function Vc(a,b){a.ta=a.j^b;return a.ba=(a.Z=a.j+b)&255}function Wc(a,b){a.ta=a.j^b;return a.ba=(a.Z=a.j+b+(a.Z&256?1:0))&255}function Xc(a,b){a.Z=a.ba=a.ta=a.j&b;(a.j|b)&8&&(a.ta^=16);return a.Z}function Yc(a,b){a.ta=b^255;b=a.ba=b+255&255;a.Z=a.Z&-256|b;return b}function Zc(a,b){a.ta=b;b=a.ba=b+1&255;a.Z=a.Z&-256|b;return b}function $c(a,b){return a.ba=a.Z=a.ta=a.j|b}function M(a,b){b^=255;a.ta=a.j^b;return a.ba=(a.Z=a.j+b+1^256)&255}
function ad(a,b){b^=255;a.ta=a.j^b;return a.ba=(a.Z=a.j+b+(a.Z&256?0:1)^256)&255}function bd(a,b){return a.ba=a.Z=a.ta=a.j^b}m.X=function(a){return this.A.X(a)};m.qa=function(a,b){this.A.qa(a,b)};function O(a){var b=a.X(a.M);H(a,a.M+1);return b}function P(a){var b=a.A.Oa(a.M);H(a,a.M+2);return b}function Q(a){var b=a.A.Oa(a.ia);a.ia=a.ia+2&65535;return b}function R(a,b){a.ia=a.ia-2&65535;a.A.Pb(a.ia,b)}
function S(a,b,c,d){d=d||2;a.L[b]&&(void 0===c&&(mb(a,"Value for "+b+" is invalid"),a.ja()),c=!a.B.va||a.B.fc?q(c,d):"--------".substr(0,d),a.L[b].textContent!=c&&(a.L[b].textContent=c))}
m.Da=function(a){this.Y&&(a||!this.B.va||this.B.fc)&&(S(this,"A",this.j),S(this,"B",this.O),S(this,"C",this.P),S(this,"BC",Lc(this),4),S(this,"D",this.R),S(this,"E",this.S),S(this,"DE",Nc(this),4),S(this,"H",this.T),S(this,"L",this.W),S(this,"HL",K(this),4),S(this,"SP",this.ia,4),S(this,"PC",this.M,4),a=Kc(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.B.va&&this.i.Xa?this.i.Xa.toFixed(2)+"Mhz":"Stopped"};
m.sb=function(a){this.B.Ib=!0;var b=this.B.Xc=this.G&&cd(this.G),c=a?this.B.Sb?0:1:-1;this.B.Sb=!1;this.D=this.b=a;do{if(this.w){var d;this.w&8&&this.sa&512?(d=199|(this.w&7)<<3,this.w&=-16,this.sa&=-513,this.N[d].call(this),d=!0):d=!1;if(d){if(!a){this.g("interrupt dispatched");break}}else if(this.w&16){this.b=0;break}}if(b){if(wd(this.G,this.M,c)){this.ja();break}c=1}this.N[O(this)].call(this)}while(0<this.b);return this.B.Ib?this.D-this.b:void 0===this.B.Ib?0:-1};
Ja(function(){for(var a=C(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new Ec(d);db(d,c)}});function xd(){this.b-=4}function yd(){H(this,P(this));this.b-=10}function zd(){H(this,Q(this));this.b-=10}function Ad(){var a=P(this);R(this,this.M);H(this,a);this.b-=17}
var Fc=[xd,function(){Mc(this,P(this));this.b-=10},function(){this.qa(Lc(this),this.j);this.b-=7},function(){Mc(this,Lc(this)+1);this.b-=5},function(){this.O=Zc(this,this.O);this.b-=5},function(){this.O=Yc(this,this.O);this.b-=5},function(){this.O=O(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255|a>>8;Qc(this,a&256);this.b-=4},xd,function(){var a;Pc(this,a=K(this)+Lc(this));Qc(this,a>>8&256);this.b-=10},function(){this.j=this.X(Lc(this));this.b-=7},function(){Mc(this,Lc(this)-1);this.b-=
5},function(){this.P=Zc(this,this.P);this.b-=5},function(){this.P=Yc(this,this.P);this.b-=5},function(){this.P=O(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;Qc(this,a);this.b-=4},xd,function(){Oc(this,P(this));this.b-=10},function(){this.qa(Nc(this),this.j);this.b-=7},function(){Oc(this,Nc(this)+1);this.b-=5},function(){this.R=Zc(this,this.R);this.b-=5},function(){this.R=Yc(this,this.R);this.b-=5},function(){this.R=O(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255|
L(this);Qc(this,a&256);this.b-=4},xd,function(){var a;Pc(this,a=K(this)+Nc(this));Qc(this,a>>8&256);this.b-=10},function(){this.j=this.X(Nc(this));this.b-=7},function(){Oc(this,Nc(this)-1);this.b-=5},function(){this.S=Zc(this,this.S);this.b-=5},function(){this.S=Yc(this,this.S);this.b-=5},function(){this.S=O(this);this.b-=7},function(){var a=this.j<<8;this.j=(L(this)<<8|this.j)>>1;Qc(this,a&256);this.b-=4},xd,function(){Pc(this,P(this));this.b-=10},function(){var a=P(this);this.A.Pb(a,K(this));this.b-=
16},function(){Pc(this,K(this)+1);this.b-=5},function(){this.T=Zc(this,this.T);this.b-=5},function(){this.T=Yc(this,this.T);this.b-=5},function(){this.T=O(this);this.b-=7},function(){var a=0,b=L(this);if(Sc(this)||9<(this.j&15))a|=6;if(b||154<=this.j)a|=96,b=1;this.j=Vc(this,a);Qc(this,b?256:0);this.b-=4},xd,function(){var a;Pc(this,a=K(this)+K(this));Qc(this,a>>8&256);this.b-=10},function(){var a;a=P(this);a=this.A.Oa(a);Pc(this,a);this.b-=16},function(){Pc(this,K(this)-1);this.b-=5},function(){this.W=
Zc(this,this.W);this.b-=5},function(){this.W=Yc(this,this.W);this.b-=5},function(){this.W=O(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},xd,function(){this.ia=P(this)&65535;this.b-=10},function(){this.qa(P(this),this.j);this.b-=13},function(){this.ia=this.ia+1&65535;this.b-=5},function(){var a=K(this);this.qa(a,Zc(this,this.X(a)));this.b-=10},function(){var a=K(this);this.qa(a,Yc(this,this.X(a)));this.b-=10},function(){this.qa(K(this),O(this));this.b-=10},function(){this.Z|=256;this.b-=
4},xd,function(){var a;Pc(this,a=K(this)+this.ia);Qc(this,a>>8&256);this.b-=10},function(){this.j=this.X(P(this));this.b-=13},function(){this.ia=this.ia-1&65535;this.b-=5},function(){this.j=Zc(this,this.j);this.b-=5},function(){this.j=Yc(this,this.j);this.b-=5},function(){this.j=O(this);this.b-=7},function(){Qc(this,L(this)?0:256);this.b-=4},function(){this.b-=5},function(){this.O=this.P;this.b-=5},function(){this.O=this.R;this.b-=5},function(){this.O=this.S;this.b-=5},function(){this.O=this.T;this.b-=
5},function(){this.O=this.W;this.b-=5},function(){this.O=this.X(K(this));this.b-=7},function(){this.O=this.j;this.b-=5},function(){this.P=this.O;this.b-=5},function(){this.b-=5},function(){this.P=this.R;this.b-=5},function(){this.P=this.S;this.b-=5},function(){this.P=this.T;this.b-=5},function(){this.P=this.W;this.b-=5},function(){this.P=this.X(K(this));this.b-=7},function(){this.P=this.j;this.b-=5},function(){this.R=this.O;this.b-=5},function(){this.R=this.P;this.b-=5},function(){this.b-=5},function(){this.R=
this.S;this.b-=5},function(){this.R=this.T;this.b-=5},function(){this.R=this.W;this.b-=5},function(){this.R=this.X(K(this));this.b-=7},function(){this.R=this.j;this.b-=5},function(){this.S=this.O;this.b-=5},function(){this.S=this.P;this.b-=5},function(){this.S=this.R;this.b-=5},function(){this.b-=5},function(){this.S=this.T;this.b-=5},function(){this.S=this.W;this.b-=5},function(){this.S=this.X(K(this));this.b-=7},function(){this.S=this.j;this.b-=5},function(){this.T=this.O;this.b-=5},function(){this.T=
this.P;this.b-=5},function(){this.T=this.R;this.b-=5},function(){this.T=this.S;this.b-=5},function(){this.b-=5},function(){this.T=this.W;this.b-=5},function(){this.T=this.X(K(this));this.b-=7},function(){this.T=this.j;this.b-=5},function(){this.W=this.O;this.b-=5},function(){this.W=this.P;this.b-=5},function(){this.W=this.R;this.b-=5},function(){this.W=this.S;this.b-=5},function(){this.W=this.T;this.b-=5},function(){this.b-=5},function(){this.W=this.X(K(this));this.b-=7},function(){this.W=this.j;
this.b-=5},function(){this.qa(K(this),this.O);this.b-=7},function(){this.qa(K(this),this.P);this.b-=7},function(){this.qa(K(this),this.R);this.b-=7},function(){this.qa(K(this),this.S);this.b-=7},function(){this.qa(K(this),this.T);this.b-=7},function(){this.qa(K(this),this.W);this.b-=7},function(){var a=this.M-1;if(this.J.length)for(var b=0;b<this.J.length;b++)if(this.J[b](a))return;this.w|=16;this.b-=7;this.G&&gb(this,-2147483648)?(H(this,a),this.G.ja()):this.sa&512||(this.G&&H(this,a),this.ja())},
function(){this.qa(K(this),this.j);this.b-=7},function(){this.j=this.O;this.b-=5},function(){this.j=this.P;this.b-=5},function(){this.j=this.R;this.b-=5},function(){this.j=this.S;this.b-=5},function(){this.j=this.T;this.b-=5},function(){this.j=this.W;this.b-=5},function(){this.j=this.X(K(this));this.b-=7},function(){this.b-=5},function(){this.j=Vc(this,this.O);this.b-=4},function(){this.j=Vc(this,this.P);this.b-=4},function(){this.j=Vc(this,this.R);this.b-=4},function(){this.j=Vc(this,this.S);this.b-=
4},function(){this.j=Vc(this,this.T);this.b-=4},function(){this.j=Vc(this,this.W);this.b-=4},function(){this.j=Vc(this,this.X(K(this)));this.b-=7},function(){this.j=Vc(this,this.j);this.b-=4},function(){this.j=Wc(this,this.O);this.b-=4},function(){this.j=Wc(this,this.P);this.b-=4},function(){this.j=Wc(this,this.R);this.b-=4},function(){this.j=Wc(this,this.S);this.b-=4},function(){this.j=Wc(this,this.T);this.b-=4},function(){this.j=Wc(this,this.W);this.b-=4},function(){this.j=Wc(this,this.X(K(this)));
this.b-=7},function(){this.j=Wc(this,this.j);this.b-=4},function(){this.j=M(this,this.O);this.b-=4},function(){this.j=M(this,this.P);this.b-=4},function(){this.j=M(this,this.R);this.b-=4},function(){this.j=M(this,this.S);this.b-=4},function(){this.j=M(this,this.T);this.b-=4},function(){this.j=M(this,this.W);this.b-=4},function(){this.j=M(this,this.X(K(this)));this.b-=7},function(){this.j=M(this,this.j);this.b-=4},function(){this.j=ad(this,this.O);this.b-=4},function(){this.j=ad(this,this.P);this.b-=
4},function(){this.j=ad(this,this.R);this.b-=4},function(){this.j=ad(this,this.S);this.b-=4},function(){this.j=ad(this,this.T);this.b-=4},function(){this.j=ad(this,this.W);this.b-=4},function(){this.j=ad(this,this.X(K(this)));this.b-=7},function(){this.j=ad(this,this.j);this.b-=4},function(){this.j=Xc(this,this.O);this.b-=4},function(){this.j=Xc(this,this.P);this.b-=4},function(){this.j=Xc(this,this.R);this.b-=4},function(){this.j=Xc(this,this.S);this.b-=4},function(){this.j=Xc(this,this.T);this.b-=
4},function(){this.j=Xc(this,this.W);this.b-=4},function(){this.j=Xc(this,this.X(K(this)));this.b-=7},function(){this.j=Xc(this,this.j);this.b-=4},function(){this.j=bd(this,this.O);this.b-=4},function(){this.j=bd(this,this.P);this.b-=4},function(){this.j=bd(this,this.R);this.b-=4},function(){this.j=bd(this,this.S);this.b-=4},function(){this.j=bd(this,this.T);this.b-=4},function(){this.j=bd(this,this.W);this.b-=4},function(){this.j=bd(this,this.X(K(this)));this.b-=7},function(){this.j=bd(this,this.j);
this.b-=4},function(){this.j=$c(this,this.O);this.b-=4},function(){this.j=$c(this,this.P);this.b-=4},function(){this.j=$c(this,this.R);this.b-=4},function(){this.j=$c(this,this.S);this.b-=4},function(){this.j=$c(this,this.T);this.b-=4},function(){this.j=$c(this,this.W);this.b-=4},function(){this.j=$c(this,this.X(K(this)));this.b-=7},function(){this.j=$c(this,this.j);this.b-=4},function(){M(this,this.O);this.b-=4},function(){M(this,this.P);this.b-=4},function(){M(this,this.R);this.b-=4},function(){M(this,
this.S);this.b-=4},function(){M(this,this.T);this.b-=4},function(){M(this,this.W);this.b-=4},function(){M(this,this.X(K(this)));this.b-=7},function(){M(this,this.j);this.b-=4},function(){Tc(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){Mc(this,Q(this));this.b-=10},function(){var a=P(this);Tc(this)||H(this,a);this.b-=10},yd,function(){var a=P(this);Tc(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,Lc(this));this.b-=11},function(){this.j=Vc(this,O(this));this.b-=
7},function(){R(this,this.M);H(this,0);this.b-=11},function(){Tc(this)&&(H(this,Q(this)),this.b-=6);this.b-=5},zd,function(){var a=P(this);Tc(this)&&H(this,a);this.b-=10},yd,function(){var a=P(this);Tc(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},Ad,function(){this.j=Wc(this,O(this));this.b-=7},function(){R(this,this.M);H(this,8);this.b-=11},function(){L(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){Oc(this,Q(this));this.b-=10},function(){var a=P(this);L(this)||H(this,a);this.b-=
10},function(){var a=O(this);Gb(this.A,a,this.j,this.M+-2&65535);this.b-=10},function(){var a=P(this);L(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,Nc(this));this.b-=11},function(){this.j=M(this,O(this));this.b-=7},function(){R(this,this.M);H(this,16);this.b-=11},function(){L(this)&&(H(this,Q(this)),this.b-=6);this.b-=5},zd,function(){var a=P(this);L(this)&&H(this,a);this.b-=10},function(){var a=O(this);this.j=Cb(this.A,a,this.M+-2&65535)&255;this.b-=10},function(){var a=
P(this);L(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},Ad,function(){this.j=ad(this,O(this));this.b-=7},function(){R(this,this.M);H(this,24);this.b-=11},function(){Rc(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){Pc(this,Q(this));this.b-=10},function(){var a=P(this);Rc(this)||H(this,a);this.b-=10},function(){var a=Q(this);R(this,K(this));Pc(this,a);this.b-=18},function(){var a=P(this);Rc(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,K(this));this.b-=
11},function(){this.j=Xc(this,O(this));this.b-=7},function(){R(this,this.M);H(this,32);this.b-=11},function(){Rc(this)&&(H(this,Q(this)),this.b-=6);this.b-=5},function(){H(this,K(this));this.b-=5},function(){var a=P(this);Rc(this)&&H(this,a);this.b-=10},function(){var a=K(this);Pc(this,Nc(this));Oc(this,a);this.b-=5},function(){var a=P(this);Rc(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},Ad,function(){this.j=bd(this,O(this));this.b-=7},function(){R(this,this.M);H(this,40);this.b-=11},
function(){Uc(this)||(H(this,Q(this)),this.b-=6);this.b-=5},function(){var a=Q(this);Ic(this,a&255|this.sa&-256);this.j=a>>8;this.b-=10},function(){var a=P(this);Uc(this)||H(this,a);this.b-=10},function(){this.sa&=-513;this.b-=4},function(){var a=P(this);Uc(this)||(R(this,this.M),H(this,a),this.b-=6);this.b-=11},function(){R(this,Kc(this)&255|this.j<<8);this.b-=11},function(){this.j=$c(this,O(this));this.b-=7},function(){R(this,this.M);H(this,48);this.b-=11},function(){Uc(this)&&(H(this,Q(this)),
this.b-=6);this.b-=5},function(){this.ia=K(this)&65535;this.b-=5},function(){var a=P(this);Uc(this)&&H(this,a);this.b-=10},function(){this.sa|=512;this.b-=4},function(){var a=P(this);Uc(this)&&(R(this,this.M),H(this,a),this.b-=6);this.b-=11},Ad,function(){M(this,O(this));this.b-=7},function(){R(this,this.M);H(this,56);this.b-=11}];
function T(a){y.call(this,"ChipSet",a,T,32768);var b=a.model;b&&!Bd[b]&&v("Unrecognized ChipSet model: "+b);this.w=Bd[b]||U;this.Ia=this.w.Ea;a.sound&&(this.aa=null,window&&(this.aa=window.AudioContext||window.webkitAudioContext),this.aa&&new this.aa);E(this)}Za(T);
var U={Ea:1978.1,Sc:{wa:0,yd:1,Cd:16,Kd:32,Td:64,Sd:128,ub:14},Ra:{wa:1,zc:1,Oc:2,Kc:4,Lc:16,Mc:32,Nc:64,ub:8},Tc:{wa:2,xd:3,ae:4,zd:8,Od:16,Pd:32,Qd:64,Ad:128,ub:0},Wd:{wa:3},Ud:{wa:2,Ld:7},Yd:{wa:3,be:1,Xd:2,Rd:4,Hd:8,Bd:16,vd:32},Vd:{wa:4},Zd:{wa:5,Dd:1,Ed:2,Fd:4,Gd:8,ce:16}},V={Ea:100,bb:{wa:66,de:1,Ic:2,Jc:4,Nd:8,Md:16,$b:32,Zb:64,Id:128},yc:{wa:66,INIT:0},Fa:{Jd:{wa:98},Pa:{xc:0,wc:1,Qc:2,Uc:4,Cc:5,Pc:6,Rc:7},Hb:16383},Bc:{wa:162,INIT:0},Ac:{wa:194,INIT:0}},Bd={SI1978:U,VT100:V};
T.prototype.pa=function(){return!1};T.prototype.Na=function(a,b,c,d){this.A=b;this.b=c;this.G=d;this.u=a;Bb(b,this,this.w.Nb);Fb(b,this,this.w.Ob)};T.prototype.Ca=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};T.prototype.Ja=function(a){return a?this.save():!0};U.Wa=[[U.Sc.ub,U.Ra.ub,U.Tc.ub,0,0,0,0]];V.Wa=[[V.yc.INIT,V.bb.Ic|V.bb.Jc,V.Bc.INIT,V.Ac.INIT],[0,0,0,0,Array(100)]];m=T.prototype;m.reset=function(){this.restore(this.w.Wa)||this.fa("reset error")};
m.save=function(){var a=new I(this);switch(this.Ia){case U.Ea:J(a,0,[this.ma,this.D,this.ua,this.N,this.Y,this.ga,this.ka]);break;case V.Ea:J(a,0,[this.ca,this.I,this.ea,this.da]),J(a,1,[this.K,this.C,this.J,this.U,this.H])}return a.data()};
m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.Ia){case U.Ea:return this.ma=b[0],this.D=b[1],this.ua=b[2],this.N=b[3],this.Y=b[4],this.ga=b[5],this.ka=b[6],!0;case V.Ea:return this.ca=b[0],this.I=b[2],this.ea=b[3],this.da=b[4],b=a[1],this.K=b[0],this.C=b[1],this.J=b[2],this.U=b[3],this.H=b[4],!0}return!1};m.start=function(){};m.stop=function(){};function Cd(a,b,c){a.D&=~b;c&&(a.D|=b)}m.Zc=function(a,b){var c=this.ma;D(this,a,null,b,"STATUS0",c);return c};
m.$c=function(a,b){var c=this.D;D(this,a,null,b,"STATUS1",c);return c};m.ad=function(a,b){var c=this.ua;D(this,a,null,b,"STATUS2",c);return c};m.Yc=function(a,b){var c=this.N>>8-this.Y&255;D(this,a,null,b,"SHIFT.RESULT",c);return c};m.ed=function(a,b,c){D(this,a,b,c,"SHIFT.COUNT",null);this.Y=b};m.gd=function(a,b,c){D(this,a,b,c,"SOUND1",null);this.ga=b};m.fd=function(a,b,c){D(this,a,b,c,"SHIFT.DATA",null);this.N=b<<8|this.N>>8};m.hd=function(a,b,c){D(this,a,b,c,"SOUND2",null);this.ka=b};
m.jd=function(a,b,c){D(this,a,b,c,"WATCHDOG",null)};function Dd(a){var b=0,c=0,d=~a.K;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.bd=function(a,b){var c=this.I,c=c&~V.bb.Zb;if((zc(this.b)&64)<<1&&(c|=V.bb.Zb,c!=this.I)){var d,e;d=this.J&1;e=this.J>>1&7;switch(e){case V.Fa.Pa.Rc:break;case V.Fa.Pa.wc:this.K=this.K<<1|d;break;case V.Fa.Pa.Cc:d=Dd(this);this.H[d]=V.Fa.Hb;fb(this,"doNVRCommand(): erase data at addr "+r(d));break;case V.Fa.Pa.xc:this.C=this.C<<1|d;break;case V.Fa.Pa.Uc:d=Dd(this);e=this.C&V.Fa.Hb;this.H[d]=e;fb(this,"doNVRCommand(): write data "+r(e)+" to addr "+r(d));break;case V.Fa.Pa.Pc:d=Dd(this);e=this.H[d];
null==e&&(e=V.Fa.Hb);this.C=e;fb(this,"doNVRCommand(): read data "+r(e)+" from addr "+r(d));break;case V.Fa.Pa.Qc:this.C<<=1;this.U=this.C&V.Fa.Hb+1;break;default:fb(this,"doNVRCommand(): unrecognized command 0x"+q(e,2))}}c&=~V.bb.$b;this.U&&(c|=V.bb.$b);this.I=c;D(this,a,null,b,"FLAGS.BUFFER",c);return c};m.kd=function(a,b,c){D(this,a,b,c,"BRIGHTNESS",null);this.ca=b};m.nd=function(a,b,c){D(this,a,b,c,"NVR.LATCH",null);this.J=b};m.md=function(a,b,c){D(this,a,b,c,"DC012",null);this.ea=b};
m.ld=function(a,b,c){D(this,a,b,c,"DC011",null);this.da=b};U.Nb={0:T.prototype.Zc,1:T.prototype.$c,2:T.prototype.ad,3:T.prototype.Yc};U.Ob={2:T.prototype.ed,3:T.prototype.gd,4:T.prototype.fd,5:T.prototype.hd,6:T.prototype.jd};V.Nb={66:T.prototype.bd};V.Ob={66:T.prototype.kd,98:T.prototype.nd,162:T.prototype.md,194:T.prototype.ld};Ja(function(){for(var a=C(document,"pc8080","chipset"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new T(d);db(d,c)}});
function Ed(a){y.call(this,"ROM",a,Ed);this.u=null;this.H=a.addr;this.C=a.size;this.I=a.writable;this.w=a.alias;this.D=a.file;this.J=ba(this.D);if(this.D){a=this.D;var b=da(this.J);"json"!=b&&"hex"!=b&&(a=qa()+"/api/v1/dump?file="+this.D+"&format=bytes&decimal=true");var c=this;oa(a,null,!0,function(a,b,f){Fd(c,a,b,f)})}}Za(Ed);var Gd=[0,5];Ed.prototype.Na=function(a,b,c,d){this.A=b;this.b=c;this.G=d;Hd(this)};
Ed.prototype.Ca=function(){if(this.Ma){if(this.G){var a=this.G,b=this.id,c=this.H,d=this.C,e=this.Ma,f=[],h;for(h in e){var g=e[h];"number"==typeof g&&(e[h]=g={o:g});var k=g.o,l=g.a;if(void 0!==k){var n=f,k=[k>>>0,h],p=ka(n,k,a.Ta);0>p&&n.splice(-(p+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.I.push({ee:b,F:c,cd:d,Ma:e,bc:f})}delete this.Ma}return!0};Ed.prototype.Ja=function(){return!0};
function Fd(a,b,c,d){if(d)a.fa("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<h.length;c++)a.u[d++]=h[c]&255,a.u[d++]=h[c]>>8&255,a.u[d++]=h[c]>>16&255,a.u[d++]=h[c]>>24&255;else a.u=e;a.Ma=e.symbols;if(!a.u.length){v("Empty ROM: "+b);return}if(1==a.u.length){v(a.u[0]);return}}catch(g){a.fa("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
" ").replace(/ +$/,"").split(" "),a.u=Array(b.length),e=0;e<b.length;e++)a.u[e]=aa(b[e],16);Hd(a)}}
function Hd(a){if(!jb(a))if(!a.D)E(a);else if(a.u&&a.A){a.C||(a.C=a.u.length);if(a.u.length!=a.C)mb(a,"ROM size (0x"+q(a.u.length)+") does not match specified size ("+("0x"+q(a.C))+")");else if(Id(a,a.H)){var b=[];"number"==typeof a.w?b.push(a.w):null!=a.w&&a.w.length&&(b=a.w);for(var c=0;c<b.length;c++){for(var d=a,e=b[c],f=d.A,h=d.C,g=[],k=d.H>>>f.la;0<h&&k<f.V.length;)g.push(f.V[k++]),h-=f.Ba;f=d.A;d=d.C;h=0;for(e>>>=f.la;0<d&&e<f.V.length;){k=g[h++];if(!k)break;f.V[e++]=k;d-=f.Ba}}delete a.u}E(a)}}
function Id(a,b){if(ub(a.A,b,a.C,a.I?1:Vb)){var c;for(c=0;c<a.u.length;c++)zb(a.A,b+c,a.u[c]);if(a.I&&256==b){for(c=0;c<Gd.length;c++)zb(a.A,Gd[c],118);Hc(a.b,function(a){return function(b){if(0<=Gd.indexOf(b)){var c=!1,h=a.b,g=a.G;if(5==b)switch(c=!0,h.P){case 2:Jd(a,String.fromCharCode(h.S));break;case 9:for(var k=Nc(h),l="",n=255;n--;){var p=a.b.X(k++);if(36==p)break;l+=String.fromCharCode(p)}Jd(a,l);break;default:c=!1}c?zd.call(h):g&&(a.g("\nCP/M vector "+r(b)),H(h,b),g.ja());b=!0}else b=!1;return b}}(a));
Jc(a.b,b)}return!0}return!1}function Jd(a,b){b=b.replace(/\r/g,"");a.Aa&&(a.Aa.value+=b,a.Aa.scrollTop=a.Aa.scrollHeight)}Ja(function(){for(var a=C(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new Ed(d);db(d,c)}});function Kd(a){y.call(this,"RAM",a,Kd);this.w=a.addr;this.C=a.size;this.u=!1}Za(Kd);m=Kd.prototype;m.Na=function(a,b,c,d){this.A=b;this.b=c;this.G=d;E(this)};m.Ca=function(a,b){b||this.reset();return!0};m.Ja=function(a){return a?this.save():!0};
m.reset=function(){!this.u&&this.C&&ub(this.A,this.w,this.C,1)&&(this.u=!0);this.u||v("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};Ja(function(){for(var a=C(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new Kd(d);db(d,c)}});function X(a){y.call(this,"Keyboard",a,X,65536);this.reset();E(this)}Za(X);
var Ld={Qa:{wa:130,Gc:1,Fc:2,Ec:4,Dc:8,Hc:16,ac:32,$d:64,wd:128}},Md={"1p":49,"2p":50,coin:51,left:37,right:39,fire:32},Nd={65:37,68:39,76:32},Od={l4:Ld.Qa.Gc,l3:Ld.Qa.Fc,l2:Ld.Qa.Ec,l1:Ld.Qa.Dc,locked:Ld.Qa.Hc,online:Ld.Qa.ac,local:~Ld.Qa.ac};
X.prototype.pa=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.L[e]){if("led"==a&&Od[b])return this.L[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return Pd(d,a,!0)},c.onkeyup=function(a){return Pd(d,a,!1)},!0;default:if(void 0!==Md[b])return this.L[e]=c,a=function(a,b){return function(){Qd(a,b,!0)}}(this,b),b=function(a,b){return function(){Qd(a,b,!1)}}(this,b),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend=b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};
X.prototype.Na=function(a,b,c,d){this.G=d;this.C=qb(a,"ChipSet");this.Ia=this.C.Ia;switch(this.Ia){case V.Ea:this.w=Ld}this.w&&(Bb(b,this,this.w.Nb),Fb(b,this,this.w.Ob))};X.prototype.Ca=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};X.prototype.Ja=function(a){return a?this.save():!0};Ld.Wa=[[0]];X.prototype.reset=function(){this.u={};this.b={};this.w&&!this.restore(this.w.Wa)&&this.fa("reset error")};
X.prototype.save=function(){var a=new I(this);switch(this.Ia){case V.Ea:J(a,0,[this.A])}return a.data()};X.prototype.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.Ia){case U.Ea:return!0;case V.Ea:return this.A=b[0],Rd(this),!0}return!1};function Rd(a){for(var b in Od){var c=a.L["led-"+b];if(c){var d=Od[b],e=!!(a.A&d);d&d-1&&(e=!(a.A&~d));c.style.backgroundColor=e?"#ff0000":"#000000"}}}
function Pd(a,b,c){var d=!0,e;a:{e=b.keyCode;e=Nd[e]||e;for(var f in Md)if(Md[f]===e){e=f;break a}e=null}e&&(d=Qd(a,e,c),b.preventDefault());return d}
function Qd(a,b,c){if(c)a.u[b]=Date.now(),delete a.b[b];else{var d=a.u[b];if(d&&100>Date.now()-d)return a.b[b]=d,Sd(a),!0;delete a.u[b]}if(a.C)switch(b){case "1p":Cd(a.C,U.Ra.Kc,c);break;case "2p":Cd(a.C,U.Ra.Oc,c);break;case "coin":Cd(a.C,U.Ra.zc,c);break;case "left":Cd(a.C,U.Ra.Mc,c);break;case "right":Cd(a.C,U.Ra.Nc,c);break;case "fire":Cd(a.C,U.Ra.Lc,c)}return!0}
function Sd(a){for(var b=-1,c=Object.keys(a.b),d=0;d<c.length;d++){var e=c[d],f=100-(Date.now()-a.b[e]);if(0<f){if(0>b||b>f)b=f}else delete a.b[e],Qd(a,e,!1)}0<=b&&setTimeout(function(){Sd(a)},b)}X.prototype.D=function(a,b,c){D(this,a,b,c,"KBDUART.STATUS",null);this.A=b;Rd(this)};Ld.Nb={};Ld.Ob={130:X.prototype.D};Ja(function(){for(var a=C(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new X(d);db(d,c)}});
function Td(a,b,c,d,e){var f=this;this.jc=xa("Gecko/");var h=["","moz","ms","webkit"];y.call(this,"Video",a,Td,262144);this.aa=a.screenWidth;this.U=a.screenHeight;this.ya=a.bufferAddr;this.rd=a.bufferRAM;var g=a.bufferFormat;this.Y=g&&Ud[g.toLowerCase()]||Vd;this.Ta=a.bufferCols;this.ea=a.bufferRows;this.od=this.oa=a.cellWidth||1;this.ha=a.cellHeight||1;this.eb=null;this.Sa=a.bufferBits||1;this.sd=a.bufferLeft||0;if(this.D=a.bufferRotate)this.D=this.D%360,0<this.D&&(this.D-=360),-90!=this.D&&(this.fa("unsupported buffer rotation: "+
this.D),this.D=0);this.qc=a.interruptRate;this.td=a.refreshRate||60;this.N=b;this.H=c;this.Ga=(this.ud=d)||b||null;this.pd=this.aa;this.qd=this.U;this.Kb=this.aa/this.Ta|0;this.ic=this.U/this.ea|0;1<this.ha&&this.ea++;b=a.smoothing;(c=Ra.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)if(d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.H[d]){this.H[d]=b;break}if(this.I=a.screenRotate)this.I=this.I%360,0<this.I&&(this.I-=360),-90!=this.I?(this.fa("unsupported screen rotation: "+
this.I),this.I=0):(this.H.translate(0,this.U),this.H.rotate(this.I*Math.PI/180),this.H.scale(this.U/this.aa,this.aa/this.U));if(this.w=e)if(this.w.gb=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.w.gb){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){Wd(f,document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},
!1);break}for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenerror","on"+d in document){document.addEventListener(d,function(){Wd(f,null)},!1);break}}if(this.ga=a.fontROM)"json"!=da(this.ga)&&(this.ga=qa()+"/api/v1/dump?file="+this.ga+"&format=bytes"),oa(this.ga,null,!0,function(a,b,c){Xd(f,a,b,c)});this.wb={}}Za(Td);var Vd=0,Ud={vt100:2};
Td.prototype.Na=function(a,b,c,d){this.u=a;this.A=b;this.b=c;this.G=d;this.C=qb(a,"ChipSet");!this.Y&&this.C&&this.C.Ia==U.Ea&&(this.Y=1);this.J=this.Ta*this.oa;this.ca=this.ea*this.ha;b=this.J;c=this.ca;this.D&&(b=this.ca,c=this.J);this.Va=(this.J*this.Sa>>3)*this.ca;if(this.rd||ub(this.A,this.ya,this.Va,3))1<this.oa?Yd(this,this.Ta*this.ea):(this.kc=this.H.createImageData(b,c),this.pc=16/this.Sa|0,Yd(this,this.Va>>1)),this.K=document.createElement("canvas"),this.K.width=b,this.K.height=c,this.fb=
this.K.getContext("2d"),this.ma={},this.Ha=1<<this.Sa,this.ua=Array(this.Ha+2),this.ua[0]=[0,0,0,255],this.ua[1]=[255,255,255,255],1==this.Y&&(this.ua[this.Ha+0]=[255,255,0,255],this.ua[this.Ha+1]=[0,255,0,255]),2==this.Y&&(this.rc=60,this.vb=!1,this.xa=Array(this.Ta));if(this.da=qb(a,"Keyboard")){for(var e in this.wb)this.da.pa("led",e,this.wb[e]);this.N&&this.da.pa(this.ud?"textarea":"canvas","kbd",this.Ga)}this.ga||E(this)};
function Xd(a,b,c,d){if(d)a.fa("Unable to load font ROM (error "+d+": "+b+")");else{ab(a.Tb,b,c);try{var e=eval("("+c+")"),f=e.bytes||e;if(!f||!f.length){v("Empty font ROM: "+b);return}if(1==f.length){v(f[0]);return}if(2048==f.length)Zd(a,f);else{a.fa("Unrecognized font data length ("+f.length+")");return}}catch(h){a.fa("Font ROM data error: "+h.message);return}(a.H||a.G)&&E(a)}}
function Zd(a,b){a.eb=b;a.ma[96]=[$d(a,a.oa,a.ha),$d(a,a.oa,a.ha,a.vb)];a.ma[64]=[$d(a,2*a.oa,a.ha),$d(a,2*a.oa,a.ha,a.vb)];a.ma[32]=a.ma[0]=[$d(a,2*a.oa,2*a.ha),$d(a,2*a.oa,2*a.ha,a.vb)]}
function $d(a,b,c,d){var e=8>=a.od?8:16,f=8<e?15:0,h=a.eb.length/e,g=!1===d,k={oa:b,ha:c};k.canvas=document.createElement("canvas");k.canvas.width=16*b;k.canvas.height=h/16*c;k.context=k.canvas.getContext("2d");for(var l=k.context.createImageData(b,c),n=0;n<h;n++){for(var p=0,x=p;p<a.ha;p++)for(var w=n*e+(f+p&e-1),w=d&&8==p?255:a.eb[w],t=0;t<c/a.ha;t++){for(var A=0,u=A;A<a.oa;A++)for(var F=w&128>>(7<A?7:A),B=0;B<b/a.oa;B++)g&&(F=!F),ae(a,l,u,x,F?1:0),u++;x++}k.context.putImageData(l,(n&15)*b,(n>>
4)*c)}return k}
Qd.prototype.Ca=function(){if(2==this.Y){for(var a={0:[32,"SET-UP A"],2:[64,'TO EXIT PRESS "SET-UP"'],22:[96," T T T T T T T T T"],23:[96,"1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890"],24:[]},b=this.ya,c=-1,d=-1,e,f=-(60==this.nc?2:5);f<this.ea;f++){var h=a[f];if(0<=c){var g=!1,c=b+2;h?h.length?d=h[0]:(c=b-1,g=!0):32==d&&(h=a[f-1],d=0);e=d&96|c>>8&15|16;zb(this.w,b++,e);zb(this.w,b++,c&
255);if(g)break}if(h)for(c=0,e=1;e<h.length;e++){for(var g=h[e],k=0;k<g.length;k++)zb(this.w,b++,g.charCodeAt(k)|c);c^=128}zb(this.w,b++,127);c=b}Zd(this)}return!0};Qd.prototype.ma=function(a,b,c){var d=this;if("led"==a||"rled"==a)return this.tb[b]=c,!0;switch(b){case "fullScreen":return this.K[b]=c,this.A&&this.A.cb?c.onclick=function(){d.cb()}:c.parentNode.removeChild(c),!0}return!1};
Qd.prototype.cb=function(){var a=!1;if(this.A){if(this.A.cb){a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=this.aa/this.W;b>c&&(a=Math.round(c/b*100)+"%")}this.fc?(this.T.style.width=a,this.T.style.width=a,this.T.style.display="block",this.T.style.margin="auto"):(this.A.style.width=a,this.A.style.height="auto");this.A.style.backgroundColor="black";this.A.cb();a=!0}this.Fa&&this.Fa.focus()}return a};
function Td(a,b){!b&&a.A&&(a.fc?a.T.style.width=a.T.style.height="":a.A.style.width=a.A.style.height="");fb(a,"notifyFullScreen("+b+")",!0)}function Vd(a,b){a.hc=b;a.za=!1;if(void 0===a.ra||a.ra.length!=a.hc)a.ra=Array(a.hc)}function Yd(a,b,c,d,e){d=a.F?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.Y&&(208<=c&&236>c?e=a.Ga+0:28<=c&&72>c&&(e=a.Ga+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 Zd(a){for(var b=a.ya,c=-1,d=0,e=60==a.nc?2:5,f=0,h=0;d<a.ea;){for(var g=0,k=b,l=c;;){var n=xb(a.w,k++);if(127==(n&127)){var p=xb(a.w,k++),c=p&96,b=(p&15)<<8|xb(a.w,k),b=b+(p&16?8192:16384);break}if(g<a.xa.length)a.xa[g++]=n;else break}if(e)e--;else{for(;g<a.xa.length;)a.xa[g++]=0;if(0<=l)for(k=0;k<g;k++){n=a.xa[k];if(!a.za||n!==a.ra[f]){var p=a,x=a.bb,w=n&127;if(n=p.ua[l][n&128?1:0]){var t=(w&15)*n.la,w=(w>>4)*n.ga,z=void 0,u=void 0,E=void 0,A=void 0,ha=n.la,pa=n.ga;x?(z=k*p.la,u=d*p.ga,
E=p.la,A=p.ga):(z=k*p.Hb,u=d*p.ec,E=p.Hb,A=p.ec);n.la>p.la&&(z*=2,E*=2);n.ga>p.ga&&(0==l&&(w+=p.ga),pa=p.ga);x?x.drawImage(n.canvas,t,w,ha,pa,z,u,E,A):(z+=0,u+=0,p.H.drawImage(n.canvas,t,w,ha,pa,z,u,E,A))}h++}f++}d++}}a.za=!0;h&&a.bb&&a.H.drawImage(a.L,0,0,a.J,a.ca-a.ga,0,0,a.ed,a.fd)}
Ja(function(){for(var a=C(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=B(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=ra().indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height=
(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Ra.aspect);f&&.3<=f&&3.33>=f&&(Ia("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");xa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new Qd(d,e,h,f,c);db(d,c)}});
function $d(a){y.call(this,"Debugger",a,$d);this.style=ae;this.ca=this.za=this.L=0;this.W=Y();this.Ta=Y();this.F=-1;this.A=[];this.ea=!1;this.da=Y();this.I=[];this.oa={};this.C=this.Y=this.H=[];be(this);this.wa=0;ce(this);this.Fa=[];de(this,a.messages);this.Ga=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return ee(b,a)}):void 0===global.$&&(global.$=function(a){return ee(b,a)})}Za($d);
var fe={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory",f:"frequencies","g [#]":"go [to #]",h:"halt","i [#]":"input port #","if":"eval expression",k:"stack trace",ln:"list nearest symbol(s)",m:"messages","o [#]":"output port #",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine",s:"set options","t [#]":"trace","u [#]":"unassemble",v:"print version","var":"assign variable"},ae=8080,ge="NONE ACI ADC ADD ADI ANA ANI CALL CC CM CNC CNZ CP CPE CPO CZ CMA CMC CMP CPI DAA DAD DCR DCX DI EI HLT IN INR INX JMP JC JM JNC JNZ JP JPE JPO JZ LDA LDAX LHLD LXI MOV MVI NOP ORA ORI OUT PCHL POP PUSH RAL RAR RET RC RM RNC RNZ RP RPE RPO RZ RLC RRC RST SBB SBI SHLD SPHL STA STAX STC SUB SUI XCHG XRA XRI XTHL".split(" "),
he="NONE ADC ADC ADD ADD AND AND CALL CALLC CALLS CALLNC CALLNZ CALLNS CALLP CALLNP CALLZ NOT CMC CMP CMP DAA ADD DEC DEC CLI STI HLT IN INC INC JMP JC JS JNC JNZ JNS JP JNP JZ MOV MOV MOV MOV MOV MOV NOP OR OR OUT JMP POP PUSH RCL RCR RET RETC RETS RETNC RETNZ RETNS RETP RETNP RETZ ROL ROR RST SBB SBB MOV MOV MOV MOV STC SUB SUB XCHG XOR XOR XCHG".split(" "),ie="B C D E H L M A BC DE HL SP PC PS PSW".split(" "),je=[[45],[42,2067,32],[71,2131,18193],[29,2067],[28,17],[22,17],[44,17,32],[63],[45,32768],
[21,18963,2067],[40,18193,2131],[23,2067],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2323,32],[71,2387,18193],[29,2323],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,18963,2323],[40,18193,2387],[23,2323],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2579,32],[68,115,18963],[29,2579],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,18963,2579],[41,18963,115],[23,2579],[28,1297],[22,1297],[44,1297,32],[16,18193],[45,32768],[42,2835,32],[70,115,18193],[29,2835],[28,1617],[22,1617],
[44,1617,32],[72],[45,32768],[21,18963,2835],[39,18193,115],[23,2835],[28,1809],[22,1809],[44,1809,32],[17],[43,17,17],[43,17,273],[43,17,529],[43,17,785],[43,17,1041],[43,17,1297],[43,17,1617],[43,17,1809],[43,273,17],[43,273,273],[43,273,529],[43,273,785],[43,273,1041],[43,273,1297],[43,273,1617],[43,273,1809],[43,529,17],[43,529,273],[43,529,529],[43,529,785],[43,529,1041],[43,529,1297],[43,529,1617],[43,529,1809],[43,785,17],[43,785,273],[43,785,529],[43,785,785],[43,785,1041],[43,785,1297],[43,
785,1617],[43,785,1809],[43,1041,17],[43,1041,273],[43,1041,529],[43,1041,785],[43,1041,1041],[43,1041,1297],[43,1041,1617],[43,1041,1809],[43,1297,17],[43,1297,273],[43,1297,529],[43,1297,785],[43,1297,1041],[43,1297,1297],[43,1297,1617],[43,1297,1809],[43,1617,17],[43,1617,273],[43,1617,529],[43,1617,785],[43,1617,1041],[43,1617,1297],[26],[43,1617,1809],[43,1809,17],[43,1809,273],[43,1809,529],[43,1809,785],[43,1809,1041],[43,1809,1297],[43,1809,1617],[43,1809,1809],[3,18193,17],[3,18193,273],
[3,18193,529],[3,18193,785],[3,18193,1041],[3,18193,1297],[3,18193,1617],[3,18193,1809],[2,18193,17],[2,18193,273],[2,18193,529],[2,18193,785],[2,18193,1041],[2,18193,1297],[2,18193,1617],[2,18193,1809],[73,18193,17],[73,18193,273],[73,18193,529],[73,18193,785],[73,18193,1041],[73,18193,1297],[73,18193,1617],[73,18193,1809],[66,18193,17],[66,18193,273],[66,18193,529],[66,18193,785],[66,18193,1041],[66,18193,1297],[66,18193,1617],[66,18193,1809],[5,18193,17],[5,18193,273],[5,18193,529],[5,18193,785],
[5,18193,1041],[5,18193,1297],[5,18193,1617],[5,18193,1809],[76,18193,17],[76,18193,273],[76,18193,529],[76,18193,785],[76,18193,1041],[76,18193,1297],[76,18193,1617],[76,18193,1809],[46,18193,17],[46,18193,273],[46,18193,529],[46,18193,785],[46,18193,1041],[46,18193,1297],[46,18193,1617],[46,18193,1809],[18,18193,17],[18,18193,273],[18,18193,529],[18,18193,785],[18,18193,1041],[18,18193,1297],[18,18193,1617],[18,18193,1809],[58],[50,2067],[34,51],[30,51],[11,51],[51,2067],[4,18193,33],[65,128],[62],
[54],[38,51],[30,32819],[15,51],[7,51],[1,18193,33],[65,128],[57],[50,2323],[33,51],[48,33,18193],[10,51],[51,2323],[74,18193,33],[65,128],[55],[54,32768],[31,51],[27,18193,33],[8,51],[7,32819],[67,18193,33],[65,128],[61],[50,2579],[37,51],[78,19283,18963],[14,51],[51,2579],[6,18193,33],[65,128],[60],[49,2579],[36,51],[75,18963,18707],[13,51],[7,32819],[77,18193,33],[65,128],[59],[50,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]],ke={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=$d.prototype;
m.Ma=function(a,b,c,d){this.w=b;this.b=c;this.u=a;(a=hc(a,"messages"))&&de(this,a);this.Qa=je;le(this,function(a){a:{var b=d.w.U,c=a[0],g=a=0,k=b.length;if(c){a=me(ne(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.w.ja;k=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;k--;){var n=b[g];n.type==c?l++||d.g("..."):(c=n.type,l=wb[c],n&&d.g(q(n.id)+" %"+q(g<<d.w.ja)+" %%"+q(n.D)+" "+r(n.Cb)+" "+
r(n.size)+" "+l),c!=Ub&&(c=-1),l=0);a+=d.w.Ba;g++}}});F(this)};
m.ma=function(a,b,c){var d=this;switch(b){case "debugInput":return this.ua=this.K[b]=c,c.onkeydown=function(a){var b;if(13==a.keyCode)b=c.value,c.value="",ee(d,b,!0);else if(27==a.keyCode)c.value=b="";else if(38==a.keyCode?d.F<d.A.length-1&&(b=d.A[++d.F]):40==a.keyCode&&(0<d.F?b=d.A[--d.F]:(b="",d.F=-1)),null!=b){var h=b.length;c.value=b;c.setSelectionRange(h,h)}null!=b&&a.preventDefault&&a.preventDefault()},!0;case "debugEnter":return this.K[b]=c,Ea(c,function(){if(d.ua){var a=d.ua.value;d.ua.value=
"";ee(d,a,!0);return!0}return!1}),!0;case "step":return this.K[b]=c,Ea(c,function(a){var b=!1;ib(d,!0)||(hb(d,!0),b=d.pb(a?1:0),hb(d,!1));return b}),!0}return!1};m.Bb=function(){this.ua&&this.ua.focus()};function me(a){a=a&&a.D;null==a&&(a=-1);return a}m.X=function(a,b){var c=255,d=me(a);-1!==d&&(c=xb(this.w,d),b&&oe(a,b));return c};m.Na=function(a,b){var c=65535,d=me(a);-1!==d&&(c=yb(this.w,d),b&&oe(a,b));return c};m.na=function(a,b,c){var d=me(a);-1!==d&&(zb(this.w,d,b),c&&oe(a,c),kc(this.b,!0))};
m.Mb=function(a,b,c){var d=me(a);if(-1!==d){var e=this.w,f=d&e.w,h=(d&e.A)>>>e.ja;f!=e.w?e.U[h].Vb(f,b&65535,d):(e.U[h++].Db(f,b&255,d),e.U[h&e.J].Db(0,b>>8&255,d+1));c&&oe(a,c);kc(this.b,!0)}};function Y(a){return{D:a,Ka:!1}}function pe(a){return[a.D,a.Ka]}function qe(a){return{D:a[0],Ka:a[1]}}
function ne(a,b,c){var d;c=(c?a.W:a.Ta).D;if(void 0!==b){d=b=re(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;c<a.I.length;c++){var f=a.I[c].La[d];if(void 0!==f){d=f.o;void 0!==d&&(e=Y(d));break}}if(d=e)return d;c=se(a,b,void 0)}null!=c&&(d=Y(c));return d}function te(a,b,c){c&&(c=c.match(/(['"])(.*?)\1/))&&(b.Lc=ue(a,b.qc=c[2]))}function oe(a,b){null!=a.D&&(a.D+=b||1)}function Z(a){return q(a,4)}
function ve(a,b,c){var d="";for(c=c||256;d.length<c;){var e=a.X(b,1);if(!e||36==e||127<=e)break;d+=32<=e?String.fromCharCode(e):"."}return d}function de(a,b){a.G=a;a.ka=a.Mc=536870912;a.xa=null;a.ya=[];var c=ue(a,b.replace("keys","key").replace("kbd","keyboard"),!1,"|");if(c.length)for(var d in ke)0<=na(c,d)&&(a.ka|=ke[d],a.g(d+" messages enabled"))}function le(a,b){for(var c in ke)if(64==ke[c]){a.Fa[c]=b;break}}
function we(a,b){var c;a=a.toUpperCase();null==b?c=na(ie,a):(c=na(ie,a.substr(b,2)),0>c&&(c=na(ie,a.substr(b,1))));return c}function xe(a,b){var c=0,d=ye(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?q(d,c):"??"}
function ye(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.N;break;case 1:c=d.O;break;case 8:c=Kc(d);break;case 2:c=d.P;break;case 3:c=d.R;break;case 9:c=Mc(d);break;case 4:c=d.S;break;case 5:c=d.V;break;case 10:c=K(d);break;case 6:c=d.X(K(d));break;case 11:c=d.ha;break;case 12:c=d.M;break;case 13:c=Jc(d);break;case 14:c=Jc(d)&255|d.j<<8}}return c}
function ze(a,b){b=re(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=we(b,c+1),0<=e&&(b=b.substr(0,c)+xe(a,e)+b.substr(c+1+ie[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=aa(e,16),null!=d&&32<=d&&128>d?(d=e+" '"+String.fromCharCode(d)+"'",b=b.replace("#"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("$",c));)e=b.substr(c+1,9),(d=ne(a,e))?(d=e+' "'+ve(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=ne(a,e))?(oe(d),d=e+' "'+
ve(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}m.message=function(a,b){b&&(a+=" at "+Z(Y(this.b.M).D));if(this.ka&1073741824)this.ya.push(a);else if(!this.xa||a!=this.xa)if(this.xa=a,this.ka&-2147483648&&(this.ia(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.mb=0;c.F-=c.b;c.b=0;kc(c)}};
function eb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.ka&g)!=g||a.message(b.$a+"."+(null!=d?"outPort":"inPort")+"("+r(c)+","+(f?f:"unknown")+(null!=d?",0x"+q(d,2):"")+")"+(null!=h?": 0x"+q(h,2):"")+(null!=e?" at "+Z(e):""))}m.Ua=function(){this.g("Type ? for help with PC8080 Debugger commands");this.Da();if(this.Ga){var a=this.Ga;this.Ga=null;ee(this,a)}};
function ce(a){var b;if(td(a)){if(!a.T||!a.T.length){a.T=Array(1E3);for(b=0;b<a.T.length;b++)a.T[b]=Y();a.ra=0;a.g("instruction history buffer allocated")}if(!a.J||!a.J.length)for(a.J=Array(256),b=0;b<a.J.length;b++)a.J[b]=[b,0]}else a.T&&a.T.length&&a.g("instruction history buffer freed"),a.ra=0,a.T=[],a.J=[]}m.Za=function(a){if(!Ae(this))return!1;this.b.Za(a);return!0};
m.pb=function(a,b,c){if(!Ae(this))return!1;this.L=0;a||td(this)&&ud(this,this.b.M,0);try{var d=this.b.pb(a);0<d&&(this.L+=d,Ac(this.b,d,!0),xc(this.b,d),this.ca++)}catch(e){"number"!=typeof e&&(this.L=0,mb(this.b,e.stack||e.message))}!1!==c&&kc(this.b);this.Da(b||!1);return 0<this.L};m.ia=function(a){this.b&&this.b.ia(a)};m.Da=function(a){void 0===a&&(a=!0);this.W=Y(this.b.M);a&&1!=this.aa?Be(this):Ce(this)};
function Ae(a){var b;if(b=a.b&&lb(a.b))b=a.b,b.B.pa?b=!0:(b.g(b.toString()+" not powered"),b=!1);b&&!ib(a.b)?(a=a.b,a.B.gb?(a.g(a.toString()+" error"),a=!0):a=!1,a=!a):a=!1;return a}m.Ca=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};m.Ia=function(a,b){b&&this.g(a?"suspending":"shutting down");return a?this.save():!0};m.reset=function(a){ce(this);this.ca=this.za=0;this.xa=null;this.L=0;this.W=Y(this.b.M);this.B.sa=!1;De(this);a||this.Da()};
m.save=function(){var a=new I(this);J(a,0,pe(this.W));J(a,1,pe(this.da));J(a,2,[this.A,this.ea,this.ka]);J(a,3,this.I);return a.data()};m.restore=function(a){var b=0;void 0!==a[2]&&(this.W=qe(a[b++]),this.da=qe(a[b++]),this.A=a[b][0],"string"==typeof this.A&&(this.A=[this.A]),this.ea=a[b][1],this.ka|=a[b][2]);a[3]&&(this.I=a[3]);return!0};m.start=function(a,b){this.aa||this.g("running");this.B.sa=!0;this.sb=a;this.tb=b};
m.stop=function(a,b){if(this.B.sa){this.B.sa=!1;this.L=b-this.tb;if(!this.aa){var c="stopped";if(this.L){var d=a-this.sb,e=0<d?Math.round(1E3*this.L/d):0,c=c+" (";td(this)&&(c+=this.ca+" opcodes, ",this.za-=this.ca,this.ca=0);c+=this.L+" cycles, "+d+" ms, "+e+" hz)"}else gb(this,-2147483648)&&(c+=" (use the 't' command to execute blocked faults)");this.g(c)}this.Da(!0);this.Bb();De(this,this.b.M)}};function td(a){return 1<a.C.length||!!a.wa}
function ud(a,b,c){var d=a.b;if(0<c&&(a.wa&&!--a.wa||cc(a,b,1,a.C)))return!0;0<=c&&a.J.length&&(a.ca++,b=xb(a.w,b),null!=b&&(a.J[b][1]++,b=a.T[a.ra],b.D=d.M,b.Ka=!1,++a.ra==a.T.length&&(a.ra=0)));return!1}function Db(a,b,c){a.g("break on input from port "+r(b)+": "+q(c));a.ia(!0)}function Hb(a,b,c){a.g("break on output to port "+r(b)+": "+q(c));a.ia(!0)}
function be(a){var b,c;a.C=["bp"];if(void 0!==a.Y)for(b=1;b<a.Y.length;b++){c=a.Y[b];var d=a.w;dc(d.U[me(c)>>>d.ja],!1)}a.Y=["br"];if(void 0!==a.H)for(b=1;b<a.H.length;b++)c=a.H[b],d=a.w,dc(d.U[me(c)>>>d.ja],!0);a.H=["bw"];a.ab=0}m.Sa=function(a,b,c){var d=!0;c||Ee(this,a,b,!1,!0);if(a!=this.C){var e=me(b);if(-1===e)this.g("invalid address: "+Z(b.D)),d=!1;else{var f=this.w;f.U[e>>>f.ja].Sa(e&f.w,a==this.H)}}d&&(a.push(b),c?b.Ka=!0:(Fe(this,a,a.length-1,"set"),ce(this)));return d};
function Ee(a,b,c,d,e){var f=!1;c=me(c);for(var h=1;h<b.length;h++){var g=b[h];if(c==me(g)&&(!d||g.Ka)){f=!0;g.Ka||e||Fe(a,b,h,"cleared");b.splice(h,1);b!=a.C&&(d=a.w,dc(d.U[c>>>d.ja],b==a.H));g.Ka||ce(a);break}}return f}function df(a,b){for(var c=1;c<b.length;c++)Fe(a,b,c);return b.length-1}function Fe(a,b,c,d){c=b[c];a.g(b[0]+" "+Z(c.D)+(d?" "+d:c.qc?' "'+c.qc+'"':""))}
function De(a,b){if(void 0!==b)cc(a,b,1,a.C,!0),a.aa=0;else for(var c=1;c<a.C.length;c++){var d=a.C[c];if(d.Ka){if(!Ee(a,a.C,d,!0))break;c=0}}}
function cc(a,b,c,d,e){var f=!1;if(!a.ab++)for(var h=1;!f&&h<d.length;h++){var g=d[h];if(!e||g.Ka)for(var k=me(g),l=0;l<c;l++)if(b+l==k){var n,f=!0;g.Ka&&(Ee(a,d,g,!0),e=!0);if(n=g.Lc){for(var f=!1,p=0;p<n.length;p++)if(!ef(a,n[p],!0)){if(n[p].indexOf("if")){f=!0;break}for(var x=p+1;x<n.length&&n[x].indexOf("else");x++)p++;if(x==n.length){f=!0;break}}a.b.B.sa||(f=!0)}if(f){e||Fe(a,d,h,"hit");break}}}a.ab--;return f}
function ff(a,b,c,d){for(var e=Y(b.D),f=a.X(b,1),h=a.Qa[f],g="",k=(8086!=a.style?ge:he)[h[0]],l=h.length-1,n=0,p,x=1;x<=l;x++){var w="";p=h[x];if(void 0!==p&&!(p&16384&&a.style==ae)){var t=p&240;if(t){var z=p&15;z?n=z:p|=n;p&61440||(p|=1==x?8192:4096);if(t&32)a:{var w=a,t=p,z=b,u=" ";switch(t&15){case 1:u=q(w.X(z,1),2);break;case 2:u=q(w.X(z,1)<<24>>24,4);break;case 3:u=q(w.Na(z,2),4);break;default:w="imm("+r(t)+")";break a}8086==w.style&&t&64?u="["+u+"]":t&16||(u=(w.style==ae?"$":"0x")+u);w=u}else t&
16?(w=(p&3840)>>8,t=ie[w],8086==a.style&&p&64&&(6==w&&(t="HL"),t="["+t+"]"),w=t):t&128&&(w=(f>>3&7).toString());if(!w||!w.length){g="INVALID";break}0<g.length&&(g+=",");g+=w||"???"}}}f="";h=Z(e.D)+" ";if(-1!==e.D&&-1!==b.D){do if(f+=q(a.X(e,1),2),null==e.D)break;while(e.D!=b.D)}h+=ia(f,10);h=h+(p&32768?"*":" ")+ia(k,7);g&&(h+=" "+g);c&&(h=ia(h,40)+";"+c,h=a.b.B.fb?h+("cycles="+yc(a.b).toString()+" cs="+q(a.b.i.ub)):h+(null!=d?"="+d.toString():""));return h}
function gf(a,b){var c;switch(b){case "IF":c=a.b.ta&512;break;case "SF":c=Tc(a.b);break;case "ZF":c=Sc(a.b);break;case "AF":c=Rc(a.b);break;case "PF":c=Qc(a.b);break;case "CF":c=M(a.b);break;default:c=0}return b.charAt(0)+(c?"1":"0")+" "}function hf(a,b){return ie[b]+"="+xe(a,b)+" "}function jf(a){return hf(a,7)+hf(a,8)+hf(a,9)+hf(a,10)+hf(a,11)+gf(a,"IF")+gf(a,"SF")+gf(a,"ZF")+gf(a,"AF")+gf(a,"PF")+gf(a,"CF")}
var kf={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
function lf(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<<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;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?1:0;break;case "&":d=f&e;break;
Td.prototype.Ca=function(){if(2==this.Y){for(var a={0:[32,"SET-UP A"],2:[64,'TO EXIT PRESS "SET-UP"'],22:[96," T T T T T T T T T"],23:[96,"1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890","1234567890"],24:[]},b=this.ya,c=-1,d=-1,e,f=-(60==this.rc?2:5);f<this.ea;f++){var h=a[f];if(0<=c){var g=!1,c=b+2;h?h.length?d=h[0]:(c=b-1,g=!0):32==d&&(h=a[f-1],d=0);e=d&96|c>>8&15|16;zb(this.A,b++,e);zb(this.A,b++,c&
255);if(g)break}if(h)for(c=0,e=1;e<h.length;e++){for(var g=h[e],k=0;k<g.length;k++)zb(this.A,b++,g.charCodeAt(k)|c);c^=128}zb(this.A,b++,127);c=b}be(this)}return!0};Td.prototype.pa=function(a,b,c){var d=this;if("led"==a||"rled"==a)return this.wb[b]=c,!0;switch(b){case "fullScreen":return this.L[b]=c,this.w&&this.w.gb?c.onclick=function(){d.gb()}:c.parentNode.removeChild(c),!0}return!1};
Td.prototype.gb=function(){var a=!1;if(this.w){if(this.w.gb){a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=this.aa/this.U;b>c&&(a=Math.round(c/b*100)+"%")}this.jc?(this.N.style.width=a,this.N.style.width=a,this.N.style.display="block",this.N.style.margin="auto"):(this.w.style.width=a,this.w.style.height="auto");this.w.style.backgroundColor="black";this.w.gb();a=!0}this.Ga&&this.Ga.focus()}return a};
function Wd(a,b){!b&&a.w&&(a.jc?a.N.style.width=a.N.style.height="":a.w.style.width=a.w.style.height="");fb(a,"notifyFullScreen("+b+")",!0)}function Yd(a,b){a.lc=b;a.za=!1;if(void 0===a.ka||a.ka.length!=a.lc)a.ka=Array(a.lc)}function ae(a,b,c,d,e){d=a.D?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.Y&&(208<=c&&236>c?e=a.Ha+0:28<=c&&72>c&&(e=a.Ha+1));a=a.ua[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 be(a){for(var b=a.ya,c=-1,d=0,e=60==a.rc?2:5,f=0,h=0;d<a.ea;){for(var g=0,k=b,l=c;;){var n=xb(a.A,k++);if(127==(n&127)){var p=xb(a.A,k++),c=p&96,b=(p&15)<<8|xb(a.A,k),b=b+(p&16?8192:16384);break}if(g<a.xa.length)a.xa[g++]=n;else break}if(e)e--;else{for(;g<a.xa.length;)a.xa[g++]=0;if(0<=l)for(k=0;k<g;k++){n=a.xa[k];if(!a.za||n!==a.ka[f]){var p=a,x=a.fb,w=n&127;if(n=p.ma[l][n&128?1:0]){var t=(w&15)*n.oa,w=(w>>4)*n.ha,A=void 0,u=void 0,F=void 0,B=void 0,ha=n.oa,pa=n.ha;x?(A=k*p.oa,u=d*p.ha,
F=p.oa,B=p.ha):(A=k*p.Kb,u=d*p.ic,F=p.Kb,B=p.ic);n.oa>p.oa&&(A*=2,F*=2);n.ha>p.ha&&(0==l&&(w+=p.ha),pa=p.ha);x?x.drawImage(n.canvas,t,w,ha,pa,A,u,F,B):(A+=0,u+=0,p.H.drawImage(n.canvas,t,w,ha,pa,A,u,F,B))}h++}f++}d++}}a.za=!0;h&&a.fb&&a.H.drawImage(a.K,0,0,a.J,a.ca-a.ha,0,0,a.pd,a.qd)}
Ja(function(){for(var a=C(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=z(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=ra().indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height=
(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Ra.aspect);f&&.3<=f&&3.33>=f&&(Ia("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");xa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new Td(d,e,h,f,c);db(d,c)}});
function ce(a){y.call(this,"Debugger",a,ce);this.style=de;this.ca=this.za=this.K=0;this.U=Y();this.Va=Y();this.D=-1;this.w=[];this.ea=!1;this.da=Y();this.I=[];this.ga={};this.C=this.Y=this.H=[];ee(this);this.ua=0;fe(this);this.Ga=[];ge(this,a.messages);this.Ha=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return he(b,a)}):void 0===global.$&&(global.$=function(a){return he(b,a)})}Za(ce);
var ie={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory",f:"frequencies","g [#]":"go [to #]",h:"halt","i [#]":"input port #","if":"eval expression","int [#]":"request interrupt",k:"stack trace",ln:"list nearest symbol(s)",m:"messages","o [#]":"output port #",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine",s:"set options","t [#]":"trace","u [#]":"unassemble",v:"print version","var":"assign variable"},
de=8080,je="NONE ACI ADC ADD ADI ANA ANI CALL CC CM CNC CNZ CP CPE CPO CZ CMA CMC CMP CPI DAA DAD DCR DCX DI EI HLT IN INR INX JMP JC JM JNC JNZ JP JPE JPO JZ LDA LDAX LHLD LXI MOV MVI NOP ORA ORI OUT PCHL POP PUSH RAL RAR RET RC RM RNC RNZ RP RPE RPO RZ RLC RRC RST SBB SBI SHLD SPHL STA STAX STC SUB SUI XCHG XRA XRI XTHL".split(" "),ke="NONE ADC ADC ADD ADD AND AND CALL CALLC CALLS CALLNC CALLNZ CALLNS CALLP CALLNP CALLZ NOT CMC CMP CMP DAA ADD DEC DEC CLI STI HLT IN INC INC JMP JC JS JNC JNZ JNS JP JNP JZ MOV MOV MOV MOV MOV MOV NOP OR OR OUT JMP POP PUSH RCL RCR RET RETC RETS RETNC RETNZ RETNS RETP RETNP RETZ ROL ROR RST SBB SBB MOV MOV MOV MOV STC SUB SUB XCHG XOR XOR XCHG".split(" "),
le="B C D E H L M A BC DE HL SP PC PS PSW".split(" "),me=[[45],[42,2067,32],[71,2131,18193],[29,2067],[28,17],[22,17],[44,17,32],[63],[45,32768],[21,18963,2067],[40,18193,2131],[23,2067],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2323,32],[71,2387,18193],[29,2323],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,18963,2323],[40,18193,2387],[23,2323],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2579,32],[68,115,18963],[29,2579],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,18963,
2579],[41,18963,115],[23,2579],[28,1297],[22,1297],[44,1297,32],[16,18193],[45,32768],[42,2835,32],[70,115,18193],[29,2835],[28,1617],[22,1617],[44,1617,32],[72],[45,32768],[21,18963,2835],[39,18193,115],[23,2835],[28,1809],[22,1809],[44,1809,32],[17],[43,17,17],[43,17,273],[43,17,529],[43,17,785],[43,17,1041],[43,17,1297],[43,17,1617],[43,17,1809],[43,273,17],[43,273,273],[43,273,529],[43,273,785],[43,273,1041],[43,273,1297],[43,273,1617],[43,273,1809],[43,529,17],[43,529,273],[43,529,529],[43,529,
785],[43,529,1041],[43,529,1297],[43,529,1617],[43,529,1809],[43,785,17],[43,785,273],[43,785,529],[43,785,785],[43,785,1041],[43,785,1297],[43,785,1617],[43,785,1809],[43,1041,17],[43,1041,273],[43,1041,529],[43,1041,785],[43,1041,1041],[43,1041,1297],[43,1041,1617],[43,1041,1809],[43,1297,17],[43,1297,273],[43,1297,529],[43,1297,785],[43,1297,1041],[43,1297,1297],[43,1297,1617],[43,1297,1809],[43,1617,17],[43,1617,273],[43,1617,529],[43,1617,785],[43,1617,1041],[43,1617,1297],[26],[43,1617,1809],
[43,1809,17],[43,1809,273],[43,1809,529],[43,1809,785],[43,1809,1041],[43,1809,1297],[43,1809,1617],[43,1809,1809],[3,18193,17],[3,18193,273],[3,18193,529],[3,18193,785],[3,18193,1041],[3,18193,1297],[3,18193,1617],[3,18193,1809],[2,18193,17],[2,18193,273],[2,18193,529],[2,18193,785],[2,18193,1041],[2,18193,1297],[2,18193,1617],[2,18193,1809],[73,18193,17],[73,18193,273],[73,18193,529],[73,18193,785],[73,18193,1041],[73,18193,1297],[73,18193,1617],[73,18193,1809],[66,18193,17],[66,18193,273],[66,
18193,529],[66,18193,785],[66,18193,1041],[66,18193,1297],[66,18193,1617],[66,18193,1809],[5,18193,17],[5,18193,273],[5,18193,529],[5,18193,785],[5,18193,1041],[5,18193,1297],[5,18193,1617],[5,18193,1809],[76,18193,17],[76,18193,273],[76,18193,529],[76,18193,785],[76,18193,1041],[76,18193,1297],[76,18193,1617],[76,18193,1809],[46,18193,17],[46,18193,273],[46,18193,529],[46,18193,785],[46,18193,1041],[46,18193,1297],[46,18193,1617],[46,18193,1809],[18,18193,17],[18,18193,273],[18,18193,529],[18,18193,
785],[18,18193,1041],[18,18193,1297],[18,18193,1617],[18,18193,1809],[58],[50,2067],[34,51],[30,51],[11,51],[51,2067],[4,18193,33],[65,128],[62],[54],[38,51],[30,32819],[15,51],[7,51],[1,18193,33],[65,128],[57],[50,2323],[33,51],[48,33,18193],[10,51],[51,2323],[74,18193,33],[65,128],[55],[54,32768],[31,51],[27,18193,33],[8,51],[7,32819],[67,18193,33],[65,128],[61],[50,2579],[37,51],[78,19283,18963],[14,51],[51,2579],[6,18193,33],[65,128],[60],[49,2579],[36,51],[75,18963,18707],[13,51],[7,32819],[77,
18193,33],[65,128],[59],[50,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]],ne={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=ce.prototype;
m.Na=function(a,b,c,d){this.A=b;this.b=c;this.u=a;(a=hc(a,"messages"))&&ge(this,a);this.Sa=me;oe(this,function(a){a:{var b=d.A.V,c=a[0],g=a=0,k=b.length;if(c){a=pe(qe(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.A.la;k=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;k--;){var n=b[g];n.type==c?l++||d.g("..."):(c=n.type,l=wb[c],n&&d.g(q(n.id)+" %"+q(g<<d.A.la)+" %%"+q(n.F)+" "+r(n.Fb)+" "+
r(n.size)+" "+l),c!=Ub&&(c=-1),l=0);a+=d.A.Ba;g++}}});E(this)};
m.pa=function(a,b,c){var d=this;switch(b){case "debugInput":return this.ma=this.L[b]=c,c.onkeydown=function(a){var b;if(13==a.keyCode)b=c.value,c.value="",he(d,b,!0);else if(27==a.keyCode)c.value=b="";else if(38==a.keyCode?d.D<d.w.length-1&&(b=d.w[++d.D]):40==a.keyCode&&(0<d.D?b=d.w[--d.D]:(b="",d.D=-1)),null!=b){var h=b.length;c.value=b;c.setSelectionRange(h,h)}null!=b&&a.preventDefault&&a.preventDefault()},!0;case "debugEnter":return this.L[b]=c,Ea(c,function(){if(d.ma){var a=d.ma.value;d.ma.value=
"";he(d,a,!0);return!0}return!1}),!0;case "step":return this.L[b]=c,Ea(c,function(a){var b=!1;ib(d,!0)||(hb(d,!0),b=d.sb(a?1:0),hb(d,!1));return b}),!0}return!1};m.Eb=function(){this.ma&&this.ma.focus()};function pe(a){a=a&&a.F;null==a&&(a=-1);return a}m.X=function(a,b){var c=255,d=pe(a);-1!==d&&(c=xb(this.A,d),b&&re(a,b));return c};m.Oa=function(a,b){var c=65535,d=pe(a);-1!==d&&(c=yb(this.A,d),b&&re(a,b));return c};m.qa=function(a,b,c){var d=pe(a);-1!==d&&(zb(this.A,d,b),c&&re(a,c),kc(this.b,!0))};
m.Pb=function(a,b,c){var d=pe(a);if(-1!==d){var e=this.A,f=d&e.A,h=(d&e.w)>>>e.la;f!=e.A?e.V[h].Yb(f,b&65535,d):(e.V[h++].Gb(f,b&255,d),e.V[h&e.J].Gb(0,b>>8&255,d+1));c&&re(a,c);kc(this.b,!0)}};function Y(a){return{F:a,La:!1}}function se(a){return[a.F,a.La]}function te(a){return{F:a[0],La:a[1]}}
function qe(a,b,c){var d;c=(c?a.U:a.Va).F;if(void 0!==b){d=b=ue(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;c<a.I.length;c++){var f=a.I[c].Ma[d];if(void 0!==f){d=f.o;void 0!==d&&(e=Y(d));break}}if(d=e)return d;c=ve(a,b,void 0)}null!=c&&(d=Y(c));return d}function we(a,b,c){c&&(c=c.match(/(['"])(.*?)\1/))&&(b.Vc=xe(a,b.uc=c[2]))}function re(a,b){null!=a.F&&(a.F+=b||1)}function Z(a){return q(a,4)}
function ye(a,b,c){var d="";for(c=c||256;d.length<c;){var e=a.X(b,1);if(!e||36==e||127<=e)break;d+=32<=e?String.fromCharCode(e):"."}return d}function ge(a,b){a.G=a;a.na=a.Wc=536870912;a.xa=null;a.ya=[];var c=xe(a,b.replace("keys","key").replace("kbd","keyboard"),!1,"|");if(c.length)for(var d in ne)0<=na(c,d)&&(a.na|=ne[d],a.g(d+" messages enabled"))}function oe(a,b){for(var c in ne)if(64==ne[c]){a.Ga[c]=b;break}}
function ze(a,b){var c;a=a.toUpperCase();null==b?c=na(le,a):(c=na(le,a.substr(b,2)),0>c&&(c=na(le,a.substr(b,1))));return c}function Ae(a,b){var c=0,d=Be(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?q(d,c):"??"}
function Be(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 0:c=d.O;break;case 1:c=d.P;break;case 8:c=Lc(d);break;case 2:c=d.R;break;case 3:c=d.S;break;case 9:c=Nc(d);break;case 4:c=d.T;break;case 5:c=d.W;break;case 10:c=K(d);break;case 6:c=d.X(K(d));break;case 11:c=d.ia;break;case 12:c=d.M;break;case 13:c=Kc(d);break;case 14:c=Kc(d)&255|d.j<<8}}return c}
function Ce(a,b){b=ue(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=ze(b,c+1),0<=e&&(b=b.substr(0,c)+Ae(a,e)+b.substr(c+1+le[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=aa(e,16),null!=d&&32<=d&&128>d?(d=e+" '"+String.fromCharCode(d)+"'",b=b.replace("#"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("$",c));)e=b.substr(c+1,9),(d=qe(a,e))?(d=e+' "'+ye(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=qe(a,e))?(re(d),d=e+' "'+
ye(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}m.message=function(a,b){b&&(a+=" at "+Z(Y(this.b.M).F));if(this.na&1073741824)this.ya.push(a);else if(!this.xa||a!=this.xa)if(this.xa=a,this.na&-2147483648&&(this.ja(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.pb=0;c.D-=c.b;c.b=0;kc(c)}};
function eb(a,b,c,d,e,f,h,g){g|=256;null!=f&&(a.na&g)!=g||a.message(b.cb+"."+(null!=d?"outPort":"inPort")+"("+r(c)+","+(f?f:"unknown")+(null!=d?",0x"+q(d,2):"")+")"+(null!=h?": 0x"+q(h,2):"")+(null!=e?" at "+Z(e):""))}m.Wa=function(){this.g("Type ? for help with PC8080 Debugger commands");this.Da();if(this.Ha){var a=this.Ha;this.Ha=null;he(this,a)}};
function fe(a){var b;if(cd(a)){if(!a.N||!a.N.length){a.N=Array(1E3);for(b=0;b<a.N.length;b++)a.N[b]=Y();a.ka=0;a.g("instruction history buffer allocated")}if(!a.J||!a.J.length)for(a.J=Array(256),b=0;b<a.J.length;b++)a.J[b]=[b,0]}else a.N&&a.N.length&&a.g("instruction history buffer freed"),a.ka=0,a.N=[],a.J=[]}m.ab=function(a){if(!De(this))return!1;this.b.ab(a);return!0};
m.sb=function(a,b,c){if(!De(this))return!1;this.K=0;a||cd(this)&&wd(this,this.b.M,0);try{var d=this.b.sb(a);0<d&&(this.K+=d,Bc(this.b,d,!0),yc(this.b,d),this.ca++)}catch(e){"number"!=typeof e&&(this.K=0,mb(this.b,e.stack||e.message))}!1!==c&&kc(this.b);this.Da(b||!1);return 0<this.K};m.ja=function(a){this.b&&this.b.ja(a)};m.Da=function(a){void 0===a&&(a=!0);this.U=Y(this.b.M);a&&1!=this.aa?Ee(this):Fe(this)};
function De(a){var b;if(b=a.b&&jb(a.b))b=a.b,b.B.ra?b=!0:(b.g(b.toString()+" not powered"),b=!1);b&&!ib(a.b)?(a=a.b,a.B.jb?(a.g(a.toString()+" error"),a=!0):a=!1,a=!a):a=!1;return a}m.Ca=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};m.Ja=function(a,b){b&&this.g(a?"suspending":"shutting down");return a?this.save():!0};m.reset=function(a){fe(this);this.ca=this.za=0;this.xa=null;this.K=0;this.U=Y(this.b.M);this.B.va=!1;Ge(this);a||this.Da()};
m.save=function(){var a=new I(this);J(a,0,se(this.U));J(a,1,se(this.da));J(a,2,[this.w,this.ea,this.na]);J(a,3,this.I);return a.data()};m.restore=function(a){var b=0;void 0!==a[2]&&(this.U=te(a[b++]),this.da=te(a[b++]),this.w=a[b][0],"string"==typeof this.w&&(this.w=[this.w]),this.ea=a[b][1],this.na|=a[b][2]);a[3]&&(this.I=a[3]);return!0};m.start=function(a,b){this.aa||this.g("running");this.B.va=!0;this.vb=a;this.wb=b};
m.stop=function(a,b){if(this.B.va){this.B.va=!1;this.K=b-this.wb;if(!this.aa){var c="stopped";if(this.K){var d=a-this.vb,e=0<d?Math.round(1E3*this.K/d):0,c=c+" (";cd(this)&&(c+=this.ca+" opcodes, ",this.za-=this.ca,this.ca=0);c+=this.K+" cycles, "+d+" ms, "+e+" hz)"}else gb(this,-2147483648)&&(c+=" (use the 't' command to execute blocked faults)");this.g(c)}this.Da(!0);this.Eb();Ge(this,this.b.M)}};function cd(a){return 1<a.C.length||!!a.ua}
function wd(a,b,c){var d=a.b;if(0<c&&(a.ua&&!--a.ua||cc(a,b,1,a.C)))return!0;0<=c&&a.J.length&&(a.ca++,b=xb(a.A,b),null!=b&&(a.J[b][1]++,b=a.N[a.ka],b.F=d.M,b.La=!1,++a.ka==a.N.length&&(a.ka=0)));return!1}function Db(a,b,c){a.g("break on input from port "+r(b)+": "+q(c));a.ja(!0)}function Hb(a,b,c){a.g("break on output to port "+r(b)+": "+q(c));a.ja(!0)}
function ee(a){var b,c;a.C=["bp"];if(void 0!==a.Y)for(b=1;b<a.Y.length;b++){c=a.Y[b];var d=a.A;dc(d.V[pe(c)>>>d.la],!1)}a.Y=["br"];if(void 0!==a.H)for(b=1;b<a.H.length;b++)c=a.H[b],d=a.A,dc(d.V[pe(c)>>>d.la],!0);a.H=["bw"];a.eb=0}m.Ua=function(a,b,c){var d=!0;c||He(this,a,b,!1,!0);if(a!=this.C){var e=pe(b);if(-1===e)this.g("invalid address: "+Z(b.F)),d=!1;else{var f=this.A;f.V[e>>>f.la].Ua(e&f.A,a==this.H)}}d&&(a.push(b),c?b.La=!0:(Ie(this,a,a.length-1,"set"),fe(this)));return d};
function He(a,b,c,d,e){var f=!1;c=pe(c);for(var h=1;h<b.length;h++){var g=b[h];if(c==pe(g)&&(!d||g.La)){f=!0;g.La||e||Ie(a,b,h,"cleared");b.splice(h,1);b!=a.C&&(d=a.A,dc(d.V[c>>>d.la],b==a.H));g.La||fe(a);break}}return f}function hf(a,b){for(var c=1;c<b.length;c++)Ie(a,b,c);return b.length-1}function Ie(a,b,c,d){c=b[c];a.g(b[0]+" "+Z(c.F)+(d?" "+d:c.uc?' "'+c.uc+'"':""))}
function Ge(a,b){if(void 0!==b)cc(a,b,1,a.C,!0),a.aa=0;else for(var c=1;c<a.C.length;c++){var d=a.C[c];if(d.La){if(!He(a,a.C,d,!0))break;c=0}}}
function cc(a,b,c,d,e){var f=!1;if(!a.eb++)for(var h=1;!f&&h<d.length;h++){var g=d[h];if(!e||g.La)for(var k=pe(g),l=0;l<c;l++)if(b+l==k){var n,f=!0;g.La&&(He(a,d,g,!0),e=!0);if(n=g.Vc){for(var f=!1,p=0;p<n.length;p++)if(!jf(a,n[p],!0)){if(n[p].indexOf("if")){f=!0;break}for(var x=p+1;x<n.length&&n[x].indexOf("else");x++)p++;if(x==n.length){f=!0;break}}a.b.B.va||(f=!0)}if(f){e||Ie(a,d,h,"hit");break}}}a.eb--;return f}
function kf(a,b,c,d){for(var e=Y(b.F),f=a.X(b,1),h=a.Sa[f],g="",k=(8086!=a.style?je:ke)[h[0]],l=h.length-1,n=0,p,x=1;x<=l;x++){var w="";p=h[x];if(void 0!==p&&!(p&16384&&a.style==de)){var t=p&240;if(t){var A=p&15;A?n=A:p|=n;p&61440||(p|=1==x?8192:4096);if(t&32)a:{var w=a,t=p,A=b,u=" ";switch(t&15){case 1:u=q(w.X(A,1),2);break;case 2:u=q(w.X(A,1)<<24>>24,4);break;case 3:u=q(w.Oa(A,2),4);break;default:w="imm("+r(t)+")";break a}8086==w.style&&t&64?u="["+u+"]":t&16||(u=(w.style==de?"$":"0x")+u);w=u}else t&
16?(w=(p&3840)>>8,t=le[w],8086==a.style&&p&64&&(6==w&&(t="HL"),t="["+t+"]"),w=t):t&128&&(w=(f>>3&7).toString());if(!w||!w.length){g="INVALID";break}0<g.length&&(g+=",");g+=w||"???"}}}f="";h=Z(e.F)+" ";if(-1!==e.F&&-1!==b.F){do if(f+=q(a.X(e,1),2),null==e.F)break;while(e.F!=b.F)}h+=ia(f,10);h=h+(p&32768?"*":" ")+ia(k,7);g&&(h+=" "+g);c&&(h=ia(h,40)+";"+c,h=a.b.B.ib?h+("cycles="+zc(a.b).toString()+" cs="+q(a.b.i.xb)):h+(null!=d?"="+d.toString():""));return h}
function lf(a,b){var c;switch(b){case "IF":c=a.b.sa&512;break;case "SF":c=Uc(a.b);break;case "ZF":c=Tc(a.b);break;case "AF":c=Sc(a.b);break;case "PF":c=Rc(a.b);break;case "CF":c=L(a.b);break;default:c=0}return b.charAt(0)+(c?"1":"0")+" "}function mf(a,b){return le[b]+"="+Ae(a,b)+" "}function nf(a){return mf(a,7)+mf(a,8)+mf(a,9)+mf(a,10)+mf(a,11)+lf(a,"IF")+lf(a,"SF")+lf(a,"ZF")+lf(a,"AF")+lf(a,"PF")+lf(a,"CF")}
var of={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
function pf(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<<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;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?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 se(a,b,c){var d;if(b){b=re(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e<l.length;){var n=l[e++],p=n.length,n=ja(n);if(!n){f=!0;break}n=mf(a,n,null,!1===c);if(void 0===n){f=!0;c=!1;break}g.push(n);if(e==l.length)break;var n=l[e++],x=n.length;k.length&&kf[n]<kf[k[k.length-1]]&&lf(g,k,1);k.push(n);b=b.substr(p+x)}lf(g,k)&&1==g.length||(f=!0);f?c&&a.g("error parsing '"+h+"' at character "+(h.length-b.length)):(d=g.pop(),c&&nf(a,null,
d))}return d}function re(a,b){for(var c;(c=b.match(/\{(.*?)}/))&&!(0<=c[1].indexOf("{"));){var d=se(a,c[1]);b=b.replace("{"+c[1]+"}",null!=d?q(d):"undefined")}for(;(c=b.match(/\[(.*?)]/))&&!(0<=c[1].indexOf("["));)d=ne(a,c[1]),b=b.replace("["+c[1]+"]",d?q(a.Na(d,0),4):"undefined");for(c=b;d=c.match(/\$([a-z]+)/i);){var e=null;switch(d[1].toLowerCase()){case "ops":e=a.ca-a.za}if(null==e)break;c=c.replace(d[0],e.toString())}return c}
function mf(a,b,c,d){var e;void 0!==b?(e=we(b),0<=e?e=ye(a,e):(e=a.oa[b],void 0===e&&(e=aa(b))),void 0!==e||d||a.g("invalid "+(c?c:"value")+": "+b)):d||a.g("missing "+(c||"value"));return e}
function nf(a,b,c){var d,e=!1;if(void 0!==c){e=!0;d=c;var f,h="";if(!f||4<f)f=4;for(var g=0;g<f;g++){h&&(h=","+h);var k=d&255,l=8,n="";void 0===l?l=32:32<l&&(l=32);if(null==k||isNaN(k))for(;0<l--;)n="?"+n;else for(;0<l--;)n=(k&1?"1":"0")+n,k>>=1;h=n+"b"+h;d>>=8}d="0x"+q(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function of(a,b){if(b)return nf(a,b,a.oa[b]);var c=0;for(b in a.oa)nf(a,b,a.oa[b]),c++;return 0<c}$d.prototype.Ra=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};
function pf(a,b,c){var d=[],e=me(b)>>>0;for(b=0;b<a.I.length;b++){var f=a.I[b],h=f.D>>>0,g=f.Tc;if(e>=h&&e<h+g){e=ka(f.Yb,[e-h],a.Ra);0<=e?qf(a,b,e,d):c&&(e=~e,qf(a,b,e-1,d),qf(a,b,e,d));break}}return d}function qf(a,b,c,d){var e={},f=a.I[b].Yb,h=0,g=null;0<=c&&c<f.length&&(h=f[c][0],g=f[c][1]);g&&(e=a.I[b].La[g],g="."==g.charAt(0)?null:e.l||g);d.push(g);d.push(h);d.push(e.a);d.push(e.c)}
function rf(a,b){if("?"==b)a.g("frequency commands:"),a.g("\tclear\tclear all frequency counts");else{var c,d=0;if(a.J)if("clear"==b){for(c=0;c<a.J.length;c++)a.J[c]=[c,0];a.g("frequency data cleared");d++}else if(void 0!==b)a.g("unknown frequency command: "+b),d++;else{var e=a.J.slice();e.sort(function(a,b){return b[1]-a[1]});var f=8086!=a.style?ge:he;for(c=0;c<e.length;c++){var h=e[c][0],g=e[c][1];g&&(a.g((f[a.Qa[h][0]]+" ").substr(0,5)+" ("+("0x"+q(h,2))+"): "+g+" times"),d++)}}d||a.g("no frequency data available")}}
function sf(a,b){var c=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(c){if(!c[1])return of(a)||a.g("no variables"),!0;if(!c[2])return of(a,c[1]);if(!c[3])return delete a.oa[c[1]],!0;var d=se(a,c[3]);return void 0!==d?(a.oa[c[1]]=d,!0):!1}a.g("invalid assignment:"+b);return!1}
function tf(a,b,c){var d=null;if(b=ne(a,b,!0)){var e=pf(a,b,!0);if(e.length){var f,h;e[0]&&(h="",(f=b.D-e[1])&&(h=" + "+r(f)),f=e[0]+" ("+Z(e[1])+")"+h,c&&a.g(f),d=f);4<e.length&&e[4]&&(h="",(f=e[5]-b.D)&&(h=" - "+r(f)),f=e[4]+" ("+Z(e[5])+")"+h,c&&a.g(f),d||(d=f))}else c&&a.g("no symbols")}return d}
function uf(a,b){switch(b[1]){case "8080":a.style=ae;break;case "8086":a.style=8086;break;case "cs":var c;void 0!==b[3]&&(c=+b[3]);switch(b[2]){case "int":a.b.i.jb=c;break;case "start":a.b.i.vb=c;break;case "stop":a.b.i.lb=c;break;default:a.g("unknown cs option");return}void 0!==c&&jc(a.b);a.g("checksums "+(a.b.B.fb?"enabled":"disabled"));return;case "sp":void 0!==b[2]&&(zc(a.b,+b[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.Wa.toFixed(2)+"Mhz")+
" ("+a.b.i.Ya+"x)");return;case "?":a.g("debugger options:");a.g("\t8080\t\tselect 8080-style mnemonics");a.g("\t8086\t\tselect 8086-style mnemonics");a.g("\tcs int #\tset checksum cycle interval to #");a.g("\tcs start #\tset checksum cycle start count to #");a.g("\tcs stop #\tset checksum cycle stop count to #");a.g("\tsp #\t\tset speed multiplier to #");break;default:if(b[1]){a.g("unknown option: "+b[1]);return}}a.g(a.style+"-style mnemonics enabled")}
function Be(a,b){var c;if(b&&"?"==b[1])a.g("register commands:"),a.g("\tr\tdump registers"),a.g("\trx [#]\tset flag or register x to [#]");else{var d=a.b;null==c&&(c=!0);if(null!=b&&1<b.length){var e=b[1],f=null,h=e.indexOf("=");if(0<h)f=e.substr(h+1),e=e.substr(0,h);else if(2<b.length)f=b[2];else{a.g("missing value for "+b[1]);return}var h=!1,g=se(a,f);if(void 0!==g)switch(h=!0,e.toUpperCase()){case "A":d.j=g&255;break;case "B":d.N=g&255;break;case "BC":d.N=g>>8&255;case "C":d.O=g&255;break;case "D":d.P=
g&255;break;case "DE":d.P=g>>8&255;case "E":d.R=g&255;break;case "H":d.S=g&255;break;case "HL":d.S=g>>8&255;case "L":d.V=g&255;break;case "SP":d.ha=g&65535;break;case "PC":H(d,g);a.W=Y(d.M);break;case "PS":Hc(d,g);break;case "PSW":Hc(d,g&255|d.ta&-256);d.j=g>>8;break;case "CF":d.Z=g?d.Z|256:d.Z&255;break;case "PF":g?Qc(d)||(d.ba^=1):Qc(d)&&(d.ba^=1);break;case "AF":d.qa=g?~d.ba&16|d.qa&-17:d.ba&16|d.qa&-17;break;case "ZF":d.Z=g?d.Z&-256:d.Z|255;break;case "SF":g?Tc(d)||(d.ba^=192):Tc(d)&&(d.ba^=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}kc(d);a.g("updated registers:")}a.g(jf(a));c&&(a.W=Y(d.M),Ce(a,Z(a.W.D)))}}function vf(a,b){b=ja(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(ze(a,c[2])):se(a,b,!0)}function wf(a,b,c){var d="t"!=b;c=mf(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);ya(c,function(){return hb(a,!0)&&a.pb(e,d,!1)},function(){kc(a.b);hb(a,!1)})}
function Ce(a,b,c,d){if(b=ne(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=ne(a,c,!0);if(!d||d.D<b.D)return;e=d.D-b.D;if(256<e){a.g("range too large");return}d=-1}c=0;for(var f;0<e&&d--;){f=ib(a,!1)||a.aa?a.L:null;var h=null!=f?"cycles":null,g=pf(a,b),k=b.D;if(g[0]&&d&&(!c&&d||0>g[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=ff(a,b,h,f);a.g(f);a.W=b;e-=b.D-k;c++}}}
function ue(a,b,c,d){if(c)if(b){0>a.F&&a.A.length&&(a.F=0);if(0>a.F||b!=a.A[a.F])a.A.splice(0,0,b),a.F=0;a.F--}else a.ea?b="end":b=a.A[a.F+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var h=b.charAt(f);if('"'==h||"'"==h)e?h==e&&(e=null):e=h;else if(h==d&&!e||!h)a.push(ja(b.substring(c,f))),c=f+1}}return a}
function ef(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ea&&(a.g("ended assemble at "+Z(a.da.D)),a.W=a.da,a.ea=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.xa=null;if(lb(a)&&0<b.length){a.ea&&(b="a "+Z(a.da.D)+" "+b);var f=b.replace(/ +/g," ").split(" ");if(f&&f.length)for(var h=f[0],g=h.charAt(0),k=1;k<h.length;k++){var l=h.charAt(k);if("?"==g||"r"==g||"a">l||"z"<l){f[0]=h.substr(k);f.unshift(h.substr(0,k));break}}switch(f[0].charAt(0)){case "a":var n=ne(a,f[1],!0);if(n)if(a.da=
n,void 0===f[2])a.g("begin assemble at "+Z(n.D)),a.ea=!0,kc(a.b);else{var p;a.g("not supported yet");p=[];if(p.length){for(var x=0;x<p.length;x++)a.na(n,p[x],1);a.g(ff(a,a.da))}}break;case "b":a:{var w=f[0],t=f[1],z=b;if("?"==t)a.g("breakpoint commands:"),a.g("\tbi [p]\ttoggle break on input port [p]"),a.g("\tbo [p]\ttoggle break on output port [p]"),a.g("\tbp [a]\tset exec breakpoint at addr [a]"),a.g("\tbr [a]\tset read breakpoint at addr [a]"),a.g("\tbw [a]\tset write breakpoint at addr [a]"),
a.g("\tbc [a]\tclear breakpoint at addr [a]"),a.g("\tbl\tlist all breakpoints"),a.g("\tbn [n]\tbreak after [n] instruction(s)");else{var u=w.charAt(1);if("l"==u){var E=0,E=E+df(a,a.C),E=E+df(a,a.Y);(E+=df(a,a.H))||a.g("no breakpoints")}else if("n"==u)a.wa=mf(a,t),a.g("break after "+a.wa+" instruction(s)");else if(void 0===t)a.g("missing breakpoint address");else{var A=Y();if("*"!=t&&(A=ne(a,t,!0),!A))break a;t=r(A.D);"c"==u?null==A.D?(be(a),a.g("all breakpoints cleared")):Ee(a,a.C,A)||Ee(a,a.Y,A)||
Ee(a,a.H,A)||a.g("breakpoint missing: "+Z(A.D)):"i"==u?a.g("breakpoint "+(Ab(a.w,A.D)?"enabled":"cleared")+": port "+t+" (input)"):"o"==u?a.g("breakpoint "+(Eb(a.w,A.D)?"enabled":"cleared")+": port "+t+" (output)"):null!=A.D&&(te(a,A,z),"p"==u?a.Sa(a.C,A):"r"==u?a.Sa(a.Y,A):"w"==u?a.Sa(a.H,A):a.g("unknown breakpoint command: "+u))}}}break;case "c":a.Aa&&(a.Aa.value="");break;case "d":a:{var ha,pa=f[0],za=f[1],Ta=f[2],Rf=f[3];if("?"==za){var Aa="";for(ha in ke)a.Fa[ha]&&(Aa&&(Aa+=","),Aa+=ha);Aa+=
",state,symbols";a.g("dump memory commands:");a.g("\tdb [a] [#] dump # bytes at address a");a.g("\tdw [a] [#] dump # words at address a");a.g("\tdd [a] [#] dump # dwords at address a");a.g("\tdh [#] [#] dump # instructions from history");Aa.length&&a.g("dump extension commands:\n\t"+Aa)}else if("state"==za){var Ge=xf(a.u,!0);"console"==Ta?console.log(Ge):(a.Aa&&(a.Aa.value=""),a.g(Ge))}else if("symbols"==za)for(var bd=0;bd<a.I.length;bd++){var cd=a.I[bd],jb;for(jb in cd.La)if("."!=jb.charAt(0)){var He=
cd.La[jb].o;if(void 0!==He){var Ie=cd.La[jb].l;Ie&&(jb=Ie);a.g(Z(He)+" "+jb)}}}else{if("d"==pa){for(ha in ke)if(f[1]==ha){var Je=a.Fa[ha];Je?(f.shift(),f.shift(),Je(f)):a.g("no dump registered for "+za);break a}za||(pa=a.Hb||"db")}else a.Hb=pa;if("dh"==pa){var Ke=za,Le=Ta,Me="",Ne=0,W=a.ra,Ba=a.T;if(Ba.length){var ca=+Ke||a.bb,kb=+Le||10;isNaN(ca)?ca=kb:Me="more ";ca>Ba.length&&(a.g("note: only "+Ba.length+" available"),ca=Ba.length);W-=ca;0>W&&(null==Ba[Ba.length-1].D?(ca=W+ca,W=0):W+=Ba.length);
var dd=[];"call"==Le&&(kb=1E5,dd=["CALL"]);for(void 0!==Ke&&a.g(ca+" instructions earlier:");0<kb&&W!=a.ra;){var Oe=Ba[W++];if(null==Oe.D)break;var Ib=Y(Oe.D),Sf=ca--,Pe=ff(a,Ib,"history",Sf);(!dd.length||0<=Pe.indexOf(dd[0]))&&a.g(Pe);Ib.Nb&&(W+=Ib.Nb,kb-=Ib.Nb,ca-=Ib.Nb);W>=Ba.length&&(W=0);a.bb=ca;Ne++;kb--}}Ne||(a.g("no "+Me+"history available"),a.bb=void 0)}else{var lc=ne(a,za);if(lc){var mc=0;Ta&&("l"==Ta.charAt(0)&&(Ta=Ta.substr(1)||Rf),mc=mf(a,Ta)>>>0,65536<mc&&(mc=65536));for(var Ua="",nc=
"dd"==pa?4:"dw"==pa?2:1,oc=nc*mc||128,Tf=oc+15>>4||1;Tf--&&0<oc;){var pc=0,ed=0,Jb,Kb="",fd="",za=Z(lc.D);for(Jb=16;0<Jb&&0<oc;Jb--){var qc=a.X(lc,1),pc=pc|qc<<(ed++<<3);ed==nc&&(Kb+=q(pc,2*nc),Kb+=1==nc?9==Jb?"-":" ":" ",pc=ed=0);fd+=32<=qc&&128>qc?String.fromCharCode(qc):".";oc--}Ua&&(Ua+="\n");Ua+=za+" "+Kb+(0==Jb?" "+fd:"")}Ua&&a.g(Ua);a.Ta=lc}}}}break;case "e":if("else"==f[0])break;var rc=1,Qe=255,Re=a.X,Se=a.na;"ew"==f[0]&&(rc=2,Qe=65535,Re=a.Na,Se=a.Mb);var Te=rc<<1,Ue=f[1];if(null==Ue)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 sc=ne(a,Ue);if(sc)for(var tc=2;tc<f.length;tc++){var Lb=se(a,f[tc]);if(void 0===Lb){a.g("unrecognized value: "+f[tc]);break}Lb&~Qe&&a.g("warning: "+q(Lb)+" exceeds "+rc+"-byte value");var Uf=Re.call(a,sc);a.g("changing "+Z(sc.D)+" from 0x"+q(Uf,Te)+" to 0x"+q(Lb,Te));Se.call(a,sc,Lb,rc)}}break;case "f":rf(a,f[1]);break;case "g":a:{var Ve=f[1],Vf=b;if(void 0!==Ve){var gd=ne(a,Ve,!0);if(!gd)break a;
te(a,gd,Vf);a.Sa(a.C,gd,!0)}a.Za(!0)||c||a.g("cpu busy or unavailable, run command ignored")}break;case "h":a:{var hd;if(a.B.sa)hd="halting",a.ia();else{if(ib(a,!0))break a;hd="already halted"}c||a.g(hd)}break;case "i":if("if"==f[0]){var id;var Mb=b.substr(2),Mb=ja(Mb);se(a,Mb)?(c||a.g("true: "+Mb),id=!0):(c||a.g("false: "+Mb),id=!1);id||(d=!1);break}var jd=f[1];if(jd&&"?"!=jd){var kd=mf(a,jd);if(void 0!==kd){var Wf=Cb(a.w,kd);a.g(r(kd)+": "+("0x"+q(Wf,2)))}}else a.g("input commands:"),a.g("\ti [p]\tread port [p]"),
a.g("warning: port accesses can affect hardware state");break;case "k":var Xf=f[0];if("?"==f[1])a.g("stack trace commands:"),a.g("\tk\tshow frame addresses"),a.g("\tks\tshow symbol information");else{var ld=0,We=Y(),Nb=Y(a.b.ha);for(a.g("stack trace for "+Z(Nb.D));10>ld;){for(var Va=null,Yf=256;65536>Nb.D>>>0;){We.D=a.Na(Nb,2);if(null==Nb.D||!Yf--)break;for(var Zf=a,uc=We,Xe=null,Ob=uc.D,Ye=Ob,md=1;6>=md&&Ob;md++){if(2<md){uc.D=Ob;var vc=ff(Zf,uc);if(0<=vc.indexOf("CALL")){var Ze=vc.indexOf(" ");
if(Ob+(vc.indexOf(" ",Ze+1)-Ze-1)/2==Ye){Xe=vc;break}}}Ob--}uc.D=Ye;if(Va=Xe)break}if(!Va||null==Va)break;var $e=null;if("ks"==Xf){var af=Va.match(/[0-9A-F]+$/);af&&($e=tf(a,af[0]))}Va=ia(Va,50)+" ;"+($e||"stack="+Z(Nb.D));a.g(Va);ld++}ld||a.g("no return addresses found")}break;case "l":if("ln"==f[0]){tf(a,f[1],!0);break}break;case "m":a:{var Ca,Da=null,L=f[1];"?"==L&&(L=void 0);if(void 0!==L){var Ka=0;if("all"==L)Ka=1878917119,L=null;else if("on"==L)Da=!0,L=null;else if("off"==L)Da=!1,L=null;else{"keys"==
L&&(L="key");"kbd"==L&&(L="keyboard");for(Ca in ke)if(L==Ca){Ka=ke[Ca];Da=!!(a.ka&Ka);break}if(!Ka){a.g("unknown message category: "+L);break a}}if(Ka)if("on"==f[2])a.ka|=Ka,Da=!0;else if("off"==f[2]&&(a.ka&=~Ka,Da=!1,1073741824==Ka)){for(var nd=0;nd<a.ya.length;nd++)a.g(a.ya[nd]);a.ya=[]}}var $f=0,La="";for(Ca in ke)if(!L||L==Ca){var ag=!!(a.ka&ke[Ca]);if(null===Da||Da==ag)La&&(La+=","),++$f%10||(La+="\n\t"),"key"==Ca&&(Ca="keys"),La+=Ca}void 0===L&&a.g("message commands:\n\tm [category] [on|off]\tturn categories on/off");
a.g((null!==Da?Da?"messages on: ":"messages off: ":"message categories:\n\t")+(La||"none"));ce(a)}break;case "o":var od=f[1],bg=f[2];if(od&&"?"!=od){var pd=mf(a,od,"port #"),qd=mf(a,bg);void 0!==pd&&void 0!==qd&&(Gb(a.w,pd,qd),a.g(r(pd)+": "+("0x"+q(qd,2))))}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){vf(a,b.substr(5));break}var bf="pr"==f[0]?1:0,cg=1+bf;if(a.aa)a.g("step in progress");
else{var rd=Y(a.b.M);switch(a.X(rd)){case 205:a.aa=cg,oe(rd,3)}a.aa?(a.Sa(a.C,rd,!0),a.Za()||(a.u&&a.u.Bb(),a.aa=0)):wf(a,bf?"tr":"t")}break;case "r":if("reset"==b){a.u&&a.u.reset();break}Be(a,f);break;case "s":uf(a,f);break;case "t":wf(a,f[0],f[1]);break;case "u":Ce(a,f[1],f[2],8);break;case "v":if("var"==f[0]){sf(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.23.3 ("+a.b.Ha+",RELEASE"+(nb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(ra());break;case "?":if(f[1]){vf(a,b.substr(1));break}var Pb="commands:",
sd;for(sd in fe)Pb+="\n"+ia(sd,7)+fe[sd];td(a)||(Pb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(Pb);break;default:a.g("unknown command: "+b),d=!1}}}catch(cf){a.g("debugger error: "+(cf.stack||cf.message)),d=!1}return d}function ee(a,b,c){b=ue(a,b,c);for(var d in b)if(!ef(a,b[d]))return!1;return!0}Ja(function(){for(var a=C(document,"pc8080","debugger"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new $d(d);db(d,c)}});
function I(a,b,c){this.id=a.id;this.key=yf(a,b,c);this.G=a.G;zf(this,a.oc)}function yf(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
I.prototype={constructor:I,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){zf(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}}};
function zf(a,b){a[a.id]={};b&&J(a,"parms",b);a.b=!1}function Af(a){var b=!0;if(ua()){var c=JSON.stringify(a[a.id]);wa(a.key,c)||(v("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Bf(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){v(c.message||c),b=!1}return b}function Cf(a,b){return b?(a[a.id]=b,a.b=!0):a.b?!0:ua()&&(b=va(a.key))?(a[a.id]=b,a.b=!0):!1}function Df(a,b){return a[a.id][b]||null}function J(a,b,c){try{a[a.id][b]=c}catch(d){}}
function Ef(a,b,c){y.call(this,"Computer",a,Ef,67108864);this.B.pa=!1;Ff(this,b);this.aa=hc(this,"autoPower",a);this.A=0;this.oa=a.busWidth||a.buswidth;this.u=Gf;this.W=null;this.J=this.ea=!1;this.ra=hc(this,"url")||"";(Math.random()+.1).toString(36);this.C=Hf(this);if(this.b=cb("CPU",this.id)){this.G=cb("Debugger",this.id);this.I=[];for(b=null;b=qb(this,"Video",b);)this.I.push(b);this.w=new sb({id:this.Qb+".bus",busWidth:this.oa},this.b,this.G);var d,e=bb(this.id);if((this.F=cb("Panel",this.id))&&
this.F.Aa)for(b=0;b<e.length;b++)d=e[b],d.fa=this.F.fa,d.g=this.F.g,d.Aa=this.F.Aa;this.g("PC8080 v1.23.3\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");for(b=0;b<e.length;b++)d=e[b],d.Ma&&d.Ma(this,this.w,this.b,this.G);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.T=d:this.u=parseInt(d,10));var f;if(a=hc(this,"state")||(f=!0,a.state))b=this.ca=a,f||(this.J=!0,this.u=Gf),this.u&&(this.Y=new I(this,"1.23.3"),Cf(this.Y)?
b=null:delete this.Y);!b&&this.u&&(b=If(this))&&(this.J=!0);if(b){var h=this;oa(b,null,!0,function(a,b,c){c?(h.T=null,h.J=!1,h.fa("Unable to load machine state from server (error "+c+(b?": "+ja(b):"")+")")):(h.W=b,h.ea=!0);F(h)})}else F(this);this.K.power||(this.aa=!0);!c&&this.aa&&Jf(this,this.zb)}else v("Unable to find CPU component")}Za(Ef);var Gf=0;function Ff(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){v(d.message+" ("+c+")")}}a.L=b}
function hc(a,b,c){var d=b.toLowerCase(),d=Ra[b]||Ra[d];void 0===d&&a.L&&(d=a.L[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function Jf(a,b,c){for(var d=bb(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!lb(f)){lb(f,function(){Jf(a,b,c)});return}}b.call(a,c)}
function Kf(a,b){var c=new I(a,"1.23.3","validate");if(Cf(c)&&Bf(c)){var d=Df(c,"timestamp"),e=b?Df(b,"timestamp"):"unknown";d!=e&&(a.fa("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}m=Ef.prototype;
m.zb=function(a){void 0===a&&(a=this.u||(this.W?1:Gf));if(!this.A){this.A++;var b=!1,c=!1;this.da=!1;var d=this.Y||new I(this,"1.23.3");if(-1==a)b=!0;else if(a>Gf){if(Cf(d,this.W)){this.H=new I(this,"1.23.3","failsafe");Cf(this.H)&&(Lf(this,d),a=2,zf(this.H));J(this.H,"timestamp",ma());Af(this.H);var e=this.u&&!this.J;if(1==a||sa("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Bf(d)){var f=Df(d,"code"),h=Df(d,"data");f&&("ok"==f?Cf(d,h):("error"==f&&
"no machine state"!=h?(this.fa("Error: "+h),"unable to verify user"==h&&(wa("user",""),this.C=null)):this.g(f+": "+h),zf(d),Cf(d)?(c=Bf(d),e=!0):c=!1))}e&&Kf(this,c?d:null)}else 2==a&&d.clear()}else Kf(this);delete this.W;delete this.Y}e=bb(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.b&&(c=Mf(this,h,d,b,c));b=[d,a,c];-1!=a?Jf(this,this.Zb,b):this.Zb(b)}};
function Mf(a,b,c,d,e){if(!b.B.pa){b.B.pa=!0;if(b.Ca){var f=null;e&&((f=Df(c,b.id))||(f=Df(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.Ca(f,d)&&f&&(v("Unable to restore state for "+b.type),a.ca&&!a.ea?(c.clear(),a.u=Gf,window&&window.location.reload()):a.da=!0,b.Ca(null),e=!1)}if(!d&&b.dc)for(a=b.dc.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
m.Zb=function(a){var b=a[0],c=0>a[1];a=a[2];this.ua=!0;this.B.pa=!0;var d=this.K.power;d&&(d.textContent="Shutdown");this.b&&(Mf(this,this.b,b,c,a),wc(this.b));this.da&&(Lf(this,b),b.clear());!c&&this.H&&(this.H.clear(),delete this.H);this.A=0};
function Lf(a,b){if(sa("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.C||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.ra;e.user=c;e.type="bug";e.data=d;oa("http://www.pcjs.org/api/v1/report",e,!0)}}
function xf(a,b,c){var d,e="none";if(a.A)return null;a.A--;var f=new I(a,"1.23.3"),h=new I(a,"1.23.3","validate"),g=ma();J(h,"timestamp",g);J(f,"timestamp",g);J(f,"version","1.23.3");J(f,"url",window?window.location.href:null);J(f,"browser",ra());a.b&&a.b.Ia&&(c&&a.b.ia(),d=a.b.Ia(b,c),"object"===typeof d&&J(f,a.b.id,d),c&&(a.b.B.pa=!1,!1===d&&(e=null)));for(var g=bb(a.id),k=0;k<g.length;k++){var l=g[k];l.B.pa&&(l.Ia&&(d=l.Ia(b,c),"object"===typeof d&&J(f,l.id,d)),c&&(l.B.pa=!1,!1===d&&(e=null)))}e&&
(c?(g=d=!1,b?(a.C&&Nf(a,a.C,f.toString()),Af(h)&&Af(f)||(e=null,d=g=!0)):a.u&&(d=!0,g=3==a.u),d&&f.clear(g)):e=f.toString());c&&(a.B.pa=!1,b=a.K.power)&&(b.textContent="Power");a.A=0;return e}m.reset=function(){this.w&&this.w.reset&&(fb(this,"Resetting "+this.w.type),this.w.reset());for(var a=bb(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.w&&c.reset&&(fb(this,"Resetting "+c.type),c.reset())}};
function ve(a,b,c){var d;if(b){b=ue(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e<l.length;){var n=l[e++],p=n.length,n=ja(n);if(!n){f=!0;break}n=qf(a,n,null,!1===c);if(void 0===n){f=!0;c=!1;break}g.push(n);if(e==l.length)break;var n=l[e++],x=n.length;k.length&&of[n]<of[k[k.length-1]]&&pf(g,k,1);k.push(n);b=b.substr(p+x)}pf(g,k)&&1==g.length||(f=!0);f?c&&a.g("error parsing '"+h+"' at character "+(h.length-b.length)):(d=g.pop(),c&&rf(a,null,
d))}return d}function ue(a,b){for(var c;(c=b.match(/\{(.*?)}/))&&!(0<=c[1].indexOf("{"));){var d=ve(a,c[1]);b=b.replace("{"+c[1]+"}",null!=d?q(d):"undefined")}for(;(c=b.match(/\[(.*?)]/))&&!(0<=c[1].indexOf("["));)d=qe(a,c[1]),b=b.replace("["+c[1]+"]",d?q(a.Oa(d,0),4):"undefined");for(c=b;d=c.match(/\$([a-z]+)/i);){var e=null;switch(d[1].toLowerCase()){case "ops":e=a.ca-a.za}if(null==e)break;c=c.replace(d[0],e.toString())}return c}
function qf(a,b,c,d){var e;void 0!==b?(e=ze(b),0<=e?e=Be(a,e):(e=a.ga[b],void 0===e&&(e=aa(b))),void 0!==e||d||a.g("invalid "+(c?c:"value")+": "+b)):d||a.g("missing "+(c||"value"));return e}
function rf(a,b,c){var d,e=!1;if(void 0!==c){e=!0;d=c;var f,h="";if(!f||4<f)f=4;for(var g=0;g<f;g++){h&&(h=","+h);var k=d&255,l=8,n="";void 0===l?l=32:32<l&&(l=32);if(null==k||isNaN(k))for(;0<l--;)n="?"+n;else for(;0<l--;)n=(k&1?"1":"0")+n,k>>=1;h=n+"b"+h;d>>=8}d="0x"+q(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function sf(a,b){if(b)return rf(a,b,a.ga[b]);var c=0;for(b in a.ga)rf(a,b,a.ga[b]),c++;return 0<c}ce.prototype.Ta=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};
function tf(a,b,c){var d=[],e=pe(b)>>>0;for(b=0;b<a.I.length;b++){var f=a.I[b],h=f.F>>>0,g=f.cd;if(e>=h&&e<h+g){e=ka(f.bc,[e-h],a.Ta);0<=e?uf(a,b,e,d):c&&(e=~e,uf(a,b,e-1,d),uf(a,b,e,d));break}}return d}function uf(a,b,c,d){var e={},f=a.I[b].bc,h=0,g=null;0<=c&&c<f.length&&(h=f[c][0],g=f[c][1]);g&&(e=a.I[b].Ma[g],g="."==g.charAt(0)?null:e.l||g);d.push(g);d.push(h);d.push(e.a);d.push(e.c)}
function vf(a,b){if("?"==b)a.g("frequency commands:"),a.g("\tclear\tclear all frequency counts");else{var c,d=0;if(a.J)if("clear"==b){for(c=0;c<a.J.length;c++)a.J[c]=[c,0];a.g("frequency data cleared");d++}else if(void 0!==b)a.g("unknown frequency command: "+b),d++;else{var e=a.J.slice();e.sort(function(a,b){return b[1]-a[1]});var f=8086!=a.style?je:ke;for(c=0;c<e.length;c++){var h=e[c][0],g=e[c][1];g&&(a.g((f[a.Sa[h][0]]+" ").substr(0,5)+" ("+("0x"+q(h,2))+"): "+g+" times"),d++)}}d||a.g("no frequency data available")}}
function wf(a,b){var c=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(c){if(!c[1])return sf(a)||a.g("no variables"),!0;if(!c[2])return sf(a,c[1]);if(!c[3])return delete a.ga[c[1]],!0;var d=ve(a,c[3]);return void 0!==d?(a.ga[c[1]]=d,!0):!1}a.g("invalid assignment:"+b);return!1}
function xf(a,b,c){var d=null;if(b=qe(a,b,!0)){var e=tf(a,b,!0);if(e.length){var f,h;e[0]&&(h="",(f=b.F-e[1])&&(h=" + "+r(f)),f=e[0]+" ("+Z(e[1])+")"+h,c&&a.g(f),d=f);4<e.length&&e[4]&&(h="",(f=e[5]-b.F)&&(h=" - "+r(f)),f=e[4]+" ("+Z(e[5])+")"+h,c&&a.g(f),d||(d=f))}else c&&a.g("no symbols")}return d}
function yf(a,b){switch(b[1]){case "8080":a.style=de;break;case "8086":a.style=8086;break;case "cs":var c;void 0!==b[3]&&(c=+b[3]);switch(b[2]){case "int":a.b.i.mb=c;break;case "start":a.b.i.yb=c;break;case "stop":a.b.i.ob=c;break;default:a.g("unknown cs option");return}void 0!==c&&jc(a.b);a.g("checksums "+(a.b.B.ib?"enabled":"disabled"));return;case "sp":void 0!==b[2]&&(Ac(a.b,+b[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.Ya.toFixed(2)+"Mhz")+
" ("+a.b.i.$a+"x)");return;case "?":a.g("debugger options:");a.g("\t8080\t\tselect 8080-style mnemonics");a.g("\t8086\t\tselect 8086-style mnemonics");a.g("\tcs int #\tset checksum cycle interval to #");a.g("\tcs start #\tset checksum cycle start count to #");a.g("\tcs stop #\tset checksum cycle stop count to #");a.g("\tsp #\t\tset speed multiplier to #");break;default:if(b[1]){a.g("unknown option: "+b[1]);return}}a.g(a.style+"-style mnemonics enabled")}
function Ee(a,b){var c;if(b&&"?"==b[1])a.g("register commands:"),a.g("\tr\tdump registers"),a.g("\trx [#]\tset flag or register x to [#]");else{var d=a.b;null==c&&(c=!0);if(null!=b&&1<b.length){var e=b[1],f=null,h=e.indexOf("=");if(0<h)f=e.substr(h+1),e=e.substr(0,h);else if(2<b.length)f=b[2];else{a.g("missing value for "+b[1]);return}var h=!1,g=ve(a,f);if(void 0!==g)switch(h=!0,e.toUpperCase()){case "A":d.j=g&255;break;case "B":d.O=g&255;break;case "BC":d.O=g>>8&255;case "C":d.P=g&255;break;case "D":d.R=
g&255;break;case "DE":d.R=g>>8&255;case "E":d.S=g&255;break;case "H":d.T=g&255;break;case "HL":d.T=g>>8&255;case "L":d.W=g&255;break;case "SP":d.ia=g&65535;break;case "PC":H(d,g);a.U=Y(d.M);break;case "PS":Ic(d,g);break;case "PSW":Ic(d,g&255|d.sa&-256);d.j=g>>8;break;case "CF":d.Z=g?d.Z|256:d.Z&255;break;case "PF":g?Rc(d)||(d.ba^=1):Rc(d)&&(d.ba^=1);break;case "AF":d.ta=g?~d.ba&16|d.ta&-17:d.ba&16|d.ta&-17;break;case "ZF":d.Z=g?d.Z&-256:d.Z|255;break;case "SF":g?Uc(d)||(d.ba^=192):Uc(d)&&(d.ba^=192);
break;case "IF":d.sa=g?d.sa|512:d.sa&-513;break;default:a.g("unknown register: "+e);return}if(!h){a.g("invalid value: "+f);return}kc(d);a.g("updated registers:")}a.g(nf(a));c&&(a.U=Y(d.M),Fe(a,Z(a.U.F)))}}function zf(a,b){b=ja(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(Ce(a,c[2])):ve(a,b,!0)}function Af(a,b,c){var d="t"!=b;c=qf(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);ya(c,function(){return hb(a,!0)&&a.sb(e,d,!1)},function(){kc(a.b);hb(a,!1)})}
function Fe(a,b,c,d){if(b=qe(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=qe(a,c,!0);if(!d||d.F<b.F)return;e=d.F-b.F;if(256<e){a.g("range too large");return}d=-1}c=0;for(var f;0<e&&d--;){f=ib(a,!1)||a.aa?a.K:null;var h=null!=f?"cycles":null,g=tf(a,b),k=b.F;if(g[0]&&d&&(!c&&d||0>g[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=kf(a,b,h,f);a.g(f);a.U=b;e-=b.F-k;c++}}}
function xe(a,b,c,d){if(c)if(b){0>a.D&&a.w.length&&(a.D=0);if(0>a.D||b!=a.w[a.D])a.w.splice(0,0,b),a.D=0;a.D--}else a.ea?b="end":b=a.w[a.D+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var 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 jf(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ea&&(a.g("ended assemble at "+Z(a.da.F)),a.U=a.da,a.ea=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.xa=null;if(jb(a)&&0<b.length){a.ea&&(b="a "+Z(a.da.F)+" "+b);var f=b.replace(/ +/g," ").split(" ");if(f&&f.length)for(var h=f[0],g=h.charAt(0),k=1;k<h.length;k++){var l=h.charAt(k);if("?"==g||"r"==g||"a">l||"z"<l){f[0]=h.substr(k);f.unshift(h.substr(0,k));break}}switch(f[0].charAt(0)){case "a":var n=qe(a,f[1],!0);if(n)if(a.da=
n,void 0===f[2])a.g("begin assemble at "+Z(n.F)),a.ea=!0,kc(a.b);else{var p;a.g("not supported yet");p=[];if(p.length){for(var x=0;x<p.length;x++)a.qa(n,p[x],1);a.g(kf(a,a.da))}}break;case "b":a:{var w=f[0],t=f[1],A=b;if("?"==t)a.g("breakpoint commands:"),a.g("\tbi [p]\ttoggle break on input port [p]"),a.g("\tbo [p]\ttoggle break on output port [p]"),a.g("\tbp [a]\tset exec breakpoint at addr [a]"),a.g("\tbr [a]\tset read breakpoint at addr [a]"),a.g("\tbw [a]\tset write breakpoint at addr [a]"),
a.g("\tbc [a]\tclear breakpoint at addr [a]"),a.g("\tbl\tlist all breakpoints"),a.g("\tbn [n]\tbreak after [n] instruction(s)");else{var u=w.charAt(1);if("l"==u){var F=0,F=F+hf(a,a.C),F=F+hf(a,a.Y);(F+=hf(a,a.H))||a.g("no breakpoints")}else if("n"==u)a.ua=qf(a,t),a.g("break after "+a.ua+" instruction(s)");else if(void 0===t)a.g("missing breakpoint address");else{var B=Y();if("*"!=t&&(B=qe(a,t,!0),!B))break a;t=r(B.F);"c"==u?null==B.F?(ee(a),a.g("all breakpoints cleared")):He(a,a.C,B)||He(a,a.Y,B)||
He(a,a.H,B)||a.g("breakpoint missing: "+Z(B.F)):"i"==u?a.g("breakpoint "+(Ab(a.A,B.F)?"enabled":"cleared")+": port "+t+" (input)"):"o"==u?a.g("breakpoint "+(Eb(a.A,B.F)?"enabled":"cleared")+": port "+t+" (output)"):null!=B.F&&(we(a,B,A),"p"==u?a.Ua(a.C,B):"r"==u?a.Ua(a.Y,B):"w"==u?a.Ua(a.H,B):a.g("unknown breakpoint command: "+u))}}}break;case "c":a.Aa&&(a.Aa.value="");break;case "d":a:{var ha,pa=f[0],za=f[1],Ua=f[2],Vf=f[3];if("?"==za){var Aa="";for(ha in ne)a.Ga[ha]&&(Aa&&(Aa+=","),Aa+=ha);Aa+=
",state,symbols";a.g("dump memory commands:");a.g("\tdb [a] [#] dump # bytes at address a");a.g("\tdw [a] [#] dump # words at address a");a.g("\tdd [a] [#] dump # dwords at address a");a.g("\tdh [#] [#] dump # instructions from history");Aa.length&&a.g("dump extension commands:\n\t"+Aa)}else if("state"==za){var Je=Bf(a.u,!0);"console"==Ua?console.log(Je):(a.Aa&&(a.Aa.value=""),a.g(Je))}else if("symbols"==za)for(var dd=0;dd<a.I.length;dd++){var ed=a.I[dd],kb;for(kb in ed.Ma)if("."!=kb.charAt(0)){var Ke=
ed.Ma[kb].o;if(void 0!==Ke){var Le=ed.Ma[kb].l;Le&&(kb=Le);a.g(Z(Ke)+" "+kb)}}}else{if("d"==pa){for(ha in ne)if(f[1]==ha){var Me=a.Ga[ha];Me?(f.shift(),f.shift(),Me(f)):a.g("no dump registered for "+za);break a}za||(pa=a.Kb||"db")}else a.Kb=pa;if("dh"==pa){var Ne=za,Oe=Ua,Pe="",Qe=0,W=a.ka,Ba=a.N;if(Ba.length){var ca=+Ne||a.fb,lb=+Oe||10;isNaN(ca)?ca=lb:Pe="more ";ca>Ba.length&&(a.g("note: only "+Ba.length+" available"),ca=Ba.length);W-=ca;0>W&&(null==Ba[Ba.length-1].F?(ca=W+ca,W=0):W+=Ba.length);
var fd=[];"call"==Oe&&(lb=1E5,fd=["CALL"]);for(void 0!==Ne&&a.g(ca+" instructions earlier:");0<lb&&W!=a.ka;){var Re=Ba[W++];if(null==Re.F)break;var Jb=Y(Re.F),Wf=ca--,Se=kf(a,Jb,"history",Wf);(!fd.length||0<=Se.indexOf(fd[0]))&&a.g(Se);Jb.Qb&&(W+=Jb.Qb,lb-=Jb.Qb,ca-=Jb.Qb);W>=Ba.length&&(W=0);a.fb=ca;Qe++;lb--}}Qe||(a.g("no "+Pe+"history available"),a.fb=void 0)}else{var mc=qe(a,za);if(mc){var nc=0;Ua&&("l"==Ua.charAt(0)&&(Ua=Ua.substr(1)||Vf),nc=qf(a,Ua)>>>0,65536<nc&&(nc=65536));for(var Va="",oc=
"dd"==pa?4:"dw"==pa?2:1,pc=oc*nc||128,Xf=pc+15>>4||1;Xf--&&0<pc;){var qc=0,gd=0,Kb,Lb="",hd="",za=Z(mc.F);for(Kb=16;0<Kb&&0<pc;Kb--){var rc=a.X(mc,1),qc=qc|rc<<(gd++<<3);gd==oc&&(Lb+=q(qc,2*oc),Lb+=1==oc?9==Kb?"-":" ":" ",qc=gd=0);hd+=32<=rc&&128>rc?String.fromCharCode(rc):".";pc--}Va&&(Va+="\n");Va+=za+" "+Lb+(0==Kb?" "+hd:"")}Va&&a.g(Va);a.Va=mc}}}}break;case "e":if("else"==f[0])break;var sc=1,Te=255,Ue=a.X,Ve=a.qa;"ew"==f[0]&&(sc=2,Te=65535,Ue=a.Oa,Ve=a.Pb);var We=sc<<1,Xe=f[1];if(null==Xe)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 tc=qe(a,Xe);if(tc)for(var uc=2;uc<f.length;uc++){var Mb=ve(a,f[uc]);if(void 0===Mb){a.g("unrecognized value: "+f[uc]);break}Mb&~Te&&a.g("warning: "+q(Mb)+" exceeds "+sc+"-byte value");var Yf=Ue.call(a,tc);a.g("changing "+Z(tc.F)+" from 0x"+q(Yf,We)+" to 0x"+q(Mb,We));Ve.call(a,tc,Mb,sc)}}break;case "f":vf(a,f[1]);break;case "g":a:{var Ye=f[1],Zf=b;if(void 0!==Ye){var id=qe(a,Ye,!0);if(!id)break a;
we(a,id,Zf);a.Ua(a.C,id,!0)}a.ab(!0)||c||a.g("cpu busy or unavailable, run command ignored")}break;case "h":a:{var jd;if(a.B.va)jd="halting",a.ja();else{if(ib(a,!0))break a;jd="already halted"}c||a.g(jd)}break;case "i":if("if"==f[0]){var kd;var Nb=b.substr(2),Nb=ja(Nb);ve(a,Nb)?(c||a.g("true: "+Nb),kd=!0):(c||a.g("false: "+Nb),kd=!1);kd||(d=!1);break}if("int"==f[0]){var vc;var $f=f[1];if(a.b.sa&512){var ld=ve(a,$f);if(null==ld)vc=!1;else{a.g("requesting interrupt level "+ld);var Ze=a.b;Ze.w=Ze.w&
-8|ld|8;vc=!0}}else a.g("interrupts disabled (use rif=1 to enable)"),vc=!1;vc||(d=!1);break}var md=f[1];if(md&&"?"!=md){var nd=qf(a,md);if(void 0!==nd){var ag=Cb(a.A,nd);a.g(r(nd)+": "+("0x"+q(ag,2)))}}else a.g("input commands:"),a.g("\ti [p]\tread port [p]"),a.g("warning: port accesses can affect hardware state");break;case "k":var bg=f[0];if("?"==f[1])a.g("stack trace commands:"),a.g("\tk\tshow frame addresses"),a.g("\tks\tshow symbol information");else{var od=0,$e=Y(),Ob=Y(a.b.ia);for(a.g("stack trace for "+
Z(Ob.F));10>od;){for(var Wa=null,cg=256;65536>Ob.F>>>0;){$e.F=a.Oa(Ob,2);if(null==Ob.F||!cg--)break;for(var dg=a,wc=$e,af=null,Pb=wc.F,bf=Pb,pd=1;6>=pd&&Pb;pd++){if(2<pd){wc.F=Pb;var xc=kf(dg,wc);if(0<=xc.indexOf("CALL")){var cf=xc.indexOf(" ");if(Pb+(xc.indexOf(" ",cf+1)-cf-1)/2==bf){af=xc;break}}}Pb--}wc.F=bf;if(Wa=af)break}if(!Wa||null==Wa)break;var df=null;if("ks"==bg){var ef=Wa.match(/[0-9A-F]+$/);ef&&(df=xf(a,ef[0]))}Wa=ia(Wa,50)+" ;"+(df||"stack="+Z(Ob.F));a.g(Wa);od++}od||a.g("no return addresses found")}break;
case "l":if("ln"==f[0]){xf(a,f[1],!0);break}break;case "m":a:{var Ca,Da=null,N=f[1];"?"==N&&(N=void 0);if(void 0!==N){var La=0;if("all"==N)La=1878917119,N=null;else if("on"==N)Da=!0,N=null;else if("off"==N)Da=!1,N=null;else{"keys"==N&&(N="key");"kbd"==N&&(N="keyboard");for(Ca in ne)if(N==Ca){La=ne[Ca];Da=!!(a.na&La);break}if(!La){a.g("unknown message category: "+N);break a}}if(La)if("on"==f[2])a.na|=La,Da=!0;else if("off"==f[2]&&(a.na&=~La,Da=!1,1073741824==La)){for(var qd=0;qd<a.ya.length;qd++)a.g(a.ya[qd]);
a.ya=[]}}var eg=0,Ma="";for(Ca in ne)if(!N||N==Ca){var fg=!!(a.na&ne[Ca]);if(null===Da||Da==fg)Ma&&(Ma+=","),++eg%10||(Ma+="\n\t"),"key"==Ca&&(Ca="keys"),Ma+=Ca}void 0===N&&a.g("message commands:\n\tm [category] [on|off]\tturn categories on/off");a.g((null!==Da?Da?"messages on: ":"messages off: ":"message categories:\n\t")+(Ma||"none"));fe(a)}break;case "o":var rd=f[1],gg=f[2];if(rd&&"?"!=rd){var sd=qf(a,rd,"port #"),td=qf(a,gg);void 0!==sd&&void 0!==td&&(Gb(a.A,sd,td),a.g(r(sd)+": "+("0x"+q(td,
2))))}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){zf(a,b.substr(5));break}var ff="pr"==f[0]?1:0,hg=1+ff;if(a.aa)a.g("step in progress");else{var ud=Y(a.b.M);switch(a.X(ud)){case 205:a.aa=hg,re(ud,3)}a.aa?(a.Ua(a.C,ud,!0),a.ab()||(a.u&&a.u.Eb(),a.aa=0)):Af(a,ff?"tr":"t")}break;case "r":if("reset"==b){a.u&&a.u.reset();break}Ee(a,f);break;case "s":yf(a,f);break;case "t":Af(a,f[0],
f[1]);break;case "u":Fe(a,f[1],f[2],8);break;case "v":if("var"==f[0]){wf(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.23.3 ("+a.b.Ia+",RELEASE"+(nb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(ra());break;case "?":if(f[1]){zf(a,b.substr(1));break}var Qb="commands:",vd;for(vd in ie)Qb+="\n"+ia(vd,9)+ie[vd];cd(a)||(Qb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(Qb);break;default:a.g("unknown command: "+b),d=!1}}}catch(gf){a.g("debugger error: "+(gf.stack||gf.message)),d=!1}return d}
function he(a,b,c){b=xe(a,b,c);for(var d in b)if(!jf(a,b[d]))return!1;return!0}Ja(function(){for(var a=C(document,"pc8080","debugger"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new ce(d);db(d,c)}});function I(a,b,c){this.id=a.id;this.key=Cf(a,b,c);this.G=a.G;Df(this,a.sc)}function Cf(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
I.prototype={constructor:I,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){Df(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}}};
function Df(a,b){a[a.id]={};b&&J(a,"parms",b);a.b=!1}function Ef(a){var b=!0;if(ua()){var c=JSON.stringify(a[a.id]);wa(a.key,c)||(v("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Ff(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){v(c.message||c),b=!1}return b}function Gf(a,b){return b?(a[a.id]=b,a.b=!0):a.b?!0:ua()&&(b=va(a.key))?(a[a.id]=b,a.b=!0):!1}function Hf(a,b){return a[a.id][b]||null}function J(a,b,c){try{a[a.id][b]=c}catch(d){}}
function If(a,b,c){y.call(this,"Computer",a,If,67108864);this.B.ra=!1;Jf(this,b);this.aa=hc(this,"autoPower",a);this.w=0;this.ga=a.busWidth||a.buswidth;this.u=Kf;this.U=null;this.J=this.ea=!1;this.ka=hc(this,"url")||"";(Math.random()+.1).toString(36);this.C=Lf(this);if(this.b=cb("CPU",this.id)){this.G=cb("Debugger",this.id);this.I=[];for(b=null;b=qb(this,"Video",b);)this.I.push(b);this.A=new sb({id:this.Tb+".bus",busWidth:this.ga},this.b,this.G);var d,e=bb(this.id);if((this.D=cb("Panel",this.id))&&
this.D.Aa)for(b=0;b<e.length;b++)d=e[b],d.fa=this.D.fa,d.g=this.D.g,d.Aa=this.D.Aa;this.g("PC8080 v1.23.3\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");for(b=0;b<e.length;b++)d=e[b],d.Na&&d.Na(this,this.A,this.b,this.G);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.N=d:this.u=parseInt(d,10));var f;if(a=hc(this,"state")||(f=!0,a.state))b=this.ca=a,f||(this.J=!0,this.u=Kf),this.u&&(this.Y=new I(this,"1.23.3"),Gf(this.Y)?
b=null:delete this.Y);!b&&this.u&&(b=Mf(this))&&(this.J=!0);if(b){var h=this;oa(b,null,!0,function(a,b,c){c?(h.N=null,h.J=!1,h.fa("Unable to load machine state from server (error "+c+(b?": "+ja(b):"")+")")):(h.U=b,h.ea=!0);E(h)})}else E(this);this.L.power||(this.aa=!0);!c&&this.aa&&Nf(this,this.Cb)}else v("Unable to find CPU component")}Za(If);var Kf=0;function Jf(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){v(d.message+" ("+c+")")}}a.K=b}
function hc(a,b,c){var d=b.toLowerCase(),d=Ra[b]||Ra[d];void 0===d&&a.K&&(d=a.K[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function Nf(a,b,c){for(var d=bb(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!jb(f)){jb(f,function(){Nf(a,b,c)});return}}b.call(a,c)}
function Of(a,b){var c=new I(a,"1.23.3","validate");if(Gf(c)&&Ff(c)){var d=Hf(c,"timestamp"),e=b?Hf(b,"timestamp"):"unknown";d!=e&&(a.fa("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}m=If.prototype;
m.Cb=function(a){void 0===a&&(a=this.u||(this.U?1:Kf));if(!this.w){this.w++;var b=!1,c=!1;this.da=!1;var d=this.Y||new I(this,"1.23.3");if(-1==a)b=!0;else if(a>Kf){if(Gf(d,this.U)){this.H=new I(this,"1.23.3","failsafe");Gf(this.H)&&(Pf(this,d),a=2,Df(this.H));J(this.H,"timestamp",ma());Ef(this.H);var e=this.u&&!this.J;if(1==a||sa("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Ff(d)){var f=Hf(d,"code"),h=Hf(d,"data");f&&("ok"==f?Gf(d,h):("error"==f&&
"no machine state"!=h?(this.fa("Error: "+h),"unable to verify user"==h&&(wa("user",""),this.C=null)):this.g(f+": "+h),Df(d),Gf(d)?(c=Ff(d),e=!0):c=!1))}e&&Of(this,c?d:null)}else 2==a&&d.clear()}else Of(this);delete this.U;delete this.Y}e=bb(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.b&&(c=Qf(this,h,d,b,c));b=[d,a,c];-1!=a?Nf(this,this.cc,b):this.cc(b)}};
function Qf(a,b,c,d,e){if(!b.B.ra){b.B.ra=!0;if(b.Ca){var f=null;e&&((f=Hf(c,b.id))||(f=Hf(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.Ca(f,d)&&f&&(v("Unable to restore state for "+b.type),a.ca&&!a.ea?(c.clear(),a.u=Kf,window&&window.location.reload()):a.da=!0,b.Ca(null),e=!1)}if(!d&&b.hc)for(a=b.hc.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
m.cc=function(a){var b=a[0],c=0>a[1];a=a[2];this.ma=!0;this.B.ra=!0;var d=this.L.power;d&&(d.textContent="Shutdown");this.b&&(Qf(this,this.b,b,c,a),lc(this.b));this.da&&(Pf(this,b),b.clear());!c&&this.H&&(this.H.clear(),delete this.H);this.w=0};
function Pf(a,b){if(sa("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.C||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.ka;e.user=c;e.type="bug";e.data=d;oa("http://www.pcjs.org/api/v1/report",e,!0)}}
function Bf(a,b,c){var d,e="none";if(a.w)return null;a.w--;var f=new I(a,"1.23.3"),h=new I(a,"1.23.3","validate"),g=ma();J(h,"timestamp",g);J(f,"timestamp",g);J(f,"version","1.23.3");J(f,"url",window?window.location.href:null);J(f,"browser",ra());a.b&&a.b.Ja&&(c&&a.b.ja(),d=a.b.Ja(b,c),"object"===typeof d&&J(f,a.b.id,d),c&&(a.b.B.ra=!1,!1===d&&(e=null)));for(var g=bb(a.id),k=0;k<g.length;k++){var l=g[k];l.B.ra&&(l.Ja&&(d=l.Ja(b,c),"object"===typeof d&&J(f,l.id,d)),c&&(l.B.ra=!1,!1===d&&(e=null)))}e&&
(c?(g=d=!1,b?(a.C&&Rf(a,a.C,f.toString()),Ef(h)&&Ef(f)||(e=null,d=g=!0)):a.u&&(d=!0,g=3==a.u),d&&f.clear(g)):e=f.toString());c&&(a.B.ra=!1,b=a.L.power)&&(b.textContent="Power");a.w=0;return e}m.reset=function(){this.A&&this.A.reset&&(fb(this,"Resetting "+this.A.type),this.A.reset());for(var a=bb(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.A&&c.reset&&(fb(this,"Resetting "+c.type),c.reset())}};
m.start=function(a,b){for(var c=bb(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};m.stop=function(a,b){for(var c=bb(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}};
m.ma=function(a,b,c){var d=this;switch(b){case "power":return this.K[b]=c,c.onclick=function(){d.A||(d.B.pa?xf(d,!1,!0):Jf(d,d.zb))},!0;case "reset":return this.K[b]=c,c.onclick=function(){if(d.B.pa&&!d.A)if(d.u&&!d.T){var a=sa("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");xf(d,a,!0);!a&&d.ca?window&&window.location.reload():d.zb(Gf)}else d.reset(),d.b&&wc(d.b)},!0;case "save":if(ea(qa(),"pcjs.org")){c.parentNode.removeChild(c);
break}this.K[b]=c;c.onclick=function(){var a=Hf(d,!0);if(a){var b=!!(d.u&&!d.T||d.ca),c=xf(d,b);b?Nf(d,a,c):d.fa("Resume disabled, machine state not saved")}};return!0}return!1};
function Hf(a,b){var c=a.C;c||(c=va("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=Of(a,c))||a.fa("The user ID is invalid."))):b&&a.fa("Browser local storage is not available"));return c}
function Of(a,b){a.C=null;var c=oa(qa()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(wa("user",c.data),a.C=c.data)}catch(e){v(e.message+" ("+d+")")}return a.C}function If(a){var b=null;a.C&&(b=qa()+"/api/v1/user?req=load&user="+a.C+"&state="+yf(a,"1.23.3"));return b}
function Nf(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=yf(a,"1.23.3");d.data=c;b=oa(qa()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.fa("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.fa(c),wa("user",""),a.C=null)}}
function qb(a,b,c){a=bb(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}m.Bb=function(a){if(this.I.length){var b=0,c=0;a&&window&&(b=window.scrollX,c=window.scrollY);var d=this.I[0];d.Fa&&d.Fa.focus();a&&window&&window.scrollTo(b,c)}};m.Da=function(a){this.b&&this.b.Da(a);this.F&&this.F.Da(a)};
function Cc(a,b){for(var c=0;c<a.I.length;c++){var d=a.I[c],e=!0;if(0<=b){if(d.mc)if(b&1)e=d.b,e.A=e.A&-8|10,e=!1;else{var f=d.b;f.A=f.A&-8|9}if(f=e&&d.za){for(var f=d.w,h=d.Ta,g=!0,k=d.ya>>>f.ja;0<h&&k<f.U.length;)f.U[k].Ja&&(f.U[k].Ja=g=!1,f.U[k].ac=!0),h-=f.Ba,k++;f=g}f&&(e=!1)}if(e)if(1<d.la)switch(d.Y){case 2:Zd(d)}else{var g=d.ya,k=g+d.Ta,l=0,n=0,p=0,e=d.J,x=0,f=d.ca,w=h=0,t=d.Qa,z=(1<<t)-1;d.hd&&(t=-t,w=16+t);for(;g<k;){var u=yb(d.w,g);if(d.za&&u===d.ra[l])n+=d.lc;else{d.ra[l]=u;var E=w;E&&
(u=u>>8|(u&255)<<8);n<e&&(e=n);for(var A=d.lc;A--;){var ha=u>>E&z;Yd(d,d.gc,n++,p,ha);E+=t}n>x&&(x=n);p<f&&(f=p);p>=h&&(h=p+1)}g+=2;l++;if(n>=d.J&&(n=0,p++,p>d.ca))break}d.za=!0;e<d.J&&(g=x-e,h-=f,d.F&&(k=e,l=g,e=f,g=h,f=d.J-(k+l),h=l),d.bb.putImageData(d.gc,0,0,e,f,g,h),d.H.drawImage(d.L,0,0,d.L.width,d.L.height,0,0,d.aa,d.W))}}}
Ja(function(){for(var a=C(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=B(c),c=C(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],h=B(f),h=new Ef(h,d,!0);db(h,f);h.aa&&Jf(h,h.zb)}});Fa.show.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=B(a[b]);(c=cb("Computer",c.id))&&c.ua&&!c.B.pa&&c.zb(-1)}});
Fa.exit.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=B(a[b]);(c=cb("Computer",c.id))&&c.B.pa&&xf(c,!(!c.u||c.T),!0)}});var Pf=0;function Qf(a,b,c,d,e,f){e("Loading "+a+"...");oa(a,null,!0,function(h,g,k){k?(g||(g="unable to load "+a+" ("+k+")"),f(g,null)):dg(g,a,b,c,d,e,f)})}
function dg(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{if(c){ab(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(p){g=null,a=p.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?eg(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
function eg(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/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,n=/( [a-z]+=)(['"])(.*?)\2/g;l=n.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
"");a=a.replace(d[0],h);eg(a,b,c)}})}else c(a,null)}
function fg(a,b,c,d){function e(a){if(void 0===g){var b=h&&C(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ga(a))}function f(a){e("Error: "+a);k&&(--Pf||Na(!0));k=!1}var h,g,k=!0;Pf++;$a[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var n=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css";p.styleSheet?p.styleSheet.cssText=l:p.appendChild(document.createTextNode(l));n.appendChild(p)}c||
(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?Qf(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,--Pf||Na(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--Pf||Na(!0)):f("invalid machine element: "+
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?Qf(b,a,d,!0,e,l):dg(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(x){f(x.message)}return k}window.embedPC8080=function(a,b,c,d){Na(!1);return fg(a,b,c,d)};window.enableEvents=Na;window.sendEvent=Oa;
function gg(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){hg(b,d)}):hg(null,d)}else v("Error ("+c+") requesting "+a)}
function hg(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 n=g[l],p=da(l);if("xml"==p){for(p=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=p.exec(g[l]);){var x=d[2];x&&(g[x]||(n=n.replace(d[0],"")))}d=l=ba(l)}else"xsl"==p&&(e=l=ba(l));k[l]=n}a&&(k[l="css"]=a);b[2]&&(k[l="parms"]=b[2]);b[3]&&(k[l="state"]=b[3]);d&&e?(l=JSON.stringify(k),h+=".js",c=c[1]+"var resources="+l+";"+c[2]+c[3],c=c.replace(/\u00A9/g,
m.pa=function(a,b,c){var d=this;switch(b){case "power":return this.L[b]=c,c.onclick=function(){d.w||(d.B.ra?Bf(d,!1,!0):Nf(d,d.Cb))},!0;case "reset":return this.L[b]=c,c.onclick=function(){if(d.B.ra&&!d.w)if(d.u&&!d.N){var a=sa("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Bf(d,a,!0);!a&&d.ca?window&&window.location.reload():d.Cb(Kf)}else d.reset(),d.b&&lc(d.b)},!0;case "save":if(ea(qa(),"pcjs.org")){c.parentNode.removeChild(c);
break}this.L[b]=c;c.onclick=function(){var a=Lf(d,!0);if(a){var b=!!(d.u&&!d.N||d.ca),c=Bf(d,b);b?Rf(d,a,c):d.fa("Resume disabled, machine state not saved")}};return!0}return!1};
function Lf(a,b){var c=a.C;c||(c=va("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=Sf(a,c))||a.fa("The user ID is invalid."))):b&&a.fa("Browser local storage is not available"));return c}
function Sf(a,b){a.C=null;var c=oa(qa()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(wa("user",c.data),a.C=c.data)}catch(e){v(e.message+" ("+d+")")}return a.C}function Mf(a){var b=null;a.C&&(b=qa()+"/api/v1/user?req=load&user="+a.C+"&state="+Cf(a,"1.23.3"));return b}
function Rf(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Cf(a,"1.23.3");d.data=c;b=oa(qa()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.fa("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.fa(c),wa("user",""),a.C=null)}}
function qb(a,b,c){a=bb(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}m.Eb=function(a){if(this.I.length){var b=0,c=0;a&&window&&(b=window.scrollX,c=window.scrollY);var d=this.I[0];d.Ga&&d.Ga.focus();a&&window&&window.scrollTo(b,c)}};m.Da=function(a){this.b&&this.b.Da(a);this.D&&this.D.Da(a)};
function Dc(a,b){for(var c=0;c<a.I.length;c++){var d=a.I[c],e=!0;if(0<=b){if(d.qc)if(b&1)e=d.b,e.w=e.w&-8|10,e=!1;else{var f=d.b;f.w=f.w&-8|9}if(f=e&&d.za){for(var f=d.A,h=d.Va,g=!0,k=d.ya>>>f.la;0<h&&k<f.V.length;)f.V[k].Ka&&(f.V[k].Ka=g=!1,f.V[k].ec=!0),h-=f.Ba,k++;f=g}f&&(e=!1)}if(e)if(1<d.oa)switch(d.Y){case 2:be(d)}else{var g=d.ya,k=g+d.Va,l=0,n=0,p=0,e=d.J,x=0,f=d.ca,w=h=0,t=d.Sa,A=(1<<t)-1;d.sd&&(t=-t,w=16+t);for(;g<k;){var u=yb(d.A,g);if(d.za&&u===d.ka[l])n+=d.pc;else{d.ka[l]=u;var F=w;F&&
(u=u>>8|(u&255)<<8);n<e&&(e=n);for(var B=d.pc;B--;){var ha=u>>F&A;ae(d,d.kc,n++,p,ha);F+=t}n>x&&(x=n);p<f&&(f=p);p>=h&&(h=p+1)}g+=2;l++;if(n>=d.J&&(n=0,p++,p>d.ca))break}d.za=!0;e<d.J&&(g=x-e,h-=f,d.D&&(k=e,l=g,e=f,g=h,f=d.J-(k+l),h=l),d.fb.putImageData(d.kc,0,0,e,f,g,h),d.H.drawImage(d.K,0,0,d.K.width,d.K.height,0,0,d.aa,d.U))}}}
Ja(function(){for(var a=C(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=z(c),c=C(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],h=z(f),h=new If(h,d,!0);db(h,f);h.aa&&Nf(h,h.Cb)}});Fa.show.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=z(a[b]);(c=cb("Computer",c.id))&&c.ma&&!c.B.ra&&c.Cb(-1)}});
Fa.exit.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=z(a[b]);(c=cb("Computer",c.id))&&c.B.ra&&Bf(c,!(!c.u||c.N),!0)}});var Tf=0;function Uf(a,b,c,d,e,f){e("Loading "+a+"...");oa(a,null,!0,function(h,g,k){k?(g||(g="unable to load "+a+" ("+k+")"),f(g,null)):ig(g,a,b,c,d,e,f)})}
function ig(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{if(c){ab(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(p){g=null,a=p.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?jg(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
function jg(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/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,n=/( [a-z]+=)(['"])(.*?)\2/g;l=n.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
"");a=a.replace(d[0],h);jg(a,b,c)}})}else c(a,null)}
function kg(a,b,c,d){function e(a){if(void 0===g){var b=h&&C(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ga(a))}function f(a){e("Error: "+a);k&&(--Tf||Na(!0));k=!1}var h,g,k=!0;Tf++;$a[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var n=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css";p.styleSheet?p.styleSheet.cssText=l:p.appendChild(document.createTextNode(l));n.appendChild(p)}c||
(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?Uf(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,--Tf||Na(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--Tf||Na(!0)):f("invalid machine element: "+
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?Uf(b,a,d,!0,e,l):ig(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(x){f(x.message)}return k}window.embedPC8080=function(a,b,c,d){Na(!1);return kg(a,b,c,d)};window.enableEvents=Na;window.sendEvent=Oa;
function lg(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){mg(b,d)}):mg(null,d)}else v("Error ("+c+") requesting "+a)}
function mg(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 n=g[l],p=da(l);if("xml"==p){for(p=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=p.exec(g[l]);){var x=d[2];x&&(g[x]||(n=n.replace(d[0],"")))}d=l=ba(l)}else"xsl"==p&&(e=l=ba(l));k[l]=n}a&&(k[l="css"]=a);b[2]&&(k[l="parms"]=b[2]);b[3]&&(k[l="state"]=b[3]);d&&e?(l=JSON.stringify(k),h+=".js",c=c[1]+"var resources="+l+";"+c[2]+c[3],c=c.replace(/\u00A9/g,
"&#xA9;"),l=h,g=null,k="data:application/javascript,",k=xa("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+='<div id="'+f+'"></div>\n',c+="...\n",c+='<script type="text/javascript" src="'+h+'">\x3c/script>\n',c+='<script type="text/javascript">embedPC("'+f+'","'+d+'","'+e+'");\x3c/script>\n\n',c+="The machine should appear where the <div> is located.",v(c)):v("Missing XML/XSL resources")}
window.savePC=function(a,b,c){var d=cb("Computer",a),e=cb("Debugger",a);if(d){var f=xf(d,!0),h=d.L?JSON.stringify(d.L):null;b||(b="/versions/pcjs/1.23.3/pc"+(e?"-dbg":"")+".js");if(c&&c({state:f,oc:h}))return!0;oa(b,null,!0,function(c,d,e){gg(c,d,e,[a,ba(b,!0),h,f])});return!0}v("Unable to identify machine '"+a+"'");return!1};})();
window.savePC=function(a,b,c){var d=cb("Computer",a),e=cb("Debugger",a);if(d){var f=Bf(d,!0),h=d.K?JSON.stringify(d.K):null;b||(b="/versions/pcjs/1.23.3/pc"+(e?"-dbg":"")+".js");if(c&&c({state:f,sc:h}))return!0;oa(b,null,!0,function(c,d,e){lg(c,d,e,[a,ba(b,!0),h,f])});return!0}v("Unable to identify machine '"+a+"'");return!1};})();

View file

@ -6,60 +6,60 @@ typeof b){var k="",l;for(l in b)b.hasOwnProperty(l)&&(k&&(k+="&"),k+=l+"="+encod
function t(a){window&&window.alert(a)}function ja(a){var b=!1;window&&(b=window.confirm(a));return b}var ka=null;function la(){if(null==ka){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}ka=a}return ka}function ma(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function na(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function oa(a){if(window){var b=window?window.navigator.userAgent:"";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}var qa={init:[],show:[],exit:[]},ra=!1,sa=!0;function ta(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function ua(a){qa.init.push(a)}
function va(a){if(sa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){t(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function wa(a){!sa&&a?(sa=!0,ra&&xa("init")):sa=a}function xa(a){qa[a]&&va(qa[a])}ta("onload",function(){ra=!0;va(qa.init)});ta("onpageshow",function(){va(qa.show)});ta(oa("Opera")||oa("iOS")?"onunload":"onbeforeunload",function(){va(qa.exit)});
function v(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.lb=b.comment;this.Cb=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.ab=this.id.substr(0,b),this.$a=this.id.substr(b+1)):this.$a=this.id;this[a]=c;this.h={ra:!1,ya:!1,cb:!1,P:!1,ka:!1};this.Oa=null;this.h.ka=!1;this.w={};this.K=null;w.push(this)}var ya=void 0,za={};
function u(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.pb=b.comment;this.Gb=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.eb=this.id.substr(0,b),this.cb=this.id.substr(b+1)):this.cb=this.id;this[a]=c;this.h={ua:!1,Ba:!1,gb:!1,P:!1,la:!1};this.Ra=null;this.h.la=!1;this.w={};this.N=null;w.push(this)}var ya=void 0,za={};
if(window){ya||(ya=window.location.search.substr(1));for(var Aa,Ba=/\+/g,Ca=/([^&=]+)=?([^&]*)/g;Aa=Ca.exec(ya);)za[decodeURIComponent(Aa[1].replace(Ba," "))]=decodeURIComponent(Aa[2].replace(Ba," "))}function Da(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
function x(a,b){b||(b=v);a.prototype=Da(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}var w=[],Ea={};function Fa(a,b,c){Ea[a]&&b&&(Ea[a][b]=c)}function Ga(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<w.length;b++){var d=w[b];a&&d.id.indexOf(a)||c.push(d)}return c}
function x(a,b){b||(b=u);a.prototype=Da(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}var w=[],Ea={};function Fa(a,b,c){Ea[a]&&b&&(Ea[a][b]=c)}function Ga(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<w.length;b++){var d=w[b];a&&d.id.indexOf(a)||c.push(d)}return c}
function Ha(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<w.length;d++)if(c)c==w[d]&&(c=null);else if(!(a!=w[d].type||b&&w[d].id.indexOf(b)))return w[d]}return null}function y(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){t(c.message+" ("+a+")")}return b}
function Ia(a,b){for(var c=A(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var e=c[d].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var k=g.split(" "),l=0;l<k.length;l++)switch(g=k[l],g){case "pc8080-binding":(g=y(h))&&g.binding&&a.R(g.type,g.binding,h,g.value),l=k.length}}}}
function A(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
v.prototype={constructor:v,parent:null,toString:function(){return this.name?this.name:this.id||this.type},R:function(a,b,c){switch(b){case "clear":return this.w[b]||(this.w[b]=c,c.onclick=function(a){return function(){a.w.print&&(a.w.print.value="")}}(this)),!0;case "print":return this.w[b]||(this.ga=this.w[b]=c,c.value="",this.X=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
this.I=function(a){this.X(a,this.$a)}),!0;default:return!1}},log:function(){},X:function(){},status:function(a){this.X(this.$a+": "+a)},I:function(a,b,c){c=c||this.type;b||t((c?c+": ":"")+a)},Z:function(){return this.h.P=!0},ea:function(a,b){b&&(this.h.P=!1);return!0}};function Ja(a,b){if(a.h.cb)return a.h.ya&&(a.h.ya=!1),a.h.cb=!1;if(a.h.ka)return a.X(a.toString()+" error"),!1;a.h.ya=b;return a.h.ya}function B(a){if(!a.h.ka&&(a.h.ra=!0,a.h.ra)){var b=a.Oa;a.Oa=null;b&&b()}}
function Ka(a,b){b&&(a.h.ra?b():a.Oa=b);return a.h.ra}
function Ia(a,b){for(var c=z(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var e=c[d].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var k=g.split(" "),l=0;l<k.length;l++)switch(g=k[l],g){case "pc8080-binding":(g=y(h))&&g.binding&&a.R(g.type,g.binding,h,g.value),l=k.length}}}}
function z(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
u.prototype={constructor:u,parent:null,toString:function(){return this.name?this.name:this.id||this.type},R:function(a,b,c){switch(b){case "clear":return this.w[b]||(this.w[b]=c,c.onclick=function(a){return function(){a.w.print&&(a.w.print.value="")}}(this)),!0;case "print":return this.w[b]||(this.ha=this.w[b]=c,c.value="",this.X=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
this.I=function(a){this.X(a,this.cb)}),!0;default:return!1}},log:function(){},X:function(){},status:function(a){this.X(this.cb+": "+a)},I:function(a,b,c){c=c||this.type;b||t((c?c+": ":"")+a)},Z:function(){return this.h.P=!0},fa:function(a,b){b&&(this.h.P=!1);return!0}};function Ja(a,b){if(a.h.gb)return a.h.Ba&&(a.h.Ba=!1),a.h.gb=!1;if(a.h.la)return a.X(a.toString()+" error"),!1;a.h.Ba=b;return a.h.Ba}function B(a){if(!a.h.la&&(a.h.ua=!0,a.h.ua)){var b=a.Ra;a.Ra=null;b&&b()}}
function Ka(a,b){b&&(a.h.ua?b():a.Ra=b);return a.h.ua}
var La="undefined"!==typeof ArrayBuffer,Ma=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,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,0,1,1,0,1,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,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,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,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,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,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
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 Na(a){v.call(this,"Panel",a,Na)}x(Na);m=Na.prototype;m.R=function(a,b,c,d){return this.u&&this.u.R(a,b,c,d)||this.a&&this.a.R(a,b,c,d)||this.D&&this.D.R(a,b,c,d)?!0:this.parent.R.call(this,a,b,c,d)};m.ha=function(a,b,c,d){this.u=a;this.l=b;this.a=c;this.K=d;this.D=Oa(a,"Keyboard")};m.Z=function(a,b){b||Pa();return!0};m.ea=function(){return!0};m.na=function(){};
function Pa(){for(var a=!1,b=A(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=y(d),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<w.length;h++)if(w[h].id===f){f=w[h];break a}f=null}f||(a=!0,f=new Na(e));Ia(f,d);a&&B(f)}}ua(Pa);
function Qa(a,b,c){v.call(this,"Bus",a,Qa);this.a=b;this.K=c;this.i=a.busWidth||16;this.s=Math.pow(2,this.i);this.g=this.s-1|0;this.c=16>=this.i?10:20>=this.i?12:24>=this.i?14:15;this.l=1<<this.c;this.v=this.l>>2;this.f=this.l-1;this.j=this.s/this.l|0;this.u=this.j-1;this.m=[];this.o=[];this.F=[];this.C=[];a=new C;Ra(a,this.K);this.b=Array(this.j);for(b=0;b<this.j;b++)this.b[b]=a;B(this)}x(Qa);Qa.prototype.reset=function(){};Qa.prototype.Z=function(a,b){b||this.reset();return!0};
function Sa(a,b,c,d){for(var e=b,f=c,h=e>>>a.c;0<f&&h<a.b.length;){var g=a.b[h],k=h*a.l,l=a.l-(e-k);l>f&&(l=f);if(g&&g.size){if(g.type==d){if(e+f<=g.pa)return g.Wa+=g.pa-e,g.pa=e,!0;if(e>=g.pa+g.Wa){l=g.size-(e-k);l>f&&(l=f);g.Wa=e-g.pa+l;e=k+a.l;f-=l;h++;continue}}return Ta(1,e,f)}e=new C(e,l,a.l,d);Ra(e,a.K,g);a.b[h++]=e;e=k+a.l;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+Ua[d]+" at "+("0x"+q(b,4))),!0):Ta(2,b,c)}
Qa.prototype.H=function(a){return this.b[(a&this.g)>>>this.c].Ha(a&this.f,a)};function Va(a,b){return a.b[(b&a.g)>>>a.c].Va(b&a.f,b)}function Wa(a,b){var c=b&a.f,d=(b&a.g)>>>a.c;return c!=a.f?a.b[d].vc(c,b):a.b[d++].Ha(c,b)|a.b[d&a.u].Ha(0,b+1)<<8}Qa.prototype.S=function(a,b){this.b[(a&this.g)>>>this.c].Ia(a&this.f,b&255,a)};function Xa(a,b,c){a.b[(b&a.g)>>>a.c].Fb(b&a.f,c&255,b)}
function Ya(a,b,c){var d=b&a.f,e=(b&a.g)>>>a.c;d!=a.f?a.b[e].wc(d,c&65535,b):(a.b[e++].Ia(d,c&255,b),a.b[e&a.u].Ia(0,c>>8&255,b+1))}function Za(a,b,c){var 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.m[k]?t("Input port 0x"+q(k,4)+" already registered"):f.m[k]=[g,!1]}}
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 Na(a){u.call(this,"Panel",a,Na)}x(Na);m=Na.prototype;m.R=function(a,b,c,d){return this.u&&this.u.R(a,b,c,d)||this.a&&this.a.R(a,b,c,d)||this.D&&this.D.R(a,b,c,d)?!0:this.parent.R.call(this,a,b,c,d)};m.ia=function(a,b,c,d){this.u=a;this.l=b;this.a=c;this.N=d;this.D=Oa(a,"Keyboard")};m.Z=function(a,b){b||Pa();return!0};m.fa=function(){return!0};m.oa=function(){};
function Pa(){for(var a=!1,b=z(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=y(d),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<w.length;h++)if(w[h].id===f){f=w[h];break a}f=null}f||(a=!0,f=new Na(e));Ia(f,d);a&&B(f)}}ua(Pa);
function Qa(a,b,c){u.call(this,"Bus",a,Qa);this.a=b;this.N=c;this.i=a.busWidth||16;this.s=Math.pow(2,this.i);this.g=this.s-1|0;this.c=16>=this.i?10:20>=this.i?12:24>=this.i?14:15;this.l=1<<this.c;this.v=this.l>>2;this.f=this.l-1;this.j=this.s/this.l|0;this.u=this.j-1;this.m=[];this.o=[];this.F=[];this.C=[];a=new C;Ra(a,this.N);this.b=Array(this.j);for(b=0;b<this.j;b++)this.b[b]=a;B(this)}x(Qa);Qa.prototype.reset=function(){};Qa.prototype.Z=function(a,b){b||this.reset();return!0};
function Sa(a,b,c,d){for(var e=b,f=c,h=e>>>a.c;0<f&&h<a.b.length;){var g=a.b[h],k=h*a.l,l=a.l-(e-k);l>f&&(l=f);if(g&&g.size){if(g.type==d){if(e+f<=g.sa)return g.Za+=g.sa-e,g.sa=e,!0;if(e>=g.sa+g.Za){l=g.size-(e-k);l>f&&(l=f);g.Za=e-g.sa+l;e=k+a.l;f-=l;h++;continue}}return Ta(1,e,f)}e=new C(e,l,a.l,d);Ra(e,a.N,g);a.b[h++]=e;e=k+a.l;f-=l}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+Ua[d]+" at "+("0x"+q(b,4))),!0):Ta(2,b,c)}
Qa.prototype.H=function(a){return this.b[(a&this.g)>>>this.c].Ka(a&this.f,a)};function Va(a,b){return a.b[(b&a.g)>>>a.c].Ya(b&a.f,b)}function Wa(a,b){var c=b&a.f,d=(b&a.g)>>>a.c;return c!=a.f?a.b[d].Ec(c,b):a.b[d++].Ka(c,b)|a.b[d&a.u].Ka(0,b+1)<<8}Qa.prototype.T=function(a,b){this.b[(a&this.g)>>>this.c].La(a&this.f,b&255,a)};function Xa(a,b,c){a.b[(b&a.g)>>>a.c].Jb(b&a.f,c&255,b)}
function Ya(a,b,c){var d=b&a.f,e=(b&a.g)>>>a.c;d!=a.f?a.b[e].Fc(d,c&65535,b):(a.b[e++].La(d,c&255,b),a.b[e&a.u].La(0,c>>8&255,b+1))}function Za(a,b,c){var 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.m[k]?t("Input port 0x"+q(k,4)+" already registered"):f.m[k]=[g,!1]}}
function $a(a,b,c){var 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.o[k]?t("Output port 0x"+q(k,4)+" already registered"):f.o[k]=[g,!1]}}function Ta(a,b,c){t("Memory block error ("+a+": "+q(b)+","+q(c)+")");return!1}var ab;if(La){var bb=new ArrayBuffer(2);(new DataView(bb)).setUint16(0,256,!0);ab=256===(new Uint16Array(bb))[0]}else ab=!1;var cb=ab;
function C(a,b,c,d){this.id=db+=2;this.a=null;this.pa=a;this.Wa=b;this.size=c||0;this.type=d||eb;this.f=d==fb;Ra(this);this.ca=this.tb=!1;if(c)if(La)this.c=new ArrayBuffer(c),this.l=new DataView(this.c,0,c),this.b=new Uint8Array(this.c,0,c),this.j=new Uint16Array(this.c,0,c>>1),this.a=new Int32Array(this.c,0,c>>2),gb(this,cb?hb:ib);else{this.a=Array(c>>2);for(a=0;a<this.a.length;a++)this.a[a]=0;gb(this,jb)}else gb(this)}var eb=0,fb=2,Ua=["NONE","RAM","ROM","VID","H/W"],db=0;
C.prototype={constructor:C,parent:null,za:function(a){this.pa=a},save:function(){var a,b;if(La)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.l.getInt32(b<<2,!0);else a=this.a;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(La)for(b=0;b<a.length;b++)this.l.setInt32(b<<2,a[b],!0);else this.a=a;return this.ca=!0}return!1},w:function(){return 255},o:function(){},m:function(a,b){return this.Ha(a++,b++)|this.Ha(a,b)<<8},u:function(a,b,c){this.Ia(a++,b&255,c++);this.Ia(a,b>>
8,c)},C:function(a){return this.a[a>>2]>>>((a&3)<<3)&255},L:function(a){var b=a>>2;a=(a&3)<<3;var c=this.a[b]>>a;return 24>a?c&65535:c&255|(this.a[b+1]&255)<<8},W:function(a,b){var c=a>>2,d=(a&3)<<3;this.a[c]=this.a[c]&~(255<<d)|b<<d;this.ca=!0},oa:function(a,b){var c=a>>2,d=(a&3)<<3;24>d?this.a[c]=this.a[c]&~(65535<<d)|b<<d:(this.a[c]=this.a[c]&16777215|b<<24,c++,this.a[c]=this.a[c]&-256|b>>8);this.ca=!0},v:function(a,b){return this.Va(a,b)},G:function(a,b){return this.Db(a,b)},O:function(a,b,c){this.f||
this.Fb(a,b,c)},aa:function(a,b,c){this.f||this.ba(a,b,c)},s:function(a){return this.b[a]},F:function(a){return this.b[a]},D:function(a){return this.l.getUint16(a,!0)},U:function(a){return a&1?this.b[a]|this.b[a+1]<<8:this.j[a>>1]},N:function(a,b){this.b[a]=b;this.ca=!0},V:function(a,b){this.b[a]=b;this.ca=!0},$:function(a,b){this.l.setUint16(a,b,!0);this.ca=!0},fa:function(a,b){a&1?(this.b[a]=b,this.b[a+1]=b>>8):this.j[a>>1]=b;this.ca=!0}};
function Ra(a,b,c){a.K=b;a.g=a.i=0;c&&((a.g=c.g)&&kb(a,lb,!1),(a.i=c.i)&&mb(a,lb,!1))}function mb(a,b,c){c&&a.i||(a.Ia=!a.f&&b[2]||a.o,a.wc=!a.f&&b[3]||a.u);if(c||void 0===c)a.Fb=b[2]||a.o,a.ba=b[3]||a.u}function kb(a,b,c){c&&a.g||(a.Ha=b[0]||a.w,a.vc=b[1]||a.m);if(c||void 0===c)a.Va=b[0]||a.w,a.Db=b[1]||a.m}function gb(a,b){b||(b=nb);kb(a,b,void 0);mb(a,b,void 0)}var nb=[],jb=[C.prototype.C,C.prototype.L,C.prototype.W,C.prototype.oa],lb=[C.prototype.v,C.prototype.G,C.prototype.O,C.prototype.aa];
if(La)var ib=[C.prototype.s,C.prototype.D,C.prototype.N,C.prototype.$],hb=[C.prototype.F,C.prototype.U,C.prototype.V,C.prototype.fa];
function ob(a,b){v.call(this,"CPU",a,ob);var c=a.cycles||b,d=a.multiplier||1;this.c={};this.c.wa=c;this.c.Sa=0;this.c.va=d;this.c.eb=Math.round(this.c.wa/1E4)/100;this.c.sa=this.c.eb*this.c.va;this.h.da=!1;this.h.vb=!1;this.h.sb=a.autoStart;this.h.ub=!1;this.h.Ma=!1;this.c.Qa=this.c.ua=0;this.c.Ra=a.csStart;this.c.Aa=a.csInterval;this.c.Ba=a.csStop;this.fa=this.hb.bind(this);B(this)}x(ob);var pb=["power","reset"];m=ob.prototype;
m.ha=function(a,b,c,d){this.u=a;this.l=b;this.K=d;for(b=0;b<pb.length;b++)(c=this.w[pb[b]])&&this.u.R(null,pb[b],c);this.W=(b=Oa(a,"Video"))&&Math.max(b.jc,b.wb)||60;this.F=Oa(a,"ChipSet");a=qb(a,"autoStart");null!=a&&(this.h.sb="true"==a?!0:"false"==a?!1:!!a);B(this)};m.reset=function(){this.c.Sa=0};m.save=function(){return null};m.restore=function(){return!1};
m.Z=function(a,b){if(!b){if(a&&this.restore){rb(this);if(!this.restore(a))return!1;sb(this)}else this.reset();this.X("No debugger detected")}tb(this);return!0};m.ea=function(a){return a?this.save():!0};function ub(a){(a.h.sb||void 0===a.w.run)&&a.hb(!0)}m.yb=function(){return 0};function sb(a){void 0===a.c.Ra&&(a.c.Ra=0);void 0===a.c.Aa&&(a.c.Aa=-1);void 0===a.c.Ba&&(a.c.Ba=-1);a.h.Ma=0<=a.c.Ra&&0<a.c.Aa;a.h.Ma&&(a.c.Qa=0,a.c.ua=a.c.Ra-a.O)}
m.R=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.w[b]=c;a=!0;break;case "run":this.w[b]=c;c.onclick=function(){var a;if(a=d.u)if(a=d.u,a.h.P)a=!0;else{var b=null,c,g=Ga(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.h.ra);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.h.P);c++);c==g.length&&(b=a);t("The "+b.type+" component ("+b.id+") is not "+(b.h.ra?"powered yet":"ready yet"+(b.Oa?" (waiting for notification)":""))+".");a=!1}a&&(d.h.da?vb(d,!0):d.hb(!0))};a=!0;
break;case "speed":this.w[b]=c;a=!0;break;case "setSpeed":this.w[b]=c,c.onclick=function(){wb(d,d.c.va<<1,!0)},c.textContent=this.c.sa.toFixed(2)+"Mhz",a=!0}return a};function xb(a,b,c){a.O+=b;c&&(a.N=a.a=0)}
function yb(a,b){var c=30;c<a.W&&(c=a.W);2>c&&(c=2);var d=1;b&&1<a.c.va&&a.c.la&&(d=a.c.la/a.c.eb);a.c.zb=Math.round(1E3/30);a.c.kc=Math.floor(a.c.wa/c*d);a.c.fb=Math.floor(a.c.wa/30*d);a.c.Bb=Math.floor(a.c.wa/a.W*d);a.c.Ab=Math.floor(a.c.wa/2*d);b||(a.c.Ea=a.c.fb,a.c.Da=a.c.Bb,a.c.Ca=a.c.Ab);a.c.gb=0}function zb(a){return a.O+a.L+a.N-a.a}function rb(a){a.c.la=0;a.O=a.L=a.N=a.a=0;sb(a);wb(a,1)}
function wb(a,b,c){if(void 0!==b){.8>a.c.la/a.c.sa&&(b=1);a.c.va=b;b=a.c.eb*a.c.va;if(a.c.sa!=b){a.c.sa=b;b=a.c.sa.toFixed(2)+"Mhz";var d=a.w.setSpeed;d&&(d.textContent=b);a.X("target speed: "+b)}c&&a.u&&Ab(a.u)}xb(a,a.L);a.L=0;a.c.ta=ga();a.c.ma=0;yb(a)}
m.hb=function(a){if(Ja(this,!0)){if(!this.h.da){wb(this);this.u&&this.u.start(this.c.ta,zb(this));this.h.da=!0;this.h.vb=!0;this.F&&this.F.start();var b=this.w.run;b&&(b.textContent="Halt");this.u&&(this.u.na(!0),a&&Ab(this.u,!0))}this.c.gb>=this.c.wa&&yb(this,!0);this.c.Fa=0;this.c.Pa=ga();this.c.ma&&(a=this.c.Pa-this.c.ma,a>this.c.zb&&(this.c.ta+=a,this.c.ta>this.c.Pa&&(this.c.ta=this.c.Pa)));try{do{this.Eb(this.h.Ma?1:this.c.kc);var c=this.N-this.a;this.L+=c;this.c.Fa+=c;xb(this,0,!0);a=c;this.h.Ma&&
(b=!1,this.c.Qa=this.c.Qa+this.yb()|0,this.c.ua-=a,0>=this.c.ua&&(this.c.ua+=this.c.Aa,b=!0),0<=this.c.Ba&&this.c.Ba<=zb(this)&&(this.c.Aa=this.c.Ba=-1,sb(this),vb(this),b=!0),b&&this.X(zb(this)+" cycles: checksum="+q(this.c.Qa)));this.c.Da-=c;0>=this.c.Da&&(this.c.Da+=this.c.Bb,this.u&&Bb(this.u,this.c.Sa++),this.c.Sa>this.W&&(this.c.Sa=0));this.c.Ca-=c;0>=this.c.Ca&&(this.c.Ca+=this.c.Ab,this.u&&this.u.na());this.c.Ea-=c;if(0>=this.c.Ea){this.c.Ea+=this.c.fb;break}}while(this.h.da)}catch(e){vb(this);
tb(this);this.u&&this.u.stop(ga(),zb(this));Ja(this,!1);c=e.stack||e.message;this.h.ka=!0;this.I(c);return}c=setTimeout;a=this.fa;this.c.ma=ga();b=this.c.zb;this.c.Fa&&(b=Math.round(b*this.c.Fa/this.c.fb));var b=b-(this.c.ma-this.c.Pa),d=this.c.ma-this.c.ta;d&&(this.c.la=Math.round(this.L/(10*d))/100,864E5<=d&&(this.O=0,wb(this)));if(0>b||this.c.la<this.c.sa)b=0;this.c.gb+=this.c.Fa;this.c.ma+=b;c(a,b)}else tb(this),this.u&&this.u.stop(ga(),zb(this))};m.Eb=function(){return 0};
function vb(a,b){a.h.ya&&(a.h.cb=!0);a.N-=a.a;a.a=0;xb(a,a.L);a.L=0;if(a.h.da){a.h.da=!1;a.F&&a.F.stop();var c=a.w.run;c&&(c.textContent="Run")}a.h.Na=b}function tb(a){a.u&&(Bb(a.u,-1),a.u.na(void 0))}function Db(a){this.U=+a.model||8080;ob.call(this,a,1E6);this.$=Eb;rb(this);this.h.Na=this.h.Zb=!1;this.ba=0;this.V=[];this.aa=0;Fb(this)}x(Db,ob);function Gb(a,b){a.V.push(b)}m=Db.prototype;m.reset=function(){this.h.da&&vb(this);Fb(this);rb(this);this.h.ka=!1;this.parent.reset.call(this)};
function Fb(a){a.b=0;a.f=0;a.A=0;a.g=0;a.B=0;a.i=0;a.j=0;a.v=0;D(a,a.aa);Hb(a,0);a.D=0}function Ib(a,b){a.aa=b;D(a,b)}m.yb=function(){var a=this.b+this.f+this.A+this.g+this.B+this.i+this.j|0;return a=a+this.v+this.o+Jb(this)|0};
m.save=function(){var a=new E(this);G(a,0,[this.b,this.f,this.A,this.g,this.B,this.i,this.j,this.v,this.o,Jb(this)]);G(a,1,[this.D,this.O,this.c.va]);for(var b=this.l,c=0,d=[],e=0;e<b.j;e++){var f=b.b[e];if(f.ca||f.tb){d[c++]=e;var h=c++;a:if(f=f.save()){for(var g=0,k=0,l=[];g<f.length;){for(var p=f[g],n=g+1;n<f.length&&f[n]===p;)n++;l[k++]=n-g;l[k++]=p;g=n}if(l.length<f.length){f=l;break a}}d[h]=f}}G(a,2,d);return a.data()};
m.restore=function(a){var b=a[0];this.b=b[0];this.f=b[1];this.A=b[2];this.g=b[3];this.B=b[4];this.i=b[5];this.j=b[6];this.v=b[7]&65535;D(this,b[8]);Hb(this,b[9]);b=a[1];this.D=b[0];this.O=b[1];wb(this,b[3]);a:{b=this.l;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.v){for(var f=0,h=Array(b.v),g=0;g<e.length-1;)for(var k=e[g++],l=e[g++];k--;)h[f++]=l;e=h}f=b.b[d];if(!f||!f.restore(e)){t("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
function C(a,b,c,d){this.id=db+=2;this.a=null;this.sa=a;this.Za=b;this.size=c||0;this.type=d||eb;this.f=d==fb;Ra(this);this.da=this.xb=!1;if(c)if(La)this.c=new ArrayBuffer(c),this.l=new DataView(this.c,0,c),this.b=new Uint8Array(this.c,0,c),this.j=new Uint16Array(this.c,0,c>>1),this.a=new Int32Array(this.c,0,c>>2),gb(this,cb?hb:ib);else{this.a=Array(c>>2);for(a=0;a<this.a.length;a++)this.a[a]=0;gb(this,jb)}else gb(this)}var eb=0,fb=2,Ua=["NONE","RAM","ROM","VID","H/W"],db=0;
C.prototype={constructor:C,parent:null,Ca:function(a){this.sa=a},save:function(){var a,b;if(La)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.l.getInt32(b<<2,!0);else a=this.a;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(La)for(b=0;b<a.length;b++)this.l.setInt32(b<<2,a[b],!0);else this.a=a;return this.da=!0}return!1},w:function(){return 255},o:function(){},m:function(a,b){return this.Ka(a++,b++)|this.Ka(a,b)<<8},u:function(a,b,c){this.La(a++,b&255,c++);this.La(a,b>>
8,c)},C:function(a){return this.a[a>>2]>>>((a&3)<<3)&255},J:function(a){var b=a>>2;a=(a&3)<<3;var c=this.a[b]>>a;return 24>a?c&65535:c&255|(this.a[b+1]&255)<<8},W:function(a,b){var c=a>>2,d=(a&3)<<3;this.a[c]=this.a[c]&~(255<<d)|b<<d;this.da=!0},ra:function(a,b){var c=a>>2,d=(a&3)<<3;24>d?this.a[c]=this.a[c]&~(65535<<d)|b<<d:(this.a[c]=this.a[c]&16777215|b<<24,c++,this.a[c]=this.a[c]&-256|b>>8);this.da=!0},v:function(a,b){return this.Ya(a,b)},G:function(a,b){return this.Hb(a,b)},L:function(a,b,c){this.f||
this.Jb(a,b,c)},aa:function(a,b,c){this.f||this.ba(a,b,c)},s:function(a){return this.b[a]},F:function(a){return this.b[a]},D:function(a){return this.l.getUint16(a,!0)},V:function(a){return a&1?this.b[a]|this.b[a+1]<<8:this.j[a>>1]},K:function(a,b){this.b[a]=b;this.da=!0},S:function(a,b){this.b[a]=b;this.da=!0},$:function(a,b){this.l.setUint16(a,b,!0);this.da=!0},ga:function(a,b){a&1?(this.b[a]=b,this.b[a+1]=b>>8):this.j[a>>1]=b;this.da=!0}};
function Ra(a,b,c){a.N=b;a.g=a.i=0;c&&((a.g=c.g)&&kb(a,lb,!1),(a.i=c.i)&&mb(a,lb,!1))}function mb(a,b,c){c&&a.i||(a.La=!a.f&&b[2]||a.o,a.Fc=!a.f&&b[3]||a.u);if(c||void 0===c)a.Jb=b[2]||a.o,a.ba=b[3]||a.u}function kb(a,b,c){c&&a.g||(a.Ka=b[0]||a.w,a.Ec=b[1]||a.m);if(c||void 0===c)a.Ya=b[0]||a.w,a.Hb=b[1]||a.m}function gb(a,b){b||(b=nb);kb(a,b,void 0);mb(a,b,void 0)}var nb=[],jb=[C.prototype.C,C.prototype.J,C.prototype.W,C.prototype.ra],lb=[C.prototype.v,C.prototype.G,C.prototype.L,C.prototype.aa];
if(La)var ib=[C.prototype.s,C.prototype.D,C.prototype.K,C.prototype.$],hb=[C.prototype.F,C.prototype.V,C.prototype.S,C.prototype.ga];
function ob(a,b){u.call(this,"CPU",a,ob);var c=a.cycles||b,d=a.multiplier||1;this.c={};this.c.za=c;this.c.Va=0;this.c.ya=d;this.c.hb=Math.round(this.c.za/1E4)/100;this.c.va=this.c.hb*this.c.ya;this.h.ea=!1;this.h.zb=!1;this.h.wb=a.autoStart;this.h.yb=!1;this.h.Pa=!1;this.c.Ta=this.c.xa=0;this.c.Ua=a.csStart;this.c.Da=a.csInterval;this.c.Ea=a.csStop;this.ga=this.kb.bind(this);B(this)}x(ob);var pb=["power","reset"];m=ob.prototype;
m.ia=function(a,b,c,d){this.u=a;this.l=b;this.N=d;for(b=0;b<pb.length;b++)(c=this.w[pb[b]])&&this.u.R(null,pb[b],c);this.W=(b=Oa(a,"Video"))&&Math.max(b.sc,b.Ab)||60;this.F=Oa(a,"ChipSet");a=qb(a,"autoStart");null!=a&&(this.h.wb="true"==a?!0:"false"==a?!1:!!a);B(this)};m.reset=function(){this.c.Va=0};m.save=function(){return null};m.restore=function(){return!1};
m.Z=function(a,b){if(!b){if(a&&this.restore){rb(this);if(!this.restore(a))return!1;sb(this)}else this.reset();this.X("No debugger detected")}tb(this);return!0};m.fa=function(a){return a?this.save():!0};function ub(a){(a.h.wb||void 0===a.w.run)&&a.kb(!0)}m.Cb=function(){return 0};function sb(a){void 0===a.c.Ua&&(a.c.Ua=0);void 0===a.c.Da&&(a.c.Da=-1);void 0===a.c.Ea&&(a.c.Ea=-1);a.h.Pa=0<=a.c.Ua&&0<a.c.Da;a.h.Pa&&(a.c.Ta=0,a.c.xa=a.c.Ua-a.L)}
m.R=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.w[b]=c;a=!0;break;case "run":this.w[b]=c;c.onclick=function(){var a;if(a=d.u)if(a=d.u,a.h.P)a=!0;else{var b=null,c,g=Ga(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.h.ua);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.h.P);c++);c==g.length&&(b=a);t("The "+b.type+" component ("+b.id+") is not "+(b.h.ua?"powered yet":"ready yet"+(b.Ra?" (waiting for notification)":""))+".");a=!1}a&&(d.h.ea?vb(d,!0):d.kb(!0))};a=!0;
break;case "speed":this.w[b]=c;a=!0;break;case "setSpeed":this.w[b]=c,c.onclick=function(){wb(d,d.c.ya<<1,!0)},c.textContent=this.c.va.toFixed(2)+"Mhz",a=!0}return a};function xb(a,b,c){a.L+=b;c&&(a.K=a.a=0)}
function yb(a,b){var c=30;c<a.W&&(c=a.W);2>c&&(c=2);var d=1;b&&1<a.c.ya&&a.c.ma&&(d=a.c.ma/a.c.hb);a.c.Db=Math.round(1E3/30);a.c.tc=Math.floor(a.c.za/c*d);a.c.ib=Math.floor(a.c.za/30*d);a.c.Fb=Math.floor(a.c.za/a.W*d);a.c.Eb=Math.floor(a.c.za/2*d);b||(a.c.Ha=a.c.ib,a.c.Ga=a.c.Fb,a.c.Fa=a.c.Eb);a.c.jb=0}function zb(a){return a.L+a.J+a.K-a.a}function rb(a){a.c.ma=0;a.L=a.J=a.K=a.a=0;sb(a);wb(a,1)}
function wb(a,b,c){if(void 0!==b){.8>a.c.ma/a.c.va&&(b=1);a.c.ya=b;b=a.c.hb*a.c.ya;if(a.c.va!=b){a.c.va=b;b=a.c.va.toFixed(2)+"Mhz";var d=a.w.setSpeed;d&&(d.textContent=b);a.X("target speed: "+b)}c&&a.u&&Ab(a.u)}xb(a,a.J);a.J=0;a.c.wa=ga();a.c.na=0;yb(a)}
m.kb=function(a){if(Ja(this,!0)){if(!this.h.ea){wb(this);this.u&&this.u.start(this.c.wa,zb(this));this.h.ea=!0;this.h.zb=!0;this.F&&this.F.start();var b=this.w.run;b&&(b.textContent="Halt");this.u&&(this.u.oa(!0),a&&Ab(this.u,!0))}this.c.jb>=this.c.za&&yb(this,!0);this.c.Ia=0;this.c.Sa=ga();this.c.na&&(a=this.c.Sa-this.c.na,a>this.c.Db&&(this.c.wa+=a,this.c.wa>this.c.Sa&&(this.c.wa=this.c.Sa)));try{do{this.Ib(this.h.Pa?1:this.c.tc);var c=this.K-this.a;this.J+=c;this.c.Ia+=c;xb(this,0,!0);a=c;this.h.Pa&&
(b=!1,this.c.Ta=this.c.Ta+this.Cb()|0,this.c.xa-=a,0>=this.c.xa&&(this.c.xa+=this.c.Da,b=!0),0<=this.c.Ea&&this.c.Ea<=zb(this)&&(this.c.Da=this.c.Ea=-1,sb(this),vb(this),b=!0),b&&this.X(zb(this)+" cycles: checksum="+q(this.c.Ta)));this.c.Ga-=c;0>=this.c.Ga&&(this.c.Ga+=this.c.Fb,this.u&&Bb(this.u,this.c.Va++),this.c.Va>this.W&&(this.c.Va=0));this.c.Fa-=c;0>=this.c.Fa&&(this.c.Fa+=this.c.Eb,this.u&&this.u.oa());this.c.Ha-=c;if(0>=this.c.Ha){this.c.Ha+=this.c.ib;break}}while(this.h.ea)}catch(e){vb(this);
tb(this);this.u&&this.u.stop(ga(),zb(this));Ja(this,!1);c=e.stack||e.message;this.h.la=!0;this.I(c);return}c=setTimeout;a=this.ga;this.c.na=ga();b=this.c.Db;this.c.Ia&&(b=Math.round(b*this.c.Ia/this.c.ib));var b=b-(this.c.na-this.c.Sa),d=this.c.na-this.c.wa;d&&(this.c.ma=Math.round(this.J/(10*d))/100,864E5<=d&&(this.L=0,wb(this)));if(0>b||this.c.ma<this.c.va)b=0;this.c.jb+=this.c.Ia;this.c.na+=b;c(a,b)}else tb(this),this.u&&this.u.stop(ga(),zb(this))};m.Ib=function(){return 0};
function vb(a,b){a.h.Ba&&(a.h.gb=!0);a.K-=a.a;a.a=0;xb(a,a.J);a.J=0;if(a.h.ea){a.h.ea=!1;a.F&&a.F.stop();var c=a.w.run;c&&(c.textContent="Run")}a.h.Qa=b}function tb(a){a.u&&(Bb(a.u,-1),a.u.oa(void 0))}function Cb(a){this.V=+a.model||8080;ob.call(this,a,1E6);this.$=Eb;rb(this);this.h.Qa=this.h.hc=!1;this.ba=0;this.S=[];this.aa=0;Fb(this)}x(Cb,ob);function Gb(a,b){a.S.push(b)}m=Cb.prototype;m.reset=function(){this.h.ea&&vb(this);Fb(this);rb(this);this.h.la=!1;this.parent.reset.call(this)};
function Fb(a){a.b=0;a.f=0;a.A=0;a.g=0;a.B=0;a.i=0;a.j=0;a.v=0;D(a,a.aa);Hb(a,0);a.D=0}function Ib(a,b){a.aa=b;D(a,b)}m.Cb=function(){var a=this.b+this.f+this.A+this.g+this.B+this.i+this.j|0;return a=a+this.v+this.o+Jb(this)|0};
m.save=function(){var a=new E(this);F(a,0,[this.b,this.f,this.A,this.g,this.B,this.i,this.j,this.v,this.o,Jb(this)]);F(a,1,[this.D,this.L,this.c.ya]);for(var b=this.l,c=0,d=[],e=0;e<b.j;e++){var f=b.b[e];if(f.da||f.xb){d[c++]=e;var h=c++;a:if(f=f.save()){for(var g=0,k=0,l=[];g<f.length;){for(var p=f[g],n=g+1;n<f.length&&f[n]===p;)n++;l[k++]=n-g;l[k++]=p;g=n}if(l.length<f.length){f=l;break a}}d[h]=f}}F(a,2,d);return a.data()};
m.restore=function(a){var b=a[0];this.b=b[0];this.f=b[1];this.A=b[2];this.g=b[3];this.B=b[4];this.i=b[5];this.j=b[6];this.v=b[7]&65535;D(this,b[8]);Hb(this,b[9]);b=a[1];this.D=b[0];this.L=b[1];wb(this,b[3]);a:{b=this.l;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.v){for(var f=0,h=Array(b.v),g=0;g<e.length-1;)for(var k=e[g++],l=e[g++];k--;)h[f++]=l;e=h}f=b.b[d];if(!f||!f.restore(e)){t("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
m.R=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "BC":case "D":case "E":case "DE":case "H":case "L":case "HL":case "SP":case "PC":case "PS":case "IF":case "SF":case "ZF":case "AF":case "PF":case "CF":this.w[b]=c;this.ba++;d=!0;break;default:d=this.parent.R.call(this,a,b,c)}return d};function Kb(a){return a.f<<8|a.A}function Lb(a,b){a.f=b>>8&255;a.A=b&255}function Mb(a){return a.g<<8|a.B}function Nb(a,b){a.g=b>>8&255;a.B=b&255}function I(a){return a.i<<8|a.j}
function K(a,b){a.i=b>>8&255;a.j=b&255}function D(a,b){a.o=b&65535}function L(a){return a.m&256?1:0}function N(a,b){a.m=a.m&255|b}function Ob(a){return Ma[a.s&255]?4:0}function Jb(a){return a.G&-214|(a.s&128?128:0)|(a.m&255?0:64)|((a.s^a.C)&16?16:0)|Ob(a)|L(a)}function Hb(a,b){a.m=a.s=a.C=0;b&1&&(a.m|=256);b&4||(a.s|=1);b&16&&(a.C|=16);b&64||(a.m|=255);b&128&&(a.s^=192);a.G=a.G&-726|b&512|2}function Pb(a,b){a.C=a.b^b;return a.s=(a.m=a.b+b)&255}
function Qb(a,b){a.C=a.b^b;return a.s=(a.m=a.b+b+(a.m&256?1:0))&255}function Rb(a,b){a.m=a.s=a.C=a.b&b;(a.b|b)&8&&(a.C^=16);return a.m}function Sb(a,b){a.C=b^255;b=a.s=b+255&255;a.m=a.m&-256|b;return b}function Tb(a,b){a.C=b;b=a.s=b+1&255;a.m=a.m&-256|b;return b}function Ub(a,b){return a.s=a.m=a.C=a.b|b}function O(a,b){b^=255;a.C=a.b^b;return a.s=(a.m=a.b+b+1^256)&255}function Vb(a,b){b^=255;a.C=a.b^b;return a.s=(a.m=a.b+b+(a.m&256?0:1)^256)&255}function Wb(a,b){return a.s=a.m=a.C=a.b^b}m.H=function(a){return this.l.H(a)};
m.S=function(a,b){this.l.S(a,b)};function P(a){var b=a.H(a.o);D(a,a.o+1);return b}function Q(a){var b=Wa(a.l,a.o);D(a,a.o+2);return b}function R(a){var b=Wa(a.l,a.v);a.v=a.v+2&65535;return b}function S(a,b){a.v=a.v-2&65535;Ya(a.l,a.v,b)}function T(a,b,c,d){d=d||2;a.w[b]&&(void 0===c&&(a.h.ka=!0,a.I("Value for "+b+" is invalid"),vb(a)),c=!a.h.da||a.h.ub?q(c,d):"--------".substr(0,d),a.w[b].textContent!=c&&(a.w[b].textContent=c))}
m.na=function(a){this.ba&&(a||!this.h.da||this.h.ub)&&(T(this,"A",this.b),T(this,"B",this.f),T(this,"C",this.A),T(this,"BC",Kb(this),4),T(this,"D",this.g),T(this,"E",this.B),T(this,"DE",Mb(this),4),T(this,"H",this.i),T(this,"L",this.j),T(this,"HL",I(this),4),T(this,"SP",this.v,4),T(this,"PC",this.o,4),a=Jb(this),T(this,"PS",a,4),T(this,"IF",a&512?1:0,1),T(this,"SF",a&128?1:0,1),T(this,"ZF",a&64?1:0,1),T(this,"AF",a&16?1:0,1),T(this,"PF",a&4?1:0,1),T(this,"CF",a&1?1:0,1));if(a=this.w.speed)a.textContent=
this.h.da&&this.c.la?this.c.la.toFixed(2)+"Mhz":"Stopped"};m.Eb=function(a){this.h.Na=!0;this.h.Zb=!1;this.h.vb=!1;this.N=this.a=a;do{if(a=this.D)this.D&8&&this.G&512?(a=199|(this.D&7)<<3,this.D&=-16,this.G&=-513,this.$[a].call(this),a=!0):a=!1,a=!a;if(a&&this.D&16){this.a=0;break}this.$[P(this)].call(this)}while(0<this.a);return this.h.Na?this.N-this.a:void 0===this.h.Na?0:-1};ua(function(){for(var a=A(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new Db(d);Ia(d,c)}});
m.T=function(a,b){this.l.T(a,b)};function P(a){var b=a.H(a.o);D(a,a.o+1);return b}function Q(a){var b=Wa(a.l,a.o);D(a,a.o+2);return b}function R(a){var b=Wa(a.l,a.v);a.v=a.v+2&65535;return b}function S(a,b){a.v=a.v-2&65535;Ya(a.l,a.v,b)}function T(a,b,c,d){d=d||2;a.w[b]&&(void 0===c&&(a.h.la=!0,a.I("Value for "+b+" is invalid"),vb(a)),c=!a.h.ea||a.h.yb?q(c,d):"--------".substr(0,d),a.w[b].textContent!=c&&(a.w[b].textContent=c))}
m.oa=function(a){this.ba&&(a||!this.h.ea||this.h.yb)&&(T(this,"A",this.b),T(this,"B",this.f),T(this,"C",this.A),T(this,"BC",Kb(this),4),T(this,"D",this.g),T(this,"E",this.B),T(this,"DE",Mb(this),4),T(this,"H",this.i),T(this,"L",this.j),T(this,"HL",I(this),4),T(this,"SP",this.v,4),T(this,"PC",this.o,4),a=Jb(this),T(this,"PS",a,4),T(this,"IF",a&512?1:0,1),T(this,"SF",a&128?1:0,1),T(this,"ZF",a&64?1:0,1),T(this,"AF",a&16?1:0,1),T(this,"PF",a&4?1:0,1),T(this,"CF",a&1?1:0,1));if(a=this.w.speed)a.textContent=
this.h.ea&&this.c.ma?this.c.ma.toFixed(2)+"Mhz":"Stopped"};m.Ib=function(a){this.h.Qa=!0;this.h.hc=!1;this.h.zb=!1;this.K=this.a=a;do{if(a=this.D)this.D&8&&this.G&512?(a=199|(this.D&7)<<3,this.D&=-16,this.G&=-513,this.$[a].call(this),a=!0):a=!1,a=!a;if(a&&this.D&16){this.a=0;break}this.$[P(this)].call(this)}while(0<this.a);return this.h.Qa?this.K-this.a:void 0===this.h.Qa?0:-1};ua(function(){for(var a=z(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new Cb(d);Ia(d,c)}});
function Xb(){this.a-=4}function Yb(){D(this,Q(this));this.a-=10}function Zb(){D(this,R(this));this.a-=10}function $b(){var a=Q(this);S(this,this.o);D(this,a);this.a-=17}
var Eb=[Xb,function(){Lb(this,Q(this));this.a-=10},function(){this.S(Kb(this),this.b);this.a-=7},function(){Lb(this,Kb(this)+1);this.a-=5},function(){this.f=Tb(this,this.f);this.a-=5},function(){this.f=Sb(this,this.f);this.a-=5},function(){this.f=P(this);this.a-=7},function(){var a=this.b<<1;this.b=a&255|a>>8;N(this,a&256);this.a-=4},Xb,function(){var a;K(this,a=I(this)+Kb(this));N(this,a>>8&256);this.a-=10},function(){this.b=this.H(Kb(this));this.a-=7},function(){Lb(this,Kb(this)-1);this.a-=5},function(){this.A=
Tb(this,this.A);this.a-=5},function(){this.A=Sb(this,this.A);this.a-=5},function(){this.A=P(this);this.a-=7},function(){var a=this.b<<8&256;this.b=(a|this.b)>>1;N(this,a);this.a-=4},Xb,function(){Nb(this,Q(this));this.a-=10},function(){this.S(Mb(this),this.b);this.a-=7},function(){Nb(this,Mb(this)+1);this.a-=5},function(){this.g=Tb(this,this.g);this.a-=5},function(){this.g=Sb(this,this.g);this.a-=5},function(){this.g=P(this);this.a-=7},function(){var a=this.b<<1;this.b=a&255|L(this);N(this,a&256);
var Eb=[Xb,function(){Lb(this,Q(this));this.a-=10},function(){this.T(Kb(this),this.b);this.a-=7},function(){Lb(this,Kb(this)+1);this.a-=5},function(){this.f=Tb(this,this.f);this.a-=5},function(){this.f=Sb(this,this.f);this.a-=5},function(){this.f=P(this);this.a-=7},function(){var a=this.b<<1;this.b=a&255|a>>8;N(this,a&256);this.a-=4},Xb,function(){var a;K(this,a=I(this)+Kb(this));N(this,a>>8&256);this.a-=10},function(){this.b=this.H(Kb(this));this.a-=7},function(){Lb(this,Kb(this)-1);this.a-=5},function(){this.A=
Tb(this,this.A);this.a-=5},function(){this.A=Sb(this,this.A);this.a-=5},function(){this.A=P(this);this.a-=7},function(){var a=this.b<<8&256;this.b=(a|this.b)>>1;N(this,a);this.a-=4},Xb,function(){Nb(this,Q(this));this.a-=10},function(){this.T(Mb(this),this.b);this.a-=7},function(){Nb(this,Mb(this)+1);this.a-=5},function(){this.g=Tb(this,this.g);this.a-=5},function(){this.g=Sb(this,this.g);this.a-=5},function(){this.g=P(this);this.a-=7},function(){var a=this.b<<1;this.b=a&255|L(this);N(this,a&256);
this.a-=4},Xb,function(){var a;K(this,a=I(this)+Mb(this));N(this,a>>8&256);this.a-=10},function(){this.b=this.H(Mb(this));this.a-=7},function(){Nb(this,Mb(this)-1);this.a-=5},function(){this.B=Tb(this,this.B);this.a-=5},function(){this.B=Sb(this,this.B);this.a-=5},function(){this.B=P(this);this.a-=7},function(){var a=this.b<<8;this.b=(L(this)<<8|this.b)>>1;N(this,a&256);this.a-=4},Xb,function(){K(this,Q(this));this.a-=10},function(){var a=Q(this);Ya(this.l,a,I(this));this.a-=16},function(){K(this,
I(this)+1);this.a-=5},function(){this.i=Tb(this,this.i);this.a-=5},function(){this.i=Sb(this,this.i);this.a-=5},function(){this.i=P(this);this.a-=7},function(){var a=0,b=L(this);if((this.s^this.C)&16||9<(this.b&15))a|=6;if(b||154<=this.b)a|=96,b=1;this.b=Pb(this,a);N(this,b?256:0);this.a-=4},Xb,function(){var a;K(this,a=I(this)+I(this));N(this,a>>8&256);this.a-=10},function(){var a;a=Q(this);a=Wa(this.l,a);K(this,a);this.a-=16},function(){K(this,I(this)-1);this.a-=5},function(){this.j=Tb(this,this.j);
this.a-=5},function(){this.j=Sb(this,this.j);this.a-=5},function(){this.j=P(this);this.a-=7},function(){this.b=~this.b&255;this.a-=4},Xb,function(){this.v=Q(this)&65535;this.a-=10},function(){this.S(Q(this),this.b);this.a-=13},function(){this.v=this.v+1&65535;this.a-=5},function(){var a=I(this);this.S(a,Tb(this,this.H(a)));this.a-=10},function(){var a=I(this);this.S(a,Sb(this,this.H(a)));this.a-=10},function(){this.S(I(this),P(this));this.a-=10},function(){this.m|=256;this.a-=4},Xb,function(){var a;
this.a-=5},function(){this.j=Sb(this,this.j);this.a-=5},function(){this.j=P(this);this.a-=7},function(){this.b=~this.b&255;this.a-=4},Xb,function(){this.v=Q(this)&65535;this.a-=10},function(){this.T(Q(this),this.b);this.a-=13},function(){this.v=this.v+1&65535;this.a-=5},function(){var a=I(this);this.T(a,Tb(this,this.H(a)));this.a-=10},function(){var a=I(this);this.T(a,Sb(this,this.H(a)));this.a-=10},function(){this.T(I(this),P(this));this.a-=10},function(){this.m|=256;this.a-=4},Xb,function(){var a;
K(this,a=I(this)+this.v);N(this,a>>8&256);this.a-=10},function(){this.b=this.H(Q(this));this.a-=13},function(){this.v=this.v-1&65535;this.a-=5},function(){this.b=Tb(this,this.b);this.a-=5},function(){this.b=Sb(this,this.b);this.a-=5},function(){this.b=P(this);this.a-=7},function(){N(this,L(this)?0:256);this.a-=4},function(){this.a-=5},function(){this.f=this.A;this.a-=5},function(){this.f=this.g;this.a-=5},function(){this.f=this.B;this.a-=5},function(){this.f=this.i;this.a-=5},function(){this.f=this.j;
this.a-=5},function(){this.f=this.H(I(this));this.a-=7},function(){this.f=this.b;this.a-=5},function(){this.A=this.f;this.a-=5},function(){this.a-=5},function(){this.A=this.g;this.a-=5},function(){this.A=this.B;this.a-=5},function(){this.A=this.i;this.a-=5},function(){this.A=this.j;this.a-=5},function(){this.A=this.H(I(this));this.a-=7},function(){this.A=this.b;this.a-=5},function(){this.g=this.f;this.a-=5},function(){this.g=this.A;this.a-=5},function(){this.a-=5},function(){this.g=this.B;this.a-=
5},function(){this.g=this.i;this.a-=5},function(){this.g=this.j;this.a-=5},function(){this.g=this.H(I(this));this.a-=7},function(){this.g=this.b;this.a-=5},function(){this.B=this.f;this.a-=5},function(){this.B=this.A;this.a-=5},function(){this.B=this.g;this.a-=5},function(){this.a-=5},function(){this.B=this.i;this.a-=5},function(){this.B=this.j;this.a-=5},function(){this.B=this.H(I(this));this.a-=7},function(){this.B=this.b;this.a-=5},function(){this.i=this.f;this.a-=5},function(){this.i=this.A;this.a-=
5},function(){this.i=this.g;this.a-=5},function(){this.i=this.B;this.a-=5},function(){this.a-=5},function(){this.i=this.j;this.a-=5},function(){this.i=this.H(I(this));this.a-=7},function(){this.i=this.b;this.a-=5},function(){this.j=this.f;this.a-=5},function(){this.j=this.A;this.a-=5},function(){this.j=this.g;this.a-=5},function(){this.j=this.B;this.a-=5},function(){this.j=this.i;this.a-=5},function(){this.a-=5},function(){this.j=this.H(I(this));this.a-=7},function(){this.j=this.b;this.a-=5},function(){this.S(I(this),
this.f);this.a-=7},function(){this.S(I(this),this.A);this.a-=7},function(){this.S(I(this),this.g);this.a-=7},function(){this.S(I(this),this.B);this.a-=7},function(){this.S(I(this),this.i);this.a-=7},function(){this.S(I(this),this.j);this.a-=7},function(){var a=this.o-1;if(this.V.length)for(var b=0;b<this.V.length;b++)if(this.V[b](a))return;this.D|=16;this.a-=7;this.G&512||vb(this)},function(){this.S(I(this),this.b);this.a-=7},function(){this.b=this.f;this.a-=5},function(){this.b=this.A;this.a-=5},
5},function(){this.i=this.g;this.a-=5},function(){this.i=this.B;this.a-=5},function(){this.a-=5},function(){this.i=this.j;this.a-=5},function(){this.i=this.H(I(this));this.a-=7},function(){this.i=this.b;this.a-=5},function(){this.j=this.f;this.a-=5},function(){this.j=this.A;this.a-=5},function(){this.j=this.g;this.a-=5},function(){this.j=this.B;this.a-=5},function(){this.j=this.i;this.a-=5},function(){this.a-=5},function(){this.j=this.H(I(this));this.a-=7},function(){this.j=this.b;this.a-=5},function(){this.T(I(this),
this.f);this.a-=7},function(){this.T(I(this),this.A);this.a-=7},function(){this.T(I(this),this.g);this.a-=7},function(){this.T(I(this),this.B);this.a-=7},function(){this.T(I(this),this.i);this.a-=7},function(){this.T(I(this),this.j);this.a-=7},function(){var a=this.o-1;if(this.S.length)for(var b=0;b<this.S.length;b++)if(this.S[b](a))return;this.D|=16;this.a-=7;this.G&512||vb(this)},function(){this.T(I(this),this.b);this.a-=7},function(){this.b=this.f;this.a-=5},function(){this.b=this.A;this.a-=5},
function(){this.b=this.g;this.a-=5},function(){this.b=this.B;this.a-=5},function(){this.b=this.i;this.a-=5},function(){this.b=this.j;this.a-=5},function(){this.b=this.H(I(this));this.a-=7},function(){this.a-=5},function(){this.b=Pb(this,this.f);this.a-=4},function(){this.b=Pb(this,this.A);this.a-=4},function(){this.b=Pb(this,this.g);this.a-=4},function(){this.b=Pb(this,this.B);this.a-=4},function(){this.b=Pb(this,this.i);this.a-=4},function(){this.b=Pb(this,this.j);this.a-=4},function(){this.b=Pb(this,
this.H(I(this)));this.a-=7},function(){this.b=Pb(this,this.b);this.a-=4},function(){this.b=Qb(this,this.f);this.a-=4},function(){this.b=Qb(this,this.A);this.a-=4},function(){this.b=Qb(this,this.g);this.a-=4},function(){this.b=Qb(this,this.B);this.a-=4},function(){this.b=Qb(this,this.i);this.a-=4},function(){this.b=Qb(this,this.j);this.a-=4},function(){this.b=Qb(this,this.H(I(this)));this.a-=7},function(){this.b=Qb(this,this.b);this.a-=4},function(){this.b=O(this,this.f);this.a-=4},function(){this.b=
O(this,this.A);this.a-=4},function(){this.b=O(this,this.g);this.a-=4},function(){this.b=O(this,this.B);this.a-=4},function(){this.b=O(this,this.i);this.a-=4},function(){this.b=O(this,this.j);this.a-=4},function(){this.b=O(this,this.H(I(this)));this.a-=7},function(){this.b=O(this,this.b);this.a-=4},function(){this.b=Vb(this,this.f);this.a-=4},function(){this.b=Vb(this,this.A);this.a-=4},function(){this.b=Vb(this,this.g);this.a-=4},function(){this.b=Vb(this,this.B);this.a-=4},function(){this.b=Vb(this,
@ -73,79 +73,81 @@ f=0;0<d;){var h=b.m[a],g=b.F[a]||1,k=1==g?255:2==g?65535:-1,l=k;void 0!==h&&h[0]
function(){var a=R(this);S(this,I(this));K(this,a);this.a-=18},function(){var a=Q(this);Ob(this)||(S(this,this.o),D(this,a),this.a-=6);this.a-=11},function(){S(this,I(this));this.a-=11},function(){this.b=Rb(this,P(this));this.a-=7},function(){S(this,this.o);D(this,32);this.a-=11},function(){Ob(this)&&(D(this,R(this)),this.a-=6);this.a-=5},function(){D(this,I(this));this.a-=5},function(){var a=Q(this);Ob(this)&&D(this,a);this.a-=10},function(){var a=I(this);K(this,Mb(this));Nb(this,a);this.a-=5},function(){var a=
Q(this);Ob(this)&&(S(this,this.o),D(this,a),this.a-=6);this.a-=11},$b,function(){this.b=Wb(this,P(this));this.a-=7},function(){S(this,this.o);D(this,40);this.a-=11},function(){this.s&128||(D(this,R(this)),this.a-=6);this.a-=5},function(){var a=R(this);Hb(this,a&255|this.G&-256);this.b=a>>8;this.a-=10},function(){var a=Q(this);this.s&128||D(this,a);this.a-=10},function(){this.G&=-513;this.a-=4},function(){var a=Q(this);this.s&128||(S(this,this.o),D(this,a),this.a-=6);this.a-=11},function(){S(this,
Jb(this)&255|this.b<<8);this.a-=11},function(){this.b=Ub(this,P(this));this.a-=7},function(){S(this,this.o);D(this,48);this.a-=11},function(){this.s&128&&(D(this,R(this)),this.a-=6);this.a-=5},function(){this.v=I(this)&65535;this.a-=5},function(){var a=Q(this);this.s&128&&D(this,a);this.a-=10},function(){this.G|=512;this.a-=4},function(){var a=Q(this);this.s&128&&(S(this,this.o),D(this,a),this.a-=6);this.a-=11},$b,function(){O(this,P(this));this.a-=7},function(){S(this,this.o);D(this,56);this.a-=
11}];function U(a){v.call(this,"ChipSet",a,U);var b=a.model;b&&!ac[b]&&t("Unrecognized ChipSet model: "+b);this.b=ac[b]||W;this.U=this.b.Y;a.sound&&(this.j=null,window&&(this.j=window.AudioContext||window.webkitAudioContext),this.j&&new this.j);B(this)}x(U);
var W={Y:1978.1,Xb:{T:0,Ac:1,Ec:16,Lc:32,Vc:64,Uc:128,xa:14},ja:{T:1,Hb:1,Wb:2,Sb:4,Tb:16,Ub:32,Vb:64,xa:8},Yb:{T:2,zc:3,cd:4,Bc:8,Qc:16,Rc:32,Sc:64,Cc:128,xa:0},Yc:{T:3},Wc:{T:2,Mc:7},$c:{T:3,dd:1,Zc:2,Tc:4,Jc:8,Dc:16,xc:32},Xc:{T:4},ad:{T:5,Fc:1,Gc:2,Hc:4,Ic:8,ed:16}},X={Y:100,Ja:{T:66,fd:1,Pb:2,Qb:4,Pc:8,Nc:16,Oc:32,jb:64,Kc:128},Gb:{T:66,INIT:0},Rb:{T:98,INIT:0},Jb:{T:162,INIT:0},Ib:{T:194,INIT:0}},ac={SI1978:W,VT100:X};U.prototype.R=function(){return!1};
U.prototype.ha=function(a,b,c,d){this.l=b;this.a=c;this.K=d;this.u=a;Za(b,this,this.b.Ta);$a(b,this,this.b.Ua)};U.prototype.Z=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};U.prototype.ea=function(a){return a?this.save():!0};W.za=[[W.Xb.xa,W.ja.xa,W.Yb.xa,0,0,0,0]];X.za=[[X.Gb.INIT,X.Rb.INIT,X.Ja.Pb|X.Ja.Qb,X.Jb.INIT,X.Ib.INIT]];m=U.prototype;m.reset=function(){this.restore(this.b.za)||this.I("reset error")};
m.save=function(){var a=new E(this);switch(this.U){case W.Y:G(a,0,[this.D,this.c,this.G,this.f,this.i,this.F,this.C]);break;case X.Y:G(a,0,[this.m,this.v,this.g,this.s,this.o])}return a.data()};m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.U){case W.Y:return this.D=b[0],this.c=b[1],this.G=b[2],this.f=b[3],this.i=b[4],this.F=b[5],this.C=b[6],!0;case X.Y:return this.m=b[0],this.v=b[1],this.g=b[2],this.s=b[3],this.o=b[4],!0}return!1};m.start=function(){};m.stop=function(){};
function bc(a,b,c){a.c&=~b;c&&(a.c|=b)}m.cc=function(){return this.D};m.dc=function(){return this.c};m.ec=function(){return this.G};m.bc=function(){return this.f>>8-this.i&255};m.mc=function(a,b){this.i=b};m.oc=function(a,b){this.F=b};m.nc=function(a,b){this.f=b<<8|this.f>>8};m.pc=function(a,b){this.C=b};m.qc=function(){};m.fc=function(){return this.g=this.g&~X.Ja.jb|((zb(this.a)&64)<<1?X.Ja.jb:0)};m.rc=function(a,b){this.m=b};m.uc=function(a,b){this.v=b};m.tc=function(a,b){this.s=b};
m.sc=function(a,b){this.o=b};W.Ta={0:U.prototype.cc,1:U.prototype.dc,2:U.prototype.ec,3:U.prototype.bc};W.Ua={2:U.prototype.mc,3:U.prototype.oc,4:U.prototype.nc,5:U.prototype.pc,6:U.prototype.qc};X.Ta={66:U.prototype.fc};X.Ua={66:U.prototype.rc,98:U.prototype.uc,162:U.prototype.tc,194:U.prototype.sc};ua(function(){for(var a=A(document,"pc8080","chipset"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new U(d);Ia(d,c)}});
function cc(a){v.call(this,"ROM",a,cc);this.b=null;this.j=a.addr;this.c=a.size;this.m=a.writable;this.f=a.alias;this.g=a.file;this.o=ba(this.g);if(this.g){a=this.g;var b=ca(this.o);"json"!=b&&"hex"!=b&&(a=ia()+"/api/v1/dump?file="+this.g+"&format=bytes&decimal=true");var c=this;r(a,null,!0,function(a,b,f){dc(c,a,b,f)})}}x(cc);var ec=[0,5];cc.prototype.ha=function(a,b,c,d){this.l=b;this.a=c;this.K=d;fc(this)};
cc.prototype.Z=function(){this.i&&(this.K&&this.K.a(this.id,this.j,this.c,this.i),delete this.i);return!0};cc.prototype.ea=function(){return!0};
function dc(a,b,c,d){if(d)a.I("Unable to load system ROM (error "+d+": "+b+")");else{Fa(a.ab,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.b=f;else if(h)for(a.b=Array(4*h.length),d=c=0;c<h.length;c++)a.b[d++]=h[c]&255,a.b[d++]=h[c]>>8&255,a.b[d++]=h[c]>>16&255,a.b[d++]=h[c]>>24&255;else a.b=e;a.i=e.symbols;if(!a.b.length){t("Empty ROM: "+b);return}if(1==a.b.length){t(a.b[0]);return}}catch(g){a.I("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
" ").replace(/ +$/,"").split(" "),a.b=Array(b.length),e=0;e<b.length;e++)a.b[e]=aa(b[e]);fc(a)}}
function fc(a){if(!Ka(a))if(!a.g)B(a);else if(a.b&&a.l){a.c||(a.c=a.b.length);if(a.b.length!=a.c){var b="ROM size (0x"+q(a.b.length)+") does not match specified size ("+("0x"+q(a.c))+")";a.h.ka=!0;a.I(b)}else if(gc(a,a.j)){b=[];"number"==typeof a.f?b.push(a.f):null!=a.f&&a.f.length&&(b=a.f);for(var c=0;c<b.length;c++){for(var d=a,e=b[c],f=d.l,h=d.c,g=[],k=d.j>>>f.c;0<h&&k<f.b.length;)g.push(f.b[k++]),h-=f.l;f=d.l;d=d.c;h=0;for(e>>>=f.c;0<d&&e<f.b.length;){k=g[h++];if(!k)break;f.b[e++]=k;d-=f.l}}delete a.b}B(a)}}
function gc(a,b){if(Sa(a.l,b,a.c,a.m?1:fb)){var c;for(c=0;c<a.b.length;c++)Xa(a.l,b+c,a.b[c]);if(a.m&&256==b){for(c=0;c<ec.length;c++)Xa(a.l,ec[c],118);Gb(a.a,function(a){return function(b){if(0<=ec.indexOf(b)){var c=!1,h=a.a,g=a.K;if(5==b)switch(c=!0,h.A){case 2:hc(a,String.fromCharCode(h.B));break;case 9:for(var k=Mb(h),l="",p=255;p--;){var n=a.a.H(k++);if(36==n)break;l+=String.fromCharCode(n)}hc(a,l);break;default:c=!1}c?Zb.call(h):g&&(a.X("\nCP/M vector 0x"+q(b,4)),D(h,b),vb(g));b=!0}else b=!1;
return b}}(a));Ib(a.a,b)}return!0}return!1}function hc(a,b){b=b.replace(/\r/g,"");a.ga&&(a.ga.value+=b,a.ga.scrollTop=a.ga.scrollHeight)}ua(function(){for(var a=A(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new cc(d);Ia(d,c)}});function ic(a){v.call(this,"RAM",a,ic);this.f=a.addr;this.c=a.size;this.b=!1}x(ic);m=ic.prototype;m.ha=function(a,b,c,d){this.l=b;this.a=c;this.K=d;B(this)};m.Z=function(a,b){b||this.reset();return!0};m.ea=function(a){return a?this.save():!0};
m.reset=function(){!this.b&&this.c&&Sa(this.l,this.f,this.c,1)&&(this.b=!0);this.b||t("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};ua(function(){for(var a=A(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new ic(d);Ia(d,c)}});function Y(a){v.call(this,"Keyboard",a,Y);this.reset();B(this)}x(Y);
var Z={ia:{T:130,Nb:1,Mb:2,Lb:4,Kb:8,Ob:16,kb:32,bd:64,yc:128}},jc={"1p":49,"2p":50,coin:51,left:37,right:39,fire:32},kc={65:37,68:39,76:32},lc={l4:Z.ia.Nb,l3:Z.ia.Mb,l2:Z.ia.Lb,l1:Z.ia.Kb,locked:Z.ia.Ob,online:Z.ia.kb,local:~Z.ia.kb};
Y.prototype.R=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.w[e]){if("led"==a&&lc[b])return this.w[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return mc(d,a,!0)},c.onkeyup=function(a){return mc(d,a,!1)},!0;default:if(void 0!==jc[b])return this.w[e]=c,a=function(a,b){return function(){nc(a,b,!0)}}(this,b),b=function(a,b){return function(){nc(a,b,!1)}}(this,b),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend=b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};
Y.prototype.ha=function(a,b,c,d){this.K=d;this.F=Oa(a,"ChipSet");this.U=this.F.U;switch(this.U){case X.Y:this.b=Z}this.b&&(Za(b,this,this.b.Ta),$a(b,this,this.b.Ua))};Y.prototype.Z=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};Y.prototype.ea=function(a){return a?this.save():!0};Z.za=[[0]];Y.prototype.reset=function(){this.l={};this.a={};this.b&&!this.restore(this.b.za)&&this.I("reset error")};
Y.prototype.save=function(){var a=new E(this);switch(this.U){case X.Y:G(a,0,[this.c])}return a.data()};Y.prototype.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.U){case W.Y:return!0;case X.Y:return this.c=b[0],oc(this),!0}return!1};function oc(a){for(var b in lc){var c=a.w["led-"+b];if(c){var d=lc[b],e=!!(a.c&d);d&d-1&&(e=!(a.c&~d));c.style.backgroundColor=e?"#ff0000":"#000000"}}}
function mc(a,b,c){var d=!0,e;a:{e=b.keyCode;e=kc[e]||e;for(var f in jc)if(jc[f]===e){e=f;break a}e=null}e&&(d=nc(a,e,c),b.preventDefault());return d}
function nc(a,b,c){if(c)a.l[b]=Date.now(),delete a.a[b];else{var d=a.l[b];if(d&&100>Date.now()-d)return a.a[b]=d,pc(a),!0;delete a.l[b]}if(a.F)switch(b){case "1p":bc(a.F,W.ja.Sb,c);break;case "2p":bc(a.F,W.ja.Wb,c);break;case "coin":bc(a.F,W.ja.Hb,c);break;case "left":bc(a.F,W.ja.Ub,c);break;case "right":bc(a.F,W.ja.Vb,c);break;case "fire":bc(a.F,W.ja.Tb,c)}return!0}
function pc(a){for(var b=-1,c=Object.keys(a.a),d=0;d<c.length;d++){var e=c[d],f=100-(Date.now()-a.a[e]);if(0<f){if(0>b||b>f)b=f}else delete a.a[e],nc(a,e,!1)}0<=b&&setTimeout(function(){pc(a)},b)}Y.prototype.f=function(a,b){this.c=b;oc(this)};Z.Ta={};Z.Ua={130:Y.prototype.f};ua(function(){for(var a=A(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new Y(d);Ia(d,c)}});
function qc(a,b,c,d,e){var f=this;this.nb=oa("Gecko/");var h=["","moz","ms","webkit"];v.call(this,"Video",a,qc);this.v=a.screenWidth;this.o=a.screenHeight;this.$=a.bufferAddr;this.hc=a.bufferRAM;var g=a.bufferFormat;this.s=g&&rc[g.toLowerCase()]||sc;this.Ka=a.bufferCols;this.G=a.bufferRows;this.$b=this.M=a.cellWidth||1;this.J=a.cellHeight||1;this.Xa=null;this.oa=a.bufferBits||1;this.ic=a.bufferLeft||0;if(this.c=a.bufferRotate)this.c=this.c%360,0<this.c&&(this.c-=360),-90!=this.c&&(this.I("unsupported buffer rotation: "+
this.c),this.c=0);this.wb=a.interruptRate;this.jc=a.refreshRate||60;this.m=b;this.f=c;this.ba=(this.lc=d)||b||null;this.ac=this.v;this.gc=this.o;this.ib=this.v/this.Ka|0;this.mb=this.o/this.G|0;1<this.J&&this.G++;b=a.smoothing;(c=za.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)if(d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.f[d]){this.f[d]=b;break}if(this.g=a.screenRotate)this.g=this.g%360,0<this.g&&(this.g-=360),-90!=this.g?(this.I("unsupported screen rotation: "+
this.g),this.g=0):(this.f.translate(0,this.o),this.f.rotate(this.g*Math.PI/180),this.f.scale(this.o/this.v,this.v/this.o));if(this.b=e)if(this.b.qa=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.b.qa){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){tc(f,document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},!1);
break}for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenerror","on"+d in document){document.addEventListener(d,function(){tc(f,null)},!1);break}}if(this.L=a.fontROM)"json"!=ca(this.L)&&(this.L=ia()+"/api/v1/dump?file="+this.L+"&format=bytes"),r(this.L,null,!0,function(a,b,c){uc(f,a,b,c)});this.bb={}}x(qc);var sc=0,rc={vt100:2};
qc.prototype.ha=function(a,b,c,d){this.u=a;this.l=b;this.a=c;this.K=d;this.F=Oa(a,"ChipSet");!this.s&&this.F&&this.F.U==W.Y&&(this.s=1);this.i=this.Ka*this.M;this.C=this.G*this.J;b=this.i;c=this.C;this.c&&(b=this.C,c=this.i);this.La=(this.i*this.oa>>3)*this.C;if(this.hc||Sa(this.l,this.$,this.La,3))1<this.M?vc(this,this.Ka*this.G):(this.ob=this.f.createImageData(b,c),this.rb=16/this.oa|0,vc(this,this.La>>1)),this.j=document.createElement("canvas"),this.j.width=b,this.j.height=c,this.Ya=this.j.getContext("2d"),
this.O={},this.fa=1<<this.oa,this.V=Array(this.fa+2),this.V[0]=[0,0,0,255],this.V[1]=[255,255,255,255],1==this.s&&(this.V[this.fa+0]=[255,255,0,255],this.V[this.fa+1]=[0,255,0,255]),2==this.s&&(this.xb=60,this.Za=!1,this.W=Array(this.Ka));if(this.D=Oa(a,"Keyboard")){for(var e in this.bb)this.D.R("led",e,this.bb[e]);this.m&&this.D.R(this.lc?"textarea":"canvas","kbd",this.ba)}this.L||B(this)};
function uc(a,b,c,d){if(d)a.I("Unable to load font ROM (error "+d+": "+b+")");else{Fa(a.ab,b,c);try{var e=eval("("+c+")"),f=e.bytes||e;if(!f||!f.length){t("Empty font ROM: "+b);return}if(1==f.length){t(f[0]);return}if(2048==f.length)wc(a,f);else{a.I("Unrecognized font data length ("+f.length+")");return}}catch(h){a.I("Font ROM data error: "+h.message);return}(a.f||a.K)&&B(a)}}
function wc(a,b){a.Xa=b;a.O[96]=[xc(a,a.M,a.J),xc(a,a.M,a.J,a.Za)];a.O[64]=[xc(a,2*a.M,a.J),xc(a,2*a.M,a.J,a.Za)];a.O[32]=a.O[0]=[xc(a,2*a.M,2*a.J),xc(a,2*a.M,2*a.J,a.Za)]}
function xc(a,b,c,d){var e=8>=a.$b?8:16,f=8<e?15:0,h=a.Xa.length/e,g=!1===d,k={M:b,J:c};k.canvas=document.createElement("canvas");k.canvas.width=16*b;k.canvas.height=h/16*c;k.context=k.canvas.getContext("2d");for(var l=k.context.createImageData(b,c),p=0;p<h;p++){for(var n=0,H=n;n<a.J;n++)for(var J=p*e+(f+n&e-1),J=d&&8==n?255:a.Xa[J],V=0;V<c/a.J;V++){for(var F=0,u=F;F<a.M;F++)for(var z=J&128>>(7<F?7:F),M=0;M<b/a.M;M++)g&&(z=!z),yc(a,l,u,H,z?1:0),u++;H++}k.context.putImageData(l,(p&15)*b,(p>>4)*c)}return k}
qc.prototype.Z=function(){if(2==this.s){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.$,c=-1,d=-1,e,f=-(60==this.xb?2:5);f<this.G;f++){var h=a[f];if(0<=c){var g=!1,c=b+2;h?h.length?d=h[0]:(c=b-1,g=!0):32==d&&(h=a[f-1],d=0);e=d&96|c>>8&15|16;Xa(this.l,b++,e);Xa(this.l,b++,c&255);
if(g)break}if(h)for(c=0,e=1;e<h.length;e++){for(var g=h[e],k=0;k<g.length;k++)Xa(this.l,b++,g.charCodeAt(k)|c);c^=128}Xa(this.l,b++,127);c=b}zc(this)}return!0};qc.prototype.R=function(a,b,c){var d=this;if("led"==a||"rled"==a)return this.bb[b]=c,!0;switch(b){case "fullScreen":return this.w[b]=c,this.b&&this.b.qa?c.onclick=function(){d.qa()}:c.parentNode.removeChild(c),!0}return!1};
qc.prototype.qa=function(){var a=!1;if(this.b){if(this.b.qa){a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=this.v/this.o;b>c&&(a=Math.round(c/b*100)+"%")}this.nb?(this.m.style.width=a,this.m.style.width=a,this.m.style.display="block",this.m.style.margin="auto"):(this.b.style.width=a,this.b.style.height="auto");this.b.style.backgroundColor="black";this.b.qa();a=!0}this.ba&&this.ba.focus()}return a};
function tc(a,b){!b&&a.b&&(a.nb?a.m.style.width=a.m.style.height="":a.b.style.width=a.b.style.height="")}function vc(a,b){a.pb=b;a.aa=!1;if(void 0===a.N||a.N.length!=a.pb)a.N=Array(a.pb)}function yc(a,b,c,d,e){d=a.c?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.s&&(208<=c&&236>c?e=a.fa+0:28<=c&&72>c&&(e=a.fa+1));a=a.V[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 zc(a){for(var b=a.$,c=-1,d=0,e=60==a.xb?2:5,f=0,h=0;d<a.G;){for(var g=0,k=b,l=c;;){var p=Va(a.l,k++);if(127==(p&127)){var n=Va(a.l,k++),c=n&96,b=(n&15)<<8|Va(a.l,k),b=b+(n&16?8192:16384);break}if(g<a.W.length)a.W[g++]=p;else break}if(e)e--;else{for(;g<a.W.length;)a.W[g++]=0;if(0<=l)for(k=0;k<g;k++){p=a.W[k];if(!a.aa||p!==a.N[f]){var n=a,H=a.Ya,J=p&127;if(p=n.O[l][p&128?1:0]){var V=(J&15)*p.M,J=(J>>4)*p.J,F=void 0,u=void 0,z=void 0,M=void 0,pa=p.M,Cb=p.J;H?(F=k*n.M,u=d*n.J,z=n.M,M=n.J):(F=
k*n.ib,u=d*n.mb,z=n.ib,M=n.mb);p.M>n.M&&(F*=2,z*=2);p.J>n.J&&(0==l&&(J+=n.J),Cb=n.J);H?H.drawImage(p.canvas,V,J,pa,Cb,F,u,z,M):(F+=0,u+=0,n.f.drawImage(p.canvas,V,J,pa,Cb,F,u,z,M))}h++}f++}d++}}a.aa=!0;h&&a.Ya&&a.f.drawImage(a.j,0,0,a.i,a.C-a.J,0,0,a.ac,a.gc)}
ua(function(){for(var a=A(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=y(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing &lt;canvas&gt; 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<=(window?window.navigator.userAgent:"").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||za.aspect);f&&.3<=f&&3.33>=f&&(ta("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");oa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new qc(d,e,h,f,c);Ia(d,c)}});
function E(a,b,c){this.id=a.id;this.key=Ac(a,b,c);this.K=a.K;Bc(this,a.Cb)}function Ac(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
E.prototype={constructor:E,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){Bc(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}}};
function Bc(a,b){a[a.id]={};b&&G(a,"parms",b);a.a=!1}function Cc(a){var b=!0;if(la()){var c=JSON.stringify(a[a.id]);na(a.key,c)||(t("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Dc(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){t(c.message||c),b=!1}return b}function Ec(a,b){return b?(a[a.id]=b,a.a=!0):a.a?!0:la()&&(b=ma(a.key))?(a[a.id]=b,a.a=!0):!1}function Fc(a,b){return a[a.id][b]||null}function G(a,b,c){try{a[a.id][b]=c}catch(d){}}
function Gc(a,b,c){v.call(this,"Computer",a,Gc);this.h.P=!1;Hc(this,b);this.F=qb(this,"autoPower",a);this.f=0;this.L=a.busWidth||a.buswidth;this.b=Ic;this.s=null;this.m=this.G=!1;this.N=qb(this,"url")||"";(Math.random()+.1).toString(36);this.c=Jc(this);if(this.a=Ha("CPU",this.id)){this.K=Ha("Debugger",this.id);this.j=[];for(b=null;b=Oa(this,"Video",b);)this.j.push(b);this.l=new Qa({id:this.ab+".bus",busWidth:this.L},this.a,this.K);var d,e=Ga(this.id);if((this.g=Ha("Panel",this.id))&&this.g.ga)for(b=
0;b<e.length;b++)d=e[b],d.I=this.g.I,d.X=this.g.X,d.ga=this.g.ga;this.X("PC8080 v1.23.3\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");for(b=0;b<e.length;b++)d=e[b],d.ha&&d.ha(this,this.l,this.a,this.K);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.u=d:this.b=parseInt(d,10));var f;if(a=qb(this,"state")||(f=!0,a.state))b=this.C=a,f||(this.m=!0,this.b=Ic),this.b&&(this.v=new E(this,"1.23.3"),Ec(this.v)?b=null:delete this.v);
!b&&this.b&&(b=Kc(this))&&(this.m=!0);if(b){var h=this;r(b,null,!0,function(a,b,c){c?(h.u=null,h.m=!1,h.I("Unable to load machine state from server (error "+c+(b?": "+(String.prototype.trim?b.trim():b.replace(/^\s+|\s+$/g,"")):"")+")")):(h.s=b,h.G=!0);B(h)})}else B(this);this.w.power||(this.F=!0);!c&&this.F&&Lc(this,this.Ga)}else t("Unable to find CPU component")}x(Gc);var Ic=0;
function Hc(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){t(d.message+" ("+c+")")}}a.o=b}function qb(a,b,c){var d=b.toLowerCase(),d=za[b]||za[d];void 0===d&&a.o&&(d=a.o[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function Lc(a,b,c){for(var d=Ga(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!Ka(f)){Ka(f,function(){Lc(a,b,c)});return}}b.call(a,c)}
function Mc(a,b){var c=new E(a,"1.23.3","validate");if(Ec(c)&&Dc(c)){var d=Fc(c,"timestamp"),e=b?Fc(b,"timestamp"):"unknown";d!=e&&(a.I("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}m=Gc.prototype;
m.Ga=function(a){void 0===a&&(a=this.b||(this.s?1:Ic));if(!this.f){this.f++;var b=!1,c=!1;this.D=!1;var d=this.v||new E(this,"1.23.3");if(-1==a)b=!0;else if(a>Ic){if(Ec(d,this.s)){this.i=new E(this,"1.23.3","failsafe");Ec(this.i)&&(Nc(this,d),a=2,Bc(this.i));G(this.i,"timestamp",ha());Cc(this.i);var e=this.b&&!this.m;if(1==a||ja("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Dc(d)){var f=Fc(d,"code"),h=Fc(d,"data");f&&("ok"==f?Ec(d,h):("error"==f&&
"no machine state"!=h?(this.I("Error: "+h),"unable to verify user"==h&&(na("user",""),this.c=null)):this.X(f+": "+h),Bc(d),Ec(d)?(c=Dc(d),e=!0):c=!1))}e&&Mc(this,c?d:null)}else 2==a&&d.clear()}else Mc(this);delete this.s;delete this.v}e=Ga(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.a&&(c=Oc(this,h,d,b,c));b=[d,a,c];-1!=a?Lc(this,this.qb,b):this.qb(b)}};
function Oc(a,b,c,d,e){if(!b.h.P){b.h.P=!0;if(b.Z){var f=null;e&&((f=Fc(c,b.id))||(f=Fc(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.Z(f,d)&&f&&(t("Unable to restore state for "+b.type),a.C&&!a.G?(c.clear(),a.b=Ic,window&&window.location.reload()):a.D=!0,b.Z(null),e=!1)}if(!d&&b.lb)for(a=b.lb.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
m.qb=function(a){var b=a[0],c=0>a[1];a=a[2];this.O=!0;this.h.P=!0;var d=this.w.power;d&&(d.textContent="Shutdown");this.a&&(Oc(this,this.a,b,c,a),ub(this.a));this.D&&(Nc(this,b),b.clear());!c&&this.i&&(this.i.clear(),delete this.i);this.f=0};
function Nc(a,b){if(ja("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.c||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.N;e.user=c;e.type="bug";e.data=d;r("http://www.pcjs.org/api/v1/report",e,!0)}}
function Pc(a,b,c){var d,e="none";if(a.f)return null;a.f--;var f=new E(a,"1.23.3"),h=new E(a,"1.23.3","validate"),g=ha();G(h,"timestamp",g);G(f,"timestamp",g);G(f,"version","1.23.3");G(f,"url",window?window.location.href:null);G(f,"browser",window?window.navigator.userAgent:"");a.a&&a.a.ea&&(c&&vb(a.a),d=a.a.ea(b,c),"object"===typeof d&&G(f,a.a.id,d),c&&(a.a.h.P=!1,!1===d&&(e=null)));for(var g=Ga(a.id),k=0;k<g.length;k++){var l=g[k];l.h.P&&(l.ea&&(d=l.ea(b,c),"object"===typeof d&&G(f,l.id,d)),c&&
(l.h.P=!1,!1===d&&(e=null)))}e&&(c?(g=d=!1,b?(a.c&&Qc(a,a.c,f.toString()),Cc(h)&&Cc(f)||(e=null,d=g=!0)):a.b&&(d=!0,g=3==a.b),d&&f.clear(g)):e=f.toString());c&&(a.h.P=!1,b=a.w.power)&&(b.textContent="Power");a.f=0;return e}m.reset=function(){this.l&&this.l.reset&&this.l.reset();for(var a=Ga(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.l&&c.reset&&c.reset()}};m.start=function(a,b){for(var c=Ga(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};
11}];function U(a){u.call(this,"ChipSet",a,U);var b=a.model;b&&!ac[b]&&t("Unrecognized ChipSet model: "+b);this.b=ac[b]||W;this.V=this.b.Y;a.sound&&(this.F=null,window&&(this.F=window.AudioContext||window.webkitAudioContext),this.F&&new this.F);B(this)}x(U);
var W={Y:1978.1,ec:{U:0,Jc:1,Nc:16,Vc:32,dd:64,cd:128,Aa:14},ka:{U:1,Nb:1,bc:2,Yb:4,Zb:16,$b:32,ac:64,Aa:8},fc:{U:2,Ic:3,nd:4,Kc:8,Zc:16,$c:32,ad:64,Lc:128,Aa:0},gd:{U:3},ed:{U:2,Wc:7},jd:{U:3,od:1,hd:2,bd:4,Sc:8,Mc:16,Gc:32},fd:{U:4},kd:{U:5,Oc:1,Pc:2,Qc:4,Rc:8,pd:16}},X={Y:100,qa:{U:66,qd:1,Wb:2,Xb:4,Yc:8,Xc:16,nb:32,mb:64,Tc:128},Mb:{U:66,INIT:0},ca:{Uc:{U:98},pa:{Lb:0,Kb:1,dc:2,gc:4,Qb:5,cc:6,ld:7},Oa:16383},Pb:{U:162,INIT:0},Ob:{U:194,INIT:0}},ac={SI1978:W,VT100:X};U.prototype.R=function(){return!1};
U.prototype.ia=function(a,b,c,d){this.l=b;this.a=c;this.N=d;this.u=a;Za(b,this,this.b.Wa);$a(b,this,this.b.Xa)};U.prototype.Z=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};U.prototype.fa=function(a){return a?this.save():!0};W.Ca=[[W.ec.Aa,W.ka.Aa,W.fc.Aa,0,0,0,0]];X.Ca=[[X.Mb.INIT,X.qa.Wb|X.qa.Xb,X.Pb.INIT,X.Ob.INIT],[0,0,0,0,Array(100)]];m=U.prototype;m.reset=function(){this.restore(this.b.Ca)||this.I("reset error")};
m.save=function(){var a=new E(this);switch(this.V){case W.Y:F(a,0,[this.L,this.f,this.S,this.o,this.v,this.J,this.K]);break;case X.Y:F(a,0,[this.C,this.i,this.G,this.D]),F(a,1,[this.m,this.c,this.j,this.s,this.g])}return a.data()};
m.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.V){case W.Y:return this.L=b[0],this.f=b[1],this.S=b[2],this.o=b[3],this.v=b[4],this.J=b[5],this.K=b[6],!0;case X.Y:return this.C=b[0],this.i=b[2],this.G=b[3],this.D=b[4],b=a[1],this.m=b[0],this.c=b[1],this.j=b[2],this.s=b[3],this.g=b[4],!0}return!1};m.start=function(){};m.stop=function(){};function bc(a,b,c){a.f&=~b;c&&(a.f|=b)}m.lc=function(){return this.L};m.mc=function(){return this.f};m.nc=function(){return this.S};
m.kc=function(){return this.o>>8-this.v&255};m.vc=function(a,b){this.v=b};m.xc=function(a,b){this.J=b};m.wc=function(a,b){this.o=b<<8|this.o>>8};m.yc=function(a,b){this.K=b};m.zc=function(){};function cc(a){var b=0,c=0,d=~a.m;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.oc=function(){var a=this.i,a=a&~X.qa.mb;if((zb(this.a)&64)<<1&&(a|=X.qa.mb,a!=this.i)){var b,c;b=this.j&1;switch(this.j>>1&7){case X.ca.pa.Kb:this.m=this.m<<1|b;break;case X.ca.pa.Qb:b=cc(this);this.g[b]=X.ca.Oa;break;case X.ca.pa.Lb:this.c=this.c<<1|b;break;case X.ca.pa.gc:b=cc(this);c=this.c&X.ca.Oa;this.g[b]=c;break;case X.ca.pa.cc:b=cc(this);c=this.g[b];null==c&&(c=X.ca.Oa);this.c=c;break;case X.ca.pa.dc:this.c<<=1,this.s=this.c&X.ca.Oa+1}}a&=~X.qa.nb;this.s&&(a|=X.qa.nb);return this.i=a};
m.Ac=function(a,b){this.C=b};m.Dc=function(a,b){this.j=b};m.Cc=function(a,b){this.G=b};m.Bc=function(a,b){this.D=b};W.Wa={0:U.prototype.lc,1:U.prototype.mc,2:U.prototype.nc,3:U.prototype.kc};W.Xa={2:U.prototype.vc,3:U.prototype.xc,4:U.prototype.wc,5:U.prototype.yc,6:U.prototype.zc};X.Wa={66:U.prototype.oc};X.Xa={66:U.prototype.Ac,98:U.prototype.Dc,162:U.prototype.Cc,194:U.prototype.Bc};ua(function(){for(var a=z(document,"pc8080","chipset"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new U(d);Ia(d,c)}});
function dc(a){u.call(this,"ROM",a,dc);this.b=null;this.j=a.addr;this.c=a.size;this.m=a.writable;this.f=a.alias;this.g=a.file;this.o=ba(this.g);if(this.g){a=this.g;var b=ca(this.o);"json"!=b&&"hex"!=b&&(a=ia()+"/api/v1/dump?file="+this.g+"&format=bytes&decimal=true");var c=this;r(a,null,!0,function(a,b,f){ec(c,a,b,f)})}}x(dc);var fc=[0,5];dc.prototype.ia=function(a,b,c,d){this.l=b;this.a=c;this.N=d;gc(this)};
dc.prototype.Z=function(){this.i&&(this.N&&this.N.a(this.id,this.j,this.c,this.i),delete this.i);return!0};dc.prototype.fa=function(){return!0};
function ec(a,b,c,d){if(d)a.I("Unable to load system ROM (error "+d+": "+b+")");else{Fa(a.eb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.b=f;else if(h)for(a.b=Array(4*h.length),d=c=0;c<h.length;c++)a.b[d++]=h[c]&255,a.b[d++]=h[c]>>8&255,a.b[d++]=h[c]>>16&255,a.b[d++]=h[c]>>24&255;else a.b=e;a.i=e.symbols;if(!a.b.length){t("Empty ROM: "+b);return}if(1==a.b.length){t(a.b[0]);return}}catch(g){a.I("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
" ").replace(/ +$/,"").split(" "),a.b=Array(b.length),e=0;e<b.length;e++)a.b[e]=aa(b[e]);gc(a)}}
function gc(a){if(!Ka(a))if(!a.g)B(a);else if(a.b&&a.l){a.c||(a.c=a.b.length);if(a.b.length!=a.c){var b="ROM size (0x"+q(a.b.length)+") does not match specified size ("+("0x"+q(a.c))+")";a.h.la=!0;a.I(b)}else if(hc(a,a.j)){b=[];"number"==typeof a.f?b.push(a.f):null!=a.f&&a.f.length&&(b=a.f);for(var c=0;c<b.length;c++){for(var d=a,e=b[c],f=d.l,h=d.c,g=[],k=d.j>>>f.c;0<h&&k<f.b.length;)g.push(f.b[k++]),h-=f.l;f=d.l;d=d.c;h=0;for(e>>>=f.c;0<d&&e<f.b.length;){k=g[h++];if(!k)break;f.b[e++]=k;d-=f.l}}delete a.b}B(a)}}
function hc(a,b){if(Sa(a.l,b,a.c,a.m?1:fb)){var c;for(c=0;c<a.b.length;c++)Xa(a.l,b+c,a.b[c]);if(a.m&&256==b){for(c=0;c<fc.length;c++)Xa(a.l,fc[c],118);Gb(a.a,function(a){return function(b){if(0<=fc.indexOf(b)){var c=!1,h=a.a,g=a.N;if(5==b)switch(c=!0,h.A){case 2:ic(a,String.fromCharCode(h.B));break;case 9:for(var k=Mb(h),l="",p=255;p--;){var n=a.a.H(k++);if(36==n)break;l+=String.fromCharCode(n)}ic(a,l);break;default:c=!1}c?Zb.call(h):g&&(a.X("\nCP/M vector 0x"+q(b,4)),D(h,b),vb(g));b=!0}else b=!1;
return b}}(a));Ib(a.a,b)}return!0}return!1}function ic(a,b){b=b.replace(/\r/g,"");a.ha&&(a.ha.value+=b,a.ha.scrollTop=a.ha.scrollHeight)}ua(function(){for(var a=z(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new dc(d);Ia(d,c)}});function jc(a){u.call(this,"RAM",a,jc);this.f=a.addr;this.c=a.size;this.b=!1}x(jc);m=jc.prototype;m.ia=function(a,b,c,d){this.l=b;this.a=c;this.N=d;B(this)};m.Z=function(a,b){b||this.reset();return!0};m.fa=function(a){return a?this.save():!0};
m.reset=function(){!this.b&&this.c&&Sa(this.l,this.f,this.c,1)&&(this.b=!0);this.b||t("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};ua(function(){for(var a=z(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new jc(d);Ia(d,c)}});function Y(a){u.call(this,"Keyboard",a,Y);this.reset();B(this)}x(Y);
var Z={ja:{U:130,Ub:1,Tb:2,Sb:4,Rb:8,Vb:16,ob:32,md:64,Hc:128}},kc={"1p":49,"2p":50,coin:51,left:37,right:39,fire:32},lc={65:37,68:39,76:32},mc={l4:Z.ja.Ub,l3:Z.ja.Tb,l2:Z.ja.Sb,l1:Z.ja.Rb,locked:Z.ja.Vb,online:Z.ja.ob,local:~Z.ja.ob};
Y.prototype.R=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.w[e]){if("led"==a&&mc[b])return this.w[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return nc(d,a,!0)},c.onkeyup=function(a){return nc(d,a,!1)},!0;default:if(void 0!==kc[b])return this.w[e]=c,a=function(a,b){return function(){oc(a,b,!0)}}(this,b),b=function(a,b){return function(){oc(a,b,!1)}}(this,b),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend=b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};
Y.prototype.ia=function(a,b,c,d){this.N=d;this.F=Oa(a,"ChipSet");this.V=this.F.V;switch(this.V){case X.Y:this.b=Z}this.b&&(Za(b,this,this.b.Wa),$a(b,this,this.b.Xa))};Y.prototype.Z=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};Y.prototype.fa=function(a){return a?this.save():!0};Z.Ca=[[0]];Y.prototype.reset=function(){this.l={};this.a={};this.b&&!this.restore(this.b.Ca)&&this.I("reset error")};
Y.prototype.save=function(){var a=new E(this);switch(this.V){case X.Y:F(a,0,[this.c])}return a.data()};Y.prototype.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.V){case W.Y:return!0;case X.Y:return this.c=b[0],pc(this),!0}return!1};function pc(a){for(var b in mc){var c=a.w["led-"+b];if(c){var d=mc[b],e=!!(a.c&d);d&d-1&&(e=!(a.c&~d));c.style.backgroundColor=e?"#ff0000":"#000000"}}}
function nc(a,b,c){var d=!0,e;a:{e=b.keyCode;e=lc[e]||e;for(var f in kc)if(kc[f]===e){e=f;break a}e=null}e&&(d=oc(a,e,c),b.preventDefault());return d}
function oc(a,b,c){if(c)a.l[b]=Date.now(),delete a.a[b];else{var d=a.l[b];if(d&&100>Date.now()-d)return a.a[b]=d,qc(a),!0;delete a.l[b]}if(a.F)switch(b){case "1p":bc(a.F,W.ka.Yb,c);break;case "2p":bc(a.F,W.ka.bc,c);break;case "coin":bc(a.F,W.ka.Nb,c);break;case "left":bc(a.F,W.ka.$b,c);break;case "right":bc(a.F,W.ka.ac,c);break;case "fire":bc(a.F,W.ka.Zb,c)}return!0}
function qc(a){for(var b=-1,c=Object.keys(a.a),d=0;d<c.length;d++){var e=c[d],f=100-(Date.now()-a.a[e]);if(0<f){if(0>b||b>f)b=f}else delete a.a[e],oc(a,e,!1)}0<=b&&setTimeout(function(){qc(a)},b)}Y.prototype.f=function(a,b){this.c=b;pc(this)};Z.Wa={};Z.Xa={130:Y.prototype.f};ua(function(){for(var a=z(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=y(c),d=new Y(d);Ia(d,c)}});
function rc(a,b,c,d,e){var f=this;this.rb=oa("Gecko/");var h=["","moz","ms","webkit"];u.call(this,"Video",a,rc);this.v=a.screenWidth;this.o=a.screenHeight;this.$=a.bufferAddr;this.qc=a.bufferRAM;var g=a.bufferFormat;this.s=g&&sc[g.toLowerCase()]||tc;this.Ma=a.bufferCols;this.G=a.bufferRows;this.ic=this.O=a.cellWidth||1;this.M=a.cellHeight||1;this.$a=null;this.ra=a.bufferBits||1;this.rc=a.bufferLeft||0;if(this.c=a.bufferRotate)this.c=this.c%360,0<this.c&&(this.c-=360),-90!=this.c&&(this.I("unsupported buffer rotation: "+
this.c),this.c=0);this.Ab=a.interruptRate;this.sc=a.refreshRate||60;this.m=b;this.f=c;this.ba=(this.uc=d)||b||null;this.jc=this.v;this.pc=this.o;this.lb=this.v/this.Ma|0;this.qb=this.o/this.G|0;1<this.M&&this.G++;b=a.smoothing;(c=za.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)if(d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.f[d]){this.f[d]=b;break}if(this.g=a.screenRotate)this.g=this.g%360,0<this.g&&(this.g-=360),-90!=this.g?(this.I("unsupported screen rotation: "+
this.g),this.g=0):(this.f.translate(0,this.o),this.f.rotate(this.g*Math.PI/180),this.f.scale(this.o/this.v,this.v/this.o));if(this.b=e)if(this.b.ta=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.b.ta){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){uc(f,document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},!1);
break}for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenerror","on"+d in document){document.addEventListener(d,function(){uc(f,null)},!1);break}}if(this.J=a.fontROM)"json"!=ca(this.J)&&(this.J=ia()+"/api/v1/dump?file="+this.J+"&format=bytes"),r(this.J,null,!0,function(a,b,c){vc(f,a,b,c)});this.fb={}}x(rc);var tc=0,sc={vt100:2};
rc.prototype.ia=function(a,b,c,d){this.u=a;this.l=b;this.a=c;this.N=d;this.F=Oa(a,"ChipSet");!this.s&&this.F&&this.F.V==W.Y&&(this.s=1);this.i=this.Ma*this.O;this.C=this.G*this.M;b=this.i;c=this.C;this.c&&(b=this.C,c=this.i);this.Na=(this.i*this.ra>>3)*this.C;if(this.qc||Sa(this.l,this.$,this.Na,3))1<this.O?wc(this,this.Ma*this.G):(this.sb=this.f.createImageData(b,c),this.vb=16/this.ra|0,wc(this,this.Na>>1)),this.j=document.createElement("canvas"),this.j.width=b,this.j.height=c,this.ab=this.j.getContext("2d"),
this.L={},this.ga=1<<this.ra,this.S=Array(this.ga+2),this.S[0]=[0,0,0,255],this.S[1]=[255,255,255,255],1==this.s&&(this.S[this.ga+0]=[255,255,0,255],this.S[this.ga+1]=[0,255,0,255]),2==this.s&&(this.Bb=60,this.bb=!1,this.W=Array(this.Ma));if(this.D=Oa(a,"Keyboard")){for(var e in this.fb)this.D.R("led",e,this.fb[e]);this.m&&this.D.R(this.uc?"textarea":"canvas","kbd",this.ba)}this.J||B(this)};
function vc(a,b,c,d){if(d)a.I("Unable to load font ROM (error "+d+": "+b+")");else{Fa(a.eb,b,c);try{var e=eval("("+c+")"),f=e.bytes||e;if(!f||!f.length){t("Empty font ROM: "+b);return}if(1==f.length){t(f[0]);return}if(2048==f.length)xc(a,f);else{a.I("Unrecognized font data length ("+f.length+")");return}}catch(h){a.I("Font ROM data error: "+h.message);return}(a.f||a.N)&&B(a)}}
function xc(a,b){a.$a=b;a.L[96]=[yc(a,a.O,a.M),yc(a,a.O,a.M,a.bb)];a.L[64]=[yc(a,2*a.O,a.M),yc(a,2*a.O,a.M,a.bb)];a.L[32]=a.L[0]=[yc(a,2*a.O,2*a.M),yc(a,2*a.O,2*a.M,a.bb)]}
function yc(a,b,c,d){var e=8>=a.ic?8:16,f=8<e?15:0,h=a.$a.length/e,g=!1===d,k={O:b,M:c};k.canvas=document.createElement("canvas");k.canvas.width=16*b;k.canvas.height=h/16*c;k.context=k.canvas.getContext("2d");for(var l=k.context.createImageData(b,c),p=0;p<h;p++){for(var n=0,H=n;n<a.M;n++)for(var J=p*e+(f+n&e-1),J=d&&8==n?255:a.$a[J],V=0;V<c/a.M;V++){for(var G=0,v=G;G<a.O;G++)for(var A=J&128>>(7<G?7:G),M=0;M<b/a.O;M++)g&&(A=!A),zc(a,l,v,H,A?1:0),v++;H++}k.context.putImageData(l,(p&15)*b,(p>>4)*c)}return k}
rc.prototype.Z=function(){if(2==this.s){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.$,c=-1,d=-1,e,f=-(60==this.Bb?2:5);f<this.G;f++){var h=a[f];if(0<=c){var g=!1,c=b+2;h?h.length?d=h[0]:(c=b-1,g=!0):32==d&&(h=a[f-1],d=0);e=d&96|c>>8&15|16;Xa(this.l,b++,e);Xa(this.l,b++,c&255);
if(g)break}if(h)for(c=0,e=1;e<h.length;e++){for(var g=h[e],k=0;k<g.length;k++)Xa(this.l,b++,g.charCodeAt(k)|c);c^=128}Xa(this.l,b++,127);c=b}Ac(this)}return!0};rc.prototype.R=function(a,b,c){var d=this;if("led"==a||"rled"==a)return this.fb[b]=c,!0;switch(b){case "fullScreen":return this.w[b]=c,this.b&&this.b.ta?c.onclick=function(){d.ta()}:c.parentNode.removeChild(c),!0}return!1};
rc.prototype.ta=function(){var a=!1;if(this.b){if(this.b.ta){a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=this.v/this.o;b>c&&(a=Math.round(c/b*100)+"%")}this.rb?(this.m.style.width=a,this.m.style.width=a,this.m.style.display="block",this.m.style.margin="auto"):(this.b.style.width=a,this.b.style.height="auto");this.b.style.backgroundColor="black";this.b.ta();a=!0}this.ba&&this.ba.focus()}return a};
function uc(a,b){!b&&a.b&&(a.rb?a.m.style.width=a.m.style.height="":a.b.style.width=a.b.style.height="")}function wc(a,b){a.tb=b;a.aa=!1;if(void 0===a.K||a.K.length!=a.tb)a.K=Array(a.tb)}function zc(a,b,c,d,e){d=a.c?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.s&&(208<=c&&236>c?e=a.ga+0:28<=c&&72>c&&(e=a.ga+1));a=a.S[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 Ac(a){for(var b=a.$,c=-1,d=0,e=60==a.Bb?2:5,f=0,h=0;d<a.G;){for(var g=0,k=b,l=c;;){var p=Va(a.l,k++);if(127==(p&127)){var n=Va(a.l,k++),c=n&96,b=(n&15)<<8|Va(a.l,k),b=b+(n&16?8192:16384);break}if(g<a.W.length)a.W[g++]=p;else break}if(e)e--;else{for(;g<a.W.length;)a.W[g++]=0;if(0<=l)for(k=0;k<g;k++){p=a.W[k];if(!a.aa||p!==a.K[f]){var n=a,H=a.ab,J=p&127;if(p=n.L[l][p&128?1:0]){var V=(J&15)*p.O,J=(J>>4)*p.M,G=void 0,v=void 0,A=void 0,M=void 0,pa=p.O,Db=p.M;H?(G=k*n.O,v=d*n.M,A=n.O,M=n.M):(G=
k*n.lb,v=d*n.qb,A=n.lb,M=n.qb);p.O>n.O&&(G*=2,A*=2);p.M>n.M&&(0==l&&(J+=n.M),Db=n.M);H?H.drawImage(p.canvas,V,J,pa,Db,G,v,A,M):(G+=0,v+=0,n.f.drawImage(p.canvas,V,J,pa,Db,G,v,A,M))}h++}f++}d++}}a.aa=!0;h&&a.ab&&a.f.drawImage(a.j,0,0,a.i,a.C-a.M,0,0,a.jc,a.pc)}
ua(function(){for(var a=z(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=y(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing &lt;canvas&gt; 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<=(window?window.navigator.userAgent:"").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||za.aspect);f&&.3<=f&&3.33>=f&&(ta("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");oa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new rc(d,e,h,f,c);Ia(d,c)}});
function E(a,b,c){this.id=a.id;this.key=Bc(a,b,c);this.N=a.N;Cc(this,a.Gb)}function Bc(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
E.prototype={constructor:E,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){Cc(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}}};
function Cc(a,b){a[a.id]={};b&&F(a,"parms",b);a.a=!1}function Dc(a){var b=!0;if(la()){var c=JSON.stringify(a[a.id]);na(a.key,c)||(t("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Ec(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){t(c.message||c),b=!1}return b}function Fc(a,b){return b?(a[a.id]=b,a.a=!0):a.a?!0:la()&&(b=ma(a.key))?(a[a.id]=b,a.a=!0):!1}function Gc(a,b){return a[a.id][b]||null}function F(a,b,c){try{a[a.id][b]=c}catch(d){}}
function Hc(a,b,c){u.call(this,"Computer",a,Hc);this.h.P=!1;Ic(this,b);this.F=qb(this,"autoPower",a);this.f=0;this.J=a.busWidth||a.buswidth;this.b=Jc;this.s=null;this.m=this.G=!1;this.K=qb(this,"url")||"";(Math.random()+.1).toString(36);this.c=Kc(this);if(this.a=Ha("CPU",this.id)){this.N=Ha("Debugger",this.id);this.j=[];for(b=null;b=Oa(this,"Video",b);)this.j.push(b);this.l=new Qa({id:this.eb+".bus",busWidth:this.J},this.a,this.N);var d,e=Ga(this.id);if((this.g=Ha("Panel",this.id))&&this.g.ha)for(b=
0;b<e.length;b++)d=e[b],d.I=this.g.I,d.X=this.g.X,d.ha=this.g.ha;this.X("PC8080 v1.23.3\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");for(b=0;b<e.length;b++)d=e[b],d.ia&&d.ia(this,this.l,this.a,this.N);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.u=d:this.b=parseInt(d,10));var f;if(a=qb(this,"state")||(f=!0,a.state))b=this.C=a,f||(this.m=!0,this.b=Jc),this.b&&(this.v=new E(this,"1.23.3"),Fc(this.v)?b=null:delete this.v);
!b&&this.b&&(b=Lc(this))&&(this.m=!0);if(b){var h=this;r(b,null,!0,function(a,b,c){c?(h.u=null,h.m=!1,h.I("Unable to load machine state from server (error "+c+(b?": "+(String.prototype.trim?b.trim():b.replace(/^\s+|\s+$/g,"")):"")+")")):(h.s=b,h.G=!0);B(h)})}else B(this);this.w.power||(this.F=!0);!c&&this.F&&Mc(this,this.Ja)}else t("Unable to find CPU component")}x(Hc);var Jc=0;
function Ic(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){t(d.message+" ("+c+")")}}a.o=b}function qb(a,b,c){var d=b.toLowerCase(),d=za[b]||za[d];void 0===d&&a.o&&(d=a.o[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function Mc(a,b,c){for(var d=Ga(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!Ka(f)){Ka(f,function(){Mc(a,b,c)});return}}b.call(a,c)}
function Nc(a,b){var c=new E(a,"1.23.3","validate");if(Fc(c)&&Ec(c)){var d=Gc(c,"timestamp"),e=b?Gc(b,"timestamp"):"unknown";d!=e&&(a.I("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}m=Hc.prototype;
m.Ja=function(a){void 0===a&&(a=this.b||(this.s?1:Jc));if(!this.f){this.f++;var b=!1,c=!1;this.D=!1;var d=this.v||new E(this,"1.23.3");if(-1==a)b=!0;else if(a>Jc){if(Fc(d,this.s)){this.i=new E(this,"1.23.3","failsafe");Fc(this.i)&&(Oc(this,d),a=2,Cc(this.i));F(this.i,"timestamp",ha());Dc(this.i);var e=this.b&&!this.m;if(1==a||ja("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Ec(d)){var f=Gc(d,"code"),h=Gc(d,"data");f&&("ok"==f?Fc(d,h):("error"==f&&
"no machine state"!=h?(this.I("Error: "+h),"unable to verify user"==h&&(na("user",""),this.c=null)):this.X(f+": "+h),Cc(d),Fc(d)?(c=Ec(d),e=!0):c=!1))}e&&Nc(this,c?d:null)}else 2==a&&d.clear()}else Nc(this);delete this.s;delete this.v}e=Ga(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.a&&(c=Pc(this,h,d,b,c));b=[d,a,c];-1!=a?Mc(this,this.ub,b):this.ub(b)}};
function Pc(a,b,c,d,e){if(!b.h.P){b.h.P=!0;if(b.Z){var f=null;e&&((f=Gc(c,b.id))||(f=Gc(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.Z(f,d)&&f&&(t("Unable to restore state for "+b.type),a.C&&!a.G?(c.clear(),a.b=Jc,window&&window.location.reload()):a.D=!0,b.Z(null),e=!1)}if(!d&&b.pb)for(a=b.pb.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
m.ub=function(a){var b=a[0],c=0>a[1];a=a[2];this.L=!0;this.h.P=!0;var d=this.w.power;d&&(d.textContent="Shutdown");this.a&&(Pc(this,this.a,b,c,a),ub(this.a));this.D&&(Oc(this,b),b.clear());!c&&this.i&&(this.i.clear(),delete this.i);this.f=0};
function Oc(a,b){if(ja("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.c||"",d=b.toString(),e={app:"PC8080",ver:"1.23.3"};e.url=a.K;e.user=c;e.type="bug";e.data=d;r("http://www.pcjs.org/api/v1/report",e,!0)}}
function Qc(a,b,c){var d,e="none";if(a.f)return null;a.f--;var f=new E(a,"1.23.3"),h=new E(a,"1.23.3","validate"),g=ha();F(h,"timestamp",g);F(f,"timestamp",g);F(f,"version","1.23.3");F(f,"url",window?window.location.href:null);F(f,"browser",window?window.navigator.userAgent:"");a.a&&a.a.fa&&(c&&vb(a.a),d=a.a.fa(b,c),"object"===typeof d&&F(f,a.a.id,d),c&&(a.a.h.P=!1,!1===d&&(e=null)));for(var g=Ga(a.id),k=0;k<g.length;k++){var l=g[k];l.h.P&&(l.fa&&(d=l.fa(b,c),"object"===typeof d&&F(f,l.id,d)),c&&
(l.h.P=!1,!1===d&&(e=null)))}e&&(c?(g=d=!1,b?(a.c&&Rc(a,a.c,f.toString()),Dc(h)&&Dc(f)||(e=null,d=g=!0)):a.b&&(d=!0,g=3==a.b),d&&f.clear(g)):e=f.toString());c&&(a.h.P=!1,b=a.w.power)&&(b.textContent="Power");a.f=0;return e}m.reset=function(){this.l&&this.l.reset&&this.l.reset();for(var a=Ga(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.l&&c.reset&&c.reset()}};m.start=function(a,b){for(var c=Ga(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};
m.stop=function(a,b){for(var c=Ga(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}};
m.R=function(a,b,c){var d=this;switch(b){case "power":return this.w[b]=c,c.onclick=function(){d.f||(d.h.P?Pc(d,!1,!0):Lc(d,d.Ga))},!0;case "reset":return this.w[b]=c,c.onclick=function(){if(d.h.P&&!d.f)if(d.b&&!d.u){var a=ja("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Pc(d,a,!0);!a&&d.C?window&&window.location.reload():d.Ga(Ic)}else d.reset(),d.a&&ub(d.a)},!0;case "save":if(da(ia(),"pcjs.org")){c.parentNode.removeChild(c);break}this.w[b]=
c;c.onclick=function(){var a=Jc(d,!0);if(a){var b=!!(d.b&&!d.u||d.C),c=Pc(d,b);b?Qc(d,a,c):d.I("Resume disabled, machine state not saved")}};return!0}return!1};
function Jc(a,b){var c=a.c;c||(c=ma("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=Rc(a,c))||a.I("The user ID is invalid."))):b&&a.I("Browser local storage is not available"));return c}
function Rc(a,b){a.c=null;var c=r(ia()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(na("user",c.data),a.c=c.data)}catch(e){t(e.message+" ("+d+")")}return a.c}function Kc(a){var b=null;a.c&&(b=ia()+"/api/v1/user?req=load&user="+a.c+"&state="+Ac(a,"1.23.3"));return b}
function Qc(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Ac(a,"1.23.3");d.data=c;b=r(ia()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.I("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.I(c),na("user",""),a.c=null)}}
function Oa(a,b,c){a=Ga(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}function Ab(a,b){if(a.j.length){var c=0,d=0;b&&window&&(c=window.scrollX,d=window.scrollY);var e=a.j[0];e.ba&&e.ba.focus();b&&window&&window.scrollTo(c,d)}}m.na=function(a){this.a&&this.a.na(a);this.g&&this.g.na(a)};
function Bb(a,b){for(var c=0;c<a.j.length;c++){var d=a.j[c],e=!0;if(0<=b){if(d.wb)if(b&1)e=d.a,e.D=e.D&-8|10,e=!1;else{var f=d.a;f.D=f.D&-8|9}if(f=e&&d.aa){for(var f=d.l,h=d.La,g=!0,k=d.$>>>f.c;0<h&&k<f.b.length;)f.b[k].ca&&(f.b[k].ca=g=!1,f.b[k].tb=!0),h-=f.l,k++;f=g}f&&(e=!1)}if(e)if(1<d.M)switch(d.s){case 2:zc(d)}else{var g=d.$,k=g+d.La,l=0,p=0,n=0,e=d.i,H=0,f=d.C,J=h=0,V=d.oa,F=(1<<V)-1;d.ic&&(V=-V,J=16+V);for(;g<k;){var u;u=d.l;var z=g,M=z&u.f,pa=(z&u.g)>>>u.c;u=M!=u.f?u.b[pa].Db(M,z):u.b[pa++].Va(M,
z)|u.b[pa&u.u].Va(0,z+1)<<8;if(d.aa&&u===d.N[l])p+=d.rb;else{d.N[l]=u;(z=J)&&(u=u>>8|(u&255)<<8);p<e&&(e=p);for(M=d.rb;M--;)pa=u>>z&F,yc(d,d.ob,p++,n,pa),z+=V;p>H&&(H=p);n<f&&(f=n);n>=h&&(h=n+1)}g+=2;l++;if(p>=d.i&&(p=0,n++,n>d.C))break}d.aa=!0;e<d.i&&(g=H-e,h-=f,d.c&&(k=e,l=g,e=f,g=h,f=d.i-(k+l),h=l),d.Ya.putImageData(d.ob,0,0,e,f,g,h),d.f.drawImage(d.j,0,0,d.j.width,d.j.height,0,0,d.v,d.o))}}}
ua(function(){for(var a=A(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=y(c),c=A(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],h=y(f),h=new Gc(h,d,!0);Ia(h,f);h.F&&Lc(h,h.Ga)}});qa.show.push(function(){for(var a=A(document,"pc8080","computer"),b=0;b<a.length;b++){var c=y(a[b]);(c=Ha("Computer",c.id))&&c.O&&!c.h.P&&c.Ga(-1)}});
qa.exit.push(function(){for(var a=A(document,"pc8080","computer"),b=0;b<a.length;b++){var c=y(a[b]);(c=Ha("Computer",c.id))&&c.h.P&&Pc(c,!(!c.b||c.u),!0)}});var Sc=0;function Tc(a,b,c,d,e,f){e("Loading "+a+"...");r(a,null,!0,function(h,g,k){k?(g||(g="unable to load "+a+" ("+k+")"),f(g,null)):Uc(g,a,b,c,d,e,f)})}
function Uc(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{if(c){Fa(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\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(n){g=null,a=n.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?Vc(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
function Vc(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");r(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);Vc(a,b,c)}})}else c(a,null)}
function Wc(a,b,c,d){function e(a){if(void 0===g){var b=h&&A(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=fa(a))}function f(a){e("Error: "+a);k&&(--Sc||wa(!0));k=!1}var h,g,k=!0;Sc++;Ea[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css";n.styleSheet?n.styleSheet.cssText=l:n.appendChild(document.createTextNode(l));p.appendChild(n)}c||
(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?Tc(c,null,null,!1,e,function(d,k){if(k)if(Fa(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--Sc||wa(!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),--Sc||wa(!0)):f("invalid machine element: "+
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?Tc(b,a,d,!0,e,l):Uc(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(H){f(H.message)}return k}window.embedPC8080=function(a,b,c,d){wa(!1);return Wc(a,b,c,d)};window.enableEvents=wa;window.sendEvent=xa;
function Xc(a,b,c,d){if(!c&&b){d.push(b);a=Ea[d[0]];b=null;for(var e in a)if(da(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?r(b,null,!0,function(a,b){Yc(b,d)}):Yc(null,d)}else t("Error ("+c+") requesting "+a)}
function Yc(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=Ea[f],k={},l;for(l in g){var p=g[l],n=ca(l);if("xml"==n){for(n=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=n.exec(g[l]);){var H=d[2];H&&(g[H]||(p=p.replace(d[0],"")))}d=l=ba(l)}else"xsl"==n&&(e=l=ba(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.R=function(a,b,c){var d=this;switch(b){case "power":return this.w[b]=c,c.onclick=function(){d.f||(d.h.P?Qc(d,!1,!0):Mc(d,d.Ja))},!0;case "reset":return this.w[b]=c,c.onclick=function(){if(d.h.P&&!d.f)if(d.b&&!d.u){var a=ja("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Qc(d,a,!0);!a&&d.C?window&&window.location.reload():d.Ja(Jc)}else d.reset(),d.a&&ub(d.a)},!0;case "save":if(da(ia(),"pcjs.org")){c.parentNode.removeChild(c);break}this.w[b]=
c;c.onclick=function(){var a=Kc(d,!0);if(a){var b=!!(d.b&&!d.u||d.C),c=Qc(d,b);b?Rc(d,a,c):d.I("Resume disabled, machine state not saved")}};return!0}return!1};
function Kc(a,b){var c=a.c;c||(c=ma("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=Sc(a,c))||a.I("The user ID is invalid."))):b&&a.I("Browser local storage is not available"));return c}
function Sc(a,b){a.c=null;var c=r(ia()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(na("user",c.data),a.c=c.data)}catch(e){t(e.message+" ("+d+")")}return a.c}function Lc(a){var b=null;a.c&&(b=ia()+"/api/v1/user?req=load&user="+a.c+"&state="+Bc(a,"1.23.3"));return b}
function Rc(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Bc(a,"1.23.3");d.data=c;b=r(ia()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.I("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.I(c),na("user",""),a.c=null)}}
function Oa(a,b,c){a=Ga(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}function Ab(a,b){if(a.j.length){var c=0,d=0;b&&window&&(c=window.scrollX,d=window.scrollY);var e=a.j[0];e.ba&&e.ba.focus();b&&window&&window.scrollTo(c,d)}}m.oa=function(a){this.a&&this.a.oa(a);this.g&&this.g.oa(a)};
function Bb(a,b){for(var c=0;c<a.j.length;c++){var d=a.j[c],e=!0;if(0<=b){if(d.Ab)if(b&1)e=d.a,e.D=e.D&-8|10,e=!1;else{var f=d.a;f.D=f.D&-8|9}if(f=e&&d.aa){for(var f=d.l,h=d.Na,g=!0,k=d.$>>>f.c;0<h&&k<f.b.length;)f.b[k].da&&(f.b[k].da=g=!1,f.b[k].xb=!0),h-=f.l,k++;f=g}f&&(e=!1)}if(e)if(1<d.O)switch(d.s){case 2:Ac(d)}else{var g=d.$,k=g+d.Na,l=0,p=0,n=0,e=d.i,H=0,f=d.C,J=h=0,V=d.ra,G=(1<<V)-1;d.rc&&(V=-V,J=16+V);for(;g<k;){var v;v=d.l;var A=g,M=A&v.f,pa=(A&v.g)>>>v.c;v=M!=v.f?v.b[pa].Hb(M,A):v.b[pa++].Ya(M,
A)|v.b[pa&v.u].Ya(0,A+1)<<8;if(d.aa&&v===d.K[l])p+=d.vb;else{d.K[l]=v;(A=J)&&(v=v>>8|(v&255)<<8);p<e&&(e=p);for(M=d.vb;M--;)pa=v>>A&G,zc(d,d.sb,p++,n,pa),A+=V;p>H&&(H=p);n<f&&(f=n);n>=h&&(h=n+1)}g+=2;l++;if(p>=d.i&&(p=0,n++,n>d.C))break}d.aa=!0;e<d.i&&(g=H-e,h-=f,d.c&&(k=e,l=g,e=f,g=h,f=d.i-(k+l),h=l),d.ab.putImageData(d.sb,0,0,e,f,g,h),d.f.drawImage(d.j,0,0,d.j.width,d.j.height,0,0,d.v,d.o))}}}
ua(function(){for(var a=z(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=y(c),c=z(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],h=y(f),h=new Hc(h,d,!0);Ia(h,f);h.F&&Mc(h,h.Ja)}});qa.show.push(function(){for(var a=z(document,"pc8080","computer"),b=0;b<a.length;b++){var c=y(a[b]);(c=Ha("Computer",c.id))&&c.L&&!c.h.P&&c.Ja(-1)}});
qa.exit.push(function(){for(var a=z(document,"pc8080","computer"),b=0;b<a.length;b++){var c=y(a[b]);(c=Ha("Computer",c.id))&&c.h.P&&Qc(c,!(!c.b||c.u),!0)}});var Tc=0;function Uc(a,b,c,d,e,f){e("Loading "+a+"...");r(a,null,!0,function(h,g,k){k?(g||(g="unable to load "+a+" ("+k+")"),f(g,null)):Vc(g,a,b,c,d,e,f)})}
function Vc(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{if(c){Fa(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\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(n){g=null,a=n.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?Wc(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
function Wc(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");r(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);Wc(a,b,c)}})}else c(a,null)}
function Xc(a,b,c,d){function e(a){if(void 0===g){var b=h&&z(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=fa(a))}function f(a){e("Error: "+a);k&&(--Tc||wa(!0));k=!1}var h,g,k=!0;Tc++;Ea[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css";n.styleSheet?n.styleSheet.cssText=l:n.appendChild(document.createTextNode(l));p.appendChild(n)}c||
(c="/versions/pc8080/1.23.3/components.xsl");l=function(d,g){g?Uc(c,null,null,!1,e,function(d,k){if(k)if(Fa(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--Tc||wa(!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),--Tc||wa(!0)):f("invalid machine element: "+
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?Uc(b,a,d,!0,e,l):Vc(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(H){f(H.message)}return k}window.embedPC8080=function(a,b,c,d){wa(!1);return Xc(a,b,c,d)};window.enableEvents=wa;window.sendEvent=xa;
function Yc(a,b,c,d){if(!c&&b){d.push(b);a=Ea[d[0]];b=null;for(var e in a)if(da(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?r(b,null,!0,function(a,b){Zc(b,d)}):Zc(null,d)}else t("Error ("+c+") requesting "+a)}
function Zc(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=Ea[f],k={},l;for(l in g){var p=g[l],n=ca(l);if("xml"==n){for(n=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=n.exec(g[l]);){var H=d[2];H&&(g[H]||(p=p.replace(d[0],"")))}d=l=ba(l)}else"xsl"==n&&(e=l=ba(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,
"&#xA9;"),l=h,g=null,k="data:application/javascript,",k=oa("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+='<div id="'+f+'"></div>\n',c+="...\n",c+='<script type="text/javascript" src="'+h+'">\x3c/script>\n',c+='<script type="text/javascript">embedPC("'+f+'","'+d+'","'+e+'");\x3c/script>\n\n',c+="The machine should appear where the <div> is located.",t(c)):t("Missing XML/XSL resources")}
window.savePC=function(a,b,c){var d=Ha("Computer",a),e=Ha("Debugger",a);if(d){var f=Pc(d,!0),h=d.o?JSON.stringify(d.o):null;b||(b="/versions/pcjs/1.23.3/pc"+(e?"-dbg":"")+".js");if(c&&c({state:f,Cb:h}))return!0;r(b,null,!0,function(c,d,e){Xc(c,d,e,[a,ba(b,!0),h,f])});return!0}t("Unable to identify machine '"+a+"'");return!1};})();
window.savePC=function(a,b,c){var d=Ha("Computer",a),e=Ha("Debugger",a);if(d){var f=Qc(d,!0),h=d.o?JSON.stringify(d.o):null;b||(b="/versions/pcjs/1.23.3/pc"+(e?"-dbg":"")+".js");if(c&&c({state:f,Gb:h}))return!0;r(b,null,!0,function(c,d,e){Yc(c,d,e,[a,ba(b,!0),h,f])});return!0}t("Unable to identify machine '"+a+"'");return!1};})();