diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 17642bef..33ca4fd0 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -62,7 +62,7 @@ ;; 64 = no keys repeat .alias key_repeat_flags $028A ; p58 ;; https://www.c64-wiki.com/wiki/Page_2 - .alias key_repeat_speed $028B + .alias key_repeat_counter $028B .alias key_first_repeat_delay $028C ;; bit 0 = shift, 1 = Vendor Key, 2 = Control .alias key_bucky_state $028D diff --git a/c64/kernal/cint.s b/c64/kernal/cint.s index f5509932..900add6d 100644 --- a/c64/kernal/cint.s +++ b/c64/kernal/cint.s @@ -24,14 +24,9 @@ cint: ;; Set key repeat delay (Compute's Mapping the 64 p215) ;; Making some numbers up here: Repeat every ~1/10th sec - ;; But require key to be held for 4x that long before - ;; repeating - lda #$05 - sta key_repeat_speed - - ;; Set key frequency counters (Compute's Mapping the 64 p215) - asl - asl + ;; But require key to be held for ~1/3sec before + ;; repeating (Compute's Mapping the 64 p58) + lda #22 sta key_first_repeat_delay ;; Set current colour for text (Compute's Mapping the 64 p215) diff --git a/c64/kernal/scan_keyboard.s b/c64/kernal/scan_keyboard.s index 551c41fb..61b783a6 100644 --- a/c64/kernal/scan_keyboard.s +++ b/c64/kernal/scan_keyboard.s @@ -355,12 +355,12 @@ skip0: cmp #$ff beq Exist ;; // Handle 'null' values cmp BufferOld - beq Exist + beq KeyHeld cmp BufferOld+1 - beq Exist + beq KeyHeld cmp BufferOld+2 - beq Exist - + beq KeyHeld +RecordKeypress: ;; // New Key Detected ldy BufferQuantity cpy #MaxKeyRollover @@ -385,6 +385,35 @@ skip0: stx Buffer+1 jmp Return +KeyHeld: + ;; The key in A is still held down. + ;; compare with key in last_key_matrix_position + ;; (Compute's Mapping the 64 p36-37) + ;; if different, reset repeat count down. + cmp last_key_matrix_position + beq SameKeyHeld + ;; Different key held + pha + lda key_first_repeat_delay + sta key_repeat_counter + pla + jmp Exist +SameKeyHeld: + dec key_repeat_counter + bpl + + ;; Count down ended, so repeat key now + + ;; Reload key repeat counter + ;; (Compute's Mapping the 64 p58) + pha + lda #6 + sta key_repeat_counter + pla + + jmp RecordKeypress + +* jmp Exist + BufferEmpty: ;; // No new Alphanumeric keys to handle. lda #$ff