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
|
||||
|
||||
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
|
||||
jr main ; drain the sio while it still has data
|
||||
|
||||
check_quit:
|
||||
ld c,dconio ; direct console i/o, no echo
|
||||
ld e,0ffh ; ff polls, returning zero if no key
|
||||
call bdos
|
||||
@@ -124,13 +128,15 @@ found_point:
|
||||
ld (hl),00h ; null terminate, discarding the rest
|
||||
ret
|
||||
|
||||
read_char_b:
|
||||
wait:
|
||||
read_char_b: ; carry set with the char in a, carry clear if nothing waiting
|
||||
in a,(siob_ctrl)
|
||||
bit 0,a
|
||||
jr z,wait
|
||||
|
||||
jr z,no_char
|
||||
in a,(siob_data)
|
||||
scf ; flag a as a real character
|
||||
ret
|
||||
no_char:
|
||||
or a ; clears carry, a holds status not data
|
||||
ret
|
||||
|
||||
parse_char: ; char should be in register a
|
||||
|
||||
Reference in New Issue
Block a user