Fix serial and keyboard input to be non-blocking
This commit is contained in:
+11
-5
@@ -45,8 +45,12 @@ start:
|
|||||||
call print_str_to_lcd
|
call print_str_to_lcd
|
||||||
|
|
||||||
main:
|
main:
|
||||||
call read_char_b
|
call read_char_b ; never blocks now
|
||||||
|
jr nc,check_quit ; wire is idle, go look at the keyboard
|
||||||
call parse_char
|
call parse_char
|
||||||
|
jr main ; drain the sio while it still has data
|
||||||
|
|
||||||
|
check_quit:
|
||||||
ld c,dconio ; direct console i/o, no echo
|
ld c,dconio ; direct console i/o, no echo
|
||||||
ld e,0ffh ; ff polls, returning zero if no key
|
ld e,0ffh ; ff polls, returning zero if no key
|
||||||
call bdos
|
call bdos
|
||||||
@@ -124,13 +128,15 @@ found_point:
|
|||||||
ld (hl),00h ; null terminate, discarding the rest
|
ld (hl),00h ; null terminate, discarding the rest
|
||||||
ret
|
ret
|
||||||
|
|
||||||
read_char_b:
|
read_char_b: ; carry set with the char in a, carry clear if nothing waiting
|
||||||
wait:
|
|
||||||
in a,(siob_ctrl)
|
in a,(siob_ctrl)
|
||||||
bit 0,a
|
bit 0,a
|
||||||
jr z,wait
|
jr z,no_char
|
||||||
|
|
||||||
in a,(siob_data)
|
in a,(siob_data)
|
||||||
|
scf ; flag a as a real character
|
||||||
|
ret
|
||||||
|
no_char:
|
||||||
|
or a ; clears carry, a holds status not data
|
||||||
ret
|
ret
|
||||||
|
|
||||||
parse_char: ; char should be in register a
|
parse_char: ; char should be in register a
|
||||||
|
|||||||
Reference in New Issue
Block a user