Skip to content

Commit

Permalink
Console Takeover Improvements, Issue #485
Browse files Browse the repository at this point in the history
Thanks and credit to @skullandbones for pointing out multiple deficiencies in the console takeover algorithm.  In this commit:
- All char units are flushed when a new RomLdr prompt is emitted.
- Intervening non-space characters will now prevent console takeover.  Console takeover requires two consecutive space characters on the same character unit with no intervening non-space characters on the same unit or any intervening characters on an alternate unit.
  • Loading branch information
wwarthen committed Dec 23, 2024
1 parent f976ede commit 5544275
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
61 changes: 52 additions & 9 deletions Source/HBIOS/romldr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,12 @@ prompt:
call dsky_l2on
#endif
;
; purge any garbage on the line
call delay ; wait for prompt to be sent
ld b,0 ; failsafe max iterations
purge:
call cst ; anything there?
jr z,wtkey ; if not, move on
call cin ; read and discard
djnz purge ; and loop till no more
call delay ; wait for prompt to be sent?
;
#if (BIOS == BIOS_WBW)
;
call flush ; flush all char units
;
#if (AUTOCON)
or $ff ; initial value
ld (conpend),a ; ... for conpoll routine
Expand Down Expand Up @@ -459,6 +455,46 @@ clrbuf1:
ret
;
;=======================================================================
; Flush queued data from all character units
;=======================================================================
;
; Prior to starting to poll for a console takeover request, we clean
; out pending data from all character units. The active console
; is included.
;
#if (BIOS == BIOS_WBW)
;
flush:
ld a,(curcon) ; get active console unit
push af ; save it
ld c,0 ; char unit index
;
flush1:
ld b,0 ; loop max failsafe counter
ld a,c ; put char unit in A
ld (curcon),a ; and then make it cur con
;
flush2:
call cst ; char waiting?
jr z,flush3 ; all done, do next unit
call cin ; get and discard char
djnz flush2 ; loop max times
;
flush3:
inc c ; next char unit
ld a,(ciocnt) ; get char unit count
cp c ; unit > cnt?
jr c,flush_z ; done
jr flush1 ; otherwise, do next char unit
;
flush_z:
pop af ; recover active console unit
ld (curcon),a ; and reset to original value
ret ; done
;
#endif
;
;=======================================================================
; Poll character units for console takeover request
;=======================================================================
;
Expand Down Expand Up @@ -490,8 +526,15 @@ conpoll1:
jr z,conpoll2 ; if no char, move on
call cin ; get char
cp ' ' ; space char?
jr nz,conpoll2 ; if not, move on
jr z,conpoll1a ; if so, handle it
;
; something other than a <space> was received, clear
; the pending console
or $ff ; idle value
ld (conpend),a ; save it
jr conpoll2 ; continue checking
;
conpoll1a:
; a <space> char was typed. check to see if we just saw a
; <space> from this same unit.
ld a,(conpend) ; pending con unit to A
Expand Down
2 changes: 1 addition & 1 deletion Source/ver.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#DEFINE RMN 5
#DEFINE RUP 0
#DEFINE RTP 0
#DEFINE BIOSVER "3.5.0-dev.101"
#DEFINE BIOSVER "3.5.0-dev.102"
#define rmj RMJ
#define rmn RMN
#define rup RUP
Expand Down
2 changes: 1 addition & 1 deletion Source/ver.lib
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ rmn equ 5
rup equ 0
rtp equ 0
biosver macro
db "3.5.0-dev.101"
db "3.5.0-dev.102"
endm

0 comments on commit 5544275

Please sign in to comment.