5 ; Digital Research, Inc
7 ; Pacific Grove, CA 93950
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
17 ; Modified for faster character I/O by Udo Munk
25 cseg ; GENCPM puts CSEG stuff in common memory
27 ; variables in system data page
29 ;; extrn @covec,@civec,@aovec,@aivec,@lovec ; I/O redirection vectors
31 ; user defined character I/O routines
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
38 include modebaud.inc ; define mode bits
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
46 @CIVEC: dw 0 ; Console Input Redirection
48 @COVEC: dw 0 ; Console Output Redirection
50 @AIVEC: dw 0 ; Auxiliary Input Redirection
52 @AOVEC: dw 0 ; Auxiliary Output Redirection
54 @LOVEC: dw 0 ; List Output Redirection
60 ld c,15 ; initialize all 16 character devices
68 ; ld hl,1000000000000000b ; assign console to HOST
69 ld hl,0010000000000000b ; assign console to ASCI1
72 ld hl,0000000000000000b ; assign auxiliary to nothing
75 ld hl,0000000000000000b ; assign printer to nothing
81 ; Return address of character device table
90 ; Console Output. Send character in <C>
91 ; to all selected devices
95 ld hl,(@covec) ; fetch console output bit vector
100 ; Auxiliary Output. Send character in <C>
101 ; to all selected devices
105 ld hl,(@aovec) ; fetch aux output bit vector
110 ; List Output. Send character in <C>
111 ; to all selected devices.
115 ld hl,(@lovec) ; fetch list output bit vector
118 ld b,0 ; start with device 0
120 add hl,hl ; shift out next bit
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
128 inc b ; next device number
130 or l ; see if any devices left
131 jr nz,co$next ; and go find them...
136 ; Console Output Status. Return true if
137 ; all selected console output devices
142 ld hl,(@covec) ; get console output bit vector
147 ; Auxiliary Output Status. Return true if
148 ; all selected auxiliary output devices
153 ld hl,(@aovec) ; get aux output bit vector
158 ; List Output Status. Return true if
159 ; all selected list output devices
164 ld hl,(@lovec) ; get list output bit vector
167 ld b,0 ; start with device 0
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
180 or l ; see if any more selected devices
182 or 0FFh ; all selected were ready, return true
185 coster: ; check for output device ready, including optional
188 ;TODO: interrupt driven devices should xon/xoff handle
192 ld h,0 ; make device code 16 bits
193 push hl ; save it in stack
196 add hl,hl ; create offset into device characteristics tbl
198 add hl,de ; make address of mode byte
201 pop hl ; recover console number in <HL>
202 jp z,?cost ; not a xon device, go get output status direct
204 add hl,de ; make pointer to proper xon/xoff flag
205 call cist1 ; see if this keyboard has character
207 call nz,ci1 ; get flag or read key if any
209 jr nz,not$q ; if its a ctl-Q,
210 ld a,0FFh ; set the flag ready
213 jr nz,not$s ; if its a ctl-S,
214 ld a,00h ; clear the flag
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
221 cist1: ; get input status with <BC> and <HL> saved
230 cost1: ; get output status, saving <BC> & <HL>
239 ci1: ; get input, saving <BC> & <HL>
249 ; Auxiliary Input Status. Return true if
250 ; any selected auxiliary input device
251 ; has an available character.
254 ld hl,(@aivec) ; get aux input bit vector
259 ; Console Input Status. Return true if
260 ; any selected console input device
261 ; has an available character.
264 ld hl,(@civec) ; get console input bit vector
268 ld b,0 ; start with device 0
270 add hl,hl ; check next bit
271 ld a,0 ; assume device not ready
272 call c,cist1 ; check status for this device
274 ret nz ; if any ready, return true
275 inc b ; next device number
277 or l ; see if any more selected devices
279 xor a ; all selected were not ready, return false
284 ; Auxiliary Input. Return character from first
285 ; ready auxiliary input device.
293 ; Console Input. Return character from first
294 ; ready console input device.
300 push hl ; save bit vector
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
307 jr nz,ci$rdy ; this device has a character
308 inc b ; else, next device
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
315 pop hl ; discard extra stack
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