]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blob - cbios/chario.180
6b8eff1457d6dda1372b0a7d293daed1aea5ac13
[z180-stamp-cpm3.git] / cbios / chario.180
1 title 'Character I/O Module for the Modular CP/M 3 BIOS'
2 page 255
3 .z80
4
5
6
7 public ?cinit,?ci,?co,?cist,?cost
8 public @ctbl
9
10
11 extrn ff.init,ff.ist,ff.in,ff.ost,ff.out
12 extrn as0init,as0ista,as0inp,as0osta,as0out
13 extrn as1init,as1ista,as1inp,as1osta,as1out
14 extrn _b0call
15
16 include config.inc
17 include z180reg.inc
18
19 include modebaud.inc ; define mode bits and baud equates
20
21 max$devices equ 3
22
23
24 ;--------------------------------------------------------------
25 ; Init character device
26 ; c: device
27
28 cseg
29 ?cinit: ; init devices
30 b0call _cinit
31 ret
32
33 dseg
34 _cinit:
35 ld b,c
36 call vector$io
37 dw ff.init
38 dw as0init
39 dw as1init
40 dw rret
41
42
43 ;--------------------------------------------------------------
44 ; Character input
45 ; b: device
46 ; return:
47 ; a: input char
48
49 cseg
50 ?ci: ; character input
51 b0call _ci
52 ret
53
54 dseg
55 _ci:
56 call vector$io
57 dw ff.in
58 dw as0inp
59 dw as1inp
60 dw null$input
61
62 ;--------------------------------------------------------------
63 ; Input status
64 ; b: device
65 ; return:
66 ; a: 0ffh if char available, else 0
67
68 cseg
69 ?cist: ; character input
70 b0call _cist
71 ret
72
73 dseg
74 _cist: ; character input status
75 call vector$io
76 dw ff.ist
77 dw as0ista
78 dw as1ista
79 dw null$status
80
81 ;--------------------------------------------------------------
82 ; Character output
83 ; b: device
84 ; c: output char
85 ; return:
86 ; a: output char
87
88 cseg
89 ?co: ; character input
90 b0call _co
91 ret
92
93 dseg
94 _co: ; character output
95 call vector$io
96 dw ff.out
97 dw as0out
98 dw as1out
99 dw rret
100
101
102 ;--------------------------------------------------------------
103 ; Output status
104 ; b: device
105 ; return:
106 ; a: 0ffh if device ready for next output char, else 0
107
108
109 cseg
110 ?cost: ; character input
111 b0call _cost
112 ret
113
114 dseg
115 _cost: ; character output status
116 call vector$io
117 dw ff.ost
118 dw as0osta
119 dw as1osta
120 dw ret$true
121
122 ;--------------------------------------------------------------
123
124 dseg
125 vector$io:
126 pop hl
127 push de
128 ld de,max$devices ; default if
129 ld a,b ;
130 cp e ; b > max$devices
131 jr nc,exist
132 ld e,a
133 exist:
134 add hl,de
135 add hl,de
136
137 ld e,(hl)
138 inc hl
139 ld d,(hl)
140 ex de,hl
141 pop de
142 jp (hl)
143
144
145 null$input:
146 ld a,1Ah
147 rret:
148 ret
149 ret$true:
150 or 0FFh
151 ret
152
153 null$status:
154 xor a
155 ret
156
157 ;--------------------------------------------------------------
158
159 cseg
160 @ctbl:
161 db 'USB0 ' ; device 0
162 db mb$in$out
163 db baud$none
164
165 db 'ASCI0 ' ; device 1
166 db mb$in$out+mb$serial+mb$soft$baud
167 db baud$19200
168
169 db 'ASCI1 ' ; device 2
170 db mb$in$out+mb$serial+mb$soft$baud
171 db baud$134
172
173 db 0 ; table terminator
174
175
176 end