From 5f6cc08a97b4d57bc61b7a813e0218a1fef840d7 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sat, 20 Apr 2019 00:28:18 +0930 Subject: [PATCH] modify keyboard scan routine to extract bucky bits and store in expected variables --- c64/kernal/scan_keyboard.s | 81 ++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 20 deletions(-) diff --git a/c64/kernal/scan_keyboard.s b/c64/kernal/scan_keyboard.s index a1ef5120..56dab5c7 100644 --- a/c64/kernal/scan_keyboard.s +++ b/c64/kernal/scan_keyboard.s @@ -159,10 +159,20 @@ ;// Operational Variables .alias MaxKeyRollover 3 -Keyboard: - jmp Main +scan_keyboard: + ;; Call main keyboard scanning routine + jsr Main + bcc + + rts +* + ;; Work out what is new and needs to be added + ;; to the input buffer. + ;; Also update the bucky key status flags etc + rts + + ;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; // Routine for Scanning a Matrix Row @@ -372,26 +382,57 @@ skip0: ;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; // Check and flag Non Alphanumeric Keys - lda ScanResult+6 - eor #$ff - and #%10000000 ;// Left Shift - lsr - sta NonAlphaFlagY - lda ScanResult+0 - eor #$ff - and #%10100100 ;// RUN STOP - C= - CTRL - ora NonAlphaFlagY - sta NonAlphaFlagY - lda ScanResult+1 - eor #$ff - and #%00011000 ;// Right SHIFT - CLR HOME - ora NonAlphaFlagY - sta NonAlphaFlagY + ;; Store last row of keyboard scan result, + ;; so that RUN/STOP etc can be checked easily + ;; (Compute's Mapping the 64, p27) + lda ScanResult+0 + sta BUCKYSTATUS - lda ScanResult+7 ;// The rest - eor #$ff - sta NonAlphaFlagX + ;; Store de-bounce data for bucky keys + ;; (Compute's Mapping the 64, p58-59) + lda key_bucky_state + sta key_last_bucky_state + ;; Build bucky state + lda #$00 + sta key_bucky_state + lda ScanResult+6 + eor #$ff + and #%10000000 ;// Left Shift + asl + asl + and #$01 + ora key_bucky_state + sta key_bucky_state + + ;; Right shift + lda ScanResult+1 + eor #$ff + lsr + lsr + lsr + lsr + and #$01 + ora key_bucky_state + sta key_bucky_state + + ;; Control + lda ScanResult+0 + eor #$ff + and #$04 + ora key_bucky_state + sta key_bucky_state + + ;; C= key + lda ScanResult+0 + eor #$ff + lsr + lsr + lsr + lsr + and #$02 + ora key_bucky_state + sta key_bucky_state ;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; // Check for pressed key(s)