Keyboard
From The Dragon Archive
How the keyboard matrix scan work is described in "Inside the Dragon" book on page 198-204.
Dragon 32 keyboard map:
LSB $FF02 MSB | PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 <- column ----|---------------------------------------------- PA0 | 0 1 2 3 4 5 6 7 LSB PA1 | 8 9 : ; , - . / $ PA2 | @ A B C D E F G F PA3 | H I J K L M N O F PA4 | P Q R S T U V W 0 PA5 | X Y Z Up Down Left Right Space 0 PA6 | ENT CLR BRK N/C N/C N/C N/C SHFT PA7 - Comparator input MSB ^ | row
CoCo keyboard map:
LSB $FF02 MSB | PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 <- column ----|---------------------------------------------- PA0 | @ A B C D E F G LSB PA1 | H I J K L M N O $ PA2 | P Q R S T U V W F PA3 | X Y Z Up Down Left Right Space F PA4 | 0 1 2 3 4 5 6 7 0 PA5 | 8 9 : ; , - . / 0 PA6 | ENT CLR BRK N/C N/C N/C N/C SHFT PA7 - Comparator input MSB ^ | row
e.g. (Dragon):
- 'U' $55 -> col: 5 - row: 4
- 'Y' $59 -> col: 1 - row: 5
If "U" is pressed, then when PB5 of PIA0 is LOW, PA4 of PIA0 will read LOW, else it will read HIGH.
Similarly if "A" is pressed then when PB1 is LOW, PA2 will read LOW, else it will read HIGH.
Each key is just a switch bridging a row and a column - if the column is low, then the row will be pulled low when the key is pressed (the A side of the PIA has an internal pull-up, so in input mode it will read as high if not connected to anything - no key pressed).
matrix columns PB0-PB7 are:
- configured as outputs
- connected to: $ff02 -> PIA 0 B side Data register
matrix rows PA0-PA6 are:
- configured as inputs
- connected to: $ff00 -> PIA 0 A side Data register
Forum threads: