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
@@ -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:
|
||||
Reference in new issue
Block a user