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

Comparing vt102/vt102 (file contents):
Revision 1.10 by root, Wed Dec 3 02:07:44 2014 UTC vs.
Revision 1.17 by root, Wed Dec 3 02:16:30 2014 UTC

21#use common::sense; 21#use common::sense;
22 22
23my $VT102 = 1; 23my $VT102 = 1;
24my $VT131 = 0; 24my $VT131 = 0;
25my $AVO = 1; 25my $AVO = 1;
26my $KBD = 1;
27 26
28if ($ARGV[0] =~ /^-?-vt100$/) { 27shift, ($VT102 = 0), ($AVO = 0) if $ARGV[0] =~ /^-?-vt100$/;
29 shift; $VT102 = 0; $AVO = 0; 28shift, ($VT102 = 0) if $ARGV[0] =~ /^-?-vt100\+avo$/;
30} 29shift if $ARGV[0] =~ /^-?-vt102$/;
31 30shift, ($VT131 = 1) if $ARGV[0] =~ /^-?-vt131$/;
32if ($ARGV[0] =~ /^-?-vt100\+avo$/) {
33 shift; $VT102 = 0; $AVO = 1;
34}
35
36if ($ARGV[0] =~ /^-?-vt102$/) {
37 shift; # default
38}
39
40if ($ARGV[0] =~ /^-?-vt131$/) {
41 shift; $VT131 = 1;
42}
43 31
44if ($ARGV[0] =~ /^-/) { 32if ($ARGV[0] =~ /^-/) {
45 die <<EOF; 33 die <<EOF;
46 34
47VT102, A VT100/101/102/131 SIMULATOR 35VT102, A VT100/101/102/131 SIMULATOR
84} 72}
85 73
86############################################################################# 74#############################################################################
87# ROM/hardware init 75# ROM/hardware init
88 76
77my $PTY; # the pty we allocated, if any
78my $KBD = 1;
79
89my $ROMS = do { 80my $ROMS = do {
90 binmode DATA; 81 binmode DATA;
91 local $/; 82 local $/;
92 <DATA> 83 <DATA>
93}; 84};
94 85
950x6801 == length $ROMS or die "corrupted rom image"; 860x6801 == length $ROMS or die "corrupted rom image";
96
97binmode STDOUT;
98 87
99my @M = (0xff) x 65536; # main memory, = (0xff) x 65536; 88my @M = (0xff) x 65536; # main memory, = (0xff) x 65536;
100 89
101# populate mem with rom contents 90# populate mem with rom contents
102if ($VT102) { 91if ($VT102) {
108} 97}
109 98
110############################################################################# 99#############################################################################
111# 8085 CPU registers and I/O support 100# 8085 CPU registers and I/O support
112 101
113my $PTY; # the pty we allocated, if any
114
115# 8080/8085 registers 102# 8080/8085 registers
116# b, c, d, e, h, l, a
117my ($A, $B, $C, $D, $E, $H, $L, $A); 103my ($A, $B, $C, $D, $E, $H, $L);
118my ($PC, $SP, $IFF, $FA, $FZ, $FS, $FP, $FC); 104my ($PC, $SP, $IFF, $FA, $FZ, $FS, $FP, $FC);
119 105
120my $RST = 0; # 8080 pending interrupts 106my $RST = 0; # 8080 pending interrupts
121my $INTMASK = 7; # 8085 half interrupts 107my $INTMASK = 7; # 8085 half interrupts
122my $INTPEND = 0; # 8085 half interrupts 108my $INTPEND = 0; # 8085 half interrupts
123
124my $x; # dummy temp for instructions
125 109
126my $CLK; # rather inexact clock 110my $CLK; # rather inexact clock
127 111
128############################################################################# 112#############################################################################
129# the dreaded NVR1400 chip. not needed to get it going, but provided anyway 113# the dreaded NVR1400 chip. not needed to get it going, but provided anyway
143 sub { $NVR[$_[0]] = 0x3fff; }, # 5 erase 127 sub { $NVR[$_[0]] = 0x3fff; }, # 5 erase
144 sub { $NVRDATA = $NVR[$_[0]]; }, # 6 read 128 sub { $NVRDATA = $NVR[$_[0]]; }, # 6 read
145 sub { }, # 7 standby 129 sub { }, # 7 standby
146); 130);
147 131
148my @bitidx; 132my @NVR_BITIDX;
149$bitidx[1 << $_] = 9 - $_ for 0..9; 133$NVR_BITIDX[1 << $_] = 9 - $_ for 0..9;
150 134
151# the nvr1400 state machine. what a monster 135# the nvr1400 state machine. what a monster
152sub nvr() { 136sub nvr() {
153 my $a1 = $bitidx[(~$NVRADDR ) & 0x3ff]; 137 my $a1 = $NVR_BITIDX[(~$NVRADDR ) & 0x3ff];
154 my $a0 = $bitidx[(~$NVRADDR >> 10) & 0x3ff]; 138 my $a0 = $NVR_BITIDX[(~$NVRADDR >> 10) & 0x3ff];
155 139
156# printf "NVR %02x A %020b %d %d D %02x\n", $NVRLATCH, $NVRADDR & 0xfffff, $a1, $a0, $NVRDATA; 140# printf "NVR %02x A %020b %d %d D %02x\n", $NVRLATCH, $NVRADDR & 0xfffff, $a1, $a0, $NVRDATA;
157 141
158 $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1) 142 $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1)
159} 143}
306sub in_1b { 0xff } # vt102 unknown 290sub in_1b { 0xff } # vt102 unknown
307 291
308############################################################################# 292#############################################################################
309# 8085 cpu opcodes and flag handling 293# 8085 cpu opcodes and flag handling
310 294
295my $x; # dummy scratchpad for opcodes
296
311sub sf { # set flags (ZSC - AP not implemented) 297sub sf { # set flags (ZSC - AP not implemented)
312 $FS = $_[0] & 0x080; 298 $FS = $_[0] & 0x080;
313 $FZ = !($_[0] & 0x0ff); 299 $FZ = !($_[0] & 0x0ff);
314 $FC = $_[0] & 0x100; 300 $FC = $_[0] & 0x100;
315 301
498 $M[$PC], $op[$M[$PC]]; 484 $M[$PC], $op[$M[$PC]];
499} 485}
500 486
501############################################################################# 487#############################################################################
502# video emulation 488# video emulation
489
490binmode STDOUT;
503 491
504my @CHARMAP = ( 492my @CHARMAP = (
505 " " , "\x{29eb}", "\x{2592}", "\x{2409}", 493 " " , "\x{29eb}", "\x{2592}", "\x{2409}",
506 "\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}", 494 "\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}",
507 "\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}", 495 "\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}",
750 738
751 $insn .= "$op;\n"; 739 $insn .= "$op;\n";
752 } 740 }
753 741
754 742
755 $insn .= "$pc"; 743 $insn .= $pc;
756 $insn =~ s/\x00.*$//s; 744 $insn =~ s/\x00.*$//s;
757 745
758 eval "use integer; sub { $insn }" or die "$insn: $@" 746 eval "use integer; sub { $insn }" or die "$insn: $@"
759 })->(); 747 })->();
760 748
812 # 6.5 vt125 mb7 read ready (something modem?) 800 # 6.5 vt125 mb7 read ready (something modem?)
813 # 7.5 vt125 mb7 vblank h(?) 801 # 7.5 vt125 mb7 vblank h(?)
814 # trap vt125 mbi init h(?) 802 # trap vt125 mbi init h(?)
815 my $vec; 803 my $vec;
816 804
817 $x = $INTPEND & ~$INTMASK; 805 my $pend = $INTPEND & ~$INTMASK;
818 806
819 if ($x & 1) { $vec = 0x2c; $INTPEND &= ~1; 807 if ($pend & 1) { $vec = 0x2c; $INTPEND &= ~1;
820 } elsif ($x & 2) { $vec = 0x34; $INTPEND &= ~2; 808 } elsif ($pend & 2) { $vec = 0x34; $INTPEND &= ~2;
821 } elsif ($x & 4) { $vec = 0x3c; $INTPEND &= ~4; 809 } elsif ($pend & 4) { $vec = 0x3c; $INTPEND &= ~4;
822# } elsif ($RST ) { $vec = $RST * 8; $RST = 0; # the vt102 firmware doesn't like combined interrupts 810# } elsif ($RST ) { $vec = $RST * 8; $RST = 0; # the vt102 firmware doesn't like combined interrupts
823 } elsif ($RST & 1) { $vec = 0x08; $RST &= ~1; # separate is better for vt102 811 } elsif ($RST & 1) { $vec = 0x08; $RST &= ~1; # separate is better for vt102
824 } elsif ($RST & 2) { $vec = 0x10; $RST &= ~2; 812 } elsif ($RST & 2) { $vec = 0x10; $RST &= ~2;
825 } elsif ($RST & 4) { $vec = 0x20; $RST &= ~4; 813 } elsif ($RST & 4) { $vec = 0x20; $RST &= ~4;
826 } else { 814 } else {
841# vt100 @ 0x0000+0x0800 23-032E2 829# vt100 @ 0x0000+0x0800 23-032E2
842# vt100 @ 0x0800+0x0800 23-061E2 830# vt100 @ 0x0800+0x0800 23-061E2
843# vt100 @ 0x1000+0x0800 23-033E2 831# vt100 @ 0x1000+0x0800 23-033E2
844# vt100 @ 0x1800+0x0800 23-034E2 832# vt100 @ 0x1800+0x0800 23-034E2
845# 833#
846# vt102 @ 0x0000+0x8000 23-226E4 834# vt102 @ 0x0000+0x2000 23-226E4
847# vt102 @ 0x8000+0x8000 23-225E4 835# vt102 @ 0x8000+0x2000 23-225E4
848# 836#
849# vt131 @ 0xa000+0x0800 23-280E2 837# vt131 @ 0xa000+0x0800 23-280E2
850# 838#
851 839
852__DATA__ 840__DATA__

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines