From 5dedf1314e270ed8a1dfd1b6fc1888cd344cf957 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 16 Oct 2019 17:47:26 +0200 Subject: [PATCH] most C128 keys work now --- c64/kernal/keyboard/kb_matrix_128.s | 10 ++++----- c64/kernal/keyboard/scnkey.s | 34 +++++++++++++++++++++++++---- c64/kernal/keyboard/scnkey_128.s | 14 ++++++------ 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/c64/kernal/keyboard/kb_matrix_128.s b/c64/kernal/keyboard/kb_matrix_128.s index 8afbef1a..40657284 100644 --- a/c64/kernal/keyboard/kb_matrix_128.s +++ b/c64/kernal/keyboard/kb_matrix_128.s @@ -12,10 +12,10 @@ kb_matrix_128: - // XXX fill-in the matrix properly!!! - .byte $41,$42,$43,$44,$45,$46,$47,$48 - .byte $51,$52,$53,$54,$55,$56,$57,$58 - .byte $61,$62,$63,$64,$65,$66,$67,$68 + .byte KEY_HELP,$38,$38,KEY_TAB_FW,$32,$34,$37,$31 + .byte KEY_ESC,$2B,$2D,$8D,$0D,$36,$39,$33 + .byte $00,$30,$2E,$91,$11,$9D,$1D,$00 + kb_matrix_128_bucky_filter: @@ -23,7 +23,7 @@ kb_matrix_128_bucky_filter: .byte %00000000 .byte %00000000 - .byte %00000000 // XXX ALT, NO_SCRL - probably here + .byte %10000001 // XXX ALT, NO_SCRL - probably here diff --git a/c64/kernal/keyboard/scnkey.s b/c64/kernal/keyboard/scnkey.s index 91698ef5..3f43cc2a 100644 --- a/c64/kernal/keyboard/scnkey.s +++ b/c64/kernal/keyboard/scnkey.s @@ -260,13 +260,39 @@ scnkey_output_key: lda #$03 sta KOUNT - // Output PETSCII code to the keyboard buffer + // Retrieve the PETSCII code + #if CONFIG_KEYBOARD_C128 - - // XXX implement C128 key matrix support here + + cpy #$40 + bcs !+ + + lda (KEYTAB), y // retrieve key code from standard matrix + jmp scnkey_got_petscii + +!: + + lda kb_matrix_128 - $40, y // retrieve key code from C128 extended matrix + cmp KEY_TAB_FW // special handling for SHIFT+TAB + bne scnkey_got_petscii + lda SHFLAG // special handling for SHIFT+TAB + and #KEY_FLAG_SHIFT + bne !+ + lda KEY_TAB_FW + bne scnkey_got_petscii // branch alWAYS +!: + lda KEY_TAB_BW + +#else + + lda (KEYTAB), y #endif - lda (KEYTAB), y + + // Output PETSCII code to the keyboard buffer + +scnkey_got_petscii: + beq scnkey_no_keys // branch if we have no PETSCII code for this key ldy NDX sta KEYD, y diff --git a/c64/kernal/keyboard/scnkey_128.s b/c64/kernal/keyboard/scnkey_128.s index e8f5a000..6763a201 100644 --- a/c64/kernal/keyboard/scnkey_128.s +++ b/c64/kernal/keyboard/scnkey_128.s @@ -17,7 +17,7 @@ scnkey_128: - sty CIA1_PRA // disconnect all the classic keys first + sty CIA1_PRA // disconnect all the classic keys first ldx #$02 scnkey_matrix_128_loop: @@ -31,18 +31,18 @@ scnkey_matrix_128_loop: bne scnkey_128_no_keys // clash, more than one key pressed // We have at least one key pressed in this row, we need to find which one exactly ldy #$07 -scnkey_matrix_128_loop_inner: // XXX try to deduplicate this with regular SCNKEY +scnkey_matrix_128_loop_inner: cmp kb_matrix_row_keys, y - bne !+ // not this particular key - tya // now .A contains key offset within a row + bne !+ // not this particular key + tya // now .A contains key offset within a row clc - adc kb_matrix_row_offsets, x // now .A contains key offset from the matrix start + adc kb_matrix_row_offsets, x // now .A contains key offset from the matrix start tay jmp scnkey_matrix_128_loop_next !: dey bpl scnkey_matrix_128_loop_inner - bmi scnkey_128_no_keys // branch always, multiple keys must have been pressed + bmi scnkey_128_no_keys // branch always, multiple keys must have been pressed scnkey_matrix_128_loop_next: dex bpl scnkey_matrix_128_loop @@ -53,7 +53,7 @@ scnkey_matrix_128_loop_next: beq scnkey_128_done // Shift the matrix code -.break + clc tya adc #$40