EasyManua.ls Logo

Commodore VIC-20 - Page 116

Commodore VIC-20
308 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...
Pay
special
attention
to
the
fact
that
N,D
is
actually
each
PAIR
of
values
in
the
DATA
statement
in
line
80.
For
example,
225,250
is
the
note
(225)
and
time
duration
(250
jiffies)
the
note
is
played.
The
next
note
is
226
which
is
also
held
for
a
duration
of
250,
and
so
on
until
the
computer
comes
to
the
DATA
pair
of
-1.
-
1.
which
is
the
signal
to
END
1he
program.
There
are
two
ways
to
end
the
music
portion
of
a
program.
To
turn
off
the
music
and
continue
the
program
you
should
simply
POKE
the
speaker(s)
with
a
zero
to
turn
them
off
when
the
program
reaches
your
DATA
signal
(the
signal
here
\s
-1,-1
but
it
could
be
any
number).
To
end
the
entire
program
when
the
music
stops
POKE
the
speaker(s)
off
with
a
zero
and
END
the
program
by
using
the
END
command
as
shown
tn
line
40.
EXAMPLE
2:
MUSIC
USfNG
MULTIPLE
SPEAKERS
10
POKE
36878,15
20
S1
=36S74:S2
=
36875:
S3-36876
30
READ
DTN1tN2,N3
40
IF
D=-1THENPOKES1,
0:POKES2,0:POKES3,
0:END
50
POKE
S1,N1
60
POKE
S2,N2
70
POKE
S3,N3
flO
FORT
=
1TOD:NEXT
90
GOTO30
100DATA500,225.225,225,
0,0,0,0,500,225,225,225,
500,232,232,232,0,0,0,0,
500,232,232r232
110DATA250,240h240,240l
250,239,239,239,
125,237.237,237,
67.5,235,235,235,
33,232,232,232
120DATA33,231,231,231,
33,228,228,228,
33,225,225.225,
33,223r223:223,
500,195,195.195
130DATA500;2407240,240
140DATA-
1,0,0,0
This
program
is
essentially
the
same
as
Example
1,
except
several
speakers
are used,
and
each
speaker
must
be
desig
nated
separately.
If
you're
not
familiar
with
DATA
statements,
here's
a
good
example
of
how
they
work.
In
the
previous
ex-
ampfe
we
told
the
VIC
to
scan
through
the
DATA
and
READ
N,D
where
the
first
number
was
the
NOTE
and
the
second
num
ber
was
the
DURATION.
In
this
example,
we
are rearranging
the
program
so
the
VIC
reads
the
DATA
numbers
in
a
slightly
different
order.
Line
30
instructs
the
VIC
to
READ
the
data
in
this
order:
DURATION,
NOTE
1.
NOTE
2,
NOTE
3.
These
notes
are
only
played
on
their
corre
sponding speakers
per
lines
60-70.
The
music
is
the
same
as
EXAMPLE
1
except
we're
using
three
speakers
and
setting
the
same
duration
for
all
3
notes
so
they
pfay
simultaneously.
Ef
you
want
different
speakers
to
pJay
100