Professional Documents
Culture Documents
Sx64 Portable
Sx64 Portable
1. ^ I ~
- LI
■ i ■ m i - m m ■ l iTi i "J ■ i ■ 3 -
\ commodore
COMPUTER
Downloaded from www.Manualslib.com manuals search engine
USER'S
USER'S GUIDE
GUIDE STATEMENT
STATEMENT
"This
" This equipment
equipment generates
generates and
and uses
uses radio
radi o frequency
frequency energy.
energy. If11 itit is
is not
not pro
pro-
perly
perly installed
instal led and
and used
used in
in strict
strict accordance
accordance with
with the
the manufacturer's
manufacturer's instruc
instruc-
tions,
tions , this
this equipment
eq ui pment may
may interfere
interfere with
with radio
rad io and
and television
televisi on reception.
reception. This
This
machine
machine has
has been
been tested
tested and
and found
found to
to comply
comply with
with the
the limits
limits for
for aa Class
Class BB
computing
computing device
device in
in accordance
accordance with
with the
the specifications
specifications in
in Subpart
Subpart JJ of
of Part
Part 15
15
of
o f FCC
FCC Rules,
Rules, which
which are
are designed
designed to
to provide
provide reasonable
reasonable protection
protection against
against
such
such interference
interference in
in aa residential
residential installation.
installation . IfIf you
you suspect
suspect interference,
interfe rence , you
you
can
can test
test this
this equipment
equipment byby turning
turning ifif off
off and
and on.
on. If11 you
you determine
determine that
that there
there is
is in
in·
terference
terference with
with radio
radio or
or television
television reception,
recept ion , try
try one
one or
or more
more of
of the
the following
followi ng
measures to
measures to correct
correct it:
it :
•• reorient the
reorient the receiving
receiving antenna
antenna
• move
move the
the computer away
away from
from the
the receiver
receiver
• change
change the
the relative positions
pos itions of
of the
the computer
compute r equipment
eq uipment and
and the
the receiver
rece ive r
• plug
plug the
the computer
computer into
into aa different
different outlet
outlet so
so that
that the
the computer
computer and
and the
the
receiver are
are on
on different
different branch
branch circuits.
If necessary,
necessary, consult
consult your
yo ur Commodore
Commodore dealer
dealer or
or an
an experienced
experienced radio/televi
radio/televi-
sion
sion technician for additional
additional suggestions.
suggestions. You may
may also
also wish to consult
consu lt the
following booklet,
booklet, which was prepared byby the Federal
Federal Communications
Communications Com-Com-
mission:
mission:
"How
" How to
to Identify
Identify and Resolve Radio-TV
Radi o·TV Interference Problems"
Problems" This
Th is booklet
is available from the U.S. Government Printing Office,
Office, Washington.
Washington, D.C. 20402.
20402,
Stock No. 004-000-00345-4."
004-000·00345·4."
TTHE INFORMATION IN
H E INFORMATION IN TH
THIS MANUAL HAS
IS MANUAL HAS BEEN
BEEN REV
REVIEWED AND IS
I EWED AND IS BELIEVED
BELIEVED TO TO BE
BE ry
ENTIRELY
ENTIRE RELIABLE.
L Y RELI ABLE , NONO RESPON
RESPONSIBILITY, HOWEVER, IS
SIBI LI TY, HOWEVER, IS ASSUMEO
ASSUMED FO
FOR fNACCURACIES.
R INACCURACIES.
TTHE
HE MMATERIAL
AT ERIA L IIN THIS
N TH MANUAL
IS MAN IS FOR
U A L IS FOR INFO
INFORMATION PURPOSES
RMA T ION PUR ONLY, AND
POSES ONLY, AND IS
IS SUB
SUBJECT
JEC T
TO CH ANGE WITHOUT NOTICE
TO CHANGE WITHOUT NOTICE. __
THIS
TH MANUAL IS
IS MANUAL IS COPYRIGHTED
COPYRIGHTED ANDAN D CONTA
CONTAINS PROPRIETARY INFORMATI
INS PROPRIETARY INFORMATION. NO PART
ON . NO PART OFOF
TTHIS PUBLICATION
H IS PUB LICA TI ON M MAY BE REP
A Y BE REPRODUCED,
RODUCED, ST STORED
O RED ININ AA RE
RETRIEVAL SYSTEM,
T R IEVA L SY OR TTRANS
ST EM, OR RANS·
MMITTED
ITT ED IIN
N ANY ANY FORM
FORM OR
OR BYBY ANY
ANY M MEANS.
EANS, EELECTRONIC, MECHANICAL,
L ECTRON I C, MECHANICA PHOTOCOPYING,
L , PHOTOCOPY I NG,
RECORDING OR
RECORDING OR OTHERW
OTHERWISE. WITHOUT
ISE. WIT THE
HOU T TH PRIOR
E PR WRITTEN PERMISSION
IOR WRITTEN PERMISSION OF OF COM!\10DORE
COMMODORE
BUS INESS t\.l
BUSINESS ACHINES, INC
MACHINES. INC ^
Copvrigh!©1983
CoPV by Commodore
r ighl© l g83 bv Commodore Busin
Business Machines.
ess Machi nes, I Inc
nc
All
All ngh ! s reserved.
rights reserved.
CHAPTER 2
GETTING STARTED
Communicating with your your64: Keyboard . . . . . . . . • . . . . . . . . . . • . • . . ..
64: The Keyboard 12
12
Loading and Saving Programs
Loadi ng and Saving Programs. . . . . . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . .. 17
17
How to Load
How Load Prepackaged Software . . . . . . . . . . . . • . . . . . . . . • . • . . . . . . .. 118
B
How to Format
How Format a New
New Disk . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . . . . . . .. 19
19
How to Save Programs.
How Programs . . . . . . . . . . . . . • . . . . . . . . . . • . • . . .. 19
Listing
Li Directory of Programs on a Disk
sting a Directory Disk . . . . . . . . . . . . . . . . . . . . .. 20
Files
Files. ............................. . . •... . . ...• . • . . . . . ... 20
Sequential Files ............................•......... .. . .. .... . 21
Files
Relative Fi les ...........................................•.•.... 24
v Random Access File ...................... . . . . . . . . . . • . • . • . . .. 26
Chart of BASIC Commands for Disks and Printers. Printers .. . . • .• . . . •. .• . . .. 30
CHAPTER 33
BEGINNING BASIC
Printing and Calculating . . . . . . . . . . . . . . • . . . . . . . • . . . . . . . . . . • . . . . . . .. 32
Mathematical Functions ........... ... . . . .. . .. .. ..•...... . ... . ... 33
Multiple
Multiple Calculations
Calculations onon One Line
Line .............. . . . . . •.. . . ... .• .•... 35
Execution
Execution Order in Calculations
Calculations . . . . . . . . . . . . . . . . . . . . • . • . • . 36
36
Combining PRINT'S
PRI NT' s Capabilities
Capabilities .....• . . . . ... . ....•. •. .... . ........ 37
v CHAPTER 4 4
WRITING SIMPLE
SIMPLE PROGRAMS
PROGRAMS IN
IN BASIC
BASIC
Line
Line Numbers
Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . .. 39
39
The
The GOTO
GOTO Statement
Statement . . . . . . . . . . . . • . . . . . . . . . . . . . . • . . . . . . . . . . • . • . .. 4040
Using
Using the
th e LIST
LIST Command
Command ... . . . . . . . .. . . ... . . . . • . .. . . . •.• . ........ 40 40
Editing
Edit ing Tips
Tips. ...... .......•..............•....... ... . ....... 41
41
How
How to
to Use
Use Variables
Variables ........... ..... . . . . . • . . . . . . . . . . . . • . .. 42
42
Using
Using FOR...NEXT
FOR. .. NEXT Loops
Loops .. ...• . . . . .... . .• .•.• . . . ...... . • . ..I...... .. .... 45
45
v
v
CHAPTER 66
CHAPTER
COLOR GRAPHICS
COLOR GRAPHICS
How
How to
to Use
Use Colorand
Color and Graphics
Graphics on
on YourComputer
Your Computer . . . . . . . . . . . . . . • . . . 58
58
Printing
Printing Colors
Colors . . . . . . . . . . . . . . . . . . . . ........ . 59
59
ColorCHRS
Color CHR$ Codes
Codes. . . . . . . . . . . . . . . . . . . . . .. ....... . • . . . . . 61
61
How
How toto Use PEEKS
PEEKs and and POKEs
POKEs. . . . . . . . . . . . . . . . . • . • . . . . . . . . . . 63
63
Screen Graphics
Screen Graphics. .................•............•.. . 64
64
Screen Memory Map
Screen Memory Map . . . . . ......•...•.•......•...•......... . 65
65
Color Memory Map
Color Memory Map . . . . . . . . . . . . . . . . . . • . . . . . . . . • . . . . . . . . . . • . . . . .. °6
66
More
More Bouncing
Bouncing Balls
Balls . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . . 67
67
CHAPTER 7
INTRODUCTION TO SPRITES
Bits, Bytes
Bits, Bytes and
and Sprites
Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . • . • . • . . . . . . . . . . .. 69
69
Creating Sprites
Creating Sprites . . . . . . . . . . . . . . .. . . . . ........• . •. . ......• . • . .. 7?
72
More on Sprites: Colors and Extra Movement . . . . . . . . . . . . . . . • . . . • . . . .. 78
CHAPTER 8
MAKING MUSIC ON YOUR COMPUTER: FOR
NON-PROGRAMMERS
NON·PROGRAMMERS
Structure of
Structure of aa Sound
Sound Program
Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . .. 79
79
Sample Sound
Sample Sound Program
Program . . . .. .. . . . .• .. .•. .. . . . . .•.•. .. . . °^
85
Playing aa Song
Playing Song on on Your
Your 64
64 .. .. .. .. . .. .. .. .. .. . .. .. .. .. . 87
87
Creating Sound
Creating Sound Effects
Effects . . . . . . . . . . • . • . . . . . . . . • . . . • . . . . . . • . • . • .. "
89
CHAPTER 9
CHAPTER
ADVANCED DATA
ADVANCED DATA HANDLING
HANDLING
READ and
READ and DATA
DATA Statements
Statements . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . . . . . . . 91
91
Calculating Averages . . . . . . . . . . . . . • . • . . . . . . . . • . . . . . . . . . . . . .
Calculating Averages. 93
93
Subscripted
Subscri Variables ............ .. . . . ........•. . ............
pted Variables 95
95
Dimensioning Arrays
Dimensioning Arrays . . . . . . . . . ......•. 96
96
Simulated Dice
Simulated Dice Roll
Roll with
with Arrays
Arrays. ..... ....•... .... .. . 97
97
Two-dimensional
Two- Arrays.
dimensional Arrays . . .... . . . . . ..... .. . • . • . .. . .. . . • . • . .... "
99
()
f.1
—
()
n
n
v INTRODUCTION
The Commodore Executive
The Executive 6464 is one
one of the best
best values in the home com·com
v
puter industry. You can use use your
your 64K color
color computer
computer for for everything from
v business applications to household paperwork to excit exciting games. The 64 offers
ing games. offers
(64K), lots of color
you lots of memory (64K), color(16
(16 different colors), lots of sound (music
v prepackag
and sound effects), and lots of fun and practical uses. You can use prepackag·
easy-to-learn BASIC.
ed software, or you can write your own programs in easy·to·learn BASIC. All
software designed for the Commodore 64 on disk or cartridge also runs on the
Executive 64.
Executive
v
Executive 64 models (the SX-64 and the DX-64)
The Executive DX-64) have all the capabilities of
selling
the best sell ing Commodore 64, plus one or two disk drives and a 5" color
monitor bubuilt-in. Executive 64 snaps together to form its own carrying case,
ilt·in. The Executive case,
and it's light enough to carry and use anywhere.
easy-to-read user's guide contains all the information you need to set up
This easy·to·read
v
properly,
your equipment properl DX-64.
y, understand how to operate your new SX-64 or DX-64,
how to create your own simple BASIC programs.
and learn how
This user's guide is intended to introduce you to computers, but it is beyond
v the scope of this manual to tell you everything you need to know about com· com
puters or about BASIC. However, this guide does refe referr you to a variety of
v
publications that explain the topics we present here in more detail. These
v publications include the Commodore 64 Programmer's Reference Guide and
our Introduction to BASIC series.
v For those of you who don't want program,, you won
wan t to learn how to program won't't have to
whole book to learn how to use Commodore prepackaged
search through the whole
v games, or other prepackaged,
programs and games, prepackaged, third party software. We've put all
the information you need to know right up front in Chapters 1 1 and 2.
2.
SPRITE GRAPHICS
Many exciting features are waiting for you inside your Executive 64. Your
Your
new computer gives you the microcomputer industry's most advanced
v graphics, which
graphiCS, which we call
call SPRITE GRAPHICS. Sprite graphics let you:
SPRITE GRAPHICS.
• Design your
yo ur own pictures
pictures in different colors, just like the ones you see on
arcade-type
arcade· type video games.
games.
o Animate
Ani mate as
as many as 88 different
differe nt overlapping sprites
sprites at once.
• Double a sprite's size.
Double a sprite's size.
• Move
Move your
your creations anywhere
anywhere on the the screen.
o Pass
Pass images
images in in front
front or
or behind
behind each
each other.
other.
• Use
Use automatic
automatic collision
collision detection
detection that
that tells
tells the
the computer
computer toto do
do whatever
whatever you
you
want
want when
when sprites
sprites touch
touch each
each other.
You
You can
can use
use these
these features
feat ures to
to write
write games
games and
and educational
educati onal software.
software. In
In addi
addi-
tion,
tion, you'll
you'll see
see sprites
sprites used
used inin the
the preprogrammed
preprogrammed software
software you
you buy
buy from
from Com
Com·
modore.
modore.
v
v
LOW-PRICED
LOW·PRICED PERIPHERALS
PERIPHERALS
As
As your
your computer
computer needs
needs grow,
grow, so
so can
can your system. You can expand your
system
system byby connecting
connecting your
your Executive
Execu tive 64 to
to other pieces of equipment,
equ ipment, known
as
as peripherals,
peripherals, which
which include
include accessories
accessories like
like these:
these:
•• The
The VIC-1541
VIC·1541 disk
disk drive
drive (as many as five at aa time).
ti me).
•• The
The VIC
VIC 1525,
1525, 1526,
1526, and MPS·801
MPS-801 dot matrix printers,
printers, and the 1520
printer/plotter,
printer/pl otter, for
for printed
printed copies of your programs, letters, etc.
programs, letters, etc.
•• The
The 1600
1600 VICMODEM for access through your telephone to the massive
databases of
of larger
larger computers, services of hundreds of specialists
computers, and the selVices
and aa variety
and vari ety of
of information
information networks.
•• The Commodore 1701/1702
The 1701 /1 702 color monitor.
monitor.
•• The
The Z-80
Z·80 microprocessor,
microprocessor, for access to CP/M"
CP/M * *,, which offers a variet
variety ap
y of ap·
plications software.
plications software.
Commodore wants you to really enjoy your new Executive 64. As you learn,
bear
bear in
in mind
mind that
that programming takes time to learn. Be patient with yourself as
you go
you go through the USER'S
USER'S GUIDE.
GUIDE. Before you start,
start, please take a
a few minu tes
minutes
to fill
to fill out and
and mail in the owner/registration
owner/registrati on card that came with your computer
computer.
This
Thi s will ensure that your new computer is properly registered with Com·
Com
Headq uarters and that you receive the most up-ta-date
modore Headquarters up-to-date information
information
regarding future
regarding fut ure enhancements
enhancements for
for your
your system.
system.
•Commodore 64 and
·Commodore 64 and Executive
Executive 64
64 are
are trademarks
trademarks of
of Commodore
Commodore Electronics
Electronics
Ltd
Ltd..
.. CP/M is
**CP/M is a
a reg istered trademark
registered trademark of
of Digital
Digital Research
Research,, Inc.
Inc. Specificat ions are
Specifications are
subject to change.
subject to change.
RELEASE
BUTTONS
()
FUSE
POWER
SWnCH
DISK DRIVE
aiSK DRIVE
HANDLE
HANDLE LIGHT
lOC
LOCK
I(
HINGE
I- --
S" COLOR
MONITOR
v O_BAS
KEYBOARD-TO-BASE
E
KEYBOARO-T
CONNECTOR
CONNECTOR
BASE_TO.
KEYBOARD
CONNECTOR
12. Adjust
Adj ust the picture
picture,, if necessary. The backg round color shou
background ld be white,
should white, the
should
border shou flight blue·green),
ld be cyan (light blue-green), and the characters should be blue.
The picture controls are behind the small door with the Commodore logo.
This door is on the right front as you face the monitor. Use the button to
open the door. The control knobs are identified inside the door. door. Use them
would
as you wou ld use the adjustments on a TV set. Note that the top knob con· con
trols
tro the
is th volume
e vo your Executive 64.
lume for your
v
Now yo u're ready to begin using your Executive 64. If you have any problems,
you're
trouble-shooting chart. Before you use the disk drive,
consult the trouble'shooting drive, be su
sure
re to
consult Chapter 2.
v 4
Symptom
Symptom Cause
Cause Remedy
Remedy
Indicator Light
Indicator Light Computer not
Computer not Make
Make sure
sure power
power switch
switch
not "On"
not "On" "On"
"On" isis in
in "On"
"On" position
position
Power
Power cable
cable not
not Check
Check power
power socket
socket for
for
plugged in
plugged in loose or
loose or disconnected
disconnected
power
power cable.
cable.
v
Power supply
Power supply not
not Check
Check connection
connection
plugged in
plugged in with
with wall
wall outlet
outlet
Bad fu
Bad fuse in
se in Take
Take system
system to
to
computer
computer authorized dealer
authorized dealer for
for
replacement
replacement of
of fu se
fuse
No picture
No picture Power not
Power not ON
ON Check
Check previous
previous remed ies
remedies
Malfunction
Malfunction Take
Take system
system toto
authorized
authorized Commodore
Commodore
dealer for repair
Random pattern on Cartridge not Turn
Turn off
off power
power and
and
monitor when properly installed rein sert cartridge
reinsert cartridge
cartridge
cartridg e is in
Picture
Pict with
ure wit poor
h poor Poorly
Poorl y adjusted Adjust picture
Adjust picture controls
controls
or no
or no color
coior picture
picture
Excess background Volume too Adj ust volume
Adjust volume control
control
noise high
v Picture
Picture OK,
OK, but no
no Volume
Volume too Adjust volume
Adjust volume control
control
sound
sound low
Disk
Disk won't
won't LOAD
LOAD Disk
Disk improperly
improperly Remove disk;
Remove disk; insert
insert
inserted
in serted according to
according to directions
directions
(see Chapter
(see Chapter 2)
2)
Drive
Drive door
door noi
not Make sure
Make sure door
door is
is
v closed
closed secure
secure
Bad
Bad disk
disk Insert another
Insert another disk
disk
Malfunctioning
Malfunctioning Take system
Take system to
to
drive
drive authorized dealer for
authorized dealer for
repai r
repair
v
Downloaded from www.Manualslib.com manuals search engine
CURSOR
CURSOR
The
The flashing
flashing square
square under
under READY
READY isis called
called the
the cursor.
cursor. It's
It's aa marker
marker that
that
shows
shows where
where what
what you
you type
type on
on the
the keyboard
keyboard will
will be
be displayed
displayed onon the
the screen.
screen.As
As
(l
you type, the cursor moves ahead one space as the original cursor position is
you type, the cursor moves ahead one space as the original cursor position is
replaced
rep laced with
with the
the character
character you
you typed.
typed. Try
Try typing
typing onon the
the keyboard
keyboard and and watch
watch (l
the
the cursor
cursor move
move while
while characters
characters you
you type
type are
are displayed
displayed onon the
the screen.
screen .
COLOR ADJUSTMENT
COLOR ADJUSTMENT
There
There is
is aa simple
simple way
way to
to get
get aa pattern
pattern of
of colors
colors on
on the
the monitor
monitor so
so youyou can
can
easily
easily adjust
adjust the
the set.
set. Even
Even though
though you
you may
may not
not be
be familiar
familiar with
with the
the operation
operation of of
the
the computer
computer right
right now,
now, just
just follow
follow along,
along, and
and you'll
you'll see
see how
how easy
easy itit is
is to
to use
use
your computer.
your co mputer.
First,
First , look
look on
on the
the left
left side
side of
of the
the keyboard
keyboard and
and locate
locate the
the key
key marked
marked
II!iiDI .
ISTI1 . ThisThis stands
stands for
for ConTROL
ConTROL andand is
is used,
used, in
in conjunction
conjun ction with
with other
other
keys, to
keys, to instruct
instruct the
the computer
computer to
to do
do aa specific
specific task.
task.
To
To use
use aa control
control (unction,
fun ction, you
you hold
hold down
down the II!iiDI key while
the »**<:;.* wh ile pressing
pressing aa
second key.
second key. —■■■■ mm
Try
Try this:
this: hold
hold the II!iiDI key
the KUiil key while
while also
also pressing
pressing the the Q D key.key. Then
Then
release both
both keys.
keys. Nothing
Nothing obvious should
should have
have happened,
happened , butbut ifif you
you touch
tou ch any
key now,
now, the
the screen will
wil l show
show the
the character displayed in in reverse
reverse type,
type, rather
rather
than normal type — like
- like the opening message
message of anything
anything youyou typed eariler.
Held down the
Hold Mbai:!.,., .
;he HJ.mJ.U What happens9 did th
happens? If you did thee above procedure
procedure cor-
cor
rectly, you sh
rectly , you should
ould see a light blue bar
bar move across the screen and then move
down to Mb3i:"\-)
to the next line as long as the fciJ.m-T.^ is
i ■ pressed.
presse I
-
READY
II RED BAR
D GREEN BAR
D BLUE BAR
D YELLOW BAR
At this pOint
point everything is properly adjusted and work working correctly. The
ing correctly.
language. However,
following chapters will introduce you to the BASIC language. However, you can
immediately start using some of the many prewritten applications and games
knowing
available without know ing anything about computer programming.
Each of these packages contains detailed information abou aboutt how to use the
suggested,, though,
program. It is suggested though, that you read th
through
rough the first few chapters of
this manual to become more familiar with the operation
operat ion of your
you r new system.
system.
STORAGE DEVICES
STORAGE DEVICES
Disk Drives
Disk Drives
Commodore's
Commodore's disk
disk drives
drives let
let you
you store
store large
large amounts
amounts of of information
information on
on 5Va
5'A""
floppy
floppy diskettes.
diskettes. Diskettes
Diskettes offeroffer fast
fast storage
storage and and retrieval,
retrieval , and
and they
automatically
automatically keep
keep track of
of all
all your
your files
fi les in
in aa directory,
directory, oror table
table of
of contents,
contents, that
you
you can
can display
display on
on your
your screen
screen or or print
print onon aa printer.
pri nter.
The
The SX-64
SX-64 is
is equipped
equipped with
with one
one built-in
built-in disk
disk drive;
drive; the
the DX-64
DX-64 has
has two
two drives.
drives.
In
In addition,
addition , you
you can add
add extra
extra disk
disk drives
drives by
by daisy-chaining them
them to
to your
your com
com-
puter.
puter. Daisy-chaining
Daisy-chaining means
means connecting one drive to the computer,
computer, and
and then
connecting additional drives to each other.
By
By acquiring the Commodore
Commodore 6464 IEEE Interface Expansion
Expansion Card,
Card , you can also
attach any IEEE disk drive, such as Commodore's CBM
CBM 8050 or 4040 Dual Flop
Flop·
py Disk Drives,
Drives, to the Executive
Exec utive 64.
64.
Chapter 22 contains detailed information on using disk drives.
Printer/Plotter
Printer/Plotter
Commodore's 1520
Commodore's 1520 Printer/Plotter
Printer/Plotter prints
prints and
and draws
draws graphics
graphics inin four
four colors
colors
(black, bl
(black, blue, red,, and
ue, red and green).
green). With
With the 1520, you
you can
can draw
draw barc
bar charts, pies, and
harts, pies, and aa
va riety of
variety of complex
complex graphics.
graphics.
THE 170111702
THE 1701/1702 MONITOR
MONITOR
Commodore's 14"
Commodore's 14" color
color monitor
monitor offers
offers aa superior
superior color
color picture
picture with
with high
high
resolution
reso that enhances
lu tion that enhances yo
your computing
ur co experience. This
mputing experience. This moni
monitor can
tor ca be con-
n be con
nected 10
nected to the
the Exec
Executive 64. The
utive 64. The monitor
monitor is
is connec
connected to the
ted to the compu
computer by an
ter by an
8-pin DIN
8·pin DIN cable.
cable. The
The 1701
1701/1702 Color Monitor
/1702 Color Monitor User's
User's Guide
Guide that
that comes
comes with
with the
the
monitor clearly
monitor clearly explains
explains connections.
connections. You You can
can also
also consult
consult Appendix
Appendix II for
for infor-
infor
mation about
mation about the
the pinouts
pinouts in
in the
the 8-pin
8-pin connector.
connector.
NOTE: You
NOTE: You can
can also
also use
use aa 5-p
5-pin cable to
in cable to con
connect
nect aa monit
monitor to the
or to the Executive
Executive 64.
64.
Just
Just plug
plug itit into
into the
the 8·pin
8-pin connector.
connector.
The 1600
The 1600 VICMODEM
VICMODEM
Commodore's inexpensive
Commodore's inexpensive 1600
1600 VICMODEM
VICMODEM leislets you
you use
use your
your telephone
telephone to
to
connect your
connect your Executive
Executive 64
64 to
to other
other computers
computers and
and computer
computer services.
services. These
These
computer services
computer services include
include CompuServe,
CompuServe, TheThe Commodore
Commodore Information
Information Net·
Net
work. The
work, The Source,
Source, Dow
Dow Jones
Jones News/Retrieval,
News/Retrieval, and
and others.
others.
v THE Z·BO
THE Z-80 MICROPROCESSOR
MICROPROCESSOR AND
AND CP/M"
CP/M"' OPERATING
OPERATING SYSTEM
SYSTEM
The Z-80
The Z-80 microprocessor
microprocessor turns
turns your
your Executive
Executive 64
64 into
into a
a dual
dual microprocessor
microprocessor
home computer.
home computer. The
The Z.aO
Z-80 gives
gives you
you access
access to
to the
the popular
popular CP/M
CP/M Operating
Operating
System, which ofters
System, offers a
a vari
variety software applications, includi
ety of software including wordprocess-
ng wordprocess·
ing., wide
ing widely-used business
ly-used busi programs, high
ness programs, high level computer languages (e.g.,
COBOL,
CO FORTRAN), and other uselul
BOL, FORTRAN), useful programs.
ATTACHMENTS FOR
ATIACHMENTS FOR GAMES AND OTHER USES
COMMODORE
COMMODORE GRAPHICS AIDS
AIDS
Commodore
Commodore provides
provides aa variety
variety of
of graphics
graphics programming
programming aids,
aids, including
including the
the
SUPEREXPANDER
SUPER EXPANDER 64 64 cartridge,
cartridge, which adds
adds easy-to-learn
easy·to·learn graphic
graphic plotting
plotting and
and
music
music programming
programming commands
commands to to BASIC;
BASIC; SIMON'S
SIMON 'S BASIC,
BASIC, which adds
adds 118
11 8
powerfu l new
powerful new commands
commands to to BASIC,
BASIC, including
including programming
programming help
help and
and graphics
graphics
commands:
commands; andand LOGO,
LOGO, an an easy-to-learn
easy·to·learn progamming
progamming language
language with
with TURTLE
TURTLE
graphics.
graphics.
10
10
MUSIC ATTACHMENTS
MUSIC ATTACHMENTS
Commodore
Commodore will
will also
also soon
soon offer
offer aa Musical
Musical Keyboard
Keyboard andand aa 3-pad
3-pad percussion
percussion
attachment
attachment called
called the
the Digi-drumrM.
Digi-drum™. Both
Both products
products will
will include
include special
special software
software
packages.
packages. These
These attachments
attachments will
will increase
increase the
the music
music making
making capabilities
capabilities of
of
the 64
the 64 computers.
computers.
CONNECTING TO
CONNECTING TO A
A STEREO
STEREO SYSTEM
SYSTEM
The
The sound
sound and
and music-making
music-making capabilities
capabilities of
of the
the Executive
Execut ive 64
64 can
can be
be enhanc
enhanc-
ed
ed by
by connecting
connecting your
your computer
computer to
to aa high
high quality
quali ty amplifier and
and stereo
stereo speakers.
speakers.
The
The 8-pin
8-pin DIN
DIN cable
cable discussed
discussed in
in the 1701/1702
170111702 Color
Color Monitor
Monitor section
section can also
also
be
be used
used to
to connect your
your computer
computer to
to an
an amplifier.
amplifier.
DESIGNING A
A COMPUTER SYSTEM FOR YOUR NEEDS
Commodore offers a variety of peripherals that
offers a th at let you create your own own
customized computer system.
system. We offer different types of storage,
storage, printing,
printing, and
telecommunications
tel devices so
ecommunications devices so you
you can
can choose
choose what's
what's best
best for
for you
you.. For
For more
more
information about
information about Commodore
Commodore peripherals,
peripherals, read
read The
The Commodore
Commodore Peripherals
Peripherals
magazines
Guide and the Commodore magazi nes discussed in Appendix
Appendi x R R and consult
your Commodore dealer.
11
11
•• Fi
Files
les
• Sequential Files
• Relative Files
•• Random Access
Random Access Files
Files
NOTE: Memory is
NOTE: is all
all the information the com
com-
knows without
puter currectly knows without needing
needing you
you to tell
tell 0
it where to
it to look.
look.
SHIFT The SHIFT
The SH IFT key
key works
works like like the
the shift
shift key
key on
on aa
typewriter: itit lets
regular typewriter: lets you
you print
print capital
capital letters
letters
or the
or the top
top characters
characters on
on double
double character
character keys.
keys.
mm
t::jJ
- \\
~-'
~
m ~-'
'\
12
12
'-;-h
-
~
-
-
When
When you
you are
are using
using the
the four
fou r special
special function
function
keys
keys at
at the
th e right
right side
side of
01 the
the keyboard,
keyboard, the
the SHIFT
SHIFT
key
key gives
gives you
yo u the
the functions
fun ctions on
on the
the FRONT
FRONT of
of the
the
key
key (f2,
(f2, f4,
f4, f6,
f6, and
and f8).
13
13
You must
You must use
use the
the SHIFT
SHIFT key
key with
with thethe
t+ CRSR
CRSR+ key to
. key to move
move the
the cursor
cursor up,
up, and
and with
with
the +* CRSR
CRSR-*- key to move
- key move the
the cursor
cursor to
to the left.
left.
You don't
You don't have
have to keep
keep tapping
tapping a CRSR
CRSR key
key to
get it
get it to move more
move more than one
one space. Just hold itit
Just hold
down until
down until the cursor is
is where you want
want it.
it.
INST/DEL
INSTIDEL DEL stands for DELete.
DEL DELete. When you press the
DEL key,
DEL key, the cursor moves
moves back
back a space and
that's
erases the character that' s there.
PRINT ""ERROR"#B
ERROR" #.
PRINT ""ERROR"B
ERROR" .
middle
When you DELete in the middl e of a line, move
cursor
the cu rsor just to the left of the character you
want to DELete.
FIX
FI ITAGAINS,
X IT AGAINS, SAM
FIX
FI X IT AGAINSB
AGAINS . SAM
Then press the key. Th
th e DEL key. Thee characters to the
right
ri ght automatically move over to close up the
space.
space.
FIX
FI X IT AGAIN,
AGAIN , SAM
INST stands
stands for INSerT.
INSerT. You have to use the
SHIFT
SHI FT key with
wi th the
th e INST/DEL
INSTIDEL key when you
yo u want
want
to
to insert characters
charac ters in a line.
If you've
you 've left some characters out of a line,
line, use
the
the CRSR keys to to move the
the cursor back to
to the
the er
er·
ror.
ror.
WHILE
WH ILE UU WERE OUT
WHILE
WHILE.■ WERE
WERE OUT
Then,
Then, while
while you
you hold
hold down
down thethe SHIFT
SHI FT key,
key,
press the INST/DEL
press the INST/DEL key until you have enough
until you have enough
space to
space to add
add the
the missing
missing characters. INST
characters. INST
doesn't
doesn't move
move the
the cursor;
cursor; itit adds
adds space
space between
between
the
the cursor
cursor and
and the
the character
character to
to its
its right.
right.
WHILE
WHILE.■ U
U WERE
WERE OUT
OUT
WHILE
WH ILE YOU
YOU WERE
WERE OUT
OUT
Use
Use the
the DEL
DEL and
and INST
INST keys
keys together
together to
to fix
fix
wrong
wrong characters.
characters .
WE'RE NUMBER
WE'RE NUMBER TWO!
TWO!
WE'RE
WE'RE NUMBER ! !
NUMBER
WE'RE
W E'RE NUMBER ■
NU MBER. !
WE'RE NUMBER
WE'RE NUMBER ONE!
ON E !
14
14
...-J
--'
v
'-'
'-"
'-'
~
'-"
'-'
15
15
1. ~
1. [Cs| lets
lets you
you switch
switch back
back and
and forth between
fonh between
the upper and lower case display mode (the let· let
ters and characters on the tops of the keys) keys}
and the upper case/graphic display mode (capi·(capi
tal letters and the graphics on the fronts of the
the
keys).
To switch modes, press the ~ C= and SH SHIFT
IFT
keys at the same time.
your64,
When you first turn on your is in the up·
64, it Is up
case/graphic
per case/g mode, which means that
raphic mode,
everything you type in is in capital letters.
mode, you can also print
When you are in this mode,
graphics
all the graph ics on the fronts of the keys.
• To print the graphic on the right side of a
key, hold down the SH SHIFT
IFT key while you
press the key with the graphic you want to
print. You can on only
ly print the right side
graphics when you are in the upper
case/graphic mode.
print
• To pri nt the graphic on the left side of a key,
hold down the ~ ,O key while you press the
graphic key. YouYou" can print the left side
graphic in either mode.
16
r;-~
~
2. The ~
2. The [C=j key
key also
also lets
lets you
you use
use the
the second
second set
set of
of
eight colors shown on the color keys. keys.JTo
To get
these other co lors, hold down the ~
colors, [CE key
you
while yo number for the color you
u press the number
—
want.
-
Executive
The Exec cartridge. Th
utive 64 accepts programs from disk or cartridge. This
is means you
can use prewritten software simplsimply important, the 64
y by loading it. But more important,
lets you save your own programs tor for reuse. To reuse a program you wrote and
disk, all you do is load and run it.
saved on disk,
Prepackaged software on disk or cartridge designed for the Commodore 64
runs
also run Executive
s on the Exec utive 64.
17
17
Loading Disks
Disks,
Disks, which
which are often
often called
called "floppy
" floppy disks",
disks ", are
are really easy to
to use.
use.
The
The steps are
are the same
same for loading
loading preprogrammed disks and disks that that you
program yourself.
you rself.
1.
1. insert
Insert aa disk into your disk drive. Make
Make sure the label on the disk is facing up.
Put the disk in so that the labelled end goes in last. Look for a little notch on
on
the disk (it might be covered with
with a little piece of tape). This
Thi s notch must be
on the left side as you put in the disk,
disk, assuming that you're
you 're facing your com·
com
puter. Be sure the disk is all the way in.in.
2. Close the protective gate on the disk drive after you insert the disk. Just
push down the lever.
3. Type LOAD ""PROGRAM
PROGRAM NAM NAME".
E" , 8. The 8 is the code for disks. You need to
type it here to let the computer know you you're
're loading a disk.
NOTE: You can LOAD th
NOTE: thee first program by using the ·' sign in place o
off the
program name:
name: LOAD " .
"*"," , 8.
4. Press the RETURN key.
4. key. The disk will spin and your screen will
wi ll say:
SEARCHING FOR PROGRAM NAME
LOADING
READY
•■
RUN when the screen says READY and the cursor appears. Your soft·
5. Type RUN soft
~is~~u~
ware is ready to use. n
n
18
18 n
Downloaded from www.Manualslib.com manuals search engine
HOW TO FORMAT A NEW DISK
new. unprogrammed disk for the first time, you need to
When you're using a new,
headering,, prepares your disk by do-
format it. Formatting, which is also called headering do
ing things like dividing the disk into blocks. Formatting also creates a directory
that you use as a table of contents for the files yoyou
u save on the disk. DO NOT
header a preprogrammed disk.
You oonly disks, not disks that already have programs on
nly have to format new disks,
unless
them unl ess you want to erase the entire disk and reuse it.
disk, use this special version of the OPEN and NEW com·
To format a new disk, com
mands:
mands:
NO: <name> , < id Y '
1,8.15,liN0:<name>.<id>"
OPEN 1,8,15,"
v NO tells the computer to header (N
(NEW) 0. If you have a DX-64,
EW) the disk in drive O. DX-64,
disks
header disk 0.
s in drive O.
The name you use in this command goes in the directory as the name of the
v entire disk. Give the disk any name up to 16 characters.
'-' The id is any two characte
characters.
rs. Give the disk any id you want,
want, but you should
give every disk a different id code.
off. type CLOSE 1
When the disk drive light goes off, 1 and press return.
BE CAREFUL! Headering a disk erases all information on the disk, disk, if there is
any. Header only a new disk
disk or a disk you are willing to erase.
erase. Here are some ex-
ex
amples of OPEN comm
commands
ands that header aa disk:
disk:
OPEN 1,8,
1,8,15,"N0:MYFILE.A3"
15," NO:MYFILE,A3"
OPEN 1,8,15,"NO:$RECORDS,02"
1,8,15,"N0:$RECORDS,02"
Now that you know how to header aa disk, you are ready to use disks to write
write
and save programs on your
your Executi
Executive
ve 64. Appendix
Appendi x SS contains more informa-
informa
tion on the OPEN command.
19
19
LISTING
LISTING A
A DIRECTORY
DIRECTORY OF
OF PROGRAMS
PROGRAMS ON
ON A
A DISK
When you
When you SAVE
SAVE programs
programs on
on aa disk,
disk, the
the computer
comp uter automatically
automatically makes
makes aa ^
table of contents,
table contents, or
or aa DIRECTORY,
DIRECTORY, of the
the names
names of
of the
the programs
programs on
on the
the disk.
disk.
You
You can
can display this
this directory
directory to
to see
see what
what programs
programs are on
on your
yo ur disk.
disk. Follow
Follow
these steps:
these steps:
-—i
1.
1. Key
Key in:
in: LOAD
LOAD "$",8
"$",8 and press RETURN.
RETURN . The
Th e computer
computer displays
displays this
this
message:
message: <■
SEARCHING FOR $ m
LOADING
READY
READY ^
Your
Your programs names are
are displayed on your
your screen. _
FILES
There
Th ere are two types of files that you
yo u can store:
1.
1. PROGRAM FILES, which store BASIC or machine language programs.programs.
FILES, which store numeric and string data that you can use in pro
2. DATA FILES, pro·
grams. A unit of a data file is called a
a RECORD;
RECORD; each record can contain one ^
or
or more pieces of data.
1.
1. SEQUENTIAL FILES,
FILES, which store data in records in the order you input the
data. Data records are accessed sequentially,
sequentially, which means that you can 't go
can't
directly to record 10;
10; you must read the file from beginning to end. ^
2. RELATIVE FILES, which let you access data records directly by positioning
a pointer relative
pOinter to any record relat ive to the beginning of the file,
file, which means that
you can go directly to record 10. 10.
3. RANDOM ACCESS,
ACCESS, or user files,fites , which store data records according to yo ur
your
design.
des file
ign. Unlike the other fil types, these files are not maintained by the disk
e types, ^
operating
operat system.
ing sys tem. You must design and maintain them yourself.
20
20
v EXAMPLES
EXAM OPENING
PLES OF OPENI SEQUENTIAL
NG SEQU FILES:
ENTI AL FILES:
8, 2,
OPEN 2, 8, 2, "O:
"0:DATA, S, W"
DATA, S, W
8, 8, 8,
OPEN 8, 8, "O:
"0:Program,
Program , P, R"
OPEN A, C, "0:" + A$ +
B, C,
A, B, "u,
"U, W"
WRITING TO AND
AND READING FROM
FROM A
A SEQUENTIAL FILE
PRINT#
PRINT# and
and INPUTS
INPUT# and GET#
GET#
The
The PRINTS
PRINT# command works exactly
exactly like
like the
the PRINT statement,
statement, except
except that
output is re-directed
re·directed to
to the
the disk
disk drive. The
The reason
reason for the special emphasis
emphasis on
on
the
the word
word exactly
exactly is
is that
that all
all the
the formatting capabilities
capabilities of
of the
the PRINT
PRINT statement,
statemen t,
as
as applies
applies to
to punctuation
punctuation and
and data
data types,
types, applies
applies here
here too.
too. ItIt just
just means that
you
you have
have to
to be
be careful
caref ul when
when putting
putting data
data into
into your
your files.
FORMAT
FOR MAT FOR
FOR WRITING
WR ITING TO
TO FILE
FILE WITH
WITH PRINTS:
PRINT#:
PRINTS
PRIN T# files,
file# , data
data list
list
The file# is
is the
the one
one from the
the OPEN
OPEN statement when
when the file
fil e was
was created.
created.
The
The data
data list
list is
is the
the same
same as
as the
the regular
reg ular PRINT
PRINT statement
statement —
- aa list
list of
of variables
variables
and/or
and/or text
text inside
inside quotes.
quotes. However,
However, you
you must
mu st be
be especially
especially careful
careful when
when
writing
writing data
data so
so that
that itit is
is as
as easy
easy as
as possible
possible to
to read
read back
back again
again later.
later.
v
21
21
col
char
char 10 14
The
The eof
eat stands
stands for
for the
the end-of-file
end-at-tile marker.
marker. String
Stri ng data
data entering
entering the
the file
file goes
goes in
in
byte by
byte by byte,
byte, including
including spaces.
spaces.
For
For instance,
instance, let's
let's set
set up
up some
some variables
variables with
with the
the statement
statement A$=
A$= "HELLO":
" HELLO" :
B$=
B$= "ALL":
"ALL" : C$=
C$= "BYE".
" BYE". Here
Here is
is aa picture
picture of
of aa file
file after
after the
the statement
statement PRINTS
PRINT#
5, A$:
5, A$; B$;
BS; C$:
CS:
..Jur
h.. ,
\ Il \ l I LI LIUI ' I L
H
!
[■
2
I.
.1
1.
i
0
5
A
6
L
7
L
U
B
'*
Y
10
b.
11
CR
U
eof
IJ
CR stands
stands for the CHRS
CHRS code 13, the
the carriage return,
return, which is automatically
automatically
PRINTed at the
the end of every PRINT or PRINT#
PRINT# statement unless there
there is aa com-
com
ma or
or semicolon at the end of the
the line.
line.
FORMAT
FOR MAT FOR INPUT# STATEMENT:
INPUT# STATEMENT:
INPUT# file# , variable list
INPUTS file#,
i L 0 A L L B Y 1. CR eol
II L
7 9 IU II 12 U 14 IS
s 6
8
1
\.that
hll ' 1 4
-
H b 1. L 0 ■\ L L CR eol
di.hj[
lJf I 2 3 4 b 7 8 10 12 13 i4 :j 24
22
22
CR euf
io I2 13 IS
v
GET#
disk, one charac
The GET# retrieves data from the disk, character time.
ter at a time.
STATEMENT:
FORMAT FOR THE GET# STATEM ENT:
GET# file#,
file# , variable
variable list
including the
Data comes in byte by byte, including the CR,
CR, comma,
comma, and other separating
characters.
charac ters. It is much safer to use string variables when using the GET# state-
state
ment. You will get a BASIC error message if string string data is received where aa
number was requrequested, butt not vice-versa.
ested, bu
EXAMPLES
EXAM PLES OF GET#
GET# STATEMENT:
GET#
GET# 5,
5, A$
GET# A,
A, B$,
B$, C$,
C$, D$
D$
GET 5,
5, A
The GET# statement is is extremely
ex tremely useful
usefu l when
when examining files with unknown
unknown
contents,
contents, like aa file that
that may have
have been
been damaged
damaged by an an experimental program. It
is
is safer than INPUT#
INPUT# because there there is
is aa limit
limit to the number
number of
of characters
charac ters allow
al low-
ed
ed between
between separators
separators of of INPUT
INPUT variables.
va ri ables. With
With GET#,
GET#, you
you receive every
every
character,
characte r, and
and you
you can
can examine
examine separators
separat ors as as well as
as other
other data.
data.
23
23
EXAMPLES
EXAMPLES OF
OF OPEN
OPEN STATEMENT
STATEMENT CREATING
CREATING RELATIVE
RELATIVE FILES:
FILES:
OPEN
OPEN 2,2,8,
8, 2, " FILE,L," ++ CHR$(100)
2, I*FILE,L1" CHR$(100)
OPEN
OPEN F.
F, 8,8, F.
F, A$
A$ ++ ",L,"
", L," ++ CHR$(O)
CHR$(Q)
OPEN
OPEN A,
A, B,
B, C,
C, "TEST,L,"+
" TEST,L," + CHR$(33)
CHR$(33)
RELATIVE
RELATIVE FILE
FILE FORMAT
FORMAT
'
DATA
DATA BLOCK
BLOCK
BYTE
BYTE DEFINITION
DEFINITION
0,1
0,1 Track
Track and
and sector
sector of
of next
next data
data block.
block.
2- 256
2—256 254
254 bytes
bytes of
of data.
data. Empty
Empty records
records contain
contain FFFF (all
(all binary ones) in
the first byte followed by 00 (binary all
the first byte foll owed by 00 (binary al l zeros) to the end of the
record.
record. Partially
Partially filled
filled records are
are padded with nulls (00).
(00).
SIDE
SIDE SECTOR
SECTOR BLOCK
BLOCK
BYTE
BYTE DEFINITION
0,1
0,1 Track
Track and
and sector
sector of next side sector block.
block.
22 Side sector
Side sector number.
number. (0-5)
33 Record length.
4,5
4,5 Track and sector of first side sector (number 0)
6,7
6,7 Track and sector of second side sector (number 1)
8,9
8,9 Track and sector of third side sector (number 2)
10,11
10,11 Track and sector of fourth side sector (number 3)
3)
12,13
12,13 Track and sector of fifth side sec tor (number 4)
sector
14,15
14,15 Track and sector of sixth side sector (number
Track (number 5)
16- 256
16—256 Track
Track and
and sector
sector pOinters
pointers to
to 120
120 data
data blocks.
blocks.
24
24
The
Th e position command is sent to the command channel (15), so you must
In the following example, 15
open an additional file for the command channel. In 15
is the file number of the command channel, and 8 is the file number of the
is
relative file.
relative
15,8,15
OPEN 15,8, 15
8,8.8
OPEN 8,8,8
FORMAT FOR POSITION COMMAND:
PRINT#file#, ""P"
PRINT#file#, CHR$(channel# + 96) CHR$(rec#lo) CHR$(rec#hi)
P" CHRS(channel#
CHRS(position)
CHR$(position)
EXAMPLES
EXAM PLES OF POSITION COMMAND:
PRINT#15, P" CHR$(CH + 96) CHR$(R1
PRINT#15, ""P" CHR$(R1)) CHR$(R2)
CHR${R2) CHR$(P)
CHR$(P)
v
PRINT#15, ""P" CHR$(R1)) CHR$(R2) CHR$(P)
P" CHR$(4 + 96) CHR$(R1 CHR$(P)
The 2-byte format for the record number is needed because one byte can only
numbers, and we can have over 700 records in the file.
hold 256 different numbers, file_ The
rec# 10
lo contains the least significant part of the address,
address, and the rec# hi is the
v most significant part. This could be translated to the actual record number by
the formula REC#
REC#= = REC HI *" 256 + REC LO. LO.
If the record number is known, the high and low bytes can be determined as
follows:
fol lows:
REC# HI=INT(REC#/256)
HI = INT(REC#1256)
REC# LO= REC#—REC#
REC#-REC# Hl'256
HI"256
'-'
EXAMPLE:
EXAM PLE:
v
PRINT#15,
PRINT#15, "P"
" P" CHR$(4 +
+ 96)
96) CHR$(R1)
CHRS(R1) CHR$(R2)
CH RS(R2) CHR$(0)
CH R$(O)
If REC# = 540:
540: R2=
R2 = INT(540/256)
INT(5401256) ...
__ _so
so R2
R2 = 22
R1 = 540-R2"256 .. .__. so
R1=540—R2*256 so R1=28
R1 = 28
Let's
Let's assume
assume we
we have
have aa mailing
mailing list.
list. The
Th e list
list consists
consists of
of 88 pieces
pieces of data,
data, ac
ac-
cording
cording to
to this
this chart:
chart:
Field
Field Name
Name Length
Length
state
state 22
first
first name
name 12
12 zip code
zip code g9
last
last name
name 15
15 phone
phone number
number 10
10
address
add ress line
line 11 20
20
address
address line
line 22 20
20 - --- -- -
city
city 12
12 TOTAL
TOTAL 100
100
v
25
25
RANDOM FILES,
FILES, OR USER
USER FILES
FILES
Random
Random files
files let you access
access and
and update
update each
each of
of the individual
individual 256-byte
256·byte
blocks
blocks of
of data
data stored
stored on
on the disk.
disk. As was mentioned
mentioned in
in the first chapter,
chapter, there
are a
a total of
of 683
683 blocks on
on the diskette, of which 664
664 are
are free onon aa blank
blank
diskette. Each
Each block
block of data really means
means 11 Track and
and sector of the
the same
same name.
name.
The diskette is
The diskette is divided
divided into
into tracks,
tracks, which
which are
are laid
laid out
out as
as concentric
concentric circles
circles on
on
the surface of the diskette. There are 35 different tracks,
tracks, starting with track 11 at
the
the outside of the diskette toto track 35 at the center. Track 18 is used for the
the center.
directory, and the DOS fills up the diskette from the center outward.
directory,
subdivided
Each track is subd ivided into sectors. Because there is more room on the
outer tracks, there are more sectors there. The outer tracks contain 21 sectors
each. The table below shows the
each, while the inner ones only have 17 blocks each.
numbe
numberr of
of sectors pe
perr track.
Block Format
Track and Block Format
TRACK NUMBE
NUMBERR RANGE
SECTOR RANG E TOTAL BLOCKS
TOTAL BLOCKS
11 to 17
17 o0 to 2020 21
21
18
18 to 24
24 o0 toto 18
18 19
19
25
25 to
to 30
30 o0 toto 17
17 18
18
31
31 to
to 35
35 o0 toto 16
16 17
17
The DOS
The DOS contains
contains commands
commands for for read
reading and writing
ing and writing directly
directly to
to any
any track
track
and sector
and sector on
on the
the diskette.
diskette. There
There are
are also
also commands
commands forfor checking
checking toto see
see which
which
blocks (tracks
blocks (tracks && sectors)
sectors) are
are available,
available, and
and for
for marking
marking off
off used
used blocks.
blocks.
NOTE: You
NOTE: You must
must be be sure
sure to
to mai
maintain this
ntain th information, especially
is information, especially when
when there
there are
are
other types
other types of
of files
files on
on the
the disk.
disk. Fail
Failure to do
ure to do so
so cou
could corrupt other
ld corrupt other files
files..
These commands
These commands are are transmitted
transmitted through
through the
the command
command channel
channel (channel#
(channel
15), and tell the disk what to do with the data. The data must be read later
15), and tell the disk what to do with the data. The data must be read later
through
through one
one ofof the
the open
open data
data channels.
channels.
26
26
OPEN
OPEN file#,
file# , device#,
device#, channel*,
channel#, "#buffer#"
" #buffer#"
v EXAMPLES
EXAMPLES OF
OF OPENING
OPENING RANDOM
RANDOM ACCESS
ACCESS DATA
DATA CHANNEL:
CHANNEL:
OPEN 5,
OPEN 5, 8,
8, 5,
5, "#"
" #"
OPEN A,
OPEN A, B,
B, C,
C, "#2"
BLOCK·READ
BLOCK-READ
BLOCK-WRITE
BLOCK-WRITE
27
27
PRINT#file#,
PRINT#file#, "BLOCK-ALLOCATE:"
"BLOCK·ALLOCATE:" drive; track; sector
drive; track;
If
If you
yo u try
try aa block
block that
that isn't available, error message to
available, the DOS will set the error to
number 65,65, NO BLOCK,
BLOCK, and set the track and bl block next
ock numbers to the next
available
available track and bl
block
ock number. Therefore,
Therefore, any time you attempt to write aa
block
block to
to the disk,
diSk, you must first try to allocate that block. If that block isn't
available,
available, read the next block available from the error channe
channell and the
thenn allocate
that
that block.
bl ock.
BLOCK-FREE
BLOCK·FREE
The
The BLOCK-FREE
BLOCK·FREE command
com mand is the opposite of BLOCK·ALLOCATE,
BLOCK-ALLOCATE, in that itit
frees
frees aa block
bl ock that you
you don't
don't want to use anymore for use by the sys system.
tem. ItIt is
is
vaguely
vaguely similar
si milar to the
the SCRATCH
SCRATCH command for files,files, since it doesn't really erase
any
any data
data from the disk
disk —
- just
just frees the entry,
entry, in this case just in the BAM
BAM..
FORMAT
FORMAT FOR BLOCK-FREE
BLOCK·FREE COMMAND: 0
PRINT#file#,
PRINT#file#, "BLOCK-FREE:"
" BLOCK·FREE:" drive;
drive; track; sector "
or
or abbreviated
abbreviated as
as
PRINT#file#,
PRINT#fi le#, "B-F:"
"B·F:" drive;
drive; track;
track; sector
USING
USING RANDOM
RANDOM FILES
The
The most
most common
common methodmethod for keeping track of which bl
blocks
ocks on the disk you
used,
used , is
is to
to build
bu ild up
up aa sequential file to go with each file.
each random fil e. Use this file to
keep
keep aa list
list of
of record,
record, track,
track, and sector locations. This
Thi s means that there are 3
channels
channe ls open
open to
to the
the disk
disk for
for each
each random
ran dom file:
fil e: one for the com
command channel,,
mand channel
one
one for
for the
the random
random data,
data, and
and the
the other for the sequential data. Thi
seq uential data. Thiss also means
that
that there
there are
are 22 buffers
buffers that
that you're filling
filling up at the same time.
time.
28
28
BUFFER-POINTER
BUFFER·POINTER
pointer keeps track of where the last piece of data was wri
The buffer painter written.
tten. It
pointer for where the next piece of data is to be read. By changing
also is the painter
pointer's location within the buffer,
the buffer painter's buffer, yo
youu can get random access to the
individual bytes within a block. This way, you can subdivide each block into
records.
example, let
For example, let's hypothetical
's take a hypotheti mailing
cal mai ling list. The information such as
name, address,
name, address, etc.,
etc., will take up a total of 64 characters maximum. We cou could
ld
divide each block of the random access file into 4 separate records records,, and by
track, sector,
knowing the track, sector, and record numbers, we can access that indiviindividual
dual
record.
FORMAT FOR BUFFER·POINTER
BUFFER-POINTER COM
COMMAND:
MAND:
PRINT#file#,
PRINT#fil e# , ""BUFFER-POINTER:" channel; location
BUFFE R-POINTER:" channel;
or abbreviated as
PRINT#file#, ""B-P:"
PRINT#file#, channel;; location
B-P:" channel
EXAMPLE OF SETIING
EXAMPLE SETTING POINTER
POINTER TO 64TH CHARACTE
CHARACTERR OF BUFFER:
BUFFE R:
v
PRINT# 15,
15, ""B-P:" 5; 64
B·P:" 5;
v PRiNT#file#,
PRINT#file#, "UA:"
"UA:" channel; drive;
dri ve; track; sector
sec tor
There is no
no difference
difference between
between the U1
U1 and UA designations for this com
com-
mand.
mand.
v
The
The BLOCK-WRITE
BLOCK-WRITE command writes the contents of the buffer to the block block
on
on the disk
disk along with the value ofof the buffer-pointer.
buffer,pointer. The USER2 command
writes
writes the buffer
buffer without
without disturbing
disturbing the buffer-pointer
buffer-painter value
value already
already stored
stored on
on
that
that block of
of the diskette.
diskette. This
This is
is useful
useful when aa block is to be read in in with
with
BLOCK-READ,
BLOCK·READ, updated
updated through the BUFFER-POINTER
BU FF ER·POINTER and and PRINT#
PR INT#
statements,
statements, and
and then
then written
written back
back to
to the
the diskette with
with USER2.
FORMAT
FORMAT FOR
FOR USER2
USER2 COMMAND:
COM MAND:
PR)NT#file#,
PRINT#file# , "U2:"
" U2:" channel;
channe l; drive;
drive; track;
track; sector
sector
v or
or
PRINT#file#.
PRINT#file#, "UB:"
" UB:" channel:
channel ; drive;
drive; track;
track; sector
sector
29
29
v
Downloaded from www.Manualslib.com manuals search engine
CHART
CHART OF
OF BASIC
BASIC COMMANDS
COMMANDS FOR
FOR DISKS
DISKS AND
AND PRINTERS
PRINTERS
This
This chart
chart lists
lisls the
Ihe BASIC
BASIC commands
commands and
and statements
slalemenls that
that are
are used
used to
to per
per-
form
form operations
operations with
with disk
disk drives.
drives. Commands
Commands marked
marked with
with aa "• sign
sign can
can also
also be
be
used
used toto direct
direct output
output to
to printers
printers when
when you
you use
use the
the printer
printer device
device number,
number. which
which
is
is 4.
4. Disk
Disk Operating
Operating Systems
Systems (DOS)
(DOS) error
error messages
messages areare described
described in in Appendix
Appendix
B.
B.
Command Function
Command Function Examples
Examples
CLOSE'■
CLOSE Ends file
Ends file or
or CLOSE 11
CLOSE closes
closes file
file 1,
1. which
which
closes channel must
must have
have been
been
to aa device
to device previously
previously OPENed
OPENed
with
with the
the same
same
number
number
CMD'■
CMD Redirects output
Redirects output OPEN
OPEN 1,8,'1SCOTT"
1.8."SCOn" file
file must
must be
be OPENed
OPENed
from screen
from screen to
to first
first
device named
device named CMD
CMD11 sends
sends file
file 11 output
output to
to
disk
OPEN
OPEN 1,4:CMD
1.4:CMD 11 sends output
output to
to
printer
GET#
GET# Reads characters OPEN
OPEN 1,8,"SCOTT"
1.8."SCOn" OPENs
OPENs file 11 on disk.
one by one from GET# 1,A$
1.A$ reads from
from file 1;
1;
device named in assigns data to A$
OPEN statement GET# 1,A,B,C
1.A.B.C reads from file 1;
1;
assigns data to A,
A.
B, then C
then B. C then
back to A, etc.
A. etc.
LOAD Brings programs LOAD .."*",8
.. ·.8 loads 11st
st program
into current on disk
memory from disk LOAD ""SCM",8
SCM " .8 loads file SCM from
disk
LOAD "$".8
"$",8 loads file directory
(key in LIST to
{key
display)
INITIALIZE Returns drive to the OPEN 15.8.15."1"
15,8,15,"!" OPENs command
same state as when channel (15). When
you turned it on. command channel is
Use when error OPEN,. the
OPEN
prevents disk INITIALIZE command
operations. device
is sent to the device
named (the disk
named
drive, device 8).
drive.
INPUT#
1NPUT# Retrieves
Retrieves data 1,8,"MEYER"
OPEN 1.8."MEYER" OPENs file 11 on disk
stored on disk INPUT# 1.A.B
INPUT# 1,A,B reads data.
reads data, assigns
to variables
to variables AA and
and B
B
NEW
NEW Headers
Headers diskette. 15,8.15"N0:
OPEN 15.8.15" NO: OPENs file SCM. NO
Also erases SCM.01" means NEW
means NEW disk in
diskette. drive 0. SCM is
drive O. SCM is the
the
name of
name of the disk. 01
is
is the disk
disk id.
30
v
OPEN *
OPEN· Opens channel for 1,8,8,"D,W""
OPEN 1,8,8,"D,W opens file D on disk.
input or output W means write to
to a peripheral file.. 8 is the
file
secondary address,
required for disk. See
Appendix S.
OPEN 1,4 opens channel to
printer
prin ter
1,8.0
OPEN 1,8,0 opens file 11 to read
from disk
PRINT# *• Writes data to a OPEN 1,B,8,"SCM"
OPEN 1,8,8,"SCM" opens disk file 11 to
file write
PRINTS 1,"
PRINT# 1,"A";"B"
A" ;" B" writes A and B B to
1
file 1
1
CLOSE 1 writi ng to file 1
ends writing 1
v
RENAME
RENAM E Changes a file OPEN 15,8,15,"R: RENAMES
RENAM Es fifile
le 15.
name. newname
new name = old
name"
v
15,8,15,-R:
OPEN 15,8,15,"R: RENAMEs
RENAMES file
SCM = MEYER"
SCM= MEYER,
MEY ER, changing it
to SCM
SAVE Stores program SAVE ""SCM",8
SCM",8 stores file
fi le SCM on
disk
SCRATCH Erase files from
from OPEN 15,8,15"S:
OPEN Erases file GMS
disk GMS"
OPEN
OP EN 15,8,15"S: Erases all files that
M*"
M* " start with M.
Appendix
Appendix S
S and
and the
the Commodore
Commodore 64
64 Programmer's
Programmer's Reference
Reference Guide
Gu ide contain
contain
more
more information
information about
about these BASIC
BASIC commands and
and statements.
statements.
The 64 Programmer's
The Programmer's Reference
Reference Guide
Guide explains
explains all
all BASIC
BASIC version
vers ion 2.0
2.0 com
com·
v mands
mands and
and statements.
sta tement s. The
The Commodore
Commodore Peripheral
Peripheral Guide
Guide contains
conta ins more
more
detailed
detail ed information
information and
and sample
sample programs
programs for
for using
using disk
disk drives
drives and
and printers.
pri nters.
There
There books
books are
are available
available at
at bookstores
bookstores and
and from
from your
yo ur Commodore
Commodore dealer.
dealer.
31
31
n
n
—
—■
—■
PRINTING
PRINTING AND CALCULATING
CALCULATING
If you
If you don't know
know BASIC,
BASIC, this
this section
section teaches
teaches you
you how
how to
to do
do some
some simple
simple
things like
things like print
print words
words and
and calculate
calculate problems.
problems.
The PRINT statement tells
The tells the 64 computer
the 64 computer to
to print
print something
something on
on the
the screen.
screen.
PRINT
PRINT is
is one
one of
of the
the most useful
useful and
and powerful
powerful commands in
in the
the BASIC
BASIC
language. You
language. You can
can use itit to
to display
display just
just about anything,
anything, including graphics
graphics and
and
the
the results of computations.
computations. To
To use
use the PRINT
PRINT command,
command , follow these steps:
1.
1. Key in
in the word
word PRINT.
PRINT. This
This tells the
the computer what kind of job
job you want
want it
do.
to do.
2. Key in a
a quotation
quotation mark.
mark. This tells
tel ls the
the computer
computer where the message you
you
want to print begins.
3. Key in
in whatever you want to print on the
the screen.
4. Key in a closing quotation mark. This tells the computer where the message
you want to print ends.
you
5. Press the RETURN key.
key. This
Thi s tells the computer to follow your instructions,
which in this case is to print your message exactly as you typed it.
The
Th e Executive 64 prints whatever you enclosed in quotes. Remember to key
in both quotation marks.
If you make a mistake in your PRINT statement, useuse the INSTfDEL
INST/DEL key to cor-
cor
rect your error. You like before you press
You can change as many characters as you like
the RETURN key.
mistake that you didn
If you made a mistake didn't
't catch before you pressed the RETURN
Instead, it displays an error
key, the computer can't follow your instructions. Instead,
help you figure out what you did wrong. For example:
message to help
?SYNTAX
7SYNTAX ERROR
ERROR
32
v USING
USING PRINT
PRINT TO
TO CALCULATE
CALCULATE
You
You can
can use
use PRINT
PRINT to
10 do
do more
more than
Ihan just
just display
display what
what you
you put
put in
in quotation
quotation
marks.
marks. You
You can
can also
also use
use itit to
to perform
perform calculations
calcu lations and
and automatically
automatically display
display
th e results.
the results. Follow
Follow these
these steps:
steps:
1. Key
1. Key in
in PRINT
PRINT
2.
2. Key
Key in
in the
the calculation
calculation you
you want
wa nt to
to solve.
solve. DON'T
DON'T enclose
enclose itit in
in quotation
quotation
marks.
marks.
3.
3. Press
Press the
the RETURN
RETURN key.
key. The
The computer
computer displays
displays the
th e answer
answer followed
followed by
by the
the
READY prompt.
READY prompt.
v Here's
Here's an
an example:
example:
PRINT
PRINT 12 + 12
12 + 12 Type
Type this
this line
line and
and press
press RETURN
RETURN
24
24
v The computer
comp uter displays
displays
READY
READY The
v •
■
Be
Be sure you
you leave off the
the
the answer
answer
the quotation
quotation marks when
when you
you want
want the computer
computer to
to
solve
solve aa problem.
problem. If you type the
the problem
problem inside quotation
quotation marks,
marks, the
the computer
computer
v assumes youyou just
just want
want to
to display
display the
the problem, not solve it. For example:
PRINT "12 + 12"
" 12 + in this
Key in this line
12 + 12
12 + 12 and press RETURN
and RETURN
u READY
READY The computer displays
displays
•
■ what 's in
what's in quotes
So all you have to do to use PRINT as a calculator is omit the quotation
marks. You can use PRINT to add,
add, subtract, multiply
multiply and divide.
divide. You can also
v use exponents and perform advanced mathematical functions such as figuring
figu rin g
square roots.
MATHEMATICAL FUNCTIONS
ADDITION
SUBTRACTION
Use the minus
minus sign (-) to subtract. Press the RETU RN key at th
RETURN thee end of the
calculation. For example:
PRINT 12 - 9
12-9 in this and RETURN
Key in RETURN
3 this
The computer displays thi s
MULTIPLICATION
MULTIPLICATION
PRINT 12
PRINT 12 ** 12
12 Key in
Key in this and RETURN
RETURN
144
144 The
The compu
computer ter displays this
33
33
DIVISION
DIVISION
Use the
Use the slash mark
mark (~
(/) for divisio
division. Press the
n. Press the RETURN
RETURN key
key after you
you type
type the
the
calculation. For
calculation. For example:
,—,
PRINT 144/12
PRINT 144/12 Key in
Key in this and RETURN
RETURN
12
12 The computer displays this
EXPONENTIATION
EXP ONENTIATION
Use the up arrow ((t
Use t )) to raise a number
number to a power. Press the RETURN
RETURN key
after you type the calculation. For example, to find 12 to the fifth power, type
this:
PRINT 12 tt 5 RETURN
Key in this and RETURN
248832 The computer displays this
—
This is the same as:
PRINT 12 • 12 •* 12 •* 12 •* 12
248832 .—V
TIP:
TIP:
BASIC has shortcuts that make programming even faster. One shortcut is abo ab
keywords. For example,
breviating BASIC keywords. example, you can use a ?? in place of PRINT.
book, we
Throughout this book, we'll BASIC keywords.
'll show you other abbreviations for BASIC
Appendix D D lists these abbreviations and shows what is displayed on the
screen when you type the abbreviated form
form..
"
~-
34
34
? 3 "5-
?3 * 5 _ 7+2
7 + 2 Key in this and RETURN
10 The computer displays this
v
So far our examples have used small numbers and simple problems. But the
v 64 can do much more complex calculations. The next example adds large
numbers.
Notice that 78956.87 doesn't have a comma between the 8 and the 9. You
BASIC. BASIC thinks commas indicate new
can't use commas this way in BASIC.
v numbers,
numbers, so it would think 78,956.87
78.956.87 is tw
twoo numbers:
numbers: 78 and 956.87. Remember
to press RETURN after you type the problem.
? 1234.5 + 3457.8 + 78956.87
?
83649.17
83649. 17
The next example
The example uses a ten digit number. The 64 can work with numbers
that have up to ten dig
digits,
its, but can only display nine digits in the answer. So the
64 rounds numbers that are more than nine digits. Numbers five and over are
v rounded up,
up, and numbers four and under are rounded down. This means that
12123123.5. Because of rounding,
12123123.45 is rounded to 12123123.5. rounding, the computer
doesn't give the same answer you'd get if you added these numbers by hand. In
this case,
case, the answer is 12131364.817. You can see the difference ro rounding
unding
v
makes.
makes.
?
? 12123123.45
12123123.45 + 345.78 + 7895.687
v 12131364.9
The
The 64 prints
pri nts numbers between 0.01
0.01 and
and 999,999,999 using standard nota·
nota
tion,
tion , except for leaving out
out commas in large numbers.
numbers. Numbers outside this
range are printed using scientific notation. Scientific notation lets you
yo u express
a
a very large or very small
smal l number
number as aa power of
of 10. For example:
v
?123000000000000000
? 123000000000000000
v 1.23E+17
1.23E + 17
Another way of expressing this number is is 1.23
1.23 *" 10
10 117.
! 17. The
The 64 uses scien
scien-
tific notation
notation for
for numbers with lots of digits
digits to
to make them easier to read.
read.
There
There is
is a limit to
to the numbers
numbers the
the computer
computer can handle,
hand le, even
even using scien
scien·
tific
tific notation.
notation. These
The se limits are:
v
Largest
Largest numbers: +/- 1.70141183E + 38
1.70 141183E+38
v Smallest numbers:
numbers: +/-
+ / - 2.93873588E-39
2.93873588E - 39
35
35
You get 14 because the parentheses allow 20 and 8 to be added before the
division occurs.
order, and the
Here's another example that shows how you can change the order,
answer, wi th parentheses:
with
? 30 + 15 "2 - 3
15-2-3
57
? (30 + 15) "* 2 -- 3
87
30 + 15 " (2 -- 3)
??30
15
(30 + 15)"
??(30 15) * (2 -- 3)
-45
last example has
The last has two calcu
calculations in parentheses.
lations in parentheses. As usual,
usual, they're
left to right,
evaluated from left right, and then the rest
rest of
of the problem
problem is
is solved.
solved. When
have more
you have more than one
one calcul
calculation in paren
ation in parentheses, can furthe
theses, you can furtherr con
control
trol the
order by
order by using parentheses
parentheses withi
within parentheses. The problem
n parentheses. problem in
in the
the innermost
innermost
parentheses is
parentheses is solved
solved fifirst. For example:
rst. For example:
30 +
?? 30 + (15
(15 "' (2
(2 -- 3))
3))
15
15
In this
In this case,
case, 33 isis subtracted
subtracted from
from 2,
2, then
then 15
15 is
is multiplied
multiplied by
by -- 1,
1, and
and -- 15
15 is
is
added to
added to 30.
30. As
As you
you experiment
experiment wi
with solving calculations,
th solving calculations, you'll
you'll get
get fami
familiar
liar
with the
with the order
order in
in which
which mixed
mixed calculat
calculations are solved.
ions are solved.
36
36
? 2 '* 3;4
3:4 -- 6;2 ,t 3;6 4:100 + (- 48)
3:6 f/ 4;100
v 6
6-2 - 2 8 1.51.5 52
37
37
n
-
38
LINE NUMBERS
We mentioned before in step 4 that line numbers tell the computer that
you're
you program. They also tell the computer in what order you want the
're writing a program.
executive. Without line numbers to te
statements in your program to executive. tell com
ll the com·
puter when to follow which instruction, the computer doesn't know what to do
first.
fi rst.
longer and more comp
The longer complex
lex your program is, the more important it is to
remember that the computer relies on you to tell it WH
WHEN
EN to do things, as well
as WHAT to do. One good thing about this is that you can key in line 20 before
line 10 because the computer just checks the line numbers to find out the order
for executing the program
program.. The computer doesn
doesn't
't check for the order your lines
the
appear on th screen.
e screen.
Another advantage of line numbers is that you can use the number to refer to
the statement on the line. When you want to go back and repeat the execution
of aa statement, all
al l you do is refer to it by line
line number in
in a
a GOTO statement,
statement, as
you did
did in the
th e example
example above.
39
39
40
40
LIST
10 PRINT ""COMMODORE":
COMMODORE";
20 GOTO 10
COMMODORE COMMODOR
COMMODORE COMMODOREE COMMODORE COMMODORE
COMMODORE COMMODORE COMMODOR
COMMODORE COMMODORE
E COMMODORE
BREAK IN 10
READY
41
41
equation,
In this equal X and Yare
ion, X Y are variables. Suppose X X slands
stands for Ihe
the number of
days in a month. One of Ihethe best th things
ings about a variable is th that
at you can reuse it
in a prog
in program, can stand fo
ram, so X can forr the days in aallll the months, not just one month.
This is where Y Y comes in. All monmonthsth s have 28 days,
days, so Y stands for the days
over 28. Later in this chapter there's a prog ram that gives values to these two
program
variables.
Th
Thee most important thing
thi ng now is understandi
understanding ng how vari ables work,
variables work, because
variables allow you to do complex tasks with you computer. Variables also let
you write programs that are very reusable.
n
Imagine that your computer contains a bunch of little slots, like a bank of r
mail boxes. When you write a program,
program, you can use some of these slots to hold
hold
values. All you
you do is give a name to the slots you need,
need, and during the program
you can put values into each slot by using the slot's name.
name. For example, in the
above, we used two slots by naming one X
equation above, X and one Y. At the beginning
program, these slots have names, but they're empty.
of a program, empty. Here's what happens
when you put aa value in Y's slot:
X Y
3
20 Y = 3
Since Y equals 28 plus Y, when you RUN the program X's slot gets a value, too.
X Y
31
31 3
Here's
Here's how the program
program looks:
10
10 X
X = 28 + YY
28 +
20
20 Y
Y = 33
30 ? "THE NUMBER
30 NUMBER OF DAYS
DAYS IN MAY IS";X
IS";X
RUN
RUN
THE
TH E NUMBER
NUMB ER OF DAYS IN
IN MAY IS
IS 31
31
Here's
Here's another
another program
program that
that uses
uses variables:
variables:
10
10 X%
X % = 15
15
20 X
X = 23.5
23.5
30
30 X$
X$ = 'TOTAL:11
"TOTAL:"
40
40 Y
Y == X%
X% ++ XX
50
50 ?? X$;Y
X$;Y
42
42
When
When you
you RUN
RUN the program. Y
the program, Y gets a val
value:
ue: 38.5
The
The above
above example
example uses
uses the
the three types of
th ree types of variab
variables:
les:
v POSSIBLE
POSSIBLE
TYPE
TYPE SYMBOL
SYMBOL DESCRIPTION EXAMPLES VALUES
Integer %
% whole numbe
numbers
rs X%
A /o,, A1 %
/o 15,102,3
Text
Text string
stri ng $S characters
characters in X$. AB$
X$, ""TOTAL",
TOTAL",
quotes ""DAY 1"
DAY 1"
Floating
Floating read (decimal) X, AB
X, 23.5, 12,
point
point or whole num
numbers
bers +2
1.3E+2
1.3E
Be
Be sure
sure you
you use
use the
the right variable types in your programs. If you try to do
something
something like
like assign aa text string to an integ
integer variable,, your program won
er variable won't
't
work.
work .
There
There are a few
few other
other things
th ing s to keep in
in mind when you ass
assign
ign names to
variables:
variables:
•• A
A variable
variable name
name can
can have
have one or two characters, not cou
counting special
nting the special
symbol
symbol used
used with
with integer and text string variables.
•• You
You can
can use
use more
more than
than two alphabetic characters in
in a variable name, but
but the
computer
computer only
only recognizes the first two. So the computer would
comp uter wou ld think PA,
PA.
PARTNO
PARTNO and
and PAGENO
PAGENO are the same variable
variab le referring to the same ""slot".
slot" .
•• A
A program
program is
is easier
easier for people to read when you use longer variable names,
but
but when
when you
you use
use more
more than two characters in
in a name,
name, be sure the first two
are
are unique.
unique.
•• You
You can
can use
use X,
X, X%,
X% , and
and XS
X$ in
in one program because the special symbols % %
and $ make each variable
and $ make each vari able name unique.
uniqu e. The same is true of A2, A2%,
A2 , A2% , and
A2$.
A2$.
•• The
The first
fi rst character
charac ter must
must be alphabetic (A to Z). The second and any later
characters
characters cancan be
be either alphabetic or numeric (0(0 to 9). Remember that the
computer
comp uter ignores
ignores every
every character after
after the second unles
unless s it's a % or $ in the
third position.
third position.
•• Variable
Variable names
names can't
can ' t contain
contain BASIC keywords,
keywords, which
wh ich are also called reserv·
reserv
ed
ed words.
words. These
These are
are thethe words
word s like PRINT and RUN that are part of the
BASIC
BASIC language.
language. Appendix
Appendix D D lists
lists all
all the
the BASIC
BASIC reserved words.
wo rd s.
v
43
43
44
44
Line
Li ne 10 gives the variable
the va range
riable CT a rang e of values from 11 to 4, and tells
te lls the com,
com
puter to execute the next lines until CT equals 4.
Line 20 tells the computer to print EXECUTI
EXECUTIVE VE 64.
64.
Line 30 tells the computer to add 11 to ththe value
e current val ue of CT. As long as the
value
val remains
ue of CT rema within
ins withi n the range of 1 1 to 4, the program repeats
repeats,, and EX,
EX
ECUTIVE 64 is PRINTed again.again. When CT equals 4, line 20 executes one more
time. When line 30 again adds 1 1 to CT,
CT. the computer knows that CT is now out
range.. So the computer stops executing the loop,
of range loop, and the program ends by
itself.
45
45
CHAPTER 55
CHAPTER
*-
ADVANCED BASIC
ADVANCED BASIC
•• Introduction
Introduction
•• Simple An imation
Simple Animation
•• INPUT
IN PUT
•• Using
Using the
the GET
GET Statement
Statement for
for Data
Data Input
Input
•• Using
Using GET
GET to
to Program
Program Function
Function Keys
Keys ^
•• Random
Ran dom Numbers
Numbers and
and Other
Other Functions
Functions
•• Guessing Game
Guessing Game
(->
•• Your Roll
Your Roll
•• Random Graphics
Random Graphics
INTRODUCTION
INTRODUCTION
The
The next
next few
few chapters
chap ters are
are for
for people
people who
who are
are familiar
familiar with
with BASIC
BASIC program
program·
ming
ming language
language and
and the
the concepts
concepts necessary
necessary to
to write advanced
advanced programs.
prog rams.
Those
Those of
of you
you who
who are
are just
just starting
st arting to
to learn
learn how
how to
to program
program maymay find
find some
some of
of
the information
information too technical to understand completely.
comp letely. But
But you'll
you 'll find some
some
simple
simple examples
examples that
that are
are written
wri tten for
for new
new users in two
users in two chapters.
chapters, SPRITE
SPRITE
GRAPHICS and CREATING
GRAPH ICS and SOUND. These
CREATING SOUND. examples will
These examples will give you a
give you a good
good idea
idea
of how to use the sophisti
sophisticated
cated graphics and sound capabilities
capabili ties available on
yo ur Exec
your utive 64.
Executive 64.
If you want to learn more about writin writing
g programs in BASIC, check the
bibliography
bibli ography inin the
the back
back ofof this
this manual
manual (Appendix
(Appendix N).
N).
IfIf you
you are
are already
already familiar
familiar with
with BASIC
BASIC programmi
programming, the following
ng, the following chapters
chapters
will help
will help you
you get
get started
started with
with advanced
advanced BASIC
BASIC prog
programming techniques.
ramm ing techn You'll
iques. You 'll
find extensive
find extensive information
information about
about advanced
advanced prog
programming
rammin g inin th
the COMMODORE
e COMMODORE
64 PROGRAMMER'S
64 PROGRAMMER'S REFERENCEREFERENCE GUIDE,GUIDE, which
which is
is available
available through
through your
your
local Commod ore
local Commodore dealer. dealer.
46
46
INDICATES NEW
NEW COMMAND
10 REM BOUNCING BALL
"(CLR/HOME^
20 PRINT "(CLR/HOME "
25 FOR XX = 1 TO 10: PRINT "(CRSR/DOWN)"
"(CRSR/DOWN)":NEXT
:NEXT
30 FOR BL = 1 1 TO 40
40 PRINT" . (CRSR LEFT)";:REM
LEFT)";:REM is a SHIFT - Q
aSHIFT-Q
50 FOR TM
FOR TM =\i TO 5
= 1 TO 5 ----~~----
NEXTTM THESE SPACES
THESE
60 NEXT TM
ARE INTENTIONAL
ARE INTENTIO NAL
70 NEXT BL
75 REM MOVE
MOVEjBALL
BALL RIGHT TO LEFT
80 FOR BL =/40 =
40 TO 11 STEP - - 11
PRINT ""^CRSR
90 PRINT LEFT) (C
(CRSR LEFT) (CRSR LEFT) (CRSR LEFT)";
RSR LEFT)
FOR
100 FO R TM = 11 TO 55
110 NEXTTM
110 NEXT TM
120 NEXT BL
130 GOTO 20
TIP:
All words in this text will
wi ll be completed on on one line. However, as
line. However as lonq
long as
as you
yo u
don 't hit
don't hit £ ' ;liIli'Ii'
your
your 64
64 wil
wi ll automatically to the
au tomatica lly move to the next
next line even
even in
in thp
the
middle
midd le of aa word.
word.
When
When this
this program RUNs,
RUNs, it displays aa bouncing
bouncing ball
ball moving across the
screen from left
screen left to right
ri ght and
and back again. Take
Take aa close
close look at the
the program
program to
to see
how this
th is is done.
done.
Line
Line 10
10 is
is aa REMark
REMark that
that tells
tel ls you
you what
what the
the program
program does.
does. A
A REMark
REMark state
state-
ment
ment has no
no effect on
on the program itself.
itself.
Line
Line 20
20 clears
clears the screen.
screen.
Line
Line 25
25 PRINTs
PRINTs tenten cursor-down
cursor-down commands.
commands. This Thi s just
just positions
positions the
the ball
ball in
in
the
th e middle
middle ofof the
the screen.
screen. Without
Without this
this line,
li ne, the
the ball
ball would
wo uld move
move across
across the
the top
top
line
li ne of the
the screen.
screen.
Line
Line 30
30 sets
sets up
up aa loop
loop to
to move
move the ball
bal l 40
40 columns
column s from left to right.
Line
Line 40
40 does
does three
three things:
things:
1.
1. PRINTs
PRINTs aa space
space to
to erase
erase the
the previous
previous ball
ball positions
positions.
2.
2. PRINTs
PRINTs the
the ball.
ball.
3.
3. Performs
Perform s aa cursor-left
cursor·left to
to get
get ready
ready to
to erase
erase the
the current
current ball
ball position
positi on again.
again.
47
47
Line
line 50
50 and
and 60 60 set
se t up
upaa loop
loop that
that slows
slows downdown the the ball's
ball's movement.
movemen t.WithoutWithou t
this
this loop,
loop, the
the ball
ball would
wo uld move
move tootoo fast
fast for
fo ryou
you toto see
see clearly.
clearly.
Line
line 70
70 completes
completes the the loop
loop set
set up
up inin line
line 3030 to
to PRINT
PRINT balls
balls onon the
the screen.
screen.
Each
Each time
tim e the
the loop
loop executes,
executes, the the ball
ball moves
moves another
anotherspace
space to to the
the right.
right. As
As you
you
can
can see
see from
from thethe illustration,
illustration, the the program
program contains
contains aa loop
loop within
within aa loop.
loop. You
You
can
can include
include up up toto ten
ten loops
loops within
within aa loop.
loop. TheThe only
only time
time you
you getget inin trouble
trouble isis
when
when thethe loops
loops cross
cross overover each
each other.
ot her. The
The loops
loops have
have toto be
be NESTED
NESTED inside inside
each
each other.
other. In
In other
other words,
words, ifif you
you start
start loop
loop AA and
and then
then start
start loop
loop BB inside
insi de loop
loop
A. you must finish loop B (the inside loop) first.
A, you must finish loop B (the inside loop) first.
When
When you're
you 're writing
writing aa program
program with wit h loops,
loops, it's
it's aa good
good idea
idea toto draw
draw arrows
arrows
from
from the
the beginning
beginning to to the
the end
end ofof the
the loops.
loops. IfIf your
your loops
loops cross,
cross , the
th e computer
computer
can't
can't figure
figure out
out what
what you
you want,
want, so
so itit can't
can't execute
execute your
your program.
program .
Lines
lines 80
80 through
through 120120 just
just reverse
reverse thethe steps
steps inin the
the first
first part
part of
of the
the program,
program,
and
and move
move the
the ball
bal l from
from right
right toto left.
left. Line
line 9090 is
is slightly
slightly different
different from
from line
line 40
40
because
because the
the ball
ball is
is moving
moving in in the
the opposite
opposi te direction,
direc ti on, and
and you
you have
have to
to erase
erase the
the
ball
ball to
to the
the right
right and
and move
move toto the
the left.
left.
Line
line 130
130 sends
sends thethe program
program backback to to line
line 20
20 to
to start
start the
the whole
whole process
process over
over
again.
again.
For
Fo r aa variation
variati on on
on the
the program,
prog ram , change
change line
line 40
40 to
to read:
read:
40
40 PRINT
PRINT "<SHIFT>
" <SHIFT> < Q>"
0 >"
Run
Run the
the program
program and
and see
see what
what happens
happens now.
now. Because
Because you
you left
left out
out the
the cursor
curso r
control,
cont rol , each
each ball
ball remains
remains on
on the
the screen
screen until
until it is
is erased
erased by
by the
the ball
ball moving
moving
right to left in
in the
the second
second part of
of the program.
program.
48
48
10 INPUT
10 INPUT A$
A$
20 PRINT ""YOU
20 PRINT TYPED ";AS
YOU TYPED ";A$
PRINT
30 PRINT
40 IF AS = "STOP"
IF A$ "STOP" THEN END
END
50 GOTO
50 GOTO 1010
RUN
RUN
? GO
? GO
YOU TYPED GO
YOU TYPED GO
? CONTINUE
YOU TYPED CONTIN
CONTINUE
UE
? STOP
YOU TYPED STOP
Here's what happens in this program:
Line 10 tells the comp
computer
uter to display a question mark to prompt you to INPUT
a value for AS,
AS, and to wait until you
you supply the value before contin
continuing
uing the pro·
pro
gram execution.
Line 20 PRINTS
PRINTs aa message and the INPUT value, and line 30 PRINTs a blank
line.
line.
Line
Line 40 tells the computer to end the program
program immediately
immediately IF the value you
INPUT
IN PUT for AS
A$ is STOP.
STOP.
Line
Line 50
50 returns the program
program to line
line 10
10 so
so you can INPUT
INPUT another value. IF
IF line
line
40
40 is
is true because
becau se the
the last
last value you
you INPUT
INPUT for A$
AS was STOP,
STOP, then line
line 50
50 isn't
isn't
executed.
executed.
You
You can
can INPUT
INPUT numeric
numeric or
or string
string variables,
variables, and
and you
you can
can have
have the INPUT
INPUT
statement
statement print
print aa message
message along
along with
with aa question
question mark
mark to
to describe
describe the
the kind
kind of
of
INPUT
INPUT the
the computer
computer is
is waiting
waiting for.
for. For
For example,
example, here's
here's what
what happens
happens when
when you
you
add
add aa prompt
prompt message
message to
to line
line 10
10 of
of the
the previous
previous example:
example:
10
10 INPUT
INPUT "KEEP
" KEEP GOING";A$
GOING"; A$ Prompt
Prompt message
message can't
can 't
RUN
RUN be
be more
more than
than 38
38
KEEP
KEEP GOING?
GOING? GOGO characters
characters
YOU
YOU TYPED
TYPED GO
GO
v KEEP
KEEP GOING?
GOING? STOP
STOP
YOU
YOU TYPED
TYPED STOP
STOP
v
v
49
49
NEW
NEW
11 REM
REM TEMPERATURE
TEMPERATURE CONVERSION
CONVERSION PROGRAM
PROGRAM
55 PRINT "(CLR/HOME)"
PRINT " (CLRlH OM E)"
10
10 PRINT
PRINT "CONVERT
"CONVERT FROM
FROM FAHRENHEIT
FAHRENHEIT OR
OR CELSIUS
CELSIUS (F/C)":INPUT
(F/C)": INPUT A$
AS
20
20 AS == ""THEN
IF AS
IF "" THEN 10
10
30
30 IF AS == "F"THEN
IF AS " F" THEN 100
100
40
40 IF <>
"c" THEN
IF A$O"C"
AS THEN END
END
50
50 INPUT
INPUT "ENTER
" ENTER DEGREES
DEGREES CELSUIS:
CELSU IS: ";C" ;C
60
60 FF == (C*9)/5
(C ' 9V5+ 32
+ 32
70
70 PRINT
PRINT C;"
C;" DEG. CELSIUS == ";"; F;"
DEG. CELSIUS F;" DEG.
DEG. FAHRENHEIT"
FAH RENHEIT"
80
80 PRINT
PRINT
90
90 GOTO 10
GOTO 10
100
100 INPUT
INPUT "ENTER
"ENTER DEGREES
DEGREES FAHRENHEIT:
FAHRENHEIT: ";F ";F
110
110 C = (F-32)'5/9
C = (F-32)'5/9
120
120 PRINT
PRINT F:"
F;" DEG.FAHRENHEIT
DEG.FAHRENHEIT == ";C:" ";C;" DEG.
DEG . CELSIUS"
CELSIUS"
130
130 PRIN T
PRINT
140
140 GOTO 10
GOTO 10
Line
Lin e 10
10 uses
uses the
the INPUT
INPUT statement
statement to
to print
print aa prompt
promp t message
message and
and to
to wait
wait for
for
you to
you to type in aa value
type in value for
for A$.
AS.
Lines
Lines 20.
20, 30
30 and
and 40
40 check what
what you
yo u typed
typed in
in and
and tell
tell the
the computer
computer where
where to
go
go next.
next. Line
Li ne 20
20 tells
tells the
the computer
computer to
to go
go back
back to
to line
line 10
10 and
and ask
ask for
for INPUT
IN PUT again
again
IF
IF nothing
nothing waswas typed
typed inin (IF
(IF just
just RETURN
RETURN was
was pressed).
pressed). Line
Line 30
30 tells
tel ls the
the com
com-
puter to go straight to line
line 100
100 and perform
perform the
the Fahrenheit-to-Celsius
Fahrenheit-to-Ce lsius conver
conver-
sion IF the val ue you
value you typed for
for A$
AS is
is F.
F.
Line 40
Line 40 checks
checks to
to be
be sure
sure that
that you
you haven't
haven't typed in anything
typed in anything beside
beside F
F or
or C.
C. IF
IF
you have, line 40 ends the program. IF yo youu typed in a C, C. the computer
automatically moves
automatically moves to
to line
line 50
50 to
to perform
perform the
the Celsius-ta-Fahren
Celsius-to-Fahrenheit conversion..
heit conversion
ItIt may
may seem
seem like
like too
too much
much detail
detail to
to include
include all
all these
these IF
IF statements
statements to
to ccheck
heck
what you INPUT. But But this is a good programming
programming practice that can spare you a
lot of frustration. You should always try to be be sure that your program
program takes care
of
of allall possibilities.
possibilities.
Back to the example:
Back example: once
once the program
program knows
knows what
what type of conversi
conversion
on to
make, the
make, the calculations are made.
made. Then
Then the program
program PRINTs
PRINTS the temperature
you
you entered
entered and
and the
the converted
converted temperature.
temperature.
The calcu
The calculation this
lation thi program performs
s program performs isis just
just straight
straight math,
math, using
using the
the slan-
stan
dard formula
dard formula for
for temperature
temperature conve
conversion. After the
rsion . After the calculation
calculation finishes
finishes and
and the
the
answer is
answer is PRINTed
PRINTed., the
the program
program loops
loops back
back and
and starts
starts over.
over.
Here's aa sample
Here's sample exec
execution of th
ution of this program::
is program
CONVERT
CO FROM FAHRENHEIT
NVERT FROM FAHRENHEIT OR OR CELSIUS
CELSIUS (F/C):
(F/C): ?F
?F
ENTER
ENTER DEGREES FAHRENHEIT: 32
DEGREES FAHRENHEIT: 32
32 DEG
32 FAHRENHEIT =- 00 DEG
DEG.. FAHRENHEIT DEG.. CELSIUS
CELSIUS
CONVERT FROM
CONVERT FROM FAHRENH
FAHRENHEIT OR CELSIUS
EIT OR CELSIUS (F/C):
(F/C): ??
After you
After you RUN
RUN this
this program,
program, you
you might
might want
want to
to save
save itit on
on disk.
disk. This
This program,
program,
as wel
as welll as
as others
others in
in this
this manual,
manual, can
can fo
form part of
rm part of yo
your program library.
ur program library.
n
50
50
n
Downloaded from www.Manualslib.com manuals search engine
n
USING THE GET STATEMENT FOR DATA INPUT
press
GET lets you input one character at a time from the keyboard without press·
ing the RETURN key.
key. This really speeds up entering data in many cases.
When you RUN a program that has a GET statement, whatever key you press
include
is assigned to the variable you inc exam
lude in the GET statement. Here's an exam·
ple:
pie:
11 < CLRlHOM E >"
PRINT ""<CLR/HOME>"
10 AS: IF A$
GET A$: AS ;= """
" THEN 10 No space between
20 PRINT A$;
A$; quotes
30 GOTO 10
Line
Li ne 11 clears the screen.
Line
li keyboard.. In
ne 10 lets you type in any key on the keyboard In effect
effect,, the loop in line 10
tells
tel computer
ls the comp uter to wait until you type in a key before moving to line 20.
Line 20 displays the keys you type on the screen.
line screen.
Line 30 sends the program back to GET another character.
line character. It's important to
remember that the character you type in won won't't be displayed uniessyou
unless you PRINT it
screen, as we've done in line 20.
to the screen,
The IF statement
slatement in line 10 is very important. GET continually works,works, even if
you
yo INPUT, which waits for your response),
u don't press a key (unlike INPUT, response), so the se·
se
continually
cond part of line 10 contin ually checks the keyboard until you hit a key.
Try leaving out the second part of line 10 10 and see what happens.
To stop this program,
program, press the RUN/STOP
RUN/STOP and RESTORE
RESTORE keys.
You can easily rewrite the beginning of the temperature conversion program
to use GET instead of INPUT. If you've SAVEd this program, program, LOAD it and
change lines 10 and 20 like this:
10 PRINT "CONVERT FROM FAHRENHEIT OR CELSIUS (F/C)"
20 GET A$: IF AS
A$ =
; "" THEN 20
51
51
f1
f1 == CHRS(133)
CHR$(133) f2
f2 == CHRS(137)
CHRS(137)
f3
f3 == CHRS(134)
CHRS(134) f4
f4 == CHR$(138)
CHR$(138)
f5
f5 =- CHR$(135)
CHR$(135) f6
f6 == CHR$(139)
CHRS039)
f7
f7 == CHR$(136)
CHR${136) f8
f8 == CHRS(140)
CHRS(140)
The COMMODORE
The COMMODORE 64 64 PROGRAMMER'S
PROGRAMMER'S REFERENCE
REFERENCE GUID
GUIDE has more
E has more in·
in
formation about
formation about programming
programming function
function keys
keys.. You
You can
can purchase
purchase this
this extensive
extensive
guide from
guide from you
your local Commodore
r local Commodore dealer.
dealer.
52
52
.789280697 .664673958
.256373663 .0123442287
.682952381
.682952381 3.90587279E-04
3.90587279E - 04
.402342724 .879300926
.158209063 .245596701
Your numbers don'tdon't match? It woul
wouldd be incredible if they did because the
program generates a completely
completely random list of tenten numbers.
If you RUN the program a a few more time, you'll see that the the results are
always different. Though
Th ough the numbers don't have a
don 't have a pattern, you'll
you' ll notice aa few
cons istencies about the list the
consistencies the program
program displays.
displays.
v For one thing,
thing , the results are always between 11 and 0. 0, but never equal to 11 or
0.
O. For
For another,
another, the
the numbers
numbers are
are real
real numbers (with decimal points).
pOints).
Now,
Now, we started out to
to simulate dice tosses,
tosses, and
and the
the results from this
this pro
pro.
gram aren't
gram aren't exactly
exactly what
what we're
we're looking for. Now we'll
we'll add
add aa few more
more features
to
to this
this program
program to get what we
we want.
want.
First,
First, add
add this line
line to
to the program
program to replace line 20,
20, and RUN the program
program
aaain:
again:
20
20 PRINT 6*RND(1),
6'RND(1),
RUN
RUN
3.60563664 4.52687513
4.52687513
5.48602315
5.48602315 1.09650123
1.09650123
3.10045018
3. 10045018 4.39052168
4.39052168
3.91302584 5.06321506
5.0632 1506
2.32056144
2.32056144 4.10781302
4.1078 1302
v
v
53
53
Now
Now we've
we've got
got results
results larger
larger than
than 1.
1, but
but still
still have
have real
real numbers.
numbers. To
To solve
solve this,
this,
we'll use
we'll use another
another function.
fu nction.
The
The INT
INT function
function converts
conve rts real
real numbers
numbers to
to integer
integer (whole)
(whole) numbers.
numbers. So
So try
try
replacing line 20
replac ing line 20 again:
again:
20
20 PRINT
PRINT INT(6'RND(1)),
INT(6 " RND(1)), "
RUN
RUN
2
2 3
3 1
100
2
2 4
4 5
5 5
5 ~
o
0 11
Now
Now we're
we're even
even closer
closer to
to our
our goal,
goal, but
but you'll
you 'll notice
notice that
that the
the numbers
numbers range
range
from
from 11 to
to 5,
5, not
not 11 to
to 6. So
So as aa final step,
step, we'll
we 'll replace line
line 20 again:
20 PRINT
20 PRINT INT(6'RND(1)) + 11
INT(6" RND(1)) +
Now
Now when
when you
you RUN
RUN the
the program,
program, you'll
you'll get
get the
the results
results you
you want.
want.
When
When you
you want
want to
to generate
generate aa range
range ofof real
real numbers instead
instead of
of whole
whole
numbers,
numbers, the
the formula is
is slightly
slightly different
different because
because you
you must
must subtract
subtract the
the lower
lower
limit of
of the range from the upper
upper limit. For
For example,
example, you
you can generate
generate random
numbers 25 by typing:
numbers between 11 and 25 typing:
20 PRINT
20 PRINT RND(1)'(25-1) + 11
RND(1)" (25- 1) +
The
T he general
general formula for generating random numbers
numbers in a certain range is:
NUMBER = RND{1)
RND(1) *(UPPER
"(UPPER LIMIT -
- LOWER + LOWER LIMIT
LOWER LIMIT) +
54
NEW
NEW
11
22
55
REM NUMBER
REM
PRINT
INPUT
NUMB ER GUESSING
GUESSIN G GAME
"(CLR/HOME)"
PRINT "(CLRlHOME)"
IN PUT -'ENTER
"ENTER UPPER
GAME
UPPER LIMIT
LIMIT FOR
FOR GUESS
GUESS ";LI
";LI
-------.r----'--_
INDICATES
INDICATES NO
NO
10
10 NM =
NM = INT(LI*RND(1))+1
INT(LI·RND(l))+ 1 SPACE
SPACE AFTER
AFTER
15
15 =
CN = 00
CN QUOTATION
QUOTATION MARK
MARK
20
20 PRINT
PRINT "I'VE
" I'VE GOT
GOT THE
THE NUMBER.":PRINT
NUM BER.": PRINT
30
30 INPUT "'WHAT'S
INPUT "WHAT'S YOUR
YOU R GUESS";
GU ESS"; GU
GU
35
35 CN =
CN = CN
CN +
+ 11
40
40 IFGU>NM
IF GU > NM THEN
TH EN PRINT
PRINT "MY
" MY NUMBER
NUMBER IS
IS LOWER":
LOWER": PRINT:GOTO
PRINT:GOTO 30
30
50
50 IF
IF GU<
GU < NM
NM THEN
THEN PRINT
PRINT "MY
" MY NUMBER
NUMBER IS
IS HIGHER":
HIGHER" : PRINT:GOTO
PRINT:GOTO 30
30
60
60 PRINT
PRINT "GREAT!
" GREAT! YOU
YOU GOT
GOT MY
MY NUMBER"
65
65 PRINT
PRINT "IN
" IN ONLY
ONLY "';
"; CN
CN ;"GUESSES.":PRINT
;"GUESSES." :PRINT
70
70 PRINT
PRiNT "DO
" DO YOU
YOU WANT
WANT TO
TO TRY ANOTHER
ANOTHER (Y/N)";
(YIN)";
80 GET
80 GET AN$:
AN $: IF
IF AN$=""
AN$= ,'" THEN
THEN 80
80
90 IF
90 IF AN$
AN$ == "Y"
" Y" THEN
THEN 22
100 IF
100 IF AN$<
AN$ >"N" <>
"N" THEN 70
110 END
110 END
You
You can specify how
how large
large the
the number will
wil l be
be at the start
start of
of the program.
'-' Then,
Then, it's up to you to guess what the number is.
A sample
sample run follows
fo llows along with an explanation.
explanation .
WHAT'S YOUR
YOUR GUESS ? 20
MY NUMBER IS LOWER.
v
WHAT'S YOUR GUESS ? 19
19
GREAT
GREAT!! YOU GOT MY
MY NUMBER
IN
IN ONLY 3 GUESSES.
55
55
The IFfTHEN
IF/THEN statemen
statementt (li nes 40-60)
(lines 40-60) compare your guess to the random
number (NM) generated by line 10. 10. If your guess is wrong,
wrong , the program tell s you
tells
whether yo ur guess is higher or lower than NM
your NM..
Each titime
me yo u make a guess,
you guess, line 35 adds 1 1 to CN
CN.. CN is a counter that keeps
track of how many guesses you take to get the riright ght number. Th e purpose of
The
this
thi game, of course,
s game, course, is to guess the number in as few tri
tries
es as possible.
When you get the right answer,
answer, the prog ram displays the message,
program message. GREAT
GREAT!!
YOU GOT MY NUMBER,
NUMBER, and tel ls you how many guesses you look.
tells took.
Remember that the program ccreates each time
rea tes a new random number each tim e you
play the game
game.. .
You might want to add a few lines to the program that also specify the lower
range of numbers generated by this game.
game.
PROGRAMMING
PROGRAMM ING TIPS:
lines
In line 50. a colon separat
s 40 and 50, separates multiple
es mu ltiple statements on a single line.
Th is not on
This ly saves typing
only typing time,
time, but it also conserves memory space.
Also notice that the IFfTHEN
IF/THEN statements in these two lines PRINT some thi ng
something
before
bef ore branching to another liline.
ne.
YOUR ROll
ROLL
The fo llowing program simulates the throw of two
following Iwo dice. You can play this lit·
dice. You lit
tle game by itself,
tie itseif, or use it as part of a larger game.
From
F ro m what yoyou've random
u've learned about BASIC and rand numbers,
om nu you can
mbers , see if you
what's
follow what program.
's going on in this progra you
m. As yo recall
u may reca ll from the section on
programming
programm keys, CHR$(32) is the cha
ing the function keys, character
racter string code for the
space bar.
56
If you
If you type:
type:
PRINT CHR${205);CHR$(206)
PRINT CHR$(205);C HR$(206)
the computer displays the two right side graphics on the M M and N N keys,
keys, which
are the characters used in the little maze program you you just tried.
The formula 205.5 + RND(1
RND(1)) tells the computer to pick a random number bet· bet
ween 205.5 and 206.5 There is fifty-fifty
fifty· fifty chance that the random number will be
CHRS ignores fractional values, so half the time the
above or below 206. CHR$
printed,, and the rest of the time code 206 is
character with code 205 is printed
displayed.
displayed.
You can experiment with this program by adding or subtracting a couple of
tenths from 205.5. This gives either character a greater chance of being
displayed.
displayed.
v
v
v
57
57
CHAPTER
CHAPTER 66
COLOR AND
COLOR AND GRAPHICS
GRAPHICS
•• How
How to
to Use
Use Color
Color and
and Graphics
Graphics on
on Your
Your Computer
Compu ter
•• Prin ting Colors
Printing Colors
•• Color CHR$
Color CHR$ Codes
Codes
•• How to
How to Use
Use PEEKs
PEEKs and
and POKES
POKEs
•• Screen Graphics
Screen Graphics
• Screen
Screen Memory
Memory Map
Map
• Color Memory
Color Memory Map
Map
• More
More Bouncing Balls
Balls
—
HOW
HOW TO USE
USE COLOR
COLOR AND GRAPHICS
GRAPHICS ON YOUR COMPUTER
So
So far
far this
this book has presented
presented some of the the sophisticated
sophisticated computing
capabilities
capabilities of
of your
your 64.
64. But one
one of
of the
the most
most exciting
exciting features
features of your
your new com
com·
puter
puter is its outstanding
outstanding ability
abi lity to produce 16
16 different colors
colo rs and aa lot of dif
dif·
fe rent graphics.
ferent
You've
You 've already
al ready seen
seen aa very simple
simple demonstration
demonstration of the graphics in the
the boun
boun-
cing
cing ball program and
and in the maze program at the end of the last chapter. This
chapter introduces you to new concepts that explain graphic and color
programming, and that suggest
programming, for creating your
sugges t ideas for your own games and advanc-
advanc
ed animation.
<-
58
PRINTING COLORS
When you tried the color ali gment tes
aligment testt in Chap ter 1,
Chapter 1, you discovered that you
colors
can change text co lors by simply holding down the CTR CTRL L key and pressing one
of the color keys.
The 64 offers a full range of 16 colors. Though only eight colors are printed on
you
the color keys, yo u can get eight more by holding down the C = - key and press-
press
key. Here's a list of the colors:
ing a color key.
•
KEYBOARD COLOR: DISPLAY KEYBOARD COLOR DISPLAY
milD ~D
.~
BLACK ■ ORANGE ••
milD WHITE III ~D BROWN
BRO WN fJ
m
~ ~EI ~
*
RED
C YAN
PURPLE
~
•
ii
0n
~a
~D
LT
LT.. RED
GRAY
G RAY 11
GRAY 2
..
1
~
« i
ii
II
GREEN ~D IT.
LT. GREEN
milD
BLUE
YELLOW
=
B
m
m
~D
~D
LT
LT.. BLUE
GRAY 3 ..
0□
••
'-'
'-'
v
v
v
v
59
59
mIIaOODDDD
You'll
You'll recall
recal l that cursor
cu rsor controls appear as
as graphic
graphic characters in
in the PRINT
PRINT
statement. Color controls areare also
also represented as
as graphic characters. The color
chart printed above shows the graphic characters that appear with each each color.
color.
Because ofof the graphic characters
characte rs that are displayed when you select color
keys, your PRINT statement will
keys, will look strange,
strange, but when you RUN
RUN the
th e program,
program ,
you' ll see that
you'll that only the
the text of the message is displayed. The letters in
in the
the
au tomatical ly change colors
message automatically colo rs according
according to the color
co lor controls you plac
plac·
ed in
in the PRINT statement.
Now try making up some examples of your own
own,, mixing any nu
number
mber of colors
within a single PRINT statement. Don't forget
lorget the second se
sett of colors
colors that you
can get by holding down the ~
can Cs key while you press a color key.
key
TIP:
TIP:
After you
you RUN aa program with color or mode (reverse) changes,
changes, you' ll notice
you'll
that the READY prompt and any add itional text yo
additional youu key in is the same as the
last co lor or mode change you made. To get back to the normal display, press
color
these keys together:
RUN /STOP and RESTORE
RUN/STOP
60
CHRS(28) CHANGES
CHR$(28) CHANGES ME
ME TO?
TO?
When
When you
you RUN
RUN this
this program,
program, the the screen
screen clears
c lears before
before the
the message
message in in line
line 20
20
is PRINTed. The
is PRINTed. The texttext should be red now.
now.
In
In many
many cases,
cases, you'll
you 'll find
find that it's much
much easier to useuse the CHRS function
funct ion toto
change
change colors,
colors, especially
especially if youyou want to to experiment.
experiment. The
The next
next page
page shows
shows
another
ano ther way
way to
to get
get a rainbow
rainbow of of colors.
colors. There
There are
are aa number
number ofof similar
sim ilar lines in
in
the program (40(40 through
through 110).
110), so use
use the editing
editing keys to spare
spare yourself aa lot of
typing.
typing . See the notes at the the end of the program listing
listing to
to refresh
refres h your memory
on editing procedures.
v
NEW
11 REM AUTOMATIC COLOR
REM AUTOMATIC COLOR BARS
5 PRINT CHR$(147)
CHR$(147) :: REM CHR$(147)
CHR$(147)= = CLR/HOM
CLR/HOMEE
PRINT
10 PRIN T CHRS(18); " ";:REM
";:REM REVERSE BAR
20 CL = INT(8· RND(1»+1
INT(8*RND(1))+1
30 ON CL GOTO 40,50,60,70,80,90,100,1 10
40.50.60,70.80.90.100,110
40 PRINT CHRS(5);: GOTO 10
50 PRINT CHRS(28);:
CHRS(28):: GOTO 10
60 PRINT CHRS(30);: GOTO 10
70 PRINT
PRINT CHR$(31);:
CHRS(31):: GOTO 1010
80 PRINT CHRS(144);:
PRINT CHR$(144);: GOTO 10
90 PRINT
PRINT CHRS(156);: GOTO 1010
v 100
100 PRINT
PRINT CHR$(158);:
CHRS(158);: GOTO
GOTO 10
10
11
1100 PRINT
PRINT CHRS(159);:
CHR$(159);: GOTO 1010
Type
Type lilines
nes 55 through
through 40
40 normally.
normally. Your
Your display
display should
should look
look like
like this:
this:
v
11 REM
REM AUTOMATIC
AUTOMATIC COLORCOLOR BARS
BARS
55 PRINT
PRINT CHR$(147): REM
CHR$(147): REM CHR$(147)=
CHR$(147)= CLR/ HOME
CLR/HOME
10 PRINT
10 PRINT CHRS(18);
CHRS(18); "" "";:REM REVERSE BARS
;: REM REVERSE BARS
v 20
20 CL
CL =
= INT(8· RND(1 »+ 1
INT(8*RND{1))+1
30
30 ON
ON CL
CL GOTO
GOTO 40,50,60,70,80,90,100,11 0
40,50,60,70,80,90,100,110
v 40
40 PRINT
PRINT CHR$(5);:
CHR${5);: GOTO
GOTO 1010
•
v
61
61
NEW
NEW
11 RE M AUTOMATIC
REM AUTOMATIC COLOR
COLOR BARS
BARS
PR INT CHR${147):
55 PRINT CHR$(147): REM
REM CHR$(147)=
CHR$(147} = CLR/HOME
CLR/ HOM E
10 PRINT
10 PRINT CHR$(18);
CHR$(1S); " ;: REM REVERSE
" ;:REM REVERSE BAR
BAR
20 CL
20 CL =
= INT(8*RND<1))+1
INT(S ·RND(1))+ 1
30 ON
30 ON CL
CL GOTO
GOTO 40,50,60,70,80,90,100,110
40,50,60, 70,SO,90, 100,1 10
50 PRINT
50 PRINT CHR$(28);:
CHR$(2S);: GOTO
GOTO 10
10
Don't
Don't worry
worry about
about line
line 40;
40; it's
it's still
still there,
there, as
as you
you can see
see by
by LISTing
liSTing the
the pro
pro·
gram. Follow
Fol low the same steps
steps to
to modify
mod ify line 40 with
with aa new
new line
line number and
and
CHR$
CHR$ code until
until you've entered all remaining lines.
al l the remaining li nes. As aa final
fina l check,
check, LIST
the entire
enti re program
program to make
make sure all the lines are
are right before
before you
you RUN
RUN it.
You probably understand the
the color
co lor bar program except for line 30. Here's
Here's aa
brief explanation of how this program
prog ram works.
wo rks.
Line 5
line 5 prints
pri nts the CHR$ code for CLR/HOM
CLR/HOME.
E.
Line 10
line 10 turns on reverse type and prints 5 spaces,
spaces, which
wh ich turn out to be a bar
since they're reversed.
reversed . The first time through the program,
program, the bar is light blue,
blue,
the normal screen display color.
Line 20 uses the random function to select at random a color between 11 and
S.
8.
Line 30 uses a variation of the IFITHEN
line IF/THEN statement,
statement, called ON/GOTO,
ON/GOTO, which
lets the program choose from as list ofof line numbers whe
wherere the program will go
next. If the
Ihe ON variable (in this case CL) has a value of 1,
1, the program goes to
2. the
the first line number listed (here it's line 40). If the variable has a value of 2,
listed, and so on.
program goes to the second line listed,
Lines 40 through 110 just convert the ra
lines random
ndom key colors to the appropriate
CHR$ code for that cocolor
lor and return the program to line 10 to PRINT a section
again..
of the bar in that color. Then the whole process starts again
See if you can figure out how to produce 16 random colors. Expand
ON/GOTO
ON /GOTO to handle the additional colors and add the remaining CHR$ codes.
62
62
I 53~80 I I 53~81 I
53280
2
53281
1
53282
53282 53283
' -"'53"'2"'83;;--1
BORDER BACKGROUND
COLOR COLOR
The first two slots are the memory locations for the border and background
screen. We've put 2, the value for RED in the border color box,
colors on your screen. box,
1, the value for WHITE in the background color box. Now try typing this:
and 1,
POKE 53281,7 RETURN
The background color of your screen wil wil!l change to yel
yellow
low because we put
the value 7, for yellow, in the location that controls backgound color.
Try POKEing different values into the background color location and see
what result you get
get.. Here's a
a list of the values to POKE for each color available
on your 64:
0 BLACK 8 ORANGE
1
1 WHITE 9
9 BROWN
2
2 RED 10
10 light RED
3 CYAN 11
11 GRAY 11
4
4 PURPLE 12
12 GRAY 22
5
5 GREEN 13
13 light GREEN
GREEN
6 BLUE 14
14 light BLUE
BLU E
7
7 YELLOW
YELLOW 15
15 GRAY 3 3
Here's
Here's aa little
little program that you can
can use to
to display
display various
various border and
and
background
background color
color combinations:
combinations:
NEW
10
10 FOR
FOR BA
BA = 0TO
0 TO 15
15
20
20 FOR
FOR BO
BO = 0TO
0 TO 15
15
30
30 POKE
POKE 53280.BA
53280,BA
40
40 POKE
POKE 53281,BO
53281,BO
50
50 FOR
FOR XX = 11 TO
TO 500:
500: NEXT
NEXT XX
60
60 NEXT
NEXT BO:
BO: NEXT
NEXT BA
BA
RUN
RU N
v
v
63
63
SCREEN GRAPHICS
SCREEN GRAPHICS
So
So far when you've
you've PRINTed
PRINTed information,
information, the
the computer
computer has has handled
handled the inin·
formation sequentially:
sequentially: one
one character
character PRINTed
PRINTed after the next,
next, starting
starting from
from the
current cursor
cursor position,
position, except
except when you
you asked
asked for aa new
new line,
line, or used
used aa comma
in PRINT formatting.
You can PRINT
PRINT data in aa particular place by starting from aa known place on
the screen and PRINTing
PRINTing the correct number of cursor controls to format the
display.
display. But this
this takes
takes time
time and program steps.
steps.
But just as there are certain locations in the 64's memory to control color,
color,
there are also
there are also memory
memory locations
locations that
that you
you can
can use
use to
to control
control screen locations.
screen locations.
64
64
SCREEN MEMORY
SCREEN MEMORY MAP
MAP
The 64's
The 64's screen
screen can
can hold 1000
1000 characters (40(40 columns byby 25 lines), so
so there
there
are 1000
are 1000 memory locations
locations set aside to represent
represent what is on thethe screen. Imag-
Imag
ine the screen as a grid,
ine grid, 40 by 25, with
with each square standing for one one memory
location.
location.
Each memory location can contain one of the 256 different characters the 64
Each
can display (see Appendix E). E). Each
Each of these 256 characters is represented by a
number from 0 to 255. IfIf you POKE POKE the value for a character into a speci specific
fi c
screen memory location, that character wi will
ll be displayed in that specific screen
location.
Here's a grid that represen
Here's represents ts your screen, complete with the numbers of each
screen memory
memory location.
location.
COLUMN
COLUMH
10 20
10 JO 39
106)
1063
1024
.064
106'
104
IID~
Il144
U
184
1184
m
122J
264
1264
304
1304
344
1344
v 3S4
1384
1424
m
464
1464
JO i
504
ISD~
544
15u
584~
158
624
!62~
664
166J
v 704
110J
744
1744
784
1784
824
1824 10
8G4
IBM
v 904
190J
944
19H
9E4
19M
\t
202]
mi
"
65
65
COLOR
COLOR MEMORY MAP
MEMORY MAP
You can change the color of the ball that appeared by altering another range
of
of memory.
memory. Type:
Type:
66
66
v 67
67
n
n
**
Downloaded from www.Manualslib.com manuals search engine
Downloaded from www.Manualslib.com manuals search engine
CHAPTER 77
CHAPTER
INTRODUCTION TO
INTRODUCTION TO SPRITES
SPRITES
•• Bits,
Bits, Bytes
Bytes and
and Sprites
Sprites
•• Creating
Creating Sprites
Sprites
•• More on
More on Sprites:
Sprites: Colors
Colors and
and Extra
Extra Movement
Movement
In
In previous
previous chapters,
chapters, we've
we've shown
shown you
you how
how to
to use
use graphic
graphic symbols
symbols inin PRINT
PRINT
statements
statements to
to create
create animation
animation and
and other
other visual
visual effects.
effects.
In
In chapter
chapter 6,6, we
we also
also showed
showed you
you how
how to
to POKE
POKE character
character codes
codes in
in specific
specific
screen
screen memory
memory locations,
locations, which
which put
put characters
characters directly
directly on
on the
the screen
screen inin the
the
place you
place you selected.
selected.
In
In both
both ofof these
these cases,
cases, you
you have
have toto create
create objects
objects from
from existing
existing graphic
graphic sym
sym-
bols,
bols, so
so these
these methods
methods take
take aa lotlot of
of work.
work. When
When you
you want
want to
to move
move the
the object,
object,
you
you must
must use
use aa number
number of of program
program statements
statements toto keep
keep track
track of
of the
the object
object and
and
move
move itit to
to aa new
new place.
place. And
And sometimes
sometimes the the shape
shape and
and resolution
resolution ofof the
the object
object
isn't
isn't as
as good
good asas you'd
you 'd like
like itit to
to be
be because
because of of the
the limitations
limitations of
of using
using graphic
graphic
symbols.
symbols.
You
You can
can eliminate
eliminate aa lotlot of
of these
these problems
problems by by using
using sprites
sprites in
in animated
animated se se-
quences.
quences. A A sprite isis aa high-resolution
high-resolution porgrammable
porgrammable object object that you can makemake
into just
just about any shape by using using BASIC commands. Ail All you have
have to do to
move
move the
the object
object isis simply
simply tell
tell the
the computer
computer the the position where
where you'd
you'd like
like the
the
sprite to go. The computer takes care of the rest.
But this isn't
But this isn't all
all you
you can
can do
do with
with sprites. For example
sprites. For example,, you
you can
can change
change their
their
color, you can tell if one object collides with another, you can make them go in
front and behind each other, and you can easi easilyly expand their size.
You have to learn a few more details about your 64 and the way it hand handlesles
numbers before you can use sprites. It's not difficult, though, so just
numbers before you can use sprites. It's not difficult, though, so just follow the follow the
examples and
examples and you'
you'llll be
be maki
making your own
ng your own sprites
sprites dodo amaz
amazing things in
ing things in no
no time.
time.
68
68
3
3 213
2 t 3 ON
ON and ON
ON and
and ON
ON 1111
11
8
= 8 and OFF
ON and ON and 11 11 0
0
ON and OFF and
and ON 10
10 11
ON and OFF and OFF 11 0
000
OFF and ON and ON o
0 1111
OFF and OFF and ON 00 1
001
OFF and ON and OFF o0 11 0
OFF and OFF and OFF 0 00
000
v
As you can see, the number of possible values equals 2 raised to the power
bits. In other words, if you have 8 bits,You
of the number of bits. bits,you have 218,or
2t8,or 256,
256, dif-
dif
Eight
ferent combinations of bits. Eig dif
ht bits equal a BYTE, so a byte can store 256 dif-
ferent values.
bits are OFF, the byte equals zero;
When all eight bits zero: when all eight bits are ON
ON.,
lowest of the 256 combinations,
the byte equals 255 (since zero counts as the lowest
naturally
naturally the highest
highest value is 255 rather
rather than 256).
Any combination of a byte's ON's and OFF's, or 11's 's and O0's,
's, converts to a
base 10)
decimal (i.e., base 10) value between 0 and 255. Here's a way to figure out the
byte when you have
value of the byte have different combinations of ON and OFF bits: bits:
128
128 64
64 32
32 16
16 88 4 2 1
1
1 00 11 11 0 11
0 00 1
Now add
Now add up
up Ihe
the values
values of
of the
the ON
ON bits
bits to
to find
find the
the value
value of
of the
the byte:
byte:
128 +
128 32 +
+ 32 16 +
+ 16 4 +
+ 4 + 11 = 181
181 =
69
69
Here's aa table
Here's tabte showing
showing BINARY
BINARY to
to DECIMAL
DECtMAL conversion.
conversion. AA zero
zero indicates
indicates
that
that aa bit
bit is
is OFF,
OFF, and
and aa 11 shows
shows that
that aa bit
bit is
is ON.
ON . To
To find
find out
out the
the value
value of
of the
the en
en-
tire byte,
tire byte, just
just add
add up
up the
the DECIMAL
DECtMAL value
va lue of
of each
each ON
ON bit,
bit, just
just as
as we
we did
did above.
above.
BINARY TO
BINARY TO DECIMAL
DECIMAL CONVERSION
CONVERSION
Decimal
Decimal Value
Value
128
128
0
64
6'
0
0
32
32
0
0
16
16
0
0
88
0
0
•
4
0
0
22
0
0
11
11 2|0
210
0
0 0
0 0
0 0
0 0
0 0
0 11 0
0 7\
2111 —
0
0 0
0 0
0 0
0 00 11 0
0 0
0 2]
2122
0
0 0
0 0
0 0
0 11 0
0 0
0 0
0 2T3 -
213
0
0 0
0 0
0 J1 0
0 0
0 0
0 0
0 2?4
21'
0
0 0
0 11 0
0 0
0 0
0 0
0 0
0 2T5
2)5
0
0 11 0
0 0
0 0
0 0
0 0
0 0
0 2|6
216
11
- 0 0
0 0 0
0 0
0 0
0 0
0 2f7
217
~
TIP:
TIP:
Converting binary
binary numbers
numbers to their
their decimal
decimal values
values is the basis
basis for
for creating
data
data to represent and manipulate
mani pulate sprites.
sprites. Here's a program that does these
conversions (or
for you.
you . Since you'll be using
using this program
program often,
often , you should enter
enter
and save it.
5
5 REM BINARY TO DECIMAL CONVERTER
10
10 INPUT ""ENTER
ENTER 8-BIT BINARY NUMBER :";A$
12
12 IF LEN (A$)< <>
(A$) > 8 THEN PRINT ""88 BITS PLEASE
PLEASE...":
... ": GOTO 10
10
15 TL = 0 C = 0
0::C
20 FOR X = 8 TO 1 1 STEP - - 11 :: C = C + 1
1
30 TL = TL + VAL(MIDS(A$,C,I»'2
VAL(MID$(A$.C.1))*2 t(X-l)
t(X-1)
40 NEXT
NEXTXX
50 PRINT AS;" ;" = ";TL;" DECIMAL"
AS; " BINARY "•■;"
60 GOTO 10
At line 10 you enter a binary number as the string A$. Line 12 uses the LEN
digits. If you didn't,
(length) function to check to be sure you entered 8 binary digits.
the program asks for more and repeats line 10.10.
15, TL keeps track of the binary number's decimal val
In line 15, value, in
ue, and C in·
being
dicates which bit is bei ng worked on as the program goes through the loop.
value
Line 30 updates the val VALand
ue of TL. Appendix C explains the VAL MIDS func-
and MID$ func
tions.
PRINTS the binary and decimal values of the byte.
Line 50 PRINTs byte. Line 60 returns the
program to the beginning.
70
'-'
'-'
v
v
v
v
'-'
v
71
71
v
v
Downloaded from www.Manualslib.com manuals search engine
~-
CREATING SPRITES
controlled
Sprites are control (VIC-II chip) in the 64.
ted by their own video display chip (VIC·II
The chip does all the work of creating and keeping track of characters and
graphics, creating colors.
graphics, colors, and moving the graphics around. All
Ail you have to do is
tell the computer three things about the sprite:
• What it should look like
• What color it should be
• Where it should appear
inter
The sprite's display chip has 46 different ON/OFF locations that act like inter·
locations.
nal memory locat ions. Each of these locations breaks down into a series of 8
bytes, and each byte can be either ON or OFF. So this means you
bytes, you have 368
ON/OFF locations for sprites. By POKEing the appropriate decimal val value
ue in the
location, you can control the formation and movement of your
proper memory location,
aboul this later.
sprites. We'll give you more detail about
In addition to showing you sprite display chip locations,
locations, we'll show you how
to use some of the 64's main memory to store data that defines the sprites.
Finally, we'll use eight memory locations directly after the screen memory to
tell the computer exactly which memory area each sprite will get its data from.
Sounds like aa lot of details,
details, but don't worry,
worry, you'll get the hang of it as we go '"'
through some examples.
Before you get started,
started, here are some important things to know about 0.
sprites:
• Sprites are usually displayed in a special high resolution mode which turns
the screen into a
a 320 dot wide by 200 dot high area.
area.
• Each sprite
sprit e object is 24 dots wide
wide by 21 dots high.
• You can control up to eight sprites at a
a time. The sprites are numbered 00 to 7.
• Each sprite has individual color control.
contro1. n
• There's a sprite multi-color mode.
• You can use sprite-to-sprite
sprite·ia-sprite and sprite-to-background collision
col lision detection. n
But first you need to know what VIC-II
VIC·II chip
chip locations control the functions
you need.
need. Remember that the sprites' chip
ch ip has 46 different ON /OFF
/O FF locations.
Here's aa partial
partial map
map that shows some of these locations, which are called
registers.
registers. Appendix
Appendix P P has
has aa complete
comp lete VIC
VIC chip register map.
map, but the registers
you'll need for
for sprites
sprites are
are listed
listed here:
Registers Description
o
0 X
X coordinate
coordinate of sprite
sprite 00
11 Y
Y coordinate
coordinate of
of sprite
sprite 00
2-15
2·15 X
X and Y
Y coordinates, paired
paired like registers 00 and
and 11 for sprites
1-7
1·7
16
16 Most
Most significant
signi fi cant Bit
Bit —
- XX coordinate
coordi nate
21
21 Sprite appear:
appear: A=
A = appear,
appear, 0=
0 = disappear
disappear
23 Expand
Expand sprite
sprite in
in Y
Y direction
direction
29
29 Expand
Expand sprite
sprite in
in X
X direction
direction
39-46
39-46 Sprite
Sprite 0-7
0·7 color
color
72
Now youyou need to separate each row into thirds so you can convert the ONs
and OFFs
OFFs into pieces of data the computer can read. Dividing the rows is sim sim·
ple
pie since you've
yo u've already split each row into into three sections.
sections.
Now each section of each row has eight squares, squares, and each set of eight
squares is is equal toto one piece
piece of data ca called
lled aa BYTE.
BYTE. This
Thi s means youyou have three
bytes per row.row .
Startin g on the
Starting th e first
first row of the balloon drawing
drawing and working from from the left, the
first eight squares are blank (0), (0), so the value for that
for th at series (byte) is 0.
O.
73
73
v
Downloaded v
from www.Manualslib.com manuals search engine
-
SERIES
SERIES SERIES SERIES
118
128 31
32
I1
88 2
:
128 32
28 2
I
128 ;31
3
8 1
64 16 4 11 64 16 4 11 64 16 A 1
4+m+t
5 +-1-+++
6 +-1-+++
) +-1-+++
~ 1:0 tt!tj::j:
~ II
11 m S H
13
14+t++t+ t-+-
15
16 ++:t+rn:t+
-t
I) ++++ 1-++-++
18 +t++t+I+++
19 ++++I-++-+++-
10 + +++ I-++-+++-
11 +-II-+I-+-++t+++
10 I15
COLUMN
128 64 32
SZ 16
16 8 4 2 1
n
o0 1 1 1 1 1 1
it it it it ir it it ti
o0+64+32+16+8
+ 64 + 32 + 16 + 8 + 44+ + 22+1
+ 1 = 127
74
DATAO,
DATA 127,0
0, 127, °
calculated
The three series of dots that make up row two are calc this:
ulated like thi s:
Series
Se 1:
rie s 1: I 0 I 0 0 0 0 0 0 1
1 ~
Series 2,
Series 2: eel > 1 } 1 1
1 1
1 1
] 1
1
if iT it it it 1t iT 1t
128 64
128+64+32
32 + + + 16 + 8
16+8 +
+44 +
+22 + 11 = 255
Series 3: I 1I I I 0 0 0 0 0 0
iT 1T
128 + 64
+ = 192
v
20
20
30
30
40
40
FOR N
FOR
FOR X
POKE
N = 0 TO 62:
X =
PO KE V
= 0 TO
TO 200
V + 4,X:
°°
62: READ Q:
200
4,X: REM UPDATE
Q : POKE 832+ N,Q:
J
UPDATE X X COORDINATES
NEXT
N,Q: NEXT
GETS ITS INFO.
FROM DATA
50
50 POKE VV++ 5,X:
5,X: REM UPDATE Y Y COORDINATES
60
60 NEXTX
NEXT X INFO. READ IN
70
70 GOTO 30 FROMQ
200 DATA
DATA 0,127,0,1,255,192,3,255,224,3,231,224
210 DATA
DATA 7,217,240,7,223,240,7,217,240,3,231,224
7,217,240,7,223,240,7,217,240,3,231 ,224
220
220 DATA
DATA 3,255,224,3,255,224,2,255,160,1,127,64
230
230 DATA
DATA 1,62,64,0,156,128,0,156,128,0,73,0,0,73,0
1,62,64,0,156,128,0,156,128,0,73,0,0,73,0
240
240 DATA
DATA 0,62,0,0,62,0,0,62,0,0,28,0
0,62,0,0,62,0,0,62,0,0,28,0
v
v
75
75
Line
line 10
10 in
in the
the program
program sets
sets VV to
to the
the VIC
VIC chip's
chip's starting
starting memory
memory location.
location.
Then
Then later
later in
in the
the program
program youyou can
can get
get the
the VIC
VIC chip
chip memory
memory location
location you
you want
want
just
just by
by adding
adding thethe appropriate
appropriate register
register number
number toto V.
V.
Line
line 11
11 makes
makes sprite
sprite 22 appear
appear byby POKEing
POKEing aa 44 into
into the
the SPRITE
SPRITE ENABLE
ENABLE
REGISTER
REGISTER (21).
(21). Why
Why POKE
POKE aa 4?4? Because
Because 44 is
is the
the decimal
decimal value
value for
for 22 to
to the
the se
se·
cond
cond power.
power. Recall
Recall that
that thethe decimal
decimal value
value for
for aa sprite
sprite is
is 22 to
to the
the power
power ofof the
the
number
number ofof the
the sprite.
sprite. IfIf you
you wanted
wanted to to turn
turn ON
ON sprite
sprite 3,
3, you'd
you'd use
use this
this state
state·
ment:
ment: POKE
POKE VV + + 21,8.
21,8. YouYou turn
turn aa sprite
sprite ON
ON byby POKEing
POKEing the the decimal
decimal value
value for
for
the sprite into the sprite enable register (21). Here's how register 21 looks after
the sprite into the sprite enable register (21). Here's how register 21 looks after (]
line 11
line 11 turns
turns ON
ON sprite
sprite 2:
2:
R~;
1 8
128 64
64 32 16 8 4 2 1 decima
1 decimal
REG. values
21 1 :
0 1 0
0 1 3002 1 :0 1 :0 1 41 1 0
: 1 o
0
7 6 5 4 3 22 1 o0 sprite
sprite
number
number
If you wanted to turn ON both sprites 2 and 3, 3. you'd add 8 and 4, 4. the decimal
values for the sprites, and use this statement: POKE V + 21,12
12 tells the computer where to lind
Line 12 find the data for sprite two. Recall that
pointer
the pOin ter for sprite 2 is memory location 2042. This line POKEs a 13 into into spri
sprite
te
pointer, which means
2's pOinter, means that sprite 2's data will be be kept
kept in the 13th13th series of
sprite bytes.
bytes.
Line 20 puts
line puts data intointo the 63 bytes
bytes that make
make upup a sprite. READ
READ Q Q gets the
data from the DATA
data DATA statements in in lines
lines 200 through 240. The 832 832 in
in the POKE
POKE
statement is
statement is the
the location
location ofof the
the 13th
13th block
block ofof sprile
sprite bytes.
bytes. AsAs the
the loop
loop in
in line
line 20
READs data,
READs data, the values
values areare POKEd
POKEd intointo the
the 63
63 sprite
sprite bytes
bytes located
located inin block
block 13.13.
Lines 30
lines 30 through
through 50 50 control
control the
the sprite's
sprite's movement
movement across
across thethe screen.
screen. line
Line 4040
POKEs the
POKEs the value
value of
of XX into
into the
the VIC
VIC chip
chip register
register location
location (4)
(4) that
that represents
represents the the
sprite 2'5
sprite 2's X
X coordinate.
coordinate. The
The X
X coordinate
coordinate represents
represents horizontal
horizontal movement.
movement. Line
Line
50 POKEs
50 POKEs thethe current
current value
value of of XX into
into the
the register
register location
location (5)
(5) that
that stands
stands for
for
sprite 2's
sprite 2's Y
Y coordinate,
coordinate, oror ve
vertical movement. This
rt ical movement. This loop
loop moves
moves the
the sprite
sprite DOWN
DOWN
and
and TOTO THE
THE RIGHT.
RIGHT.
line
Line 70
70 starts
starts the
the program
program over over again.
again.
Lines 200 through 240 contain the data
lines 200 through 240 contain the data for
for the
the sprite.
sprite.
Try adding
Try adding the
the following
following line
line and
and RUN
RUN the
the program
program again:
again:
25 POKE
25 V +
POKE V + 23,4:
23,4: POKE + 29,4:
POKE VV-f 29,4: REM
REM EXPAND
EXPAND SPRITE
SPRITE
76
76
Line 11
Line 11 turns
turns ONON sprites
sprites 22 and
and 33 byby POKEing
POKEing their
their combined
combined decimal
decimal values
values
(4 and
(4 and 8)8) into
into the
the sprite
sprite enable
enable register
register (21).
(21).
Line
Lin 12 te
e 12 tells the computer
lls the computer to to find
find the
the data
data for
for the
the sprites
sprites in
in the
the 13th
13th block
block of
of
VIC chip
VIC chip memory.
memory. Recall
Recall that
that 2042
2042 is is sprite
sprite 2's
2's pOinter,
pointer, and
and 2043
2043 is is sprite
sprite 3's.
3's.
Lines 45
Lines 45 and
and 5555 move
move sprite
sprite 33 around
around by by POKEing
POKEing values
values into
into sprite
sprite 3's
3's X
X and
and
YY coordinates
coordinates (V (V + 66 and
and VV + + 7).
7).
The following lines lines put
put sprite 4 4 on
on the
the screen,
screen, too:
too:
11
11 POKE V
POKE V + 21
21,28
,28
12
12 POKE 2042,13:
POKE 2042.13: POKE
POKE 2043,13:
2043.13: POKE
POKE 2044,13
25
25 POKE V
POKE V + 23,12:
23,12: POKE
POKE VV + 29,12
29 12
48
48 POKE V
POKE V + 8,X
8,X
58
58 POKE V
POKE V + 9,100
9,100
v
Line 11 turns ON sprites 2,3, 2,3, and 4 4 by POKEing their comb combined
ined decimal
values
val ues (4, 8,8, and 16)
16) into the spri
sprite
te enable register (21).
Line 12 tells the computer to find the data for all three sprites in the 13th
block of
block of memory.
memory.
Line 25 doubles
doubles the size of sprites 22 and 33 by POKEing their combined
decimal value into the registers that control sprite expansionexpansion (23 and and 29).
29).
Lh.e
Li,.e 48
48 moves sprite 44 along the X X axis (horizontally).
(horizontally).
Line 58 positions sprite 44 halfway
halfway down
down the screen at location
location 100.
100. Before,
Before,
we've changed the the YY coordinate throughout the program
program by by using
using aa loop
loop (see
(see
line
line 50
50 in
in the
the original
original program).
program). But
But now
now the
the value for
for the
the YY coordinate
coordinate for
for sprite
sprite
01 ++ 9)9) stays
44 (V stays the
the same
same during
during the
the program.
program. This
This means
means that
that sprite
sprite 44 only
only
moves
moves horizontally.
horizontally.
77
77
The
The following program revises
following program revises the original balloon
the original program so
balloon program so that
that sprite 2
sprite 2
moves all the way across the screen
moves all the way across the screen: :
10
10 V = 53248: POKE V+21,4:
V=53248: V + 21,4 : POK
POKEE 2042,13
20 FOR N = 0 TO 62: 62 : READ Q : POKE 832+ N,Q :: NEXT
25
25 POKE
POKE V V++ 5,
5, 100
100
30
30 FOR
FOR X X == 00 TO
TO 255
255
40
40 POKE
POKEV V+4,X
+ 4.X
50
50 NEXT
NEXT
60 POKE
POKE V+ 16,4
V+16,4
70
70 FOR
FOR X = 0 TO
X = 0 TO 6363
80
80 POKE
POKEV+4, X
V+ 4, X
90
90
100
NEXT
NEXT
POKE
'"'
100 POKE V V++ 16,0
16,0 r..
110
110 GOTO
GOTO 30 30
Line 60
line 60 sets
sets the
the most
most sign
significant bit for
ificant bit for sprite
sprite 2.2.
liLines 70 through
nes 70 through 90 90 contain
contain the
the loop
loop that
that moves
moves sprite
sprite 22 across
across screen
screen loca·
loca
tions 256
tions 256 through
through 320.320.
liLine 100 turns
ne 100 turns OFF
OFF the the MSB
MSB so so that
that sprite
sprite 22 can
can gogo back
back toto the
the left
left edge
edge ooff
the screen.
the screen. In
In other
other words,
words, when
when the
the MSB
MSB isis ON
ON,, the
the sprite
sprite can
can only
only move
move from
from
locations 256
locations 256 through
through 320.320. You
You have
have to
to turn
turn the
the MSB
MSB backback OFF
OFF before
before you
you can
can
move the sprite from locations 0 through
move the sprite from locations 0 through 255. 255.
The best
The best way
way to to learn
learn about
about sprites
sprites isis to
to experiment
experiment with with them.
them. TheThe Com·
Com
modore64
modore 64Progra
Programmer's Reference Guide
mmer's Reference Guidehas hasmore
more information
informationaboutabout sprites.
sprites.
78
78
MAKING MUSIC
ON YOUR COMPUTER:
FOR NON-PROGRAMMERS
•• Structure
Structure of
of aa Sound
Sound Program
Program
•• Sample
Sample Sound
Sound Program
Program
Playing aaSong
•• Playing Song on
on Your
Your 64
64
•• Creating
Creating Sound
Sound Effects
Effecls
Your
Your 64's
64's sound-making
sound·making features
fealures let
lei you
you make
make music
music and
and sound
sound effects.
effects. This
This
chapter
chapter is
is an
an introduction
introduction to
to using
using your
your computer's
computer's sound
sound chip,
chip, the
the SID
SID chip.
chip.
The
The Commodore
Commodore 64 64 Programmer's
Programmer's Reference
Reference Guide
Guide has
has extensive
extensive information
information
about music-makinng.
about music·makinng.
STRUCTURE
STRUCTURE OF
OF A
A SOUND
SOUND PROGRAM
PROGRAM
Before
Before we
we begin
begin explaining
explaining how
how to
to program
program the
the sound
sound chip,
chip, we
we want
want you
you to
to
understand
understand aa little
little about
about the
the important
important SID
SID chip
chip memory
memory locations
locations associated
associated
with
with sound-making.
sound-making. These
These locations
locations include:
include:
•• Volume
Volume
•• Waveform
Waveform
•• High and
High and low
low frequency
frequency
• The envelope generator:
generator:
Attack -
Decay
Decay
Sustain
Sustain
Rel ease
Release
VOLUME: There
VOLUME: There are
are 16
16 volume
volume levels.
ievels. To
To set
set the
the volume,
volume, POKE
POKE the
the level
level you
you
want (0-15) at memory location 54296.
want (0·15) 54296. Zero turns the volume OFF.
OFF.
You only
You only have
have to
to set
set the
the volume
volume once
once at
at the
the beginning
beginning of
of your
your program.
program. Thi
Thiss
setting
volume sett ing controls all three of the 64's voices.
WAVEFORM: Th
WAVEFORM: The waveform control
e waveform control STARTS
STARTS and
and STOPS
STOPS EACH
EACH NOTE.
NOTE. Each
Each
voice
vo has its
ice has its own
own waveform
waveform memory
memory location
location that
that lets
lets you
you define
define four
four different
different
types of
types of waveform
waveform by by POKEing
POKEing the start/stop
start/stop numbers
numbers for
for the waveform
waveform you
want. There
want. There areare four
four waveform
waveform types'
types-
Sawtooth:
Sawtooth:
79
79
v
v
Pulse (variable rectangular waves):
v
r— PULSE
PUlSE WIDU.
WIDTH--
~
'-- '--
80
60
WAVEFORM
WAVEFORM MEMORY
MEMORY LOCATIONS
LOCATIONS
VOICE 11
VOICE VOICE
VOICE 22 VOICE
VO ICE 33
54276
54276 54283
54283 54290
54290
This
Thi s chart
chart shows
shows each
each waveform's
waveform 's start
start and
and stop
stop numbers.
numbers. These
Th ese are
are the
the
numbers
numbers you
you POKE
POKE into
into the
the memory
memory location
locati on for
for the
the voice
voice you're
you 're programming:
programming:
NOTE
NOTE START/STOP
START/STOP NUMBERS
NUMBERS
TRIANG LE
TRIANGLE SAWTOOTH
SAWTOOTH PULSE
PU LSE NOISE
NOISE
ON/OFF
ON/OFF ON/OFF
ON/OFF ON/OFF
ON /OFF ON/OFF
ON/OFF
17/16
17/16 33/32
33/32 65/64
65/64 129/128
129/128
For
For example,
example, this
th is statement
statement STARTS
STARTS aa sawtooth
sawtooth waveform in
In voice
vOice 1,
1, and
and
STOPS
STOPS a triangle waveform in
in voice 2:
2:
POKE
POKE 54276,33:
54276,33: POKE 54283,16
54283,16
FREQUENCY:
FREQUENCY: A A sound's pitch is determined by the FREQUEN
FREQUENCY CY of the sound
sou nd
you produce when you make music.
waves you music. For
For each note in a music or sound
POKEs: one for the high frequency
program, you must include two separate POKEs:
byte,
byte, and one for the low frequency byte.
byte. The MUSICAL NOTENOTE VALUE
VALUE TABLE in
Appendix M M shows you the POKEs you need to play any note in the 64's eight
oc tave range.
octave
The
Th e high and low frequency memory locations are different for each voice
use, so you can program all three voices independently. Thi
you use, This lets
s let s you
effects.
create 3-voice music and exotic sound effects.
voice's
Here's a chart of the memory locations for each voice frequen
's high and low frequen-
cy bytes:
bytes:
VOICE
VOICE FREQUENCY
FREQUENCY POKE NUMBER
POKE NUMBER
11 HIGH
HIG H 54273
54273
11 LOW
LOW 54272
54272
22 HIGH
HIGH 54280
54280
22 LOW
LOW 54279
54279
33 HIGH
HIGH 54287
54287
33 LOW
LOW 54286
54286
81
81
v
SUSTAIN LEV EL - - --....,---~
SUSTAIN LEVEL---/ 1 . ----,.
, ' ,
, I
A : 0 : 5 , R:
NOTE:
NOTE: ATTACK,
ATTACK, DECAY,
DECAY, and RELEASE are
are RATES.
RATES. SUSTAIN
SUSTAIN is
is aa LEVEL.
LEVEL.
v
82
82
VOICE RATE/LEVEL
RATBLEVEL POKE NUMBER
1I attack/decay 54277
1
1 sustain/release 54278
2 attack/decay 54284
2 sustain/release 54285
3 attack/decay 54291
3 sustain/release 54292
We mentioned before the ATTACK
ATIACK and DECAY rates share the same byte. So
you must COMBINE ATTACK ATIACK and DECAY settings by adding them. Then you
total in a POKE statement.
enter the total
The ATTACK
ATIACK rates occupy the 2 2 tt 7,
7, 2 t 6,2
6, 2 t 5,
5, and 2 t 4
4 bits,
bits, so th
thee
128,64.
values are 128, 32, and 16. DECAY rates are 2 t 3,2 t 2,
64, 32, 2,2
2 t 1,and
I , and 2 t 0,0.
8, 4,
or 8, 4, 2, and 1. Suppose you want to set a HIGH ATIACKATTACK rate and a LOW
DECAY rate: add Ihe the high attack value (128) to the
Ihe low decay value (2), and
POKE 130 to Ihe the appropriate memory location.
This chart shows you what numbers to POKE for ATTACK ATIACK and DECAY rates:
HIGH
HI GH MEDIUM LOW LOWEST HIGH MED. LOW LOWEST
ATTACK
AITACK ATTACK
AITACK ATTACK
AITACK ATTACK
AITACK DECAY DECAY DECAY DECAY
128
128 64 32 16 8 4 2 1
1
VOICE ATIACK
ATTACK DECAY
POKE 54277,66 11 MED (64) LOW (2)
POKE 54284 ,100
54284,100 2 MED (64) +
LOW (32) MED (4)
POKE 54291 ,15
54291,15 3 ZERO MAX
(8+4+2+ 1)
(8+4+2+1)
83
POKE 54277,190
30 POKE
RUN the program again and notice
Now RUN notice the difference in
in the note.
note. Try other
combinations
comb of attack and decay settings to get an idea
inations of idea of how you can use
attack/decay rates to create a variety of sound effects.
different allackldecay
SETTING.. Like ATTACK/DECAY,
SUSTAIN/RELEASE SETIING ATIACKIDECAY, SUSTAIN/RELEASE
share a byte. But remember that this sharing doesn't mean that SUSTAIN and
LEVEL, while release,
RELEASE are alike. SUSTAIN is a LEVEL, release, allack
attack and decay are
RATES.
SUSTAIN is a proportion of maximum volume. You
You can sustain, hold,,
sustain, or hold
notes and sounds at any of 16 volume levels.
This table shows you what numbers to POKE for sustain/re
sustain/release
lease values:
HIGH
HIGH MEDIUM LOW LOWEST HIGH MED. LOW
LOW LOWEST
LOWEST
SUSTAIN
SUSTAIN SUSTAIN SUSTAIN
SUSTAIN SUSTAIN
SUSTAIN RELEASE
RELEASE RELEASE
RELEASE RELEASE
RELEASE RELEASE
RELEASE
128
128 64
64 32
32 16
16 8
8 4
4 2
2 11
NOTE:
NOTE: You
You can increase
increase the SUSTAIN
SUSTAIN level by adding together
together all
all the
the SUSTAIN
SUSTAIN
values: 128
128 + + 64
64 ++ 32
32 ++ 16
16 = 240,
240, which
which is is the
the MAXIMUM
MAXIMUM SUSTAIN
SUSTAIN LEVELLEVEL. AA
SUSTAIN
SUSTAIN level
level of
of 128
128 is
is approximately
approx imately 50%50% of of volume. You
You can increase
increase the
the
RELEASE
RELEASE rate by by adding
adding together
together all
all the
the RELEASE
RELEASE values:
values: 88 +
+ 44 ++ 22 ++ 11 =
15,
15, which
which is
is the
the MAXIMUM
MAXIMUM RELEASE
RELEASE RATE.
RATE.
Combine
Combine the
the sustain
sustain level
level and
and release
release rate
rate the
the same
same way
way you
you combine
combine thethe at
at-
tack
tack and
and decay
decay rates:
rates: add
add the
the two
two values
values andand POKE
POKE the
the total
total to
to the
the memory
memory
location
location of
of the
the voice
voice you
you want.
want.
To
To see
see the
the effects
effects of
of the
the sustain
sustain level
level setting
selling add
add this
this line
line to
to the
the last
last sample
sample
program:
program:
35
35 POKE
POKE 54278,128
54278,128
Now
Now RUN
RUN thethe program
program again
again and
and note
note the
the change.
change. With
With line
line 35,
35, we
we tell
tell the
the
v computer to sustain the note at a HIGH SUSTAIN LEVEL (128). You can vary the
comp uter to sustain the note at a HIGH SUSTAIN LEVEL (128). You can vary the
v duration
duration of
of aa note
note by
by changing
changing the the count
count inin line
line 70.
70. Remember
Remember that that the
the sustain
sustain
level
level maintains
maintains aa note
note atat aa proportion
proportion ofof the
the volume
volume asas the
the note
note falls
falls from
from its
its
peak
peak volume:
volume: this
this isn't
isn't the
the same
same thing
thing as
as the
the note's
note's duration.
duration.
To
To see
see the
the effect
effect of
of the
the release
release rate,
rate, try
try changing
changi ng line
line 35
35 to
to POKE
POKE 54278,89
54278 ,8~
(sustain
(sustain == 80,
80, release
release == 9).
9).
84
85
85
You can
You can change
change toto aa sawtooth
sawtooth wave wave byby changing
changing lineline 85
85 to
to read
read
POKE54276.33 and
POKE54276,33 and line
line 90
90 to to read
read FORT;
FORT= n0250:NEXT:POKE54276,32.
1TO250:NEXT:POKE54276,32.
Changing the
Changing the waveform
waveform can
can dramatically
dramatically change
change Ihe
the sound
sound your
your computer
computer
produces.
prod uces.
You can
You can also
also change
change the
the sound
sound in in other
other ways.
ways. For
For example,
example, you
you can
can change
change
the harpsichord·like
the harpsichord-like sound
sound in in the
the previous
previous program
program toto aa banjo-like
banjo-like sound
sound by by
changing the
changing the ATTACK/DECAY
ATTACK/DECAY rate rate of
of each
each note.
note. Do
Do this
this by
by changing
changing line
line 20
20 to
to
read:
read:
20 POKE54277,3:
20 POKE54277.3:POKE54278,0 creates banjo
POKE54278,0 ............... creates banjo effect
effect by
by setting
setting zero
zero
SUSTAIN
SUSTAIN
As this program
As program demonstrates,
demonstrates, your
your 64
64 can sound
sound like
like aa variety
variety of
of musical
musical in-
in
struments.
v
v_
v
v
86
86
Line 20 READs the first number from the DATA statement. If that number is
- 1,, the program ENDs automatically. This occurs when the final DATA state-
-1 state
ment (line 120) is read. /-.
Line 30 READs the second number from the DATA list.
Line 40 READs the third number from the DATA list. *
Line 60 POKEs:
1. The value for H H that was assigned in the READH statement in line 20. Until
-- 1
1 is read
read,, this value is assigned to the HIGH FREQUENCY register.
register. ^
2. The value for L that was assigned in the READL statement in line 30. This
value is assigned to the LOW FREQUENCY register. Together these two r<
POKEs determine the pitch for one note.
3. The value that turns ON the variable pulse waveform for voice 1.
87
H7
'-'
'-'
'-'
v
v
'-'
'-'
v
V
'-'
V
'-'
v
'-'
88
-'
Downloaded v
from www.Manualslib.com manuals search engine
-
CREATING
CREATING SOUND
SOUND EFFECTS
EFFECTS
Your
Your 64's
64's SID
SID chip
chip lets you
you create
create aa wide
wide variety
variety of
of sound
sound effects,
effects, such
such as
as an
an
explosion during
during aa game,
game, or
or aa buzzer that
that warns
warns you when
when you've
you've made
made aa
mistake.
mistake.
Here
Here are
are just aa few
few suggestions for
for creating
creating sound
sound effects:
1.
1. Vary
Vary rapidly
rapid ly between two
two notes to create
create aa tremor
tremor sound.
2. Use
Use the multivoice
multivoice effects to
to play more than
than one voice
vo ice at a time,
time, with each
voice
voice independently
independently controlled,
controll ed , so
so you
you have different
different noises at once.
once. Or use
one voice as
as an echo or
or response to
to another voice.
vo ice.
3, Use
3. Use the different pulse widths
widths to
to create different sounds.
4.
4. Use the
the NOISE WAVEFORM
WAV EFORM to make white noise
nOise to accent tonal
tonal sound ef
ef·
fects,
fects , create explosion
explosion noises,
nOises , gunshots,
gunshots, footsteps,
foots teps , or
or alarms. When you
you
use
use the noise
noise waveform
waveform with the
the same musical notes that create music,
music, you
can create different
can di fferent types of white noise.
noise.
5. Combine several
5. several HIGH/LOW
HI GH/LOW FREQUENCIES
FREQUENCIES in rapid succession across dif
dif·
ferent
fe rent octaves.
6. Try POKEing the extra note settings in Appendix M.
M. ~
DOLL CRYING
NEW
54272TO54296:POKEL,0:NEXT
5 FORL= 54272T054296: POKEL,O:N EXT .... Clears SID chip
10 S
S== 54272
24.15 ... ............. ..
20 POKES+ 24,15 Sets volume
. .......... Sets volume ^
30 POKES+ 4,65 .................... . .............. Turns ON pulse waveform in
voice
vo ice 11 -->-
40 POKES+ 5,15 .................... .. ........ .. ........ Sets attack/decay rate
POKES + 5,15
50FORX=200TO5STEP-2
50 FOR X = 200T05STEP - 2 .......... .. .... Sets timing loop for RELEAS
RELEASEE or
time between notes
POKES-f
60 POKES 1,40:POKES,X:NEXT
+ 1,40:POKES,X: NEXT. .. ...... Sets hi/lo frequencies
70FORX=
70 150TO5STEP-2
FOR X = 150T05STE timing loop
P - 2 ........................ Sets faster liming
1.40:POKES,X:NEXT
80 POKES + 1,40:POKES,X: NEXT ................ Sets hi/lo frequencies
POKES+
90 POKES 4T64 ........................................... Turns OFF pulse waveform
+ 4,64
89
'--'
v
v
v
v
v
v
v
v
v
v
v
v
90
v
v
Downloaded from www.Manualslib.com manuals search engine
—
READ
READ AND
AND DATA
DATA STATEMENTS
STATEMENTS
So far
far we've
we 've shown
shown you how how to
to assign
assign values to to variables
va riables directly (A = 2),
and
and how
how to to assign
assign values
values while
wh ile the
the program
program isis RUNning
RUNning (INPUT
(I NPUT andand GET).
GET].
But
Bu t often
often you'll
you 'll find that
that neither
neither way
way suits
suits your
your needs
needs for fo r variable
variable assign
assign·
ment
ment in
in aa program,
program, especially
especially when
when you
you have
have large
larg e amounts
amounts of of data.
data.
In the
the chapter
chapter 77 when
when we
we introduced
introduced sprites,
sprites, wewe used
used READREAD and and DATA
DATA
statements to to assign
assign values
values for sprites.
sprites. Here's
Here's aa short
short program
program that shows shows you
how these
how these two statements
statement s work
work together:
together:
10 READ X
READX
20 PRINT "X IS
PRINT IS NOW :";X
N0W:";X
30
30 GOTO 10
GOTO 10
40 DATA 1, 34,
34, 10.5, 16, 234.56
10.5, 16,
RUN
X IS
IS NOW:
NOW : 1
1
X IS
X IS NOW ::34
34
X
X IS NOW:
NOW : 10.5
X
X IS
IS NOW : 16
X
X IS
IS NOW:
NOW : 234.56
DATA ERROR IN 10
?OUT OF DATA
READY
•
91
91
•• Use:
Use:
-— integer
integer numbers
numbers (e.g., 34),
v -— real
real numbers
numbers (e.g., 234.65),
-— numbers
numbers expressed in in scientific notati
notation (e.g.,, 2.4E
on (e.g. + 04),
2.4E+04),
v -— words (as long as you use a string variable in in the READ
READ statement),
but DON
but DON'T use:
'T use:
-— variables or
-— arithmetic operations
items
in DATA statements. The item treated as slrings
s listed below are Irealed strings if you try
only
to READ them, and you can on ly READ them as strings with string variables
in the READ statement
in statement..
DATA A. 2*5. B + 2
23/56, 2·5,
A, 23156,
40
40 DATA 1.
1, 34. 10.5, 16.
34, 10.5, 16, 34.56
t
pointer
p6inter
When the last DATA
DATA value has
has been assigned to the variable in
in the READ
statement
statement and
and the computer
computer tries
tries to
to execute
execute the
the loop
loop again,
again, the
the OUT OF
OF DATA
DATA
ERROR
ERROR is
is displayed.
displayed .
Here's an
an example
example that
that shows
shows one way
way to
to avoid
avoid the
the OUT OF
OF DATA
DATA ERROR.
ERROR.
v NEW
NEW
v
10
10 FOR
FOR XX =
= 11 to
to 33
v 15
15 READ
READ A$
A$
20
20 PRINT
PRINT "A$
" A$ IS
IS NOW
NOW :: ";
"; A$
A$
30
30 NEXT
NEXT
40
40 DATA
DATA THIS,
THIS, IS,
IS, FUN
FUN
v
......, RUN
RUN
v AS
A$ IS
IS NOW
NOW: THIS
THIS
A$ IS NOW
A$IS NOW : IS
IS
v AS
A$ IS
IS NOW
NOW: FUN
FUN
READY
READY
92
92
v
Downloaded v
from www.Manualslib.com manuals search engine
This
This time
time we
Vie put
put the
the READ
READ statement
statement inside
inside aa FOR/NEXT
FOR/N EXT loop
loop that
that limited
limited
the
the number
number ofof READings
READings toto equal
equal the
the numbers
numbers of
of items
items in
in the
the DATA
DATA statement.
statemen t.
As
As long
long as
as you
you know
know how
how many
many items
items will
will be
be in
in your
yo ur DATA
DATA statements,
statements, this
this
method
meth od is
is fine.
fine. But
But often
often either
either you
you won't
won't know
know or
or you
you won't
won't want
want to
to bother
bother to
to
count.
count.
Sometimes
Sometimes the
the best
bes t way
way to
to avoid
avoid an
an OUT
OUT OF
OF DATA
DATA ERROR
ERROR is
is to
to end
end your
you r
DATA statement
DATA statement with
with aa FLAG.
FLAG. AA flag
flag is
is some
some value
value that
that would
wou ld not
not ordinarily ap-
ordinaril y ap
pear in
pear in your
your DATA
DATA list,
list, such
such as
as aa negative
negalive number,
number, aa very
very large
large number,
number, aa very
very
small
small number,
number, or
or aa special
special word,
word, such
such as
as END
END or
or STOP.
STO P. When
When you
you use
use aa flag,
flag ,
add
add an
an IF/THEN
IFITHEN statement
statement to
to tell
tell the
the computer
computer to
to branch
branch to
to another
another part
part of
of the
the
program when
program when the
the flag
flag is
is read.
read. For
For example:
example:
10 READ A
10 READ A
15
15 IF
IF A
A < < OTHEN
0 THEN END
END
20 DATA
20 DATA 13,35,29,
13, 35, 29, -999
-999
25 PRINT
25 PRINT "TOTAL
" TOTAL = ";
"; A
A
30 GOTO
30 GOTO 10
10
This
This program
program READsand
READs and PRINTS
PRINTs aa value
value for A
A until
until it reaches -999.
- 999. Line
line 15
15
tells
tells the computer
computer to
to END
END the
the program
program immediately
immediately when
when aa negative
negative value
value is
read.
There
There is also
also aa way to
to reuse
reuse the items in
in aa DATA
DATA statement by RESTOREing
the
the data pointer
pOinter to
to the
the beginning of the
the DATA
DATA list. Try adding this line:
45 RESTORE
45
to the second program in
in this chapter and RUN it again. You
You'll
'll see that the data
pointer has been RESTOREd
pOinter RESTOREd to the first item in
in the DATA list,
list, and that you
yo u can
all the items.
reREAD all
CALCULATING AVERAGES
Here's a program that READs a set of numbers from a DATA list and
calculates their average. This program also uses a flag to tell the computer
when to stop READi
READingng DATA.
NEW
5 T=O
T = 0 :CT=O
: CT = 0
10 READ
READX X
20 IF X = -- 11 THEN 50: REM CHECK FOR FLAG
25CT=CT
25 CT = CT +1 + 1
30 T = T + X:X : REM UPDATE TOTAL
40 GOTO 10 ^
PRINT ""THERE
50 PRINT THERE WWERE
ERE "; CT;"VALUES READ"
60 PRINT " TOTAL
PRINT "TOTAL = ";T
PRINT "AVERAGE = "";; T/CT
70 PRINT " AVERAG E
80 DATA
DATA 75, 80, 62, 91
91,, 87,
37, 93, 78, -1
- 1
RUN
RUN
TH ERE WERE 7 VALU
THERE ES READ
VALUES
TOTAL = 566
AV ERAGE = 80.8571429
AVERAGE
93
93
NEW
10 READ N$,A,B,C
N$;'"S
20 PRINT N$" WERE: "
" S SCORES WERE' ";A;"
A" "'";B;"
B'" "";C
'C
30 PRINT ""AND
Aim THE AVERAGE IS: ''';(A';
";(A+ B+ 8
+ C)/3
(;)13
40 PRINT: GOTO 10 10
50 DATA MIKE, 190, 185,
MIKE, 190, 185, 165,
165, DICK,
DICK, 225,
225, 245, 190
60 DATA JOHN,
JOHN, 155,155, 185,205,
185, 205, PAUL,
PAUL, 160,
160, 179, 187
RUN
DICK'S
DICK'S SCORES WERE: 225 245 190
190
AND
AND THE AVERAGE IS:
IS : 220
v
v
Line
line 10
10 READs aa value
val ue for
for each of the variables.
variables. The
The DATA statement lists
lists its
its
items
items in
in the same
same order that
that the
the READ
READ statement
statement expects to to find them. In
In other
other
words,
words, there's
there's aa name to
to go with
with the
the string
strin g variable,
variab le, and
and numbers
numbers toto go
go with
with the
integer
in teger variables.
variables.
v
v
v 94
94
5
5 PRINT CHR$(147)
PRINT CHR$(147)
10
10 INPUT "HOW
" HOW MANY
MANY NUMBERS :";X
20 FOR A
20 =
A = 11 TO
TO X
X
30 PRINT ""ENTER
ENTER VALUE
VALU E # ";
";A;:INPUT
A;: INPUT B(A)
40 NEXT
50 =
SU = a0
60
60 FOR A =
FOR A - 11 TO
TO X
X ^
70 SU = SU + B(A)
SU
80 NEXT
NEXT
90 PRINT :: PRINT "AVERAGE = "; SU/X
PRINT
RUN
RUN
HOW
HOW MANY NUMBERS :?
MANY NUMBERS :? 5
5
ENTER
ENTER VALUE
VALUE# # 11 ??125
125
ENTER
ENTER VALUE
VALUE # 2 ?? 167
#2 167
ENTER
ENTER VA LUE ##3
VALUE 3 ?? 189
189
ENTER
ENTER VA LUE ##4
VALUE 4 ?? 167
167
ENTER
ENTER VALUE
VALUE ##55 ?? 158
158
AVERAGE == 161
AVERAGE ,2
161.2
95
95
B
B (D
(1) 125
125
v
B (2)
B (2) 167
167
v B (3)
B (3) 189
189
B
B (4)
(4) 167
167
B
B (5) 158
After
After you INPUT
INPUT all
all the values,
values, they are stored in
in array B.
B. You can
can now
now ac-
ac
cess
cess these
these values
va lues just
just by using the subsc
subscripted variables.
ripted variab les. For example, see
v
what
what happens
happens when you add these lines:
v
100
100 PRINT B(X-1)
PRINT B (X - 1)
v 120 PRINT B
120 PRINT (3)
B(3)
130
130 PRINT B(X-3)
PRI NT B (X - 3)
DIMENSIONING ARRAYS
If
If you try
try to enter more than ten numbers in an array, you'll get
get a DI
DIMENSION
MENSION
v ERROR. Arrays of moremore then ten elements need to be predefined in a DI DIMEN
M EN-
SION
SION statement. For example,
example, if you
yo u want an array to hold 25 values, you'd wr
write
ite
v this
th is statement
statement in your program:
prog ram:
DIM BB (25)
DIM (25)
You
You can
can also
also use
use aa variable in a
variable in DIMension statement.
a DIMension statement. For
For example,
example, in
in the
the
last program
last program you could
co uld have used this statement since X equaled the total
v number of
number of values
values in
in array B:
v 15 DIM
15 DIM B
B (X)
(X)
But be
But be careful
care fu l when
whe n you
you use
use variables
vari ables to
to define
define arrays:
arrays: once
once an
an array
array is
is
DIMensioned, it can't
DIMensioned, can 't be reDIMensioned
re DI Mensioned in
in ano ther part of the program. So
another
v don't use
don't use aa variable
variable whose
whose value
value will
will change in the program.
You can
You can use
use more
more than
than one
one array in a program
program,, and you can DIMension the
themm
all on
all on the
the same
same line:
line:
v 10 DIM
10 DI M A
A (12),
(12), B
B (35),
(35), C
C (3,5)
(3,5)
v Arrays A
Arrays A and
and B
B are
are one-dimensional
one-d imensional arrays,
arrays, but
but C
C is
is a
a two·d imens ional array.
two-dimensional array.
One-dimensional arrays
One-dimensional arrays just
just have
have ROWS
ROWS of
of data,
data, but
but two-dimens ional arrays
two-dimensional arrays
v have both
have both rows
rows and
and columns
columns of
of data,
data, just
just like
like a
a chart.
chart. Array
Array C
C has
has 33 rows
rows and
and 5
5
v columns . Rows are always listed first in a DIMension statemen
columns. Rows are always listed first in a DIMension statement. t.
v
v 96
96
Line 10 asks you how many times yo u'll throw the dice iin the simulated roll.
you'll
Line 20 sets up a loop to count the number of dice rolls so that the program
ends on the Xth roll.
Line 30 makes R R equal to the random number rolled.
Line 40 sets up the array F,
F, for FAC
FACE,
E, which keeps track of how many times
each face turns up. Whatever value R R acquires in in the dice roll becomes the
array, and line 40 adds one to the appropriate array vari
subscript for the array, variable.
able.
For example,
example, even/
every time a 22 is thrown,
thrown , FF (2) is increased by one.
Line 70 PRINTs
PRINTs the number of times each face shows up. up. Here's a sample
RUN:
97
v
v
98
98
0o 1 22 33 44 55 66
You'll
You' ll notice
notice that there's
there 's aa zeroth
zeroth row and
and column,
column, so
so when you
you DiMension
DIMens ion A A n
(4,6), you're
(4,6), yo u're creating an array with 5
5 rows and 7 columns,
7 colum ns, or 35 elements.
elements. n
You
You can
can access
access any element of
any element of a
a two-dimensional
two-di mensional array
array by
by using
using its row and
its row and
column subscri
column subscripts. For exampl
pts. For example, suppose you
e, suppose you want to assign
want to 255 to
assign 255 to A (3,4):
A (3 ,4): n
10 LET A(3.4)
10 A(3,4) = 255
Here's what th
thee grid looks like now:
o0 122 33 44 55 66
o0
1
22
33 255
255
44
Two-dimensional
Two-d arrays follow
imensional arrays follow the
the same
same rul
rules as one·dimensional
es as one-dimensional arrays:
arrays:
DIM ensioning:
DIMensioning: DIM A
DIM A (20,20)
(20.20)
Assigning
Assigning data
data values:
values: A(1.1)
A(1, =
1) = 255255
Assigning
Assigning val ues to
values to
other
other val ues:
values: AB == A(1,1)
AS A(1,1)
PRINTi ng val
PRINTing ues:
values: PRINT
PRINT A(1,1)
A(1.1)
m
99
99
CLUB QUESTIONNAIRE
CLUB
ARE YOU IN
Q1: ARE IN FAVOR
FAVOR OF RESO
RESOLUTION
LUTION #1?
11 -— YES 2 -— NO
NO 3 -— UNDECI
UNDECIDED
DE D
...., Let's
Let 's suppose there are four questions, so the array, which we'll call A, will be
DIMensioned A(4,3). Here's
DIMensioned Here's how
how the array table looks:
looks:
v
YES NO
NO UNDECIDED
UNDECIDED
QUESTION
QU ESTI ON 11
QUESTION
QU ESTI ON 2
QUESTION
QU ESTI ON 3
QUESTION 4
pro
The program that keeps track of the responses is on the next page. This pro·
gram uses many of the programming techniques that have been presented so
far.
far.
PRINT
Lines 30-65 PRI NT the questions in numerical order and ask you to INPUT the
response.
Line 70 adds one to the appropriate array element. Remember that R R is the
number, and the questions are in rows. C
question number, C is the response number,
number, and
the responses are in columns.
Line 90 asks if you have another set of responses to IN INPUT.
PUT.
Lines 110 and 120 tell the program where to go, go, depending on your response
to line 90.
Lines 130-170
130-1 70 PRINT thethe total
total number
nu mber of each
each response.
Each time you you INPUT aa response at at line
li ne 61,
61 , liline
ne 70 updates the right
rig ht element
of the
the array. Recall the R R is the question
question number and C C is
is the response number,
number,
v so if your response to to question
question 22 is 33 (undecided),
(undecided), line 70 adds one to to array ele
ele-
ment A{2,3).
A(2,3)_
You'll
You 'll notice
noti ce that we
we didn't use
use the
the zeroth
zeroth row and columncolum n inin this
th is example.
example.
You
You don't
don't have to to use
use this row
row and column,
colum n, butbut remember
remember that
that they
they are
are always
always
present
present in in even/
every array
array you
you use.
use.
v
100
100
Downloaded from www.Manualslib.com manuals search engine
SHIFT
20
20 PRINT"" (CLRI
PRINT <CLR/HOME>
HOME> ""
30 FOR
FO RRR = 1 1 TO 4 4 ~
40 PRINT
PRIN T "QUESTION # :: "; R R
50 1-YES 2·NO
PRINT " 1·YES 2-NO 3·UNDECI
3-UNDECIDED" DED"
60 PRINT ""WHAT
WHAT WAS THE RESPNSE :: ";
61
61 GET C:
GET C: IF
IF CC (1<1 oror C>
C> 3 3 THEN
THEN 61 61
65 PRINT C: PRINT
70 A(R,C) = A(R,C) +: + : REM UPDATE ELEMENT
80 NEXT R R
85 PRINT
90 PRINT ""DO
DO YOU WAN WANT T TO ENTER ANOTHER"; ANOTHER": PRINT
""RESPONSE
RESPONSE (Y (Y/N)";
I N)";
100 GET A$ :: IF A$ = " " THEN 100
A$ = "Y" THEN 20
110 IF AS
120IFAS
120 IF A$ (><> ""N" THEN 100
N" THEN 100
130 PRINT
130 <
PRINT "" <CLR/HOME
CLRI HOME > > ";"THE
";"THE TOTAL TOTAL RESPONSES
RESPONSES
WERE:":PRINT
W ERE:": PRINT
SPC(18);"RESPONSE"
140 PRINT SPC(18);" RESPONSE" ~
"QUESTION","YES'VNO","UNDECIDED"
141 PRINT "QU ESTlON","YES" ,"NO"," UNDECIDED"
142 PRINT
142 PRINT .....................................
" .""
150 FOR R R = 1 1 TO 4 4
160 PRINT R, R, A(R,1),
A( R,1), A(R,2), A(R,3)
A(R,3)
170 NEXT R R
RUN
QUESTION # :: 1
1
1-YES 2-NO 3-UNDECIDED
1·YES 2·NO 3·UNDECIDED
WHAT WAS TH THE E RESPONSE :: 1
1
QU ESTION # : 2
QUESTION#:2 ^
1-YES 2·NO
1·YES 2-NO 3·U
3-UNDECIDED
NDECIDED
WHAT WAS THE RE RESPONSE
SPONSE :: 1
1
And so on.
on ...
TOTAL
THE TOTA WERE:
L RESPONSES W ERE:
RESPONSE
QUESTION YES NO UNDECIDED
UN DECIDED
11 6 1
1 0
2 5
5 2 0
0
3 7
7 0 0
A
4 2
2 4
4 1
1
101
1(11
APPENDICES
APPENDICES
INTRODUCTION
INTRODUCTION
Now
Now that
that you've
you 've gotten
gotten toto know
know your
you r 64,64, we
we want
want youyou to to know
know thatthat ourour
customer
customer support
support does
does not
not stop
stop here.
here. You
You may
may not
not know
know itTit, but
but Commodore
Commodore
has
has been
been inin business
business for
for over
over2323years.
years. InInthe
the1970's
1970'swe
we introduced
introduced the thefirst
fi rst self-
sel f·
contained
contained personal
personal computer
compu ter (the
(the PET).
PET). We We have
have since
si nce become
become the the leading
leading
computer
computer company
company in in many
many countries
countri es ofof the
the world.
world. Our
Our ability
ability toto design
design and and
manufacture
man ufac tu re our
our own
own computer
computerchips
chips lets
lets ususbring
bring you
you new
new and
and better
bett er personal
personal
computers
computers at at prices
pri ces way
way below
be low what
what you'd
you'd expect
expect for
for this
this level
level of
of technical
tec hnical
excellence.
excellence.
Commodore
Commodore isis committed
committed to to supporting
supporting you.
you, the
the end
end user.
user. We
We also
also assist
assist
you
you by by supporting
supporting the the dealer
dealer whowho sold
sold you
you your
your computer,
computer, magazines
magazines that that
publish
publish how-to
how·to articles
articles showing
showing you you new
new applications
applica tions oror techniques,
techn iques, andand soft
salt·
ware
ware developers
developers who who produce
produce programs
programs on on cartridge
cartridge and
and disk
disk for
for use
use with
with your
your
computer.
co mputer. We We encourage
encourage you you toto establish
establish or
or join
join aa Commodore
Commodore "user "user club"
club"
where
where you you can
can learn
learn new
new techniques,
techniques, exchange
exchange ideas
ideas and
and share
share discoveries.
discoveri es.
We
We publish
publi sh two
two separate
separate magazines
magazi nes which
which contain
contain programming
program mi ng tips,
tips , informa
informa·
tion
tion onon new
new products
products andand ideas
ideas for computer
computer applications.
applications. (See
(See Appendix
Appendix N). N).
In
In North
North America.
America, Commodore
Commodore provides
provides aa -Commodore
" Commodore Information Net- Net· ^
work"
work" on on the
the CompuServe
CompuServe Information
Information Service.
Service. ToTo use
use this
this network,
network, all all you
need
need is is your
your 64
64 computer
computer andand our
our low
low cost
cost VICMODEM
VICMODEM telephone
telephone interface cart cart·
ridge (or oth er compatible
ridge (or other compatible modem).
The following
following APPENDICES
APPENDICES containcontain charts,
charts, tables, and other
other information
information
which
which help you you program your you r Executive 64 faster
faste r and more
more efficiently.
efiiciently. They
also include important information on the wide variety of Commodore CommOdore products
you may be interested in, in. and a bibliography listing of over 20 books and
magazines which can help you develop your programming skills and keep you
current on the latest information concerning your computer and peri peripherals.
pherals.
102
102
C64 105
105 -— LOGO
LOGO is an educati
educational
onal language for students.
students. Because LOGO is so ve verr-
satile, it is simple enoug
satile, enoughh for pre-schoolers and sophisticated enough to
challenge college graduates.
graduates. A A small triangular cursor,
cursor, called a Turtle,
Turtle, is used
to draw the graphics.
LOGO includes the following
foll owing features: four different types of screens;
cataloging commands; a a TRACE command
com mand for programming
programming and debugging;
debugging;
LIST
LI ST processing; and
and the ability
abi lity to
10 read music,
mUSiC, graphics,
graphics, and text files
fi les previous
previous-
ly created
c reated with LOGO.
LOGO.
C64 106
106 —
- PILOT
PILOT for the 64 is the most
mos t powerful
powerfu l version
version of PILOT
PILOT available. With
With this
program,
prog ram, you
yo u can
ca n define
define your
yo ur own
own characters,
characters, create
create colorful,
colorful, movable
movable objects
called
called sprites,
sprites, and
and create
create music and and aa variety of
of sound effects. This is a
superior
superior instructional
instructional tool
tool .. .... educators
educators can write their
their own
own software which
which
combines fun.
fu n, entertainment,
entertainment, and and learning.
learn ing. Programs written
writt en on
on COMMON
PILOT
PILOT can
can also
also be
be run
run without any conversions. Also, Also, aa RUN-ONLY
RUN -ONLY VERSION
VERSION of
the
the program
program is is included.
included.
C64 107
107 —
- PET
PET EMULATOR
Converts
Convert s most
most software
so ftware designed
designed for
for Commodore
Commodore PET computers to
to soft
soft-
ware
wa re for
for your
yo ur 64.
64. A
A valuable
valua ble teaching
teaching tool
tool utilizing
utilizing your
your 64
64 and
and PET
PET educational
educational
software.
soft wa re.
103
103
C64
C64 110
110 —
- CP/M'
CP/M 2.2
2.2 OPERATING
OPERATING SYSTEM
SYSTEM
The
The CP/M'
CP/M ~ 2.2
2.2 Operating
Operating System
System turns
turns your
your 64
64 into
into aa dual
dual processor
processor home
home
computer.
comp uter. This
This system
system lets
lets you
you expand
expand the
the software
software applications
applications you
yo u can
can use
use
with
with your
your 64.
64. When
When you
you add
add this
this easy-to-install
easy-to-install system,
system, you
you can
can begin
begin using
using
some
some ofof the
the many
many available
available CPIW
C P/M!> programs,
programs, including
including widely
widely used
used business
business
applications,
applications, word
word processing,
processing, and
and high
high level
level computer
computer languages.
languages.
■CP/M
' CP/M isis aa registered
registered trademark
Irademal1l oi
0 1Digital
Oigital Research.
Research, Inc.
Inc
BUSINESS
BUSINESS SOFTWARE
SOFTWARE -
- FOR
FOR HOME
HOME AND
AND OFFICE
OFFICE
C64 200
C64 200 —
- EASY
EASY CALC
CALC 64
64
EasyCatc
EasyCalc 64
64 is
is an
an easy-to-use
easy-to-use electronic
electronic spread
spread sheet.
sheet. EasyCatc
EasyCalc has
has editing
editing
functions
functions and
and help
help screens,
screens, and
and itit lets
lets you
you print
print bar
bar charts
charts and
and individually
individually for
for-
matted
matted tables.
tables. EasyCalc
EasyCalc also
also lets
lets youyou view
view up
up to
to four
fou r pages
pages at
at once
once onon the
the
screen.
screen.
- EASY FINANCE II
C64 202 —
Shows you
you how to make the most out of your hard-earned money by
(or you. Principal,
calculating 12 loan concepts for payment, last payment
Principal, regular payment, payment,,
and remaining balance are just some of the functions EASY FINANCE can
programming
determine. You need absolutely no programmi knowledge
ng know ledge to use this
product.
C64
C64 207
207 -— EASY
EASY SCRfPT
SCRIPT
Powerful word
Powerful word processor
processor with
with table
table producing
producing capabilities;
capabilities: comprehensive
comprehensive
printer controls: easy up-date facilities; easy document handling
printer controls; easy up-date facilities; easy document handling and and much,
much.
much
much more.
more.
C64
C64 208
208 -- EASY
EASY SPELL
SPELL 6464
Now you
Now you can
can prod
produce flawless wri
uce flawless writing! EasySpell 64 offers
ting ! EasySpel164 offers all
all these
these features:
features:
Automatically corrects
Automatically corrects spelling
spelling errors;
errors; Counts
Counts the the words
words in in your
your manuscript;
manuscript:
Has aa built-in
Has built-in 20,000
20,000 word
word lexicon
lexicon that
that lets
lets you
you add
add words
words notnot already
already stored
stored
there; Is
there; Is designed
designed to to be
be used
used with
with EasyScript
EasyScript 64, 64, anan easy-to-use
easy-to-use word-word-
processor. Because
processor. Because youyou can
can add
add toto the
the lexicon,
lexicon. EasySpel1
EasySpell can can easily
easily bebe
adapted for
adapted for writing
writing reports
reports in
in specialized
specialized fields
fields such
such asas medicine,
medicine, law,law, and
and
science. All
science. All you
you do
do isis add
add the
the words
words you
you use
use to
to the
the lexicon!
lexicon!
104
104
C64 214 —
- EASY FINANCE IV
Is a business managemenl
management package that shows managers how to make the
right decisions about production, inventory, control
control,, compensation,
compensation , and much
more. Lease purchase analysis, depreciation switch, and optimal order quantity
are some of the
the 21
2t functions this
this program will calculate
calcu late for you.
C64 215 —
- EASY FINANCE V
V
yo u how to make the most out of statistics such as
Shows you as payoff matrix
analysis,
analYSiS, regression analysis forecast
forecasting,
ing, and apportionment by ratios.
rati os. It is
is
completely pre-programmed
pre ·programmed and very easy to use. With
With just
iust aa few simple
si mple
v
keystrokes, you
you can
can improve your finances!
finances!
C64
C64 216
216 —
- THE
TH E MANAGER
MANAG ER
General
General data
data base to
to handle
handle user created
created files.
files. Interfaces
Interfaces with
with Wordprocess
Word process·
ing,
ing, accumulates
accumulates totals
totals on
on screen
screen and creates
creates subfiles.
subfiles. Sorts
Sorts from
from any
any field.
field.
Powerful
Powerful report
report printing
printing capabilities.
capabili tie s.
C64
C64 220
220 —
- GENERAL LEDGER
LEDGER
Customized
Customized Chart-of-Accounts.
Chart·of·Accou nts. Convenient
Convenient entry
entry of
of cash
cash receipts:
receipts;
disbursements;
disbu rsemen ts ; general
general journal
journal transactions.
transactions. Interfaces with other
other accounting
accounting
modules
modules for
for automated
automated posting
posting of
of G/L
GIL transactions.
transactions . Maintains
Maintains account
account
balances monthly,
balances monthly, quarterly,
quarterly, yearly,
yearly, previous
previ ous quarters
quarters and
and years.
years. Departmental
Departmental
reporting
reportin g and
and many
many other
other features.
features.
v
v
105
105
C64
C64 222
222 —
- ACCOUNTS
ACCOUNTS PAYABLE/CHECKWRITING
PAYABLE/CHECK WRITING
Maintains
Maintainsvendor
vendor master
masterfile.
fi le. Automatic
Automatic aging
agingof
of open
open invoices.
invoices. Automatical
Automatical·
lyIy combines
combines invoices
invoices by
by vendor
vendor and and prints
prints checks
checks with
with full
full remittance
remittance detail.
detail.
Provides
Provides open
open item
item aging
aging report
report by by30,60,90
30, 60, 90day
daycategories.
categories. Interfaces
Interfaces with
with the
the
general ledger
general ledger for
for automated
automated postings.
postings.
C64 223
C64 223 —
- PAYROLL
PAYROLL
Master
Master record
record ofof each
each employee
employee pay
pay activity.
activity. Automatically
Automatically calculates
calculates period
period
pay
pay amount
amount including
including all
all tax
tax and
and miscellaneous
miscellaneous deductions.
deductions. Prints
Prints payroll
payroll
checks
checks with
with full
full pay
pay deduction
deduction detail.
detail. Comprehensive
Comprehensive management
management reporting
reporting
including
including W2's
W2 's and
and 941's.
941 's. General
General ledger
ledger interface
interface for
for automated
automated postings.
postings.
C64 224
C64 224 —
- INVENTORY
INVENTORY MANAGEMENT
MANAGEMENT
Perpetual
Perpetual inventory
inventory records
records for
for all
all stock
stock items.
items. Processes
Processes stock
stock receipts,
receipts,
stock
stock issues,
issues, stock
stock orders,
orders , and
and stock
stock adjustments
adjustmen ts with
with full
full audit
audit trail.
trail. Optional
Optional
interface
interface to
to Order
Order Entry/Point-of-Sale
Entry/Point-of-Sale for
for automated
automated billing
billing of
of inventory
inventory items
items
and
and automated
automated stock-on-hand
stock-on -hand reduction.
reduct ion. Capability
Capability to
to selectively
selectively calculate
calculate re
re-
order level
order level and economic order
and economic order quantity
quantity by inventory category. Assists
inventory category. manage
Ass ists manage·
reports.
ment in parts ordering by generating shortage and re-order reports.
C64 602
C64 602 -— KIC
KICKMAN
KMAN Joystick or
Joystick or Keyboard
Keyboard
. InIn KICKMAN
KICKMAN,, you you maneuver
maneuver aa clever
clever unicyclist
unicyclist who
who scores
scores paints
points by
by catch-
catch
ing balloons, ghosts, and PAC-MAN. KICKMAN uses his head and his feet to
Ing balloons, ghosts, and PAC-MAN. KICKMAN uses his head and his feet to
catch the
catch the falling
falling objects.
objects. During
During some
some phases
phases ofof the
the game,
game, KICKMAN
KICKMAN bursts
bursts
the
the balloons
balloons toto score
score pOints.
points.
C64
C64 603
603 -— SEAWOLF
SEAWOLF Paddles
Paddles
As the
As the commander
commander ofof aa torpedo
torpedo boat,
boat, you
you must
must sink
sink all
all enemy
enemy ships.
ships. Your
Your
targets are fast-moving P.T. boats, cruisers, and freighters. You can play
targets are fast·moving P.T. boats, cruisers, and freighters. You can play
SEAWOLF
SEAWOLF with
with one
one or
or two
two players.
players.
C64
C64604
604-— SPEED/BINGO
SPEED/BINGOMATH MATH Joystickor
Joystick orKeyboard
Keyboard
These two
These two math
math games
games help
help you
you bubuild math skills
ild math skills and
and have
have fun
fun at
at the
the same
same
time.
time. SPEED
SPEED MATH
MATH gives
gives you
you aa time
time limit
limit toto solve
solve aavariety
varietyof
of math
math problems.
problems.
BINGO MATH
BINGO MATH asks
asks you
you to
to solve
solve math
math problems
problems and and use
use the
the answer
answer to to play
play
BINGO.
BINGO. You
You can
can play
play against
against the
the clock
clock or or against
against your
your friends.
friends.
106
106
C64 606
C64 606 -— CLOWNS
CLOWNS Paddles
Paddles
Score paints
Score points in
in CLOWNS
CLOWNS by by popping
popping aa skyfu
skyfull of
of colored
colored balloons.
balloons. You
You have
have
two CLOWNS,
two CLOWNS, one one onon aa seesaw,
seesaw, and
and one
one sailing
sailing through
through the
the air
air bursting
bursting
v balloons.
bal When the
loons. When the clown
clown comes
comes down,
down, you
you must
must catch
catch him
him with
with the
the seesaw
seesaw
and send
and send the
the other
other clown
clown up
up to
to pop
pop balloons.
balloons.
C64 609
C64 609 -- VISIBLE
VISIBLE SOLAR
SOLAR SYSTEM
SYSTEM Keyboard
Keyboa rd
You are
You are the
the commander
commander of of aa spaceship
spaceship on on aa journey
journey through
through our
our Solar
Solar
System. The
System. The ship
ship has
has aa cru
cruising range of
ising range of over
over 11 billion
billion miles
miles and
and is
is packed
packed with
with
computerized equipment
computerized equipment to to help
help you
you discover
discover more
more about
about the
the planets
planets that
that you
you
visit.
visit.
C64 610
C64 610 -- TOOTH
TOOTH INVADERS
INVADERS Joystick
Joyslick
In this game for
In for children,
children, the
the evil
evil O.K.
D.K. spreads plaque
plaque on your teeth. You
You
must floss
must floss and
and clean
clean the
the teeth
teeth before
before they
they fallout.
fall out. As
As each
each tooth
tooth is
is ccleaned,
leaned , itit
glows and changes color. You can kill kill O.K.
D.K. by
by running
running over him,
him, but
but he always
comes back!
comes back! When
When you
you succeed
succeed in
in cleaning
cleaning all
all the
the teeth,
teeth, a
a shower
shower of
of fluoride
fluoride
rains down
rains down from
from a
a cloud.
cloud.
C64 613
C64 613-LAZARIAN
- LAZAR IAN Joystick
Joystick
You are
You are the pilot
the pi of a
lot of a space
space fighter
fighter stationed
stationed in
in a
a remote
remote sector
sector of
of the
the galaxy.
galaxy
Your mission is to rescue stranded starships and to defend your sector against
aa variety
variety of
of threats.
threats. Th
There are three
ere are three phases
phases in
in the game, and
the game, and you
you get
get three ships
th ree ships
to
to complete
comp lete your
your mission.
mi ssion.
C64
C64 614
614 —- OMEGA
OMEGA RACERACE Joystick,
Joystick, Paddles,
Paddles, Keyboard
Keyboard
You
You are
are an
an Omegan
Omegan ship
ship competing
competing against
against the
the Droids,
Droids, the
the most
most powerful
powerfu l
force
force in
in the
the galaxy.
galaxy. You
You must
must destroy
destroy the
the enemy
enemy ships
ships and
and the
the photon
photon and
and
vapor
vapor mines
mines the
the Droids
Oroids have
have planted
planted in
in space.
space.
C64
C64 616-LEMANS
616 - LEMANS Paddle
Paddle
Your
Your car
car is
is at
at the
the pole
pole position
position in
in the
the LeMans
LeMans Grand
Grand Prix.
Prix . You
You must
must pass
pass as
as
many
many cars
cars as
as possible
possible to
to score
score enough
enough points
pOints to
to stay
stay in
in the
the race.
race. The
The race
race
takes
takes you
you over
over hazardous
hazardous terrain,
terrain , including
includ in g icy
icy roads,
roads , divided
divided highways,
highways, dark
dark
roads,
roads, and
and dangerous
dangerous curves.
curves. You
You must
must be
be careful
careful not
not to
to wreck
wreck your
your car
car as
as you
you
race
race to
to the
the finish
finish line.
line.
C64
C64 617
617 -
- PINBALL
PINBALL SPECTACULAR
SPECTACULAR Paddle
Paddle
PINBALL
PINBALL SPECTACULAR
SPECTACU LAR isis like
like playing
playing pinball
pinball on
on your
your 64.
64. This
This game
game offers
offers
fast
fast action
action and
and great
great sound
sound effects.
effects.
C64
C64625-ZORKI
625 - ZORK I Keyboard
Keyboard(Disk)
(Disk)
ZORK I involves the Great Underground Empire; it confronts you with perils
ZORK I invo lves the Great Underground Empire; it confronts you with perils
and
and predicaments
predicaments ranging
ranging from
from the the mystical
mystical to
to the
the macabre.
macabre. You
You strive
strive toto
discover
discover the
the Twenty
Twenty Treasures
Treasures ofof ZORK
ZORK and
and escape
escape with
with them
them and
and your
your life!
life!
107
107
C64
C64627
627 —
- ZORKZORK III
III Keyboard
Keyboard
ZORK
ZORK IIIIII involves
involves aa delightful
del ightful and
and curious
curious place
place with
with ancient
ancient high-arched
high-arched
aqueduct
aqueduct systems,
systems, swirling
swirling mists
mists of
of the
the Land
Land of
of Shadow,
Shadow, and
and aa brilliant
bri lliant pit
pit of
of
fire.
fire. You
You should
should use
use logical
logical problem-solving
problem-solving in
in this
this game;
game; ZORK
ZORK III
II I gives
gives you
you aa
theme, morals,
theme, morals, and
and meaning
meaning inin your
your adventures.
adventures.
C64
C64 628
628 —- DEADLINE
DEADLI NE Keyboard
Keyboard
You
Yo u are
are the
the chief
chief ofof detectives
delectives trying
trying to
to solve
solve thethe murder
murder of
of aa millionaire
mi ll ionaire
philanthropist.
philanthropist. You
You have
have twelve
twelve simulated
sim ulated hours
hours to
to uncover
uncover the
the truth
truth before
before thethe
wrong
wrong will
will is
is read
read to
to the
the eager
eager heirs.
hei rs. The
The mystery
mystery isis confusing,
confusing, and
and it's
it's easy
easy toto
get
get lost
lost as
as you
you try
try to
to piece
piece together
together aa convincing
convincing case
case before
before it's
it's too
too late.
late.
C64 629 —
C64629 - STARCROSS
STARCROSS Keyboard
Keyboard
STARCROSS
STARCROSS is
is another
another mind-bending
mind-bending science
science fiction
fiction adventure
adventure game.
game. You
You
are
are aa space
space prospector
prospector in
in aa one-person
one-person ship
ship searching
search ing for
for black
black holes.
holes. You
You
couldn't
cou ldn't afford
afford the best
best equipment,
equipment, so
so you must
must do
do your best
best with aa smart-
smart-
aleck computer
computer and a mass
mass detector.
detector.
C64 630 —
- SUSPENDED Keyboard
SUSPENDED
SUSPE NDED takes place on aa computer-controlled
compu ter-controlled planet that is facing
fac ing aa
catastrophe. The
catastrophe. main computer
The main computer has
has just malfunctioned; you
just malfunctioned; you take control and
take control and
guide six robots to help you manually maintain the planet while they try to
repairr the cause of the com
discover and repai computer's
pu ter's breakdown.
ART &
& MUSIC
C64 403
C64 403 -— MUSIC
MUSIC COMPOSER
COMPOSER
You
Yo don't have
u don't have to
to be
be a musician
musician to
to make
make music
music onon your
your 64.
64. This
This package
package
teaches you
teaches you everything
everything you
you need
need to
to know
know toto play
play songs
songs and
and create
create sound
sound ef-
ef
fects on
fects on your
your computer.
computer. The
The manual
manual also
also suppl
supplies sample songs
ies sample songs for
for you
you to
to
play.
play.
EDUCATION &
EDUCATION & LEARNING
LEARNING AIDS
AIDS
C64 310
C64 310 -— EASYLESSON
EASYLESSON 64 64 and
and EASYQUIZ
EASYQUIZ 64 64
EasyLesson and
EasyLesson and EasyOuiz
EasyQuiz let
let yo
you use your
u use your 64
64 as
as aa teaching
teaching tool.
tool. With
With these
these
two programs,
two programs, you you can
can easily
easily create
create lessons
lessons andand tests
tests onon topics
topics that
that you
you
choose. Here are some of the things you can do with these
choose. H ere are some of the thi ngs yo u can do with these ed ucation pro- education pro
grams: CCreate
grams: reate aa pool
pool of
of qquestions
uestions to to use
use as
as aa lesson;
lesson: CClassify questions
lassify ques into as
ti ons into as
many as
many as seven
seven categories;
categories; Print
Print out
out each
each lesson
lesson or
or quiz
quiz you
you create;
create; Shuffle
Shuffle test
test
questions be
questions before each qquiz;
fore each Give the
ui z; Give the lest
test in
in either
either flash
flash card
card or
ormultiple
multiple choice
choice
form at.
format.
108
108
C64 701
C64 701 —- GEOGRAPHY
GEOGRAPHY II
This
This educational
educat ional package
package contains
contains thirteen
thi rteen quizzes
quizzes about
about countries,
countries, states,
states,
and
and their
their capitals.
capitals. There
There is
is also
also aa program
program that
that lets
lets you
you print
print out
out aa map
map of
of
England.
England.
C64 702
C64 702 —
- ENGLISH
ENGLISH II
14 programs
14 prog rams that
that teach
teach you
you more
more about
about English.
Engl ish. Word
Word games,
games, poetry,
poetry, word
word
defin itions, and
definitions, and parts
parts of
of speech.
speech.
C64 703 -
C64 - ENGLISH
ENGLISH IIII
16
16 programs
programs help
help sharpen your
your language
language skills.
skills. Spelling
Spelli ng and
and vocabulary
vocabulary
drills,
dri lls, lessons
lessons about homonyms,
homonyms, verb
verb forms,
forms, and
and punctuation.
704 —
C64 704 - ENGLISH III
Collection
Collection of
of 15
15 programs
programs from Commodore's
Commodore's English language series con
con-
more about the parts of speech.
centrating on teaching you more
- ENGLISH IV
C64 705 —
15
15 more English language programs —
- drills on rhyming
rhyming,, unscrambling
words, and spelling.
words, and spelling.
109
109
C64 713
C64 713 —
- MATHEMATICS V
V
Fifteen
Fifteen more
more math
math education
education programs.
programs. Learn while
while you
you have
have fun.
fun .
715 —
C64 715 - MATHEMATICS
MATH EMATICS VII
VII
Sixteen advanced math programs —
advanced math - prime
prime numbers, and
and roots.
- COMPUTER SCIENCE II
C64 717 —
thirteen
These thi rteen programs show you
you more about using your computer. The
programs lists, drawi
programs include sorting lists, drawing
ng graphics, and creating animation.
110
C64 726
C64 726 —- GAMES
GAMES IIIIII
More
More fun
fun and
and educational
educational games
games that
that let
let you
you play
play and
and learn
learn on
on your
you r 64.
64. Seven
Seven
games in
games in this
thi s collection.
coll ection.
111
111
20:
20: READ ERROR
READ ERROR (block
(block header
header not
not found)
found)
The
The disk
disk controller
controller is
is unable
unable toto locate
locate the
the header
header of
of the
the requested
requested data
data
block.
block. Caused
Caused byby an
an illegal
illegal sector
sector number,
number, oror the
the header
header has
has been
been
destroyed.
destroyed.
21 :
21: READ ERROR
READ ERROR (no
(no sync
sync character)
character)
The
The disk
disk controller
controller is
is unable
unable to
to detect
detect aa sync
sync mark
mark on
on the
the desired
desired track.
track.
Caused
Caused by
by misalignment
misalignment of
of the
the read/writer
read/w ri ter head,
head, no
no diskette
diskette is
is present,
present, or
or
unformatted
unformatted or
or improperly
improperly seated
seated diskette.
diskette. Can
Can also
also indicate
indicate aa hardware
hardware
failure.
failure.
22:
22: READ ERROR
READ ERROR (data
(data block
block not
not present)
present)
The
The disk
disk controller
controller has
has been
been requested to to read or
or verify
verify aa data
data block
bl ock that
that
was
was not
not properly
properly written.
wri tt en. This
Th is error
error message
message occurs in in conjunction
conjunction with
with
the
the BLOCK
BLOCK commands
com mands and and indicates
indicates an
an illegal
illegal track
track and/or
and/or sector
sector rereo
quest.
quest.
25:
25: WRITE ERROR (write·verify
(write-verify error)
This
Thi controller
s message is generated if the contro ll er detects a mismatch between
the data in the DOS memory.
the written data and Ihe
112
112
33:
33: SYNTAX ERROR (invalid file name)
Pattern matching is invalidly used in the OPEN or SAVE command.
~ 34:
34: SYNTAX ERROR (no file given)
The file name was left ou
outt of a command or the DOS does not recognize it
as
as such.
such. Typically,
Typically, a colon (:) has been left out of the command.
51:
51: OVERFLOW
OVERFLOW IN IN RECORD
RECORD
— PRINTS
PRINT# statement
statement exceeds
exceeds record
record boundary.
boundary. Information
Information is
is truncated.
truncated.
Since
Since the
the carriage
carriage return which
which is sent
sen t as
as a record
record terminator
terminator is
is counted
counted
in
in the
the record
record size,
size , this
this message
message will
will occur
occ ur if the
the total
total characters
characte rs in the
the
record
record (including
(including the
the final carriage
carriage return)
return) exceeds
exceeds the
the defined
defined size.
size.
52:
52: FILE
FILE TOO
TOO LARGE
LARGE
Record
Record position
position within
within aa relative file indicates
indicates that
that disk
disk overflow will
will
~ result.
resul t.
v
113
113
65: NO BLOCK
occurs
This message occ conjunclion with the B·A
urs in conjunction B-A command. It indicates
that the block to be allocated has been previously allocated. The
parameters indicate the track and sector avai
available
lable with the next highest
number. (0)T then all blocks higher in number
number. If the parameters are zero (0),
are in use.
use.
67: ILLEGAL
ILLEGAL SYSTEM T OR S
TOR S
This
Th is special
spec ial error message indicates an illegal system track or sector.
71:
71: DIRECTORY
DIRECTORY ERROR
ERROR (')
The BAM
BAM does not match
match the
the internal count.
count. There
There is
is aa problem
problem in
in the
BAM
BAM allocation
allocation or the BAM
rect this
this problem,
BAM has been
problem, reinitialize
reinitialize the
been overwritten
overwritten in DOS
the diskette
diskette to
DOS memory.
to restore the
memory. To
the BAM
BAM in
To cor
cor-
in memory.
"
Some active
BAM
active files may be terminated by the corrective
BAM = Block
Block Availability
Availability Map
Map
correct ive action.
action. NOTE:
NOTE: '"'
72:
72: DISK
DISK FULL
FULL
Either
Either the
the blocks
blocks on
on the
the diskette
diskette are
are used
used or
or the
the directory
directory is at its
its entry
entry ",...,
limit.
limi t. DISK
DISK FULL
FULL is
is sent
sent when
when two
two blocks
blocks are
are available
available on
on the
the 1541
1541 to
to
allow
allow the
the current
currenl file
file to
to be
be closed.
closed.
114
114
115
115
VARIABLES
VARIABLES
The 64 uses three types of variables in BASIC. These are real
real numeric,
numeric, in
in-
teger numeric,
numeric , and string (alphanumeric) variables.
Variable names may
may consist of a single letter, a letter followed
fol lowed by a number,
numbe r,
or two
or two letters.
letters.
An integer variable is specified by using the percent (% (%)) sign after th
thee
variable name. String variables have the dollar sign ($) after their name.
EXAMPLES
Real Variable Names: A, A5, BZ
A. A5,
Integer Variable
Integer Variable Names
Names:: A%,
A%. A5 %, Bl%
A5%. BZ%
String Variable Names:
Names: AS,
A$, A5$,
A5S. BZ$
BZS
ARRAYS are lists of variables with the same name, name, using numbers
numbers called
subscripts
su elementt of the array. Arrays are defined using the DI
bscripts to specify the elemen DIMM
statement,, and
statement and may
may contain
contain floating po
point, integer, or
int , integer, or string variables. The array
array
name is
variable name is fol
followed by a set of parentheses
lowed by parentheses ( enclosing
) enclosi number of
ng the number
va riables in
variables in the list.
list.
116
116
n
OPERATORS
arithmetic
The arithmet ic operators include the following signs:
+ Addition
- Subtraction
Multiplication
Multiplica tion
/ Division
Divisi on
t (exponentiation)
Raising to a power (exponen ti ation)
On a li
line containing
ne contain operator, there is a set order in
ing more than one operator, in which
occur. If several operations are used together on the same
operations always occur.
liline,
ne, the computer assigns priorities as follows: First, exponentiation. Next,
Next,
division, and last, addition and subtraction.
multiplication and division,
You can change the order of operations by enclosing within parentheses the
calculation to be performed first. Operations enclosed in parentheses will take
place before other operations.
There are also operations for equalities and inequalities:
= Equal To
<
< Less Than
>
> Greater
Grea ter Than
< =-
< Less Than or Equal To
>=
>= Greater Than or Equal To
<>
< '/ Not Equal To
To
....... Finally,
Fi nally, there
Ihere are three logical operators:
v AND
OR
'-' NOT
NOT
_ These
These are
are used most often
often to join
join multiple formulas in
in IF .
...
. . THEN
THEN
statements.
statements . For
For example:
IF A
IF A = B
BAND C = D
AND C D THEN
TH EN 100
100 (Requires both parts
parts to
to be
be true)
true)
IF
IF A
A = B
B OR
OR C
C= D
D THEN
THEN 100
100 (Allows
(Allows either part to
to be
be true)
true)
COMMANDS
COMMANDS
CONT
CO NT (Continue)
(Continue)
This
This command
command is is used
used to
to restart
restart the
the execution
execution of
of aa program
program which
wh ich has
has been
been
stopped
stopped by
by either
either using
using the
the STOP
STOP key,
key, aa STOP
STOP statement,
statement. or or an
an END
END statement
statement
within
within the
the program.
program. The
The program
program will
will restart
restart at
at the
the exact
exact place
place from
from where
where itit left
left
off.
off.
v
117
117
LIST
The LIST
The LI ST command
command allows you you to
to look at lines
lines of
of aa BASIC program in in
memory. You
You can ask for the
the entire program
program to
to be displayed,
displayed, or
or only
only certain
certain line
numbers.
LIST ShowS entire program
Shows
LIST 10-
10 - Shows 10 until end
only from line 10
LIST 10
10 Shows 10
only line 10
LIST
LI ST -
- 10
10 Shows lines from
from beginning
begi nn ing until 10
10
LIST
LI ST 10-20
10·20 Shows line from
line from 10
10 to 20,
20, inclusive
incl usive
LOAD
LOAD AS,S
LOAD A$,8 for prog
Looks for program
ram whose name is in the variable A$
LOAD
LOAD ""HELLO"T8
HELLO",S program
Looks for prog called
ram cal led HELLO on the disk dri
drive
ve
LOAD ""*",8
"',S Looks for fifirst
rst program on disk
NEW
N EW
This command erases the entire program in memory, and also clears out any
variables that may have been usedused.. Unless the program was SAVEd,
SAVEd, it is lost.
BE CAREFUL WHENWHE N YOU USE THIS COMMAND.
COMMAND.
command
The NEW com mand can also be used as a BASIC program statement. When
program
the prog reaches
ram reac line, the prog
hes this line, program
ram is erased. This is useful if you want
to leave everything neat when the program is done.
RUN
program, once the program is loaded
This command causes execution of a program,
RUN,, the computer will start
into memory. If there is no line number following RUN
with the lowest line number. If a line number is designated, the program will
start executing from the specified line.
RUN Starts program at lowest line number
RUN 100 Starts execution at line 100
RUN
RU NX UNDEFINED
UND EFINED STATEMENT ERROR. You must always specify
line number,
an actual line number, not a variable representation
11S
118
SAVE
SAV A$,8
E A$,8 Stores on
Stores on disk
disk with
with name
name in
in A$
AS
SAVE ""HELLO",8
SAVE HELLO",8 Stores
Stores on
on disk
disk with
with name
name HELLO
HELLO
VERIFY
VERIFY
This
Thi command causes
s command causes Ihethe com
computer to check
puler 10 check the
the program
program on on disk
disk against
against
the one
the one inin memory.
memory. This
This is
is proof
proof that
that the
the program
program isis ac
actually
tually SAVEd, in in case
case the
the
disk is
disk is bad,
bad, or
or something
something wenwentt wrong
wrong during
during the SAVE.
SAVE.
VERIFY followed by by a program
program name,
name, or aa string variable,
variable, will
will search for that
that
program and then cheCk.
program check. Device
Device nu
number is included
mber is included with the veri
verify command,
fy command.
command.
~ VERIFY ""HELLO",8
HELLO",8 HELLO on disk, then checks
Searches for HELLO
~ STATEMENTS
CLOSE
This command completes and closes any files used by OPEN statements.
The number following CLOSE is the file number to be cclosed.
losed.
CLOSE 2 Only file #2 is closed
CLR
CLR
This command
command will will erase any
any variables
variables in memory, but
in memory, bu t leaves
leaves the
the program
program
itself intact.
intact. This
Thi s command is automatically
automatically executed when aa RUN command is is
given.
given.
CMD
CMD
CMD
CMD sends
sends the
the output
output which normally
normally would
wou ld go
go to the
the screen
screen (i.e.,
(i.e., PRINT
PRINT
statements,
statements, LISTs,
LISTs, but
but not
not POKEs
POK Es onto
on to the
the screen)
screen) to
to another
another device
device instead.
ins lead.
This
This could
could be
be aa printer,
printer, or
or aa data
data file on
on disk.
disk. This
This device
device or
or file
file must
must bebe OPEN-
OPEN-
ed
ed first.
first. The
The CMD
CM D command
command must must be
be followed
followed by
by aa number
number oror numeric
numeric variable
variable
referring
referring to
to the
Ihe file.
fi le.
OPEN
OPEN 1,4
1,4 OPENs
OPENs device
device #4,
#4, which
which is
is the
the printer
printer
CMD
CMD11 All
All normal
normal output
output now
now goes
goes to
to printer
printer
LIST
LIST The
The program
program listing
listing now
now goes
goes toto the
the printer,
printer, not
not the
the
scree n
screen
To
To send
send output
outpu t back
back to
to the
the screen,
screen, CLOSE
CLOSE the
the file
lile with
with CLOSE
CLOS E 1.1.
DATA
DATA
This
Th is statement
statemen t isis followed
fol lowed by
by aa list
list of
of items
items to
to be
be used
used by
by READ
READ statements.
statements.
Items
Items may
may be
be numeric
numeric values
values oror test
tes t strings,
strings, and
and items
items are
are separated
separated by by com
com -
mas.
mas. String
String items
items need
need not not be
be inside
in side quote
quote marks
marks unless
unless they
they contain
contain space,
space,
colon,
colon , or
or comma.
comma. IfIf two
two commas
com mas havehave nothing
nothi ng between
between them,
them , the
the value
val ue will
wi ll be
be
READ
READ as
as aa zero
ze ro for
for aa number,
number, or
or an
an empty
empty string.
string.
v DATA
DATA 12,
12, 14.5,
14.5, "HELLO,
" HELLO, MOM",
MOM ", 3.14,
3. 14, PART1
PART1
119
119
10 DEF
10 DEF FNA{X)
FNA(X) = 12*(34.75
12"(34.75 - XI.3)
- XI.3)
20
20 PRINT
PRINT FNA(7)
FNA(7) t
t
T J
| 77 is
IS inserted
X is
X IS m
Insefl e<! where
In lr\e
wnele
rormula
the formula
For this
For this example,
example, the
the result
result woud
woud be
be 137.
137.
DIM
41 ELEMENTS
41 16 ELEMENTS
ELEMENTS 125
125 ELEMENTS
ELEM ENTS
You can dimension more than one array in a DIM statement. However, be
careful not to dimension an array more than once.
END
statement,, the program halts,
When a program encounters an END statement halts, as if it ran
out of lines. You may use CON
CONT program.
T to restart the program.
FOR ....
. . TO ..
.... STEP
FOR L = 1
10 FOR 1 TO 10
10 STEP .1
20 PRINT
PRINT LL
30 NEXT
NEXT LL
the
The end of th may be
e loop value may be followed by
by the word STEP and another
number or
number or va
variable. In this case
ri able. In case,, the value foll
following STEP
ow in g STE is added
P is added each time in-
in
1. Th
stead of 1. This count
is allows you to co or by
un t backwards, or by Iraclions.
fractions.
120
120
v 10 GET
10 GET A$:
AS: IF
IF A$
A$ == ....""THEN 10
THEN 10
GET#
GET#
GET# statement
The GET# statement is
is used
used with
with a previously OPENed
OPENed device or
or file,
file, to input
one character at aa time from that device or
or file
file..
v GET#1,A$
GET #1 ,AS
input one character from a data file.
This would input
GOSUB
GOTO, except the computer remembers which
This statement is similar to GOTO,
program line it last executed before the GOSUB. When a line with a RETURN
encountered,
statement is encoun tered , the program jumps back to the statement im·
im
following
mediately fo This
llowing the GOSUB. Th yourr pro·
is is useful if there is a routine in you pro
gram that occurs in
in several parts of the program. Instead of typing the routine
over, execute GOSUBs each time the routine is needed.
over and over,
20 GOSUB
20 800
GOSUB 800
GOTO OR
OR GO
GO TOTO
When aa statement with the GOTO command is is reached,
reached , the next line to be
be
executed will
will be the one with the
the line
line number following the
the word
word GOTO.
GOTO.
IF
IF .... .THEN
. THEN
IF
IF ...
... THEN
TH EN lets
lets the
the computer
computer analyze
analyze aa situation
siluation and
and take
take two
two possible
poss ible
courses
co urse s ofof action,
action , depending
depending on on the
th e outcome.
ou tcome. IfIf the
the expression
expres sion isis true,
true , the
the
statement
statement following THEN THEN is is executed.
executed . This
This may
may bebe any
any BASIC
BASIC statement.
statement.
IfIf the
the expression
expression is is false,
false, the
the program
program goes
goes directly
directly to
to the
the next
next line.
line.
The
The expression
expression being
bei ng evaluated
evaluated may may bebe aa variable
variable or
or formula,
form ula, in
in which
which case
case itit
is
is considered
cons idered true
true ifif nonzero,
nonze ro, and
and false
fal se ifif zero.
zero. In
In most
most cases,
cases, there
there is
is an
an ex
ex-
pression
pression involving
involving relational
relational operators
operators (=,
( ;;;; , < < ,, >> , <=>=
< :;;; , > :;;; , <>
< >
AND,
AND, OR
OR NOT).
NOT).
10
10 IF
IF XX >
> 10
10 THEN
THEN END
END
INPUT
INPUT
The
The INPUT
INPUT statement
slatement allows
allows the
the program
program to
to get
get data
data from
from the
the user,
user, assign
assign·
ing
ing that
that data
data to10 aa variable.
variable. The
The program
program will
will stop,
stop, print
print aa question
question mark
mark (?)
(?) on
on
the
the screen,
screen, and
and wait
wait for
for the
the user
user toto type
type in
in the
the answer
answer and and hit
hit RETURN.
RETURN .
INPUT
INPUT isis followed
foll owed byby aa variable
va riab le name,
name, or
or aa list
list of
of variable
va riable names,
names, separated
separated
by
by commas.
commas. AA message
message maymay be be placed
placed within
within quote
quote marks,
marks, before
bef ore the
the list
list of
of
variable
variable names
names toto be
be INPUT.
IN PUT. IfIf more
more than
than one
one variable
variable isis to
to be
be INPUT,
INPUT,they
they must
must
be
be separated
separated by
by commas
commas when
when typed.
typed .
10
10 INPUT
INPUT -PLEASE
'·PLEASE ENTER
ENTER YOUR
YOUR FIRST
FIRST NAME";A$
NAME "; A$
v
20
20 PRINT
PRINT "ENTER
" ENTER YOUR
YOU R CODE
CODE NUMBER";:!NPUT
NUMBER" ;:INPUT BB
121
121
LET
LET
LET
LET is
is hardly
hardly ever
ever used
used in
in programs,
programs , since
since itit is
is optional,
optional, but
but the
the statement
statement is
is
the
the heart
heart of
of all
all BASIC
BASIC programs.
programs. The
The variable
variable name
name which
which isis to
to be
be assigned
assigned the
the
result
resuit of
of aa calculation
ca lculation is
is on
on the
the left
left side
side of
of the
the equal
equal sign,
sign, and
and the
the formula
formula on
on
the right.
the ri ght.
10 LET
10 LET A = 55
A =
LET D$ = "HELLO"
20 LET " HELLO"
NEXT
NEXT
NEXT is
NEXT is always
always used
used in
in conjunction
conjunction withwith the
the FOR
FOR statement.
statement. When
When the the pro
pro·
gram
gram reaches
reaches aa NEXT
NEXT statement,
statement , itit checks
checks the
the FOR
FOR statement
statement to
to see
see ifif the
the limit
limit
of
of the
the loop
loop has
has been
been reached.
reached . IfIf the
the loop is not
not finished,
finished, the
the loop
loop variable
variable is
is in
in·
creased by the specified STEP value. If the loop
loop is
is finished,
finished , execution proceeds
w ith the statement following
with following NEXT.
NEXT.
NEXT may be followed
foll owed by aa variable
variable name,
name, or list
list of
of variable
variable names,
names,
separated by
by commas. If there
there are
are no names listed,
listed, the
th e loop
loop started
started is the one
being completed.
comp leted. If variables
variab les are given,
give n, they are completed in order
order from
from left to
to
right.
right.
10 FOR X
10 X = 11 TO 100: NEXT
ON
ON
This command turnsturn s the
the GOTO and GOSUB comma commands special versions
nds into special vers ions
of the IF statement. ON is followed by a formu formula,
la, which is evaluated. If the
result of the calcu
calculation one, the first line on the list is executed;
lation is one, result
executed ; if the resull
2, the second liline
is 2, ne isis executed,
executed, and so on. If the result is 0, negative, or larger
than
than the list of numbers,
numbers, the next line executed wi willll be the statement fofollowing
ll owing
the ON
ON statement.
10 INPUT X
20 ON X GOTO
GOTO 10,20,30,40,50
10.20,30,40,50
OPEN
The OPEN statement allows the 64 to access devices such as the disk for
data, a printer, or even the screen. OPEN is foll followed (0-255), to
owed by a number (0·255),
following
which all followi number
ng statements will refer. There is usually a second number
after the fifirst,
rst , which is
is the device number.
The
Th numbers
e device nu are::
mbers are
°0 Screen
4 Printer
Printer
8 Disk
Disk
122
122
v POKE
formulas.. The first location is a
POKE is always followed by two numbers, or formulas
location;
memory locati on; the second number is a decimal val value
ue from 0 to 255, which
willl be placed in the memory location
wil location,, rep
replacing
lacing any previously stored valvalue.
ue.
POKE 53281
10 POKE 53281.0
,0
4096' 13
20 S = 4096"1 3
POKES+
30 POKE S + 29,8
PRINT
the
The PRINT statement is th use, but there are a
e first one most people learn to use,
number of variations to be aware of. PRINT can be fo followed
llowed by:
Text String with
with quotes
Variable
Variab le names
Functions
Functions
Punctuation
Punct uation marks
v Punctuation marks are used to help format the data on the screen. screen. The com
com-
ma divides the screen
screen into four columns,
co lumns, while the semicolon
sem ico lon suppresses all
spacing. Either
Ei ther mark
mark can be
be the last symbol on on aa line.
li ne. This
Thi s results in
in the
th e next
thing PRINTed acting as if it were
we re aa continuation of the same PRINT statement.
stat emen t.
10
10 PRINT "HELLO"
" HELLO"
20
20 PRINT "HELLO",A$
" HELLO",A$
30
30 PRINT A+B
A+ B
40
40 PRINT J;
J;
60
60 PRINT A,B,C,D
A,B,C,D
Also
Also see:
see: POS,
POS, SPC
SPC and
and TAB
TAB functions
fu ncti ons
PRINTS
PRINT#
There
There are
are aa few
few differences
differences between
between this
thi s statement
statement and and PRINT.
PRINT. PRINTS
PR INT# is
is
followed
followed by
by aa number,
number, which
which refers
refe rs to
to the
the device
device or or data
data file
file previously
previously
OPENed.
OPENed. This
This number
number is
is followed
followed by
by aa comma
comma and and aa list
list to
to be
be printed.
printed. The
The com
com·
ma
ma and
and semicolon
semicolon have
have the
th e same
same effect
effect as
as they
they do
do in
in PRINT.
PRINT. Please
Please note
note that
that
some
some devices
devices may
may not
not work
work with
wi th TAB
TAB and
and SPC.
SPC.
100
100 PRINT#1."DATA
PRINT#l ,"DATA VALUES";
VALU ES"; A%,
A%, B1,
Bl , C$
C$
123
123
REM (Remark)
REMark is a note to whomever is reading a LIST of the program. It may ex· ex
program,, or give additional instructions. REM statements
plain a section of the program
in no way affect the operation of the program,
program, except to add to its length. REM
may be fo llowed
followed by any text.
RESTORE
program, the pOinter
When executed in a program, pointer to which an item in a DATA state·
state
ment wiwillll be READ next is reset to the first item in the list. This gives you the
re-READ
ability to re·R information.
EAD the in RESTORE stands by itself on a line.
formation. RESTORE
RETURN
This statement is always used in
in conjunction with GOSUB. When the pro·
pro
RETURN,, it will go to the statement immediately following
gram encounters a RETURN
the GOSUB comma nd. If no GOSUB was previously issued
command. issued,, a RETURN
WITHOUT GOSUB
GOSUB ERROR wi ll occur.
will
STOP
This statement will hal
haltt program execution. The message,
message. BREAK IN xxx will
displayed,, where xxx is the line number contain
be displayed containing
ing STOP. The program may
be restarted by USing
using the CONT command. STOP is normally used in
in debugging
a program.
SYS
SYS is followed by a decimal number or numeric value in the range 0·65535.
0-65535.
The program will then beg in executing the machine language program start
begin ing
starting
at that memory location. This is similar to the USR function
function,, but does not allow
parameter passing.
WAIT
WAIT is used to halt the program until the contents of a memory locat ion
location
changes in a speci fi c way. WAI
specific WAITT is followed by a memory location (X) and up to
variables.
two var iables. The format is:
WA IT X,Y,Z
WAIT
NUMERIC FUNCTIONS
ABS(X) (absolute value)
ABS(X) value)
ABS returns the absolute value of the number,
number, without its sign (+
{+ or -
- ).
). The
answer is always positive.
124
124
COS(X) (cosine)
'-' cosine
Returns the value of the cos X, where X is an angle measured in ra·
ine of X, ra
dians.
v EXP(X)
mathematical
Returns the value of the mathemat ica l constant e(2.71827183) raised to the
Ihe
power of X.
FNxx(X)
FN xx(X)
Returns the val
value user-defined functio
ue of the user·defined function DEF FN
n xx created in a OEF FNxx(X)
xx(X)
statement.
INT(X)
Returns the truncated value of X,
X, that is,
is. with all the decimal places to the
riright the
ght of th removed.. The result wil
e decimal point removed willl always be less than
than,, or equal
v
to, X. Thus, with
Thu s, any negative numbers wit h decimal places will become the integer
less than their curre nt value.
current
LOG(X) (logarithm)
Will
Will return the natural log of X. The natural log to the base e (see EXP(X».
EXP(X)). To
convert to log base 10,
10, simpy divide by LOG(10).
LOG(10).
PEEK(X)
0-65535, giving a
Used to find out contents of memory location X, in the range 0·65535,
result
resuit from 0-255. PEEK is often used in conjunction with
in conjunct ion wi th the POKE statement.
statemen t.
v
RND(X) (random
{random number)
RND(X) returns a random number in the range 0·1. 0-1. The first random number
should be generated by the form formula RND(-TI)
ula RND( - TI) to start things off differently
every time. After this, X should be a 1 1 or any positive number. If X is zero,
zero, the
result wi ll
will be the same random number as the last one.
A negat
A negativeive value for X will reseed the generator. The use of the same negative
number for X wiwill result
ll resu "random"
lt in the same sequence of "random numbers.
" numbers.
v formula
The fo generating
rm ula for generat number between
ing a number between X and Y is:
N = RND(1),
RND(1)*(Y-X)+X
(Y - X)+ X
where,
where.
v
Y is the upper limit
X is the lower range of numbers desired.
SGN(X) (sign)
This
Thi returns
s function ret negative,
urn s the sign (positive, negat ive, or zero) of X. Th
Thee result will
be + 11 if positive, 0 if zero,
zero , and - 1
- 1 if negative.
negat ive.
v
SIN(X) (sine)
v SIN(X) is the trigonometric function.
trigo nometric sine fu nction. The result will be the sine of X,
X,
in radians.
where X is an angle in
125
v
Downloaded from www.Manualslib.com manuals search engine
SQR(X) {square
SQR(X) (s quare root)
root)
This
This function
function will
will return
return the
the square
square root
root of
of X,
X, where
where XX is
is aa positive
positive number
number or
or
O. IfIf XX is
0. is negative,
negative, an
an ILLEGAL
ILLEGAL QUANTITY
QUANTITY ERROR
ERROR results.
resuits.
TAN(X) (tangent)
TAN(X) (tangent)
The
The result
result will
will be
be the
the tangent
tangent of
of X,
X, where
where XX is
is an
an angle
angle in
in radians.
radians.
US~
USR(X) ~
When
When this
this function
function is
is used,
used , the
the program
program jumps
jumps to
to aa machine
mach ine language
language pro
pro·
gram
gram whose
whose starting
starting point
point is
is contained
contained in
in memory
memory locations.
locations. The
The parameter
parameter XX .-.
is
is passed
passed to
to the
the machine
machine language
language program,
program, which
which will
will return
return another
another value
value
back to
to the
the BASIC
BASIC program.
program. Refer
Refer to
to the
the Commodore
Commodore 64
64 Programmer's
Programmer's
Reference
Reference Manual
Manual for
for more
more details
details on
on this
this function
function and
and machine
machine language
language pro
pro-
gramming.
gramming.
STRING FUNCTIONS
ASC(XS)
ASC(XS)
This
Thi s function will
will return the
the ASCII
ASCII code
code of
of the
the first character of X$.
XS.
CHRS(X)
CHR$(X)
This
This is the opposite of ASC,
ASC, and returns aa string character
character whose ASCII
ASCII code
is X.
isX.
LEFTS(XS,X)
Returns a string containing the leftmost X
X characters of $X.
SX.
LEN(XS)
LEN{X$)
Returned will be the number of characters (includ
(including
ing spaces and other sym
sym-
bols) in the string XS.
X$.
MIDS(XS, S,X)
MID^XS.S.X)
willll return a string containing X
This wi X characters starting from the Sth
character in X$.
RIGHTS(XS,X)
RIGHTS(X$,X)
X$.
Returns the rightmost X characters in XS.
STRS(X)
This
Thi s will return a string which is identical to the PRINTed version of X.
VAL(XS)
This
Thi opera
s function converts X$ into a number, and is essentially the inverse opera-
tion from STR$. The string is examined from the leftmost
leftmost character to the right,
right,
recognizable
for as many characters as are in recog number format.
nizable number
lOX
10 X = VAL(" 123.456")
VALC'123.456") X = 123.456
10
10 X = VAL(" 12A13B")
VAL("12A13B") X =
X = 12
12
10
10 X = VAL("RIU017"
VAL("RIU017")) X = 0
10
10 X = VAL(" -1.23.45.67")
VAL("-1.23.45.67") X = --1.23
1.23
126
126
POS(X)
POS<X)
This
This function
funct ion returns
returns the
the number
number of
of the
the column
co lumn (0-39)
(0-39) at
at which
which the
the next
next
PRINT statement
PRINT statement will
wi ll begin
begin on
on the
the screen.
screen. XX may
may have any value
have any value and
and is
is not
not
used.
used.
SPC(X)
SPCpC)
This is
This is used
used in
in aa PRINT
PRINT statement
statement to
to skip
ski p XX spaces
spaces forward.
forward.
TAB(X)
TAB(X)
'-J TAB
TAB is
is also
also used
used in
in aa PRINT
PRINT statement;
statement ; the
the next
next item
item to
to be
be PRINTed
PRINTed will
wi ll be
be
in column
in column X.
127
127
Looks lik.
Look. like Looks like
Com- Abbrevi- this on Com- Abbrevi- this on
mand
mond ation
otion screen mand
mond ation screen
screen
DATA
DATA D EI:IID
D ETTTal A DD~
Q INPUT NONE INPUT
IN PUT
.'
DEF
DEF D EI:IID E DEl INPUT# I EI:IID N [2]
DIM
DIM i) eh3 i
D D INT
INT NONE INT
INT
128
128
'-'
Looks like Looks like
looks
'-' Com
Com· Abbrevi
Abbrevi- this on Com
Com- Abbrevi
Abb revi- this on
mand
mond at ion
ation scree
screenn mond
mand ation screen
V
LEFTS LE rmID F LEQ RIGHT$
RIGHTS R rmID I RW
'-'
LE
LENN NONE LEN RN
RNDD R rmID N R[ZJ
'-'
v
LET L rmID
L EHE E El RUN R rmID u RW
LI ST
LIST rmID W SAVE S rmID A S~
v LOAD rmID o
a 0 SGN S rmID G s[O
V MID$
MIDS
NEW
NEXT
MrmID
NONE
N rmID
I MW
NEW
N
El
SPC(
SQR
STATUS
S rmID P
S rmID
S
ST
ST
EflT; Q S.
s O
ST
NOT N rmID a nD
NO STEP stB!!!
ST rmID E STD
pas
POS NONE pas
POS THEN t rmID
T E!Uj H T[]
PRINT ? ? TlME
TIME TI
Tl TI
Tl
v
'-'
PRINT#
PRINT # P rmID R P
Id TIMES Tl$
TIS Tl$
TIS
V
READ R rmID E REl USR U rmID
U EH S U~
u[v)
REM NONE REM VAL v rmID
V ET!T A vV~
5]
v RESTORE RE rmID S RE~ VERIFY v rmID
V EH E vEl
V RETUR N RE rmID
RE tSIUI T
T RE [[] WAIT WrmID A W~
V
V
v
v
v
129
V
v
Downloaded from www.Manualslib.com manuals search engine
APPENDIX EE
APPENDIX
SCREEN
SCREEN DISPLAY
DISPLAY CODES
CODES
The
The following
following chart
chart lists
lists all
all of
of the
the characters
characters built
built into
into the
the 64's
64's character
cha racter
sets.
sets. ItIt shows
shows which
which numbers
numbers should
should be
be POKEd
POKEd into
into screen
screen memory
memory (locations
(locat ions
1024-2023}
1024-2023) to
to get
get aa desired
desired character.
ch aracter. Also
Also shown
shown is
is which
which character
character cor
cor-
responds
respon ds to
to aa number
number PEEKed
PEEKed from
from the
the screen.
screen .
Two
Two character
charact er sets
set s are
are available,
available, but
but only
on ly one
one set
set at
at aa time.
time. This
Thi s means
means that
that
you
yo u cannot
cannot have
have characters
characters from
from one
one set
set on
on the
th e screen
screen atat the
the same
same time
time you
you
have
have characters
characte rs from
from the,other
the other set
set displayed.
displayed. The
The sets
sets are
are switched
switched by by holding
holding
down
down the Ii!:W and
the ETUI and 'C=' keys [QJ
keys simultaneously.
simultaneousl y_
From
From BASIC,
BASIC, POKE
POKE 53272,21
53272,21 will
will switch
switch to
to upper
upper case
case mode
mode and
and POKE
POKE
53272,23 switches
53272.23 switches to
to lower
lower case.
case.
Any
Any number
number on
on the
the chart
chart may
may also
also be
be displayed
displayed in
in REVERSE.
REVERSE. The
Th e reverse
reverse
character
character code
code may
may be
be obtained
obtain ed by
by adding
adding 128
128 to
to the
the values
values shown.
shown.
If
II you
you want
want toto display
display aa solid
solid circle
ci rcle at
at location
location 1504,
1504, POKE
POKE thethe code
code for
for the
the
circle
circle (81)
(81) into
into location
location 1504:
1504: POKE
POKE 1504,81.
1504,81.
There
There is is aa corresponding
corresponding memory
memory location
location to
to control
cont rol the
the color
color of
of each
each
character
character displayed
displayed on
on the
the screen
screen (locations
(locations 55296-56295).
55296·56295). ToTo change
change the
the color
color
of
of the
th e circle
circle to
to yellow
yel low (color
(color code
code 7)
7) you
yo u would
would POKE
POKE the
the corresponding
corresponding
memory
memory location
location (55776)
(55776) with
with the
the character
cha racter color:
co lor: POKE
POKE 55776,7.
55776,7.
Refer
Refer to
to Appendix
Appendi x G
G for the
the complete
complete screen
screen and
and color
co lor memory
memory maps,
maps, along
along
wit h color codes.
with
NOTE: The
The following
follow ing POKEs display
display the
the same
same symbol in
in set 11 and 2:
2: 1.
1, 27-64.
27·64,
91-93, 96-104,106-121 , 123-127.
91-93. 96-104, 106-121, 123-127.
SCREEN CODES
1
SET 1 SET 2 POKE 1
SET 1 SET 2 POKE 1
SET 1 SET 2 POKE
@
@ o0 C c 3 F
F f 6
A a 1 oD d 4 G
G g 7
Bb2Ee5Hh
E e 5 H h 8
B b 2
""
130
130
'-'
SET 11 SET 2 POKE SET 11 SET 2 POKE
POKE SET 11 SET 2 POKE
V
V 9 % 37 ~ A 65
V J 10 & 38 m
CD B
B 66
'--'
K k 11
11 39 B
El C 67
V
L 12 40 B
El D 68
v
M m 13 41
41
Q
El E 69
v
N
N n 14 42 U
D F 70
0O o
0 15 + 43 []
D G 71
V
P P
P 16 44 a
[] H 72
v
v
Q
Q q
q 17 45 W I 73
R
R r 18 46 ~
a J 74
v
S s
S 19 47 □
EJ K 75
v
T t 20 0 48 0D L 76
U
U uu 21
21
49
S
is] M 77
v
V Vv 22 2 50 00 N
N 78
'-' w
W w
w 23 3 51
51
0□ o
0 79
'-' X x
X 24 4 52
0 P
p 80
v yY y
y 25 5 53 II] Q
Q 81
v z
Z z
z 26 6 54 □
D R
R 82
v 27 7 55 ~ S 83
'-' £ 28 8 56 [] T 84
v 29 9 57 W U
U 85
v i 30 58 ~ V 86
'-' -
SPACE
31
32 <
59
60
D
l±l
W
w
X
87
88
v
33 61 [] Y
Y 89
v
34 > 62 [1] z
Z 90
# 35 ? 63 EB 91
$ 36 El 64 IJ 92
v
131
131
v
Downloaded from www.Manualslib.com manuals search engine
SET 11 SET 2 POKE SET 11 SET 2 POKE SET 11 SET 2 POKE
rnCD 93 ~ ~ ,05
105 E
[J ,17
117
3
~ ~ 95 [8 ,07
107 □
U ,,9
119
H
~
. C.
SPACE 96 ,08
108 ,120
20
E
IJ 97 [g ,09
109 ~
U ,2,
121
H 98 6J '110
,0 a
0 0
0 ,122
22
n
0 99 □
U ',,
111 E
ILJ ,23
123 -
D
0 ,00
100
ca ,,2
112
a
~ ,24
124
□
0 ,0,
101
B
El ,,3
113 H
I:J ,25
125
II ,102
02 53 '114
,4 H
~ ,26
126
0 ,103
03 BJ ,,5
115 ~
S ,27
127
,....,
—
~ ,04
104 0 ,,6
116
r.
Codes Irom
from ,128-255
28-255 are reversed images of codes 0-,
Images 01 0-127.
27.
'-
,32
132 —
v PRINTS CHR5
CHA$ PRINTS CHRS
CHR$ PRINTS CHR$
CHA$ PRINTS
PAINTS CHRS
CHA$
-•
n
V 0 17 34 3 51
51
'-' 18 #
# 35 4 52
'-' 2 19 $ 36 5 53
v 3 II 20 % 37 6 54
v
v
'-'
'"
v
-
DIS"'ES _~8
4
5
6
7
21
22
23
23
24
24
25
&
&
(
)
•
38
39
40
41
41
42
7
8
9
55
56
57
58
59
'H"'ES _~99 26 +
+ 43 C 60
-•
v
10 27 44 61
v
11
11 28
28 - 45 :::> 62
v
12
12 ag 29
29 46 ? 63
-
v
IiID!II 13
13 30 / 47 @
@ 64
64
v t:
SWITCH TO
14 31 0
0 48
48 A
A 65
LOWER CASE
'-' 15
15
lID 32 1 49
49 B
B 66
v 16
16 33 2
2 50 C
C 67
67
v
v
v
v
'-'
v
'-' 133
133
'-'
Downloaded from www.Manualslib.com manuals search engine
PRINTS CHRS PRINTS CHRS PRINTS CHAt PRINTS CHRS
--
D 68 97 @) 126 Grey 3 155
E 69 CD 98 l"1IIIJ 127 156
F 70 El 99 128 riI 157
G 71 EJ 100 Ora nge 129 158
H 72 Ll 101 130 159
I 73 g 102 131 IB 160
J 74 [] 103 132 (] 161
K
L
M
75
76
77
0
bJ
[3
104
105
106
11
13
15
133
134
135
•
0
0
162
163
164
N 78 EJ 107 17 136 0 165
0 79 0 108 12 137 II 166
P 80 IS] 109 14 138 0 167
a 81 0 11 0 16 139 ~ 168
R 82 0 111 18 140 ~ 169
S 83 0 112 1liIIII1II!m141 0 170
T 84 II 11 3 ' ~142 rn 171
U 85 0 114 143 c:. 172
v
W
X
86
87
88
~
0
115
116
117
•.. III
144
145
146
[l3
6J
Q
173
174
175
Y 89 ~ 118 III 147 ca 176
Z 90 D 11 9
II 148 E:l 177
[ 91 ~ 120 Brown 149 EIl 178
£ 92 121 11 . Red 150 BJ 179
J 93 [l] 122 Grev 1 151 0 180
1 94 tE 123 Grev 2 152 (] 181
-El 95
96
IJ
CD
124
125
Lt . Gr een
Lt . Blue
153
154
[J
U
182
183
I
134
134
PRINTS CHRS
CHAt PRINTS CHRS
CHR$ PRINTS CHRS
CHAt PRINTS CHRS
~ 184 0 186 H
~ 188 ~
H 190
~ 185 ~ 187 e:J 189 ~
V 191
191
'--'
'--'
'-'
'--'
'--'
'--'
v
'--'
v
V
'--'
'-'
v
v
v
v
v
v
135
135
APPENDIX
APPENDIX G
G
SCREEN
SCREEN AND
AND COLOR
COLOR MEMORY
MEMORY MAPS
MAPS
The
The following
fol lowing charts
charts list
li st which
which memory
memory locations
loca tions control
cont rol placing
placing characters
characters
on
on the
the screen,
screen, which
which locations
locati ons are
are used
used to
to change
change individual
indi vi dual character
character colors,
colors,
and
and they
they show
show character
character color
color codes.
codes.
SCREEN
SCREEN MEMORY
MEMORY MAP
MAP
COLUMN
COLUMN
10 20
20 HJO J9
1063
■ -■
II
1024-~~1
1024-
.1064
■ : •. ~'lqH 'H
, __;+1 1· - rTl'.
j!-! -pt , -
'- L- - ~~
!.::JJ 0 ~
::■
\I :
1\0,',
--::
1\8'
1184
\22:
' : ' __ • :- _
~
__
, .....
____ ___ _
_ _
___ ,
_~ .
__
_ 0_ ,' • •
_
_ ._ .
+- _ ••
__
~~ _____
.. I
126 ~
1264 _~_ _ . tI ~ I '
V
lJOJ: ~~~. r"* . L-__ _ - - - - - , -
IH~
mt '-t~~-·! .-~. ' I ... +----
I' - -,+-----
■ ■■■■
138'
1424
UN
1.164
1464
150~:
■■
L--.......t.
_
,
•
'-11;=-'--
.
._ .
• •
-1---
• I __ +
j +-
+- .-
_ . -...
_ _!_
I
. •- •_
•
' .. • _' _' .
t- . ~
-0.- ••
.~- 10 ~
- - _ . _ -
. ---~
—
15.1.1
1541 i i '
I~ J .•
1584 -
162.1
■ '■
- _. +- i ...■
166.1
■■■ :
: - :. •_ ___
■:: f-"
11&!
1J8J
r-----[:, —
1814
1824
186~
■■■ I
1904
1904
11344
gJ~
\....---.-_-
:
I H+rH
' 10
198. —
19841 i
The
Th e actual values to POKE into a color memory location to change a
ch aracter's color are:
character's
o0 BLACK 8 ORANGE —
11 WHITE 9 BROWN
2 RED
RED 10 U ght RED
Light
3 CYAN 11 GRAY 1
11GRAY1
4 PURPLE 12 GRAY 2
5 GR EEN
GREEN Light
13 Li ght GREEN
6 BLUE
BLUE 14 Ughl
Light BLUE
7 YELLOW 15 GRAY 3
136
136
corner
corn er ooff the screen to red
red,, type:
type: POKE
POKE 55296,2_
55296,2.
56255
56155
- -I
ff
56295
56m
v
w
137
137
v
Downloaded from www.Manualslib.com manuals search engine
APPENDIX HH
APPENDIX
DERIVING
DERIVING MATHEMATICAL
MATHEMATICAL FUNCTIONS
FUNCTIONS
Functions
Functions that
that are
are intrinsic
intrinsic to
to 64
64 BASIC
BASIC may
may be
be calculated
calculated as
as follows:
follows:
FUNCTION
FUNCTION BASIC
BASIC EQUIVALENT
EQUIVALENT
SECANT
SECANT SEC(X)=1/COS(X)
SEqX) = lICOS(X)
COS ECANT
COSECANT CSC(X)
csqX) == 1/SIN{X)
1ISIN(X) -
COTA NGENT
COTANGENT COT{X)=1/TAN(X)
COT(X) = 11T AN(X)
INVERSE SINE
INVERSE SINE ARCSIN(X)=ATN(X/SQR(-X'X+1))
ARCSIN (X)= ATN(XlSQR( - X· X+ 1))
INVERSE COSINE
INVERSE COS INE ARCCOSfX}=
ARCCOS(X) = -ATN<X/SQR
- ATN (XlSOR
(-X'X+1))
(-X·X+1)) ++ ff/2
}[ 12
INVERSE SECANT
INVERSE SECANT ARCSEC(X) = ATN(X/SQR(X'
ARCSEqXI=ATN X-
(XlSQR(X ·X - 1))
1))
INVERSE COSECANT
INVERSE COSECANT ARCCSC(X)
ARCCSqX) == ATN(XJSQR(X*
ATN(XlSQR(X · XX -- 1))
1))
+
+ (SGN(X)-TJr/2)
(SGN(X) - 1· }[ 12)
INVERSE COTANGENT
INVERSE COTANGENT ARCOT(X)
ARCOT(X) =
= ATN{X)
ATN (X) +
+ Jt/2
}[ 12
HYPERBOLIC SINE
HYPERBOLIC SINE SINH(X)b
SINH(XI = (EXP(X)
(EXP(X) -
- EXP(-
EXP( - X))/2
X))12
HYPERBOLIC COSINE
HYPERBOLIC COSINE COSH(X)
COS H(X) = (EXP(X)
(EXP(X) ++ EXP(
EXPI-- X))/2
X))12
HYPERBOLIC TANGENT
HYPERBOLIC TANGENT TANH(X) = EXP(-
TANH (X)= EXP( - X)/(EXP(x) + EXP
XIIIEXP(xl+ EXP
1- x))"2+ 1
HYPERBOLIC SECANT
HYPERBOLIC SECANT SECH(X)
SECH (X) =
= 2/(EXP(X)
2J(EX P(X) +
+ EXP(
EXP( -
- X)}
X))
HYPERBOLIC COSECANT
HYPERBOLIC COSECANT CSCH(X)
CSCH(X) =
= 2/{EXP(X)
2J(EX P(X) -
- EXP(
EXP( -
- X))
X))
HYPERBOLIC COTANGENT COTH(X)=EXP(-X)/(EXP(X)
COTH (X) = EXP( - X)I(EXPIX)
-EXP(-X))"2+1
- EXP(- X))·2+ 1
INVERSE
IN VERSE HYPERBOLIC SINE ARCSINH(X)= LOG(X + SQRIX
ARCSINHIX)= LOG(X+ SQR(X'X+
· X+ 1))
1))
INVERSE HYPERBOLIC COSINE ARCCOSH(X)
ARCCOSH(X)== LOG(X
LOG(X +
+ SQRIX
SQR(X"· X
X -- 1))
1))
INVERSE HYPERBOLIC TANGENT ARCTAN
ARCTANHH(X) = LOGI(1
IX) = LOGf(l +
+ X)/(1
X)111 - X))/2
- X))12
INVERSE HYPERBOLIC SECANT ARCSECH(X)
ARCSECH IX) =- LOG((SQR
( - X· X+ 1)+ 1/X)
COSECANT
INVERSE HYPERBOLIC COS ECANT ARCCSCH(X)=
ARCCSCH LOG((SGN(X)"SQR
IX) = LOGI(SGN (X)" SQR
(X*X+1/x)
IX · X+ 11x)
INVERSE HYPERBOLIC
INVERSE HYPERBOLIC COTANGENT ARCCOTH(X)=LOG((X+1)/{X-1))/2
ARCCOTH IX) = LOG(IX + 1)I(X - 1))1 2
138
138
v
APPENDIX II
APPENDIX
PINOUTS FOR
PINOUTS FOR INPUT/OUTPUT
INPUT/OUTPUT DEVICES
DEVICES
This appendi
This appendixx isis designed
designed to
to sh
show you what
ow you what connec
connections may be
tions may be made
made to
to
the Exec
the Executive 64.
utive 64.
1)1) Game
Game 1I/O
/0 4)
4) Serial /0 (Disk/Printer)
Serial 1I/O (Disk/Printer)
2) Cartridge Slot
2) Cartridge Slot 5)
5) Modulator
Modulator Output
Output
3) Audio/Video
3) Audi ol Video 6) User Port
6) User Port
Control Port
Control Port 1
1
Pin
Pin Type
Type Note
Note
11 JOYAO
JOYAO
22 JOYA1
JOYAl
33 JOYA2
JOYA2
44 JOYA3
5 POT AY
POT AY
66 BUTTON A/LP
sunON A1LP
77 + 5V
+5V MAX.
MAX. 50mA
50mA
8 GND
9 POT AX
POT
1 2 3 4 5
o 0 000
o 0 o 0
6 7 8 9
Control
Control Port
Port 22
Pin
Pin Type
Type Note
Note
11 JOYB0
JOYSO
22 JOYB1
JOYSI
33 JOYB2
JOYS2
44 JOYB3
JOYS3
55 POT
POT BY
BY
66 BUTTON
sunON BS
77 + 5V
+5V MAX. 50mA
MAX. 50mA
88 GND
GND
99 POT
POT BX
SX
v
v
v
v 139
139
Pin
Pin Type
Type Pin
Pin Type
Type
A
A GND
GND N
N A9
A9
B
B ROMH
ROMH P
P A8
A8
C
C RESET
RESET R
R A7
A7
D
D NMI
NMI S
S A6
A6
E
E S 02
S02 T
T A5
AS
F
F A15
A15 U
U A4
A4
H
H A14 V
V A3
A3
JJ A13
A1 3 w
W A2
K
K A12 X
X A1
A1
L All
A11 Y
Y A0
AO
M
M Al0
A10 z
Z GND
I ::::::::::::::::::::::
xIZ Y
r W \I U T S"';> N III L!( J H F
XWVUTSOPNMIKJHF DC B A
EDCBA
E
I
140
140
v
v
Serial
Serial I/O
Pin
Pin Type
11 SERIAL SRQIN
2
2 GND
3
3 SERIAL ATN IN/OUT
IN/O UT
4
4 SERIAL CLK IN/OUT
w
5
5 SERIAL DATA
DATA IN/OUT
6
6 RESET
RESET
v
v
141
141
v
Downloaded from www.Manualslib.com manuals search engine
User 1/0
User I/O
Pi n
Pin Type
Type Note
Note
~
11 GND
GND
22 + 5V
+5V MAX. 100mA
MAX.100mA
3
3 RESET
RESET
4
4 CNTl
GNTI
5
5 SP1
SP1 -
6
6 CNT2
GNT2
7
7 SP2
SP2
B
8 PC2
PG2
9
9 SEA. ATN
SER. ATN IN
IN
10
10 9
9 VAC
VAG MAX. 100mA
MAX.100mA
11
11 9
9 VAC
VAG MAX.
MAX. 100mA
100mA
12
12 GND
GND
Pin Type
Type Note
Note
A
A GND
GND
B
B FLAG2
C
G PBO
PBO
D
D PB1
-
EE PB2
F
F PB3
PB3
H
H PB4
JJ PB5
K PB6
L PB7
M
M PA2 —
N
N GND
1 2
12 3
3 ..4 5 6 7
7 8 9 10 11 12
12
::::::::::::
ABC 0 E F H J K L M N
ABCDEFHJKLMN
142
142
7 40 forj-Ho5:pr
7 40 fo r J=lloS :prlnl chr i ((yeJ»
i ntchr* y ( j ) ) ;;: n@ x t J
:n*>:tj
7 50 pr
750 prlnt
mt "" ':golo810
:gotoS10
s ao pr
300 print"ljou
i nf'you got qot it It inI n only"j
o n l 'J ";g;",]W?Ss ... s . "
g;"guesses."
Input"~anoth~
3 10 in
S10 puf'S anotherr word" ~ord " gz*
;=i
r=l:i
82 0 r=l
S20 : i ff asc
asc (( z«
zt) ~ } 7Sgo
)'.> 78 goto5
toSOO 00
1 r€'tll
re in "'' ':0-
*** SE'OUE'nc ...
stouenc?
22 r€-tll
ram
.
... ,. from
3
3
4
4
r*w
r"'H1
5 r^-ni
re la *- *
r"'/Il
.....
r @nI * " co
***
K « man
f rO DI pet
soft~ar
l ,o:: 371
t· o t'O::
mont t gogOtA",r
371
mer u
u s ... r group
r'''' t. user
tusre... •?
orout,
@>:):c:t,an'1o<-
c h a n >j e
lJ vv iI 11
I 1©0:- .• pa
00 1S 936
18936
77 re rE'(11
in
bO ~O dim d I to a$(26> a t e 26)
100100 r*a"abcd«-fghi
= S="abcdE'fg h i iif:k linnor-qrstuvw:;u~" It(j n or,qrsl u v ,", ~:u=''
11 0 zl$
110 zIS = =""12345678901234t.67S90123456"
1 234567890 1 ~3 4 ~67390 1 ~3456"
200~OO print"3PPenter
prlnt"'~~€-nt -? r length ' ... ngth of of string
s trIn g to t o be
bE' ss-aue-ncedP"
s ... a u ~nCE'd~"
220~20 int,ut ""Ma
incut >: iIIIlU
in 3 >; in u mtll length
l ... nath 15 I S 26
26 "-.
" i s'/.
s?'
2SQ~30 If sm/.<A
if s% < l or or eX s% ~ 26 ~6 then th ... n 200200
22 44 00 s=sX
S= 57-
300 for
300 f or i=l I =1 to to 5s —
3 10 a*<
310 a"I)=toIJt.(::t
i)=mid«(zt.i,1) . l.l )
320 next
320 n ... ::t i m
4 00 rein
400 r eto randomizerandOtol ::e string s t r I ng
4:00 for
420 f o r i=l 1=1 to to 5s fM
4 30 k=int(rnd(1>»S+1)
430 f: =lntC rnd ( l )rs +l)
44 0 tt=st(i)
440 t"= a t ( I ) —
450 ate at<i)=at(k> I )=ato.)
1,60 a to. )=t t
4 70 next
470 nO? i:t Ii
480 gasul,
1,80 gosub 'f~O ?50 —
~Y;:j t=0
595 l;O
600 rrein
600 ... m rreverse... v ... rs ... substrIng
substr i no r"»
605
6 05 t=t. t=i+l +l
6610
10 Iinput nt,ut "IIOw "Now ',lan many ';! 1..0
lo r' €-v",rs-? "";rX
r*-v>?r$t? ; riC ,-«,
620 If i f r% rX-0 =O goto gotu 900
630 If if r7. rZ>0 ~O a andn d riC rX , =s goto ooto 650 ^
640 orlnt orint "toust "must be bet w...... n 11 and "is
b~ between ";s:: go to 6610
goto 10
650 r=lnt(rZ
r=int(rX/2) /:!) ^
660 for 1=1 to rr
70 U
6670 tt =a = st< t e i) i ) -.
680
6S0 at(, att i )=a i (r7.- 1 +1)
>=3*(r%-i+i>
6YO
6V0 a at s (rr.-I+
Cr%-i + } 1 )=t
J=lt t ^
700 nne^.t o? ), t Ii
I~{l
750 90Sll~'
gosub "'~O
950 ^
800
^00 c=c=l: l: for II»2 ':~ to s
8£10
10 If
if a t (!l >a t.( I - I ) goto 8SiO
3*(i)>3t(i-1) 050
820
S20 cc=0 =0
830
S30 nne;:t
... ~: t Ii
8840
40 If
if c =O goto 600
c=0
850
S50 pcrint
r I nt "~ ~ou did
"0gou did it In
in "~ i t;" ~ triPS"
";t;" tries"
YOO
V00 r",M
re« cho:-cf:check for for an oth~r gaM'"
another game
9910
10 Input
incut "~~ant "flwant to lo play
day agaagainIn ";4"; ut '
y20
'120 'if
f lleft* (ut.
... ft i Cu i.I1 )="IJ"
) = "ij" or 'Jy«="ak"
t ="I')I-\" or yy*t ="
= "l" goto
1 " ooto ~O
200O
930
930 o:-nd
end
9~0
950 ,.r
print I nt
960
960 print lleft»(zlt.5l~ft t(zIS. s)
970
'i/o ffor
o r 1= i=l1 to ss:: e,rlnt
print a8*(iJiine>lt
i (ll ; : n E'>: t Ii
9S0 [,r
9BO print
I nt ""B"
fI "
9'10
9V0 rreturn
... turn (^
ThIS
This pr o ~r im (Oullesy
program of G~
touitesy ot ne Du
Gene ls
Deals l^,
144
144
v l!5i?
1:;0 PR1HT"HRMG
PR I I/T"HAti(' 011. Oii - ';ETTil"::;
SETTING UP UP FFEC'UFREQUEHCV TABLE..."
E IIC',' TAE:LE . . . ..
!19@
':.n 3=13*4096+1924iOIMF<26>iDIMf
·;=1~: + -lO :.!.l';+102-1 : [ . r,.,F · ';:: '; ,.- : 011-11 ':25:" C255)
200 FORI=a0TO2SsPOf
FOR I =(tT02'3 : F(' f E ·;:· ... r .-O;NE;:T
ES+I (1 : 'lE: :T
210
.:: 10 F 11=7040
= 7" 1)41) ::FORI=1 FOP. I"" 1 r02':- rO2esF':27-I : F' :;:.:- - I '=F '=F11 t*-5. 5. :?+S+30 ~:O ::F1=F1. '2 rf '-•: 1/
F I =F 1. -::: l.'ll
1': . ::NE::T
IIE::T
v 220
'::1(1 ~: J;= " ('121·' ::EP,:".T';'r':-I.l1 :.:"X';:'I':! -- io ( r"
K*o"iP2W3ERST6V7UI900P@-*£
230
'::::0 FOPI = I1TOLEN'^
FOP! TOLEII-1 -Fr ·■ ::11 ·ff:,(·"lIO ■ FViC f.H tO*> .t ' I'K'*,
r ,r I '>J> >■! aHEXT
· "" t:t tE:: T
240
~ ..W FRINT'TJ
PRHIT":J
250
~=.o FlT=0
HT =0 :jOE=0DE=O : :3U=15 .1..1<: 1 '3 :sRE-S
FE:.:' ::SV=SU+ ';'./.,.';:.1.' + L';loi-REtflVafl^-lS+DE:
loPE : A '.,' ".HT'" 16+C'E :
WV=16sH=0
(·IV = I';' : ! j=O ::M=I 1'1 ", i ::0C=4
1)( :::4 :iHB=25t;:
L;E:=': ':..:: : .:-'"->"
2S9
~.:. O FOR I "OT
FOR! =9T02 ')2 ::POKES+5+I
F (lIE ':: - ,:.+ I t*7 7 .-flT*l€+DE
riT t I';' .. DE ::P0KES+6+I*7
POLE ': ... 6+ I ;. 7 '- ::SU+lS-i-RE
I) " l';.,F E
:270
71) POkE" : .... ';:': .,. I +7 •-4000HND255
POKES-t-2-t-£*? 4(u)(,t=it 10255 ::Fi> POI E'; ES+3-*-I*7
... ;:.,. I .. :- •-4000. r25t" ::HEi
4(\(":0. ''::50::: I IE: :T IT
2S0
'=: G~ ~) POKES+24
PQK E·: .... .: 4 •. 1 15sREM+16*-64
'5 : PEr·l ~ 1 .; .... ,:: .~ ::POt ES+23
F 0 1 E';:. +.=:-::: •-77
300
:;:00 GETR4:IFfl*=""THEH300
(,ETA t : I FAr"." "THEil:'':'')
310
3 1') FR=F>' K'
FR",F k- ~SC fliC'fll) · A.t: , .■ '. ■.1H:T=V-f7:CF=r5-<-T+4
'H : T = ..... .. 7 : CF' .. ·; .. T ....\ ::1J F FFP=ZTWEM500
FF' ::::THEII':.('O
v 2-20
:;:.~ O POKEs+^vT.ZiPEM
POKE:c_ .. .£. .. T ,: : FE!,' F r 1/ I ·;. H DEC.
FIHI1H DEC'iU'i ',,: u·;
325
3~ 5 P0KES+5+T,ZjREM
?OI'r ; .. 5·.. T .: : ?El-l FFIMI5H It I r ·::.H flTT/REL
ATT. '!='EL
v 330
::::0 P0KECR,S:P0kECR,3:REM
POKE ( P ,:::: : POh.EC P • (\ : F'EI-! F FIX I:' (OFF IF F
34Q
3·'1) PCKES+T.FP-HBfIHT-"FR.-'HE.'
POI,tE '; ... T .FP-He· " ltIT· FF! . "HI::· :;PEH PEt'l ':::ETSET LO LO
3S0
J5(' POKES+1
POV E ·: .+l t-T .FP.'HB
.. T .FP. ·HE: ::PEM F·E/-l ·;·ET SET HI
360
30;
:0 POKES+&+T,SViREM
POVE·;+,; ... T . ·3··... : FEtl SET ;ET DEC. "SUS
DE':. ":;1)-;
365
>;-5 POKES+S+T,flV;FEM
;::")1 E ·;+5 ... T .1'1'. / : FElt ':SET ET flTT/REL
ATT. 'FEL
370
?7(1 P0KECP..MV+1
POt E CP .ltl'·... + 1 :F0RIh1T0SO*HTiNEXT
: F (lr. I", 1 T050 + HT : t IE :: T
375
;'75 POKECR,WV:REH
P')I E(P. J..j'·/ :FE t-l FI)L': PULSE E
3S0
:'::::1) I F ? = 1THEtl'·/ ....·' ~ 1 : ! r '·..'", ~: THE II'.,i= ')
IFP=1THEHV=V+1:IFV=3THENV=0
400
.11)(, GOTO
I:;OT(' 300:;;'(11)
v
500
5(11) IFhJ="S"THE1
IFA ..: = " ii " THE I 11' !E-1=1
1 = 1 :0C=4
: (n: ",4 :G0T03S0
: (·(lTI):2(")
5
51 (. IR=2!0C=3
J FA:t= " ~ " THEI Ht;.:. : (n: :=:.~: :OOTHi : (,OTI):100 00
,:. ~ (\ J FA .! :" II" THEI If·I=·1 M=-1 :0C-2: ,)(::.=: :OOT03G@
: (·OTI)~ ('0:'
'3:::0 I FA:t;;"II"TI-IEtU·l =-8 ",·; :OC
: 0)(,:, : (,')T');'(":'
= l[ :G0T030G
54@
':.-I\) IFPiS
I FAx",, = "3"THEHl-J=0
" !t" THEt n-l=~:' iWV=lw : (.O T'):; ,:.,=.
:~J''''= i':· sG0T0300
530
55(' IIFAI="
FRJ= "K" .\: "T THEt
I-I E tH (Ua I,. Il :: UV=
l l ·.'=:2 ?2 :: GO(.o TO SCO
r .:I:;·(Il)
559
5-=0 IFH**"M"THEHW=£:NV=e-4 :':'('j.:.:;.:,,:o
IFH.r= " ~ " T J-. E t!Ll =':: ; 1·\'/= ':: .. :G0T030'3
570
':,";"0 IFh-C="
1 F~ r= " B"THENW=3jUV=!128
tI " THEtal= :; : \·1\·' = i ,:: .3 : GOTO
(.I)TO:<:500 O:II)
580
5'~ IJ IFR*ss"
rFA I:::" "THEIiP=l-P
"THEliP ",I-P :G0T0JO0 : (,I)T':':.(u)
'3::...:.
590 IFfl*»"3"THEH2S0
I FA .r o>" ;]" T!1Et I~ ('(o
v 500
~.•:1\) GOTO
':.O T(' 500
~:(.n
:.:.>:.
:;:■:»-« PPIHT"HIT
P ~· ttIT"HIT fl
~ VI EV"
E',"
v S10
:;: \ 1) L-ETR-t:
('E TI;~ : [FH.r = ""THEIi.5lij
rF~l.r", ""jHE!;;I':' :l-iflIT
: I·j "';iT FOP
F('F hi
~ , Ij EV
E'?'
>20
-;'::0 PPIMTftf:RETURN
F·PIHT,.; . : f.ETI .IFil
NOTES:
NOTES:
Line
Line 100
100 uses
uses (SHIFT
(S H IFT CLR(HOME).
CLA /H OME). Line 530
Line u ses (17)
530 uses (17)
(CTRL
(C TAL 91.1CTRL
9).(C TAL )).(SHIFT
)).(SHIFT B).
B). Line 540
Line u ses (12)
540 uses (12)
Line
Line 150
150 uses
use s (CRSR
(CASA DOWN)
DOWN ) Line 550
Line uses (II)
550 uses (1 4)
Line
Line 240
240 uses
uses (CRSR
(CASA UP)
UP) Line 560
Line u ses (f6)
560 uses (16)
Line
Line 500
500 uses
uses (11)
(11) Line
Li ne 570
570 uses
uses (f8)
(18)
Line
Line 510
510 uses
uses (13)
(13) Line
Line 590
590 uses
uses (SHIFT
(S HIFT CLR/HOME)
CLA /HOME )
v Line
Line 520
520 uses
uses (151
( 15 )
145
String Dimensions
String Dimensions
Delete
Delete allall statements
statements that that are
are used
used to
to declare
declare the
the length
length of
of strings.
strings, AA state
state,
ment
ment such
such as as DIM
DIM AS(IJ).
A$(I ,J), which
which dimensions
dimensions aa string
string array
array for
for JJ elements
elements oiof
length
length I,I, should
should be be converted
converted to to the
the Commodore
Commodore BASIC BASIC statement
statement DIMDIM AS(J).
AS(J),
Some
Some BASICS
BASICs use use aa comma
com ma or or ampersand
ampersand forfor string
str ing concatenation.
concatenation, Each
Each of
of
these
these must
must be be changed
cha nged to to aa plus
plus sign,
sign, which
wh ich isis the
the Commodore
Commodore BASIC BASIC
operator for
operator for string
string concatenation.
concatenati on.
In
In Commodore
Commodore 64 64 BASIC,
BASIC, the the MIDS,
MIDS, RIGHTS,
RIGHTS, and
and LEFTS
LEFTS functions
functions areare used
used
to
to take
take substrings
substrings of
of strings.
strings, Forms
Forms such
such as
as A$(1)
AS(1) to
to access
access the
the Ith
Ith character
character in
in
A$,
A$ , or
or A$(I.J)
A$(I ,J) to
to take
take aa substring
substring of
of AS
A$ from
from position
position II to
to J.
J, must
must be
be changed
changed as
as
follows:
follows:
Other
Other BASIC
BASIC Commodore
Commodore BASIC
BASIC
A$(l)
A$(I) = XS
X$ AS = LEFT$(A$,l-1) + X$+MID$(AS.I
LEFT$(A$,1- 1)+X$+MI + 1))
D$(AS,I+1
A$(I.J)
A$(I,J) = X$ AS
A$ = LEFT$(A$,1-1)+X$+MID$(AS,J + 1)
LEFT$(A$,1- 1)+ X$+ MID$(A$,J 1)
Multiple Assignments
Multiple Assignments
To set B
B and C equal zero, some BASICs
equal to zero, BASlCs allow statements of the form
form::
10 LET B
B =
= C =
= 0
Commodore BASIC on the 64 would interpret the second equal sign as a
logical operator and set B = --11 if
If C 0. Instead,
C = 0, Instead, conve
convert this
rt th to:
is statement to:
10
10CC = 0: B = 0
0 : B 0
Multiple
Multiple Statements
BASICS use
Some BASICs use aa backslash
backslash (/) to separate multiple
multiple statements on a line.
line.
With Commodore
With Commodore BASIC,
BASIC, separate allall statements by
by a
a colon
colon (:).
MAT
MAT Functions
Functions
Programs using
Programs using the
the MATMAT funct
functions available on
ions available on some
some BASICs
BASICS must
must be
be
rewritten using
rewrillen using FOR
FOR ...
. . . NEXT
NEXT loops
loops to
to execute
execute properly.
properly.
146
146
BAD
BAD SUBSCRIPT The program was trying to reference
reference an element of an array
is outside of the range specified in the DIM statement
whose number is statement..
BREAK
BREA execution
K Program execu tion was stopped because you hit the STOP key.
CAN'T CONTINUE ThThe CONT
e CON will
T command wi not work, either because the pro·
ll not pro
v RUN., there has been an error, or a line has been edited.
gram was never RUN
required
DEVICE NOT PRESENT The req I/O
10 device was not available for an OPEN,
uired 1
CLOSE,
CLOS INPUT#. or GET#.
E, CMD, PRINT#, INPUT#,
DIVISION BY ZERO Division by zero is a mathematical oddity and not allowed.
v loan
EXTRA IGNORED Too many items of data were typed in response to an INPUT
statement. Only the first few items were accepted.
FILE NOT FOUND No file with that name exists.
FILE NOT OPEN Th The
e file
fi le specified in a CLOSE,
CLOSE, CM
CMD. INPUTS,, or
D, PRINT#, INPUT#
GET#, must first
GET#, lirst be OPENed.
OPENed .
FILE OPEN An attemp
attemptt was made to open a
a file using the number of an already
open file.
FORMULA TOO COMPLEXCOMPLEX The string expression being evaluated should shoul d be
split into at least two parts
two part s for
fo r the system
sys tem to work with,
wi th, or a formula has too
many parentheses.
147
147
REDIM ' D ARRAY An array may only be DIMensioned once. If an array variable is
REDIM'D
used before that array is OIM 'd, an automatic DIM operation is performed on
DIM'd,
that array setting the number of elements to ten,
ten, and any subsequent DI Ms will
DIMs will
cause this error.
REDO FROM START Character data was typed in during an INPUT statement
when numeric data was expected. Just re·type
re-type the entry so that it is correct,
correct, and
the program will continue by itself.
RETURN WITHOUT GOSUB A RETURN statem
statement encountered, and no
ent was encountered,
GOSUB command has been issued.
STRING TOO LONG A string can contain up to 255 characters.
7SYNTAX ERROR A statement is unrecognizable by the 64. A missing or extra
?SYNTAX
parentheses,
parentheses, misspelled keywords, etc.
time.
TOO MANY FILES You tried to OPEN more than 10 files at one time.
in place of a string,
TYPE MISMATCH This error occurs when a number is used in string,
or vice-versa.
vice-versa.
UNDEF'D FUNCTION A user defined function was referenced, but it has never
UNDEF'D
been defined using the DEF FN statement.
UNDEF'D
UNDEF' D STATEMENT An attempt was made to GOTO or GOSUB or RUN a
line number that doesn't exist.
VERIFY The program on disk does not match the program currently in memory.
148
MUSICAL
M NOTE
USICAL NOTE OSCILLATOR
OSCIL FREQ
LATOR FREQ
00 C-0
C·O . 268
268 11 12
12
11 C#-0
C#·O 284 11 28
28
2 0D-0
·0 301 11 45
u 3 0D#-0
#·0 318 11 62
4 E-0
E·O 337 11 81
81
5 F-0
F·O 358 11 102
102
6 F#-0
F#·O 379 11 123
123
7 G-0
G·O 401 11 145
88 G#-0
G#·O 425 11 169
99 A-0
A·O 451
451 11 195
195
10 A#-0
A#·O 477 11 221
11 B-0
B·O 506 11 250
16 C-1l
C· 536 2 24
17 C#-1
C#·1 568 2 56
18 D-1
0 ·1 602 2 90
19 D#-1
0 #·1 637 2 125
20 E-1
E·l 675 2 163
21 F-1
F·l 716 2 204
204
22
22 F#-1
F#·l 758 2 246
23 G-1
G·l 803 3 35
24
24 G#-1
G#·l 851 3 83
25
25 A-1
A· l 902 3
3 134
134
26
26 A#-1
A#· l 955
955 3
3 187
187
27 B-1
B·l 1012
1012 3
3 244
244
32
32 C-2
C·2 1072
1072 44 48
48
33
33 C#-2
C#·2 1136
1136 44 11
112 2
34
34 D-2
0·2 1204
1204 44 180
35
35 D#-2
0 #·2 1275
1275 44 25 1
251
36
36 E-2
E·2 1351
1351 55 71
71
37
37 F-2
F·2 1432
1432 55 152
152
38
38 F#-2
F#·2 1517
1517 55 237
237
39
39 G-2
G·2 1607
1607 66 71
40
40 G#-2
G#·2 1703
1703 6 6 167
167
41
41 A-2
A·2 1804
1804 77 12
12
42
42 A#-2
A#·2 1911
1911 77 119
119
43
43 B-2
B·2 2025
2025 77 233
233
48
48 C-3
C·3 2145
2145 88 97
97
149
149
150
150
SETTINGS
FILTER SETIINGS
Location Contents
54293 (0-7)
Low cutoff frequency (0·7)
v
54294 (0-255)
High cutoff frequency (0·255)
54295 Resonance 4-7)
(bits 4·7)
Filter voice (bitt 2)
3 (bi
Filter voice 2 (bit 1)
v Filter voice 1 (bit 0)
1
54296 High pass (bit 6)
Bandpass (bit 5)
Low pass (bit 4)
0-3)
Volume (bits 0·8)
v
151
151
Compute
Compute "Compute's
"Compute's First
First Book
Book of
of PET/CBM"
PET/CBM "
Cow bay Computing
Cowbay Comput ing "Feed
" Feed Me,
Me, I'm
I'm Your
Your PET
PET Computer",
Computer" , Carol
Carol
Alexander
Alexander
"Looking
" Looking Good
Good with
with Your
Your PET".
PET", Carol
Carol Alexander
Alexande r
"Teacher's
" Teacher's PET —
- Plans,
Plan s, Quizzes,
Quizzes, and Answers"
Creative Computing
Creative Computing "Getting
"Ge ttin g Acquainted
Acquainted With
Wi th Your
Your VIC
VIC 20".
20", T.
T. Hartnell
Hartnell
Dilithium Press
Dilithium Press "BASIC
" BASIC Basic-English
Basic·English Dictionary
Dictionary for
for the
the PET",
PET" ,
Larry Noonan
Larry Noonan
"PET
" PET BASIC".
BASIC" , Tom
Tom Rugg
Rug g and
and Phil
Ph il Feldman
Feldman
Faulk Baker
Faulk Bake r Associates ""MOS
MOS Programming
Programming Manuai",
Manual", MOS
MOS Technology
Technology
Hayden Book
Hayden Book Co. "BASIC
" BASIC From
From the Ground
Ground Up",
Up" , David
David E. Simon
Simon
"1
" I Speak
Speak BASIC to My PET".
PET" , Aubrey Jones,
Jones, Jr.
Jr.
""Library
Library of PET Subroutines",
Subroutines" , Nick
Ni ck Hampshire
Hampsh ire
"PET Graphics", Nick Hampshire
""BASIC Handbook, Apple. TRS·80,
BASIC Conversions Handbook, TRS-80, and
PET", David A. Brain, Phi
A. Brain, Phillip
llip R. Oviatt., Paul J.
R. Oviatt
Paquin, and Chandler P.
Paquin, P. Stone
McGraw·Hill
McGraw-Hill ""Hands-On PET".. Herbert
Hands·On BASIC With a PET" Herbert D.
D.
Peckman
Peckman
""Home Use o
Home and Office Use off VisiCalc", D.
D. Castlewitz,
Castlewitz.
and l.
L Chisauki
t52
152
Reston Publishing
Reston Publishing Co. ""PET IEEE 488 Bus
PET and the IEEE Bus (GPIB)",
(GPIB)". Eugene
Eugene Fisher
Fisher
and C.C.W.
W. Jensen
""PET
PET BASIC -— Training Your PET Computer"
Computer",,
Ramon Zamora, Wm. F. Carrie, and B. Albrecht
""PET Recreation",
PET Games and Rec L
reati on", M. Ogelsby, l.
D. Kunkin
Lindsey, and D.
""PET BASIC". Richard Huskell
PET BASIC",
""VIC Recreation"
VIC Games and Recreati on"
Telmas Courseware ""BASIC T. A.
BASIC and the Personal Computer", T. A.
Ratings Dwyer,
Dwye M. Critchfield
r, and M.
Total Information
Total "■'Understanding PET/CBM. Vol. 1,
Understanding Your PET/CBM, 1,
Services BASIC Programming"
David Schultz
"Understanding Your VIC", David
Commodore
Commodore Magazines provide you with
with the
the most up-to-date
up·to·date information
information for
your Executive 64.
64. Two of the most popular publications
publications that you
yo u should
should
seriously
seriousl y consider
consider subscribing
subscribing to
to are:
COMMODORE
COMMODORE —
- The Microcomputer Magazine is
is published
published bi-monthly
bi·monthly and
and is
is
available
available by
by subscription
subscription {$15.00
($15.00 per
per year.
year, U.S.,
U.S., and
and $25.00
$25.00 per year,
year, worldwide).
worldwide).
POWER/PLAY
POWER /PLAY —
- The Home Computer Magazine
Magazine is
is published
published quarterly
quarterly and
and is
is
available
available by
by subscription
subscription ($10.00
($10.00 per
per year,
year, U.S.,
U.S., and
and $15.00
$15.00 per
per year
year worldwide).
worldwide).
153
153
Register
Register
Dec
Dec
#
•
He,
Hex DBl
D87 DM
D86 DB5
D85 D84
D84 D83
D53 D82
DB2 D81
DBl D80
DBO
00 00 SOX?
SOX7 SOXO
SOXO SPRITE
SPRITE 00 XX
Component
Component
l1 11 SOY7
SOY7 SOYO
SOya SPRITE
SPRITE 00 YY
Component
Component
22 22 SIX?
S1X7 S1XO
SlXO SPRITE
SPRITE 11 XX
SlY? SIYO
S1YO SPRITE
SPRITE 11 YY
33 33 S1Y7
44 44 S2X7
S2X7 S2XO
S2XO SPRITE
SPRITE 22 XX
55 55 S2Yl
S2Y7 S2YO
S2YO SPRITE
SPRITE 22 YY
66 66 S3X7
S3X7 S3XO
S3XO SPRITE
SPRITE 33 XX
77 71 S3Y7
S3Y7 S3YO
S3YO SPRITE
SPRITE 33 YY
54Xl S4XO SPRITE
SPRITE 44 XX
8B 8B S4X7 54XO
9 9 $4Y7
S4Y7 S4YO
S4YO SPRITE
SPRITE 44 YY
9 9
10
10 A
A S5Xl
S5X7 S5XO
S5XO SPRITE
SPRITE 55 X
X
11 B S5Y7
S5Y7 S5YO
S5YO SPRITE
SPRIT E 55 Y
Y
11 B
12 C S6X7
S6X7 S6XO
S6XO SPRITE
SPRITE 66 X
X
12 C
13
13 D
0 56Yl
S6Y7 S6YO
S6YQ SPRITES
SPRITE 6 Yy
E S7X7 SPRITE 7
7X
"
14 E S7XO SPRITE
Component
Component
X
15 F S7Y? S7YO
S7YO SPRITE 7
SPRITE 7 Y
Y
15 F S7Y7
Component
Component
16
16 10
10 S7X8 56XB
S6X8 ssxa
ssxa 54XB
S4X8 S3X8 S2X8
S2XB S1X8
SlX8 S0X8
SOXB MSB 01
MSB of X
X
COORD.
COORD.
17
17 11
11 RCB
RCB ECM BMM RSEL YSCL2 YSCL1
BMM BLNK ASEL YSCLO
Sell VSCLO Y
Y sCROLL
SCROLL
MODE
MODE
lB 12 RCl
RC7 RGG
RC6 RC5
RC5 RC4
RC4 RC3
RC3 RC2
RC2 RC1
RCl RCO
RCO RASTER
RASTER
18 12
19
19 13 lPX7
LPX7 LPXO
LPXQ LIGHT PEN
UGHT PEN X
X
20 lPY7 LPYO
---- -
LIGHT PEN
UGHT PEN Y
Y
20
"14 LPY7
154
154
22 16 N.C.
N .C. N.C. RST MCM CSEL I"SCl2 XSCL1l XSCLO
XSCL2 XSCL X SCROLL
MODE
23 17 5EXY7
EXY7 SEXYO
SEXYQ SPRITE
EXPAND YY
24 l18
B VS13 VS12 VS11
VSll VS10
VSlO CB13 CB12
CB 12 CB11
CBll N.C,
N.C. SCREEN
Character
Memory
25 19 IRQ
lRO N.C. N.C. N.C. ISSC
LPIRQ lSSC ISBC
Isac RIRQ Interupt
Request's
26 1A
lA N.C.
N.C. N.C. N.C.
N.C. N.C.
N.C. MLPI MISSC M1SB(
MLPi I"'SSC MISBC MRIRQ Interupt
Requestt
Reques
MASKS
27 1B
lB BSP7 BSPO Background-
Background·
Sprite
PRIORITY
28 1C
lC SCM7 SCMO Multicolor
Multicofor
SPRITE
SPRITE
SELECT
29 1D
10 SEXX7
EXX7 SEXXO SPRITE
EXPAND XX
30 1E
lE SSC7 SSCO Sprite·Sprite
Sprite-Sprite
COLLISION
31 IF
lF SBC7 SBCO Sprite-
Sprite·
Background
COLLISION
Register #
# Register ##
Dec Hex Color Dec Hex Color
32
32 20 BORDER COLOR 39
39 27
27 SPRITE
SPRITE 00 COLOR
COLOR
3:
33 21
21 BACKGROUND 40
40 28
2B SPRITE
SPRITE 11 COLOR
COLOR
COLOR 0
0
41 29
29 SPRITE
SPRITE 22 COLOR
COLOR
34
34 22
22 BACKGROUND
BACKGROUND
COLOR
COLOR 11 42
42 2A
2A SPRITE 33 COLOR
COLOR
35
35 23
23 BACKGROUND
BACKGROUND 43
43 2B
2B SPRITE 4~ COLOR
SPRITE COLOR
COLOR
COLOR 22 44
44 2C
2C SPRITE
SPRITE 55 COLOR
COLOR
36
36 24
24 BACKGROUND
BACKGROUND 45
45 2D
20 SPRITE
SPRITE 66 COLOR
COLOR
COLOR
COLOR 33
46
46 2E
2E SPRITE
SPRITE 77 COLOR
COLOR
37
37 25
25 SPRITE
SPRITE
MULTICOLOR
MULTlCOLOR 00
38
38 26
26 SPRITE
SPRITE
MULTICOLOR
MULTICOLOA 11
v
155
155
Dec
Dec He,
Hex Color
Color Dec
Dec He,
Hex Color
Color
00 0
0 BLACK
BLACK 8B aB ORANGE
ORANGE
11 11 WHIT E
WHITE 9
9 9
9 BROWN
BROW N
22 22 RED
RED 10
10 A
A LT.
LT. RED
RED
33 3
3 CYAN
CVAN 11
11 B
B GRAY
GRAY 11
44 44 PURPLE
PURPLE 12
12 C
C GRAY
GRAY 22
5
5 5
5 GREEN
GREEN 13
13 D
D LT.
LT. GREEN
GREEN
6
6 6
•■ BLUE
BLUE 14
14 E
E LT.
LT. BLUE
BLUE
77 7
7 YELLOW
YELLOW 15
15 F
F GRAY
GRAY 33
LEGEND
LEGEND
ONLY
ONLY COLORS
COLORS 0-7
0-7 MAY
MAY BE
BE USED
USED IN
IN MULTICOLOR
MULTICOlOA CHARACTER
CHARACTER MODE
MODE
' r.
156
156
ADDRESS
ACO I US D&7
001 DB6
0" DBS
0" DB4
08' DB3
Oil 0DB2
82 DB1
0"' DBO
0'0 OESCII,-rION
DESCHIPTION
00
00 ((100)
$00) M0X7
MOX7 M0X6
MOX6 M0X5
MOX5 M0X4
MOX" M0X3
MOX) MOX2
M0X2 MOX
M0X1I Moxa
MOXO MOB
MOB 00 )(X-po»ition
, OOIlI;on
01
01 (SOD
(SO l) M0Y7
MOV7 M0Y6
MOY6 M0Y5
MCYS M0Y4
MOY" MOY)
M0Y3 MO'(2
M0Y2 MOV
M0Y1I MOYO
M0Y0 MOB
MOB 00 Y'CMu rl ion
Y-poiition
02
0' (S02)
(S0 21 M!X7
MIX] M1X6
MIX6 MIX5
M l ;J(5 M1X4
M I X" MIX]
M1X3 MIX2
M1X2 MIX
M1X1I M1XO
MIXO MO
MOBB 11 X- PO l llio n
X-povtion
03
0' (103))
(SOJ M1Y7
M 1Y7 M1Y6
MIY6 M1Y5
M I l'S M IrA
MIY4 M 1V)
M1Y3 M112
MIY2 M1Yl
M1Y1 MIYO
M1Y0 MOB
MOB 11 Y, pO l ilion
Y-poiition
004
' ($04)
(S04 ) M2X7
M'lXl M2X6
M2X6 M2X5
M2XS M2X4
M2X 4. M2X3
M2X3 M2X2
M2X2 M2X1
M2X l M2XO
M2X0 M08
MOB '22 X- O<I1",on
X-ponIion
005
' (105))
(S05 M2Y7
M2Y7 M2Y6
M2 Y6 M2 '(5
M2Y5 M2Y4
M'lV" M2Y3
M'lV) M2Y2
M2Y2 M2 YI
M2Y1 M2 YO
M2Y0 "·oo''''on
MOB '22 Y-po»iliof>
MOB
06
06 (106)
(1061 M3X7
M3X7 M3X6
MJ X6 M3X5
M)X5 M3X4
M3 XA M)X3
M3X3 M)X2
M3X2 M)XI
M3X1 MJ XO
M3X0 MOB
MOS J3 X·oo,,,,O"
X-po»ilion
07
07 (S07)
(S07) M3Y7
MlY7 M3Y6
M)Y6 M3Y5
M) Y5 M3Y4
M)Y" M3Y3
M)Y) M3Y2
M) Y'l M)Y1
M3Y1 M3'(0
M3Y0 Moe
MOB 33 Y·p.o l i" on
Y-poiilion
v OB
O' iS08)
(S08) M4X7
M J, X7 MM4X6
4 X6 M4X5
M4 X5 M4X4
M 4 X4 M4X3
M4X3 M 4 X2
M4X2 M4
M4X1 XI M4
M4X0 XO Moe
MOB 4* X· POII' ,on
X-poiition
so
09 (109)
(S09) M4Y7
M 4 Y7 M4Y6
MH6 M4Y5
M4 Y5 M4Y4
M4 Y4 M4Y3
M 4 Y3 M
M4Y24 Y2 M4
M4Y1 YI M4Y O MO B 44 Y. pol i, io n
M4Y0 MOB Y-poiition
10
10 (SOA)
(SOA) M5X7
M5X7 M5X6
.'.15 '1. 6 M5X5
M5X5 M5X4
M5XJ, M5X3
M5 X3 M5X2
M5 X2 .'.15'1.
MSX11 .'.15 '1.0 X· ~O I " ' On
M5X0 Mo
MOB e 55 X-pontpon
11
II ilOB))
(SOe M5Y7
M5Y7 M5Y6
M5Y6 MSY5
M5Y,5 M5Y4
M,5 Y4 M5Y3
M5 Y3 M5Y2 M
M5Y15Y I M5YO
M5YQ MO
MOB B 5S Y. i>o.n ,on
Y-poiition
12 (IOC)) M6X7 M6X6
M6 X6 M6X5
.'.16 '1. ,5 M6X4
M6XJ, M6X3
.'.16 '1. 3 .'.16 '1. 2
,.""
(SOC M6X7 M6X2 M6X1I
M6X .'.16
M6X0 '1.0 MOB
MOB 6 X.pO"lion
13 (SOD))
(SOD M6Y7
M6Y7 M6Y6 M6Y5
M6Y,5 M6Y4 M6Y3 M6Y2
M6Y2 M6Y!
M6 YI M6Y
M6Y0 O MOB 66 Y· po.",on
MOB Y-poiition
11 llOE))
(SO£ M7X7
M7X7 M7X6 M7X5
M7XS M7X4
M7XJ, M7X3
.'.17'1.3 M7X2
M 7X2 M7X1
.'.17 '1.1 .'.17
M7X0 '1. 0 .'.loa 77 X·.,Oll' ,on
v If (10F)
(SOF) M7Y7 M7Y6 M7Y5 M7Y4
Mm M7Y3
MOB X-ponrion
M7Y2 Y ·~O I "' on
"
16 ($10)
(S IO ) M7XS
M7X8 M6X8
M6X8 M5XB
MSX8 M4X8
M 4 X8 M3X8 M2X8
M7YII
M7Y
M I X8
M6YO
M6Y0
.'.10 '1. 8
Moe
MOB 77 Y-poinion
"
17 (til)
(S 1 1) P.CB
Re. ECM
OCM BMM DEN
OEN RSEL
M1X8 M0X8 MSa
MSB o
off X·pOI
X-pontioi" ,o n
"
18
IB (112)
(S 12) RC7
'07 RC6
' CO RC5
'CO RC4
,C '
IIS
RC3
'el
H
RC2
'C'
"
Y2 VI
"
'RC1
CI
YO
'0
RCO
'CO
SSe••» I-•*!
. ~'
Roite r 'regnter
IIotl.r .9'''.'
19 ($13)
(S 131 lLPXB
PX8 lLPX7
PX7 lLPX6
PX6 LPX5
lPXS lLPX4
PXJ, lLPX3
PX3 lLPX2
P X2 lLPXl
PXl l. gh , Pen
Ughi p. n X)(
"0
'20
21
21
1114)
is 141
(115)
(S I S)
LPY7
lP
M7E
M7!
Y7 lLPY6
M4E
MOE
PY6 LPY5
lPY5
M5E
M"
"Y<
LPY4
M4E
M' E
IPY3
LPYJ
M3E
MlE
lLPY2
PY2
M2E
LPY
.PY1I
MI!
MtE
lIPYO
PY O
MOE
'gh, P.
lLight Penn Y
Y
.'1108 Enable
MOB Enob l.
22
"
23
($16)
(S 16)
(117)
-
—
M7YE
-
— RES
RES MCM
MCM C5EL
CS El X2
X2 XI XO
xo See te»t
Se !. d
M6YE
,."
2*
(S I7)
(SIB)
(S 18 )
M7YE
VMI3
VM I 3
M6YE
VM12
VM I 2
M5YE
MSYE
VM1
VM I 1I
M4YE
M 4 YE
VM10
VM IO
M3YE
M3 YE
CB13
Ce l 3
M2YE
CB)2
C 6 12
Ml Y£E
M IY
CB1I
C BI I
MO
-
YE
MOYE MOB Y-e*oond
MOB Y-e_ r::ond
Memory Pomteri
Memory Po,n' e "
25 (119) IRQ
IRQ - - - IL'
""
(S 19) — — — ILP IMMC
IMMC IMBC
IMBC IRST
III Sf I n!e ''v
Interr ~ 1 Regiitor
jpt II e g itle .
2-,
27
IDA)
(S IA)
'SIB)
-
—
M7DP
-
—
M6DP
-
—
M5DP
-
—
M4DP
EIP
fL '
M3DP
EMMC
eM MC EMBC
EMB C EIISf
ERST Eno b leb Inier'jpi
Enob In1etru p.
27 n i B) M 7 DP M6DP MSDP M40P M3DP M2DP
M20P M I DP
M1DP .'.l OO P
MODP M O B-O
MOB AT A Priority
DATA P" o to 'V
,.
28
28
29
3D
(SIC)
(S IC )
(SID)
(S I D)
($>E>
IS I f)
M7MC
M 7MC
M7XE
M7xe
M7M
M7M
M6MC
M6M C
M6XE
M6XE
M6M
M'M
M5MC
MSM C
M5XE
M SX E
M5M
M5M
M4MC
M 4 MC
M4XE
M4XE
M4M
M.M
M3MC
M3MC
M3XE
M3x e
M3M
M'M
M2MC
M2MC
M3XE
M2XE
M2M
M'M
M I MC
MIMC
MIXE
M I XE
.'11 1M
M1M
MOMC
M0MC
MOM
MOXE
MOM
MOM
M O B Multicolor
MOB
MO B X-siponO
MOB X- upo nd
MO B-MOB
MOB
Se l
M ull 'colot Sel
Co llo • •on
'0 MOS Collision
31 (S1F)
(S I F) M7D
M70 M6D
MOO M5D
M5 0 M40
M. O M3D M20 MIO MOO
""
M'O M2D MID MOD MO B_D ATA Collision
MOB-DATA Col l",on
32 (120)
($10 ) -
— —- -
— -
— EC3
Eel EC2
EO EC I
EC1 fCO
ECO hle to o)'. Coior
Exter, Co Ot
33
,.
II (121)
(S2 1) -
— —- —- -
— B0C3
.Oel B0C2
.0<2 8 0C I
B0C1 BOCO
' DCO Bl"gd 00
Bkgd - 0 Color
C o lo .
34 (122)
(s n ) -
— —
- —- -
— B1C3
61C3 BIC2
8 1C2 B1C!
81C I BIC O
B1C0 8i; g d #1
Bkgd - I Color
Co lo.
35
" (S23)
(S23 ) -— —
- —- -
— B2C3
82C3 B2C2
82C2 B2CI
B2 C I BKO
B2C0 Bl"gd #2
Bkgd _ 2 Color
Co lo .
36 (S34)
- - - - "'3
" 83C3
B3C3 33C3
(S2 4) — — — — fl3C2 B3C1
83C I B3C0
B3CO Bi; gd #3 Color
Bkgo Co lo .
37
31 (125)
(S2 S) -
— —- —- -
— MM03
MM03 MM0 2
MM03 MM01
MMO' MM OO
MM00 MOB Multicolor
MOB Mu il ico lot #0
' 0
:=
"3. (126)
(S26 ) -
— —
- —
-- -
— MM
MM13
I3 MM12
MM I2 MM11
MM I. MM10
MM IO MOS M ul" cOIOt #1
MO B Multicolor
"
j9 l$27)
(S2 7 ) —- —
- — —- M0C3
MaC) M0C2
MOC2 M0C1
MaC I MOCO
M0C0 MOB 00 Color
MOB C o lo .
0
.,. 0 ($38)
(S28 ) —- —
- —- —- M)C3
MICJ MIC2
MIC2 M1C!
M IC I M IC a
M1C0 MOB 1 I Color
MOB Co lo .
.,.,
1 H29)
(S29 ) —
- —
- —- —
- M2C3
M2C3 M2C2
M2C2 M2 C I
M2CI M2 CO
W2C0 MO B 3"1 Color
MOB Co lo.
- - -
.,..
2 (12A)
($1A) — — —
—
- M3c)
M3C3 M3C2
M3C2 M3C1
M3C ' M3 CO
M3C0 M O B 3J Color
MOB Cole r
3 (S2B)
( UB) —
- —
-- —- —
- M4C3
M 4CJ M4C2
M 4C2 M 4CI
M4C1 M4CO
M4C0 MOB 44 Color
MOB Colo '
-
.
4 (12C)
(SK I -
— — —- — M5C3
MSC 3 M5C2
MSC2 M5C1
MSC I MSCO
M5C0 MOB 5S Color
MOB Colo'
5 (J2D)
($:2 0 ) -
— — - — - —- M6C3
M6CJ M6C2
M6C2 M6C I
M6C1 M6CO
M6C0 MOe i6 Color
MOB Colo,
46 :$2E>
($:2E ) -
— — - —- —- M7C3
M 7C 3 M7C2
M7C2 M7C1
M 7C I M7 CO
M7C0 MOB 77 Color
MOB C o lor
NOT
•°° 3' - I '
v
157
157
v
*-
158
158
LOW FREQUENCY 54272 135 134 162 223 62 193 107 60 57 99 190 75
54276 17 33 65 129
54277 128 64 32 16
SUSTAINfRELEASE POKE SUS4 SUS3 SUS2 SUS1 REL4 REL3 REL2 REL1
54276 128 64 32 16
TO PLAY A NOTE C# D# F# G# A#
54283 17 33 65 129
ATTACHJDECAY
ATTACKJOECAY POKE ATM ATK3 ATK2 ATK1 DEC4 DEC3 DEC2 DEC1
54284 128 64 32 16 1
SUSTAIN/RELEASE POKE SUS4 SUS3 SUS2 SUS1 REL4 REL3 REL2 REL1
54285 128 64 32 16
v 54290 17 33 65 129
v
159
Decay -— rate
rale sound lalls
tails from peek volume to sustain level
Waveform -— "shape" of
o( sound wave
Pulse
Pulse — tone Quality
- lone quality of Pulse Waveform
NOTE: AttacWDecay
NOTE: and Sustain/Release
Attack/Decay and SustairWRelease settings
settings should
should always
always be POKEd
POKEd In
in your
your program
program BEFORE
BEFORE
is POKEd.
the Waveform IS POKEd.
160
FEATURES
• 3 TONE OSCILLATORS
Range: 0-4 kHz
• 4 WAVEFORMS
WAVE FORMS PER OSCILLATOR
Triangle. Sawtooth,
Triangle,
Variable Pulse, Noise
• 3
3 AMPLITUDE MODULATORS
Range: 48 dB
• 3 ENVELOPE GENERATORS
response
Exponential respon se
Attack Rate: 2 ms-8 s
Decay Rate:
Rate: 6 ms-24 s
Level:: O-peak
Sustain Level 0-peak vo lume
volume
Release Rate: 6 ms-24 s
SYNCHRONIZATION
• OSCILLATOR SYNC HRON IZATION
• RING MODULATION
DESCRIPTION
The
Th 65811 consists of three syn
e 658 synthesizer "voices"" which can be used in-
thesizer "voices in
dependent ly or in con
dependently junction with each other (or external audio sources) to
conjunction
complex
create com sounds.
ple x so Oscillator/Waveform
unds. Each voice consists of a Tone Osc illatorlWaveform
Generator,
Generator, an Envelope Generator and an Amplitude Modulator_
Modulator. The Tone
Oscillator controls the pitch of the voice over a wide range_
range. The Oscillator pro-
pro
frequency,, w
duces four waveforms at the selected frequency with
ith the unique harmonic con·con
v tent of each waveform prov
providing simple
iding si control
m ple co ntrol of tone co
color. The
lor . Th volume
e vo lum e
dynam ics of the oscil
dynamics lator are controlled by the Amplitude Modu
oscillator lator under the
Modulator
direction of the Envelope Generator_
Generator. When triggered,
triggered, the Envelope Generator
envelope
creates an amplitude enve with
lope wit h programmable rates of increasing and
decreasing vol ume. In addition to the th
volume. ree voices, a programmable Filter is pro-
three pro
complex,, dynam
vided for generating complex dynamic subtractive
ic tone colors via subt rac tive syntheses.
SID allows the microprocessor to read the changing output of the third
Oscillator and third EnEnvelope
velope Generator. T These outputs
hese outp uts can be used as a
source of modulation information for creating vibratovibrato,, frequency/filter sweeps
similar
and sim ilar effects. The third oscillator
th ird osci ll ator can also act as a random number
generator for games. Two AlD A/D conve
converters
rters are provided for ininterfacing
terfacing SID with
potentiometers. ThThese
ese can be used for "paddles
"paddles"" in
in a game environment or as
v front panel controls in a music synthesizer. SID ca can
n process external audio
signals, allowing multiple SID chips to be daisy-chained or mixed in complex
v polyphonic systems.
systems.
t61
161
a
<
o
~
.
ADDRESS REG- F1EG NAME REG <° CD
A
"<01
<01"
"-
|HEX> Voice 1
TYPE o
Table 1.
°7 °* - __£°
cl °
ro
a 0 0 FG
*~ f; FREQ LO WHITE- ONLY
o
-F; CO
o
4,<>O-
0 0 Q F9 freo m WRITE ONLY uV CD
z
-
—A1
Cl
0 0 0 PW~ PW6 PW5 Jp-w4 PW3 PW2 PW, ~PW0 PW LO WHITE ONLY
-
X
0000
PW,, PWa 1>W HI WHITE ONLY
O
O
NOISE rLTL TEST SYNC GATE CONTROL REG WRITE ONLY
i—
--
ATK3 ATK? ATK, ATK0 DCY3 DCY? OCY, [>CY0 ATTACK/nrCAY WRITF ONLY
- oo -
... ...... ...
:'::~ 8o~a03il :g
STN? STN, STN0 RLS3 RLSj RLS, WRITE ONLY
tfolce 7
0
__
00000000
FHEO LO WF1HEONLY
0
FREQ HI WHI1F ONLY
a"
--
_00
PWr PWG PW5 PW, PW3 PW, pw0 PWLO WHIIEONLY
(TJ
-
m
- - - -
"- -'
-
WING
__
0000
...
--
__
~ ~ ~ ~ ~
00
000000
c;8 g:;5g 152
STN3 STN? STN, SIN,, RLSj RLS;. HLS, FILS,, SUSTAINJHEIEASE WHITE ONI Y Q
Voice 3 70
I
I
11)
Fo FREQ LO V.I.I 1 .".. ■ o S
162
ro ID
__
--
--
00
—b ■ Fl( ■v,7~ F,o"" FREO HI WHITE ONLY
Fib F,.'~
o
..
PW, PW6 PWS PW4 PW3 PW2 PW, PW0 PWLO WHITE ONLY
ft) m it
'-- ~ ! ,
__
w
,.. !:. !:. ,..
00
- - - - PW,, PW,o PW9 PWB WHI WHITE ONLY
>o
-
~
:'
NOISE TEST SYNC GATE CONTROl HFC. WRITF ONLY o o
_ _
n_n_ 3
", - o - o -
..:: In '"
__
!:.
OOOCl
ATK3 AIK, ATK, ATKo 0CY3 DCY^ DCY, DCYy ATTACKIDECAY WHITf ONLr
Tob ie 1. SID Reg ist er Map
-
g ::
_
e
... a o :z:
OIl
~ ~ ~ ~ ~
~
Ww
5555555
QI;>QOO
STN.. RIS, SUSIAINiRE LEASE WRITE ONLY
-0
STNa STN, STNu RLS3 HLfi,
~ !fii~t;!; HLSn
" Filler
-
- - - FC;, FC," FC0 FC LO WHITE ONt.V
-
...
FC,0 FCB FC, PCs FC, FC, WRIIEONLY
J'
FC, FC HI
--,.
-
... ~
',J Vi
RESa RES; FILIEX
rJ,'
RES, RESo FILT 1 filt ; FILI 1 RES'FIll WRITE ONLY
0
l:
~ aJ
CI..
CI..
Q--O
HP VOL, VOL0 WHITE ONLY
-
3 OFF BP LP VOL3 VOL, MODE/VOL
Misc.
PX, PX6 PX5 ~PX, PX3 PX3 PX, PX,, POT X HF.ADONLY
ro
o -
PY, PY;, py. PVj py, PY0 POT Y F1EA0 0NLY a.
P*6
-
>
-
0
0 0
>
:: ::::
z z
<:I
.!:3
E, Es Ej Ej E, Eo ENV, REAOONLY
These regi sters are ei ther WRITE-only or READ-only and are listed below in
ll
Th ere are 29 eight-bit registers in SID which control the generation of sound.
n
APPENDIX
APPENDIX SS
DISK
DISK and
and PRINTER
PRINTER COMMANDS
COMMANDS and
and
STATEMENTS
STATEMENTS
The
The following
following BASIC
BASIC commands
commands and
and statements
statements let
let you
you perform
perform aa variety
variety of
of
operations
operations on
on disk
disk drives
drives and
and any
any compatible
compatible Commodore
Commodore printer.
printer.
CLOSE
CLOSE
TYPE: I/O
TYPE: I/O Statement
Statement
FORMAT: CLOSE < file
FORMAT: file number
number >
>
Action:
Action: This
This statement
statement shuts
shuts off
off any
any data
data file
fi le or
or channel
channel to
to aa device.
device. The
The file
file
number
number is
is the
the same
same as
as when
when the
the file
file or
or device
device was
was OPENed
OPENed (see
(see OPEN
OPEN state
state·
ment and the section on INPUT/OUTPUT
INPUT/OUTPUT programming).
When
When working
work ing with
with storage
storage devices
devices like
like disks,
disks, the
the CLOSE
CLOSE operation
operation stores
stores
any incomplete buffers
buffers to the device.
device. When this is is not performed,
performed, the file will
be unreadable
unreadable on the disk.
disk. The CLOSE operation
operation isn't
isn't as
as necessary
necessary with other
other
devices,
devices, but
but it does free
free up
up memory for
for other
other files.
files. See your
you r external device
device
v
manual
manual for more details.
v
EXAMPLES of CLOSE Statement:
Statement:
10 CLOSE 1
10 1
20 CLOSE X
30 CLOSE
CLOSE 9 *• (1
(1 + J)
+ J)
CMD
TYPE: I/O Statement
FORMAT: CMD < file number >
> I,string)
[,string]
Action: This statement switches the primary output device from the TV
screen to the file specified. This file could be on disk, printer,printer, or an I/O device
like the modem. The file number must be specif specified
ied in a prior OPEN statement.
specified, is sent to the file. Thi
The string, when specified, This titling
s is handy for tit ling printouts,
etc.
When this command is in effect, any PRINT statements and LIST commands
willl not display on the screen, but will send the text in the same format to the
wil
lifile.
le.
re-direct the output back
To re·direct back to the screen, the PRIN
PRINT#T# command should send
blank line to the CMO
a blank CMD device before
before CLOSEing,
CLOSEing. so it will stop expec
expecting
ting data
(called ""un-listening"
un-l istening" the device).
v 7SYNTAX ERROR)
Any system error (like ?SYNTAX ERROR) will cause outpuoutputt to return
return to the
Devices aren't un-listened
screen. Devices un-listened by this, so you should send a blank blank like
like after
an error condition.
an condition. (See
(See you
your printer or disk
r printer disk manual
manual for m
more details.)
ore details.)
163
163
EXAMPLES of
EXAMPLES of CMD
CMD Statement:
Statement:
OPEN 4,4:
OPEN 4, 4: CMD
CMD 4,
4, ""TITLE"
TITLE" :: LIST:
LIST: REM
REM LISTS
LISTS PROGRAM
PROGRAM ON
CN
PRINTER
PRINTER
PRINTS 4: CLOSE 4: REM
PRINT# REM UN·LlSTENS
UN-LISTENS AND CLOSES PRINTER
PRINTER
10
10 1, 8, 4, ""TEST":
OPEN 1,8,4, REM CREATE SEQ FILE
TEST": REM FILE fl
20 REM OUTPUT TO TAPE FILE,
CMD 8: REM FILE, NOT
NOT SCREEN
30
30 FOR L =
FOR = 11 TO 100
40 PRINT L:
PRINT L: REM
REM PUTS
PUTS NUMB
NUMBER IN DISK
ER IN DISK BUFFER
BUFFER g
50 NEXT
NEXT
60 PRINTS 1: REM
PRINT# REM UNLISTEN
UNLISTEN
70 CLOSE 1: REM WRITE UNFINISHED BUFFER, PROPERLY PROPERLY
FINISH
GET#
TYPE:
TY I/O Statement
PE: 1/0
FORMAT: GET#
FORMAT: GETS (<file number> , (variable
file number>, < variable list
list>>
characters one·at·a·time
Action: This statement reads characters one-at-a-time from the device or file _
specified. It works the same as the GET statement,
specified. statement, except that the data comes
from a different place than the keyboard.
keyboard. If no character is received
received,, the variable m
(equal
is set to an empty string (equ "") or to 0 for numeric variables. Characters
al to lIt')
files , like the comma (,) or IIll!Il:II
used to separate data in files, Ifflim key code (ASC code
of 13),
13), are received like any other character.
character. _
When used with device #3 (TV screen), this statemenl statement will read characters
one
one by one from the screen. Each use of GET# GET# moves the cursor 11 position to
the ri
right.
ght. The character at the end of the loglogical
ical line is changed to a CHR$ (13),
CHR$ (13),
the EEII key
the Im!ID key code.
code. #
EXAMPLES of GETS
GET# Statement
5
5 GETS
GET# 1,
1, A$
AS
10
10 OPEN 1, 3: GETS
1,3: GET# 1,Z7S
1, Z7S
20 GETS
GET# 1,
1, A,
A, B,
B, CS,
CS, DS
OS
164
164
LOAD
LOAD
TYPE: Command
TYPE:
FORMAT LOAD
FORMAT LOAD "" < fil <
fi!e-name>
e.name > "" , < device ,<
device >
> [,
[, < address
address >
> []<
Action: The LOAD statement read readss the contents of a program fi
file
le from disk
memory. That way you can use the information LOADed or change the in·
into memory. in
formation
formati on in some way.way. The disk unit is normally device number 8. The LOAD
all open files
closes all fi les and, if it is used in direct mode, it performs aa CLR (clear)
(cl ear)
before reading the program.
prog ram. If LOAD is executed from within aa program,
program, the
program is RUN.
is RU N. This means that that you
you can
can use LOAD to "chain" several pro pro·
grams together.
toge ther. None
None of
of the variables are cleared during a cha
chain operation.
in operati on.
If you
you are using
using fife-name
file·name pattern
pattern matching,
matching, the first file which matches
matches the
pattern is loaded.
loaded. The asterisk in in quotes by itself ("*") ('" ") causes
causes the first
fi rst file-name
file·name
in
in the disk
disk directory
directory toto be
be loaded.
loaded. If the
the file-name
fi le·name usedused does not
not exist oror ifif itit is
is
not a a program
program file,
file, the
the BASIC
BASIC error
error message
message ?FILE ?FILE NOTNOT FOUND
FOUND occurs.
occurs.
If
If you use
use the
the secondary
secondary address
address of of 11 this will
will cause the program
program to to LOAD
LOAD to 10
the
the memory
memory location
locati on from
from which
which itit was
was saved.
saved.
EXAMPLES
EXAMPLES of of LOAD
LOAD Command:
Command:
LOAD
LOAD A$,8
AS,8 (Uses
(Uses the
the name
name in
in AS
AS to
to search)
search)
LOAD "*",8
LOAD UUI,S (LOADs
(LOAD s first
first program
program from
from disk)
disk)
LOAD
LOAD "$",8:LIST
" S" ,8:LlST (LOADs
(LOADs and
and LISTs
LISTs disk
disk directory)
directory)
LOAD
LOAD "FUN",8
"FUN'\8 (LOAD
(LOAD aa file
file from
tram disk)
disk)
SEARCHING
SEARCHING FOR
FOR FUN
FUN
LOADING
LOADING
READY.
READY.
v
LOAD
LOAD "GAME
"GAME ONE",8,1
ONE" ,8,1 (LOAD
(LOAD aa file
file to
to the
the specific
specific memory
memory
SEARCHING
SEARCHING FOR
FOR GAME
GAME ONE
ONE location
location from
from which
which the
the program
program was
was
LOADING
LOADING saved on the disk)
saved on the disk)
READY.
READY.
v 165
165
NOTE:
NOTE: File
File numbers
numbers over
over 128
128 were
were really
really designed
designed for
for other
other uses
uses so
so it's
it's good
good
practice
practice to
to use
use only
only numbers
numbers beiow
below 127
127 for
for file numbers.
numbers.
Each
Each peripheral device
device (printer,
(printer, disk drive) in the system
system has
has its
its own
own number
number
which
which itit answers
answers to.
to. The
The ^device))
(device) number is used
number is used with
with OPEN
OPEN to
to specify
specify on
on
which device the data file
fil e exists. Peripherals
Peripherals like disk drives or printers also
answer to several secondary addresses. Think of these as codes which tell n
each device what operation to perform. The device logical file number is used
with every GET#,
GET#. IN PUT#, and PRINT#.
1NPUT#,
The file·name
The file-name cancan also
also be
be left
left out,
out, but
but later
later on
on in
in your
your program
program you
you can
can NOT
NOT
call the file by name if you have not already given it one.
files,, the secondary addresses 2 thru 14 are available for data·files,
For disk files data-files,
numbers have special meani
but other numbers meanings in DOS commands. You must
ngs in must use a
secondary address when using your disk drivels). drive(s). (See your disk drive manual
for DOS DOS command details.)
The (file.name
fifiles.
les. IfIf the fil
>
<file-name) is a string of 1·16 1-16 characters and is is optional for printer
printer
file
e (< type>
type > is is left
left out the type of file wi will
ll automatically default to
Program file
the Program file un
unless
less the mode mode is given
is given.. Sequential
Sequential files are are OPENed
OPENed lorfor
reading <
reading <mode)> =R unless you
writing (made»
writing
made>
<(mode> ;=W
; R
W is
un less
is specified.
you
specified. A
specify
A lile
that
file (<type>
type) can
files should be OPENed for
files
can be
should
be used
be
used to
OPENed
to OPE
OPEN
lor
an ex·
N an ex-
isting Relative
isting Relative Iifile. Use REL
Ie. Use REL lor for (type)
<type> with with Relative
Relative liles.
files. Relative
Relative and
and Se·
Se
quential
quential liles files are
are for
for disk
disk only.
only.
IfIf you
you try
try to
to access
access aa filefile before
before itit is
is OPENed
OPENed the the BASIC
BASIC error
error message
message ?FILE
?FILE
NOT OPEN
NOT OPEN wi will occur. IfIf you
ll occur. you try try to
to OPEN
OPEN aa Iifile for reading
Ie for reading wh which does not
ich does not exist
exist
the BASIC
the BASIC error
error message
message ?FILE ?FILE NOT NOT FOUND
FOUND will will occur.
occur. IfIf aa file
file is
is OPENed
OPENed to to
disk lor
disk for writing
writing and and the
the file·name
file-name already
already exists,
exists, thethe DOSDOS error
error message
message FILE
FILE
EXISTS occurs.
EXISTS occurs. IfIf aa Iilefile isis OPENed
OPENed that that is is already
already OPEN,OPEN, the the BASIC
BASIC error
error
message FILE
message FILE OPENOPEN occu occurs. (See Pri
rs. (See Printer Manual lor
nter Manual for lurther
further detailS.)
details.)
166
166
10 OPEN
10 OPEN 12,
12, 3
3 (Screen
(Screen output)
output)
10 OPEN
10 OPEN 130,
130,44 (Printer
(Printer output)
output)
10 OPEN
10 OPEN 1,2,0,
1,2,0, CHRS(10)
CHR${10) channel to
(Open channel to RS·232
RS-232 device)
device)
10 OPEN 1,4,0,
10 1,4,0, ""STRING"
STRING" (Send
(Send upper case/graphics
case/graphics to the
the
printer)
printer)
10 OPEN 1,4,7,
10 1,4,7, ""STRING"
STRING" upper/lower case to printer)
(Send upperllower printer)
10 OPEN 1,5,7, ""STRING"
10 STRING " (Send
(Send upperllower
upper/lower case to printer
with device #5)
10 OPEN 1,8,15,
1,8,15, ""COMMAND'
COMMAND" (Send
(Send a command to disk)
v
10 OPEN 1,8,1, "NAME,L" + (Relative file OPEN (1st time) where
CHRS(X)
CHR$(X) X is the length of the relative record)
OPEN,, 1,8,1,"
10 OPEN 1,8,1,"NAME"
NAME" (Relative or sequential read)
PRINT#
TYPE: I/O Statement
FORMAT: PRINT#
FORMAT: <
PRINT#<file-number
file·number )> [< variable [<
variable>][<,/;>
) ] [ (/;) (<variable>
variable > ]]...
...
Actions:
Action s: The PRINT# statement is used to write data items to a logical file. It
must use the same number used to OPEN the file. Output goes to the device- device·
number used in the OPEN statement. The The <( variable^
( variable> expressions in the
in
output-list
output·l ist can be of any type. The punctuation characters between items are are
the same
same as with
with the PRINT statement and they they can be be used in in the same way.
The
The effects of of punctuation
punctuation are are different in in two significant respects. respects.
If
If no
no punctuation
punctuation finishes the list, list, aa carriage-return
carriage-return and and aa line-feed
line-feed are
are written
written
at
at the
the end ofof the
the data.
data. IfIf aa comma or or semicolon
semicolon terminates
termi nates the output-list,
output·list, the
v carriage-return
carriage-return and and line-feed
line-feed are are suppressed.
suppressed. Regardless
Regardless of of the
the punctuation,
punctuation ,
the next
next PRINT#
PRIN T# statement
statement beginsbegins output
output in in the next
next available
available character
character posiposi·
v tion.
tion. The
The line-feed
line·feed will
will act
act as as aa stop
stop when
when using
using the the INPUT#
INPUT# statement,
statement, leaving
leaving
an
an empty
empty variable
variable when
when the the next
next INPUT#
INPUT# is is executed.
executed. The The line-feed
line·feed cancan be
be sup
sup·
pressed
pressed of of compensated
compensated for for as
as shown
shown in in the
the examples
examples below.below.
The
The easiest
easiest way
way to
to write
write more
more than
than one
one variable
variable to to aa file
file on
on disk
disk is
is to
to set
set aa str
str·
ing
ing variable
variable to
to CHR$(13),
CHRS(13), and and useuse that
that string
string in in between
between all all the
the other
other variables
variab les
when
when writing
writing the
the file.
file.
v
v
v 167
167
EXAMPLESofof PRINTS
EXAMPLES PRINTH Statement
Statement
1)1)
10 OPEN
10 OPEN 1,8,4,
1,B,4,"MY
" MY FILE"
FILE" -
20 R$
20 RS == CHRS(13)
CHRS(13) (By
(By Changing
Changing the
the CHRS(13)
CHRS(13) to
to
30 PRINTS
30 PRINTH1,1;RS;2;RS;3;RS;4;R$;5
1,1;RS;2;RS;3;RS;4;RS;5 CHRS(44)
CHRS(44)youyou put
put aa","
"," between
between each
each
40 PRINTS
40 PRINTH1,6
1,6 varible. CHR$(59) would put
varible. CHRS(59) would put a";"a ";"
50 PRINTS
50 PRINTH1,7
1,7 between
between each
each variable.)
variable.}
2)
2)
10 COS
10 COS== CHR${44):
CHRS(44): CRS
CRS== CHRS(13)
CHRS(13)
20 PRINTS
20 PRINTH1,1, "AAA"CO$"BBB",
" AAA"COS " BBB", AAA,BBB
AAA,BBB CCCDDDEEE
CCCDDDEEE
"CCC";"DDD";"EEE"CRS
" CCC";" DDO ";"EE E"CRS (carriage
(carriage return)
return)
" FFF"CRS;
"FFF"CRS; FFF(carriage
FFF(carriage return)
re tu rn)
30 INPUTS1,
30 INPUTH1, AS,BCDES,FS
AS,BCDES,FS
3) ~-
3)
55 CRS=CHRS(13)
CR$ = CHRS(13)
10
10 PRINTS2,
PRINT#2, "AAA";CRS;"BBB"
"AAA";CRS;" BBB " (10
(10 blanks)AAA
blanks)AAA
20 PRINT#2,
20 PRINTH2, "CCC";
" CCC"; BBB
BBB
(10
(10 blanks)
blanks) CCC
CCC n
30 INPUTS2,
30 INPUTH2, A$,B$,DUMMY$,C$
AS,BS,DUMMYS,CS
—
SAVE
SAVE
TYPE: Command
TYPE: Command
FORMAT: SAVE
FORMAT: <
SAVE"" <file-name> >",<
file·name " , <device-number>
device·number [, <address) >[,
<address> I]
Action: The SAVE
Action: The SAVE com
command
mand isis used
used to store the
to store the program
program that
that is
is currently
currently in
in
memory onto
memory onto a
a diskette
diskette file.
file. The
The program
program being
being SAVEd
SAVEd isis only
only affected
affected by by the
the
command wh while SAVE is happening. The program remains in the current
ile the SAVE
computer
comp memory even after the SAVE operation is completed until you put
uter memory
something else
something else there
there by
by using
using another
another command
command.. The
The file
file type
type will
will be
be ""prg"
prg"
(program). The
(program). The SAVE
SAVE statement
statement cancan be
be used
used in
in your
your programs
programs and and execution
execution
next statement
will continue with the next statement after the SAVE is is completed.
When saving
When saving programs
programs onto
onto aa disk,
disk, the
the <file·name)
<file-name> mustmust bebe present
present..
EXAMPLES
EXAMPLES of
of SAVE
SAVE Command:
Command:
SAVE
SAVE AS,B
A$,8 (Store on
(Store on disk
disk with
with the
the name
name AS)
AS)
168
168
VERIFY
VERIFY
TYPE: Command
TYPE: Command
FORMAT: VERIFY
FORMAT: VERIFY "" <file·name
<file-name> " , <<device)
)", device )
v
Action: The
Action: The VERI
VERIFY command is
FY command is used
used,, in
in direct
direct or
or program
program mode,
mode, toto com·
com
pare the
pare the contents
contents of
of aa BASIC
BASIC program
program file
file on
on disk
disk with
with the
the program
program currently
currently in
in
memory. VERIFY
memory. VERIFY is
is norr]1ally
normally used
used right
right after
after aa SAVE,
SAVE, to
to make
make sure
sure that
that the
the pro·
pro
gram was
gram was stored
stored correctly
correctly on
on tape
tape or
or disk.
disk.
For disk
For disk files (device
(device number
number 8),
8), the file·name
file-name must
must be
be present.
present. IfIf any
any dif·
dif
ference in
ference in program
program text
text are
are found
found,, the
the BASIC
BASIC error
error message
message ?VERIFY
7VERIFY ERROR
ERROR
is displayed.
is displayed.
program name
A program name can
can be
be given either in
in quotes
quotes ('''
("") or as
') or as a string variable.
variable.
169
169
v
Downloaded from www.Manualslib.com manuals search engine
INDEX
INDEX
A
A
Abbreviations,
Abbreviations , BASIC
BASIC commands,
commands, 34,
34, 128-129
128-129
Accessories, 9-11
Accessories, 9.-11 ,_
Addition, 33
Addition, 33
AND operator, 117
AND operator, 117 _
Animation, 47-48,
Animation, 47-48, 67
67
Arit hmetic, Operators,
Arithmetic, Opera tors, 33-34,
33·34, 117
11 7
Arithmetic,
Arithmetic , Formulas,
Formulas , 138
138
Arrays, 95-96
Arrays, 95-96 —
ASC function , 126
ASe function, 126
ASC II character
ASCII character codes,
codes, 133-135
133-135
B
B
BASIC
BASIC
abbreviations, 34,
abbreviations, 34 , 128-129
128·129
commands, 117-119
commands, 117-1 19
numeric
numeric functions.
functions, 33-36,
33-36, 124-126
124-126
operators, 117
operators, 117
other functions,
other functions, 127
127
string functions,
string 126
functions, 126
variables,
variables , 42-44,
42-44, 116
116
Bibl iography, 152-153
Bibliography, 152·153
Binary arithmetic, 69-70
Binary arithmetic, 69-70
Bit, 69
Bit.
Business aids,
Business aids, 103-105
103-105
Byte, 69
Byte. 69
C
C
Calculations,
Calculations, 33-37
codes, 61
CHRS codes, 61,, 126,
126, 133-135
133-135
CHR$
C fu nction , 126
H RS function, 126
CLR statement
statement,, 119 119 ,_,
CLR,
CLR, HOM
HOME E key,
key, 1515
Clock,1 16-117
Clock, 116-117 ^
CLOSE statement
statement,, 30, 30, 119,
119, 163
Color
Color ^
adj ustment , 7-8
adjustment,
keys
keys,, 16
memory map, map, 66,66, 137
PEEKS and POK POKES,ES,
screen and border,
border, 63-64
Commands,
Commands, BASIC, 117·119 117-119
Commodore key key,, (see
(see graphics keys) 16
Connections,
optional,
optional. 9·" 9-11
rear,
rear, 1,3
1,3 '•"*
TV/Mon
TV/Monitor,itor, 1,9
Ca
CONTNT command,
command, 117 117
Co nTRol key,
ConTRoL key, 1616
COSine
COSine function
function,, 125 125
CuRSoR
CuRSoR keys,keys. 14 14
Correcting
Correcting errors
errors,, 14·15
14-15
Cursor,
Cursor, 7 7
170
170
E
E
Editing
Edit programs, 14-15,
ing programs, 14-15, 41
41,, 62
62
END stat
END statement,
ement , 120120
Equal, not-equal·to,
Equal, not-equal-to, signs,
signs, 117
117
Equations.
Equatio 33-37, 117
ns, 33-37,
Error messages, App_
Error App. 8, App. L
Executive 64
Executive 64
installation, 3
transporting, 5
Expansion portport,, 1
1
EXPonent function, 125
Exponentiation, 34
F
F
(disk),
Files, (d 17-31
isk), 17·31
Files, (Rand
Files, (Random om Access), 20,
20, 26-29
Files, (Relative),
Files, (Relative), 20,
20, 24-26
Files, (Sequential),
Files, (Sequential). 20,
20, 21-24
21·24
v FOR statement,
FOR statement, 45,45, 120
120
FRE functions, 127 127
Function
Fun ction keys, 16, 52
16,52
Functions,
Functions, 124-127
124·127
G
G
Game
Game controls
controls and
and ports,
ports, 1,
" 10
10
GET statement,
statement, 51-52.
51-52, 121
121
GET#
GET# statement,
statement , 121,
121 , 164
164
Getting
Getting started,
started , 12-20
12-20
v GOSUB
GOSUB statement,
statement , 121
121
GOTO
GOTO (GO
(GO TO)
TO) statement,
sta lemen l , 40,
40, 121
121
Graphic
Graphic keys,
keys, 13.
13, 16
16
Graphic
Graphic symbols,
symbols, (see
(see graphic
graphic keys)
keys) 13,
13, 16.
16, 64.
64, App.
App. EE and
and FF
Greater
Grea ter than,
than, 117
117
v H
H
Headering
Headeri ng disks,
disks. 19
19
Hyperbolic
Hyperboli c functions,
functions, 138
138
v
171
171
IEEE·48 Interface,
IEEE-48 Interface,99
IF ...THEN statement,
IF...THEN 121
stat ement, 121
INPUT statement.
INPUT statement , 49-50,
49·50, 121
121
INPUn, 30.
INPUT#. 30, 122,
122, 165
165
INSert key,
INSert 14
key, 14
INTege r function,
INTeger function , 53-54,
53-54 , 125
125
In teger variable,
Integer variable, 42-44,
42-44 , 116
116
110 pinouts,
I/O pinouts, 139-
139· 142
142
ports, 11
1/0 ports,
I/O
JJ
Joysticks , 1.I, 10
Joysticks. 10
~
KK
Keyboard , 12-17
Keyboard, 12-17
m
Ll
LEFTS function,
LEFTS function, 126
126 ^>
LENgth function , 126
LENgth function, 126
Less than,117
Less than , 117 ,->
LET statement,
LET 122
sta tement , 122
LI ST command,
LIST command , 40,
40, 118
11 8
LOAD command, 18,
LOAD command. 18, 118
118
LOGarithm function,
LOGarithm function, 125
125
Loops, 40, 45
Loops, 40, 45
Lower case
Lower case characters,
characters , 16
16
M
M
Mathematic s, 33-37
Mathematics, 33-37
formu las, 138
formulas, 138
function
function table,
table, 138
138
symbols,
symbols. 33-34, 36. 36, 117
Memory
Memory maps,
maps, 136·1 37
136-137
MIDS function ,
MIDS function, 126 126
Multiplication,
Multiplication, 3333
Music,
Music, 1"
11. 79·88
79-88
N
N
Names
Names ^
prog ram, 19
program, 19
variable,
variable, 42·44,
42-44, 116
116 „
NEW
NEW command,
command, 19, 19, 3D,
30, 118
118
NEXT statement,, 45,
NEXT statement 45, 122
122 ^
NOT
NOT operator,
operator. 117
117
Numeric
Numeric variables
variables., 42-44,
42-44, 116
116
Numeric
Numeric functions, 124·126
funct ions, 124-126
o0
ON
ON statement
statement,, 122
122 ^
OPEN
OP statement, 19,
EN statement. 19, 30.
30. 122-123.
122-123, 167-168
167-168
Operators,
Operators, -^
arithmetic,
arithmetic, 33·37,
33-37, 117
117
logical,
logical, 117
117 ^
re lational, 117
relational, 117
172
172
aQ
Quotation marks,
Quotation marks, 32-33,
32-33, 37
R
R
RaNDom function, 53-54,
RaNDom function, 53-54, 125
125
Random numbers, 53-54
READ sta
READ statement, 91,, 124
tement , 91 124
REMark sstatement,
tat ement, 124
U Reserved words,
Reserved words, (see
(see Command
Command statements)
statements) 116-127
116-127
Restore key, 15
RESTORE statement,
RESTORE statement, 124124
Return key, 12
RETURN
RETU statement, 124
RN statement, 124
RIGHTS
RIG 126
H T$ function, 126
command,, 118
RUN command 118
RUN/STOP key, 16 16
S
SAVE
SAVE command, 19, 30, 119,
19,30, 168
119, 168
Saving
Saving programs (disk),
(disk), 19
19
Screen
Screen memory
memory maps,
maps, 65-66.
65·66, 136
136
SGN,
SGN , function,
function, 125
125
Shift
Shift key,
key, 12-13
12·13
SINe
SINe function,
function, 125
125
Sound
Sound effects,
effects, 89-90
89·90
SPC
SPC function,
function, 127
127
SX-64
SX·64 features,
features, 1-2
1·2
SPRITE
SPRITE EDITOR,
EDITOR, ii
SPRITE
SPRITE graphics,
graphics, 69-78
69·78
SQuaRe
SQuaRe function,
function, 126
126
STOP
STOP command,
command , 117.
117, 124
124
STOP
STOP key,
key , 16
16
v
String
Siring variables,
variables, 42-44,
42·44 , 116
116
STR$
STA$ (unctions,
func tio ns, 126
126
Subscripted
Subscripted variables,
variables , 95
95
Subtraction,
Subtraction, 33
33
Syntax
Syntax error,
error, 32.
32. App.
App. LL
SYS
SYS statement.
statement, 124
124
v
v 173
173
T
T
TAB fun ction, 127
TAB function, 127
TAN func tion, 126
TAN function, 126
Tl
TI variable,
variable, 116-117
116-117
Tl$
TIS variable.
variable, 116-117
116-1 17
Time clock.
Time clock, 116-117
116·117
TV
TV connections,
connections, 1." 99
U
U
Upper/Lower Case mode,
mode, 16
16
function, 126
USR function,
User defined function, (see DEF)
User DEF) 120
V
V
function , 126
VALue function, 126
Variables 42-44,
42·44, 116
116
95-96
array, 95-96
dimensions,
dimensions, 96
poin t, 42-44,
floating point, 42·44, 116
116 _
integer, 42-44.
42-44, 116
116
numeric, 42-44,
42·44, 116 ,-,
string ($),
($1. 42-44,
42·44 . 116
116
V ERIFY command, 30,
VERIFY 30, 119,
119, 169
Voice,
VOice, 79-84
79·84
^*\
W
W
WAIT command, 124
zZ
z·ao.
Z-80, 10
174
'-' MEMO
MEMO
'-'
'-'
v
v
v
--
"
.."
ee,.. be ...., •• _n 1 ,100. <><, ... . bu. _'" ' .... (,," , _ " •• 'Koo;I "
ARRAY VARIABLES
ARRAY VARIABLES
INSTiDEL
INSTIOfl
C'BL
Dtlfiei
0..10, ..
W~.n ."
When
<"","',•. ," e.." .~' <.... ~
,." .. ............... <010, h • .
v "~ N o",.
•• 1. <, •
lelic'i
PRINT
•• • , <010' ....... tHo .. ,od '"
~gl . o",." M _ XYISI
lIl(iJ
I ..·o · (), .... .. . _ n eSS )
v 1",.. ·0."", " . _ XI (SSS)
X*(S.S.S)
tn uiea -v.ih SHIFT itlf
Arrayi
...,,"" a* ul> '"
. I. ... ~ vi
0 1 gp to eleven .It"","" I' u",,, ,,,," 0-101 <O n be u" "
rfi !iubitr.D.i 0-10) con be uied
tHo ...... " ""po.IIo- •• co •• on"
*.here ... ..ci.,d
.. 10.,. needed ",,".>...... .....to ,100" . .... .. ....... , ,, need ' "
A" a* I with more *non eleven element
a"ii-
9'''P'''' """lay"""',
unplav mode
LEN
liN IXII
t!
At . V t.
J< ~ I
Seri
~" m
'•text
",,,3»,mum
.. ,,,",,, lublir.ptl
. ..... . >' ipote
. 1. .... .. 11
tirmc
V
" UGFIing
,·" ... nQ
• •".n ., number
Rtluin .. " ... 10.' of
al AlO.O
o .....
of chorotlfr!
Ol
000)
, 00'oct.,. in
,n
f".
. "b .. " .. " lor A
, ..... . Io'
lo· !X
! ~·■ I|*|Y*
A
,I · Y' I)'
I ' 11' "
X~
.' Divilicn
• Addition
Sl ~ ~ (
STRilX, R.lurn ""m.'.e
R.' ",~,i nunwnc .alue
' 01 ... ot
01 X
...
v KAllXi!
ton.er
B,Wn
ed lo a 11-mg
..
r.,,i nc nnUWer:c cha.a^ie.
,x
v tOAO NII.M! •B
IOAD "NAME" 10<.<1 n "'''I/,om
londi. .. from d,,
o'ogram I..,... dill~ INPUT ABC A
S»E
!.It.It NAoMI
NAWE .9 So ••• "a "'''9''''''
iovei program '" i« " ..,
ilnl ■nln ualu* Can olio INPUT Ai
v ""
RUN
BUN " .
RUN ( ' H"'~' "'<>\I'''~ " " ",~ o. I.n.
OAI
DATA. ABC
AB C , ... ,""" .. 0 •• , " • • ol~. , ' "0'
co .. tHo
Be ...
Kied
. .. by
b. ~!.
BEAD " a ..... ~ " .
O HOTUWK1
~ IAD . ~ 0' • A" '\1" ' " f" DA' ....'". ' " A ~ O. A
u ,.,
5ro~
END
"1 5' 0 .. 1 ..••• " do ' o ""'" '" '0 " ''''
",AO,n
BEADmg g ,".
rhe DAIA I,,,
DAlA "g"'"
CO NI
CONT Co",.~_. "'<>\1'0'" ~ . ... ", ... " 1'0'" PRIM A - A PBINTi
""' ilr.r.9
NII "" A-
"\1 A " .... VOl". 0) A
I",~ ~ ~" 0'011'''''' 'w", ""I,." 'ob. dC'a
v V..".~. 'O,,'.n!. ,,/ "'. ""'....
PROGRAM FLOW
UST
LIST A,
a IB f."........
lull 1 ,om U. A
I.,,, io ~"
A ... . IB
line BETURN Uarki end gl luhroutinr Returni i
v
v
FILL OUT AND MAIL TODAY GET MORE INFORMATION FOR YOUR MONEY
Please ~ i gn me
Plea se sign m e up for:
for :
Name
Name Phone
__ yea r (~) ol
_ycar!s) 01 POWER/PLAY
POWER/PIJW a)
at •>!().(X)/year
Sm.OD/year
Address _ _ _ _ _ _ _ _ _ _ _ __
Address
_ yc ar (~) of
_year(s) of COMMODORE
CO,\lVv\ODOR[ at
,"II 515.00'year
S15.OOIyear
City
Ci ty Sial e
Stale l ip
Zip _ _ __
Canadian
Ca nadian and Foreign:
and Forci gn : POWER/PLAY$?5.00/year;
POWER/PI.AY S1S.00lyca r; COM-
COM·
Compul e r model:
Computer model: _ _ _ _ _ _ _ _ _ _ _ _ __ MODORE $25.0Qtyear
S2S.00lycar
I:ncloscd is
Inclosed is my
my check
chcck or
or money
m o ney order
o rd er for
for $S _ _ __ __
o
i ] Address
Addres~ Change.
Change . Enter new address
dtkJ r c~~ above
.IUUVl.' &
&. enclose
cn du ~c
present
present mailing
mailing label
label Make check
ch etk or
or money order
ord er payable
payablc to:
10:
Io] Renewal
Ren ewa l subscription
sub scription COMMODORE
COMMODORE BUSINESS
BUSINESS MACHINES, INC.
Io) New
New subscription
subscrip tion The Meadows,
Meadows, 487 Pi,k Drive,
487 Devon Park Drive, Wayne,
Wayne, PA 19087
19087
) ) ) ) ') ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
(i
(i
v Commodore Business
Commodore Business Mochines,
Machines, Inc.
Inc.
1200 W;lsan
1200 Wilson Dr;ve
Drive
v Westchester, PA
WeSichesler, PA 19380,
19380, US.A.
U.S.A.
Commodore Business
Commodore Business Mochines
Machines Ltd
Ltd..
3370 Pharmacy
3370 Pharmacy Aven
Avenue, Agincourt,
ue, Ag;ncaurl,
Ontario, MIW
Onlar;o, M1W 2K2K4, Canada
4 , Canada
Commodore Business
Commodore Business Mochines
Machines (UK) Ltd.
Ltd
v 675 Ajax
675 Ajgx Aven
Avenue, Trading Estate,
ue, Trading Estate,
Slough Berks,
Slough Berks, Sll
SL1 4BG
4BG,, England
England
Italiana S.R.L.
Commodore Itoliana
Via Conservatoire 22
Via COnservQlorio 22
Milano
M 20122,
;iono 201 Italy
22, 110 1'1
v
Commodore Information Center
Center
5 Onion Road
5 On;on
Lane
lane Cove 2066
2066 NSW,
NSW, Australia
Au slral ;a
Commodore
Commodore Computer
Computer B.V.B. V.
Marksingel
Mar s; ngel 2e481
2e4811I N.V.
NY Breda
Breda
Postlrus
POSilru s 720,
720, 480
~80 3aS
3aS Breda,
Breda, Netherlands
NClher lands
Commodore
Commodore AG(Schweiz)
AG(Schweiz)
Aeschenvorstadt
Aesc henvorSi ad I 57
57
401 0 Basel,
40 10 Basel, Switzerland
Sw dzcr land
Like the Commodore 64, the SX-64 has 64K memory, 16 colors, a
sound chip that lets you play music on your computer, and a video chip
that lets you create complex graphics. In addition, all software designed
on disk and cartridge for the Commodore 64 runs on the SX-64.
This easy-to-read user's guide contains all the information you need to
set up your equipment, understand how to operate your new SX-64,
and learn how to create simple BASIC programs. Technical information
for beginners as well as experienced programmers is also included.
ft commodore
COMPUTER
P/N 251249 Printed in Japan
Downloaded from www.Manualslib.com manuals search engine