Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 243

Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 246

Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 243

Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 246

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /mnt/cpcwiki-httpdocs/includes/diff/DairikiDiff.php on line 434
Changes - CPCWiki

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]]