Programming:Keyboard scanning

From CPCWiki - THE Amstrad CPC encyclopedia!
Revision as of 18:37, 26 August 2006 by Octoate (Talk | contribs) (Initial page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is a routine which scans the keyboard directly. It is approximately 8% faster then the firmware routine and doesn't enable interrupts.

Input: A = layer (&40 - &49)

Output: A = hardware keyboard value

Destroyed: BC


Hardware scancode table

Value:
Layer
&7F &BF &DF &EF &F7 &FB &FD &FE
&40 (ZB) ENTER F3 F6 F9 CURDOWN CURRIGHT CURUP
&41 F0 F2 F1 F5 F8 F7 COPY CURLEFT
&42 CONTROL \ SHIFT F4 ] RETURN [ CLR
&43 . /  :  ; P @ - ^
&44 , M K L I O 9 0
&45 SPACE N J H Y U 7 8
&46 V B F G T R 5 6
&47 X C D S W E 3 4
&48 Z CAPSLOCK A TAB Q ESC 2 1
&49 DEL - - - - - - -

Scanning routine

ld a, layer	;use the value from the table above
ld bc, &F6C0
out (c), c
ld bc, &F40E
out (c), c
ld bc, &F792
out (c), c
ld b, &F6
out (c), c
ld b, &F4
in a, (c)
ld bc, &F782
out (c), c
ld bc, &F600
out (c), c

;now check for the value from the table
;e.g. with 'cp <value>'
;and a condition
;e.g. 'jp <condition>, xxxx' or 'call <condition>, xxxx'