keyboardhandler

This commit is contained in:
Irmen de Jong 2022-08-04 23:04:16 +02:00
parent 00b717cde8
commit 197081f10d
3 changed files with 14 additions and 7 deletions

View File

@ -15,9 +15,9 @@ sealed class PtExpression(val type: DataType, position: Position) : PtNode(posit
if(type==DataType.UNDEFINED) {
@Suppress("LeakingThis")
when(this) {
is PtBuiltinFunctionCall -> {}
is PtFunctionCall -> {}
is PtIdentifier -> {}
is PtBuiltinFunctionCall -> { /* void function call */ }
is PtFunctionCall -> { /* void function call */ }
is PtIdentifier -> { /* non-variable identifier */ }
else -> throw IllegalArgumentException("type should be known @$position")
}
}

View File

@ -98,7 +98,7 @@ cx16 {
&uword ISTOP = $0328
&uword IGETIN = $032a
&uword ICLALL = $032c
&uword KEYHDL = $032e ; keyboard scan code handler
&uword KEYHDL = $032e ; keyboard scan code handler see examples/cx16/keyboardhandler.p8
&uword ILOAD = $0330
&uword ISAVE = $0332
&uword NMI_VEC = $FFFA ; 65c02 nmi vector, determined by the kernal if banked in

View File

@ -6,7 +6,7 @@ main {
sub start() {
txt.print("ps2 scancode handler test - press keys! esc to quit!\n")
txt.print("ps2 custom key handler test - press keys! esc to quit!\n")
sys.set_irqd()
uword old_keyhdl = cx16.KEYHDL
@ -22,7 +22,7 @@ main {
sys.clear_irqd()
}
sub keyboard_scancode_handler(ubyte prefix, ubyte scancode, bool updown) {
sub keyboard_scancode_handler(ubyte prefix, ubyte scancode, bool updown) -> bool {
txt.print_ubhex(prefix, true)
txt.chrout(':')
txt.print_ubhex(scancode, true)
@ -36,7 +36,7 @@ main {
; escape was pressed! exit back to basic
main.start.escape_pressed = true
}
return
return true ; true = consume key event, false = continue processing it
asm_shim:
%asm {{
@ -49,8 +49,15 @@ asm_shim:
+ stx prefix
sta scancode
jsr keyboard_scancode_handler
beq +
plx
pla
lda #0 ;By setting A=0 we will consume this key event
tax
plp
rts
+ plx
pla ; leave A untouched, continue processing
plp
rts
}}