]> cloudbase.mooo.com Git - z180-stamp.git/blame - z180/bioscio.180
Adaptions for fatfs R0.13b
[z180-stamp.git] / z180 / bioscio.180
CommitLineData
30d1329e
L
1\r
2 .z80\r
3\r
4; Copyright (C), 1982\r
5; Digital Research, Inc\r
6; P.O. Box 579\r
7; Pacific Grove, CA 93950\r
8\r
9; This is the invariant portion of the modular BIOS and is\r
10; distributed as source for informational purposes only.\r
11; All desired modifications should be performed by\r
12; adding or changing externally defined modules.\r
13; This allows producing "standard" I/O modules that\r
14; can be combined to support a particular system\r
15; configuration.\r
16;\r
17; Modified for faster character I/O by Udo Munk\r
18\r
19cr equ 13\r
20lf equ 10\r
21bell equ 7\r
22ctlQ equ 'Q'-'@'\r
23ctlS equ 'S'-'@'\r
24\r
25 cseg ; GENCPM puts CSEG stuff in common memory\r
26\r
27 ; variables in system data page\r
28\r
29;; extrn @covec,@civec,@aovec,@aivec,@lovec ; I/O redirection vectors\r
30 \r
31 ; user defined character I/O routines\r
32\r
33 extrn ?ci,?co,?cist,?cost ; each take device in <B>\r
34 extrn ?cinit ; (re)initialize device in <C>\r
35 extrn @ctbl ; physical character device table\r
36\r
37\r
38 include modebaud.inc ; define mode bits\r
39\r
40\r
41 public @covec,@civec,@aovec,@aivec,@lovec ; I/O redirection vectors\r
42 public ?const,?conin,?cono,?list,?auxo,?auxi\r
43 public ?lists,?conos,?auxis,?auxos,?dvtbl,charini\r
44\r
45\r
46@CIVEC: dw 0 ; Console Input Redirection\r
47 ; Vector (word, r/w)\r
48@COVEC: dw 0 ; Console Output Redirection\r
49 ; Vector (word, r/w)\r
50@AIVEC: dw 0 ; Auxiliary Input Redirection\r
51 ; Vector (word, r/w)\r
52@AOVEC: dw 0 ; Auxiliary Output Redirection\r
53 ; Vector (word, r/w)\r
54@LOVEC: dw 0 ; List Output Redirection\r
55 ; Vector (word, r/w)\r
56\r
57\r
58charini:\r
59\r
60 ld c,15 ; initialize all 16 character devices\r
61c$init$loop:\r
62 push bc\r
63 call ?cinit\r
64 pop bc\r
65 dec c\r
66 jp p,c$init$loop\r
67\r
8df5b655 68; ld hl,1000000000000000b ; assign console to HOST\r
2fe44122 69 ld hl,0010000000000000b ; assign console to ASCI1\r
30d1329e
L
70 ld (@civec),hl\r
71 ld (@covec),hl\r
72 ld hl,0000000000000000b ; assign auxiliary to nothing\r
73 ld (@aivec),hl\r
74 ld (@aovec),hl\r
75 ld hl,0000000000000000b ; assign printer to nothing\r
76 ld (@lovec),hl\r
77 ret\r
78\r
79\r
80 ; DEVTBL\r
81 ; Return address of character device table\r
82\r
83?dvtbl:\r
84devtbl:\r
85 ld hl,@ctbl\r
86 ret\r
87\r
88\r
89 ; CONOUT\r
90 ; Console Output. Send character in <C>\r
91 ; to all selected devices\r
92\r
93?cono:\r
94conout:\r
95 ld hl,(@covec) ; fetch console output bit vector\r
96 jr out$scan\r
97\r
98\r
99 ; AUXOUT\r
100 ; Auxiliary Output. Send character in <C>\r
101 ; to all selected devices\r
102\r
103?auxo:\r
104auxout:\r
105 ld hl,(@aovec) ; fetch aux output bit vector\r
106 jr out$scan\r
107\r
108\r
109 ; LIST\r
110 ; List Output. Send character in <C>\r
111 ; to all selected devices.\r
112\r
113?list:\r
114list:\r
115 ld hl,(@lovec) ; fetch list output bit vector\r
116\r
117out$scan:\r
118 ld b,0 ; start with device 0\r
119co$next:\r
120 add hl,hl ; shift out next bit\r
121 jr nc,not$out$device\r
122 push hl ; save the vector\r
123 push bc ; save the count and character\r
124 call ?co ; if device selected, print it\r
125 pop bc ; recover count and character\r
126 pop hl ; recover the rest of the vector\r
127not$out$device:\r
128 inc b ; next device number\r
129 ld a,h\r
130 or l ; see if any devices left\r
131 jr nz,co$next ; and go find them...\r
132 ret\r
133\r
134\r
135 ; CONOST\r
136 ; Console Output Status. Return true if\r
137 ; all selected console output devices\r
138 ; are ready.\r
139\r
140?conos:\r
141conost:\r
142 ld hl,(@covec) ; get console output bit vector\r
143 jr ost$scan\r
144\r
145\r
146 ; AUXOST\r
147 ; Auxiliary Output Status. Return true if\r
148 ; all selected auxiliary output devices\r
149 ; are ready.\r
150\r
151?auxos:\r
152auxost:\r
153 ld hl,(@aovec) ; get aux output bit vector\r
154 jr ost$scan\r
155\r
156\r
157 ; LISTST\r
158 ; List Output Status. Return true if\r
159 ; all selected list output devices\r
160 ; are ready.\r
161\r
162?lists:\r
163listst:\r
164 ld hl,(@lovec) ; get list output bit vector\r
165\r
166ost$scan:\r
167 ld b,0 ; start with device 0\r
168cos$next:\r
169 add hl,hl ; check next bit\r
170 push hl ; save the vector\r
171 push bc ; save the count\r
172 ld a,0FFh ; assume device ready\r
173 call c,coster ; check status for this device\r
174 pop bc ; recover count\r
175 pop hl ; recover bit vector\r
176 or a ; see if device ready\r
177 ret z ; if any not ready, return false\r
178 inc b ; drop device number\r
179 ld a,h\r
180 or l ; see if any more selected devices\r
181 jr nz,cos$next\r
182 or 0FFh ; all selected were ready, return true\r
183 ret\r
184\r
185coster: ; check for output device ready, including optional\r
186 ; xon/xoff support\r
187 ;\r
188 ;TODO: interrupt driven devices should xon/xoff handle\r
189 ; in isv\r
190\r
191 ld l,b\r
192 ld h,0 ; make device code 16 bits\r
193 push hl ; save it in stack\r
194 add hl,hl\r
195 add hl,hl\r
196 add hl,hl ; create offset into device characteristics tbl\r
197 ld de,@ctbl+6\r
198 add hl,de ; make address of mode byte\r
199 ld a,(hl)\r
200 and mb$xon$xoff\r
201 pop hl ; recover console number in <HL>\r
202 jp z,?cost ; not a xon device, go get output status direct\r
203 ld de,xofflist\r
204 add hl,de ; make pointer to proper xon/xoff flag\r
205 call cist1 ; see if this keyboard has character\r
206 ld a,(hl)\r
207 call nz,ci1 ; get flag or read key if any\r
208 cp ctlq\r
209 jr nz,not$q ; if its a ctl-Q,\r
210 ld a,0FFh ; set the flag ready\r
211not$q:\r
212 cp ctls\r
213 jr nz,not$s ; if its a ctl-S,\r
214 ld a,00h ; clear the flag\r
215not$s:\r
216 ld (hl),a ; save the flag\r
217 call cost1 ; get the actual output status,\r
218 and (hl) ; and mask with ctl-Q/ctl-S flag\r
219 ret ; return this as the status\r
220\r
221cist1: ; get input status with <BC> and <HL> saved\r
222 push bc\r
223 push hl\r
224 call ?cist\r
225 pop hl\r
226 pop bc\r
227 or a\r
228 ret\r
229\r
230cost1: ; get output status, saving <BC> & <HL>\r
231 push bc\r
232 push hl\r
233 call ?cost\r
234 pop hl\r
235 pop bc\r
236 or a\r
237 ret\r
238\r
239ci1: ; get input, saving <BC> & <HL>\r
240 push bc\r
241 push hl\r
242 call ?ci\r
243 pop hl\r
244 pop bc\r
245 ret\r
246\r
247\r
248 ; AUXIST\r
249 ; Auxiliary Input Status. Return true if\r
250 ; any selected auxiliary input device\r
251 ; has an available character.\r
252?auxis:\r
253auxist:\r
254 ld hl,(@aivec) ; get aux input bit vector\r
255 jr ist$scan\r
256\r
257\r
258 ; CONST\r
259 ; Console Input Status. Return true if\r
260 ; any selected console input device\r
261 ; has an available character.\r
262?const:\r
263const:\r
264 ld hl,(@civec) ; get console input bit vector\r
265\r
266\r
267ist$scan:\r
268 ld b,0 ; start with device 0\r
269cis$next:\r
270 add hl,hl ; check next bit\r
271 ld a,0 ; assume device not ready\r
272 call c,cist1 ; check status for this device\r
273 or a\r
274 ret nz ; if any ready, return true\r
275 inc b ; next device number\r
276 ld a,h\r
277 or l ; see if any more selected devices\r
278 jr nz,cis$next\r
279 xor a ; all selected were not ready, return false\r
280 ret\r
281\r
282\r
283 ; AUXIN\r
284 ; Auxiliary Input. Return character from first\r
285 ; ready auxiliary input device.\r
286?auxi:\r
287auxin:\r
288 ld hl,(@aivec)\r
289 jr in$scan\r
290\r
291\r
292 ; CONIN\r
293 ; Console Input. Return character from first\r
294 ; ready console input device.\r
295?conin:\r
296conin:\r
297 ld hl,(@civec)\r
298\r
299in$scan:\r
300 push hl ; save bit vector\r
301 ld b,0\r
302ci$next:\r
303 add hl,hl ; shift out next bit\r
304 ld a,0 ; insure zero a (nonexistant device not ready).\r
305 call c,cist1 ; see if the device has a character\r
306 or a\r
307 jr nz,ci$rdy ; this device has a character\r
308 inc b ; else, next device\r
309 ld a,h\r
310 or l ; see if any more devices\r
311 jr nz,ci$next ; go look at them\r
312 pop hl ; recover bit vector\r
313 jr in$scan ; loop til we find a character\r
314ci$rdy:\r
315 pop hl ; discard extra stack\r
316 jp ?ci\r
317\r
318\r
319\r
320xofflist:\r
321 db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero\r
322 db -1,-1,-1,-1,-1,-1,-1,-1\r
323\r
324\r
325 end\r
326\r