added joystick support to MEGA65 keyboard scanner
This commit is contained in:
1 parent
05f57201ba
commit
5c8ac04083
5 files changed
+77
-11
No files matched your search
@@ -60,10 +60,10 @@
|
||||
!addr M65_KB_PRESSED_OLD = $563 ; $563-$565 keys pressed during previous scan
|
||||
!addr M65_KB_PRESSED_NEW = $566 ; $566-$568 set of M65_KB_PRESSED minus M65_KB_PRESSED_OLD
|
||||
!addr M65_JOYCRSR = $569 ; joystick to be used for cursor movement
|
||||
; $56A-$5EB -- UNUSED --
|
||||
!addr M65_DMAGIC_LIST = $5F1 ; $5EF-$5FF reserved for DMAgic list, 15 bytes (modulo bytes are not needed)
|
||||
!addr M65_RS232_INBUF = $600 ; $600-$6FF -- reserved for RS-232 input buffer --
|
||||
!addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer --
|
||||
; $56A-$5EB -- UNUSED --
|
||||
!addr M65_DMAGIC_LIST = $5F1 ; $5EF-$5FF reserved for DMAgic list, 15 bytes (modulo bytes are not needed)
|
||||
!addr M65_RS232_INBUF = $600 ; $600-$6FF -- reserved for RS-232 input buffer --
|
||||
!addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer --
|
||||
|
||||
;
|
||||
; Addresses for configuring the DMA job
|
||||
|
||||
@@ -13,4 +13,5 @@
|
||||
|
||||
;; #ALIAS# kb_matrix_alwaysrepeat = KERNAL_0.kb_matrix_alwaysrepeat
|
||||
;; #ALIAS# __kb_matrix_alwaysrepeat_end = KERNAL_0.__kb_matrix_alwaysrepeat_end
|
||||
|
||||
;; #ALIAS# kb_matrix_joy_status = KERNAL_0.kb_matrix_joy_status
|
||||
;; #ALIAS# kb_matrix_joy_keytab_idx = KERNAL_0.kb_matrix_joy_status
|
||||
@@ -259,7 +259,7 @@ scnkey_joystick_1:
|
||||
|
||||
scnkey_joystick_filtered:
|
||||
|
||||
; Set appropriate keyboard matrix and key code for joystick event
|
||||
; Decode joystick event using appropriate matrix
|
||||
|
||||
ldy #$03
|
||||
@5:
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
;; #LAYOUT# M65 KERNAL_C #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Matrix for retrieving C64 joystick status and inject is as keyboard event
|
||||
;
|
||||
|
||||
!ifndef CONFIG_JOY1_OR_JOY2_CURSOR {
|
||||
|
||||
kb_matrix_joy_status:
|
||||
|
||||
!byte %00001110 ; up
|
||||
!byte %00001101 ; down
|
||||
!byte %00001011 ; left
|
||||
!byte %00000111 ; right
|
||||
|
||||
kb_matrix_joy_keytab_idx:
|
||||
|
||||
!byte $07 ; up
|
||||
!byte $07 ; down
|
||||
!byte $02 ; left
|
||||
!byte $02 ; right
|
||||
}
|
||||
|
||||
kb_matrix_joy_keytab_lo:
|
||||
|
||||
!byte <__kb_matrix_shift ; up
|
||||
!byte <__kb_matrix_normal ; down
|
||||
!byte <__kb_matrix_shift ; left
|
||||
!byte <__kb_matrix_normal ; right
|
||||
|
||||
kb_matrix_joy_keytab_hi:
|
||||
|
||||
!byte >__kb_matrix_shift ; up
|
||||
!byte >__kb_matrix_normal ; down
|
||||
!byte >__kb_matrix_shift ; left
|
||||
!byte >__kb_matrix_normal ; right
|
||||
@@ -192,18 +192,46 @@ m65_scnkey_try_joystick:
|
||||
|
||||
m65_scnkey_try_joy1:
|
||||
|
||||
+nop
|
||||
; XXX provide implementation
|
||||
lda #$FF
|
||||
sta CIA1_PRA ; disconnect all the rows to prevent keyboard interference
|
||||
|
||||
lda CIA1_PRB
|
||||
bra m65_scnkey_try_joy_common
|
||||
|
||||
m65_scnkey_try_joy2:
|
||||
|
||||
+nop
|
||||
; XXX provide implementation
|
||||
lda CIA1_PRA
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_try_joy_common:
|
||||
|
||||
; XXX provide implementation
|
||||
and #%00001111 ; filter out anything but joystick movement
|
||||
beq m65_scnkey_no_keys ; branch if no joystick movement detected
|
||||
|
||||
; Decode joystick event using appropriate matrix
|
||||
|
||||
ldy #$03
|
||||
@1:
|
||||
cmp kb_matrix_joy_status, y
|
||||
beq @2
|
||||
dey
|
||||
bpl @1
|
||||
|
||||
; Not found
|
||||
|
||||
bra m65_scnkey_no_keys
|
||||
@2:
|
||||
; Found joystick movement
|
||||
|
||||
lda kb_matrix_joy_keytab_lo, y
|
||||
sta KEYTAB+0
|
||||
lda kb_matrix_joy_keytab_hi, y
|
||||
sta KEYTAB+1
|
||||
lda kb_matrix_joy_keytab_idx, y
|
||||
tay
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_got_key: ; .Y should now contain the key offset in matrix pointed by KEYTAB
|
||||
|
||||
|
||||
Reference in new issue
Block a user