]> cloudbase.mooo.com Git - z180-stamp.git/blame - z180/bioscio.180
Change message start token from 0x81 to 0xAE
[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
3531528e 68 ld hl,1000000000000000b ; assign console to HOST\r
30d1329e
L
69 ld (@civec),hl\r
70 ld (@covec),hl\r
71 ld hl,0000000000000000b ; assign auxiliary to nothing\r
72 ld (@aivec),hl\r
73 ld (@aovec),hl\r
74 ld hl,0000000000000000b ; assign printer to nothing\r
75 ld (@lovec),hl\r
76 ret\r
77\r
78\r
79 ; DEVTBL\r
80 ; Return address of character device table\r
81\r
82?dvtbl:\r
83devtbl:\r
84 ld hl,@ctbl\r
85 ret\r
86\r
87\r
88 ; CONOUT\r
89 ; Console Output. Send character in <C>\r
90 ; to all selected devices\r
91\r
92?cono:\r
93conout:\r
94 ld hl,(@covec) ; fetch console output bit vector\r
95 jr out$scan\r
96\r
97\r
98 ; AUXOUT\r
99 ; Auxiliary Output. Send character in <C>\r
100 ; to all selected devices\r
101\r
102?auxo:\r
103auxout:\r
104 ld hl,(@aovec) ; fetch aux output bit vector\r
105 jr out$scan\r
106\r
107\r
108 ; LIST\r
109 ; List Output. Send character in <C>\r
110 ; to all selected devices.\r
111\r
112?list:\r
113list:\r
114 ld hl,(@lovec) ; fetch list output bit vector\r
115\r
116out$scan:\r
117 ld b,0 ; start with device 0\r
118co$next:\r
119 add hl,hl ; shift out next bit\r
120 jr nc,not$out$device\r
121 push hl ; save the vector\r
122 push bc ; save the count and character\r
123 call ?co ; if device selected, print it\r
124 pop bc ; recover count and character\r
125 pop hl ; recover the rest of the vector\r
126not$out$device:\r
127 inc b ; next device number\r
128 ld a,h\r
129 or l ; see if any devices left\r
130 jr nz,co$next ; and go find them...\r
131 ret\r
132\r
133\r
134 ; CONOST\r
135 ; Console Output Status. Return true if\r
136 ; all selected console output devices\r
137 ; are ready.\r
138\r
139?conos:\r
140conost:\r
141 ld hl,(@covec) ; get console output bit vector\r
142 jr ost$scan\r
143\r
144\r
145 ; AUXOST\r
146 ; Auxiliary Output Status. Return true if\r
147 ; all selected auxiliary output devices\r
148 ; are ready.\r
149\r
150?auxos:\r
151auxost:\r
152 ld hl,(@aovec) ; get aux output bit vector\r
153 jr ost$scan\r
154\r
155\r
156 ; LISTST\r
157 ; List Output Status. Return true if\r
158 ; all selected list output devices\r
159 ; are ready.\r
160\r
161?lists:\r
162listst:\r
163 ld hl,(@lovec) ; get list output bit vector\r
164\r
165ost$scan:\r
166 ld b,0 ; start with device 0\r
167cos$next:\r
168 add hl,hl ; check next bit\r
169 push hl ; save the vector\r
170 push bc ; save the count\r
171 ld a,0FFh ; assume device ready\r
172 call c,coster ; check status for this device\r
173 pop bc ; recover count\r
174 pop hl ; recover bit vector\r
175 or a ; see if device ready\r
176 ret z ; if any not ready, return false\r
177 inc b ; drop device number\r
178 ld a,h\r
179 or l ; see if any more selected devices\r
180 jr nz,cos$next\r
181 or 0FFh ; all selected were ready, return true\r
182 ret\r
183\r
184coster: ; check for output device ready, including optional\r
185 ; xon/xoff support\r
186 ;\r
187 ;TODO: interrupt driven devices should xon/xoff handle\r
188 ; in isv\r
189\r
190 ld l,b\r
191 ld h,0 ; make device code 16 bits\r
192 push hl ; save it in stack\r
193 add hl,hl\r
194 add hl,hl\r
195 add hl,hl ; create offset into device characteristics tbl\r
196 ld de,@ctbl+6\r
197 add hl,de ; make address of mode byte\r
198 ld a,(hl)\r
199 and mb$xon$xoff\r
200 pop hl ; recover console number in <HL>\r
201 jp z,?cost ; not a xon device, go get output status direct\r
202 ld de,xofflist\r
203 add hl,de ; make pointer to proper xon/xoff flag\r
204 call cist1 ; see if this keyboard has character\r
205 ld a,(hl)\r
206 call nz,ci1 ; get flag or read key if any\r
207 cp ctlq\r
208 jr nz,not$q ; if its a ctl-Q,\r
209 ld a,0FFh ; set the flag ready\r
210not$q:\r
211 cp ctls\r
212 jr nz,not$s ; if its a ctl-S,\r
213 ld a,00h ; clear the flag\r
214not$s:\r
215 ld (hl),a ; save the flag\r
216 call cost1 ; get the actual output status,\r
217 and (hl) ; and mask with ctl-Q/ctl-S flag\r
218 ret ; return this as the status\r
219\r
220cist1: ; get input status with <BC> and <HL> saved\r
221 push bc\r
222 push hl\r
223 call ?cist\r
224 pop hl\r
225 pop bc\r
226 or a\r
227 ret\r
228\r
229cost1: ; get output status, saving <BC> & <HL>\r
230 push bc\r
231 push hl\r
232 call ?cost\r
233 pop hl\r
234 pop bc\r
235 or a\r
236 ret\r
237\r
238ci1: ; get input, saving <BC> & <HL>\r
239 push bc\r
240 push hl\r
241 call ?ci\r
242 pop hl\r
243 pop bc\r
244 ret\r
245\r
246\r
247 ; AUXIST\r
248 ; Auxiliary Input Status. Return true if\r
249 ; any selected auxiliary input device\r
250 ; has an available character.\r
251?auxis:\r
252auxist:\r
253 ld hl,(@aivec) ; get aux input bit vector\r
254 jr ist$scan\r
255\r
256\r
257 ; CONST\r
258 ; Console Input Status. Return true if\r
259 ; any selected console input device\r
260 ; has an available character.\r
261?const:\r
262const:\r
263 ld hl,(@civec) ; get console input bit vector\r
264\r
265\r
266ist$scan:\r
267 ld b,0 ; start with device 0\r
268cis$next:\r
269 add hl,hl ; check next bit\r
270 ld a,0 ; assume device not ready\r
271 call c,cist1 ; check status for this device\r
272 or a\r
273 ret nz ; if any ready, return true\r
274 inc b ; next device number\r
275 ld a,h\r
276 or l ; see if any more selected devices\r
277 jr nz,cis$next\r
278 xor a ; all selected were not ready, return false\r
279 ret\r
280\r
281\r
282 ; AUXIN\r
283 ; Auxiliary Input. Return character from first\r
284 ; ready auxiliary input device.\r
285?auxi:\r
286auxin:\r
287 ld hl,(@aivec)\r
288 jr in$scan\r
289\r
290\r
291 ; CONIN\r
292 ; Console Input. Return character from first\r
293 ; ready console input device.\r
294?conin:\r
295conin:\r
296 ld hl,(@civec)\r
297\r
298in$scan:\r
299 push hl ; save bit vector\r
300 ld b,0\r
301ci$next:\r
302 add hl,hl ; shift out next bit\r
303 ld a,0 ; insure zero a (nonexistant device not ready).\r
304 call c,cist1 ; see if the device has a character\r
305 or a\r
306 jr nz,ci$rdy ; this device has a character\r
307 inc b ; else, next device\r
308 ld a,h\r
309 or l ; see if any more devices\r
310 jr nz,ci$next ; go look at them\r
311 pop hl ; recover bit vector\r
312 jr in$scan ; loop til we find a character\r
313ci$rdy:\r
314 pop hl ; discard extra stack\r
315 jp ?ci\r
316\r
317\r
318\r
319xofflist:\r
320 db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero\r
321 db -1,-1,-1,-1,-1,-1,-1,-1\r
322\r
323\r
324 end\r
325\r