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

Comparing vt102/vt102 (file contents):
Revision 1.2 by root, Mon Dec 1 15:37:50 2014 UTC vs.
Revision 1.9 by root, Mon Dec 1 20:12:07 2014 UTC

21# ./vt102 bash 21# ./vt102 bash
22# ./vt102 telnet towel.blinkenlights.nl 22# ./vt102 telnet towel.blinkenlights.nl
23# ./vt102 curl http://artscene.textfiles.com/vt100/trekvid.vt 23# ./vt102 curl http://artscene.textfiles.com/vt100/trekvid.vt
24# ./vt102 curl http://artscene.textfiles.com/vt100/surf.vt # in 3d! 24# ./vt102 curl http://artscene.textfiles.com/vt100/surf.vt # in 3d!
25 25
26use strict;
27use feature qw(state);
26use common::sense; 28#use common::sense;
27 29
28$| = 1; 30$| = 1;
29 31
30my $VT102 = 0; 32my $VT102 = 1;
31my $AVO = $VT102 || 1; 33my $AVO = $VT102 || 1;
32my $KBD = 1; 34my $KBD = 1;
33 35
34############################################################################# 36#############################################################################
35 37# rom initialising
36my $PTY; # the pty we allocated, if any
37 38
38my $ROM = do { 39my $ROM = do {
39 binmode DATA; 40 binmode DATA;
40 local $/; 41 local $/;
41 <DATA> 42 <DATA>
54} else { 55} else {
55 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROM, 0x0000, 0x2000; 56 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROM, 0x0000, 0x2000;
56} 57}
57 58
58############################################################################# 59#############################################################################
60# cpu registers and I/O support
59 61
62my $PTY; # the pty we allocated, if any
60my $PRSTATUS = 0; 63my $PRSTATUS = 0;
61 64
62# 8080/8085 registers 65# 8080/8085 registers
63# b, c, d, e, h, l, a 66# b, c, d, e, h, l, a
64my ($A, $B, $C, $D, $E, $H, $L, $A); 67my ($A, $B, $C, $D, $E, $H, $L, $A);
71my $x; # dummy temp for instructions 74my $x; # dummy temp for instructions
72 75
73my $CLK; # rather inexact clock 76my $CLK; # rather inexact clock
74 77
75############################################################################# 78#############################################################################
79# the dreaded nvr1400 chip. not needed to get it going, but provided for reference
76 80
77# nvram 81# nvram
78my @NVR = (0x3fff) x 100; # vt102: 214e accum, 214f only lower 8 bit used, first 44 bytes 82my @NVR = (0x3fff) x 100; # vt102: 214e accum, 214f only lower 8 bit used, first 44 bytes
79my $NVRADDR; 83my $NVRADDR;
80my $NVRDATA; 84my $NVRDATA;
81my $NVRLATCH; 85my $NVRLATCH;
82 86
83#$NVR[$_] = $_ for 0..99;#d#
84
85my @NVRCMD = ( 87my @NVRCMD = (
86 sub { # accept data
87 $NVRDATA = ($NVRDATA << 1) + $_[1]; 88 sub { $NVRDATA = ($NVRDATA << 1) + $_[1]; }, # 0 accept data
88 }, 89 sub { $NVRADDR = ($NVRADDR << 1) + $_[1]; }, # 1 accept addr
89 sub { # accept addr 90 sub { ($NVRDATA <<= 1) & 0x4000 }, # 2 shift out
90 $NVRADDR = ($NVRADDR << 1)+ $_[1]; 91 undef, # 3 not used, will barf
91 },
92 sub { # shift out
93 my $bit = $NVRDATA & 0x02000;
94 $NVRDATA *= 2;
95 $bit
96 },
97 undef,
98 sub { # write
99 print "NVR WRITE $_[0]\n";#d#
100 $NVR[$_[0]] = $NVRDATA & 0x3fff; 92 sub { $NVR[$_[0]] = $NVRDATA & 0x3fff; }, # 4 write
101 }, 93 sub { $NVR[$_[0]] = 0x3fff; }, # 5 erase
102 sub { # erase 94 sub { $NVRDATA = $NVR[$_[0]]; }, # 6 read
103 print "NVR ERASE $_[0]\n";#d# 95 sub { }, # 7 standby
104 $NVR[$_[0]] = 0x3fff;
105 },
106 sub { # read
107# print "NVR READ $_[0] = $NVR[$_[0]]\n";#d#
108 $NVRDATA = $NVR[$_[0]];
109 },
110 sub { # standby
111 },
112); 96);
113 97
114my @bitidx; 98my @bitidx;
115$bitidx[1 << $_] = 9 - $_ for 0..9; 99$bitidx[1 << $_] = 9 - $_ for 0..9;
116 100
124 $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1) 108 $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1)
125} 109}
126 110
127############################################################################# 111#############################################################################
128 112
129my $DC11 = 0; # 4 bit commands 113my $DC11_REVERSE = 0;
130my $DC12 = 0;
131 114
132my $XON = 1; # false if terminal wants us to pause 115my $XON = 1; # false if terminal wants us to pause
133my $PUSARTCMD; 116my $PUSARTCMD;
134 117
135my @KXMIT; # current scan queue 118my @KXMIT; # current scan queue
141 124
142sub out_00 { # pusartdata 125sub out_00 { # pusartdata
143 # handle xon/xoff, but also pass it through 126 # handle xon/xoff, but also pass it through
144 if ($_[0] == 0x13) { 127 if ($_[0] == 0x13) {
145 $XON = 0; 128 $XON = 0;
129 return;#d#
146 } elsif ($_[0] == 0x11) { 130 } elsif ($_[0] == 0x11) {
147 $XON = 1; 131 $XON = 1;
132 return;#d#
148 } 133 }
149 134
150 syswrite $PTY, chr $_[0]; 135 syswrite $PTY, chr $_[0];
151 136
152 $INTPEND |= 1; # 5.5 txrdy 137 $INTPEND |= 1;
153} 138}
154 139
155sub out_01 { 140sub out_01 {
156 $PUSARTCMD = shift; 141 $PUSARTCMD = shift;
157 142
158 $INTPEND |= 1 if $PUSARTCMD & 0x01; # VT102, 5.5 txrdy 143 $INTPEND |= 1 if $PUSARTCMD & 0x01; # VT102, 5.5 txrdy
159 $INTPEND |= 2 if $PUSARTCMD & 0x04; # VT102, 6.5 rxrdy 144 $INTPEND |= 2 if $PUSARTCMD & 0x04 && !@PUSARTRECV; # VT102, 6.5 rxrdy, needed for some reason
160} 145}
161 146
162sub out_02 { } # baudrate generator 147sub out_02 { } # baudrate generator
163 148
164sub out_23 { } # unknown 149sub out_23 { } # unknown
169 154
170sub out_62 { 155sub out_62 {
171 $NVRLATCH = shift; 156 $NVRLATCH = shift;
172} 157}
173 158
174sub out_a2 { $DC11 = shift } 159sub out_a2 {
160 my $dc11 = 0x0f & shift;
161
162 $DC11_REVERSE = 1 if $dc11 == 0b1010;
163 $DC11_REVERSE = 0 if $dc11 == 0b1011;
164}
165
175sub out_c2 { } # unknown 166sub out_c2 { } # unknown
176sub out_d2 { $DC12 = shift } 167sub out_d2 { } # 0..3 == 80c/132c/60hz/50hz
177 168
178sub out_82 { 169sub out_82 {
179 # keyboard 170 # keyboard
180 171
181 # CLICK STARTSCAN ONLINE LOCKED | CTS DSR INSERT L1(?) 172 # CLICK STARTSCAN ONLINE LOCKED | CTS DSR INSERT L1(?)
215 206
216my $NVRBIT; 207my $NVRBIT;
217my $LBA; 208my $LBA;
218 209
219sub in_00 { # pusart data 210sub in_00 { # pusart data
220# print "READ PUSARTDATA (@PUSARTRECV)\n"; 211 # interrupt not generated here, because infinite
221 212 # speed does not go well with the vt102.
222# $RST |= 2 if $#PUSARTRECV && $XON;
223# $INTPEND |= 2 if $#PUSARTRECV && $XON;
224 213
225 shift @PUSARTRECV 214 shift @PUSARTRECV
226} 215}
227 216
228sub in_01 { # pusart status 217sub in_01 { # pusart status
237 226
238sub in_0f { } # unknown, connected to out 2f 227sub in_0f { } # unknown, connected to out 2f
239 228
240sub in_42 { # flag buffer 229sub in_42 { # flag buffer
241 ++$LBA; 230 ++$LBA;
242# ++$LBA;
243# printf "%04x lba %04x, %04x\n", $PC, $LBA, $CLK;
244 231
245 $NVRBIT = nvr ? 0x20 : 0x00 if ($LBA & 0x3) == 0x2; 232 $NVRBIT = nvr ? 0x20 : 0x00 if ($LBA & 0x3) == 0x2;
246 233
247 # KBD_XMITEMPTY LBA7 NVRDATA ODDFIELD - OPTION !GFX !AVO PUSART_TXRDY 234 # KBD_XMITEMPTY LBA7 NVRDATA ODDFIELD - OPTION !GFX !AVO PUSART_TXRDY
248 235
266sub in_17 { 0xff } # unknown, printer status clear by reading? 253sub in_17 { 0xff } # unknown, printer status clear by reading?
267sub in_1b { 0xff } # unknown 254sub in_1b { 0xff } # unknown
268 255
269############################################################################# 256#############################################################################
270 257
271sub sf { 258sub sf { # set flags (ZSC - AP not implemented)
272 $FS = $_[0] & 0x080; 259 $FS = $_[0] & 0x080;
273 $FZ = ($_[0] & 0x0ff) == 0; 260 $FZ = ($_[0] & 0x0ff) == 0;
274 $FC = $_[0] & 0x100; 261 $FC = $_[0] & 0x100;
275 262
276 $_[0] & 0xff 263 $_[0] & 0xff
277} 264}
278 265
279sub sf_nc { 266sub sf_nc { # set flags except carry
280 $FS = $_[0] & 0x080; 267 $FS = $_[0] & 0x080;
281 $FZ = ($_[0] & 0x0ff) == 0; 268 $FZ = ($_[0] & 0x0ff) == 0;
282 269
283 $_[0] & 0xff 270 $_[0] & 0xff
284} 271}
453} 440}
454 441
455############################################################################# 442#############################################################################
456 443
457my @chr = ( 444my @chr = (
458 " ", 445 " " , "\x{29eb}", "\x{2592}", "\x{2409}",
459 "\x{29eb}", 446 "\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}",
460 "\x{2592}", 447 "\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}",
461 "\x{2409}", 448 "\x{2510}", "\x{250c}", "\x{2514}", "\x{253c}",
462 "\x{240c}", 449 "\x{23ba}", "\x{23bb}", "\x{2500}", "\x{23bc}",
463 "\x{240d}", 450 "\x{23bd}", "\x{251c}", "\x{2524}", "\x{2534}",
464 "\x{240a}", 451 "\x{252c}", "\x{2502}", "\x{2264}", "\x{2265}",
465 "\x{00b0}", 452 "\x{03c0}", "\x{2260}", "\x{00a3}", "\x{00b7}",
466 "\x{00b1}",
467 "\x{2424}",
468 "\x{240b}",
469 "\x{2518}",
470 "\x{2510}",
471 "\x{250c}",
472 "\x{2514}",
473 "\x{253c}",
474 "\x{23ba}",
475 "\x{23bb}",
476 "\x{2500}",
477 "\x{23bc}",
478 "\x{23bd}",
479 "\x{251c}",
480 "\x{2524}",
481 "\x{2534}",
482 "\x{252c}",
483 "\x{2502}",
484 "\x{2264}",
485 "\x{2265}",
486 "\x{03c0}",
487 "\x{2260}",
488 "\x{00a3}",
489 "\x{00b7}",
490 (map chr, 0x020 .. 0x7e), 453 (map chr, 0x020 .. 0x7e),
491 "?",
492); 454);
493 455
494utf8::encode $_ for @chr; 456utf8::encode $_ for @chr;
457
458my @sgr; # sgr sequences for attributes
459
460for (0x00 .. 0xff) {
461 my $sgr = "";
462
463 $sgr .= ";5" unless $_ & 0x01;
464 $sgr .= ";4" unless $_ & 0x02;
465 $sgr .= ";1" unless $_ & 0x04;
466 $sgr .= ";7" if $_ & 0x80;
467
468 $sgr[$_] = "\e[${sgr}m";
469}
495 470
496sub prscr { 471sub prscr {
497 my $i = 0x2000; 472 my $i = 0x2000;
498 473
499 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; 474 my $scr = sprintf "\e[H--- KBD %08b CLK %d\e[K\n", $KSTATUS, $CLK;
500 475
476 $scr .= "\e[?5" . ($DC11_REVERSE ? "h" : "l");
477
501 line: 478 line:
502 for my $y (0 .. 25) { 479 for my $y (0 .. 25) { # ntsc, two vblank delay lines, up to 24 text lines
480 my $prev_sgr;
481
503 $scr .= sprintf "%2d |", ++$y; 482 $scr .= sprintf "%2d \xe2\x94\x82", $y;
504 483
505 for (0..140) { 484 for (0..139) {
506 my $c = $M[$i++]; 485 my $c = $M[$i];
507
508# printf "%04x %02x\n", $i-1,$c;
509 486
510 if ($c == 0x7f) { # also 0xff, but the firmware avoids that 487 if ($c == 0x7f) { # also 0xff, but the firmware avoids that
511 $scr .= "|\x1b[K\n"; 488 $scr .= "\e[m\xe2\x94\x82\e[K\n";
512 489
513 my $a1 = $M[$i++]; 490 my $a1 = $M[$i + 1];
514 my $a0 = $M[$i++]; 491 my $a0 = $M[$i + 2];
515 492
516 $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff); 493 $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff);
517 494
518 next line; 495 next line;
519 } 496 }
520 497
521 $scr .= "\x1b[7m" if $c & 0x80; 498 my $sgr = $sgr[ ($M[$i++ + 0x1000] & 15) | ($c & 0x80)];
522 $scr .= $chr[$c & 0x7f] // sprintf "[%02x]", $c & 0x7f; 499
523 $scr .= "\x1b[m" if $c & 0x80; 500 # ~1 sgr 5 blink
501 # ~2 sgr 4 underline
502 # ~4 sgr 1 bold
503 # 0x80 in attr, sgr 7, reversed
504
505 $scr .= $prev_sgr = $sgr if $sgr ne $prev_sgr;
506
507 $scr .= $chr[$c & 0x7f];
524 } 508 }
525 509
526 $scr .= "\x1b[K\noverflow\x1b[K\n"; 510 $scr .= "\e[K\nvideo overflow\e[K\n";
527 last; 511 last;
528 } 512 }
529 513
514 $scr .= "\e[m";
515
530 if (0) { 516 if (0) {
531 $scr .= "\x1b[K\n"; 517 $scr .= "\e[K\n";
532 for my $o (0x200 .. 0x232) { 518 for my $o (0x200 .. 0x232) {
533 $scr .= sprintf "%04x:", $o * 16; 519 $scr .= sprintf "%04x:", $o * 16;
534 for (0..15) { 520 for (0..15) {
535 $scr .= sprintf " %02x", $M[$o * 16 + $_]; 521 $scr .= sprintf " %02x", $M[$o * 16 + $_];
536 } 522 }
537 $scr .= "\x1b[K\n"; 523 $scr .= "\e[K\n";
538 } 524 }
539 } 525 }
540 526
541 $scr .= "\x1b[J"; 527 $scr .= "\e[J";
542 528
543 syswrite STDOUT, $scr; 529 syswrite STDOUT, $scr;
544} 530}
545 531
546############################################################################# 532#############################################################################
549 require IO::Pty; 535 require IO::Pty;
550 $PTY = IO::Pty->new; 536 $PTY = IO::Pty->new;
551 537
552 my $slave = $PTY->slave; 538 my $slave = $PTY->slave;
553 539
540 $PTY->set_winsize (24, 80);
541
554 unless (fork) { 542 unless (fork) {
555 $ENV{TERM} = $VT102 ? "vt102" : "vt100"; 543 $ENV{TERM} = $VT102 ? "vt102" : "vt100";
556 544
557 close $PTY; 545 close $PTY;
558 546
559 open STDIN , "<&", $slave; 547 open STDIN , "<&", $slave;
560 open STDOUT, ">&", $slave; 548 open STDOUT, ">&", $slave;
561 open STDERR, ">&", $slave; 549 open STDERR, ">&", $slave;
562 550
551 system "stty ixoff erase ^H";
552
553 $PTY->make_slave_controlling_terminal;
563 close $slave; 554 $PTY->close_slave;
564 555
565 exec @ARGV; 556 exec @ARGV;
566 } 557 }
567 558
568 close $slave; 559 $PTY->close_slave;
560
569} else { 561} else {
570 open $PTY, "</dev/null" or die;#d 562 open $PTY, "</dev/null" or die;#d
571} 563}
572 564
573############################################################################# 565#############################################################################
592 0x7b, -0x7b, # leave setup 584 0x7b, -0x7b, # leave setup
593); 585);
594 586
595############################################################################# 587#############################################################################
596 588
597# 0x80 shift, 0x100 ctrl, 0x200 toggle 589# 0x080 shift, 0x100 ctrl
598my %KEYMAP = ( 590my %KEYMAP = (
591 # these get overwritten by generic control codes, but both work, so i have no priority
592 # tid fix these.
599 "\t" => 0x3a, 593 "\t" => 0x3a,
600 "\r" => 0x64, 594 "\r" => 0x64,
601 "\n" => 0x44, 595 "\n" => 0x44,
602 596
597 "\x00" => 0x77 | 0x100, # CTRL-SPACE
598 "\x1c" => 0x45 | 0x100, # CTRL-\
599 "\x1d" => 0x14 | 0x100, # CTRL-]
600 "\x1e" => 0x24 | 0x100, # CTRL-~
601 "\x1f" => 0x75 | 0x100, # CTRL-?
602
603 # hardcoded rxvt keys 603 # hardcoded rxvt keys
604 "\e" => 0x2a, # ESC 604 "\e" => 0x2a, # ESC
605 "\e[3~" => 0x03, # DC 605 "\e[3~" => 0x03, # DC
606 "\e[5~" => 0x7e, # CAPS LOCK (prior) 606 "\e[5~" => 0x7e, # CAPS LOCK (prior)
607 "\e[6~" => 0x6a, # NO SCROLL (next) 607 "\e[6~" => 0x6a, # NO SCROLL (next)
608 "\e[A" => 0x30, # UP 608 "\e[A" => 0x30, # UP
609 "\e[B" => 0x22, # DOWN 609 "\e[B" => 0x22, # DOWN
610 "\e[C" => 0x10, # RIGHT 610 "\e[C" => 0x10, # RIGHT
611 "\e[D" => 0x20, # LEFT 611 "\e[D" => 0x20, # LEFT
612 "\e[a" => 0x30 | 0x080, # UP 612 "\e[a" => 0x30 | 0x080, # UP
613 "\e[b" => 0x22 | 0x080, # DOWN 613 "\e[b" => 0x22 | 0x080, # DOWN
614 "\e[c" => 0x10 | 0x080, # RIGHT 614 "\e[c" => 0x10 | 0x080, # RIGHT
615 "\e[d" => 0x20 | 0x080, # LEFT 615 "\e[d" => 0x20 | 0x080, # LEFT
616 "\e[7~" => 0x7b, # SETUP (home) 616 "\e[7~" => 0x7b, # SETUP (home)
617 "\e[8~" => 0x23, # BREAK (end) 617 "\e[8~" => 0x23, # BREAK (end)
618 "\e[8\$" => 0x23 | 0x080, # SHIFT BREAK / DISCONNECT (shift-end) 618 "\e[8\$" => 0x23 | 0x080, # SHIFT BREAK / DISCONNECT (shift-end)
619 "\x7f" => 0x33, # BACKSPACE 619 "\x7f" => 0x33, # BACKSPACE
620 620
621 "\e[11~" => 0x32, # F1 621 "\e[11~" => 0x32, # F1
622 "\e[11~" => 0x42, # F2 622 "\e[11~" => 0x42, # F2
623 "\e[11~" => 0x31, # F3 623 "\e[11~" => 0x31, # F3
624 "\e[11~" => 0x41, # F4 624 "\e[11~" => 0x41, # F4
625); 625);
626 626
627@KEYMAP{map chr, 0x20..0x40} = unpack "C*", pack "H*", 627@KEYMAP{map chr, 0x20..0x40} = unpack "C*", pack "H*",
628 "779ad5a9a8b8a755a6b5b6b466256575" . "351a3929283837273626d656e634e5f5" . "b9"; 628 "779ad5a9a8b8a755a6b5b6b466256575" . "351a3929283837273626d656e634e5f5" . "b9";
629 629
630@KEYMAP{map chr, 0x5b .. 0x7e} = unpack "C*", pack "H*", 630@KEYMAP{map chr, 0x5b .. 0x7e} = unpack "C*", pack "H*",
631 "154514b7a5" . "244a6879591949485816574746766706" . "050a185a0817780969077a95c594a4"; 631 "154514b7a5" . "244a6879591949485816574746766706" . "050a185a0817780969077a95c594a4";
632 632
633$KEYMAP{"\x3f" & $_} ||= $KEYMAP{$_} | 0x100 for "a" .. "z"; # ctrl 633$KEYMAP{"\x1f" & $_} ||= $KEYMAP{$_} | 0x100 for "a" .. "z"; # ctrl
634$KEYMAP{uc $_} ||= $KEYMAP{$_} | 0x080 for "a" .. "z"; # shift 634$KEYMAP{uc $_} ||= $KEYMAP{$_} | 0x080 for "a" .. "z"; # shift
635 635
636my $KEYMATCH = join "|", map quotemeta, reverse sort keys %KEYMAP; 636my $KEYMATCH = join "|", map quotemeta, reverse sort keys %KEYMAP;
637$KEYMATCH = qr{^($KEYMATCH)}s; 637$KEYMATCH = qr{^($KEYMATCH)}s;
638 638
721 eval "use integer; sub { $insn }" or die "$insn: $@" 721 eval "use integer; sub { $insn }" or die "$insn: $@"
722 })->(); 722 })->();
723 723
724 ++$CLK; 724 ++$CLK;
725 725
726 #TODO: just check on ret instructions or so 726 # things we do from time too time only
727 unless ($CLK & 0xf) {
728 # do I/O
729
730 unless ($CLK & 0x7ff) {
731
732 # pty/serial I/O
733 unless (@PUSARTRECV || @KQUEUE || !$PTY) {
734 my $rin = ""; (vec $rin, fileno $PTY, 1) = 1;
735
736 if (select $rin, undef, undef, 0) {
737 sysread $PTY, my $buf, 256;
738 push @PUSARTRECV, unpack "C*", $buf;
739 }
740 }
741
742 # keyboard input
743 if ($KBD) {
744 while (select my $rin = "\x01", undef, undef, 0) {
745 sysread STDIN, $STDIN_BUF, 1, length $STDIN_BUF
746 or last;
747 }
748
749 stdin_parse if length $STDIN_BUF;
750 }
751 }
752
753 # kick off various interrupts
754
755 $RST |= 2 if @PUSARTRECV && $XON; # VT100, but works on vt102, too (probably not used on real hardware though)
756 #$INTPEND |= 2 if @PUSARTRECV && $XON; # VT102, 6.5 rxrdy
757
758 # kick off vertical retrace form time to time
759 unless ($CLK & 0x1ff) {
760 $RST |= 4; # vertical retrace
761 }
762
763 # handle video hardware
764
765 unless ($CLK & 0x1fff) {
766 prscr;
767 }
768 }
769
727 # the interrupt logic 770 # the interrupt logic
728 $x = $INTPEND & ~$INTMASK; 771 $x = $INTPEND & ~$INTMASK;
729
730 if (($RST || $x) && $IFF) { 772 if (($RST || $x) && $IFF) {
731 # rst 1 kbd data available 773 # rst 1 kbd data available
732 # rst 2 pusart xmit+recv flag 774 # rst 2 pusart xmit+recv flag
733 # rst 4 vertical retrace 775 # rst 4 vertical retrace
734 # 5.5 vt125 mb7 trans ready (serial send?) 776 # 5.5 vt125 mb7 trans ready (serial send?)
751 $M[--$SP] = $PC >> 8; 793 $M[--$SP] = $PC >> 8;
752 $M[--$SP] = $PC & 0xff; 794 $M[--$SP] = $PC & 0xff;
753 $PC = $vec; 795 $PC = $vec;
754 796
755 $IFF = 0; 797 $IFF = 0;
756 }
757
758 # things we do from time too time only
759 unless ($CLK & 0xf) {
760 # do I/O
761
762 unless ($CLK & 0x7ff) {
763
764 # pty/serial I/O
765 unless (@PUSARTRECV || @KQUEUE || !$PTY) {
766 my $rin = ""; (vec $rin, fileno $PTY, 1) = 1;
767
768 if (select $rin, undef, undef, 0) {
769 sysread $PTY, my $buf, 256;
770 push @PUSARTRECV, unpack "C*", $buf;
771 }
772 }
773
774 # keyboard input
775 if ($KBD) {
776 while (select my $rin = "\x01", undef, undef, 0) {
777 sysread STDIN, $STDIN_BUF, 1, length $STDIN_BUF
778 or last;
779 }
780
781 stdin_parse if length $STDIN_BUF;
782 }
783 }
784
785 # kick off various interrupts
786
787 $RST |= 2 if @PUSARTRECV && $XON;# vt100, also works on vt102, probably by accident
788 #$INTPEND |= 2 if @PUSARTRECV && $XON;# real vt102 probably does it this way
789
790 unless ($CLK & 0x3ff) {
791 $RST |= 4; # vertical retrace
792 }
793
794 # handle video hardware
795
796 unless ($CLK & 0x1fff) {
797 prscr;
798 }
799 } 798 }
800} 799}
801 800
802__DATA__ 801__DATA__
8031N ;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 8021N ;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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines