Skip to navigation


Keyboard: RDKEY

[BBC Master version]

Name: RDKEY [Show more] Type: Subroutine Category: Keyboard Summary: Scan the keyboard for key presses
Context: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * DK4 calls RDKEY * PAS1 calls RDKEY * PAUSE2 calls RDKEY * TITLE calls RDKEY * TT217 calls RDKEY * DOKEY calls via RDKEY-1

Scan the keyboard, starting with internal key number 16 ("Q") and working through the set of internal key numbers, returning the resulting key press in ASCII. This routine is effectively the same as OSBYTE 122, though the OSBYTE call preserves A, unlike this routine.
Returns: X If a key is being pressed, X contains the ASCII code of the key pressed, otherwise it contains 0 A Contains the same as X Y Y is preserved
Other entry points: RDKEY-1 Only scan the keyboard for valid BCD key numbers
SED \ Set the D flag to enter decimal mode. Because \ internal key numbers are all valid BCD (Binary Coded \ Decimal) numbers, setting this flag ensures we only \ loop through valid key numbers .RDKEY TYA \ Store Y on the stack so we can retrieve it later PHA JSR FILLKL \ Call FILLKL to scan the keyboard, update the key \ logger and return any non-logger key presses in X PLA \ Retrieve the value of Y we stored above TAY LDA TRTB%,X \ Fetch the internal key number for the key pressed STA KL \ Store the key pressed in KL TAX \ Copy the key value into X RTS \ Return from the subroutine