Changes

Programming:Keyboard scanning

282 bytes added, 09:07, 27 November 2007
This is a routine which scans one line of the keyboard directly. It is approximately 8% faster then the firmware routine and doesn't enable interrupts.
'''Input:''' A = ''line (&40 - &49)''
'''Output:''' A = ''hardware keyboard value''
'''Destroyed:''' BC
<pre>LD A,kbdline ; from 0 to 9 with bdir/bc1=01
LD BC,#F782 ; PPI port A out /C out
OUT (C),C
LD BC,#F40E ; Select Ay reg 14 on ppi port A
OUT (C),C
LD BC,#F6CO ; This value is an AY index (R14)
OUT (C),C
OUT (C),0 ; Validate!!
LD BC,#F792 ; PPI port A in/C out
OUT (C),C
DEC B
OUT (C),A ; Send KbdLine on reg 14 AY through ppi port A
LD B,#F4 ; Read ppi port A
IN A,(C) ; e.g. AY R14 (AY port A)
LD BC,#F782 ; PPI port A out / C out
OUT (C),C
DEC B ; Reset PPI Write
OUT (C),0
<pre>
ld a, line ;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), a
ld b, &F4
in a, (c)
ld bc, &F782
out (c), c
ld bc, &F600
out (c), c
</pre>
 
Now check for the value from the table
e.g. with''' 'bit x,A' '''
and a condition
e.g.''' 'jp z,xxxx' '''or''' 'call z,xxxx' '''
Now check for the value from the table e.g. with''''bit x,A''''and a condition e.g.''''jp z,xxxx''''or''''call z,xxxx''''
</pre>
Please note:
 
* Bit = 0: Key is pressed
* Bit = 1: Key is not pressed
445
edits