-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpmrun.asm
1703 lines (1646 loc) · 33 KB
/
cpmrun.asm
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
.org 0d1a881h-2
.db $EF,$7B
.assume ADL=1
jp main4cpmemu
.db 1
.db 16,16
.db $00,$ff,$00,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $ff,$00,$ff,$00,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $ff,$ff,$ff,$00,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $ff,$00,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.db "CP/M",0
objname4dimg:
.db $15,"CPM00000",0
objname4bdata:
.db $15,"BUF4PGIN",0
cpmappparam:
.dl 0
.dl usercpmappstart
main4cpmemu:
ld a,(cpmappparam)
ld (cpmparamk),a
ld a,mb
sub a,cpmbiosbank0pos
ld (diskdmabank),a
ld a,075h
ld (0D005A0h),a ;curXRow
ld hl,0220h
ld (0D00599h),hl
ld a,061h
ld (0D007C4h),a
ld a,00Ah
ld (0D02505h),a
ld hl,0
ld (0D007C5h),hl;
ld a,089h
ld (0D00595h),a;curRow
ld hl,objname4bdata
;call 0020320h ;_Mov9ToOP1
;call 002050Ch ;_ChkFindSym
;jp nc,main4cpmemu_2
main4cpmemu_1:
ld hl,0020000h
;call 0021338h ;_CreateVar
;ld (ptr4allocedmem+0),hl
ld bc,0010000h
add hl,bc
;ld (ptr4allocedmem+3),hl
ld hl,(ptr4allocedmem+0)
ld bc,0020000h
ld a,0
ld (disktrk+0),a
ld (disktrk+1),a
ld (disktrk+2),a
;call 0210e0h ;_MemSet
call backupcpmram_2
ld bc,010000h
ld hl,0d00000h
ld a,0
call 0210e0h ;_MemSet
ld a,(cpmappparam)
bit 0,a
call nz,cpmapploader
ld bc,biossize
ld de,0d0fa00h
ld hl,buffer4trampoline
ldir
ld hl,08000h
ld (diskdma),hl
ld a,mb
ld (diskdma+2),a
ld a,0
ld (disksec+0),a
ld (disksec+1),a
ld (disksec+2),a
call.lil bios_adl_read
and a,a
jp z,cpm00000found
ld bc,01600h
ld de,0d0dc00h
ld hl,cpm62k
ldir
ld bc,128
ld de,0d08000h
ld hl,cpmbtl
ldir
cpm00000found:
;call backupcpmram_2
ld a,0c3h
ld hl,08000h
ld (0d08080h),a
ld (0d08081h),hl
ld hl,08000h
ld (ixiybak+0),ix
ld (ixiybak+3),iy
;lplp: jr lplp
di
call saveexxreg
call _real180
call loadexxreg
;call _em180
ld ix,(ixiybak+0)
ld iy,(ixiybak+3)
notfound:
call backupcpmram
call restorecpmram_2
ld hl,objname4bdata
;call 0020320h ;_Mov9ToOP1
;call 002050Ch ;_ChkFindSym
;call 0020588h ;_DelVar
;jp 002120Ch ;_ErrCustom1
ei
ret
main4cpmemu_2:
;call 0020588h ;_DelVar
jp main4cpmemu_1
backupcpmram:
ld hl,0d00000h
ld de,(ptr4allocedmem+0)
ld bc,65536
ldir
ret
restorecpmram:
ld hl,(ptr4allocedmem+0)
ld de,0d00000h
ld bc,65536
ldir
ret
backupcpmram_2:
ld hl,0d00000h
ld de,(ptr4allocedmem+3)
ld bc,32768;65536
ldir
ret
restorecpmram_2:
ld hl,(ptr4allocedmem+3)
ld de,0d00000h
ld bc,32768;65536
ldir
ret
cpmapploader:
ld hl,(cpmappparam+3)
ld de,0d00100h
ld bc,usercpmappsize
ldir
ret
saveexxreg:
exx
ld (backregcontext+(3*0)),bc
ld (backregcontext+(3*1)),de
ld (backregcontext+(3*2)),hl
exx
ex af,af'
push hl
push af
pop hl
ld (backregcontext+(3*3)),hl
pop hl
ex af,af'
ret
loadexxreg:
ex af,af'
push hl
ld hl,(backregcontext+(3*3))
push hl
pop af
pop hl
ex af,af'
exx
ld bc,(backregcontext+(3*0))
ld de,(backregcontext+(3*1))
ld hl,(backregcontext+(3*2))
exx
ret
buffer4trampoline:
.org 0fa00H
.assume ADL=0
biosstart:
jp bgbioscalltrptoadl+(6*0)
jp bgbioscalltrptoadl+(6*1)
jp bgbioscalltrptoadl+(6*2)
jp bgbioscalltrptoadl+(6*3)
jp bgbioscalltrptoadl+(6*4)
jp bgbioscalltrptoadl+(6*5)
jp bgbioscalltrptoadl+(6*6)
jp bgbioscalltrptoadl+(6*7)
jp bgbioscalltrptoadl+(6*8)
jp bgbioscalltrptoadl+(6*9)
jp bgbioscalltrptoadl+(6*10)
jp bgbioscalltrptoadl+(6*11)
jp bgbioscalltrptoadl+(6*12)
jp bgbioscalltrptoadl+(6*13)
jp bgbioscalltrptoadl+(6*14)
jp bgbioscalltrptoadl+(6*15)
jp bgbioscalltrptoadl+(6*16)
jp bgbioscalltrptoadl+(6*17)
jp bgbioscalltrptoadl+(6*18)
jp bgbioscalltrptoadl+(6*19)
jp bgbioscalltrptoadl+(6*20)
jp bgbioscalltrptoadl+(6*21)
jp bgbioscalltrptoadl+(6*22)
jp bgbioscalltrptoadl+(6*23)
jp bgbioscalltrptoadl+(6*24)
jp bgbioscalltrptoadl+(6*25)
jp bgbioscalltrptoadl+(6*26)
jp bgbioscalltrptoadl+(6*27)
jp bgbioscalltrptoadl+(6*28)
jp bgbioscalltrptoadl+(6*29)
jp bgbioscalltrptoadl+(6*30)
jp bgbioscalltrptoadl+(6*31)
jp bgbioscalltrptoadl+(6*32)
biostrpend:
biostrpsize: .equ (biostrpend-biosstart)
dpbase:
.dw 0000h, 0000h
.dw 0000h, 0000h
.dw dirbf, dpblk
.dw chk00, all00
dpblk:
.dw 256 ;sectors per track
.db 4 ;block shift factor
.db 15 ;block mask - with block shift, sets block size to 1024
.db 0 ;null mask
.dw 1023 ;disk size-1 = number of blocks in a disk - 1
.dw 256 ;directory max = no. directory entries/disk, arbitrary
.db 240 ;alloc 0 -- need 4 bits (blocks) for 256 directory entries --
.db 0 ;alloc 1 -- no. bits = (directory max x 32)/block size
.dw 0 ;check size -- no checking, so zero
.dw 1 ;track offset -- first track for system
bgbioscalltrptoadl:
call.lil bios_adl_boot
jp (hl)
call.lil bios_adl_wboot
jp (hl)
call.lil bios_adl_const
ret
call.lil bios_adl_conin
ret
call.lil bios_adl_conout
ret
call.lil bios_adl_list
ret
call.lil bios_adl_punch
ret
call.lil bios_adl_reader
ret
call.lil bios_adl_home
ret
call.lil bios_adl_seldsk
ret
call.lil bios_adl_settrk
ret
call.lil bios_adl_setsec
ret
call.lil bios_adl_setdma
ret
call.lil bios_adl_read
ret
call.lil bios_adl_write
ret
call.lil bios_adl_listst
ret
call.lil bios_adl_sectran
ret
call.lil bios_adl_conost
ret
call.lil bios_adl_auxist
ret
call.lil bios_adl_auxost
ret
call.lil bios_adl_devtbl
ret
call.lil bios_adl_devini
ret
call.lil bios_adl_drvtbl
ret
call.lil bios_adl_multio
ret
call.lil bios_adl_flush
ret
call.lil bios_adl_move
ret
call.lil bios_adl_time
ret
call.lil bios_adl_selmem
ret
call.lil bios_adl_setbnk
ret
call.lil bios_adl_xmove
ret
call.lil bios_adl_userf
ret
call.lil bios_adl_reserv1
ret
call.lil bios_adl_reserv2
ret
track: .fill 2 ;two bytes for expansion
sector: .fill 2 ;two bytes for expansion
dmaad: .fill 2 ;direct memory address
diskno: .fill 1 ;disk number 0-15
begdat: .equ $ ;beginning of data area
dirbf: .fill 128 ;scratch directory area
all00: .fill 128 ;allocation vector 0
chk00: .fill 1 ;check vector 0
enddat: .equ $ ;end of data area
datsiz: .equ $-begdat; ;size of data area
hstbuf: .fill 256 ;buffer for host disk sector
addrbeepconf:.db 00h
biostime_vec: .equ 0fe58h
biosend:
biossize: .equ biosend-biosstart
.org buffer4trampoline+(biosend-biosstart)
.assume ADL=0
bios_z80_ttyout_:
ld b,0
out0 (0Ch),b
ld c,8
nop
nop
nop
bios_z80_ttyout__:
out0 (0Ch),a
srl a
dec c
jr nz,bios_z80_ttyout__
ld b,1
out0 (0Ch),b
ret.l
bios_z80_ttyst_:
ld a,((bios_z80_ttybuffer&0ffffh) + 1)
bit 0,a
jr nz,bios_z80_ttyst_1
ld de,1
ld hl, $FFFF - $5000
bios_z80_ttyst__:
add hl,de
jr c,bios_z80_ttyst_0
in0 b,(0Bh)
bit 0,b
jr nz,bios_z80_ttyst__
or a,a
ld b,2
nop
nop
bios_z80_ttyst___:
in0 a,(0Bh)
and a,1
or a,b
ld b,a
sla b
jr nc,bios_z80_ttyst___
nop
in0 a,(0Bh)
and a,1
or a,b
ld b,a
nop
nop
ld a,b
in0 b,(0Bh)
ld ((bios_z80_ttybuffer&0ffffh) + 0),a
ld a,1
ld ((bios_z80_ttybuffer&0ffffh) + 1),a
bios_z80_ttyst_1:
ld a,0ffh
ret.l
bios_z80_ttyst_0:
ld a,00h
ret.l
bios_z80_ttyin_:
ld a,((bios_z80_ttybuffer&0ffffh) + 1)
bit 0,a
jr z,bios_z80_ttyin__
xor a,a
ld ((bios_z80_ttybuffer&0ffffh) + 1),a
ld a,((bios_z80_ttybuffer&0ffffh) + 0)
ret.l
bios_z80_ttyin__:
in0 b,(0Bh)
bit 0,b
jr nz,bios_z80_ttyin__
or a,a
ld b,2
nop
nop
bios_z80_ttyin___:
in0 a,(0Bh)
and a,1
or a,b
ld b,a
sla b
jr nc,bios_z80_ttyin___
nop
in0 a,(0Bh)
and a,1
or a,b
ld b,a
nop
nop
ld a,b
in0 b,(0Bh)
ret.l
bios_z80_ttybuffer:
.db 0
.db 0
.assume ADL=1
bios_adl_boot:
;lplp_4_wboot: jr lplp_4_wboot
;out0 (3),a
ld a,0
ld.sis (4),a
ld a,095h
ld.sis (3),a
jp bios_adl_wboot
ret.l
bios_adl_wboot:
ld a,0
ld (disktrk+0),a
ld (disktrk+1),a
ld (disktrk+2),a
ld hl,(cpmbegin)
ld bc,(cpmsize-1)
;inc b
ld c,1
bios_adl_wboot_1:
ld (diskdma),hl
ld a,mb
ld (diskdma+2),a
ld a,c
ld (disksec+0),a
ld a,0
ld (disksec+1),a
ld (disksec+2),a
call.lil bios_adl_read
and a,a
jr nz,bios_adl_wboot_2
inc c
ld a,l
add a,080h
ld l,a
ld a,h
adc a,0
ld h,a
djnz bios_adl_wboot_1
bios_adl_wboot_2:
ld bc,(cpmsize-1)
ld c,128
mlt bc
ld hl,(cpmbegin)
add.sis hl,bc
ex de,hl
ld hl,biosstart
ld bc,biostrpsize
ldir.sis
ex de,hl
ld a,0c3h
ld.sis (0),a
ld hl,(cpmbegin);0fa03h
ld bc,(cpmsize-1)
ld c,128
mlt bc
inc bc
inc bc
inc bc
add hl,bc
ld.sis (1),hl
ld bc,(bdospos)
ld hl,(cpmbegin)
add hl,bc
ld.sis (5),a
ld.sis (6),hl
ld.sis sp,0080h
ld.sis a,(4)
ld c,a
ld a,(cpmparamk)
bit 0,a
jr nz,bios_adl_wboot_3
ld a,c
ld hl,(cpmbegin)
ret.l
bios_adl_wboot_3:
ld a,(cpmparamk)
res 0,a
ld (cpmparamk),a
ld a,0
ld.sis (05ch),a
ld.sis (06ch),a
ld.sis (080h),a
ld a,020h
ld.sis (05dh),a
ld.sis (06dh),a
ld hl,05dh
ld de,05eh
ld bc,10
ldir.sis
ld hl,06dh
ld de,06eh
ld bc,10
ldir.sis
ld hl,080h
ld de,081h
ld bc,127
ldir.sis
ld a,(cpmappparam+1)
ld c,a
ld.sis sp,0ff80h
ld hl,0fa03h
push.sis hl
ld hl,0100h
ret.l
bios_adl_const:
ld.sis a,(3)
and a,3
jr z,bios_adl_const_tty
cp a,1
jr z,bios_adl_const_crt
cp a,2
jp z,bios_adl_listst
ret.l
bios_adl_const_tty:
;ld a,0h
di
ld a,mb
ld (bios_backup_of_mbase_and_nmihndler+0),a
ld.sis hl,(0066h)
ld (bios_backup_of_mbase_and_nmihndler+1),hl
ld a, bios_z80_ttyst_ >> 16
ld mb,a
ld hl,045edh
ld.sis (0066h),hl
call.sis bios_z80_ttyst_ & 0ffffh
ld c,a
ld hl,(bios_backup_of_mbase_and_nmihndler+1)
ld.sis (0066h),hl
ld a,(bios_backup_of_mbase_and_nmihndler+0)
ld mb,a
di
ld a,c
ret.l
bios_adl_const_crt:
ld (backup4bcdehl+(3*0)),bc
ld (backup4bcdehl+(3*1)),de
ld (backup4bcdehl+(3*2)),hl
ld a,(buff4sc)
or a,a
jr nz,bios_adl_const_crt_
call loadexxreg
call backupcpmram
call restorecpmram_2
ld (ixiybak+6),ix
ld (ixiybak+9),iy
ld ix,(ixiybak+0)
ld iy,(ixiybak+3)
call 02014ch ;GetCSC
di
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
di
call saveexxreg
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ld (buff4sc),a
or a,a
jr z,bios_adl_const_crt_1
bios_adl_const_crt_:
ld a,0ffh
ret.l
bios_adl_const_crt_1:
ld a,0h
ret.l
bios_adl_conin:
ld.sis a,(3)
and a,3
jr z,bios_adl_conin_tty
cp a,1
jr z,bios_adl_conin_crt
cp a,2
jp z,bios_adl_reader
ret.l
bios_adl_conin_tty:
di
ld a,mb
ld (bios_backup_of_mbase_and_nmihndler+0),a
ld.sis hl,(0066h)
ld (bios_backup_of_mbase_and_nmihndler+1),hl
ld a, bios_z80_ttyout_ >> 16
ld mb,a
ld hl,045edh
ld.sis (0066h),hl
call.sis bios_z80_ttyin_ & 0ffffh
ld c,a
ld hl,(bios_backup_of_mbase_and_nmihndler+1)
ld.sis (0066h),hl
ld a,(bios_backup_of_mbase_and_nmihndler+0)
ld mb,a
di
ld a,c
;ld a,0h
ret.l
bios_adl_conin_crt:
ld (backup4bcdehl+(3*0)),bc
ld (backup4bcdehl+(3*1)),de
ld (backup4bcdehl+(3*2)),hl
ld a,(buff4sc)
or a,a
jp nz,bios_adl_conin_crt_1
call loadexxreg
call backupcpmram
call restorecpmram_2
ld (ixiybak+6),ix
ld (ixiybak+9),iy
ld ix,(ixiybak+0)
ld iy,(ixiybak+3)
ld a,($D00595)
ld l,a
ld h,$1A
mlt hl
or a,a
push hl
pop bc
ld a,($D00596)
ld hl,$000000
ld l,a
ld de,$D006C0
add hl,de
add hl,bc
ld a,020h
ld (hl),a
call 0208B0h ;_CursorOn
call 020D8Ch ;_GetKey
push af
call 0208A8h ;_CursorOff
cp a,0fch
jr c,bios_adl_conin_crt_notrans
bios_adl_conin_crt_transgo:
call 020e40h ;_ConvKeyToTok
pop af
ld a,e
di
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
call saveexxreg
ret.l
bios_adl_conin_crt_trans:
pop af
push af
jr bios_adl_conin_crt_transgo
bios_adl_conin_crt_notrans:
ld b,a
ld a,0
ld (buff4sc),a
ld a,b
ld hl,ascii_2_keycode
ld de,0
ld e,a
add hl,de
ld a,(hl)
or a,a
jr z,bios_adl_conin_crt_trans
pop hl
cp a,255
jp z,bios_adl_conin_crt_3
cp a,254
jp z,bios_adl_conin_crt_4
di
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
call saveexxreg
ret.l
ld a,(buff4sc)
or a,a
jr z,bios_adl_conin_crt_2
bios_adl_conin_crt_1:
ld b,a
ld a,0
ld (buff4sc),a
ld a,b
ld hl,bios_adl_ksc
ld bc,0
ld c,a
add hl,bc
ld a,(hl)
cp a,255
jr z,bios_adl_conin_crt_3
cp a,254
jp z,bios_adl_conin_crt_4
di
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_conin_crt_2_reset_alpha:
ld a,(bios_adl_conin_crt_enableshift_flg)
bit 0,a
jp nz,bios_adl_conin_crt_enableshift
bios_adl_conin_crt_2:
call loadexxreg
call backupcpmram
call restorecpmram_2
ld (ixiybak+6),ix
ld (ixiybak+9),iy
ld ix,(ixiybak+0)
ld iy,(ixiybak+3)
bios_adl_conin_crt_2_:
ld a,(bios_adl_conin_crt_enableshift_flg)
bit 0,a
jr nz,bios_adl_conin_crt_3
call 02014ch ;GetCSC
or a,a
jr z,bios_adl_conin_crt_2_
di
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
call saveexxreg
jp bios_adl_conin_crt_1
bios_adl_conin_crt_3:
call loadexxreg
call backupcpmram
call restorecpmram_2
ld (ixiybak+6),ix
ld (ixiybak+9),iy
ld ix,(ixiybak+0)
ld iy,(ixiybak+3)
bios_adl_conin_crt_3_:
call 02014ch ;GetCSC
or a,a
jr z,bios_adl_conin_crt_3_
di
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
call saveexxreg
ld hl,bios_adl_ksc_2
ld bc,0
ld c,a
add hl,bc
ld a,(hl)
cp a,255
jp z,bios_adl_conin_crt_2_reset_alpha
cp a,254
jp z,bios_adl_conin_crt_4
di
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_conin_crt_4:
call loadexxreg
call backupcpmram
call restorecpmram_2
ld (ixiybak+6),ix
ld (ixiybak+9),iy
ld ix,(ixiybak+0)
ld iy,(ixiybak+3)
bios_adl_conin_crt_4_:
call 02014ch ;GetCSC
or a,a
jr z,bios_adl_conin_crt_4_
di
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
call saveexxreg
ld hl,bios_adl_ksc_3
ld bc,0
ld c,a
add hl,bc
ld a,(hl)
cp a,255
jp z,bios_adl_conin_crt_enableshift
cp a,254
jp z,bios_adl_conin_crt_2
di
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_conin_crt_enableshift:
ld a,(bios_adl_conin_crt_enableshift_flg)
xor a,1
ld (bios_adl_conin_crt_enableshift_flg),a
ld a,0
jp bios_adl_conin_crt_2
bios_adl_conout:
ld.sis a,(3)
and a,3
jr z,bios_adl_conout_tty
cp a,1
jr z,bios_adl_conout_crt
cp a,2
jp z,bios_adl_list
;out0 (4),c
ret.l
bios_adl_conout_tty:
;ld a,c
di
ld a,mb
ld (bios_backup_of_mbase_and_nmihndler+0),a
ld.sis hl,(0066h)
ld (bios_backup_of_mbase_and_nmihndler+1),hl
ld a, bios_z80_ttyout_ >> 16
ld mb,a
ld hl,045edh
ld.sis (0066h),hl
ld a,c
call.sis bios_z80_ttyout_ & 0ffffh
ld hl,(bios_backup_of_mbase_and_nmihndler+1)
ld.sis (0066h),hl
ld a,(bios_backup_of_mbase_and_nmihndler+0)
ld mb,a
di
ret.l
bios_adl_conout_crt:
ld a,c
ld (backup4bcdehl+(3*0)),bc
ld (backup4bcdehl+(3*1)),de
ld (backup4bcdehl+(3*2)),hl
call loadexxreg
call backupcpmram
call restorecpmram_2
ld (ixiybak+6),ix
ld (ixiybak+9),iy
ld ix,(ixiybak+0)
ld iy,(ixiybak+3)
cp a,08h
jp z,bios_adl_conout_crt_bs
cp a,0ah
jp z,bios_adl_conout_crt_lf
cp a,0dh
jp z,bios_adl_conout_crt_cr
cp a,05bh
jp z,bios_adl_conout_crt_5b
cp a,0c1h
jp z,bios_adl_conout_crt_c1
bios_adl_conout_crt_show4proced:
call 0207b8h ;PutC
di
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
call saveexxreg
di
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_conout_crt_5b:
ld a,0c1h
jp bios_adl_conout_crt_show4proced
bios_adl_conout_crt_c1:
ld a,05bh
jp bios_adl_conout_crt_show4proced
bios_adl_conout_crt_bs:
ld a,(0D00596h) ;curCol
dec a
cp a,0ffh
jr z,bios_adl_conout_crt_bs_pl
ld (0D00596h),a ;curCol
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
di
call saveexxreg
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_conout_crt_bs_pl:
ld a,25
ld (0D00596h),a ;curCol
ld a,(0D00595h) ;curRow
dec a
ld (0D00595h),a ;curRow
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
di
call saveexxreg
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_conout_crt_cr:
ld a,0
ld (0D00596h),a ;curCol
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
di
call saveexxreg
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_conout_crt_lf:
;ld a,(0D00595h) ;curRow
;inc a
;ld (0D00595h),a ;curRow
;cp a,6
;jr nc,bios_adl_conout_crt_lf_skp
;ld a,6
;ld (0D00595h),a ;curRow
;ld a,25
;ld (0D00596h),a ;curCol
;ld a,32
;call 0207b8h ;PutC
call 00207F0h ;_NewLine
di
bios_adl_conout_crt_lf_skp:
ld (ixiybak+0),ix
ld (ixiybak+3),iy
ld ix,(ixiybak+6)
ld iy,(ixiybak+9)
call backupcpmram_2
call restorecpmram
di
call saveexxreg
ld bc,(backup4bcdehl+(3*0))
ld de,(backup4bcdehl+(3*1))
ld hl,(backup4bcdehl+(3*2))
ret.l
bios_adl_list:
ld.sis a,(3)
rrca
rrca
rrca
rrca
rrca
rrca
and a,3