modify keyboard scan routine to return raw matrix codes

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-20 00:35:20 +09:30
1 parent 5f6cc08a97
commit cef8ffeb43
1 file changed
+18 -37
+18 -37
View File
@@ -181,7 +181,6 @@ KeyInRow:
bcs nokey0 bcs nokey0
jsr KeyFound jsr KeyFound
nokey0: nokey0:
inx
asl asl
bcs nokey1 bcs nokey1
jsr KeyFound jsr KeyFound
@@ -224,14 +223,23 @@ nokey7:
;; // Routine for handling: Key Found ;; // Routine for handling: Key Found
KeyFound: KeyFound:
stx TempZP stx TempZP
dec KeyQuantity dec KeyQuantity
bmi OverFlow bmi OverFlow
ldy KeyTable,x
ldx KeyQuantity ;; Originally, we resolved the keys.
sty BufferNew,x ;; Now we just return the matrix position, so that
ldx TempZP ;; we can do C64-style bucky modifications as normal
rts ;; was: ldy KeyTable,x
pha
txa
tay
pla
ldx KeyQuantity
sty BufferNew,x
ldx TempZP
rts
;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;; // Routine for handling: Overflow ;; // Routine for handling: Overflow
@@ -242,7 +250,6 @@ OverFlow:
pla pla
pla pla
;// Don't manipulate last legal buffer as the routine will fix itself once it gets valid input again. ;// Don't manipulate last legal buffer as the routine will fix itself once it gets valid input again.
lda #$03
sec sec
rts rts
@@ -252,13 +259,11 @@ OverFlow:
NoActivityDetected: NoActivityDetected:
;; // Exit With A = #$01, Carry Set & Reset BufferOld. ;; // Exit With A = #$01, Carry Set & Reset BufferOld.
lda #$00
sta SimultaneousAlphanumericKeysFlag ;// Clear the too many keys flag once a "no activity" state is detected.
stx BufferOld stx BufferOld
stx BufferOld+1 stx BufferOld+1
stx BufferOld+2 stx BufferOld+2
sec sec
lda #$01
rts rts
@@ -268,7 +273,6 @@ NoActivityDetected:
ControlPort: ControlPort:
;; // Exit with A = #$02, Carry Set. Keep BufferOld to verify input after Control Port activity ceases ;; // Exit with A = #$02, Carry Set. Keep BufferOld to verify input after Control Port activity ceases
sec sec
lda #$02
rts rts
@@ -288,12 +292,6 @@ Main:
cpx $dc01 cpx $dc01
beq NoActivityDetected beq NoActivityDetected
lda SimultaneousAlphanumericKeysFlag
beq skip0
;; // Waiting for all keys to be released before accepting new input.
lda #$05
sec
rts
skip0: skip0:
;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -536,23 +534,8 @@ Return: ;; // A is preset
TooManyNewKeys: TooManyNewKeys:
sec sec
lda #$ff
sta BufferQuantity
sta SimultaneousAlphanumericKeysFlag
lda #$04
rts rts
;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KeyTable:
.byte $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff ;// CRSR DOWN, F5, F3, F1, F7, CRSR RIGHT, RETURN, INST DEL
.byte $ff, $05, $13, $1a, $34, $01, $17, $33 ;// LEFT SHIFT, "E", "S", "Z", "4", "A", "W", "3"
.byte $18, $14, $06, $03, $36, $04, $12, $35 ;// "X", "T", "F", "C", "6", "D", "R", "5"
.byte $16, $15, $08, $02, $38, $07, $19, $37 ;// "V", "U", "H", "B", "8", "G", "Y", "7"
.byte $0e, $0f, $0b, $0d, $30, $0a, $09, $39 ;// "N", "O" (Oscar), "K", "M", "0" (Zero), "J", "I", "9"
.byte $2c, $00, $3a, $2e, $2d, $0c, $10, $2b ;// ",", "@", ":", ".", "-", "L", "P", "+"
.byte $2f, $1e, $3d, $ff, $ff, $3b, $2a, $1c ;// "/", "^", "=", RIGHT SHIFT, HOME, ";", "*", "£"
.byte $ff, $11, $ff, $20, $32, $ff, $1f, $31 ;// RUN STOP, "Q", "C=" (CMD), " " (SPC), "2", "CTRL", "<-", "1"
BufferOld: BufferOld:
.byte $ff, $ff, $ff .byte $ff, $ff, $ff
@@ -562,5 +545,3 @@ Buffer:
BufferQuantity: BufferQuantity:
.byte $ff .byte $ff
SimultaneousAlphanumericKeysFlag:
.byte $00