8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

ABC2 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)).

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.

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 exit with IWA set to -1 and A set to #&40 (result
is Integer).
Otherwise, Set A to X (the ASCII code of the character pressed, or #&FF (if specific key scan was done - and the key
wasn't pressed) and set the IWA to the 2-byte value of: A (low byte) and Y (high byte) and exit with A=#&40 (result is
Integer).


Disassembly for the INKEY routine

ABC2   032 018 170 20 12 AA JSR &AA12 Get Integer value and call OSBYTE &81 (Inkey)
ABC5   152 98 TYA
ABC6   208 019 D0 13 BNE 19 --> &ABDB Set IWA to TRUE (-1)
ABC8   138 8A TXA
ABC9 L 076 026 174 4C 1A AE JMP &AE1A Set IWA to 16-bit value

AA12: Get Integer value and call OSBYTE &81 (Inkey)

AA12   032 180 150 20 B4 96 JSR &96B4 Get Integer value at PTR B
AA15   169 129 A9 81 LDA#&81
AA17 * 166 042 A6 2A LDX &2A
AA19 + 164 043 A4 2B LDY &2B
AA1B L 076 244 255 4C F4 FF JMP &FFF4   OSBYTE

 


 Back to 8BS
Or