more work on MEGA65 native keyboard scanner
This commit is contained in:
1 parent
ddc9f10f32
commit
8c822f4464
9 files changed
+128
-22
No files matched your search
@@ -1,18 +1,20 @@
|
||||
;; #LAYOUT# M65 KERNAL_0 #TAKE-FLOAT
|
||||
;; #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT
|
||||
;; #LAYOUT# M65 KERNAL_C #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Definitions for communication with MEGA65 segment KERNAL_C from KERNAL_0
|
||||
; Definitions for communication with MEGA65 segment KERNAL_C from KERNAL_0 / KERNAL_1
|
||||
;
|
||||
|
||||
|
||||
!ifdef SEGMENT_KERNAL_0 {
|
||||
!ifndef SEGMENT_KERNAL_C {
|
||||
|
||||
; Label definitions
|
||||
|
||||
!addr VKC__m65_cursor_blink = $C000 + 2 * 0
|
||||
!addr VKC__m65_scnkey = $C000 + 2 * 1
|
||||
!addr VKC__m65_scnkey_init_keylog = $C000 + 2 * 2
|
||||
|
||||
} else {
|
||||
|
||||
@@ -20,4 +22,5 @@
|
||||
|
||||
!word m65_cursor_blink
|
||||
!word m65_scnkey
|
||||
!word m65_scnkey_init_keylog
|
||||
}
|
||||
@@ -30,6 +30,7 @@
|
||||
;; #ALIAS# screen_check_toggle_quote = KERNAL_0.screen_check_toggle_quote
|
||||
;; #ALIAS# screen_code_to_petscii = KERNAL_0.screen_code_to_petscii
|
||||
;; #ALIAS# m65_scnkey_init_pressed = KERNAL_0.m65_scnkey_init_pressed
|
||||
;; #ALIAS# scnkey_set_keytab = KERNAL_0.scnkey_set_keytab
|
||||
|
||||
;; #ALIAS# setup_irq_timer = KERNAL_0.setup_irq_timer
|
||||
;; #ALIAS# wait_x_bars = KERNAL_0.wait_x_bars
|
||||
|
||||
@@ -10,4 +10,8 @@
|
||||
;; #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
|
||||
;; #ALIAS# kb_matrix_alwaysrepeat = KERNAL_0.kb_matrix_alwaysrepeat
|
||||
;; #ALIAS# __kb_matrix_alwaysrepeat_end = KERNAL_0.__kb_matrix_alwaysrepeat_end
|
||||
|
||||
@@ -25,6 +25,13 @@ m65_mode64:
|
||||
jsr viciv_shutdown
|
||||
jsr vicii_init
|
||||
|
||||
; Restore KEYLOG
|
||||
|
||||
lda #<scnkey_set_keytab
|
||||
sta KEYLOG+0
|
||||
lda #>scnkey_set_keytab
|
||||
sta KEYLOG+1
|
||||
|
||||
; Switch CPU speed to normal
|
||||
|
||||
lda #$40
|
||||
|
||||
@@ -8,6 +8,16 @@ m65_native_meminit:
|
||||
|
||||
jsr m65_scnkey_init_pressed
|
||||
|
||||
lda VIC_CTRLA
|
||||
pha
|
||||
ora #%00100000
|
||||
sta VIC_CTRLA
|
||||
|
||||
jsr (VKC__m65_scnkey_init_keylog)
|
||||
|
||||
pla
|
||||
sta VIC_CTRLA
|
||||
|
||||
; Prepare generic DMAgic list
|
||||
|
||||
jsr m65_dmagic_init
|
||||
|
||||
@@ -406,6 +406,8 @@ scnkey_try_repeat:
|
||||
bpl @9
|
||||
bmi scnkey_done
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
scnkey_handle_repeat:
|
||||
|
||||
} ; no CONFIG_KEY_REPEAT_ALWAYS
|
||||
|
||||
@@ -19,7 +19,7 @@ m65_scnkey:
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_loop:
|
||||
m65_scnkey_fetch_loop:
|
||||
|
||||
stx $D614
|
||||
lda $D613
|
||||
@@ -28,7 +28,7 @@ m65_scnkey_loop:
|
||||
ora M65_KB_COLSUM
|
||||
sta M65_KB_COLSUM
|
||||
dex
|
||||
bpl m65_scnkey_loop
|
||||
bpl m65_scnkey_fetch_loop
|
||||
|
||||
;
|
||||
; Retrieve SHIFT / VENDOR / CTRL / ALT / NO SCROLL / CAPS LOCK status
|
||||
@@ -45,11 +45,11 @@ m65_scnkey_loop:
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_shflag_loop:
|
||||
m65_scnkey_bucky_loop:
|
||||
|
||||
inx
|
||||
asr ; ASR preserves most significant bit, but in our case it is 0
|
||||
bcc m65_scnkey_shflag_next
|
||||
bcc m65_scnkey_bucky_next
|
||||
|
||||
; Bucky key pressed
|
||||
|
||||
@@ -61,9 +61,20 @@ m65_scnkey_shflag_loop:
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_shflag_next:
|
||||
m65_scnkey_bucky_next:
|
||||
|
||||
bne m65_scnkey_shflag_loop
|
||||
bne m65_scnkey_bucky_loop
|
||||
|
||||
; Set KEYTAB vector
|
||||
|
||||
lda KEYLOG+1
|
||||
bne @1
|
||||
jsr m65_scnkey_set_keytab ; KEYLOG routine on zeropage? most likely vector not set
|
||||
bra m65_scnkey_keytab_set_done
|
||||
@1:
|
||||
jsr (KEYLOG)
|
||||
|
||||
m65_scnkey_keytab_set_done:
|
||||
|
||||
;
|
||||
; Scan the keyboard matrix stored in memory to determine which keys were pressed
|
||||
@@ -79,7 +90,7 @@ m65_scnkey_shflag_next:
|
||||
jsr m65_scnkey_init_pressed
|
||||
|
||||
lda M65_KB_COLSUM
|
||||
beq m65_scnkey_no_key ; branch if no key was pressed XXX try joystick
|
||||
+beq m65_scnkey_no_keys ; branch if no key was pressed XXX try joystick
|
||||
|
||||
ldx #$08
|
||||
|
||||
@@ -134,16 +145,29 @@ m65_scnkey_next_1:
|
||||
; XXX add proper implementation
|
||||
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
|
||||
;
|
||||
cpy LSTX
|
||||
beq m65_scnkey_try_repeat ; branch if the same key as previously
|
||||
sty LSTX
|
||||
|
||||
ldy __kb_matrix_normal, x ; XXX select matrix
|
||||
beq m65_scnkey_no_key
|
||||
; Reset key repeat counters XXX turn values into constants
|
||||
|
||||
!ifndef CONFIG_RS232_UP9600 {
|
||||
lda #$16
|
||||
} else {
|
||||
lda #$18
|
||||
}
|
||||
sta DELAY
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
@@ -164,20 +188,67 @@ m65_scnkey_output_key:
|
||||
lda #$03
|
||||
sta KOUNT
|
||||
|
||||
; Retrieve the PETSCII code
|
||||
|
||||
lda (KEYTAB), y
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_got_petscii:
|
||||
|
||||
; Put the key into the keyboard buffer
|
||||
|
||||
tya
|
||||
beq m65_scnkey_no_keys ; branch if we have no PETSCII code for this key
|
||||
ldy NDX
|
||||
sta KEYD, y
|
||||
inc NDX
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_done:
|
||||
|
||||
rts
|
||||
|
||||
m65_scnkey_try_repeat:
|
||||
|
||||
; XXX
|
||||
!ifndef CONFIG_KEY_REPEAT_ALWAYS {
|
||||
|
||||
; Check whether we should repeat keys - first the flag, afterwards hardcoded list
|
||||
|
||||
lda RPTFLG
|
||||
bmi m65_scnkey_handle_repeat ; branch if we should repeat always
|
||||
|
||||
tya
|
||||
ldx #(__kb_matrix_alwaysrepeat_end - kb_matrix_alwaysrepeat - 1)
|
||||
@1:
|
||||
cmp kb_matrix_alwaysrepeat, x
|
||||
beq m65_scnkey_handle_repeat
|
||||
dex
|
||||
bpl @1
|
||||
bmi m65_scnkey_done
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_handle_repeat:
|
||||
|
||||
} ; no CONFIG_KEY_REPEAT_ALWAYS
|
||||
|
||||
; Countdown before first repeat
|
||||
|
||||
lda DELAY
|
||||
beq @1
|
||||
dec DELAY
|
||||
|
||||
rts
|
||||
@1:
|
||||
; Countdown before subsequent repeats
|
||||
|
||||
lda KOUNT
|
||||
beq m65_scnkey_output_key ; if second counter is also 0, we can repeat the key
|
||||
dec KOUNT
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -189,12 +260,8 @@ m65_scnkey_jam:
|
||||
|
||||
jmp m65_scnkey_init_pressed
|
||||
|
||||
m65_scnkey_no_key:
|
||||
m65_scnkey_no_keys:
|
||||
|
||||
; XXX
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
m65_scnkey_is_new:
|
||||
@@ -0,0 +1,12 @@
|
||||
;; #LAYOUT# M65 KERNAL_C #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
m65_scnkey_init_keylog:
|
||||
|
||||
lda #<m65_scnkey_set_keytab
|
||||
sta KEYLOG+0
|
||||
lda #>m65_scnkey_set_keytab
|
||||
sta KEYLOG+1
|
||||
|
||||
rts
|
||||
File renamed without changes.
Reference in new issue
Block a user