This repository has been archived by the owner on Dec 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathVT100.txt
5844 lines (5569 loc) · 154 KB
/
VT100.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;
; DZ80 V3.4.1 8080 Disassembly of archive/VT100.bin
; 2016/08/03 14:55
;
; Comments beginning with ";;" borrowed from Adam Mayer's (https://github.com/phooky)
; work at https://github.com/phooky/VT100-Hax/blob/master/ROMs/haxrom.d80 and http://vt100romhax.tumblr.com
;
; All other comments/annotations by Jeff Parsons (@jeffpar) <[email protected]>
;
;
; Data area definitions
;
20 4E stack_top equ 204eh
20 4E scratch_start equ 204eh
;
; The "Keys Flag Byte/Buffer" at 0x2068 contains the following bits:
;
; 0-1 Key counter
; 2 Key counter overflow bit
; 3 Setup
; 4 Control
; 5 Shift
; 6 Caps Lock
; 7 Last Key
;
20 68 key_flags equ 2068h ; "Keys Flag Buffer"
20 6A key_buffer equ 206ah ; start of the "three place New Key Address Buffer"
20 F6 cursor_address equ 20f6h
21 2D cursor_countdn equ 212dh
21 BA cursor_visible equ 21bah
;
; Reset vector
;
00 00 org 0
39 0000 F3 di
40 0001 31 4E 20 lxi sp,stack_top ; SP = 0x204e
41 0004 C3 3B 00 jmp reset
;
; Interrupt vector 0x1 for Keyboard
;
00 08 org 8
46 0008 CD FD 00 call X00fd
47 000B FB ei
48 000C C9 ret
;
; Interrupt vector 0x2 for PUSART
;
00 10 org 10h
53 0010 CD CC 03 call X03cc
54 0013 FB ei
55 0014 C9 ret
;
; Interrupt vector 0x3 for Keyboard and PUSART
;
00 18 org 18h
60 0018 CD CC 03 call X03cc
61 001B CD FD 00 call X00fd
62 001E FB ei
63 001F C9 ret
;
; Interrupt vector 0x4 for Video (vertical retrace)
;
00 20 org 20h
68 0020 CD CF 04 call X04cf
69 0023 C9 ret
;
; Interrupt vector 0x5 for Keyboard and Video
;
00 28 org 28h
74 0028 CD CF 04 call X04cf
75 002B C9 ret
;
; Interrupt vector 0x6 for PUSART and Video
;
00 30 org 30h
80 0030 CD CC 03 X0030: call X03cc
81 0033 CD CF 04 call X04cf
82 0036 FB ei
83 0037 C9 ret
;
; Interrupt vector 0x7 for Keyboard and PUSART and Video
;
00 38 org 38h
88 0038 C3 30 00 jmp X0030
;
; Beginning of power-up (reset) code at 0x003b
;
93 003B 1E 01 reset: mvi e,1
94 003D F3 X003d: di
95 003E 3E 0F mvi a,0fh
96 0040 D3 62 out 62h ;; 0x0f to NVR latch
97 0042 2F cma ;; invert A (0xf0)
98 0043 D3 42 out 42h ;; 0xf0 to brightness
;;
;; Run checksum on each 2K ROM, indicating with
;; the keyboard LEDs which is being scanned.
;; The # of the chip being scanned is stored in B.
;;
104 0045 AF xra a ;; zero A
105 0046 57 mov d,a ;; zero D, L, H
106 0047 6F mov l,a
107 0048 67 mov h,a
108 0049 3C X0049: inr a ;; next 2K ROM
109 004A 47 mov b,a ;; store the current ROM # in B
110 004B D3 82 out 82h ;; show current ROM on LEDs
111 004D 0E 08 mvi c,8 ;; Checksum over 8 256B blocks
112 004F 07 X004f: rlc ;; Rotate A left
113 0050 AE xra m ;; A <- A ^ memory
114 0051 2C inr l ;; next memory address
115 0052 C2 4F 00 jnz X004f ;; ... repeat until end of block
116 0055 24 inr h ;; next block
117 0056 0D dcr c ;; decrement block count
118 0057 C2 4F 00 jnz X004f ;; ... repeat until end of chip
119 005A B7 ora a ;; Check the value of the accumulator
120 005B C2 5B 00 X005b: jnz X005b ;; If it's not zero, hang forever
121 005E 78 mov a,b ;; Put the ROM # back in the accumulator
122 005F FE 04 cpi 4 ;; If it's not 4...
123 0061 C2 49 00 jnz X0049 ;; repeat for the next ROM
125 0064 3C inr a
126 0065 D3 82 out 82h ;; write 5 to LEDs (turns on L2 and L4)
128 0067 0E AA mvi c,0aah ;; Test pattern: 0xaa
129 0069 06 2C mvi b,2ch ;; 0x2c is the top of RAM on the basic board
130 006B DB 42 in 42h ;;
131 006D E6 02 ani 2 ;; flags buffer &= 0x02 : is AVO installed?
132 006F C2 74 00 jnz X0074 ;; if bit 2 is not set, AVO is installed
133 0072 06 40 mvi b,40h ;; 0x40 is the top of RAM on the AVO
134 0074 60 X0074: mov h,b ;; load HL with top of RAM
135 0075 2B dcx h ;; dec HL
136 0076 36 00 X0076: mvi m,0 ;; M <- 0
137 0078 2B dcx h ;; dec HL
138 0079 7C mov a,h ;; a <- h
139 007A FE 1F cpi 1fh ;; compare to 1f (top of ROM)
140 007C C2 76 00 jnz X0076 ;; continue to zero if not at ROM
142 007F 23 inx h
;;
;; Zero all RAM. C gets the high byte of the address of the top of
;; RAM, HL is loaded with it, and it zeros memory all the way down,
;; leaving the start of RAM in HL
;;
;; From start of RAM, test that it's all zero
;;
150 0080 7E X0080: mov a,m ;; read a byte of memory
151 0081 B7 ora a
152 0082 CA 90 00 jz X0090 ;; if it's zero, skip ahead
153 0085 E6 0F ani 0fh
154 0087 7C mov a,h
155 0088 C2 A1 00 jnz X00a1 ;; err
156 008B FE 30 cpi 30h
157 008D DA A1 00 jc X00a1 ;; err
158 0090 71 X0090: mov m,c ;; run test pattern through ram
159 0091 7E mov a,m
160 0092 A9 xra c
161 0093 CA A8 00 jz X00a8 ;; jump to 00a8 if ok
162 0096 E6 0F ani 0fh
163 0098 7C mov a,h
164 0099 C2 A1 00 jnz X00a1 ;; err
165 009C FE 30 cpi 30h
166 009E D2 A8 00 jnc X00a8 ;; ok
167 00A1 16 01 X00a1: mvi d,1
168 00A3 FE 2C cpi 2ch
169 00A5 DA A5 00 X00a5: jc X00a5 ;; Hang if non-AVO memory
170 00A8 AF X00a8: xra a
171 00A9 23 inx h
172 00AA B5 ora l
173 00AB C2 80 00 jnz X0080
174 00AE B4 ora h
175 00AF B8 cmp b
176 00B0 C2 80 00 jnz X0080
177 00B3 79 mov a,c ;; Repeat mem test with pattern 0x55
178 00B4 07 rlc
179 00B5 4F mov c,a
180 00B6 DA 74 00 jc X0074
;;
;; Memory test is done
;;
184 00B9 D5 push d
185 00BA CD A4 02 call X02a4 ;; zero scratch and screen mem
186 00BD CD EB 02 call X02eb ;; Set a number of scratch values to fixed values
187 00C0 CD 5B 17 call X175b ;; .... more memory initialization
188 00C3 D1 pop d
189 00C4 CA CB 00 X00c4: jz X00cb
190 00C7 7A mov a,d
191 00C8 F6 02 ori 2
192 00CA 57 mov d,a
193 00CB 3E 2F X00cb: mvi a,2fh
194 00CD 32 C9 21 sta X21c9
195 00D0 D3 62 out 62h
;
; Prepare to enter the "beep" loop
;
199 00D2 01 FF 0F X00d2: lxi b,X0fff
200 00D5 FB ei
201 00D6 3E 08 X00d6: mvi a,8
202 00D8 A3 ana e
203 00D9 3E 7F mvi a,7fh
204 00DB C2 E0 00 jnz X00e0
205 00DE 3E FF mvi a,0ffh
206 00E0 D3 82 X00e0: out 82h
207 00E2 0B dcx b
208 00E3 78 mov a,b
209 00E4 B1 ora c
210 00E5 C2 D6 00 jnz X00d6
;
; Done "beeping" now
;
214 00E8 D3 82 X00e8: out 82h ; A = 0, so all LEDs off now
215 00EA 3A 68 20 lda key_flags
216 00ED B7 ora a
217 00EE FA F5 00 jm X00f5
218 00F1 7A mov a,d
219 00F2 F6 04 ori 4
220 00F4 57 mov d,a
221 00F5 D5 X00f5: push d
;
; The next call issues the following:
;
; 03A2 CD8103 CALL 0381 ;stack=204A
; 0B67 CDAD10 CALL 10AD ;stack=2048
; chipset.outPort(0x00A2,DC012,0x00) at 10BD
; chipset.outPort(0x00A2,DC012,0x04) at 10C1
;
; and then:
;
; 03A2 CD8103 CALL 0381 ;stack=204A
; 0B67 CDAD10 CALL 10AD ;stack=2048
; 10C9 CDAA0F CALL 0FAA ;stack=2046
; 0FB6 CC8814 CALLZ 1488 ;stack=2040
; 1488 CD9314 CALL 1493 ;stack=203E
; chipset.inPort(0x0042,FLAGS.BUFFER): 0x60 at 1493
;
; Note that once we're inside 0FAA, that appears to be where we stay.
;
242 00F6 CD A2 03 call X03a2
244 00F9 D1 pop d
245 00FA C3 75 08 jmp X0875
;
; Keyboard interrupt handler
;
249 00FD F5 X00fd: push psw
250 00FE DB 82 in 82h ;; Read from keyboard port
251 0100 E5 push h
252 0101 C5 push b
253 0102 47 mov b,a ;; copy b <- a
254 0103 D6 7C sui 7ch ;; subtract 0x7c from a
255 0105 FA 1A 01 jm X011a ;; jump to 011a if a is a normal key
256 0108 67 mov h,a ;; otherwise h <- a
257 0109 24 inr h ;; h++
258 010A 3E 10 mvi a,10h ;; a <- 0x10
259 010C 0F rrc
260 010D 07 X010d: rlc
261 010E 25 dcr h
262 010F C2 0D 01 jnz X010d
263 0112 21 68 20 lxi h,key_flags ;; load keys flag addresss
264 0115 B6 ora m ;; or in control bit
265 0116 77 mov m,a ;; store again
266 0117 C3 2D 01 jmp X012d ;; jump to end to interrupt
268 011A 21 68 20 X011a: lxi h,key_flags ;; load keys flag address
269 011D 3E 07 mvi a,7
270 011F A6 ana m ;; load key counter
271 0120 FE 04 cpi 4 ;; if overflow.. (>3 keys)
272 0122 F2 2D 01 jp X012d ;; discard keypress and end interrupt
273 0125 34 inr m ;; otherwise increment key counter
274 0126 21 6A 20 lxi h,key_buffer ;; load key address buffer
275 0129 CD DE 13 call X13de ;; add key counter to address buffer
276 012C 70 mov m,b ;; save key to address buffer
277 012D C1 X012d: pop b
278 012E E1 pop h
279 012F F1 pop psw
280 0130 C9 ret
;;
;; End of keyboard interrupt handler
;;
284 0131 E6 7F X0131: ani 7fh
285 0133 4F mov c,a
286 0134 3A 7B 20 lda X207b
287 0137 B7 ora a
288 0138 C2 FF 01 jnz X01ff
289 013B 79 X013b: mov a,c
290 013C FE 01 cpi 1
291 013E CA C3 01 jz X01c3
292 0141 3A A7 21 lda X21a7
293 0144 E6 20 ani 20h
294 0146 C2 75 01 jnz X0175
295 0149 3A 78 21 lda X2178
296 014C B7 ora a
297 014D C2 5F 01 jnz X015f
298 0150 79 mov a,c
299 0151 FE 41 cpi 41h
300 0153 FA 5B 01 jm X015b
301 0156 3E 1B mvi a,1bh
302 0158 CD 18 0F call X0f18
303 015B 79 X015b: mov a,c
304 015C C3 0D 08 jmp X080d
306 015F 3E 1B X015f: mvi a,1bh
307 0161 CD 18 0F call X0f18
308 0164 79 mov a,c
309 0165 FE 41 cpi 41h
310 0167 F2 5B 01 jp X015b
311 016A 3E 3F mvi a,3fh
312 016C CD 18 0F X016c: call X0f18
313 016F 79 mov a,c
314 0170 C6 40 adi 40h
315 0172 C3 0D 08 jmp X080d
317 0175 3A 78 21 X0175: lda X2178
318 0178 B7 ora a
319 0179 C2 9E 01 jnz X019e
320 017C 79 mov a,c
321 017D FE 41 cpi 41h
322 017F FA 5B 01 jm X015b
323 0182 FE 50 cpi 50h
324 0184 FA 9E 01 jm X019e
325 0187 3E 1B X0187: mvi a,1bh
326 0189 CD 18 0F call X0f18
327 018C 3E 4F mvi a,4fh
328 018E CD 18 0F X018e: call X0f18
329 0191 C3 5B 01 jmp X015b
331 0194 3E 1B X0194: mvi a,1bh
332 0196 CD 18 0F call X0f18
333 0199 3E 5B mvi a,5bh
334 019B C3 8E 01 jmp X018e
336 019E 3A BC 21 X019e: lda X21bc
337 01A1 B7 ora a
338 01A2 CA B5 01 jz X01b5
339 01A5 79 mov a,c
340 01A6 FE 41 cpi 41h
341 01A8 F2 87 01 jp X0187
342 01AB 3E 1B X01ab: mvi a,1bh
343 01AD CD 18 0F call X0f18
344 01B0 3E 4F mvi a,4fh
345 01B2 C3 6C 01 jmp X016c
347 01B5 79 X01b5: mov a,c
348 01B6 FE 41 cpi 41h
349 01B8 FA AB 01 jm X01ab
350 01BB FE 50 cpi 50h
351 01BD FA 94 01 jm X0194
352 01C0 C3 87 01 jmp X0187
354 01C3 21 15 08 X01c3: lxi h,X0815
355 01C6 E5 push h
356 01C7 3A A5 21 lda X21a5
357 01CA B7 ora a
358 01CB C0 rnz
359 01CC CD 53 08 call X0853
360 01CF 01 0E 02 lxi b,X020e
361 01D2 21 68 20 lxi h,key_flags
362 01D5 7E mov a,m
363 01D6 E6 10 ani 10h
364 01D8 C2 00 09 jnz X0900
365 01DB 7E mov a,m
366 01DC E6 20 ani 20h
367 01DE CA E4 01 jz X01e4
368 01E1 01 D2 00 lxi b,X00d2
369 01E4 3E 25 X01e4: mvi a,25h
370 01E6 F6 08 ori 8
371 01E8 B0 ora b
372 01E9 D3 01 out 1
373 01EB 3A 7F 20 lda X207f
374 01EE 81 add c
375 01EF 4F mov c,a
376 01F0 C5 X01f0: push b
377 01F1 CD 93 14 call X1493
378 01F4 C1 pop b
379 01F5 3A 7F 20 lda X207f
380 01F8 B9 cmp c
381 01F9 C2 F0 01 jnz X01f0
382 01FC C3 94 03 jmp X0394
384 01FF 21 12 08 X01ff: lxi h,X0812
385 0202 E5 push h
386 0203 AF xra a
387 0204 32 30 21 sta X2130
388 0207 32 B8 21 sta X21b8
389 020A 21 A3 21 lxi h,X21a3
390 020D 79 mov a,c
391 020E D6 41 X020e: sui 41h
392 0210 47 mov b,a
393 0211 7E X0211: mov a,m
394 0212 CA 22 02 jz X0222
395 0215 05 dcr b
396 0216 CA 26 02 jz X0226
397 0219 05 dcr b
398 021A CA 15 18 jz X1815
399 021D 05 dcr b
400 021E CA 1E 18 jz X181e
401 0221 C9 ret
403 0222 3D X0222: dcr a
404 0223 F8 rm
405 0224 77 mov m,a
406 0225 C9 ret
408 0226 3C X0226: inr a
409 0227 FE 20 cpi 20h
410 0229 C8 rz
411 022A 77 mov m,a
412 022B C9 ret
414 022C 3A A7 21 X022c: lda X21a7
415 022F 2F cma
416 0230 E6 10 ani 10h
417 0232 21 A5 21 lxi h,X21a5
418 0235 B6 ora m
419 0236 C2 41 08 jnz X0841
420 0239 3A BF 21 lda X21bf
421 023C 01 11 02 lxi b,X0211
422 023F A0 ana b
423 0240 C2 45 02 jnz X0245
424 0243 0E 13 mvi c,13h
425 0245 79 X0245: mov a,c
426 0246 D6 11 sui 11h
427 0248 32 C4 21 sta X21c4
428 024B CD 7E 0F call X0f7e
429 024E C3 12 08 jmp X0812
431 0251 F3 X0251: di
432 0252 31 4E 20 lxi sp,stack_top ; SP = 0x204e
433 0255 21 00 20 lxi h,2000h
434 0258 E5 push h
435 0259 7E mov a,m
436 025A 1F rar
437 025B DA 65 02 jc X0265
438 025E DB 42 in 42h
439 0260 E6 02 ani 2
440 0262 CA 69 02 jz X0269
441 0265 3C X0265: inr a
442 0266 32 C8 21 sta X21c8
443 0269 CD A2 03 X0269: call X03a2
444 026C 3A 50 20 lda X2050
445 026F 3D dcr a
446 0270 32 53 21 sta X2153
447 0273 E1 pop h
448 0274 7E mov a,m
449 0275 36 7F mvi m,7fh
450 0277 B7 ora a
451 0278 CA 98 02 jz X0298
452 027B F2 85 02 jp X0285
453 027E 21 CB 21 lxi h,X21cb
454 0281 36 0A mvi m,0ah
455 0283 E6 7F ani 7fh
456 0285 32 BD 21 X0285: sta X21bd
457 0288 C6 30 adi 30h
458 028A 2A F6 20 lhld cursor_address
459 028D 77 mov m,a
460 028E FE 34 cpi 34h
461 0290 CA 98 02 jz X0298
462 0293 3E 20 mvi a,20h
463 0295 32 A5 21 sta X21a5
464 0298 CD F2 0B X0298: call X0bf2
465 029B 01 11 00 lxi b,X0011
466 029E CD 7E 0F call X0f7e
467 02A1 C3 AE 03 jmp X03ae
;;
;; Zero all scratch and screen RAM above stack
;;
471 02A4 21 4E 20 X02a4: lxi h,scratch_start ;; HL = 0x204e (just above stack)
472 02A7 11 B2 0F lxi d,0fb2h ;; DE = 0x0fb2 (every byte from 0x204e up to 0x3000)
473 02AA 06 00 mvi b,0 ;; B = 0
474 02AC CD 83 10 call memset ;; memset(0x1083): set 0x0fb2 bytes to 0 starting at 0x204e
475 02AF 2F cma ;; invert A
476 02B0 32 04 21 sta X2104 ;; store A in 0x2104
477 02B3 21 04 20 lxi h,X2004 ;; HL <- 0x2004
478 02B6 22 52 20 shld X2052 ;; *(0x2052) = 0x2004
479 02B9 21 D0 22 lxi h,X22d0 ;; HL <- 0x22d0
480 02BC 22 F6 20 shld cursor_address ;; *(20f6) = 0x22d0
481 02BF C9 ret
;;
;; Initialize start of screen RAM and wipe attribute RAM to 0xff
;;
485 02C0 CD 15 0A X02c0: call X0a15 ;; 0x2140 = 0xe605
486 02C3 21 00 20 lxi h,2000h ;; HL = 0x2000
487 02C6 11 D9 02 lxi d,X02d9 ;; DE = 0x02d9
488 02C9 06 12 mvi b,12h ;; B = 18
489 02CB CD 8B 03 call memmove ;; copy 18 bytes from 0x02d9 to 0x2000
490 02CE 21 00 30 lxi h,3000h ;; HL = 0x3000
491 02D1 11 00 10 lxi d,1000h ;; DE = 0x1000
492 02D4 06 FF mvi b,0ffh ;; B = 0xFF
493 02D6 C3 83 10 jmp memset ;; invoke memset(0x1083) to set all of attribute RAM to 0xFF and return
;;
;; 0x02d9 through 0x02eb are the initial values for the screen RAM;
;; it's copied into low RAM at 0x2000 during init.
;;
X02d9:
499 02D9 db 07fh,070h,003h
7F 70 03
500 02DC db 07fh,0f2h,0d0h
7F F2 D0
501 02DF db 07fh,070h,006h
7F 70 06
502 02E2 db 07fh,070h,00ch
7F 70 0C
503 02E5 db 07fh,070h,00fh
7F 70 0F
504 02E8 db 07fh,070h,003h
7F 70 03
;;
;; Initialize several scratch values. We don't know what all of these are for yet.
;;
508 02EB 21 12 02 X02eb: lxi h,212h ;; HL = 0x0212 (530.)
509 02EE 22 2D 21 shld cursor_countdn ;; Store 0x0212 at cursor_countdn [0x212d]
510 02F1 3E 35 mvi a,35h ;; A = 0x35
511 02F3 32 2C 21 sta X212c ;; 0x212c = 0x35
512 02F6 3E 01 mvi a,1 ;; A = 1
513 02F8 32 5B 20 sta X205b ;; 0x205b = 1
514 02FB 32 76 21 sta X2176 ;; 0x2176 = 1
515 02FE 21 FF 07 lxi h,X07ff ;; HL = 0x07ff
516 0301 22 49 21 shld X2149 ;; store 0xff07 at 0x2149
517 0304 3E 02 mvi a,2 ;; A = 2
518 0306 32 73 20 sta X2073 ;; 0x2073 = 2
519 0309 3E F7 mvi a,0f7h ;; A = 0xf7
520 030B 32 FA 20 sta X20fa ;; 0x20fa = 0xf7
521 030E DB 42 in 42h ;; read flags buffer
522 0310 E6 04 ani 4 ;; And it with 0x04 (check graphics flag)
523 0312 3E 01 mvi a,1 ;; A=1
524 0314 C2 1A 03 jnz X031a ;; if no graphics skip
525 0317 32 79 20 sta X2079 ;; else store 1 in 0x2079
526 031A 3E FF X031a: mvi a,0ffh ;; A = 0xff
527 031C 32 0E 21 sta X210e ;; 0x210e = 0xff
528 031F 32 BA 21 sta cursor_visible ;; set cursor_visible [0x21ba] to 0xff (initially visible)
529 0322 26 80 mvi h,80h ;; H = 0x80
530 0324 6C mov l,h ;; L = 0x80
531 0325 22 C0 20 shld X20c0 ;; Store 0x8080 at 0x20c0
532 0328 C9 ret
534 0329 3E 40 X0329: mvi a,40h
535 032B D3 01 out 1
536 032D 3A 58 21 lda X2158
537 0330 D3 02 out 2
538 0332 3A A4 21 lda X21a4
539 0335 D3 01 out 1
540 0337 CD 94 03 call X0394
541 033A 3E 10 mvi a,10h
542 033C 32 C9 21 sta X21c9
543 033F D3 62 out 62h
544 0341 C9 ret
546 0342 3A A2 21 X0342: lda X21a2
547 0345 B7 ora a
548 0346 CA 4B 03 jz X034b
549 0349 3E 10 mvi a,10h
550 034B 47 X034b: mov b,a
551 034C D3 C2 out 0c2h
552 034E 3A 7C 20 lda X207c
553 0351 D3 C2 out 0c2h
554 0353 FE 20 cpi 20h
555 0355 21 70 09 lxi h,X0970
556 0358 C2 5E 03 jnz X035e
557 035B 21 70 03 lxi h,X0370
558 035E 22 01 20 X035e: shld X2001
559 0361 3A A8 21 lda X21a8
560 0364 E6 10 ani 10h
561 0366 C8 rz
562 0367 78 mov a,b
563 0368 D3 C2 out 0c2h
564 036A C9 ret
566 036B 3A A6 21 X036b: lda X21a6
567 036E E6 20 ani 20h
568 0370 C2 75 03 X0370: jnz X0375
569 0373 3E 01 mvi a,1
570 0375 F6 0A X0375: ori 0ah
571 0377 D3 A2 out 0a2h
572 0379 3A 5B 21 lda X215b
573 037C F6 0C ori 0ch
574 037E D3 A2 out 0a2h
575 0380 C9 ret
577 0381 3A A2 21 X0381: lda X21a2
578 0384 B7 ora a
579 0385 CA 63 0B jz X0b63
580 0388 C3 77 0B jmp X0b77
;;
;; memmove(0x038b): Move B bytes at DE to HL
;;
memmove:
585 038B 1A ldax d ;; Load memory at DE into accumulator
586 038C 77 mov m,a ;; Store it at HL
587 038D 23 inx h ;; HL++
588 038E 13 inx d ;; DE++
589 038F 05 dcr b ;; B--
590 0390 C2 8B 03 jnz memmove ;; until B is zero
591 0393 C9 ret
593 0394 3A A5 21 X0394: lda X21a5
594 0397 B7 ora a
595 0398 3E 01 mvi a,1
596 039A C2 9F 03 jnz X039f
597 039D 3E 05 mvi a,5
598 039F C3 7B 1F X039f: jmp X1f7b
600 03A2 CD 81 03 X03a2: call X0381
601 03A5 CD DB 1D call X1ddb
602 03A8 CD 6B 03 call X036b
603 03AB C3 42 03 jmp X0342
605 03AE CD 88 14 X03ae: call X1488
606 03B1 CD 87 05 call X0587
607 03B4 21 77 21 lxi h,X2177
608 03B7 7E mov a,m
609 03B8 B7 ora a
610 03B9 36 00 mvi m,0
611 03BB C4 20 1A cnz X1a20
612 03BE 3A A5 21 lda X21a5
613 03C1 B7 ora a
614 03C2 CA AE 03 jz X03ae
615 03C5 AF xra a
616 03C6 32 44 21 sta X2144
617 03C9 C3 AE 03 jmp X03ae
;;
;; Receiver interrupt handler
;;
621 03CC F5 X03cc: push psw
622 03CD C5 push b
623 03CE E5 push h
624 03CF DB 00 in 0 ;; Read from PUSART data
625 03D1 E6 7F ani 7fh
626 03D3 CA 3A 04 jz X043a
627 03D6 4F mov c,a
628 03D7 3A A5 21 lda X21a5
629 03DA B7 ora a
630 03DB C2 3A 04 jnz X043a
631 03DE DB 01 in 1 ;; Read from PUSART ctrl
632 03E0 E6 38 ani 38h
633 03E2 CA ED 03 jz X03ed
634 03E5 0E 1A mvi c,1ah
635 03E7 3E 27 mvi a,27h
636 03E9 F6 10 ori 10h
637 03EB D3 01 out 1
638 03ED 79 X03ed: mov a,c
639 03EE FE 7F cpi 7fh
640 03F0 CA 37 04 jz X0437
641 03F3 3A A7 21 lda X21a7
642 03F6 E6 10 ani 10h
643 03F8 79 mov a,c
644 03F9 CA 09 04 jz X0409
645 03FC 21 C2 21 lxi h,X21c2
646 03FF FE 11 cpi 11h
647 0401 CA 3E 04 jz X043e
648 0404 FE 13 cpi 13h
649 0406 CA 44 04 jz X0444
650 0409 21 C0 20 X0409: lxi h,X20c0
651 040C 4E mov c,m
652 040D 44 mov b,h
653 040E 02 stax b
654 040F 79 mov a,c
655 0410 3C inr a
656 0411 E6 BF ani 0bfh
657 0413 77 mov m,a
658 0414 47 mov b,a
659 0415 3A C1 20 lda X20c1
660 0418 90 sub b
661 0419 C2 27 04 jnz X0427
662 041C 71 mov m,c
663 041D 78 mov a,b
664 041E 3C inr a
665 041F E6 BF ani 0bfh
666 0421 6F mov l,a
667 0422 36 1A mvi m,1ah
668 0424 C3 31 04 jmp X0431
670 0427 F2 2C 04 X0427: jp X042c
671 042A C6 40 adi 40h
672 042C FE 20 X042c: cpi 20h
673 042E C2 37 04 jnz X0437
674 0431 01 13 01 X0431: lxi b,X0113
675 0434 CD 7E 0F call X0f7e
676 0437 CD 47 0E X0437: call X0e47
677 043A E1 X043a: pop h
678 043B C1 pop b
679 043C F1 pop psw
680 043D C9 ret
;;
;; End of keyboard interrupt handler
;;
684 043E 3E FE X043e: mvi a,0feh
685 0440 A6 ana m
686 0441 C3 47 04 jmp X0447
688 0444 3E 01 X0444: mvi a,1
689 0446 B6 ora m
690 0447 77 X0447: mov m,a
691 0448 C3 37 04 jmp X0437
693 044B X044b: db 30h
30
694 044C 29 dad h
695 044D 31 21 32 lxi sp,X3221
696 0450 40 mov b,b
697 0451 33 inx sp
698 0452 23 inx h
699 0453 34 inr m
700 0454 24 inr h
701 0455 35 dcr m
702 0456 25 dcr h
703 0457 36 5E mvi m,5eh
704 0459 37 stc
705 045A 26 38 mvi h,38h
706 045C 2A 39 28 lhld X2839
707 045F 2D dcr l
708 0460 5F mov e,a
709 0461 3D dcr a
710 0462 2B dcx h
711 0463 60 mov h,b
712 0464 7E mov a,m
713 0465 5B mov e,e
714 0466 7B mov a,e
715 0467 5D mov e,l
716 0468 7D mov a,l
717 0469 3B dcx sp
718 046A 3A 2F 3F lda X3f2f
719 046D 27 daa
720 046E 22 2C 3C shld X3c2c
721 0471 2E 3E mvi l,3eh
722 0473 5C mov e,h
723 0474 7C mov a,h
724 0475 db 20h
20
X0476:
726 0476 KBTab: db 20h, 7fh, 7fh, 7fh, 00h, 'p', 'o', 'y', 't', 'w', 'q'
20 7F 7F 7F
00 70 6F 79
74 77 71
727 0481 db 0c3h, 00h, 00h, 00h, ']', '[', 'i', 'u', 'r', 'e', '1'
C3 00 00 00
5D 5B 69 75
72 65 31
728 048C db 0c4h, 00h, 0c2h, 081h, '`', '-', '9', '7', '4', '3', 1bh
C4 00 C2 81
60 2D 39 37
34 33 1B
729 0497 db 0c1h, 0d2h, 0d0h, 08h, '=', '0', '8', '6', '5', '2', 09h
C1 D2 D0 08
3D 30 38 36
35 32 09
730 04A2 db 0b7h, 0d3h, 0d1h, 0b0h, 0ah, '\', 'l', 'k', 'g', 'f', 'a'
B7 D3 D1 B0
0A 5C 6C 6B
67 66 61
731 04AD db 0b8h, 8dh, 0b2h, 0b1h, 00h, 27h, 3bh, 'j', 'h', 'd', 's'
B8 8D B2 B1
00 27 3B 6A
68 64 73
732 04B8 db 0aeh, 0ach, 0b5h, 0b4h, 0dh, '.', ',', 'n', 'b', 'x', 82h
AE AC B5 B4
0D 2E 2C 6E
62 78 82
733 04C3 db 0b9h, 0b3h, 0b6h, 0adh, 00h, '/', 'm', ' ', 'v', 'c', 'z'
B9 B3 B6 AD
00 2F 6D 20
76 63 7A
734 04CE FF rst 7
;;
;; Vertical interrupt handler
;;
738 04CF F5 X04cf: push psw
739 04D0 E5 push h
740 04D1 D5 push d
741 04D2 CD 4E 10 call X104e
742 04D5 C5 push b
743 04D6 3E 09 mvi a,9
744 04D8 D3 A2 out 0a2h
745 04DA FB ei
746 04DB 3A 65 20 lda X2065
747 04DE B7 ora a
748 04DF C2 0B 05 jnz X050b
749 04E2 21 51 20 lxi h,X2051
750 04E5 B6 ora m
751 04E6 CA 3E 05 jz X053e
752 04E9 3E 01 mvi a,1
753 04EB 32 65 20 sta X2065
754 04EE B6 ora m
755 04EF 36 00 mvi m,0
756 04F1 3E 01 mvi a,1
757 04F3 32 5B 20 sta X205b
758 04F6 3A 56 21 lda X2156
759 04F9 F2 05 05 jp X0505
760 04FC 3E 99 mvi a,99h
761 04FE 32 5B 20 sta X205b
762 0501 3A 55 21 lda X2155
763 0504 3D dcr a
764 0505 CD 2F 12 X0505: call X122f
765 0508 32 7A 20 sta X207a
766 050B 01 5B 20 X050b: lxi b,X205b
767 050E 0A ldax b
768 050F 21 5A 20 lxi h,X205a
769 0512 86 add m
770 0513 27 daa
771 0514 E6 0F ani 0fh
772 0516 77 mov m,a
773 0517 57 mov d,a
774 0518 E6 03 ani 3
775 051A D3 A2 out 0a2h
776 051C 7A mov a,d
777 051D 1F rar
778 051E A7 ana a
779 051F 1F rar
780 0520 F6 04 ori 4
781 0522 D3 A2 out 0a2h
782 0524 7A mov a,d
783 0525 B7 ora a
784 0526 C2 3E 05 jnz X053e
785 0529 32 65 20 sta X2065
786 052C 0A ldax b
787 052D B7 ora a
788 052E 3A 56 21 lda X2156
789 0531 FA 38 05 jm X0538
790 0534 3A 55 21 lda X2155
791 0537 3D dcr a
792 0538 CD CE 11 X0538: call X11ce
793 053B 32 7A 20 sta X207a
794 053E 21 78 20 X053e: lxi h,X2078
795 0541 7E mov a,m
796 0542 B7 ora a
797 0543 CA 4F 05 jz X054f
798 0546 35 dcr m
799 0547 E6 04 ani 4
800 0549 0F rrc
801 054A 0F rrc
802 054B 0F rrc
803 054C 32 46 21 sta X2146
804 054F 21 2C 21 X054f: lxi h,X212c
805 0552 7E mov a,m
806 0553 3D dcr a
807 0554 C2 69 05 jnz X0569
808 0557 36 35 mvi m,35h
809 0559 3E 08 mvi a,8
810 055B D3 A2 out 0a2h
811 055D 21 CB 21 lxi h,X21cb
812 0560 7E mov a,m
813 0561 B7 ora a
814 0562 CA 6A 05 jz X056a
815 0565 D3 A2 out 0a2h
816 0567 EE 01 xri 1
817 0569 77 X0569: mov m,a
818 056A 3E 40 X056a: mvi a,40h
819 056C 32 48 21 sta X2148
820 056F 21 7F 20 lxi h,X207f
821 0572 34 inr m
822 0573 3A A3 21 lda X21a3
823 0576 D3 42 out 42h
824 0578 3A 58 21 lda X2158
825 057B D3 02 out 2
826 057D 3A C9 21 lda X21c9
827 0580 D3 62 out 62h
828 0582 C1 pop b
829 0583 D1 pop d
830 0584 E1 pop h
831 0585 F1 pop psw
832 0586 C9 ret
834 0587 3A A5 21 X0587: lda X21a5
835 058A 21 7B 20 lxi h,X207b
836 058D B6 ora m
837 058E C0 rnz
838 058F CD 75 06 call X0675
839 0592 C8 rz
840 0593 47 X0593: mov b,a
841 0594 3A 7B 20 lda X207b
842 0597 B7 ora a
843 0598 78 mov a,b
844 0599 C2 A9 05 jnz X05a9
845 059C 3A 79 20 lda X2079
846 059F 07 rlc
847 05A0 78 mov a,b
848 05A1 DA A9 05 jc X05a9
849 05A4 FE 20 cpi 20h
850 05A6 DA B2 08 jc X08b2
851 05A9 2A 40 21 X05a9: lhld X2140
852 05AC E9 pchl
854 05AD FE 1B X05ad: cpi 1bh
855 05AF C2 CC 05 jnz X05cc
856 05B2 21 B8 05 lxi h,X05b8
857 05B5 C3 18 0A jmp X0a18
859 05B8 FE 32 X05b8: cpi 32h
860 05BA C2 C5 05 jnz X05c5
861 05BD 3E 01 mvi a,1
862 05BF 32 79 20 sta X2079
863 05C2 C3 15 0A jmp X0a15
865 05C5 47 X05c5: mov b,a
866 05C6 3E 1B mvi a,1bh
867 05C8 CD D2 05 call X05d2
868 05CB 78 mov a,b
869 05CC CD D2 05 X05cc: call X05d2
870 05CF C3 62 0C jmp X0c62
872 05D2 4F X05d2: mov c,a
873 05D3 C5 X05d3: push b
874 05D4 CD 88 14 call X1488
875 05D7 C1 pop b
876 05D8 DB 42 in 42h
877 05DA E6 04 ani 4
878 05DC C2 D3 05 jnz X05d3
879 05DF 79 mov a,c
880 05E0 D3 E2 out 0e2h
881 05E2 C9 ret
883 05E3 CD 46 0C X05e3: call X0c46
884 05E6 F5 X05e6: push psw
885 05E7 FE 7F cpi 7fh
886 05E9 CA 73 06 jz X0673
887 05EC E5 push h
888 05ED D5 push d
889 05EE C5 push b
890 05EF 4F mov c,a
891 05F0 21 FC 20 lxi h,X20fc
892 05F3 56 mov d,m
893 05F4 23 inx h
894 05F5 7A mov a,d
895 05F6 85 add l
896 05F7 6F mov l,a
897 05F8 7A mov a,d
898 05F9 D6 02 sui 2
899 05FB F2 FF 05 jp X05ff
900 05FE 7A mov a,d
901 05FF 32 FC 20 X05ff: sta X20fc
902 0602 56 mov d,m
903 0603 3A FA 20 lda X20fa
904 0606 B2 ora d
905 0607 47 mov b,a
906 0608 7A mov a,d
907 0609 07 rlc
908 060A 79 mov a,c
909 060B D2 16 06 jnc X0616
910 060E D6 5F sui 5fh
911 0610 FE 20 cpi 20h
912 0612 D2 16 06 jnc X0616
913 0615 4F mov c,a
914 0616 7A X0616: mov a,d
915 0617 E6 40 ani 40h
916 0619 79 mov a,c
917 061A CA 24 06 jz X0624
918 061D FE 23 cpi 23h
919 061F C2 24 06 jnz X0624
920 0622 0E 1E mvi c,1eh
921 0624 3A FB 20 X0624: lda X20fb
922 0627 B1 ora c
923 0628 4F mov c,a
924 0629 3A 42 21 lda X2142
925 062C B7 ora a
926 062D CA 41 06 jz X0641
927 0630 21 F8 20 lxi h,X20f8
928 0633 3A 53 21 lda X2153
929 0636 BE cmp m
930 0637 C2 41 06 jnz X0641
931 063A 36 00 mvi m,0
932 063C C5 push b
933 063D CD 55 09 call X0955
934 0640 C1 pop b
935 0641 2A F6 20 X0641: lhld cursor_address
936 0644 71 mov m,c
937 0645 7C mov a,h
938 0646 C6 10 adi 10h
939 0648 67 mov h,a
940 0649 70 mov m,b
941 064A 78 mov a,b
942 064B 32 F5 20 sta X20f5
943 064E 21 F4 20 lxi h,X20f4
944 0651 71 mov m,c
945 0652 21 F8 20 lxi h,X20f8
946 0655 3A 53 21 lda X2153
947 0658 BE cmp m
948 0659 C2 68 06 jnz X0668
949 065C 79 mov a,c
950 065D 32 F4 20 sta X20f4
951 0660 3A A8 21 lda X21a8
952 0663 E6 40 ani 40h
953 0665 C3 6D 06 jmp X066d
955 0668 34 X0668: inr m
956 0669 CD 36 16 call X1636
957 066C AF xra a
958 066D 32 42 21 X066d: sta X2142
959 0670 C1 X0670: pop b
960 0671 D1 pop d
961 0672 E1 pop h
962 0673 F1 X0673: pop psw
963 0674 C9 ret
965 0675 3A C4 21 X0675: lda X21c4
966 0678 B7 ora a
967 0679 C2 85 06 jnz X0685
968 067C 21 C0 20 lxi h,X20c0