Skip to navigation

Elite on the BBC Micro

Keyboard: RDKEY (Master version)

Name: RDKEY [View in context] Type: Subroutine [Compare versions] Category: Keyboard Summary: Scan the keyboard for key presses
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 RDKEY2 \ Call RDKEY2 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 TRANTABLE,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