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
@@ -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