collapseos/kernel/ti/kbd.asm
Virgil Dupras ca84b5dac8 recipes/ti84: first step
This was mostly lifted from my "tihello" example, but it required significant
adjustments.

This commit also introduces a font management system. A lot of fonts are
available online, but sources aren't always clear so to avoid copyright
landmines, I re-created my first 5x7 font from scratch.

As it is now, this resulting ROM gets "Collapse OS>" to be displayed on the
LCD screen. Much work still left to do.

ref #41
2019-11-07 11:52:29 -05:00

28 lines
600 B
NASM

; kbd
;
; Control TI-84+'s keyboard.
;
; *** Constants ***
.equ KBD_PORT 0x01
; *** Code ***
; Sending 0xff to the port resets the keyboard, and then we have to send groups
; we want to "listen" to, with a 0 in the group bit. Thus, to know if *any* key
; is pressed, we send 0xff to reset the keypad, then 0x00 to select all groups,
; if the result isn't 0xff, at least one key is pressed.
waitForKey:
push af
ld a, 0xff
out (KBD_PORT), a
ld a, 0x00
out (KBD_PORT), a
.loop:
in a, (KBD_PORT)
inc a ; if a was 0xff, will become 0 (z test)
jr z, .loop ; zero? nothing pressed
pop af
ret