Skip to content

Commit

Permalink
Fixed keyboard shift scanning, misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChartreuseK committed Aug 5, 2020
1 parent e70abae commit c5beee6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion constants.s
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ MODE1_ECHO EQU $80
MODE1_CASE EQU $40
MODE1_INV EQU $20

BAUD_MAX EQU 6 ; 9600 max
BAUD_MAX EQU 3 ; 1200 max

SCUM_UPPER EQU -$40
SCUM_MIXED EQU -$00
Expand Down
25 changes: 12 additions & 13 deletions kbd.s
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ KBDPOLL SUBROUTINE
BVS .b6
TAX
LDA LOG2_TBL,X ; Read in highest set bit
BPL .store ; Branch always (Value is between 0 and 5)
BPL .store ; Branch always (Value is between 2 and 7)
.b7 LDA #0 ; Table is backwards so 7->0
BEQ .store ; Branch always
.b6 LDA #1 ; Table is backwards so 6->1
Expand All @@ -58,23 +58,22 @@ KBDPOLL SUBROUTINE
ADC KEY ; A now contains our offset into the tables
TAX ; Save into X

LDA KBDMATRIX,X
BMI .special ; Keys with high bit set shouldn't be modified

LDA CTRL
BEQ .notctrl
; Ctrl pressed, read lower table and bitmask to CTRL keys
LDA KBDMATRIX,X
AND #$9F
.special
RTS
.notctrl
LDA SHIFT
BEQ .notshift
; Shift pressed, read upper table
LDA KBDMATRIX_SHIFT,X
RTS
.notshift
LDA KBDMATRIX,X
BMI .special ; Don't have control modify special keys
LDA CTRL
BEQ .notctrl
; Ctrl pressed, read lower table and bitmask to CTRL keys
LDA KBDMATRIX,X
AND #$9F
.special
RTS
.notctrl
LDA MODE1 ; Check mode
AND #MODE1_CASE ; Check if we need to do case fixing (all upper)
BEQ .casefix
Expand Down Expand Up @@ -192,7 +191,7 @@ KR9 DC.B '=, '.,$EF,$03, '<, ' , '[,$FF
; Keymasks to remove modifers from the scan results
KEYMASK DC.B $FF,$DF,$FF,$DF,$DF,$DF,$FF,$DF,$D6,$DE
; Which bits indicate shift keys
SHIFTMASK DC.B $00,$000,$00,$00,$00,$00,$00,$00,$21,$00
SHIFTMASK DC.B $00,$00,$00,$00,$00,$00,$00,$00,$21,$00
; Which bits indicate ctrl keys
CTRLMASK DC.B $00,$00,$00,$00,$00,$00,$00,$00,$08,$01

Expand Down
10 changes: 5 additions & 5 deletions petterm.s
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ INIT SUBROUTINE


; Initial baud rate
LDA #$01 ; 300 baud
LDA #$03 ; 1200 baud
STA BAUD

; Disable all PIA interrupt sources
Expand Down Expand Up @@ -171,8 +171,6 @@ INIT SUBROUTINE


; Initialize state
LDA #STSTART
STA RXSTATE
LDA #STIDLE ; Output 1 idle tone first
STA TXSTATE

Expand All @@ -185,17 +183,19 @@ INIT SUBROUTINE
STA RXTGT ; Fire immediatly
STA RXBUFW
STA RXBUFR
;STA RXNEW ; No bytes ready
STA TXNEW ; No bytes ready
STA ROW
STA COL
STA MODE1
; Set-up screen
STA CURLOC
LDA #$80
STA CURLOC+1 ;$8000 = top left of screen
JSR CLRSCR


LDA #$40
STA MODE1 ; Default to mixed case, non-inverted

LDA #0
STA VIA_TIM1L
STA VIA_TIM1H ; Need to clear high before writing latch
Expand Down
4 changes: 0 additions & 4 deletions zpage.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ RXTGT DS.B 1 ; Sample number of next recv event
TXCUR DS.B 1 ; Current byte being transmitted
RXCUR DS.B 1 ; Current byte being received
TXSTATE DS.B 1 ; Next Transmit state
RXSTATE DS.B 1 ; Next Receive state
TXBIT DS.B 1 ; Tx data bit #
RXBIT DS.B 1 ; Rx data bit #
RXSAMP DS.B 1 ; Last sampled value

TXBYTE DS.B 1 ; Next byte to transmit
;RXBYTE DS.B 1 ; Last receved byte

;RXNEW DS.B 1 ; Indicates byte has been recieved
TXNEW DS.B 1 ; Indicates to start sending a byte

BAUD DS.B 1 ; Current baud rate, index into table
Expand Down

0 comments on commit c5beee6

Please sign in to comment.