Skip to content

Commit

Permalink
Merge pull request #17 from OliveIsAWord/main
Browse files Browse the repository at this point in the history
`keyboard_update` now exhausts keyboard queue
  • Loading branch information
ry755 authored Oct 9, 2024
2 parents 7a818fa + e2ed524 commit 9fcc1a8
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions keyboard.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,28 @@
; r0: non-zero if F12 was pressed, zero otherwise
keyboard_update:
; pop a key from the keyboard queue
in r0, 0x80000500
cmp r0, 0
ifz jmp keyboard_update_end
in r1, 0x80000500

; invoke the debug monitor if F12 was pressed
cmp r0, 0x58
ifz jmp keyboard_update_end
; no key event
cmp r1, 0
ifz mov r0, 0
ifz ret

; check if this is a make or break scancode
bts r0, 7
ifnz jmp keyboard_update_break_scancode
; invoke the debug monitor if F12 was pressed
cmp r1, 0x58
ifz mov r0, 1
ifz ret

mov r1, r0
mov r0, EVENT_TYPE_KEY_DOWN
mov r2, 0
mov r3, 0
mov r4, 0
mov r5, 0
mov r6, 0
mov r7, 0
call new_event
mov r0, 0
jmp keyboard_update_end
keyboard_update_break_scancode:
and r0, 0x7F
mov r1, r0
mov r0, EVENT_TYPE_KEY_UP
; check if this is a key up or key down scancode
bts r1, 7
ifz mov r0, EVENT_TYPE_KEY_DOWN
ifnz mov r0, EVENT_TYPE_KEY_UP
ifnz and r1, 0x7F
mov r2, 0
mov r3, 0
mov r4, 0
mov r5, 0
mov r6, 0
mov r7, 0
call new_event
mov r0, 0
keyboard_update_end:
ret
jmp keyboard_update

0 comments on commit 9fcc1a8

Please sign in to comment.