@ -175,6 +175,21 @@ start1:
# endif
;
# if ( BIOS = = BIOS_WBW )
; Get the current console unit
ld b , BF_SYSPEEK ; HBIOS func: POKE
ld d , BID_BIOS ; BIOS bank
ld hl , HCB_LOC + HCB_CONDEV ; Con unit num in HCB
rst 08 ; do it
ld a , e ; put in A
ld ( curcon ), a ; save it
;
; Get character unit count
ld b , BF_SYSGET ; HBIOS func: SYS GET
ld c , BF_SYSGET_CIOCNT ; HBIOS subfunc: CIO unit count
rst 08 ; E := unit count
ld a , e ; put in A
ld ( ciocnt ), a ; save it
;
; Check for DSKY and set flag
ld b , BF_SYSGET ; HBIOS func: get
ld c , BF_SYSGET_DSKYCNT ; get DSKY count
@ -261,6 +276,13 @@ wtkey:
jp nz , ds kycmd ; if pending, do DSKY command
# endif
;
# if ( BIOS = = BIOS_WBW )
# if ( AUTOCON )
call conpoll ; poll for console takeover
jp nz , docon ; if requested, takeover
# endif
# endif
;
# if ( BOOT_TIMEOUT ! = - 1 )
; check for timeout and handle auto boot here
ld a ,( acmd_act ) ; get auto cmd active flag
@ -293,6 +315,62 @@ clrbuf1:
ret
;
;=======================================================================
; Poll character units for console takeover request
;=======================================================================
;
; Poll all character units in system for a console takeover request.
; A takeover request is just pressing <space> at the port that wants
; to takeover. Return with ZF set if a console takeover was requested.
; If so, the requested console unit will be recorded in (newcon).
;
# if ( BIOS = = BIOS_WBW )
# if ( AUTOCON )
;
conpoll:
; save active console unit
ld a ,( curcon )
;ld (savcon),a
ld e , a ; save in E
;
; loop through all char ports
ld a ,( ciocnt ) ; count of char units
ld b , a ; use for loop counter
ld c , 0 ; init unit num
;
conpoll1:
ld a , c ; next char unit to test
cp e ; is this the active console?
jr z , conpoll2 ; if so, don't test, move on
ld ( curcon ), a ; make it current port
call cs t ; char waiting?
jr z , conpoll2 ; if no char, move on
call cin ; get char
cp ' ' ; space char?
jr nz , conpoll2 ; if not, move on
jr conpoll3 ; space char typed, take console
;
conpoll2:
inc c ; next char unit
djnz conpoll1 ; loop till done
xor a ; ret w/ Z for no takeover
jr conpoll4 ; all done, no takeover
;
conpoll3:
; record a new console request
ld a ,( curcon ) ; record the unit
ld ( newcon ), a ; ... as new console
or $ ff ; ret w/ NZ for new con req
;
conpoll4:
; restore active console and exit
ld a , e ; restore active
ld ( curcon ), a ; ... console
ret ; done, NZ if new con request
;
# endif
# endif
;
;=======================================================================
; Process a command line from buffer
;=======================================================================
;
@ -625,14 +703,8 @@ setcon:
jp c , err_nocon ; handle overflow error
;
; Check against max char unit
push de
push af ; save requested unit
ld b , BF_SYSGET ; HBIOS func: SYS GET
ld c , BF_SYSGET_CIOCNT ; HBIOS subfunc: CIO unit count
rst 08 ; E := unit count
pop af ; restore requested unit
cp e ; compare
pop de
ld hl , ciocnt
cp ( hl )
jp nc , err_nocon ; handle invalid unit
ld ( newcon ), a ; save validated console
;
@ -716,6 +788,7 @@ docon: ld hl,str_newcon ; new console msg
call prtdecb ; print unit num
;
; Set console unit
ld ( curcon ), a ; update loader console unit
ld b , BF_SYSPOKE ; HBIOS func: POKE
ld d , BID_BIOS ; BIOS bank
ld e , a ; Char unit value
@ -1864,7 +1937,8 @@ cout:
;
; Output character to console via HBIOS
ld e , a ; output char to E
ld c , CIO_CONSOLE ; console unit to C
ld a ,( curcon ) ; get current console
ld c , a ; console unit to C
ld b , BF_CIOOUT ; HBIOS func: output char
rst 08 ; HBIOS outputs character
;
@ -1884,7 +1958,8 @@ cin:
push hl
;
; Input character from console via hbios
ld c , CIO_CONSOLE ; console unit to c
ld a ,( curcon ) ; get current console
ld c , a ; console unit to C
ld b , BF_CIOIN ; HBIOS func: input char
rst 08 ; HBIOS reads character
ld a , e ; move character to A for return
@ -1904,7 +1979,8 @@ cst:
push hl
;
; Get console input status via HBIOS
ld c , CIO_CONSOLE ; console unit to C
ld a ,( curcon ) ; get current console
ld c , a ; console unit to C
ld b , BF_CIOIST ; HBIOS func: input status
rst 08 ; HBIOS returns status in A
;
@ -2417,6 +2493,13 @@ loadcnt .db 0 ; num disk sectors to load
switches .db 0 ; front panel switches
diskcnt .db 0 ; disk unit count value
dskyact .db 0 ; DSKY active if != 0
;
# if ( BIOS = = BIOS_WBW )
curcon .db CIO_CONSOLE ; current console unit
ciocnt .db 1 ; count of char units
savcon .db 0 ; con save for conpoll
# endif
;
;=======================================================================
; Pad remainder of ROM Loader