AMSTRAD cpc 6128 User Instruction page 418

Integrated computer/disc system
Hide thumbs Also See for cpc 6128:
Table of Contents

Advertisement

In a complete program that may be moving objects on the screen, adding up totals and
the like, a background tune can be kept continually playing by having a sub-routine
called to play each note only when there is a free slot in the queue. This ensures that
the program does not pause while waiting for a free slot to appear. If the note values
for this tune were being read from D A T A statements, then the sound routine could be
set stop re-initialising itself just before the data is exhausted.
The number within the brackets of the 0 N S
Q ()
GO SUB command can be 1, 2 or
4 depending on which channel queue is to be tested for a free slot.
There is a function S
Q ( )
that may be used within a program to read the current state
of any of the sound channels. The number within the brackets after S
Q
is again 1, 2,
or 4, to specify for which channel the information should be returned. The function
returns a bit-significant number and will again require an understanding of binary
numbers to decipher it. The bits of the value returned have the following significance:
BIT
DECIMAL MEANING
0,1,2
1,2,4
8
Number of free spaces in the queue
Note at head of queue is marked to rendezvous with A
Note at head of queue is marked to rendezvous with B
Note at head of queue is marked to rendezvous with C
Top note in queue has hold bit set (the queue is held)
A note is currently playing
4
5
6
7
16
32
64
128
Try this simple example:
HI SOUND 2,200
20 x=SQ(2)
30 PRINT BIN$(x)
run
This will print the binary number
10000 100,
in which bit 7 is set, indicating that
the channel was currently playing when the S
Q
function was used. The last three
digits 100, when converted to decimal give the value 4 indicating that there were 4
free entries in the queue. This function may be used to test a queue's status at a given
point within a program - unlike 0 N S
Q ()
GO SUB which will test and react to a
queue's status at an indeterminate point.
So far, all the examples have just dealt with one or two notes of sound. Processing a
whole group of unrelated notes, for example in a piece of music, can be achieved by
listing the required notes in a D A T A statement, from where they can be REA D into a
SOU N D command:
At your leisure ....
Chapter 9· Page 45

Advertisement

Table of Contents
loading

Table of Contents