shell: improve reliability

Make ASCII_BS (sent when driven through kbd) make the same thing as
ASCII_DEL. Also, don't crash on filling the buffer.
This commit is contained in:
Virgil Dupras 2019-06-30 13:25:14 -04:00
parent ad31c7f7f5
commit b7cda6ed14
1 changed files with 5 additions and 3 deletions

View File

@ -87,6 +87,8 @@ shellLoop:
jr z, .do ; char is LF? do!
cp ASCII_DEL
jr z, .delchr
cp ASCII_BS
jr z, .delchr
; Echo the received character right away so that we see what we type
call stdioPutC
@ -98,8 +100,9 @@ shellLoop:
xor a ; look for null
call findchar ; HL points to where we need to write
; A is the number of chars in the buf
cp SHELL_BUFSIZE
jr z, .do ; A == bufsize? then our buffer is full. do!
cp SHELL_BUFSIZE-1 ; -1 is because we always want to keep our
; last char at zero.
jr z, .do ; end of buffer reached? buffer is full. do!
; bring the char back in A
ex af, af'
@ -124,7 +127,6 @@ shellLoop:
ld hl, .prompt
call printstr
jr shellLoop
; no ret because we never return
.prompt:
.db "> ", 0