fix bug in key repeat logic. More remain

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-24 07:34:35 +09:30
1 parent faf7547e74
commit c7e265f4ac
1 file changed
+11 -11
+11 -11
View File
@@ -66,7 +66,6 @@ scan_keyboard:
;; Decrement key repeat timeout if non-zero ;; Decrement key repeat timeout if non-zero
ldx key_repeat_counter ldx key_repeat_counter
stx $0427
beq sk_start beq sk_start
dec key_repeat_counter dec key_repeat_counter
@@ -75,7 +74,6 @@ sk_start:
jsr Main jsr Main
lda BufferQuantity lda BufferQuantity
sta $0420
beq no_keys_waiting beq no_keys_waiting
;; Stuff each key pressed into the keyboard buffer ;; Stuff each key pressed into the keyboard buffer
@@ -83,7 +81,6 @@ sk_start:
ldy #$00 ldy #$00
* *
lda Buffer,y lda Buffer,y
sta $0424,y
jsr accept_key jsr accept_key
iny iny
cpy BufferQuantity cpy BufferQuantity
@@ -115,8 +112,6 @@ accept_key:
;; But don't insert $00 characters ;; But don't insert $00 characters
beq sk_nokey beq sk_nokey
sta $044c,y
;; Stash key into keyboard buffer ;; Stash key into keyboard buffer
ldx keys_in_key_buffer ldx keys_in_key_buffer
cpx key_buffer_size cpx key_buffer_size
@@ -381,8 +376,8 @@ skdone:
;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;; // Key Scan Completed ;; // Key Scan Completed
;; // Put any new key (not in old scan) into buffer ;; // Put any new key (not in old scan) into buffer
ldx #MaxKeyRollover-1 ldx #MaxKeyRollover-1
@@ -391,7 +386,6 @@ ProcessPressedKeys:
;; Check if the currently pressed key is continuing to be held down ;; Check if the currently pressed key is continuing to be held down
lda BufferNew,x lda BufferNew,x
sta $0400,x
cmp #$ff cmp #$ff
beq ConsiderNextKey beq ConsiderNextKey
cmp BufferOld cmp BufferOld
@@ -401,7 +395,6 @@ ProcessPressedKeys:
cmp BufferOld+2 cmp BufferOld+2
beq KeyHeld beq KeyHeld
RecordKeypress: RecordKeypress:
;; // New Key Detected ;; // New Key Detected
@@ -418,6 +411,14 @@ ConsiderNextKey:
dex dex
bpl ProcessPressedKeys bpl ProcessPressedKeys
;; Copy new presses to old list
ldx #MaxKeyRollover-1
*
lda BufferNew,x
sta BufferOld,x
dex
bpl -
;; Return success and set of pressed keys ;; Return success and set of pressed keys
clc clc
rts rts
@@ -451,9 +452,8 @@ BuckyHeld:
jmp ConsiderNextKey jmp ConsiderNextKey
SameKeyHeld: SameKeyHeld:
ldx key_repeat_counter
beq KeyCanRepeat
dec key_repeat_counter dec key_repeat_counter
bpl KeyCanRepeat
bne KeyRepeatWait bne KeyRepeatWait
;; Count down ended, so repeat key now ;; Count down ended, so repeat key now
KeyCanRepeat: KeyCanRepeat: