Changes

Programming:Keyboard redefinition

22 bytes added, 08:44, 1 September 2014
For performance , it is possible to compute directly offset and mask in keyboard buffer with GetMask function.This is usefull for game as IsPressed function can be considered as slow.
As SHIFT or CONTROL status can be a control problem , you can inhibate them using IgnoreSHITFCTRL.
<pre>
ret
;check if there is a key is down at (HL);only the first key found is returned
;return carry is a key is down
;return key code in A : key code = (line*8)+bit
GetPressed
push HL
ld C,10.loop_col
ld B,8
ld A,(HL++).loop_bit rla jr nc,.pressed
djnz .loop_bit
dec C
rrca
rrca
ld E,A ld D,0
add HL,DE
;so we get the address
pop AF;now get the
and 7
inc A
.loop
rra ;get bit in carry
djnz .loop
ccf ;reverse bit
pop HL
ENDMODULE</pre>
 
[[Category:Programming]]