cpct_isAnyKeyPressed

Checks if there is at least one key pressed.

C Definition

u8 cpct_isAnyKeyPressed ();

Assembly call (Input parameters on registers)

call cpct_isAnyKeyPressed_asm

Return value

<u8>false (0, no single key is pressed) or true (>0, at least one key is pressed).  Take into account that true is not 1, but any non-0 number.  Return value is placed in registers A and L (same value for both)

Details

Checks if at least one key from the keyboard is pressed.  It does it looking at the cpct_keyboardStatusBuffer, which is an 80-bit array holding the pressed / not pressed status of each of the 80 keys in the CPC keyboard.  If at least one key is pressed, one of the 80-bits representing the keys must be set to 0 (which means that key is pressed right now).

The cpct_keyboardStatusBuffer is just an array in memory that must be updated with current key status.  To do this, cpct_scanKeyboard routines must be used before calling this function.

Destroyed Register values

A, B, HL

Required memory

13 bytes

Time Measures

  Case      | microSecs (us) | CPU Cycles
-------------------------------------------
Any         |       83       |    332
-------------------------------------------
unsigned char (u8 = unsigned 8-bits, 1 byte )
Checks if there is at least one key pressed.
extern u8 cpct_keyboardStatusBuffer[10]
10-bytes (80-bits) array containing pressed / not pressed status of all the keys / buttons the Amstrad CPC can manage (up to 80).
Reads the status of keyboard and joysticks and stores it in the 10 bytes reserved as cpct_keyboardStatusBuffer
Close