more work on MEGA65 keyboard support
This commit is contained in:
1 parent
3a2a59837c
commit
391eb72c67
7 files changed
+141
-27
No files matched your search
@@ -29,6 +29,7 @@
|
||||
;; #ALIAS# colour_codes = KERNAL_0.colour_codes
|
||||
;; #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# setup_irq_timer = KERNAL_0.setup_irq_timer
|
||||
;; #ALIAS# wait_x_bars = KERNAL_0.wait_x_bars
|
||||
|
||||
@@ -4,11 +4,17 @@
|
||||
|
||||
m65_native_meminit:
|
||||
|
||||
; Initialize variables for keyboard scanning
|
||||
|
||||
jsr m65_scnkey_init_pressed
|
||||
|
||||
; Prepare generic DMAgic list
|
||||
|
||||
jsr m65_dmagic_init
|
||||
|
||||
;
|
||||
; Copy MEGA65 charset to target location - set size
|
||||
;
|
||||
|
||||
lda #$00
|
||||
sta M65_DMAJOB_SIZE_0
|
||||
|
||||
@@ -317,7 +317,7 @@ scnkey_output_key:
|
||||
|
||||
lda NDX
|
||||
cmp XMAX
|
||||
bcs scnkey_early_repeat ; no space in buffer
|
||||
bcs scnkey_buffer_full ; no space in buffer
|
||||
|
||||
; Reinitialize secondary counter
|
||||
|
||||
@@ -466,7 +466,7 @@ scnkey_handle_repeat:
|
||||
|
||||
rts
|
||||
|
||||
scnkey_early_repeat:
|
||||
scnkey_buffer_full:
|
||||
|
||||
; Keyboard buffer was full - at least make sure the key
|
||||
; will be repeated as soon as possible
|
||||
|
||||
@@ -61,6 +61,8 @@ scnkey_valid_offset_cont:
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
} ; no CONFIG_LEGACY_SCNKEY
|
||||
|
||||
scnkey_toggle_if_needed: ; entry for SCNKEY (TWW/CTR version)
|
||||
|
||||
; Check if we should toggle the character set
|
||||
@@ -105,7 +107,4 @@ scnkey_toggle_if_needed: ; entry for SCNKEY (TWW/CTR version)
|
||||
sta VIC_YMCSB
|
||||
@1:
|
||||
rts
|
||||
|
||||
}
|
||||
|
||||
} ; no CONFIG_LEGACY_SCNKEY
|
||||
}
|
||||
@@ -69,21 +69,116 @@ m65_scnkey_shflag_next:
|
||||
; Scan the keyboard matrix stored in memory to determine which keys were pressed
|
||||
;
|
||||
|
||||
ldx #$02
|
||||
@1:
|
||||
lda M65_KB_PRESSED, x
|
||||
sta M65_KB_PRESSED_OLD, x
|
||||
dex
|
||||
bpl @1
|
||||
|
||||
jsr m65_scnkey_init_pressed
|
||||
|
||||
lda M65_KB_COLSUM
|
||||
beq m65_scnkey_no_key ; branch if no key was pressed XXX try joystick
|
||||
|
||||
ldx #$08
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_loop_1:
|
||||
|
||||
lda M65_KB_COLSCAN, x
|
||||
pha
|
||||
ldy #$FF
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
m65_scnkey_loop_2:
|
||||
|
||||
iny
|
||||
pla
|
||||
beq m65_scnkey_next_1
|
||||
asl
|
||||
pha
|
||||
bcc m65_scnkey_loop_2
|
||||
|
||||
; Found a pressed key - add it to the list
|
||||
|
||||
lda M65_KB_PRESSED+2
|
||||
bpl m65_scnkey_jam ; branch if too many keys pressed
|
||||
lda M65_KB_PRESSED+1
|
||||
sta M65_KB_PRESSED+2
|
||||
lda M65_KB_PRESSED+0
|
||||
sta M65_KB_PRESSED+1
|
||||
|
||||
sty M65_KB_PRESSED+0
|
||||
txa
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
clc
|
||||
adc M65_KB_PRESSED+0
|
||||
sta M65_KB_PRESSED+0
|
||||
|
||||
bra m65_scnkey_loop_2
|
||||
|
||||
m65_scnkey_next_1:
|
||||
|
||||
dex
|
||||
bpl m65_scnkey_loop_1
|
||||
|
||||
;
|
||||
; Analyze currently and previously pressed keys
|
||||
;
|
||||
|
||||
; XXX add proper implementation
|
||||
ldx M65_KB_PRESSED+0
|
||||
|
||||
;
|
||||
; Convert the key coordinates to key code
|
||||
;
|
||||
|
||||
; XXX add proper implementation
|
||||
ldy __kb_matrix_normal, x
|
||||
beq m65_scnkey_no_key
|
||||
|
||||
m65_scnkey_output_key:
|
||||
|
||||
;
|
||||
; Output selected key to the keyboard buffer
|
||||
;
|
||||
|
||||
; Check if we have free space in the keyboard buffer
|
||||
|
||||
lda NDX
|
||||
cmp XMAX
|
||||
+bcs scnkey_buffer_full
|
||||
|
||||
; Put the key into the keyboard buffer
|
||||
|
||||
tya
|
||||
ldy NDX
|
||||
sta KEYD, y
|
||||
inc NDX
|
||||
|
||||
rts
|
||||
|
||||
|
||||
; XXX
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m65_scnkey_no_key:
|
||||
|
||||
|
||||
m65_scnkey_jam:
|
||||
|
||||
; XXX
|
||||
|
||||
jmp m65_scnkey_init_pressed
|
||||
|
||||
m65_scnkey_no_key:
|
||||
|
||||
; XXX
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,12 @@
|
||||
;; #LAYOUT# M65 KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
m65_scnkey_init_pressed:
|
||||
|
||||
lda #$FF
|
||||
sta M65_KB_PRESSED+0
|
||||
sta M65_KB_PRESSED+1
|
||||
sta M65_KB_PRESSED+2
|
||||
|
||||
rts
|
||||
Reference in new issue
Block a user