From f37e32f856710372862869b4662d94f7710cffaf Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sat, 20 Apr 2019 02:02:45 +0930 Subject: [PATCH] stuff newly read keys into the keyboard buffer --- c64/kernal/,aliases.s | 1 + c64/kernal/keyboard_matrix.s | 23 +++++++++++++++++++++++ c64/kernal/scan_keyboard.s | 12 ++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 c64/kernal/keyboard_matrix.s diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 091864e3..17642bef 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -49,6 +49,7 @@ ; "Compute's Mapping the 64" book + .alias keyboard_buffer $0277 .alias MEMSTR $0281 .alias MEMSIZ $0283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct .alias text_colour $0286 ; p55 diff --git a/c64/kernal/keyboard_matrix.s b/c64/kernal/keyboard_matrix.s new file mode 100644 index 00000000..d252fbed --- /dev/null +++ b/c64/kernal/keyboard_matrix.s @@ -0,0 +1,23 @@ + ;; Key board matrixes: + ;; unshifted, shifted, control and C= modified + ;; 64 bytes for each + + +keyboard_matrixes: + ;; Unshifted matrix built by refering to + ;; Compute's Mapping the 64 p38-39 + ;; and C64 PRG pages 379-381 + .byte 20,13,29,136,133,134,15 + .byte $33,87,$41,$34,90,83,$45,$00 + .byte $35,$52,$44,$36,$43,$46,$54,88 + .byte $37,89,$47,$38,$42,$48,$55,$56 + .byte $39,$49,$4A,$30,$4D,$4B,$4F,$4E + .byte 43,$50,$4C,45,46,58,$40,44 + .byte $23,42,59,$13,$00,61,94,47 + .byte $31,95,$00,$32,$20,$00,$51,3 + + ;; XXX - Implement shifted + + ;; XXX - Implement control modified + + ;; XXX - Implement C= modified diff --git a/c64/kernal/scan_keyboard.s b/c64/kernal/scan_keyboard.s index 54afc1bf..244c1dd6 100644 --- a/c64/kernal/scan_keyboard.s +++ b/c64/kernal/scan_keyboard.s @@ -72,6 +72,18 @@ scan_keyboard: beq + ;; Got a key, turn it from matrix position to key value, ;; and stuff it in the keyboard buffer + + ;; Convert matrix position to key code + ;; XXX - Add offset of $40, $80 or $C0 if shift, CONTROL or C= are held down + tax + lda keyboard_matrixes,x + + ;; Stash key into keyboard buffer + ldx keys_in_key_buffer + cpx key_buffer_size + beq + + sta keyboard_buffer,x + inc keys_in_key_buffer *