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

Comparing vt102/vt102 (file contents):
Revision 1.27 by root, Fri Dec 5 05:41:11 2014 UTC vs.
Revision 1.33 by root, Wed Nov 11 16:32:21 2015 UTC

66 SET UP Home 66 SET UP Home
67 BACKSPACE Rubout 67 BACKSPACE Rubout
68 CAPS LOCK Prior/PgUp 68 CAPS LOCK Prior/PgUp
69 NO SCROLL Next/PgDown 69 NO SCROLL Next/PgDown
70 BREAK End 70 BREAK End
71 CTRL-C Insert
71 72
72Set-Up Guide: 73Set-Up Guide:
73 74
74 http://vt100.net/docs/vt102-ug/chapter3.html#S3.6 75 http://vt100.net/docs/vt102-ug/chapter3.html#S3.6
75 76
92 <DATA> 93 <DATA>
93}; 94};
94 95
950x6801 == length $ROMS or die "corrupted rom image"; 960x6801 == length $ROMS or die "corrupted rom image";
96 97
97my @M = (0xff) x 65536; # main memory, = (0xff) x 65536; 98my @M = (0xff) x 65536; # main memory
98 99
99# populate mem with rom contents 100# populate mem with rom contents
100if ($VT102) { 101if ($VT102) {
101 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x2000, 0x2000; 102 @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x2000, 0x2000;
102 @M[0x8000 .. 0x9fff] = unpack "C*", substr $ROMS, 0x4000, 0x2000; 103 @M[0x8000 .. 0x9fff] = unpack "C*", substr $ROMS, 0x4000, 0x2000;
537sub display { 538sub display {
538 # this is for the powersave mode - check whether the cursor is on here, 539 # this is for the powersave mode - check whether the cursor is on here,
539 # and only allow powersave later when it was on the last display time 540 # and only allow powersave later when it was on the last display time
540 $CURSOR_IS_ON = $M[$VT102 ? 0x207b : 0x21ba]; 541 $CURSOR_IS_ON = $M[$VT102 ? 0x207b : 0x21ba];
541 542
543 my $leds = join " ", map $KSTATUS & 2**$_ ? "\e[7m$LED[$_]\e[m" : "$LED[$_]", reverse 0 .. $#LED;
544
545 my $scr = sprintf "\e[H--- LED [ %s ] CLK %d\e[K\n", $leds, $CLK;
546
547 $scr .= "\e[?5" . ($DC11_REVERSE ? "h" : "l");
548
542 my $i = 0x2000; 549 my $i = 0x2000;
543
544 my $leds = join " ", map $KSTATUS & 2**$_ ? "\e[7m$LED[$_]\e[m" : "$LED[$_]", reverse 0 .. $#LED;
545
546 my $scr = sprintf "\e[H--- LED [ %s ] CLK %d\e[K\n", $leds, $CLK;
547
548 $scr .= "\e[?5" . ($DC11_REVERSE ? "h" : "l");
549 550
550 line: 551 line:
551 for my $y (0 .. 25) { # ntsc, two vblank delay lines, up to 24 text lines 552 for my $y (0 .. 25) { # ntsc, two vblank delay lines, up to 24 text lines
552 my $prev_sgr; 553 my $prev_attr;
554 my ($c, $attr); # declare here for speedup
553 555
554 $scr .= sprintf "%2d \xe2\x94\x82", $y; 556 $scr .= sprintf "%2d \xe2\x94\x82", $y;
555 557
556 for (0..139) { 558 for (0..139) {
557 my $c = $M[$i]; 559 $c = $M[$i];
558 560
559 if ($c == 0x7f) { # also 0xff, but the firmware avoids that 561 if ($c == 0x7f) { # also 0xff, but the firmware avoids that
560 $scr .= "\e[m\xe2\x94\x82\e[K\n"; 562 $scr .= "\e[m\xe2\x94\x82\e[K\n";
561 563
562 my $a1 = $M[$i + 1]; 564 my $a1 = $M[$i + 1];
565 $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff); 567 $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff);
566 568
567 next line; 569 next line;
568 } 570 }
569 571
572 $scr .= $SGR[$prev_attr = $attr]
570 my $sgr = $SGR[ ($M[$i++ + 0x1000] & 15) | ($c & 0x80)]; 573 if $prev_attr != ($attr = ($M[$i++ + 0x1000] & 15) | ($c & 0x80));
571
572 $scr .= $prev_sgr = $sgr if $sgr ne $prev_sgr;
573 574
574 $scr .= $CHARMAP[$c & 0x7f]; 575 $scr .= $CHARMAP[$c & 0x7f];
575 } 576 }
576 577
577 $scr .= "\e[K\nvideo overflow\e[K\n"; 578 $scr .= "\e[K\nvideo overflow\e[K\n";
598 "\x1e" => 0x24 | 0x100, # CTRL-~ 599 "\x1e" => 0x24 | 0x100, # CTRL-~
599 "\x1f" => 0x75 | 0x100, # CTRL-? 600 "\x1f" => 0x75 | 0x100, # CTRL-?
600 601
601 # hardcoded rxvt keys 602 # hardcoded rxvt keys
602 "\e" => 0x2a, # ESC 603 "\e" => 0x2a, # ESC
604 "\e[2~" => 0x79 | 0x100, # CTRL-C (insert)
603 "\e[3~" => 0x03, # DC 605 "\e[3~" => 0x03, # DC
604 "\e[5~" => 0x7e, # CAPS LOCK (prior) 606 "\e[5~" => 0x7e, # CAPS LOCK (prior)
605 "\e[6~" => 0x6a, # NO SCROLL (next) 607 "\e[6~" => 0x6a, # NO SCROLL (next)
606 "\e[A" => 0x30, # UP 608 "\e[A" => 0x30, # UP
607 "\e[B" => 0x22, # DOWN 609 "\e[B" => 0x22, # DOWN
614 "\e[7~" => 0x7b, # SETUP (home) 616 "\e[7~" => 0x7b, # SETUP (home)
615 "\e[8~" => 0x23, # BREAK (end) 617 "\e[8~" => 0x23, # BREAK (end)
616 "\e[8\$" => 0x23 | 0x080, # SHIFT BREAK / DISCONNECT (shift-end) 618 "\e[8\$" => 0x23 | 0x080, # SHIFT BREAK / DISCONNECT (shift-end)
617 "\x7f" => 0x33, # BACKSPACE 619 "\x7f" => 0x33, # BACKSPACE
618 620
619 "\e[11~" => 0x32, # F1 621 "\e[11~" => 0x32, # PF1
620 "\e[11~" => 0x42, # F2 622 "\e[12~" => 0x42, # PF2
621 "\e[11~" => 0x31, # F3 623 "\e[13~" => 0x31, # PF3
622 "\e[11~" => 0x41, # F4 624 "\e[14~" => 0x41, # PF4
623); 625);
624 626
625@KEYMAP{map chr, 0x20 .. 0x40, 0x5b .. 0x7e} = unpack "C*", pack "H*", 627@KEYMAP{map chr, 0x20 .. 0x40, 0x5b .. 0x7e} = unpack "C*", pack "H*",
626 "779ad5a9a8b8a755a6b5b6b466256575" . "351a3929283837273626d656e634e5f5" . "b9" # 20..40 628 "779ad5a9a8b8a755a6b5b6b466256575" . "351a3929283837273626d656e634e5f5" . "b9" # 20..40
627 . "154514b7a5" . "244a6879591949485816574746766706" . "050a185a0817780969077a95c594a4"; # 5b..7e 629 . "154514b7a5" . "244a6879591949485816574746766706" . "050a185a0817780969077a95c594a4"; # 5b..7e
656 # skip input we can't decipher 658 # skip input we can't decipher
657 substr $STDIN_BUF, 0, 1, ""; 659 substr $STDIN_BUF, 0, 1, "";
658} 660}
659 661
660if ($KBD) { 662if ($KBD) {
661 system "stty -icanon -icrnl -inlcr -echo min 1 time 0"; 663 system "stty -icanon -icrnl -inlcr -echo min 1 time 0"; # -isig
662 eval q{ sub END { system "stty sane" } }; 664 eval q{ sub END { system "stty sane" } };
663 $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { exit 1 }; 665 $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { exit 1 };
664} 666}
665 667
666############################################################################# 668#############################################################################
763 } 765 }
764 766
765 $insn .= "$op;\n"; 767 $insn .= "$op;\n";
766 } 768 }
767 769
768
769 $insn .= $pc; 770 $insn .= $pc;
770 $insn =~ s/\x00.*$//s; 771 $insn =~ s/\x00.*$//s;
771 772
772 eval "sub { $insn }" or die "$insn: $@" 773 eval "sub { $insn }" or die "$insn: $@"
773 })->(); 774 })->();
777 # things we do from time to time only 778 # things we do from time to time only
778 unless ($CLK & 0xf) { 779 unless ($CLK & 0xf) {
779 # do I/O 780 # do I/O
780 781
781 unless ($CLK & 0xfff) { 782 unless ($CLK & 0xfff) {
782 if (select $x = $RIN, undef, undef, $POWERSAVE < 10 ? 0 : $CURSOR_IS_ON && 10) { 783 if (select $x = $RIN, undef, undef, $POWERSAVE < 10 ? 0 : $CURSOR_IS_ON && 3600) {
783 784
784 # pty/serial I/O 785 # pty/serial I/O
785 if ($PTY && (vec $x, fileno $PTY, 1) && (@PUSARTRECV < 128) && !@KQUEUE) { 786 if ($PTY && (vec $x, fileno $PTY, 1) && (@PUSARTRECV < 128) && !@KQUEUE) {
786 sysread $PTY, my $buf, 256; 787 sysread $PTY, my $buf, 256;
787 788
788 # linux don't do cs7 and/or parity anymore, so we need to filter # out xoff characters to avoid freezes. 789 # linux don't do cs7 and/or parity anymore, so we need to filter
790 # out xoff characters to avoid freezes.
789 push @PUSARTRECV, grep { ($_ & 0x7f) != 0x13 } unpack "C*", $buf; 791 push @PUSARTRECV, grep { ($_ & 0x7f) != 0x13 } unpack "C*", $buf;
790 } 792 }
791 793
792 # keyboard input 794 # keyboard input
793 if ($KBD && (vec $x, 0, 1)) { 795 if ($KBD && (vec $x, 0, 1)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines