ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/vt102/vt102
(Generate patch)

Comparing vt102/vt102 (file contents):
Revision 1.5 by root, Mon Dec 1 18:41:36 2014 UTC vs.
Revision 1.13 by root, Wed Dec 3 02:13:26 2014 UTC

15# 15#
16 16
17# If this file contains embedded ROMs, the above copyright notice does 17# If this file contains embedded ROMs, the above copyright notice does
18# not apply to them. 18# not apply to them.
19 19
20# this hack is not considered release ready in and way, shape, or form 20use strict;
21# ./vt102 bash
22# ./vt102 telnet towel.blinkenlights.nl
23# ./vt102 curl http://artscene.textfiles.com/vt100/trekvid.vt
24# ./vt102 curl http://artscene.textfiles.com/vt100/surf.vt # in 3d!
25
26# TODO: ctrl
27
28use common::sense; 21#use common::sense;
29
30$| = 1;
31 22
32my $VT102 = 1; 23my $VT102 = 1;
33my $AVO = $VT102 || 1; 24my $VT131 = 0;
25my $AVO = 1;
34my $KBD = 1; 26my $KBD = 1;
35 27
36############################################################################# 28shift, ($VT102 = 0), ($AVO = 0) if $ARGV[0] =~ /^-?-vt100$/;
37# rom initialising 29shift, ($VT102 = 0) if $ARGV[0] =~ /^-?-vt100\+avo$/;
30shift if $ARGV[0] =~ /^-?-vt102$/;
31shift, ($VT131 = 1) if $ARGV[0] =~ /^-?-vt131$/;
38 32
33if ($ARGV[0] =~ /^-/) {
34 die <<EOF;
35
36VT102, A VT100/101/102/131 SIMULATOR
37
38Usage:
39
40 $0 [option] [program [args]]
41
42Examples:
43
44 $0 bash
45 $0 telnet towel.blinkenlights.nl
46 $0 curl http://artscene.textfiles.com/vt100/trekvid.vt
47 $0 curl http://artscene.textfiles.com/vt100/surf.vt # in 3d!
48
49Option can be one of:
50
51 --vt100
52 --vt100+avo
53 --vt102
54 --vt131
55
56Non-obvious special keys are:
57
58 SET UP Home
59 BACKSPACE Rubout
60 CAPS LOCK Prior/PgUp
61 NO SCROLL Next/PgDown
62 BREAK End
63
64Set-Up Guide:
65
66 http://vt100.net/docs/vt102-ug/chapter3.html#S3.6
67
68Author:
69
70 Marc Lehmann <vt102\@schmorp.de>
71
72EOF
73}
74
75#############################################################################
76# ROM/hardware init
77
39my $ROM = do { 78my $ROMS = do {
40 binmode DATA; 79 binmode DATA;
41 local $/; 80 local $/;
42 <DATA> 81 <DATA>
43}; 82};
44 83
450x6001 == length $ROM or die "corrupted rom image"; 840x6801 == length $ROMS or die "corrupted rom image";
46 85
47binmode STDOUT; 86binmode STDOUT;
48 87
49my @M = (0xff) x 65536; # main memory, = (0xff) x 65536; 88my @M = (0xff) x 65536; # main memory, = (0xff) x 65536;
50 89
51# populate mem with rom contents 90# populate mem with rom contents
52if ($VT102) { 91if ($VT102) {
53 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROM, 0x2000, 0x2000; 92 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x2000, 0x2000;
54 @M[0x8000 .. 0x9fff] = unpack "C*", substr $ROM, 0x4000, 0x2000; 93 @M[0x8000 .. 0x9fff] = unpack "C*", substr $ROMS, 0x4000, 0x2000;
94 @M[0xa000 .. 0xa7ff] = unpack "C*", substr $ROMS, 0x6000, 0x0800 if $VT131;
55} else { 95} else {
56 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROM, 0x0000, 0x2000; 96 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x0000, 0x2000;
57} 97}
58 98
59############################################################################# 99#############################################################################
60# cpu registers and I/O support 100# 8085 CPU registers and I/O support
61 101
62my $PTY; # the pty we allocated, if any 102my $PTY; # the pty we allocated, if any
63my $PRSTATUS = 0;
64 103
65# 8080/8085 registers 104# 8080/8085 registers
66# b, c, d, e, h, l, a 105# b, c, d, e, h, l, a
67my ($A, $B, $C, $D, $E, $H, $L, $A); 106my ($A, $B, $C, $D, $E, $H, $L, $A);
68my ($PC, $SP, $IFF, $FA, $FZ, $FS, $FP, $FC); 107my ($PC, $SP, $IFF, $FA, $FZ, $FS, $FP, $FC);
74my $x; # dummy temp for instructions 113my $x; # dummy temp for instructions
75 114
76my $CLK; # rather inexact clock 115my $CLK; # rather inexact clock
77 116
78############################################################################# 117#############################################################################
79# the dreaded nvr1400 chip. not needed to get it going, but provided for reference 118# the dreaded NVR1400 chip. not needed to get it going, but provided anyway
80 119
81# nvram 120# nvram
82my @NVR = (0x3fff) x 100; # vt102: 214e accum, 214f only lower 8 bit used, first 44 bytes 121my @NVR = (0x3fff) x 100; # vt102: 214e accum, 214f only lower 8 bit used, first 44 bytes
83my $NVRADDR; 122my $NVRADDR;
84my $NVRDATA; 123my $NVRDATA;
107 146
108 $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1) 147 $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1)
109} 148}
110 149
111############################################################################# 150#############################################################################
151# I/O ports - output
112 152
113my $DC11 = 0; # 4 bit commands 153my $DC11_REVERSE = 0;
114my $DC12 = 0;
115 154
116my $XON = 1; # false if terminal wants us to pause 155my $XON = 1; # false if terminal wants us to pause
117my $PUSARTCMD; 156my $PUSARTCMD;
118 157
119my @KXMIT; # current scan queue 158my @KXMIT; # current scan queue
155 194
156sub out_62 { 195sub out_62 {
157 $NVRLATCH = shift; 196 $NVRLATCH = shift;
158} 197}
159 198
160sub out_a2 { $DC11 = shift } 199sub out_a2 {
200 my $dc11 = 0x0f & shift;
201
202 $DC11_REVERSE = 1 if $dc11 == 0b1010;
203 $DC11_REVERSE = 0 if $dc11 == 0b1011;
204}
205
161sub out_c2 { } # unknown 206sub out_c2 { } # unknown
162sub out_d2 { $DC12 = shift } 207sub out_d2 { } # 0..3 == 80c/132c/60hz/50hz
163 208
164sub out_82 { 209sub out_82 {
165 # keyboard 210 # keyboard
166 211
167 # CLICK STARTSCAN ONLINE LOCKED | CTS DSR INSERT L1(?) 212 # CLICK STARTSCAN ONLINE LOCKED | CTS DSR INS L1
168 # CLICK STARTSCAN ONLINE LOCKED | LED1 LED2 LED3 LED4 213 # CLICK STARTSCAN ONLINE LOCKED | L1 L2 L3 L4
169 $KSTATUS = $_[0]; 214 $KSTATUS = $_[0];
170 215
171 # start new scan unless scan in progress 216 # start new scan unless scan in progress
172 if (($_[0] & 0x40) && !@KXMIT) { 217 if (($_[0] & 0x40) && !@KXMIT) {
173 # do not reply with keys in locked mode 218 # do not reply with keys in locked mode
196 $RST |= 1; 241 $RST |= 1;
197 } 242 }
198} 243}
199 244
200############################################################################# 245#############################################################################
246# I/O ports - input
201 247
202my $NVRBIT; 248my $NVRBIT;
203my $LBA; 249my $LBA6; # twice the frequenxy of LBA7
204 250
205sub in_00 { # pusart data 251sub in_00 { # pusart data
206 # interrupt not generated here, because infinite 252 # interrupt not generated here, because infinite
207 # speed does not go well with the vt102. 253 # speed does not go well with the vt102.
208 254
217sub in_22 { # modem buffer(?) 263sub in_22 { # modem buffer(?)
218 # wild guess: -CTS -SPDI -RI -CD 0 0 0 0 264 # wild guess: -CTS -SPDI -RI -CD 0 0 0 0
219 0x20 265 0x20
220} 266}
221 267
222sub in_0f { } # unknown, connected to out 2f 268sub in_0f { 0xff } # vt102 unknown, connected to out 2f
223 269
224sub in_42 { # flag buffer 270sub in_42 { # flag buffer
225 ++$LBA; 271 ++$LBA6;
226 272
227 $NVRBIT = nvr ? 0x20 : 0x00 if ($LBA & 0x3) == 0x2; 273 $NVRBIT = nvr ? 0x20 : 0x00 if ($LBA6 & 0x3) == 0x2;
228 274
229 # KBD_XMITEMPTY LBA7 NVRDATA ODDFIELD - OPTION !GFX !AVO PUSART_TXRDY 275 # KBD_XMITEMPTY LBA7 NVRDATA ODDFIELD - OPTION !GFX !AVO PUSART_TXRDY
230 276
231 my $f = 0x85 | $NVRBIT; 277 my $f = 0x85 | $NVRBIT;
232 278
233 $f |= 0x02 unless $AVO; 279 $f |= 0x02 unless $AVO;
234 $f |= 0x40 if $LBA & 0x2; 280 $f |= 0x40 if $LBA6 & 0x2;
235 281
236 $f 282 $f
237} 283}
238 284
239sub in_82 { # tbmt keyboard uart 285sub in_82 { # tbmt keyboard uart
241 287
242 $RST |= 1; 288 $RST |= 1;
243 shift @KXMIT 289 shift @KXMIT
244} 290}
245 291
246sub in_03 { 0xff } # unknown, printer uart input? 292sub in_03 { 0xff } # vt102 unknown, printer uart input?
247sub in_0b { 0xff } # unknown 293sub in_0b { 0xff } # vt102 unknown
248sub in_17 { 0xff } # unknown, printer status clear by reading? 294sub in_17 { 0xff } # vt102 unknown, printer status clear by reading?
249sub in_1b { 0xff } # unknown 295sub in_1b { 0xff } # vt102 unknown
250 296
251############################################################################# 297#############################################################################
298# 8085 cpu opcodes and flag handling
252 299
253sub sf { # set flags (ZSC - AP not implemented) 300sub sf { # set flags (ZSC - AP not implemented)
254 $FS = $_[0] & 0x080; 301 $FS = $_[0] & 0x080;
255 $FZ = ($_[0] & 0x0ff) == 0; 302 $FZ = !($_[0] & 0x0ff);
256 $FC = $_[0] & 0x100; 303 $FC = $_[0] & 0x100;
257 304
258 $_[0] & 0xff 305 $_[0] &= 0xff;
306}
307
308sub sf8 { # set flags (ZSC - AP not implemented)
309 $FS = $_[0] & 0x080;
310 $FZ = !($_[0] & 0x0ff);
311 $FC = 0;
259} 312}
260 313
261sub sf_nc { # set flags except carry 314sub sf_nc { # set flags except carry
262 $FS = $_[0] & 0x080; 315 $FS = $_[0] & 0x080;
263 $FZ = ($_[0] & 0x0ff) == 0; 316 $FZ = ($_[0] & 0x0ff) == 0;
264 317
265 $_[0] & 0xff 318 $_[0] &= 0xff;
266} 319}
267 320
268my @op = map { sprintf "status(); die 'unknown op %02x'", $_ } 0 .. 255; 321my @op = map { sprintf "status(); die 'unknown op %02x'", $_ } 0x00 .. 0xff;
269my @ops;
270 322
271my @reg = qw($B $C $D $E $H $L $M[$H*256+$L] $A); 323my @reg = qw($B $C $D $E $H $L $M[$H*256+$L] $A);
272my @cc = ('if !$FZ', 'if $FZ', 'if !$FC', 'if $FC', ';die', ';die', 'if !$FS', 'if $FS'); # die == unimplemented $FP parity 324my @cc = ('if !$FZ', 'if $FZ', 'if !$FC', 'if $FC', ';die', ';die', 'if !$FS', 'if $FS'); # die == unimplemented $FP parity
325
326$op[0x00] = '';
273 327
274# mov r,r / r,M / M,r 328# mov r,r / r,M / M,r
275for my $s (0..7) { 329for my $s (0..7) {
276 for my $d (0..7) { 330 for my $d (0..7) {
277 $op[0x40 + $d * 8 + $s] = "$reg[$d] = $reg[$s]"; 331 $op[0x40 + $d * 8 + $s] = "$reg[$d] = $reg[$s]"; # mov
278 } 332 }
279} 333}
280 334
281$op[0x00] = ''; 335$op[0x76] = 'die "HLT"'; # hlt (mov m,m)
336
337# mvi r / M
338$op[0x06 + $_ * 8] = "$reg[$_] = IMM8" for 0..7;
282 339
283$op[0x01] = '($B, $C) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi 340$op[0x01] = '($B, $C) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi
284$op[0x11] = '($D, $E) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi 341$op[0x11] = '($D, $E) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi
285$op[0x21] = '($H, $L) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi 342$op[0x21] = '($H, $L) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi
286$op[0x31] = '$SP = IMM16' ; # lxi #d# 0xf000 because of limited stack 343$op[0x31] = '$SP = IMM16' ; # lxi
287 344
288$op[0x02] = '$M[$B * 256 + $C] = $A'; # stax 345$op[0x02] = '$M[$B * 256 + $C] = $A'; # stax
289$op[0x12] = '$M[$D * 256 + $E] = $A'; # stax 346$op[0x12] = '$M[$D * 256 + $E] = $A'; # stax
290$op[0x32] = '$M[IMM16 ] = $A'; # sta 347$op[0x32] = '$M[IMM16 ] = $A'; # sta
291 348
349$op[0x0a] = '$A = $M[$B * 256 + $C]'; # ldax b
350$op[0x1a] = '$A = $M[$D * 256 + $E]'; # ldax d
351$op[0x3a] = '$A = $M[IMM16]'; # lda
352
353$op[0x22] = '($M[IMM16], $M[IMM16 + 1]) = ($L, $H)'; # shld
354$op[0x2a] = '($L, $H) = ($M[IMM16], $M[IMM16 + 1])'; # lhld
355
292sub inxdcx($$$) { 356sub inxdcx($$$) {
293 $x = ($_[0] * 256 + $_[1] + $_[2]) & 0xffff; 357 $x = $_[0] * 256 + $_[1] + $_[2];
294 $_[0] = $x >> 8; 358 ($_[0], $_[1]) = (($x >> 8) & 0xff, $x & 0xff);
295 $_[1] = $x & 0xff;
296} 359}
297 360
298$op[0x03] = 'inxdcx $B, $C, 1'; # inx 361$op[0x03] = 'inxdcx $B, $C, 1'; # inx
299$op[0x13] = 'inxdcx $D, $E, 1'; # inx 362$op[0x13] = 'inxdcx $D, $E, 1'; # inx
300$op[0x23] = 'inxdcx $H, $L, 1'; # inx 363$op[0x23] = 'inxdcx $H, $L, 1'; # inx
303$op[0x1b] = 'inxdcx $D, $E, -1'; # dcx 366$op[0x1b] = 'inxdcx $D, $E, -1'; # dcx
304$op[0x2b] = 'inxdcx $H, $L, -1'; # dcx 367$op[0x2b] = 'inxdcx $H, $L, -1'; # dcx
305$op[0x3b] = '--$SP' ; # dcx 368$op[0x3b] = '--$SP' ; # dcx
306 369
307# "no carry" doesn't seem to be needed for vt100 - optimize? 370# "no carry" doesn't seem to be needed for vt100 - optimize?
308$op[0x04 + $_ * 8] = "$reg[$_] = sf_nc $reg[$_] + 1" for 0..7; # inr
309$op[0x05 + $_ * 8] = "$reg[$_] = sf_nc $reg[$_] - 1" for 0..7; # dcr
310
311# mvi r / M
312$op[0x06 + $_ * 8] = "$reg[$_] = IMM8" for 0..7; 371$op[0x04 + $_ * 8] = "sf_nc ++$reg[$_]" for 0..7; # inr
372$op[0x05 + $_ * 8] = "sf_nc --$reg[$_]" for 0..7; # dcr
373
374$op[0x07] = ' $FC = $A & 0x80; $A = (($A << 1) + ($FC && 0x01)) & 0xff '; # rlc
375$op[0x17] = ' ($FC, $A) = ($A & 0x80, (($A << 1) + ($FC && 0x01)) & 0xff)'; # ral
376
377$op[0x0f] = ' $FC = $A & 0x01; $A = ($A >> 1) | ($FC && 0x80) '; # rrc
378$op[0x1f] = ' ($FC, $A) = ($A & 0x01, ($A >> 1) | ($FC && 0x80))'; # rar
379
380$op[0x2f] = '$A ^= 0xff'; # cma
313 381
314# getting this insn wrong (its the only 16 bit insn to modify flags) 382# getting this insn wrong (its the only 16 bit insn to modify flags)
315# wasted three of my best days with mindless vt102 rom reverse engineering 383# wasted three of my best days with mindless vt102 rom reverse engineering
316sub dad { 384sub dad {
317 $x = $H * 256 + $L + $_[0]; 385 $x = $H * 256 + $L + $_[0];
323$op[0x09] = 'dad $B * 256 + $C'; # dad 391$op[0x09] = 'dad $B * 256 + $C'; # dad
324$op[0x19] = 'dad $D * 256 + $E'; # dad 392$op[0x19] = 'dad $D * 256 + $E'; # dad
325$op[0x29] = 'dad $H * 256 + $L'; # dad 393$op[0x29] = 'dad $H * 256 + $L'; # dad
326$op[0x39] = 'dad $SP '; # dad 394$op[0x39] = 'dad $SP '; # dad
327 395
328$op[0x07] = ' $FC = $A >> 7; $A = ($A * 2 + $FC) & 0xff '; # rlc 396$op[0x80 + $_] = 'sf $A += + ' . $reg[$_] for 0..7; # add
329$op[0x17] = ' ($FC, $A) = ($A >> 7, ($A * 2 + $FC) & 0xff)'; # ral 397$op[0x88 + $_] = 'sf $A += ($FC && 1) + ' . $reg[$_] for 0..7; # adc
398$op[0x90 + $_] = 'sf $A -= + ' . $reg[$_] for 0..7; # sub
399$op[0x98 + $_] = 'sf $A -= ($FC && 1) + ' . $reg[$_] for 0..7; # sbb
400$op[0xa0 + $_] = 'sf8 $A &= ' . $reg[$_] for 0..7; # ana
401$op[0xa8 + $_] = 'sf8 $A ^= ' . $reg[$_] for 0..7; # xra
402$op[0xb0 + $_] = 'sf8 $A |= ' . $reg[$_] for 0..7; # ora
403$op[0xb8 + $_] = 'sf $x = $A - ' . $reg[$_] for 0..7; # cmp
404# possible todo: optimize ora a, maybe xra a
330 405
331$op[0x0f] = ' $FC = $A & 1; $A = ($A >> 1) | ($FC && 0x80) '; # rrc 406$op[0xc6] = 'sf $A += IMM8'; # adi
332$op[0x1f] = ' ($FC, $A) = ($A & 1, ($A >> 1) | ($FC && 0x80))'; # rar 407# ce ADI NYI
408$op[0xd6] = 'sf $A -= IMM8'; # sui
409# de SBI NYI
410$op[0xe6] = 'sf8 $A &= IMM8'; # ani
411$op[0xee] = 'sf8 $A ^= IMM8'; # xri
412$op[0xf6] = 'sf8 $A |= IMM8'; # ori
413$op[0xfe] = 'sf $A - IMM8'; # cpi
333 414
334$op[0x0a] = '$A = $M[$B * 256 + $C]'; # ldax b 415$op[0xc5] = 'PUSH $B; PUSH $C';
335$op[0x1a] = '$A = $M[$D * 256 + $E]'; # ldax d 416$op[0xd5] = 'PUSH $D; PUSH $E';
336$op[0x3a] = '$A = $M[IMM16]'; # lda 417$op[0xe5] = 'PUSH $H; PUSH $L';
418$op[0xf5] = 'PUSH $A; PUSH +($FS && 0x80) | ($FZ && 0x40) | ($FA && 0x10) | ($FP && 0x04) | ($FC && 0x01)'; # psw
419
420$op[0xc1] = '($C, $B) = (POP, POP)'; # pop
421$op[0xd1] = '($E, $D) = (POP, POP)'; # pop
422$op[0xe1] = '($L, $H) = (POP, POP)'; # pop
423$op[0xf1] = '($x, $A) = (POP, POP); ($FS, $FZ, $FA, $FP, $FC) = ($x & 0x80, $x & 0x40, $x & 0x10, $x & 0x04, $x & 0x01)'; # pop psw
424
425$op[0xc2 + $_ * 8] = 'BRA IMM16 ' . $cc[$_] for 0..7; # jcc
426$op[0xc3] = 'JMP IMM16'; # jmp
427
428$op[0xc4 + $_ * 8] = '(PUSH PC >> 8), (PUSH PC & 0xff), (BRA IMM16) ' . $cc[$_] for 0..7; # ccc
429$op[0xcd] = '(PUSH PC >> 8), (PUSH PC & 0xff), (BRA IMM16)'; # call
430
431$op[0xc0 + $_ * 8] = 'BRA POP + POP * 256 ' . $cc[$_] for 0..7; # rcc
432$op[0xc9] = 'JMP POP + POP * 256'; # ret
433
434$op[0xc7 + $_ * 8] = "JMP $_ * 8" for 0..7; # rst
435
436$op[0xe9] = 'JMP $H * 256 + $L'; # pchl
437# f9 SPHL NYI
438
439$op[0x37] = '$FC = 1 '; # stc
440$op[0x3f] = '$FC = !$FC'; # cmc
441
442$op[0xd3] = 'OUT'; # out
443$op[0xdb] = 'IN'; # in
444
445$op[0xeb] = '($D, $E, $H, $L) = ($H, $L, $D, $E)'; # xchg
446
447# e3 xthl NYI # @ 917b, hl <-> (sp)
337 448
338$op[0x20] = '$A = $INTPEND * 16 + $INTMASK + ($IFF && 8)'; # rim (incomplete) 449$op[0x20] = '$A = $INTPEND * 16 + $INTMASK + ($IFF && 8)'; # rim (incomplete)
339$op[0x30] = '$INTMASK = $A & 7 if $A & 8'; # sim (incomplete) 450$op[0x30] = '$INTMASK = $A & 7 if $A & 8'; # sim (incomplete)
340 451
341$op[0x22] = '($M[IMM16], $M[IMM16 + 1]) = ($L, $H)'; # shld 452$op[0xf3] = '$IFF = 0'; # DI
342$op[0x2a] = '($L, $H) = ($M[IMM16], $M[IMM16 + 1])'; # lhld 453$op[0xfb] = '$IFF = 1'; # EI
343 454
344# yeah, the fucking setup screens actually use daa... 455# yeah, the fucking setup screens actually use daa...
345$op[0x27] = ' 456$op[0x27] = '
346 my ($h, $l); 457 my ($h, $l);
347 458
348 ($h, $l) = ($A >> 4, $A & 15); 459 ($h, $l) = ($A >> 4, $A & 15);
349 460
350 if ($l > 9 || $FA) { 461 if ($l > 9 || $FA) {
351 $A = sf $A + 6; 462 sf $A += 6;
352 ($h, $l) = ($A >> 4, $A & 15); 463 ($h, $l) = ($A >> 4, $A & 15);
353 } 464 }
354 465
355 if ($h > 9 || $FC) { 466 if ($h > 9 || $FC) {
356 $h += 6; 467 $h += 6;
357 $A = ($h * 16 + $l) & 0xff; 468 $A = ($h * 16 + $l) & 0xff;
358 } 469 }
359'; # daa, almost certainly borked, also, acarry not set by sf 470'; # daa, almost certainly borked, also, acarry not set by sf
360 471
361$op[0x2f] = '$A ^= 0xff'; # cma
362
363$op[0x37] = '$FC = 1 '; # stc
364$op[0x3f] = '$FC = !$FC'; # cmc
365
366$op[0x76] = 'die "HLT"'; # hlt
367
368$op[0x80 + $_] = '$A = sf $A + ' . $reg[$_] for 0..7; # add
369$op[0x88 + $_] = '$A = sf $A + $FC + ' . $reg[$_] for 0..7; # adc
370$op[0x90 + $_] = '$A = sf $A - ' . $reg[$_] for 0..7; # sub
371$op[0x98 + $_] = '$A = sf $A - $FC - ' . $reg[$_] for 0..7; # sbb
372$op[0xa0 + $_] = '$A = sf $A & ' . $reg[$_] for 0..7; # ana
373$op[0xa8 + $_] = '$A = sf $A ^ ' . $reg[$_] for 0..7; # xra
374$op[0xb0 + $_] = '$A = sf $A | ' . $reg[$_] for 0..7; # ora
375$op[0xb8 + $_] = ' sf $A - ' . $reg[$_] for 0..7; # cmp
376# possible todo: optimize ora a, maybe xra a
377
378$op[0xc6 + $_] = '$A = sf $A + IMM8'; # adi
379$op[0xd6 + $_] = '$A = sf $A - IMM8'; # sui
380$op[0xe6 + $_] = '$A = sf $A & IMM8'; # ani
381$op[0xee + $_] = '$A = sf $A ^ IMM8'; # xri
382$op[0xf6 + $_] = '$A = sf $A | IMM8'; # ori
383$op[0xfe + $_] = ' sf $A - IMM8'; # cpi
384
385$op[0xc1] = '($C, $B) = (POP, POP)'; # pop
386$op[0xd1] = '($E, $D) = (POP, POP)'; # pop
387$op[0xe1] = '($L, $H) = (POP, POP)'; # pop
388$op[0xf1] = '($x, $A) = (POP, POP); ($FS, $FZ, $FA, $FP, $FC) = (!!($x & 0x80), !!($x & 0x40), !!($x & 0x10), !!($x & 0x04), !!($x & 0x01))'; # pop psw
389
390$op[0xeb] = '($D, $E, $H, $L) = ($H, $L, $D, $E)'; # xchg
391
392$op[0xc2 + $_ * 8] = 'BRA IMM16 ' . $cc[$_] for 0..7; # jcc
393$op[0xc3] = 'JMP IMM16'; # jmp
394
395$op[0xc4 + $_ * 8] = '(PUSH PC >> 8), (PUSH PC & 0xff), (BRA IMM16) ' . $cc[$_] for 0..7; # ccc
396$op[0xcd] = '(PUSH PC >> 8), (PUSH PC & 0xff), (BRA IMM16)'; # call
397
398$op[0xc7 + $_ * 8] = "JMP $_ * 8" for 0..7; # rst
399
400$op[0xc0 + $_ * 8] = 'BRA POP + POP * 256 ' . $cc[$_] for 0..7; # rcc
401$op[0xc9] = 'JMP POP + POP * 256'; # ret
402
403$op[0xc5] = 'PUSH $B; PUSH $C';
404$op[0xd5] = 'PUSH $D; PUSH $E';
405$op[0xe5] = 'PUSH $H; PUSH $L';
406$op[0xf5] = 'PUSH $A; PUSH +($FS && 0x80) | ($FZ && 0x40) | ($FA && 0x10) | ($FP && 0x04) | ($FC && 0x01)'; # psw
407
408$op[0xd3] = 'OUT'; # out
409$op[0xdb] = 'IN'; # in
410
411# e3 xthl @ 917b, hl <-> (sp)
412
413$op[0xe9] = 'JMP $H * 256 + $L'; # pchl
414
415$op[0xf3] = '$IFF = 0'; # DI
416$op[0xfb] = '$IFF = 1'; # EI
417
418@ops = @op; # for debugging #d#
419
420############################################################################# 472#############################################################################
473# print cpu status for debugging purposes
421 474
422# print cpu status, for debugging 475# print cpu status, for debugging
423sub status { 476sub status {
424 my $PC = shift || $PC; 477 my $PC = shift || $PC;
425 478
429 ($FZ ? "1" : "0") 482 ($FZ ? "1" : "0")
430 . ($FS ? "1" : "0") 483 . ($FS ? "1" : "0")
431 . ($FC ? "1" : "0") 484 . ($FC ? "1" : "0")
432 . ($FA ? "1" : "0") 485 . ($FA ? "1" : "0")
433 . ($FP ? "1" : "0"), 486 . ($FP ? "1" : "0"),
434 $M[$PC], $ops[$M[$PC]]; 487 $M[$PC], $op[$M[$PC]];
435} 488}
436 489
437############################################################################# 490#############################################################################
491# video emulation
438 492
439my @chr = ( 493my @CHARMAP = (
440 " " , "\x{29eb}", "\x{2592}", "\x{2409}", 494 " " , "\x{29eb}", "\x{2592}", "\x{2409}",
441 "\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}", 495 "\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}",
442 "\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}", 496 "\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}",
443 "\x{2510}", "\x{250c}", "\x{2514}", "\x{253c}", 497 "\x{2510}", "\x{250c}", "\x{2514}", "\x{253c}",
444 "\x{23ba}", "\x{23bb}", "\x{2500}", "\x{23bc}", 498 "\x{23ba}", "\x{23bb}", "\x{2500}", "\x{23bc}",
446 "\x{252c}", "\x{2502}", "\x{2264}", "\x{2265}", 500 "\x{252c}", "\x{2502}", "\x{2264}", "\x{2265}",
447 "\x{03c0}", "\x{2260}", "\x{00a3}", "\x{00b7}", 501 "\x{03c0}", "\x{2260}", "\x{00a3}", "\x{00b7}",
448 (map chr, 0x020 .. 0x7e), 502 (map chr, 0x020 .. 0x7e),
449); 503);
450 504
451utf8::encode $_ for @chr; 505utf8::encode $_ for @CHARMAP;
452 506
453sub prscr { 507my @SGR; # sgr sequences for attributes
508
509for (0x00 .. 0xff) {
510 my $sgr = "";
511
512 # ~1 sgr 5 blink
513 # ~2 sgr 4 underline
514 # ~4 sgr 1 bold
515 # 0x80 in attr, sgr 7, reversed
516
517 $sgr .= ";5" unless $_ & 0x01;
518 $sgr .= ";4" unless $_ & 0x02;
519 $sgr .= ";1" unless $_ & 0x04;
520 $sgr .= ";7" if $_ & 0x80;
521
522 $SGR[$_] = "\e[${sgr}m";
523}
524
525my @LED = $VT102
526 ? qw(L1 INSERT DSR CTS LOCKED LOCAL SCAN BEEP)
527 : qw(L4 L3 L2 L1 LOCKED LOCAL SCAN BEEP);
528
529# display screen
530sub display {
454 my $i = 0x2000; 531 my $i = 0x2000;
455 532
456 my $scr = sprintf "\x1b[H--- KBD %08b CLK %d PC %04x RST %03b IFF %01b PUS %02x IM %03b\x1b[K\n", $KSTATUS, $CLK, $PC, $RST, $IFF, $PUSARTCMD, $INTMASK; 533 my $leds = join " ", map $KSTATUS & 2**$_ ? "\e[7m$LED[$_]\e[m" : "$LED[$_]", reverse 0 .. $#LED;
534
535 my $scr = sprintf "\e[H--- LED [ %s ] CLK %d\e[K\n", $leds, $CLK;
536
537 $scr .= "\e[?5" . ($DC11_REVERSE ? "h" : "l");
457 538
458 line: 539 line:
459 for my $y (0 .. 25) { 540 for my $y (0 .. 25) { # ntsc, two vblank delay lines, up to 24 text lines
541 my $prev_sgr;
542
460 $scr .= sprintf "%2d |", ++$y; 543 $scr .= sprintf "%2d \xe2\x94\x82", $y;
461 544
462 for (0..140) { 545 for (0..139) {
463 my $c = $M[$i++]; 546 my $c = $M[$i];
464
465# printf "%04x %02x\n", $i-1,$c;
466 547
467 if ($c == 0x7f) { # also 0xff, but the firmware avoids that 548 if ($c == 0x7f) { # also 0xff, but the firmware avoids that
468 $scr .= "|\x1b[K\n"; 549 $scr .= "\e[m\xe2\x94\x82\e[K\n";
469 550
470 my $a1 = $M[$i++]; 551 my $a1 = $M[$i + 1];
471 my $a0 = $M[$i++]; 552 my $a0 = $M[$i + 2];
472 553
473 $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff); 554 $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff);
474 555
475 next line; 556 next line;
476 } 557 }
477 558
478 $scr .= "\x1b[7m" if $c & 0x80; 559 my $sgr = $SGR[ ($M[$i++ + 0x1000] & 15) | ($c & 0x80)];
479 $scr .= $chr[$c & 0x7f] // sprintf "[%02x]", $c & 0x7f; 560
480 $scr .= "\x1b[m" if $c & 0x80; 561 $scr .= $prev_sgr = $sgr if $sgr ne $prev_sgr;
562
563 $scr .= $CHARMAP[$c & 0x7f];
481 } 564 }
482 565
483 $scr .= "\x1b[K\noverflow\x1b[K\n"; 566 $scr .= "\e[K\nvideo overflow\e[K\n";
484 last; 567 last;
485 } 568 }
486 569
487 if (0) {
488 $scr .= "\x1b[K\n";
489 for my $o (0x200 .. 0x232) {
490 $scr .= sprintf "%04x:", $o * 16;
491 for (0..15) {
492 $scr .= sprintf " %02x", $M[$o * 16 + $_];
493 }
494 $scr .= "\x1b[K\n";
495 }
496 }
497
498 $scr .= "\x1b[J"; 570 $scr .= "\e[m\e[J";
499 571
500 syswrite STDOUT, $scr; 572 syswrite STDOUT, $scr;
501} 573}
502 574
503############################################################################# 575#############################################################################
576# keyboard handling
504 577
505if (@ARGV) { 578# 0x080 shift, 0x100 ctrl
506 require IO::Pty; 579my %KEYMAP = (
507 $PTY = IO::Pty->new; 580 "\t" => 0x3a,
581 "\r" => 0x64,
582 "\n" => 0x44,
583
584 "\x00" => 0x77 | 0x100, # CTRL-SPACE
585 "\x1c" => 0x45 | 0x100, # CTRL-\
586 "\x1d" => 0x14 | 0x100, # CTRL-]
587 "\x1e" => 0x24 | 0x100, # CTRL-~
588 "\x1f" => 0x75 | 0x100, # CTRL-?
589
590 # hardcoded rxvt keys
591 "\e" => 0x2a, # ESC
592 "\e[3~" => 0x03, # DC
593 "\e[5~" => 0x7e, # CAPS LOCK (prior)
594 "\e[6~" => 0x6a, # NO SCROLL (next)
595 "\e[A" => 0x30, # UP
596 "\e[B" => 0x22, # DOWN
597 "\e[C" => 0x10, # RIGHT
598 "\e[D" => 0x20, # LEFT
599 "\e[a" => 0x30 | 0x080, # UP
600 "\e[b" => 0x22 | 0x080, # DOWN
601 "\e[c" => 0x10 | 0x080, # RIGHT
602 "\e[d" => 0x20 | 0x080, # LEFT
603 "\e[7~" => 0x7b, # SETUP (home)
604 "\e[8~" => 0x23, # BREAK (end)
605 "\e[8\$" => 0x23 | 0x080, # SHIFT BREAK / DISCONNECT (shift-end)
606 "\x7f" => 0x33, # BACKSPACE
607
608 "\e[11~" => 0x32, # F1
609 "\e[11~" => 0x42, # F2
610 "\e[11~" => 0x31, # F3
611 "\e[11~" => 0x41, # F4
612);
508 613
509 my $slave = $PTY->slave; 614@KEYMAP{map chr, 0x20 .. 0x40, 0x5b .. 0x7e} = unpack "C*", pack "H*",
615 "779ad5a9a8b8a755a6b5b6b466256575" . "351a3929283837273626d656e634e5f5" . "b9" # 20..40
616 . "154514b7a5" . "244a6879591949485816574746766706" . "050a185a0817780969077a95c594a4"; # 5b..7e
510 617
511 $PTY->set_winsize (24, 80); 618$KEYMAP{"\x1f" & $_} ||= $KEYMAP{$_} | 0x100 for "a" .. "z"; # ctrl
619$KEYMAP{"\x20" ^ $_} ||= $KEYMAP{$_} | 0x080 for "a" .. "z"; # shift
512 620
513 unless (fork) { 621my $KEYMATCH = join "|", map quotemeta, reverse sort keys %KEYMAP;
514 $ENV{TERM} = $VT102 ? "vt102" : "vt100"; 622$KEYMATCH = qr{^($KEYMATCH)}s;
515 623
516 close $PTY; 624my %KMOD;
517 625
518 open STDIN , "<&", $slave; 626sub key {
519 open STDOUT, ">&", $slave; 627 my ($key) = @_;
520 open STDERR, ">&", $slave;
521 628
522 system "stty ixoff erase ^H"; 629 push @KQUEUE, -0x7c if !($key & 0x100) && delete $KMOD{0x7c}; # ctrl-up
630 push @KQUEUE, -0x7d if !($key & 0x080) && delete $KMOD{0x7d}; # shift-up
523 631
524 $PTY->make_slave_controlling_terminal; 632 push @KQUEUE, 0x7c if $key & 0x100 && !$KMOD{0x7c}++; # ctrl-down
525 $PTY->close_slave; 633 push @KQUEUE, 0x7d if $key & 0x080 && !$KMOD{0x7d}++; # shift-down
526 634
527 exec @ARGV; 635 $key &= 0x7f;
528 } 636 push @KQUEUE, $key, -$key;
529
530 $PTY->close_slave;
531
532} else {
533 open $PTY, "</dev/null" or die;#d
534} 637}
535 638
536############################################################################# 639my $STDIN_BUF;
537 640
641sub stdin_parse {
642 key $KEYMAP{$1}
643 while $STDIN_BUF =~ s/$KEYMATCH//;
644
645 # skip input we can't decipher
646 substr $STDIN_BUF, 0, 1, "";
647}
648
649if ($KBD) {
650 system "stty -icanon -icrnl -inlcr -echo min 1 time 0";
651 eval q{ sub END { system "stty sane" } };
652 $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { exit 1 };
653}
654
655#############################################################################
538# initial key input, to set up online mode etc. 656# initial key input, to set up online mode etc.
657# could be done via nvram defaults
658
539@KQUEUE = ( 659@KQUEUE = (
540 0x7b, -0x7b, # setup 660 0x7b, -0x7b, # setup
541 0, # delay 661 0, # delay
542 0x28, -0x28, # 4, toggle local/online 662 0x28, -0x28, # 4, toggle local/online
543 0x38, -0x38, # 5, setup b 663 0x38, -0x38, # 5, setup b
554 0x37, -0x37, # 6 toggle wrap around 674 0x37, -0x37, # 6 toggle wrap around
555 0x7b, -0x7b, # leave setup 675 0x7b, -0x7b, # leave setup
556); 676);
557 677
558############################################################################# 678#############################################################################
679# process/pty management
559 680
560# 0x80 shift, 0x100 ctrl, 0x200 toggle 681require IO::Pty;
561my %KEYMAP = ( 682$PTY = IO::Pty->new;
562 "\t" => 0x3a,
563 "\r" => 0x64,
564 "\n" => 0x44,
565 683
566 # hardcoded rxvt keys 684my $slave = $PTY->slave;
567 "\e" => 0x2a, # ESC
568 "\e[3~" => 0x03, # DC
569 "\e[5~" => 0x7e, # CAPS LOCK (prior)
570 "\e[6~" => 0x6a, # NO SCROLL (next)
571 "\e[A" => 0x30, # UP
572 "\e[B" => 0x22, # DOWN
573 "\e[C" => 0x10, # RIGHT
574 "\e[D" => 0x20, # LEFT
575 "\e[a" => 0x30 | 0x080, # UP
576 "\e[b" => 0x22 | 0x080, # DOWN
577 "\e[c" => 0x10 | 0x080, # RIGHT
578 "\e[d" => 0x20 | 0x080, # LEFT
579 "\e[7~" => 0x7b, # SETUP (home)
580 "\e[8~" => 0x23, # BREAK (end)
581 "\e[8\$" => 0x23 | 0x080, # SHIFT BREAK / DISCONNECT (shift-end)
582 "\x7f" => 0x33, # BACKSPACE
583 685
584 "\e[11~" => 0x32, # F1 686$PTY->set_winsize (24, 80);
585 "\e[11~" => 0x42, # F2
586 "\e[11~" => 0x31, # F3
587 "\e[11~" => 0x41, # F4
588);
589 687
590@KEYMAP{map chr, 0x20..0x40} = unpack "C*", pack "H*", 688unless (fork) {
591 "779ad5a9a8b8a755a6b5b6b466256575" . "351a3929283837273626d656e634e5f5" . "b9"; 689 $ENV{TERM} = $VT102 ? "vt102" : "vt100";
592 690
593@KEYMAP{map chr, 0x5b .. 0x7e} = unpack "C*", pack "H*", 691 close $PTY;
594 "154514b7a5" . "244a6879591949485816574746766706" . "050a185a0817780969077a95c594a4";
595 692
596$KEYMAP{"\x3f" & $_} ||= $KEYMAP{$_} | 0x100 for "a" .. "z"; # ctrl 693 open STDIN , "<&", $slave;
597$KEYMAP{uc $_} ||= $KEYMAP{$_} | 0x080 for "a" .. "z"; # shift 694 open STDOUT, ">&", $slave;
695 open STDERR, ">&", $slave;
598 696
599my $KEYMATCH = join "|", map quotemeta, reverse sort keys %KEYMAP; 697 system "stty ixoff erase ^H";
600$KEYMATCH = qr{^($KEYMATCH)}s;
601 698
602sub key { 699 $PTY->make_slave_controlling_terminal;
603 my ($key) = @_; 700 $PTY->close_slave;
604 701
605 state %MOD; 702 @ARGV = "sh" unless @ARGV;
606 703 exec @ARGV;
607 push @KQUEUE, -0x7c if !($key & 0x100) && delete $MOD{0x7c}; # ctrl-up
608 push @KQUEUE, -0x7d if !($key & 0x080) && delete $MOD{0x7d}; # shift-up
609
610 push @KQUEUE, 0x7c if $key & 0x100 && !$MOD{0x7c}++; # ctrl-down
611 push @KQUEUE, 0x7d if $key & 0x080 && !$MOD{0x7d}++; # shift-down
612
613 $key &= 0x7f;
614 push @KQUEUE, $key, -$key;
615} 704}
616 705
617my $STDIN_BUF; 706$PTY->close_slave;
618 707
619sub stdin_parse {
620 key $KEYMAP{$1}
621 while $STDIN_BUF =~ s/$KEYMATCH//;
622
623 # skip input we can't decipher
624 substr $STDIN_BUF, 0, 1, "";
625}
626
627if ($KBD) {
628 system "stty -icanon -icrnl -inlcr -echo min 1 time 0";
629 eval q{ sub END { system "stty sane" } };
630 $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { exit 1 };
631}
632
633############################################################################# 708#############################################################################
709# the actual hardware simulator
634 710
635my @ICACHE; # compiled instruction cache 711my @ICACHE; # compiled instruction cache
636 712
637# the cpu
638while () { 713while () {
639
640 # execute extended basic blocks 714 # execute extended basic blocks
641 $PC = ($ICACHE[$PC] ||= do { 715 $PC = ($ICACHE[$PC] ||= do {
642 my $pc = $PC; 716 my $pc = $PC;
643 717
644 my $insn = ""; 718 my $insn = "";
645 719
646 # the jit compiler 720 # the jit compiler
647 for (0..15) { 721 for (0..31) {
648
649 # optional tracing support
650 if (0) {
651 $insn .= qq<
652 if (\$PRSTATUS) {
653 status $pc;
654 die unless --\$PRSTATUS;
655 }
656 >;
657 }
658
659 my $imm; 722 my $imm;
660 my $op = $op[$M[$pc++]]; 723 my $op = $op[$M[$pc++]];
661 724
662 for ($op) { 725 for ($op) {
663 s/\bPUSH\b/\$M[--\$SP] =/g; # push byte to stack 726 s/\bPUSH\b/\$M[--\$SP] =/g; # push byte to stack
676 739
677 $insn .= "$op;\n"; 740 $insn .= "$op;\n";
678 } 741 }
679 742
680 743
681 $insn .= "$pc"; 744 $insn .= $pc;
682 $insn =~ s/\x00.*$//s; 745 $insn =~ s/\x00.*$//s;
683 746
684 eval "use integer; sub { $insn }" or die "$insn: $@" 747 eval "use integer; sub { $insn }" or die "$insn: $@"
685 })->(); 748 })->();
686 749
688 751
689 # things we do from time too time only 752 # things we do from time too time only
690 unless ($CLK & 0xf) { 753 unless ($CLK & 0xf) {
691 # do I/O 754 # do I/O
692 755
693 unless ($CLK & 0x7ff) { 756 unless ($CLK & 0xfff) {
694 757
695 # pty/serial I/O 758 # pty/serial I/O
696 unless (@PUSARTRECV || @KQUEUE || !$PTY) { 759 unless ((@PUSARTRECV >= 128) || @KQUEUE || !$PTY) {
697 my $rin = ""; (vec $rin, fileno $PTY, 1) = 1; 760 my $rin = ""; (vec $rin, fileno $PTY, 1) = 1;
698 761
699 if (select $rin, undef, undef, 0) { 762 if (select $rin, undef, undef, 0) {
700 sysread $PTY, my $buf, 256; 763 sysread $PTY, my $buf, 256;
701 push @PUSARTRECV, unpack "C*", $buf; 764 push @PUSARTRECV, unpack "C*", $buf;
722 unless ($CLK & 0x1ff) { 785 unless ($CLK & 0x1ff) {
723 $RST |= 4; # vertical retrace 786 $RST |= 4; # vertical retrace
724 } 787 }
725 788
726 # handle video hardware 789 # handle video hardware
727
728 unless ($CLK & 0x1fff) { 790 unless ($CLK & 0x3fff) {
729 prscr; 791 display;
730 } 792 }
731 } 793 }
732 794
733 # the interrupt logic 795 # the interrupt logic
734 $x = $INTPEND & ~$INTMASK; 796 if (($RST || ($INTPEND & ~$INTMASK)) && $IFF) {
735 if (($RST || $x) && $IFF) {
736 # rst 1 kbd data available 797 # rst 1 kbd data available
737 # rst 2 pusart xmit+recv flag 798 # rst 2 pusart xmit+recv flag
738 # rst 4 vertical retrace 799 # rst 4 vertical retrace
739 # 5.5 vt125 mb7 trans ready (serial send?) 800 # 5.5 vt125 mb7 trans ready (serial send?)
740 # 6.5 vt125 mb7 read ready (something modem?) 801 # 6.5 vt125 mb7 read ready (something modem?)
741 # 7.5 vt125 mb7 vblank h(?) 802 # 7.5 vt125 mb7 vblank h(?)
742 # trap vt125 mbi init h(?) 803 # trap vt125 mbi init h(?)
743 my $vec; 804 my $vec;
744 805
806 $x = $INTPEND & ~$INTMASK;
807
745 if ($x & 1) { $vec = 0x2c; $INTPEND &= ~1; 808 if ($x & 1) { $vec = 0x2c; $INTPEND &= ~1;
746 } elsif ($x & 2) { $vec = 0x34; $INTPEND &= ~2; 809 } elsif ($x & 2) { $vec = 0x34; $INTPEND &= ~2;
747 } elsif ($x & 4) { $vec = 0x3c; $INTPEND &= ~4; 810 } elsif ($x & 4) { $vec = 0x3c; $INTPEND &= ~4;
748# } elsif ($RST ) { $vec = $RST * 8; $RST = 0; # for some reason, this breaks vt102 811# } elsif ($RST ) { $vec = $RST * 8; $RST = 0; # the vt102 firmware doesn't like combined interrupts
749 } elsif ($RST & 1) { $vec = 0x08; $RST &= ~1; # separate is better for vt102 812 } elsif ($RST & 1) { $vec = 0x08; $RST &= ~1; # separate is better for vt102
750 } elsif ($RST & 2) { $vec = 0x10; $RST &= ~2; 813 } elsif ($RST & 2) { $vec = 0x10; $RST &= ~2;
751 } elsif ($RST & 4) { $vec = 0x20; $RST &= ~4; 814 } elsif ($RST & 4) { $vec = 0x20; $RST &= ~4;
752 } else { 815 } else {
753 die; 816 die;
758 $PC = $vec; 821 $PC = $vec;
759 822
760 $IFF = 0; 823 $IFF = 0;
761 } 824 }
762} 825}
826
827#############################################################################
828# roms in the data section + one newline
829#
830# vt100 @ 0x0000+0x0800 23-032E2
831# vt100 @ 0x0800+0x0800 23-061E2
832# vt100 @ 0x1000+0x0800 23-033E2
833# vt100 @ 0x1800+0x0800 23-034E2
834#
835# vt102 @ 0x0000+0x2000 23-226E4
836# vt102 @ 0x8000+0x2000 23-225E4
837#
838# vt131 @ 0xa000+0x0800 23-280E2
839#
763 840
764__DATA__ 841__DATA__
7651N ;0>b/BWog<Gӂ,O$ O[xI,ڥ#€€yOtͤ[zW>/2!b>>g$>% !h w-!h >-4!j pO:{ y:! u:x!_yA[>y >yA[>?y@ :x!žyA[P>>O[>>[Î:!ʵyA>>OlyAPÇ!:!S!h ~ ~ : O͓: Ô!20!2!!!yAG~"&=w< w:!/!!A:!Ey2!~1N ! ~eBi<2!͢:P =2S!~6ʘ!!6 8421N ;0>b/BWog<Gӂ,O$ O[xI,ڥ#€€yOtͤ[zW>/2!b>>g$>% !h w-!h >-4!j pO:{ y:! u:x!_yA[>y >yA[>?y@ :x!žyA[P>>O[>>[Î:!ʵyA>>OlyAPÇ!:!S!h ~ ~ : O͓: Ô!20!2!!!yAG~"&=w< w:!/!!A:!Ey2!~1N ! ~eBi<2!͢:P =2S!~6ʘ!!6
7662!0* w4ʘ> 2! ~î!N ̓/2!! "R !""  8432!0* w4ʘ> 2! ~î!N ̓/2!! "R !"" 
767! ͋!2[ 2v!!"I!>2s >2 B>2y >2!2!&l" >@:X!:!͔>2!b:!K>G:| !p ^!p" :!x:! u> 844! ͋!2[ 2v!!"I!>2s >2 B>2y >2!2!&l" >@:X!:!͔>2!b:!K>G:| !p ^!p" :!x:! u>
871 948
872.y' &%&5>LGxWdkͨwͨ/w!e!6#}vnͨwͨ ڐWzʁÚ#}v>‡ :,!ڢy2!:!OW!e!oһ$zW>0)1!2@3#4$5%6^7&8*9(-_=+`~[{]};:/?'",<.>\| poytwq][iure1`-9743=08652 Ѱ 949.y' &%&5>LGxWdkͨwͨ/w!e!6#}vnͨwͨ ڐWzʁÚ#}v>‡ :,!ڢy2!:!OW!e!oһ$zW>0)1!2@3#4$5%6^7&8*9(-_=+`~[{]};:/?'",<.>\| poytwq][iure1`-9743=08652 Ѱ
873\lkgfa';jhds .,nbx* :B!4 950\lkgfa';jhds .,nbx* :B!4
874!O!,ͳʄmÝ 951!O!,ͳʄmÝ
875! 0>2ͳʥ†">02I y>c}" 2. y2N!~2/ z#ͫ:/ w:N!O:/ O#:. <õ!N!蝾:&0> 2 !{!>!q{" ÎWaitp!O!'6#'M_! 0R_:B!7N  952! 0>2ͳʥ†">02I y>c}" 2. y2N!~2/ z#ͫ:/ w:N!O:/ O#:. <õ!N!蝾:&0> 2 !{!>!q{" ÎWaitp!O!'6#'M_! 0R_:B!7N 
8768>2\0͍2\0:y!ʟ25!24!̞D!;!~G6̞:70xˆ!F!~ɞ˞w:5!ڞ:4!ឯ͆;:<!Bʾ:B!.ڇ!!~#;:!;D!!"!F#ux‡2A0:{!4R*|!x7fÇ:%0H:l :5!S*6!:4!k!wf##]~#fo:K 2\0 )şZşG>2\0:70ʫx!z!«!F!~ w!B0~w:40x·!l 62\0+2\012 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 9538>2\0͍2\0:y!ʟ25!24!̞D!;!~G6̞:70xˆ!F!~ɞ˞w:5!ڞ:4!ឯ͆;:<!Bʾ:B!.ڇ!!~#;:!;D!!"!F#ux‡2A0:{!4R*|!x7fÇ:%0H:l :5!S*6!:4!k!wf##]~#fo:K 2\0 )şZşG>2\0:70ʫx!z!«!F!~ w!B0~w:40x·!l 62\0+2\012 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv^y5k6!
954"~ACŠ>Bw2"!z"pv"x">Cw2"!n"pv"l"!!~< N[>2,!NAp##!(0S{}ˠ>w# »xE##ö6T]#zpw#sX6#N|p}Hpv"x"7:
955"C*C!(0:!@W ==}wï2C!2D!z5*b Q!{!| gH:d G| gW]>6#k<|eoozW>Ê

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines