Atari ST series Technical Reference Manual page 24

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

There's one problem with relying on Kbshift() to supply
the information that Bconin() omits: The console device
saves incoming keystrokes in a memory buffer, which means
that it's possible that a character received via Bconin() may
actually be the result of a keypress that took place some time
ago. Therefore, testing the shift keys at the time the charac­
ter is read may not tell you what their status was at the time
the user entered the character.
If your program is reading the console device frequently,
this will probably not present a real problem since a large
number of program statements can execute in the time it
takes the user to remove his fingers from the keyboard. If
there is a significant time delay between reads, such that
Kbshift may not reflect the actual shift key status, you may
wish to change the system variable conterm, a byte value
which is stored at location 1156 ($484). If you set bit 3 of this
variable to 1, the BIOS Bconin() function will return the key­
board shift status code in the most significant byte of the
scancode. This eliminates calling Kbshift separately. Since con­
term is in protected memory, shift into supervisor mode be­
fore changing this value.
Shifting between supervisor and user modes will be dis­
cussed in Chapters 2 and 5.
Having the keyboard shift codes in the high byte of the
scancode seems so handy that you may wonder why it isn't
the default state of affairs. The reason is compatibility. The
keycodes the ST uses are based on those used by the IBM
PC, so the format in which scan codes are returned is also
based on the PC format. Programs that rely on the fact that
the ST console keyboard system mirrors that of the PC may
not handle the scan codes correctly if there is unexpected
data in the high byte. Therefore, if you set the conterm bit in
your program, remember to set it back when your program
ends, so other programs will not receive unexpected data in
the high byte.
One of the problems with using Bconin() is that if no
character is available from the device; the function waits until
one is available. This leaves your program stuck until input
is received. If your program doesn't receive any input, it re­
mains stuck forever, forcing the user to turn off the com­
puter to regain control. To prevent this situation, the BIOS
includes a function that lets you determine whether a charac­
ter is waiting to be received. This function is called Bconstat,
and its C macro uses this syntax:
CHAPTER 2

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents