6502-OS/programs/ps2_keyboard_printer.s65

62 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2024-01-09 02:29:45 +01:00
.include "lcd.h65"
2024-08-08 20:15:50 +02:00
.include "string.h65"
2024-01-09 02:29:45 +01:00
.include "ps2_keyboard_text_handler.h65"
.export ps2_keyboard_printer
.import home:absolute
.code
2024-08-08 20:15:50 +02:00
;;********************************************************************************
;; @brief Print characters to the display when a key was pressed
;; @details
;; Print the character that corresponds to a key.
;; This uses the @ref kb "text keyboard handler" to correctly handle modifier keys
;;
;; Controls:
;; - `ESC`: Jump home
;; - `Print`: Clear the display
;; - `F12`: Restart the program
;; @ingroup applications keyboard
;;********************************************************************************
2024-01-09 02:29:45 +01:00
.proc ps2_keyboard_printer
jsr lcd::clear
jsr kb::init
2024-08-08 20:15:50 +02:00
jeq loop
ps2kb_PrintCmdFailed
; jmp homeloop
ps2kb_CmdEnable
jsr ps2kb::begin_receive
2024-01-09 02:29:45 +01:00
loop:
2024-08-08 20:15:50 +02:00
wai
; ; put shift, ralt and lalt in debug leds
; lda kb::modifier
; Reverse A
; and #%00000111
; ora IO1 + IO::RANH
; sta IO1 + IO::RANH
2024-01-09 02:29:45 +01:00
lda kb::char
beq @no_char
stz kb::char
jsr lcd::print_char
bra loop
@no_char:
lda kb::keycode
beq loop
2024-08-08 20:15:50 +02:00
stz kb::keycode
2024-01-09 02:29:45 +01:00
cmp #kb::K::ESCAPE
beq @esacpe
cmp #kb::K::PRINT
beq @clear_display
2024-08-08 20:15:50 +02:00
cmp #kb::K::F12
jeq ps2_keyboard_printer
2024-01-09 02:29:45 +01:00
bra loop
@esacpe:
jmp home
@clear_display:
jsr lcd::clear
bra loop
.endproc