×   Main Menu ALL The 8BS News Manuals (New menu) Links Worth a Look Tools Disc and Basic Webring Site Map 8BS Guestbook Old Guest Book Me The Barnsley Rovers   
8-Bit Software

The BBC and Master Computer Public Domain Library

AEB3 INKEY$

Submitted by Steve Fewell

Description:

Call routine &AA12 to get the Integer parameter (after the INKEY$ keyword) and call OSBYTE &81 (Inkey).
&AA12 will set X (LSB) and Y (MSB) to the Inkey Time limit (if <= &7FFF) or Key value to check (if >= &8000) specified
in the IWA (&2A (LSB) & &2B (MSB)). However, the Key value setting is of no use when using the INKEY$ function.

On return from the OSBYTE #&81 call, the following conditions will apply:
If a negative parameter value is specified then Y & X will both equal #&FF if the key specified is being pressed.
If a positive parameter value is specified then Y will equal 0 if a key has been pressed within the time limit, and X will
be the ASCII value of the Key that was pressed.

Set A to X (the ASCII code for the key pressed - if any key was pressed, or #&FF (if a specific key scan was done)).
If the OSBYTE #&81 call returns with Y not set to 0 then no key was pressed (if Time Limit) or the specified key was
pressed (if a negative - specific key scan - parameter was supplied), so set the SWA to a null string (set SWA length (&36)
to 0) and exit with A = #&00 (as the result is a String value).
Otherwise, call routine &AE6C to Store the ASCII code for the key pressed in location &0600 (the SWA), set the SWA
length (&36) to 1, and exit with A = #&00 (the result is a String value).


Disassembly for the INKEY$ routine

AEB3   032 018 170 20 12 AA JSR &AA12 Get Integer parameter and call OSBYTE &81 (Inkey)
AEB6   138 8A TXA
AEB7   192 000 C0 00 CPY#&00
AEB9   240 177 F0 B1 BEQ -79 --> &AE6C Set SWA to the 1-byte ASCII character (in A)
AEBB   169 000 A9 00 LDA#&00
AEBD   128 208 80 D0 BRA -48 --> &AE8F Set SWA length (&36) to A and exit with A = 0

 


 Back to 8BS
Or