Revert "more work on MEGA65 keyboard scanner"
This reverts commit 7918ef55b9.
This commit is contained in:
1 parent
7918ef55b9
commit
05dbeea181
5 files changed
+84
-108
No files matched your search
@@ -32,7 +32,6 @@
|
|||||||
!addr C65_EXTKEYS_PR = $D607
|
!addr C65_EXTKEYS_PR = $D607
|
||||||
!addr C65_EXTKEYS_DDR = $D608
|
!addr C65_EXTKEYS_DDR = $D608
|
||||||
|
|
||||||
!addr KBSCN_KEYCODE = $D610
|
|
||||||
!addr KBSCN_BUCKY = $D611
|
!addr KBSCN_BUCKY = $D611
|
||||||
!addr KBSCN_PEEK = $D613
|
!addr KBSCN_PEEK = $D613
|
||||||
!addr KBSCN_SELECT = $D614
|
!addr KBSCN_SELECT = $D614
|
||||||
|
|||||||
@@ -53,7 +53,10 @@
|
|||||||
!addr M65_TXTWIN_Y1 = $591 ; text window - bottom-right Y coordinate + 1
|
!addr M65_TXTWIN_Y1 = $591 ; text window - bottom-right Y coordinate + 1
|
||||||
!addr M65_TXTROW_OFF = $592 ; $592-$593 offset to the current text row from the viewport start
|
!addr M65_TXTROW_OFF = $592 ; $592-$593 offset to the current text row from the viewport start
|
||||||
!addr M65_SCRCOLMAX = $594 ; maximum allowed column
|
!addr M65_SCRCOLMAX = $594 ; maximum allowed column
|
||||||
; $595-$5EB -- UNUSED --
|
!addr M65_KB_BUCKY = $595 ; result of bucky keys scan
|
||||||
|
!addr M65_KB_COLSCAN = $596 ; $596-$59E results of keyboard scan, columns 0-8
|
||||||
|
|
||||||
|
; $59F-$5EB -- UNUSED --
|
||||||
!addr M65_DMAGIC_LIST = $5F1 ; $5EF-$5FF reserved for DMAgic list, 15 bytes (modulo bytes are not needed)
|
!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_INBUF = $600 ; $600-$6FF -- reserved for RS-232 input buffer --
|
||||||
!addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer --
|
!addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer --
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ scnkey_output_key:
|
|||||||
|
|
||||||
lda NDX
|
lda NDX
|
||||||
cmp XMAX
|
cmp XMAX
|
||||||
bcs scnkey_early_repeat ; branch if no free space in buffer
|
bcs scnkey_early_repeat ; no space in buffer
|
||||||
|
|
||||||
; Reinitialize secondary counter
|
; Reinitialize secondary counter
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
;; #LAYOUT# M65 KERNAL_0 #TAKE
|
|
||||||
;; #LAYOUT# * * #IGNORE
|
|
||||||
|
|
||||||
; Keyboard matrix for bucky keys decoding on MEGA65
|
|
||||||
|
|
||||||
|
|
||||||
m65_kb_matrix_bucky:
|
|
||||||
|
|
||||||
!byte KEY_FLAG_SHIFT
|
|
||||||
!byte KEY_FLAG_SHIFT
|
|
||||||
!byte KEY_FLAG_VENDOR
|
|
||||||
!byte KEY_FLAG_CTRL
|
|
||||||
!byte KEY_FLAG_ALT
|
|
||||||
!byte KEY_FLAG_NO_SCRL
|
|
||||||
!byte KEY_FLAG_CAPSL
|
|
||||||
@@ -4,120 +4,109 @@
|
|||||||
|
|
||||||
m65_scnkey:
|
m65_scnkey:
|
||||||
|
|
||||||
; Read the key from automatic scanner
|
; First scan the whole keyboard
|
||||||
|
|
||||||
lda KBSCN_BUCKY
|
lda KBSCN_BUCKY
|
||||||
ldy KBSCN_KEYCODE
|
sta M65_KB_BUCKY
|
||||||
sty KBSCN_KEYCODE
|
|
||||||
|
|
||||||
; Update the SHFLAG in a way that preserves .Y
|
ldx #$08
|
||||||
|
@1:
|
||||||
and #%01111111
|
stx KBSCN_SELECT
|
||||||
|
lda KBSCN_PEEK
|
||||||
ldx SHFLAG
|
eor #$FF ; let bit 1 mean 'pressed', not the otherwise
|
||||||
stx LSTSHF ; needed for SHIFT+VENDOR support
|
sta M65_KB_COLSCAN, x
|
||||||
|
|
||||||
ldx #$00
|
|
||||||
stx SHFLAG
|
|
||||||
dex
|
dex
|
||||||
|
bpl @1
|
||||||
|
|
||||||
|
; Update the SHFLAG
|
||||||
|
|
||||||
|
lda SHFLAG
|
||||||
|
sta LSTSHF ; needed for SHIFT+VENDOR support
|
||||||
|
|
||||||
|
ldy #$00 ; the new SHFLAG will be constructed in .Y
|
||||||
|
ldx M65_KB_BUCKY
|
||||||
|
beq m65_scnkey_SHFLAG_ready
|
||||||
|
|
||||||
; FALLTROUGH
|
; FALLTROUGH
|
||||||
|
|
||||||
m65_scnkey_SHFLAG_loop:
|
m65_scnkey_detect_SHIFT:
|
||||||
|
|
||||||
inx
|
txa
|
||||||
asr
|
and #%00000011
|
||||||
bcc m65_scnkey_SHFLAG_next
|
beq m65_scnkey_detect_VENDOR
|
||||||
|
|
||||||
; Bucky key pressed
|
|
||||||
|
|
||||||
pha
|
|
||||||
lda m65_kb_matrix_bucky, x
|
|
||||||
ora SHFLAG
|
|
||||||
sta SHFLAG
|
|
||||||
pla
|
|
||||||
|
|
||||||
; FALLTROUGH
|
|
||||||
|
|
||||||
m65_scnkey_SHFLAG_next:
|
|
||||||
|
|
||||||
bne m65_scnkey_SHFLAG_loop
|
|
||||||
|
|
||||||
; We have the key code in .Y - check if same as the last one
|
|
||||||
|
|
||||||
cpy LSTX
|
|
||||||
beq m65_scnkey_try_repeat
|
|
||||||
|
|
||||||
; Not the same key - store the key code, reset delay counter
|
|
||||||
|
|
||||||
sty LSTX
|
|
||||||
!ifndef CONFIG_RS232_UP9600 {
|
|
||||||
lda #$16
|
|
||||||
} else {
|
|
||||||
lda #$18
|
|
||||||
}
|
|
||||||
sta DELAY
|
|
||||||
|
|
||||||
; FALLTROUGH
|
|
||||||
|
|
||||||
m65_scnkey_output_key:
|
|
||||||
|
|
||||||
; Check if we have free space in the keyboard buffer
|
|
||||||
|
|
||||||
lda NDX
|
|
||||||
cmp XMAX
|
|
||||||
+bcs scnkey_early_repeat ; branch if no free space in buffer
|
|
||||||
|
|
||||||
; Reinitialize secondary counter
|
|
||||||
|
|
||||||
lda #$03
|
|
||||||
sta KOUNT
|
|
||||||
|
|
||||||
; Output PETSCII code to the keyboard buffer
|
|
||||||
|
|
||||||
m65_scnkey_got_petscii:
|
|
||||||
|
|
||||||
; XXX if no key pressed, try joysticks
|
|
||||||
|
|
||||||
tya
|
tya
|
||||||
beq m65_scnkey_done ; branch if no key was pressed
|
ora #KEY_FLAG_SHIFT
|
||||||
ldy NDX
|
tay
|
||||||
sta KEYD, y
|
|
||||||
inc NDX
|
|
||||||
|
|
||||||
; FALLTROUGH
|
; FALLTROUGH
|
||||||
|
|
||||||
m65_scnkey_done:
|
m65_scnkey_detect_VENDOR:
|
||||||
|
|
||||||
|
txa
|
||||||
|
and #%00001000
|
||||||
|
beq m65_scnkey_detect_CTRL
|
||||||
|
|
||||||
rts
|
tya
|
||||||
|
ora #KEY_FLAG_VENDOR
|
||||||
|
tay
|
||||||
|
|
||||||
m65_scnkey_try_repeat:
|
; FALLTROUGH
|
||||||
|
|
||||||
!ifndef CONFIG_KEY_REPEAT_ALWAYS {
|
m65_scnkey_detect_CTRL:
|
||||||
|
|
||||||
|
txa
|
||||||
|
and #%00000100
|
||||||
|
beq m65_scnkey_detect_ALT
|
||||||
|
|
||||||
; Check whether we should repeat keys - first the flag, afterwards hardcoded list
|
tya
|
||||||
|
ora #KEY_FLAG_CTRL
|
||||||
|
tay
|
||||||
|
|
||||||
lda RPTFLG
|
; FALLTROUGH
|
||||||
bmi m65_scnkey_handle_repeat ; branch if we should repeat always
|
|
||||||
|
|
||||||
; XXX if key to be repeated - go to m65_scnkey_handle_repeat, otherwise to m65_scnkey_done
|
m65_scnkey_detect_ALT:
|
||||||
|
|
||||||
|
txa
|
||||||
|
and #%00010000
|
||||||
|
beq m65_scnkey_detect_CAPS_LOCK
|
||||||
|
|
||||||
m65_scnkey_handle_repeat:
|
tya
|
||||||
|
ora #KEY_FLAG_ALT
|
||||||
|
tay
|
||||||
|
|
||||||
} ; no CONFIG_KEY_REPEAT_ALWAYS
|
; FALLTROUGH
|
||||||
|
|
||||||
; Countdown before first repeat
|
m65_scnkey_detect_CAPS_LOCK:
|
||||||
|
|
||||||
|
txa
|
||||||
|
and #%01000000
|
||||||
|
beq m65_scnkey_detect_NO_SCRL
|
||||||
|
|
||||||
lda DELAY
|
tya
|
||||||
beq @10
|
ora #KEY_FLAG_NO_SCRL
|
||||||
dec DELAY
|
tay
|
||||||
|
|
||||||
rts
|
; FALLTROUGH
|
||||||
@10:
|
|
||||||
; Countdown before subsequent repeats
|
m65_scnkey_detect_NO_SCRL:
|
||||||
|
|
||||||
|
txa
|
||||||
|
and #%00100000
|
||||||
|
beq m65_scnkey_SHFLAG_ready
|
||||||
|
|
||||||
|
tya
|
||||||
|
ora #KEY_FLAG_CAPSL
|
||||||
|
tay
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
m65_scnkey_SHFLAG_ready:
|
||||||
|
|
||||||
|
sty SHFLAG
|
||||||
|
|
||||||
|
|
||||||
|
; XXX
|
||||||
|
|
||||||
lda KOUNT
|
|
||||||
beq m65_scnkey_output_key ; if second counter is also 0, we can repeat the key
|
|
||||||
dec KOUNT
|
|
||||||
|
|
||||||
rts
|
rts
|
||||||
Reference in new issue
Block a user