.TT217 STY YSAV ; Store Y in temporary storage, so we can restore it ; later .t LDY #2 ; Wait for 2/50 of a second (0.04 seconds) on PAL JSR DELAY ; systems, or 2/60 of a second (0.33 seconds) on NTSC, ; to implement a simple keyboard debounce and prevent ; multiple key presses being recorded JSR RDKEY ; Scan the keyboard for a key press and return the ; internal key number in A and X (or 0 for no key press) BNE t ; If a key was already being held down when we entered ; this routine, keep looping back up to t, until the ; key is released .t2 JSR RDKEY ; Any pre-existing key press is now gone, so we can ; start scanning the keyboard again, returning the ; internal key number in A and X (or 0 for no key press) BEQ t2 ; Keep looping up to t2 until a key is pressed LDA TRANTABLE,X ; TRANTABLE points to the key translation table, which ; is used to translate internal key numbers to ASCII, so ; this fetches the key's ASCII code into A LDY YSAV ; Restore the original value of Y we stored above TAX ; Copy A into X .out RTS ; Return from the subroutineName: TT217 [Show more] Type: Subroutine Category: Keyboard Summary: Scan the keyboard until a key is pressedContext: See this subroutine in context in the source code References: This subroutine is called as follows: * gnum calls TT217 * MT26 calls TT217 * qv calls TT217 * TT214 calls TT217 * mes9 calls via out * OUCH calls via out * GTDRV calls via t * LOD calls via t * SVE calls via t * tapeerror calls via t * YESNO calls via t
Scan the keyboard until a key is pressed, and return the key's ASCII code. If, on entry, a key is already being held down, then wait until that key is released first (so this routine detects the first key down event following the subroutine call).
Returns: X The ASCII code of the key that was pressed A Contains the same as X Y Y is preserved
Other entry points: out Contains an RTS t As TT217 but don't preserve Y, set it to YSAV instead
[X]
Subroutine DELAY (category: Utility routines)
Wait for a specified time, in either 1/50s of a second (on PAL systems) or 1/60s of a second (on NTSC systems)
[X]
Subroutine RDKEY (category: Keyboard)
Scan the keyboard for key presses
[X]
Variable TRANTABLE (category: Keyboard)
Translation table from internal key number to ASCII
[X]
Label t2 is local to this routine