Changes

Programming:Keyboard scanning

98 bytes added, 14 January
/* Complete keyboard scanning routine */
keyscan di ;1 ##%%## C P C VERSION ##%%##
xor a ;1
ld hl,keymap ;3
ld bc,#f782 ;3
out (c),c ;4
ld bc,#f40e ;3
ld e,b ;1
out (c),c ;4
ld e,b ;1
ld bc,#f6c0 ;3
ld d,b ;1
out (c),c ;4
xor a ld d,b ;1
out (c),a ;4
sub c ;1 a=#40 (-#C0)
ld bc,#f792 ;3
out (c),c ;4
ld a,#40 ;2 ld c,d ;1 (+4241)
loop ld b,d ;1
out (c),a ;4 select line
ld bc,#f782 ;3
out (c),c ;4
ei ;1 (+8 = 209 208 microseconds)
ret
</pre>
* '''Q,A,O,P,SPACE''' - (Q up, A down, O left, P right, SPACE fire) This is a good solution, and it's a sort of standard (used by many games). It is best for english QWERTY keyboards, on french AZERTY it'd be A-Q-O-P (but because the decoding of the keys is done in software, normally by the OS, the bits in the keyboard matrix are actually the same).
The standard CPC has only 1 physical digital joystick port(and no analog joystick port). But it was possible to daisy chain the official Amstrad joysticks. And a common accessory, the joystick port doubler, offered 2 digital joystick ports.  The CPC+ and GX4000 have 2 digital joystick ports built-in (and 1 analog joystick port).
The CPC+ and GX4000 have 2 joystick ports built-in.== See Also ==
See the relevant cpcwiki page: * [[Digital Joysticks]]* [[Keyboard Versions]]
[[Category:Programming]][[Category:CPC Internal Components]]
28
edits