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
71 ld hl,0000000000000000b ; assign auxiliary to nothing
74 ld hl,0000000000000000b ; assign printer to nothing
80 ; Return address of character device table
89 ; Console Output. Send character in <C>
90 ; to all selected devices
94 ld hl,(@covec) ; fetch console output bit vector
99 ; Auxiliary Output. Send character in <C>
100 ; to all selected devices
104 ld hl,(@aovec) ; fetch aux output bit vector
109 ; List Output. Send character in <C>
110 ; to all selected devices.
114 ld hl,(@lovec) ; fetch list output bit vector
117 ld b,0 ; start with device 0
119 add hl,hl ; shift out next bit
121 push hl ; save the vector
122 push bc ; save the count and character
123 call ?co ; if device selected, print it
124 pop bc ; recover count and character
125 pop hl ; recover the rest of the vector
127 inc b ; next device number
129 or l ; see if any devices left
130 jr nz,co$next ; and go find them...
135 ; Console Output Status. Return true if
136 ; all selected console output devices
141 ld hl,(@covec) ; get console output bit vector
146 ; Auxiliary Output Status. Return true if
147 ; all selected auxiliary output devices
152 ld hl,(@aovec) ; get aux output bit vector
157 ; List Output Status. Return true if
158 ; all selected list output devices
163 ld hl,(@lovec) ; get list output bit vector
166 ld b,0 ; start with device 0
168 add hl,hl ; check next bit
169 push hl ; save the vector
170 push bc ; save the count
171 ld a,0FFh ; assume device ready
172 call c,coster ; check status for this device
173 pop bc ; recover count
174 pop hl ; recover bit vector
175 or a ; see if device ready
176 ret z ; if any not ready, return false
177 inc b ; drop device number
179 or l ; see if any more selected devices
181 or 0FFh ; all selected were ready, return true
184 coster: ; check for output device ready, including optional
187 ;TODO: interrupt driven devices should xon/xoff handle
191 ld h,0 ; make device code 16 bits
192 push hl ; save it in stack
195 add hl,hl ; create offset into device characteristics tbl
197 add hl,de ; make address of mode byte
200 pop hl ; recover console number in <HL>
201 jp z,?cost ; not a xon device, go get output status direct
203 add hl,de ; make pointer to proper xon/xoff flag
204 call cist1 ; see if this keyboard has character
206 call nz,ci1 ; get flag or read key if any
208 jr nz,not$q ; if its a ctl-Q,
209 ld a,0FFh ; set the flag ready
212 jr nz,not$s ; if its a ctl-S,
213 ld a,00h ; clear the flag
215 ld (hl),a ; save the flag
216 call cost1 ; get the actual output status,
217 and (hl) ; and mask with ctl-Q/ctl-S flag
218 ret ; return this as the status
220 cist1: ; get input status with <BC> and <HL> saved
229 cost1: ; get output status, saving <BC> & <HL>
238 ci1: ; get input, saving <BC> & <HL>
248 ; Auxiliary Input Status. Return true if
249 ; any selected auxiliary input device
250 ; has an available character.
253 ld hl,(@aivec) ; get aux input bit vector
258 ; Console Input Status. Return true if
259 ; any selected console input device
260 ; has an available character.
263 ld hl,(@civec) ; get console input bit vector
267 ld b,0 ; start with device 0
269 add hl,hl ; check next bit
270 ld a,0 ; assume device not ready
271 call c,cist1 ; check status for this device
273 ret nz ; if any ready, return true
274 inc b ; next device number
276 or l ; see if any more selected devices
278 xor a ; all selected were not ready, return false
283 ; Auxiliary Input. Return character from first
284 ; ready auxiliary input device.
292 ; Console Input. Return character from first
293 ; ready console input device.
299 push hl ; save bit vector
302 add hl,hl ; shift out next bit
303 ld a,0 ; insure zero a (nonexistant device not ready).
304 call c,cist1 ; see if the device has a character
306 jr nz,ci$rdy ; this device has a character
307 inc b ; else, next device
309 or l ; see if any more devices
310 jr nz,ci$next ; go look at them
311 pop hl ; recover bit vector
312 jr in$scan ; loop til we find a character
314 pop hl ; discard extra stack
320 db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero
321 db -1,-1,-1,-1,-1,-1,-1,-1