EasyManua.ls Logo

Commodore Plus 4 - Page 186

Commodore Plus 4
464 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...
174
Some
Programming
Techniques
Random
Numbers
BASIC
has
a
built-in
random
number
function
that
returns
a
floating
point
number
between
0
and
1.
When
called
with
a
negative
argument,
the
RND
function
reseeds the
random
number
generator
with
the
value
specified
and
returns
the
first
value
from
this
seed.
When
called
with
a
zero
argument,
the
RND
function
reseeds the
random
number
generator
from
a
hardware
clock
and
returns
the
first
value
from
this
seed.
When
called
with
a
positive
argument,
the
next
value
in
the
random
sequence
is
returned.
To
have
a
different
random
number
sequence
every
time
the
program
is
run,
call
RND
at
zero
first,
then
at
1
(or
any
positive
number)
thereafter.
To
have
the
same
sequence
each
time,
call
RND
at
a
constant
negative
seed
value
first,
then
at
1
(or
any
positive
number)
thereafter.
When
a
random
floating
point
number
between
L
and
H
is
needed,
use
(H-L)*RND(1)+L
When
a
random
integer
between
L%
and
H%
(inclusive)
is
needed,
use
INT((H%-L%+1)*RND(1)+L%)
Programming
Sound
and
Music
The
computer
has
two
voices
that
can
play
music
and
a
voice
setting
that
can
create
noise.
Only
two
commands,
VOL
and
SOUND,
are
required
to
play
music
and
sound
effects.
The
VOL
Command
The
VOL
command
sets
the
volume
level
for
tones
played
by
the
SOUND
command.
The
volume
level
can
be
from
0
(off)
to
8
(highest
volume).
You
must
be
sure
that
the
volume
selector
on
your
TV
or
monitor
is
turned
up.
The
level
of
volume
set
by
the
VOL
command
is
relative
to
other
VOL
settings.
The
absolute
sound
level
is
set
by
the
volume
selector
on
your
TV
or
monitor.
The
volume
level
remains
at
the
last
level
set
at
the
end
of
a
program.
If
you
do
not
turn
the
volume
off
at
the
end
of
the
program
or
reset
its
value,
the
next
SOUND
command
plays
at
the
volume
last
set,
even
if
the
next
SOUND
command
is
in
a
different
program.
You
must
execute
a
VOL
command
before
the
SOUND
command,
or
you
will
not
be
able
to
hear
any
sound.
The
SOUND
Command
The
SOUND
command
selects
the
tone
to
be
played.
The
SOUND
command
has
three
parameters:

Other manuals for Commodore Plus 4

Related product manuals