cpct_isAnyKeyPressed_f

Checks if there is at least one key pressed.  This function does the same as cpct_isAnyKeyPressed but ~73% faster.

C Definition

u8 cpct_isAnyKeyPressed_f ();

Assembly call (Input parameters on registers)

call cpct_isAnyKeyPressed_f_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).  This is exactly the same as its brother function cpct_isAnyKeyPressed but using an unrolled version of the loop that makes it ~73% faster.  However, it’s counterpart is requiring more space for performing the operation.

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

27 bytes

Time Measures

  Case      | microSecs (us) | CPU Cycles
-------------------------------------------
Any         |       48       |    192
-------------------------------------------
Checks if there is at least one key pressed.
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