PET Keyboard Read Routine
Posted: Sat Nov 13, 2021 5:24 pm
Greets!
If there are any PET gurus out there, I would appreciate some ideas on why I can't seem to read input directly from PORTB on the 6520 that is connected to the PET keyboard. I am familiar enough with the hardware to know that bits (3:0) feed a 74LS145 BCD decoder that drives one of ten ROW lines LOW. I also know that pressing a key will drive one of the Columns LOW that feeds into the 6520 PORTB input.
I need to read input data from PORTB of the 6520 as fast as possible (for reasons I will explain later), so I made this basic assembly test just to make sure I was on the right track. I fully expected this to show characters change on the screen as I pressed various keys....
Simple enough, it sets the 145 to zero, then writes whatever value it finds on the input of PORTB to the upper left corner of the screen. Just to verify my sanity (and that the code works), it also dumps a rolling character to the second location on the screen, and that indeed works.
What is odd is that the keyboard has no effect on the first character, it just stays at 255. Even if I alter the 145 value, nothing changes.
I have run this code on 2 real PETs as well as vice, and it is the same on all.
Any ideas? I am almost certain that my addresses are correct; $E819 to set the 145, and $E812 to read the data.
On a side note, this "Basic Stub" just stuffs "SYS 2000" into basic line zero. Address 2000 is the start of assembly code.
I use this for all my PET progs, and it works well.
Here is a Vice shot, showing the 255 character (top left) and my rolling character working...

Cheers!
Brad
If there are any PET gurus out there, I would appreciate some ideas on why I can't seem to read input directly from PORTB on the 6520 that is connected to the PET keyboard. I am familiar enough with the hardware to know that bits (3:0) feed a 74LS145 BCD decoder that drives one of ten ROW lines LOW. I also know that pressing a key will drive one of the Columns LOW that feeds into the 6520 PORTB input.
I need to read input data from PORTB of the 6520 as fast as possible (for reasons I will explain later), so I made this basic assembly test just to make sure I was on the right track. I fully expected this to show characters change on the screen as I pressed various keys....
Code: Select all
; ******************************************************************
; ********** PET BASIC PROGRAM STUB
; ********** SAVE CODE STARTING @ 1025
; ******************************************************************
; START OF BASIC
.ORG 1025
.WORD 1025
; ADD BASIC SYS2000 COMMAND
.BYTE 11,4,0,0,158,50,48,48,48,0,0,0
; START OF PRORAM + BASIC OFFSET
.ORG 2000+2
; DISABLE PET KERNAL
;SEI
; ******************************************************************
; ********** MAIN LOOP
; ******************************************************************
MAIN:
; SET KBD.ROW
lda #0
STA $E810
; RED KBD.COL
LDA $E812
STA 32768
; ALIVE TEST
INX
STX 32769
; LOOP
JMP MAIN
What is odd is that the keyboard has no effect on the first character, it just stays at 255. Even if I alter the 145 value, nothing changes.
I have run this code on 2 real PETs as well as vice, and it is the same on all.
Any ideas? I am almost certain that my addresses are correct; $E819 to set the 145, and $E812 to read the data.
On a side note, this "Basic Stub" just stuffs "SYS 2000" into basic line zero. Address 2000 is the start of assembly code.
I use this for all my PET progs, and it works well.
Here is a Vice shot, showing the 255 character (top left) and my rolling character working...
Cheers!
Brad