From 5544275e0d625ac983f84738fdd029270dd7d802 Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Mon, 23 Dec 2024 13:56:09 -0800 Subject: [PATCH] Console Takeover Improvements, Issue #485 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. --- Source/HBIOS/romldr.asm | 61 +++++++++++++++++++++++++++++++++++------ Source/ver.inc | 2 +- Source/ver.lib | 2 +- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/Source/HBIOS/romldr.asm b/Source/HBIOS/romldr.asm index 7386e798..28d2a51f 100644 --- a/Source/HBIOS/romldr.asm +++ b/Source/HBIOS/romldr.asm @@ -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 @@ -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 ;======================================================================= ; @@ -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 was received, clear + ; the pending console + or $ff ; idle value + ld (conpend),a ; save it + jr conpoll2 ; continue checking ; +conpoll1a: ; a char was typed. check to see if we just saw a ; from this same unit. ld a,(conpend) ; pending con unit to A diff --git a/Source/ver.inc b/Source/ver.inc index 9415efd4..6548fe96 100644 --- a/Source/ver.inc +++ b/Source/ver.inc @@ -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 diff --git a/Source/ver.lib b/Source/ver.lib index b8050de7..c60af165 100644 --- a/Source/ver.lib +++ b/Source/ver.lib @@ -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