… | |
… | |
21 | #use common::sense; |
21 | #use common::sense; |
22 | |
22 | |
23 | my $VT102 = 1; |
23 | my $VT102 = 1; |
24 | my $VT131 = 0; |
24 | my $VT131 = 0; |
25 | my $AVO = 1; |
25 | my $AVO = 1; |
26 | my $KBD = 1; |
|
|
27 | |
26 | |
28 | shift, ($VT102 = 0), ($AVO = 0) if $ARGV[0] =~ /^-?-vt100$/; |
27 | shift, ($VT102 = 0), ($AVO = 0) if $ARGV[0] =~ /^-?-vt100$/; |
29 | shift, ($VT102 = 0) if $ARGV[0] =~ /^-?-vt100\+avo$/; |
28 | shift, ($VT102 = 0) if $ARGV[0] =~ /^-?-vt100\+avo$/; |
30 | shift if $ARGV[0] =~ /^-?-vt102$/; |
29 | shift if $ARGV[0] =~ /^-?-vt102$/; |
31 | shift, ($VT131 = 1) if $ARGV[0] =~ /^-?-vt131$/; |
30 | shift, ($VT131 = 1) if $ARGV[0] =~ /^-?-vt131$/; |
… | |
… | |
73 | } |
72 | } |
74 | |
73 | |
75 | ############################################################################# |
74 | ############################################################################# |
76 | # ROM/hardware init |
75 | # ROM/hardware init |
77 | |
76 | |
|
|
77 | my $PTY; # the pty we allocated, if any |
|
|
78 | my $KBD = 1; |
|
|
79 | |
78 | my $ROMS = do { |
80 | my $ROMS = do { |
79 | binmode DATA; |
81 | binmode DATA; |
80 | local $/; |
82 | local $/; |
81 | <DATA> |
83 | <DATA> |
82 | }; |
84 | }; |
83 | |
85 | |
84 | 0x6801 == length $ROMS or die "corrupted rom image"; |
86 | 0x6801 == length $ROMS or die "corrupted rom image"; |
85 | |
|
|
86 | binmode STDOUT; |
|
|
87 | |
87 | |
88 | my @M = (0xff) x 65536; # main memory, = (0xff) x 65536; |
88 | my @M = (0xff) x 65536; # main memory, = (0xff) x 65536; |
89 | |
89 | |
90 | # populate mem with rom contents |
90 | # populate mem with rom contents |
91 | if ($VT102) { |
91 | if ($VT102) { |
… | |
… | |
97 | } |
97 | } |
98 | |
98 | |
99 | ############################################################################# |
99 | ############################################################################# |
100 | # 8085 CPU registers and I/O support |
100 | # 8085 CPU registers and I/O support |
101 | |
101 | |
102 | my $PTY; # the pty we allocated, if any |
|
|
103 | |
|
|
104 | # 8080/8085 registers |
102 | # 8080/8085 registers |
105 | # b, c, d, e, h, l, a |
|
|
106 | my ($A, $B, $C, $D, $E, $H, $L, $A); |
103 | my ($A, $B, $C, $D, $E, $H, $L); |
107 | my ($PC, $SP, $IFF, $FA, $FZ, $FS, $FP, $FC); |
104 | my ($PC, $SP, $IFF, $FA, $FZ, $FS, $FP, $FC); |
108 | |
105 | |
109 | my $RST = 0; # 8080 pending interrupts |
106 | my $RST = 0; # 8080 pending interrupts |
110 | my $INTMASK = 7; # 8085 half interrupts |
107 | my $INTMASK = 7; # 8085 half interrupts |
111 | my $INTPEND = 0; # 8085 half interrupts |
108 | my $INTPEND = 0; # 8085 half interrupts |
… | |
… | |
132 | sub { $NVR[$_[0]] = 0x3fff; }, # 5 erase |
129 | sub { $NVR[$_[0]] = 0x3fff; }, # 5 erase |
133 | sub { $NVRDATA = $NVR[$_[0]]; }, # 6 read |
130 | sub { $NVRDATA = $NVR[$_[0]]; }, # 6 read |
134 | sub { }, # 7 standby |
131 | sub { }, # 7 standby |
135 | ); |
132 | ); |
136 | |
133 | |
137 | my @bitidx; |
134 | my @NVR_BITIDX; |
138 | $bitidx[1 << $_] = 9 - $_ for 0..9; |
135 | $NVR_BITIDX[1 << $_] = 9 - $_ for 0..9; |
139 | |
136 | |
140 | # the nvr1400 state machine. what a monster |
137 | # the nvr1400 state machine. what a monster |
141 | sub nvr() { |
138 | sub nvr() { |
142 | my $a1 = $bitidx[(~$NVRADDR ) & 0x3ff]; |
139 | my $a1 = $NVR_BITIDX[(~$NVRADDR ) & 0x3ff]; |
143 | my $a0 = $bitidx[(~$NVRADDR >> 10) & 0x3ff]; |
140 | my $a0 = $NVR_BITIDX[(~$NVRADDR >> 10) & 0x3ff]; |
144 | |
141 | |
145 | # printf "NVR %02x A %020b %d %d D %02x\n", $NVRLATCH, $NVRADDR & 0xfffff, $a1, $a0, $NVRDATA; |
142 | # printf "NVR %02x A %020b %d %d D %02x\n", $NVRLATCH, $NVRADDR & 0xfffff, $a1, $a0, $NVRDATA; |
146 | |
143 | |
147 | $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1) |
144 | $NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1) |
148 | } |
145 | } |
… | |
… | |
487 | $M[$PC], $op[$M[$PC]]; |
484 | $M[$PC], $op[$M[$PC]]; |
488 | } |
485 | } |
489 | |
486 | |
490 | ############################################################################# |
487 | ############################################################################# |
491 | # video emulation |
488 | # video emulation |
|
|
489 | |
|
|
490 | binmode STDOUT; |
492 | |
491 | |
493 | my @CHARMAP = ( |
492 | my @CHARMAP = ( |
494 | " " , "\x{29eb}", "\x{2592}", "\x{2409}", |
493 | " " , "\x{29eb}", "\x{2592}", "\x{2409}", |
495 | "\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}", |
494 | "\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}", |
496 | "\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}", |
495 | "\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}", |