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