… | |
… | |
93 | <DATA> |
93 | <DATA> |
94 | }; |
94 | }; |
95 | |
95 | |
96 | 0x6801 == length $ROMS or die "corrupted rom image"; |
96 | 0x6801 == length $ROMS or die "corrupted rom image"; |
97 | |
97 | |
98 | my @M = (0xff) x 65536; # main memory, = (0xff) x 65536; |
98 | my @M = (0xff) x 65536; # main memory |
99 | |
99 | |
100 | # populate mem with rom contents |
100 | # populate mem with rom contents |
101 | if ($VT102) { |
101 | if ($VT102) { |
102 | @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x2000, 0x2000; |
102 | @M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x2000, 0x2000; |
103 | @M[0x8000 .. 0x9fff] = unpack "C*", substr $ROMS, 0x4000, 0x2000; |
103 | @M[0x8000 .. 0x9fff] = unpack "C*", substr $ROMS, 0x4000, 0x2000; |
… | |
… | |
538 | sub display { |
538 | sub display { |
539 | # 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, |
540 | # 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 |
541 | $CURSOR_IS_ON = $M[$VT102 ? 0x207b : 0x21ba]; |
541 | $CURSOR_IS_ON = $M[$VT102 ? 0x207b : 0x21ba]; |
542 | |
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 | |
543 | my $i = 0x2000; |
549 | my $i = 0x2000; |
544 | |
|
|
545 | my $leds = join " ", map $KSTATUS & 2**$_ ? "\e[7m$LED[$_]\e[m" : "$LED[$_]", reverse 0 .. $#LED; |
|
|
546 | |
|
|
547 | my $scr = sprintf "\e[H--- LED [ %s ] CLK %d\e[K\n", $leds, $CLK; |
|
|
548 | |
|
|
549 | $scr .= "\e[?5" . ($DC11_REVERSE ? "h" : "l"); |
|
|
550 | |
550 | |
551 | line: |
551 | line: |
552 | 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 |
553 | my $prev_sgr; |
553 | my $prev_attr; |
|
|
554 | my ($c, $attr); # declare here for speedup |
554 | |
555 | |
555 | $scr .= sprintf "%2d \xe2\x94\x82", $y; |
556 | $scr .= sprintf "%2d \xe2\x94\x82", $y; |
556 | |
557 | |
557 | for (0..139) { |
558 | for (0..139) { |
558 | my $c = $M[$i]; |
559 | $c = $M[$i]; |
559 | |
560 | |
560 | if ($c == 0x7f) { # also 0xff, but the firmware avoids that |
561 | if ($c == 0x7f) { # also 0xff, but the firmware avoids that |
561 | $scr .= "\e[m\xe2\x94\x82\e[K\n"; |
562 | $scr .= "\e[m\xe2\x94\x82\e[K\n"; |
562 | |
563 | |
563 | my $a1 = $M[$i + 1]; |
564 | my $a1 = $M[$i + 1]; |
… | |
… | |
566 | $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff); |
567 | $i = 0x2000 + (($a1 * 256 + $a0) & 0xfff); |
567 | |
568 | |
568 | next line; |
569 | next line; |
569 | } |
570 | } |
570 | |
571 | |
|
|
572 | $scr .= $SGR[$prev_attr = $attr] |
571 | my $sgr = $SGR[ ($M[$i++ + 0x1000] & 15) | ($c & 0x80)]; |
573 | if $prev_attr != ($attr = ($M[$i++ + 0x1000] & 15) | ($c & 0x80)); |
572 | |
|
|
573 | $scr .= $prev_sgr = $sgr if $sgr ne $prev_sgr; |
|
|
574 | |
574 | |
575 | $scr .= $CHARMAP[$c & 0x7f]; |
575 | $scr .= $CHARMAP[$c & 0x7f]; |
576 | } |
576 | } |
577 | |
577 | |
578 | $scr .= "\e[K\nvideo overflow\e[K\n"; |
578 | $scr .= "\e[K\nvideo overflow\e[K\n"; |
… | |
… | |
765 | } |
765 | } |
766 | |
766 | |
767 | $insn .= "$op;\n"; |
767 | $insn .= "$op;\n"; |
768 | } |
768 | } |
769 | |
769 | |
770 | |
|
|
771 | $insn .= $pc; |
770 | $insn .= $pc; |
772 | $insn =~ s/\x00.*$//s; |
771 | $insn =~ s/\x00.*$//s; |
773 | |
772 | |
774 | eval "sub { $insn }" or die "$insn: $@" |
773 | eval "sub { $insn }" or die "$insn: $@" |
775 | })->(); |
774 | })->(); |
… | |
… | |
785 | |
784 | |
786 | # pty/serial I/O |
785 | # pty/serial I/O |
787 | if ($PTY && (vec $x, fileno $PTY, 1) && (@PUSARTRECV < 128) && !@KQUEUE) { |
786 | if ($PTY && (vec $x, fileno $PTY, 1) && (@PUSARTRECV < 128) && !@KQUEUE) { |
788 | sysread $PTY, my $buf, 256; |
787 | sysread $PTY, my $buf, 256; |
789 | |
788 | |
790 | # 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. |
791 | push @PUSARTRECV, grep { ($_ & 0x7f) != 0x13 } unpack "C*", $buf; |
791 | push @PUSARTRECV, grep { ($_ & 0x7f) != 0x13 } unpack "C*", $buf; |
792 | } |
792 | } |
793 | |
793 | |
794 | # keyboard input |
794 | # keyboard input |
795 | if ($KBD && (vec $x, 0, 1)) { |
795 | if ($KBD && (vec $x, 0, 1)) { |