Commodore 128 Programmer's Reference Manual page 368

Hide thumbs Also See for 128:
Table of Contents

Advertisement

358
COMMODORE 128
ii
register is incremented again and the high byte duration is loaded into the accumulator
^
and stored in zero page location $FB. These two locations are decremented in the
instructions stored in location $185B through $1862.
j (
The instructions stored in locations $1850 through $1857 GATE the note, in other
[j
words play the note. To output audible notes, each voice has a gate bit which initiates the
sound from the envelope generator for a particular voice. Bit 0 of location $D404 is the
gate bit for voice 1. To gate a bit, set bit 0 and also set the bit for the desired wave-
j
form at the same time. In this case, the sawtooth waveform is gated on (32+1 = $21).
<—'
At this point, the sawtooth waveform is gated on and is playing in the voice 1
envelope generator. The selected frequency is output until you turn off the gate bit.
s I
Here's where the duration of the note comes into play. The instructions stored in
N
locations $185B through $1862 decrement the low and high byte duration value stored
in zero page locations $FA and $FB respectively. These instructions act as a time delay
which count through the loops using the duration values from page 354 that are stored in
{
the musical data region starting at $1890 in memory. When both $FA and $FB are equal
U
to zero, program control drops through to the instructions stored at $1864 through
$186A. These instructions clear the voice 1 gate bit and stop the envelope generator
| i
from outputting sound.
[ J
At this point, the Y register is incremented ($186E) and the program jumps to
$182F where the X register is cleared to zero. Since the Y register was already
incremented before the JMP instruction in location $186F-71, the low byte frequency
j j
value for the second note is already pointed to by the Y register plus the base address of
U
$1890. The program then loads that low-byte value and stores it in the location $D400
plus the offset of the X register, in this case 0. That gives the appropriate address $D400
[ j
for the voice 1 (low byte) frequency control register. These instructions are executed
l
repetitively until a low-byte frequency of zero is encountered. When the low-byte
frequency equals zero, control is passed to location $1875, the volume is cleared to
zero, and the program breaks.
} I
This program plays 19 notes, and on the 20th a zero is detected as the low-byte
U
frequency value (in location $18DC), so volume is set to zero and the program ends.
This data is entered as an example. Place your data there instead according to the note
\ \
table in Figure 11-15 at the end of the chapter and the duration table on page 354.
! J
Expand on this example. Add multiple voices using different waveforms. Utilize
the filter to perfect the quality of the musical notes. Use this program as a basis for your
own full-featured musical program.
\
L
SYNCHRONIZATION AND
| i
RING MODULATION
u
j
i
The 6581 SID chip lets you create more complex harmonic structures through synchro-
(j
nization or ring modulation of two voices.
The process of synchronization is basically a logical ANDing of two wave forms.
When either is zero, the output is zero.
I i
Here's a synchronization algorithm:
I—1

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents