Pictures of C64 keyboards
|CIA 1 Port B ($DC01)||Joy 2|
|PA0||CRSR DN||F5||F3||F1||F7||CRSR RT||RETURN||DELETE||Up|
The matrix directly covers 64 out of the 66 keys. The remaining two are
Restore which is tied to the NMI line and not part of the matrix, and
Shift Lock which is tied to the same wire as
direct addressing of a key
; This program waits until the key "S" was pushed. ; Start with SYS 49152 *=$c000 ; startaddress PRA = $dc00 ; CIA#1 (Port Register A) DDRA = $dc02 ; CIA#1 (Data Direction Register A) PRB = $dc01 ; CIA#1 (Port Register B) DDRB = $dc03 ; CIA#1 (Data Direction Register B) start sei ; interrupts deactivated lda #%11111111 ; CIA#1 port A = outputs sta DDRA lda #%00000000 ; CIA#1 port B = inputs sta DDRB lda #%11111101 ; testing column 1 (COL1) of the matrix sta PRA loop lda PRB and #%00100000 ; masking row 5 (ROW5) bne loop ; wait until key "S" cli ; interrupts activated ende rts ; back to BASIC
.c000 78 sei .c001 a9 ff lda #$ff .c003 8d 02 dc sta $dc02 .c006 a9 00 lda #$00 .c008 8d 03 dc sta $dc03 .c00b a9 fd lda #$fd .c00d 8d 00 dc sta $dc00 .c010 ad 01 dc lda $dc01 .c013 29 20 and #$20 .c015 d0 f9 bne $c010 .c017 58 cli .c018 60 rts
Keyboardrequest in BASIC
- With the BASIC-Command INPUT:
10 INPUT "Write here something"; A$ 20 PRINT "You write: "; A$
Remark: The keyboard input must be a confirmation by pushing the key <RETURN> to continue the program. The keyboard input is saved after the input in variable A$.
- With the BASIC-Command GET:
Remark: The keyboard input occurs key by key. Control and function keys work, too, but the screen output isn't always correct.
When no key is pressed the variable A$ gets an empty char string. For simulation a wait mode must be checked A$. Then A$ is empty, the program must be jumping to the command GET.
- With the BASIC-Command PEEK:
10 PRINT "Push a key, please:": T = "" 20 T = PEEK(197): IF T=64 THEN 20 30 PRINT "You push the key <"; CHR$(T) ;"> with the keycode: "; T
Remark: The keyboard input is occur key by key with reading the memory adress 197 ($00C5).
Then not a key is pushing, is the confirmation value 64. After that (for the wait mode) must be jumping to the command PEEK.
Control and function keys can clicking, too. The screen output isn't correct, but the keycode is correct.
PEEKs & POKEs
POKE 650,128 activate the autorepeat by pushing a key for a longer time
POKE 650,0 deactivate this function.
POKE 655,71 change the pointer of the keyboard codetable; now keyboardlock
POKE 655,72 deactivate the lock
POKE 56322,224 deactivated the keyboard, because the pointer of the CIA 1 is changed. This POKE is using for the joystickscans.
POKE 56322,255 activated the keyboard.
or by deactivation the interrupt (exception: <RUN/STOP>+<RESTORE>) or ports.
Deactivate separate keys:
In the memory adresses 631-640 is the keyboardchache (puffer). It has got a cache for 10 chars and be by using PEEK read off or by using POKE simulat keyboard input.
POKE 198,0 cleared the keyboard chache.