Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF

176 X=ADVAL(0) AND 3 will give a number with the following meaning X=0 no button pressed X=1 left side fire button pressed X=2 right side fire button pressed X=3 both fire buttons pressed X=ADVAL(0) DIV256 will give the number of the last analogue to digital channel to complete conversion. If the value returned is zero then no channel has yet completed conversion. ADVAL with a negative number in the parentheses, eg X=ADVAL(-3) , can be used to see how full any of the internal buffers are. When characters are typed in on the keyboard they are put into a buffer from which they are extracted with statements like INPUT and GET . Other buffers are used internally for other purposes.

The exact meaning of the number returned depends on the buffer being tested. X=ADVAL(-1) Returns the number of characters in the keyboard buffer. X=ADVAL(-2) Returns the number of characters in the RS423 input buffer. X=ADVAL(-3) Returns the number of free spaces in the RS423 output buffer. X=ADVAL(-4) Returns the number of free spaces in the printer output buffer. X=ADVAL(-5) Returns the number of free spaces in the sound channel 0 buffer. X=ADVAL(-6) Returns the number of free spaces in the sound channel 1 buffer. X=ADVAL(-7) Returns the number of free spaces in the sound channel 2 buffer. X=ADVAL(-8) Returns the number of free spaces in the sound channel 3 buffer.

X=ADVAL(-9) Returns the number of free spaces in the speech buffer. This feature can be used, for example, to ensure that a program never gets stuck waiting for a sound channel to empty, eg: IF ADVAL(-7) 0 THEN SOUND 2, …etc