1 |
root |
1.1 |
#!/opt/bin/perl |
2 |
|
|
|
3 |
root |
1.2 |
# |
4 |
|
|
# Copyright(C) 2014 Marc Alexander Lehmann <vt102@schmorp.de> |
5 |
|
|
# |
6 |
|
|
# vt102 is free software; you can redistribute it and/or modify it under |
7 |
|
|
# the terms of the GNU General Public License as published by the Free |
8 |
|
|
# Software Foundation; either version 3, or (at your option) any later |
9 |
|
|
# version. |
10 |
|
|
# |
11 |
|
|
# vt102 is distributed in the hope that it will be useful, but WITHOUT |
12 |
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 |
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
14 |
|
|
# for more details. |
15 |
|
|
# |
16 |
|
|
|
17 |
|
|
# If this file contains embedded ROMs, the above copyright notice does |
18 |
|
|
# not apply to them. |
19 |
|
|
|
20 |
root |
1.9 |
use strict; |
21 |
|
|
#use common::sense; |
22 |
root |
1.1 |
|
23 |
root |
1.3 |
my $VT102 = 1; |
24 |
root |
1.10 |
my $VT131 = 0; |
25 |
|
|
my $AVO = 1; |
26 |
root |
1.1 |
|
27 |
root |
1.13 |
shift, ($VT102 = 0), ($AVO = 0) if $ARGV[0] =~ /^-?-vt100$/; |
28 |
|
|
shift, ($VT102 = 0) if $ARGV[0] =~ /^-?-vt100\+avo$/; |
29 |
|
|
shift if $ARGV[0] =~ /^-?-vt102$/; |
30 |
|
|
shift, ($VT131 = 1) if $ARGV[0] =~ /^-?-vt131$/; |
31 |
root |
1.10 |
|
32 |
|
|
if ($ARGV[0] =~ /^-/) { |
33 |
|
|
die <<EOF; |
34 |
|
|
|
35 |
|
|
VT102, A VT100/101/102/131 SIMULATOR |
36 |
|
|
|
37 |
|
|
Usage: |
38 |
|
|
|
39 |
|
|
$0 [option] [program [args]] |
40 |
|
|
|
41 |
|
|
Examples: |
42 |
|
|
|
43 |
|
|
$0 bash |
44 |
|
|
$0 telnet towel.blinkenlights.nl |
45 |
|
|
$0 curl http://artscene.textfiles.com/vt100/trekvid.vt |
46 |
|
|
$0 curl http://artscene.textfiles.com/vt100/surf.vt # in 3d! |
47 |
|
|
|
48 |
|
|
Option can be one of: |
49 |
|
|
|
50 |
|
|
--vt100 |
51 |
|
|
--vt100+avo |
52 |
|
|
--vt102 |
53 |
|
|
--vt131 |
54 |
|
|
|
55 |
|
|
Non-obvious special keys are: |
56 |
|
|
|
57 |
|
|
SET UP Home |
58 |
|
|
BACKSPACE Rubout |
59 |
|
|
CAPS LOCK Prior/PgUp |
60 |
|
|
NO SCROLL Next/PgDown |
61 |
|
|
BREAK End |
62 |
|
|
|
63 |
|
|
Set-Up Guide: |
64 |
|
|
|
65 |
|
|
http://vt100.net/docs/vt102-ug/chapter3.html#S3.6 |
66 |
|
|
|
67 |
|
|
Author: |
68 |
|
|
|
69 |
|
|
Marc Lehmann <vt102\@schmorp.de> |
70 |
|
|
|
71 |
|
|
EOF |
72 |
|
|
} |
73 |
|
|
|
74 |
root |
1.1 |
############################################################################# |
75 |
root |
1.10 |
# ROM/hardware init |
76 |
root |
1.1 |
|
77 |
root |
1.15 |
my $PTY; # the pty we allocated, if any |
78 |
|
|
my $KBD = 1; |
79 |
|
|
|
80 |
root |
1.10 |
my $ROMS = do { |
81 |
root |
1.1 |
binmode DATA; |
82 |
|
|
local $/; |
83 |
|
|
<DATA> |
84 |
|
|
}; |
85 |
|
|
|
86 |
root |
1.10 |
0x6801 == length $ROMS or die "corrupted rom image"; |
87 |
root |
1.1 |
|
88 |
|
|
my @M = (0xff) x 65536; # main memory, = (0xff) x 65536; |
89 |
|
|
|
90 |
|
|
# populate mem with rom contents |
91 |
|
|
if ($VT102) { |
92 |
root |
1.10 |
@M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x2000, 0x2000; |
93 |
|
|
@M[0x8000 .. 0x9fff] = unpack "C*", substr $ROMS, 0x4000, 0x2000; |
94 |
|
|
@M[0xa000 .. 0xa7ff] = unpack "C*", substr $ROMS, 0x6000, 0x0800 if $VT131; |
95 |
root |
1.1 |
} else { |
96 |
root |
1.10 |
@M[0x0000 .. 0x1fff] = unpack "C*", substr $ROMS, 0x0000, 0x2000; |
97 |
root |
1.1 |
} |
98 |
|
|
|
99 |
|
|
############################################################################# |
100 |
root |
1.10 |
# 8085 CPU registers and I/O support |
101 |
root |
1.1 |
|
102 |
|
|
# 8080/8085 registers |
103 |
root |
1.16 |
my ($A, $B, $C, $D, $E, $H, $L); |
104 |
root |
1.1 |
my ($PC, $SP, $IFF, $FA, $FZ, $FS, $FP, $FC); |
105 |
|
|
|
106 |
|
|
my $RST = 0; # 8080 pending interrupts |
107 |
|
|
my $INTMASK = 7; # 8085 half interrupts |
108 |
|
|
my $INTPEND = 0; # 8085 half interrupts |
109 |
|
|
|
110 |
|
|
my $x; # dummy temp for instructions |
111 |
|
|
|
112 |
|
|
my $CLK; # rather inexact clock |
113 |
|
|
|
114 |
|
|
############################################################################# |
115 |
root |
1.10 |
# the dreaded NVR1400 chip. not needed to get it going, but provided anyway |
116 |
root |
1.1 |
|
117 |
|
|
# nvram |
118 |
|
|
my @NVR = (0x3fff) x 100; # vt102: 214e accum, 214f only lower 8 bit used, first 44 bytes |
119 |
|
|
my $NVRADDR; |
120 |
|
|
my $NVRDATA; |
121 |
|
|
my $NVRLATCH; |
122 |
|
|
|
123 |
|
|
my @NVRCMD = ( |
124 |
root |
1.5 |
sub { $NVRDATA = ($NVRDATA << 1) + $_[1]; }, # 0 accept data |
125 |
|
|
sub { $NVRADDR = ($NVRADDR << 1) + $_[1]; }, # 1 accept addr |
126 |
|
|
sub { ($NVRDATA <<= 1) & 0x4000 }, # 2 shift out |
127 |
|
|
undef, # 3 not used, will barf |
128 |
|
|
sub { $NVR[$_[0]] = $NVRDATA & 0x3fff; }, # 4 write |
129 |
|
|
sub { $NVR[$_[0]] = 0x3fff; }, # 5 erase |
130 |
|
|
sub { $NVRDATA = $NVR[$_[0]]; }, # 6 read |
131 |
|
|
sub { }, # 7 standby |
132 |
root |
1.1 |
); |
133 |
|
|
|
134 |
root |
1.15 |
my @NVR_BITIDX; |
135 |
|
|
$NVR_BITIDX[1 << $_] = 9 - $_ for 0..9; |
136 |
root |
1.1 |
|
137 |
|
|
# the nvr1400 state machine. what a monster |
138 |
|
|
sub nvr() { |
139 |
root |
1.15 |
my $a1 = $NVR_BITIDX[(~$NVRADDR ) & 0x3ff]; |
140 |
|
|
my $a0 = $NVR_BITIDX[(~$NVRADDR >> 10) & 0x3ff]; |
141 |
root |
1.1 |
|
142 |
|
|
# printf "NVR %02x A %020b %d %d D %02x\n", $NVRLATCH, $NVRADDR & 0xfffff, $a1, $a0, $NVRDATA; |
143 |
|
|
|
144 |
|
|
$NVRCMD[($NVRLATCH >> 1) & 7]($a1 * 10 + $a0, $NVRLATCH & 1) |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
############################################################################# |
148 |
root |
1.10 |
# I/O ports - output |
149 |
root |
1.1 |
|
150 |
root |
1.6 |
my $DC11_REVERSE = 0; |
151 |
root |
1.1 |
|
152 |
|
|
my $XON = 1; # false if terminal wants us to pause |
153 |
|
|
my $PUSARTCMD; |
154 |
|
|
|
155 |
|
|
my @KXMIT; # current scan queue |
156 |
|
|
my %KXMIT; # currently pressed keys |
157 |
|
|
my @KQUEUE; # key event queue |
158 |
|
|
my $KXCNT; # count for debouncew |
159 |
|
|
my @PUSARTRECV; |
160 |
|
|
my $KSTATUS; |
161 |
|
|
|
162 |
|
|
sub out_00 { # pusartdata |
163 |
|
|
# handle xon/xoff, but also pass it through |
164 |
|
|
if ($_[0] == 0x13) { |
165 |
|
|
$XON = 0; |
166 |
root |
1.3 |
return;#d# |
167 |
root |
1.1 |
} elsif ($_[0] == 0x11) { |
168 |
|
|
$XON = 1; |
169 |
root |
1.3 |
return;#d# |
170 |
root |
1.1 |
} |
171 |
|
|
|
172 |
|
|
syswrite $PTY, chr $_[0]; |
173 |
|
|
|
174 |
root |
1.3 |
$INTPEND |= 1; |
175 |
root |
1.1 |
} |
176 |
|
|
|
177 |
|
|
sub out_01 { |
178 |
|
|
$PUSARTCMD = shift; |
179 |
|
|
|
180 |
|
|
$INTPEND |= 1 if $PUSARTCMD & 0x01; # VT102, 5.5 txrdy |
181 |
root |
1.3 |
$INTPEND |= 2 if $PUSARTCMD & 0x04 && !@PUSARTRECV; # VT102, 6.5 rxrdy, needed for some reason |
182 |
root |
1.1 |
} |
183 |
|
|
|
184 |
|
|
sub out_02 { } # baudrate generator |
185 |
|
|
|
186 |
|
|
sub out_23 { } # unknown |
187 |
|
|
sub out_27 { } # unknown |
188 |
|
|
sub out_2f { } # unknown, connected to in 0f |
189 |
|
|
|
190 |
|
|
sub out_42 { } # brightness |
191 |
|
|
|
192 |
|
|
sub out_62 { |
193 |
|
|
$NVRLATCH = shift; |
194 |
|
|
} |
195 |
|
|
|
196 |
root |
1.6 |
sub out_a2 { |
197 |
|
|
my $dc11 = 0x0f & shift; |
198 |
|
|
|
199 |
|
|
$DC11_REVERSE = 1 if $dc11 == 0b1010; |
200 |
|
|
$DC11_REVERSE = 0 if $dc11 == 0b1011; |
201 |
|
|
} |
202 |
|
|
|
203 |
root |
1.1 |
sub out_c2 { } # unknown |
204 |
root |
1.6 |
sub out_d2 { } # 0..3 == 80c/132c/60hz/50hz |
205 |
root |
1.1 |
|
206 |
|
|
sub out_82 { |
207 |
|
|
# keyboard |
208 |
|
|
|
209 |
root |
1.10 |
# CLICK STARTSCAN ONLINE LOCKED | CTS DSR INS L1 |
210 |
|
|
# CLICK STARTSCAN ONLINE LOCKED | L1 L2 L3 L4 |
211 |
root |
1.1 |
$KSTATUS = $_[0]; |
212 |
|
|
|
213 |
|
|
# start new scan unless scan in progress |
214 |
|
|
if (($_[0] & 0x40) && !@KXMIT) { |
215 |
|
|
# do not reply with keys in locked mode |
216 |
|
|
# or during post (0xff), |
217 |
|
|
# mostly to skip init and not fail POST, |
218 |
|
|
# and to send startup keys only when terminal is ready |
219 |
|
|
unless (($_[0] & 0x10) || ($_[0] == 0xff) || ($VT102 && $INTMASK == 0x07)) { |
220 |
|
|
if ($KXCNT <= 0 && @KQUEUE) { |
221 |
|
|
my $c = shift @KQUEUE; |
222 |
|
|
|
223 |
|
|
if ($c < 0) { # key up |
224 |
|
|
delete $KXMIT{-$c}; |
225 |
|
|
$KXCNT = 10; |
226 |
|
|
} elsif ($c > 0) { # key down |
227 |
|
|
undef $KXMIT{$c}; |
228 |
|
|
$KXCNT = 10; |
229 |
|
|
} else { # delay |
230 |
|
|
$KXCNT = 100; |
231 |
|
|
} |
232 |
|
|
} |
233 |
|
|
|
234 |
|
|
--$KXCNT; |
235 |
|
|
@KXMIT = sort keys %KXMIT; |
236 |
|
|
} |
237 |
|
|
|
238 |
|
|
$RST |= 1; |
239 |
|
|
} |
240 |
|
|
} |
241 |
|
|
|
242 |
|
|
############################################################################# |
243 |
root |
1.10 |
# I/O ports - input |
244 |
root |
1.1 |
|
245 |
|
|
my $NVRBIT; |
246 |
root |
1.10 |
my $LBA6; # twice the frequenxy of LBA7 |
247 |
root |
1.1 |
|
248 |
|
|
sub in_00 { # pusart data |
249 |
root |
1.3 |
# interrupt not generated here, because infinite |
250 |
|
|
# speed does not go well with the vt102. |
251 |
root |
1.1 |
|
252 |
|
|
shift @PUSARTRECV |
253 |
|
|
} |
254 |
|
|
|
255 |
|
|
sub in_01 { # pusart status |
256 |
|
|
# DSR SYNDET FE OE | PE TXEMPTY RXRDY TXRDY |
257 |
|
|
0x85 + (@PUSARTRECV && 0x02) |
258 |
|
|
} |
259 |
|
|
|
260 |
|
|
sub in_22 { # modem buffer(?) |
261 |
|
|
# wild guess: -CTS -SPDI -RI -CD 0 0 0 0 |
262 |
|
|
0x20 |
263 |
|
|
} |
264 |
|
|
|
265 |
root |
1.10 |
sub in_0f { 0xff } # vt102 unknown, connected to out 2f |
266 |
root |
1.1 |
|
267 |
|
|
sub in_42 { # flag buffer |
268 |
root |
1.10 |
++$LBA6; |
269 |
root |
1.1 |
|
270 |
root |
1.10 |
$NVRBIT = nvr ? 0x20 : 0x00 if ($LBA6 & 0x3) == 0x2; |
271 |
root |
1.1 |
|
272 |
|
|
# KBD_XMITEMPTY LBA7 NVRDATA ODDFIELD - OPTION !GFX !AVO PUSART_TXRDY |
273 |
|
|
|
274 |
|
|
my $f = 0x85 | $NVRBIT; |
275 |
|
|
|
276 |
|
|
$f |= 0x02 unless $AVO; |
277 |
root |
1.10 |
$f |= 0x40 if $LBA6 & 0x2; |
278 |
root |
1.1 |
|
279 |
|
|
$f |
280 |
|
|
} |
281 |
|
|
|
282 |
|
|
sub in_82 { # tbmt keyboard uart |
283 |
|
|
return 0x7f unless @KXMIT; |
284 |
|
|
|
285 |
|
|
$RST |= 1; |
286 |
|
|
shift @KXMIT |
287 |
|
|
} |
288 |
|
|
|
289 |
root |
1.10 |
sub in_03 { 0xff } # vt102 unknown, printer uart input? |
290 |
|
|
sub in_0b { 0xff } # vt102 unknown |
291 |
|
|
sub in_17 { 0xff } # vt102 unknown, printer status clear by reading? |
292 |
|
|
sub in_1b { 0xff } # vt102 unknown |
293 |
root |
1.1 |
|
294 |
|
|
############################################################################# |
295 |
root |
1.10 |
# 8085 cpu opcodes and flag handling |
296 |
root |
1.1 |
|
297 |
root |
1.3 |
sub sf { # set flags (ZSC - AP not implemented) |
298 |
root |
1.10 |
$FS = $_[0] & 0x080; |
299 |
|
|
$FZ = !($_[0] & 0x0ff); |
300 |
|
|
$FC = $_[0] & 0x100; |
301 |
|
|
|
302 |
|
|
$_[0] &= 0xff; |
303 |
|
|
} |
304 |
root |
1.1 |
|
305 |
root |
1.10 |
sub sf8 { # set flags (ZSC - AP not implemented) |
306 |
|
|
$FS = $_[0] & 0x080; |
307 |
|
|
$FZ = !($_[0] & 0x0ff); |
308 |
|
|
$FC = 0; |
309 |
root |
1.1 |
} |
310 |
|
|
|
311 |
root |
1.3 |
sub sf_nc { # set flags except carry |
312 |
root |
1.1 |
$FS = $_[0] & 0x080; |
313 |
|
|
$FZ = ($_[0] & 0x0ff) == 0; |
314 |
|
|
|
315 |
root |
1.10 |
$_[0] &= 0xff; |
316 |
root |
1.1 |
} |
317 |
|
|
|
318 |
root |
1.10 |
my @op = map { sprintf "status(); die 'unknown op %02x'", $_ } 0x00 .. 0xff; |
319 |
root |
1.1 |
|
320 |
|
|
my @reg = qw($B $C $D $E $H $L $M[$H*256+$L] $A); |
321 |
|
|
my @cc = ('if !$FZ', 'if $FZ', 'if !$FC', 'if $FC', ';die', ';die', 'if !$FS', 'if $FS'); # die == unimplemented $FP parity |
322 |
|
|
|
323 |
root |
1.10 |
$op[0x00] = ''; |
324 |
|
|
|
325 |
root |
1.1 |
# mov r,r / r,M / M,r |
326 |
|
|
for my $s (0..7) { |
327 |
|
|
for my $d (0..7) { |
328 |
root |
1.10 |
$op[0x40 + $d * 8 + $s] = "$reg[$d] = $reg[$s]"; # mov |
329 |
root |
1.1 |
} |
330 |
|
|
} |
331 |
|
|
|
332 |
root |
1.10 |
$op[0x76] = 'die "HLT"'; # hlt (mov m,m) |
333 |
|
|
|
334 |
|
|
# mvi r / M |
335 |
|
|
$op[0x06 + $_ * 8] = "$reg[$_] = IMM8" for 0..7; |
336 |
root |
1.1 |
|
337 |
|
|
$op[0x01] = '($B, $C) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi |
338 |
|
|
$op[0x11] = '($D, $E) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi |
339 |
|
|
$op[0x21] = '($H, $L) = (IMM16 >> 8, IMM16 & 0xff)'; # lxi |
340 |
root |
1.10 |
$op[0x31] = '$SP = IMM16' ; # lxi |
341 |
root |
1.1 |
|
342 |
|
|
$op[0x02] = '$M[$B * 256 + $C] = $A'; # stax |
343 |
|
|
$op[0x12] = '$M[$D * 256 + $E] = $A'; # stax |
344 |
|
|
$op[0x32] = '$M[IMM16 ] = $A'; # sta |
345 |
|
|
|
346 |
root |
1.10 |
$op[0x0a] = '$A = $M[$B * 256 + $C]'; # ldax b |
347 |
|
|
$op[0x1a] = '$A = $M[$D * 256 + $E]'; # ldax d |
348 |
|
|
$op[0x3a] = '$A = $M[IMM16]'; # lda |
349 |
|
|
|
350 |
|
|
$op[0x22] = '($M[IMM16], $M[IMM16 + 1]) = ($L, $H)'; # shld |
351 |
|
|
$op[0x2a] = '($L, $H) = ($M[IMM16], $M[IMM16 + 1])'; # lhld |
352 |
|
|
|
353 |
root |
1.1 |
sub inxdcx($$$) { |
354 |
root |
1.10 |
$x = $_[0] * 256 + $_[1] + $_[2]; |
355 |
|
|
($_[0], $_[1]) = (($x >> 8) & 0xff, $x & 0xff); |
356 |
root |
1.1 |
} |
357 |
|
|
|
358 |
|
|
$op[0x03] = 'inxdcx $B, $C, 1'; # inx |
359 |
|
|
$op[0x13] = 'inxdcx $D, $E, 1'; # inx |
360 |
|
|
$op[0x23] = 'inxdcx $H, $L, 1'; # inx |
361 |
|
|
$op[0x33] = '$SP++' ; # inx |
362 |
|
|
$op[0x0b] = 'inxdcx $B, $C, -1'; # dcx |
363 |
|
|
$op[0x1b] = 'inxdcx $D, $E, -1'; # dcx |
364 |
|
|
$op[0x2b] = 'inxdcx $H, $L, -1'; # dcx |
365 |
|
|
$op[0x3b] = '--$SP' ; # dcx |
366 |
|
|
|
367 |
|
|
# "no carry" doesn't seem to be needed for vt100 - optimize? |
368 |
root |
1.10 |
$op[0x04 + $_ * 8] = "sf_nc ++$reg[$_]" for 0..7; # inr |
369 |
|
|
$op[0x05 + $_ * 8] = "sf_nc --$reg[$_]" for 0..7; # dcr |
370 |
|
|
|
371 |
|
|
$op[0x07] = ' $FC = $A & 0x80; $A = (($A << 1) + ($FC && 0x01)) & 0xff '; # rlc |
372 |
|
|
$op[0x17] = ' ($FC, $A) = ($A & 0x80, (($A << 1) + ($FC && 0x01)) & 0xff)'; # ral |
373 |
|
|
|
374 |
|
|
$op[0x0f] = ' $FC = $A & 0x01; $A = ($A >> 1) | ($FC && 0x80) '; # rrc |
375 |
|
|
$op[0x1f] = ' ($FC, $A) = ($A & 0x01, ($A >> 1) | ($FC && 0x80))'; # rar |
376 |
root |
1.1 |
|
377 |
root |
1.10 |
$op[0x2f] = '$A ^= 0xff'; # cma |
378 |
root |
1.1 |
|
379 |
|
|
# getting this insn wrong (its the only 16 bit insn to modify flags) |
380 |
|
|
# wasted three of my best days with mindless vt102 rom reverse engineering |
381 |
|
|
sub dad { |
382 |
|
|
$x = $H * 256 + $L + $_[0]; |
383 |
|
|
|
384 |
|
|
($H, $L) = (($x >> 8) & 0xff, $x & 0xff); |
385 |
|
|
$FC = $x > 0xffff; |
386 |
|
|
} |
387 |
|
|
|
388 |
|
|
$op[0x09] = 'dad $B * 256 + $C'; # dad |
389 |
|
|
$op[0x19] = 'dad $D * 256 + $E'; # dad |
390 |
|
|
$op[0x29] = 'dad $H * 256 + $L'; # dad |
391 |
|
|
$op[0x39] = 'dad $SP '; # dad |
392 |
|
|
|
393 |
root |
1.10 |
$op[0x80 + $_] = 'sf $A += + ' . $reg[$_] for 0..7; # add |
394 |
|
|
$op[0x88 + $_] = 'sf $A += ($FC && 1) + ' . $reg[$_] for 0..7; # adc |
395 |
|
|
$op[0x90 + $_] = 'sf $A -= + ' . $reg[$_] for 0..7; # sub |
396 |
|
|
$op[0x98 + $_] = 'sf $A -= ($FC && 1) + ' . $reg[$_] for 0..7; # sbb |
397 |
|
|
$op[0xa0 + $_] = 'sf8 $A &= ' . $reg[$_] for 0..7; # ana |
398 |
|
|
$op[0xa8 + $_] = 'sf8 $A ^= ' . $reg[$_] for 0..7; # xra |
399 |
|
|
$op[0xb0 + $_] = 'sf8 $A |= ' . $reg[$_] for 0..7; # ora |
400 |
|
|
$op[0xb8 + $_] = 'sf $x = $A - ' . $reg[$_] for 0..7; # cmp |
401 |
|
|
# possible todo: optimize ora a, maybe xra a |
402 |
root |
1.1 |
|
403 |
root |
1.10 |
$op[0xc6] = 'sf $A += IMM8'; # adi |
404 |
|
|
# ce ADI NYI |
405 |
|
|
$op[0xd6] = 'sf $A -= IMM8'; # sui |
406 |
|
|
# de SBI NYI |
407 |
|
|
$op[0xe6] = 'sf8 $A &= IMM8'; # ani |
408 |
|
|
$op[0xee] = 'sf8 $A ^= IMM8'; # xri |
409 |
|
|
$op[0xf6] = 'sf8 $A |= IMM8'; # ori |
410 |
|
|
$op[0xfe] = 'sf $A - IMM8'; # cpi |
411 |
root |
1.1 |
|
412 |
root |
1.10 |
$op[0xc5] = 'PUSH $B; PUSH $C'; |
413 |
|
|
$op[0xd5] = 'PUSH $D; PUSH $E'; |
414 |
|
|
$op[0xe5] = 'PUSH $H; PUSH $L'; |
415 |
|
|
$op[0xf5] = 'PUSH $A; PUSH +($FS && 0x80) | ($FZ && 0x40) | ($FA && 0x10) | ($FP && 0x04) | ($FC && 0x01)'; # psw |
416 |
root |
1.1 |
|
417 |
|
|
$op[0xc1] = '($C, $B) = (POP, POP)'; # pop |
418 |
|
|
$op[0xd1] = '($E, $D) = (POP, POP)'; # pop |
419 |
|
|
$op[0xe1] = '($L, $H) = (POP, POP)'; # pop |
420 |
root |
1.10 |
$op[0xf1] = '($x, $A) = (POP, POP); ($FS, $FZ, $FA, $FP, $FC) = ($x & 0x80, $x & 0x40, $x & 0x10, $x & 0x04, $x & 0x01)'; # pop psw |
421 |
root |
1.1 |
|
422 |
|
|
$op[0xc2 + $_ * 8] = 'BRA IMM16 ' . $cc[$_] for 0..7; # jcc |
423 |
|
|
$op[0xc3] = 'JMP IMM16'; # jmp |
424 |
|
|
|
425 |
|
|
$op[0xc4 + $_ * 8] = '(PUSH PC >> 8), (PUSH PC & 0xff), (BRA IMM16) ' . $cc[$_] for 0..7; # ccc |
426 |
|
|
$op[0xcd] = '(PUSH PC >> 8), (PUSH PC & 0xff), (BRA IMM16)'; # call |
427 |
|
|
|
428 |
root |
1.10 |
$op[0xc0 + $_ * 8] = 'BRA POP + POP * 256 ' . $cc[$_] for 0..7; # rcc |
429 |
|
|
$op[0xc9] = 'JMP POP + POP * 256'; # ret |
430 |
|
|
|
431 |
root |
1.1 |
$op[0xc7 + $_ * 8] = "JMP $_ * 8" for 0..7; # rst |
432 |
|
|
|
433 |
root |
1.10 |
$op[0xe9] = 'JMP $H * 256 + $L'; # pchl |
434 |
|
|
# f9 SPHL NYI |
435 |
root |
1.1 |
|
436 |
root |
1.10 |
$op[0x37] = '$FC = 1 '; # stc |
437 |
|
|
$op[0x3f] = '$FC = !$FC'; # cmc |
438 |
root |
1.1 |
|
439 |
|
|
$op[0xd3] = 'OUT'; # out |
440 |
|
|
$op[0xdb] = 'IN'; # in |
441 |
|
|
|
442 |
root |
1.10 |
$op[0xeb] = '($D, $E, $H, $L) = ($H, $L, $D, $E)'; # xchg |
443 |
|
|
|
444 |
|
|
# e3 xthl NYI # @ 917b, hl <-> (sp) |
445 |
root |
1.1 |
|
446 |
root |
1.10 |
$op[0x20] = '$A = $INTPEND * 16 + $INTMASK + ($IFF && 8)'; # rim (incomplete) |
447 |
|
|
$op[0x30] = '$INTMASK = $A & 7 if $A & 8'; # sim (incomplete) |
448 |
root |
1.1 |
|
449 |
|
|
$op[0xf3] = '$IFF = 0'; # DI |
450 |
|
|
$op[0xfb] = '$IFF = 1'; # EI |
451 |
|
|
|
452 |
root |
1.10 |
# yeah, the fucking setup screens actually use daa... |
453 |
|
|
$op[0x27] = ' |
454 |
|
|
my ($h, $l); |
455 |
|
|
|
456 |
|
|
($h, $l) = ($A >> 4, $A & 15); |
457 |
|
|
|
458 |
|
|
if ($l > 9 || $FA) { |
459 |
|
|
sf $A += 6; |
460 |
|
|
($h, $l) = ($A >> 4, $A & 15); |
461 |
|
|
} |
462 |
|
|
|
463 |
|
|
if ($h > 9 || $FC) { |
464 |
|
|
$h += 6; |
465 |
|
|
$A = ($h * 16 + $l) & 0xff; |
466 |
|
|
} |
467 |
|
|
'; # daa, almost certainly borked, also, acarry not set by sf |
468 |
root |
1.1 |
|
469 |
|
|
############################################################################# |
470 |
root |
1.10 |
# print cpu status for debugging purposes |
471 |
root |
1.1 |
|
472 |
|
|
# print cpu status, for debugging |
473 |
|
|
sub status { |
474 |
|
|
my $PC = shift || $PC; |
475 |
|
|
|
476 |
|
|
printf "%04x/%04x A=%02x BC=%02x:%02x DE=%02x:%02x HL=%02x:%02x ZSCAP=%s: %02x %s\n", |
477 |
|
|
$PC, $SP, |
478 |
|
|
$A, $B, $C, $D, $E, $H, $L, |
479 |
|
|
($FZ ? "1" : "0") |
480 |
|
|
. ($FS ? "1" : "0") |
481 |
|
|
. ($FC ? "1" : "0") |
482 |
|
|
. ($FA ? "1" : "0") |
483 |
|
|
. ($FP ? "1" : "0"), |
484 |
root |
1.10 |
$M[$PC], $op[$M[$PC]]; |
485 |
root |
1.1 |
} |
486 |
|
|
|
487 |
|
|
############################################################################# |
488 |
root |
1.10 |
# video emulation |
489 |
root |
1.1 |
|
490 |
root |
1.14 |
binmode STDOUT; |
491 |
|
|
|
492 |
root |
1.10 |
my @CHARMAP = ( |
493 |
root |
1.5 |
" " , "\x{29eb}", "\x{2592}", "\x{2409}", |
494 |
|
|
"\x{240c}", "\x{240d}", "\x{240a}", "\x{00b0}", |
495 |
|
|
"\x{00b1}", "\x{2424}", "\x{240b}", "\x{2518}", |
496 |
|
|
"\x{2510}", "\x{250c}", "\x{2514}", "\x{253c}", |
497 |
|
|
"\x{23ba}", "\x{23bb}", "\x{2500}", "\x{23bc}", |
498 |
|
|
"\x{23bd}", "\x{251c}", "\x{2524}", "\x{2534}", |
499 |
|
|
"\x{252c}", "\x{2502}", "\x{2264}", "\x{2265}", |
500 |
|
|
"\x{03c0}", "\x{2260}", "\x{00a3}", "\x{00b7}", |
501 |
root |
1.1 |
(map chr, 0x020 .. 0x7e), |
502 |
|
|
); |
503 |
|
|
|
504 |
root |
1.10 |
utf8::encode $_ for @CHARMAP; |
505 |
root |
1.1 |
|
506 |
root |
1.10 |
my @SGR; # sgr sequences for attributes |
507 |
root |
1.6 |
|
508 |
|
|
for (0x00 .. 0xff) { |
509 |
|
|
my $sgr = ""; |
510 |
|
|
|
511 |
root |
1.10 |
# ~1 sgr 5 blink |
512 |
|
|
# ~2 sgr 4 underline |
513 |
|
|
# ~4 sgr 1 bold |
514 |
|
|
# 0x80 in attr, sgr 7, reversed |
515 |
|
|
|
516 |
root |
1.6 |
$sgr .= ";5" unless $_ & 0x01; |
517 |
|
|
$sgr .= ";4" unless $_ & 0x02; |
518 |
|
|
$sgr .= ";1" unless $_ & 0x04; |
519 |
|
|
$sgr .= ";7" if $_ & 0x80; |
520 |
|
|
|
521 |
root |
1.10 |
$SGR[$_] = "\e[${sgr}m"; |
522 |
root |
1.6 |
} |
523 |
|
|
|
524 |
root |
1.10 |
my @LED = $VT102 |
525 |
|
|
? qw(L1 INSERT DSR CTS LOCKED LOCAL SCAN BEEP) |
526 |
|
|
: qw(L4 L3 L2 L1 LOCKED LOCAL SCAN BEEP); |
527 |
|
|
|
528 |
|
|
# display screen |
529 |
|
|
sub display { |
530 |
root |
1.1 |
my $i = 0x2000; |
531 |
|
|
|
532 |
root |
1.10 |
my $leds = join " ", map $KSTATUS & 2**$_ ? "\e[7m$LED[$_]\e[m" : "$LED[$_]", reverse 0 .. $#LED; |
533 |
|
|
|
534 |
|
|
my $scr = sprintf "\e[H--- LED [ %s ] CLK %d\e[K\n", $leds, $CLK; |
535 |
root |
1.6 |
|
536 |
|
|
$scr .= "\e[?5" . ($DC11_REVERSE ? "h" : "l"); |
537 |
root |
1.5 |
|
538 |
root |
1.1 |
line: |
539 |
root |
1.6 |
for my $y (0 .. 25) { # ntsc, two vblank delay lines, up to 24 text lines |
540 |
|
|
my $prev_sgr; |
541 |
|
|
|
542 |
root |
1.9 |
$scr .= sprintf "%2d \xe2\x94\x82", $y; |
543 |
root |
1.1 |
|
544 |
root |
1.6 |
for (0..139) { |
545 |
|
|
my $c = $M[$i]; |
546 |
root |
1.1 |
|
547 |
|
|
if ($c == 0x7f) { # also 0xff, but the firmware avoids that |
548 |
root |
1.9 |
$scr .= "\e[m\xe2\x94\x82\e[K\n"; |
549 |
root |
1.1 |
|
550 |
root |
1.6 |
my $a1 = $M[$i + 1]; |
551 |
|
|
my $a0 = $M[$i + 2]; |
552 |
root |
1.1 |
|
553 |
|
|
$i = 0x2000 + (($a1 * 256 + $a0) & 0xfff); |
554 |
|
|
|
555 |
|
|
next line; |
556 |
|
|
} |
557 |
|
|
|
558 |
root |
1.10 |
my $sgr = $SGR[ ($M[$i++ + 0x1000] & 15) | ($c & 0x80)]; |
559 |
root |
1.6 |
|
560 |
|
|
$scr .= $prev_sgr = $sgr if $sgr ne $prev_sgr; |
561 |
|
|
|
562 |
root |
1.10 |
$scr .= $CHARMAP[$c & 0x7f]; |
563 |
root |
1.1 |
} |
564 |
|
|
|
565 |
root |
1.6 |
$scr .= "\e[K\nvideo overflow\e[K\n"; |
566 |
root |
1.1 |
last; |
567 |
|
|
} |
568 |
|
|
|
569 |
root |
1.10 |
$scr .= "\e[m\e[J"; |
570 |
root |
1.1 |
|
571 |
|
|
syswrite STDOUT, $scr; |
572 |
|
|
} |
573 |
|
|
|
574 |
|
|
############################################################################# |
575 |
root |
1.10 |
# keyboard handling |
576 |
root |
1.1 |
|
577 |
root |
1.7 |
# 0x080 shift, 0x100 ctrl |
578 |
root |
1.1 |
my %KEYMAP = ( |
579 |
root |
1.8 |
"\t" => 0x3a, |
580 |
|
|
"\r" => 0x64, |
581 |
|
|
"\n" => 0x44, |
582 |
|
|
|
583 |
|
|
"\x00" => 0x77 | 0x100, # CTRL-SPACE |
584 |
|
|
"\x1c" => 0x45 | 0x100, # CTRL-\ |
585 |
|
|
"\x1d" => 0x14 | 0x100, # CTRL-] |
586 |
|
|
"\x1e" => 0x24 | 0x100, # CTRL-~ |
587 |
|
|
"\x1f" => 0x75 | 0x100, # CTRL-? |
588 |
|
|
|
589 |
|
|
# hardcoded rxvt keys |
590 |
|
|
"\e" => 0x2a, # ESC |
591 |
|
|
"\e[3~" => 0x03, # DC |
592 |
|
|
"\e[5~" => 0x7e, # CAPS LOCK (prior) |
593 |
|
|
"\e[6~" => 0x6a, # NO SCROLL (next) |
594 |
|
|
"\e[A" => 0x30, # UP |
595 |
|
|
"\e[B" => 0x22, # DOWN |
596 |
|
|
"\e[C" => 0x10, # RIGHT |
597 |
|
|
"\e[D" => 0x20, # LEFT |
598 |
|
|
"\e[a" => 0x30 | 0x080, # UP |
599 |
|
|
"\e[b" => 0x22 | 0x080, # DOWN |
600 |
|
|
"\e[c" => 0x10 | 0x080, # RIGHT |
601 |
|
|
"\e[d" => 0x20 | 0x080, # LEFT |
602 |
|
|
"\e[7~" => 0x7b, # SETUP (home) |
603 |
|
|
"\e[8~" => 0x23, # BREAK (end) |
604 |
|
|
"\e[8\$" => 0x23 | 0x080, # SHIFT BREAK / DISCONNECT (shift-end) |
605 |
|
|
"\x7f" => 0x33, # BACKSPACE |
606 |
|
|
|
607 |
|
|
"\e[11~" => 0x32, # F1 |
608 |
|
|
"\e[11~" => 0x42, # F2 |
609 |
|
|
"\e[11~" => 0x31, # F3 |
610 |
|
|
"\e[11~" => 0x41, # F4 |
611 |
root |
1.1 |
); |
612 |
|
|
|
613 |
root |
1.10 |
@KEYMAP{map chr, 0x20 .. 0x40, 0x5b .. 0x7e} = unpack "C*", pack "H*", |
614 |
|
|
"779ad5a9a8b8a755a6b5b6b466256575" . "351a3929283837273626d656e634e5f5" . "b9" # 20..40 |
615 |
|
|
. "154514b7a5" . "244a6879591949485816574746766706" . "050a185a0817780969077a95c594a4"; # 5b..7e |
616 |
root |
1.1 |
|
617 |
root |
1.7 |
$KEYMAP{"\x1f" & $_} ||= $KEYMAP{$_} | 0x100 for "a" .. "z"; # ctrl |
618 |
root |
1.10 |
$KEYMAP{"\x20" ^ $_} ||= $KEYMAP{$_} | 0x080 for "a" .. "z"; # shift |
619 |
root |
1.1 |
|
620 |
|
|
my $KEYMATCH = join "|", map quotemeta, reverse sort keys %KEYMAP; |
621 |
|
|
$KEYMATCH = qr{^($KEYMATCH)}s; |
622 |
|
|
|
623 |
root |
1.10 |
my %KMOD; |
624 |
|
|
|
625 |
root |
1.1 |
sub key { |
626 |
|
|
my ($key) = @_; |
627 |
|
|
|
628 |
root |
1.10 |
push @KQUEUE, -0x7c if !($key & 0x100) && delete $KMOD{0x7c}; # ctrl-up |
629 |
|
|
push @KQUEUE, -0x7d if !($key & 0x080) && delete $KMOD{0x7d}; # shift-up |
630 |
root |
1.1 |
|
631 |
root |
1.10 |
push @KQUEUE, 0x7c if $key & 0x100 && !$KMOD{0x7c}++; # ctrl-down |
632 |
|
|
push @KQUEUE, 0x7d if $key & 0x080 && !$KMOD{0x7d}++; # shift-down |
633 |
root |
1.1 |
|
634 |
|
|
$key &= 0x7f; |
635 |
|
|
push @KQUEUE, $key, -$key; |
636 |
|
|
} |
637 |
|
|
|
638 |
|
|
my $STDIN_BUF; |
639 |
|
|
|
640 |
|
|
sub stdin_parse { |
641 |
|
|
key $KEYMAP{$1} |
642 |
|
|
while $STDIN_BUF =~ s/$KEYMATCH//; |
643 |
|
|
|
644 |
|
|
# skip input we can't decipher |
645 |
|
|
substr $STDIN_BUF, 0, 1, ""; |
646 |
|
|
} |
647 |
|
|
|
648 |
|
|
if ($KBD) { |
649 |
|
|
system "stty -icanon -icrnl -inlcr -echo min 1 time 0"; |
650 |
|
|
eval q{ sub END { system "stty sane" } }; |
651 |
|
|
$SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { exit 1 }; |
652 |
|
|
} |
653 |
|
|
|
654 |
|
|
############################################################################# |
655 |
root |
1.10 |
# initial key input, to set up online mode etc. |
656 |
|
|
# could be done via nvram defaults |
657 |
|
|
|
658 |
|
|
@KQUEUE = ( |
659 |
|
|
0x7b, -0x7b, # setup |
660 |
|
|
0, # delay |
661 |
|
|
0x28, -0x28, # 4, toggle local/online |
662 |
|
|
0x38, -0x38, # 5, setup b |
663 |
|
|
0, # delay |
664 |
|
|
(0x10, -0x10) x 2, # cursor right |
665 |
|
|
0x37, -0x37, # 6 toggle soft scroll |
666 |
|
|
(0x10, -0x10) x 1, # cursor right |
667 |
|
|
0x37, -0x37, # 6 toggle autorepeat off |
668 |
|
|
(0x10, -0x10) x 8, # cursor right |
669 |
|
|
0x37, -0x37, # 6 toggle keyclick |
670 |
|
|
(0x10, -0x10) x 1, # cursor right |
671 |
|
|
$VT102 ? () : (0x37, -0x37), # 6 toggle ansi/vt52 |
672 |
|
|
(0x10, -0x10) x 7, # cursor right |
673 |
|
|
0x37, -0x37, # 6 toggle wrap around |
674 |
|
|
0x7b, -0x7b, # leave setup |
675 |
|
|
); |
676 |
|
|
|
677 |
|
|
############################################################################# |
678 |
|
|
# process/pty management |
679 |
|
|
|
680 |
|
|
require IO::Pty; |
681 |
|
|
$PTY = IO::Pty->new; |
682 |
|
|
|
683 |
|
|
my $slave = $PTY->slave; |
684 |
|
|
|
685 |
|
|
$PTY->set_winsize (24, 80); |
686 |
|
|
|
687 |
|
|
unless (fork) { |
688 |
|
|
$ENV{TERM} = $VT102 ? "vt102" : "vt100"; |
689 |
|
|
|
690 |
|
|
close $PTY; |
691 |
|
|
|
692 |
|
|
open STDIN , "<&", $slave; |
693 |
|
|
open STDOUT, ">&", $slave; |
694 |
|
|
open STDERR, ">&", $slave; |
695 |
|
|
|
696 |
|
|
system "stty ixoff erase ^H"; |
697 |
|
|
|
698 |
|
|
$PTY->make_slave_controlling_terminal; |
699 |
|
|
$PTY->close_slave; |
700 |
|
|
|
701 |
|
|
@ARGV = "sh" unless @ARGV; |
702 |
|
|
exec @ARGV; |
703 |
|
|
} |
704 |
|
|
|
705 |
|
|
$PTY->close_slave; |
706 |
|
|
|
707 |
|
|
############################################################################# |
708 |
|
|
# the actual hardware simulator |
709 |
root |
1.1 |
|
710 |
|
|
my @ICACHE; # compiled instruction cache |
711 |
|
|
|
712 |
|
|
while () { |
713 |
|
|
# execute extended basic blocks |
714 |
|
|
$PC = ($ICACHE[$PC] ||= do { |
715 |
|
|
my $pc = $PC; |
716 |
|
|
|
717 |
|
|
my $insn = ""; |
718 |
|
|
|
719 |
|
|
# the jit compiler |
720 |
root |
1.10 |
for (0..31) { |
721 |
root |
1.1 |
my $imm; |
722 |
|
|
my $op = $op[$M[$pc++]]; |
723 |
|
|
|
724 |
|
|
for ($op) { |
725 |
|
|
s/\bPUSH\b/\$M[--\$SP] =/g; # push byte to stack |
726 |
|
|
s/\bPOP\b/\$M[\$SP++]/g; # pop byte from stack |
727 |
|
|
|
728 |
|
|
s/\bIMM16\b/$imm \/\/= $M[$pc++] + $M[$pc++] * 256/xge; # 16 bit insn immediate |
729 |
|
|
s/\bIMM8\b /$imm \/\/= $M[$pc++] /xge; # 8 bit insn immediate |
730 |
|
|
|
731 |
|
|
s/\bPC\b/$pc/ge; # PC at end of insn |
732 |
|
|
s/\bBRA\b/return/g; # conditional jump |
733 |
|
|
s/\bJMP\b(.*)/$1\x00/sg; # unconditional jump |
734 |
|
|
|
735 |
|
|
s/\bIN\b/ sprintf "\$A = in_%02x", $M[$pc++]/xge; |
736 |
|
|
s/\bOUT\b/sprintf "out_%02x \$A ", $M[$pc++]/xge; |
737 |
|
|
} |
738 |
|
|
|
739 |
|
|
$insn .= "$op;\n"; |
740 |
|
|
} |
741 |
|
|
|
742 |
|
|
|
743 |
root |
1.12 |
$insn .= $pc; |
744 |
root |
1.1 |
$insn =~ s/\x00.*$//s; |
745 |
|
|
|
746 |
|
|
eval "use integer; sub { $insn }" or die "$insn: $@" |
747 |
|
|
})->(); |
748 |
|
|
|
749 |
|
|
++$CLK; |
750 |
|
|
|
751 |
|
|
# things we do from time too time only |
752 |
|
|
unless ($CLK & 0xf) { |
753 |
|
|
# do I/O |
754 |
|
|
|
755 |
root |
1.10 |
unless ($CLK & 0xfff) { |
756 |
root |
1.1 |
|
757 |
|
|
# pty/serial I/O |
758 |
root |
1.10 |
unless ((@PUSARTRECV >= 128) || @KQUEUE || !$PTY) { |
759 |
root |
1.1 |
my $rin = ""; (vec $rin, fileno $PTY, 1) = 1; |
760 |
|
|
|
761 |
|
|
if (select $rin, undef, undef, 0) { |
762 |
|
|
sysread $PTY, my $buf, 256; |
763 |
|
|
push @PUSARTRECV, unpack "C*", $buf; |
764 |
|
|
} |
765 |
|
|
} |
766 |
|
|
|
767 |
|
|
# keyboard input |
768 |
|
|
if ($KBD) { |
769 |
|
|
while (select my $rin = "\x01", undef, undef, 0) { |
770 |
|
|
sysread STDIN, $STDIN_BUF, 1, length $STDIN_BUF |
771 |
|
|
or last; |
772 |
|
|
} |
773 |
|
|
|
774 |
|
|
stdin_parse if length $STDIN_BUF; |
775 |
|
|
} |
776 |
|
|
} |
777 |
|
|
|
778 |
|
|
# kick off various interrupts |
779 |
|
|
|
780 |
root |
1.3 |
$RST |= 2 if @PUSARTRECV && $XON; # VT100, but works on vt102, too (probably not used on real hardware though) |
781 |
|
|
#$INTPEND |= 2 if @PUSARTRECV && $XON; # VT102, 6.5 rxrdy |
782 |
root |
1.1 |
|
783 |
root |
1.3 |
# kick off vertical retrace form time to time |
784 |
root |
1.5 |
unless ($CLK & 0x1ff) { |
785 |
root |
1.1 |
$RST |= 4; # vertical retrace |
786 |
|
|
} |
787 |
|
|
|
788 |
|
|
# handle video hardware |
789 |
root |
1.10 |
unless ($CLK & 0x3fff) { |
790 |
|
|
display; |
791 |
root |
1.1 |
} |
792 |
|
|
} |
793 |
root |
1.4 |
|
794 |
|
|
# the interrupt logic |
795 |
root |
1.10 |
if (($RST || ($INTPEND & ~$INTMASK)) && $IFF) { |
796 |
root |
1.4 |
# rst 1 kbd data available |
797 |
|
|
# rst 2 pusart xmit+recv flag |
798 |
|
|
# rst 4 vertical retrace |
799 |
|
|
# 5.5 vt125 mb7 trans ready (serial send?) |
800 |
|
|
# 6.5 vt125 mb7 read ready (something modem?) |
801 |
|
|
# 7.5 vt125 mb7 vblank h(?) |
802 |
|
|
# trap vt125 mbi init h(?) |
803 |
|
|
my $vec; |
804 |
|
|
|
805 |
root |
1.10 |
$x = $INTPEND & ~$INTMASK; |
806 |
|
|
|
807 |
root |
1.4 |
if ($x & 1) { $vec = 0x2c; $INTPEND &= ~1; |
808 |
|
|
} elsif ($x & 2) { $vec = 0x34; $INTPEND &= ~2; |
809 |
|
|
} elsif ($x & 4) { $vec = 0x3c; $INTPEND &= ~4; |
810 |
root |
1.10 |
# } elsif ($RST ) { $vec = $RST * 8; $RST = 0; # the vt102 firmware doesn't like combined interrupts |
811 |
root |
1.4 |
} elsif ($RST & 1) { $vec = 0x08; $RST &= ~1; # separate is better for vt102 |
812 |
|
|
} elsif ($RST & 2) { $vec = 0x10; $RST &= ~2; |
813 |
|
|
} elsif ($RST & 4) { $vec = 0x20; $RST &= ~4; |
814 |
|
|
} else { |
815 |
|
|
die; |
816 |
|
|
} |
817 |
|
|
|
818 |
|
|
$M[--$SP] = $PC >> 8; |
819 |
|
|
$M[--$SP] = $PC & 0xff; |
820 |
|
|
$PC = $vec; |
821 |
|
|
|
822 |
|
|
$IFF = 0; |
823 |
|
|
} |
824 |
root |
1.1 |
} |
825 |
|
|
|
826 |
root |
1.10 |
############################################################################# |
827 |
|
|
# roms in the data section + one newline |
828 |
|
|
# |
829 |
|
|
# vt100 @ 0x0000+0x0800 23-032E2 |
830 |
|
|
# vt100 @ 0x0800+0x0800 23-061E2 |
831 |
|
|
# vt100 @ 0x1000+0x0800 23-033E2 |
832 |
|
|
# vt100 @ 0x1800+0x0800 23-034E2 |
833 |
|
|
# |
834 |
root |
1.11 |
# vt102 @ 0x0000+0x2000 23-226E4 |
835 |
|
|
# vt102 @ 0x8000+0x2000 23-225E4 |
836 |
root |
1.10 |
# |
837 |
|
|
# vt131 @ 0xa000+0x0800 23-280E2 |
838 |
|
|
# |
839 |
|
|
|
840 |
root |
1.1 |
__DATA__ |
841 |
|
|
1N ; 0 >b/BWog<Gӂ,O $
O [ xI <ӂ,Bt @`+6 +|v #~ʐ |¡ 0ڡ q~ʨ |¡ 0Ҩ ,ڥ # yOt ͤ[ zW>/2!b>> >ӂx ӂ:h zW͢uۂG|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 |
842 |
|
|
2!0* w4ʘ> 2! ~î!N ̓/2!! "R !"" |
843 |
|
|
! ͋! 0 Ãppppp!"-!>52,!>2[ 2v!!"I!>2s >2 B>2y >2!2!&l" >@:X!:!͔>2!b:!K>G:| !p ^!p" :!x:! u> |
844 |
|
|
Ӣ:[!Ӣ:!cww#:!>>{́kB͈͇!w!~6 :!ʮ2D!î :O:!:8>'y7:!y !!>D! NDy<wG: 'qx<o61,@ 7~G>G>w70)1!2@3#4$5%6^7&8*9(-_=+`~[{]};:/?'",<.>\| poytwq ][iure1 `-9743=08652 Ѱ |
845 |
|
|
\lkgfa ';jhds
.,nbx /m vczN> Ӣ:e !Q >>2e 6 >2[ :V!>2[ :U!=/2z [ |
846 |
|
|
!Z 'wWӢzӢz>2e |
847 |
|
|
:V!8:U!=2z !x ~O52F!!,!~=i65>Ӣ!!~jӢw>@2H!! 4:!B:X!:!b:!!{ uG:{ x©:y xک ڲ*@!! |
848 |
|
|
2>2y |
849 |
|
|
G>xbO͈ByFsO! V#zozz2 V: Gzy_ Oz@y$#$: O:B!A! :S!A6 U * q|gpx2 ! q! :S!hy2 :!@m462B!:!
! ~#n& V! ~<w+@0§~z:h _!A{2g W !n ~!j #6
#{>2r !G:r < 2r :!@{:P!!_#!s 56:r y!n ~C#8vyj !n ~[ |
850 |
|
|
f#}rQ |
851 |
|
|
lNG:g x2g 2P!{j,C_:D!A{WW{!v_ Ny1 xpy{aOx0!K~###NxyA[? {AAO:!2T!S:P!!n A#!n ~8#+A:P!w>2r !h Vw#r#w#L:!@>2G!{*j:d:0!W:1!_>= zħ;>>ܧ>b>ܧz >oz2 QW>>Wʞ _{ |
852 |
|
|
>!_ ^#V 8 A
U U U K <2 :!*{!|!r!>w!r!~w!{!F#\!~0 #
$ !x ~w! ~562 6K :! K ! V:V!s Ϳxr6:!ʘ ͎>2!4:! 2 =2 2} 2!! |
853 |
|
|
0ҽ !} O~ʻ q2~ ! |
854 |
|
|
:} :! !P |
855 |
|
|
! |
856 |
|
|
G:! x( 2)1#!{ |
857 |
|
|
!:~ O#
|
858 |
|
|
## |
859 |
|
|
~#fo!"@!A |
860 |
|
|
B |
861 |
|
|
C |
862 |
|
|
D |
863 |
|
|
F |
864 |
|
|
GH |
865 |
|
|
IJ |
866 |
|
|
K |
867 |
|
|
YZ=>1W<]`
c ER M1W[ |
868 |
|
|
H
DU 7h8q=>ZNFOF 345J67`
8
!"@!>H2~ ! "0!! |
869 |
|
|
:} ! |
870 |
|
|
:!!0!:K!_ |
871 |
|
|
~! |
872 |
|
|
G :!# |
873 |
|
|
DBCHSArfSxyd cqn
JAKlmhg
!"@!G ڲ!Q!.! "@!~B6x 2R!!"@!6 x PO2 Ϳ:R!]2 |
874 |
|
|
62!ͭPLPÉ>2!ͭL2U!Ϳx2V!y2P BH>ê! :U!G~ʸ! 56:!͎>2!5:!2 -!x!6!x!6 !!~ w:!&&Hl" " 2 &&l" !E!x#~wG7)w:~ G!J##~ȸ9#~! 44AHB01 2 !y ~ |
875 |
|
|
6! |
876 |
|
|
!! w! !͋6!xʗ 2 ! ~w>õ:!»>õ>! w>2 :0!!r!~w>Ϳ
:! 6+6/6?#>1
BG/Oxy0w#6:!x!r!2
~w>Ϳ
:!x)
0w#6~w>Ϳ
: G:!J
:U!Ox<z
ͻ
: <z
6B͎> |