diff --git a/src/,,config_mega65.s b/src/,,config_mega65.s index b313772b..2c129faa 100644 --- a/src/,,config_mega65.s +++ b/src/,,config_mega65.s @@ -52,7 +52,7 @@ ;; #CONFIG# JOY1_CURSOR NO ;; #CONFIG# JOY2_CURSOR NO -;; #CONFIG# M65_KB_DEV NO ; for development, keep disabled for release builds +;; #CONFIG# M65_KB_DEV NO ; for development, keep disabled for release builds ;; #CONFIG# PROGRAMMABLE_KEYS YES @@ -63,15 +63,15 @@ ;; #CONFIG# KEYCMD_F3 "@9$" ;; #CONFIG# KEYCMD_F4 "RUN:" ;; #CONFIG# KEYCMD_F5 "@10$" -;; #CONFIG# KEYCMD_F6 NO +;; #CONFIG# KEYCMD_F6 "\5FL" ;; #CONFIG# KEYCMD_F7 "@11$" -;; #CONFIG# KEYCMD_F8 NO +;; #CONFIG# KEYCMD_F8 "\5FHF" ;; #CONFIG# KEYCMD_HELP "LIST" -;; #CONFIG# KEYCMD_F9 "\5FL" +;; #CONFIG# KEYCMD_F9 "REM F9" ;; #CONFIG# KEYCMD_F10 "REM F10" -;; #CONFIG# KEYCMD_F11 "\5FH" +;; #CONFIG# KEYCMD_F11 "REM F11" ;; #CONFIG# KEYCMD_F12 "REM F12" ;; #CONFIG# KEYCMD_F13 "REM F13" ;; #CONFIG# KEYCMD_F14 "REM F14" diff --git a/src/kernal/board_m65/mega65_imports_C.s b/src/kernal/board_m65/mega65_imports_C.s index 922818f6..dc2723a1 100644 --- a/src/kernal/board_m65/mega65_imports_C.s +++ b/src/kernal/board_m65/mega65_imports_C.s @@ -9,4 +9,5 @@ ;; #ALIAS# m65_scnkey_init_pressed = KERNAL_0.m65_scnkey_init_pressed ;; #ALIAS# scnkey_buffer_full = KERNAL_0.scnkey_buffer_full +;; #ALIAS# scnkey_toggle_if_needed = KERNAL_0.scnkey_toggle_if_needed ;; #ALIAS# kb_matrix_bucky_shflag = KERNAL_0.kb_matrix_bucky_shflag diff --git a/src/kernal/keyboard/kb_matrix.s b/src/kernal/keyboard/kb_matrix.s index dfcc7a35..2405b202 100644 --- a/src/kernal/keyboard/kb_matrix.s +++ b/src/kernal/keyboard/kb_matrix.s @@ -33,6 +33,19 @@ __kb_matrix_normal: !byte $00,$09,$00,$84,$10,$16,$19,$1B } +!ifdef SEGMENT_KERNAL_C { +__kb_matrix_caps: + !byte $14,$0D,$1D,$88,$85,$86,$87,$11 + !byte $33,$77,$61,$34,$7A,$73,$65,$00 + !byte $35,$72,$64,$36,$63,$66,$74,$78 + !byte $37,$79,$67,$38,$62,$68,$75,$76 + !byte $39,$69,$6A,$30,$6D,$6B,$6F,$6E + !byte $2B,$70,$6C,$2D,$2E,$3A,$40,$2C + !byte $5C,$2A,$3B,$13,$00,$3D,$5E,$2F + !byte $31,$5F,$00,$32,$20,$00,$71,$03 + !byte $00,$09,$00,$84,$10,$16,$19,$1B +} + __kb_matrix_shift: !byte $94,$8D,$9D,$8C,$89,$8A,$8B,$91 !byte $23,$77,$61,$24,$7A,$73,$65,$00 diff --git a/src/kernal/keyboard/kb_matrix_lookup.s b/src/kernal/keyboard/kb_matrix_lookup.s index b320f0ae..22a281ef 100644 --- a/src/kernal/keyboard/kb_matrix_lookup.s +++ b/src/kernal/keyboard/kb_matrix_lookup.s @@ -1,6 +1,7 @@ ;; #LAYOUT# STD * #TAKE ;; #LAYOUT# X16 * #IGNORE ;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# M65 KERNAL_C #TAKE ;; #LAYOUT# * * #IGNORE ; @@ -15,6 +16,8 @@ kb_matrix_lookup: +!ifndef SEGMENT_KERNAL_C { + !byte (__kb_matrix_normal - kb_matrix) ; %000 Normal !byte (__kb_matrix_shift - kb_matrix) ; %001 SHIFT !byte (__kb_matrix_vendor - kb_matrix) ; %010 VENDOR @@ -23,4 +26,30 @@ kb_matrix_lookup: !byte $FF ; %101 SHIFT+CTRL !byte $FF ; %110 VENDOR+CTRL !byte $FF ; %111 SHIFT+VENDOR+CTRL -} \ No newline at end of file + +} else { + + ; MEGA65 native mode - no CAPS LOCK active + + !word __kb_matrix_normal ; %0.000 Normal + !word __kb_matrix_shift ; %0.001 SHIFT + !word __kb_matrix_vendor ; %0.010 VENDOR + !word $0000 ; %0.011 SHIFT+VENDOR + !word __kb_matrix_ctrl ; %0.100 CTRL + !word $0000 ; %0.101 SHIFT+CTRL + !word $0000 ; %0.110 VENDOR+CTRL + !word $0000 ; %0.111 SHIFT+VENDOR+CTRL + + ; MEGA65 native mode - CAPS LOCK pressed + + !word __kb_matrix_caps ; %1.000 Normal + !word __kb_matrix_shift ; %1.001 SHIFT + !word __kb_matrix_vendor ; %1.010 VENDOR + !word $0000 ; %1.011 SHIFT+VENDOR + !word __kb_matrix_ctrl ; %1.100 CTRL + !word $0000 ; %1.101 SHIFT+CTRL + !word $0000 ; %1.110 VENDOR+CTRL + !word $0000 ; %1.111 SHIFT+VENDOR+CTRL +} + +} diff --git a/src/kernal/keyboard/scnkey_set_keytab.s b/src/kernal/keyboard/scnkey_set_keytab.s index 98d90a77..1bef2873 100644 --- a/src/kernal/keyboard/scnkey_set_keytab.s +++ b/src/kernal/keyboard/scnkey_set_keytab.s @@ -21,16 +21,14 @@ scnkey_set_keytab: ; Set initial KEYTAB value - lda #kb_matrix sta KEYTAB+1 ; Calculate table index - lda SHFLAG - and #$07 ; we are only interested in SHIFT / CTRL / VENDOR keys + and #$07 ; we are interested in SHIFT, VENDOR and CTRL keys only tax ; Retrieve table offset diff --git a/src/kernal/keyboard_m65/mega65_scnkey.s b/src/kernal/keyboard_m65/mega65_scnkey.s index a3f34bef..210afe72 100644 --- a/src/kernal/keyboard_m65/mega65_scnkey.s +++ b/src/kernal/keyboard_m65/mega65_scnkey.s @@ -132,16 +132,21 @@ m65_scnkey_next_1: ; ; XXX add proper implementation - ldx M65_KB_PRESSED+0 + ldy M65_KB_PRESSED+0 + + ; FALLTROUGH + +m65_scnkey_got_key: ; .Y should now contain the key offset in matrix pointed by KEYTAB ; ; Convert the key coordinates to key code ; - ; XXX add proper implementation - ldy __kb_matrix_normal, x + ldy __kb_matrix_normal, x ; XXX select matrix beq m65_scnkey_no_key + ; FALLTROUGH + m65_scnkey_output_key: ; @@ -154,6 +159,11 @@ m65_scnkey_output_key: cmp XMAX +bcs scnkey_buffer_full + ; Reinitialize secondary counter + + lda #$03 + sta KOUNT + ; Put the key into the keyboard buffer tya diff --git a/src/kernal/keyboard_m65/mega65_scnkey_set_kaytab.s b/src/kernal/keyboard_m65/mega65_scnkey_set_kaytab.s new file mode 100644 index 00000000..2920d7d3 --- /dev/null +++ b/src/kernal/keyboard_m65/mega65_scnkey_set_kaytab.s @@ -0,0 +1,35 @@ +;; #LAYOUT# M65 KERNAL_C #TAKE +;; #LAYOUT# * * #IGNORE + +; +; MEGA65 native mode version of a well-known Kernal routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - pages 220, 221 +; + + +m65_scnkey_set_keytab: + + ; Set initial KEYTAB value + lda #kb_matrix + sta KEYTAB+1 + + ; Calculate table index + lda SHFLAG + asl ; multiply by 2 - keyboard matrix lookup table consists of words + and #$2E ; we are interested in SHIFT, VENDOR, CTRL and CAPS LOCK keys only + tax + and #$20 ; isolate CAPS LOCK bit + beq @1 + txa ; we have to move the CAPS LOCK bit (only) by one position down + and #$0E + ora #$10 + tax +@1: + + ; XXX finish the implementation + + + jmp scnkey_toggle_if_needed