Keyboard
From C64-Wiki
| | This article is under construction and classified as "work in progress" !!! |
The C64 Keyboard has 66 keys on it.
Keyboard reads are done using the CIA.
Contents |
[edit] Definition
- The C64 is a keyboard computer, also a computer, which is build in a keyboard.
- This types of computer are other Commodore homecomputers like VC 20, C16, C116, C128, Plus/4, Amiga or Atari ST.
- The Keyboard is the main input device of the C64.
- Over the keyboard will be writting BASIC-commands as LOAD, LIST, RUN etc.
[edit] Pictures of C64 keyboards
[edit] Keyboard Map
| CIA 1 Port B ($DC01) | Joy 2 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| PB7 | PB6 | PB5 | PB4 | PB3 | PB2 | PB1 | PB0 | |||
| CIA1 Port A | PA7 | STOP | Q | C= | SPACE | 2 | CTRL | <- | 1 | |
| PA6 | / | ^ | = | RSHIFT | HOME | ; | * | £ | ||
| PA5 | , | @ | : | . | - | L | P | + | ||
| PA4 | N | O | K | M | 0 | J | I | 9 | Fire | |
| PA3 | V | U | H | B | 8 | G | Y | 7 | Right | |
| PA2 | X | T | F | C | 6 | D | R | 5 | Left | |
| PA1 | LSHIFT | E | S | Z | 4 | A | W | 3 | Down | |
| PA0 | CRSR DN | F5 | F3 | F1 | F7 | CRSR RT | RETURN | DELETE | Up | |
| Joy 1 | Fire | Right | Left | Down | Up | |||||
[edit] Programming
[edit] Assembler
[edit] direct adressing of a key
; This program waits until the key "S" was pushed. ; Start with SYS 49152 *=$c000 ; startadress 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
[edit] 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:
10 PRINT "Push a key, please:": A$ = "" 20 GET A$: IF A$="" THEN 20 30 PRINT "You push: "; A$
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.
[edit] PEEKs & POKEs
Autorepeat:
POKE 650,128 activate the autorepaet by pushing a key for a longer time
POKE 650,0 deactivate this function.
Keyboardlock:
POKE 649,0 blocks the keyboard, because the keyboard puffer has got the length 0
POKE 649,10: POKE 808,237 deactivate the lock.
or
POKE 655,71 change the pointer of the keyboard codetable; now keyboardlock
POKE 655,72 deactivate the lock
or
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:
Keyboardcache:
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.
[edit] Links
| Wikipedia: Keyboard_(computing) |
