new SCNKEY can now use joystick port 1

This commit is contained in:
FeralChild64 committed 2019-10-14 19:58:59 +02:00
1 parent 677e5452a6
commit 643de3a8b7
6 files changed
+111 -24

No files matched your search

+9 -3
View File
@@ -45,6 +45,15 @@
// #define CONFIG_SID_D5XX
// Keyboard settings
// #define CONFIG_SCNKEY_TWW_CTR // XXX document this
// #define CONFIG_KEY_REPEAT // XXX document this
#define CONFIG_JOY1_CURSOR // XXX document this
#define CONFIG_JOY2_CURSOR // XXX document this
// Eye candy
// #define CONFIG_BANNER_SIMPLE
@@ -58,9 +67,6 @@
#define CONFIG_PANIC_SCREEN
#define CONFIG_DOS_WEDGE
#define CONFIG_BCD_SAFE_INTERRUPTS
// #define CONFIG_SCNKEY_TWW_CTR // XXX document this
#define CONFIG_JOY1_CURSOR // XXX document this
#define CONFIG_JOY2_CURSOR // XXX document this
// Debug options
+9 -3
View File
@@ -47,6 +47,15 @@
// #define CONFIG_SID_D5XX
// Keyboard settings
#define CONFIG_SCNKEY_TWW_CTR // XXX document this
// #define CONFIG_KEY_REPEAT // XXX document this
#define CONFIG_JOY1_CURSOR // XXX document this
#define CONFIG_JOY2_CURSOR // XXX document this
// Eye candy
// #define CONFIG_BANNER_SIMPLE
@@ -60,9 +69,6 @@
#define CONFIG_PANIC_SCREEN
#define CONFIG_DOS_WEDGE
#define CONFIG_BCD_SAFE_INTERRUPTS
#define CONFIG_SCNKEY_TWW_CTR // XXX document this
#define CONFIG_JOY1_CURSOR // XXX document this
#define CONFIG_JOY2_CURSOR // XXX document this
// Debug options
+9 -3
View File
@@ -45,6 +45,15 @@
#define CONFIG_SID_D5XX
// Keyboard settings
// #define CONFIG_SCNKEY_TWW_CTR // XXX document this
#define CONFIG_KEY_REPEAT // XXX document this
#define CONFIG_JOY1_CURSOR // XXX document this
#define CONFIG_JOY2_CURSOR // XXX document this
// Eye candy
// #define CONFIG_BANNER_SIMPLE
@@ -58,9 +67,6 @@
#define CONFIG_PANIC_SCREEN
#define CONFIG_DOS_WEDGE
#define CONFIG_BCD_SAFE_INTERRUPTS
// #define CONFIG_SCNKEY_TWW_CTR // XXX document this
#define CONFIG_JOY1_CURSOR // XXX document this
#define CONFIG_JOY2_CURSOR // XXX document this
// Debug options
+4
View File
@@ -75,9 +75,13 @@ cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start?
// Enable cursor repeat - XXX make it configurable
#if CONFIG_KEY_REPEAT
lda #$80
sta RPTFLG
#endif
// Set keyboard decode vector (Compute's Mapping the 64 p215)
#if CONFIG_SCNKEY_TWW_CTR
+38
View File
@@ -0,0 +1,38 @@
//
// Matrix for retrieving C64 joystick status and inject is as keyboard event
//
#if !CONFIG_SCNKEY_TWW_CTR && (CONFIG_JOY1_CURSOR || CONFIG_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
#endif
+42 -15
View File
@@ -23,7 +23,7 @@
// XXX add Commodore 128 keyboard support
// XXX add Commodore 65 keybopard support
// XXX add support for using joysticks to move cursor keys
// XXX fix support for joystick port 2 to move cursor keys
// XXX add support for keys which are repeated always
@@ -72,14 +72,9 @@ scnkey_bucky_loop:
jsr via_keylog // XXX for some CPUs we have indirect jsr
// Check if KEYTAB is not 0 (happens if more than one bucky key is pressed)
// High byte equal to 0 = table considered invalid
lda KEYTAB+1
beq scnkey_no_keys
#if CONFIG_JOY2_CURSOR
// XXX why this does not work???
// XXX why this does not work
// Check for control port 2 activity
@@ -92,7 +87,8 @@ scnkey_bucky_loop:
// stx CIA1_DDRA // set port back to output
// and #%00001111 // filter out anything but joystick movement
// bne scnkey_joystick_a_filtered
// cmp #%00001111
// bne scnkey_joystick_filtered
#endif
@@ -101,11 +97,17 @@ scnkey_bucky_loop:
jsr keyboard_disconnect // disconnect all the rows, .X will be $FF
cpx CIA1_PRB // only control port activity will be reported
#if CONFIG_JOY1_CURSOR
bne scnkey_joystick_x // use joystick for cursor keys
bne scnkey_joystick_1 // use joystick for cursor keys
#else
bne scnkey_no_keys // if activity detected do not scan the keyboard
#endif
// Check if KEYTAB is not 0 (happens if more than one bucky key is pressed)
// High byte equal to 0 = table considered invalid
lda KEYTAB+1
beq scnkey_no_keys
// Scan the keyboard matrix
ldy #$FF // offset in key matrix table, $FF for not found yet
@@ -159,22 +161,46 @@ scnkey_no_keys:
rts
#if CONFIG_JOY1_CURSOR || CONFIG_JOY2_CURSOR
#if CONFIG_JOY1_CURSOR
scnkey_joystick_x:
scnkey_joystick_1:
// Handle joystick activity (in .X) as cursor keys
// Prepare joystick 1 status
txa
lda CIA1_PRB
and #%00001111 // filter out anything but movement
// FALLTROUGH
scnkey_joystick_a_filtered:
#endif
// XXX finish the implementation
#if CONFIG_JOY1_CURSOR || CONFIG_JOY2_CURSOR
scnkey_joystick_filtered:
// Set appropriate keyboard matrix and key code for joystick event
ldy #$03
!:
cmp kb_matrix_joy_status, y
beq !+
dey
bpl !-
// Not found
rts
!:
// Found
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
#endif
@@ -228,6 +254,7 @@ scnkey_done:
scnkey_handle_repeat:
// Check whether we should repeat keys
// XXX always repeat SPACE, cvursors, ins/del
lda RPTFLG
bpl scnkey_done // branch if we should do no repeat