Atari ST series Technical Reference Manual page 90

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

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 = sta rt TO fin ish STEP increment
POKE register, valu e
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)
/*
/*
/**********************************************/
i f include <osbind.h>
unsigned commands[]=
(
0X73F, 0X080F,OxOODE,0x0101,0X073E,OxFFll,0x0800,0xFF05,
0X080F,0XFF11,0x0800,0X003F,0x0101,0XFF03,0X080F,OxFFll,
82
CHAPTER 4
/* For macro definitions */
/ *
list of D os o u n d Q
*/
*/
*/
*/
*/
*/
*/
commands */

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents