JavaScript版『4次元迷路』リリース

[5月12日の記事](https://qiita.com/KoichiYasuoka/items/83e846909b2cfcfc6f24)の続きだが、PC-8001向けゲーム『4次元迷路』(cf.第1回アスキーソフトウェアコンテスト審査発表, ASCII, Vol.8, No.3 (1984年3月), pp.165-172)を、何とかJavaScript上で動かしてみた。

http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/4D-maze/4D-maze.html

6月6日時点でのプログラムリストも、以下に公開しておくことにする。

```
<!DOCTYPE html><head><meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>4-Dimensional Maze by Koichi Yasuoka, June 6, 2025</title>
<script>
var pc8001=new Object();
pc8001.memory=new Array(65536);
pc8001.memory.fill(0);
["0000 C3 00 E0",
 "0018                         FE 0C CA 4C 09 76",
 "0166                   C0",
 "093A                               79 32 62 EA 78 32", // init display
 "0940 65 EA C6 B0 3E 14 8F 32 66 EA D3 30 ED 5B 5A EA",
 "0950 21 00 F3 06 50 73 23 10 FC 70 23 70 23 3A 65 EA",
 "0960 C6 B0 9F C6 02 77 23 72 23 01 50 11 71 23 72 23",
 "0970 10 FA 71 23 70 23 11 00 F3 EB 01 B8 0B ED B0 21",
 "0980 01 01 22 63 EA 3E 20 D3 51 C9",
 "0FAC                                     C5 0E 00 ED", // key-scan
 "0FB0 78 EE FF 20 0D 0C CB 59 28 F5 32 69 EA C1 B7 C0",
 "0FC0 37 C9 06 07 07 38 02 10 FB 79 87 87 87 80 D6 28",
 "0FD0 4F 9F C6 10 47 0A 18 E2 30 31 32 33 34 35 36 37",
 "0FE0 38 39 2A 2B 3D 2C 2E 0D 40 61 62 63 64 65 66 67",
 "0FF0 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77",
 "1000 78 79 7A 5B 5C 5D 5E 2D 30 31 32 33 34 35 36 37",
 "1010 38 39 3A 3B 2C 2E 2F 00",
 "1602       21 76 EA 11 81 06 7B 07 30 06 D3 10 3E 03", // read date
 "1610 18 18 DB 40 B4 C6 10 CB 1E 7B E6 07 20 0A 7D D6",
 "1620 7A 20 02 ED 67 2C 15 C8 3E 05 D3 40 06 3A 10 FE",
 "1630 3E 01 32 67 EA D3 40 1D 18 CE",
 "164C                                     3E 04 D3 10", // reset date
 "1650 3E 05 D3 40 06 3A 10 FE 3E 01 32 67 EA D3 40 C3",
 "1660 02 16",
 "1663          21 7A EA 7E ED 67 2E 76 11 29 03 3E 01", // write date
 "1670 18 19 16 05 7B E6 07 4F CB 0E 9F E6 08 0D 20 0B",
 "1680 4F 7D FE 7A 20 03 7E ED 67 2C 79 D3 10 7A D3 40",
 "1690 06 3A 10 FE 3E 01 32 67 EA D3 40 1D F8 20 D3 3C",
 "16A0 16 03 18 E7",
 "C800 21 47 C8 11 CA CA 01 26 D8 DB 03 E6 20 CC 30 CC",
 "C810 21 5F C8 CD ED 52 C3 81 00 CD F9 E4 E6 03 20 09",
 "C820 3A 1F E9 87 85 E6 04 0F 3C D6 02 86 77 2B E6 07",
 "C830 28 09 FE 04 28 05 34 30 02 35 35 D6 02 C8 FE 04",
 "C840 C8 2B 34 D0 35 35 C9 53 4F 55 4E 44 B0 00 53 54",
 "C850 4F 50 0D 0A 0A 00 53 54 41 52 54 0D 0A 0A 00 BD",
 "C860 C0 B0 C4 CA 20 45 30 30 30 C3 DE BD A1 07 00 CD",
 "C870 F9 E4 E6 0F C6 03 67 CD F9 E4 E6 0F C6 03 6F C9",
 "C880 21 59 E9 56 23 23 5E EB CD CA D2 21 1C E9 35 C8",
 "C890 7E 2A 5A E9 ED 5B 5E E9 19 22 5A E9 4C 2A 5C E9",
 "C8A0 11 50 00 19 22 5C E9 ED 5B 58 E9 19 22 58 E9 69",
 "C8B0 CD E7 D1 AF 32 1C E9 C9 00 00 00 3E 01 0F 10 FD",
 "C8C0 21 1E E9 B6 77 C9 00 00 00 41 04 10 11 06 06 CD",
 "C8D0 30 DA 01 01 00 CD 30 DA CD CE DD C3 F7 CC CD 5F",
 "C8E0 E0 54 5D CD 19 E5 CB 7E 28 0A 3A 33 E9 80 FE 08",
 "C8F0 D2 3C CB C9 7E 36 A0 DD 66 00 DD 6E 01 DD 72 00",
 "C900 DD 73 01 DD 5E 02 DD 56 05 DD 71 02 DD 77 05 4B",
 "C910 CD 19 E5 72 48 0C 21 00 00 44 CD 30 DA 0D 06 06",
 "C920 CD 30 DA 79 FE 04 D0 41 CD BB C8 3A 33 E9 81 FE",
 "C930 08 D2 93 DF 51 CD 93 DF 15 20 16 21 48 E9 11 44",
 "C940 E9 ED A0 ED A0 ED A0 7E 12 36 00 CD 79 DC C3 CE",
 "C950 DD 15 20 16 21 4C E9 11 48 E9 ED A0 ED A0 ED A0",
 "C960 7E 12 36 00 CD F4 DB C3 79 DC CD 6F C8 24 2C 22",
 "C970 4C E9 3E 0D 32 4F E9 C3 F4 DB 00 25 CB 7C 28 15",
 "C980 24 24 18 11 2D CB 7D 28 0C 2C 2C 18 08 0D CB 79",
 "C990 CA C9 C8 0C 0C 7C 85 81 28 57 F2 9F C9 ED 44 08",
 "C9A0 E5 79 D9 4F E1 CD 5F E0 54 5D CD 19 E5 CB 7E C2",
 "C9B0 3C CB 7E 36 A0 DD 66 00 DD 6E 01 DD 72 00 DD 73",
 "C9C0 01 DD 5E 02 DD 56 05 DD 71 02 DD 77 05 E5 D5 D9",
 "C9D0 06 06 CD 30 DA C1 E1 54 5D CD 19 E5 70 EB CD C0",
 "C9E0 DA 06 00 CD 30 DA 08 FE 04 D0 47 CD BB C8 C3 93",
 "C9F0 DF DD 66 00 DD 6E 01 DD 4E 02 CD C0 DA 06 00 CD",
 "CA00 30 DA 21 00 00 01 00 06 CD 30 DA C3 F7 CC 00 00",
 "CA10 00 21 C4 F7 11 46 00 0E 09 06 19 72 23 23 10 FB",
 "CA20 19 0D 20 F5 32 0E E9 87 C6 AD 6F 26 E5 4E 23 6E",
 "CA30 26 E6 11 56 F6 CD AA DE 26 E6 69 11 4C F7 01 78",
 "CA40 00 D5 CD AA DE D1 EB 09 EB 7E B7 20 F4 C3 F9 E4",
 "CA50 00 00 00 00 06 06 DB 08 E6 40 28 0E DB 09 07 07",
 "CA60 30 06 05 07 30 04 10 FB AF C9 3A 0E E9 90 C8 78",
 "CA70 C9 00 51 75 69 65 74 20 34 B0 01 44 69 6D 65 6E",
 "CA80 73 69 6F 6E 61 6C 20 4D 61 7A 65 00 50 75 73 68",
 "CA90 20 52 45 54 55 52 4E 20 4B 65 79 00 3E E8 32 5B",
 "CAA0 EA 01 19 28 CD 3A 09 3E 0C DF 3E 01 32 91 FE 21",
 "CAB0 9B F6 11 78 00 36 C8 19 19 36 A8 01 88 06 19 71",
 "CAC0 10 FC 01 68 03 19 71 10 FC 21 78 CA 11 F6 F3 CD",
 "CAD0 AA DE 11 5A FE CD AA DE 3E 06 CD 11 CA CD CA E5",
 "CAE0 3E 02 32 91 FE CD 54 CA C4 11 CA DB 01 07 38 F5",
 "CAF0 C9 CD 02 16 3A 76 EA CB 37 32 2E E9 21 7C EA 11",
 "CB00 10 00 06 0A 72 19 10 FC AF 32 5A EA 21 00 FF 22",
 "CB10 60 EA 21 66 EA CB 8E C3 BB E5 DD 35 04 C0 DD 36",
 "CB20 04 60 DD 66 00 DD 6E 01 DD 4E 02 CD C0 DA B5 CA",
 "CB30 7B C9 7C B1 CA 84 C9 7C B5 CA 8D C9 DD 66 00 DD",
 "CB40 6E 01 DD 4E 02 DD 46 03 E5 C5 CD BB D5 08 06 00",
 "CB50 CD 30 DA EB CD 6F C8 CB 02 28 04 9F 6F 18 05 CB",
 "CB60 03 9F 2F 67 22 3E E9 C1 E1 54 5D CD 19 E5 DD 7E",
 "CB70 05 77 EB CD E0 E4 54 5D CD 19 E5 CB 7E 20 78 7E",
 "CB80 DD 77 05 36 A0 AF CD 15 CC AF CD 15 CC DD 36 04",
 "CB90 30 EB DD 74 00 DD 75 01 DD 71 02 CD BB D5 F5 06",
 "CBA0 06 CD 30 DA F1 FE 05 D0 47 08 B8 DA 77 DA 78 D9",
 "CBB0 47 CD BB C8 CD 93 DF D9 7C B5 C0 DD 36 04 90 2A",
 "CBC0 3E E9 0D 20 0B 22 44 E9 3E 06 32 47 E9 C3 CE DD",
 "CBD0 0D 20 11 3A 33 E9 FE 06 C8 22 48 E9 3E 09 32 4B",
 "CBE0 E9 C3 79 DC 0D C0 3A 33 E9 FE 05 D0 22 4C E9 3E",
 "CBF0 0D 32 4F E9 C3 F4 DB DD 66 00 DD 6E 01 DD 4E 02",
 "CC00 54 5D CD 19 E5 36 A0 EB CD C0 DA 06 06 CD 30 DA",
 "CC10 3E 02 DD 77 04 DD AD 0F 0F 9F F6 01 87 47 DD 86",
 "CC20 03 FE 06 38 05 EE 01 90 90 90 DD 77 03 C9 00 00",
 "CC30 1A EE 0A 12 0A EE 20 02 0E 8A 02 08 CD ED 52 08",
 "CC40 60 0F 0F 81 6F 23 C3 ED 52 3A 34 E9 E6 03 20 13",
 "CC50 DD 21 A0 E9 DD 7E 04 B7 C4 1A CB DD 7D C6 06 DD",
 "CC60 6F 20 F1 21 47 E9 7E B7 28 11 35 20 0E 36 06 CD",
 "CC70 CE DD 21 46 E9 CD 19 C8 CD CE DD 21 4B E9 7E B7",
 "CC80 28 11 35 20 0E 36 09 CD 79 DC 21 4A E9 CD 19 C8",
 "CC90 CD 79 DC 21 4F E9 7E B7 C8 35 C0 36 0D CD F4 DB",
 "CCA0 21 4E E9 CD 19 C8 C3 F4 DB 00 00 00 60 88 EE BB",
 "CCB0 FC F9 07 88 06 FF F7 F8 70 88 FF BB F0 F8 60 88",
 "CCC0 6E BB F4 F8 70 88 77 FF F0 F8 EE FF 60 88 FE FF",
 "CCD0 FF FF 60 88 06 BB F7 F8 70 FF 07 F8 F0 FF FF FF",
 "CCE0 E0 B8 CE A8 F0 F8 70 88 FF BB F0 F8 70 88 0F 8F",
 "CCF0 66 F8 06 FF 00 00 00 F1 0E 68 CD 9F D8 21 FA DC",
 "CD00 11 09 4A 3E 11 CD 78 E1 2C 1D 20 F7 01 10 00 CD",
 "CD10 24 CD 21 AC CC 11 30 F8 01 48 00 CD 69 D8 C3 8A",
 "CD20 DF 00 00 00 DB 09 0F 38 08 3A C6 E8 FE E3 CA 5B",
 "CD30 E7 C5 CD 01 D8 01 00 02 CD F8 D7 C1 78 B1 0B 20",
 "CD40 E3 C9 00 00 00 00 98 98 98 D8 D8 D8 78 78 78 78",
 "CD50 9F 77 11 44 03 06 1F 47 31 44 0F 07 9F 77 11 00",
 "CD60 0F 07 9F 77 91 44 0B 07 9F 77 F9 00 08 07 F8 77",
 "CD70 F9 00 18 07 F1 70 19 07 F0 70 08 47 F0 74 F0 70",
 "CD80 08 47 00 44 80 70 9F 07 8F 70 11 00 9F 77 01 00",
 "CD90 8F 77 F0 70 11 44 F3 74 F0 70 19 07 F1 70 F0 60",
 "CDA0 99 44 B9 77 F0 50 0F 00 FF 05 C0 70 C4 70 C4 70",
 "CDB0 C0 70 C4 74 C0 70 84 61 C0 70 44 45 00 00 40 00",
 "CDC0 4C 07 C0 70 C0 71 80 70 84 72 C0 70 C4 70 40 70",
 "CDD0 C4 55 C0 50 44 75 C0 50 44 75 00 00 C0 70 C4 7C",
 "CDE0 C0 70 C0 74 C0 70 C0 70 C4 11 C0 50 44 75 00 00",
 "CDF0 C0 70 C0 74 C0 74 C0 70 44 45 C0 70 84 61 C0 70",
 "CE00 44 45 00 00 C0 70 48 61 C0 70 C0 70 00 44 C0 70",
 "CE10 00 44 C0 70 44 45 C0 70 84 34 C0 70 C4 70 C0 70",
 "CE20 C4 74 00 00 C0 70 C4 7C C0 70 C0 74 C0 70 C0 70",
 "CE30 C4 11 00 00 C0 70 C0 74 C0 74 80 70 84 72 C0 50",
 "CE40 44 75 00 00 C0 70 48 61 C0 70 C0 70 00 44 C0 70",
 "CE50 00 44 C0 70 44 45 C0 70 84 34 0C 61 0C 01 4C 47",
 "CE60 0C 07 0C 47 0C 07 00 00 4C 57 04 04 4C 55 04 07",
 "CE70 4C 47 04 04 48 27 08 07 4C 17 0C 01 4C 57 04 04",
 "CE80 4C 47 08 03 00 00 4C 17 04 00 4C 17 08 06 4C 47",
 "CE90 0C 07 4C 07 4C 07 0C 07 00 00 C4 70 04 00 0C 17",
 "CEA0 0C 07 0C 07 4C 55 04 07 00 00 4C 07 4C 07 0C 07",
 "CEB0 48 27 08 07 44 56 0C 04 4C 57 04 04 3E 02 32 20",
 "CEC0 E9 CD 52 DA 0E A8 CD 9F D8 01 40 00 CD 24 CD 3E",
 "CED0 20 D3 51 CD A3 DB 21 8B F7 11 46 CD 01 78 00 1A",
 "CEE0 77 09 13 7B FE 50 20 F7 EB 11 3B F7 01 5A 00 CD",
 "CEF0 69 D8 01 40 00 CD 24 CD 21 5A CE 11 A1 F8 01 62",
 "CF00 00 CD 69 D8 01 40 00 CD 24 CD 3A 10 E9 B7 28 39",
 "CF10 3D 28 45 C6 02 28 55 3D CD 59 E2 2A 3B E9 11 10",
 "CF20 FA 7C B5 28 12 1B 7D B7 28 07 1B 3A 3B E9 CD FC",
 "CF30 E2 3A 3C E9 CD FC E2 3A 3D E9 CD FC E2 21 DA CD",
 "CF40 01 40 00 CD 69 D8 C3 8A DF 21 1A CE 11 11 FA 01",
 "CF50 40 00 CD 69 D8 C3 8A DF 11 12 FA 3E 0A CD FC E2",
 "CF60 21 22 CE 01 38 00 CD 69 D8 C3 8A DF 21 AA CD 11",
 "CF70 18 FA 01 24 00 CD 69 D8 11 FE FA 01 4C 00 CD 69",
 "CF80 D8 C3 8A DF 00 21 00 E9 7E 23 5E 23 4E 23 86 57",
 "CF90 7B 23 86 5F 79 23 86 4F 62 6B CD 19 E5 CB 46 C0",
 "CFA0 D9 3A 00 E9 2A 01 E9 4C 67 CD 19 E5 3A 0D E9 77",
 "CFB0 D9 7E 32 0D E9 36 01 21 00 E9 72 23 73 23 71 21",
 "CFC0 48 E9 11 44 E9 01 08 00 ED B0 2B 70 CD 37 DE CD",
 "CFD0 12 DE CD 1E E0 3A 0D E9 FE 80 CA BC CE FE A0 CA",
 "CFE0 F8 CC C3 77 DA CD AC 0F 21 30 E9 BE C8 77 FE 35",
 "CFF0 CA 85 CF FE 38 CA 50 DF FE 32 CA 3E DF FE 34 CA",
 "D000 2C DF FE 36 CA 1A DF FE 78 CA 01 DF FE 63 CA E2",
 "D010 DE FE 7A CA C3 DE FE BB CA 01 DF FE BF CA E2 DE",
 "D020 FE C2 CA C3 DE C9 DB 06 EE FF 28 0B 0F 38 32 0E",
 "D030 00 0C 0F 30 FC 18 0C DB 07 E6 03 FE 03 C8 0E 04",
 "D040 0F CB 11 79 C6 11 6F 26 E9 7E B7 C8 3A 0D E9 B7",
 "D050 C0 34 79 87 32 0D E9 11 00 00 CD 89 D8 14 20 FA",
 "D060 C9 21 0D E9 7E B7 C8 36 00 0F C6 11 6F 26 E9 35",
 "D070 11 00 00 CD 89 D8 15 20 FA C9 DD 21 60 E9 06 01",
 "D080 DD 7E 07 FE 80 28 33 67 DD 6E 03 CD 1F D1 DD F9",
 "D090 D1 E1 19 E5 33 33 7C D1 E1 19 E5 31 FD FF 6F 3A",
 "D0A0 21 E9 57 5F CB 33 7C 82 BB 30 0B 7D 82 BB 30 06",
 "D0B0 CD 1F D1 04 18 04 DD 36 07 80 DD 7D C6 08 DD 6F",
 "D0C0 FE A0 20 BC 05 C0 AF 32 21 E9 C9 00 00 21 00 00",
 "D0D0 44 CD 30 DA CD 5F E0 11 9A E9 13 13 13 13 13 13",
 "D0E0 1A BC 20 F6 13 1A BD 20 F2 13 1A B9 20 EE 13 13",
 "D0F0 1A B7 28 EA AF 12 13 CD 19 E5 1A 77 CD 77 DA 21",
 "D100 0F E9 35 23 34 C2 92 E2 35 C3 92 E2 3A 33 E9 FE",
 "D110 04 C8 7C C6 11 FE 23 D0 7D C6 11 FE 23 D0 F1 CD",
 "D120 0C E1 CD F9 E0 7E A9 77 C9 3A 21 E9 B7 28 1A D9",
 "D130 11 63 E9 06 08 1A 6F 13 13 13 13 1A 67 FE 80 C4",
 "D140 1F D1 13 13 13 13 10 ED D9 EB 21 60 E9 0A 03 77",
 "D150 23 0A 03 77 23 23 73 23 0A 03 77 23 0A 03 77 23",
 "D160 23 72 23 7D FE A0 20 E5 0A 32 21 E9 C9 00 00 00",
 "D170 7A 87 87 90 94 81 D0 7B 87 87 90 95 81 C9 00 00",
 "D180 00 B9 00 4B 00 4B 00 B9 00 47 FF B5 FF B5 FF 47",
 "D190 FF B9 00 B5 FF B5 FF B9 00 47 FF 4B 00 4B 00 47",
 "D1A0 FF 11 21 01 75 00 75 00 21 01 DF FE 8B FF 8B FF",
 "D1B0 DF FE 21 01 8B FF 8B FF 21 01 DF FE 75 00 75 00",
 "D1C0 DF FE 1A A1 01 A8 00 A8 00 A1 01 5F FE 58 FF 58",
 "D1D0 FF 5F FE A1 01 58 FF 58 FF A1 01 5F FE A8 00 A8",
 "D1E0 00 5F FE 25 00 00 00 FE 11 28 5A D2 08 D6 FE 09",
 "D1F0 28 2D D2 8E D2 3D C2 0C D1 3A 4F E9 B7 CA 0C D1",
 "D200 ED 5B 4C E9 01 06 31 CD 70 D1 D2 0C D1 01 81 D1",
 "D210 CD 29 D1 CD F4 DB AF 32 4F E9 0E 03 C3 CD D0 3A",
 "D220 4B E9 B7 CA 8E D2 ED 5B 48 E9 01 08 30 CD 70 D1",
 "D230 D2 8E D2 01 A2 D1 CD 29 D1 CD 79 DC AF 32 4B E9",
 "D240 0E 02 C3 CD D0 3A 47 E9 B7 CA 08 D6 ED 5B 44 E9",
 "D250 01 0A 2F CD 70 D1 D2 08 D6 01 C3 D1 CD 29 D1 CD",
 "D260 CE DD AF 32 47 E9 0E 01 C3 CD D0 00 00 00 72 02",
 "D270 00 00 E4 04 00 00 C8 08 10 00 80 00 31 01 20 27",
 "D280 00 00 40 4E 00 00 80 8C 00 01 00 08 10 13 3A 33",
 "D290 E9 FE 05 C8 7C C6 1A FE 35 D0 7D C6 1A FE 35 D0",
 "D2A0 F1 25 2D CD 0C E1 CD F9 E0 3E 6A C6 04 CB 09 30",
 "D2B0 FA 16 D2 5F 1A AE 77 23 13 1A AE 77 01 77 00 09",
 "D2C0 13 1A AE 77 23 13 1A AE 77 C9 FE 11 D2 09 D6 FE",
 "D2D0 09 D2 A1 D2 C3 1F D1 00 00 00 21 51 E9 56 23 23",
 "D2E0 5E EB CD CA D2 21 1B E9 35 C8 7E 2A 52 E9 ED 5B",
 "D2F0 56 E9 19 22 52 E9 4C 2A 54 E9 11 B0 FF 19 22 54",
 "D300 E9 ED 5B 50 E9 19 22 50 E9 69 CD E7 D1 AF 32 1B",
 "D310 E9 C9 00 00 00 3E 19 32 1C E9 21 58 E9 36 80 23",
 "D320 36 31 23 36 80 23 36 00 3A 32 E9 D6 31 CD 48 D3",
 "D330 B7 ED 52 22 5C E9 3A 31 E9 CD 48 D3 22 5E E9 21",
 "D340 00 31 C3 09 D6 00 00 00 6F 3A 0E E9 3D 28 1C 3D",
 "D350 28 0D 7D 07 9F 67 29 29 29 29 29 11 68 01 C9 7D",
 "D360 07 9F 67 29 29 29 29 11 A8 02 C9 4F 7D 61 69 87",
 "D370 30 03 ED 44 0C 06 08 87 30 0A CB 7F 28 03 C6 40",
 "D380 23 C6 40 23 29 10 F0 29 11 E8 03 0D C0 AF 95 6F",
 "D390 9F 94 67 C9 00 00 00 3E 19 32 1B E9 21 50 E9 36",
 "D3A0 80 23 36 CF 23 36 80 23 36 00 3A 32 E9 C6 31 CD",
 "D3B0 48 D3 19 22 54 E9 3A 31 E9 CD 48 D3 22 56 E9 21",
 "D3C0 00 CF C3 09 D6 2A 31 E9 01 01 01 DB 01 0F 38 02",
 "D3D0 2D 0D DB 00 07 07 38 03 24 0C 0C 07 07 38 03 25",
 "D3E0 0D 0D 07 07 38 02 2C 0C 0D 28 27 7C C6 24 FE 49",
 "D3F0 38 05 3A 32 E9 67 04 7D C6 24 FE 49 38 06 10 12",
 "D400 3A 31 E9 6F D9 2A 31 E9 CD 09 D6 D9 22 31 E9 CD",
 "D410 09 D6 3A 33 E9 FE 06 C8 21 0C E9 35 C0 36 07 21",
 "D420 30 E9 7E B7 28 08 DB 09 E6 40 C8 36 00 C9 DB 09",
 "D430 E6 40 C0 36 FF 21 35 E9 34 CB 46 C2 97 D3 C3 15",
 "D440 D3 3A 0E E9 FE 04 DA C5 D3 21 0C E9 35 C0 36 07",
 "D450 FE 06 C2 26 D0 C3 E5 CF 00 00 00 7E 36 06 FE 04",
 "D460 D2 20 E4 2A 31 E9 CD 09 D6 21 B8 FE 11 6E F7 01",
 "D470 18 00 ED B0 11 E6 F7 01 18 00 ED B0 11 5E F8 01",
 "D480 18 00 ED B0 C9 00 00 00 7E 36 05 2A 31 E9 FE 04",
 "D490 DC 09 D6 CD 28 D5 0E 00 1E 01 26 03 16 39 2E FD",
 "D4A0 CD EB D4 2C 7D FE 04 20 F7 1C 25 7C FE FC 20 EC",
 "D4B0 61 1C 0E 03 16 39 2E FD CD EB D4 2C 7D FE 04 20",
 "D4C0 F7 1C 0D 79 FE FC 20 EC 21 00 03 16 39 1C 0E FD",
 "D4D0 CD EB D4 0C 79 FE 04 20 F7 25 7C FE FC 20 EC 21",
 "D4E0 00 00 01 00 09 C3 30 DA 00 00 00 E5 79 D9 4F E1",
 "D4F0 CD 5F E0 CD 19 E5 7E D9 14 14 06 03 FE C1 CA 54",
 "D500 D9 06 06 FE A0 CA 54 D9 C9 00 00 00 38 38 38 38",
 "D510 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38",
 "D520 38 38 38 38 38 00 00 00 11 0C D5 CD B0 E3 21 CC",
 "D530 F3 0E 03 06 07 54 5D 3E 33 BE 23 23 20 FB 36 3B",
 "D540 23 36 B8 23 36 49 23 36 38 EB 11 78 00 19 10 E5",
 "D550 19 0D 20 DF 21 D2 42 11 03 1E 3E 11 CD 78 E1 3E",
 "D560 22 CD 78 E1 7C C6 1D 67 7D C6 1D 6F 3E 44 CD 78",
 "D570 E1 3E 88 CD 78 E1 01 03 E3 09 1D 20 DD C9 00 00",
 "D580 00 7E 36 04 2A 31 E9 FE 04 DC 09 D6 CD 28 D5 26",
 "D590 03 1E 01 25 25 0E 03 16 39 2E FD CD EB D4 2C 7D",
 "D5A0 FE 04 20 F7 1C 0D 79 FE FC 20 EC 1C 24 20 E4 21",
 "D5B0 00 00 01 00 09 C3 30 DA 00 00 00 CD C0 DA CB 79",
 "D5C0 28 02 ED 44 84 CB 7C 28 02 94 94 85 CB 7D C8 95",
 "D5D0 95 C9 00 00 00 44 4F 04 00 01 00 88 8E 08 00 03",
 "D5E0 00 00 0C 00 11 17 01 00 08 00 22 2F 02 40 F4 44",
 "D5F0 00 10 00 80 E8 88 00 30 00 00 C0 00 10 71 11 00",
 "D600 80 00 20 F2 22 00 00 00 F1 25 25 2D 2D CD 0C E1",
 "D610 CD F9 E0 3E CF C6 06 CB 09 30 FA 16 D5 5F 06 03",
 "D620 1A AE 77 23 13 10 F9 01 75 00 09 06 03 1A AE 77",
 "D630 23 13 10 F9 C9 00 00 00 3A 0E E9 FE 04 4F 78 32",
 "D640 0E E9 38 10 E5 CB 49 CC 20 E4 21 00 00 22 31 E9",
 "D650 CD 09 D6 E1 11 6E F7 01 18 00 ED B0 11 E6 F7 01",
 "D660 18 00 ED B0 11 5E F8 01 18 00 ED B0 C9 00 00 00",
 "D670 00 00 00 00 00 00 00 1F 5D 55 15 5D 1D D1 55 1D",
 "D680 F1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0F",
 "D690 EF 22 E0 2F E3 F0 2E E3 F0 00 00 00 00 00 00 00",
 "D6A0 00 00 00 00 00 00 00 47 55 44 54 45 54 54 45 54",
 "D6B0 74 00 00 00 00 00 00 00 1F 5D D5 11 5D 55 15 55",
 "D6C0 5D 15 1D D1 11 1D 5D 55 15 5D 55 15 5D 55 1D 0F",
 "D6D0 0F EF 32 0E EF 22 00 00 EF 00 EF F0 00 0F EF 22",
 "D6E0 00 EF 22 00 EF 00 0F 0F 47 55 55 45 55 55 45 44",
 "D6F0 55 44 55 55 55 45 55 55 45 55 55 45 55 44 45 07",
 "D700 00 00 00 00 00 1F 5D 55 1D 5D 55 15 D1 D5 11 5D",
 "D710 D5 11 0F 00 00 00 00 00 00 00 00 00 00 0F EF 00",
 "D720 0F EF 22 00 FE 32 0E EF 32 0E 0F 00 00 00 00 00",
 "D730 00 00 00 00 00 47 55 44 45 55 55 45 55 44 45 55",
 "D740 44 45 07 00 00 00 00 00 00 00 00 C0 84 C0 44 80",
 "D750 84 C0 84 00 00 4C 04 4C 0C 4C 08 70 34 70 45 70",
 "D760 72 70 34 10 01 57 04 07 07 47 03 2E 6A 2E AA 6E",
 "D770 6A 2E 6A EE EE A2 EA A2 E2 A2 E6 8F CB 8F BA 8F",
 "D780 8D 8F CB EF FE A8 FB F8 F8 B8 FC 00 00 00 00 C0",
 "D790 44 C0 C0 C0 40 4C 00 00 00 00 00 00 00 00 00 70",
 "D7A0 45 60 61 70 00 07 00 00 00 00 00 00 00 00 00 2E",
 "D7B0 AA 2E 2E 2E AE A2 0E 00 00 00 00 00 00 00 00 8F",
 "D7C0 BA 9F 9E 8F FF F8 0F 00 00 00 00 00 00 00 CD 54",
 "D7D0 CA C8 21 70 D6 3D CA 38 D6 21 B8 D6 3D CA 38 D6",
 "D7E0 21 00 D7 3D CA 38 D6 21 0E E9 3D CA 81 D5 3D CA",
 "D7F0 88 D4 C3 5B D4 00 00 00 78 B1 0B 20 FB C9 00 00",
 "D800 00 21 34 E9 3A 1D E9 B7 20 10 3A 1E E9 07 38 15",
 "D810 06 0F 07 38 0A 06 1F 07 38 05 AF D3 40 18 0A 7E",
 "D820 A0 FE 08 30 F5 3E 20 D3 40 32 67 EA 34 01 00 02",
 "D830 CD F8 D7 7E E6 0F C0 3A 0E E9 D6 04 C8 3D C8 3A",
 "D840 20 E9 11 B8 FE B7 28 0F 11 4B D7 3D 28 03 11 8B",
 "D850 D7 CB 6E 28 02 CB EB EB 11 8A FD 01 10 00 ED B0",
 "D860 11 02 FE 01 10 00 ED B0 C9 D9 01 03 00 CD 24 CD",
 "D870 D9 ED A0 7B C6 77 5F 30 01 14 ED A0 E0 7B D6 78",
 "D880 5F 30 E6 15 18 E3 00 00 00 3E 20 D3 40 42 10 FE",
 "D890 AF D3 40 42 10 FE 7B B7 C8 1D 18 ED 00 00 00 21",
 "D8A0 53 F3 06 19 1E 12 7E E6 10 B1 77 23 23 1D 20 F6",
 "D8B0 11 54 00 19 10 EE 0E 03 3E 21 D3 51 11 40 40 CD",
 "D8C0 89 D8 3E 20 D3 51 11 FF 20 CD 89 D8 0D 20 E9 3E",
 "D8D0 21 D3 51 32 1D E9 C9 00 00 00 EE FF 60 88 FE FF",
 "D8E0 70 88 0F 8F E6 F8 E0 F8 0E 8F 0F 8F 66 B8 E6 BB",
 "D8F0 FF FF 0F 8F EE BB 0C 8B 0F 8F F7 B8 0F 8B EF FF",
 "D900 0E 8F E6 F8 00 00 00 CD 5B E3 CD 52 DA 0E C8 CD",
 "D910 9F D8 21 FA EA 11 09 2C 3E 11 CD 78 E1 2C 1D 20",
 "D920 F7 01 10 00 CD 24 CD 21 DA D8 11 37 F8 01 2A 00",
 "D930 CD 69 D8 C3 8A DF 00 00 00 00 00 00 00 00 00 FF",
 "D940 FF FF FF FF FF 7D 7B 7D 7B 7D 7B 95 95 E4 E5 2D",
 "D950 3E 00 00 00 78 FE 06 38 36 D5 D9 E1 FE 09 9F E6",
 "D960 E0 C6 88 5F 54 26 78 CD F9 E0 7A C6 02 2B 2B BE",
 "D970 38 FB 28 08 47 0E B8 23 23 CD CC DC 2B 2B 7E BA",
 "D980 20 04 23 73 18 07 42 4B 23 23 CD CC DC D9 78 D5",
 "D990 D9 87 C6 39 6F 26 D9 46 23 4E E1 CD F9 E0 70 23",
 "D9A0 71 D9 C9 00 00 00 7C 3C C0 7D C6 03 FE 07 D0 87",
 "D9B0 C6 3B 57 3E 03 91 FE 07 D0 C6 11 5F C3 54 D9 00",
 "D9C0 00 00 7C 3D C0 7D C6 03 FE 07 D0 87 C6 3B 57 3E",
 "D9D0 03 91 FE 07 D0 3C 5F C3 54 D9 00 00 00 7D B7 C0",
 "D9E0 79 C6 03 FE 07 D0 87 C6 3B 57 3E 03 94 FE 07 D0",
 "D9F0 C6 11 5F C3 54 D9 00 00 00 7C B7 C0 7D C6 03 FE",
 "DA00 07 D0 87 C6 3B 57 3E 03 91 FE 07 D0 C6 09 5F C3",
 "DA10 54 D9 00 00 00 79 B7 C0 7D C6 03 FE 07 D0 87 C6",
 "DA20 3B 57 3E 03 94 FE 07 D0 3C 5F C3 54 D9 00 00 00",
 "DA30 3A 0E E9 D6 04 28 0D 3D C0 CD 15 DA 04 CD F9 D9",
 "DA40 04 C3 DD D9 CD C2 D9 04 CD F9 D9 04 C3 A6 D9 00",
 "DA50 00 00 3A 0E E9 D6 04 C8 3D C8 3A 1E E9 E6 E0 C0",
 "DA60 21 B8 FE 11 40 FA 01 13 00 ED B0 11 B8 FA 01 13",
 "DA70 00 ED B0 C9 00 00 00 FD 21 A0 E9 06 00 FD 7E 04",
 "DA80 B7 28 19 FD 66 00 FD 6E 01 FD 4E 02 CD BB D5 FE",
 "DA90 04 30 09 4F 3E 01 0F 0D 20 FC B0 47 FD 7D C6 06",
 "DAA0 FD 6F 20 D9 78 32 1E E9 C3 93 DF 00 00 00 01 3A",
 "DAB0 E9 13 03 1A B7 28 FA 3D 0A C8 ED 44 C9 00 00 00",
 "DAC0 D5 ED 5B 00 E9 3A 02 E9 91 ED 44 32 3D E9 7C 93",
 "DAD0 32 3B E9 7D 92 32 3C E9 C5 11 05 E9 CD AE DA 67",
 "DAE0 11 08 E9 CD AE DA 6F 11 02 E9 CD AE DA C1 D1 4F",
 "DAF0 C9 00 00 00 01 01 00 04 30 80 00 00 3A 0F E9 FE",
 "DB00 10 C8 21 01 01 4C CD 19 E5 7E E6 A1 C0 61 69 0E",
 "DB10 00 CD 19 E5 7E FE 80 C0 36 A0 21 0F E9 34 21 9E",
 "DB20 E9 01 06 00 09 7E B7 20 FB EB 21 F9 DA 13 ED B8",
 "DB30 CD 92 E2 21 01 01 0E 00 CD BB D5 FE 04 30 09 D9",
 "DB40 47 CD BB C8 CD 93 DF D9 06 06 CD 30 DA 7C B5 C0",
 "DB50 79 FE 03 28 0F D0 CD 6F C8 22 48 E9 3E 09 32 4B",
 "DB60 E9 C3 79 DC 3A 33 E9 FE 06 C8 CD 6F C8 24 2C 22",
 "DB70 4C E9 3E 0D 32 4F E9 C3 F4 DB 00 CD 02 16 3A 11",
 "DB80 E9 21 76 EA BE C8 7E 32 11 E9 23 5E 23 56 EB 11",
 "DB90 07 00 B7 ED 52 D2 07 D9 E6 1F CC FC DA C3 5B E3",
 "DBA0 00 00 00 21 01 F3 11 46 00 0E 19 06 32 72 23 10",
 "DBB0 FC 19 0D 20 F6 21 53 F3 11 77 00 06 19 36 B8 23",
 "DBC0 7E FE 33 28 05 CD BA DC 18 F6 19 10 F0 C9 00 00",
 "DBD0 00 21 22 24 12 48 44 42 84 21 42 22 12 48 24 44",
 "DBE0 84 E1 00 00 1E 68 01 10 86 61 08 80 16 78 00 00",
 "DBF0 87 00 00 00 21 4C E9 01 10 08 CD BA DD E5 CD F9",
 "DC00 E0 3A 1F E9 87 87 87 C6 D1 5F 16 DB 0E 02 06 04",
 "DC10 1A AE 77 23 13 10 F9 79 01 74 00 09 4F 0D 20 EE",
 "DC20 E1 11 04 04 CD DC DC 2C C3 DC DC 00 00 00 21 24",
 "DC30 A2 84 44 12 00 00 00 09 00 00 48 42 54 12 22 84",
 "DC40 21 44 48 2A 42 12 00 00 90 00 00 00 48 22 21 45",
 "DC50 24 84 A1 04 00 00 40 1A 30 A4 04 40 4A 03 48 03",
 "DC60 00 00 30 84 21 0C 00 00 C0 12 C0 52 02 20 25 0C",
 "DC70 58 02 00 00 20 85 00 00 00 21 48 E9 01 11 06 CD",
 "DC80 BA DD E5 CD F9 E0 3A 1F E9 87 5F 87 87 87 83 C6",
 "DC90 2E 5F 16 DC 0E 03 06 06 1A AE 77 23 13 10 F9 79",
 "DCA0 01 72 00 09 4F 0D 20 EE E1 11 02 06 CD DC DC 2C",
 "DCB0 CD DC DC 2C CD DC DC 00 00 00 E5 23 23 7E B7 28",
 "DCC0 06 2B 2B 77 23 18 F4 E1 C9 00 00 00 E5 7E B7 28",
 "DCD0 06 70 41 4F 23 18 F6 E1 C9 00 00 00 E5 44 26 78",
 "DCE0 CD F9 E0 78 82 2B 2B BE 38 FB 28 09 C5 47 23 4E",
 "DCF0 23 CD CC DC C1 2B 7E AB E6 07 20 02 3E 40 C6 78",
 "DD00 4F 2B 7E B8 38 07 23 71 2B 20 EA 18 05 23 23 CD",
 "DD10 CC DC 2B 4E 23 7E FE 33 28 0C 23 79 4E B9 20 F4",
 "DD20 2B CD BA DC 18 EF E1 C9 00 00 00 43 08 48 44 88",
 "DD30 80 80 34 00 10 00 30 44 03 01 00 00 80 00 C0 22",
 "DD40 0C 08 00 2C 01 21 22 11 10 10 C2 43 08 08 88 44",
 "DD50 84 80 34 00 10 30 44 03 00 01 00 00 80 C0 22 0C",
 "DD60 00 08 00 2C 01 01 11 22 12 10 C2 11 42 08 00 00",
 "DD70 80 24 11 00 1E 88 00 00 88 E1 00 00 B0 44 03 30",
 "DD80 44 0B 00 88 24 01 00 00 10 42 88 11 42 08 00 00",
 "DD90 80 24 11 00 D0 22 0C C0 22 0D 00 00 87 11 00 00",
 "DDA0 11 78 00 88 24 01 00 00 10 42 88 00 00 00 B8 30",
 "DDB0 01 78 B9 D8 79 3D C9 00 00 00 7E CD AE DD 77 5F",
 "DDC0 23 7E CD AE DD 77 CB 37 57 EB C9 00 00 00 21 44",
 "DDD0 E9 01 13 03 CD BA DD E5 CD F9 E0 3A 1F E9 87 87",
 "DDE0 87 87 87 C6 2B 5F 16 DD 0E 04 06 08 1A AE 77 23",
 "DDF0 13 10 F9 79 01 70 00 09 4F 0D 20 EE E1 11 01 08",
 "DE00 CD DC DC 2C CD DC DC 2C CD DC DC 2C C3 DC DC 00",
 "DE10 00 00 CD DF E1 3A 47 E9 B7 C4 CE DD 3A 4B E9 B7",
 "DE20 C4 79 DC 3A 4F E9 B7 C4 F4 DB AF 67 6F 22 1B E9",
 "DE30 32 21 E9 C9 00 00 00 3A 47 E9 B7 20 1D 21 00 00",
 "DE40 0E 01 CD 5F E0 CD 19 E5 CB 76 C0 CB 6E 28 0B CD",
 "DE50 6F C8 22 44 E9 3E 06 32 47 E9 3A 4B E9 B7 20 1D",
 "DE60 21 00 00 0E 02 CD 5F E0 CD 19 E5 CB 76 C0 CB 6E",
 "DE70 28 0B CD 6F C8 22 48 E9 3E 09 32 4B E9 3A 4F E9",
 "DE80 B7 C0 21 00 00 0E 03 CD 5F E0 CD 19 E5 7E FE A0",
 "DE90 C0 CD 6F C8 24 2C 22 4C E9 3E 0D 32 4F E9 C9 AF",
 "DEA0 32 47 E9 32 4B E9 32 4F E9 C9 C5 ED A0 13 7E FE",
 "DEB0 95 30 06 B7 20 F5 23 C1 C9 23 46 12 13 13 10 FB",
 "DEC0 23 18 E8 21 09 E9 11 06 E9 CD 62 DF 21 44 E9 11",
 "DED0 04 00 06 03 3E 18 96 23 4E 77 2B 71 19 10 F5 C3",
 "DEE0 12 DE 21 06 E9 11 09 E9 CD 62 DF 21 45 E9 11 04",
 "DEF0 00 06 03 3E 18 96 2B 4E 77 23 71 19 10 F5 C3 12",
 "DF00 DE 21 03 E9 54 5D CD 62 DF 21 09 E9 54 5D CD 62",
 "DF10 DF CD 9F DE CD 37 DE C3 12 DE 21 03 E9 11 09 E9",
 "DF20 CD 62 DF CD 9F DE CD 37 DE C3 12 DE 21 09 E9 11",
 "DF30 03 E9 CD 62 DF CD 9F DE CD 37 DE C3 12 DE 21 06",
 "DF40 E9 11 03 E9 CD 62 DF CD 9F DE CD 37 DE C3 12 DE",
 "DF50 21 03 E9 11 06 E9 CD 62 DF CD 9F DE CD 37 DE C3",
 "DF60 12 DE 06 03 4E 1A 77 79 ED 44 12 23 13 10 F5 3A",
 "DF70 06 E9 2A 07 E9 84 85 E6 02 4F 3A 09 E9 2A 0A E9",
 "DF80 84 85 0F E6 03 A9 32 1F E9 C9 01 00 04 CD 24 CD",
 "DF90 C3 D9 E8 3A 0E E9 D6 04 C8 3D C8 3A 1E E9 0E 78",
 "DFA0 07 38 0C 0E D8 07 38 07 0E B8 07 38 02 0E 18 21",
 "DFB0 58 FA 3E 33 06 02 23 23 BE 20 FB 23 71 21 D0 FA",
 "DFC0 10 F4 C9 00 00 0C 0C 4C 04 4C 08 4C 04 06 4C 04",
 "DFD0 00 4C 4C 0C 48 08 4C 08 8C 04 4C 04 4C 08 00 00",
 "DFE0 00 17 07 57 04 17 06 57 04 00 55 07 00 07 07 07",
 "DFF0 27 07 17 06 17 06 57 04 17 06 11 00 00 00 00 00",
 "E000 C3 D3 E8 00 00 3A 1B E9 B7 C4 DA D2 3A 1C E9 B7",
 "E010 C4 80 C8 3A 21 E9 B7 C2 7A D0 C9 00 00 00 21 B8",
 "E020 FE 3A 0D E9 E6 1E 28 03 21 C5 DF 11 1C FC 01 1C",
 "E030 00 ED B0 11 94 FC 01 1C 00 ED B0 C8 0F 11 36 FC",
 "E040 C3 FC E2 00 00 00 11 3A E9 23 13 35 20 05 34 EB",
 "E050 86 77 C9 34 28 F3 ED 44 EB 86 77 C9 00 00 00 D5",
 "E060 C5 79 44 4D 2A 00 E9 22 3B E9 2A 01 E9 22 3C E9",
 "E070 21 02 E9 CD 46 E0 78 21 05 E9 CD 46 E0 79 21 08",
 "E080 E9 CD 46 E0 3A 3B E9 2A 3C E9 C1 D1 4C 67 C9 00",
 "E090 00 00 3E 07 90 E5 C5 21 28 E9 11 22 E9 01 06 00",
 "E0A0 ED B0 47 48 21 00 00 CD 5F E0 CD 19 E5 7E 12 E6",
 "E0B0 40 20 3A 48 21 01 00 CD 5F E0 CD 19 E5 7E 13 12",
 "E0C0 32 2D E9 48 21 00 FF CD 5F E0 CD 19 E5 7E 13 12",
 "E0D0 48 21 FF 00 CD 5F E0 CD 19 E5 7E 13 12 48 21 00",
 "E0E0 01 CD 5F E0 CD 19 E5 7E 13 12 C1 E1 C9 AF 06 05",
 "E0F0 13 12 10 FC C1 E1 C9 00 00 7D 6C 26 F3 B7 C8 D5",
 "E100 11 78 00 19 3D 20 FC D1 C9 00 00 00 7C C6 33 67",
 "E110 7D C6 31 6F 3E 01 CB 3C 30 02 3E 10 CB 3D 30 01",
 "E120 07 4F CB 3D D0 07 07 4F C9 00 00 00 08 79 0F 0F",
 "E130 0F 0F 4F E6 0F 28 01 23 08 C9 00 00 00 08 79 07",
 "E140 07 07 07 4F E6 F0 28 01 2B 08 C9 00 00 00 11 78",
 "E150 00 CB 01 30 04 0E 10 19 C9 CB 61 C8 0E 01 19 C9",
 "E160 00 00 00 11 88 FF CB 09 30 04 0E 08 19 C9 CB 59",
 "E170 C8 0E 80 19 C9 00 00 00 08 E5 D5 CD 0C E1 CD F9",
 "E180 E0 42 7E B1 77 08 0F DC 2C E1 0F DC 4E E1 0F DC",
 "E190 3D E1 0F DC 63 E1 08 10 E9 D1 E1 C9 00 00 00 CB",
 "E1A0 03 DD 7E 00 DD AE FA DD 2B E6 40 C8 7B C3 78 E1",
 "E1B0 00 00 00 AF DD CB 01 76 28 01 7B CB 03 DD 23 DD",
 "E1C0 CB FF 76 28 01 B3 B7 C2 78 E1 C9 00 00 00 2A 08",
 "E1D0 1E 0D 14 0B 0C 09 06 07 02 05 00 03 00 00 00 CD",
 "E1E0 A3 DB AF 32 20 E9 32 33 E9 21 CE E1 06 07 CD 92",
 "E1F0 E0 DD 21 29 E9 5E 23 56 23 D5 D9 D1 63 6B 1E 11",
 "E200 CD B3 E1 AF 94 67 CD B3 E1 6C CD B3 E1 AF 94 67",
 "E210 CD B3 E1 D9 05 C8 CD 92 E0 D9 54 CB 32 CD 9F E1",
 "E220 CD 9F E1 7C 65 6F CD 9F E1 CD 9F E1 D9 DD CB FF",
 "E230 76 28 C2 DD 7E FF FE C0 20 06 3E 02 32 20 E9 C9",
 "E240 78 32 33 E9 3E 40 DD A6 FA DD A6 FB DD A6 FC DD",
 "E250 A6 FD C8 3E 01 32 20 E9 C9 21 00 00 22 3B E9 22",
 "E260 3C E9 B7 C8 47 21 3E E9 2B 34 7E 36 00 FE 0A 28",
 "E270 F7 77 10 F1 C9 00 00 00 4C 0C 0C 0C 0C 4C 0C 00",
 "E280 00 00 00 C0 C4 C7 07 47 07 07 17 01 00 00 00 00",
 "E290 70 74 3A 0E E9 D6 04 C8 3D C8 21 78 E2 11 1B F5",
 "E2A0 01 0D 00 ED B0 11 93 F5 01 0D 00 ED B0 3A 0F E9",
 "E2B0 CD 59 E2 21 3B E9 11 22 F5 06 03 7E CD FC E2 23",
 "E2C0 10 F9 C9 00 21 76 EA AF 77 23 77 23 77 C3 63 16",
 "E2D0 C0 C4 70 74 40 0C 40 47 40 C4 70 55 40 C4 50 75",
 "E2E0 C0 C0 10 71 C0 44 50 75 C0 44 70 75 40 C4 00 70",
 "E2F0 C0 C4 70 75 C0 C4 50 75 80 84 70 72 E5 21 3B E9",
 "E300 34 35 20 04 B7 28 1E 77 87 87 C6 D0 6F 26 E2 C5",
 "E310 ED A0 ED A0 EB 01 76 00 09 EB ED A0 ED A0 EB 01",
 "E320 86 FF 09 EB C1 E1 13 13 C9 00 00 00 C4 04 0C 4C",
 "E330 4C 0C 4C 04 00 00 00 00 00 00 00 00 00 00 00 00",
 "E340 C0 C4 70 00 07 07 07 07 57 04 00 00 00 00 00 00",
 "E350 00 00 00 00 00 00 70 74 00 00 00 3A 0E E9 D6 04",
 "E360 C8 3D C8 16 F3 21 2C E3 1E AE 01 16 00 ED B0 14",
 "E370 1E 26 01 16 00 ED B0 AF 32 3B E9 21 78 EA 15 1E",
 "E380 B5 06 03 3A 3B E9 B7 28 10 EB 36 80 78 01 78 00",
 "E390 09 36 20 01 88 FF 09 47 EB 13 7E 0F 0F 0F 0F E6",
 "E3A0 0F CD FC E2 7E E6 0F CD FC E2 2B 10 D6 C9 00 00",
 "E3B0 21 33 F3 0E 19 E5 06 1D 36 00 23 10 FB 3E 33 23",
 "E3C0 23 BE 20 FB 23 1A 77 3E 50 23 BE 77 23 20 FA E1",
 "E3D0 79 01 78 00 09 13 4F 0D 20 DB C9 00 00 00 B8 98",
 "E3E0 98 B8 78 78 B8 B8 B8 F8 F8 F8 B8 B8 B8 18 18 B8",
 "E3F0 B8 98 98 B8 98 98 B8 9F 11 03 F8 F9 08 8F 00 0F",
 "E400 11 9F 01 8F F0 11 F3 F0 19 F1 77 44 06 77 00 07",
 "E410 77 44 07 00 77 00 77 70 44 74 70 07 70 00 00 00",
 "E420 11 DE E3 CD B0 E3 EB 11 40 FA 01 13 00 ED B0 11",
 "E430 B8 FA 01 13 00 ED B0 CD 5B E3 CD 92 E2 CD 1E E0",
 "E440 C3 93 DF 00 00 00 05 05 05 01 00 00 00 01 00 00",
 "E450 00 01 07 00 06 00 00 FF FF FF FF FF FF FF FF FF",
 "E460 FF 00 00 00 00 00 00 00 00 00 21 46 E4 11 00 E9",
 "E470 01 21 00 ED B0 21 05 05 4C CD 19 E5 36 01 21 47",
 "E480 E9 11 04 00 06 03 72 19 10 FC 21 A4 E9 11 06 00",
 "E490 06 10 72 19 10 FC 3E B8 32 5B EA 01 19 50 CD 3A",
 "E4A0 09 3E 0C DF 3E 33 32 0C FF 21 2F FF 11 B7 FE 01",
 "E4B0 B8 0B ED B8 CD C4 E2 CD 20 E4 CD F9 E4 E6 07 CA",
 "E4C0 12 DE 3D CA 50 DF 3D CA 3E DF 3D CA 2C DF 3D CA",
 "E4D0 1A DF 3D CA 01 DF 3D CA E2 DE C3 C3 DE 00 00 00",
 "E4E0 78 0F 9F F6 01 CB 48 20 07 CB 50 20 06 84 67 C9",
 "E4F0 85 6F C9 81 4F C9 00 00 00 E5 D5 2A 2E E9 7C 85",
 "E500 57 5D CB 0C 65 2E 00 CB 1C CB 1D 19 19 19 22 2E",
 "E510 E9 7C 85 D1 E1 C9 00 00 00 3E 08 BC 38 27 BD 38",
 "E520 24 B9 38 21 C5 45 3E FF 94 6F 26 C7 D5 04 05 28",
 "E530 06 11 F8 FF 19 10 FD 41 04 05 28 06 11 C0 FF 19",
 "E540 10 FD D1 C1 C9 21 66 01 C9 00 00 00 54 5D CD 19",
 "E550 E5 7E B7 C8 EB 3E FF 12 E5 79 D9 4F E1 CD F9 E4",
 "E560 E6 07 FE 06 30 F7 47 CD E0 E4 54 5D CD 19 E5 EB",
 "E570 CD E0 E4 E5 CD 19 E5 7E 36 FF E1 FE C1 28 D6 30",
 "E580 04 B7 28 19 D9 E5 C5 CD 54 CA C4 11 CA C1 E1 3A",
 "E590 3B E9 B7 28 C3 3D 32 3B E9 20 BD 18 01 12 21 FF",
 "E5A0 C7 01 48 02 34 28 01 35 2B 78 B1 0B 20 F6 C9 7B",
 "E5B0 07 7B 19 7B 2F B3 42 B3 56 C9 6F 2A 8F EF 11 2E",
 "E5C0 39 19 D0 21 D1 C6 22 8F EF C9 21 FF C7 11 FE C7",
 "E5D0 01 48 02 36 C1 ED B8 3E 20 32 3B E9 21 05 05 4C",
 "E5E0 CD 4C E5 0E 08 0D 2E 08 2D 26 08 25 E5 C5 CD 4C",
 "E5F0 E5 C1 E1 25 20 F5 2D 20 EF 0D 20 E9 24 2C CD 19",
 "E600 E5 36 80 C9 00 00 00 41 74 74 61 63 6B 28 46 61",
 "E610 72 29 95 0E 66 A5 01 31 00 41 74 74 61 63 6B 28",
 "E620 42 65 74 77 65 65 6E 29 95 0A 66 A5 01 32 00 41",
 "E630 74 74 61 63 6B 28 4E 65 61 72 29 95 0D 66 A5 01",
 "E640 33 00 4D 61 70 28 50 61 72 61 6C 6C 65 6C 29 95",
 "E650 0C 66 A5 01 34 00 4D 61 70 28 50 65 72 70 65 6E",
 "E660 64 69 63 75 6C 61 72 29 95 07 66 A5 01 35 00 4D",
 "E670 6F 76 65 95 13 53 48 49 46 54 00 53 68 6F 74 A5",
 "E680 10 53 50 41 43 45 00 41 69 6D 00 20 20 55 70 A5",
 "E690 14 38 00 20 20 44 6F 77 6E A5 12 32 00 20 20 4C",
 "E6A0 65 66 74 A5 12 34 00 20 20 52 69 67 68 74 A5 11",
 "E6B0 36 00 00 4D 61 72 6B A5 12 31 B0 01 39 00 44 65",
 "E6C0 6D 61 72 6B A5 12 30 00 00 41 64 76 61 6E 63 65",
 "E6D0 A5 11 35 00 43 68 61 6E 67 65 20 6F 66 20 44 69",
 "E6E0 72 65 63 74 69 6F 6E 00 20 20 55 70 77 61 72 64",
 "E6F0 A5 10 38 00 20 20 44 6F 77 6E 77 61 72 64 A5 0E",
 "E700 32 00 20 20 4C 65 66 74 77 61 72 64 A5 0E 34 00",
 "E710 20 20 52 69 67 68 74 77 61 72 64 A5 0D 36 00 20",
 "E720 20 42 61 63 6B 77 61 72 64 A5 0E 58 00 52 6F 74",
 "E730 61 74 65 00 20 20 43 6C 6F 63 6B 77 69 73 65 A5",
 "E740 0D 43 00 20 20 43 6F 75 6E 74 65 72 63 6C 6F 63",
 "E750 6B 77 69 73 65 A5 06 5A 00 00 00 3E 07 DF 3E 20",
 "E760 D3 51 CD A3 DB CD 65 E8 CD 32 E8 CD 80 E7 C3 D9",
 "E770 E8 00 4C 04 0C 44 0C 4C 04 55 07 07 56 04 57 04",
 "E780 3A 1A E5 3D CD 59 E2 21 72 E7 11 8F FA 01 07 00",
 "E790 ED B0 11 07 FB 01 07 00 ED B0 21 3C E9 11 A0 FA",
 "E7A0 7E CD FC E2 23 7E CD FC E2 CD AA E8 21 3D E9 28",
 "E7B0 08 E6 0F 46 77 2B 70 18 CE 46 CB 40 28 16 2B 7E",
 "E7C0 87 87 86 87 80 FE 1B 30 0B FE 0D 38 0C 21 B7 BD",
 "E7D0 77 BE 28 05 3E 07 DF 18 AE 4F 3C 32 1A E5 32 E4",
 "E7E0 E5 32 E7 E5 32 EA E5 F6 02 1F 67 6F 32 46 E4 22",
 "E7F0 47 E4 22 76 E4 22 DD E5 3E FF 67 91 6F 22 32 E5",
 "E800 54 5D 41 19 10 FD 22 3D E5 E5 19 D1 41 04 19 10",
 "E810 FD AF 95 6F 9F 94 67 22 A2 E5 22 D1 E5 C9 0C 00",
 "E820 4C 04 0C 0C 4C 04 0C 00 47 04 57 04 43 03 57 04",
 "E830 47 04 AF 32 76 EA 2A 90 DB 22 77 EA 16 F8 CD 65",
 "E840 E3 CD AA E8 21 77 EA 28 07 ED 6F 23 ED 6F 18 EC",
 "E850 7E FE 60 30 0B 23 7E 2A 77 EA 22 90 DB FE 24 D8",
 "E860 3E 07 DF 18 D7 21 1E E8 11 CC F6 01 0A 00 ED B0",
 "E870 11 44 F7 01 0A 00 ED B0 21 3B E9 74 3A 96 E8 11",
 "E880 E2 F6 CD FC E2 CD AA E8 28 0B FE 36 30 F7 E6 0F",
 "E890 32 96 E8 18 EA 3E 03 21 00 DB 77 B7 C8 36 10 21",
 "E8A0 4D CC 36 1F 47 CB 3E 10 FC C9 CD 01 D8 21 30 E9",
 "E8B0 06 08 CD AC 0F BE 28 0B 77 FE 0D C8 FE 30 38 03",
 "E8C0 FE 3A D8 10 ED 18 E3 00 00 00 00 D3 E8 00 D4 BD",
 "E8D0 B5 B6 00 31 FF FF CD F1 CA 31 FF FF CD 9C CA CD",
 "E8E0 6A E4 CD 7B DB CD CE D7 CD 41 D4 CD 05 E0 CD 49",
 "E8F0 CC CD 01 D8 3A 34 E9 E6 03 20 ED 18 E5 00 00 00"
].forEach(function(v){
  var t=v.split(/ +/);
  var a=parseInt(t[0],16);
  var i;
  for(i=1;i<t.length;i++)
    pc8001.memory[a+i-1]=parseInt(t[i],16);
});
pc8001.font=[
// 0x00 - 0x07
  "-------- -###---- -###---- -###---- -###---- ###----- --#----- -###----",
  "-------- -#------ -#------ -#------ -#------ #------- -#-#---- -#--#---",
  "-------- -###---- -###---- -###---- -###---- ###----- -###---- -###----",
  "-------- ---##-#- ---#--#- -#----#- -#------ #---##-- -#-#--#- -#--#---",
  "-------- -####-#- -###-#-- -###-#-- -######- ####--#- -#-#-#-- -###-#--",
  "-------- ----###- ----#--- ----#--- -----#-- ---#--#- ---##--- -----#--",
  "-------- ----#-#- ---#-#-- ---#-#-- -----#-- ---#--#- ---#-#-- -----#--",
  "-------- ----#-#- --#---#- --#---#- -----#-- ----##-# ---#--#- -----###",
// 0x08 - 0x0f
  "-###---- -#-#---- -#------ -#-#---- --####-- --###--- -###---- -###----",
  "-#--#--- -#-#---- -#------ -#-#---- -#------ -#------ -#------ -#------",
  "-###---- -###---- -#------ -###---- -#------ -#------ -###---- -###----",
  "-#--#### -#-#---- -#--###- -#-#---- -#---#-- --#####- ---#---- ---#----",
  "-###-#-- -#-####- -####--- -#-#---# --###--- ----#--# -#####-- -######-",
  "-----### -----#-- ----##-- ---##-## ----#--- ----###- ---#--#- -----#--",
  "-------# -----#-- ----#--- ---#-#-# ----#--- ----#-#- ---#--#- -----#--",
  "-----### -----#-- ----#--- ---#---# ----#### ----#--# ----##-- ----###-",
// 0x10 - 0x17
  "-###---- -###---- -###---- -###---- -###---- -#--#--- -###---- -###----",
  "-#--#--- -#--#--- -#--#--- -#--#--- -#--#--- -##-#--- -#------ -#------",
  "-#--#--- -#--#--- -#--#--- -#--#--- -#--#--- -#-##--- -###---- -###----",
  "-#--#### -#--#-#- -#--###- -#--#### -#--#-#- -#--#--# ---#---- -#--###-",
  "-###-#-- -###-##- -###---# -###---# -###-##- -#--#-#- -####--# -####--#",
  "-----### ------#- -----##- -----### ----#-#- ----##-- ----##-# ----###-",
  "-----#-- ------#- ----#--- -------# ---##### ----#-#- ----#-## ----#--#",
  "-----### -----### ----#### ----#### ------#- ----#--# ----#--# ----###-",
// 0x18 - 0x1f
  "--###--- -###---- -###---- -###---- -------- -------- -------- --------",
  "-#------ -#------ -#------ -#------ ----#--- ---#---- ----#--- ----#---",
  "-#------ -###---- -###---- -###---- -----#-- --#----- ---###-- ----#---",
  "--###--- -#------ ---###-- -#------ -######- -######- --#-#-#- ----#---",
  "----#--# -###---# -###--#- -######- -----#-- --#----- ----#--- --#-#-#-",
  "----##-# ---##-## ---###-- ---#---- ----#--- ---#---- ----#--- ---###--",
  "----#-## ---#-#-# ---#--#- ---#---- -------- -------- ----#--- ----#---",
  "----#--# ---#---# ---###-- ----###- -------- -------- -------- --------",
// 0x20 - 0x27
  "-------- ----#--- --#--#-- --#--#-- ----#--- -------- --##---- -----#--",
  "-------- ----#--- --#--#-- --#--#-- ---####- -##---#- -#--#--- ----#---",
  "-------- ----#--- --#--#-- -######- --#-#--- -##--#-- -#--#--- ---#----",
  "-------- ----#--- -------- --#--#-- ---###-- ----#--- --##---- --------",
  "-------- -------- -------- -######- ----#-#- ---#---- -#--#-#- --------",
  "-------- -------- -------- --#--#-- --####-- --#--##- -#---#-- --------",
  "-------- ----#--- -------- --#--#-- ----#--- -#---##- --###-#- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0x28 - 0x2f
  "-----#-- --#----- ----#--- -------- -------- -------- -------- --------",
  "----#--- ---#---- --#-#-#- ----#--- -------- -------- -------- ------#-",
  "---#---- ----#--- ---###-- ----#--- -------- -------- -------- -----#--",
  "---#---- ----#--- --#####- --#####- -------- -######- -------- ----#---",
  "---#---- ----#--- ---###-- ----#--- -------- -------- -------- ---#----",
  "----#--- ---#---- --#-#-#- ----#--- ----#--- -------- ---##--- --#-----",
  "-----#-- --#----- ----#--- -------- ----#--- -------- ---##--- -#------",
  "-------- -------- -------- -------- ---#---- -------- -------- --------",
// 0x30 - 0x37
  "--####-- ----#--- --####-- --####-- -----#-- -######- ---###-- -######-",
  "-#----#- ---##--- -#----#- -#----#- ----##-- -#------ --#----- -#----#-",
  "-#---##- --#-#--- ------#- ------#- ---#-#-- -####--- -#------ -----#--",
  "-#-##-#- ----#--- ----##-- ---###-- --#--#-- -----#-- -#####-- ----#---",
  "-##---#- ----#--- --##---- ------#- -######- ------#- -#----#- ---#----",
  "-#----#- ----#--- -#------ -#----#- -----#-- -#---#-- -#----#- ---#----",
  "--####-- --#####- -######- --####-- -----#-- --###--- --####-- ---#----",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0x38 - 0x3f
  "--####-- --####-- -------- -------- ----###- -------- -###---- --####--",
  "-#----#- -#----#- -------- -------- ---##--- -------- ---##--- -#----#-",
  "-#----#- -#----#- ----#--- ----#--- --##---- -######- ----##-- ------#-",
  "--####-- --#####- -------- -------- -##----- -------- -----##- ----##--",
  "-#----#- ------#- -------- -------- --##---- -######- ----##-- ---#----",
  "-#----#- -----#-- ----#--- ----#--- ---##--- -------- ---##--- --------",
  "--####-- --###--- -------- ----#--- ----###- -------- -###---- ---#----",
  "-------- -------- -------- ---#---- -------- -------- -------- --------",
// 0x40 - 0x47
  "---###-- ---##--- -#####-- ---###-- -####--- -######- -######- ---###--",
  "--#---#- --#--#-- --#---#- --#---#- --#--#-- -#------ -#------ --#---#-",
  "-#--#-#- -#----#- --#---#- -#------ --#---#- -#------ -#------ -#------",
  "-#-#-##- -######- --####-- -#------ --#---#- -####--- -####--- -#--###-",
  "-#--##-- -#----#- --#---#- -#------ --#---#- -#------ -#------ -#----#-",
  "--#----- -#----#- --#---#- --#---#- --#--#-- -#------ -#------ --#---#-",
  "---####- -#----#- -#####-- ---###-- -####--- -######- -#------ ---###--",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0x48 - 0x4f
  "-#----#- ---###-- ----###- -#----#- -#------ -#----#- -#----#- ---##---",
  "-#----#- ----#--- -----#-- -#---#-- -#------ -##--##- -##---#- --#--#--",
  "-#----#- ----#--- -----#-- -#--#--- -#------ -#-##-#- -#-#--#- -#----#-",
  "-######- ----#--- -----#-- -###---- -#------ -#-##-#- -#--#-#- -#----#-",
  "-#----#- ----#--- -----#-- -#--#--- -#------ -#----#- -#---##- -#----#-",
  "-#----#- ----#--- -#---#-- -#---#-- -#------ -#----#- -#----#- --#--#--",
  "-#----#- ---###-- --###--- -#----#- -######- -#----#- -#----#- ---##---",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0x50 - 0x57
  "-#####-- ---##--- -#####-- --####-- --#####- -#----#- -#----#- -#----#-",
  "-#----#- --#--#-- -#----#- -#----#- ----#--- -#----#- -#----#- -#----#-",
  "-#----#- -#----#- -#----#- -#------ ----#--- -#----#- -#----#- -#----#-",
  "-#####-- -#----#- -#####-- --####-- ----#--- -#----#- --#--#-- -#-##-#-",
  "-#------ -#--#-#- -#--#--- ------#- ----#--- -#----#- --#--#-- -#-##-#-",
  "-#------ --#--#-- -#---#-- -#----#- ----#--- -#----#- ---##--- -##--##-",
  "-#------ ---##-#- -#----#- --####-- ----#--- --####-- ---##--- -#----#-",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0x58 - 0x5f
  "-#----#- --#---#- -######- --####-- --#---#- --####-- ----#--- --------",
  "-#----#- --#---#- ------#- --#----- --#---#- -----#-- ---#-#-- --------",
  "--#--#-- --#---#- -----#-- --#----- ---#-#-- -----#-- --#---#- --------",
  "---##--- ---###-- ---##--- --#----- --#####- -----#-- -------- --------",
  "--#--#-- ----#--- --#----- --#----- ----#--- -----#-- -------- --------",
  "-#----#- ----#--- -#------ --#----- --#####- -----#-- -------- --------",
  "-#----#- ----#--- -######- --####-- ----#--- --####-- -------- -######-",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0x60 - 0x67
  "-------- -------- -#------ -------- ------#- -------- ----##-- --------",
  "-------- -------- -#------ -------- ------#- -------- ---#--#- --------",
  "-------- --####-- -#-###-- --####-- --###-#- --####-- ---#---- --###-#-",
  "-------- -----#-- -##---#- -#----#- -#---##- -#----#- -#####-- -#---##-",
  "-------- --####-- -#----#- -#------ -#----#- -######- ---#---- -#---##-",
  "-------- -#---#-- -##---#- -#----#- -#---##- -#------ ---#---- --###-#-",
  "-------- --###-#- -#-###-- --####-- --###-#- --####-- ---#---- ------#-",
  "-------- -------- -------- -------- -------- -------- -------- --####--",
// 0x68 - 0x6f
  "-#------ ----#--- -----#-- -#------ ---##--- -------- -------- --------",
  "-#------ -------- -------- -#------ ----#--- -------- -------- --------",
  "-#-###-- ---##--- ----##-- -#---#-- ----#--- -###-##- -#-###-- --####--",
  "-##---#- ----#--- -----#-- -#--#--- ----#--- -#--#--# -##---#- -#----#-",
  "-#----#- ----#--- -----#-- -#-#---- ----#--- -#--#--# -#----#- -#----#-",
  "-#----#- ----#--- -----#-- -##-#--- ----#--- -#--#--# -#----#- -#----#-",
  "-#----#- ---###-- -#---#-- -#---#-- ---###-- -#--#--# -#----#- --####--",
  "-------- -------- --###--- -------- -------- -------- -------- --------",
// 0x70 - 0x77
  "-------- -------- -------- -------- ---#---- -------- -------- --------",
  "-------- -------- -------- -------- ---#---- -------- -------- --------",
  "-#-###-- --###-#- -#-###-- --#####- -#####-- -#----#- -#----#- -#-----#",
  "-##---#- -#---##- -##---#- -#------ ---#---- -#----#- -#----#- -#--#--#",
  "-##---#- -#---##- -#------ --####-- ---#---- -#----#- -#----#- -#--#--#",
  "-#-###-- --###-#- -#------ ------#- ---#--#- -#---##- --#--#-- -#--#--#",
  "-#------ ------#- -#------ -#####-- ----##-- --###-#- ---##--- --##-##-",
  "-#------ ------#- -------- -------- -------- -------- -------- --------",
// 0x78 - 0x7f
  "-------- -------- -------- ----###- ----#--- -###---- --##---- --------",
  "-------- -------- -------- ---#---- ----#--- ----#--- -#--#--# --------",
  "-#----#- -#----#- -######- ---#---- -------- ----#--- -----##- --------",
  "--#--#-- -#----#- -----#-- --#----- -------- -----#-- -------- --------",
  "---##--- -#---##- ---##--- ---#---- -------- ----#--- -------- --------",
  "--#--#-- --###-#- --#----- ---#---- ----#--- ----#--- -------- --------",
  "-#----#- ------#- -######- ----###- ----#--- -###---- -------- --------",
  "-------- --####-- -------- -------- -------- -------- -------- --------",
// 0x80 - 0x87
  "-------- -------- -------- -------- -------- -------- -------- ########",
  "-------- -------- -------- -------- -------- -------- ######## ########",
  "-------- -------- -------- -------- -------- ######## ######## ########",
  "-------- -------- -------- -------- ######## ######## ######## ########",
  "-------- -------- -------- ######## ######## ######## ######## ########",
  "-------- -------- ######## ######## ######## ######## ######## ########",
  "-------- ######## ######## ######## ######## ######## ######## ########",
  "######## ######## ######## ######## ######## ######## ######## ########",
// 0x88 - 0x8f
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ----#---",
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ----#---",
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ----#---",
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ----#---",
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ########",
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ----#---",
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ----#---",
  "#------- ##------ ###----- ####---- #####--- ######-- #######- ----#---",
// 0x90 - 0x97
  "----#--- -------- ----#--- ----#--- ######## -------- ----#--- -------#",
  "----#--- -------- ----#--- ----#--- -------- -------- ----#--- -------#",
  "----#--- -------- ----#--- ----#--- -------- -------- ----#--- -------#",
  "----#--- -------- ----#--- ----#--- -------- -------- ----#--- -------#",
  "######## ######## #####--- ----#### -------- ######## ----#--- -------#",
  "-------- ----#--- ----#--- ----#--- -------- -------- ----#--- -------#",
  "-------- ----#--- ----#--- ----#--- -------- -------- ----#--- -------#",
  "-------- ----#--- ----#--- ----#--- -------- -------- ----#--- -------#",
// 0x98 - 0x9f
  "-------- -------- ----#--- ----#--- -------- -------- ----#--- ----#---",
  "-------- -------- ----#--- ----#--- -------- -------- ----#--- ----#---",
  "-------- -------- ----#--- ----#--- -------- -------- ----#--- ----#---",
  "-------- -------- ----#--- ----#--- -------- -------- -----#-- ---#----",
  "----#### #####--- ----#### #####--- ------## ###----- ------## ###-----",
  "----#--- ----#--- -------- -------- -----#-- ---#---- -------- --------",
  "----#--- ----#--- -------- -------- ----#--- ----#--- -------- --------",
  "----#--- ----#--- -------- -------- ----#--- ----#--- -------- --------",
// 0xa0 - 0xa7
  "-------- -------- ---###-- -------- -------- -------- -------- --------",
  "-------- -------- ---#---- -------- -------- -------- -######- --------",
  "-------- -------- ---#---- -------- -------- -------- ------#- --#####-",
  "-------- -------- ---#---- ----#--- -------- ---##--- -######- ------#-",
  "-------- --###--- -------- ----#--- --#----- ---##--- ------#- ----##--",
  "-------- --#-#--- -------- ----#--- ---#---- -------- -----#-- ----#---",
  "-------- --###--- -------- --###--- ----#--- -------- --###--- ---#----",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xa8 - 0xaf
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-----#-- ----#--- -------- -----#-- ---#---- -------- --####-- --------",
  "----#--- --#####- --#####- --#####- --#####- ---###-- -----#-- --#-#-#-",
  "---##--- --#---#- ----#--- ----##-- ---#--#- -----#-- --####-- --#-#-#-",
  "--#-#--- ------#- ----#--- ---#-#-- ---#-#-- -----#-- -----#-- ------#-",
  "----#--- ----##-- --#####- --#--#-- ---#---- --#####- --####-- ----##--",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xb0 - 0xb7
  "-------- -######- ------#- ----#--- -------- ----#--- ---#---- ----#---",
  "-------- ------#- -----#-- -######- --#####- -######- -######- --#####-",
  "-------- ------#- ----#--- -#----#- ----#--- ----#--- ---#--#- ----#---",
  "--#####- ---#-#-- ---##--- -#----#- ----#--- ---##--- ---#--#- --#####-",
  "-------- ---##--- --#-#--- ------#- ----#--- --#-#--- ---#--#- ----#---",
  "-------- ---#---- -#--#--- -----#-- ----#--- -#--#--- ---#--#- ----#---",
  "-------- --#----- ----#--- --###--- --#####- ----#--- --#--#-- ----#---",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xb8 - 0xbf
  "---####- --#----- -------- --#--#-- -------- -######- --#----- -#----#-",
  "--#---#- --#####- -######- -######- -###---- ------#- -######- -#----#-",
  "-#----#- -#--#--- ------#- --#--#-- -------- -----#-- --#---#- --#---#-",
  "-----#-- ----#--- ------#- --#--#-- -###--#- ----#--- --#--#-- ------#-",
  "----#--- ----#--- ------#- -----#-- ------#- ---##--- --#----- -----#--",
  "---#---- ----#--- ------#- ----#--- -----#-- --#--#-- --#----- ----#---",
  "-##----- ---#---- -######- ---#---- -####--- -#----#- ---####- --##----",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xc0 - 0xc7
  "---####- -----#-- -------- --####-- ---#---- ----#--- -------- --------",
  "--#---#- --###--- -#-#--#- -------- ---#---- ----#--- --####-- --#####-",
  "-##---#- ----#--- -#-#--#- -######- ---#---- -######- -------- ------#-",
  "---#-#-- -######- -#-#--#- ----#--- ---##--- ----#--- -------- ---#-#--",
  "----#--- ----#--- -----#-- ----#--- ---#-#-- ----#--- -------- ----#---",
  "---#---- ----#--- ----#--- ---#---- ---#---- ---#---- -------- ---#-#--",
  "-##----- -###---- -###---- --#----- ---#---- --#----- -######- --#-----",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xc8 - 0xcf
  "----#--- ------#- ---#---- -#------ -------- -------- ----#--- -######-",
  "--#####- ------#- ----#--- -#------ -######- ---#---- --#####- ------#-",
  "-----#-- ------#- -----#-- -######- ------#- --#-#--- ----#--- ------#-",
  "----#--- -----#-- -#----#- -#------ ------#- -#---#-- ----#--- -----#--",
  "---###-- ----#--- -#----#- -#------ -----#-- ------#- --#-#-#- --#-#---",
  "--#-#-#- ---#---- -#----#- -#------ ----#--- ------#- --#-#-#- ---#----",
  "----#--- --#----- -#----#- --#####- --##---- -------- ----#--- ----#---",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xd0 - 0xd7
  "-------- -----#-- -------- -------- --#----- -------- -######- --####--",
  "--####-- ----#--- ------#- -######- --#----- --###--- ------#- --------",
  "-------- ---#---- ------#- ---#---- -######- ----#--- ------#- -######-",
  "--####-- --#----- ---#-#-- -######- --#---#- ----#--- -######- ------#-",
  "-------- -#--#--- ----#--- ---#---- --#--#-- ----#--- ------#- -----#--",
  "-#####-- -#####-- ---#-#-- ---#---- --#----- ----#--- ------#- ----#---",
  "------#- ------#- -##----- ---####- --#----- -######- -######- ---#----",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xd8 - 0xdf
  "-#----#- --#-#--- --#----- -------- -------- -------- ---#---- -###----",
  "-#----#- --#-#--- --#----- -######- -######- -###---- -#--#--- -#-#----",
  "-#----#- --#-#--- --#----- -#----#- -#----#- ------#- --#----- -###----",
  "-#----#- --#-#-#- --#---#- -#----#- -#----#- ------#- -------- --------",
  "------#- --#-#-#- --#--#-- -#----#- ------#- -----#-- -------- --------",
  "-----#-- --#-##-- --#-#--- -#----#- -----#-- ----#--- -------- --------",
  "---##--- -#--#--- --##---- -######- ---##--- -###---- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
// 0xe0 - 0xe7
  "-------- ----#--- ----#--- ----#--- -------# #------- ######## ########",
  "-------- ----#--- ----#--- ----#--- ------## ##------ -####### #######-",
  "######## ----#### ######## #####--- -----### ###----- --###### ######--",
  "-------- ----#--- ----#--- ----#--- ----#### ####---- ---##### #####---",
  "-------- ----#--- ----#--- ----#--- ---##### #####--- ----#### ####----",
  "######## ----#### ######## #####--- --###### ######-- -----### ###-----",
  "-------- ----#--- ----#--- ----#--- -####### #######- ------## ##------",
  "-------- ----#--- ----#--- ----#--- ######## ######## -------# #-------",
// 0xe8 - 0xef
  "----#--- --##-##- ----#--- ---###-- -------- -------- -------# #-------",
  "---###-- -####### ---###-- ---###-- --####-- --####-- ------#- -#------",
  "--#####- -####### --#####- -####### -######- -#----#- -----#-- --#-----",
  "-####### -####### -####### -####### -######- -#----#- ----#--- ---#----",
  "-####### --#####- --#####- -##-#-## -######- -#----#- ---#---- ----#---",
  "---###-- ---###-- ---###-- ----#--- -######- -#----#- --#----- -----#--",
  "--#####- ----#--- ----#--- --#####- --####-- --####-- -#------ ------#-",
  "-------- -------- -------- -------- -------- -------- #------- -------#",
// 0xf0 - 0xf7
  "#------# -####### -#------ --###### -####### -----#-- -------- --###-#-",
  "-#----#- -#--#--# -######- --#----# -#-----# ###-###- ---##--- ---#--#-",
  "--#--#-- -#--#--# -#--#--- --###### -#-----# #-#--#-- --#--#-- -#######",
  "---##--- -####### --####-- --#----# -####### ###-#### -#----#- ---#-###",
  "---##--- -#-----# --#-#--- --###### -#-----# #-#---#- --####-- --###-##",
  "--#--#-- -#-----# -######- --#----# -#-----# ###-#### ---#-#-- -#-#--#-",
  "-#----#- -#-----# ----#--- -#-----# -####### ----#-#- --#--#-- ---#-#--",
  "#------# -------- -------- -------- -------- ------#- -------- --------",
// 0xf8 - 0xff
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------",
  "-------- -------- -------- -------- -------- -------- -------- --------"];
pc8001.display=new Object();
pc8001.display.columns=40;
pc8001.display.initColor=0xe8;
pc8001.initDisplay=function(svg){
  var d=pc8001.display;
  var x,y,e,t,c;
  d.svg=svg;
  d.lines=25;
  d.reverse=0;
  d.colors=new Array(256);
  d.colors.fill("control");
  for(x=0;x<8;x++){
    d.colors[0x08+x]="rgb(0 0 0)";
    d.colors[0x18+x]="#000000";
    d.colors[0x28+x]="rgb(0 0 255)";
    d.colors[0x38+x]="#0000ff";
    d.colors[0x48+x]="rgb(255 0 0)";
    d.colors[0x58+x]="#ff0000";
    d.colors[0x68+x]="rgb(255 0 255)";
    d.colors[0x78+x]="#ff00ff";
    d.colors[0x88+x]="rgb(0 255 0)";
    d.colors[0x98+x]="#00ff00";
    d.colors[0xa8+x]="rgb(0 255 255)";
    d.colors[0xb8+x]="#00ffff";
    d.colors[0xc8+x]="rgb(255 255 0)";
    d.colors[0xd8+x]="#ffff00";
    d.colors[0xe8+x]="rgb(255 255 255)";
    d.colors[0xf8+x]="#ffffff";
  }
  e=document.createElementNS("http://www.w3.org/2000/svg","text");
  e.setAttribute("font-family","monospace");
  e.setAttribute("font-size",2);
  e.setAttribute("fill","none");
  d.svg.appendChild(e);
  e.textContent=String.fromCodePoint(0x2588);
  d.monowidth=(e.getBBox().width<2)?1:2;
  e=[[0x3000,0x2598,0x259d,0x2580],
     [0x2596,0x258c,0x259e,0x259b],
     [0x2597,0x259a,0x2590,0x259c],
     [0x2584,0x2599,0x259f,0x2588]];
  if(pc8001.display.monowidth<2)
    e[0][0]=0xa0;
  d.font=new Array(256);
  d.font.fill("");
  d.font.forEach(function(v,x,a){
    var t=new Array(8);
    var i,j
    for(i=j=0;i<8;i++){
      t[i]=pc8001.font[(x&0xf8)+i].split(" ")[x%8].replace(/-/g,"0").replace(/#/g,"1");
      if(t[i]=="00000000")
        j++;
    }
    if(j!=8){
      for(i=0;i<8;i+=2){
        for(j=0;j<8;j+=2)
          a[x]+=String.fromCodePoint(e[parseInt(t[j+1].substr(i+1,1)+t[j].substr(i+1,1),2)][parseInt(t[j+1].substr(i,1)+t[j].substr(i,1),2)]);
      }
    }
  });
  d.blocks=new Array(256);
  d.blocks.fill("");
  for(x=1;x<256;x++){
    if((x&0xcc)>0)
      d.blocks[x]+=String.fromCodePoint(e[(x>>4)&3][x&3],e[(x>>6)&3][(x>>2)&3]);
    else
      d.blocks[x]+=String.fromCodePoint(e[(x>>4)&3][x&3]);
  }
  d.bgchars=new Array(56);
  d.bgchars.fill("");
  for(x=0;x<4;x++){
    d.bgchars[0x04+x]=d.bgchars[0x14+x]=d.bgchars[0x24+x]=d.bgchars[0x34+x]=String.fromCodePoint(0x2588);
    d.bgchars[0x10+x]=String.fromCodePoint(0x258f);
    d.bgchars[0x20+x]=String.fromCodePoint(0x2595);
    d.bgchars[0x30+x]=String.fromCodePoint(0x258c,e[0][0],e[0][0],0x2590);
  }
  e=document.createElementNS("http://www.w3.org/2000/svg","path");
  e.setAttribute("id","charpath");
  t=(d.monowidth<2)?"2.4":"4";
  e.setAttribute("d","M 0 1 h "+t+" m -"+t+" 1 h "+t+" m -"+t+" 1 h "+t+" m -"+t+" 1 h "+t);
  d.svg.appendChild(e);
  e=document.createElementNS("http://www.w3.org/2000/svg","g");
  e.setAttribute("class","blink");
  d.svg.appendChild(e);
  d.blinker=e;
  d.textArray=t=new Array(80);
  for(x=0;x<80;x++)
    t[x]=new Array(25);
  d.start=d.end=0xf300;
  for(y=0;y<25;y++){
    for(x=0;x<80;x++){
      pc8001.memory[d.end]=0;
      d.end++;
      t[x][y]=new Object();
      t[x][y].color=d.colors[d.initColor];
      c=(x%2==0||d.columns==80)?d.colors[d.initColor]:"none";
      e=document.createElementNS("http://www.w3.org/2000/svg","text");
      e.setAttribute("y",x*2);
      e.setAttribute("x",y*4);
      e.setAttribute("font-size",160/d.columns);
      e.setAttribute("font-family","monospace"); 
      e.setAttribute("fill",c);
      e.setAttribute("transform","matrix(0 1 1 0 "+((d.monowidth<2)?128:144)/d.columns+" 0)");
      e.setAttribute("textLength",4);
      e.setAttribute("lengthAdjust","spacingAndGlyphs");
      d.svg.appendChild(e);
      t[x][y].controlbox=e;
      t[x][y].control=d.reverse;
      e=document.createElementNS("http://www.w3.org/2000/svg","text");
      e.setAttribute("font-family","monospace");
      if(d.colors[d.initColor].substr(0,1)=="#"){
        e.setAttribute("font-size",2);
        e.setAttribute("transform","matrix(0 "+((d.monowidth<2)?5/3:1)+" "+80/d.columns+" 0 "+(x*2+72/d.columns)+" "+y*100/d.lines+")");
      }
      else{
        e.setAttribute("font-size",1);
        e.setAttribute("transform","matrix(0 "+((d.monowidth<2)?5/3:1)+" "+40/d.columns+" 0 "+x*2+" "+y*100/d.lines+")");
      }
      e.setAttribute("fill",c);
      d.svg.appendChild(e);
      t[x][y].textbox=e;
      e=document.createElementNS("http://www.w3.org/2000/svg","textPath");
      e.setAttribute("href","#charpath");
      t[x][y].textbox.appendChild(e);
      t[x][y].textpath=e;
      t[x][y].data=0;
    }
    pc8001.memory[d.end]=0;
    d.end++;
    pc8001.memory[d.end]=0;
    d.end++;
    pc8001.memory[d.end]=(d.columns==40)?2:1;
    d.end++;
    for(x=3;x<39;x++){
      pc8001.memory[d.end]=(x%2==0)?80:d.initColor;
      d.end++;
    }
    pc8001.memory[d.end]=0;
    d.end++;
  }
  d.end--;
  pc8001.outports[0x30]=(d.columns==80)?0x29:0x28;
}
pc8001.resizeDisplay=function(columns,lines){
  var d=pc8001.display;
  var x,y,t;
  if((columns!=40&&columns!=80)||lines<20||lines>25){
    console.log("Unable resizeDisplay",columns,lines);
    return;
  }
  if(columns!=d.columns||lines!=d.lines){
    for(y=0;y<25;y++){
      for(x=0;x<80;x++){
        t=d.textArray[x][y];
        t.controlbox.setAttribute("x",y*100/lines);
        t.controlbox.setAttribute("font-size",160/columns);
        t.controlbox.setAttribute("transform","matrix(0 1 1 0 "+(d.monowidth<2?128:144)/columns+" 0)");
        t.controlbox.textContent=d.bgchars[t.control];
        if(t.color.substr(0,1)=="#"){
          t.textbox.setAttribute("font-size",2);
          t.textbox.setAttribute("transform","matrix(0 "+((d.monowidth<2)?5/3:1)+" "+80/columns+" 0 "+(x*2+72/columns)+" "+y*100/lines+")");
          t.textpath.textContent=d.blocks[t.data];
        }
        else{
          t.textbox.setAttribute("font-size",1);
          t.textbox.setAttribute("transform","matrix(0 "+((d.monowidth<2)?5/3:1)+" "+40/columns+" 0 "+x*2+" "+y*100/lines+")");
          t.textpath.textContent=d.font[t.data];
        }
        if(y>=lines||(x%2==1&&columns==40)){
          t.controlbox.setAttribute("fill","none");
          t.textbox.setAttribute("fill","none");
        }
        else{
          t.controlbox.setAttribute("fill",t.color);
          t.textbox.setAttribute("fill",((t.control&1)==1)?"none":((t.control&4)==4)?"black":t.color);
          if((t.control&2)==2)
            d.blinker.appendChild(t.textbox);
          else
            d.svg.appendChild(t.textbox);
        }
      }
    }
  }
  d.columns=columns;
  d.lines=lines;
}
pc8001.reverseDisplay=function(rev){
  var d=pc8001.display;
  var x,y,t;
  if(rev!=0)
    rev=4;
  if(d.reverse==rev)
    return;
  for(y=0;y<25;y++){
    for(x=0;x<80;x++){
      t=d.textArray[x][y];
      t.control^=4;
      t.controlbox.textContent=d.bgchars[t.control];
      if(y<d.lines&&(x%2==0||d.columns==80))
        t.textbox.setAttribute("fill",((t.control&1)==1)?"none":((t.control&4)==4)?"black":t.color);
    }
  }
  d.reverse=rev;
}
pc8001.writeMemory=function(address,data){
  var t=pc8001.memory[address];
  var d=pc8001.display;
  var x,y,f,i,j,k;
  if(data<0||data>0xff){
    console.log("writeMemory",address.toString(16),data);
    Object.keys(pc8001.z80.regs).forEach(function(v){
      console.log(" reg",v,pc8001.z80.regs[v].toString(16).toUpperCase().padStart(v.length*2,"0"));
  });
    console.log(" flags",pc8001.z80.flags);
    data=(data+65536)&0xff;
  }
  if(address<0x6000)
    console.log("write",data,"to ROM",address.toString(16).toUpperCase().padStart(4,"0"),"at",pc8001.z80.regs["PC"].toString(16).toUpperCase().padStart(4,"0"));
  else
    pc8001.memory[address]=data;
  if(address<d.start||d.end<address||t==data)
    return;
  x=(address-d.start)%120;
  y=Math.floor((address-d.start)/120);
  if(x<80){
    t=d.textArray[x][y];
    if(y<d.lines&&(x%2==0||d.columns==80))
      t.textpath.textContent=(t.color.substr(0,1)=="#")?d.blocks[data]:d.font[data];
    t.data=data;
    return;
  }
  for(f=1;f==1;y=(y>d.lines-2)?0:y+1){
    i=d.start+80+y*120;
    j=d.textArray[79][(y==0)?d.lines-1:y-1].control;
    k=d.textArray[79][(y==0)?d.lines-1:y-1].color;
    for(x=0;x<80;x++){
      if(pc8001.memory[i]==x){
        i++;
        t=d.colors[pc8001.memory[i]];
        if(t=="control")
          j=(pc8001.memory[i]&0x3f)^d.reverse;
        else
          k=t;
        i++;
      }
      t=d.textArray[x][y];
      f=0;
      if(t.color!=k){
        if(x%2==0||d.columns==80){
          t.controlbox.setAttribute("fill",k);
          t.textbox.setAttribute("fill",k);
          if(t.color.substr(0,1)!=k.substr(0,1)){
            if(k.substr(0,1)=="#"){
              t.textbox.setAttribute("font-size",2);
              t.textbox.setAttribute("transform","matrix(0 "+((d.monowidth<2)?5/3:1)+" "+80/d.columns+" 0 "+(x*2+72/d.columns)+" "+y*100/d.lines+")");
              t.textpath.textContent=d.blocks[t.data];
            }
            else{
              t.textbox.setAttribute("font-size",1);
              t.textbox.setAttribute("transform","matrix(0 "+((d.monowidth<2)?5/3:1)+" "+40/d.columns+" 0 "+x*2+" "+y*100/d.lines+")");
              t.textpath.textContent=d.font[t.data];
            }
          }
        }
        t.color=k;
        f=1;
      }
      if(t.control!=j){
        if(x%2==0||d.columns==80){
          t.textbox.setAttribute("fill",((j&1)==1)?"none":((j&4)==4)?"black":k);
          if(((t.control^j)&2)==2){
            if((j&2)==2)
              d.blinker.appendChild(t.textbox);
            else
              d.svg.appendChild(t.textbox);
          }
          t.controlbox.textContent=d.bgchars[j];
        }
        t.control=j;
        f=1;
      }
    }
  }
}
pc8001.inports=new Array(256);
pc8001.inports.fill(0xff);
pc8001.outports=new Array(256);
pc8001.outports.fill(0);
pc8001.keymap=new Array(256);
pc8001.keymap.fill([]);
pc8001.keymap[13]=[1,0x7f];                    // enter-key
pc8001.keymap[96]=[0,0xfe];                    // ten-key 0
pc8001.keymap[97]=[0,0xfd];                    // ten-key 1
pc8001.keymap[98]=pc8001.keymap[40]=[0,0xfb];  // ten-key 2 = downarrow
pc8001.keymap[99]=[0,0xf7];                    // ten-key 3
pc8001.keymap[100]=pc8001.keymap[37]=[0,0xef]; // ten-key 4 = leftarrow
pc8001.keymap[101]=[0,0xdf,9,0xbf];            // ten-key 5 = space-key
pc8001.keymap[102]=pc8001.keymap[39]=[0,0xbf]; // ten-key 6 = rightarrow
pc8001.keymap[103]=[0,0x7f];                   // ten-key 7
pc8001.keymap[104]=pc8001.keymap[38]=[1,0xfe]; // ten-key 8 = uparrow
pc8001.keymap[105]=[1,0xfd];                   // ten-key 9
pc8001.keymap[32]=[9,0xbf,0,0xdf];             // space-key = ten-key 5
pc8001.keymap[112]=pc8001.keymap[70]=[9,0xfd]; // function-key F1 = key F
pc8001.keymap[113]=pc8001.keymap[66]=[9,0xfb]; // function-key F2 = key B
pc8001.keymap[114]=pc8001.keymap[78]=[9,0xf7]; // function-key F3 = key N
pc8001.keymap[115]=pc8001.keymap[188]=[9,0xef];// function-key F4 = key <
pc8001.keymap[116]=pc8001.keymap[190]=[9,0xdf];// function-key F5 = key >
pc8001.keymap[16]=[8,0xbf];                    // shift-key
pc8001.keymap[67]=[2,0xf7];                    // key C
pc8001.keymap[88]=[5,0xfe];                    // key X
pc8001.keymap[90]=[5,0xfb];                    // key Z
pc8001.keymap[48]=[6,0xfe];                    // key 0
pc8001.keymap[49]=[6,0xfd];                    // key 1
pc8001.keymap[50]=[6,0xfb];                    // key 2
pc8001.keymap[51]=[6,0xf7];                    // key 3
pc8001.keymap[52]=[6,0xef];                    // key 4
pc8001.keymap[53]=[6,0xdf];                    // key 5
pc8001.keymap[54]=[6,0xbf];                    // key 6
pc8001.keymap[55]=[6,0x7f];                    // key 7
pc8001.keymap[56]=[7,0xfe];                    // key 8
pc8001.keymap[57]=[7,0xfd];                    // key 9
pc8001.keydown=function(event){
  var k=pc8001.keymap[event.keyCode]
  var i;
  if(k.length<2)
    return;
  for(i=0;i<k.length;i+=2)
    pc8001.inports[k[i]]&=k[i+1];
}
pc8001.keyup=function(event){
  var k=pc8001.keymap[event.keyCode]
  var i;
  if(k.length<2)
    return;
  for(i=0;i<k.length;i+=2)
    pc8001.inports[k[i]]|=(k[i+1]^0xff);
  if(pc8001.beep.counter<0){
    pc8001.beep.counter=pc8001.beep.on=0;
    pc8001.beep.start=pc8001.z80.states;
    pc8001.beep.oscillator.start();
  }
}
pc8001.beep=new Object();
pc8001.beep.audio=new(window.AudioContext||window.webkitAudioContext)();
pc8001.beep.buffer=pc8001.beep.audio.createBuffer(1,Math.floor(pc8001.beep.audio.sampleRate/60),pc8001.beep.audio.sampleRate);
pc8001.beep.oscillator=pc8001.beep.audio.createBufferSource();
pc8001.beep.oscillator.buffer=pc8001.beep.buffer;
pc8001.beep.wave=pc8001.beep.buffer.getChannelData(0);
pc8001.beep.wave.fill(0);
pc8001.beep.counter=-1;
pc8001.beep.oscillator.loop=true;
pc8001.beep.oscillator.connect(pc8001.beep.audio.destination);
pc8001.beep.refWave=new Array(pc8001.beep.wave.length);
pc8001.beep.refWave.fill(0);
pc8001.beep.refWave.forEach(function(v,i,a){
  a[i]=Math.sin(i*Math.PI*2/pc8001.beep.audio.sampleRate*2400);
});
pc8001.calendar=new Object();
pc8001.calendar.command=function(com){
  var d,j,k;
  switch(com){
    case 4:
      pc8001.calendar.differential=0;
    case 3:
      pc8001.calendar.readreg="00000000";
      pc8001.calendar.writereg="";
      pc8001.calendar.date=new Date();
      return 0;
    case 2:
      d=new Date();
      k=pc8001.calendar.writereg;
      if(k.length>40){
        j=parseInt(parseInt(k.slice(0,-40),2).toString(16),10);
        if(!isNaN(j))
          d.setFullYear(j);
      }
      if(k.length>39){
        j=parseInt(k.slice(-40,-36),2);
        if(!isNaN(j))
          d.setMonth(j-1);
      }
      if(k.length>31){
        j=parseInt(parseInt(k.slice(-32,-24),2).toString(16),10);
        if(!isNaN(j))
          d.setDate(j);
      }
      if(k.length>23){
        j=parseInt(parseInt(k.slice(-24,-16),2).toString(16),10);
        if(!isNaN(j))
          d.setHours(j);
      }
      if(k.length>15){
        j=parseInt(parseInt(k.slice(-16,-8),2).toString(16),10);
        if(!isNaN(j))
          d.setMinutes(j);
      }
      if(k.length>7){
        j=parseInt(parseInt(k.slice(-8),2).toString(16),10);
        if(!isNaN(j))
          d.setSeconds(j);
      }
      pc8001.calendar.date=new Date();
      pc8001.calendar.differential=pc8001.calendar.date-d;
    case 1:
      d=new Date(pc8001.calendar.date-pc8001.calendar.differential);
      j=d.getFullYear().toString()+(d.getMonth()+1).toString(16)+d.getDay().toString()
      k=parseInt(j,16).toString(2).padStart(32,"0");
      j=(d.getDate()*1000000+d.getHours()*10000+d.getMinutes()*100+d.getSeconds()).toString();
      k+=parseInt(j,16).toString(2).padStart(32,"0");
      pc8001.calendar.readreg=k;
      pc8001.calendar.writereg="";
  }
  return (pc8001.calendar.readreg.slice(-1)=="1")?0x10:0;
}
pc8001.calendar.command(4);
pc8001.calendar.shift=function(b){
  var t;
  pc8001.calendar.writereg=(((b&8)==0)?"0":"1")+pc8001.calendar.writereg;
  t=pc8001.calendar.readreg.slice(-1)+pc8001.calendar.readreg.slice(0,-1);
  pc8001.calendar.readreg=t;
  return (t.slice(-1)=="1")?0x10:0;
}
pc8001.z80=new Object();
pc8001.z80.frequency=4000000;                  // 4MHz
pc8001.z80.millistates=pc8001.z80.frequency/1000;
pc8001.z80.regs={"PC":0,"SP":0,"A":0,"B":0,"C":0,"D":0,"E":0,"H":0,"L":0,"J":0,"X":0,"K":0,"Y":0,"a":0,"b":0,"c":0,"d":0,"e":0,"h":0,"l":0};
pc8001.z80.flags={"Z":0,"C":0,"V":0,"M":0,"H":0,"N":0,"DUMMY":0,"z":0,"c":0,"v":0,"m":0,"h":0,"n":0,"dummy":0};
pc8001.z80.mnemonics={};
pc8001.z80.halt=pc8001.z80.states=0;
pc8001.z80.ops=new Array(256);
pc8001.z80.ops.fill(["UNDEF","",0]);
pc8001.z80.ops[0xcb]=new Array(257);
pc8001.z80.ops[0xcb].fill(["UNDEF","CB",0]);
pc8001.z80.ops[0xcb][256]=-1;
pc8001.z80.ops[0xdd]=new Array(257);
pc8001.z80.ops[0xdd].fill(["UNDEF","DD",0]);
pc8001.z80.ops[0xdd][256]=-1;
pc8001.z80.ops[0xed]=new Array(257);
pc8001.z80.ops[0xed].fill(["UNDEF","ED",0]);
pc8001.z80.ops[0xed][256]=-1;
pc8001.z80.ops[0xfd]=new Array(257);
pc8001.z80.ops[0xfd].fill(["UNDEF","FD",0]);
pc8001.z80.ops[0xfd][256]=-1;
pc8001.z80.mnemonics["UNDEF"]=function(x,m){
  pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xffff)&0xffff;
  pc8001.z80.halt=1;
  console.log(performance.now()-pc8001.z80.millitimer,"milliseconds");
  console.log(pc8001.z80.states,"states");
  console.log(m[0],m[1],x.toString(16).toUpperCase().padStart(2,"0"));
  Object.keys(pc8001.z80.regs).forEach(function(v){
    console.log(" reg",v,pc8001.z80.regs[v].toString(16).toUpperCase().padStart(v.length*2,"0"));
  });
  console.log(" flags",pc8001.z80.flags);
}
pc8001.z80.ops[0x00]=["NOP",4];
pc8001.z80.mnemonics["NOP"]=function(x,m){
}
pc8001.operators=["ADD","ADC","SUB","SBC","AND","XOR","OR","CP"];
pc8001.params=["B","C","D","E","H","L","(HL)","A"];
pc8001.params.forEach(function(v,i,a){
  var j;
  for(j=0;j<8;j++)
    pc8001.z80.ops[i*8+j+0x40]=["LD",v,a[j],(i==6||j==6)?7:4];
  pc8001.z80.ops[i*8+4]=["INC",v,(i==6)?11:4];
  pc8001.z80.ops[i*8+5]=["DEC",v,(i==6)?11:4];
  pc8001.z80.ops[i*8+6]=["LD",v,"n",(i==6)?10:7];
  pc8001.operators.forEach(function(w,j){
    pc8001.z80.ops[i+j*8+0x80]=[w,"A",v,(i==6)?7:4];
  });
  if(i!=6){
    pc8001.z80.ops[0xdd][i*8+0x46]=["LD",v,"(JX+d)",19];
    pc8001.z80.ops[0xdd][i+0x70]=["LD","(JX+d)",v,19];
    pc8001.z80.ops[0xdd][i*8+0x44]=["LD",v,"J",8];
    pc8001.z80.ops[0xdd][i*8+0x45]=["LD",v,"X",8];
    pc8001.z80.ops[0xdd][i+0x60]=["LD","J",v,8];
    pc8001.z80.ops[0xdd][i+0x68]=["LD","X",v,8];
    pc8001.z80.ops[0xfd][i*8+0x46]=["LD",v,"(KY+d)",19];
    pc8001.z80.ops[0xfd][i+0x70]=["LD","(KY+d)",v,19];
    pc8001.z80.ops[0xfd][i*8+0x44]=["LD",v,"K",8];
    pc8001.z80.ops[0xfd][i*8+0x45]=["LD",v,"Y",8];
    pc8001.z80.ops[0xfd][i+0x60]=["LD","K",v,8];
    pc8001.z80.ops[0xfd][i+0x68]=["LD","Y",v,8];
    pc8001.z80.ops[0xed][i*8+0x40]=["IN",v,"(BC)",12];
    pc8001.z80.ops[0xed][i*8+0x41]=["OUT","(BC)",v,12];
  }
  pc8001.z80.ops[0xcb][i+0x00]=["RLC",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x08]=["RRC",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x10]=["RL",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x18]=["RR",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x20]=["SLA",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x28]=["SRA",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x30]=["SLL",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x38]=["SRL",v,(i==6)?15:8];
  for(j=0;j<8;j++){
    pc8001.z80.ops[0xcb][i+j*8+0x40]=["BIT",j,v,(i==6)?12:8];
    pc8001.z80.ops[0xcb][i+j*8+0x80]=["RES",j,v,(i==6)?15:8];
    pc8001.z80.ops[0xcb][i+j*8+0xc0]=["SET",j,v,(i==6)?15:8];
  }
});
pc8001.operators.forEach(function(v,i){
  pc8001.z80.ops[i*8+0xc6]=[v,"A","n",7];
  pc8001.z80.ops[0xdd][i*8+0x84]=[v,"A","J",8];
  pc8001.z80.ops[0xdd][i*8+0x85]=[v,"A","X",8];
  pc8001.z80.ops[0xdd][i*8+0x86]=[v,"A","(JX+d)",19];
  pc8001.z80.ops[0xfd][i*8+0x84]=[v,"A","K",8];
  pc8001.z80.ops[0xfd][i*8+0x85]=[v,"A","Y",8];
  pc8001.z80.ops[0xfd][i*8+0x86]=[v,"A","(KY+d)",19];
});
pc8001.z80.ops[0x76]=["HALT","",4];
pc8001.z80.mnemonics["HALT"]=pc8001.z80.mnemonics["UNDEF"];
pc8001.z80.ops[0x02]=["LD","(BC)","A",7];
pc8001.z80.ops[0x0a]=["LD","A","(BC)",7];
pc8001.z80.ops[0x12]=["LD","(DE)","A",7];
pc8001.z80.ops[0x1a]=["LD","A","(DE)",7];
pc8001.z80.ops[0x32]=["LD","(nn)","A",13];
pc8001.z80.ops[0x3a]=["LD","A","(nn)",13];
pc8001.z80.ops[0xdd][0x26]=["LD","J","n",11];
pc8001.z80.ops[0xdd][0x2e]=["LD","X","n",11];
pc8001.z80.ops[0xdd][0x36]=["LD","(JX+d)","n",19];
pc8001.z80.ops[0xdd][0x64]=["LD","J","J",8];
pc8001.z80.ops[0xdd][0x65]=["LD","J","X",8];
pc8001.z80.ops[0xdd][0x6c]=["LD","X","J",8];
pc8001.z80.ops[0xdd][0x6d]=["LD","X","X",8];
pc8001.z80.ops[0xfd][0x26]=["LD","K","n",11];
pc8001.z80.ops[0xfd][0x2e]=["LD","Y","n",11];
pc8001.z80.ops[0xfd][0x36]=["LD","(KY+d)","n",19];
pc8001.z80.ops[0xfd][0x64]=["LD","K","K",8];
pc8001.z80.ops[0xfd][0x65]=["LD","K","Y",8];
pc8001.z80.ops[0xfd][0x6c]=["LD","Y","K",8];
pc8001.z80.ops[0xfd][0x6d]=["LD","Y","Y",8];
pc8001.z80.mnemonics["LD"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a=-1;
  var b,c;
  switch(m[1].length){
    case 4:
      if(m[1]=="(nn)"){
        a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
        pc8001.z80.regs["PC"]=pc=(pc+2)&0xffff;
      }
      else
        a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
  }
  switch(m[2].length){
    case 4:
      if(m[2]=="(nn)"){
        b=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
        pc8001.z80.regs["PC"]=pc=(pc+2)&0xffff;
      }
      else
        b=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      c=pc8001.memory[b];
      break;
    case 6:
      b=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(b>0x7f)
        b+=0xff00;
      b+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      c=pc8001.memory[b&0xffff];
      break;
    default:
      if(m[2]=="n"){
        c=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        c=pc8001.z80.regs[m[2]];
  }
  if(a<0)
    pc8001.z80.regs[m[1]]=c;
  else
    pc8001.writeMemory(a,c);
}
pc8001.z80.ops[0x01]=["LD16","BC","nn",10];
pc8001.z80.ops[0x11]=["LD16","DE","nn",10];
pc8001.z80.ops[0x21]=["LD16","HL","nn",10];
pc8001.z80.ops[0x22]=["LD16","(nn)","HL",16];
pc8001.z80.ops[0x2a]=["LD16","HL","(nn)",16];
pc8001.z80.ops[0x31]=["LD16","SP","nn",10];
pc8001.z80.ops[0xf9]=["LD16","SP","HL",6];
pc8001.z80.ops[0xed][0x43]=["LD16","(nn)","BC",20];
pc8001.z80.ops[0xed][0x4b]=["LD16","BC","(nn)",20];
pc8001.z80.ops[0xed][0x53]=["LD16","(nn)","DE",20];
pc8001.z80.ops[0xed][0x5b]=["LD16","DE","(nn)",20];
pc8001.z80.ops[0xed][0x63]=["LD16","(nn)","HL",20];
pc8001.z80.ops[0xed][0x6b]=["LD16","HL","(nn)",20];
pc8001.z80.ops[0xed][0x73]=["LD16","(nn)","SP",20];
pc8001.z80.ops[0xed][0x7b]=["LD16","SP","(nn)",20];
pc8001.z80.ops[0xdd][0x21]=["LD16","JX","nn",14];
pc8001.z80.ops[0xdd][0x22]=["LD16","(nn)","JX",20];
pc8001.z80.ops[0xdd][0x2a]=["LD16","JX","(nn)",20];
pc8001.z80.ops[0xdd][0xf9]=["LD16","SP","JX",10];
pc8001.z80.ops[0xfd][0x21]=["LD16","KY","nn",14];
pc8001.z80.ops[0xfd][0x22]=["LD16","(nn)","KY",20];
pc8001.z80.ops[0xfd][0x2a]=["LD16","KY","(nn)",20];
pc8001.z80.ops[0xfd][0xf9]=["LD16","SP","KY",10];
pc8001.z80.mnemonics["LD16"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var h,l,a;
  switch(m[2]){
    case "nn":
      l=pc8001.memory[pc];
      h=pc8001.memory[(pc+1)&0xffff];
      pc=pc8001.z80.regs["PC"]=(pc+2)&0xffff;
      break;
    case "(nn)":
      a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
      pc=pc8001.z80.regs["PC"]=(pc+2)&0xffff;
      l=pc8001.memory[a];
      h=pc8001.memory[(a+1)&0xffff];
      break;
    case "SP":
      a=pc8001.z80.regs["SP"];
      h=a>>8;
      l=a&0xff;
      break;
    default:
      h=pc8001.z80.regs[m[2].substr(0,1)];
      l=pc8001.z80.regs[m[2].substr(1)];
  }
  switch(m[1]){
    case "(nn)":
      a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
      pc=pc8001.z80.regs["PC"]=(pc+2)&0xffff;
      pc8001.writeMemory(a,l);
      pc8001.writeMemory((a+1)&0xffff,h);
      return;
    case "SP":
      pc8001.z80.regs["SP"]=h*256+l;
      return;
    default:
      pc8001.z80.regs[m[1].substr(0,1)]=h;
      pc8001.z80.regs[m[1].substr(1)]=l;
  }
}
pc8001.z80.ops[0x08]=["EX","AF","af",4];
pc8001.z80.ops[0xe3]=["EX","(SP)","HL",19];
pc8001.z80.ops[0xeb]=["EX","DE","HL",4];
pc8001.z80.mnemonics["EX"]=function(x,m){
  var a,t;
  if(m[1]=="(SP)"){
    a=pc8001.z80.regs["SP"]
    t=pc8001.memory[a];
    pc8001.writeMemory(a,pc8001.z80.regs[m[2].substr(1)]);
    pc8001.z80.regs[m[2].substr(1)]=t;
    a=(a+1)&0xffff;
    t=pc8001.memory[a];
    pc8001.writeMemory(a,pc8001.z80.regs[m[2].substr(0,1)]);
    pc8001.z80.regs[m[2].substr(0,1)]=t;
    return;
  }
  t=pc8001.z80.regs[m[1].substr(0,1)];
  pc8001.z80.regs[m[1].substr(0,1)]=pc8001.z80.regs[m[2].substr(0,1)];
  pc8001.z80.regs[m[2].substr(0,1)]=t;
  if(m[1].substr(1)=="F"){
    a=["Z","C","V","M","H","N","DUMMY"];
    a.forEach(function(v){
      var b=pc8001.z80.flags[v];
      pc8001.z80.flags[v]=pc8001.z80.flags[v.toLowerCase()];
      pc8001.z80.flags[v.toLowerCase()]=b;
    });
    return;
  }
  t=pc8001.z80.regs[m[1].substr(1)];
  pc8001.z80.regs[m[1].substr(1)]=pc8001.z80.regs[m[2].substr(1)];
  pc8001.z80.regs[m[2].substr(1)]=t;
}
pc8001.z80.ops[0xd9]=["EXX",4];
pc8001.z80.mnemonics["EXX"]=function(x,m){
  var r=["B","C","D","E","H","L"];
  r.forEach(function(v){
    var t=pc8001.z80.regs[v];
    pc8001.z80.regs[v]=pc8001.z80.regs[v.toLowerCase()];
    pc8001.z80.regs[v.toLowerCase()]=t;
  });
}
pc8001.z80.ops[0xdd][0x34]=["INC","(JX+d)",23];
pc8001.z80.ops[0xfd][0x34]=["INC","(KY+d)",23];
pc8001.z80.mnemonics["INC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=(t+1)&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(t==0x80)?1:0;
  pc8001.z80.flags["H"]=((t&0x0f)==0)?1:0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.ops[0x03]=["INC16","BC",6];
pc8001.z80.ops[0x13]=["INC16","DE",6];
pc8001.z80.ops[0x23]=["INC16","HL",6];
pc8001.z80.ops[0x33]=["INC16","SP",6];
pc8001.z80.ops[0xdd][0x23]=["INC16","JX",10];
pc8001.z80.ops[0xfd][0x23]=["INC16","KY",10];
pc8001.z80.mnemonics["INC16"]=function(x,m){
  var t;
  if(m[1]=="SP")
    pc8001.z80.regs["SP"]=(pc8001.z80.regs["SP"]+1)&0xffff;
  else{
    pc8001.z80.regs[m[1].substr(1)]=t=(pc8001.z80.regs[m[1].substr(1)]+1)&0xff;
    if(t==0)
      pc8001.z80.regs[m[1].substr(0,1)]=(pc8001.z80.regs[m[1].substr(0,1)]+1)&0xff;
  }
}
pc8001.z80.ops[0xdd][0x35]=["DEC","(JX+d)",23];
pc8001.z80.ops[0xfd][0x35]=["DEC","(KY+d)",23];
pc8001.z80.mnemonics["DEC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=(t+0xff)&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(t==0x7f)?1:0;
  pc8001.z80.flags["H"]=((t&0x0f)==0x0f)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0x0b]=["DEC16","BC",6];
pc8001.z80.ops[0x1b]=["DEC16","DE",6];
pc8001.z80.ops[0x2b]=["DEC16","HL",6];
pc8001.z80.ops[0x3b]=["DEC16","SP",6];
pc8001.z80.ops[0xdd][0x2b]=["DEC16","JX",6];
pc8001.z80.ops[0xfd][0x2b]=["DEC16","KY",6];
pc8001.z80.mnemonics["DEC16"]=function(x,m){
  var t;
  if(m[1]=="SP")
    pc8001.z80.regs["SP"]=(pc8001.z80.regs["SP"]+0xffff)&0xffff;
  else{
    pc8001.z80.regs[m[1].substr(1)]=t=(pc8001.z80.regs[m[1].substr(1)]+0xff)&0xff;
    if(t==0xff)
      pc8001.z80.regs[m[1].substr(0,1)]=(pc8001.z80.regs[m[1].substr(0,1)]+0xff)&0xff;
  }
}
pc8001.z80.ops[0x09]=["ADD16","HL","BC",11];
pc8001.z80.ops[0x19]=["ADD16","HL","DE",11];
pc8001.z80.ops[0x29]=["ADD16","HL","HL",11];
pc8001.z80.ops[0x39]=["ADD16","HL","SP",11];
pc8001.z80.ops[0xdd][0x09]=["ADD16","JX","BC",15];
pc8001.z80.ops[0xdd][0x19]=["ADD16","JX","DE",15];
pc8001.z80.ops[0xdd][0x29]=["ADD16","JX","JX",15];
pc8001.z80.ops[0xdd][0x39]=["ADD16","JX","SP",15];
pc8001.z80.ops[0xfd][0x09]=["ADD16","KY","BC",15];
pc8001.z80.ops[0xfd][0x19]=["ADD16","KY","DE",15];
pc8001.z80.ops[0xfd][0x29]=["ADD16","KY","KY",15];
pc8001.z80.ops[0xfd][0x39]=["ADD16","KY","SP",15];
pc8001.z80.mnemonics["ADD16"]=function(x,m){
  var t;
  t=pc8001.z80.regs[m[1].substr(0,1)]*256+pc8001.z80.regs[m[1].substr(1)];
  if(m[2]=="SP")
    t+=pc8001.z80.regs["SP"];
  else
    t+=pc8001.z80.regs[m[2].substr(0,1)]*256+pc8001.z80.regs[m[2].substr(1)];
  if(t>0xffff){
    pc8001.z80.flags["C"]=1;
    t&=0xffff;
  }
  else
    pc8001.z80.flags["C"]=0;
  pc8001.z80.regs[m[1].substr(0,1)]=t>>8;
  pc8001.z80.regs[m[1].substr(1)]=t&0xff;
}
pc8001.z80.mnemonics["ADD"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=t+u;
  pc8001.z80.flags["C"]=(v>0xff)?1:0;
  v&=0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((t>0x7f&&u>0x7f&&v<0x80)||(t<0x80&&u<0x80&&v>0x7f))?1:0;
  pc8001.z80.flags["H"]=((t&0x0f)+(u&0x0f)>0x0f)?1:0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.ops[0xed][0x4a]=["ADC16","HL","BC",15]
pc8001.z80.ops[0xed][0x5a]=["ADC16","HL","DE",15]
pc8001.z80.ops[0xed][0x6a]=["ADC16","HL","HL",15]
pc8001.z80.ops[0xed][0x7a]=["ADC16","HL","SP",15]
pc8001.z80.mnemonics["ADC16"]=function(x,m){
  var t,u,v;
  t=pc8001.z80.regs[m[1].substr(0,1)]*256+pc8001.z80.regs[m[1].substr(1)];
  if(m[2]=="SP")
    u=pc8001.z80.regs["SP"];
  else
    u=pc8001.z80.regs[m[2].substr(0,1)]*256+pc8001.z80.regs[m[2].substr(1)];
  v=t+u+pc8001.z80.flags["C"]
  if(v>0xffff){
    pc8001.z80.flags["C"]=1;
    v&=0xffff;
  }
  else
    pc8001.z80.flags["C"]=0;
  pc8001.z80.regs[m[1].substr(0,1)]=v>>8;
  pc8001.z80.regs[m[1].substr(1)]=v&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7fff)?1:0;
  pc8001.z80.flags["V"]=((u<0x8000&&t<0x8000&&v>0x7fff)||(u>0x7fff&&t>0x7fff&&v<0x8000))?1:0;
}
pc8001.z80.mnemonics["ADC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v,c;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  c=pc8001.z80.flags["C"];
  v=t+u+c;
  pc8001.z80.flags["C"]=(v>0xff)?1:0;
  v&=0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((t>0x7f&&u>0x7f&&v<0x80)||(t<0x80&&u<0x80&&v>0x7f))?1:0;
  pc8001.z80.flags["H"]=((t&0x0f)+(u&0x0f)+c>0x0f)?1:0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.ops[0xed][0x44]=["NEG","A",8];
pc8001.z80.mnemonics["NEG"]=function(x,m){
  var t=(256-pc8001.z80.regs[m[1]])&0xff;
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["C"]=(t==0)?0:1;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(t==0x80)?1:0;
  pc8001.z80.flags["H"]=((t&0x0f)==0)?0:1;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.mnemonics["SUB"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=u-t;
  pc8001.z80.flags["C"]=(v<0)?1:0;
  v=(v+256)&0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((u<0x80&&t>0x7f&&v>0x7f)||(u>0x7f&&t<0x80&&v<0x80))?1:0;
  pc8001.z80.flags["H"]=((u&0x0f)-(t&0x0f)<0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0xed][0x42]=["SBC16","HL","BC",15]
pc8001.z80.ops[0xed][0x52]=["SBC16","HL","DE",15]
pc8001.z80.ops[0xed][0x62]=["SBC16","HL","HL",15]
pc8001.z80.ops[0xed][0x72]=["SBC16","HL","SP",15]
pc8001.z80.mnemonics["SBC16"]=function(x,m){
  var t,u,v;
  t=pc8001.z80.regs[m[1].substr(0,1)]*256+pc8001.z80.regs[m[1].substr(1)];
  if(m[2]=="SP")
    u=pc8001.z80.regs["SP"];
  else
    u=pc8001.z80.regs[m[2].substr(0,1)]*256+pc8001.z80.regs[m[2].substr(1)];
  v=t-u-pc8001.z80.flags["C"]
  if(v<0){
    pc8001.z80.flags["C"]=1;
    v=(v+65536)&0xffff;
  }
  else
    pc8001.z80.flags["C"]=0;
  pc8001.z80.regs[m[1].substr(0,1)]=v>>8;
  pc8001.z80.regs[m[1].substr(1)]=v&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7fff)?1:0;
  pc8001.z80.flags["V"]=((u<0x8000&&t>0x7fff&&v>0x7fff)||(u>0x7fff&&t<0x8000&&v<0x8000))?1:0;
}
pc8001.z80.mnemonics["SBC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v,c;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  c=pc8001.z80.flags["C"];
  v=u-t-c;
  pc8001.z80.flags["C"]=(v<0)?1:0;
  v=(v+256)&0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((u<0x80&&t>0x7f&&v>0x7f)||(u>0x7f&&t<0x80&&v<0x80))?1:0;
  pc8001.z80.flags["H"]=((u&0x0f)-(t&0x0f)-c<0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.mnemonics["AND"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  t&=pc8001.z80.regs[m[1]];
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["C"]=0;
  pc8001.z80.flags["H"]=1
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x2f]=["CPL","A",4];
pc8001.z80.mnemonics["CPL"]=function(x,m){
  pc8001.z80.regs[m[1]]^=0xff;
  pc8001.z80.flags["H"]=1;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.mnemonics["XOR"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  t^=pc8001.z80.regs[m[1]];
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["C"]=0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["OR"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  t|=pc8001.z80.regs[m[1]];
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["C"]=0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["CP"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=u-t;
  pc8001.z80.flags["C"]=(v<0)?1:0;
  v=(v+256)&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((u<0x80&&t>0x7f&&v>0x7f)||(u>0x7f&&t<0x80&&v<0x80))?1:0;
  pc8001.z80.flags["H"]=((u&0x0f)-(t&0x0f)<0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0x37]=["SCF",4];
pc8001.z80.mnemonics["SCF"]=function(x,m){
  pc8001.z80.flags["C"]=1;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.ops[0x3f]=["CCF",4];
pc8001.z80.mnemonics["CCF"]=function(x,m){
  pc8001.z80.flags["C"]^=1;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.ops[0x27]=["DAA",4];
pc8001.z80.mnemonics["DAA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  var v;
  if(pc8001.z80.flags["N"]==0){
    if(pc8001.z80.flags["C"]==0){
      v=((t>0x99)?0x60:0)+(((pc8001.z80.flags["H"]==1||(t&0x0f)>9))?6:0);
      pc8001.z80.flags["C"]=(t>0x99)?1:0;
    }
    else
      v=((pc8001.z80.flags["H"]==1)||((t&0x0f)>9)?0x66:0x60);
    pc8001.z80.flags["H"]=((t&0x0f)>9)?1:0;
  }
  else{
    if(pc8001.z80.flags["C"]==0){
      if(pc8001.z80.flags["H"]==0)
        v=((t>0x99)?0xa0:0)+(((t&0x0f)>9)?0xfa:0);
      else{
        v=(t>0x99)?0x9a:0xfa;
        pc8001.z80.flags["H"]=((t&0x0f)<6)?1:0;
      }
      pc8001.z80.flags["C"]=(t>0x99)?1:0;
    }
    else{
      v=(pc8001.z80.flags["H"]==0&&((t&0x0f)<10))?0xa0:0x9a;
      pc8001.z80.flags["H"]&=((t&0x0f)<6)?1:0;
    }
  }
  pc8001.z80.regs["A"]=(t+v)&0xff;
}
pc8001.z80.ops[0xc2]=["JP","NZ","nn",10];
pc8001.z80.ops[0xc3]=["JP","","nn",10];
pc8001.z80.ops[0xca]=["JP","Z","nn",10];
pc8001.z80.ops[0xd2]=["JP","NC","nn",10];
pc8001.z80.ops[0xda]=["JP","C","nn",10];
pc8001.z80.ops[0xe2]=["JP","NV","nn",10];
pc8001.z80.ops[0xea]=["JP","V","nn",10];
pc8001.z80.ops[0xf2]=["JP","NM","nn",10];
pc8001.z80.ops[0xfa]=["JP","M","nn",10];
pc8001.z80.ops[0xe9]=["JP","","(HL)",4];
pc8001.z80.ops[0xdd][0xe9]=["JP","","(JX)",8];
pc8001.z80.ops[0xfd][0xe9]=["JP","","(KY)",8];
pc8001.z80.mnemonics["JP"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
  }
  if(c==0){
    if(m[2]=="nn")
      pc8001.z80.regs["PC"]=(pc+2)&0xffff;
    return;
  }
  switch(m[2].length){
    case 2:
      pc8001.z80.regs["PC"]=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
      return;
    case 4:
      pc8001.z80.regs["PC"]=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      return;
  }
}
pc8001.z80.ops[0x10]=["JR","DJNZ","e",13];
pc8001.z80.ops[0x18]=["JR","","e",12];
pc8001.z80.ops[0x20]=["JR","NZ","e",12];
pc8001.z80.ops[0x28]=["JR","Z","e",12];
pc8001.z80.ops[0x30]=["JR","NC","e",12];
pc8001.z80.ops[0x38]=["JR","C","e",12];
pc8001.z80.mnemonics["JR"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
      break;
    case 4:
      pc8001.z80.regs["B"]=c=(pc8001.z80.regs["B"]+0xff)&0xff;
  }
  if(c==0){
    if(m[2]=="e")
      pc8001.z80.regs["PC"]=(pc+1)&0xffff;
    return;
  }
  c=pc8001.memory[pc];
  pc8001.z80.regs["PC"]=((c>0x7f)?pc+0xff01+c:pc+1+c)&0xffff;
}
pc8001.z80.ops[0xc4]=["CALL","NZ","nn",17];
pc8001.z80.ops[0xc7]=["CALL","","0000",11];
pc8001.z80.ops[0xcc]=["CALL","Z","nn",17];
pc8001.z80.ops[0xcd]=["CALL","","nn",17];
pc8001.z80.ops[0xcf]=["CALL","","0008",11];
pc8001.z80.ops[0xd4]=["CALL","NC","nn",17];
pc8001.z80.ops[0xd7]=["CALL","","0010",11];
pc8001.z80.ops[0xdc]=["CALL","C","nn",17];
pc8001.z80.ops[0xdf]=["CALL","","0018",11];
pc8001.z80.ops[0xe4]=["CALL","NV","nn",17];
pc8001.z80.ops[0xe7]=["CALL","","0020",11];
pc8001.z80.ops[0xec]=["CALL","V","nn",17];
pc8001.z80.ops[0xef]=["CALL","","0028",11];
pc8001.z80.ops[0xf4]=["CALL","NM","nn",17];
pc8001.z80.ops[0xf7]=["CALL","","0030",11];
pc8001.z80.ops[0xfc]=["CALL","M","nn",17];
pc8001.z80.ops[0xff]=["CALL","","0038",11];
pc8001.z80.mnemonics["CALL"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var sp=pc8001.z80.regs["SP"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
  }
  if(c==0){
    if(m[2]=="nn")
      pc8001.z80.regs["PC"]=(pc+2)&0xffff;
    return;
  }
  if(m[2]=="nn"){
    a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
    pc=(pc+2)&0xffff;
  }
  else
    a=parseInt(m[2],16);
  pc8001.writeMemory((sp+0xffff)&0xffff,pc>>8);
  pc8001.z80.regs["SP"]=sp=(sp+0xfffe)&0xffff;
  pc8001.writeMemory(sp,pc&0xff);
  pc8001.z80.regs["PC"]=a;
}
pc8001.z80.ops[0xc0]=["RET","NZ",11];
pc8001.z80.ops[0xc8]=["RET","Z",11];
pc8001.z80.ops[0xc9]=["RET","",10];
pc8001.z80.ops[0xd0]=["RET","NC",11];
pc8001.z80.ops[0xd8]=["RET","C",11];
pc8001.z80.ops[0xe0]=["RET","NV",11];
pc8001.z80.ops[0xe8]=["RET","V",11];
pc8001.z80.ops[0xf0]=["RET","NM",11];
pc8001.z80.ops[0xf8]=["RET","M",11];
pc8001.z80.mnemonics["RET"]=function(x,m){
  var sp=pc8001.z80.regs["SP"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
  }
  if(c==0)
    return;
  pc8001.z80.regs["PC"]=pc8001.memory[sp]+pc8001.memory[(sp+1)&0xffff]*256;
  pc8001.z80.regs["SP"]=(sp+2)&0xffff;
}
pc8001.z80.ops[0xc5]=["PUSH","BC",11];
pc8001.z80.ops[0xd5]=["PUSH","DE",11];
pc8001.z80.ops[0xe5]=["PUSH","HL",11];
pc8001.z80.ops[0xf5]=["PUSH","AF",11];
pc8001.z80.ops[0xdd][0xe5]=["PUSH","JX",15];
pc8001.z80.ops[0xfd][0xe5]=["PUSH","KY",15];
pc8001.z80.mnemonics["PUSH"]=function(x,m){
  var sp=pc8001.z80.regs["SP"];
  pc8001.writeMemory((sp+0xffff)&0xffff,pc8001.z80.regs[m[1].substr(0,1)]);
  pc8001.z80.regs["SP"]=sp=(sp+0xfffe)&0xffff;
  if(m[1]=="AF")
    pc8001.writeMemory(sp,(pc8001.z80.flags["DUMMY"]&0x28)|pc8001.z80.flags["C"]|(pc8001.z80.flags["N"]<<1)|(pc8001.z80.flags["V"]<<2)|(pc8001.z80.flags["H"]<<4)|(pc8001.z80.flags["Z"]<<6)|(pc8001.z80.flags["M"]<<7));
  else
    pc8001.writeMemory(sp,pc8001.z80.regs[m[1].substr(1)]);
}
pc8001.z80.ops[0xc1]=["POP","BC",10];
pc8001.z80.ops[0xd1]=["POP","DE",10];
pc8001.z80.ops[0xe1]=["POP","HL",10];
pc8001.z80.ops[0xf1]=["POP","AF",10];
pc8001.z80.ops[0xdd][0xe1]=["POP","JX",14];
pc8001.z80.ops[0xfd][0xe1]=["POP","KY",14];
pc8001.z80.mnemonics["POP"]=function(x,m){
  var sp=pc8001.z80.regs["SP"];
  var t=pc8001.memory[sp];
  if(m[1]=="AF"){
    pc8001.z80.flags["C"]=((t&1)==0)?0:1;
    pc8001.z80.flags["N"]=((t&2)==0)?0:1;
    pc8001.z80.flags["V"]=((t&4)==0)?0:1;
    pc8001.z80.flags["H"]=((t&0x10)==0)?0:1;
    pc8001.z80.flags["Z"]=((t&0x40)==0)?0:1;
    pc8001.z80.flags["M"]=((t&0x80)==0)?0:1;
    pc8001.z80.flags["DUMMY"]=t;
  }
  else
    pc8001.z80.regs[m[1].substr(1)]=t;
  pc8001.z80.regs[m[1].substr(0,1)]=pc8001.memory[(sp+1)&0xffff];
  pc8001.z80.regs["SP"]=(sp+2)&0xffff;
}
pc8001.z80.ops[0x07]=["RLCA",4];
pc8001.z80.mnemonics["RLCA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  var c=(t>0x7f)?1:0;
  pc8001.z80.regs["A"]=((t<<1)+c)&0xff;
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.mnemonics["RLC"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=(t>0x7f)?1:0;
  t=((t<<1)+c)&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x0f]=["RRCA",4];
pc8001.z80.mnemonics["RRCA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  var c=t&1;
  pc8001.z80.regs["A"]=(t>>1)+c*0x80;
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.mnemonics["RRC"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=t&1;
  t=(t>>1)+c*0x80;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x17]=["RLA",4];
pc8001.z80.mnemonics["RLA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  var c=(t>0x7f)?1:0;
  pc8001.z80.regs["A"]=((t<<1)+pc8001.z80.flags["C"])&0xff;
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.mnemonics["RL"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=(t>0x7f)?1:0;
  t=((t<<1)+pc8001.z80.flags["C"])&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x1f]=["RRA",4];
pc8001.z80.mnemonics["RRA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  pc8001.z80.regs["A"]=(t>>1)+pc8001.z80.flags["C"]*0x80;
  pc8001.z80.flags["C"]=t&1;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.mnemonics["RR"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=t&1;
  t=(t>>1)+pc8001.z80.flags["C"]*0x80;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SLA"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=t<<1;
  pc8001.z80.flags["C"]=(t>0xff)?1:0;
  t&=0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SRA"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  pc8001.z80.flags["C"]=t&1;
  t=((t>>1)|(t&0x80));
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SLL"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=(t<<1)|1;
  pc8001.z80.flags["C"]=(t>0xff)?1:0;
  t&=0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SRL"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  pc8001.z80.flags["C"]=t&1;
  t=t>>1;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["BIT"]=function(x,m){
  var a,t;
  switch(m[2].length){
    case 4:
      a=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[2].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[2]];
  }
  pc8001.z80.flags["Z"]=((t&(1<<m[1]))==0)?1:0;
  pc8001.z80.flags["H"]=1;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.mnemonics["RES"]=function(x,m){
  var a,t
  switch(m[2].length){
    case 4:
      a=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[2].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[2]]
  }
  t&=(1<<m[1])^0xff;
  if(a<0)
    pc8001.z80.regs[m[2]]=t;
  else
    pc8001.writeMemory(a,t);
}
pc8001.z80.mnemonics["SET"]=function(x,m){
  var a,t;
  switch(m[2].length){
    case 4:
      a=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[2].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[2]]
  }
  t|=1<<m[1];
  if(a<0)
    pc8001.z80.regs[m[2]]=t;
  else
    pc8001.writeMemory(a,t);
}
pc8001.z80.ops[0xed][0x67]=["RRD",18];
pc8001.z80.mnemonics["RRD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var c=pc8001.memory[hl];
  var t=pc8001.z80.regs["A"];
  pc8001.writeMemory(hl,(c>>4)|((t<<4)&0xf0))
  pc8001.z80.regs["A"]=t=(t&0xf0)|(c&0x0f);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0xed][0x6f]=["RLD",18];
pc8001.z80.mnemonics["RLD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var c=pc8001.memory[hl];
  var t=pc8001.z80.regs["A"];
  pc8001.writeMemory(hl,((c<<4)&0xf0)|(t&0x0f))
  pc8001.z80.regs["A"]=t=(t&0xf0)|(c>>4);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0xed][0xa0]=["LDI",16];
pc8001.z80.mnemonics["LDI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var de=pc8001.z80.regs["D"]*256+pc8001.z80.regs["E"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  pc8001.writeMemory(de,pc8001.memory[hl]);
  hl=(hl+1)&0xffff;
  de=(de+1)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["D"]=de>>8;
  pc8001.z80.regs["E"]=de&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.ops[0xed][0xb0]=["LDIR",21];
pc8001.z80.mnemonics["LDIR"]=function(x,m){
  pc8001.z80.mnemonics["LDI"](x,m);
  if(pc8001.z80.flags["V"]==1)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xa8]=["LDD",16];
pc8001.z80.mnemonics["LDD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var de=pc8001.z80.regs["D"]*256+pc8001.z80.regs["E"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  pc8001.writeMemory(de,pc8001.memory[hl]);
  hl=(hl+0xffff)&0xffff;
  de=(de+0xffff)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["D"]=de>>8;
  pc8001.z80.regs["E"]=de&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
  pc8001.z80.flags["H"]=0;
  pc8001.z80.flags["N"]=0;
}
pc8001.z80.ops[0xed][0xb8]=["LDDR",21];
pc8001.z80.mnemonics["LDDR"]=function(x,m){
  pc8001.z80.mnemonics["LDD"](x,m);
  if(pc8001.z80.flags["V"]==1)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xa1]=["CPI",16];
pc8001.z80.mnemonics["CPI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  var t=pc8001.z80.regs["A"];
  var u=pc8001.memory[hl];
  var v=(t-u+256)&0xff;
  hl=(hl+1)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
  pc8001.z80.flags["H"]=((t&0x0f)-(u&0x0f)<0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0xed][0xb1]=["CPIR",21];
pc8001.z80.mnemonics["CPIR"]=function(x,m){
  pc8001.z80.mnemonics["CPI"](x,m);
  if(pc8001.z80.flags["V"]==1&&pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xa9]=["CPD",16];
pc8001.z80.mnemonics["CPD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  var t=pc8001.z80.regs["A"];
  var u=pc8001.memory[hl];
  var v=(t-u+256)&0xff;
  hl=(hl+0xffff)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
  pc8001.z80.flags["H"]=((t&0x0f)-(u&0x0f)<0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0xed][0xb9]=["CPDR",21];
pc8001.z80.mnemonics["CPDR"]=function(x,m){
  pc8001.z80.mnemonics["CPD"](x,m);
  if(pc8001.z80.flags["V"]==1&&pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xdb]=["IN","A","(n)",11];
pc8001.z80.mnemonics["IN"]=function(x,m){
  var c,t,pc;
  if(m[2]=="(n)"){
    pc=pc8001.z80.regs["PC"];
    c=pc8001.memory[pc]+pc8001.z80.regs[m[1]]*256;
    pc8001.z80.regs["PC"]=(pc+1)&0xffff;
  }
  else
    c=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
  pc8001.z80.regs[m[1]]=t=pc8001.inport16(c);
  if(m[2]!="(n)"){
    pc8001.z80.flags["Z"]=(t==0)?1:0;
    pc8001.z80.flags["M"]=(t>0x7f)?1:0;
    pc8001.z80.flags["H"]=0;
    pc8001.z80.flags["N"]=0;
    t=(((t>>6)|4)^(t>>3)^t)&3;
    pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
  }
}
pc8001.z80.ops[0xed][0xa2]=["INI",16];
pc8001.z80.mnemonics["INI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=(pc8001.z80.regs["B"]+0xff)&0xff;
  pc8001.writeMemory(hl,pc8001.inport16(b*256+pc8001.z80.regs["C"]));
  hl=(hl+1)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0xed][0xb2]=["INIR",21];
pc8001.z80.mnemonics["INIR"]=function(x,m){
  pc8001.z80.mnemonics["INI"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xaa]=["IND",16];
pc8001.z80.mnemonics["IND"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=(pc8001.z80.regs["B"]+0xff)&0xff;
  pc8001.writeMemory(hl,pc8001.inport16(b*256+pc8001.z80.regs["C"]));
  hl=(hl+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0xed][0xba]=["INDR",21];
pc8001.z80.mnemonics["INDR"]=function(x,m){
  pc8001.z80.mnemonics["IND"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.inport16=function(p){
  return pc8001.inports[p&0xff];
}
pc8001.z80.ops[0xd3]=["OUT","(n)","A",11];
pc8001.z80.mnemonics["OUT"]=function(x,m){
  var c,pc;
  if(m[1]=="(n)"){
    pc=pc8001.z80.regs["PC"];
    c=pc8001.memory[pc]+pc8001.z80.regs[m[2]]*256;
    pc8001.z80.regs["PC"]=(pc+1)&0xffff;
  }
  else
    c=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
  pc8001.outport16(c,pc8001.z80.regs[m[2]]);
}
pc8001.z80.ops[0xed][0xa3]=["OUTI",16];
pc8001.z80.mnemonics["OUTI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=(pc8001.z80.regs["B"]+0xff)&0xff;
  pc8001.outport16(b*256+pc8001.z80.regs["C"],pc8001.memory[hl]);
  hl=(hl+1)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0xed][0xb3]=["OTIR",21];
pc8001.z80.mnemonics["OTIR"]=function(x,m){
  pc8001.z80.mnemonics["OUTI"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xab]=["OUTD",16];
pc8001.z80.mnemonics["OUTD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=(pc8001.z80.regs["B"]+0xff)&0xff;
  pc8001.outport16(b*256+pc8001.z80.regs["C"],pc8001.memory[hl]);
  hl=(hl+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
  pc8001.z80.flags["N"]=1;
}
pc8001.z80.ops[0xed][0xbb]=["OTDR",21];
pc8001.z80.mnemonics["OTDR"]=function(x,m){
  pc8001.z80.mnemonics["OUTD"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.outport16=function(p,d){
  var t=pc8001.outports[p&0xff];
  pc8001.outports[p&0xff]=d;
  switch(p&0xff){
    case 0x10:
      return;
    case 0x30:
      if((d^t)==1)
        pc8001.resizeDisplay(((d&1)==1)?80:40,25);
      return;
    case 0x40:
      pc8001.beep.on=((d&0x20)==0)?0:1;
      if(((d^t)&6)!=0){
        switch(d&6){
          case 2:
            t=pc8001.calendar.command(pc8001.outports[0x10]);
            break;
          case 4:
            t=pc8001.calendar.shift(pc8001.outports[0x10]);
            break;
          default:
            return;
        }
        if(t==0)
          pc8001.inports[0x40]&=0xef;
        else
          pc8001.inports[0x40]|=0x10;
      }
      return;
    case 0x51:
      switch(d){
        case 0x20:
          pc8001.reverseDisplay(0);
          return;
        case 0x21:
          pc8001.reverseDisplay(1);
          return;
      }
      console.log("OUT (51H),",d);
      return;
  }
  pc8001.z80.mnemonics["UNDEF"](p&0xff,["UNDEF","OUT",0]);
}
pc8001.z80.ops[0xdd][0xcb]=["EXTCB","DD CB dd","JX",20];
pc8001.z80.ops[0xfd][0xcb]=["EXTCB","FD CB dd","KY",20];
pc8001.z80.mnemonics["EXTCB"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var d=pc8001.memory[pc];
  var e=pc8001.memory[(pc+1)&0xffff];
  var f=pc8001.z80.ops[0xcb][e].slice();
  pc8001.z80.regs["PC"]=(pc+2)&0xffff;
  if(f[f.length-2]=="(HL)"){
    f[f.length-2]="("+m[2]+"+"+d.toString(16).padStart(2,"0")+")";
    pc8001.z80.mnemonics[f[0]](e,f);
    return;
  }
  pc8001.z80.mnemonics["UNDEF"](e,["UNDEF",m[1],0]);
}
pc8001.z80.run=function(){
  var i,pc,v,m,s;
  for(i=0;i<4000;i++){
    pc=pc8001.z80.regs["PC"];
    v=pc8001.memory[pc];
    m=pc8001.z80.ops[v];
    pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
    s=m[m.length-1];
    if(s<0){
      v=pc8001.memory[pc];
      m=m[v];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      s=m[m.length-1];
    }
    pc8001.z80.states+=s;
    pc8001.z80.mnemonics[m[0]](v,m);
    if(pc8001.z80.halt==1)
      return;
    if(pc8001.beep.counter!=-1){
      v=Math.floor(pc8001.z80.states*pc8001.beep.audio.sampleRate/pc8001.z80.frequency)%pc8001.beep.refWave.length;
      if(v==pc8001.beep.counter){
        pc8001.beep.wave[v]=pc8001.beep.on*pc8001.beep.refWave[v];
        pc8001.beep.counter=(pc8001.beep.counter+1)%pc8001.beep.refWave.length;
      }
    }
    s=pc8001.z80.states-(performance.now()-pc8001.z80.millitimer)*pc8001.z80.millistates;
    if(s>1000)
      break;
  }
  if(s<0){
    pc8001.z80.states%=pc8001.z80.frequency;
    pc8001.z80.millitimer=performance.now()-pc8001.z80.states/pc8001.z80.millistates;
  }
  pc8001.z80.timer=setTimeout("clearTimeout(pc8001.z80.timer);pc8001.z80.run()",(s>1000)?s/pc8001.z80.millistates:0);
}
pc8001.run=function(){
  document.addEventListener("keydown",pc8001.keydown);
  document.addEventListener("keyup",pc8001.keyup);
  pc8001.z80.millitimer=performance.now();
  pc8001.z80.run();
}
</script>
<style>
.blink{
  animation: blink 1.5s step-end infinite
}
@keyframes blink{
  0% {opacity:1}
  75% {opacity:0}
}
</style>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 width=984 height=624 viewBox="-2 -2 164 104"
 style="background-color:black"
 onload="pc8001.initDisplay(this);pc8001.run()">
</svg>
</body>
</html>
```

[カレンダークロックμPD1990ACへの書き込み](https://qiita.com/KoichiYasuoka/items/9410023f213e62a822a4)をエミュレートしたり、μPD3301の連続画面反転(「OUT (51H),A」で21Hと20Hを交互に渡す)をエミュレートしたり、かなり苦労して実装したのだが、肝心のゲームの内容が思い出せない。7分間の制限時間内に立体迷路を脱出するのだが、出口からQUIPが20杪おきに入ってくるので、QUIPを倒す(ファンクションキー1・2・3が攻撃モードへの切り替え)必要がある、というのが、40年前の私(安岡孝一)による設定だったように思う。攻撃モードでは、ファンクションキー1・2・3で距離を合わせ、テンキーの8・2・4・6で照準を合わせて、スペースキーで攻撃するのだが、とりあえずファンクションキー1・2・3はF・B・Nに、テンキーの8・2・4・6は上下左右の矢印キーに、それぞれ割り当てておいた。移動モードへの切り替えはシフトキーだが、こちらはテンキーの8・2・4・6で向きを変えることになっていたため、これも上下左右の矢印キーにアサインした。移動モードでの前進はテンキーの5だが、これはスペースキーと共用にした。あと、探査モードへの切り替えがファンクションキー4・5に準備されているが、これは&lt; &gt;にキーアサインした。それにしても、キーがヤヤコシイ。こんなの覚えられないと思うのだが、試しに遊んでみてほしい。