mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 17:08:07 +11:00
kbd: give the device a little breathing room in tight loops
This commit is contained in:
parent
2c6ab08d51
commit
cd7743b3ae
@ -17,8 +17,9 @@ kbdInit:
|
|||||||
|
|
||||||
kbdGetC:
|
kbdGetC:
|
||||||
in a, (KBD_PORT)
|
in a, (KBD_PORT)
|
||||||
or a ; cp 0
|
or a
|
||||||
ret z
|
jr z, .nothing
|
||||||
|
|
||||||
; scan code not zero, maybe we have something.
|
; scan code not zero, maybe we have something.
|
||||||
; Do we need to skip it?
|
; Do we need to skip it?
|
||||||
push af ; <|
|
push af ; <|
|
||||||
@ -35,7 +36,7 @@ kbdGetC:
|
|||||||
call addHL ; |
|
call addHL ; |
|
||||||
ld a, (hl) ; |
|
ld a, (hl) ; |
|
||||||
pop hl ; <|
|
pop hl ; <|
|
||||||
or a ; cp 0
|
or a
|
||||||
jp z, unsetZ ; no code. Keep A at 0, but unset Z
|
jp z, unsetZ ; no code. Keep A at 0, but unset Z
|
||||||
; We have something!
|
; We have something!
|
||||||
cp a ; ensure Z
|
cp a ; ensure Z
|
||||||
@ -58,6 +59,18 @@ kbdGetC:
|
|||||||
xor a
|
xor a
|
||||||
ld (KBD_SKIP_NEXT), a
|
ld (KBD_SKIP_NEXT), a
|
||||||
jp unsetZ
|
jp unsetZ
|
||||||
|
.nothing:
|
||||||
|
; We have nothing. Before we go further, we'll wait a bit to give our
|
||||||
|
; device the time to "breathe". When we're in a "nothing" loop, the z80
|
||||||
|
; hammers the device really fast and continuously generates interrupts
|
||||||
|
; on it and it interferes with its other task of reading the keyboard.
|
||||||
|
push bc
|
||||||
|
ld b, 0
|
||||||
|
.wait:
|
||||||
|
nop
|
||||||
|
djnz .wait
|
||||||
|
pop bc
|
||||||
|
jp unsetZ
|
||||||
|
|
||||||
; A list of the value associated with the 0x80 possible scan codes of the set
|
; A list of the value associated with the 0x80 possible scan codes of the set
|
||||||
; 2 of the PS/2 keyboard specs. 0 means no value. That value is a character than
|
; 2 of the PS/2 keyboard specs. 0 means no value. That value is a character than
|
||||||
|
Loading…
Reference in New Issue
Block a user