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) { if(type==DataType.UNDEFINED) {
@Suppress("LeakingThis") @Suppress("LeakingThis")
when(this) { when(this) {
is PtBuiltinFunctionCall -> {} is PtBuiltinFunctionCall -> { /* void function call */ }
is PtFunctionCall -> {} is PtFunctionCall -> { /* void function call */ }
is PtIdentifier -> {} is PtIdentifier -> { /* non-variable identifier */ }
else -> throw IllegalArgumentException("type should be known @$position") else -> throw IllegalArgumentException("type should be known @$position")
} }
} }

View File

@@ -98,7 +98,7 @@ cx16 {
&uword ISTOP = $0328 &uword ISTOP = $0328
&uword IGETIN = $032a &uword IGETIN = $032a
&uword ICLALL = $032c &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 ILOAD = $0330
&uword ISAVE = $0332 &uword ISAVE = $0332
&uword NMI_VEC = $FFFA ; 65c02 nmi vector, determined by the kernal if banked in &uword NMI_VEC = $FFFA ; 65c02 nmi vector, determined by the kernal if banked in

View File

@@ -6,7 +6,7 @@ main {
sub start() { 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() sys.set_irqd()
uword old_keyhdl = cx16.KEYHDL uword old_keyhdl = cx16.KEYHDL
@@ -22,7 +22,7 @@ main {
sys.clear_irqd() 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.print_ubhex(prefix, true)
txt.chrout(':') txt.chrout(':')
txt.print_ubhex(scancode, true) txt.print_ubhex(scancode, true)
@@ -36,7 +36,7 @@ main {
; escape was pressed! exit back to basic ; escape was pressed! exit back to basic
main.start.escape_pressed = true main.start.escape_pressed = true
} }
return return true ; true = consume key event, false = continue processing it
asm_shim: asm_shim:
%asm {{ %asm {{
@@ -49,8 +49,15 @@ asm_shim:
+ stx prefix + stx prefix
sta scancode sta scancode
jsr keyboard_scancode_handler jsr keyboard_scancode_handler
beq +
plx plx
pla pla
lda #0 ;By setting A=0 we will consume this key event
tax
plp
rts
+ plx
pla ; leave A untouched, continue processing
plp plp
rts rts
}} }}