4Bh KB$TEST looks for a keypress
Input - none -
Output - none -
Description

Looks in keyboard buffer for a key but does not remove it.

If the buffer is not empty, the ascii value of the first key found in the buffer is returned in the B register. The unget buffer KBB_WAIT is tested for a key before looking in KBT_BUFF. If KBB_WAIT is empty and there is a key in KBT_BUFF, it is transferred to KBB_WAIT.

If no keys are found, the following will occur:

  1. If KBB_PKOF is non-zero, the pack will switch off using system service PK$PKOF.
  2. If TMB_SWOF is non-zero and TMW_TOUT is zero, the machine will switch off using system service BT$SWOF.
  3. If low battery is detected, BATTERY TOO LOW will be displayed for 4 secs before the machine switches off.

If the I mask (bit 4) of the condition code register is set (ie interrupts are disabled) when KB$TEST is called, it will poll the keyboard itself allowing the operating system to run with interrupts disabled. Every function of the keyboard interrupt routine is carried out except alarm checking. Any keys found are put in the keyboard buffer, the frame-counter is incremented and the display timer is decremented etc. There is a 50ms fixed delay after polling the keyboard so that if KB$TEST is called in a loop, the keyboard is polled approximately every 50ms. After polling the keyboard itself, KB$TEST looks in the keyboard buffer as usual.

Registers A and X are preserverd.

Example
        OS      KB$TEST         ;LOOK IN KEYBOARD BUFFER
        TSTB                    ;TEST IF KEY
        BEQ     NOKEY           ;BRANCH IF NO KEY FOUND

        ;HERE IF KEY FOUND

NOKEY:
Errors - none -