Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
7 ZX<br />
for the required integers or<br />
variables and separators. If all is<br />
well, then the routine will be ex<br />
ited and allow entry of the line into<br />
the program. The syntax used<br />
for the command requires a<br />
space between the end of the<br />
command word and the first in<br />
teger or variable, but the syntax<br />
checker will accept capital or<br />
small letters in the command<br />
word which allows any printout<br />
of the program to look like<br />
original Spectrum commands,<br />
except that they are preceded<br />
by a ' *'.<br />
Software Notes<br />
When the SHADOW ROM is<br />
paged in, routines in the BASIC<br />
ROM can be called up using RST<br />
10H followed by the address of<br />
the routine required. In syntax<br />
time EXPT1 is used to process<br />
numeric expressions and<br />
STEND is called to mark the end<br />
of the statement. Progress is<br />
made down the line being<br />
checked by use of GETCH to<br />
find the ' * ' and NXTCH to advance<br />
past it. ERR6 points to the<br />
original address in the BASIC<br />
ROM which was intercepted to<br />
enable the new routine. CHADD<br />
is used to read the next<br />
character including spaces. During<br />
runtime EXPT1 puts the integers<br />
on the calculator stack<br />
from where they ae retrieved by<br />
FINT1 and put into the<br />
Accumulator in the case of 8 bit<br />
integers, and retrieved by FINT2<br />
and put in the BC register pair in<br />
the case of 16 bit integers. This<br />
is a programming choice which<br />
has to be made depending on<br />
the size of the integers involved<br />
and is not done by the operating<br />
system. The runtime exit is<br />
made by a jump to END 1.<br />
ROUTINE VALUE FUNCTION<br />
The New<br />
Commands<br />
The commands may at first<br />
sight appear to duplicate each<br />
other but that is not the case,<br />
and there is a specific purpose to<br />
each.<br />
* PLAY enables the required<br />
channels and defines the type of<br />
sound.<br />
* MUSIC will give a tone from<br />
the musical scale.<br />
* SOUND will give a tone or<br />
noise of a given pitch.<br />
* PLAY<br />
Format; tone channel, noise<br />
channel, envelope shape,<br />
envelope period.<br />
tone channel 0-7<br />
noise channel 0-7<br />
envelope 0-7<br />
duration 0 32767<br />
This command does not actually<br />
produce any sounds but is used<br />
to enable the designated tone<br />
and noise channels selected by<br />
* MUSIC or * SOUND. It<br />
does, however, select the<br />
envelope shape and period<br />
which are common to all chan<br />
nets. There are three tone channels<br />
and three noise channels<br />
through which noise is output<br />
from the single noise generator.<br />
The effect of combining the<br />
channels is beyond a simple<br />
description and only experimen<br />
tation can bring out the full<br />
capabilities of the generator.<br />
TONE CHANNEL selects either<br />
no channels at all, or any combination<br />
of the three where the<br />
binary bits of the number in<br />
dicate the channels required.<br />
The NOISE CHANNEL selection<br />
is done in a similar manner to the<br />
tone channel selection. The<br />
GETCH 001 8h Gets character from basic into A,<br />
NXTCH 0020h Gets next character ignoring spaces.<br />
CHADD 0074h Reads next character.<br />
ERR6 OlFOh Normal error handling address.<br />
STEND 05B7h Syntax exit routine.<br />
END1 05C1 h Run-time exit routine.<br />
EXPT1 1 C82h Syntax check for numerics — puts it<br />
on stack if alright.<br />
FINT1 1 E94h Puts single byte integer from stack in<br />
n. A<br />
FINT2 1 E99h Puts two byte integer from shack in<br />
BC.<br />
STAKA 2D28h Puts A on stack.<br />
STORE 5BF0h Eight byte temporary store.<br />
TABLE OF VARIABLE AND THEIR FUNCTIONS<br />
SOUNDS<br />
ENVELOPE 1<br />
ENVELOPE shape is selected<br />
with reference to fig 2. and<br />
takes control of the output<br />
volume when the volume<br />
parameter on that channel is<br />
zero. If 2 or 8 is selected then an<br />
envelope of a fixed length is<br />
given. Any other choice will<br />
select a continuous sound but<br />
each has a different shape and<br />
will therefore give the sound a<br />
different timbre. The DURA-<br />
TION of the Envelope Period is a<br />
value between 0 > 65335.<br />
Although the PSG could<br />
never be classed as a synthesiser<br />
the ability to modify the<br />
output waveform does allow<br />
different sounds to be produced.<br />
A sharp attack or rise time<br />
produces a percussion type<br />
sound and if followed by a rapid<br />
decay will give a sound like a<br />
snare drum. As the attack and<br />
decay are lengthened a more<br />
mellow sound will be produced.<br />
For envelope type 2, a period of<br />
around 1000 will give a sharp<br />
banjo effect and using envelope<br />
5 with a short period of around<br />
20 will give a machine like effect.<br />
The duration of the note is no<br />
8<br />
ENVELOPE SHAPES<br />
longer defined and will continue<br />
to sound until either the pitch is<br />
changed or it is turned off using<br />
* PLAY 0,0,0,0 which will<br />
reset all the registers to zero ex<br />
cept register 7 which is set to<br />
255.<br />
10 REM play demonstration<br />
20 INPUT "envelope shape";e<br />
25 INPUT "duration";d<br />
30 * SOUND 1,200,0<br />
40 * PLAY 1,0.e,d<br />
50 PRINT AT 10,2; "Press any<br />
key to re-enter"<br />
55 PAUSE 0<br />
60 CLS<br />
70 GOTO 10<br />
* MUSIC<br />
Format; channel, octave,<br />
note, volume.<br />
channel 1 -3<br />
octave 0-6<br />
note 112<br />
volume 0-1 5<br />
This command is used to<br />
generate a musical output of a<br />
tone set by OCTAVE and NOTE<br />
and output it through the<br />
designated CHANNEL "at the •<br />
COMPUTING DECEMBER/JANUARY 1985 67