EasyManua.ls Logo

Atari ST series - Page 90

Atari ST series
420 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 4
effects like wailing sirens. The structure of these commands
is like the FOR command in BASIC, which lets you run a
loop a certain number of times by specifying a starting vari
able value, an ending value, and the number added to the
variable each time through the loop. In BASIC, this com
mand would look like this:
FOR value = start TO finish STEP increment
POKE register, value
NEXT value
Since each sound command can only have a maximum
of four bytes, and there are five parameters to pass here (the
sound command, register number, starting value, ending
value, and increment value), two commands are used. Com
mand 128 is used to store the starting value in a temporary
register, while command 129 supplies the register number,
the increment, and the ending value. There are two impor
tant points to remember about these commands. First, twos-
complement addition is used when adding the increment to
the current register value, meaning that the numbers 128-255
are treated as negative numbers. Therefore, you can count a
value down as well as up. Secondly, the end value must be
matched exactly in order for the loop to end. If you specify 6
as your starting number and 25 as the ending number, with
an increment of 2, the loop will never end, since you'll go
from 24 to 26 without ever hitting 25. This feature can be
used to your advantage for repeating loops.
Program 4-4 demonstrates the use of the Dosound()
command to play a tune in the background while other pro
cessing continues. It plays the first few notes of
Twinkle, Tin
kle, Little Star, while printing out the words at the same time.
Program 4-4. XDSOUND.C
/it*********************************************/
/* */
/* XDSOUND.C Demonstrates use of XBIOS */
/* Dosound() command for executing a series */
/* of sound events via the timer interrupt */
/* (plays Twinkle, Twinkle Little Star) */
/* */
/* */
/**********************************************/
if include <osbind.h> /* For macro definitions */
unsigned commands[]= / * list of DosoundQ commands */
(
0X73F, 0X080F,OxOODE,0x0101,0X073E,OxFFll,0x0800,0xFF05,
0X080F,0XFF11,0x0800,0X003F,0x0101,0XFF03,0X080F,OxFFll,
82

Related product manuals