Commodore SX-64, SX-65 Portable User Manual
PDF
Document
Advertentie
Advertentie
T
1.
_
^
5
I
_
~
- LI
■ i ■ m i - m m ■ l iTi i "J ■ i ■ 3 -
4 Friendly Introduction to Your SX-64 Portable Color Computer
\ commodore
COMPUTER
USER'S GUIDE
GUIDE STATEMENT
STATEMENT
USER'S
" This equipment
equipment generates
generates and
and uses
uses radio
radi o frequency
frequency energy.
energy. If11 itit is
is not
not pro
pro"This
and used
used in
in strict
strict accordance
accordance with
with the
the manufacturer's
manufacturer's instruc
instrucperly installed
instal led and
perly
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 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
machine
computing device
device in
in accordance
accordance with
with the
the specifications
specifications in
in Subpart
Subpart JJ of
of Part
Part 15
15
computing
o f FCC
FCC Rules,
Rules, which
which are
are designed
designed to
to provide
provide reasonable
reasonable protection
protection against
against
of
such
such interference
interference in
in aa residential
residential installation.
installation . IfIf you
you suspect
suspect interference,
interfe rence , you
you
can test
test this
this equipment
equipment by
by turning
turning ifif off
off and
and on.
on. If11 you
you determine
determine that
that there
there is
is in
in·
can
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
terference
measures to
to correct
correct it:
it :
measures
••
reorient the
the receiving
receiving antenna
antenna
reorient
•
move the
the computer away
away from
from the
the receiver
receiver
move
•
•
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
change
plug the
the computer
computer into
into aa different
different outlet
outlet so
so that
that the
the computer
computer and
and the
the
plug
are on
on different
different branch
branch circuits.
receiver are
necessary, consult
consult your
yo ur Commodore
Commodore dealer
dealer or
or an
an experienced
experienced radio/televi
radio/televiIf necessary,
sion technician for additional
additional suggestions.
suggestions. You may
may also
also wish to consult
consu lt the
sion
booklet, which was prepared by
by the Federal
Federal Communications
Communications ComComfollowing booklet,
mission:
mission:
" How to
to Identify
Identify and Resolve Radio-TV
Radi o·TV Interference Problems"
Problems" This
Th is booklet
"How
Office, Washington.
Washington, D.C. 20402.
20402,
is available from the U.S. Government Printing Office,
004-000·00345·4."
Stock No. 004-000-00345-4."
-
-
-
-
—
TTHE
H E INFORMATION
IS MANUAL
I EWED AND
INFORMATION IN
IN TH
THIS
MANUAL HAS
HAS BEEN
BEEN REV
REVIEWED
AND IS
IS BELIEVED
BELIEVED TO
TO BE
BE
ENTIRELY
RELIABLE.
NO RESPON
RESPONSIBILITY,
HOWEVER, IS
IS ASSUMEO
ASSUMED FO
FOR
fNACCURACIES.
ENTIRE
L Y RELI
ABLE , NO
SIBI LI TY, HOWEVER,
R INACCURACIES.
MATERIAL
THIS
MANUAL
IS FOR
FOR INFO
INFORMATION
PURPOSES
ONLY, AND
AND IS
IS SUB
SUBJECT
TTHE
HE M
AT ERIA L IIN
N TH
IS MAN
U A L IS
RMA T ION PUR
POSES ONLY,
JEC T
TO
CH
ANGE
WITHOUT
NOTICE
TO CHANGE WITHOUT NOTICE.
THIS
MANUAL IS
IS COPYRIGHTED
COPYRIGHTED AND
AN D CONTA
CONTAINS
PROPRIETARY INFORMATI
INFORMATION.
NO PART
PART OF
OF
TH
IS MANUAL
INS PROPRIETARY
ON . NO
PUBLICATION
MAY
BE REP
REPRODUCED,
STORED
IN AA RE
RETRIEVAL
SYSTEM,
OR TTRANS
LICA TI ON M
A Y BE
RODUCED, ST
O RED IN
T R IEVA L SY
ST EM, OR
RANS·
TTHIS
H IS PUB
M
ITT ED IIN
N ANY
EANS, EELECTRONIC,
L ECTRON I C, MECHANICA
L , PHOTOCOPY
I NG,
MITTED
ANY FORM
FORM OR
OR BY
BY ANY
ANY M
MEANS.
MECHANICAL,
PHOTOCOPYING,
RECORDING
ISE. WIT
HOU T TH
E PR
IOR WRITTEN
RECORDING OR
OR OTHERW
OTHERWISE.
WITHOUT
THE
PRIOR
WRITTEN PERMISSION
PERMISSION OF
OF COM!\10DORE
COMMODORE
BUS
INESS t\.l
ACHINES, INC
BUSINESS
MACHINES.
INC
CoPV
r ighl© l g83 bv
ess Machi
nes, I Inc
nc
Copvrigh!©1983
by Commodore
Commodore Busin
Business
Machines.
All
! s reserved.
All ngh
rights
reserved.
ry
__
^
v
v
v
TABLE OF
OF CONTENTS
CONTENTS
TABLE
CHAPTER 1
1
CHAPTER
v
SETTING UP
UP
SETTING
v
Unpacking
Unpacking and
and Setting
Setting Up
Up the
the Executive
Executive 64
64 Computer.
Computer . . . . • . • . . . . . . . . ..
Transporting the
the Executive
Executive 64
64 . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . .
Transporting
Troubleshooting chart:
chart: Executive
Executive64
Troubleshooting
64 . . . . . . . .. ......... ... .•.• ......
Color Adjustment.
Adjustment . . . . . . . . . . . . . . . . . . . . . .. .. ...........•. • . . ..
Color
Expanding
Expanding Your
Your System
System With
With Optional
Optional Peripherals
Peripherals . . . . . . . • . • . • . . . . . . .
v
33
55
66
77
99
CHAPTER 2
GETTING STARTED
v
Communicating with your
64: The Keyboard
your64:
Keyboard . . . . . . . . • . . . . . . . . . . • . • . . ..
Loading
and
Saving
Programs
Loadi ng and Saving Programs. . . . . . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . ..
How to Load
Load Prepackaged Software . . . . . . . . . . . . • . . . . . . . . • . • . . . . . . ..
How
How to Format
Format a New
New Disk . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . . . . . . ..
How
How to Save Programs.
Programs . . . . . . . .
How
. . . . . • . . . . . . . . . . • . • . . ..
Listing
Directory of Programs on a Disk
Disk
Li
sting a Directory
. . . . . . . . . . . . . . . . . . . . ..
Files
Files.
.............................
. . •... . . ...• . • . . . . . ...
Sequential Files ............................•......... .. . .. .... .
Files
Relative Fi
les ...........................................•.•....
Random Access File ......................
. . . . . . . . . . • . • . • . . ..
Chart of BASIC Commands for Disks and Printers.
.. . . • .• . . . •. .• . . ..
Printers
12
12
17
17
118
B
19
19
19
20
20
21
24
26
30
CHAPTER 33
BEGINNING BASIC
Printing and Calculating
. . . . . . . . . . . . . . • . . . . . . . • . . . . . . . . . . • . . . . . . ..
Mathematical Functions ........... ... . . . .. . .. .. ..•...... . ... . ...
Multiple
Multiple Calculations
Calculations on
on One Line
Line .............. . . . . . •.. . . ... .• .•...
Execution
Execution Order in Calculations
Calculations . . . . . . . . . . . . . . . . . . . . • . • . • .
Combining PRINT'S
PRI NT' s Capabilities
Capabilities .....• . . . . ... . ....•. •. .... . ........
v
32
33
35
36
36
37
CHAPTER 4
4
SIMPLE PROGRAMS
PROGRAMS IN
IN BASIC
BASIC
WRITING SIMPLE
Line
Line Numbers
Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . .. 39
39
The GOTO
GOTO Statement
Statement . . . . . . . . . . . . • . . . . . . . . . . . . . . • . . . . . . . . . . • . • . .. 40
40
The
Using
Using the
th e LIST
LIST Command
Command ... . . . . . . . .. . . ... . . . . • . .. . . . •.• . ........ 40
40
Editing
Edit ing Tips
Tips.
.....
. .......•..............•....... ... . .......
........... .....
. . . . . • . . . . . . . . . . . . • . ..
Using
Using FOR...NEXT
FOR. .. NEXT Loops
Loops .. ...• . . . . .... . .• .•.• . . . ...... . • . ..I......
.. ....
How
How to
to Use
Use Variables
Variables
v
v
v
41
41
42
42
45
45
CHAPTER 55
CHAPTER
ADVANCED BASIC
BASIC
ADVANCED
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . .
Introduction
SimpleAnimation
Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . . . . .
Simple
INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . .
...
INPUT
Using the
the GET
GETStatement
Statemen t for
for Data
Data Input
Input. . . . . . . . . . • . . . . . . . . . .
Using
Using
Using GET
GETto
to Program
Program Function
Function Keys
Keys ................•. • ....•. • .....
Random Numbers
Numbers and
and Other
Other Functions
Funct ion s ..... . . . ..•.. . ... . .• . •. . . ....
Random
46
46
47
47
49
49
51
51
52
52
53
53
Guessing Game
Game . . . . . . . . . . . . . . . . . . . . . . .
. ............ 55
55
Guessing
Your Roll
Roll .. . ...... ... ..... .. ..... . ...... • . ... .. .. . . . .•... . ..... 56
56
Your
Random Graphics
Graphics . . . . . . . • . • . .. . . .. . . . . . • . • . . . .. . . . . . • . . . . . . . . . .. 57
57
Random
CHAPTER 66
CHAPTER
COLOR GRAPHICS
GRAPHICS
COLOR
How
How to
to Use
Use Colorand
Color and Graphics
Graphics on
on YourComputer
Your Computer . . . . . . . . . . . . . . • . . .
Printing Colors
Colors . . . . . . . . . . . . . . . . . . . .
........ .
Printing
Color CHR$ Codes
Codes. . . . . . . . . . . . . . . . . . . . . .. ....... . • . . . . .
ColorCHRS
How to
to Use PEEKS
PEEKs and
and POKEs
POKEs. . . . . . . . . . . . . . . . . • . • . . . . . . . . . .
How
Screen
Graphics.
.................•............•.. .
Screen Graphics
Screen
Memory
Map
.
.
.
.
.
......•...•.•......•...•......... .
Screen Memory Map
Color
Memory
Map
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . • . . . . . . . . • . . . . . . . . . . • . . . . ..
Color Memory Map
More Bouncing
Bouncing Balls
Balls . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . .
More
58
58
59
59
61
61
63
63
64
64
65
65
66
°6
67
67
CHAPTER 7
INTRODUCTION TO SPRITES
Bits,
Bits, Bytes
Bytes and
and Sprites
Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . • . • . • . . . . . . . . . . .. 69
69
Creating
72
Creating Sprites
Sprites . . . . . . . . . . . . . . .. . . . . ........• . •. . ......• . • . ..
7?
More on Sprites: Colors and Extra Movement . . . . . . . . . . . . . . . • . . . • . . . .. 78
CHAPTER 8
MAKING MUSIC ON YOUR COMPUTER: FOR
NON·PROGRAMMERS
NON-PROGRAMMERS
Structure
Structure of
of aa Sound
Sound Program
Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . ..
Sample
. . . .. .. . . . .• .. .•. .. . . . . .•.•. .. . .
Sample Sound
Sound Program
Program
Playing
. .. .. .. .. .. . .. .. .. .. .
Playing aa Song
Song on
on Your
Your 64
64 .. .. .. ..
Creating
Creating Sound
Sound Effects
Effects . . . . . . . . . . • . • . . . . . . . . • . . . • . . . . . . • . • . • ..
79
79
85
°^
87
87
89
"
CHAPTER
CHAPTER 9
ADVANCED
ADVANCED DATA
DATA HANDLING
HANDLING
READ
READ and
and DATA
DATA Statements
Statements . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . . . . . . .
Calculating
Averages.
Calculating Averages . . . . . . . . . . . . . • . • . . . . . . . . • . . . . . . . . . . . . .
pted Variables
Subscri
Subscripted
Variables ............ .. . . . ........•. . ............
Dimensioning
......•.
Dimensioning Arrays
Arrays . . . . . . . . .
Simulated
..... ....•...
.... .. .
Simulated Dice
Dice Roll
Roll with
with Arrays
Arrays.
Twodimensional Arrays
. . .... . . . . . ..... .. . • . • . .. . .. . . • . • . ....
Two-dimensional
Arrays.
91
91
93
93
95
95
96
96
97
97
99
"
APPENDICES
Software ..................•......... .•.•.. ...... . . . ... 103
103
Available Software
Description
of DOS
DOS Error
Error Messages
Messages .....•. • . • . •.• .. . . .. • . • .. . . . .... 112
112
Descripti
on of
Executive 64 BASiC
BASIC ...... .........
116
Executive
. ............ . ..... 116
Abbreviations for BASIC
............. .
. ... 128
BASIC Keywords
Keywords .
128
Display Codes
130
Screen Display
........
.......•.•..
. . . .... 130
CHR$ Codes ......... ... ......... • .•... . ........ . ..... 133
133
ASCII and CHR$
Screen and Color Memory
Memory Maps
Maps ...... . .. . •.• .•. •. • . . •...•.. . •.. ... 136
136
Deriving
Mathematical Funcl
Functions
138
Deri
ving Mathemalical
ions ....•.......................•..... 138
Pinouts
Pinouts for Input/Output
Input/Output Devices
Devices ......... ....... ........ ..... . ..... 139
139
Programs to Try ..................... ....
. ........ ...... .. 143
Converting Standard BASIC
BASIC Programs to Executive 64 BASIC
BASIC ......•. .... 146
Messages .............. .... ............................... 147
Error Messages
Values . . . . . . . . . . . .
Music Note Values.
..........
. ...... 149
Bibliography . . .
Bibliography.
. .............. .. • .• .•.• . •.. ..•.• .•.• .. . .... 152
Register
Sprite Regi
ster Map . . . . . . . . . . . .
. .. .•.•.•.. .
. ...•... . ... 154
6566/6567 (VIC-II) Chip Regi
ster Map . . . . . . . . . . . . .. . . ........•..... 157
Register
Settings
Executive 64 Sound Control Setti
ngs ................. . ..... • .•• . ... 158
6581 Sound Interface Device
(SID) Chip Specifications ... . . . . • . • . . • .. .. 161
Device(SID)
Disk and Printer Commands and Statements . . .. . .. . ......... • ..... 163
INDEX .... .. . . . . . . . .. . .... .. .. .. . . . . . .. .. .. . .. . . . . ... . ... ..170
no
v
-
—
-
-
-
-
()
f.1
—
()
n
n
-
v
v
v
v
v
v
v
v
INTRODUCTION
The
The Commodore Executive
Executive 64
64 is one
one of the best
best values in the home com·
com
puter industry. You can use
use your
your 64K color
color computer
computer for
for everything from
business applications to household paperwork to excit
ing games.
exciting
games. The 64 offers
offers
you lots of memory (64K),
(16 different colors), lots of sound (music
(64K), lots of color
color(16
and sound effects), and lots of fun and practical uses. You can use prepackag·
prepackag
easy-to-learn BASIC.
BASIC. All
ed software, or you can write your own programs in easy·to·learn
software designed for the Commodore 64 on disk or cartridge also runs on the
Executive 64.
Executive
The Executive
Executive 64 models (the SX-64 and the DX-64)
DX-64) have all the capabilities of
the best sell
ing Commodore 64, plus one or two disk drives and a 5" color
selling
monitor bu
ilt·in. The Executive
built-in.
Executive 64 snaps together to form its own carrying case,
case,
and it's light enough to carry and use anywhere.
This easy·to·read
easy-to-read user's guide contains all the information you need to set up
your equipment properl
y, understand how to operate your new SX-64 or DX-64,
properly,
DX-64.
and learn how
how to create your own simple BASIC programs.
v
v
v
v
v
This user's guide is intended to introduce you to computers, but it is beyond
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
publications that explain the topics we present here in more detail. These
publications include the Commodore 64 Programmer's Reference Guide and
our Introduction to BASIC series.
For those of you who don't want
wan t to learn how to program
't have to
program,, you won
won't
search through the whole
whole book to learn how to use Commodore prepackaged
programs and games,
games, or other prepackaged,
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 we call
call SPRITE
SPRITE GRAPHICS.
graphics, which
GRAPHICS. Sprite graphics let you:
•
yo ur own pictures
pictures in different colors, just like the ones you see on
Design your
arcade-type
arcade· type video games.
games.
o
•
•
o
•
Ani mate as
as many as 88 different
differe nt overlapping sprites
sprites at once.
Animate
Double
a
sprite's
size.
Double a sprite's size.
Move
Move your
your creations anywhere
anywhere on the
the screen.
Pass
Pass images
images in
in front
front or
or behind
behind each
each other.
other.
Use automatic
automatic collision
collision detection
detection that
that tells
tells the
the computer
computer to
to do
do whatever
whatever you
you
Use
want
want when
when sprites
sprites touch
touch each
each other.
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
addiYou
tion,
tion, you'll
you'll see
see sprites
sprites used
used in
in the
the preprogrammed
preprogrammed software
software you
you buy
buy from
from Com
Com·
modore.
modore.
v
v
v
MUSIC
MUSIC SYNTHESIS
SYNTHESIS
The
The Executive
Executive 64
64 also
also has
has built-in
built·in music
music and
and sound
sound effects
effects that
that rival
rival many
many
well
well known
known music
mu sic synthesizers.
synthesizers. This
Thi s part
part of
of your
you r computer
computer gives
gives you:
you:
••
33 independent
independent voices,
vOices , each
each with
with aa full
full 99 octave
octave piano-type
piano-type range.
range.
•• 44 different
different waveforms
waveforms (sawtooth,
(sawtooth, triangle,
tri angle, variable
variable pulse,
pulse, and
and noise).
noise).
•• A
A programmable
programmable ADSR
ADSR (attack,
(attack, decay,
decay, sustain,
sustain, and
and release)
release) envelope
envelope
generator.
generator.
•• A
A programmable
programmable high,
high, low,
low, and
and bandpass
bandpass filter
filter that
that you
you can
can use
use for
for each
••
voice.
voice.
Variable
Variable resonance
resonance and
and volume
vo lume controls.
controls.
IfIf you
you want
want your
your music
music to
to play
play back
back with
with professional sound reproduction,
the
high-quality
64 computers
computers let
let you
you connect
connect your
your audio
audio output to
to almost any high·quality
the 64
amplification
amplification system.
system.
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 by
by 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
MPS-801 dot matrix printers,
printers, and
The VIC
VIC 1525,
1525, 1526,
1526, and MPS·801
printer/pl otter, for
for printed
printed copies of your programs,
programs, letters,
printer/plotter,
letters, etc.
etc.
••
The 1600
1600 VICMODEM for access through your telephone to the massive
The
databases of
of larger
larger computers,
computers, and the selVices
services of hundreds of specialists
••
The Commodore 1701/1702
1701 /1 702 color monitor.
The
monitor.
••
The Z-80
Z·80 microprocessor,
microprocessor, for access to CP/M"
y of ap·
The
CP/M * *,, which offers a variet
variety
ap
the
1520
and aa variety
vari ety of
of information
information networks.
and
plications software.
software.
plications
Commodore wants you to really enjoy your new Executive 64. As you learn,
bear in
in mind
mind that
that programming takes time to learn. Be patient with yourself as
bear
you go
go through the USER'S
USER'S GUIDE.
GUIDE. Before you start,
tes
you
start, please take a
a few minu
minutes
to fill
fill out and
and mail in the owner/registration
owner/registrati on card that came with your computer
to
computer.
Thi s will ensure that your new computer is properly registered with Com·
This
Com
Headq uarters and that you receive the most up-ta-date
modore Headquarters
up-to-date information
information
regarding future
fut ure enhancements
enhancements for
regarding
for your
your system.
system.
NOTE: Many programs are under development while this manual
NOTE:
manual is
is being
being pro·
pro
duced. Please
Please check
check with
with your local Commodore dealer and with Commodore
duced.
Commodore
User's Magazines
Magazines and Clubs, which wi
ll keep you up·to·date
User's
will
up-to-date on
on the
the many
many ap·
ap
plications programs
programs being
plications
being written
written all
all over
over the
the world
world for
for the
the Commodore
Commodore 64
64 and
and
64.
Executive 64.
Executive
·Commodore 64
•Commodore
64 and
and Executive
Executive 64
64 are
are trademarks
trademarks of
of Commodore
Commodore Electronics
Electronics
Ltd
Ltd..
.. CP/M is
istered trademark
ions are
**CP/M
is a
a reg
registered
trademark of
of Digital
Digital Research
Research,, Inc.
Inc. Specificat
Specifications
are
subject
to
change.
subject to change.
CHAPTER 1
1
SETTING UP
• Unpacking and Setting Up the Executive 64 Computer
• Transporting the Executive 64
n
• Troubleshooting Chart: Executive 64
• Color Adjustment
• Expand
ing Your Systems With Optional Peripherals
Expanding
RELEASE
BUTTONS
()
-
—
GAME
PORTS
PORTS
CARTRIDGE
PORT
AUDIO/ VIDEO
AUDIO/VIDEO
CONNECTOR
SERIAL
PORT
USER
PORT
POWER SOCKET
FUSE
POWER
SWnCH
—
—
STORAGE ISX-64
O.'#L"I
ISX-64ONLY}
STORAGE
-
MONITOR
MONITOR
CONTROL
PANEL
ROLPANEL
CO NT
DISK DRIVE
aiSK DRIVE
HANDLE
HANDLE
LIGHT
I(
lOC
LOCK
HINGE
--
I-
S" COLOR
MONITOR
v
E
O_BAS
KEYBOARD-TO-BASE
KEYBOARO-T
CONNECTOR
CONNECTOR
v
BASE_TO.
KEYBOARD
CONNECTOR
2
UNPACKING AND SETTING
SEITING UP
UP THE EXECUTIVE
EXECUTIVE 64
UNPACKING
COMPUTER
COMPUTER
Remove your
you r Executive
Executive 64
64 carefully
carefully from its
its packaging.
packaging. Inside you should
should
Remove
these items:
find these
•
The Executive
Exec utive 64
64 computer
computer
The
'•
boxes. One box contains aa
carryin g case that contains
con tains two white boxes.
A black carrying
cord ; the other
other contains aa smaller
smaller cable
cable for connecting the
the keyboard.
keyboard.
power cord:
missi ng when you
you first unpack your Executive 64,
It any
any of these items is missing
If
contact your
you r dealer
dealer immediately
immediate ly for replacement.
contact
Before you
you begin
begin setting up your
you r Executive
Exec utive 64 for the first time, take a few
mi
nutes
to
examine
the
diagrams
in
thi s section. Look over your
yo ur computer,
minutes
this
computer,
the outlet, called
cal led ports,
ports , where peripheral devices are
are
noting the locations of the
plu gged into the
the computer.
computer. Note the ON/OFF switch,
switch, the
Ihe power cord outlet,
plugged
Th is examination
examinat ion will simplify
simplify the set up
up procedure.
hand le locks. This
and the handle
Foll ow these instructions each time
tim e you set up
Exec utive 64:
Follow
up your Executive
1.
Exec utive 64 on its end
en d so that the front of the computer and the
the
Stand the Executive
2.
2.
top.
handle are on top.
are located at the base of each side of the
Unlock the handle. The locks are
handle,
the circular
ci rcu lar blue hinges. Note that there are three dots
handle, just under the
on each hinge just above the lock tabs.
tabs. Move both lock tabs to the center
position
position..
3.
Move the handle down towards the
the side with the four rubber feet. Set the
handle so it is perpendicular to the sides of the computer.
computer. You may wish to
readjust the handle later.
later.
4.
Relock the handle lock tabs so the handle is stable.
4.
stable. Make sure both lock
tabs are locked and that the handle is secured.
secured.
5. Set the computer down careful
ly so that the handle serves as the front supcarefully
sup
port.
6. Remove the front
fro nt cover of the Executive 64 by pushing down the dark grey
button
s at the top of the cover. Hold down the buttons while you ease the
buttons
top of the cover towards yo
u. lift
you.
Lift out the bottom of the cove
coverr and place the
keyboard on the table in front of the computer base.
7. Connect the keyboard to the base with the short,
short, dark grey cable you found
in the separate ca
rryin g case when you first chec
ked the co
ntents of the
carrying
checked
contents
Exec
utive 64.
Executive
64. The larger,
larger, angled end of the cable goes into a slot on the
bottom of the computer located just under the disk drive.
ould lift up
drive. You sh
should
the computer base to see how this plug connect
s. Note the corresponding
connects.
ug goes.
2 rows of holes where the pl
plug
goes. Hold the plug with the rows of pins
perpendicular to the computer base. In
In other words
words,, the pins don't go in
first
first;; they should be on the side facing the back end of the computer. Push
the plug up and in unlil
until it is securely installed.
installed.
8. Plu
g the other end of th
e cable into the port in the back of the keyboard.
Plug
the
keyboard.
ure.
Note that the plug goes in only one way. Make sure the plug is sec
secure.
9. Make sure your Executive 64 is turned OFF. The power switch is on the far
left top of the back end as you face the monitor.
monitor. Look at this end of the
co
mpu ter, and move the switch back and forth until you see the white circomputer,
cir
de of the switch. When the computer is OFF,
rcle is
cle on one si
side
OFF. the ci
circle
SHOWING
SHOWING..
10.
g in the power cord.
10. Plu
Plug
cord. This cord goes in the back near the power switch.
Note that the plug goes in on
ly one way. Make sure the cord is secure. Plug
only
the other end into a standard 120 volt outlet for three prong plugs.
3
n
11.
11, Turn the computer on with the power switch discussed in step 9. When the
compu
ter is on
computer
on,, the red disk drive light (or lights, if you have two drives)
come on and in a few seconds the screen displays the power-on message:
v
v
SX-64 BASIC V2.0
*""
64K RAM SYSTEM
SYSTEM 38911 BASIC BYTES
BYTES FREE
READY.
READY.
12. Adjust
Adj ust the picture
round color shou
ld be white,
white, the
picture,, if necessary. The backg
background
should
border shou
ld be cyan (light
should
flight blue·green),
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
as you wou
ld use the adjustments on a TV set. Note that the top knob con·
would
con
tro
is th
e vo
lume for your
trols
the
volume
your Executive 64.
Now yo
u're ready to begin using your Executive 64. If you have any problems,
you're
consult the trouble'shooting
re to
trouble-shooting chart. Before you use the disk drive,
drive, be su
sure
consult Chapter 2.
v
v
v
4
TRANSPORTING THE EXECUTIVE 64
The Executive 64 is easy to pack and carry with you. Follow these steps to
prepare your Executive 64 for carrying:
1.
2.
3.
Remove any disks from the disk drives and turn the computer OFF. If you
have an SX-64, do not carry disks in the computer's storage slot.
Remove any cartridges.
Turn off and disconnect any peripheral devices that are attached to your
computer.
4.
5.
Remove the power cord from the back end of the computer.
Unplug the
the keyboard connection cable from the keyboard,
keyboard, and then remove
the other end from the base of the computer.
6. Pack the cables in their boxes, and put the boxes in the carrying case. Note
that the smaller cable goes in the smaller box.
bot
7. Place the metal strip at the top of the keyboard into the long slot at the bot·
tom of the computer's front
front,, just under the monitor and disk drive.
8. Push the keyboard on the slot until the keyboard clicks into place in the
buttons above the monitor and disk drive. Make sure the keyboard is
securely attached.
9. Lift the computer up to stand on its back end.
10.
locked
10. Unlock the tabs on each side of the handle's base.
base. The tabs are un
unlocked
when they are in the center position. Make sure both tabs are unlocked.
11. Move the handle up to the top of the computer so the handle rests in the
carrying position. The handle should be parallel to the sides of the comcom
puter's base.
base.
12.
12. Relock the tabs.
tabs. The tabs are locked when they are in the side positions,
position. Make sure both tabs are locked and that the han
hannot in the center position.
dle is secure.
13. Attach the carrying case containing
containi ng the cords to the Executive 64's hand
le.
13.
handle.
The Executive 64 is now ready to be carried wherever you go. Be sure to han
handle the Executive 64 carefully when you transport it.
5
v
TROUBLESHOOTING CHART:
CHART: Executive
Executive 64
64
TROUBLESHOOTING
Symptom
Symptom
Cause
Cause
Remedy
Remedy
Indicator Light
Light
Indicator
Computer
not
Computer not
"On"
"On"
Make
Make sure
sure power
power switch
switch
Power
Power cable
cable not
not
plugged in
in
plugged
Check
Check power
power socket
socket for
for
loose
loose or
or disconnected
disconnected
power
power cable.
cable.
Power
Power supply
supply not
not
plugged
plugged in
in
Check
Check connection
connection
with
with wall
wall outlet
outlet
Bad fu
fuse
in
Bad
se in
computer
computer
Take
Take system
system to
to
authorized
authorized dealer
dealer for
for
replacement
se
replacement of
of fu
fuse
Power not
not ON
ON
Power
Check
ies
Check previous
previous remed
remedies
Malfunction
Malfunction
Take
Take system
system to
to
authorized
authorized Commodore
Commodore
dealer for repair
Cartridge not
properly installed
Turn
Turn off
off power
power and
and
rein
sert cartridge
reinsert
cartridge
Poorly
Poorl
y adjusted
picture
picture
Adjust picture
Adjust
picture controls
controls
Volume too
high
Adj ust volume
Adjust
volume control
control
Volume too
Volume
low
Adjust volume
volume control
control
Adjust
Disk improperly
improperly
Disk
in serted
inserted
Remove disk;
disk; insert
insert
Remove
according to
to directions
directions
according
not "On"
"On"
not
v
No picture
picture
No
Random pattern on
monitor when
cartridge
cartridg
e is in
Picture
with
poor
Pict
ure wit
h poor
or no
no color
coior
or
Excess background
noise
v
Picture
no
Picture OK,
OK, but no
sound
sound
Disk
Disk won't
won't LOAD
LOAD
isis in
in "On"
"On" position
position
(see Chapter
Chapter 2)
2)
(see
v
Drive door
door noi
not
Drive
closed
closed
secure
Bad disk
disk
Bad
Insert another
another disk
disk
Insert
Malfunctioning
Malfunctioning
Take system
system to
to
Take
authorized
dealer
for
authorized dealer for
drive
drive
Make sure
sure door
door is
is
Make
secure
repai r
repair
v
6
v
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 where
where what
what you
you type
type on
on the
the keyboard
keyboard will
will be
be displayed
displayed on
on the
the screen.
screen.As
As
shows
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
rep laced with
with the
the character
character you
you typed.
typed. Try
Try typing
typing on
on the
the keyboard
keyboard and
and watch
watch
replaced
the cursor
cursor move
move while
while characters
characters you
you type
type are
are displayed
displayed on
on the
the screen.
screen .
the
COLOR ADJUSTMENT
ADJUSTMENT
COLOR
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 you
you can
can
There
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
easily
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
the
your computer.
co mputer.
your
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
First,
This stands
stands for
for ConTROL
ConTROL and
and is
is used,
used, in
in conjunction
conjun ction with
with other
other
ISTI1 . This
II!iiDI .
keys, to
to instruct
instruct the
the computer
computer to
to do
do aa specific
specific task.
task.
keys,
you hold
hold down
down the
the »**<:;.*
II!iiDI key while
wh ile pressing
pressing aa
To use
use aa control
control (unction,
fun ction, you
To
second
key.
second key.
—■■■■
mm
Try this:
this: hold
hold the
the KUiil
II!iiDI key
key while
while also
also pressing
pressing the
the Q
D key.
key. Then
Then
Try
both keys.
keys. Nothing
Nothing obvious should
should have
have happened,
happened , but
but ifif you
you touch
tou ch any
release both
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
the
opening
message
of
anything
you
typed
eariler.
- like
message
anything you
Held down the
;he HJ.mJ.U What happens9
did th
thee above procedure
procedure corcor
Hold
happens? If you did
Mbai:!.,., .
rectly , you
ould see a light blue bar
rectly,
you sh
should
bar move across the screen and then move
Mb3i:"\-)
to the next line as long as the fciJ.m-T.^ is
down to
i ■ pressed.
presse I
-
READY
7
(l
(l
EIilI
Now,
Now. hold
hold
KUiil while
while pressing
pressing any
any of
of the
the other
other number
number keys.
keys. Each
Each of
of
them
ll be
them has
has aa color
color marked
marked on
on the
the front.
front. Anything
Anything displayed
displayed from
from this
this point
point wi
will
be
in that
that color.
color. For example, hold
hold E3 and
and the
the
Q key
key and
and release
release both.
both.
in
Now hold the
Watch
Watch the
the displa,y.
display. The bar
bar is
is now
now in
in yellow!
yellow! In
In aa like
like manner
manner you
you can
can change
change
the
lors indicated
the bar
bar to
to any
any of the other
other co
colors
indicated on
on the
the number
number keys
keys by
by holding
holding
EES and
and the
the appropriate
appropriate,- key.
key.
Change
ust the
Change the
the bar
bar to
to a
a few
few more
more different
different colors
colors and
and then
then adj
adjust
the color
color and
and
tint
ls on
ur monitor
lor you
tint contro
controls
on yo
your
monitor so
so the
the display
display matches
matches the
the co
color
you selected.
selected.
The display
display should
should appear
appear something
something like
like this:
this:
The
EIilI
D
EIilI
II
D
D
D
RED BAR
GREEN BAR
BLUE BAR
YELLOW BAR
ing correctly.
At this pOint
point everything is properly adjusted and work
working
correctly. The
following chapters will introduce you to the BASIC language.
language. However,
However, you can
immediately start using some of the many prewritten applications and games
available without know
ing anything about computer programming.
knowing
Each of these packages contains detailed information abou
aboutt how to use the
program. It is suggested
rough the first few chapters of
suggested,, though,
though, that you read th
through
this manual to become more familiar with the operation
operat ion of your
you r new system.
system.
8
EXPANDING
EXPANDING YOUR
YOUR SYSTEM
SYSTEM WITH
WITH OPTIONAL
OPTIONAL PERIPHERALS
PERIPHERALS
n
Commodore
Commodore offers
offers aa variety
variety of
of peripheral
peripheral devices
devices that
that expand
expand the
the
,...,
capabilities of
of your
your computer.
computer. These
These peripherals
peripherals include:
include:
capabilities
••
storage devices
devices
storage
••
pri nters and
and plotters
plotters
printers
n
monitors
•• monitors
•
modems for
for telecommunications
telecommunications
• modems
game attachments
attachments
•• game
••
speech and
and graphics
graphics modules
modules
speech
••
desktop controllers
controllers
desktop
r-.
~
STORAGE DEVICES
DEVICES
STORAGE
Disk Drives
Drives
Disk
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 diskettes.
diskettes. Diskettes
Diskettes offer
offer fast
fast storage
storage and
and retrieval,
retrieval , and
and they
floppy
automatically
automatically keep
keep track of
of all
all your
your files
fi les in
in aa directory,
directory, or
or table
table of
of contents,
contents, that
you can
can display
display on
on your
your screen
screen or
or print
print on
on aa printer.
pri nter.
you
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 acquiring the Commodore
Commodore 64
64 IEEE Interface Expansion
Expansion Card,
Card , you can also
By
CBM 8050 or 4040 Dual Flop
Flop·
attach any IEEE disk drive, such as Commodore's CBM
py Disk Drives,
Drives, to the Executive
Exec utive 64.
64.
Chapter 22 contains detailed information on using disk drives.
PRINTING AND PLOTTING DEVICES
n
Prin
ters
Printers
1526, or MPS·801
MPS-801 Printers to the Ex·
Ex
You can attach Commodore's 1525, 1526,
ecutive 64.
64. These models
models are inexpensive dot matrix
matrix printers.
printers. By acquiring the
Commodore 64
64 IEEE
IEEE Interface
Interface Expansion
Expansion Card, you can
can also
also attach
attach any IEEE
printer,
printer, such as Commodore's 6400 letter
letter quality printer, or the high
high speed 8023
dot matrix
matrix printer,
printer, to the Executive
Executive 64.
Printer/Plotter
Printer/Plotter
Commodore's
Commodore's 1520
1520 Printer/Plotter
Printer/Plotter prints
prints and
and draws
draws graphics
graphics in
in four
four colors
colors
(black,
ue, red
harts, pies,
(black, bl
blue,
red,, and
and green).
green). With
With the 1520, you
you can
can draw
draw barc
bar charts,
pies, and
and aa
va
riety of
variety
of complex
complex graphics.
graphics.
THE
THE 170111702
1701/1702 MONITOR
MONITOR
Commodore's 14"
14" color
color monitor
monitor offers
offers aa superior
superior color
color picture
picture with
with high
high
Commodore's
resolution
that enhances
enhances yo
your
computing
experience. This
This moni
monitor
can
be concon
lu tion that
ur co
mputing experience.
tor ca
n be
reso
nected 10
to the
the Exec
Executive
64. The
The monitor
monitor is
is connec
connected
to the
the compu
computer
by an
an
nected
utive 64.
ted to
ter by
8-pin DIN
DIN cable.
cable. The
The 1701
1701/1702
Color Monitor
Monitor User's
User's Guide
Guide that
that comes
comes with
with the
the
8·pin
/1702 Color
monitor clearly
clearly explains
explains connections.
connections. You
You can
can also
also consult
consult Appendix
Appendix II for
for inforinfor
monitor
mation
mation about
about the
the pinouts
pinouts in
in the
the 8-pin
8-pin connector.
connector.
NOTE: You
You can
can also
also use
use aa 5-p
5-pin
cable to
to con
connect
monitor
to the
the Executive
Executive 64.
64.
in cable
nect aa monit
or to
NOTE:
Just
Just plug
plug itit into
into the
the 8·pin
8-pin connector.
connector.
9
v
MODEMS FOR
FOR TELECOMMUNICATIONS
TELECOMMUNICATIONS
MODEMS
The 1600
1600 VICMODEM
VICMODEM
The
Commodore's
Commodore's inexpensive
inexpensive 1600
1600 VICMODEM
VICMODEM leis
lets you
you use
use your
your telephone
telephone to
to
connect
connect your
your Executive
Executive 64
64 to
to other
other computers
computers and
and computer
computer services.
services. These
These
computer
computer services
services include
include CompuServe,
CompuServe, The
The Commodore
Commodore Information
Information Net·
Net
work. The
The Source,
Source, Dow
Dow Jones
Jones News/Retrieval,
News/Retrieval, and
and others.
others.
work,
v
THE Z·BO
Z-80 MICROPROCESSOR
MICROPROCESSOR AND
AND CP/M"
CP/M"' OPERATING
OPERATING SYSTEM
SYSTEM
THE
The
The Z-80
Z-80 microprocessor
microprocessor turns
turns your
your Executive
Executive 64
64 into
into a
a dual
dual microprocessor
microprocessor
home computer.
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
home
ety of software
ng wordprocess·
System,
System, which ofters
offers a
a vari
variety
software applications, includi
including
wordprocessing., wide
widely-used
business
programs, high
high level computer languages (e.g.,
ness programs,
ing
ly-used busi
COBOL,
FORTRAN), and other uselul
useful programs.
CO
BOL, FORTRAN),
ATTACHMENTS FOR
FOR GAMES AND OTHER USES
ATIACHMENTS
Commodore ofters
offers joysticks, paddles,
paddles, and trackballs that enhance game·
gameications. For
playing
piaying on your computer. These attachments also have other appl
applications.
example,
example, the joystick works with Commodore's MAGIC DESKT"
DESK™ software
perform
com
series, which lets you perf
orm many complex tasks without knowing any com·
puter language. The joystick moves a hand that paints
points to a picture representing
the task you want to do.
THE COMMODORE SPEECH MODULE
Commodore's Speech Modu
le makes your Executive 64 talk. The module
Module
bu ilt·in vocabulary of 235 utterances,
and, with software support,
comes with aa built-in
utterances, and,
support,
speak in different voices.
voices. The Module is easily programmed in BASIC and
and
it can speak
Comalso works with preprogrammed software on disk and cartridge. Some of Com
modore's first talking cartridges include: the MAGIC
MAG IC DESK™
DESKT" series.
series, GORF
GORF, and
WIZARD
WIZARD OF WOR.
WOR.
COMMODORE
COMMODORE GRAPHICS AIDS
AIDS
Commodore provides
provides aa variety
variety of
of graphics
graphics programming
programming aids,
aids, including
including the
the
Commodore
SUPEREXPANDER
SUPER EXPANDER 64
64 cartridge,
cartridge, which adds
adds easy-to-learn
easy·to·learn graphic
graphic plotting
plotting and
and
music programming
programming commands
commands to
to BASIC;
BASIC; SIMON'S
SIMON 'S BASIC,
BASIC, which adds
adds 118
11 8
music
powerful
powerfu l new
new commands
commands to
to BASIC,
BASIC, including
including programming
programming help
help and
and graphics
graphics
commands; and
and LOGO,
LOGO, an
an easy-to-learn
easy·to·learn progamming
progamming language
language with
with TURTLE
TURTLE
commands:
graphics.
graphics.
v
10
10
SPECIAL DESKTOP
DESKTOP CONTROLLER
CONTROLLER
SPECIAL
Commodore will
will soon
soon introduce
introduce aa special
special device
device that
that controls
controls the
the screen
screen as
as
Commodore
you move
move the
Ihe controller
conlroller across
across aa desktop.
desktop. This
This new
new controller
conlroller will
will be
be an
an op
op·
you
products, such
such as
as the
the MAGIC
MAGIC
tional enhancement
enhancement for
for Commodore
Commodore Software
Software products,
tional
DESK Series.
Series.
DESK
MUSIC ATTACHMENTS
ATTACHMENTS
MUSIC
Commodore
Commodore will
will also
also soon
soon offer
offer aa Musical
Musical Keyboard
Keyboard and
and 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. These
These attachments
attachments will
will increase
increase the
the music
music making
making capabilities
capabilities of
of
packages.
the 64
64 computers.
computers.
the
CONNECTING TO
TO A
A STEREO
STEREO SYSTEM
SYSTEM
CONNECTING
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 used
used to
to connect your
your computer
computer to
to an
an amplifier.
amplifier.
be
A COMPUTER SYSTEM FOR YOUR NEEDS
DESIGNING A
a variety of peripherals that
Commodore offers
offers a
th at let you create your own
own
customized computer system.
storage, printing,
printing, and
system. We offer different types of storage,
telecommunications
devices so
so you
you can
can choose
choose what's
what's best
best for
for you
you.. For
For more
more
tel
ecommunications devices
information about
about Commodore
Commodore peripherals,
peripherals, read
read The
The Commodore
Commodore Peripherals
Peripherals
information
magazines
R and consult
Guide and the Commodore magazi
nes discussed in Appendix
Appendi x R
your Commodore dealer.
11
11
CHAPTER 2
GEITING
GETTING STARTED
Communicating with
with your
your 64:
64: The
The Keyboard
Keyboard
•• Communicating
•
Loading
Programs
Load
ing and Saving Programs
How to Load
Load Prepackaged
Prepackaged Software
• How
•
How to Format
Formal a New
New Disk
Disk
How
•
How to Save Programs
How
Directory of
of programs
programs on
on a Disk
•• Listing aa Directory
Files
•• Fi
les
• Sequential Files
•
Relative Files
••
Random Access
Access Files
Files
Random
• Chart of BASIC Commands for Disks and Printers
COMMUNICATING WITH YOUR 64: THE KEYBOARD
The computer keyboard lets you communicate with your 64. You use the
keys to tell the computer what you want it to do and to answer the questions
the computer displays on the screen.
The keyboard looks like a regu
lar typewriter,
typewriter, but the computer has special
regular
keys that let the 64 do more than a typewriter. While you read the next few
pages, take a look at these special keys.
RETURN
RETURN
Th
e RETURN key tells the computer to look at
The
what you typed and put this information in
in
memory. The RETURN key also moves the cursor
memory.
to the next line.
to
NOTE: Memory is
is all
all the information the com
comNOTE:
knows without
without needing
needing you
you to tell
tell
puter currectly knows
it where to
to look.
look.
it
The SHIFT
SH IFT key
key works
works like
like the
the shift
shift key
key on
on aa
The
typewriter: itit lets
lets you
you print
print capital
capital letters
letters
regular typewriter:
SHIFT
or the
the top
top characters
characters on
on double
double character
character keys.
keys.
or
m
mm
t::jJ
- \\
~-'
~
~-'
'\
12
12
0
When you
you are
are using
using the
the graphics
graphics on
on the
the front
front of
of
When
the
the keys,
keys, the
the SHIFT
SH IFT key
key displays
displays the
the graphic
graphic
character
c haracter on
on the
the RIGHT
RIGHT side
side of
of the
the key.
key.
'-;-h
~
-
-
-
When
When you
you are
are using
using the
the four
fou r special
special function
function
keys
th e right
right side
side of
01 the
the keyboard,
keyboard, the
the SHIFT
SHIFT
keys at
at the
key
key gives
gives you
yo u the
the functions
fun ctions on
on the
the FRONT
FRONT of
of the
the
key (f2,
(f2, f4,
f4, f6,
f6, and
and f8).
key
v
v
13
13
KEYS THAT
THAT LET
LET YOU
YOU MAKE
MAKE CHANGES
CHANGES
KEYS
CRSR
CRSR
The
The cursor
cursor is
is the
the little
little colored
colored rectangle
rectangle that
that
mark
s you
r place
marks
your
place on
on the
the screen.
screen. There
There are
are two
two
CuRSoR
CuRSoR keys:
keys:
ttCRSR+
CRSR.
-CRSR
■•-CRSR-*-
moves
moves the
the cursor
cursor up
up and
and down
down
moves
moves the
the cursor
cursor left
left and
and right
right
You
You must
must use
use the
the SHIFT
SHIFT key
key with
with the
the
t+ CRSR
. key
CRSR+
key to
to move
move the
the cursor
cursor up,
up, and
and with
with
- key
the +* CRSR
CRSR-*key to move
move the
the cursor
cursor to
to the left.
left.
You
You don't
don't have
have to keep
keep tapping
tapping a CRSR
CRSR key
key to
get
it
to
move
more
than
one
space.
Just
hold
get it
move more
one
Just hold itit
down
down until
until the cursor is
is where you want
want it.
it.
INST/DEL
INSTIDEL
DEL
DEL stands for DELete.
DELete. When you press the
DEL
DEL key,
key, the cursor moves
moves back
back a space and
erases the character that'
s there.
that's
PRINT ""ERROR"#B
ERROR" #.
ERROR" .
PRINT ""ERROR"B
When you DELete in the middl
e of a line, move
middle
the cu
rsor
just
to
the
left
of
the
character you
cursor
want to DELete.
FI
X IT
AGAINS, SAM
FIX
ITAGAINS,
FI
X
IT
AGAINS . SAM
FIX
AGAINSB
Then press the
th e DEL key.
e characters to the
key. Th
The
ri
ght automatically move over to close up the
right
space.
space.
FI
X IT AGAIN,
AGAIN , SAM
FIX
INST stands
stands for INSerT.
INSerT. You have to use the
SHI FT key with
wi th the
th e INST/DEL
INSTIDEL key when you
yo u want
want
SHIFT
to insert characters
charac ters in a line.
to
If you've
you 've left some characters out of a line,
line, use
to the
the er
er·
the CRSR keys to
to move the
the cursor back to
the
ror.
ror.
WH ILE UU WERE OUT
WHILE
WHILE.
WERE OUT
WHILE
■ WERE
Then, while
while you
you hold
hold down
down the
the SHIFT
SHI FT key,
key,
Then,
press
the
INST/DEL
key
until
you
have
enough
press the INST/DEL
until you have enough
INST
space to
to add
add the
the missing
missing characters.
characters. INST
space
doesn't move
move the
the cursor;
cursor; itit adds
adds space
space between
between
doesn't
the cursor
cursor and
and the
the character
character to
to its
its right.
right.
the
WHILE.
U WERE
WERE OUT
OUT
WHILE
■ U
WH ILE YOU
YOU WERE
WERE OUT
OUT
WHILE
Use the
the DEL
DEL and
and INST
INST keys
keys together
together to
to fix
fix
Use
wrong characters.
characters .
wrong
WE'RE NUMBER
NUMBER TWO!
TWO!
WE'RE
WE'RE
NUMBER
WE'RE NUMBER ! !
W E'RE NUMBER
NU MBER.
WE'RE
■
!
WE'RE NUMBER
NUMBER ONE!
ON E !
WE'RE
14
14
n
n
'-"
CLR/HOME
position.
~
CLR stand
s for CLeaR.
stands
CLeaR. When you use the
SHIFT key with the CLRlHOME
CLR/HOME key, the screen
CLeaRs and the cursor returns to the home
positon.
~
'-"
v
'-'
'"'
v
v
HOME moves th
e cursor back to the upper left
the
corner of the screen. This is called the ""HOME"
HOME"
RESTORE
The RETORE key returns the computer to its
RESTOREing
condi
normal state by RESTOREi
ng the default conditions (e.g.,
(e.g., the default screen color is blue,
blue, the
/0 chips is OFF, etc.) RESTORE does
default for 1I/O
things
screen,, returning it to the
such thin
gs as clear the screen
original
original color,
color, and turn off the picturepicture- and sound-
making chips.
NOTE:
work, you must hold
NOTE: For RESTORE to work,
le you press the
down the STOP key whi
while
RESTORE
RESTORE key.
For example,
example, suppose you've just played
piayed a
music program that also turn
ed you
turned
yourr screen red
'-'
'-'
'"'
and yellow while it LISTed the program. When you
propress STOP and RESTORE at the end of the pro
gram, the last note from the program wi
ll cease,
will
your screen will turn blue and the only thing
displayed will be the READY prompt.
displayed
;..)
...-J
v
--'
v
'-'
'-"
'-'
~
'-"
'-'
15
15
KEYS
FUNCTION KEYS
The keys on the right side of the keyboard,
keyboard, f1-f8,
fH8, are function
fun ction keys
keys that you
can program
program to
to perform
perform aa variety
variety of tasks.
tasks. The
The explanation
explanation of
of the
the GET
GET state
state·
can
in Chapter 55 tells
tells you
you how
how to
to program
program function
function keys.
ment in
CTRl
CTRL
The ConTRoL
ConTRol key lets you set colors and do
do
other special
special tasks
tasks called control
control functions.
functions.
other
To set
set colors,
colors, hold down
down the
the CTRL
CTRl key while
white
To
press the
the key with
with the
the color
color you want.
want. You
You
you press
more colors
cotors with the ~
can get eight more
C^
key.
6 also
also has more about colors.
Chapter 6
a control
control function,
function , hold
hold the CTRL
CTRl key
To get a
down while
wh ile you press the other key. Control
Cont rol func
func·
down
tions are commonly used in prepackaged soft
soft·
tions
processing system.
ware such as a word processing
RUN/STOP
You can halt
hal t aa BASIC
BASIC program
prog ram while it is still
stil l
RU Nning by pressing the STOP key. You can also
RUNning
use the STOP key to halt a printout while it is still
stil l
printing.
RUN
a program automatically
automatical ly
RUN lets you load a
from diskette.
When you want to use the RUN key,
key, you must
also use the SHIFT key.
~ COMMODORE KEY
The Commodore key ~
C^ can do two things:
1.
[Cs| lets
lets you
you switch
switch back
back and
and forth
between
1. ~
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).
C= and SH
SHIFT
To switch modes, press the ~
IFT
keys at the same time.
your64,
is in the up·
up
64, it Is
When you first turn on your
per case/g
raphic mode,
case/graphic
mode, which means that
everything you type in is in capital letters.
When you are in this mode,
mode, you can also print
all the graph
ics on the fronts of the keys.
graphics
• To print the graphic on the right side of a
key, hold down the SH
IFT key while you
SHIFT
press the key with the graphic you want to
print. You can on
ly print the right side
only
graphics when you are in the upper
case/graphic mode.
nt the graphic on the left side of a key,
• To pri
print
hold down the ~
,O key while you press the
graphic key. You
You" can print the left side
graphic in either mode.
16
_
r;-~
~
2.
2. The
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.
To get
keys.JTo
these other co
lors, hold down the ~
colors,
[CE key
while yo
u press the number
you
number for the color you
—
—
-
want.
LOADING AND SAVING PROGRAMS
The Exec
utive 64 accepts programs from disk or cartridge.
is means you
Executive
cartridge. Th
This
y by loading it. But more important,
can use prewritten software simpl
simply
important, the 64
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
Executive
also run
s on the Exec
utive 64.
17
17
HOW TO
TO LOAD
LOAD PREPACKAGED
PREPACKAGED SOFTWARE
SOFTWARE
HOW
Loading Cartridges
Cartridges
Loading
64.
You can
can use
use aa special
special line
line of
of programs
programs and
and games
games on
on cartridge
cartridge with
with your
your 64.
You
The programs
programs include
incl ude aa wide
wide variety
va riety of
of business
business and
and personal
personal applications.
applications. The
The
The
games are
are just
just like
like real
real arcade
arcade games,
games, not
not imitations.
imitations.
games
Follow these
these steps
steps to
to load
load games
games and
and other
other cartridges:
cartridges:
Follow
1. Turn
Turn OFF
OFF your
your Executive
Executive 64.
64.
1.
YOU MUST
MUST TURN
TURN OFF
OFF YOUR
YOUR EXECUTIVE
EXECUTI VE 64
64 BEFORE
BEFORE YOU
YOU INSERT
INSERT OR
OR
YOU
REMOVE CARTRIDGES.
CARTRIDGES. IF
IF YOU
YOU DON'T.
DON'T, YOU
YOU MAY
MAY DAMAGE
DAMAGE THE
THE CAR
CAR·
REMOVE
TRIDGE AND
AND THE
THE COMPUTER.
COMPUTER.
TRIDGE
Insert the
the cartridge
cartrid ge in
in the
the slot
slot on
on the
the top
top of
of your
your computer.
compu ter.
2. Insert
2.
3. Turn
Turn on
on your
your 64.
64.
3.
4. Begin
Begin the
the game
game by
by typing
typing the
the START
START key
key that's
tha t's listed
listed in
in the
the game's
game's instruc
instruc·
4.
tion sheet.
sheet.
tion
Loading Disks
Disks, which
which are often
often called
called "floppy
" floppy disks",
disks ", are
are really easy to
to use.
use.
Disks,
The steps are
are the same
same for loading
loading preprogrammed disks and disks that
that you
The
program yourself.
you rself.
Insert aa disk into your disk drive. Make
1. insert
1.
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
with a little piece of tape). This
Thi s notch must be
the disk (it might be covered with
disk, assuming that you're
com
on the left side as you put in the disk,
you 're facing your 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
E" , 8. The 8 is the code for disks. You need to
NAME".
type it here to let the computer know you
're loading a disk.
you're
NOTE:
e first program by using the ·' sign in place o
NOTE: You can LOAD th
the
off the
8.
program name:
LOAD
"
.
"
,
name:
"*",
4.
wi ll say:
4. Press the RETURN key.
key. The disk will spin and your screen will
SEARCHING FOR PROGRAM NAME
LOADING
READY
•
■
5. Type RUN
RUN when the screen says READY and the cursor appears. Your soft·
soft
~is~~u~
ware is ready to use.
n
n
18
18
n
HOW TO FORMAT A NEW DISK
When you're using a new,
new. unprogrammed disk for the first time, you need to
headering,, prepares your disk by dodo
format it. Formatting, which is also called headering
ing things like dividing the disk into blocks. Formatting also creates a directory
that you use as a table of contents for the files yo
u save on the disk. DO NOT
you
header a preprogrammed disk.
only
disks, not disks that already have programs on
You o
nly have to format new disks,
them unl
ess you want to erase the entire disk and reuse it.
unless
To format a new disk,
disk, use this special version of the OPEN and NEW com·
com
mands:
mands:
1,8.15,liN0:<name>.<id>"
NO: <name> , < id Y '
OPEN 1,8,15,"
v
(NEW)
0. If you have a DX-64,
DX-64,
NO tells the computer to header (N
EW) the disk in drive O.
disks
0.
header disk
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
rs. Give the disk any id you want,
want, but you should
characters.
give every disk a different id code.
off. type CLOSE 1
1 and press return.
When the disk drive light goes off,
disk, if there is
BE CAREFUL! Headering a disk erases all information on the disk,
disk or a disk you are willing to erase.
ex
any. Header only a new disk
erase. Here are some excommands
disk:
amples of OPEN comm
ands that header aa disk:
15," NO:MYFILE,A3"
OPEN 1,8,
1,8,15,"N0: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
ve 64. Appendix
Appendi x S
S contains more informaand save programs on your
your Executi
Executive
informa
tion on the OPEN command.
HOW TO SAVE PROGRAMS
When you
you want to reuse aa program you've
you 've written, be sure to
to SAVE
SAV E it before
you
you LOAD another
another program.
program. If you
you don't,
don't, you'll
you'll lose the
the program.
program.
When you change aa SAVEd
SAVEd program,
program, you
you have to SAVE it again if you
you want
want to
When
keep the new
new version.
version .
When you
you reSAVE
reSAVE aa program,
program , you
you are replacing the
the old
o ld version
ve rsion with
with the
the new
When
one. If you want
wa nt to keep
keep both
both the
the old and
and the
the changed versions,
vers ions, you
you have
have to
to give
one.
the
the new one aa different name
name when you
you SAVE it.
When
When you
you want to
to SAVE aa program
program you've
you 've written
written on
o n disk,
disk, follow
foll ow these
these sim
sim·
ple
pie steps:
steps:
1. Key
Key in
in SAVE "PROGRAM
" PROGRAM NAME",8.
NAME",8. The
The 88 is
is the
the code
code for disks.
disks. It tells
tells the
the
1.
computer
computer that you're
you 're using
usi ng aa disk.
disk.
2. Press
Pre ss RETURN.
RETURN . The
The disk
disk makes
makes aa noise,
nOise, and
and the
the computer
comp uter displays
displays this
this
2.
message when
when the
the program
program is
is saved:
saved:
v
v
SAVING
SAVING "PROGRAM
"PROGRAM NAME"
NAME"
OK
OK
READY
READY
19
19
—
LISTING A
A DIRECTORY
DIRECTORY OF
OF PROGRAMS
PROGRAMS ON
ON A
A DISK
LISTING
When you
you SAVE
SAVE programs
programs on
on aa disk,
disk, the
the computer
comp uter automatically
automatically makes
makes aa
When
^
table of contents,
contents, or
or aa DIRECTORY,
DIRECTORY, of the
the names
names of
of the
the programs
programs on
on the
the disk.
disk.
table
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
You
these steps:
steps:
these
-—i
1. Key
Key in:
in: LOAD
LOAD "$",8
"$",8 and press RETURN.
RETURN . The
Th e computer
computer displays
displays this
this
1.
message:
message:
<■
SEARCHING FOR $
m
LOADING
READY
READY
^
in: LIST and press RETURN
2. Key in:
ft
Your programs names are
are displayed on your
your screen.
Your
_
FILES
Th ere are two types of files that you
yo u can store:
There
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
pro·
2. DATA FILES,
a RECORD;
grams. A unit of a data file is called a
RECORD; each record can contain one
^
or
or more pieces of data.
There are three types of data files
files,, which differ in the way data records are
stored and accessed
accessed::
^
1.
FILES, which store data in records in the order you input the
1. SEQUENTIAL FILES,
't go
data. Data records are accessed sequentially,
sequentially, which means that you can
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
pOinter to any record relat
ive to the beginning of the file,
file, which means that
relative
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
des
ign. Unlike the other fil
e types,
design.
file
types, these files are not maintained by the disk
^
^
operat
ing sys
tem. You must design and maintain them yourself.
operating
system.
-
20
20
SEQUENTIAL FILES
SEQUENTIAL
FORMAT FOR
FOR OPENING
OPENING A SEQUENTIAL
SEQUENTIAL FILE:
FILE:
FORMAT
file#,, device#, cchannels.
OPEN file#
hannel#, "■'O:name.type,direction"
O:name,type,direction"
The
The file number
number is
is the same as in
in all your other applications of
of the OPEN
ram to refer
statement, and itit is
hout the prog
is used
used throug
throughout
program
refer to this particular
particular file.
The device# is
h 14.11
is usually
usually 8. The channel# is
is a data channel, number
number 2 throug
through
14. It
is convenient to use the same number
number for both
both the channel#
channel^ and file#
file#,, to keep
keep
is
them stra
ight. Th
e name
straight.
The
name is
is the file name
name (no wild cards or pattern
pattern matching
matching if
you're creating a write file). The type can be
be any of the ones from the chart
beiow. You can abbreviate by
by using the first letter (P, S, U,
U, R).
R). Th
The
below.
e direction
must
be
READ
or
WRITE.
You
can
use
just
the
first
letter
(R
or
W).
must be READ or
You can use
first
(R or W).
v
FILE TYPE
MEANING
PRG
SEQ
USR
REL
Program
Sequential
User
Relative
EXAM
PLES OF OPENI
NG SEQU
ENTI AL FILES:
EXAMPLES
OPENING
SEQUENTIAL
FILES:
8, 2,
2, "O:
"0:DATA,
S, W"
W
OPEN 2, 8,
DATA, S,
8, 8, 8,
8, "O:
"0:Program,
OPEN 8,
Program , P, R"
B, C,
C, "0:" + A$ +
OPEN A,
A, B,
"U, W"
"u,
exists, you can use the replace option in the OPEN state·
state
If the file already exists,
before
the
fi
le's
name
in
the
OPEN
statement.
ment. Simply add the @O:
@0:
file's
EXAMPLE OF SEQUENTIAL FILE WITH REPLACE OPTION:
OPTION :
8, 2,
2, "@
■'@0:DATA,S,WM
OPEN 2,
2,8,
O:DATA,S,W"
shou ld always precede the name
name of the fifile
le or the drive will only
only allow
al low
The 0: should
you to use 2
bu ffers.
2 of the available buffers.
AND READING FROM
FROM A
A SEQUENTIAL FILE
WRITING TO AND
PRINT#
PRINT# and
and INPUTS
INPUT# and GET#
GET#
The PRINTS
PRINT# command works exactly
exactly like
like the
the PRINT statement,
statement, except
except that
The
re·directed to
to the
the disk
disk drive. The
The reason
reason for the special emphasis
emphasis on
on
output is re-directed
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,
the
as applies
applies to
to punctuation
punctuation and
and data
data types,
types, applies
applies here
here too.
too. ItIt just
just means that
as
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 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
The
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
When using
using the
the PRINT#
PRINT# statement,
statement, ifif you
you use
use commas
commas (,)
(,) to
to separate
separate items
items
When
be separated
separated by
by some
some blank
blank spaces,
spaces, as
as ifif itit were
were be
bein the
the list,
list, the
the items
items will
will be
in
ing formatted
formatted for
for the
the screen.
screen. Semicolons
Semicolons (;)
(;) don't
don't result
res ult in
in any
any extra
extra spaces.
spaces.
ing
In order
order to
to more
more fully
fu lly understand
understand what's
what 's happening,
happening , here
here is
is aa diagram
diagram of
of aa se
seIn
quen tial file
file created
created by
by the
the statement
statement OPEN
OPEN 5,
5, 8.
8, 5,
5, "0:TEST,S,W":
" O:TEST,S,W":
quential
col
14
10
char
char
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
The
byte by
by byte,
byte, including
including spaces.
spaces.
byte
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" :
For
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$:
A$; B$;
BS; C$:
CS:
5,
..Jur
h.. ,
\ Il \ l I LI LIUI ' I L
H
[■
I.
1.
0
A
L
L
B
Y
b.
!
2
.1
i
5
6
7
U
'*
10
11
CR
eof
U
IJ
stands for the CHRS
CHRS code 13, the
the carriage return,
return, which is automatically
automatically
CR stands
PRINTed at the
com
the end of every PRINT or PRINT#
PRINT# statement unless there
there is aa com-
ma or
or semicolon at the end of the
the line.
line.
NOTE: Do not leave a space between PRINT and #,
NOTE:
#, and do not try to abbreviate
the command as ?#. See the appendixes in the user manual for the correct abab
breviat
ion.
breviation.
FOR
MAT FOR INPUT#
INPUT# STATEMENT:
FORMAT
STATEMENT:
INPUT#
file# , variable list
INPUTS file#,
When using IN
PUT# to read data, there is no way to tell that it's not supposed
INPUTS
to be one long string.
string. You need something in the file to act as a separator.
Charac
ters to use as separators include the CR, a comma or a semicolon.
Characters
semicolon. The
CR
CR can be added easily by just using one variable per line in the PRINT# statestate
ment, and the system puts one there automatically.
automatically. The statement PRINT#
PRINTS 5,
e being written
A$: PRINT#
PRINTS 5,
5, B$: PRINT#
PRINTS 5, C$ puts a CR after every variabl
variable
written,, propro
viding th
e proper separati
on for a statement like INPUT#5,
the
separation
INPUTS5, A$,
A$, B$, C$. A line like
ZS=
"," :PRINT# 5, A$Z$
AS Z$ B$
Z$ C$ wil
l, and in less space. The
Z$=",":PRINTS5.
BSZSCS
willl do the job as wel
well,
file after that line looks like this:
II
1
\.that
hll '
L
i
L
1
-
4
0
s
A
6
7
L
8
L
9
IU
B
Y
1.
II
12
U
CR
eol
14
IS
Putting commas between
between variab
variables
Putting
les results in lots of extra space on the disk
being
being used.
used. A statement like
like PRINT#
PRINTS 5,
5. A$, BS makes
makes a file that looks like:
di.hj[
lJf
H
b
1.
L
I
2
3
4
0
b
7
8
10
22
22
■\
L
L
CR
eol
12
13
i4
:j
24
Numeric
ncNumeric data
data written
written in
in the
the file takes
takes the form of a
a string
string,, as
as ifif the
the STR$ fu
func
had been
been performed
performed on
on itit before
before wri
writing
out. The first character
character wi
will
be a
a
ting it out.
ll be
tion had
space if
if the
the number
number is
is positive,
positive, and
and a
a minus sign
sign ((-)
number is
blank space
- ) ifif the number
negative.
number, and the last
last character
character is
is the cu
cursor
right
negati
ve. Then comes the number,
rsor right
format
information for the INPUT#
INPUTS statement
character. This fo
rmat provides enough information
to read them in as separate numbers
tten with no other spec
ial
numbers if several are
are wri
written
special
separators.
is somewhat wastef
wasteful
can
be two unused
unused
separat
ors. ItIt is
ul of space, since there ca
n be
characters ifif the numbers are positive.
v
Here is a picture
picture of the file after the statement PRINT#
PRINT#5,1;
perform
Here
5, t; 3; 5; 7 is performed:
CR
io
I2
euf
13
IS
v
GET#
The GET# retrieves data from the disk,
ter at a time.
disk, one charac
character
time.
STATEMENT:
FORMAT FOR THE GET# STATEM
ENT:
GET# file#,
file# , variable
variable list
Data comes in byte by byte, including
including the
the CR,
CR, comma,
comma, and other separating
characters.
state
charac
ters. It is much safer to use string variables when using the GET# statestring data is received where a
ment. You will get a BASIC error message if string
a
number was requ
requested,
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
is extremely
ex tremely useful
usefu l when
when examining files with unknown
unknown
The GET# statement is
an experimental program. It
contents, like aa file that
that may have
have been
been damaged
damaged by an
contents,
is safer than INPUT#
INPUT# because there
there is
is aa limit
limit to the number
number of
of characters
charac ters allow
al lowis
ed between
between separators
separators of
of INPUT
INPUT variables.
va ri ables. With
With GET#,
GET#, you
you receive every
every
ed
characte r, and
and you
you can
can examine
examine separators
separat ors as
as well as
as other
other data.
data.
character,
23
23
RELATIVE
RElATIVE FILES
FILES
FORMAT
FORM AT FOR
FOR THE
THE OPEN
OPEN STATEMENT
STATEMENT TO
TO CREATE
CREATE RELATIVE
RELATI VE FILE:
FILE:
OPEN
OPEN file#.
file# , device#,
device#, channel*,
channel#, "name.L,"
" name,L," ++ CHR$(record
CHR$(record length)
length)
**
EXAMPLES
EXAMPLES OF
OF OPEN
OPEN STATEMENT
STATEMENT CREATING
CREATING RELATIVE
RELATIVE FILES:
FILES:
OPEN
8, 2,
OPEN 2,2,8,
2, I*FILE,L1"
" FILE,L," ++ CHR$(100)
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 BLOCK
BLOCK
DATA
DEFINITION
DEFINITION
BYTE
BYTE
0,1
0,1
Track and
and sector
sector of
of next
next data
data block.
block.
Track
2- 256
2—256
254
254 bytes
bytes of
of data.
data. Empty
Empty records
records contain
contain FF
FF (all
(all binary ones) in
the
first
byte
followed
by
00
(binary
all
zeros)
to the end of the
the first byte foll owed by 00 (binary al l
record.
are padded with nulls (00).
(00).
record. Partially
Partially filled
filled records are
SIDE SECTOR
SECTOR BLOCK
BLOCK
SIDE
BYTE
BYTE
DEFINITION
0,1
0,1
Track and
and sector
sector of next side sector block.
Track
block.
22
Side sector
sector number.
number. (0-5)
Side
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
tor (number 4)
Track and sector of fifth side sec
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.
Upon execution
execution,, the DOS first checks to see
see if
if the file
file exists.
exists. IfIf it
it does,
does,
lat ive file
then nothing happens.
ly way to erase an
then
happens. The on
only
an old
old re
relative
file is
is by
by using
using the
the
SCRATCH
SCRATCH command
command,, but
but not
not by
by using
using the
the replace
replace option.
option.
24
24
FORMAT FOR
FOR OPENING
OPENING AN EXISTING
EXISTING RE
RELATIVE
FILE:
FORMAT
LATIVE FILE:
file#,, device#, channel#, "name"
"name"
OPEN file#
In
e. This syntax,
In this case, the DOS
DOS automatically knows that
that it
it is
is a relative fil
file.
and the one
low either reading
riti ng to
one shown in
in the above section
section,, both
both al
allow
reading or
or w
writing
file..
the file
In
In order to read or write, you must, before
before any operation, position the file
pointer to the correc
correctt record
record position.
position.
pOinter
Th
e position command is sent to the command channel (15), so you must
The
In the following example, 15
15
open an additional file for the command channel. In
is
is the file number of the command channel, and 8 is the file number of the
relative file.
relative
15,8,15
OPEN 15,8,
15
8,8.8
OPEN 8,8,8
FORMAT FOR POSITION COMMAND:
PRINT#file#, ""P"
CHR$(channel# + 96) CHR$(rec#lo) CHR$(rec#hi)
P" CHRS(channel#
PRINT#file#,
CHRS(position)
CHR$(position)
EXAMPLES
EXAM
PLES OF POSITION COMMAND:
v
PRINT#15,
P" CHR$(CH + 96) CHR$(R1
PRINT#15, ""P"
CHR$(R1)) CHR$(R2)
CHR${R2) CHR$(P)
CHR$(P)
PRINT#15, ""P"
P" CHR$(4 + 96) CHR$(R1
CHR$(R1)) CHR$(R2) CHR$(P)
CHR$(P)
v
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.
file_ The
hold 256 different numbers,
address, and the rec# hi is the
rec# 10
lo contains the least significant part of the address,
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)
'-'
v
REC# LO= REC#—REC#
REC#-REC# Hl'256
HI"256
EXAMPLE:
EXAM PLE:
PRINT#15, "P"
" P" CHR$(4 +
+ 96)
96) CHR$(R1)
CHRS(R1) CHR$(R2)
CH RS(R2) CHR$(0)
CH R$(O)
PRINT#15,
540: R2=
R2 = INT(540/256)
INT(5401256) ...
__ _so
so R2
R2 = 22
If REC# = 540:
R1 = 540-R2"256 .. .__. so
so R1=28
R1 = 28
R1=540—R2*256
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
according
cording to
to this
this chart:
chart:
Field
Field Name
Name
Length
Length
first
first name
name
12
12
state
state
zip code
code
zip
phone number
number
phone
last
last name
name
15
15
address
add ress line
line 11
20
20
address
address line
line 22
city
city
20
20
-
12
12
TOTAL
TOTAL
v
25
25
22
g9
10
10
--- -- 100
100
This
This isis how
how the
the record
record length
length isis determined.
determined. We
We would
would probably
probably want
want toto
allowan
an extra
extracharacter
characterininlength
length for
foreach
eachfield,
field ,to
toallow
allowfor
forseparations;
separa tions;other
other·
allow
wise
INPUT# command
command would
would pick
pick up
up aa much
much longer
longer piece
piece of
of the
the file
file than
than
wise the
the INPUT#
needed ,just
just like
like inin sequential
sequential files.
files .Therefore,
Therefore,we'll
we'll set
set up
upaafile
file with
with aalength
lengthof
of
needed,
108 characters
characters per
per record.
record.
108
When working
working with
with aa new
new relative
relative file
file that
that will
will soon
soon be
be very
very large,
large,itit will
will save
save
When
much
much time
time to
to create
create aa record
record at
at the
the projected
projected end
end of
of the
the file.
file. InIn other
other words,
words, ifif
you
expect
the
file
to
be
1000
records
long,
creat
e
a
rec
ord#
1000
as
soon
as the
the
you expect the file to be 1000 records long, create a record# 1000 as soon as
file
DOS to
to create
create all
all intermediate
intermediate records,
records, mak
makfile isis created.
created. This
This will
will force
force the
the DOS
ing later
later use
use of
of those
those records
records much
much faster.
faster.
ing
EXAMPLE OF
OF CREATING
CR EATING LARGE
LARG E FILE:
FILE:
EXAMPLE
OPEN 1,8,
1,8, 15:
15: OPEN
OPEN 2,2,8,
2, "0:REL,L,"
"0:REL,L," +CHR$(60)
+CHR$(60)
OPEN
8,2,
PRINT#l , "P"
"P" CHR$(2+96)
CHR$(2 + 96) CHR$(0)
CHR$(O) CHR$(4)
CHR$(4) CHR$(1)
CHR$(l)
PRINT#1,
PRINT#2, "END"
" END"
PRINT#2,
CLOSE 2:
2: CLOSE
CLOSE 11
CLOSE
FILES, OR USER
USER FILES
FILES
RANDOM FILES,
Random files
files let you access
access and
and update
update each
each of
of the individual
individual 256-byte
256·byte
Random
blocks of
of data
data stored
stored on
on the disk.
disk. As was mentioned
mentioned in
in the first chapter,
chapter, there
blocks
a total of
of 683
683 blocks on
on the diskette, of which 664
664 are
are free on
on aa blank
blank
are a
Each block
block of data really means
means 11 Track and
and sector of the
the same
same name.
name.
diskette. Each
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
diskette is
tracks, starting with track 11 at
the surface of the diskette. There are 35 different tracks,
the
center. Track 18 is used for the
the outside of the diskette to
to track 35 at the
the center.
directory,
directory, and the DOS fills up the diskette from the center outward.
ivided into sectors. Because there is more room on the
Each track is subd
subdivided
outer tracks, there are more sectors there. The outer tracks contain 21 sectors
each, while the inner ones only have 17 blocks each.
each. The table below shows the
numbe
numberr of
of sectors pe
perr track.
Track and Block
Block Format
Format
TRACK NUMBE
R
NUMBER
RANGE
SECTOR RANG
E
TOTAL BLOCKS
BLOCKS
TOTAL
11 to 17
17
18
24
18 to 24
25
25 to
to 30
30
31
31 to
to 35
35
20
o0 to 20
18
o0 toto 18
o0 toto 17
17
16
o0 toto 16
21
21
19
19
18
18
17
17
The DOS
DOS contains
contains commands
commands for
for read
reading
and writing
writing directly
directly to
to any
any track
track
The
ing and
and sector
sector on
on the
the diskette.
diskette. There
There are
are also
also commands
commands for
for checking
checking to
to see
see which
which
and
blocks
blocks (tracks
(tracks && sectors)
sectors) are
are available,
available, and
and for
for marking
marking off
off used
used blocks.
blocks.
NOTE: You
You must
must be
be sure
sure to
to mai
maintain
this
information, especially
especially when
when there
there are
are
NOTE:
ntain th
is information,
other types
types of
of files
files on
on the
the disk.
disk. Fail
Failure
to do
do so
so cou
could
corrupt other
other files
files..
other
ure to
ld corrupt
These
These commands
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
15), and tell the disk what to do with the data. The data must be read later
later
through
through one
one of
of the
the open
open data
data channels.
channels.
26
26
OPENING AA DATA
DATA CHANNEL
CHANNEL FOR
FOR RANDOM
RANDOM ACCESS
ACCESS
OPENING
When working
working with
with random
rand om access
access files,
files, you
you need
need to
to have
have 22 channels
channels open
open
When
to the
the disk:
disk: one
one for
for the
the commands,
commands, and
and the
the other
other for
for the
the data.
data. The
The command
command
to
channe l is
is OPENed
OPENed to
to channel
channel 15,
15, just
just like
like other
other disk
disk commands
commands you've
you 've en
en·
channel
countered so
so far.
far. The
The data
data channel
channel for
for random
random access
access files
files is
is OPENed
OPENed by
by selec
selec·
countered
ting the
the pound
pound sign
sign (#)
(#) as
as the
the file
file name.
name. The
The ## sign
sign represents
represents the
the buffer
buffer
ting
number
(1·5)
where
"#"
defaults
to
the
next
available
buffer.
number (1-5) where "#" defaults to the next available buffer.
FORMAT
FORMAT FOR
FOR OPEN
OPEN STATEMENT
STATEM ENT FOR
FOR RANDOM
RANDOM ACCESS
ACCESS DATA:
DATA:
OPEN file*,
file#, device#,
device#, channel*,
channel#, "#"
" #"
OPEN
or
or
OPEN file#,
file# , device#,
device#, channel*,
channel#, "#buffer#"
" #buffer#"
OPEN
v
EXAMPLES OF
OF OPENING
OPENING RANDOM
RANDOM ACCESS
ACCESS DATA
DATA CHANNEL:
CHANNEL:
EXAMPLES
OPEN 5,
5, 8,
8, 5,
5, "#"
" #"
OPEN
OPEN A,
A, B,
B, C,
C, "#2"
OPEN
BLOCK·READ
BLOCK-READ
FORMAT FOR BLOCK-READ
BLOCK·READ COMMAND:
COMMAND:
PRINT#file#, "BLOCK-READ:"
" BLOCK·READ:" channel;
channel; drive; track;
track; sector
PRINT#file#,
or abbreviated
abbreviated as
as
or
PRINT#file#, "B-R:"
" B·R:" channel; drive; track; sector
sector
PRINT#file#,
command will move one block of data from the diskette into the
This command
selected channel. Once this operation has been performed, the INPUTS
INPUT# and
GET# statements can read the information.
BLOCK-WRITE
BLOCK-WRITE
The BLOCK·WRITE
BLOCK-WRITE command is the exact oppOSite
opposite of the BLOCK·READ
BLOCK-READ
command. First you must fill up a data buffer wi
th your informati
on , then you
with
information,
write that buffer to the correct location on the disk.
FORMAT FOR BLOCK-WRITE COMMAND:
PRINT#file#,
BLOCK-WRITE:" channel; drive; track; sector
PRINT#file#, ""BLOCK-WRITE:"
or abbreviated as
PRINT#filefl
B·W:" channel; drive; track; sector
PRINT#filelf,, ""B-W:"
v
v
When the data is
is being put
put into
into the buffer,
buffer, a pOinter
pointer in
in the DOS
DOS keeps track
of how
how many
many characters there are. When you perform
perform the BLOCK·WRITE
BLOCK-WRITE opera·
opera
tion, that pOinter
pointer is
is recorded
recorded on the disk.
v
27
27
BLOCK-ALLOCATE
BLOC K·ALLOCATE
In
random
files
along with
with regular
regular files
files,, your
your programs
programs
ndom fil
es along
In order
order to
to safely
safely use
use ra
must
check
the
BAM
(Block
Availability
Map)
to
find
available
blocks,
and
must check the BAM (Block Availabil ity Map) to find available blocks, and
change
the
BAM
to
reflect
that
you've
used
them.
Once
you
update
the
BAM,
change the BAM to reflect that you've used them. Once you update the BAM,
your
command.
your random
random files
files will
will be safe -— unless you perform the VALIDATE command.
FORMAT
FOR THE
BLOCK-ALLOCATE COMMAND:
COMMAND:
FORMAT FOR
THE BLOCK·ALLOCATE
PRINT#file#,
track; sector
PRINT#file#, "BLOCK-ALLOCATE:"
"BLOCK·ALLOCATE:" drive;
drive; track;
If
error message to
to
If you
yo u try
try aa block
block that
that isn't available,
available, the DOS will set the error
number 65,
block
next
65, NO BLOCK,
BLOCK, and set the track and bl
ock numbers to the next
available
block
Therefore, any time you attempt to write aa
available track and bl
ock number. Therefore,
block
block to
to the disk,
diSk, you must first try to allocate that block. If that block isn't
available,
channell and the
then
n allocate
available, read the next block available from the error channe
that
that block.
bl ock.
BLOCK-FREE
BLOCK·FREE
The
BLOCK-ALLOCATE, in that itit
The BLOCK-FREE
BLOCK·FREE command
com mand is the opposite of BLOCK·ALLOCATE,
frees
system.
is
frees aa block
bl ock that you
you don't
don't want to use anymore for use by the sys
tem. ItIt is
vaguely
vaguely similar
si milar to the
the SCRATCH
SCRATCH command for files,
files, since it doesn't really erase
any
entry, in this case just in the BAM
BAM..
disk —
- just
just frees the entry,
any data
data from the disk
FORMAT
FORMAT FOR BLOCK-FREE
BLOCK·FREE COMMAND:
PRINT#file#,
" BLOCK·FREE:" drive;
drive; track; sector
PRINT#file#, "BLOCK-FREE:"
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 most
most common
common method
method for keeping track of which bl
ocks on the disk you
The
blocks
bu ild up
up aa sequential file to go with each
each random fil
e. Use this file to
used , is
is to
to build
used,
file.
list of
of record,
record, track,
track, and sector locations. This
Thi s means that there are 3
keep aa list
keep
channe ls open
open to
to the
the disk
disk for
for each
each random
ran dom file:
fil e: one for the com
mand channel
channels
command
channel,,
one for
for the
the random
random data,
data, and
and the
the other for the sequential
seq uential data.
s also means
one
data. Thi
This
filling up at the same time.
that there
there are
are 22 buffers
buffers that
that you're filling
that
time.
28
28
0
"
v
BUFFER-POINTER
BUFFER·POINTER
pointer keeps track of where the last piece of data was wri
written.
tten. It
The buffer painter
also is the painter
pointer for where the next piece of data is to be read. By changing
pointer's location within the buffer,
buffer, yo
you
u can get random access to the
the buffer painter's
individual bytes within a block. This way, you can subdivide each block into
records.
For example,
's take a hypotheti
cal mai
ling list. The information such as
example, let
let's
hypothetical
mailing
name,
ld
name, address,
address, etc.,
etc., will take up a total of 64 characters maximum. We cou
could
records,, and by
divide each block of the random access file into 4 separate records
track, sector,
sector, and record numbers, we can access that indivi
individual
knowing the track,
dual
record.
FORMAT FOR BUFFER·POINTER
BUFFER-POINTER COM
COMMAND:
MAND:
PRINT#fil
e# , ""BUFFER-POINTER:"
BUFFE R-POINTER:" channel;
PRINT#file#,
channel; location
or abbreviated as
PRINT#file#, ""B-P:"
channel;; location
PRINT#file#,
B-P:" channel
v
EXAMPLE OF SETIING
SETTING POINTER
POINTER TO 64TH CHARACTE
CHARACTER
EXAMPLE
R OF BUFFER:
BUFFE R:
PRINT# 15,
15, ""B-P:"
5; 64
B·P:" 5;
USER1 and USER2
USER2
The user commands are general
ly designed to work with machine language
generally
USER 1 and USER2
US ER2 commands are
are
(see the next chapter for more on this). The USER1
EAD and BLOCK-WRITE
special versions of the BLOCK-R
BLOCK-READ
BLOCK-WRITE commands, but ...
with an important difference: the way USER1
bufferUSER1 and USER2 work with the buffer·
v
pointer.
pOinter.
BLOCK·READ command reads up to 256 characte
rs, but slops
stops reading
The BLOCK-READ
characters,
buffer,pointer stored with the block says that block
bl ock is finished.
fin ished. The
when the buffer-pointer
command performs
performs the BLOCK-READ
BLOC K·RE AD operation, but
USER1 command
but first forces the
pointer to 255 in order to read the entire block of data from the disk.
painter
disk.
v
FORMAT FOR USER1
USER1 COMMAND
" U1 :" channel;
channel; drive;
drive; track;
track; sector
sec tor
PRINT#file#, "U1:"
PRINT#file#,
or
or
v
"UA:" channel; drive;
dri ve; track; sector
sec tor
PRINT#file#, "UA:"
PRiNT#file#,
U1 and UA designations for this com
comno difference
difference between
between the U1
There is no
v
mand.
mand.
The BLOCK-WRITE
BLOCK-WRITE command writes the contents of the buffer to the block
block
The
on the disk
disk along with the value of
of the buffer-pointer.
buffer,pointer. The USER2 command
on
writes
without disturbing
disturbing the buffer-pointer
buffer-painter value
value already
already stored
stored on
on
writes the buffer
buffer without
that block of
of the diskette.
diskette. This
This is
is useful
useful when aa block is to be read in
in with
with
that
BLOCK-READ,
BU FF ER·POINTER and
and PRINT#
PR INT#
BLOCK·READ, updated
updated through the BUFFER-POINTER
statements,
statements, and
and then
then written
written back
back to
to the
the diskette with
with USER2.
FORMAT FOR
FOR USER2
USER2 COMMAND:
COM MAND:
FORMAT
PRINT#file# , "U2:"
" U2:" channel;
channe l; drive;
drive; track;
track; sector
sector
PR)NT#file#,
v
or
or
PRINT#file#.
PRINT#file#, "UB:"
" UB:" channel:
channel ; drive;
drive; track;
track; sector
sector
29
29
v
CHART OF
OF BASIC
BASIC COMMANDS
COMMANDS FOR
FOR DISKS
DISKS AND
AND PRINTERS
PRINTERS
CHART
This chart
chart lists
lisls the
Ihe BASIC
BASIC commands
commands and
and statements
slalemenls that
that are
are used
used to
to per
perThis
form operations
operations with
with disk
disk drives.
drives. Commands
Commands marked
marked with
with aa "• sign
sign can
can also
also be
be
form
used to
to direct
direct output
output to
to printers
printers when
when you
you use
use the
the printer
printer device
device number,
number. which
which
used
4. Disk
Disk Operating
Operating Systems
Systems (DOS)
(DOS) error
error messages
messages are
are described
described in
in Appendix
Appendix
is 4.
is
B.
B.
Command Function
Function
Command
Examples
Examples
CLOSE'■
CLOSE
CLOSE 11
CLOSE
Ends file
file or
or
Ends
closes channel
to aa device
device
to
closes
closes file
file 1,
1. which
which
must
must have
have been
been
previously OPENed
OPENed
previously
with
with the
the same
same
number
number
CMD'■
CMD
GET#
GET#
Redirects output
output
Redirects
from screen
screen to
to
from
OPEN
OPEN 1,8,'1SCOTT"
1.8."SCOn"
file
file must
must be
be OPENed
OPENed
device named
named
device
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
OPEN
OPEN 1,8,"SCOTT"
1.8."SCOn"
GET# 1,A$
1.A$
OPENs
OPENs file 11 on disk.
reads from
from file 1;
1;
Reads characters
one by one from
first
first
assigns data to A$
device named in
LOAD
OPEN statement
GET# 1,A,B,C
1.A.B.C
reads from file 1;
1;
A.
assigns data to A,
B, then C
C then
then B.
etc.
back to A,
A. etc.
Brings programs
into current
memory from disk
.. ·.8
LOAD .."*",8
1st
loads 1
st program
on disk
loads file SCM from
disk
loads file directory
{key
(key in LIST to
display)
LOAD ""SCM",8
SCM " .8
LOAD "$".8
"$",8
15,8,15,"!"
INITIALIZE Returns drive to the OPEN 15.8.15."1"
same state as when
you turned it on.
Use when error
prevents disk
operations.
OPENs command
channel (15). When
command channel is
OPEN,. the
OPEN
INITIALIZE command
device
is sent to the device
named (the disk
named
drive, device 8).
drive.
INPUT#
1NPUT#
Retrieves
Retrieves data
stored on disk
1,8,"MEYER"
OPEN 1.8."MEYER"
INPUT# 1.A.B
1,A,B
INPUT#
OPENs file 11 on disk
reads data.
data, assigns
reads
to
variables
A and
and B
B
to variables A
NEW
NEW
Headers
Headers diskette.
Also erases
diskette.
15,8.15"N0:
OPEN 15.8.15"
NO:
SCM.01"
OPENs file SCM. NO
means NEW
NEW disk in
means
drive
0.
SCM is
is the
the
drive O. SCM
name of
of the disk. 01
name
is
is the disk
disk id.
30
v
_
v
OPEN *
OPEN·
Opens channel for
input or output
to a peripheral
1,8,8,"D,W""
OPEN 1,8,8,"D,W
OPEN 1,4
1,8.0
OPEN 1,8,0
PRINT# *•
Writes data to a
file
OPEN 1,B,8,"SCM"
1,8,8,"SCM"
OPEN
PRINT#
A" ;" B"
PRINTS 1,"
1,"A";"B"
1
CLOSE 1
v
RENAME
RENAM
E Changes a file
name.
v
SAVE
Stores program
SCRATCH Erase files from
from
disk
OPEN 15,8,15,"R:
new
name = old
newname
name"
15,8,15,-R:
OPEN 15,8,15,"R:
SCM=
SCM = MEYER"
Compares program
program
Compares
in current
current memory
to
program
to stored program
RENAM
Es fifile
le 15.
RENAMES
RENAMEs
RENAMES file
MEY
ER, changing it
MEYER,
to SCM
stores file
fi le SCM on
disk
OPEN
OPEN 15,8,15"S:
GMS"
OP
EN 15,8,15"S:
OPEN
Erases file GMS
M*
"
M*"
start with M.
OPEN
15,8,15," V"
OPEN 15,8,15,"V"
Collects blocks
15,8,15,
OPEN 15,8,15,
taken up by
by
"VALIDATE"
improperly CLOSEd
fil es. Do not use
files.
with Random
Ran dom
Access
Access (User)
(User) Files.
Files.
VERIFY
VERIFY
opens disk file 11 to
write
B to
writes A and B
file 1
1
writi ng to file 1
ends writing
1
SAVE ""SCM",8
SCM",8
VALIDATE Reorganizes disk.
v
opens file D on disk.
W means write to
file
file.. 8 is the
secondary address,
required for disk. See
Appendix S.
opens channel to
printer
prin
ter
opens file 11 to read
from disk
Erases all files that
15.
Validates file 15.
le 15.
15.
Validates fi
file
SAVE "SM",8
"SM",8
SAVE
puts current program
puts
" SM" ,8
VERIFY "SM",8
on disk
SAV Ed
compares SAVEd
vers ion of
of SM
SM with
with
version
versio n still
sti ll in
in cur
cur·
version
rent memory
memory to
to verify
rent
program
correct program
storage
storage
Appendix S
S and
and the
the Commodore
Commodore 64
64 Programmer's
Programmer's Reference
Reference Guide
Gu ide contain
contain
Appendix
more information
information about
about these BASIC
BASIC commands and
and statements.
statements.
more
The 64 Programmer's
Programmer's Reference
Reference Guide
Guide explains
explains all
all BASIC
BASIC version
vers ion 2.0
2.0 com
com·
The
v
mands and
and statements.
sta tement s. The
The Commodore
Commodore Peripheral
Peripheral Guide
Guide contains
conta ins more
more
mands
detail ed information
information and
and sample
sample programs
programs for
for using
using disk
disk drives
drives and
and printers.
pri nters.
detailed
There books
books are
are available
available at
at bookstores
bookstores and
and from
from your
yo ur Commodore
Commodore dealer.
dealer.
There
31
31
-
n
n
—
—
-
—■
—■
-
n
—
CHAPTER 33
CHAPTER
BEGINNING BASIC
BASIC
BEGINNING
••
Printing and
and Calculating
Calculating
Printing
••
Mathematical Functions
Functions
Mathematical
••
Multiple Calculations
Calculations On
On One
One Line
line
Multiple
•
Execution Order
Order in
in Calculations
Calculations
Execution
••
Combini ng PRINT'S
PRINT's Capabilities
Capabilities
Combining
PRINTING AND CALCULATING
CALCULATING
PRINTING
If you
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
If
things like
like print
print words
words and
and calculate
calculate problems.
problems.
things
64 computer
computer to
to print
print something
something on
on the
the screen.
screen.
The PRINT statement tells
tells the
the 64
The
PRINT is
is one
one of
of the
the most useful
useful and
and powerful
powerful commands in
in the
the BASIC
BASIC
PRINT
language. You
You can
can use itit to
to display
display just
just about anything,
anything, including graphics
graphics and
and
language.
the results of computations.
computations. To
To use
use the PRINT
PRINT command,
command , follow these steps:
the
1. Key in
in the word
word PRINT.
PRINT. This
This tells the
the computer what kind of job
job you want
want it
1.
do.
to do.
a quotation
quotation mark.
mark. This tells
tel ls the
the computer
computer where the message you
you
2. Key in a
want to print begins.
in whatever you want to print on the
the screen.
3. Key in
4. Key in a closing quotation mark. This tells the computer where the message
you want to print ends.
you
Thi s tells the computer to follow your instructions,
5. Press the RETURN key.
key. This
which in this case is to print your message exactly as you typed it.
When you follow these steps,
steps, the computer prints your message and
pt. It looks lilike
ke this:
displays the READY prom
prompt.
PRINT ""II LOVE
LOVE MY COMMODORE"
You key in this and press RETURN
LOVE MY COMMODORE
II LOVE
READY
The computer prints this
Th
e Executive 64 prints whatever you enclosed in quotes. Remember to key
The
in both quotation marks.
use the INSTfDEL
INST/DEL key to corcor
If you make a mistake in your PRINT statement, use
rect your error. You
You can change as many characters as you like
like before you press
the RETURN key.
If you made a mistake
't catch before you pressed the RETURN
mistake that you didn
didn't
key, the computer can't follow your instructions. Instead,
Instead, it displays an error
message to help
help you figure out what you did wrong. For example:
?SYNTAX
7SYNTAX ERROR
ERROR
IfIf you get this message,
message, check over what you typed in to see where you made
a mistake.
The
computer
is
't follow in
stru ct ions that
mistake.
is very precise,
precise, and it can
can't
instructions
contain
stakes, be
contain spelling errors or other mistakes.
mistakes. To avoid mi
mistakes,
be sure you type
things in
in the correct form.
Remember
at the best
Remember th
that
best way to get
get to know
know BASIC
BASIC and
and your 64
64 is
is to try difdif
ferent things and see what happens.
happens.
32
v
v
USING PRINT
PRINT TO
TO CALCULATE
CALCULATE
USING
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
to perform
perform calculations
calcu lations and
and automatically
automatically display
display
marks. You
You can
can also
also use
use itit to
marks.
th e results.
results. Follow
Follow these
these steps:
steps:
the
1. Key
Key in
in PRINT
PRINT
1.
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
2.
marks.
marks.
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
3.
READY prompt.
prompt.
READY
v
Here's an
an example:
example:
Here's
PRINT 12
12 +
+ 12
12
PRINT
v
v
v
u
READY
READY
The computer
comp uter displays
displays
The
■
the answer
answer
the
•
Be sure you
you leave off the
the quotation
quotation marks when
when you
you want
want the computer
computer to
to
Be
problem. If you type the
the problem
problem inside quotation
quotation marks,
marks, the
the computer
computer
solve aa problem.
solve
you just
just want
want to
to display
display the
the problem, not solve it. For example:
assumes you
" 12 +
+ 12"
PRINT "12
12 +
+ 12
12
12
in this
this line
Key in
and press RETURN
RETURN
and
READY
READY
The computer displays
displays
■
what 's in
in quotes
what's
•
v
Type this
this line
line and
and press
press RETURN
RETURN
Type
24
24
So all you have to do to use PRINT as a calculator is omit the quotation
multiply and divide.
divide. You can also
marks. You can use PRINT to add,
add, subtract, multiply
figu rin g
use exponents and perform advanced mathematical functions such as figuring
square roots.
MATHEMATICAL FUNCTIONS
ADDITION
Use the plus sign (+)
( + ) to tell the computer to add numbers.
numbers. Remember to
press RETURN after you type PRINT and the calculation. Thi
s tells the comThis
com
puter to follow your instructions.
SUBTRACTION
Use the minus
RN key at th
e end of the
minus sign (-) to subtract. Press the RETU
RETURN
the
calculation. For example:
PRINT 12
- 9
12-9
3
Key in
in this and RETURN
RETURN
The computer displays thi
s
this
MULTIPLICATION
MULTIPLICATION
u
Use
* ) to multiply.
't use
Use the asterisk ((*)
multiply. You can
can't
use the conventional x because
because
the computer would think it's
it's the letter
letter x, not
not the multiplication
multiplication sign. Press
Press
RETURN
lculation. For
RETURN at the end of the ca
calculation.
For example:
PRINT
PRINT 12
12
144
144
**
12
12
Key
Key in
in this and RETURN
RETURN
The
ter displays this
The compu
computer
33
33
-
DIVISION
DIVISION
Use
n. Press
Use the
the slash mark
mark (~
(/) for divisio
division.
Press the
the RETURN
RETURN key
key after you
you type
type the
the
calculation. For
For example:
calculation.
,—,
PRINT 144/12
144/12
PRINT
12
12
Key in
in this and RETURN
RETURN
Key
The computer displays this
EXPONENTIATION
EXP
ONENTIATION
t )) to raise a number
Use
Use the up arrow ((t
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
248832
Key in this and RETURN
RETURN
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
breviating BASIC keywords.
keywords. For example,
example, you can use a ?? in place of PRINT.
Throughout this book,
'll show you other abbreviations for BASIC
book, we
we'll
BASIC keywords.
Appendix D
D lists these abbreviations and shows what is displayed on the
form..
screen when you type the abbreviated form
-
"
~-
34
34
v
v
MULTIPLE CALCULATIONS ON ONE LINE
The last example shows that you can perform more than one calculation on a
line. For
line. You can also perform different kinds of calculations on the same line.
example:
? 3 "5* 5 _ 7+2
7 + 2
?3
10
v
v
v
Key in this and RETURN
The computer displays this
So far our examples have used small numbers and simple problems. But the
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
can't use commas this way in BASIC.
BASIC. BASIC thinks commas indicate new
numbers,
o numbers:
numbers, so it would think 78,956.87
78.956.87 is tw
two
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
The next example
example uses a ten digit number. The 64 can work with numbers
its, but can only display nine digits in the answer. So the
that have up to ten dig
digits,
64 rounds numbers that are more than nine digits. Numbers five and over are
v
v
v
rounded up,
up, and numbers four and under are rounded down. This means that
12123123.5. Because of rounding,
rounding, the computer
12123123.45 is rounded to 12123123.5.
doesn't give the same answer you'd get if you added these numbers by hand. In
unding
this case,
case, the answer is 12131364.817. You can see the difference ro
rounding
makes.
makes.
?
? 12123123.45
12123123.45 + 345.78 + 7895.687
12131364.9
The
nota
The 64 prints
pri nts numbers between 0.01
0.01 and
and 999,999,999 using standard nota·
tion , except for leaving out
out commas in large numbers.
numbers. Numbers outside this
tion,
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
v
?123000000000000000
? 123000000000000000
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
sciennotation for
for numbers with lots of digits
digits to
to make them easier to read.
read.
tific notation
There
There is
is a limit to
to the numbers
numbers the
the computer
computer can handle,
hand le, even
even using scien
scien·
v
v
tific notation.
notation. These
The se limits are:
tific
Largest numbers: +/- 1.70141183E
1.70 141183E+38
Largest
+ 38
Smallest numbers:
numbers: +/+ / - 2.93873588E-39
2.93873588E - 39
v
35
35
EXECUTION ORDER
ORDER IN
IN CALCULATIONS
CALCULATIONS
EXECUTION
you tried
tried to
to perform
perform some
some mixed
mixed calculations
calculations of
of your
your own,
own , you
you might
might not
not
IfIf you
have gotten
gotten the
the results
results you
you expected.
expected. This
This is
is because
because the
the computer
computer performs
performs
have
calculations in
in aa certain
certain order.
order.
calculations
In this
this calculation:
calculation:
In
20 ++ 8/2
8/2
20
the answer
answer is
is 14
14 ifif you
you add
add 20
20 to
to 88 first,
fi rst, and
and then
then divide
divide 28
28 by
by 4.4. But
But the
the answer
answer
the
24 ifif you
you first
first divide
divide 88 by
by 2,
2, and
and then
then add
add 20
20 and
and 4.
4.
is 24
is
On the
the 64,
64, you
you always
always get
get 24
24 because
because the
the computer
computer always
always performs
performs calcula
calcula·
On
tions in
in the
the same
same order.
order. Problems
Problems are
are solved
solved from
from left
left to
to right,
right, but
but within
within that
that
tions
general movement,
movement, some
some types
types of
of calculations
calc ulations take
take precedence
precedence over
over others.
others.
general
Here is
is the
the order
order of
of precedence:
precedence:
Here
First:
First:
-
minus
minus sign
sign for
for negative
negative numbers,
numbers, not
not for
for subtraction.
subtraction.
Second:
Second:
tt
exponentiation, left
left to
to right
right
exponentiation,
Third:
Third:
"I
*/
multiplication and
and division,
division, left
left to
to right
right
multiplication
Fourth:
Fourth:
+
+ --
addition and
and subtraction,
subtraction, left
left to
to right
right
addition
This
This means
means that
that the
the computer
computer checks
checks the
the whole
whole calculation
calculation for
for negative
negat ive
numbers before
before doing
dOing anything
anythi ng else.
else. Then
Then itit looks
looks for
for exponents;
exponents; then
then it per
per·
numbers
forms all
al l multiplication
multi plication and
and division;
division; then
then itit adds
adds and
and subtracts.
subtracts.
forms
20 +
+ 88 /1 22 is 24:
24: 88 is
is divided
divided by
by 22 before
before 20
20 is
is added
added
This explains why
why 20
This
because division
division has
has precedence
precedence over
over addition.
addition.
because
There is
is an
an easy way to
to override the order
order of
of precedence: enclose any
There
calcu
lation you want solved first
firs t in
in parentheses. IfIf you add parentheses to the
calculation
equation shown
shown above,
above, here's what happens:
?(20+8)/2
? (20 + 8) / 2
14
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
30 + 15 " (2 -- 3)
15
??(30
(30 + 15)"
15) * (2 -- 3)
-45
The last
lations in
last example has
has two calcu
calculations
in parentheses.
parentheses. As usual,
usual, they're
evaluated from left
left to right,
right, and then the rest
rest of
of the problem
problem is
is solved.
solved. When
you have
ation in
theses, you can
trol the
have more
more than one
one calcul
calculation
in paren
parentheses,
can furthe
furtherr con
control
order
n parentheses.
order by
by using parentheses
parentheses withi
within
parentheses. The problem
problem in
in the
the innermost
innermost
parentheses
rst. For
parentheses is
is solved
solved fifirst.
For example:
example:
?? 30
30 +
+ (15
(15 "' (2
(2 -- 3))
3))
15
15
In
In this
this case,
case, 33 is
is 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
to 30.
30. As
As you
you experiment
experiment wi
with
solving calculations,
calculations, you'll
you'll get
get fami
familiar
th solving
liar
added
with
ions are
with the
the order
order in
in which
which mixed
mixed calculat
calculations
are solved.
solved.
36
36
COMBINING PRINT'S
PRINT'S CAPABILITIES
CAPABILITIES
COMBINING
v
v
'-'
'-'
The
The 64
64 computers
computers let
let you
you combine
combine the
the two
two types
types of
of print
print statements
statements that
that
in quota
quotayou've read
read about
about in
in this
this book.
book. Remember
Remember that
that anything
anything you
you enclose
enclose in
you've
tion marks
marks isis displayed
disp layed exactly
exactly as
as you
you type
type it.
it.
tion
The next
next example
example shows
shows how
how you
you can
can combine
combine the
the types
types of
of PRINT
PRINT
The
statements. The
The equation
equation enclosed
enclosed in
in quotes
quotes is
is displayed
displayed without
without being
being solved.
solved.
statements.
The
The equation
equation not
not in
in quotes
quotes isis solved.
solved. The
The semicolon
semicolon separates
separates the
the two
two parts
parts of
of
the PRINT
PRINT statement
statement {semicolon
(semicolon means
means no
no space).
space).
the
" 5 *• 99 == ";
"; 55 *• 99
?? "5
You key
key in
in this
this and
and RETURN
RETURN
You
55 •• g9 =
= 45
45
The
The computer
computer displays
displays this
this
Remember, only
only the
the second
second part
part of
of the
the statement
statement actually
actually solves
solves the
the calcula
calcu laRemember,
tion. The
The two
two parts
parts are
are separated
separated by
by aa semicolon.
semicolon. You
You always
always have
have to
to separate
separate
tion.
PRINT statement
statement with
with some
some punctuation
punctuation for
for itit to
to work
work the
the
the parts
parts of
of aa mixed
mixed PRINT
the
way you
you want
want itit to.
to. IfIf you
you use
use aa comma
comma instead
instead of
of aa semicolon,
semicolon, there
there is
is more
more
way
space between
between the
the two
two parts
parts when they're
they're displayed.
displayed. A
A semicolon
semicolon leaves
leaves out
out
space
v
space.
The
The Executive
Exec utive 64's
64's screen
screen is
is organized
organized into
into 44 zones
zones of
of 10
10 columns
columns each.
each.
When
you
use
a
comma
to
separate
parts
of
a
PRINT
statement,
the
comma
When you use a comma to separate parts of a PR INT statement, the comma
tab, sending
sending each
each result into
into the
the next
next zone.
zone. For
For example:
example:
works as a tab,
space.
?" total: " ;95,"shortage: "; 15
?"total:";95,'lshortage:";15
total:95
total:95
shortage:15
shortage:15
If you have more than four results,
results, they are automatically displayed on the
next line. For example:
?? 2 • 3,4 -- 6,2
3,6 f 4,100 + (48)
6,2 t13,6/4,100
(-48)
'-'
6
6
52
--22
8
8
0.5
[1.5
Here's the difference when you use semicolons:
semicolons:
v
? 2 '* 3;4
3:4 -- 6;2 ,t 3;6
3:6 f/ 4;100
4:100 + (- 48)
6
- 2 8 1.5
6-2
1.5 52
You can use
use the difference between
between the comma and the semicolon in
in formatformat
ting PRINT
PRINT statements to create complex displays.
37
37
-
n
-
-
-
CHAPTER 4
WRITING SIMPLE PROGRAMS IN BASIC
•
Numbers
Line Nu
mbers
• The GOTO Statement
• Using the LIST Command
•
Editing Tips
•
How to Use Variables
• Using FOR.
.. NEXT Loops
FOR...NEXT
n
So far this book has shown yo
u how to do simple things with your 64. You
've
you
You've
experim
ented with typ
in g si
ngle lines of in
structions into your comput
er and
experimented
typing
single
instructions
computer
getting instant results by pressing the RETURN key. This easy way of doing
things on you
yourr computer is called the IMMEDIATE or CALCULATOR mode.
But you
'll probably want to use your computer to do more complex jobs that
you'll
use more than one statement. When you combin
e a number of statements into
combine
a PROGRAM,
PROGRAM, you can use the fu
fullll power of your 64.
To see how easy it is to write your
you r first
fi rst prog
ram on the
Ihe 64,
program
64, follow these steps:
1.
1. Clear the screen by holding down the SHIFT key while you press the
CLRlHOME
CLR/HOME key.
2. Key in
RN . This clears out information that might still
in NEW and press RETU
RETURN.
be in the computer's memory after yo
ur expe
ri menting.
your
experimenting.
3. Key in the following two lilines
nes exactly as they appear here:
10 ? ""EXECUTIVE
EXECUTIVE 64"
20 GOTO 10
4. Remember to press the RETURN key after each line. After you key in the first
line and press RETURN
'll notice that the comp
uter doesn't respond to
RETURN,, you
you'll
computer
the PRINT command right away like it did before when you typed in the same
kind of com
mands. This is because you are now beg
inning the command
commands.
beginning
e line numbers,
with a line number (10). When you us
use
numbers, the computer knows
that yo
u're writing a program
you're
program,, so it waits for you to finish keying in the whole
program before follow
ing any of your instructions.
following
5. Key in RUN and press RETURN. The RUN command tells the computer that
you
've fin
ished keyi
ng in program statements, and you
're ready to have your
you've
finished
keying
you're
your
instructions followed. Here's what happens when yo
u RUN this program:
you
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTI
VE 64
EXECUTIVE
EXECUTIVE
EXECUTIVE 64
EXECUTI
VE 64
EXECUTIVE
EXECUTIVE 64
38
n
6.
6. Stop
Stop the program's
program's execution
execution by
by pressing
pressing the RUN/STOP
RUN/STOP key.
key. The
The computer
computer
continues to follow
follow your
your orders by
by printing
printing EXECUTIVE
EXECUTIVE 64
64 over and
and over
over un·
un
continues
til you interrupt
th the RUN/STOP
interrupt wi
with
RUN/STOP key.
key. Here's
Here's how
how your screen looks
looks when
when
press STOP.
you press
v
v
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
IN 10
BREAK IN
READY
This simple program introduces several important concepts that are the
basis for all programming.
LINE NUMBERS
We mentioned before in step 4 that line numbers tell the computer that
you
're writing a program.
you're
program. They also tell the computer in what order you want the
statements in your program to executive.
ll the com·
executive. Without line numbers to te
tell
com
puter when to follow which instruction, the computer doesn't know what to do
first.
fi rst.
The longer
lex your program is, the more important it is to
longer and more comp
complex
remember that the computer relies on you to tell it WH
EN to do things, as well
WHEN
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
't check for the order your lines
program.. The computer doesn
doesn't
the
screen.
appear on th
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
al l you do is refer to it by line
line number in
a GOTO statement,
statement, as
of aa statement, all
in a
you did
did in the
th e example
example above.
v
v
39
39
THE GOTO
GOTO STATEMENT
STATEMENT
THE
When you
you told
told the
the computer
computer to
to RUN
RUN the
the sample
sample program
program above,
above, EXECUTIVE
EXECUTIVE
When
64 was
was PRINTed
PRINTed repeatedly
repeatedl y instead
instead of
of just
just once
once because
because of
of the
the GOTO
GOTO state
state·
64
ment in
in line
line 20.
20.
ment
The GOTO
GOTO statement
statement tells
te lls the
the computer
computer to
to go
go directly
directly to
to aa specified
specified line.
line.
The
Then the
the computer
computer follows
foll ows the
the instructions
instructions in
in the
the specified
specified line
line and
and goes
goes on
on to
to
Then
I)
the next
next line.
line.
the
You can
can use
use aa GOTO
GOTO statement
statement to
to tell
tell the
the computer
computer to
to go
go back
back to
to aa line
line
You
()
that' s already
already been
been executed.
executed. Or
Or GOTO
GOTO can
can tell
tell the
the computer
computer to
to skip
skip forward,
forward ,
that's
even ifif this
this means
means that
that some
some lines
lines in
in the
the program
program don't
don't get
get executed.
executed .
even
In our
our example,
example, the
the program
program PRINTS
PRINTS the
the message
message in
in line
line 10
10 and
and moves
moves to
to
In
20. There,
There, the
the GOTO
GOTO statement
statement tells
tells the
the computer
computer to
to go
go back
back to
to line
line 10
10 and
and
line 20.
line
10 says
says to
to do.
do. So,
So, the
the program
program prints
prints the
the message
message in
in line
li ne 10
10 again,
again,
do what
what line
line 10
do
and then
then moves
moves to
to line
line 20,
20, which
which sends
sends the
the computer
computer back
back to
to line
line 10
10 and
and so
so on.
on.
and
Because the
the example
example doesn't
doesn' t give
give the
the com
com·
Thi s repetition
repetition is
is called
called aa LOOP.
LOOP. Because
This
puter aa way
way out of
of the
the loop,
loop, the
the circle
circle repeats endlessly.
end lessl y. You
You have
have to
to halt
halt the
the cy
cy·
puter
cle by interrupting
interrup ting the program with the RUN/STOP key.
It's best to
to include
include aa statement in
in your program that
that ends the
the loop
loop so
so you
you
It's
don't have to use
use the RUN/STOP
RUN /STOP key.
key. We'll
We 'll explain
explain more above
above ending
ending loops
don't
later in
in this chapter.
later
USING THE LIST COMMAND
Now that you've interrupted execution of the sample program, key in LIST on
screen . Your program is now displayed intact because it's
it's still in the com
comyour screen.
puter's memory,
execution. The only
puter's
memory, even though you interrupted the program's execution.
your?? into the word PRINT.
difference is that the computer changed your
PRINT. This
doesn' t affect your program,
doesn't
program, it's just the way the computer does things. When
you use the LIST command,
command, the computer also displays the lines of the pro·
pro
gram in correct numerical order,
order, even if you entered the lines out of order.
One of the important differences between
ing programs and entering
between writ
writing
nes in the immediate/calculator mode is that you permanen
tly lose an
single lilines
permanently
immediate statement once you execute it and clear the screen. But,
But. until you
start a new program, you can always get a program back just by keying in LIST.
LIST.
From here,
here, you can change the program, SAVE it,
it, or RUN it again.
40
40
EDITING TIPS
TIPS
EDITING
When
When you
you make
make aa mistake
mistake in
in aa line
line you've
you've keyed
keyed in,
in,or
or when
when you
you just
just want
want to
to
change aa line,
line, the
the 64
64 offers
offers you
you aa number
number of
of editing
editing options.
options.
change
1. You
You can
can retype
retype aa line
line any
any time,
time, and
and the
the computer
computer automatically
automatically substitutes
substitutes
1.
do to
to replace
replace aa line
line is
is use
use the
the
the new
new line
tine for
for the
the old
old one.
one. All
All you
you have
have to
to do
the
same line
line number.
number. For
For example:
example:
same
10 ?? "My
" My name
name is
is Sarah"
Sarah "
10
20 ?? "I
" I was
was born
born in
in California"
California"
20
20 ?? "I
" I live
live in
in Pennsylvania"
Pennsylvania"
20
RUN
RUN
My name
name is
is Sarah
Sarah
My
II live
live in
in Pennsylvania
Pennsylvania
As
As you
you can
can see,
see, the
the first
first line
line 20
20 never
never executes
executes because
because itit is
is replaced
replaced by
by
the second
second line
line 20.
20. IfIf you
you now
now key
key in
in aa LIST
LIST command,
command , you'll
you'll see
see that
that only
only
the
20 is
is still
still part
part of
of the
the program,
program.
the second
second line
line 20
the
2. You
You can
can easily
easily erase
erase aa line
li ne you
you don't
don' t want
want just
just by
by keying
keying in
in the
the line
line number
number
2.
RETURN key.
key. IfIf you
you now
now key
key in
in LIST,
LIST, you'll
you'll see
see that
that the
the line
line
and pressing
pressing the
the RETURN
and
is gone,
gone, and
and so
so is
is the
the line
line number.
number.
is
3. You
You can
can easily
easi ly edit
edit an
an existing
ex ist ing line.
line. Use
Use the
the CuRSoR
CuRSoR keys
keys to
to move
move the
the cur
cur·
3.
the line
line you
you want
want to
to change,
change, and
and then
then just
just edit
edit the
the line
line any
any way
way
sor back
back to
to the
sor
you want
want to.
to. As
As soon
soon as
as you
you press
press the
the RETURN
RETURN key,
key, the
the edited
edited line
line will
will
you
to use
use the
the INST/DEL
INST/DEL key
key to insert or
or delete.
delete.
replace the old line. Remember to
When you
you finish editing,
editing, you can check your program again to verify changes
by
com mand. Remember that LIST
LIST also puts
pu ts lines in
by keying in the LIST command.
numeri
cal order
order if you've
you 've keyed them in out of order.
numerical
order.
a semicolon to the
the end of the line,
Try editing our sample program by adding a
line,
EXECUTIVE
COMMODORE, and omitting the 64. After you
changing EXECUTI
VE to COMMODORE,
yo u finish
the changes,
changes, be sure to move the cursor past line 20 before you RUN the pro·
pro
gram. Here's how
the program works now:
how the
now:
LIST
10 PRINT ""COMMODORE":
COMMODORE";
20 GOTO 10
COMMODORE
E COMMODORE COMMODORE
COMMODORE COMMODOR
COMMODORE
COMMODORE
E COMMODORE
COMMODORE COMMODORE COMMODOR
COMMODORE
BREAK IN 10
READY
41
41
HOW TO USE VARIABLES
A variable is a symbol that slands
stands lor
for a value. Somelimes
Sometimes Ihe
the value of a
before you RUN a program. One of the purposes 01
of a pro·
pro
variable is unknown belore
gram may be to find one or more values for a variable.
variable. Look at this line from a
program:
10 X = 28
+ Y
+
In this equal
ion, X
equation,
X and Yare
Y are variables. Suppose X
X slands
stands for Ihe
the number of
the best th
things
that
days in a month. One of Ihe
ings about a variable is th
at you can reuse it
in
ram, so X can
in a prog
program,
can stand fo
forr the days in a
allll the months, not just one month.
This is where Y
Y comes in. All mon
months
have
28 days,
days, so Y stands for the days
th s
over 28. Later in this chapter there's a prog
ram that gives values to these two
program
variables.
Th
e most important thing
thi ng now is understandi
ng how vari
ables work,
The
understanding
variables
work, because
variables allow you to do complex tasks with you computer. Variables also let
you write programs that are very reusable.
Imagine that your computer contains a bunch of little slots, like a bank of
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
X and one Y. At the beginning
equation above,
of a program,
program, these slots have names, but they're empty.
empty. Here's what happens
when you put aa value in Y's slot:
X
Y
3
Now the variable Y
value
Y has the val
ue 3. You can give Y
Y this
th is value just by writing this
th is
simple statement:
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 how the program
program looks:
Here's
10
10 X
X = 28
28 +
+ YY
20
20 Y
Y = 33
30
NUMBER OF DAYS
DAYS IN MAY IS";X
IS";X
30 ? "THE NUMBER
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
n
r
When
program, the
the imaginary
imaginary slots
slots look
look like
like this
this after
after line
line 30
30 is
is exex
When you
yo u RUN
RUN the
the program,
ecuted:
ecuted:
x%
X
X$
15
23.5
TOTAL:
Y
When
program. Y
Y gets a val
value:
When you
you RUN
RUN the
the program,
ue: 38.5
The
types of
of variab
variables:
The above
above example
example uses
uses the
the three
th ree types
les:
v
SYMBOL
SYMBOL
DESCRIPTION
EXAMPLES
Integer
%
%
whole numbe
numbers
rs
Text
Text string
stri ng
$S
characters
characters in
A /o,, A1 %
/o
X%
X$. AB$
X$,
TYPE
TYPE
quotes
Floating
Floating
read (decimal)
point
point
or whole num
numbers
bers
X, AB
X,
POSSIBLE
POSSIBLE
VALUES
15,102,3
""TOTAL",
TOTAL",
1"
DAY 1"
""DAY
23.5, 12,
1.3E+2
1.3E
+2
Be
Be sure
sure you
you use
use the
the right variable types in your programs. If you try to do
something
integer
variable,, your program won
won't
something like
like assign aa text string to an integ
er variable
't
work.
work .
There
in mind when you ass
assign
There are a few
few other
other things
th ing s to keep in
ign names to
variables:
variables:
••
A variable
variable name
name can
can have
have one or two characters, not cou
nting the special
A
counting
special
symbol
symbol used
used with
with integer and text string variables.
••
You can
can use
use more
more than
than two alphabetic characters in
You
in a variable name, but
but the
computer
would
PA.
computer only
only recognizes the first two. So the computer
comp uter wou
ld think PA,
variab le referring to the same ""slot".
slot" .
PARTNO and
and PAGENO
PAGENO are the same variable
PARTNO
••
A
A program
program is
is easier
easier for people to read when you use longer variable names,
but when
when you
you use
use more
more than two characters in
but
in a name,
name, be sure the first two
are unique.
unique.
are
••
You can
can use
use X,
X, X%,
X% , and
and XS
X$ in
in one program because the special symbols %
You
%
and
$
make
each
vari
able
name
uniqu
e.
The
same
is
true
of
A2
,
A2%
,
and
and $ make each variable
unique.
A2, A2%,
A2$.
A2$.
••
The first
fi rst character
charac ter must
must be alphabetic (A to Z). The second and any later
The
characters can
can be
be either alphabetic or numeric (0
characters
(0 to 9). Remember that the
comp uter ignores
ignores every
every character after
after the second unles
s it's a % or $ in the
computer
unless
third position.
position.
third
•• Variable
Variable names
names can't
can ' t contain
contain BASIC keywords,
keywords, which
wh ich are also called reserv·
reserv
ed words.
words. These
These are
are the
the words
word s like PRINT and RUN that are part of the
ed
BASIC language.
language. Appendix
Appendix D
D lists
lists all
all the
the BASIC
BASIC reserved words.
wo rd s.
BASIC
u
v
43
43
Here's one
one more
more sample
sample program
program that
that shows
shows you
you how
how to
to use
use variables.
variables.This
This
Here's
example also
also uses
uses some
some of
of the
the other
ot her things
things you've
you 've learned
learn ed so
so far.
far.
example
NEW
NEW
10X;1
.05
10
X = 1.05
20Y;3oo
20 Y = 300
30Z;X·Y
30
Z = X * Y
40 PRINT
PRINT "SEATS
"SEATS AVAILABLE:";Y
AVAILABlE: ";Y
40
50 PRINT
PRINT "TICKETS
" TICKETS AVAILABLE:";Z
AVAllABlE:";Z
50
60Y;Y+1
60
Y = Y + 1
70
70 PRINT
PRINT "OVERBOOKING
" OVERBOOKING POINT:";Y
POINT:";Y
RUN
RUN
SEATS
AVAI LABlE: 300
300
SEATS AVAILABLE:
a
TICKETS AVAILABLE:
AVAILABLE: 315
315
TICKETS
OVERBOOKIN G POINT:
POINT: 301
301
OVERBOOKING
lines (10
(10 ■- 30)
30) assign
assign variable
variable names.
names.
Lines
lines 40
40 and
and 50
50 PRINT
PRINT aa message
message and
and the
the current
current value
value of
of variables
va riables YY and
and Z.
Z.
Lines
Notice that
that at
at line
line 40,
40, the
the value
val ue for
for YY is
is 300.
300.
Notice
Line 60
60 gives
gives Y
Y aa new
new value,
value , and
and this
this new
new value
val ue is
is PRINTed
PRINTed in
in line
line 70.
70. Line
Line 60
60
Line
shows that
that aa variable
vari able can
can have
have more
more than
than one
one value
value in
in aa program.
program.
shows
Line 60
60 also
also shows
shows another
another of
of the
the powerful
powerful features
features of
of variables:
va ri ables: you
you can
ca n
Line
make aa variable
variab le equal
equal to
to itself
itself and
and another
anoth er value.
va lue. This
This isn't
isn· t allowed
allowed in
in regular
reg ular
make
algebra,
but
this
kind
of
statement
is
common
ly
used
in
programming
It
algebra,
kind of
commonly used in programming.. It
mean s: take the
the current
cu rren t value of a variable,
variable, combine
combine itit with
wit h another value,
value, and
and
means:
va lue of
of the variable
variable with
with this new
new value. You
You can also use
replace the first value
statements like
like these:
these:
statements
^
Y ; Y - 1
YrY-1
Y; Y
X
Y = Y +
+ X
Y =
; Y/2
Y 12
Y
Y =
; Y·(X+2)
Y
Y ' (X + 2)
44
44
USING FOR/NEXT
FOR/NEXT LOOPS
LOOPS
USING
We mentioned
mentioned loops
loops earlier
earlier in
in this
th is chapter
chapter during
during the
the explanation
explanation of
of the
the
We
GOTO statement.
statement. As
As you'll
you 'll recall,
reca ll, loops
loops are
are repeated
repeated executions
executions of
of one
one or
or more
more
GOTO
lines in
in aa program.
program.
lines
v
Th e FOR/NEXT
FOR/NEXT statement
statement lets
lets you
you create
create very
very useful
useful loops
loops that
that control
control the
the
The
num ber of
of times
ti mes aa segment
segment of
of aa program
program is
is executed.
executed. The
The FOR
FOR statement
statement sets
sets
number
limit on
on the
the number
num ber of
of times
times the
the loop
loop will
wi ll execute
execute by
by assigning
assig ning aa range
range of
of
aa limit
values to
to aa variable.
variabl e. For
For example:
exampl e:
values
FOR COUNT
COUNT == 11 TO
TO 44
FOR
The
The NEXT
NEXT statement
statement marks
marks the
the end
end of
of aa FOR/NEXT
FOR/NEXT loop.
loop. When
When the
the program
program
reaches
reaches aa NEXT
NEXT statement,
statement, the
the computer
comp uter checks
checks the
the FOR
FOR statement
statement to
to see
see ifif
the limit
li mit of
of the
th e loop
loop has
has been
been reached.
reached. IfIf the
the limit
limit hasn't
hasn't been
been reached,
reach ed, the
the loop
loop
the
continu es and
and the
the variable
variable in
in the
the FOR
FOR statement
statement is
is incremented
inc remen ted by
by one.
one. For
For ex
ex continues
ample, ifif you
you add
add aa FOR/NEXT
FOR/NEXT loop
loop to
to the
th e program
program at
at the
the beginning
beginning of
of this
this
ample,
chapter, here's
here's what
what happens:
happens:
chapter,
10 FOR
FOR CT = 11 TO
TO 44
10
20 ?? "EXECUTIVE
" EXECUTIVE 64
64
20
"; "COUNT=
"COUN T = ";CT
";CT
";
30 NEXT
NEXT CT
CT
30
v
RUN
RUN
EXECUTIVE 64
64
EXECUTIVE
EXECUTIVE 64
64
EXECUTIVE
COUNT=
COUNT
= 11
COUN T= 22
COUNT=
EXECUTIVE 64
COUNT= 3
EXECUTIVE 64
EXECUTIVE
COUNT= 44
COUNT=
don't have to break
Now that you've added
added the FOR/NEXT
FOR/NEXT loop,
loop, you
yo u don't
break in with
execution.
the STOP key to halt the program's execution.
This FOR/NEXT loop works like this:
Li
ne 10 gives the
the va
riable CT a rang
e of values from 11 to 4, and tells
te lls the com,
Line
variable
range
com
puter to execute the next lines until CT equals 4.
Line 20 tells the computer to print EXECUTI
VE 64.
EXECUTIVE
64.
e current val
ue of CT. As long as the
Line 30 tells the computer to add 11 to th
the
value
val
ue of CT rema
ins withi
n the range of 1
value
remains
within
1 to 4, the program repeats
repeats,, and EX,
EX
again. When CT equals 4, line 20 executes one more
ECUTIVE 64 is PRINTed again.
time. When line 30 again adds 1
1 to CT,
CT. the computer knows that CT is now out
of range
range.. So the computer stops executing the loop,
loop, and the program ends by
itself.
v
v
45
45
"
—
CHAPTER 55
CHAPTER
ADVANCED BASIC
BASIC
ADVANCED
*-
Introduction
•• Introduction
An imation
Simple Animation
•• Simple
IN PUT
•• INPUT
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
•• Using
••
Ran dom Numbers
Numbers and
and Other
Other Functions
Functions
Random
••
Guessing Game
Game
Guessing
••
Your Roll
Roll
Your
••
Random Graphics
Graphics
Random
^
(->
INTRODUCTION
INTRODUCTION
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·
The
language and
and the
the concepts
concepts necessary
necessary to
to write advanced
advanced programs.
prog rams.
ming language
ming
Those of
of you
you who
who are
are just
just starting
st arting to
to learn
learn how
how to
to program
program may
may find
find some
some of
of
Those
information too technical to understand completely.
comp letely. But
But you'll
you 'll find some
some
the information
are written
wri tten for
for new
new users
users in
two chapters.
chapters, SPRITE
SPRITE
simple examples
examples that
that are
simple
in two
GRAPH ICS and
CREATING SOUND.
These examples
will give
give you
GRAPHICS
and CREATING
SOUND. These
examples will
you a
a good
good idea
idea
of how to use the sophisti
cated graphics and sound capabilities
capabili ties available on
sophisticated
yo
ur Exec
utive 64.
your
Executive
64.
If you want to learn more about writin
g programs in BASIC, check the
writing
bibli
ography in
bibliography
in the
the back
back of
of this
this manual
manual (Appendix
(Appendix N).
N).
you are
are already
already familiar
familiar with
with BASIC
BASIC programmi
programming,
the following
following chapters
chapters
IfIf you
ng, the
ramm ing techn
iques. You
'll
will
will help
help you
you get
get started
started with
with advanced
advanced BASIC
BASIC prog
programming
techniques.
You'll
find
rammin g in
e COMMODORE
find extensive
extensive information
information about
about advanced
advanced prog
programming
in th
the
COMMODORE
64 PROGRAMMER'S
PROGRAMMER'S REFERENCE
REFERENCE GUIDE,
GUIDE, which
which is
is available
available through
through your
your
64
local
Commod
ore
dealer.
local Commodore dealer.
46
46
SIMPLE ANIMATION
You can use some of the 64's graphic capa
bilities by putt
ing together wha
capabilities
putting
whatt
you've
manual, along with a few new conce
concepts.
you
've learned so far in this manual,
pt s.
Try entering the foltowing
h graphics.
following program to see what you can do wit
with
Notice that you can include cursor controls and screen commands WITHIN a
PRINT statement. When you see something like <
CRSR left >
<CRSR
> in a program
listing,
< - CRSR
CRSR -- >
> key. The screen
listi
ng, hold down the SHIFT key and press the <
shows th
e graphic representation of a cursor left,
the
left, which
which is two vertical reversed
bars. The graphic represen
representation
CLR/HOME key is a reversed
bars.
tation of the SHIFTed CLRlHOME
heart.
INDICATES NEW
NEW
COMMAND
10
REM BOUNCING BALL
20 PRINT "(CLR/HOME
"
"(CLR/HOME^
FOR X
X = 1 TO 10: PRINT "(CRSR/DOWN)"
25
:NEXT
"(CRSR/DOWN)":NEXT
30
1 TO 40
FOR BL = 1
PRINT" . (CRSR LEFT)";:REM
LEFT)";:REM
40
is a
SHIFT - Q
aSHIFT-Q
FOR TM
TM =\i
TO 5
5
50
FOR
= 1 TO
----~~---THESE
THESE SPACES
NEXTTM
60 NEXT
TM
ARE INTENTIO
NAL
ARE
INTENTIONAL
70
NEXT BL
REM MOVE
MOVEjBALL
75
BALL RIGHT TO LEFT
80 FOR BL =/40
40 TO 11 STEP - 11
PRINT ""^CRSR
LEFT) (C
(CRSR
LEFT) (CRSR LEFT)";
90 PRINT
(CRSR LEFT)
RSR LEFT)
100 FO
R TM = 11 TO 55
FOR
NEXTTM
110
110 NEXT
TM
120 NEXT BL
130 GOTO 20
=
TIP:
All words in this text will
wi ll be completed on
However, as
as lonq
long as
as you
yo u
on one line.
line. However
your
your 64
64 wil
wi ll automatically
au tomatica lly move to
to the
the next
next line even
even in
in thp
the
' ;liIli'Ii'
don't
don 't hit
hit £
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
left to right
ri ght and
and back again. Take
Take aa close
close look at the
the program
program to
to see
screen
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
statement
ment has no
no effect on
on the program itself.
itself.
Line
Line 20
20 clears
clears the screen.
screen.
Line 25
25 PRINTs
PRINTs ten
ten cursor-down
cursor-down commands.
commands. This
Thi s just
just positions
positions the
the ball
ball in
in
Line
th e middle
middle of
of 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
the
line
li ne of the
the screen.
screen.
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
40 does
does three
three things:
things:
Line 40
Line
1. PRINTs
PRINTs aa space
space to
to erase
erase the
the previous
previous ball
ball positions
positions.
1.
2.
2. PRINTs
PRINTs the
the ball.
ball.
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.
3.
47
47
-
line 50
50 and
and 60
60 set
se t up
upaa loop
loop that
that slows
slows down
down the
the ball's
ball's movement.
movemen t.Without
Withou t
Line
wo uld move
move too
too fast
fast for
fo ryou
you to
to see
see clearly.
clearly.
this loop,
loop, the
the ball
ball would
this
Line
line 70
70 completes
completes the
the loop
loop set
set up
up inin line
line 30
30 to
to PRINT
PRINT balls
balls on
on 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 the
the illustration,
illustration, the
the program
program contains
contains aa loop
loop within
within aa loop.
loop. You
You
can include
include up
up to
to ten
ten loops
loops within
within aa loop.
loop. The
The only
only time
time you
you get
get inin trouble
trouble isis
can
when the
the loops
loops cross
cross over
over each
each other.
ot her. The
The loops
loops have
have to
to be
be NESTED
NESTED inside
inside
when
each
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
each other.
other. In
In other
A,
you
must
finish
loop
B
(the
inside
loop)
first.
A. you must finish loop B (the inside loop) first.
When you're
you 're writing
writing aa program
program with
wit h loops,
loops, it's
it's aa good
good idea
idea to
to draw
draw arrows
arrows
When
from the
the beginning
beginning to
to the
the end
end of
of the
the loops.
loops. IfIf your
your loops
loops cross,
cross , the
th e computer
computer
from
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 .
can't
Lines
lines 80
80 through
through 120
120 just
just reverse
reverse the
the steps
steps in
in the
the first
first part
part of
of the
the program,
program,
and
to left.
left. Line
line 90
90 is
is slightly
slightly different
different from
from line
line 40
40
and move
move the
the ball
bal l from
from right
right to
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
because
ball to
to the
the right
right and
and move
move to
to the
the left.
left.
ball
Line
line 130
130 sends
sends the
the program
program back
back to
to line
line 20
20 to
to start
start the
the whole
whole process
process over
over
again.
again.
Fo r aa variation
variati on on
on the
the program,
prog ram , change
change line
line 40
40 to
to read:
read:
For
40 PRINT
PRINT "<SHIFT>
" <SHIFT> < Q>"
0 >"
40
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
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
control,
in the
the second
second part of
of the program.
program.
right to left in
-
48
48
INPUT
INPUT
Up
Up to
to now,
now, everything
everything in
in aa program
program has
has been
been set
set up
up before
before the
the program
program
RUNs.
't change
RUNs. Once
Once you
you executed
executed the
the program,
program, you
you couldn
couldn't
change or
or add
add anything.
anything.
The
The INPUT
INPUT statement
statement lets
lets you
you send
send information
information to
to aa program
program WHILE
WHILE itit is
is RUN·
RUNning.
ning. Not
Not only
only does
does the
the program
program act
act on
on this
this information
information you
you supply,
supply, but
but the
the pro·
pro
gram won't
won't continue
continue until
until you
you supply
supply it.
it.
gram
To
To get
get an
an idea
idea of
of how
how INPUT
INPUT works,
works, type
type NEW,
NEW, press
press RETURN
RETURN,, and
and enter
enter this
this
short program.
program.
short
10 INPUT
INPUT A$
A$
10
20
PRINT
TYPED ";AS
";A$
20 PRINT ""YOU
YOU TYPED
PRINT
30 PRINT
IF A$
AS = "STOP"
"STOP" THEN END
END
40 IF
50 GOTO
GOTO 10
10
50
RUN
RUN
?
GO
? GO
YOU
TYPED GO
GO
YOU TYPED
? CONTINUE
CONTINUE
YOU TYPED CONTIN
UE
? STOP
YOU TYPED STOP
Here's what happens in this program:
Line 10 tells the comp
uter to display a question mark to prompt you to INPUT
computer
AS, and to wait until you
uing the pro·
a value for AS,
you supply the value before contin
continuing
pro
gram execution.
PRINTs aa message and the INPUT value, and line 30 PRINTs a blank
Line 20 PRINTS
line.
line.
Line 40 tells the computer to end the program
program immediately
immediately IF the value you
Line
INPUT
IN PUT for AS
A$ is STOP.
STOP.
Line 50
50 returns the program
program to line
line 10
10 so
so you can INPUT
INPUT another value. IF
IF line
line
Line
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
40
executed.
executed.
You can
can INPUT
INPUT numeric
numeric or
or string
string variables,
variables, and
and you
you can
can have
have the INPUT
INPUT
You
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
statement
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
INPUT
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$
RUN
RUN
KEEP
KEEP GOING?
GOING? GO
GO
Prompt message
message can't
can 't
Prompt
be more
more than
than 38
38
be
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
Here's
Here's aa more
more complex
complex example
example that
that demonstrates
demonstrates aa lot
lot ofof what's
what's been
been
presented so
sofar,
far,including
including the
the INPUT
IN PUTstatement.
statement.
presented
NEW
NEW
11
REM
REM TEMPERATURE
TEMPERATURE CONVERSION
CONVERSION PROGRAM
PROGRAM
55
PRINT "(CLR/HOME)"
" (CLRlH OM E)"
PRINT
20
20
IF AS
AS == ""THEN
"" THEN 10
10
IF
10
10 PRINT
PRINT "CONVERT
"CONVERT FROM
FROM FAHRENHEIT
FAHRENHEIT OR
OR CELSIUS
CELSIUS (F/C)":INPUT
(F/C)": INPUT A$
AS
30
30
IF AS
AS == "F"THEN
" F" THEN 100
100
IF
40
40
50
50
60
60
70
70
80
80
90
90
100
100
110
110
120
120
130
130
140
140
INPUT "ENTER
" ENTER DEGREES
DEGREES CELSUIS:
CELSU IS: ";C
" ;C
INPUT
(C ' 9V5+
32
FF == (C*9)/5
+ 32
PRINT C;"
C;" DEG.
DEG. CELSIUS
CELSIUS == ";"; F;"
F;" DEG.
DEG. FAHRENHEIT"
FAH RENHEIT"
PRINT
PRINT
PRINT
GOTO 10
10
GOTO
INPUT "ENTER
"ENTER DEGREES
DEGREES FAHRENHEIT:
FAHRENHEIT: ";F
";F
INPUT
C
=
(F-32)'5/9
C = (F-32)'5/9
PRINT F:"
F;" DEG.FAHRENHEIT
DEG.FAHRENHEIT == ";C:"
";C;" DEG.
DEG . CELSIUS"
CELSIUS"
PRINT
PRIN T
PRINT
GOTO 10
10
GOTO
<>
IF A$O"C"
AS
"c" THEN
THEN END
END
IF
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
in aa value
value for
for A$.
AS.
you to
to type
type in
you
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
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
go next.
next. Line
IF
IF nothing
nothing was
was typed
typed in
in (IF
(IF just
just RETURN
RETURN was
was pressed).
pressed). Line
Line 30
30 tells
tel ls the
the com
computer to go straight to line
line 100
100 and perform
perform the
the Fahrenheit-to-Celsius
Fahrenheit-to-Ce lsius conver
converue you
you typed for
for A$
AS is
is F.
F.
sion IF the val
value
Line 40
40 checks
checks to
to be
be sure
sure that
that you
you haven't
haven't typed
in anything
anything beside
beside F
F or
or C.
C. IF
IF
typed in
Line
you have, line 40 ends the program. IF yo
youu typed in a C,
C. the computer
automatically moves
moves to
to line
line 50
50 to
to perform
perform the
the Celsius-ta-Fahren
Celsius-to-Fahrenheit
conversion..
automatically
heit conversion
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
ItIt may
heck
But this is a good programming
programming practice that can spare you a
what you INPUT. But
be sure that your program
program takes care
lot of frustration. You should always try to be
of
of all
all possibilities.
possibilities.
Back to the example:
example: once
once the program
program knows
knows what
what type of conversi
conversion
on to
Back
make, the
the calculations are made.
made. Then
Then the program
program PRINTs
PRINTS the temperature
make,
you
you entered
entered and
and the
the converted
converted temperature.
temperature.
The calcu
calculation
this
program performs
performs is
is just
just straight
straight math,
math, using
using the
the slanstan
The
lation thi
s program
dard formula
formula for
for temperature
temperature conve
conversion.
After the
the calculation
calculation finishes
finishes and
and the
the
dard
rsion . After
answer
answer is
is PRINTed
PRINTed., the
the program
program loops
loops back
back and
and starts
starts over.
over.
Here's
ution of
is program
Here's aa sample
sample exec
execution
of th
this
program::
CO
NVERT FROM
CONVERT
FROM FAHRENHEIT
FAHRENHEIT OR
OR CELSIUS
CELSIUS (F/C):
(F/C): ?F
?F
ENTER
ENTER DEGREES
DEGREES FAHRENHEIT:
FAHRENHEIT: 32
32
32
32 DEG
DEG.. FAHRENHEIT
FAHRENHEIT =- 00 DEG
DEG.. CELSIUS
CELSIUS
CONVERT
EIT OR
CONVERT FROM
FROM FAHRENH
FAHRENHEIT
OR CELSIUS
CELSIUS (F/C):
(F/C): ??
After you
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,
After
as wel
welll as
as others
others in
in this
this manual,
manual, can
can fo
form
part of
of yo
your
program library.
library.
as
rm part
ur program
50
50
n
n
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
is assigned to the variable you inc
lude in the GET statement. Here's an exam·
include
exam
ple:
pie:
11
10
20
30
PRINT ""<CLR/HOME>"
< CLRlHOM E >"
GET A$:
" THEN 10
AS: IF A$
AS ;= """
PRINT A$;
A$;
GOTO 10
No space between
quotes
Line
Li
ne 11 clears the screen.
Line
keyboard.. In
In effect
effect,, the loop in line 10
li
ne 10 lets you type in any key on the keyboard
tel
ls the comp
uter to wait until you type in a key before moving to line 20.
tells
computer
Line 20 displays the keys you type on the screen.
screen.
line
Line 30 sends the program back to GET another character.
character. It's important to
line
remember that the character you type in won
't
be
displayed
unless
you PRINT it
won't
uniessyou
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
yo
u don't press a key (unlike INPUT,
response), so the se·
you
INPUT, which waits for your response),
se
cond part of line 10 contin
ually checks the keyboard until you hit a key.
continually
Try leaving out the second part of line 10
10 and see what happens.
RESTORE keys.
program, press the RUN/STOP
To stop this program,
RUN/STOP and RESTORE
You can easily rewrite the beginning of the temperature conversion program
program, LOAD it and
to use GET instead of INPUT. If you've SAVEd this program,
change lines 10 and 20 like this:
10 PRINT "CONVERT FROM FAHRENHEIT OR CELSIUS (F/C)"
20 GET A$: IF AS
A$ =
; "" THEN 20
v
v
51
51
USING GET
GET TO
TO PROGRAM
PROGRAM FUNCTION
FUNCTION KEYS
KEYS
USING
Asyou'll
you 'llrecall
recall from
froman
anearlier
earlierchapter,
chapter,we
wetold
toldyou
youthat
thatthe
thekeys
keyson
onthe
theright
right
As
(f
1
through
f8)
are
function
keys
that
you
can
program
side
of
the
keyboard
side of the keyboard {f1 through f8) are function keys that you can program toto
performaavariety
variety ofof tasks.
tasks.
perform
Here's how
how to
to program
program aa function
function key:
key:
Here's
Use aaGET
GETStatement
Statement to
to read
read the
the keyboard.
keyboard.
1.1. Use
Use IF
tF statements
statements to
to compare
compare the
the key
key you
you press
press to
to the
the CHR$
CHR$ code
code for
for the
the
2.2. Use
function
function key
key you
you want
want to
to use.
use. Every
Every character
characteron
on the
the keyboard
keyboard has
has aaunique
unique
CHR$ number.
number. For
Forexample,
example, the
the CHRS
CHR$ code
code of
of f f1
133. Appendix
Appendix FFlists
liststhe
the
CHR$
1 isis 133.
code for
for all
all keys.
keys.
CHR$ code
CHR$
3. Use
Use THEN
THEN statements
statements to
to tell
tell the
the computer
computer what
what you
you want
want the
the function
function key
key
3.
to do.
do.
to
When
When you
you RUN
RUN the
the program,
program, all
all you
you so
so is
is press
press aa function
function key
key you
you program
program·
in the
the THEN
TH EN statement.
statement.
med,and
and the
the key
key will
will follow
follow the
the instructions
instructions you
you gave
gave itit in
med,
For example:
example:
For
10 GETA$:
GET A$: IF
IF AS
A$ == ""THEN
" " THEN 10
10
10
20 IF
IF AS=CHR$(137)THEN
AS = CHR$(137) TH EN A$=CHR${14)
A$ = CHR$(14)
20
30 IF
IF A$=CHR$(134)THEN
A$= CHR$(134) TH EN A$=
A$= "YOURS
"YOURS TRULY"
TRULY" +CHR$(13)
+ CHR$(13)
30
Line 10
10 tells
tells the
the program
program to
to assign
assign the
the key
key you
you press
press to
to the
the variable
variable AS.
AS. As
As
Line
you'll recall
recall from
from the
the previous
previous example,
example, the
the loop
loop in
in line
li ne 10
10 continually
contin ually checks
checks
you'll
the keyboard
keyboard for
for input.
input.
the
Line
Line 20
20 programs
programs function
function key
key 2,
2, CHR$(137).
CHR$(137). Line
Line 20
20 tells
tells the
the computer
computer to
to
A$ equal
equal to
to CHR$(14)
CHR$(14) ifif you
you press
func ti on key
2. CHR$(14)
is the
the switch
switch
make AS
make
press function
key 2.
CHRS(14) is
from upper
lower case
keyboard. When
from
upper to
to lower
case letters
letters on
on the
the keyboard.
When you
you RUN
RUN this
this program,
program,
you'll
this switch
you'll see
see that
that the
the characters
characters on
on the
the screen
screen immediately
immediately make
make this
switch if
if you
you
press
press f2.
f2.
Li
ne 30
lls the
Line
30 programs
programs function
function key
key 3,
3, CHR$(134).
CHR$(134). Line
Line 30
30 te
tells
the computer
computer to
to
make
RS TRULY
make A$
A$ equal
equal to
to the
the character
character string
string YOU
YOURS
TRULY and
and CHR$(13)
CHR$(13) if
if you
you press
press
f3 during program
program execution. CHR$(13) is
is the code for the RETURN
RETURN key.
key.
TH
E CHR$
THE
CHRS codes for the function keys
keys are:
f1
f1
f3
f3
f5
f5
f7
f7
==
==
===
CHRS(133)
CHR$(133)
CHRS(134)
CHRS(134)
CHR$(135)
CHR$(135)
CHR$(136)
CHR${136)
f2
f2
f4
f4
f6
f6
f8
f8
==
==
==
==
CHRS(137)
CHRS(137)
CHR$(138)
CHR$(138)
CHR$(139)
CHRS039)
CHRS(140)
CHRS(140)
The COMMODORE
COMMODORE 64
64 PROGRAMMER'S
PROGRAMMER'S REFERENCE
REFERENCE GUID
GUIDE
has more
more in·
in
The
E has
formation
formation about
about programming
programming function
function keys
keys.. You
You can
can purchase
purchase this
this extensive
extensive
guide
r local
guide from
from you
your
local Commodore
Commodore dealer.
dealer.
52
52
RANDOM NUMBERS AND OTHER FUNCTIONS
built-in functions that you can use to perform special tasks.
The 64 also has buill·in
built-in programs included in BASIC.
BASIC. The great advantage of
Functions are like built·in
these built·in
built-in functions is that you don't have to type in a number of statements
Instead, all you do is
every time you want to perform a specialized calculation. Instead,
type the command for Ihe
ion you want and the computer does all the rest.
ihe funct
function
built-in funct
functions
(SQR), finding out the
These built·in
ions include figuring square roots (SOR),
contents of a memory location (PEEK), generating random numbers (RND), etc.
Appendix C lists all the functions available on you
yourr computer.
One function you can have a lot of fun with is the rand
om number function
random
function,,
you'll
RND. If you want to design a game or an educational program, yo
u'll often need
to be able to program your computer to make up
up random numbers. For exam·
exam
pie,
u'd need to do this to simulate the tossing of dice. Of course you could
ple, yo
you'd
wouid
numbers, bu
butt it's much
write a program that wou
ld generate these random numbers,
calling
easier to be able to do this just by cal
ling upon the prewritten RaNDom number
function.
To see how RND works,
works, try this short program:
NEW
1 TO 10
10 FOR X = 1
20 PRINT RND
RND(1),
(1),
30 NEXT
COMMA, YOUR
IF YOU LEAVE OUT THE COMMA.
LIST OF NUMBERS
NUMBERS APPEARS AS 11 COLUMN
When you RUN this program,
program, the screen displays:
displays:
.789280697
.256373663
.682952381
.682952381
.402342724
.158209063
v
.664673958
.0123442287
3.90587279E-04
3.90587279E - 04
.879300926
.245596701
don't match? It woul
d be incredible if they did because the
Your numbers don't
would
program generates a completely
completely random list of ten
ten numbers.
a few more time, you'll see that the
the results are
If you RUN the program a
have a
always different. Though
Th ough the numbers don't
don 't have
a pattern, you'll
you' ll notice aa few
cons istencies about the list the
the program
program displays.
displays.
consistencies
For one thing,
thing , the results are always between 11 and 0.
0, but never equal to 11 or
O. For
For another,
another, the
the numbers
numbers are
are real
real numbers (with decimal points).
pOints).
0.
Now, we started out to
to simulate dice tosses,
tosses, and
and the
the results from this
this pro
pro.
Now,
gram aren't
aren't exactly
exactly what
what we're
we're looking for. Now we'll
we'll add
add aa few more
more features
gram
to
to this
this program
program to get what we
we want.
want.
20, and RUN the program
program
First, add
add this line
line to
to the program
program to replace line 20,
First,
aaain:
again:
20 PRINT 6*RND(1),
6'RND(1),
20
RUN
RUN
3.60563664
5.48602315
5.48602315
4.52687513
4.52687513
1.09650123
1.09650123
3.10045018
3. 10045018
3.91302584
4.39052168
4.39052168
2.32056144
2.32056144
4.10781302
4.1078 1302
5.06321506
5.0632 1506
v
v
53
53
"
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,
Now
we'll use
use another
another function.
fu nction.
we'll
The INT
INT function
function converts
conve rts real
real numbers
numbers to
to integer
integer (whole)
(whole) numbers.
numbers. So
So try
try
The
line 20
20 again:
again:
replac ing line
replacing
20 PRINT
PRINT INT(6'RND(1)),
INT(6 " RND(1)),
20
"
RUN
RUN
2
2
3
3
1
0
10
2
2
4
4
5
5
0
11
o
5
5
~
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
Now
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:
from
20 PRINT
PRINT INT(6'RND(1))
INT(6" RND(1)) +
+ 11
20
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.
Now
When you
you want
want to
to generate
generate aa range
range of
of real
real numbers instead
instead of
of whole
whole
When
numbers, the
the formula is
is slightly
slightly different
different because
because you
you must
must subtract
subtract the
the lower
lower
numbers,
of the range from the upper
upper limit. For
For example,
example, you
you can generate
generate random
limit of
25 by typing:
typing:
numbers between 11 and 25
numbers
20 PRINT
PRINT RND(1)'(25-1)
RND(1)" (25- 1) +
+ 11
20
T he general
general formula for generating random numbers
numbers in a certain range is:
The
RND(1) *(UPPER
"(UPPER LIMIT - LOWER
LOWER LIMIT) +
+ LOWER LIMIT
NUMBER = RND{1)
54
GUESSING GAME
GAME
GUESSING
Here's aa game
game that
that uses
uses random
random numbers.
numbers. This
This game
game not
not only
only uses
uses the
the RND
RND
Here's
function , but
but itit also
also introduces
introduces some
some additional
additional programming
programming theory.
theory .
function,
RUN this
this program,
program , the
the computer
computer generates
generates aa random
random number,
number, NM,
NM ,
When you
you RUN
When
whose
value
you'll
try
to
guess
in
as
few
turns
as
possible.
whose value you'll try to guess in as few turns as possible.
NEW
NEW
-------.r----'--_
11
22
REM NUMBER
NUMB ER GUESSING
GUESSIN G GAME
GAME
REM
PRINT
"(CLR/HOME)"
PRINT "(CLRlHOME)"
55
IN PUT -'ENTER
"ENTER UPPER
UPPER LIMIT
LIMIT FOR
FOR GUESS
GUESS ";LI
";LI
INPUT
10
10
NM =
= INT(LI*RND(1))+1
INT(LI·RND(l))+ 1
NM
15
15
CN = 00
CN
20
20
PRINT "I'VE
" I'VE GOT
GOT THE
THE NUMBER.":PRINT
NUM BER.": PRINT
PRINT
=
INDICATES
INDICATES NO
NO
SPACE
SPACE AFTER
AFTER
QUOTATION
QUOTATION MARK
MARK
30
30
INPUT "'WHAT'S
"WHAT'S YOUR
YOU R GUESS";
GU ESS"; GU
GU
INPUT
35
35
CN =
= CN
CN +
+ 11
CN
50
50
IF GU<
GU < NM
NM THEN
THEN PRINT
PRINT "MY
" MY NUMBER
NUMBER IS
IS HIGHER":
HIGHER" : PRINT:GOTO
PRINT:GOTO 30
30
IF
40
40
IF GU > NM THEN
TH EN PRINT
PRINT "MY
" MY NUMBER
NUMBER IS
IS LOWER":
LOWER": PRINT:GOTO
PRINT:GOTO 30
30
IFGU>NM
60
60
65
65
PRINT "GREAT!
" GREAT! YOU
YOU GOT
GOT MY
MY NUMBER"
PRINT
PRINT "IN
" IN ONLY
ONLY "';
"; CN
CN ;"GUESSES.":PRINT
;"GUESSES." :PRINT
PRINT
70
70
PRiNT "DO
" DO YOU
YOU WANT
WANT TO
TO TRY ANOTHER
ANOTHER (Y/N)";
(YIN)";
PRINT
80 GET
GET AN$:
AN $: IF
IF AN$=""
AN$= ,'" THEN
THEN 80
80
80
90 IF
IF AN$
AN$ =
= "Y"
" Y" THEN
THEN 22
90
100 IF
IF AN$<
AN$ >"N"
"N" THEN 70
100
<>
110 END
END
110
large the
the number will
wil l be
be at the start
start of
of the program.
You can specify how
how large
You
'-'
Then, it's up to you to guess what the number is.
Then,
A sample
sample run follows
fo llows along with an explanation.
explanation .
v
ENTER UPPER LIMIT FOR GUESS? 25
I'VE
I'VE GOT THE NUMBER.
WHAT'S YOUR GUESS ?
? 15
MY NUMBER IS HIGHER.
v
WHAT'S YOUR
YOUR GUESS ? 20
MY NUMBER IS LOWER.
WHAT'S YOUR GUESS ? 19
19
GREAT
GREAT!! YOU GOT MY
MY NUMBER
IN
IN ONLY 3 GUESSES.
DO
ER (YIN)?
DO YOU WANT TO TRY ANOTH
ANOTHER
(Y/N)?
55
55
~
nes 40-60)
The IFfTHEN
IF/THEN statemen
statementt (li
(lines
40-60) compare your guess to the random
number (NM) generated by line 10.
wrong , the program tell
s you
10. If your guess is wrong,
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
ght number. Th
e purpose of
track of how many guesses you take to get the riright
The
thi
s game,
es as possible.
this
game, of course,
course, is to guess the number in as few tri
tries
When you get the right answer,
ram displays the message,
answer, the prog
program
message. GREAT
GREAT!!
ls you how many guesses you look.
YOU GOT MY NUMBER,
NUMBER, and tel
tells
took.
Remember that the program ccreates
rea tes a new random number each
tim e you
each time
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.
PROGRAMM
ING TIPS:
PROGRAMMING
In line
s 40 and 50,
es mu
ltiple statements on a single line.
lines
50. a colon separat
separates
multiple
Th
is not on
ly saves typing
This
only
typing time,
time, but it also conserves memory space.
thi ng
Also notice that the IFfTHEN
IF/THEN statements in these two lines PRINT some
something
bef
ore branching to another liline.
ne.
before
YOUR ROll
ROLL
The fo
llowing program simulates the throw of two
Iwo dice.
You can play this lit·
following
dice. You
lit
tie
tle game by itself,
itseif, or use it as part of a larger game.
5
10
20
30
40
50
PRINT "Care to try you
yourr luck?"
PRINT ""RED
RED DICE = ";
INT(RND(1)'6)+ 1
";INT(RND(1)*6)+1
PRINT ""WHITE
WH ITE DICE = ";INT(RND(1)'6)+
";INT(RND(1)*6)+11
""PRESS
PRESS SPACE BAR FOR ANOTHER ROLL"
:PRINT
ROLL":PRINT
GET A$: IF A$ = """" THEN 40
IF A$ = CHR$(32)
CHR${32) THEN 10
F
ro m what yo
u've learned about BASIC and rand
om nu
mbers , see if you
From
you've
random
numbers,
you can
follow what
's going on in this progra
m. As yo
u may reca
ll from the section on
what's
program.
you
recall
programm
ing the function keys,
racter string code for the
programming
keys, CHR$(32) is the cha
character
space bar.
-
56
v
RANDOM GRAPHICS
GRAPHICS
RANDOM
As aa final
final note
note on
on random
random numbers,
numbers, and
and as
as an
an introduction
introduction to
to designing
designing
As
"-"
graphics, try
try entering
entering and
and RUNning
RUNning this
thi s program:
program:
graphics,
<
>"
10 PRINT
PRINT ■1<CLR/HOME>"
" CLRlHOME
10
20 PRINT
PRINT CHR$(205.5
CHRS(205.5 ++ RND
RND (1));
(1));
20
30 GOTO
GOTO 20
20
30
v
The function
function CHRS
CHR$ (CHaracter
(CHaracter String)
String) gives
gives you
you aa character,
character, based
based on
on aa stan
stan·
The
dard
255. Every
Every character
character the
the 64
64 can
can print
print is
is encoded
encoded
dard code
code number
number from
from 00 to
to 255.
this way.
way. Appendix
Append ix FF lists
lists the
the CHRS
CHR$ codes
codes for
for all
all keys.
keys.
this
A
A quick
quick way
way of
of finding
finding out
out the
the code
code for
for any
any character
character is
is to
to use
use the
the function
function
ASC (for
(for the
the standard
standard ASCII
ASCII code).
code). Type:
Type:
ASC
v
PR INT ASCf'X")
ASC("X")
PRINT
X
X is
is the
the character
character you're
you're checking.
checking. XX can
can be
be any
any printable
printable character,
character, including
including
graphics characters.
characters. You
You must
must enclose
enclose the
the character
character in
in quotation
quotation marks.
marks.
graphics
Here's an
an example:
example:
Here's
PRINT ASC("G")
ASC("G")
PRINT
71
The CHRS
CHR$ function
function is
is the
the opposite
opposite of
of ASC.
ASC.
The
PRINT CHR$(71)
CHR$(71)
PRINT
G
G
If you
you type:
type:
If
PRINT CHR${205);CHR$(206)
CHR$(205);C HR$(206)
PRINT
M and N
the computer displays the two right side graphics on the M
N keys,
keys, which
you just tried.
are the characters used in the little maze program you
The formula 205.5 + RND(1
RND(1)) tells the computer to pick a random number bet·
bet
fifty· fifty chance that the random number will be
ween 205.5 and 206.5 There is fifty-fifty
above or below 206. CHR$
CHRS ignores fractional values, so half the time the
v
character with code 205 is printed
printed,, and the rest of the time code 206 is
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
—
-
-
—
n
-
~
~
-
CHAPTER 66
CHAPTER
COLOR AND
AND GRAPHICS
GRAPHICS
COLOR
••
How to
to Use
Use Color
Color and
and Graphics
Graphics on
on Your
Your Computer
Compu ter
How
••
Prin ting Colors
Colors
Printing
••
Color CHR$
CHR$ Codes
Codes
Color
••
How to
to Use
Use PEEKs
PEEKs and
and POKES
POKEs
How
••
Screen Graphics
Graphics
Screen
•
Screen
Screen Memory
Memory Map
Map
•
Color Memory
Memory Map
Map
Color
•
More Bouncing Balls
Balls
More
—
HOW TO USE
USE COLOR
COLOR AND GRAPHICS
GRAPHICS ON YOUR COMPUTER
HOW
So far
far this
this book has presented
presented some of the
the sophisticated
sophisticated computing
So
64. But one
one of
of the
the most
most exciting
exciting features
features of your
your new com
com·
capabilities of
of your
your 64.
capabilities
puter is its outstanding
outstanding ability
abi lity to produce 16
16 different colors
colo rs and aa lot of dif
dif·
puter
fe rent graphics.
ferent
You 've already
al ready seen
seen aa very simple
simple demonstration
demonstration of the graphics in the
the boun
bounYou've
and in the maze program at the end of the last chapter. This
cing ball program and
cing
chapter introduces you to new concepts that explain graphic and color
programming, and that suggest
for creating your
your own games and advancadvanc
sugges t ideas for
programming,
ed animation.
-
<-
—
-
—
58
—
PRINTING COLORS
When you tried the color ali
gment tes
ter 1,
aligment
testt in Chap
Chapter
1, you discovered that you
can change text co
lors by simply holding down the CTR
L key and pressing one
colors
CTRL
of the color keys.
The 64 offers a full range of 16 colors. Though only eight colors are printed on
u can get eight more by holding down the C =
the color keys, yo
you
- key and presspress
ing a color key.
key. Here's a list of the colors:
KEYBOARD
milD
milD
COLOR:
BLACK
WHITE
•
C YAN
~
BLUE
YELLOW
~D
~D
~EI
~a
~D
~D
~D
~D
III
RED
GREEN
KEYBOARD
■
m
~
PURPLE
milD
DISPLAY
•
ii
0n
B
m
=
m
COLOR
ORANGE
DISPLAY
.~
••
BROWN
BRO
WN
fJ
LT
LT.. RED
*
~
G
RAY 11
GRAY
GRAY 2
LT. GREEN
IT.
LT
LT.. BLUE
GRAY 3
..
1
~
« i
II
ii
0□
••
..
When we showed you
you the boucing ball program in the last chapter, you saw
movement, can be written into PRINT
that keyboard commands,
commands, such as cursor movement,
statements.
also
changes
state ments. In
In the
the same way you
you can a
lso add text color c
hanges to your pro
pro-
'-'
grams.
grams.
J
J
'-'
V
'-'
_
v
v
v
v
59
59
Type NEW and try
try experimenting
experimenting with
with changing
changing colors.
colors. Hold
Hold down
down the
the CTRL
CTRL
Type
key and
and at
at the
the same
same time
time press
press the
the 11 key.
key. Now
Now release
release both
both keys
keys and
and press
press the
the
key
R key.
key. Now hold
hold down
down the
the CTRL key again
again and
and press
press the
th e 22 key.
key. Release
Release the
the
R
CTRL key
key and
and type
type the
the A
A key.
key. Move
Move through
through the
the numbers,
numbers, alternating
alternating with
wit h the
the
CTRL
letters, and type
type out the
the word
wo rd RAINBOW
RAINBOW like this:
letters,
10
10 PRINT",
PRIN T" r R.
Rr A.
A r II
t N.B.O.W"
r B rO r w"
mIIaOODDDD
You'll recall
recal l that cursor
cu rsor controls appear as
as graphic
graphic characters in
in the PRINT
PRINT
You'll
are also
also represented as
as graphic characters. The color
statement. Color controls are
color.
chart printed above shows the graphic characters that appear with each
each color.
of the graphic characters
characte rs that are displayed when you select color
Because of
keys, your PRINT statement will
will look strange,
strange, but when you RUN
RUN the
th e program,
program ,
keys,
you' ll see that
that only the
the text of the message is displayed. The letters in
in the
the
you'll
au tomatical ly change colors
colo rs according
according to the color
co lor controls you plac
plac·
message automatically
ed in
in the PRINT statement.
mber of colors
Now try making up some examples of your own
own,, mixing any nu
number
within a single PRINT statement. Don't forget
lorget the second se
colors that you
sett of colors
key
can
can get by holding down the ~
Cs key while you press a color key.
TIP:
TIP:
a program with color or mode (reverse) changes,
ll notice
After you
you RUN a
changes, you'
you'll
itional text yo
u key in is the same as the
that the READY prompt and any add
additional
you
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
COLOR CHRS
CHR $ CODES
CODES
COLOR
Before you
you start
start reading
reading this
this section,
section, take
take aa look
look at
at Appendix
Appendix F,
F, which
wh ich lists
lists
Before
codes for
for all
all keys
keys on
on the
the keyboard.
keyboa rd .
the CHRS
CHRS codes
the
As you
you looked
looked over
over the
the list
list of
of CHRS
CHR$ codes,
codes, you
you probably
probably noticed
noti ced that
that each
each
As
color
color has
has aa unique
unique code,
code,just
just like
like all
all the
the other
other keys
keys and
and the
the keyboard
keyboard controls.
controls. IfIf
you print
print the
the codes
codes themselves
themselves by
by using
using the
the CHRS
CHR$ function
function mentioned
mentioned in
in the
the
you
last chapter,
c hapter, you
you can
can get
get the
the same
same results
results you
you got
got by
by typing
typing CTRL
CTRL or
or [CKJ
~ and
and
last
the
colo
r
key
in
a
PRINT
statement.
the color key in a PRINT statement.
For example,
example, try
try this:
this:
For
NEW
NEW
>
<
10 PRINT
PRINT CHR$(147)
CHR$(147) :: REM
REM < CLR/HOME
CLR/HOM E >
10
20 PRINT
PRINT CHR$(28):-'CHR$(28)
CHR$(28);"CHR$(28) CHANGES
CHANG ES ME
ME TO?"
TO? "
20
RUN
RUN
CHRS(28) CHANGES
CHANGES ME
ME TO?
TO?
CHR$(28)
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
text
should
be
red
now.
is PRINTed. The text
now.
find that it's much
much easier to use
use the CHRS function
funct ion to
to
In many
many cases,
cases, you'll
you 'll find
In
change
change colors,
colors, especially
especially if you
you want to
to experiment.
experiment. The
The next
next page
page shows
shows
ano ther way
way to
to get
get a rainbow
rainbow of
of colors.
colors. There
There are
are aa number
number of
of similar
sim ilar lines in
in
another
(40 through
through 110).
110), so use
use the editing
editing keys to spare
spare yourself aa lot of
the program (40
the end of the program listing
listing to
to refresh
refres h your memory
typing . See the notes at the
typing.
v
v
on editing procedures.
NEW
REM
AUTOMATIC COLOR
11
REM AUTOMATIC
COLOR BARS
5
PRINT CHR$(147)
= CLR/HOM
E
CHR$(147) :: REM CHR$(147)
CHR$(147)=
CLR/HOME
10 PRIN
T
CHRS(18);
"
";:REM
REVERSE
BAR
PRINT
";:REM
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 10
10
80 PRINT
CHRS(144);:
GOTO
10
PRINT CHR$(144);:
90 PRINT
PRINT CHRS(156);: GOTO 10
10
100
100 PRINT
PRINT CHR$(158);:
CHRS(158);: GOTO
GOTO 10
10
11
0 PRINT
110
PRINT CHRS(159);:
CHR$(159);: GOTO 10
10
Type
nes 55 through
Type lilines
through 40
40 normally.
normally. Your
Your display
display should
should look
look like
like this:
this:
v
v
v
11 REM
REM AUTOMATIC
AUTOMATIC COLOR
COLOR BARS
BARS
55 PRINT
CHR$(147):
HOME
PRINT CHR$(147): REM
REM CHR$(147)=
CHR$(147)= CLR/
CLR/HOME
10
"";:REM
;: REM REVERSE
10 PRINT
PRINT CHRS(18);
CHRS(18); ""
REVERSE BARS
BARS
20
RND(1 »+ 1
20 CL
CL =
= INT(8·
INT(8*RND{1))+1
30
0
30 ON
ON CL
CL GOTO
GOTO 40,50,60,70,80,90,100,11
40,50,60,70,80,90,100,110
40
40 PRINT
PRINT CHR$(5);:
CHR${5);: GOTO
GOTO 10
10
•
v
61
61
EDITI NG NOTES:
NOTES:
EDITING
Use the
Ihe <
< CRSR-up
CRSR-up >
> key
key to
to position
position the
the cursor
cursor on
on line
line 40.
40. Then
Then type
type 55 over
over
Use
the 44 of
of 40.
40. Now
Now use
use the
the < CRSR-right
CRSR-right >
> key
key to
to move
move over
over to
to the
the 55 in
in the
the CHRi
CHRS
the
Press SHIFT
SH IFT and
and INST/DEL
INST/DEL to
to open
open up
up aa space,
space, and
and key
key in
in 28.
2S.
parentheses. Press
parentheses.
Now
just
press
RETURN
with
the
cursor
anywhe
re
on
the
line.
Now just press RETURN with the cursor anywhere on the line.
<
The display
display should
should look
look like
like this
this now:
now:
The
NEW
NEW
11
RE M AUTOMATIC
AUTOMATIC COLOR
COLOR BARS
BARS
REM
PR INT CHR${147):
CHR$(147): REM
REM CHR$(147)=
CHR$(147} = CLR/HOME
CLR/ HOM E
55 PRINT
10 PRINT
PRINT CHR$(18);
CHR$(1S); "
;: REM REVERSE
REVERSE BAR
BAR
10
" ;:REM
20 CL
CL =
= INT(8*RND<1))+1
INT(S ·RND(1))+ 1
20
30 ON
ON CL
CL GOTO
GOTO 40,50,60,70,80,90,100,110
40,50,60, 70,SO,90, 100,1 10
30
50 PRINT
PRINT CHR$(28);:
CHR$(2S);: GOTO
GOTO 10
10
50
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·
Don't
Fol low the same steps
steps to
to modify
mod ify line 40 with
with aa new
new line
line number and
and
gram. Follow
until you've entered all
al l the remaining
li nes. As aa final
fina l check,
check, LIST
CHR$ code until
CHR$
remaining lines.
enti re program
program to make
make sure all the lines are
are right before
before you
you RUN
RUN it.
the entire
the color
co lor bar program except for line 30. Here's
Here's aa
You probably understand the
prog ram works.
wo rks.
brief explanation of how this program
line
5 prints
pri nts the CHR$ code for CLR/HOM
E.
Line 5
CLR/HOME.
line
10 turns on reverse type and prints 5 spaces,
spaces, which
wh ich turn out to be a bar
Line 10
reversed . The first time through the program,
since they're reversed.
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
IF/THEN statement,
statement, called ON/GOTO,
ON/GOTO, which
line
lets the program choose from as list of
re the program will go
of line numbers whe
where
next. If the
Ihe ON variable (in this case CL) has a value of 1,
1, the program goes to
the first line number listed (here it's line 40). If the variable has a value of 2,
2. the
program goes to the second line listed,
listed, and so on.
lines
ndom key colors to the appropriate
Lines 40 through 110 just convert the ra
random
CHR$ code for that co
lor and return the program to line 10 to PRINT a section
color
of the bar in that color. Then the whole process starts again
again..
See if you can figure out how to produce 16 random colors. Expand
ON
/GOTO to handle the additional colors and add the remaining CHR$ codes.
ON/GOTO
62
62
HOW TO
TO USE
USE PEEKS
PEEKS AND
AND POKES
POKES
HOW
PEEKS
PEEKS and POKES
POKES let
let you search around inside
inside your
your computer's memory
memory
and stick
stick things
things in
in exactly
exactly where
where you
you want
want them
them..
and
You
'll recall
You'll
recall that
that in
in Chapter 4 we explained variables as
as being
being like
like little slots
in
's address. Well
in the computer's memory,
memory, with the variable name
name as the slot
slot's
Well,,
imagine
imagine some more
more specially defined slots in
in the computer that stand for
for
memory locations
locations and that have
have numbers
numbers for addresses.
specific memory
Your 64 looks
ions to see what the screen's
looks at these memory
memory local
locations
background
background and border
border colors should be,
be, what characters to display on the
screen and where to display them, etc.
You can change the screen colors, define and move objects, and even create
music
music by
by POKEing a different value into
into the specific memory slots.
Imagine some memory
memory slots looking something like this:
Imagine
I 53~80 I I 53~81 I
53280
53281
2
1
BORDER
COLOR
BACKGROUND
COLOR
53282
53282
53283
' -"'53"'2"'83;;--1
The first two slots are the memory locations for the border and background
colors on your screen.
screen. We've put 2, the value for RED in the border color box,
box,
and 1,
1, the value for WHITE in the background color box. Now try typing this:
POKE 53281,7
RETURN
wil!l change to yel
yellow
The background color of your screen wil
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
1
1
2
2
3
4
4
5
5
6
7
7
BLACK
WHITE
RED
CYAN
PURPLE
GREEN
BLUE
YELLOW
YELLOW
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
ORANGE
BROWN
light RED
GRAY 11
GRAY 22
GREEN
light GREEN
light BLUE
BLU E
3
GRAY 3
Here's aa little
little program that you can
can use to
to display
display various
various border and
and
Here's
background
background color
color combinations:
combinations:
NEW
10
BA = 0TO
0 TO 15
15
10 FOR
FOR BA
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
This
This program
program uses
uses two
two simple
simple loops
loopsto
to POKE
POKEvarious
variousvalues
values toto change
change the
the
background
50 contains
contains aa DELAY
DELAY loop,
loop, which
which just
just
background and
and border
border colors.
colors. Line
Line 50
slows the
the program
program down
down aa little
little bit.
bit.
slows
IfIf you're
you're curious
curious about
about what
what value
value isis currently
currentl y inin the
the memory
memory location
location for
for
background color,
color, try
try this:
this:
background
?PEEK (53280)
(53280) AND
AND 15
15
?PEEK
PEEK
PEEK looks
looks at
at aa whole
whole byte,
byte, but
but colors
colors only
only use
use half
half aa byte,
byte,called
called aa nybble.
nybble.
To PEEK
PEEK just
just this
this nybble,
nybble, you
you have
have to
to add
add the
th eAND
AND 15
15to
to your
your PEEK
PEEK statement.
statement.
To
you used
used this
this PEEK
PEEK after
after RUNning
RUNning the
the previous
previous program,
program,you'd
you'd get
get 15
15 as
as the
the
IfIf you
answer because
because the
the last
last border
border color
color POKEd
POKEd was
was GRAY
GRAY 3,3, which
which is
is 15.
15.
answer
In
In general,
general, PEEK
PEEK lets
lets you
you see
see what
what value
value is
is currently
currentl y in
in aa specific
specific memory
memory
slot. Try
Try adding
adding this
th is line
line to
to your
you r program
program to
to display
display the
the values
values of
of BORDER
BORDER and
and
slot.
BACKGROUND as
as the
the program
program RUNs.
RUN s.
BACKGROUND
25 PRINT
PRINT CHR$(147);
CHR$(147); "BORDER
"BORDER == ";"; PEEK(53280)
PEEK(53280) AND
AND 15,
15,
25
""BACKGROUND
BACKGROUND == ";"; PEEK
PEEK (53281)
(53281) AND
AND 15
15
SCREEN GRAPHICS
GRAPHICS
SCREEN
So
So far when you've
you've PRINTed
PRINTed information,
information, the
the computer
computer has
has handled
handled the in
in·
formation sequentially:
sequentially: one
one character
character PRINTed
PRINTed after the next,
next, starting
starting from
from the
cursor position,
position, except
except when you
you asked
asked for aa new
new line,
line, or used
used aa comma
current cursor
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.
this takes
takes time
time and program steps.
display. But this
steps.
But just as there are certain locations in the 64's memory to control color,
color,
there
are also
also memory
memory locations
locations that
that you
you can
can use
use to
to control
control screen
locations.
there are
screen locations.
64
64
_
SCREEN MEMORY
MEMORY MAP
MAP
SCREEN
The
The 64's
64's screen
screen can
can hold 1000
1000 characters (40
(40 columns by
by 25 lines), so
so there
there
are
are 1000
1000 memory locations
locations set aside to represent
represent what is on the
the screen. ImagImag
ine
ine the screen as a grid,
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
POKE the value for a character into a speci
specific
number from 0 to 255. IfIf you POKE
fi c
ll be displayed in that specific screen
screen memory location, that character wi
will
location.
Here's a grid that represen
represents
Here's
ts your screen, complete with the numbers of each
screen memory
memory location.
location.
10
COLUMN
COLUMH
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
JO
464
1464
504
ISD~
544
15u
v
584~
158
624
!62~
664
166J
704
110J
744
1744
v
784
1784
824
1824
8G4
IBM
904
190J
944
19H
10
9E4
19M
\t
202]
mi
v
v
65
65
"
i
The
The64's
64'sscreen
screenmemory
memorynormally
normallybegins
beginsatatmemory
memorylocation
location1024
1024and
andends
ends
location2023.
2023. Location
Location1024
1024isisthe
the upper
upperleft
leftcorner
cornerofofthe
thescreen.
screen.Location
Location
atatlocation
1025isisthe
theposition
positionofofthe
the next
nextcharacter
charactertotothe
theright,
right,and
andso
soon.
on.Location
Location 1063
1063
1025
the right-most
right·most position
positionofofthe
thefirst
first row.
row. Following
Followingthe
the last
lastcharacter
characterininaarow,
row ,
isisthe
the next
next location
location isis the
the left-most
left·most character
character on
on the
the next
next row
row down.
down.
the
Suppose
Supposeyou
you want
want totocontrol
control aaball
ball bouncing
bouncingon
on the
thescreen.
screen.The
The ball
ball isis ininthe
the
middle
29, row
row 12.
12. The
The formula
formula for
for calculating
calculating the
the
middle of
of the
the screen,
screen, column
column 29,
memory location
location on
on the
the screen
screen is:
is:
memory
POINT == 1024
1024 ++ XX ++ 40
40'
y - row
row
POINT
■ Y—
II
column
column
where XX is
is the
the column
co lu mn and
and YY is
is the
the row.
roV/.
where
Therefore,
the
memory
location
of
the ball
ball is:
is:
Therefore, the memory location of the
POINT == 1024
1024 ++ 20
20 ++ 480—row
480 - row (40x12)
(40x12)
POINT
POINT == 1524
1524
column
POINT
II
-column
Clear the
the screen
screen with
with SHIFT
SHIFT and
and CLR/HOME
CLR/HOME and
and type:
type:
Clear
POKE 1524,81—character
1524,81- character code
code
POKE
L - location
Iocation
I—
Thi s POKE
POKE statement
statement makes
makes aa ball
ball appear
appear in
in the
the middle
middle of
of the
the screen.
screen. You
You
This
have placed
placed aa character
character directly
directly into
into screen
screen memory
memory without
without using
using the
the PRINT
PRINT
have
statement. However,
However, you
you can't
can't see
see the
the ball
ball yet
yet because
because it's
it's the
the same
same color
color as
as
statement.
the screen
screen background.
background.
the
COLOR
MAP
COLOR MEMORY
MEMORY MAP
You can change the color of the ball that appeared by altering another range
of
of memory.
memory. Type:
Type:
POKE 55796,2color
55796.2—color
L-Iocation
I
location
Th
is changes
This
changes the
the ball's
ball's color
color to
to red.
red.
Every
Every spot
spot on
on the
the 64's
64's screen
screen has
has TWO
TWO memory
memory locations:
locations: one for the
character
character code,
code, and
and one
one for
for the
the color
color code.
code. The
The color
color memory
memory map
map begins
begins at
at
location
location 55296
55296 (upper
(upper left
left corner),
corner), and
and continues
continues on
on for
for 1000
1000 locations.
locations. You
You use
use
the same
same color
color codes,
codes. 00 through
through 15,
15, that
that you
you used
used to
to change
change border
border and
and
the
background
background colors,
colors, to
to directly
directly change
change character
character color.
color.
We can
can modify
modify the
the formula
formula for
for calculating
calculating screen
screen memory
memory locat
locations
to give
give
We
ions to
us
us the
the locations
locations to
to POKE
POKE colors.
colors. Here's
Here's the
the new
new formula:
formula:
- row
COLOR
COLOR PRINT
PRINT == 55296
55296 +
+ X
X +
+ 40
40 •* Y
Y—row
II
column
column
66
66
v
MORE BOUNCING BALLS
Here's a revised bouncing ball program that directly prints on the screen us·
us
statements.
s. When you
ing POKEs rather than cursor controls within PRINT statement
RUN this version, you'll see that it's much more flexible than the earlier pro·
pro
gram and it leads up to programming more sophisticated animation.
v
v
v
NEW
10 PRINT" SHIFT CLR/HOME "
20 POKE 53280,7 :: POKE 53281,6
X = 1 : Y - 1
30 X=l:Y=l
40
DX = 1
1 ::DY
= : 11
OX
OY =
40*Y,81
50 POKE 1024 + X + 40'Y,81
1 TO
TC 10 :: NEXT
60 FOR T = 1
X + 40'Y,32
70 POKE 1024 + X
40*Y,32
X + OX
DX
B0 X = X
80
IFX < = OORX>=
0 OR X> = 39 THEN OX
DX = -OX
-DX
90 IFX<=
Y = Y
Y +
+ OY
DY
100 Y
< = 0
OOF
DY = --DY
110 IF Y
Y<
OR! Y> = 24 THEN OY
OY
120 GOTO 50
Line 10 clears the screen.
Line 20 sets the background color to blue and the border color to yellow.
The X
X and Y
ball's current row and col·
col
Y variables in line 30 keep track of the bali's
umn position. The DX
OX and DY variables in line 40 are the horizontal and vertical
v
off the bali's
ball's movemenL
movement. When a + 11 is added to the value of X, the ball
direction o
+ 11 added to
moves to the right; when -- 1
lefL A
A+
1 is added,
added, the ball moves to the left.
Y moves the ball down aa row, and aa -- 1
Y moves the ball up a row.
row .
Y
1 added to Y
Line 50 puts the ball on the screen at the c
current
position.. Line 60 is a
urrent X,Y position
a
delay loop,
loop, which is included to keep the ball on the screen long enough for you
to be able to see it.
Line 70 erases the ball by putting
putting aa space (code 32) where the ball was on the
screen.
screen.
Line 80 adds the direction factor to X.
X.
90 tests to see if the
the ball
bal l has reached one
one of the side walls,
walls, and reverses
Line 90
the
the ball's
ball's direction if there's
there 's aa bounce. Lines 100
100 and 110
110 do
do the
the same thing
thing for
the
the top and bottom
bottom walls.
Line
Line 120
120 sends the
the ball
ball back to
to display and moves the
the ball
ball again.
You can
can change
change the
the ball to any
any other
other character by changing the
the code in line
You
50 from 81
81 to
to another character code.
OX or
or DY
OY to
to 00 the
the ball bounces
bounces straight
strai ght instead
instead of diagonally.
If you
you change
change DX
If
We
can
also
add
a
little
intelligence
to
the
bouncing
ball
program.
We can
add a
intelligence to the bouncing
program. So
So far the
bounds on the
the
you checked
checked for is
is whether
whether the
the ball
ball is
is going out of bounds
only thing you
screen.
screen. Try
Try adding
adding the
the following lines
lines to
to the
the program:
program:
21
21
25
25
FOR
FOR LL = 11 TO
TO 10
10
POKE
1000).166
CHRSCODE
POKE 1024
1024 +
+ INT(RND(1)*
INT(RNO(1)'1000),166-CHRSCOOE
27
27
NEXT
NEXT LL
+
+
115
115 IF PEEK(1024
PEEK(1024 + XX + 40"Y)
40 ' Y) =
= 166
166 THEN
TH EN DX
OX =
- DX
OX:: GOTO
GOTO 80
80
Lines 21
21 to
to 27
27 put ten
ten blocks
bl ocks on
on the
the screen
screen in
in random
random positions.
positions. Line
Line 115
115
Lines
PEEKs
PEEKs to
to see
see if the
the ball
ball is
is about
about to
to bounce
bounce into
into aa block,
block, and,
and, ifif so,
so, itit changes
changes
the
the ball's
bal l's direction.
direction.
v
67
67
n
()
—
—
—
-
n
n
~
**
CHAPTER 77
CHAPTER
INTRODUCTION TO
TO SPRITES
SPRITES
INTRODUCTION
Bits, Bytes
Bytes and
and Sprites
Sprites
•• Bits,
Creating Sprites
Sprites
•• Creating
••
More on
on Sprites:
Sprites: Colors
Colors and
and Extra
Extra Movement
Movement
More
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 to
to create
create animation
animation and
and other
other visual
visual effects.
effects.
statements
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
on the
the screen
screen in
in the
the
screen memory
memory locations,
locations, which
which put
put characters
characters directly
directly on
screen
place you
you selected.
selected.
place
In both
both of
of these
these cases,
cases, you
you have
have to
to create
create objects
objects from
from existing
existing graphic
graphic sym
symIn
bols,
bols, so
so these
these methods
methods take
take aa lot
lot of
of work.
work. When
When you
you want
want to
to move
move the
the object,
object,
you must
must use
use aa number
number of
of program
program statements
statements to
to keep
keep track
track of
of the
the object
object and
and
you
move
and resolution
resolution of
of the
the object
object
move itit to
to aa new
new place.
place. And
And sometimes
sometimes the
the shape
shape and
isn't as
as good
good as
as 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
isn't
symbols.
symbols.
You
You can
can eliminate
eliminate aa lot
lot of
of these
these problems
problems by
by using
using sprites
sprites in
in animated
animated se
sequences. A
A sprite is
is aa high-resolution
high-resolution porgrammable
porgrammable object
object that you can make
make
quences.
have to do to
into just
just about any shape by using
using BASIC commands. Ail
All you have
move
move the
the object
object is
is 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
isn't all
all you
you can
can do
do with
For example
example,, you
But this
with sprites.
sprites. For
you can
can change
change their
their
color, you can tell if one object collides with another, you can make them go in
ly expand their size.
front and behind each other, and you can easi
easily
You have to learn a few more details about your 64 and the way it hand
les
handles
numbers
before
you
can
use
sprites.
It's
not
difficult,
though,
so
just
follow
the
numbers before you can use sprites. It's not difficult, though, so just follow the
examples and
and you'
you'llll be
be maki
making
your own
own sprites
sprites do
do amaz
amazing
things in
in no
no time.
time.
examples
ng your
ing things
68
68
v
BITS, BYTES,
BYTES, AND
AND SPRITES
SPRITES
BITS,
Before you
you can
can use
use sprites,
sprites, it's
it's important
important that
that you
you understand
understand aa few
few general
general
Before
v
thing s about
about how
how computers
computers work,
work, so
so here's
here's aa little
little about
about binary
binary arithmetic.
ari thmeti c.
things
Think
o
f
your
computer's
memory
as
a
co
llec
ti
on
of
BYTES,
whic
break
Think of your computer's memory as a collection of BYTES, whichh break
down
down into
into eight
eight BITS
BITS per
per byte.
byte. AA bit,
bit, which
which is
is the
the smallest
smalles t amount
amount of
of informa
informa·
tion aa computer
computer can
can store,
store, can
can have
have only
only two
two values:
val ues: ON
ON or
or OFF.
OFF. When
When aa bit
bit isis
tion
ON , itit has
has the
th e value
value of
of 1:1; when
when aa bit
bi t is
is OFF,
OFF, itit has
has the
the value
value of
o f 0.
O.
ON,
When you
you program
program your
your computer,
computer, what
wh at you're
you're doing
doing is
is turning
turnin g bits
bi ts ON
ON or
or
When
OFF.
OFF. Since
Since there
Ihere are
are so
so many
many bits,
bits, and
and since
sin ce each
each different
different configuration
con figurati on of
o f ON
ON
and OFF
OFF bits
bits sends
sends aa different
different message
message to
to the
the computer,
computer, you
you can
can do
do incredible
inc redible
and
wi th your
your 64.
64.
things with
things
you have
have two
two bits
bits combined
com bined as
as aa unit
un it of
of meaning,
mean ing, you
yo u have
have four
fo ur possible
possible
IfIf you
values.
va lues. This
Th is illustration
illustration shows
shows how
how the
the number
number of
of possible
poss ible values
valu es increases
increases
with the
th e number
number of
of bits:
bit s:
with
NO. OF
OF
NO.
BITS
BITS
VALUES
VALUES
POSSIBLE
POSSIBLE COMBINATIONS
COMBINATIONS
11
22 tt 11
ON
ON
11
2
= 2
OFF
OFF
0
0
t 2
22 t2
ON and
and ON
ON
ON
11 11
2
2
NO. OF
OF
NO.
ON and
and OFF
OFF
ON
4
= 4
3
3
11 0
0
o
ON
OFF and
and ON
OFF
0 11
OFF and OFF
0
0
00
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
ON and OFF and OFF
OFF and ON and ON
OFF and OFF and ON
OFF and ON and OFF
OFF and OFF and OFF
10 1
10
1
11 0
0
00
0 1
111
00 1
001
v
o
o0 11 0
0 00
000
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
bits,you have 218,or
2t8,or 256,
256, difdif
of the number of bits.
ferent combinations of bits. Eig
ht bits equal a BYTE, so a byte can store 256 difEight
dif
ferent values.
When all eight bits
bits are OFF, the byte equals zero;
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).
0's,
Any combination of a byte's ON's and OFF's, or 11's
's and O
's, converts to a
decimal (i.e., base
base 10)
10) value between 0 and 255. Here's a way to figure out the
value of the byte
byte when you have
have different combinations of ON and OFF bits:
bits:
v
v
Draw
's for ON bits
Draw aa table for the eight bits
bits and fill in
in 1
1's
bits and O's
0's for OFF bits.
bits.
Across the top of the
ese numbers
the table, write 128,
128, 64,
64, 32, 16,
16, 8, 4, 2, and 1.
1. Th
These
numbers
are
2 11
are 2 17,
17, 2 16,
t 6, 2 tt 5, 2 tt 4,213.2
4, 2 t 3, 2 12,
t 2,2
11,, 210,
2 t 0. or
or 2 to
to the
the power
power of
of each
each of
the eight
eight bits,
bits, with
with the
the bits
bits numbered
numbered 0 through
through 7. For
For example:
example:
16
88
4
16
0
1
0 11
1
128
64
32
32
64
128
1
0
11
0
1
2
00
Now
Now add
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
1
1
—
Here's aa table
tabte showing
showing BINARY
BINARY to
to DECIMAL
DECtMAL conversion.
conversion. AA zero
zero indicates
indicates
Here's
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
enthat
tire byte,
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.
tire
BINARY TO
TO DECIMAL
DECIMAL CONVERSION
CONVERSION
BINARY
Decimal
Decimal Value
Value
•
128
128
64
6'
32
32
16
16
88
4
22
0
0
0
0
0
0
0
0
0
0
0
0
0
11
0
0
0
0
0
0
0
0
0
0
0
0
11
0
0
0
0
0
0
0
0
0
0
0
11
2|0
210
0
0
7\
2111
-
11
0
0
0
0
0
0
0
0
11
0
0
0
0
00
11
0
0
0
0
2]
2
212
0
0
0
0
11
0
0
0
0
0
0
2T3
213
0
0
J1
0
0
0
0
0
0
0
0
2?4
21'
11
0
0
0
0
0
0
0
0
0
0
2T5
2)5
0
0
0
0
0
0
0
0
0
0
0
0
2|6
216
0
0
0
0
0
0
0
0
0
0
0
2f7
217
TIP:
TIP:
binary numbers
numbers to their
their decimal
decimal values
values is the basis
basis for
for creating
Converting binary
data to represent and manipulate
mani pulate sprites.
sprites. Here's a program that does these
data
for you.
you . Since you'll be using
using this program
program often,
often , you should enter
enter
conversions (or
and save it.
5 REM BINARY TO DECIMAL CONVERTER
5
10 INPUT ""ENTER
ENTER 8-BIT BINARY NUMBER :";A$
10
12
12
15
20
30
40
50
60
<>
(A$) > 8 THEN PRINT ""88 BITS PLEASE
... ": GOTO 10
10
IF LEN (A$)<
PLEASE...":
0::C
C = 0
TL = 0
FOR X = 8 TO 1
- 11 :: C = C + 1
1 STEP 1
TL = TL + VAL(MIDS(A$,C,I»'2
VAL(MID$(A$.C.1))*2 t(X-l)
t(X-1)
NEXT
X
NEXTX
PRINT AS;"
AS; " BINARY "•■;"
;" = ";TL;" DECIMAL"
GOTO 10
At line 10 you enter a binary number as the string A$. Line 12 uses the LEN
(length) function to check to be sure you entered 8 binary digits.
digits. If you didn't,
the program asks for more and repeats line 10.
10.
ue, and C in·
In line 15,
15, TL keeps track of the binary number's decimal val
value,
in
dicates which bit is bei
ng worked on as the program goes through the loop.
being
value
VALand
MIDS funcfunc
Line 30 updates the val
ue of TL. Appendix C explains the VAL
and MID$
tions.
Line 50 PRINTs
PRINTS the binary and decimal values of the byte.
byte. Line 60 returns the
program to the beginning.
70
—
-
~
v
v
A block
block of
of bytes
bytes strun
strung
up a REG
REGISTER.
For sprite·making,
sprite-making,
A
g together makes up
ISTER. For
on.
each
each register
register is
is only
only one byte
byte long. Each
Each register
register controls a
a different functi
function.
For
le, the ENABLE
s whether
For examp
example,
ENABLE REGISTER
REGISTER control
controls
whether the sprite is ON or
or OFF;
th
e EXPAND
ISTER can
the
EXPAND X REG
REGISTER
can make
make the sprite longer,
longer, etc.
etc. When you work with
sprites, keep in
ISTER is a BYTE
in mind that a REG
REGISTER
BYTE that does a
a specific job.
A series of regi
sters makes
registers
makes up a chart called a REGISTER
REGISTER MAP.
MAP. You can find
in Appendix P.
P.
the register map for the VIC chip in
Now,
fi c ad·
Now, another important thing about bytes
bytes is
is that each byte
byte has
has a speci
specific
ad
dress in
in the computer's memory,
memory, so you can go to a specific byte if
if you know
know
its address. You used this in the last chapter when we introduced PEEKing and
POKEing.
Sprites use only some of you
yourr computer's bytes. When you work with sprites,
you're in closer contac
contactt with bytes than you are when you program in BASIC
working
because you're worki
ng directly with byte addresses. When you work with
sprit
es, you are direc
tl y con
tro lling which bits are ON and which are OFF.
sprites,
directly
controlling
To understand how to use sprites, you need to be able to figure exactly which
bytes you want to use. In this chap
ter, we'll give you formu
las for findi
ng the
chapter,
formulas
finding
bytes you want, and we'll give you sample programs for creating sprites. The
Commodore 64 Programmer's Reference Guide goes into extensive detail on
sprites.
v
'-'
'-'
v
v
v
v
'-'
v
v
V
V
v
v
v
71
71
~-
CREATING SPRITES
controlled
(VIC-II chip) in the 64.
Sprites are control
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.
colors, and moving the graphics around. All
Ail you have to do is
graphics,
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·
nal memory locat
ions. Each of these locations breaks down into a series of 8
locations.
bytes, and each byte can be either ON or OFF. So this means you
you have 368
bytes,
ON/OFF locations for sprites. By POKEing the appropriate decimal val
ue in the
value
location, you can control the formation and movement of your
proper memory location,
sprites. We'll give you more detail about
aboul this later.
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.
details, but don't worry,
worry, you'll get the hang of it as we go
Sounds like aa lot of details,
through some examples.
Before you get started,
started, here are some important things to know about
sprites:
•
'"'
0.
Sprites are usually displayed in a special high resolution mode which turns
a 320 dot wide by 200 dot high area.
the screen into a
area.
•
Each sprite
sprit e object is 24 dots wide
wide by 21 dots high.
•
a time. The sprites are numbered 00 to 7.
You can control up to eight sprites at a
•
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
VIC·II chip
chip locations control the functions
But first you need to know what VIC-II
you need.
need. Remember that the sprites' chip
ch ip has 46 different ON /OFF
/O FF locations.
a partial
partial map
map that shows some of these locations, which are called
Here's a
registers. Appendix
Appendix P
P has
has aa complete
comp lete VIC
VIC chip register map.
map, but the registers
registers.
you'll need for
for sprites
sprites are
are listed
listed here:
Registers
0
11
o
Description
X
X coordinate
coordinate of sprite
sprite 00
Y coordinate
coordinate of
of sprite
sprite 00
Y
2·15
2-15
X and Y
Y coordinates, paired
paired like registers 00 and
and 11 for sprites
X
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
29
29
39-46
39-46
Expand
Expand sprite
sprite in
in Y
Y direction
direction
Expand
Expand sprite
sprite in
in X
X direction
direction
Sprite
Sprite 0-7
0·7 color
color
72
Now we'll show you how to write a prog
ram to create and move a sprite obprogram
ob
ject. Here are some things you'll learn to do:
o•
o•
o•
o•
o•
v
v
v
Make the sprite(s) appear on the screen by POKEing into location 21
21., the
register that turns ON sprites.
pointer (memory locations 2040-2047) to show where sprite
Set the sprite pOinter
data should be read from.
memory.
POKE actual data into memory.
coordinates.
Move the sprite around by using a loop to update X
X and Y
Y coordinat
es.
Expand the sprite objec
t, change colors, perform a variety of special tasks.
object,
Suppose you want to create a ball
oon and have it float around. You can
balloon
74).
design the balloon in a 24 by 21 dot grid (see page 74).
nextt step is to convert the graphic design into data
lata the computer can
The nex
ud a sample grid that is
use. Use a piece of lined paper or graphic paper to set up
21 spaces down and 24 spaces across. Divide the 24 squares across the top in·
in
on with this seri
es of
to three sections,
sections, and number the squares in each secti
sec'ion
series
numbers: 128,64,
32, 16,
8,4, 2, 1 (see the illustration).
2 t 7,
7,
128,64,32,
16,8,4.2,1
illustration). T'lese
~ i-3se numbers are 2
2
2 t 5,
5, 2 t14,
2 t16,
6,2
4,22 t13,
3, 2 tt 2, 2 11,
t 1,22 10,
to, in other word , 2 to the power of the
number of the sprite you
're using. Recall that the eigh
you're
eightt sprites are numbers 0
through 7.
7.
Number the squares down the left side 1-21 for each row. Write the word data
at the end of each row. Now fill in the grid with any design, or use the balloon
that we've drawn.
drawn. It's easiest to outline the shape first and then go back and fill
in the grid.
Think of the squares you
you filled in as ON, and substitute a 11 for each filled
each of them a
sq uares that aren't filled as OFF.
OFF, and give each
square. Think of the squares
zero.
zero.
Now you
you need to separate each row into thirds so you can convert the ONs
sim·
and OFFs
OFFs into pieces of data the computer can read. Dividing the rows is sim
pie since you've
yo u've already split each row into
into three sections.
sections.
ple
Now each section of each row has eight squares,
squares, and each set of eight
squares is
called
piece of data ca
lled aa BYTE.
BYTE. This
Thi s means you
you have three
is equal to
to one piece
bytes per row.
row .
Startin g on the
th e first
first row of the balloon drawing
drawing and working from
from the left, the
Starting
first eight squares are blank (0),
so
the
value
for
that
series
(byte)
is 0.
(0),
for th at
O.
v
v
v
v
73
73
-
SERIES
SERIES
118
88
128 31
32
64 16
2
4
SERIES
:
I1
128
11
28
32
64
16
2
4
SERIES
3
I
;31
128
11
64
8
16
1
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-+-
++:t+rn:t+
I) ++++ 1-++-++
15
16
18
19
10
11
-t
+t++t+I+++
++++I-++-++++ +++ I-++-+++-
+-II-+I-+-++t+++
I15
10
COLUMN
The middle series of squares looks lilike
ke this (remember that a 1
led dot
1 is a fil
filled
and a a
0 is a blank dot):
128
64
32
SZ
16
16
8
4
2
1
1
1
1
o0
1
1
1
it
it
it
it
ir
it
ti
it
o0+64+32+16+8
+ 64 + 32 + 16 + 8 + 44+
+ 22+1
+ 1
74
n
=
127
The third series of ei
ght squares also contains only blanks, so it also equals
eight
So, the data fo
forr the first line is:
is:
zero. So,
°
DATAO,
127,0
DATA
0, 127,
The three series of dots that make up row two are calc
ulated like thi
s:
calculated
this:
Series
1:
Se
rie s 1:
Series 2,
2:
Series
I
I
0
eel
>
if
+
0
0
I
I
1
iT
128
I
0
0
0
1
1
1
iT
I
1
1
1
it
it
0
0
}
+
it
128
64
128+64+32
32
Series 3:
0
16+8
+ 8
+ 16
0
1
1
1t
1
]
iT
~
1
1
1t
+4
+
4
+2
2
+
+ 11
0
0
0
=
255
1T
+ 64
+
=
192
The data for the
the second row is:
DATA 1,
1,255,
255, 192
ei ght squares in each of the reUse this method to convert the three series of eight
re
maining rows.
Once you have done the rest of the conversions, yo
you
you need
u have the data you
to make the
the balloon.
ball oon.
Type in
in the following
fol lowi ng program:
v
11
REM UP,
UP, AND AWAY
UP, UP,
5
5
10
10
PRINT "(CLRlHOME)"
"(CLR/HOME)"
V
V = 53248:
53248 : REM
REM START
START OF DISPLAY CHIP
11
11
12
POKE V
V + 21,4 :: REM ENABLE
ENABLE SPRITE 22
POKE 2042,13
2042,13 :: REM SPRITE
SPRITE 22 DATA
DATA FROM 13TH BLK
BLK
20
20
Q : POKE 832+ N,Q:
NEXT
FOR N
N = 0 TO 62:
62: READ Q:
N,Q: NEXT
FOR
J
FOR X
X =
= 0 TO
TO 200
200
GETS ITS INFO.
POKE
PO KE V
V + 4,X:
4,X: REM UPDATE
UPDATE X
X COORDINATES
FROM DATA
POKE V
V+
+ 5,X:
5,X: REM UPDATE Y
Y COORDINATES
NEXTX
NEXT X
INFO. READ IN
GOTO 30
FROMQ
DATA
DATA 0,127,0,1,255,192,3,255,224,3,231,224
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
DATA
DATA 3,255,224,3,255,224,2,255,160,1,127,64
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
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
30
30
40
40
50
50
60
60
70
70
200
210
220
220
230
230
240
240
°°
v
v
75
75
IfIf you
you typed
typed everything
everything correctly,
correctly, your
your balloon
balloon isis sailing
sailing across
across the
the screen.
screen.
To
To understand
understand what
what happened,
happened, you
you need
need to
to know
know where
where each
each sprite
sprite defini
defini·
tion isis located
located inin memory.
memory.
tion
Recall
Recall that
that each
each sprite
sprite isis 24
24 by
by 21
21 dots,
dots, which
which equals
equals 504
504 dots,
dots, which
which inin turn
turn
equals 63
63 bytes
bytes (504/8
(504/8 bits).
bits). So
So each
each sprite
sprite isis 63
63 bytes
bytes plus
plus 11byte
bytewhich
which isis the
the
equals
sprite's
sprite's place
place holder,
holder, or
or pointer.
pOinter. The
The pointers
painters for
for each
each of
of the
the eight
eight possible
possible
sprites
sprites are
are located
located together
together as
as the
the last
last eight
eight bytes
bytes of
of the
the SCREEN
SCREEN MEMORY.
MEMORY.
Normally,
the
pointers
begin
at
location
2040
for
sprite
0.
through
Normally, the pOinters begin at location 2040 for sprite 0, through 2047
2047 for
for
sprite 7:7:
sprite
2040
2040
2041
2041
2042
2042
2043
2043
2044
2044
2045
2045
2046
2046
33
44
55
66
2047
2047
sprite
sprite
sprite
0
22
1
77
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.
Line
Then
Then later
later in
in the
the program
program you
you can
can get
get the
the VIC
VIC chip
chip memory
memory location
location you
you want
want
just by
by adding
adding the
the appropriate
appropriate register
register number
number to
to V.
V.
just
Line
line 11
11 makes
makes sprite
sprite 22 appear
appear by
by POKEing
POKEing aa 44 into
into the
the SPRITE
SPRITE ENABLE
ENABLE
(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·
REGISTER (21).
REGISTER
cond power.
power. Recall
Recall that
that the
the decimal
decimal value
value for
for aa sprite
sprite is
is 22 to
to the
the power
power of
of the
the
cond
you wanted
wanted to
to turn
turn ON
ON sprite
sprite 3,
3, you'd
you'd use
use this
this state
state·
number of
of the
the sprite.
sprite. IfIf you
number
ment:
+ 21,8.
21,8. You
You turn
turn aa sprite
sprite ON
ON by
by POKEing
POKEing the
the decimal
decimal value
value for
for
ment: POKE
POKE VV +
(21).
Here's
how
register
21
looks
after
the
sprite
into
the
sprite
enable
register
the sprite into the sprite enable register (21). Here's how register 21 looks after
line 11
11 turns
turns ON
ON sprite
sprite 2:
2:
line
R~;
REG.
21
64
64
1 8
128
1
:
0
7
1
0
0
6
1
32
16
3002
1 :0
5
8
1
:0
3
4
2
4
1
41
22
1
:
0
1
1
1
o
1
decima
decimal
values
0
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
Line 12
12 tells the computer where to lind
find the data for sprite two. Recall that
pointer
into spri
sprite
the pOin
ter for sprite 2 is memory location 2042. This line POKEs a 13 into
te
2's pOinter,
pointer, which means
means that sprite 2's data will be
be kept
kept in the 13th
13th series of
sprite bytes.
bytes.
line
Line 20 puts
puts data into
into the 63 bytes
bytes that make
make up
up a sprite. READ
READ Q
Q gets the
data
data from the DATA
DATA statements in
in lines
lines 200 through 240. The 832
832 in
in the POKE
POKE
statement
statement is
is the
the location
location of
of the
the 13th
13th block
block of
of sprile
sprite bytes.
bytes. As
As the
the loop
loop in
in line
line 20
READs
READs data,
data, the values
values are
are POKEd
POKEd into
into the
the 63
63 sprite
sprite bytes
bytes located
located in
in block
block 13.
13.
Lines 30
30 through
through 50
50 control
control the
the sprite's
sprite's movement
movement across
across the
the screen.
screen. line
Line 40
40
lines
POKEs the
the value
value of
of X
X into
into the
the VIC
VIC chip
chip register
register location
location (4)
(4) that
that represents
represents the
the
POKEs
sprite
sprite 2'5
2's X
X coordinate.
coordinate. The
The X
X coordinate
coordinate represents
represents horizontal
horizontal movement.
movement. Line
Line
50 POKEs
POKEs the
the current
current value
value of
of X
X into
into the
the register
register location
location (5)
(5) that
that stands
stands for
for
50
sprite
rt ical movement.
sprite 2's
2's Y
Y coordinate,
coordinate, or
or ve
vertical
movement. This
This loop
loop moves
moves the
the sprite
sprite DOWN
DOWN
and
and TO
TO THE
THE RIGHT.
RIGHT.
line
Line 70
70 starts
starts the
the program
program over
over again.
again.
lines
200
through
240
contain
the
Lines 200 through 240 contain the data
data for
for the
the sprite.
sprite.
Try
Try adding
adding the
the following
following line
line and
and RUN
RUN the
the program
program again:
again:
25
+ 29,4:
25 POKE
POKE V
V +
+ 23,4:
23,4: POKE
POKE VV-f
29,4: REM
REM EXPAND
EXPAND SPRITE
SPRITE
76
76
(]
v
v
v
v
Now
Now the
the balloon
balloon has
has doubled
doubled inin size
size because
because you
you POKEd
POKEd the
thedecimal
decimal value
value
r·
for
forsprite
sprite 22 into
intoregister
register23,
23, which
which controls
controls aasprite's
sprite's expansion
expansion inin the
the Y,
Y, or
orve
ver
tical,
trols aa sprite
's expansion
tical, direction,
direction, and
and into
into register
register 29,
29. which
which con
controls
sprite's
expansion in
in the
the
X, or
or horizontal
horizontal direction.
direction.
X,
Now
Now try
try adding
adding sprite
sprite 33 to
to your
your screen
screen by
by entering
entering these
these lines:
lines:
11
11
12
12
30
30
45
45
55
55
POKE VV ++ 21
21,12
POKE
,12
POKE 2042,13:
2042.13: POKE
POKE 2043,13
2043.13
POKE
FOR X
X == 11 TO
TO 190
190
FOR
POKE V
V +
+ 6,X
6,X
POKE
POKE
V
+
7,190 -- X
X
POKE V + 7,190
Line
Line 11
11 turns
turns ON
ON sprites
sprites 22 and
and 33 by
by POKEing
POKEing their
their combined
combined decimal
decimal values
values
(4 and
and 8)
8) into
into the
the sprite
sprite enable
enable register
register (21).
(21).
(4
lls the
Lin
e 12
Line
12 te
tells
the computer
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
VIC chip
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
Lines 45
45 and
and 55
55 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
Y coordinates
coordinates (V
(V + 66 and
and V
V +
+ 7).
7).
Y
lines put
put sprite 4
4 on
on the
the screen,
screen, too:
too:
The following lines
v
11
11
12
12
25
25
48
48
58
58
POKE V
V + 21
21,28
POKE
,28
POKE 2042,13:
2042.13: POKE
POKE 2043,13:
2043.13: POKE
POKE 2044,13
POKE
POKE V
V + 23,12:
23,12: POKE
POKE V
V + 29,12
29 12
POKE
POKE V
V + 8,X
8,X
POKE
POKE V
V + 9,100
9,100
POKE
Line 11 turns ON sprites 2,3,
ined decimal
2,3, and 4
4 by POKEing their comb
combined
val
ues (4, 8,
te enable register (21).
values
8, and 16)
16) into the spri
sprite
Line 12 tells the computer to find the data for all three sprites in the 13th
block of
of memory.
memory.
block
Line 25 doubles
doubles the size of sprites 22 and 33 by POKEing their combined
and 29).
29).
expansion (23 and
decimal value into the registers that control sprite expansion
Lh.e
Li,.e 48
48 moves sprite 44 along the X
X axis (horizontally).
(horizontally).
halfway down
down the screen at location
location 100.
100. Before,
Before,
Line 58 positions sprite 44 halfway
the YY coordinate throughout the program
program by
by using
using aa loop
loop (see
(see
we've changed the
But now
now the
the value for
for the
the YY coordinate
coordinate for
for sprite
sprite
line 50
50 in
in the
the original
original program).
program). But
line
01 ++ 9)9) stays
stays the
the same
same during
during the
the program.
program. This
This means
means that
that sprite
sprite 44 only
only
44 (V
moves
moves horizontally.
horizontally.
77
77
MORE ON
ON SPRITES:
SPRITES: COLOR
COLOR AND
AND EXTRA
EXTRA MOVEMENT
MOVEMENT
MORE
Changing aasprite's
sprite'scolor
color isis even
even easier
easierthan
than moving
moving itit around
around the
the screen.
screen.
Changing
You
You can
can use
use any
any of
of the
the 64's
64's 16
16 colors
colors with
with your
your sprites.
sprites. The
The 16
16 colors
colors are
are
numbered 00 through
through 15.
15. Chapter
Chapter 66 and
and Appendix
Appendix GG list
list the
the colors
colors and
and their
their
numbered
codes.
codes.
. ,_
Suppose
13.
Supposeyou
you want
want to
tochange
changesprite
sprite1 1's'scolor
colortoto light
lightgreen,
green,whose
whosecode
code isis13.
Just
Just enter
enterthis
this statement:
statement: POKE
POKE VV ++ 45,13
45,13(assuming
(assuming you
you set
set VVtoto 53248,
53248,the
the
VIC chip
chip starting
starting memory
memory location).
location).
VIC
When
ran the
the sprite
spri te program
program inin this
this chapter,
chapter, you
you probably
probably noticed
noticed that
that
When you
you ran
the sprites
sprites never
never moved
moved all
all the
the way
way to
to the
the right
right edge
edge of
of the
the screen.
screen. This
This hap
hap·
the
pens
pensbecause
because the
the XXdirection
direction register
register can't
can 'thold
hold aavalue
value over
over255,
255,but
but the
the screen
screen
is
320
dots
wide.
is 320 dots wide.
There's
an object
object across
across
There's aa register
register on
on the
the memory
memory map
map that
that lets
lets you
you move
move an
the entire
enti re screen.
screen. This
This register,
reg ister, location
locati on 16,
16, is
is called
called the
the MOST
MOST SIGNIFICANT
SIGNIFICANT
the
BIT (MSB)
(MSB) of
of the
the sprite's
sprite's XX direction
directi on location.
location . In
In effect,
effect, this
thi s bit
bit lets
lets you
you move
move
BIT
the sprite
sprite to
to aa horizontal
horizontal spot
spot between
between 256
256 and
and 320.
320.
the
Here's
Here's how
how the
the MSB
MSB works:
works: after
after you've
you've moved
moved the
the sprite
sprite to
to XX location
location 255,
255,
16. For
For example,
example, to
to move
move sprite
sprite 66
POKE the
the sprite's
sprite's decimal
decimal value
value into
into register
register 16.
POKE
256 through
through 320,
320, use
use this
this statement:
statement:
to horizontal
horizontal locations
locations 256
to
POKE VV +
+ 16,64
16,64
POKE
Then use
use aa loop
loop to
to move
move sprite
sprite 66 the
the 64
64 spaces
spaces from
from location
location 256
256 to
to 320:
320:
Then
FOR X
X =
= 00 TO
TO 63:
63: POKE
POKE V
V +
+ 64,X:
64,X: NEXT
NEXT
FOR
The
program revises
original balloon
program so
2
The following
following program
revises the
the original
balloon program
so that
that sprite
sprite 2
moves
all
the
way
across
the
screen
:
moves all the way across the screen:
10
10
20
25
25
30
30
40
40
50
50
60
70
70
80
80
90
90
100
100
110
110
V=53248:
E 2042,13
V = 53248: POKE V+21,4:
V + 21,4 : POK
POKE
FOR N = 0 TO 62:
62 : READ Q : POKE 832+ N,Q :: NEXT
POKE
+ 5,
POKE V
V+
5, 100
100
FOR
FOR X
X =
= 0
0 TO
TO 255
255
POKE
V+4,X
POKEV
+ 4.X
NEXT
NEXT
POKE
16,4
POKE V+
V+16,4
FOR
X
=
0
FOR X = 0 TO
TO 63
63
POKE
V+
4,
POKEV+4, X
X
NEXT
NEXT
POKE
+ 16,0
POKE V
V+
16,0
GOTO
GOTO 30
30
line
ificant bit
Line 60
60 sets
sets the
the most
most sign
significant
bit for
for sprite
sprite 2.
2.
70 through
through 90
90 contain
contain the
the loop
loop that
that moves
moves sprite
sprite 22 across
across screen
screen loca·
loca
liLines
nes 70
tions
tions 256
256 through
through 320.
320.
liLine
ne 100
100 turns
turns OFF
OFF the
the MSB
MSB so
so that
that sprite
sprite 22 can
can go
go back
back to
to the
the left
left edge
edge ooff
the
the screen.
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
locations 256
256 through
through 320.
320. You
You have
have to
to turn
turn the
the MSB
MSB back
back OFF
OFF before
before you
you can
can
255.
move
the
sprite
from
locations
0
through
move the sprite from locations 0 through 255.
The best
best way
way to
to learn
learn about
about sprites
sprites isis to
to experiment
experiment with
with them.
them. The
The Com·
Com
The
modore64
64Progra
Programmer's
Reference Guide
Guidehas
hasmore
more information
informationabout
about sprites.
sprites.
modore
mmer's Reference
78
78
'"'
r..
CHAPTER
MAKING MUSIC
ON YOUR COMPUTER:
FOR NON-PROGRAMMERS
CHAPTER 88
CHAPTER
MAKING MUSIC
MUSIC ON
ON YOUR
YOUR COMPUTER:
COMPUTER:
MAKING
FOR NON-PROGRAMMERS
NON·PROGRAMMERS
FOR
-
Structure of
of aa Sound
Sound Program
Program
•• Structure
Sample Sound
Sound Program
Program
•• Sample
Playing aaSong
Song on
on Your
Your 64
64
•• Playing
Creating Sound
Sound Effects
Effecls
•• Creating
Your
64's sound-making
sound·making features
fealures let
lei you
you make
make music
music and
and sound
sound effects.
effects. This
This
Your 64's
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
64 Programmer's
Programmer's Reference
Reference Guide
Guide has
has extensive
extensive information
information
The Commodore
Commodore 64
about music-makinng.
music·makinng.
about
STRUCTURE OF
OF A
A SOUND
SOUND PROGRAM
PROGRAM
STRUCTURE
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 sound-making.
sound-making. These
These locations
locations include:
include:
with
••
Volume
Volume
••
Waveform
Waveform
••
•
High and
and low
low frequency
frequency
High
The envelope generator:
generator:
Attack
Decay
Decay
-
Sustain
Sustain
Rel
ease
Release
VOLUME: There
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
VOLUME:
want (0·15)
want
(0-15) at memory location 54296.
54296. Zero turns the volume OFF.
OFF.
You only
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
You
volume sett
ing controls all three of the 64's voices.
setting
WAVEFORM: Th
The
waveform control
control STARTS
STARTS and
and STOPS
STOPS EACH
EACH NOTE.
NOTE. Each
Each
WAVEFORM:
e waveform
voice
has its
its own
own waveform
waveform memory
memory location
location that
that lets
lets you
you define
define four
four different
different
vo
ice has
types of
of waveform
waveform by
by POKEing
POKEing the start/stop
start/stop numbers
numbers for
for the waveform
waveform you
types
want.
want. There
There are
are four
four waveform
waveform types'
types-
Sawtooth:
Sawtooth:
79
79
Triangular:
v
v
v
Pulse (variable rectangular waves):
WIDTH-r— PULSE
PUlSE WIDU.
'--
~
effects):
White noise (used mainly for sound effects):
v
v
60
80
'--
This
This chart
chart shows
shows the
the waveform
waveform memory
memory locations
locations for
for each
each voice:
voice:
WAVEFORM MEMORY
MEMORY LOCATIONS
LOCATIONS
WAVEFORM
VOICE 11
VOICE
VOICE
VOICE 22
VOICE
VO ICE 33
54276
54276
54283
54283
54290
54290
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
This
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:
numbers
NUMBERS
NOTE START/STOP
START/STOP NUMBERS
NOTE
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 example,
example, this
th is statement
statement STARTS
STARTS aa sawtooth
sawtooth waveform in
In voice
vOice 1,
1, and
and
For
STOPS
a
triangle
waveform
in
voice
2:
STOPS
in
2:
POKE
POKE 54276,33:
54276,33: POKE 54283,16
54283,16
FREQUENCY: A
A sound's pitch is determined by the FREQUEN
CY of the sound
sou nd
FREQUENCY:
FREQUENCY
waves you
you produce when you make music.
music. For
For each note in a music or sound
program, you must include two separate POKEs:
POKEs: one for the high frequency
byte, and one for the low frequency byte.
byte,
byte. The MUSICAL NOTE
NOTE 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
you use,
s let
s you
use, so you can program all three voices independently. Thi
This
lets
create 3-voice music and exotic sound effects.
effects.
Here's a chart of the memory locations for each voice
's high and low frequenvoice's
frequen
cy bytes:
bytes:
VOICE
VOICE
FREQUENCY
FREQUENCY
POKE NUMBER
NUMBER
POKE
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
'-'
Appendix M contains a list of all the high and low frequency POKE va
lues for
values
octaves
each note. Each note in each of the eight oc
taves has two different numbers.
lue into
To playa
play a musical note, you must POKE the note's high frequency va
value
want,, and PO
POKE
fre
the high frequency location of the voice you want
KE the note's low fre·
quency value into the voice's low frequency location. For example, here's how
1:
to POKE a C note from the fifth octave in voice 1:
10 POKE
POKE 54273,33 .. . ...... ...... .... .. .... .... ............... ............... . set high frequency
15 POKE 54272,135 ....... .... .... ... ...
............. ...... ............. set low frequency
Use this
thi s line to POKE the same note in voice 2:
POKE 54279,135
10 POKE 54280,33: POKE
v
Here's a short program that POKEs C in voice 1:
=
5FORL
54272TO54296:POKEL,0:NEXT
5
FORL = 54272
TO 54296:POKEL,0:NEXT ......
10V=54296:W=54276:A
= 54277: ....................
10
V = 54296:W = 54276:A =
= 54278:
54278:H
= 54273:
54273:L
= 54272
S=
H=
L=
20 POKEV,15:POKEA,190:POKES,89 .................
SID chip
clear SID
variables
use variab
les to save
typing time
POKE vol,
VOl, attach/decay
sustain/release
30 POKEH
,33:POKEL,135 ................................... POKE hi/lo freq. notes
POKEH,33:POKEL,135
POKEW.33:FORT=
1TO200:NEXT
40 POKEW,33:FORT
= H0200:
NEXT ...... .......... start note, let it play
50 POKEW,32
POKEW.32 ............... ................ .......... .. ... ....... . stop note
firs t struck,
The ENVELOPE GENERATOR: when a note is first
struck, it rises from zero
RATE at which this rise occurs is ca
lled the
volume to its peak volume. The RATE
called
ATTACK. Then the note falls from the peak to some middle·range
middle-range vol
volume.
ume. The
note's fall is called the DECAY.
mid·range vol
ume itself is call
call·
RATE of the note's
DECAY. The mid-range
volume
ed the SUSTAIN LEVEL.
ng, it falls from the
the SUSTAIN
LEVEL When the note stops playi
playing,
ume. The RATE of this fall is ca
lled the
the RELEASE.
a
level
level to zero vol
volume.
called
RELEASE. Here's a
sketch of the four phases of a note:
v
v
SUSTAIN
1
SUSTAIN LEVEL---/
LEV EL - - --....,---~
. ----,.
,
,
A
:
'
,
I
0
:
5
, R:
NOTE:
NOTE: ATTACK,
ATTACK, DECAY,
DECAY, and RELEASE are
are RATES.
RATES. SUSTAIN
SUSTAIN is
is aa LEVEL.
LEVEL.
v
v
82
82
In this chapter we'll refer to the ATTACK/DECAY
ATIACKID ECAY memory locations, and the
SUSTAIN/RELEASE memory locati
ons. The reason we use these pai
rings is
locations.
pairings
that each of the four settings needs only 1/2 byte,
byte, so attack and decay share a
byte, as do sustain and release.
release.
This chart shows you the memory locations for the ATIACKID
ECAY byte and
ATTACK/DECAY
the SUSTAIN/RELEASE byte for each of the three vo
ices:
voices:
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
ATIACK and DECAY settings by adding them. Then you
you must COMBINE ATTACK
enter the total
total in a POKE statement.
The ATTACK
ATIACK rates occupy the 2
e
2 tt 7,
7, 2 t 6,2
6, 2 t 5,
5, and 2 t 4
4 bits,
bits, so th
the
64, 32,
2 t 1,and
I , and 2 t 0,
values are 128,
128,64.
32, and 16. DECAY rates are 2 t 3,2 t 2,
2,2
0.
or 8,
8, 4,
4, 2, and 1. Suppose you want to set a HIGH ATIACK
ATTACK rate and a LOW
DECAY rate: add Ihe
Ihe low decay value (2), and
the high attack value (128) to the
POKE 130 to Ihe
the appropriate memory location.
This chart shows you what numbers to POKE for ATTACK
ATIACK and DECAY rates:
AITACK
ATTACK
MEDIUM
AITACK
ATTACK
AITACK
ATTACK
LOWEST
AITACK
ATTACK
HIGH
DECAY
MED.
DECAY
LOW
DECAY
LOWEST
DECAY
128
128
64
32
16
8
4
2
1
1
HI
GH
HIGH
LOW
NOTE: You can increase the ATTACK
ATIACK rate by adding together all
ATIACK
all the ATTACK
values: 128 + 64 + 32 + 16 =
ATIACK RATE.
= 240, which is the MAXIMUM ATTACK
You can increase the DECAY rate by adding together all the DECAY values:
You
8 + 4
4 + 2 + 1
1 = 15,
15, which is the MAXIMUM DECAY RATE.
If you set an attack rate with no decay rate
rate,, the decay rate is automatically
zero,
rsa. For example,
ing a
zero, and vice ve
versa.
example, if you POKE 54277,64,
54277,64, you're sett
setting
medium attack rate with zero decay for voice 1.
1.
Here are some sample ATTACK/DECAY
ATIACKIDECAY POKEs:
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
POKE 54284,255
2
MAX
MAX
(128+64 +32+
16
+ 32+16
83
MAX
(8+4+2+
1)
(8+4+2+1)
MAX
+ 8+4 + 2+1)
+8+4+2+1)
Here's
Here's aa sample
sample program
program Ihal
that illuslrales
illustrates whal
what you
you can
can do
do with
with allackldecay
attack/decay
settings:
sellings:
10
= 54272T054296:POKEL,0:NEXT ... Clears
10 FORL
FORL=54272TO54296:POKEL0:NEXT...
Clears Ihe
the SID
SID chip
chip
20
POKE54296J5
Set
maximum
volume
20 POKE54296,15 ..... ..
............................... Sel maximum volume
30 POKE54
POKE54277,64
Set allackldecay
attack/decay
30
277,64 ......... ...... ... ........ .. ............. Sel
40
Ie in
40 POKE54273,162:POKE54272,37
POKE54273.162:POKE54272,37 ............... POKE
POKE one
one no
note
in voice
voice 11
50 PRINT"PR
PRINT-PRESS
ANY KEY
KEY"
Screen message
message
50
ESS ANY
" ................. ....... Screen
60
GETK$:IFKS= " " THEN60 ....... .................. Check
60GETK$:IFK$=""THEN60
Check the
the keyboard
keyboard
70 POKE54276,17:FORT
POKE54276,17:FORT=
1TO200:NEXT..... Slart
Start triangle
triangle waveform
waveform
70
= H0200:NEXT
80 POKE54276,16:FORT
POKE54276,16:FORT=
1TO50:NEXT
Stop note
note
80
= H050:N
EXT ..... .. Stop
90GOTO50
Repeat execution
execution
90
GOT050 ........ ........................ ........ ..... ...... .. Repeat
After
ECAY
After you RUN
RUN the
the program
program a few times, try
try changing the ATIACKID
ATTACK/DECAY
setting by
by changing
changing line
line 30:
30:
setting
30 POKE
POKE 54277,190
Now RUN
RUN the program again and notice
notice the difference in
in the note.
note. Try other
comb
inations of
combinations
of attack and decay settings to get an idea
idea of how you can use
attack/decay rates to create a variety of sound effects.
different allackldecay
SUSTAIN/RELEASE SETIING
ATIACKIDECAY, SUSTAIN/RELEASE
SETTING.. Like ATTACK/DECAY,
share a byte. But remember that this sharing doesn't mean that SUSTAIN and
RELEASE are alike. SUSTAIN is a LEVEL,
LEVEL, while release,
release, allack
attack and decay are
RATES.
SUSTAIN is a proportion of maximum volume. You
You can sustain,
sustain, or hold
hold,,
notes and sounds at any of 16 volume levels.
lease values:
This table shows you what numbers to POKE for sustain/re
sustain/release
HIGH
HIGH
MEDIUM
HIGH
MED.
SUSTAIN
LOW
SUSTAIN
SUSTAIN
LOWEST
SUSTAIN
SUSTAIN
SUSTAIN
SUSTAIN
RELEASE
RELEASE
RELEASE
RELEASE
LOW
LOW
RELEASE
RELEASE
LOWEST
LOWEST
RELEASE
RELEASE
128
128
64
64
32
32
16
16
8
8
4
4
2
2
11
NOTE: You
You can increase
increase the SUSTAIN
SUSTAIN level by adding together
together all
all the
the SUSTAIN
SUSTAIN
NOTE:
128 +
+ 64
64 +
+ 32
32 +
+ 16
16 = 240,
240, which
which is
is the
the MAXIMUM
MAXIMUM SUSTAIN
SUSTAIN LEVEL
LEVEL. A
A
values: 128
SUSTAIN level
level of
of 128
128 is
is approximately
approx imately 50%
50% of
of volume. You
You can increase
increase the
the
SUSTAIN
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 the
the sustain
sustain level
level and
and release
release rate
rate the
the same
same way
way you
you combine
combine the
the at
atCombine
tack and
and decay
decay rates:
rates: add
add the
the two
two values
values and
and POKE
POKE the
the total
total to
to the
the memory
memory
tack
location
location of
of the
the voice
voice you
you want.
want.
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
To
program:
program:
35
35 POKE
POKE 54278,128
54278,128
v
v
Now RUN
RUN the
the program
program again
again and
and note
note the
the change.
change. With
With line
line 35,
35, we
we tell
tell the
the
Now
(128).
You
can
vary
the
comp
uter
to
sustain
the
note
at
a
HIGH
SUSTAIN
LEVEL
computer to sustain the note at a HIGH SUSTAIN LEVEL (128). You can vary the
duration of
of aa note
note by
by changing
changing the
the count
count in
in line
line 70.
70. Remember
Remember that
that the
the sustain
sustain
duration
level maintains
maintains aa note
note at
at aa proportion
proportion of
of the
the volume
volume as
as the
the note
note falls
falls from
from its
its
level
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.
line 35
35 to
to POKE
POKE 54278,89
54278 ,8~
To see
see the
the effect
effect of
of the
the release
release rate,
rate, try
try changing
changi ng line
To
(sustain
(sustain == 80,
80, release
release == 9).
9).
84
SAMPLE SOUND PROGRAM
SAMPLE SOUND PROGRAM
This
Thisbrief
briefsound
soundprogram
programsummarizes
summarizeswhat
whatyou've
yo u've learned
learnedso
so far
farabout
about mak
mak·
ing music
musicon
onyour
yo ur64:
64 :
ing
1.1. Choose
Choose the
the voice(s)
voice(s) you
you want
want to
to use.
use. Recall
Recall that
that each
each voice
voice uses
uses different
different
memory
memory locations
locations into
intowhich
which you'll
you'll POKE
POKEvalues
values for
for waveform,
wave form , attack
attack rate,
rate ,
etc
3 voice
etc.You
Youcan
canplay
play 1,2.
1,2,or
or3
voice together,
together,but
but this
this program
program only
only uses
uses voice
voice 1.1.
22. Clear
55 FORL=
54272 TO
Clearthe
the SID
SID chip:
chip:
FORL =54272
TO 54296:
54296: POKEL,0:NEXT
POKEL,O: NEXT
3.3. Set
10
Set VOLUME:
VOLU ME:
10 POKE54296.15
POKE54296,15
4.
4. Set
Set ATTACK/DECAY
ATIACKIDECAY rates:
rates:
,-,
ri ses
to define
define how
how fast
fas t aa note
note rises
to
to and
and falls
falls from
from its
its peak
peak
to
volume
vo lume level
level (0-255):
(0·255):
20
20 POKE54277.190
POKE54277,190
5. Set
Set SUSTAIN/RELEASE
SUSTAI N/RE LEASE to
to
5.
define level
level to
to hold
hold note
note and
and
define
rate to
to release
release it:
it :
rate
6. Find
Find note
note you
you want
want to
to play
play in
in
6.
30 POKE54278,248
POKE54278,248
30
„
the TABLE
TABLE OF
OF MUSICAL
MUSICAL
the
in App.
App. M
M and
and enter
en ter
NOTES in
NOTES
the HIGH-FREQ.
HIGH·FREO. and
and LOWLOW·
the
FREO. values
values for
for that
that note
note
FREQ.
(each
(each note
note requires
req uires 22 POKEs):
POKEs): 40
40 POKE54273,16:POKE54272,195
POKE54273,16:POKE54272,195
7. Start
Start WAVEFORM
WAV EFORM (here,
(h ere,
7.
TRIANG LE):
50 POKE54276.17
POKE54276,17
TRIANGLE):
50
8. Enter
Enter aa timing
timing loop
loop to
to time
time be
be·
8.
(we use 250
250 for aa
tween notes
no tes (we
tween
= 1T0250:NEXT
quarter note):
note):
quarter
60 FORT
FORT=
1TO250:NEXT
9. STOP
STOP note
note by
by turning
turn ing off
off
9.
chosen waveform:
wave form:
chosen
70 POKE54276,16
Here's aa longer
longer program
that further
furthe r demonstrates
's music-making
Here's
program that
demonstrates your
your 64
64's
music-making
abilities:
abilities:
NEW
NEW
5
MUSICAL SCALE ......................... .
5 REM
REM MUSICAL
7
FORL=54272TO54296:POKEL0:NEXT
clears SID
SID chip
chip
7 FORL
= 54272T054296: POKEL,0:NEXT clears
lu me
10
10 POKE
POKE 54296,15
54296,15 .......... ... ........................ sets
sets vo
volume
E54278,133 ............ sets
20 POKE54277,7:POK
POKE54277,7:POKE54278,133
sets ald/s/r
a/d/s/r
50
READ
A
.........................
...............
.........
READs
50 READ A
READs 1st
1st number
number from
from line
line 110
110
55
IF
A=
-1
THENEND
....
.......................
ENDs
loop
55 IF A= - 1 THENEND
ENDS loop
60
60 READ
READ B
B ................................................. READs
READs 2nd
2nd number
number
80
POKE54273,A:POKE54272,B ..... .......... POKE
s 1st
80POKE54273APOKE54272,B
POKEs
1st number
number from
from line
line 110
110 as
as
HI-FREO and
and 2nd
2nd number
number as
as LOW·
LOWHI·FREO
FREO.
FREQ.
85
POKE54276,17
....
...
...
..........................
starts
85 POKE54276.17
starts note
note
90
FORT
=
1T0250:NEXT:POK
E54276,
16
lets
90 FORT= 1TO250:NEXT:POKE54276,16 lets note
note play,
play, then
then stops
stops itit
95
FORT
=
1T050:NEXT
....
.......................
sets
time
for
RELEASE,
95 FORT= 1TO50:NEXT
sets time for RELEASE, time
time be·
be
tween
tween notes
notes
100
tart s prog
ram
100 GOT020
GOTO20 ....... ..... ....... ... .......... ...... ........ res
restarts
program
110
110 DATA
DATA 16,195,18,209,21,31,22,96
16.195.18.209.21,31.22,96 ... ..... Iists
lists note
note value
value
120
120 DATA
DATA 25,30,28,49,31,165,33,135
25.30.28.49,31,165,33,135 ........ from
from chart
chart inin App.
App. M.
M. Each
Each part
part of
of
nu
mbers == one
te (16
numbers
one no
note
(16 and
and 19
19 ==
4th
tave C)
4th oc
octave
C)
999
999 DATA·1
DATA-1 ............................................... ENDs
ENDs program
program (see
(see line
line55)
55)
85
85
^
^
_
You
You can
can change
change to
to aa sawtooth
sawtooth wave
wave by
by changing
changing line
line 85
85 to
to read
read
POKE54276,33
POKE54276.33 and
and line
line 90
90 to
to read
read FORT;
FORT= n0250:NEXT:POKE54276,32.
1TO250:NEXT:POKE54276,32.
Changing
Changing the
the waveform
waveform can
can dramatically
dramatically change
change Ihe
the sound
sound your
your computer
computer
produces.
uces.
prod
You
You can
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
the harpsichord·like
harpsichord-like sound
sound in
in the
the previous
previous program
program to
to aa banjo-like
banjo-like sound
sound by
by
changing
changing the
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
POKE54278,0 ............... creates
20 POKE54277,3:
POKE54277.3:POKE54278,0
creates banjo
banjo effect
effect by
by setting
setting zero
zero
SUSTAIN
SUSTAIN
As
As this program
program demonstrates,
demonstrates, your
your 64
64 can sound
sound like
like aa variety
variety of
of musical
musical inin
struments.
v
v
_
v
v
v
v
v
86
86
-•
PLAYING A SONG ON YOUR 64
The next program lets you playa
Michael Row Your Boat
play a line from a song,
song, ""Michael
Ashore" . The program uses the PULSE waveform, which is a variable width recAshore".
rec
tangular wave. The third and fourth POKEs in line 10 define the pulse width for
this song.
w»
In this song, we use a duration count of 125 for an eighth note, 250 for a
quarter note,
note, 375 for a dotted quarter note,
note, 500 for a half note,
note, and 1000 for a
whole note. When you program your own songs,
songs, you can increase or decrease
these numbers to match a particular tempo or your own musical taste.
2 FOR
L =54272T054296:
F0RL
= 54272TO54296: POKEL,O:
POKEL,0: NEXT
5 S=
S = 54272
10 POKES
+ 24,15: POKES
+ 5,88: POKES
+ 3,15: POKES
+ 2,15: POKES
+ 6,89
POKES+
POKES+
POKES+
POKES+
POKES+
20 READH: IFH = -- nHENEND
1THENEND
30 READL
40 READD
60 POKES+
1,H: POKES,L: POKES+4,65
POKES+1.H:
POKES + 4,65
70 FORT
= nOD: NEXT: POKES
+ 4,64
FORT=1TOD:
POKES+
80 FORT
= n050: NEXT
FORT=1TO50:
90 GOTO 20
100 DA
TA33, 135,250,42,62,250,50,60,250,42,62,125,50,60,250
DATA33,135,250,42.62.250.50.60,250.42,62.125.50.60,250
105 DATA56,99,250
110 DATA50,60,500,0,0,125.42.62,250,50.60,250.56,99
OAT A50,60,500,0,0,125,42,62,250,50,60,250,56,99
115 DATA
1000,50,60,500
DATA1000.50.60.500
120DATA-1
120 DATA-1
Line 22 clears the SID chip.
Line 5 assigns the lowest SID chip memory location to the variable S.
Throughout the rest of the program,
program, we just add the number of the SID register
ter,
to this variable. For example, POKES+ 24,15 POKEs 15 to the volume regis
register,
which is 54296,
54296, or 54272 + 24.
Line 10 POKEs values into:
1. The vo
lume register: POKES + 24,15
volume
2. Voice 1, ATTACK/DELAY
An ACKIDELAY rat
es: POKES
+ 5,88
rates:
POKES+5.88
3. Pulse width: POKES
+ 3,15 and POKES
+ 2,15
POKES+
POKES+
4. Voice 1, SUSTAIN level/RELEASE rate: POKES
+ 6,89
POKES+
Line 20 READs the first number from the DATA statement. If that number is
-1
- 1,, the program ENDs automatically. This occurs when the final DATA statestate
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
POKEs determine the pitch for one note.
3. The value that turns ON the variable pulse waveform for voice 1.
H7
87
«
m
fl
^
~
m
r\
'—
m
g
^
/-.
*
^
r<
v
Line
ue
Line 70
70 uses
uses aa loop
loop to
to set
set the
the duration
duration for
for the
the note
note being
being played.
played. The
The val
value
for
ned in
mbers
for D
D is
is assig
assigned
in the
the READ
READ statement
statement in
in line
line 40.
40. As
As you
you can
can see,
see, the
the nu
numbers
in
sts are
tered into
e high
in the
the DATA
DATA lilists
are clus
clustered
into threes:
threes: the
the first
first number
number (e.g.
{e.g.,, 35)
35) is
is th
the
high
ue fo
r aa note,
frequency
frequency val
value
for
note, the
the second
second number
number (e.g.,
(e.g., 135)
135) is
is the
the low
low frequency
frequency
value
ird number
on for
value for
for the
the same
same note,
note, and
and the
the th
third
number (e.g.,
{e.g., 250)
250) sets
sets the
the durati
duration
for
that
note
(e.g..
a
quarter
note
C).
that note (e.g., a quarter note C).
Une
lease time
Line 80
80 is
is a
a timing
timing loop
loop that
that determines
determines re
release
time between
between notes.
notes.
Li
ne 90
Line
90 sends
sends the
the program
program back
back to
to READ
READ the
the number
number set
set for
for another
another note.
note.
s song.
Lines
Lines 100
100 through
through 120
120 contain
contain all
all the
the DATA
DATA for
for Ihe
the line
line from
from thi
this
song.
v
~
'-'
'-'
'-'
v
v
'-'
'-'
v
V
v
'-'
V
'-'
v
'-'
88
-'
v
-
CREATING SOUND
SOUND EFFECTS
EFFECTS
CREATING
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
Your
during aa game,
game, or
or aa buzzer that
that warns
warns you when
when you've
you've made
made aa
explosion during
mistake.
mistake.
Here are
are just aa few
few suggestions for
for creating
creating sound
sound effects:
Here
1. Vary
Vary rapidly
rapid ly between two
two notes to create
create aa tremor
tremor sound.
1.
Use the multivoice
multivoice effects to
to play more than
than one voice
vo ice at a time,
time, with each
2. Use
voice independently
independently controlled,
controll ed , so
so you
you have different
different noises at once.
once. Or use
voice
vo ice.
as an echo or
or response to
to another voice.
one voice as
3, Use
Use the different pulse widths
widths to
to create different sounds.
3.
the
NOISE
WAV
EFORM
to
make white noise
nOise to accent tonal
tonal sound ef
ef·
4.
Use
4.
the
WAVEFORM
fects , create explosion
explosion noises,
nOises , gunshots,
gunshots, footsteps,
foots teps , or
or alarms. When you
you
fects,
use the noise
noise waveform
waveform with the
the same musical notes that create music,
music, you
use
can create different
di fferent types of white noise.
noise.
can
5. Combine several
several HIGH/LOW
HI GH/LOW FREQUENCIES
FREQUENCIES in rapid succession across dif
dif·
5.
fe rent octaves.
ferent
M.
6. Try POKEing the extra note settings in Appendix M.
~
The Commodore 64 Pro
Pro·
sample sound effects programs. The
Here are some sample
grammer's Reference Guide
G ui de contains
contain s more examples
examp les as well as more informa
information on creating sound effects.
DOLL CRYING
NEW
POKEL,O:N EXT .... Clears SID chip
5 FORL= 54272T054296:
54272TO54296:POKEL,0:NEXT
10 S
S=
= 54272
. .......... Sets
20 POKES+ 24,15
24.15 ... ............. ..
Sets volume
volume
.............. Turns ON pulse waveform in
30 POKES+ 4,65 .................... .
vo
ice 11
voice
40 POKES+
5,15 .................... .. ........ .. ........ Sets attack/decay rate
POKES + 5,15
50
FOR X = 200T05STEP - 2 ..........
.. .... Sets timing loop for RELEAS
E or
50FORX=200TO5STEP-2
RELEASE
time between notes
60 POKES
+ 1,40:POKES,X:
NEXT.
.. ...... Sets hi/lo frequencies
POKES-f
1,40:POKES,X:NEXT
70
FOR X = 150T05STE
P - 2 ........................ Sets faster liming
70FORX=
150TO5STEP-2
timing loop
80 POKES + 1,40:POKES,X:
NEXT ................ Sets hi/lo frequencies
1.40:POKES,X:NEXT
90 POKES
+ 4,64
POKES+
4T64 ........................................... Turns OFF pulse waveform
89
^
-->-
SHOOTING
NEW
54272TO54296:POKEL,0:NEXT .... Clears SID
SID chip
5 FORL= 54272T054296:POKEL,0:NEXT
10 S= 54272
.. ..... Sets up volume loop
20
FORX= 15TOOSTEP-1 ...
20FORX=15TO0STEP-1
30
POKES + 24,X
.. ................................ POKEs X
30POKES+24.X
X to vol. register.
40 POKES+ 4,129 ...............
.. ......... Starts NOISE waveform
50 POKES+ 5,15
.................... .. .. .. ......... Sets ATTACK/DECAY rate
60 POKES
+ 1,40.....
.. .. .. ...... .. ............... Sets high frequency
POKES+
1,40
70 POKES,200:NEXT
..............
.. Sets low frequ
ency
frequency
80 POKES+ 4,128 ...........
.. .... Stops NOISE
NOISE waveform
90 POKES + 5,0
.. POKEs 0 to attack/decay
5.0 ............ .. .. ..............
100
GOT020
.................
......
...........
Repeat
s program
100GOTO20
Repeats
v
The loop that begins in line 20 sets up fading volume so that the sound of the
lume (15) and fades to 0 as the loops executes.
gunshot starls
starts at high vo
volume
executes.
Press the RUN/STOP key to end this program.
v
As we've said before, the best way to learn a new area of programming is to
experiment.
'--'
v
v
v
v
v
v
v
v
v
v
v
V
V
V
v
v
v
90
—
-
-
—
-
~
••
•
••
•
••
•
•
•
•
•
••
••
••
•
••
•
••
•
••
•
••
•
•
••
•
CHAPTER
9
ADVANCED
DATA HANDLING
CHAPTER 99
CHAPTER
ADVANCED DATA
DATA HANDLING
HANDLING
ADVANCED
••
READ and
and DATA
DATA Statements
Statements
READ
••
Calculating Averages
Averages
Calculating
••
Subscripted Variables
Variables
Subscripted
••
Dimensioning Arrays
Arrays
Dimensioning
••
Simulated Dice
Dice Roll
Roll with
with Arrays
Arrays
Simulated
••
Two-dimensional Arrays
Arrays
Two-dimensional
READ AND
AND DATA
DATA STATEMENTS
STATEMENTS
READ
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 how
how to
to assign
assign values
values while
wh ile the
the program
program is
is RUNning
RUNning (INPUT
(I NPUT and
and GET).
GET].
and
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 in
in aa program,
program, especially
especially when
when you
you have
have large
larg e amounts
amounts of
of data.
data.
ment
the chapter
chapter 77 when
when we
we introduced
introduced sprites,
sprites, we
we used
used READ
READ and
and DATA
DATA
In the
to assign
assign values
values for sprites.
sprites. Here's
Here's aa short
short program
program that shows
shows you
statements to
how these
these two statements
statement s work
work together:
together:
how
10
20
30
30
40
READ X
READX
PRINT "X IS
IS NOW
:";X
PRINT
N0W:";X
GOTO 10
10
GOTO
DATA 1, 34,
34, 10.5,
16, 234.56
10.5, 16,
RUN
X IS
IS
X
X IS
IS
X
X IS
X
IS
X IS
X
IS
X IS
NOW:
NOW : 1
1
NOW ::34
34
NOW:
NOW : 10.5
NOW : 16
NOW:
NOW : 234.56
?OUT OF DATA
DATA ERROR IN 10
READY
•
91
91
v
v
v
Line
Line 10
10 READs
READs aa value
value from
from Ihe
the DATA
DATA statement
statement at
at line
line 40
40 and
and assigns
assigns the
the
value to
to X.
X.
value
Lin
e 30
tu rn to
re the
Line
30 teils
tells the
the computer
computer to
to re
return
to line
line 10,
10, whe
where
the READ
READ assigns
assigns the
the
t va
lue in
nex
next
value
in the
the DATA
DATA statement
statement to
to X.
X. The
The loop
loop continues
continues until
until all
all the
the DATA
DATA
values are
are read
read..
values
There are
are a
a few
few important
important rules
rules you
you must
must remember
remember when
when you
you use
use DATA
DATA
There
statements:
statements:
Follow the
the DATA
DATA statemen
statement
format
precisely:
•• Follow
t form
at precisely:
v
40 DATA
DATA 1,
1, 34,
34, 10.5,
10.5, 16,
16,234.65
40
234.65
Comma separates
separates each
each item
item
Comma
v
v
Use:
•• Use:
integer numbers
numbers (e.g., 34),
-— integer
real numbers
numbers (e.g., 234.65),
-— real
-— numbers
on (e.g.
+ 04),
numbers expressed in
in scientific notati
notation
(e.g.,, 2.4E
2.4E+04),
-— words (as long as you use a string variable in
in the READ
READ statement),
but DON
DON'T
use:
'T use:
but
-— variables or
-— arithmetic operations
in DATA statements. The item
s listed below are Irealed
items
treated as slrings
strings if you try
to READ them, and you can on
ly READ them as strings with string variables
only
in the READ statement
statement..
in
DATA A.
A, 23156,
23/56, 2·5,
2*5. B + 2
When you use a READ statement,
statement, you can only get values from a DATA statestate
ment because the two slatements
statements work as partners. Each time you READ a
va
lue, the computer knows to move to th
e next val
ue in the DATA statement. In
value,
the
value
effect,
effect, there's a painter
pointer in the computer that keeps track of your place in
in the
DATA statement. After READing the first val
ue, the DATA statement
statemen t looks like
value,
this:
40 DATA 1.
1, 34.
34, 10.5,
16, 34.56
40
10.5, 16.
t
p6inter
pointer
DATA value has
has been assigned to the variable in
in the READ
When the last DATA
OF DATA
DATA
statement and
and the computer
computer tries
tries to
to execute
execute the
the loop
loop again,
again, the
the OUT OF
statement
ERROR
ERROR is
is displayed.
displayed .
an example
example that
that shows
shows one way
way to
to avoid
avoid the
the OUT OF
OF DATA
DATA ERROR.
ERROR.
Here's an
v
v
v
NEW
NEW
10
10 FOR
FOR XX =
= 11 to
to 33
15
15 READ
READ A$
A$
20
20 PRINT
PRINT "A$
" A$ IS
IS NOW
NOW :: ";
"; A$
A$
30
30 NEXT
NEXT
v
40
40 DATA
DATA THIS,
THIS, IS,
IS, FUN
FUN
......,
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
v
v
92
92
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
This
in the
the DATA
DATA statement.
statemen t.
the number
number of
of READings
READings to
to equal
equal the
the numbers
numbers of
of items
items in
the
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
As
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
method
count.
count.
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
Sometimes
apDATA statement
statement with
with aa FLAG.
FLAG. AA flag
flag is
is some
some value
value that
that would
wou ld not
not ordinarily
ordinaril y ap
DATA
pear in
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
pear
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 ,
small
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
add
program when
when the
the flag
flag is
is read.
read. For
For example:
example:
program
READ A
A
10 READ
10
<
15 IF
IF A
A <
15
0 THEN END
END
OTHEN
20 DATA
DATA 13,35,29,
13, 35, 29, -999
-999
20
25 PRINT
PRINT "TOTAL
" TOTAL = ";
"; A
A
25
30 GOTO
GOTO 10
10
30
This program
program READsand
READs and PRINTS
PRINTs aa value
value for A
A until
until it reaches -999.
- 999. Line
line 15
15
This
tells the computer
computer to
to END
END the
the program
program immediately
immediately when
when aa negative
negative value
value is
tells
read.
There is also
also aa way to
to reuse
reuse the items in
in aa DATA
DATA statement by RESTOREing
There
the
the data pointer
pOinter to
to the
the beginning of the
the DATA
DATA list. Try adding this line:
45 RESTORE
45
in this chapter and RUN it again. You
'll see that the data
to the second program in
You'll
pOinter
RESTOREd to the first item in
list, and that you
yo u can
pointer has been RESTOREd
in the DATA list,
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
ng DATA.
when to stop READi
READing
NEW
5 T=O
T = 0 :CT=O
: CT = 0
10 READ
X
READX
20 IF X = -- 1
1 THEN 50: REM CHECK FOR FLAG
25CT=CT
25 CT = CT +1
+ 1
30 T = T + X:
X : REM UPDATE TOTAL
40 GOTO 10
50 PRINT
THERE W
ERE "; CT;"VALUES READ"
PRINT ""THERE
WERE
60 PRINT
"
TOTAL
=
";T
PRINT "TOTAL
70 PRINT
"
AVERAG
E
PRINT "AVERAGE = "";; T/CT
80 DATA
DATA 75, 80, 62, 91
91,, 87,
37, 93, 78, -1
- 1
RUN
RUN
TH
ERE WERE 7 VALU
ES READ
THERE
VALUES
TOTAL = 566
AV
ERAGE = 80.8571429
AVERAGE
93
93
^
Line 5 sets CT,
CT. the CounTer, and T, the Total
Total,, to zero.
line
Line 10 READs a value from the DATA list and assigns it to X.
line
line
lue read to X is our flag (-1).
Line 20 checks to see if the va
value
(- 1). If it is, then the
program ski
ps lines 25-40 and goes straight to line 50.
skips
50.
Line 25 adds one to CT, the counter,
counter, if the value of X is not the flag.
line
Line 30 adds X to T, the running total.
line
Line 40 sends the program back to repeat line 10.
10.
line
line
ne 10 READs the flag
Line 50,
50. which isn'
isn'tt executed until li
line
flag,, PRINTs
PRINTS the
(CT).
number of values read (CT).
Line 60 PRINTs
PRINTS the total of the numbers read (T).
(T).
line
Line 70 PRINTs
PRINTS the average.
line
You can also use more than one variable in the READ statement. You can mix
the types of DATA in a DATA list when you also mix the types of variables in the
READ statement. Here's a program that does just
ju st that. It READ
s a name and
READs
calculates
the
scores.
some scores and then calcula
tes th
e average of the scores.
NEW
10 READ N$,A,B,C
20 PRINT N$"
" S SCORES WERE'
A" "'
B'" "";C
'C
N$;'"S
WERE: "
";A;"
";B;"
30 PRINT ""AND
Aim THE AVERAGE IS: ''';(A';
+ C)/3
(;)13
";(A+ B+
40 PRINT: GOTO 10
10
190, 185,
185, 165,
165, DICK,
DICK, 225,
225, 245, 190
50 DATA MIKE,
MIKE, 190,
60 DATA JOHN,
JOHN, 155,
155, 185,205,
185, 205, PAUL,
PAUL, 160,
160, 179, 187
8
RUN
MIKE'S SCORES WERE: 190 185 165
AND
AN D THE AVERAGE IS :: 180
DICK'S SCORES WERE: 225 245 190
190
DICK'S
AND
AND THE AVERAGE IS:
IS : 220
v
v
line 10
10 READs aa value
val ue for
for each of the variables.
variables. The
The DATA statement lists
lists its
its
Line
items in
in the same
same order that
that the
the READ
READ statement
statement expects to
to find them. In
In other
other
items
words, there's
there's aa name to
to go with
with the
the string
strin g variable,
variab le, and
and numbers
numbers to
to go
go with
with the
words,
integer
in teger variables.
variables.
v
v
v
v
v
94
94
SUBSCRIPTED VARIABLES
VARIABLES
SUBSCRIPTED
So
So(ar
farwe've
we'veonly
onlyused
usedsimple
simpleBASIC
BASICvariables
variablessuch
suchas
asXXand
andX$.
X$,It's
It'sdoubtful
doubtful
that
that you'll
you 'll write
write aaprogram
program that
that requires
requi res more
morevariable
variable names
namesthan
than all
all the
the com
comBASIC, but
but you
you might
mightwant
want toto be
be
binations of
of letters
letters and
and numbers
numbers available
available inin BASIC,
binations
able
able to
to group
group variable
va riable names
names together
together when
when you're
you're using
using groups
groups of
of data.
data,
Subscripted
Subscripted variables
variables let
let you
you use
use variable
variable names
names so
so that
that they
they are
are obviously
obviously
grouped together.
together, For
For example:
example:
grouped
A (0), A{1),
A (1), AA (2),
(2), AA (3)
(3)
A(0),
The
Th e numbers
numbers inin parentheses
parentheses are
are the
the SUBSCRIPTS
SUBSCRIPTS of
of variable
variable A.
A, Be
Be aware
aware
A1 does
does NOT
NOT equal
equal the
the subscripted
subscri pted variable
variable AA (1).
(1),
that the
the variable
variab le A1
that
You
You can
can use
use variables
variables and
and arithmetic
arithmetic operation
operation as
as subscripts.
subscripts. For
For example:
example:
A (X) A(X+1)
A (X + 1) AA (4-1)
(4 - 1) A(2tX)
A (2 t X)
A(X)
The
The expressions
expressions within
within the
the parentheses
parentheses are
are evaluated
evaluated according
according to
to the
the same
same
rules for
for arithmetic
ari thmetic operations
operations outlined
outlined in
in Chapter
Chapter 3.
3,
rules
variables , like
like simple
simple variables,
variables, name
name aa memory
memory location
location within
within
Subscripted variables,
Subscripted
the
the computer.
computer. But
But only
only subscripted
subscripted variables
variables name
name values
values that
that are
are organized
organized in
into an
an ARRAY.
ARRAY,
to
An
An ARRAY
ARRAY is
is understood
understood by
by the
the computer
computer to
to be
be aa unit,
unit , such
such as
as aa list
list or
or aa
table, of
of related
related values.
values,
table,
The
The following example
example uses
uses subscripted
subscripted variables
variables to
to calculate
calcu late an
an average:
average:
5
5
PRINT CHR$(147)
CHR$(147)
PRINT
10 INPUT "HOW
" HOW MANY
MANY NUMBERS :";X
10
=
20 FOR A
A = 11 TO
TO X
X
20
ENTER VALUE
VALU E # ";
A;: INPUT B(A)
30 PRINT ""ENTER
";A;:INPUT
40
50
60
60
70
80
90
NEXT
SU = a
0
FOR
FOR A
A =
- 1
1 TO
TO X
X
SU
SU = SU + B(A)
NEXT
NEXT
PRINT
PRINT :: PRINT "AVERAGE = "; SU/X
=
RUN
RUN
HOW
HOW MANY
MANY NUMBERS
NUMBERS :?
:? 5
5
# 11 ??125
125
ENTER
ENTER VALUE
VALUE#
ENTER
2 ?? 167
ENTER VALUE
VALUE #
#2
167
ENTER
LUE ##3
3 ?? 189
ENTER VA
VALUE
189
ENTER
LUE ##4
4 ?? 167
ENTER VA
VALUE
167
ENTER
5 ?? 158
ENTER VALUE
VALUE ##5
158
AVERAGE
,2
AVERAGE == 161
161.2
95
95
^
Line
Li ne 55 clears
clears the screen.
Line
INPUT
30.
Li ne 10
10 asks you to enter the total
to tal number of items you'll IN
PUT at liline
ne 30.
Line
array B. The loop
loop
Li ne 20
20 sets up
up aa loop that makes A the subscript for the array
adds
B.
adds 11 to A
A for every execution. This updates array B.
Line
Li ne 30
30 prompts you to INPUT a value for the subscripted variable B (A).
v
v
v
v
v
Lines
INPUT.
Li nes 50 through 80 keep a running total (SU) of the numbers INPUT.
Line
average.
Li ne 90
90 PRINTs
PRI NTs the average.
Each
1, so th
the
Each time
time the INPUT loop executes,
executes, A is increased by 1,
e next value
entered
program,
ar
entered is
is assigned to
to the next element in array B. At the end of the prog
ram, ar-
ray
ray B
B looks like this:
this:
B
B (D
(1)
125
125
B
B (2)
(2)
167
167
B
B (3)
(3)
189
189
(4)
(4)
167
167
B
B (5)
158
B
B
After
in array B.
B. You can
can now
now acac
After you INPUT
INPUT all
all the values,
values, they are stored in
v
v
v
cess
subscripted
variables.
cess these
these values
va lues just
just by using the subsc
ripted variab
les. For example, see
what
what happens
happens when you add these lines:
100 PRINT
PRINT B
(X - 1)
100
B(X-1)
PRINT B
(3)
120 PRINT
120
B(3)
130 PRINT
PRI NT B
(X - 3)
130
B(X-3)
DIMENSIONING ARRAYS
v
v
If you try
try to enter more than ten numbers in an array, you'll get
MENSION
If
get a DI
DIMENSION
ERROR. Arrays of more
more then ten elements need to be predefined in a DI
M ENDIMEN
SION statement. For example,
example, if you
yo u want an array to hold 25 values, you'd wr
ite
SION
write
th is statement
statement in your program:
prog ram:
this
DIM BB (25)
(25)
DIM
You can
can also
also use
use aa variable
variable in
a DIMension
You
in a
DIMension statement.
statement. For
For example,
example, in
in the
the
v
v
last program
program you could
co uld have used this statement since X equaled the total
last
number of
of values
values in
in array B:
number
15 DIM
DIM B
B (X)
(X)
15
But be
be careful
care fu l when
whe n you
you use
use variables
vari ables to
But
to define
define arrays:
arrays: once
once an
an array
array is
is
v
DIMensioned, it can't
can 't be reDIMensioned
re DI Mensioned in
ther part of the program. So
DIMensioned,
in ano
another
don't use
use aa variable
variable whose
whose value
value will
will change in the program.
don't
You can
can use
use more
more than
than one
one array in a program
m
You
program,, and you can DIMension the
them
all on
on the
the same
same line:
line:
all
v
10 DIM
DI M A
A (12),
(12), B
B (35),
(35), C
C (3,5)
(3,5)
10
v
Arrays A
A and
and B
B are
are one-dimensional
one-d imensional arrays,
imens ional array.
Arrays
arrays, but
but C
C is
is a
a two·d
two-dimensional
array.
v
v
One-dimensional arrays
arrays just
just have
have ROWS
ional arrays
One-dimensional
ROWS of
of data,
data, but
but two-dimens
two-dimensional
arrays
have both
both rows
rows and
and columns
columns of
of data,
data, just
just like
have
like a
a chart.
chart. Array
Array C
C has
has 3
3 rows
rows and
and 5
5
columns
.
Rows
are
always
listed
first
in
a
DIMension
statemen
t.
columns. Rows are always listed first in a DIMension statement.
v
v
96
96
SIMULATED DICE ROLL WITH ARRAYS
As you begin writing more comp
lex programs, you
'll find that subscripted
complex
you'll
variables cut down on the number of statements and make programs simpler to
write..
write
For example, a single subscripted variable can keep track of the number of
times each face on a die turns up in a dice roll:
11
10
20
30
40
50
60
70
SIMULATION : PRINT CHR$(147)
REM DICE SIMULATION:
INPUT ""HOW
HOW MANY ROLLS:";X
1 TO X
FOR L = 1
R
" RN D(1))+ 1
R = INT(6
INT(6'RND(1))+1
1
F(R) = F(R) + 1
NEXT L
TIMES"
PRINT ""FACE",
FACE" , ""NUMBER
NUMBER OF TIM
ES"
1 TO 6 :: PRINT C, F(C): NEXT
FOR C = 1
m
u'll throw the dice iin the simulated roll.
Line 10 asks you how many times yo
you'll
Line 20 sets up a loop to count the number of dice rolls so that the program
ends on the Xth roll.
R equal to the random number rolled.
Line 30 makes R
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
variable.
able.
subscript for the array,
example, even/
every time a 2
thrown , FF (2) is increased by one.
For example,
2 is thrown,
PRINTs the number of times each face shows up.
Line 70 PRINTs
up. Here's a sample
RUN:
HOW MANY ROLLS:
FACE
FACE
11
2
3
A4
5
5
66
?
?
1000
1000
NUMBER OF TIMES
TI MES
148
148
176
178
166
166
163
163
169
97
would
Now we'll show you how much longer your program wou
ld be if you didn't
use an array:
v
v
v
v
v
10
20
30
40
41
42
43
44
45
60
70
71
72
73
74
75
ROLLS:";X
INPUT ""HOW
HOW MANY ROLLS:";
X
FOR L = 11 TO X
INT(6*RND(1))+1
R = INT(6
'RND(1))+ 1
= 1
1 THEN F1 = F1 + 1 : NEXT
IF R =
R = 2 THEN F2
IF R
F2 + 1 : NEXT
R =
= 3 THEN F3 = F3 + 1 : NEXT
IF R
R = 4
4 THEN F4 = F4 + 1 : NEXT
IF R
= 5 THEN F5 = F5 + 1 : NEXT
IF R =
R =
= 6 TH
THEN
IF R
EN F6 = F6 + 1 : NEXT
PRINT " FACE"
NUMB ER OF TIMES"
FACE",, ""NUMBER
1, Fl
F1
PRINT 1,
2, F2
PRINT 2,
PRINT 3, F3
PRINT
4, F4
PR
INT 4,
5, F5
PRINT 5,
PRINT 6, F6
=
=
As yo
you
pro
u can see, the program has twice
twi ce as many lines. The longer the pro·
gram , the more space and time you can save when you use arrays.
gram,
arrays.
v
v
v
v
98
98
TWO·DIMENSIONAL ARRAYS
ARRAYS
TWO-DIMENSIONAL
As
As we
we mentioned
mentioned before,
before, two-dimensional
two-dimensional arrays
arrays have
have both
both rows
rows and
and
columns,
columns , like
like aachart
chart or
oraa table.
table.Two-dimensional
Two-dimensional arrays
arrays have
have two
two subscripts:
subscripts:
the
the first
first one
one isis for
for the
the ROW
ROW number;
number;the
th esecond
second isis for
for the
the COLUMN
COLUMN number.
number.
For example:
example:
For
-
(4 ,6) has
has 44 ROWS
ROWS
AA (4.6)
and 66 COLUMNS
COLUMN S
and
Here's
Here's what
what array
array AA would
wo uld look
look like
like as
as aa two-dimensional
two-dime nsional grid
grid inin memory:
memory:
o
0
33
22
1
44
55
0.
66
o
2
3
4
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
You'll
(4,6),
yo
u're
creating
an
array
with
5
rows
and
7
colum
ns,
or
35
elements.
(4,6), you're
5
7 columns,
elements.
You
element of
of a
a two-dimensional
row and
You can
can access
access any
any element
two-di mensional array
array by
by using
using its
its row
and
column subscri
subscripts.
For exampl
example,
suppose you
you want
to assign
255 to
(3,4):
column
pts. For
e, suppose
want to
assign 255
to A
A (3
,4):
n
n
n
10 LET A(3.4)
10
A(3,4) = 255
Here's what th
e grid looks like now:
the
o0
12
2
33
44
55
66
o0
1
22
255
255
33
44
Two-dimensional
arrays follow
follow the
the same
same rul
rules
as one·dimensional
one-dimensional arrays:
arrays:
Two-d
imensional arrays
es as
DIM
ensioning:
DIMensioning:
Assigning
Assigning data
data values:
values:
Assigning
ues to
Assigning val
values
to
other
ues:
other val
values:
ng val
ues:
PRINTi
PRINTing
values:
DIM A
A (20,20)
(20.20)
DIM
A(1.1)
255
A(1,
1) = 255
=
AB == A(1,1)
A(1,1)
AS
PRINT
PRINT A(1,1)
A(1.1)
99
99
m
Here's
Here's an
an example
example of
of how
how two-dimensional arrays
arrays can
can be
be used.
used. This example
example
keeps track
track of
of responses
responses to
to a
a club
club questionnaire like
like this:
this:
keeps
CLUB
CLUB QUESTIONNAIRE
Q1: ARE
LUTION #1?
ARE YOU IN
IN FAVOR
FAVOR OF RESO
RESOLUTION
11 -— YES
....,
v
2 -— NO
NO
3 -— UNDECI
DE D
UNDECIDED
Let
's suppose there are four questions, so the array, which we'll call A, will be
Let's
DIMensioned A(4,3). Here's
Here's how
how the array table looks:
looks:
DIMensioned
YES
NO
NO
UNDECIDED
UNDECIDED
QUESTION
QU
ESTI ON 11
QUESTION
QU
ESTI ON 2
QUESTION
QU
ESTI ON 3
QUESTION 4
The program that keeps track of the responses is on the next page. This pro·
pro
gram uses many of the programming techniques that have been presented so
far.
far.
Lines 30-65 PRI
NT the questions in numerical order and ask you to INPUT the
PRINT
response.
Line 70 adds one to the appropriate array element. Remember that R
R is the
number, and the questions are in rows. C
C is the response number,
number, and
question number,
the responses are in columns.
v
Line 90 asks if you have another set of responses to IN
PUT.
INPUT.
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 the
the 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
the array. Recall the R
R is the question
question number and C
C is
is the response number,
number,
of the
to question
question 22 is 33 (undecided),
(undecided), line 70 adds one to
to array ele
eleso if your response to
ment A{2,3).
A(2,3)_
You 'll notice
noti ce that we
we didn't use
use the
the zeroth
zeroth row and column
colum n in
in this
th is example.
example.
You'll
You don't
don't have to
to use
use this row
row and column,
colum n, but
but remember
remember that
that they
they are
are always
always
You
present
present in
in even/
every array
array you
you use.
use.
v
v
v
100
100
SHIFT
20
20
30
40
50
60
61
61
65
70
80
85
90
PRINT
HOME> ""
PRINT"" (CLRI
<CLR/HOME>
FO
RR
4
FOR
R = 1
1 TO 4
PRIN
T "QUESTION # :: "; R
PRINT
R
PRINT " 1·YES
DED"
1-YES 2·NO
2-NO 3·UNDECI
3-UNDECIDED"
PRINT ""WHAT
WHAT WAS THE RESPNSE :: ";
GET C:
C: IF
C (1
<1 or
or C>
C> 3
3 THEN
THEN 61
61
GET
IF C
PRINT C: PRINT
A(R,C) = A(R,C) +:
+ : REM UPDATE ELEMENT
NEXT R
R
PRINT
PRINT ""DO
DO YOU WAN
T TO ENTER ANOTHER";
ANOTHER": PRINT
WANT
""RESPONSE
RESPONSE (Y
I N)";
(Y/N)";
100 GET A$ :: IF A$ = " " THEN 100
110 IF AS
A$ = "Y" THEN 20
120
IF A$ (>
N" THEN
120IFAS
<> ""N"
THEN 100
100
130
CLRI HOME >
130 PRINT
PRINT "" <CLR/HOME
> ";"THE
";"THE TOTAL
TOTAL RESPONSES
RESPONSES
ERE:": PRINT
W
WERE:":PRINT
140 PRINT SPC(18);"
RESPONSE"
SPC(18);"RESPONSE"
141 PRINT "QU
ESTlON","YES" ,"NO"," UNDECIDED"
"QUESTION","YES'VNO","UNDECIDED"
.""
142
142 PRINT
PRINT .....................................
"
150 FOR R
4
R = 1
1 TO 4
160 PRINT R,
A( R,1), A(R,2), A(R,3)
A(R,3)
R, A(R,1),
170 NEXT R
R
RUN
~
<
~
QUESTION # :: 1
1
1-YES
2-NO
3-UNDECIDED
1·YES 2·NO 3·UNDECIDED
WHAT WAS TH
E RESPONSE :: 1
THE
1
QU
ESTION # : 2
QUESTION#:2
1·YES
NDECIDED
1-YES 2·NO
2-NO 3·U
3-UNDECIDED
WHAT WAS THE RE
SPONSE :: 1
RESPONSE
1
^
And so on.
on ...
THE TOTA
L RESPONSES W
ERE:
TOTAL
WERE:
QUESTION
YES
RESPONSE
NO
UN
DECIDED
UNDECIDED
11
2
3
4
A
6
5
5
7
7
2
2
1
1
2
0
4
4
0
0
0
0
1
1
1(11
101
-
APPENDICES
APPENDICES
INTRODUCTION
INTRODUCTION
Now
Now that
that you've
you 've gotten
gotten to
to know
know your
you r 64,
64, we
we want
want you
you to
to know
know that
that our
our
customer
here. You
You may
may not
not know
know itTit, but
but Commodore
Commodore
customer support
support does
does not
not stop
stop here.
has been
been inin business
business for
for over
over23
23years.
years. InInthe
the1970's
1970'swe
we introduced
introduced the
thefirst
fi rst selfsel f·
has
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 of
of the
the world.
world. Our
Our ability
ability to
to design
design and
and
manufacture
man ufac tu re our
our own
own computer
computerchips
chips lets
lets us
usbring
bring you
you new
new and
and better
bett er personal
personal
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
computers
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 who
who sold
sold you
you your
your computer,
computer, magazines
magazines that
that
publish how-to
how·to articles
articles showing
showing you
you new
new applications
applica tions or
or techniques,
techn iques, and
and soft
salt·
publish
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 to
to 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 on
on new
new products
products and
and 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 NetNet·
To use
use this
this network,
network, all
all you
work" on
on the
the CompuServe
CompuServe Information
Information Service.
Service. To
work"
need
need is
is your
your 64
64 computer
computer and
and our
our low
low cost
cost VICMODEM
VICMODEM telephone
telephone interface cart
cart·
(or
oth
er
compatible
modem).
ridge
ridge (or other compatible
The following
other information
following APPENDICES
APPENDICES contain
contain charts,
charts, tables, and other
information
you program your
you r Executive 64 faster
faste r and more
more efficiently.
efiiciently. They
which help you
which
CommOdore products
also include important information on the wide variety of Commodore
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
pherals.
peripherals.
102
102
^
APPENDIX A
AVAILABLE SOFTWARE
PROGRAMMING AIDS & COMPUTER LANGUAGES
C64 101 -— ASSEMBLER 64
Designed for experien
ced Assembly language prog
rammers. Package inexperienced
programmers.
in
cludes everythi
ng
needed
to
create,
assemble,
load
and
execute
6500
series
everything
assemble,
Assemb ly language code. Macro assembler ·• Two machine language monitors
Assembly
• Editor and loaders ·• Support routines ·• User manual.
C64 103 -— DISK BONUS PACK
enced and inThe Commodore 64 DISK BONUS PACK introduces the experi
experienced
in
personal comput
computer.
will find: entertainentertain
experienced user to our exciting personal
er. You will
assist
ment games, utilities to ass
ist in your programming, music and video programs
abilities
64, and several educational and personal
personal propro
to demonstrate the abilit
ies of the 64,
grams.
C64 104 —
- SUPER EXPANDER (VSP)
The SUPER EXPANDER 64 is a powerful extension of the BASIC language.
Previously,
fic memory registers in order to ac
acPreviously, you had to Peek or Poke speci
specific
features.
cess many of the computer's feat
ures. This package provides the commands
you need to use Commodore's
graphics, mUSiC,
Commodore's graphics,
music, and sound capabilities.
C64 105
105 -— LOGO
LOGO is an educati
onal language for students.
students. Because LOGO is so ve
educational
verrsatile,
satile, it is simple enoug
enoughh for pre-schoolers and sophisticated enough to
graduates. A
A small triangular cursor,
cursor, called a Turtle,
Turtle, is used
challenge college graduates.
to draw the graphics.
LOGO includes the following
foll owing features: four different types of screens;
a TRACE command
com mand for programming
programming and debugging;
debugging;
cataloging commands; a
LI
ST processing; and
and the ability
abi lity to
10 read music,
mUSiC, graphics,
graphics, and text files
fi les previous
previousLIST
ly created
c reated with LOGO.
LOGO.
C64 106
106 —
- PILOT
mos t powerful
powerfu l version
version of PILOT
PILOT available. With
With this
PILOT for the 64 is the most
ca n define
define your
yo ur own
own characters,
characters, create
create colorful,
colorful, movable
movable objects
prog ram, you
yo u can
program,
called sprites,
sprites, and
and create
create music and
and aa variety of
of sound effects. This is a
called
educators can write their
their own
own software which
which
superior instructional
instructional tool
tool .. .... educators
superior
combines fun.
fu n, entertainment,
entertainment, and
and learning.
learn ing. Programs written
writt en on
on COMMON
RUN -ONLY VERSION
VERSION of
PILOT can
can also
also be
be run
run without any conversions. Also,
Also, aa RUN-ONLY
PILOT
the program
program is
is included.
included.
the
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
software
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 109
109 —
- SCREEN
SCREEN EDITOR
EDITOR
C64
Design
Design your
your own
own screens!
screen s! The
The Screen
Screen Editor
Editor helps
helps you
you design
design software
software on
on
64 by
by letting
lettingyou
you create
create and
andedit
edityour
yourown
ownscreens.
screens.This
This programming
programming tool
tool
your64
your
isis for
for users
users with
with some
some computer
computer experience.
experience. The
The Screen
Screen Editor
Editor helps
helps you
you
design
design computer
comp uterapplications
app lications with
with functions
functions such
such as
as these:
these: Screen
Screen field
field editor;
editor;
Data field
field definition
definition and
and editing;
editing; Cursor
Cursor movement
movement from
from field
field to
to field,
fi eld, both
both
Data
backwards and
and forwards;
forward s; Quick
Quick screen
screen design
design capabilities.
capabi li lies.
backwards
C64 110
110 —
- CP/M'
CP/M 2.2
2.2 OPERATING
OPERATING SYSTEM
SYSTEM
C64
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
This system
system lets
lets you
you expand
expand the
the software
software applications
applications you
yo u can
can use
use
comp uter. This
computer.
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 of
of the
the many
many available
available CPIW
C P/M!> programs,
programs, including
including widely
widely used
used business
business
some
applications, word
word processing,
processing, and
and high
high level
level computer
computer languages.
languages.
applications,
' CP/M isis aa registered
registered trademark
Irademal1l oi
0 1Digital
Oigital Research.
Research, Inc.
Inc
■CP/M
BUSINESS SOFTWARE
SOFTWARE - FOR
FOR HOME
HOME AND
AND OFFICE
OFFICE
BUSINESS
C64 200
200 —
- EASY
EASY CALC
CALC 64
64
C64
EasyCatc
64 is
is an
an easy-to-use
easy-to-use electronic
electronic spread
spread sheet.
sheet. EasyCatc
EasyCalc has
has editing
editing
EasyCalc 64
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
forfunctions
matted
matted tables.
tables. EasyCalc
EasyCalc also
also lets
lets you
you view
view up
up to
to four
fou r pages
pages at
at once
once on
on 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,
payment, last payment
payment,,
calculating 12 loan concepts for
Principal, regular payment,
and remaining balance are just some of the functions EASY FINANCE can
ng know
ledge to use this
determine. You need absolutely no programmi
programming
knowledge
product.
C64 204 -— EASY MAIL 64
Now
Now your
your address
address files
files can
can be
be simple
simple to
to manage!
manage! Keep
Keep track
track of
of names
names and
and
addresses, simplify label printing. EasyMaii
EasyMail has
has all the features you need to
les for specific categories
prepare
prepare special mailings
mailings by
by searching your address fifiles
such as zip code. Especially
ubs and small businesses.
Especially useful
useful for cl
clubs
businesses. Here
Here are
some
of
EasyMail's
features:
Entry,
change,
or
deletion
of
name
and
address
by
some of EasyMail's features : Entry, change, or deletion of name and address by
name or
or number;
number; One
One or
or two
two abreast
abreast address
address labels;
labels; A
A com
complete
printout of
of all
all
name
plete printout
the data
data in
in your
your rec
records;
A HELP
HELP function
function that
that you
you can
can reques
requestt at
at any
any time.
time.
the
ords ; A
C64
C64 207
207 -— EASY
EASY SCRfPT
SCRIPT
Powerful word
word processor
processor with
with table
table producing
producing capabilities;
capabilities: comprehensive
comprehensive
Powerful
printer
controls:
easy
up-date
facilities;
easy
document
handling
and much,
much.
printer controls; easy up-date facilities; easy document handling and
much
much more.
more.
C64
C64 208
208 -- EASY
EASY SPELL
SPELL 64
64
Now you
you can
can prod
produce
flawless wri
writing!
EasySpell 64 offers
offers all
all these
these features:
features:
Now
uce flawless
ting ! EasySpel164
Automatically corrects
corrects spelling
spelling errors;
errors; Counts
Counts the
the words
words in
in your
your manuscript;
manuscript:
Automatically
Has aa built-in
built-in 20,000
20,000 word
word lexicon
lexicon that
that lets
lets you
you add
add words
words not
not already
already stored
stored
Has
there;
there; Is
Is designed
designed to
to be
be used
used with
with EasyScript
EasyScript 64,
64, an
an easy-to-use
easy-to-use wordwordprocessor. Because
Because you
you can
can add
add to
to the
the lexicon,
lexicon. EasySpel1
EasySpell can
can easily
easily be
be
processor.
adapted for
for writing
writing reports
reports in
in specialized
specialized fields
fields such
such as
as medicine,
medicine, law,
law, and
and
adapted
science.
science. All
All you
you do
do isis add
add the
the words
words you
you use
use to
to the
the lexicon!
lexicon!
104
104
v
C64 210 -— WORD/NAME MACHINE
Commodore's most easy·to·learn
to·use wordprocessing package.
easy-to-leam and easy·
easy-to-use
Designed for beginners and perfect for letters, address lists, and notes. Some
of the features available in these companion programs,
programs, Word Machine and
Easy-to-understand menus that let you choose what you want
Name Machine: Easy·to·understand
do; Overtyping
Overtyping,, inserting,
inserting, and deleting of text; Three print formats: Draft
Draft,, In·
In
to do;
formal,
formal. Formal;
Formal; Personalized form letters;
letters: Easy-ta-write
Easy-to-write name and address file
that lets you select by category; Prompts for data you input into the name and
to·use telephone and name and address book;
address file; Prints an easy·
easy-to-use
Prints name and address labels.
C64 212 -— EASY FINANCE II
Helps you make the right financial decisions by showing you how to make
v
the most
lculates such
mosi out of sixteen investment concepts. The program ca
calculates
functions as future investment value, initial investment, and internal
internal rate of
return. EASY FINANC
E II is very clear and easy to use;
FINANCE
use; you need absolutely no
programming knowledge to use this product.
C64 213 -— EASY FINANCE III
rsi on of EASY FINANCE II; it shows you how to make the
Is an advanced ve
version
most out of sixteen more investment concepts
concepts.. Financial terms and practices
ial paper,
are clarified and functions such as discount commerc
commercial
paper, financial
management rate of return, and financial leverage and earnings per share are
calculated
calc
ulated for you.
C64 214 —
- EASY FINANCE IV
Is a business managemenl
management package that shows managers how to make the
compensation , and much
right decisions about production, inventory, control
control,, compensation,
more. Lease purchase analysis, depreciation switch, and optimal order quantity
the 21
2t functions this
this program will calculate
calcu late for you.
are some of the
C64 215 —
- EASY FINANCE V
V
yo u how to make the most out of statistics such as
as payoff matrix
Shows you
analysis,
forecasting,
analYSiS, regression analysis forecast
ing, and apportionment by ratios.
rati os. It is
is
v
completely pre-programmed
pre ·programmed and very easy to use. With
With just
iust aa few simple
si mple
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, accumulates
accumulates totals
totals on
on screen
screen and creates
creates subfiles.
subfiles. Sorts
Sorts from
from any
any field.
field.
ing,
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;
disbu rsemen ts ; general
general journal
journal transactions.
transactions. Interfaces with other
other accounting
accounting
disbursements;
modules
modules for
for automated
automated posting
posting of
of G/L
GIL transactions.
transactions . Maintains
Maintains account
account
balances monthly,
monthly, quarterly,
quarterly, yearly,
yearly, previous
previ ous quarters
quarters and
and years.
years. Departmental
Departmental
balances
reporting
reportin g and
and many
many other
other features.
features.
v
v
105
105
C64221
221 —
- RECEIVABLE/BILLING
RECEIVABLE/BILLING
C64
Maintainscustomer
customermaster
masterfile.
file. Automatic
Automatic billing
billingwith
withcredit
creditchecking,
checking ,item
item
Maintains
descriptions, unit
unit pricing,
pricing, and
and extensions
extensions when
when interfaced
interfaced with
with Order
Order
descriptions,
Entry/Point-o f-Saleand
and Inventory
Inventory Management
Management Modules.
Modules. Flexible
Flexi blebilling
billingofofany
any
Entry/Point-of-Sale
itemand
and unit
unit price
pricewhen
when used
usedas
asstand-alone
stand-alonesystem.
system.Automatically
Automatically posts
postsbill
bill·
item
ings. Interfaces
Interfaces with
with the
the general
general ledger
ledgerfor
forautomated
automated postings.
postings.Automatically
Automatically
ings.
ages open
open receivables
recei vables by
by 30.
30,60,
60, 90
90 day
day categories.
categories.
ages
C64 222
222 —
- ACCOUNTS
ACCOUNTS PAYABLE/CHECKWRITING
PAYABLE/CHECK WRITING
C64
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 open
open item
item aging
aging report
report by
by30,60,90
30, 60, 90day
daycategories.
categories. Interfaces
Interfaces with
with the
the
Provides
general ledger
ledger for
for automated
automated postings.
postings.
general
C64 223
223 —
- PAYROLL
PAYROLL
C64
Master record
record of
of each
each employee
employee pay
pay activity.
activity. Automatically
Automatically calculates
calculates period
period
Master
pay
pay amount
amount including
including all
all tax
tax and
and miscellaneous
miscellaneous deductions.
deductions. Prints
Prints payroll
payroll
checks with
with full
full pay
pay deduction
deduction detail.
detail. Comprehensive
Comprehensive management
management reporting
reporting
checks
W2 's and
and 941's.
941 's. General
General ledger
ledger interface
interface for
for automated
automated postings.
postings.
including W2's
including
C64 224
224 —
- INVENTORY
INVENTORY MANAGEMENT
MANAGEMENT
C64
Perpetual inventory
inventory records
records for
for all
all stock
stock items.
items. Processes
Processes stock
stock receipts,
receipts,
Perpetual
stock issues,
issues, stock
stock orders,
orders , and
and stock
stock adjustments
adjustmen ts with
with full
full audit
audit trail.
trail. Optional
Optional
stock
interface
for automated
automated billing
billing of
of inventory
inventory items
items
interface to
to Order
Order Entry/Point-of-Sale
Entry/Point-of-Sale for
and
and automated
automated stock-on-hand
stock-on -hand reduction.
reduct ion. Capability
Capability to
to selectively
selectively calculate
calculate re
reorder
level and
and economic
order quantity
quantity by inventory
inventory category.
Ass ists manage·
order level
economic order
category. Assists
manage
ment in parts ordering by generating shortage and re-order reports.
reports.
GAMES & RECREATION
C64601
JUPITER LANDER
Joystick or Keyboard
C64 601 -—JUPITER
LANDER
Keyboard
You
must
carefully
land
your
spacecraft
on
the
only
solid
landing
site on
on
You must carefully land your spacecraft on the only
landing site
Jupiter. As long
long as
as your fue
fuell holds
holds out, you can make
make exploratory landings to try
to find aa solid
solid place.
place. But
But you must
must land
land below the yellow
yellow zone
zone or
or your ship
ship will
will
crash.
crash.
C64
KMAN
Joystick
C64 602
602 -— KIC
KICKMAN
Joystick or
or Keyboard
Keyboard
In KICKMAN
KICKMAN,, you
you maneuver
maneuver aa clever
clever unicyclist
unicyclist who
who scores
scores paints
points by
by catchcatch
. In
PAC-MAN.
KICKMAN
uses
his
head
and
his
feet
Ing
balloons,
ghosts,
and
ing balloons, ghosts, and PAC-MAN. KICKMAN uses his head and his feet to
to
catch
catch the
the falling
falling objects.
objects. During
During some
some phases
phases of
of the
the game,
game, KICKMAN
KICKMAN bursts
bursts
the
the balloons
balloons to
to score
score pOints.
points.
C64
C64 603
603 -— SEAWOLF
SEAWOLF
Paddles
Paddles
As
As the
the commander
commander of
of 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
Joystick
C64604
604-— SPEED/BINGO
SPEED/BINGOMATH
MATH
Joystickor
orKeyboard
Keyboard
These
ild math
These two
two math
math games
games help
help you
you bu
build
math skills
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 to
to solve
solve aavariety
varietyof
of math
math problems.
problems.
BINGO
BINGO MATH
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
Joystick
C64605
605 - - RADAR
RADARRAT
RATRACE
RACE
Joystickor
orKeyboard
Keyboard
InIn RADAR
RADAR RAT
RAT RACE,
RACE, you
you are
are aa mouse
mouse trying
trying to
to score
score points
points by
by eating
eating ten
ten
pieces
pieces of
of cheese
cheese randomly
randomly placed
placed inin aa maze.
maze. While
While you
you search
search for
forthe
the cheese,
cheese,
, and
you
're pursued
you're
pursued by
by rats
rats,
and you
you must
must avoid
avoid deadly
deadly black
black cats.
cats. You
You have
have three
three
lives and
and limited
limited time
time to
to score
score pOints.
points.
lives
v
C64 606
606 -— CLOWNS
CLOWNS
Paddles
C64
Paddles
Score
Score paints
points in
in CLOWNS
CLOWNS by
by popping
popping aa skyfu
skyfull of
of colored
colored balloons.
balloons. You
You have
have
two
two CLOWNS,
CLOWNS, one
one on
on aa seesaw,
seesaw, and
and one
one sailing
sailing through
through the
the air
air bursting
bursting
bal
loons. When
balloons.
When the
the clown
clown comes
comes down,
down, you
you must
must catch
catch him
him with
with the
the seesaw
seesaw
and send
send the
the other
other clown
clown up
up to
to pop
pop balloons.
balloons.
and
C64
C64 609
609 -- VISIBLE
VISIBLE SOLAR
SOLAR SYSTEM
SYSTEM
Keyboa
rd
Keyboard
You
You are
are the
the commander
commander of
of aa spaceship
spaceship on
on aa journey
journey through
through our
our Solar
Solar
System.
ising range
System. The
The ship
ship has
has aa cru
cruising
range of
of over
over 11 billion
billion miles
miles and
and is
is packed
packed with
with
computerized
computerized equipment
equipment to
to help
help you
you discover
discover more
more about
about the
the planets
planets that
that you
you
visit.
visit.
C64
Joyslick
C64 610
610 -- TOOTH
TOOTH INVADERS
INVADERS
Joystick
In
In this game for
for children,
children, the
the evil
evil O.K.
D.K. spreads plaque
plaque on your teeth. You
You
must
leaned , itit
must floss
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,
glows and changes color. You can kill
kill O.K.
D.K. by
by running
running over him,
him, but
but he always
comes
comes back!
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
down from
from a
a cloud.
cloud.
rains
C64 613
613-LAZARIAN
Joystick
C64
- LAZAR IAN
Joystick
You
the pi
lot of
You are
are the
pilot
of a
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
ere are
phases in
in the
the game,
and you
you get
get three
th ree ships
aa variety
variety of
of threats.
threats. Th
There
are three
three phases
game, and
ships
to
to complete
comp lete your
your mission.
mi ssion.
C64 614
614 —
- OMEGA
OMEGA RACE
RACE
Joystick, Paddles,
Paddles, Keyboard
Keyboard
C64
Joystick,
You are
are an
an Omegan
Omegan ship
ship competing
competing against
against the
the Droids,
Droids, the
the most
most powerful
powerfu l
You
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
force
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 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
Your
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
many
icy roads,
roads , divided
divided highways,
highways, dark
dark
takes you
you over
over hazardous
hazardous terrain,
terrain , including
includ in g icy
takes
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
roads,
race
race to
to the
the finish
finish line.
line.
C64 617
617 - PINBALL
PINBALL SPECTACULAR
SPECTACULAR
Paddle
C64
Paddle
PINBALL SPECTACULAR
SPECTACU LAR isis like
like playing
playing pinball
pinball on
on your
your 64.
64. This
This game
game offers
offers
PINBALL
fast
fast action
action and
and great
great sound
sound effects.
effects.
C64625-ZORKI
625 - ZORK I
Keyboard(Disk)
(Disk)
C64
Keyboard
ZORK
I
invo
lves
the
Great
Underground
Empire;
it
confronts
you
with
perils
ZORK I involves the Great Underground Empire; it confronts you with perils
and predicaments
predicaments ranging
ranging from
from the
the mystical
mystical to
to the
the macabre.
macabre. You
You strive
strive to
to
and
discover the
the Twenty
Twenty Treasures
Treasures ofof ZORK
ZORK and
and escape
escape with
with them
them and
and your
your life!
life!
discover
107
107
C64626
626—
- ZORK
ZOR KIIII
C64
Keyboard
Keyboard
ZORK
ZORK IIII gives
gives you
you aa helpful
helpful robot,
robot, an
an elusive
elusive unicorn,
unicorn, aa princess
princess who
who needs
needs
rescuing,
resc uing,and
andaademon
demon who
who demands
demandsall
all of
of your
your treasure.
treasure. Most
Mostof
ofthe
thecreatures
creatures
in ZORK
ZORK IIII cannot
cannot be
be harmed
harmed by
byyour
your sword,
sword ,bombs,
bombs,or
or poison,
poison, as
as they
they could
could inin
in
ZORK I.I.
ZORK
C64627
627 —
- ZORK
ZORK III
III
Keyboard
C64
Keyboard
ZORK IIIIII involves
involves aa delightful
del ightful and
and curious
curious place
place with
with ancient
ancient high-arched
high-arched
ZORK
aqueduct
swirling mists
mists of
of the
the Land
Land of
of Shadow,
Shadow, and
and aa brilliant
bri lliant pit
pit of
of
aqueduct systems,
systems, swirling
fire.
II I gives
gives you
you aa
fire. You
You should
should use
use logical
logical problem-solving
problem-solving in
in this
this game;
game; ZORK
ZORK III
theme, morals,
morals, and
and meaning
meaning inin your
your adventures.
adventures.
theme,
C64 628
628 —
- DEADLINE
DEADLI NE
Keyboard
C64
Keyboard
You
Yo u are
are the
the chief
chief of
of detectives
delectives trying
trying to
to solve
solve the
the 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 the
the
The mystery
mystery is
is confusing,
confusing, and
and it's
it's easy
easy to
to
wrong will
will is
is read
read to
to the
the eager
eager heirs.
hei rs. The
wrong
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.
get
C64629
- STARCROSS
STARCROSS
C64
629 —
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 smartsmart-
aleck computer
computer and a mass
mass detector.
detector.
- SUSPENDED
C64 630 —
Keyboard
SUSPE
NDED takes place on aa computer-controlled
compu ter-controlled planet that is facing
fac ing aa
SUSPENDED
catastrophe. The
main computer
computer has
has just
malfunctioned; you
you take
control and
catastrophe.
The main
just malfunctioned;
take control
and
guide six robots to help you manually maintain the planet while they try to
discover and repai
pu ter's breakdown.
repairr the cause of the com
computer's
ART &
& MUSIC
C64 402 -— MUSIC MACHINE
The MUSIC
MUSIC MACHI
MACHINE
cartridge turns
turns your
your 64
64 keyboard
keyboard into
into a
a music
music synsyn
NE cartridge
The
thesizer. Now
Now you
you can
can fully
fully use
use the
the music-making
music-making capabilities
capabilities of
of your
your compute
computerr
thesizer.
even
ow how
even ifif you
you can't
can't program
program itit or
or don'
don'tt kn
know
how to
to play
play music.
music. The
The MUSIC
MUSIC
MACHI
NE is
MACHINE
is both
both fun and educational.
C64
C64 403
403 -— MUSIC
MUSIC COMPOSER
COMPOSER
Yo
u don't
You
don't have
have to
to be
be a musician
musician to
to make
make music
music on
on your
your 64.
64. This
This package
package
teaches
teaches you
you everything
everything you
you need
need to
to know
know to
to play
play songs
songs and
and create
create sound
sound efef
ies sample
fects
fects on
on your
your computer.
computer. The
The manual
manual also
also suppl
supplies
sample songs
songs for
for you
you to
to
play.
play.
EDUCATION
EDUCATION &
& LEARNING
LEARNING AIDS
AIDS
C64
C64 310
310 -— EASYLESSON
EASYLESSON 64
64 and
and EASYQUIZ
EASYQUIZ 64
64
EasyLesson and
and EasyOuiz
EasyQuiz let
let yo
you
use your
your 64
64 as
as aa teaching
teaching tool.
tool. With
With these
these
EasyLesson
u use
two
two programs,
programs, you
you can
can easily
easily create
create lessons
lessons and
and tests
tests on
on topics
topics that
that you
you
choose.
Here
are
some
of
the
things
you
can
do
with
these
education
pro
choose. H ere are some of the thi ngs yo u can do with these ed ucation programs:
reate aa pool
uestions to
lassify ques
ti ons into
grams: CCreate
pool of
of qquestions
to use
use as
as aa lesson;
lesson: CClassify
questions
into as
as
many as
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
many
ui z; Give
questions
fore each
questions be
before
each qquiz;
Give the
the lest
test in
in either
either flash
flash card
card or
ormultiple
multiple choice
choice
form
at.
format.
108
108
r\
PUBLIC DOMAIN
DOMAIN SERIES
SERIES
PUBLIC
C64 700
700 —
- BUSINESS
BUSINESS 1I
C64
This package
pac kage contains
contai ns fourteen
fourteen programs
programs that
that cover
cover aa variety
variety of
of business
business ap
apThis
plications.
plications. The
The programs
programs include
include calculating
calcu lating interest,
interest, simulating
simulating business
business
and simulating
simulating stock
stock transactions.
transactions.
operations, and
operations,
C64 701
701 —
- GEOGRAPHY
GEOGRAPHY II
C64
This educational
educat ional package
package contains
contains thirteen
thi rteen quizzes
quizzes about
about countries,
countries, states,
states,
This
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
and
England.
England.
C64 702
702 —
- ENGLISH
ENGLISH II
C64
14 programs
prog rams that
that teach
teach you
you more
more about
about English.
Engl ish. Word
Word games,
games, poetry,
poetry, word
word
14
defin itions, and
and parts
parts of
of speech.
speech.
definitions,
C64 703 - ENGLISH
ENGLISH IIII
C64
16 programs
programs help
help sharpen your
your language
language skills.
skills. Spelling
Spelli ng and
and vocabulary
vocabulary
16
dri lls, lessons
lessons about homonyms,
homonyms, verb
verb forms,
forms, and
and punctuation.
drills,
704 —
- ENGLISH III
C64 704
Collection of
of 15
15 programs
programs from Commodore's
Commodore's English language series con
conCollection
more about the parts of speech.
centrating on teaching you more
- ENGLISH IV
C64 705 —
15 more English language programs —
- drills on rhyming
15
rhyming,, unscrambling
words,
and spelling.
spelling.
words, and
C64 706 -- ENGLISH V
13 programs -— mostly spelling drills and games that ask you to unscramble
13
words.
a quiz about some of Shakespeare's plays.
words. Also a
C64 707 -— ENGLISH VI
Thi
s part of the Eng
lish language seri
es is made up most
ly of tests on word
wo rd
This
English
series
mostly
meanings,
ulary. 12
meanings, spelling, and vocab
vocabulary.
12 programs in all.
C64 708 -— ENGLISH VII
The seventh collection of English language programs offers 3 challenging
wo
rd games.
word
C64 709 -— MATHEMATICS I
Educational package drills you in
in arithmetic, gives you algebra lessons, and
challenges yo
u wi
th math games.
you
with
C64 710 -— MATHEMATICS II
Math
ucational package
Math ed
educational
package includes
includes 15
15 programs.
C64 711 -— MATHEMATICS
MATHEMATICS III
Collection of math
rams offers lessons
math education prog
programs
lessons and drills on metric
metric
conversio
n, fac
toring , probabil
ity, math
conversion,
factoring,
probability,
math,, and algebra.
algebra. Total of 15
15 programs.
programs.
109
109
C64 712
712 —
- MATHEMATICS
MATHEMATICS IV
C64
Fourteen more
more math
math education
education programs. Lessons
Lessons and
and drills
drills cover
cover factoring
factoring
Fourteen
and algebra.
algebra.
C64 713
713 —
- MATHEMATICS V
V
C64
Fifteen more
more math
math education
education programs.
programs. Learn while
while you
you have
have fun.
fun .
Fifteen
- MATHEMATICS
MATHEMATICS VI
VI
C64 714 —
of math
math education
education programs including
including more
more drills,
drills, quizzes,
quizzes, and
and
Collection of
games. 15
15 programs.
programs.
math games.
715 —
- MATHEMATICS
MATH EMATICS VII
VII
C64 715
advanced math
- prime
prime numbers, and
and roots.
Sixteen advanced
math programs —
- MATHEMATICS
MATH EMATICS VIM
VIII
C64 716 —
Fi nal package in
in the math
math education series contains eleven programs. In
In·
Final
eludes
dri
lls,
games,
and
lessons
on
algebra,
trigonometry
,
slopes
and
lac·
cludes drills,
algebra, trigonometry,
fac
tari ng.
toring.
- COMPUTER SCIENCE II
C64 717 —
These thi
rteen programs show you
thirteen
you more about using your computer. The
programs include sorting lists,
ng graphics, and creating animation.
programs
lists, drawi
drawing
C64 718 -- SCIENCE II
Collection of science education programs,
programs, mostly about chemistry,
chemistry, but other
sciences included.
C64 719 -— SCIENCE II
13 science programs.
programs. Lessons
Lessons and quizzes cover several topics in physics
and chemis
try
and
other
sciences.
chemistry and
sciences.
C64 720 -— SCIENCE III
12 more science education programs,
programs, including a variety of
of scientific areas.
C64 721 -— SCIENCE IV
This education
ftware package contains an assortment of lessons and
education so
software
quizzes on various sciences, particu
larly biology.
particularly
biology.
C64 722 -— TECHNOLOGY II
This package of ten programs covers a variely
lated to technology
variety of topics re
related
and how recent advances affect our lives. You
'll learn more about computers as
You'll
you have fun learning.
C64 723 -— HISTORY II
This package offers four challenging quizzes on history and lamous
famous people.
There is also a fascinat
ing simulation of nineteenth
fascinating
nineteenth century American
elections
elections..
C64 724 -— GAMES I
Here is an opportunity to learn while you have fun on your computer! 14 fun
and educational games.
110
n
C64 725
725 —
- GAMES
GAMES IIII
C64
AA collection
col lec ti on of
of 13
13 educational
ed ucational games.
games. Word
Word guessing,
guessing , logic
logic games,
games, math
math
games and
and aa simulation
simulation of
o f Hi-Q.
Hi·a.
games
C64 726
726 —
- GAMES
GAMES III
III
C64
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
in this
thi s collection.
coll ection.
games
—
-
-
111
111
APPENDIX BB
APPENDIX
DESCRIPTION OF
OF DOS
DOS ERROR
ERROR MESSAGES
MESSAGES
DESCRIPTION
NOTE: Error
Error message
message numbers
numbers less
less than
than 20
20 should
should be
be ignored
ignored with
with the
the excep
excep·
NOTE:
01 which
which gives
gives information
information about
about the
the number
number of
of files
files scratched
scratched with
with the
the
tion of
of 01
tion
SCRATCH command.
command.
SCRATCH
20:
20:
READ ERROR
ERROR (block
(block header
header not
not found)
found)
READ
The disk
disk controller
controller is
is unable
unable to
to locate
locate the
the header
header of
of the
the requested
requested data
data
The
by an
an illegal
illegal sector
sector number,
number, or
or the
the header
header has
has been
been
block. Caused
Caused by
block.
destroyed.
destroyed.
21 :
21:
READ ERROR
ERROR (no
(no sync
sync character)
character)
READ
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.
The
Caused
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
Caused by
Can also
also indicate
indicate aa hardware
hardware
unformatted or
or improperly
improperly seated
seated diskette.
diskette. Can
unformatted
failure.
failure.
22:
22:
READ ERROR
ERROR (data
(data block
block not
not present)
present)
READ
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 not
not properly
properly written.
wri tt en. This
Th is error
error message
message occurs in
in conjunction
conjunction with
with
was
the BLOCK
BLOCK commands
com mands and
and indicates
indicates an
an illegal
illegal track
track and/or
and/or sector
sector re
reo
the
quest.
quest.
23:
(checksum error
error in data block)
READ ERROR (checksum
This error
error message indicates
ind icates that there is an error
error in one or more
more of
of the
Th e data has been read into the DOS memory,
memory, bul
data bytes. The
but the
checks um over
over the data is in error. This
Thi s message may also indicate
checksum
grounding problems.
24:
READ ERROR (byte decoding error)
The data or header as been read into the DOS memory,
memory, but a hardware er·
er
ror has been created due to an invalid bit pattern in
In the data byte. This
message may also ind
icate grounding problems.
indicate
25:
25:
WRITE ERROR (write·verify
(write-verify error)
This
controller
Thi
s message is generated if the contro
ll er detects a mismatch between
the written data and Ihe
the data in the DOS memory.
26:
WRITE PROTECT
PROTECT ON
message is
is generated wh
when
This message
en the controller has been requested to
write a data block while the wri
te protect
write
protect switch is depressed. Typically,
by using
using a diskette wi
with
this is caused by
th a write a protect tab over the
notch.
notch.
27:
READ
READ ERROR
ERROR (checksum
(checksum error in
in header)
header)
The controller has
has detected an
an error
error in
in the header
header of
of the requested
requested data
data
ock has
block.
block. The
The bl
block
has not
not been
been read
read into
into the DOS
DOS memory.
memory. This message
message
may
te grounding
may also
also indica
indicate
grounding problems.
problems.
112
112
'"
,...,
28:
(long data block)
WRITE ERROR (long
The controller attempts to detect the sync mark of the next header after
writing a data block. If the sync mark does not appear within a prepre
determined time,
time, the error message is generated. The error is caused by a
bad diskette format (the data extends into the next block), or by hard
ware
hardware
failure..
failure
29:
ID MISMATCH
DISK 10
ac
This message is generated when the controller has been requested to access a diskette which has not been initialized. The message can also ococ
header.
cur if a diskette has a bad header.
30:
SYNTAX ERROR (general syntax)
The DOS cannot interpret the command sent to the command channel.
—
"-'
w
—
Typically, this is caused by an illegal number of
le names,
of fi
file
names, or patterns are
illegally used. For example,
example, two file names may appear on the left side of
the COpy
COPY command.
—
v
31:
SYNTAX ERROR (invalid command)
The DOS does not recognize the command. The command must start in
the first position.
-
32:
—
SYNTAX ERROR (invalid command)
The command sent is longer than 58 characters.
33:
33:
SYNTAX ERROR (invalid file name)
Pattern matching is invalidly used in the OPEN or SAVE command.
~
34:
34:
39
v
50:
SYNTAX ERROR (no file given)
The file name was left ou
outt of a command or the DOS does not recognize it
as such.
such. Typically,
Typically, a colon (:) has been left out of the command.
as
SYNTAX ERROR (invalid command)
This error may result ifif the command sent to command channel
channe l (secon
(secon·
This
dary address 15)
15) is unrecognized by the
the DOS.
DOS.
RECORD
RECORD NOT
NOT PRESENT
of disk reading past
past the
the last record through
through INPUT#.
INPUT#, or GET# com
com·
Result of
mands. This
This message will also occur after
after positioning to aa record
record beyond
beyond
end of file
file in
in aa relative
relative file.
file. IfIf the
the intent
intent is
is to
to expand the file by adding
adding the
W
new record (with
(with aa PRINT# command),
command), the
the error
error message may be ignored.
ignored.
or GET should not be attempted after this error
error is detected without
without
INPUT or
first
first repositioning.
repositioning.
—
~
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 the
the carriage
carriage return which
which is sent
sen t as
as a record
record terminator
terminator is
is counted
counted
Since
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
r.
60:
WRITE FILE OPEN
This
Thi
s message is generated when a write fifile
le that has not been closed is
reading.
being opened for read
ing.
61:
FILE NOT OPEN
This message is generated when a file is being accessed that has not
been opened in the DOS.
DOS. Sometimes, in this case,
case, a message is not
generated: the request is simply ignored.
generated;
62:
(')
,..,
'"'
FILE NOT FOUND
The requested file does not exist on the indicated drive.
63:
FILE EXISTS
The file name of the file being created already ex
ists on th
e diskette.
exists
the
64:
FILE TYPE MISMATCH
re
The file type does not match the file type in the directory entry for the requested file.
65:
NO BLOCK
This message occ
urs in conjunction
occurs
conjunclion with the B·A
B-A command. It indicates
that the block to be allocated has been previously allocated. The
lable with the next highest
parameters indicate the track and sector avai
available
number.
(0)T then all blocks higher in number
number. If the parameters are zero (0),
use.
are in use.
66:
ILLEGAL TRACK AND SECTOR
a track or block which does not exist in
The DOS has attempted to access a
the format being used. This may indicate a problem reading the pOinter
pointer to
the next block.
67:
70:
ILLEGAL
OR S
ILLEGAL SYSTEM T
TOR
S
Th is special
spec ial error message indicates an illegal system track or sector.
This
NO CHANNEL (available)
chann el is not available,
available , or
or all
all channels
chan nels are in
in use. A
A max
maxThe requested channel
sequen tial files may
may be
be opened
opened at one time to
to the DOS.
DOS.
imum of five sequential
r-.
Direct access channels
channels may have
have six opened fifes.
files.
71:
71:
DIRECTORY
DIRECTORY ERROR
ERROR
(')
BAM does not match
match the
the internal count.
count. There
There is
is aa problem
problem in
in the
The BAM
BAM
BAM allocation
allocation or the BAM
BAM has been
been overwritten
overwritten in DOS
DOS memory.
memory. To
To cor
corthis problem,
problem, reinitialize
reinitialize the
the diskette
diskette to
to restore the
the BAM
BAM in
in memory.
rect this
Some active
active files may be terminated by the corrective
correct ive action.
action. NOTE:
NOTE:
BAM
BAM = Block
Block Availability
Availability Map
Map
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
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
limi t. DISK
limit.
allow
allow the
the current
currenl file
file to
to be
be closed.
closed.
114
114
"
'"'
",...,
73:
DOS MISMATCH (73, CBM DOS V2.6 1541)
DDS
DOS 1
1 and 2 are read compatible but not write compatible.
compatible. Disks may be
ver
interchangeably read with either DOS, but a disk formatted on one ver·
sion cannot be written upon with the other ve
rsion because the format is
version
different. This error is displayed whenever an attempt is made to write
non-compatible format. (A utili·
utili
upon a disk which has been formatted in a non·compatible
ty routine is available to assist in convert
ing from one format to another.)
converting
another.)
This
up.
Th
is message may also appear after power up.
74:
DRIVE NOT READY
An attempt has been made to access the 154
15411 single Drive Floppy Disk
without any diskettes present in either drive.
drive.
115
115
APPENDIX C
C
APPENDIX
EXECUTIVE 64
64 BASIC
BASIC
EXECUTIVE
Thi s manual
manual has
has given
given you
you an
an introduction
introd uction to
to the
the BASIC
BASIC languge
languge —
- enough
enough
This
for
for you
you to
to get
get aa feel
feel for
for computer
computer programming
programming and
and some
some of
of the
the vocabulary
vocabulary in
in-
volven. This
This appendix
appendix gives
gives aa complete
complete list
list of
of the
the rules
rules (SYNTAX)
(SYN TAX) of
of 64
64 BASIC,
BASIC,
volved.
along
along with
with concise
concise descriptions.
descriptions. Please
Please experiment
experiment with
with these
these commands.
commands.
Remember, you
you can't
can't damage
damage the
the computer
computer by
by just
just typing
typing in
in programs,
programs, and
and the
the
Remember,
best way
way to
to learn
learn computing
comp uting is
is by
by experimenting.
experimen tin g.
best
Thi s appendix
append ix is
is divided
divid ed into
into sections
sections according
according to
to the
the different
diffe rent types
types of
of
This
operations in
in BASIC.
BASIC. These
These include:
include:
operations
1. Variables
Variables and
and Operators:
Operators: describes
describes the
the different
different type
type of
of variables,
va riable s, legal
legal
1.
variable names,
names , and
and arithmetic
arith metic and
and logical
logical operators.
operators.
variable
2.
2_ Commands:
Commands: describes
describes the
the commands
commands used
used to
to work
work with
with programs,
programs, such
such as
as
editing , storing,
storing , and
and erasing.
erasing.
editing,
3.
3. Statements:
Statements: describes
describes the
the BASIC
BAS IC program
program statements
statements used
used in
in numbered
numbered
lines of programs.
lines
4. Functions:
Functions: describes
describes the
the string,
string, numeric,
numeri c, and
and print
print functions.
functions .
4.
VARIABLES
VARIABLES
The 64 uses three types of variables in BASIC. These are real
real numeric,
numeric, in
in-
numeric , and string (alphanumeric) variables.
teger numeric,
fol lowed by a number,
numbe r,
Variable names may
may consist of a single letter, a letter followed
or two
two letters.
letters.
or
e
An integer variable is specified by using the percent (%
(%)) sign after th
the
variable name. String variables have the dollar sign ($) after their name.
EXAMPLES
Real Variable Names: A,
A5, BZ
A. A5,
Integer
%, Bl%
Integer Variable
Variable Names
Names:: A%,
A%. A5
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
su
bscripts to specify the elemen
M
subscripts
elementt of the array. Arrays are defined using the DI
DIM
statement
int , integer,
statement,, and
and may
may contain
contain floating po
point,
integer, or
or string variables. The array
array
variable name
lowed by
name is
is fol
followed
by a set of parentheses
parentheses (
va
riables in
variables
in the list.
list.
) enclosi
ng the number
enclosing
number of
A(7), BZ
%(1 1), AS(50),
BZ%(11),
A$(50). PT(20,20)
PT(20.20)
n
NOTE:
ich are
NOTE: There
There are
are three variable
variable names
names wh
which
are reserved
reserved for
for use
use by
by the
the 64,
64.
les are:
$. ST
and
and may
may not
not be
be defined
defined by
by you.
you. These
These variab
variables
are: ST,
ST. TI,
Tl, and
and TI
Tl$.
ST is
is a
a
status
ich relates
status variable
variable wh
which
relates to
to inpuUoutput
input/output operations.
operations. The
The value
value of
of ST
ST will
will
change
change if
if there
there is
is aa problem
problem loading
loading a
a program
program from
from disk
disk or
or tape.
tape.
Tl and
and TIS
Tl$ are
are variables
variables which
which relate
relate to
to the
the real
real-time
clock built
built into
into the
the 64.
64.
TI
·time clock
Th
e
va
riable
TI
is
updated
every
1I60th
of
a
second.
It
starts
at
0
when
the
comThe variable Tl is updated every 1/60th of a second. It starts at 0 when the com
puter
puter is
is turned
turned on,
on. and
and is
is reset
reset only
only by
by changing
changing the
the value
value of
of TIS.
Tl$.
116
116
n
TI$
Tl$ is a siring
string which is constantly updated by the system. The first two
characters contain the number of hours,
hours, the 3rd and 4th characters the number
of minutes, and the 5th and 6th characters are the number of seconds. This
variable can be given any numeric value, and will be updated from that point.
TIS = ""101530"
101530" sets the clock to 10:15 and 30 seconds AM
AM..
This clock is erased when the computer is turned off
off,, and starts at zero when
on.
the system is turned back on.
OPERATORS
arithmetic
The arithmet
ic operators include the following signs:
+
-
Addition
Subtraction
Multiplication
tion
Multiplica
/
Division
Divisi
on
t
(exponentiation)
Raising to a power (exponen
ti ation)
On a li
line
containing
operator, there is a set order in
in which
ne contain
ing more than one operator,
operations always occur.
occur. If several operations are used together on the same
Next,
liline,
ne, the computer assigns priorities as follows: First, exponentiation. 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
.......
Fi nally, there
Ihere are three logical operators:
Finally,
v
AND
'-'
OR
NOT
NOT
_
These are
are used most often
often to join
join multiple formulas in
in IF .
. . THEN
THEN
These
...
statements.
statements . For
For example:
IF A
A = B
BAND
C = D
D THEN
TH EN 100
100 (Requires both parts
parts to
to be
be true)
true)
IF
AND C
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 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
This
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
CON T will
wil l not
not work
work ifif you
you have
have changed
changed or
or added
added lines to
to the
the program
program (or
(or
CONT
even just
just moved
moved the
the cursor),
cursor), or
or if the
the program
program halted
halted due
due to
to an
an error,
error, or
or ifif you
you
even
caused an
an error before trying
trying to
to restart
restart the
the program.
program. In
In these
these cases
cases you
you will
will get
get
caused
a CANT
CAN 'T CONTINUE
CONTINUE ERROR.
ERROR.
a
LIST
The LIST
LI ST command
command allows you
you to
to look at lines
lines of
of aa BASIC program in
in
The
You can ask for the
the entire program
program to
to be displayed,
displayed, or
or only
only certain
certain line
memory. You
numbers.
LIST
LIST
LIST
LI ST
LIST
LI ST
LIST
ShowS entire program
Shows
Shows
Shows
Shows
Shows
10 1010
10
- 10
10
10·20
10-20
10 until end
only from line 10
10
only line 10
from beginning
begi nn ing until 10
10
lines from
line from
from 10
10 to 20,
20, inclusive
incl usive
line
LOAD
transfe r a program from disk into memory so the
the
This command is used to transfer
program can be used. The command is followed by a program name enclosed
within quotes.
quotes. The name is followed by a comma and a number or numeric
variable , which acts as a device number to indicate where the program is com
comvariable,
ing from.
The disk drive is device #S.
#8.
LOAD
AS,S
LOAD A$,8
LOAD
HELLO",S
LOAD ""HELLO"T8
LOAD ""*",8
"',S
Looks for
ram whose name is in the variable A$
for prog
program
Looks for prog
ram cal
led HELLO on the disk dri
ve
program
called
drive
Looks for fifirst
rst program on disk
N
EW
NEW
This command erases the entire program in memory, and also clears out any
variables that may have been used
used.. Unless the program was SAVEd,
SAVEd, it is lost.
BE CAREFUL WHEN
WHE N YOU USE THIS COMMAND.
COMMAND.
The NEW com
mand can also be used as a BASIC program statement. When
command
hes this line,
ram is erased. This is useful if you want
the prog
ram reac
program
reaches
line, the prog
program
to leave everything neat when the program is done.
RUN
This command causes execution of a program,
program, once the program is loaded
into memory. If there is no line number following RUN
RUN,, the computer will start
with the lowest line number. If a line number is designated, the program will
start executing from the specified line.
RUN
RUN 100
RU
NX
RUN
Starts program at lowest line number
Starts execution at line 100
UND
EFINED STATEMENT ERROR. You must always specify
UNDEFINED
an actual line
line number,
number, not a variable representation
11S
118
SAVE
SAVE
This
This command
command will
will store
store the
the program
program currently
currently in
in memory
memory on
on disk.
disk.
Type
uter
Type SAVE
SAVE followed
followed by
by aa name
name in
in quotes
quotes or
or aa string
string variable;
variable; the
the comp
computer
will
will give
give the
the program
program that
that name.
name. The
The name
name is
is followed
followed by
by aa device
device number.
number.
SAVE
A$,8
SAV
E A$,8
SAVE ""HELLO",8
SAVE
HELLO",8
Stores
Stores on
on disk
disk with
with name
name in
in A$
AS
Stores
Stores on
on disk
disk with
with name
name HELLO
HELLO
VERIFY
VERIFY
Thi
s command
puler 10
This
command causes
causes Ihe
the com
computer
to check
check the
the program
program on
on disk
disk against
against
the
tually SAVEd, in
the one
one in
in memory.
memory. This
This is
is proof
proof that
that the
the program
program is
is ac
actually
in case
case the
the
disk is
is bad,
bad, or
or something
something wen
wentt wrong
wrong during
during the SAVE.
SAVE.
disk
VERIFY followed by
by a program
program name,
name, or aa string variable,
variable, will
will search for that
that
program
mber is
fy command.
program and then cheCk.
check. Device
Device nu
number
is included
included with the veri
verify
command,
command.
~
VERIFY ""HELLO",8
HELLO",8
~
STATEMENTS
Searches for HELLO
HELLO on disk, then checks
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
in memory,
bu t leaves
leaves the
the program
program
memory, but
intact. This
Thi s command is automatically
automatically executed when aa RUN command is
is
itself intact.
given.
given.
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
CMD
LISTs, but
but not
not POKEs
POK Es onto
on to the
the screen)
screen) to
to another
another device
device instead.
ins lead.
statements, LISTs,
statements,
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 be
be OPENOPENThis
ed first.
first. The
The CMD
CM D command
command must
must be
be followed
followed by
by aa number
number or
or numeric
numeric variable
variable
ed
referring
referring to
to the
Ihe file.
fi le.
OPEN
OPEN 1,4
1,4
CMD
CMD11
LIST
LIST
OPENs device
device #4,
#4, which
which is
is the
the printer
printer
OPENs
All normal
normal output
output now
now goes
goes to
to printer
printer
All
The program
program listing
listing now
now goes
goes to
to the
the printer,
printer, not
not the
the
The
scree n
screen
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.
To
DATA
DATA
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.
This
Items may
may be
be numeric
numeric values
values or
or test
tes t strings,
strings, and
and items
items are
are separated
separated by
by com
com Items
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,
mas.
colon , or
or comma.
comma. IfIf two
two commas
com mas have
have nothing
nothi ng between
between them,
them , the
the value
val ue will
wi ll be
be
colon,
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
DEF FN
FN
DEF
This command
command allows
allows you
you to
to define
define aa complex
complex calculation
calculation as
as aa function
function with
with
This
short name.
name. In
In the
the case
case of
of aa long
long formula
formula that
that is
is used
used many
many times
times within
within the
the
aa short
program , this
this can
can save
save time
time and
and space.
space.
program,
The function
function name
name will
will be
be FN
FN and
and any
any legal
legal variable
variable name
name {1(1 or
or 22 characters
characters
The
long). First
First you
you must
must define
define the
the function
function using
using the
the statement
statement DEF
DEF followed
followed by
by
long).
the function
function name.
name. Following
Following the
the name
name is
is aa set
set of
of parentheses
parentheses enclosing
enclosing aa
the
variable. Then
Then follows
follows the
the actual
actual formula
formu la that
that you
you want
want to
to define,
define, with
with
numeric variable.
numeric
the variable
variable in
in the
the proper
proper spot.
spot. You
You can
can then
then "call"
" ca ll" the
the formula,
formula, substituting
substituting any
any
the
number for
for the
the variable.
variable.
number
XI.3)
10 DEF
DEF FNA{X)
FNA(X) = 12*(34.75
12"(34.75 - XI.3)
10
20 PRINT
PRINT FNA(7)
FNA(7)
20
t
J
t
T
|
IS inserted
Insefl e<! where
wnele
77 is
X is
IS m
In lr\e
the formula
rormula
X
For this
this example,
example, the
the result
result woud
woud be
be 137.
137.
For
DIM
more than
than 11
11 elements of an array,
array, you must execute a DIM
DIM
When you use more
array . Keep
Keep in mind that the whole
whole array takes up
up room in
in
statement for the array.
memory, so
so don't create
c reate an array much larger
larger than you'll
yOu'll need. To figure the
memory,
va ri ables created with DIM.
DIM , multiply
multi ply the total number of elements
number of variables
array .
plus one in each dimension of the array.
10 DIM A$(40).
A$(40), B7(15), CC%(4,4,4)
CC % (4,4,4)
10
41
41 ELEMENTS
16 ELEMENTS
ELEMENTS
125 ELEMENTS
ELEM ENTS
125
You can dimension more than one array in a DIM statement. However, be
careful not to dimension an array more than once.
END
When a program encounters an END statement
statement,, the program halts,
halts, as if it ran
out of lines. You may use CON
T to restart the program.
CONT
program.
FOR ....
. . TO ..
.... STEP
This statement works wilh
with the NEXT statement to repeal
repeat a section o
off the pro·
pro
gram a set number of times. The format is:
FOR (Var.
tart of Count) TO (End of Count) STEP (Count By)
(Var. Name) = (S
(Start
The loop variable will be added to or subtracted from during the program.
Without any STEP specified
specified., STEP is assumed to be 1. The start count and end
coun
e loop variable.
countt are the limits to the value of th
the
10 FOR
FOR L = 1
1 TO 10
10 STEP .1
20 PRINT
PRINT L
L
30 NEXT
NEXT L
L
The end of th
e loop value may
the
may be
be followed by
by the word STEP and another
number
ri able. In
ow in g STE
P is
number or
or va
variable.
In this case
case,, the value foll
following
STEP
is added
added each time inin
stead of 1.
is allows you to co
un t backwards, or
1. Th
This
count
or by
by Iraclions.
fractions.
120
120
GET
GET
The
The GET
GET statement
statement allows
allows you
you to
to get
get data
data from
from the
the keyboard,
keyboard, one
one character
character
e.
When
GET
is
executed,
the
charac
ter
that
is
typed
is
assigned
at
a
tim
at a time. When GET is executed, the character that is typed is assigned to
to the
the
variabl
e. IfIf no
variable.
no character
character is
is typed
typed,, Ihen
then aa null
null (empty)
(empty) character
character is
is assigned.
assigned.
GET
lowed by
ly aa string
GET is
is fol
followed
by aa variable
variable name,
name, usual
usually
string variable.
variable. IfIf aa numeric
numeric
variab
le was
variable
was used
used and
and aa nonnumeric
nonnumeric key
key depressed
depressed,, the
the program
program would
would halt
halt
with
ing
with an
an error
error message.
message. The
The GET
GET statement
statement may
may be
be placed
placed into
into aa loop,
loop, check
checking
for any
any empty
empty result.
result. This
This loop
loop will
will contin
continue
until aa key
key is
is hit
hit..
for
ue until
v
10 GET
GET A$:
AS: IF
IF A$
A$
10
10
== ....""THEN
THEN 10
GET#
GET#
The GET#
GET# statement
statement is
is used
used with
with a previously OPENed
OPENed device or
or file,
file, to input
or file
file..
one character at aa time from that device or
v
GET#1,A$
GET
#1 ,AS
input one character from a data file.
This would input
GOSUB
This statement is similar to GOTO,
GOTO, except the computer remembers which
program line it last executed before the GOSUB. When a line with a RETURN
statement is encoun
tered , the program jumps back to the statement im·
encountered,
im
mediately fo
llowing the GOSUB. Th
is is useful if there is a routine in you
following
This
yourr pro·
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
800
20
GOSUB 800
GOTO OR
OR GO
GO TO
TO
is reached,
reached , the next line to be
be
When aa statement with the GOTO command is
the line
line number following the
the word
word GOTO.
GOTO.
will be the one with the
executed will
IF
. THEN
IF .... .THEN
IF ...
... THEN
TH EN lets
lets the
the computer
computer analyze
analyze aa situation
siluation and
and take
take two
two possible
poss ible
IF
co urse s of
of action,
action , depending
depending on
on the
th e outcome.
ou tcome. IfIf the
the expression
expres sion is
is true,
true , the
the
courses
statement following THEN
THEN is
is executed.
executed . This
This may
may be
be any
any BASIC
BASIC statement.
statement.
statement
the expression
expression is
is false,
false, the
the program
program goes
goes directly
directly to
to the
the next
next line.
line.
IfIf the
The expression
expression being
bei ng evaluated
evaluated may
may be
be aa variable
variable or
or formula,
form ula, in
in which
which case
case itit
The
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
exis
< ,, >> , <=>=
< :;;; , > :;;; , <>
< >
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 INPUT
INPUT statement
slatement allows
allows the
the program
program to
to get
get data
data from
from the
the user,
user, assign
assign·
The
ing
10 aa variable.
variable. The
The program
program will
will stop,
stop, print
print aa question
question mark
mark (?)
(?) on
on
ing that
that data
data to
RETURN .
the screen,
screen, and
and wait
wait for
for the
the user
user to
to type
type in
in the
the answer
answer and
and hit
hit RETURN.
the
INPUT is
is followed
foll owed by
by aa variable
va riab le name,
name, or
or aa list
list of
of variable
va riable names,
names, separated
separated
INPUT
by commas.
commas. AA message
message may
may be
be placed
placed within
within quote
quote marks,
marks, before
bef ore the
the list
list of
of
by
IN PUT. IfIf more
more than
than one
one variable
variable isis to
to be
be INPUT,
INPUT,they
they must
must
variable names
names to
to be
be INPUT.
variable
be
be separated
separated by
by commas
commas when
when typed.
typed .
v
10
10 INPUT
INPUT -PLEASE
'·PLEASE ENTER
ENTER YOUR
YOUR FIRST
FIRST NAME";A$
NAME "; A$
20
20 PRINT
PRINT "ENTER
" ENTER YOUR
YOU R CODE
CODE NUMBER";:!NPUT
NUMBER" ;:INPUT BB
121
121
v
INPUH
INPUTtf
INPUH is
is similar
simi lar to
to INPUT,
IN PUT, but
but takes
takes data
data from
from aa previously
previously OPENed
OPENed file.
file.
INPUT#
10 INPUT#1,
IN PUT#1, AA
10
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
LET
be assigned
assigned the
the
the heart
heart of
of all
all BASIC
BASIC programs.
programs. The
The variable
variable name
name which
which is
is to
to be
the
of the
the equal
equal sign,
sign, and
and the
the formula
formula on
on
resuit of
of aa calculation
ca lculation is
is on
on the
the left
left side
side of
result
the right.
ri ght.
the
10 LET
LET A
A =
= 55
10
20 LET
LET D$ = "HELLO"
" HELLO"
NEXT
NEXT
NEXT
NEXT is
is always
always used
used in
in conjunction
conjunction with
with the
the FOR
FOR statement.
statement. When
When the
the pro
pro·
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
gram
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·
of
loop is
is finished,
finished , execution proceeds
creased by the specified STEP value. If the loop
w ith the statement following
following NEXT.
NEXT.
with
foll owed by aa variable
variable name,
name, or list
list of
of variable
variable names,
names,
NEXT may be followed
by commas. If there
there are
are no names listed,
listed, the
th e loop
loop started
started is the one
separated by
give n, they are completed in order
order from
from left to
to
comp leted. If variables
variab les are given,
being completed.
right.
right.
10 FOR X
X = 11 TO 100: NEXT
10
ON
ON
This command turns
turn s the
the GOTO and GOSUB comma
nds into special
vers ions
commands
special versions
la,
which
is
evaluated.
If the
of the IF statement. ON is followed by a formu
formula,
result of the calcu
lation is one,
executed ; if the resull
calculation
one, the first line on the list is executed;
result
is 2,
ne is
2, the second liline
is executed,
executed, and so on. If the result is 0, negative, or larger
than the list of numbers,
ll owing
than
numbers, the next line executed wi
willll be the statement fo
following
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
owed by a number (0·255),
followed
(0-255), to
which all followi
ng statements will refer. There is usually a second number
following
number
after the fifirst,
rst , which is
is the device number.
°
0
Th
e device nu
mbers are
The
numbers
are::
Screen
4 Printer
Printer
8 Disk
Disk
122
122
Following
Following the
the device
device number
number may
may be
be a
a third number,
number, separated again
again by
by a
comma, which
which is
is the secondary
secondary address.
comma,
In
In the case
case of
of the
the disk, the number
number refers
refers to
to the buffer,
buffer, or channel,
channel, number.
number. In
In
the printer,
g. See
printer, the secondary address controls features like
like expanded printin
printing.
the Commodore
ra mmer's Referen
ce Manual
s.
Commodore 64
64 Prog
Programmer's
Reference
Manual for more
more detail
details.
10 OPEN 1,0
1,0
10
2,8,8,"D"
20 OPEN 2,8,8,"
D"
30 OPEN 3,4
40 OPEN 4,8,15
OPENs
OPEN
s
OPEN
s
OPENs
D
is D
OPENs
OPEN
s
OPENs
the SCREEN as a device
the disk for reading
reading,, file to be
be searched for
the printer
printer
the data channel on the disk
Also see: CLOSE,
CLOSE. CMD, GET#, INPUT#, and PRINT#,
PRlNT#, system variable ST, and
Appendix
Appe
nd ix B.
v
POKE
POKE is always followed by two numbers, or formulas
formulas.. The first location is a
ue from 0 to 255, which
memory locati
on; the second number is a decimal val
location;
value
ue.
wil
lacing any previously stored val
willl be placed in the memory location
location,, rep
replacing
value.
POKE 53281
53281.0
10 POKE
,0
4096' 13
20 S = 4096"1
3
POKES+
30 POKE
S + 29,8
PRINT
The PRINT statement is th
e first one most people learn to use,
the
use, but there are a
llowed by:
number of variations to be aware of. PRINT can be fo
followed
Text String with
with quotes
Variable
Variab le names
Functions
Functions
Punctuation
Punct
uation marks
v
screen. The com
comPunctuation marks are used to help format the data on the screen.
ma divides the screen
screen into four columns,
co lumns, while the semicolon
sem ico lon suppresses all
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
spacing. Either
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 by
by aa number,
number, which
which refers
refe rs to
to the
the device
device or
or data
data file
file previously
previously
followed
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 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
ma
some
may not
not work
work with
wi th TAB
TAB and
and SPC.
SPC.
some devices
devices may
100 PRINT#1."DATA
PRINT#l ,"DATA VALUES";
VALU ES"; A%,
A%, B1,
Bl , C$
C$
100
v
123
123
READ
READ is used to assign information from DATA statements to variables, so
the information may be put to use.
use. Care must be taken to avoid READing
strings where READ is expecting a number,
wh ich will give a TYPE MISMATCH
number, which
ERROR.
REM (Remark)
REMark is a note to whomever is reading a LIST of the program. It may ex·
ex
plain a section of the program
program,, or give additional instructions. REM statements
in no way affect the operation of the program,
program, except to add to its length. REM
may be fo
llowed
by
any
text.
followed
RESTORE
When executed in a program,
program, the pOinter
pointer to which an item in a DATA state·
state
ment wi
willll be READ next is reset to the first item in the list. This gives you the
EAD the in
formation. RESTORE
ability to re·R
re-READ
information.
RESTORE stands by itself on a line.
RETURN
This statement is always used in
in conjunction with GOSUB. When the pro·
pro
gram encounters a RETURN
RETURN,, it will go to the statement immediately following
the GOSUB comma
nd. If no GOSUB was previously issued
command.
issued,, a RETURN
WITHOUT GOSUB
ll occur.
GOSUB ERROR wi
will
STOP
This statement will hal
haltt program execution. The message,
message. BREAK IN xxx will
be displayed
ing STOP. The program may
displayed,, where xxx is the line number contain
containing
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.
in executing the machine language program start
ing
The program will then beg
begin
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
T is followed by a memory location (X) and up to
specific
WAIT
two var
iables. The format is:
variables.
WA
IT X,Y,Z
WAIT
The contents of the memory location are first exclusive·ORed
exclusive-ORed with the third
number,
t, and then log
ically ANDed with the second number. If the
number, if presen
present,
logically
result is
ro, the program goes back to that memory location and checks
is ze
zero,
again. When the result is nonzero,
nonzero, the program continues with the next stale·
state
ment.
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
"
ATN(X) (arctangent)
Returns the angle,
s, whose tangent is X.
angle, measured in radian
radians,
COS(X) (cosine)
'-'
Returns the value of the cos
ine of X,
cosine
X, where X is an angle measured in ra·
ra
dians.
v
EXP(X)
Returns the value of the mathemat
ica l constant e(2.71827183) raised to the
Ihe
mathematical
power of X.
FN
xx(X)
FNxx(X)
ue of the user·defined
n xx created in a OEF
xx(X)
Returns the val
value
user-defined functio
function
DEF FN
FNxx(X)
statement.
v
INT(X)
Returns the truncated value of X,
X, that is,
is. with all the decimal places to the
riright
ght of th
e decimal point removed
the
removed.. The result wil
willl always be less than
than,, or equal
Thu s, any negative numbers wit
h decimal places will become the integer
to, X. Thus,
with
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)
v
Used to find out contents of memory location X, in the range 0·65535,
0-65535, giving a
0-255.
PEEK
is
often
used
in
conjunct
ion
wi
th
the
POKE
statemen
t.
resuit
from
result
in conjunction with
statement.
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
ula RND(
- TI) to start things off differently
formula
RND(-TI)
every time. After this, X should be a 1
1 or any positive number. If X is zero,
zero, the
result wi
ll
be
the
same
random
number
as
the
last
one.
will
A negat
ive value for X will reseed the generator. The use of the same negative
A
negative
v
number for X wi
ll resu
lt in the same sequence of "random
" numbers.
will
result
"random"
numbers.
The fo
rm ula for generat
ing a number
formula
generating
number between
between X and Y is:
N = RND(1),
(Y - X)+ X
RND(1)*(Y-X)+X
v
where,
where.
Y is the upper limit
X is the lower range of numbers desired.
SGN(X) (sign)
Thi
s function ret
urn s the sign (positive, negat
ive, or zero) of X. Th
e result will
This
returns
negative,
The
if
positive,
0
if
zero
,
and
1
if
negat
ive.
be + 1
1
zero,
- 1
negative.
v
v
SIN(X) (sine)
SIN(X) is the trigonometric
trigo nometric sine fu
nction. The result will be the sine of X,
function.
X,
where X is an angle in
in radians.
v
125
v
SQR(X) {square
(s quare root)
root)
SQR(X)
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
This
O. IfIf XX is
is negative,
negative, an
an ILLEGAL
ILLEGAL QUANTITY
QUANTITY ERROR
ERROR results.
resuits.
0.
TAN(X) (tangent)
(tangent)
TAN(X)
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.
The
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 whose
whose starting
starting point
point is
is contained
contained in
in memory
memory locations.
locations. The
The parameter
parameter XX
gram
.-.
is passed
passed to
to the
the machine
machine language
language program,
program, which
which will
will return
return another
another value
value
is
to the
the BASIC
BASIC program.
program. Refer
Refer to
to the
the Commodore
Commodore 64
64 Programmer's
Programmer's
back to
Reference Manual
Manual for
for more
more details
details on
on this
this function
function and
and machine
machine language
language pro
proReference
gramming.
gramming.
STRING FUNCTIONS
ASC(XS)
ASC(XS)
Thi s function will
will return the
the ASCII
ASCII code
code of
of the
the first character of X$.
XS.
This
CHRS(X)
CHR$(X)
This is the opposite of ASC,
ASC, and returns aa string character
character whose ASCII
ASCII code
This
is
X.
isX.
LEFTS(XS,X)
Returns a string containing the leftmost X
X characters of $X.
SX.
LEN(XS)
LEN{X$)
(including
Returned will be the number of characters (includ
ing spaces and other sym
symbols) in the string XS.
X$.
MIDS(XS, S,X)
MID^XS.S.X)
This wi
X characters starting from the Sth
willll return a string containing X
character in X$.
RIGHTS(XS,X)
RIGHTS(X$,X)
Returns the rightmost X characters in XS.
X$.
STRS(X)
Thi
s will return a string which is identical to the PRINTed version of X.
This
VAL(XS)
Thi
s function converts X$ into a number, and is essentially the inverse operaThis
opera
tion from STR$. The string is examined from the leftmost
leftmost character to the right,
right,
for as many characters as are in recog
nizable number
recognizable
number format.
lOX
10 X
10
10 X
10
10 X
10
10 X
=
=
=
=
VAL("
123.456")
VALC'123.456")
VAL("
12A13B")
VAL("12A13B")
VAL("RIU017"
VAL("RIU017"))
VAL("
-1.23.45.67")
VAL("-1.23.45.67")
X = 123.456
X =
= 12
12
X
X = 0
X = --1.23
1.23
126
126
OTHER FUNCTIONS
FUNCTIONS
OTHER
FRE(X)
FRE(X)
This function
functi on returns
returns the
the number
number of
of unused
unused bytes
bytes available
avai table in
in memory,
memory,
This
regardless of
of the
the value
val ue of
of X.
X. Note
Note that
that FRE(X)
FRE(X) will
will read
read out
out in
in negative
negative numbers
numbers
regardless
number of
of unused
unused bytes
bytes is
is over
over 32K.
32K.
if the
the number
if
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
any value
value and
and is
is not
not
PRINT statement
statement will
wi ll begin
begin on
on the
the screen.
screen. XX may
may have
have any
PRINT
used.
used.
SPC(X)
SPCpC)
This is
is used
used in
in aa PRINT
PRINT statement
statement to
to skip
ski p XX spaces
spaces forward.
forward.
This
TAB(X)
TAB(X)
'-J
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
TAB
in
column
X.
in column
v
127
127
APPENDIX D
ABBREVIATIONS FOR BASIC KEYWORDS
As a time·saver
time-saver when typing in programs and commands,
commands, Commodore's
BASIC for the 64 lets the user abbreviate most keywords. The abbreviation for
PRINT is a question mark. The abbreviations for other words are made by typing
the first one or two letters of the word,
word, followed by the SHIFTed next letter of
line, the keyword will LIST
the word. If the abbreviations are used in a program line,
in the full form.
Looks lik.
like
Look.
Com-
mond
mand
Abbreviation
otion
Looks like
this on
this on
screen
Commond
mand
Abbrevi-
Am
END
END
E Ullbl N
N
E
[2]
EXP
EXP
EI:IID
E BfflSl
EI:IID
E
xX
A~
FN
NONE
NO
NE
ation
screen
screen
EI:IID B
A EI:IID N
A EI:IID S
A EI:IID T
C EI:IID H
CL EI:IID 0
CL
C EI:IID L
C EI:IID M
C EI:IID 0
A[]
FOR
F
c[]
FRE
F
CLO
GET
G lilIID E
G El
C D
GET#
NO
NE
NONE
GET#
cIS!
GOSUB
GOSUB
GO Ulljil SS
GO
GO
V
GO~
C D
GOTO
Goro
EI:IID
G Ulllal
G
EI:IID O0
COS
cos
NONE
NONE
COS
co s
IF
NONE
IF
DATA
DATA
D
D ETTTal A
DD~
Q
INPUT
NONE
IN PUT
INPUT
DEF
DEF
D
DEl
INPUT#
I
DIM
DIM
D
i) eh3 i
D
INT
INT
NONE
ABS
AND
ASC
ATN
CHR$
CLOSE
CLO SE
CLR
CMD
CONT
A
EI:IID
EI:IID E
.'
A
128
128
[2]
E
E
_Aj
~
FN
EI:IID 0
EI:IID R
EI:IID
E
E 2
F
0
F
[;J
G
G
[
0
[2]
N
INT
INT
~
'-'
'-'
looks
Looks like
Looks like
Com·
Com
AbbreviAbbrevi
this on
mond
mand
ComCom
mond
mand
Abb reviAbbrevi
ation
this on
screen
at
ion
ation
scree
n
screen
LEFTS
LE rmID F
LEQ
RIGHT$
RIGHTS
R rmID I
RW
LE
N
LEN
NONE
LEN
RN
D
RND
R rmID N
R[ZJ
LET
L
L rmID
EHE E
RUN
R rmID
u
RW
LI
ST
LIST
rmID
SAVE
S rmID A
S~
v
LOAD
a
rmID o
SGN
S rmID G
s[O
v
LOG
NONE
LOG
SI N
SIN
S rmID I
SEJ
V
MID$
MIDS
MrmID
MW
SPC(
S rmID P
NEW
NONE
NEW
SQR
Q
S rmID
EflT;
S
NEXT
N rmID
N
STATUS
ST
ST
ST
NOT
N rmID a
NO
nD
STEP
stB!!!
ST
rmID E
STD
ON
NONE
ON
STOP
T
S
s rmID
eui
s[O
OPEN
OrmID
00
STRS
STR$
ST rmID
^
ST
R
STQ
OR
NONE
OR
SYS
srs
S
s rmID
E2E
S
PEEK
P rmID E
pEl
TAB
TAB(!
T rmID
BHT;
T
A
TT~
g]
POKE
P rmID a
pO
TAN
NONE
TAN
pas
POS
NONE
pas
POS
THEN
t rmID
E!Uj
H
T
T[]
PRINT
?
?
TlME
TIME
TI
Tl
TI
Tl
PRINT
#
PRINT#
P rmID R
P
TIMES
TIS
Tl$
Tl$
TIS
READ
R rmID E
REl
USR
S
U
U rmID
EH
u[v)
U~
REM
NONE
REM
VAL
v rmID
ET!T
A
V
vV~
5]
v
RESTORE
RE rmID S
RE~
VERIFY
V
E
v rmID
EH
vEl
V
RETUR N
RE rmID
tSIUI T
T
RE
RE [[]
WAIT
WrmID
W~
V
'-'
'-'
v
V
v
v
'-'
V
I
P
El
W
0
El
Id
V
V
v
v
v
V
v
129
Y
A
S.
s O
[]
APPENDIX EE
APPENDIX
SCREEN DISPLAY
DISPLAY CODES
CODES
SCREEN
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
The
be POKEd
POKEd into
into screen
screen memory
memory (locations
(locat ions
sets. ItIt shows
shows which
which numbers
numbers should
should be
sets.
1024-2023}
to get
get aa desired
desired character.
ch aracter. Also
Also shown
shown is
is which
which character
character cor
cor1024-2023) to
respon ds to
to aa number
number PEEKed
PEEKed from
from the
the screen.
screen .
responds
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
yo u cannot
cannot have
have characters
characters from
from one
one set
set on
on the
th e screen
screen at
at the
the same
same time
time you
you
you
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
have
[QJ
down the
the ETUI
Ii!:W and
and 'C=' keys
keys simultaneously.
simultaneousl y_
down
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
From
53272,23 switches
switches to
to lower
lower case.
case.
53272.23
Any
on the
the chart
chart may
may also
also be
be displayed
displayed in
in REVERSE.
REVERSE. The
Th e reverse
reverse
Any number
number on
character code
code may
may be
be obtained
obtain ed by
by adding
adding 128
128 to
to the
the values
values shown.
shown.
character
II you
you want
want to
to display
display aa solid
solid circle
ci rcle at
at location
location 1504,
1504, POKE
POKE the
the code
code for
for the
the
If
circle (81)
(81) into
into location
location 1504:
1504: POKE
POKE 1504,81.
1504,81.
circle
There is
is aa corresponding
corresponding memory
memory location
location to
to control
cont rol the
the color
color of
of each
each
There
character displayed
displayed on
on the
the screen
screen (locations
(locations 55296-56295).
55296·56295). To
To change
change the
the color
color
character
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 location
location (55776)
(55776) with
with the
the character
cha racter color:
co lor: POKE
POKE 55776,7.
55776,7.
memory
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
Refer
wit h color codes.
with
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,
NOTE: The
91-93,
96-104,106-121
,
123-127.
91-93. 96-104, 106-121, 123-127.
SCREEN CODES
SET 1
1
SET 2
POKE
SET 1
1
SET 2
POKE
SET 1
1
SET 2
POKE
o0
C
c
3
F
F
f
6
1
oD
d
4
G
G
g
7
Bb2Ee5Hh
h
H
5
E
e
b
2
B
8
@
@
A
a
""
130
130
-'
'-'
SET 11
SET 2
POKE
SET 11
SET 2
POKE
POKE
SET 11
SET 2
POKE
V
V
V
'--'
V
J
K
k
L
9
%
37
~
A
65
10
&
38
CD
m
B
B
66
C
67
D
68
E
69
F
70
G
71
H
72
I
73
J
74
K
75
L
76
M
77
11
11
39
12
40
M
m
13
41
41
N
N
n
14
42
0O
0
o
15
P
P
P
16
44
Q
Q
q
q
17
45
R
R
r
18
46
S
S
s
19
47
T
t
20
U
U
u
u
21
21
v
V
V
v
22
2
50
'-'
W
w
w
w
23
3
51
51
'-'
X
X
x
24
4
52
v
yY
y
y
25
5
v
Z
z
z
z
26
v
v
V
v
v
v
v
v
'-'
£
v
v
'-'
v
i
-
SPACE
43
+
48
0
49
D
U
[]
D
[]
a
W
a
~
□
EJ
0D
is]
S
N
N
78
0
o
79
P
p
80
53
II]
Q
Q
81
6
54
D
□
R
R
82
27
7
55
~
S
83
28
8
56
[]
T
84
29
9
57
W
U
U
85
V
86
w
W
87
X
88
30
58
~
31
59
D
l±l
32
<
60
61
[]
Y
Y
89
Z
z
90
34
>
62
[1]
#
35
?
63
91
$
36
El
EB
64
IJ
92
v
v
131
131
v
El
B
El
Q
00
0
□
0
33
v
El
B
SET 11
POKE
SET 11
93
~
94
0
,06
106
95
[8
,07
107
SPACE
96
C.
,08
108
E
IJ
97
[g
,09
109
98
6J
□
U
'110
,0
rnCD
liD
3
~
.
H
SET 2
6l!l
~
0
n
D
0
0
□
II
0
,0,
101
~
,04
104
99
,00
100
,102
02
,103
03
SET 2
POKE
~
,05
105
',,
111
ca
,,2
112
B
El
53
BJ
0
,,3
113
'114
,4
,,5
115
SET 11
SET 2
[J
E
[)
a
,17
117
,118
,8
U
□
~
H
~
U
a
0
ILJ
E
~
a
H
I:J
~
H
S
~
POKE
,,9
119
,120
20
,2,
121
0
0
,122
22
,23
123
-
,24
124
,25
125
,26
126
,27
127
,,6
116
,....,
—
r.
28-255 are reversed images
Images 01
27.
Codes Irom
from ,128-255
of codes 0-,
0-127.
'-
,32
132
—
v
v
v
'-'
'-'
v
v
APPENDIX F
ASCII AND CHR$ CODES
This appendix shows you what characters will appear if you PRINT CHR$(X),
for all possible values of X.
X. It will also show the values obtained by typing
type. This is useful in
PRINT ASC("x"),
ASC(" x"), where x is any character you can type.
evaluating the character received in a GET statem
ent , converting upper/lower
statement,
case, and printing character based commands (like switch to upper/lower case)
case,
quotes.
that could not be enclosed in quotes.
"-'
v
PRINTS
CHR5
CHA$
0
V
'-'
'-'
2
v
3
v
v
'-'
'"
v
v
-
II
PRINTS
17
CHRS
CHA$
34
3
51
51
18
#
#
35
4
52
19
$
36
5
53
20
%
37
6
54
21
&
&
38
7
55
39
8
56
9
57
23
23
(
40
7
24
24
)
41
41
58
DIS"'ES _~8
25
•
42
59
9
'H"'ES _~9
26
+
+
43
10
11
11
12
12
IiID!II
t:
SWITCH TO
LOWER CASE
13
13
14
15
15
v
16
16
-•
ag
lID
28
28
C
60
44
27
-
29
29
61
45
:::>
62
46
?
63
30
/
47
@
@
64
31
0
0
48
48
A
A
65
32
1
49
49
B
B
66
33
2
2
50
C
C
67
v
v
v
v
'-'
v
V
'-'
PAINTS
PRINTS
6
'-'
'-'
CHA$
CHR$
22
v
v
-•
n
CHRS
CHR$
5
v
v
4
PRINTS
133
133
64
67
PRINTS
CHRS
PRINTS
CHRS
PRINTS
CHAt
D
68
~
97
@)
126
E
69
98
l"1IIIJ
127
F
70
CD
El
G
71
EJ
100
H
72
I
99
PRINTS
-Grey 3
riI
128
Ora nge
129
CHRS
155
156
157
158
101
130
73
Ll
g
102
131
160
J
74
[]
IB
103
132
(]
161
K
75
104
11
133
L
76
0
bJ
105
13
134
M
77
[3
106
15
135
N
78
EJ
107
17
136
0
79
0
108
12
137
P
80
IS]
109
14
138
a
81
11 0
16
139
R
82
111
18
140
S
83
T
84
0
0
0
II
U
85
0
v
86
~
115
W
87
0
116
X
88
Y
89
~
118
Z
90
D
11 9
[
91
~
120
Brown
£
92
121
J
93
[l]
1
94
95
-El
96
112
1liIIII1II!m141
11 3
' ~142
114
143
117
•..
III
III
II
•
0
159
162
163
0
0
164
II
0
166
165
167
~
~
168
0
170
rn
c:.
169
171
172
144
[l3
173
145
6J
174
Q
146
ca
147
175
176
177
149
E:l
EIl
11 . Red
150
BJ
179
122
Grev 1
151
180
tE
0
123
Grev 2
152
181
IJ
CD
124
Lt . Gr een
153
(]
[J
182
125
Lt . Blue
154
U
183
148
I
134
134
178
w
PRINTS
~
~
v
CODES
CODES
CODE
CHRS
CHAt
PRINTS
CHRS
CHR$
PRINTS
CHRS
CHAt
H
~
188
184
0
186
185
~
187
192-223
224-254
255
e:J
SAME AS
SAME AS
SAME AS
v
'--'
'--'
'--'
~
'-'
'--'
'--'
v
'--'
v
V
'--'
v
V
v
'--'
v
'-'
v
v
v
v
v
v
135
135
189
PRINTS
~
H
V
~
96-127
160-190
126
CHRS
190
191
191
-
APPENDIX G
G
APPENDIX
SCREEN AND
AND COLOR
COLOR MEMORY
MEMORY MAPS
MAPS
SCREEN
The following
fol lowing charts
charts list
li st which
which memory
memory locations
loca tions control
cont rol placing
placing characters
characters
The
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,
on
they show
show character
character color
color codes.
codes.
and they
and
SCREEN
SCREEN MEMORY
MEMORY MAP
MAP
COLUMN
COLUMN
J9
HJO
20
20
10
-■
1063
■
'H
II
!.::JJ
1024-~~1
•.
~'lqH
, __;+1 1· - rTl'.
j!-! -pt , 1\0,',
' : ' __ • :- _
, .....
'- L- -
1024.1064
■ :
::■
\I :
1\8'
1184
\22:
.. I
126 ~
1264
V
lJOJ:
mt
IH~
■ ■■■■
138'
UN
1424
1.164
1464
~
____ ___ _
__
_ _
_ _ . tI ~
~~~.
_~
L--.......t.
_
•
- _. +- i ...
._ .
_____
-
I
•
_ _!_
-0.-
'
.. •
.•
••
_' _' .
.~- 10 ~
: - :.
r-----[:,
1814
\....---.-_-
.
---~
-
■■■ I
186~
11344
gJ~
•_ ___
+~.: ~ . ~::~~
f-"
1904
1904
—
- - _ . _ -
t- . ~
'
■
:~~~
11&!
1824
j +-
i
....
■::
~~
'
'-11;=-'--
.
1584
1J8J
_ ._ .
I
r"* . L-__ _ - - - - - ,
... +----1--I' - -,+----+- .. •- •_
• •
• I __ +
_ . -...
,
i
162.1
■ '■
166.
1
■■■ :
_~ .
••
__
'-t~~-·! .-~. ' I
150~:
■■
15.1.1
1541
I~ J
_
~
~~
+- _
0_ ,' • •
__
_
___ ,
--::
0
:
I
—
'
10
H+rH
198.
19841
i
—
Th
e actual values to POKE into a color memory location to change a
The
ch
aracter's color are:
character's
o0 BLACK
8 ORANGE
11 WHITE
9 BROWN
2 RED
RED
3 CYAN
4 PURPLE
5 GR
EEN
GREEN
6 BLUE
BLUE
7 YELLOW
10 U
ght RED
Light
11 GRAY 1
11GRAY1
12 GRAY 2
13 Li
ght GREEN
Light
14 Ughl
Light BLUE
15 GRAY 3
—
—
—
136
136
w
For example, to change
change the color of
of a character
character located
located at the upper
upper left-hand
left-hand
For
corn
er ooff the screen to red
corner
red,, type:
type: POKE
POKE 55296,2_
55296,2.
COLOR MEMORY MAP
v
C
OLUMN
COLUMN
v
39
3D
20
10
10
sms
55335
I
55296m96
55416
55~16
55456
55456
55J96
S5J96
55536
ssm
55576
miG
55616
55656
55655
v
55696
55696
55736
5)136
55776
m76
55816
55856
mS6
55896
55936
55976
S6016
56016
56056
56096
56135
56 in
56116
56215
56216
56255
56155
/-I!
!-
55336
m36
55376
ssm
I
L_-±-W:
[E¢[~
I'
'f __
i
I
.-H,
--
!ttLl
'
, pi !
,,
_L
,
1-'
1100
i
-
-;
I
+
I
I
i
_..J..
-
v
v
w
137
137
v
--
-i I -
...!f
I It · ,
- - -r:
--
1_--;-1 :..:
,...
i
10
-I
ff
56m
56295
9
~
APPENDIX HH
APPENDIX
DERIVING MATHEMATICAL
MATHEMATICAL FUNCTIONS
FUNCTIONS
DERIVING
Functions that
that are
are intrinsic
intrinsic to
to 64
64 BASIC
BASIC may
may be
be calculated
calculated as
as follows:
follows:
Functions
FUNCTION
FUNCTION
BASIC
BASIC EQUIVALENT
EQUIVALENT
SECANT
SECANT
SEC(X)=1/COS(X)
SEqX) = lICOS(X)
COS ECANT
COSECANT
COTA NGENT
COTANGENT
INVERSE SINE
SINE
INVERSE
INVERSE COSINE
COS INE
INVERSE
CSC(X)
csqX) == 1/SIN{X)
1ISIN(X)
-
COT{X)=1/TAN(X)
COT(X) = 11T AN(X)
ARCSIN(X)=ATN(X/SQR(-X'X+1))
ARCSIN (X)= ATN(XlSQR( - X· X+ 1))
ARCCOSfX}=
ARCCOS(X) = -ATN<X/SQR
- ATN (XlSOR
(-X·X+1)) ++ ff/2
}[ 12
(-X'X+1))
INVERSE SECANT
SECANT
INVERSE
ARCSEC(X)
= ATN(X/SQR(X'
X(XlSQR(X ·X
- 1))
1))
ARCSEqXI=ATN
INVERSE COSECANT
COSECANT
INVERSE
ARCCSC(X)
ARCCSqX) == ATN(XJSQR(X*
ATN(XlSQR(X · XX -- 1))
1))
+
+ (SGN(X)-TJr/2)
(SGN(X) - 1· }[ 12)
INVERSE COTANGENT
COTANGENT
INVERSE
ARCOT(X)
ARCOT(X) =
= ATN{X)
ATN (X) +
+ Jt/2
}[ 12
HYPERBOLIC SINE
SINE
HYPERBOLIC
SINH(X)b
(EXP(X) - EXP(EXP( - X))/2
X))12
SINH(XI = (EXP(X)
HYPERBOLIC COSINE
COSINE
HYPERBOLIC
HYPERBOLIC TANGENT
TANGENT
HYPERBOLIC
COSH(X)
- X))/2
(EXP(X) ++ EXP(
EXPIX))12
COS H(X) = (EXP(X)
TANH(X)
= EXP(+ EXP
EXP( - X)/(EXP(x)
XIIIEXP(xl+
EXP
TANH (X)=
HYPERBOLIC SECANT
SECANT
HYPERBOLIC
SECH(X)
= 2/(EXP(X)
2J(EX P(X) +
+ EXP(
EXP( - X)}
X))
SECH (X) =
HYPERBOLIC COSECANT
COSECANT
HYPERBOLIC
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)
IN
VERSE
INVERSE
INVERSE
INVERSE
INVERSE
ARCSINH(X)=
LOG(X + SQRIX
SQR(X'X+
· X+ 1))
1))
ARCSINHIX)= LOG(X+
1- x))"2+ 1
- EXP(- X))·2+ 1
-EXP(-X))"2+1
HYPERBOLIC
HYPERBOLIC
HYPERBOLIC
HYPERBOLIC
SINE
COSINE
TANGENT
SECANT
INVERSE HYPERBOLIC COS
ECANT
COSECANT
INVERSE
INVERSE HYPERBOLIC
HYPERBOLIC COTANGENT
ARCCOSH(X)
= LOG(X
LOG(X +
+ SQRIX
SQR(X"· X
1))
ARCCOSH(X)=
X -- 1))
ARCTAN
H(X)
= LOGI(1
LOGf(l +
+ X)/(1
X))/2
X)111 - X))12
ARCTANH
IX) =
ARCSECH(X)
- LOG((SQR
ARCSECH IX) =
( - X· X+ 1)+ 1/X)
ARCCSCH(X)=
LOG((SGN(X)"SQR
IX) = LOGI(SGN
(X)" SQR
ARCCSCH
(X*X+1/x)
IX
· X+ 11x)
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
FOR INPUT/OUTPUT
INPUT/OUTPUT DEVICES
DEVICES
PINOUTS
This
x isis designed
ow you
tions may
This appendi
appendix
designed to
to sh
show
you what
what connec
connections
may be
be made
made to
to
the Exec
Executive
64.
the
utive 64.
Game 1I/O
1)1) Game
/0
2)
Cartridge
Slot
2) Cartridge Slot
3)
Audio/Video
3) Audi ol Video
4)
/0 (Disk/Printer)
4) Serial
Serial 1I/O
(Disk/Printer)
5)
5) Modulator
Modulator Output
Output
6)
User
Port
6) User Port
Control Port
Port 1
1
Control
Pin
Pin
Type
Type
JOYAO
JOYAO
JOYA1
JOYAl
JOYA2
JOYA2
JOYA3
POT AY
AY
POT
BUTTON
A/LP
sunON A1LP
+ 5V
+5V
GND
POT AX
POT
11
22
33
44
5
66
77
8
9
1
2
0
o
o
6
Note
Note
MAX.
MAX. 50mA
50mA
3
4
5
000
0
7
o
0
8
9
Control
Control Port
Port 22
Pin
Pin
11
Type
Type
JOYB0
JOYSO
22
JOYB1
JOYSI
33
JOYB2
JOYS2
JOYB3
JOYS3
44
v
55
POT
POT BY
BY
66
BUTTON
sunON BS
88
77
+
5V
+5V
99
GND
GND
POT
POT BX
SX
Note
Note
MAX. 50mA
50mA
MAX.
v
v
v
139
139
Cartridge Expansion
Expansion Slot
Slot
Cartridge
Cartridge
Cartridge Expansion
Expansion Slot
Slot
Pin
Pin
Type
Type
Pin
Pin
Type
Type
11
GND
GND
12
12
BA
BA
22
13
13
DMA
DMA
44
+5V
+
5V
+5V
+
5V
IRQ
IRQ
55
66
14
14
D7
D7
D6
D6
R/W
R/W
15
15
16
16
Dot Clock
Cl ock
Dot
17
17
D4
D4
18
18
D3
D3
19
19
20
20
D2
D2
11
11
I/O 11
I/O
GAME
GAME
EXROM
EXROM
I/O 22
I/O
ROML
ROML
Pin
Pin
33
77
88
99
D5
D5
D1
D1
21
21
DO
DO
22
22
GND
GND
Type
Type
Pin
Pin
Type
Type
A
A
GND
GND
N
N
A9
A9
B
B
C
C
ROMH
ROMH
RESET
RESET
P
P
R
R
A7
A7
D
D
E
E
NMI
NMI
A6
A6
S 02
S02
S
S
T
T
F
F
A15
A15
U
U
A4
A4
H
H
JJ
K
K
L
M
M
A14
V
V
A3
A3
A1 3
A13
w
W
A2
A12
All
A11
Al0
A10
X
X
A1
A1
Y
Y
z
Z
A0
AO
GND
10
10
I ::::::::::::::::::::::
x
IZ Y
r
W \I U T S"';> N III L!( J H F
XWVUTSOPNMIKJHF
E
DC B A
EDCBA
140
140
I
A8
A8
A5
AS
'-"
Audio/Video:
AudiolVi
deo' 8 Pin
Pin
Type
Note
11
LUM/SYNC
LUM
/SYNC
GND
AUDIO OUT
VIDEO OUT
AUDIO IN
COLOR OUT
NC
NC
Luminance/SYNC
(monocio) output
Luminan
ce/SYNC (monoclo)
2
v
3
4
5
6
7
88
Composit signal output
Chroma signal output
connection
No connection
No connection
v
v
v
Serial
Serial I/O
Pin
Pin
Type
11
SERIAL SRQIN
2
2
GND
SERIAL ATN IN/OUT
IN/O UT
3
3
w
4
4
SERIAL CLK IN/OUT
5
5
SERIAL DATA
DATA IN/OUT
6
6
RESET
RESET
v
v
v
v
141
141
v
User I/O
1/0
User
Pi n
Pin
Type
Type
11
GND
GND
Note
Note
~
MAX.
100mA
MAX.100mA
22
+
5V
+5V
3
3
RESET
RESET
4
4
GNTI
CNTl
5
5
6
6
7
7
B
8
9
9
10
10
11
11
12
12
SP1
SP1
GNT2
CNT2
SP2
SP2
PG2
PC2
SEA. ATN
ATN IN
IN
SER.
9 VAC
VAG
9
9 VAC
VAG
9
GND
GND
Pin
Type
Type
A
A
B
B
GND
GND
FLAG2
G
C
PBO
PBO
D
D
PB1
PB2
E
E
F
F
H
H
JJ
MAX.
100mA
MAX.100mA
MAX. 100mA
100mA
MAX.
Note
Note
-
PB3
PB3
PB4
PB5
PB6
PB7
PA2
GND
K
L
M
M
N
N
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
v
APPENDIX J
PROGRAMS TO TRY
We've included a number of useful programs for you to try with your 64.
These programs will prove both entertaining and useful.
v
100
120
pr i nt"~jctto
nffljotto
JjiM
i «• butt~rfi~ld'l
butterf i *l d"
Dr
inpuf'Puant
input"f'
wanl iinstructions";z*:ifasc<zS>=7SgDto250
n st r uctions";o::i : i fasc( ;;:t ) =78got o250
130
140
prinf'Ptry
print"~t
ry
pr i nf'Syou
print
"~y ou
5-letter word"
word"
to gue-ss
gu~ss the
th~ mystery
Myst~ry 5-\~tt~r
on ly Il ~gal
egal 5-letter"
must guess
9u~ss only
5-1.tt~r"
too..."
150 prinfwords,
print"words, too
••• •·
i nf'you will bethe number
160 pr
print"you
b~ told th+
nUffib~r
i nt"(or 'jots')
guess."
170 pr
print"(or
' Jots ') of your gu+ss."
of
Df
matches"
matches"
130 prlnt"flhlnt:
prinf'Phint: UII;'
the trid.
trick
vary sligrltly"
slightly"
180
iiss to lIarl,}
190 print"
print"
frOM
gu~ss to the
th~ next;
n~ x t; so that"
that "
from on~
one guess
you guess
'batch'
200 print"
iif
f 'jOll
gu~ss 'balet-,'
and get 2 jots"
210 print"
might try 'bolch'
'botch' o
or
'chart'"
print"
you Might
r 'char
t' "
for
ne>:t
220 print"
print"
fo
r the
th~ n
e xt guess..."
gU~5S • •• "
250 data bxbsf,ipccz,dbdif,esfbefpggb«
bxbsf.rpccz.dbdif,esfbe,pqgbM
260 data hpshf.
j l.l jj llll,kp
rflll'l:L.,, It,z
b\
hpshf, ibud
i bud i ,d
, d.ju
« , kpmmz
Ibzbl
sbkbi,infwfm,njnjd,boofy,qjqfs
270 data sbkbi
,llIIfwfm.njn j d,boofy , qjqfs
230
~SO data rrvftu,sjwfs,gsfttrpuufs.fwfou
vft u,s j wfs,qsftt,puufs . fwfou
29
0 data wfb
;<fbuf,fyupni,nvtiz,afcsb,gjaaz
290
wf,fyupm,nvt f z,afcsb,g j aaz
300
300 data uijdl.*svol,gMpp*fUjhfsrgblfs
u i . ldl.~svol,gMpp~,u J hfs.gblfs
cppui~.M
, inzjoh,trvbu,hbvaf,pxjoh
310 data cPPu
z j oh,tr v bu.hbvaf,p x joh
320 data ulsff,tjhiu
uisff,tjhiu,bynft,hsvnq,bsfob
. bYhft.hsvnq,bsfob
rvbsu.dsff':',cfMdi ,qsftt.tqbsl
330 data rvbsu,dsffq,cfmdi,qsftt,tqbsl
3A0
sbebs.svsbmrtnfinnifgsp>:or*s.jgu
340 data sb~bs.svsb~,t
n f~M,gsp x O,e Sj 9U
■100
= 50
400 nn=50
■ilO dim
410
d i M n$(n),z<5),y(5)
nS ( n ) ,~ ( 5),y ( 5)
420 for j=lt
j = lton:readn«(j):ne>:tj
on:r~a d nt( j) :n~ ):tj
430 t=ti
t=t i
440
440 t=t/1000:ift>=lthengoto44Q
t=t / 1000:ift > = lth~ng ot o44 0
450 z=rnd(-t)
z=rnd(-tl
500 g=O:nt=n*(rnd(l)*n+l)
g=0 :nt =n t Crnd( 1 1*n+ l )
500
510 print "Pi
" ~i have
hav~ a five
f iv p letter
I~tt~r word:":ifr:0goto560
word :": ifr ~ Ogot oS60
510
520 print
print "guess
"gu~ ss (with
( wit h legal
l ~ga t words)"
wor ds)"
520
530
530 print
print "and
"a nd i'll
i'li tell you haw
h ow many"
Many"
540
540 print
print "'jots',
" ' jots', or
or matching
matchfng letters,"
l~tt~rs, "
print
" you have...."
have . . . . "
550 pr
i nt "you
560
560 g=g+l:input "your
" you r word";zS
word "; zS
570 if
If len
\.n(zS
5thpn pr iln
t " you must guess
gu~ss a
a
570
< z* )) '■~ >■ Sthenpr
nf'you
5-letter
S-l~tt~r
v=0:h=0:m=0
v=O:h=O:m=O
590
590
fDrj=lto5
forJ=lto5
600
600
z=asc
( ~id S (z ' .j,l»
: y=asc(0Id
S ( n S ,j.l
1 )-1:ify
= 64theny
64th~ny =
=9
90
z
= asc(«id«(zi,j,l)):y
= asc(inid«<nt,j
,1))-1:
ify =
610
610
( 650r= > 90th~ npr il nt"
nt "that·s
iIfz
f z*.65orz>90thenpr
that' s
620
620
ifz=65orr=69orz=73orz=79ors=S5or2=S9thenv=v+l
if= = 6Sor==690rz= 7 3arz=790r==8Sorz=89thpnv=v+l
630
630
ii f
z = >jthenin = m*l
f==yth~nM=~+l
640
640
z<
j )=z:y(j)=y:nextj
: <j)=
z:'::I(j ) =y:n. :< tj
650
6S0
iI fm
= 5gotoS00
fl,.::z5gotoSOO
660
660
=Oarv=5thenpri
nt "come
"coM O?
i.fv
fv=
0orv=5thenc-r i nt
a
a
v
v
word!":goto560
word ~" :gotoS 60
5S0
S80
uord
ward
is
is
not
not
an .. what
on..what
a
a
word '~"" ::goto560
uord
goto560
kInd
kind
af
of
that?":goto560
that ?" : gato56 0
670
670
fo r
for
j=lto5 :y= ~(j)
j=lto5:y=y(j>
680
6S0
fo r
for
) = O :got o700
kk=lto5:if4=Z(kltl"l.nh=~,+1::<".
= lto5: i fy = z(k)thenh = h+l: = (k)=0:goto700
690
690
ne>:t
nO?'): t
kk
700
70 0
next
n~ x t
jj
710
7 10
pr
intliaBDDDUDUDDBBDHDDOaDD";H
prlnt
" CDDDDUDUDDDDDDDDODDD ";H;; "JOTS"
"J OTS "
720
72 0
iI fg<30goto560
fg <30goto560
730
7 30
pr
i nt " !I ''d
d-bet
tf-r
prtnt"
. t,o?tt~r
tell
tpll
you.,
yo u . .
143
143
word
word
was
was
'";
~
7 40 forj-Ho5:pr
fo r J=lloS :prlnl
chr i ((yeJ»
n@ x t J
i ntchr*
y ( j ) ) ;;:
:n*>:tj
"" ':golo810
:gotoS10
s ao pr
print"ljou
qot it
It in
I n only"j
o n l 'J ";g;",]W?Ss
... s . "
300
i nf'you got
g;"guesses."
3 10 in
Input"~anoth~
~ord " gz*
;=i
S10
puf'S anotherr word"
82 0 r=l
r=l:i
asc (( z«
zt)
~ } 7Sgo
78 goto5
00
S20
: i ff asc
)'.>
toSOO
7 40
prlnt
7 50 pr
750
mt
1
r€'tll
re
in
***
22
r€-tll
ram
3
3
r*w
r"'H1
.
"'' ':0-
SE'OUE'nc ...
stouenc?
... ,. from
f rO DI pet
u s ... r group
orout,
***
r'''' t. user
> *- 5of
@>:):c:t,an'1o<r"'/Il
soft~ar
re la *- *
tusre... •?
c h a n >j e
l ,o:: 371
r @nI * " co
371
5 r^-ni
t· o t'O::
mont
gOtA",r
lJ vv iI 11
I 1©0:- .• pa
00 1S
18936
66 rr •=■... mtll s,,~
K « man
t go
mer u
936
rE'(11
77 re
in
~O dim
d I to a$(26>
a t e 26)
bO
100 r*a"abcd«-fghi
= S="abcdE'fg h i iif:k linnor-qrstuvw:;u~"
It(j n or,qrsl u v ,", ~:u=''
100
11 0 zl$
zIS =
=""12345678901234t.67S90123456"
1 234567890 1 ~3 4 ~67390 1 ~3456"
110
~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~"
200
~20
int,ut ""Ma
>: iIIIlU
l ... nath 15
I S 26
26 "-.
" i s'/.
s?'
220
incut
in 3 >;
in u mtll length
~30
If sm/.<A
s% < l or
or eX
s% ~ 26
~6 then
th ... n 200
200
2SQ
if
22 44 00 s=sX
S= 57300 for
f or i=l
I =1 to
to 5s
300
a"I)=toIJt.(::t
. l.l )
3 10 a*<
310
i)=mid«(zt.i,1)
320 next
n ... ::t i
320
4 00 rein
r eto randomize
randOtol ::e string
s t r I ng
400
4:00 for
f o r i=l
1=1 to
to 5s
420
f: =lntC rnd ( l )rs +l)
4 30 k=int(rnd(1>»S+1)
430
44 0 tt=st(i)
t"= a t ( I )
440
I )=ato.)
450 ate
at<i)=at(k>
1,60 a to. )=t t
nO? i:t Ii
4 70 next
470
1,80
480 gasul,
gosub 'f~O
?50
~Y;:j t=0
l;O
595
600 rrein
... m rreverse
... v ... rs ... substrIng
600
substr i no
605
+l
6 05 t=t.
t=i+l
6610
10 Iinput
nt,ut "IIOw
';! 1..0
€-v",rs-? "";rX
; riC
"Now ',lan
many
lo r'
r*-v>?r$t?
620 If
=O goto
i f r%
rX-0
gotu 900
630 If
~O a
n d riC
if r7.
rZ>0
and
rX , =s goto
ooto 650
b~ between
bet w...... n 11 and "is
to 6610
10
640 orlnt
orint "toust
"must be
";s:: go
goto
650 r=lnt(rZ
/:!)
r=int(rX/2)
660 for 1=1 to rr
70 U
t e i)
6670
tt =a
= st<
i )
680
i (r7.- 1 +1)
6S0 at(,
att i )=a
>=3*(r%-i+i>
6YO
s (rr.-I+
t
6V0 a
at
Cr%-i + }
1 )=t
J=lt
700 nne^.t
o? ), t Ii
4
4
.....
I~{l
750
90Sll~'
gosub
800
^00
8£10
10
820
S20
830
S30
8840
40
850
S50
YOO
V00
9910
10
c=
l: for II»2
':~
to s
c=l:
If
t (!l >a t.( I - I ) goto 8SiO
050
if a
3*(i)>3t(i-1)
cc=0
=0
nne;:t
... ~: t Ii
If
=O goto 600
if c
c=0
pcrint
r I nt "~
~ou did
In
i t;" ~ triPS"
"0gou
did it
in "~
";t;"
tries"
r",M
oth~r gaM'"
check for
for an
another
game
re« cho:-cf:
Input
In ";4
'
incut "~~ant
"flwant to
lo play
day aga
again
"; ut
'if
f lleft*
... ft i Cu
i.I1 )="IJ"
t ="I')I-\" or yy*t ="
1 " ooto
(ut.
) = "ij" or 'J
y«="ak"
= "l"
goto
o:-nd
end
,.r
I nt
print
print lleft»(zlt.5l
~ft t(zIS. s)
ffor
o r 1=
1 to ss:: e,rlnt
i (ll ; : n E'>: t Ii
i=l
print a8*(iJiine>lt
'120
y20
930
930
9~0
950
960
960
'i/o
970
9BO
I nt
9S0 [,r
print
"'~O
950
m
fM
—
—
r"»
,-«,
^
^
-.
^
^
~O
O
200
""B"
fI "
9'10
... turn
9V0 rreturn
ThIS
This
—
(^
pr
o ~r im (Oullesy
ne Du
ls
program
touitesy ot
of G~
Gene
Deals
l^,
144
144
v
v
v
:?(.
At '0 ft E','E:(IAF'(I
90 PHI
PEM F-!
PIRHO
EVBORFD
P
RIIIT " ~ ~
print's
a ~J
si ~J
«j !i ~j
n ~
ai ~
v\ Ii ~I
'i ~
n Ii lm~ ~ni ••'■
110 F'PItIT"
PR1HT" ~~
;) I!I
i<l ~31J II H
i'l I!.I
!•_! fit
H ii ~J
r<_< ~J
''I I1 I~I
iig ?.!
1\('
.I "
12Q PRIlIT"
print11 :1
:j {lJ
m Jt'j
;t| aj
jj Ii ~J
y :~
:«n Ii I!J
i>j :'y
120
lj Ii H
!J i!J
.1 "u
PRINT11
1136
~· C' PF.:
r tIT" ja II II I II I1 II I I1 II I I1 I[""
PRINT"
flQ 11·1
JH IE
IE IF"
fPIT
IV |UII
|0|P!@
1140
... 0 PPItIT
" ;11~'
IT I"'IU
I rio
IP I(!! IJ*
f 1If"
T"
150
IHT " .!r
';PH(E ' F(IP
'r'F'HOt II (;"
150 PF~
PRINT"
p)'H.PhCE'
FOR ·:;.I)LO
SOLO OF'
OF: POL
FOLVPHONIC"
150 PRIIIT"
PRINT".5J-'F1
,F3,F5,F7'
OCTflVE
SELECTION"
1'::13
.tVFI.F;:.
F5.F:- ' C'CTA\/
E '::·El.ECTII)H"
100
100
v
1:-0
170
1:;0
l!5i?
!19@
':.n
200
v
'::1(1
220
'::::0
230
.::
10
210
~
..W
240
~=.o
250
~.:.
O
2S9
:270
71)
'=:
G~ ~)
2S0
300
:;:00
3
1')
310
v
v
:;:.~ O
2-20
3~
5
325
::::0
330
3·'1)
34Q
J5('
3S0
30;
:0
360
>;-5
365
?7(1
370
;'75
375
v
:'::::1)
3S0
.11)(,
400
5(11)
500
51 (.
5
,:. ~ (\
'3:::0
':.-I\)
54@
55('
530
5-=0
559
':,";"0
570
v
v
PF:ItIT"!I'F
2. r-·\ .Fo:: .F B · 1·MRVEFOPM.iV
IA V EF(,p r'I .~l' ·
PRIHT1'H"F2.F4.F£,Fa'
PR
I I/T"HAti(' 011.
E IIC',' TAE:LE
. . . ..
PR1HT"HRMG
Oii - ';ETTil"::;
SETTING UP
UP FFEC'U
FREQUEHCV
TABLE..."
·;=1~:
+ -lO :.!.l';+102-1 : [ . r,.,F · ';:: '; ,.- : 011-11 ':25:"
3=13*4096+1924iOIMF<26>iDIMf
C255)
FOR
I =(tT02'3 : F(' f E
·;:· ... r .-O;NE;:T
(1 : 'lE: :T
FORI=a0TO2SsPOf
ES+I
F 11=7040
= 7" 1)41) ::FORI=1
FOP. I"" 1 r02':: F' :;:.:- - I '=F
5. :?+
~:O ::F1=F1.
F I =F 1. -:::
1': . ::NE::T
IIE::T
rO2esF':27-I
'=F11 t*-5.
S+30
'2 rf '-•: 1/
l.'ll
~:
J;= " ('121·' ::EP,:".T';'r':-I.l1 :.:"X';:'I':! -- io ( r"
K*o"iP2W3ERST6V7UI900P@-*£
FOP!
TOLEII-1 -Fr ·■ ::11 ·ff:,(·"lIO
.t ' I'
r ,r
· "" t:t
tE:: T
FOPI = I1TOLEN'^
■ FViC f.H tO*>
K'*,
I '>J> >■!
aHEXT
PRHIT":J
FRINT'TJ
HT
=0 :jOE=0
DE=O : :3U=15
.1..1<: 1 '3 :sRE-S
FE:.:' ::SV=SU+
';'./.,.';:.1.' + L';
loPE : A '.,' ".HT'" 16+C'E :
FlT=0
loi-REtflVafl^-lS+DE:
(·IV
= I';' : ! j=O ::M=I
1'1 ", i ::0C=4
1)( :::4 :iHB=25t;:
L;E:=': ':..:: : .:-'
WV=16sH=0
"->"
FOR!
')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
FOR I "OT
=9T02
POkE"
: .... ';:': .,. I +7 •-4000HND255
4(u)(,t=it 10255 ::Fi>
POI E';
... ;:.,. I .. :- •-4000.
4(\(":0. ''::50:::
I IE: :T
POKES-t-2-t-£*?
ES+3-*-I*7
r25t" ::HEi
IT
PQK
E·: .... .: 4 •. 1
'5 : PEr·l ~ 1 .; .... ,:: .~ ::POt
F 0 1 E';:.
+.=:-::: •-77
POKES+24
15sREM+16*-64
ES+23
GETR4:IFfl*=""THEH300
(,ETA
t : I FAr"." "THEil:'':'')
FR",F
· A.t: , .■ '.
'H : T = ..... .. 7 : CF' .. ·; .. T ....\ ::1J F
FF' ::::THEII':.('O
FR=F>' K'
k- ~SC
fliC'fll)
■.1H:T=V-f7:CF=r5-<-T+4
FFP=ZTWEM500
POKE:c_
.. .£. .. T ,: : FE!,' F
r 1/ I ·;. H DEC.
',,: u·;
POKEs+^vT.ZiPEM
FIHI1H
DEC'iU'i
?OI'r
; .. 5·.. T .: : ?El-l FFIMI5H
It I r ·::.H flTT/REL
ATT. '!='EL
P0KES+5+T,ZjREM
POKE
( P ,:::: : POh.EC P • (\ : F'EI-! F
I:' (OFF
IF F
P0KECR,S:P0kECR,3:REM
FIX
POI,tE
'; ... T .FP-He· " ltIT· FF! . "HI::· :;PEH
PEt'l ':::ET
PCKES+T.FP-HBfIHT-"FR.-'HE.'
SET LO
LO
POV
E ·: .+l t-T
.. T .FP.
·HE: ::PEM
F·E/-l ·;·ET
POKES+1
.FP.'HB
SET HI
POVE·;+,;
... T . ·3··... : FEtl SET
;ET DEC.
DE':. ":;1)-;
POKES+&+T,SViREM
"SUS
;::")1
E ·;+5 ... T .1'1'. / : FElt ':SET
ET flTT/REL
ATT. 'FEL
POKES+S+T,flV;FEM
POt
E CP .ltl'·... + 1 :F0RIh1T0SO*HTiNEXT
: F (lr. I", 1 T050 + HT : t IE :: T
P0KECP..MV+1
P')I
E(P. J..j'·/ :FE t-l FI)L':
E
POKECR,WV:REH
PULSE
I F ? = 1THEtl'·/ ....·' ~ 1 : ! r '·..'", ~: THE II'.,i= ')
IFP=1THEHV=V+1:IFV=3THENV=0
I:;OT(' 300
:;;'(11)
GOTO
IFA ..: = " ii " THE I 11'
1 = 1 :0C=4
: (n: ",4 :G0T03S0
: (·(lTI):2(")
IFhJ="S"THE1
!E-1=1
J FA:t= " ~ " THEI Ht;.:. : (n: :=:.~: :OOTHi
: (,OTI):100
00
IR=2!0C=3
J FA .! :" II" THEI If·I=·1
: ,)(::.=: :OOT03G@
: (·OTI)~ ('0:'
M=-1 :0C-2
I FA:t;;"II"TI-IEtU·l =-8
",·; :OC
: 0)(,:,
: (,')T');'(":'
= l[ :G0T030G
I FAx",,
" !t" THEt n-l=~:' iWV=lw
:~J''''= i':· sG0T0300
: (.O T'):; ,:.,=.
IFPiS
= "3"THEHl-J=0
.\: "T
I-I E tH
I,. Il :: UV=
l l ·.'=:2
(.o TO
r .:I:;·(Il)
IIFAI="
FRJ= "K"
THEt
(Ua
?2 :: GO
SCO
580
5'~ IJ
IFH.r= " ~ " T J-. E t!Ll =':: ; 1·\'/= ':: .. :G0T030'3
:':'('j.:.:;.:,,:o
IFH**"M"THEHW=£:NV=e-4
1 F~ r= " B"THENW=3jUV=!128
tI " THEtal= :; : \·1\·' = i ,:: .3 : GOTO
(.I)TO:<:500
O:II)
IFh-C="
IFR*ss"
rFA I:::" "THEIiP=l-P
"THEliP ",I-P :G0T0JO0
: (,I)T':':.(u)
'3::...:.
590
I FA .r o>" ;]" T!1Et I~ ('(o
IFfl*»"3"THEH2S0
~.•:1\) GOTO
':.O T(' 500
~:(.n
500
:.:.>:.
:;:■:»-«
PPIHT"HIT
P ~· ttIT"HIT
fl
~
VI EV"
E',"
:;: \ 1) L-ETR-t:
('E TI;~ : [FH.r
rF~l.r",
""jHE!;;I':' :l-iflIT
: I·j "';iT FOP
F('F
S10
= ""THEIi.5lij
>20
-;'::0
~ , Ij EV
E'?'
hi
PPIMTftf:RETURN
F·PIHT,.; . : f.ETI .IFil
NOTES:
NOTES:
v
Line
Line 100
100 uses
uses (SHIFT
(S H IFT CLR(HOME).
CLA /H OME).
Line 530
530 uses
u ses (17)
(17)
Line
(CTRL
(C TAL 91.1CTRL
9).(C TAL )).(SHIFT
)).(SHIFT B).
B).
Line 540
540 uses
u ses (12)
(12)
Line
Line
Line 150
150 uses
use s (CRSR
(CASA DOWN)
DOWN )
Line 550
550 uses
uses (II)
(1 4)
Line
Line
Line 240
240 uses
uses (CRSR
(CASA UP)
UP)
Line 560
560 uses
u ses (f6)
(16)
Line
Line
Line 500
500 uses
uses (11)
(11)
Li ne 570
570 uses
uses (f8)
(18)
Line
Line
Line 510
510 uses
uses (13)
(13)
Line 590
590 uses
uses (SHIFT
(S HIFT CLR/HOME)
CLA /HOME )
Line
Line
Line 520
520 uses
uses (151
( 15 )
v
145
APPENDIX KK
APPENDIX
CONVERTING
CONVERTING STANDARD
STANDARD BASIC
BASIC PROGRAMS
PROGRAMS
TO EXECUTIVE
EXECUTIVE 64
64 BASIC
BASIC
TO
IfIf you
you have
have programs
programs written
written in
in aa BASIC
BASIC other
other than
than Commodore
Commodore BASIC,
BASIC,
some minor
minor adjustments
adjustments may
may be
be necessary
necessary before
be fore running
running them
them on
on the
the 64.
64.
some
We've included
included some
some hints
hints to
to make
make the
the conversion
conversion easier.
easier.
We've
String Dimensions
Dimensions
String
Delete all
all statements
statements that
that are
are used
used to
to declare
declare the
the length
length of
of strings.
strings, AA state
state,
Delete
A$(I ,J), which
which dimensions
dimensions aa string
string array
array for
for JJ elements
elements oi
of
ment such
such as
as DIM
DIM AS(IJ).
ment
length I,I, should
should be
be converted
converted to
to the
the Commodore
Commodore BASIC
BASIC statement
statement DIM
DIM AS(J).
AS(J),
length
Some
or ampersand
ampersand for
for string
str ing concatenation.
concatenation, Each
Each of
of
Some BASICS
BASICs use
use aa comma
com ma or
these
these must
must be
be changed
cha nged to
to aa plus
plus sign,
sign, which
wh ich is
is the
the Commodore
Commodore BASIC
BASIC
operator for
for string
string concatenation.
concatenati on.
operator
In Commodore
Commodore 64
64 BASIC,
BASIC, the
the MIDS,
MIDS, RIGHTS,
RIGHTS, and
and LEFTS
LEFTS functions
functions are
are used
used
In
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$ , 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
A$,
follows:
follows:
Other BASIC
BASIC
Other
Commodore BASIC
BASIC
Commodore
A$(I) = XS
X$
A$(l)
A$(I,J)
=
X$
A$(I.J)
LEFT$(A$,1- 1)+X$+MI
D$(AS,I+1
AS = LEFT$(A$,l-1)
+ X$+MID$(AS.I
+ 1))
A$
=
LEFT$(A$,11)+
X$+
MID$(A$,J
1)
AS
LEFT$(A$,1-1)+X$+MID$(AS,J + 1)
Multiple Assignments
Assignments
Multiple
To set B
B and C equal
equal to zero,
zero, some BASICs
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
If C
0. Instead,
Instead, conve
convert
this
to:
C = 0,
rt th
is statement to:
logical operator and set B = --11 if
10
C = 0:
10C
0 : B
B = 0
0
Multiple
Multiple Statements
BASICS use
use aa backslash
backslash (/) to separate multiple
multiple statements on a line.
line.
Some BASICs
With
With Commodore
Commodore BASIC,
BASIC, separate all
all statements by
by a
a colon
colon (:).
MAT
MAT Functions
Functions
Programs
ions available
Programs using
using the
the MAT
MAT funct
functions
available on
on some
some BASICs
BASICS must
must be
be
rewrillen
rewritten using
using FOR
FOR ...
. . . NEXT
NEXT loops
loops to
to execute
execute properly.
properly.
146
146
APPENDIX L
ERROR MESSAGES
Thi
s appendix contains a complete list of the error messages
This
messages generated by
by
the
64.
with
a
description
of
causes.
the 64, with a description of causes.
BAD
BAD DATA String data was received from an open file, but
but the program
program was ex·
ex
v
pecting numeric
numeric data.
pecting
BAD
BAD SUBSCRIPT The program was trying to reference
reference an element of an array
whose number is
is outside of the range specified in the DIM statement
statement..
BREA
K Program execu
tion was stopped because you hit the STOP key.
BREAK
execution
v
The
CONT
will
not work, either because the pro·
pro
CAN'T CONTINUE Th
e CON
T command wi
ll not
RUN., there has been an error, or a line has been edited.
gram was never RUN
DEVICE NOT PRESENT The req
uired 1
10 device was not available for an OPEN,
required
I/O
CLOSE,
INPUT#. or GET#.
CLOS
E, CMD, PRINT#, INPUT#,
DIVISION BY ZERO Division by zero is a mathematical oddity and not allowed.
v
EXTRA IGNORED Too many items of data were typed in response to
an INPUT
loan
statement. Only the first few items were accepted.
FILE NOT FOUND No file with that name exists.
FILE NOT OPEN Th
The
CLOSE, CM
CMD.
INPUTS,, or
e file
fi le specified in a CLOSE,
D, PRINT#, INPUT#
GET#, must first
GET#,
lirst be OPENed.
OPENed .
attemptt was made to open a
FILE OPEN An attemp
a file using the number of an already
open file.
COMPLEX The string expression being evaluated should
shoul d be
FORMULA TOO COMPLEX
parts
split into at least two
two part
s for
fo r the system
sys tem to work with,
wi th, or a formula has too
many parentheses.
ILLEGAL DEVICE NUMBER Occurs when
when you
you try to
to access aa device illegally
(e.g..
(e.g., LOADing from keyboard,
keyboard , screen,
screen, or
or RS-232C).
RS·232C).
ILLEGAL DIRECT
DIRECT The
The INPUT statement can
can only be
be used within
wi th in aa program,
program, and
and
not in
in direct
direct mode.
mode.
v
ILLEGAL
ILLEGAL QUANTITY
QUANTITY A
A number used
used as the
th e argument of
of aa function or
or statement
is out
ou t of
o f the
the allowable
allowab le range.
range .
is
LOAD
LOAD There
There is
is aa problem
problem with
with the
the program
program on
on disk.
disk.
v
MISSING FILE
FILE NAME
NAME LOADs
LOAD s and
and SAVEs
SAVEs from
from the
the serial
serial port
port (e.g.,
(e.g., the
the disk)
disk) re
reo
MISSING
quire
quire aa file
file name
name to
to be
be supplied.
supplied. Key
Key in
in the
the file
fil e name.
name.
NEXT WITHOUT
WITHOUT FOR
FOR This
Thi s is
is caused
caused by
by either
either incorrectly
incorrectly nesting
nesting loops
loops or
or hav
hav·
NEXT
ing aa variable
variable name
name in
in aa NEXT
NEXT statement
statement that
that doesn't
doesn't correspond
correspond with
wit h one
one in
in aa
ing
FOR
FOR statement.
statement.
NOT INPUT
INPUT FILE
FILE An
An attempt
attempt was
was made
made to
to INPUT
INPUT or
or GET
GET data
data from
from aa file
file which
which
NOT
was
to be
be for
for output
outpu t only.
only.
was specified
specified to
v
NOT OUTPUT
OUTPUT FILE
FILE An
An attempt
attempt was
was made
made to
to PRINT
PRINT data
data to
to aa file
file which
whi ch was
was
NOT
specified
spec ified as
as input
input only.
only.
147
147
OUT OF DATA A READ statement was executed but there is no data left
unREAD in
in a DATA statement.
OUT OF MEMORY There is no more RAM available for program or variables.
This may also occur when too many FOR loops have been nested, or when
there are too many GOSUBs in effect.
OVERFLOW The result of a computation is larger than the largest number
al
lowed, which is 1.70141
884E + 38.
allowed,
1.70141884E+3B.
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,
Ms will
will
ten, and any subsequent DI
DIMs
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
ent was encountered,
statement
encountered, and no
GOSUB command has been issued.
STRING TOO LONG A string can contain up to 255 characters.
?SYNTAX
7SYNTAX ERROR A statement is unrecognizable by the 64. A missing or extra
parentheses,
parentheses, misspelled keywords, etc.
TOO MANY FILES You tried to OPEN more than 10 files at one time.
time.
TYPE MISMATCH This error occurs when a number is used in
string,
in place of a string,
or vice-versa.
vice-versa.
UNDEF'D
UNDEF'D FUNCTION A user defined function was referenced, but it has never
been defined using the DEF FN statement.
UNDEF'
D STATEMENT An attempt was made to GOTO or GOSUB or RUN a
UNDEF'D
line number that doesn't exist.
VERIFY The program on disk does not match the program currently in memory.
148
APPENDIX M
M
APPENDIX
MUSIC NOTE
NOTE VALUES
VALUES
MUSIC
This
e#, actual
This appendix
appendix contains
contains aa complete
complete list
list of
of Not
Note#,
actual note,
note, and
and the
the values
values
to be
be POKEd
POKEd into
into the
the HI
HI FREQ
FREQ and
and LOW
LOW FREQ
FREQ registers
registers of
of the
the soun
sound
chip
to
to
d ch
ip to
produce
the
indicated
note.
prod
uce th
e ind
icated note.
OSCIL
LATOR FREQ
OSCILLATOR
FREQ
MUSICAL
NOTE
M
USICAL NOTE
u
00
11
2
3
4
5
6
7
88
9
9
10
11
16
17
18
19
20
21
22
22
23
24
24
25
25
26
26
27
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
48
48
C-0
C·O
C#-0
C#·O
0D-0
·0
#·0
0D#-0
E-0
E·O
F-0
F·O
F#-0
F#·O
G-0
G·O
G#-0
G#·O
A-0
A·O
A#-0
A#·O
B-0
B·O
C-1l
C·
C#-1
C#·1
D-1
0
·1
D#-1
0
#·1
E-1
E·l
F-1
F·l
F#-1
F#·l
G-1
G·l
G#-1
G#·l
A· l
A-1
A#-1
A#· l
B-1
B·l
C-2
C·2
C#-2
C#·2
D-2
0·2
D#-2
0 #·2
E-2
E·2
F-2
F·2
F#-2
F#·2
G-2
G·2
G#-2
G#·2
A-2
A·2
A#-2
A#·2
B-2
B·2
C-3
C·3
. 268
268
284
301
318
337
358
379
401
425
451
451
477
506
536
568
602
637
675
716
758
803
851
902
955
955
1012
1012
1072
1072
1136
1136
1204
1204
1275
1275
1351
1351
1432
1432
1517
1517
1607
1607
1703
1703
1804
1804
1911
1911
2025
2025
2145
2145
149
149
11
11
11
11
11
11
11
11
11
11
11
11
2
2
2
2
2
2
2
3
3
3
3
3
3
3
3
4
4
4
4
4
4
44
5
5
5
5
5
5
6
6
6
6
77
77
77
88
12
12
28
28
45
62
81
81
102
102
123
123
145
169
195
195
221
250
24
56
90
125
163
204
204
246
35
83
134
134
187
187
244
244
48
48
11
2
112
180
25 1
251
71
71
152
152
237
237
71
167
167
12
12
119
119
233
233
97
97
MUSICAL NOTE
NOTE
MUSICAL
49
49
50
50
51
51
52
52
53
53
54
54
55
55
56
56
57
57
58
58
59
59
64
64
65
65
66
66
67
67
68
68
69
69
70
71
72
72
73
73
74
75
80
81
82
83
84
85
86
87
88
89
90
91
91
96
97
97
98
99
99
100
100
101
101
102
102
103
103
104
104
105
105
106
106
OSCILLATOR
OSCILLATOR FREQ
FREQ
C#-3
C#-3
2273
2273
0-3
D-3
2408
2408
0#-3
D#-3
E-3
E-3
F-3
F-3
F#-3
F#-3
G-3
G-3
G#-3
G#-3
2551
2551
3406
3406
A-3
A-3
3608
3608
A#-3
A#-3
2703
2703
99
10
10
2864
2864
11
11
3034
3034
11
12
12
13
13
14
14
14
14
15
15
16
16
17
17
18
18
19
19
21
21
22
22
23
23
25
25
26
28
29
31
33
35
37
39
42
44
47
50
50
53
56
59
63
67
71
71
75
75
79
79
84
84
89
89
94
94
100
100
106
106
112
11
2
119
119
3215
3215
3823
3823
C-4
C-4
8-3
B-3
4050
4050
4291
4291
C#-4
C#-4
4547
4547
0 -4
D-4
0#-4
D#-4
4817
4817
5103
5103
E-4
E-4
5407
5407
F-4
F#-4
G-4
G#-4
A-4
A#-4
8-4
B-4
C-5
C#-5
0-5
D-5
0#-5
D#-5
E-5
F-5
F#-5
G-5
G#-5
A-5
A#-5
8-5
B-5
C-6
C#-6
0-6
D-6
0#-6
D#-6
E-6
E-6
F-6
F-6
F#-6
F#-6
G-6
G-6
G#-6
G#-6
A-6
A-6
A#-6
A#-6
5728
5728
F-4
88
99
6069
6069
6430
6430
6812
7217
7217
7647
8101
8583
9094
9634
10207
10814
11457
12139
12860
13625
14435
14435
15294
15294
16203
16203
17167
17167
18188
18188
19269
19269
20415
20415
21629
21629
22915
22915
24278
24278
25721
25721
27251
27251
28871
28871
30588
30588
6812
150
150
11
225
225
104
104
247
247
143
143
48
48
218
218
143
143
78
78
24
24
239
239
210
210
195
195
195
195
209
209
239
239
31
31
96
96
181
181
30
30
156
156
49
223
165
135
134
162
223
62
193
107
107
60
57
99
190
190
75
15
15
12
12
69
69
191
191
125
125
131
131
214
214
121
121
115
115
199
199
124
124
-
MUSICAL NOTE
v
107
112
113
114
115
116
117
118
119
120
121
122
123
B-6
B·6
C·7
C-7
C#·7
C#-7
D·7
D-7
D#·7
D#-7
E·7
E-7
F·7
F-7
F#·7
F#-7
G-7
G·7
G#·7
G#-7
A·7
A-7
A#·7
A#-7
B·7
B-7
OSCILLATOR FREQ
32407
34334
36376
38539
40830
43258
45830
48556
51443
54502
57743
61176
64814
126
134
142
150
159
168
179
189
200
212
225
238
253
FILTER SETIINGS
SETTINGS
Location
v
Contents
54293
Low cutoff frequency (0·7)
(0-7)
54294
High cutoff frequency (0·255)
(0-255)
54295
Resonance
Filter voice
Filter voice
Filter voice
54296
High pass (bit 6)
Bandpass (bit 5)
Low pass (bit 4)
Volume (bits 0·8)
0-3)
v
v
v
v
151
151
(bits 4·7)
4-7)
3 (bi
(bitt 2)
2 (bit 1)
1
1 (bit 0)
151
30
24
139
126
250
6
172
243
230
143
248
46
APPENDIX N
N
APPENDIX
BIBLIOGRAPHY
BIBLIOGRAPHY
Addison-Wesley
Addison-Wesley
" BASIC and
and the
the Personal
Personal Computer".
Computer", Dwyer
Dwyer and
and
"BASIC
Critchfield
Critchfield
Compute
Compute
"Compute's First
First Book
Book of
of PET/CBM"
PET/CBM "
"Compute's
Cow bay Computing
Comput ing
Cowbay
"Feed
" Feed Me,
Me, I'm
I'm Your
Your PET
PET Computer",
Computer" , Carol
Carol
Alexander
Alexander
" Looking Good
Good with
with Your
Your PET".
PET", Carol
Carol Alexander
Alexande r
"Looking
- Plans,
Plan s, Quizzes,
Quizzes, and Answers"
" Teacher's PET —
"Teacher's
Creative Computing
Computing
Creative
"Getting
"Ge ttin g Acquainted
Acquainted With
Wi th Your
Your VIC
VIC 20".
20", T.
T. Hartnell
Hartnell
Dilithium Press
Press
Dilithium
" BASIC Basic-English
Basic·English Dictionary
Dictionary for
for the
the PET",
PET" ,
"BASIC
Larry Noonan
Noonan
Larry
BASIC" , Tom
Tom Rugg
Rug g and
and Phil
Ph il Feldman
Feldman
" PET BASIC".
"PET
Faulk Baker
Bake r Associates
Faulk
""MOS
MOS Programming
Programming Manuai",
Manual", MOS
MOS Technology
Technology
Hayden Book
Book Co.
Hayden
" BASIC From
From the Ground
Ground Up",
Up" , David
David E. Simon
Simon
"BASIC
"1
PET" , Aubrey Jones,
Jones, Jr.
Jr.
" I Speak
Speak BASIC to My PET".
Subroutines" , Nick
Ni ck Hampshire
Hampsh ire
""Library
Library of PET Subroutines",
"PET Graphics", Nick Hampshire
Handbook, Apple. TRS·80,
TRS-80, and
""BASIC
BASIC Conversions Handbook,
PET", David A.
A. Brain,
llip R.
R. Oviatt
Brain, Phi
Phillip
Oviatt., Paul J.
Paquin,
Paquin, and Chandler P.
P. Stone
Howard W. Sams
""The
The Howard W
W. Sams Crash Course in
Microcomputers",
Microcomputers", Louis E. Frenze
Frenzel,l, Jr.
""Mostly
Mostly BASIC: Applications for Your PET",
Howard
Howard Berenbon
Interfacing".
""PET
PET Interfacin
g", James M. Downey and Steven
M. Rogers
VIC 20 Programmer's Reference Guide", A. Finkel,
""VIC
Finkel.
P.
P. Higginbottom
Higginbottom., N. Harris, and M.
M. Tomczyk
Littl
e, Brown & Co.
Little,
Businesses,
"Computer Games for Bu
sinesses, Schools, and
Homes". J. Victor Nagigian
Nagigian,, and Wi
William
Homes",
lliam S. Hodges
Tutor:
Learning
The Computer Tut
or: Learn
ing Activities for
""The
Homes and Schools"
Schools"., Gary W
W. Orwig
Orwig,, University of
Homes
Central Florida,
Florida, and William S. Hodges
Hodges
McGraw·Hill
McGraw-Hill
PET".. Herbert
Herbert D.
D.
""Hands-On
Hands·On BASIC With a PET"
Peckman
Peckman
""Home
Home and Office Use
Use o
off VisiCalc", D.
D. Castlewitz,
Castlewitz.
and l.
L Chisauki
t52
152
Osborne/McGraw-Hill
Osborne/McGraw·Hill
""PET/CBM
PET/CBM Personal
Personal Computer
Computer Guide",
Guide", Carroll
Carroll S.
S.
Donahue
Donahue
"PET
"PET Fun
Fun and
and Games",
Games". R.
R. Jeffries
Jeffries and
and G.
G. Fisher
Fisher
PET and
ue
""PET
and the
the IEEE",
IEEE", A.
A. Osborne
Osborne and
and C.
C. Donah
Donahue
""Some
Some Common
Common BASIC
BASIC Programs
Programs for
for the
the PET",
PET", l.
L
Poole,
Poole, M.
M. Borchers,
Borchers, and
and C.
C. Donahue
Donahue
""Osborne
Osborne CP/M
CP/M User
User Guide"
Guide",, Thom
Thorn Hogan
Hogan
""CBM
CBM Professional
Professional Computer
Computer Guide"
Guide"
"The
"The PET
PET Personal
Personal Computer
Computer Guide"
Guide"
""The
The 8086 Book"
Book"., Russell
Russell Rector
Rector and George
George Alexy
Alexy
P. C.
C. Publications
Publications
P.
""Beginning
Beginning Self·Teaching
Self-Teaching Computer Lessons"
Lessons"
Prentice-Hall
Prentice·Hall
"The PET Personal
puler for Beg
inners" , S.
Personal Com
Computer
Beginners",
Dunn
Dunn and V. Morgan
Morgan
Reston Publishing
Publishing Co.
Reston
""PET
PET and the IEEE
IEEE 488 Bus
Bus (GPIB)",
(GPIB)". Eugene
Eugene Fisher
Fisher
W. Jensen
and C.
C.W.
""PET
PET BASIC -— Training Your PET Computer"
Computer",,
Ramon Zamora, Wm. F. Carrie, and B. Albrecht
PET Games and Rec
reati on", M. Ogelsby, l.
""PET
Recreation",
L
Lindsey, and D.
D. Kunkin
""PET
PET BASIC",
BASIC". Richard Huskell
on"
""VIC
VIC Games and Recreati
Recreation"
Telmas Courseware
Ratings
""BASIC
BASIC and the Personal Computer", T.
A.
T. A.
Dwyer,
M. Critchfield
Dwye
r, and M.
Total Information
Total
Services
"■'Understanding
Understanding Your PET/CBM,
1,
PET/CBM. Vol. 1,
BASIC Programming"
David Schultz
"Understanding Your VIC", David
Commodore Magazines provide you with
with the
the most up-to-date
up·to·date information
information for
Commodore
64. Two of the most popular publications
publications that you
yo u should
should
your Executive 64.
seriously
seriousl y consider
consider subscribing
subscribing to
to are:
COMMODORE —
- The Microcomputer Magazine is
is published
published bi-monthly
bi·monthly and
and is
is
COMMODORE
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).
available
POWER /PLAY —
- The Home Computer Magazine
Magazine is
is published
published quarterly
quarterly and
and is
is
POWER/PLAY
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).
available by
available
153
153
APPENDIX 0
0
APPENDIX
SPRITE REGISTER
REGISTER MAP
MAP
SPRITE
•
Register
Register
#
Dec
Dec
He,
Hex
DBl
D87
00
00
SOX?
SOX7
SOXO
SOXO
l1
11
SOY7
SOY7
SOYO
SOya
22
22
SIX?
S1X7
S1XO
SlXO
SPRITE
SPRITE 11 XX
S1YO
SPRITE
SPRITE 11 YY
DM
D86
DB5
D85
D84
D84
D83
D53
D82
DB2
D81
DBl
D80
DBO
SPRITE
SPRITE 00 XX
Component
Component
SPRITE
SPRITE 00 YY
Component
Component
33
33
SlY?
S1Y7
44
44
S2X7
S2X7
SIYO
S2XO
S2XO
55
55
S2Y7
S2Yl
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
SPRITE
SPRITE 44 XX
SPRITE
SPRITE 22 XX
8B
8B
54Xl
S4X7
S4XO
54XO
9
9
9
9
$4Y7
S4Y7
S4YO
S4YO
SPRITE
SPRITE 44 YY
10
10
A
A
S5X7
S5Xl
S5XO
S5XO
SPRITE
SPRITE 55 X
X
11
11
B
B
S5Y7
S5Y7
S5YO
S5YO
SPRITE
SPRIT E 55 Y
Y
SPRITE
SPRITE 66 X
X
12
12
C
C
S6X7
S6X7
S6XO
S6XO
13
13
D
0
56Yl
S6Y7
S6YO
S6YQ
SPRITES
SPRITE 6 Yy
14
"
E
E
S7X7
S7XO
SPRITE 7
SPRITE
7X
X
Component
Component
15
15
F
F
S7Y?
S7Y7
S7YO
S7YO
SPRITE 7
7 Y
SPRITE
Y
Component
Component
16
16
10
10
S7X8 56XB
S6X8
ssxa
ssxa
S0X8
SOXB
MSB 01
of X
X
MSB
COORD.
COORD.
17
17
11
11
RCB
RCB
ECM
YSCLO
RSEL YSCL2 YSCL1
BMM
BMM BLNK ASEL
Sell VSCLO
lB
18
12
12
RCl
RC7
RGG
RC6
19
19
13
20
20
"
lPX7
LPX7
lPY7
LPY7
14
RC5
RC5
54XB
S4X8
RC4
RC4
S3X8
RC3
RC3
154
154
S2X8
S2XB
RC2
RC2
S1X8
SlX8
RC1
RCl
Y
Y
SCROLL
sCROLL
MODE
MODE
RCO
RCO
RASTER
RASTER
LPXO
LPXQ
LIGHT PEN
PEN X
X
UGHT
LPYO
LIGHT PEN
PEN Y
Y
UGHT
---- -
Register
Dec
De<:
Hex
•
D87
087
21
15
SE7
22
16
N.C.
N
.C.
23
17
5EXY7
EXY7
24
l18
B
VS13
VS12
VS11
VSll
VS10
VSlO
25
19
IRQ
lRO
N.C.
N.C.
N.C.
26
1A
lA
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
27
1B
lB
BSP7
BSPO
Background·
BackgroundSprite
PRIORITY
28
1C
lC
SCM7
SCMO
Multicolor
Multicofor
SPRITE
SPRITE
SELECT
29
1D
10
SEXX7
EXX7
SEXXO
SPRITE
EXPAND X
X
30
1E
lE
SSC7
SSCO
Sprite·Sprite
Sprite-Sprite
COLLISION
31
IF
lF
SBC7
SBCO
Sprite·
SpriteBackground
COLLISION
tt
D86
086
D85
085
D84
084
D82
DB2
D83
083
DBl
D81
DBO
D80
SEO
N.C.
RST
MCM
SPRITE
ENABLE
(ON/OFF)
XSCL2 XSCL
XSCL1l XSCLO
CSEL I"SCl2
X SCROLL
MODE
SEXYQ
SEXYO
SPRITE
EXPAND Y
Y
CB12
CB
12
CBll
CB11
N.C.
N.C,
SCREEN
Character
Memory
LPIRQ lSSC
ISSC
Isac
ISBC
RIRQ
Interupt
Request's
CB13
MLPI
MLPi I"'SSC
MISSC M1SB(
MISBC MRIRQ
Register #
#
Interupt
Reques
Requestt
MASKS
Register ##
Dec
Hex
Color
Dec
Hex
Color
32
32
20
BORDER COLOR
39
39
27
27
SPRITE 00 COLOR
COLOR
SPRITE
3:
33
21
21
BACKGROUND
COLOR 0
0
40
40
28
2B
SPRITE 11 COLOR
COLOR
SPRITE
41
34
22
22
BACKGROUND
BACKGROUND
29
29
SPRITE 22 COLOR
COLOR
SPRITE
COLOR 11
COLOR
42
42
2A
2A
SPRITE 33 COLOR
COLOR
43
43
2B
2B
SPRITE 4~ COLOR
COLOR
SPRITE
44
44
2C
2C
SPRITE 55 COLOR
COLOR
SPRITE
45
45
2D
20
SPRITE 66 COLOR
COLOR
SPRITE
46
46
2E
2E
SPRITE 77 COLOR
COLOR
SPRITE
34
35
35
23
23
BACKGROUND
BACKGROUND
COLOR
COLOR 22
36
36
24
24
BACKGROUND
BACKGROUND
COLOR
COLOR 33
37
37
25
25
SPRITE
SPRITE
MULTlCOLOR 00
MULTICOLOR
38
38
26
26
SPRITE
SPRITE
MULTICOLOA 11
MULTICOLOR
v
155
155
COLOR CODES
CODES
COLOR
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
CVAN
CYAN
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 COLORS
COLORS 0-7
0-7 MAY
MAY BE
BE USED
USED IN
IN MULTICOLOR
MULTICOlOA CHARACTER
CHARACTER MODE
MODE
ONLY
' r.
—
—
156
156
APPENDIX P
P
APPENDIX
6566/6567 (VIC-II)
(VIC-II) CHIP
CHIP REGISTER
REGISTER MAP
MAP
6566/6567
The
lor video
troller devices
The 6566/6567
6566/6567 are
are multi·purpose
multi-purpose co
color
video con
controller
devices for
for use
use in
in
both
inals and
both computer
computer video
video term
terminals
and video
video game
game applications.
applications. Both
Both devices
devices con·
con
tain
tain 47
47 control
control registers
registers which
which are
are accessed
accessed via
via aa standard
standard 8·bit
8-bit micromicro
processor
processor bus
bus (65XX)
(65XX) and
and will
will access
access up
up to
to 16K
16K of
of memory
memory for
for display
display informa·
informa
tion.
ous operating
tion. The
The vari
various
operating modes
modes and
and options
options within
within each
each mode
mode are
are described.
described.
v
DBS
0"
DB4
08'
DB3
Oil
0DB2
82
DB1
0"'
0'0
DBO
M0X7
MOX7
M0X6
MOX6
MOX)
M0X3
MOY)
M0Y3
MIX]
M1X3
M
1V)
M1Y3
MOX2
M0X2
MIX2
M1X2
MOX
I
M0X1
MOV
I
M0Y1
MIX
I
M1X1
Moxa
MOXO
M0Y6
MOY6
M0X5
MOX5
M0Y5
MCYS
M
l ;J(5
MIX5
M1Y5
M
I l'S
M0X4
MOX"
M0Y7
MOV7
M!X7
MIX]
M112
MIY2
M1Yl
M1Y1
M2X3
M2X3
M2X2
M2X2
MIYO
M1Y0
M2XO
M2X0
M'lV)
M2Y3
M2Y2
M2Y2
M)X3
M3X3
M)X2
M3X2
M3Y4
M)Y"
M)Y)
M3Y3
M)
Y'l
M3Y2
M2X
l
M2X1
M2
YI
M2Y1
M)XI
M3X1
M)Y1
M3Y1
M4X4
M
4 X4
M4Y4
M4
Y4
M5XJ,
M5X4
M4X3
M4X3
M
4 Y3
M4Y3
M5
X3
M5X3
M5Y4
M,5
Y4
M6X4
M6XJ,
M6Y4
M7XJ,
M7X4
M5Y3
M5
Y3
.'.16
'1. 3
M6X3
M6Y3
.'.17'1.3
M7X3
M
4 X2
M4X2
M
4 Y2
M4Y2
M5
X2
M5X2
M5Y2
.'.16
'1. 2
M6X2
D&7
001
00
00
01
01
02
0'
03
0'
004
'
005
'
06
06
07
07
OB
O'
((100)
$00)
(SOD
(SO
l)
(S02)
(S0
21
(103))
(SOJ
M1Y7
M
1Y7
M1X6
MIX6
M0Y4
MOY"
M1X4
M
I X"
MIY4
M
IrA
M2X4
M2X
4.
M2Y4
M'lV"
M3X4
M3
XA
MO'(2
M0Y2
M1XO
MIXO
MOB
, OOIlI;on
MOB 00 )(X-po»ition
00 Y'CMu
rl ion
Y-poiition
11 XPO l llio n
X-povtion
11 Y,
pO l ilion
Y-poiition
MOB
MOB
MO
B
MOB
MOB
MOB
M08
MOB
M2X7
M'lXl
M2Y7
M2Y7
M2Y6
M2
Y6
M2
'(5
M2Y5
M3X7
M3X7
M3Y7
MlY7
M4X7
M
J, X7
M4Y7
M
4 Y7
M5X7
M5X7
M3X6
MJ
X6
M3X5
M)X5
M)
Y5
M3Y5
ilOB))
(SOe
(IOC))
(SOC
(SOD))
(SOD
llOE))
(SO£
(10F)
(SOF)
($10)
(S
IO )
(til)
(S
1 1)
M5Y7
M5Y7
M6X7
M6X7
M6Y7
M6Y7
M7X7
M7X7
M5Y6
M5Y6
M6X6
M6
X6
M6Y6
M7X6
M4X5
M4
X5
M4Y5
M4
Y5
M5X5
M5X5
MSY5
M5Y,5
M6X5
.'.16
'1. ,5
M6Y5
M6Y,5
M7X5
M7XS
M7Y7
M7Y6
M7Y5
M7Y4
Mm
M7Y3
M7Y2
M7XS
M7X8
M6X8
M6X8
M5XB
MSX8
M
4 X8
M4X8
M2X8
P.CB
Re.
ECM
OCM
BMM
RC7
'07
RC6
' CO
RC3
'el
RC2
'C'
"
'RC1
CI
"
lLPXB
PX8
LPY7
lP
Y7
lLPX7
PX7
lLPY6
PY6
RC5
'CO
'CO
RCO
lLPX6
PX6
LPY5
lPY5
lPXS
LPX5
lLPX4
PXJ,
LPY4
LPYJ
IPY3
lLPX3
PX3
lLPY2
PY2
lLPX2
P X2
LPY
.PY1I
lLPXl
PXl
lIPYO
PY O
M7E
M7!
M4E
MOE
MI!
MtE
23
(117)
(S I7)
M7YE
M7YE
M6YE
M6YE
M5YE
MSYE
M4YE
M 4 YE
C5EL
CS
El
M3
YE
M3YE
MOE
XO
xo
.'1108 Enable
Enob l.
MOB
—
M4E
M'
E
MCM
MCM
M2E
—
M5E
M"
RES
RES
MlE
M3E
22
(112)
(S
12)
($13)
(S
131
1114)
is
141
(115)
(S
I S)
($16)
(S 16)
DEN
OEN
RC4
,C
'
M3X8
IIS
H
RSEL
M2YE
M IY
Ml
Y£E
MO
YE
MOYE
MOB Y-e*oond
Y-e_ r::ond
MOB
2*
(SIB)
(S 18 )
VMI3
VM I 3
VM12
VM I 2
VM1
VM I 1I
VM10
VM IO
25
""
(119)
(S 19)
IRQ
IRQ
2-,
IDA)
(S IA)
—
27
27
'SIB)
n i B)
M7DP
M 7 DP
M6DP
M6DP
M5DP
MSDP
28
28
(SIC)
(S IC )
M7MC
M 7MC
M6MC
M6M C
M5MC
MSM C
29
(SID)
(S I D)
M7XE
M7xe
M6XE
M6XE
3D
($>E>
IS I f)
M7M
M7M
M6M
M'M
31
M7D
M70
M6D
MOO
so
09
10
10
12
,.""
13
11
If
"
"
"
16
17
18
IB
19
"0
'20
21
21
"
,."
,.
'0
($04)
(S04
)
(105))
(S05
(106)
(1061
(S07)
(S07)
iS08)
(S08)
(109)
(S09)
(SOA)
(SOA)
-
-
M3Y6
M)Y6
M4X6
M
4 X6
M4Y6
MH6
M5X6
.'.15
'1. 6
-
M2X5
M2XS
"Y<
M6Y2
M6Y2
7X2
M
M7X2
Y2
X2
X2
M4
XI
M4X1
M4
YI
M4Y1
.'.15'1.
MSX11
M
5Y I
M5Y1
M2
YO
M2Y0
MJ
XO
M3X0
M3'(0
M3Y0
'22 XO<I1",on
X-ponIion
"·oo''''on
MOB '22 Y-po»iliof>
MOB
MOB
MOS J3
X·oo,,,,O"
X-po»ilion
Moe
l i" on
MOB 33 Y·p.o
Y-poiilion
Moe
POII' ,on
MOB 4* X·
X-poiition
MO
B 44 Y.
pol i, io n
MOB
Y-poiition
M6X
M6X1I
M6
YI
M6Y!
.'.17
'1.1
M7X1
XO
M4
M4X0
M4Y
O
M4Y0
.'.15
'1.0
M5X0
M5YO
M5YQ
.'.16
'1.0
M6X0
M6Y
O
M6Y0
.'.17
'1. 0
M7X0
Mo
e
MOB
MO
B
MOB
MOB
MOB
MOB
MOB
.'.loa
MOB
M7Y
M7YII
M
I X8
M1X8
M6YO
M6Y0
.'.10
'1. 8
M0X8
Moe
Y ·~O I "' on
MOB 7
7 Y-poinion
MSa
" ,o n
MSB o
off X·pOI
X-pontioi
VI
XI
'0
YO
55
5S
6
66
77
X·
~O I " ' On
X-pontpon
Y.
i>o.n ,on
Y-poiition
X.pO"lion
Y·
po.",on
Y-poiition
X·.,Oll'
,on
X-ponrion
SSe••» I-•*!
. ~'
IIotl.r
.9'''.'
Roite r 'regnter
l.
gh , Pen
p. n X)(
Ughi
n Y
lLight
'gh, P.
Pen
Y
See te»t
!. d
Se
Ce l 3
CB13
C 6 12
CB)2
C BI I
CB1I
-
—
—
—
ILP
IMMC
IMMC
IMBC
IMBC
III Sf
IRST
I n!e ''v
~ 1 Regiitor
II e g itle .
Interr
jpt
—
—
—
EIP
fL '
eM MC
EMMC
EMB C
EMBC
EIISf
ERST
Eno b leb Inier'jpi
In1etru p.
Enob
M4DP
M40P
M3DP
M3DP
M20P
M2DP
M I DP
M1DP
.'.l OO P
MODP
AT A Priority
P" o to 'V
M O B-O
MOB
DATA
M 4 MC
M4MC
M3MC
M3MC
M2MC
M2MC
M I MC
MIMC
MOMC
M0MC
Se l
M O B Multicolor
M ull 'colot Sel
MOB
M5XE
M SX E
M4XE
M4XE
M3XE
M3x e
M2XE
M3XE
M I XE
MIXE
MOM
MOXE
MO B X-siponO
X- upo nd
MOB
M5M
M5M
M4M
M.M
M3M
M'M
M2M
M'M
.'11 1M
M1M
MOM
MOM
Co llo • •on
MO B-MOB
MOB
MOS Collision
M5D
M5 0
M. O
M40
M3D
M'O
M20
M2D
MOO
MOD
-
MIO
MID
MO B_D ATA Collision
Col l",on
MOB-DATA
-
-
-
-
IL'
Memory Pomteri
Po,n' e "
Memory
""
(S1F)
(S I F)
32
(120)
($10 )
—
-
—
—
Eel
EC3
EO
EC2
EC I
EC1
fCO
ECO
hle to o)'. Coior
Co Ot
Exter,
(121)
(S2 1)
—
—
—
—
.Oel
B0C3
.0<2
B0C2
8 0C I
B0C1
BOCO
' DCO
34
(122)
(s n )
-
—
33
II
Bl"gd 00
- 0 Color
C o lo .
Bkgd
—
—
—
—
B1C3
61C3
8 1C2
BIC2
35
(S23)
(S23 )
81C I
B1C!
BIC O
B1C0
—
-
8i; g d #1
- I Color
Co lo.
Bkgd
—
—
B2C3
82C3
82C2
B2C2
B2 C I
B2CI
(S34)
(S2 4)
-
BKO
B2C0
36
Bl"gd #2
_ 2 Color
Co lo .
Bkgd
—
—
—
fl3C2
33C3
83C I
B3C1
B3CO
B3C0
(125)
(S2 S)
Bi; gd #3 Color
Co lo .
Bkgo
—
—
—
MM03
MM03
MM0 2
MM03
MMO'
MM01
:=
(126)
(S26 )
-
B3C3
83C3
37
—
—
-
MM OO
MM00
MOB Multicolor
Mu il ico lot #0
' 0
MOB
—
—
—
—
MM13
I3
MM
MM12
I2
MM
MM11
I.
MM
l$27)
(S2 7 )
MO B Multicolor
M ul" cOIOt #1
MOS
—
—
—
—
MaC)
M0C3
MOC2
M0C2
MaC I
M0C1
MOCO
M0C0
0
($38)
(S28 )
-
MM10
IO
MM
j9
-
—
—
—
-
MOB 00 Color
C o lo .
MOB
—
MICJ
M)C3
MIC2
MIC2
M IC I
M1C!
H29)
(S29 )
M IC a
M1C0
MOB 1 I Color
Co lo .
MOB
1
—
—
—
—
M2C2
M2C2
.,..
M2C3
M2C3
M2 C I
M2CI
M2 CO
W2C0
MO B 3"1 Color
Co lo.
MOB
2
(12A)
($1A)
—
—
—
M3c)
M3C3
M3C2
M3C2
M3C1
M3C '
M3 CO
M3C0
3
(S2B)
( UB)
M O B 3J Color
Cole r
MOB
—
—
—
M 4CJ
M4C3
M 4C2
M4C2
.
M 4CI
M4C1
(12C)
(SK I
M4CO
M4C0
MOB 44 Color
Colo '
MOB
4
—
—
—
—
MSC 3
M5C3
MSC I
M5C1
(J2D)
($:2 0 )
MSCO
M5C0
MOB 5S Color
Colo'
MOB
5
—
—
-
—
—
M6CJ
M6C3
M6C I
M6C1
M6CO
M6C0
46
-
M6C2
M6C2
:$2E>
($:2E )
-
MSC2
M5C2
-
-
MOe i6 Color
Colo,
MOB
—
—
M 7C 3
M7C3
M7C2
M7C2
M 7C I
M7C1
M7 CO
M7C0
MOB 77 Color
C o lor
MOB
,.
"
"
31
"3.
.,. 0
.,.,
NOT
-
—
-
—
—
-
-
--
—
-
-
--
-
-
-
-
-
-
—
•°° 3' -
I
'
v
v
MOYO
M0Y0
OESCII,-rION
DESCHIPTION
M1Y6
MIY6
M2X6
M2X6
11
II
v
DB6
0"
ADDRESS
ACO
I US
157
157
"'3
"
APPENDIX Q
Q
APPENDIX
EXECUTIVE 64
64
EXECUTIVE
SOUND CONTROL
CONTROL SETTINGS
SETTINGS
SOUND
This handy
handy table
table gives
gives you
yo u the
the key
key numbers
numbers you
you need
need to
to use
use inin your
your sound
sound
This
programs,
programs ,according
according to
to which
which of
of the
the 64's
64's 33 voices
voices you
you want
want to
to use.
use. To
To set
set or
or ad
adjust aa sound
sound control
control in
in your
your BASIC
BASIC program,
program,just
just POKE
POKE the
the number
number from
from the
the se
se·
just
cond column,
column, followed
followed by
by aa comma
comma (,)
(,)and
and aa number
number from
from the
the chart...
chart ... like
like this:
this:
cond
(Selects aa Triangle
Triangle Waveform
Waveform for
for VOICE
VOICE 1).
1).
POKE 54276.17
54276,17 (Selects
POKE
Remember
Remember that
that you
you must
must set
set the
the VOLUME
VOLUM E before
before you
you can
can generate
generate sound.
sound.
POKE54296
15 to
to set
set the
the volume
volume for
for all
all 33 voices.
voices.
POKE54296 followed
followed by
by aa number
number up
up to
to 15
takes 22 separate
separate POKEs
POKEs to
to generate
generate each
each musical
musical note.
note. For
For example
example
ItIt takes
POKE54273,33:POKE54272,135
POKE54273,33:POK E54272,135 designates
designates low
low CC in
in the
the sample
sample scale
scale below.^
bel ow.
Also, you
you aren't
aren't limited
limited to
to the
the numbers
numbers shown
shown in
in the
the tables.
tables. IfIf 33
33 doesn't
doesn' t
Also,
sound
" right " for
for aa low
low C,
C, try
try 34.
34. To
To provide
provide aa higher
higher SUSTAIN
SUSTAIN or
or ATTACK
ATIACK rate
rate
sou nd "right"
than
two or
or more
more SUSTAIN
SUSTAIN numbers
numbers together.
together. (Examples:
(Examples:
than those
those shown,
shown, add
add two
POKE54277.96
POKE54277,96 combines
combines two
two attack
altack rates
rates (32
(32 and
and 64)
64) for
for aa combined
combined higher
higher at
at·
provides aa low
low attack
attack rate
rate (16)
(16) and
and aa medium
medium decay
decay
tack rate,
rate, POKE54277.20
POKE54277,20 provides
tack
("',
rate (4).
(4).
rate
*-
158
158
v
FOLLOWED BY ONE OF THESE NUMBERS
TO CONTROL
v
(0 to 15 ... or... 0 to 255 depending on range)
THIS SETTING:
D#
TO PLAY A NOTE
v
F«
G
G«
AM
B
HIGH FREQUENCY
54273
33
35
37
39
42
44
47
50
53
56
63
LOW FREQUENCY
54272
135
134
162
223
62
193
107
60
57
99
WAVEFORM
POKE
TRIANGLE
SAWTOOTH
PULSE
NOISE
54276
17
33
65
129
190
75
PULSE RATE (Pulse Waveform)
v
v
Hi PULSE
54275
A value ot 0 to 15 (for Pulse waveform only)
LO PULSE
54274
A value ot 0 to 255 (tor Pulse waveform only)
ATTACK/DECAY
POKE
ATK4
ATK3
ATK2
ATK1
54277
128
64
32
16
POKE
54276
SUS4
SUS3
SUS2
SUS1
128
64
32
16
SUSTAINfRELEASE
TO PLAY A NOTE
v
C#
D#
DEC4
DEC3
DEC2
DEC1
REL4
REL3
REL2
REL1
F#
G#
A#
HIGH FREQUENCY
54230
33
39
LOW FREQUENCY
54279
135
223
WAVEFORM
POKE
TRIANGLE
SAWTOOTH
PULSE
NOISE
54283
17
33
65
129
59
193
190
PULSE RATE (Pulse Waveform)
HI PULSE
LO PULSE
54282
54281
ATTACKJOECAY
ATTACHJDECAY
POKE
ATM
ATK3
ATK2
ATK1
54284
128
64
32
16
POKE
SUS4
SUS3
SUS2
54285
128
64
32
SUS1
16
SUSTAIN/RELEASE
A value ot 0 to 15 (for Pulse waveform only)
A value of 0 to 255 (for Pulse waveform only)
C#
TO PLAY A NOTE
DEC4
DEC3
REL4
REL3
162
G#
REL1
Aft
54287
LOW FREQUENCY
54286
WAVEFORM
POKE
TRIANGLE
SAWTOOTH
PULSE
NOISE
54290
17
33
65
129
v
134
REL2
HIGH FREQUENCY
135
37
DEC1
1
D#
35
DEC2
223
42
44
47
50
53
56
59
63
62
193
107
60
57
99
190
75
PULSE RATE (Pulse Waveform)
v
H! PULSE
54289
A value of 0 to 15 (for Pulse waveform only)
LO PULSE
54288
A value ot 0 to 255 (tor Pulse waveform only)
ATTACK/DECAY
POKE
ATK4
ATK3
ATK2
ATK1
54291
128
64
32
16
POKE
SUS4
SUS3
SUS2
54292
128
64
32
SUSTAIN/RELEASE
v
159
DEC4
DEC3
SUS,
SUS1
REL4
AEL3
REL3
16
8
AEl2
2
RELI
TRY THESE SETTINGS TO SIMULATE DIFFERENT INSTRUMENTS
Instromenl
Instrument
Waveform
Attack/Deca y
Attack/Decay
Sustain/Release
Piano
F
lute
Flute
Harpsichord
Xylophone
Organ
Colliape
Accordian
Trumpet
Pulse
Triangle
Sawtooth
Triangle
Triangle
Triangle
Triangle
Sawtooth
9
96
9
9
0
0
102
96
0
0
0
0
240
240
0
0
Pulse Rate
Hi.Q,
Hi-0. Lo-255
Not
Not
Not
Not
Not
Not
Not
applicable
appl
icable
applicable
applicable
applicable
applicable
applic
able
applicable
applicable
MEANINGS OF SOUND TERMS
AttackiDecaylSustainlRelease
ADSA -— Attack/Decay/Sustain/Release
ADSR
Attack -— rate
rale sound rises to peek volume
Decay -— rate
rale sound lalls
tails from peek volume to sustain level
Sustain -— prolong rate at cenain
certain volume level
Release -— rate al
w hich volume fa11s
at which
falls from
trom sustain level
Waveform -— "shape" of
o( sound wave
Pulse —
- lone
Pulse
tone Quality
quality of Pulse Waveform
NOTE:
Attack/Decay and
NOTE: AttacWDecay
and Sustain/Release
SustairWRelease settings
settings should
should always
always be POKEd
POKEd In
in your
your program
program BEFORE
BEFORE
the Waveform IS
is POKEd.
POKEd.
160
~
APPENDIX R
R
6581 SOUND INTERFACE DEVICE (SID)
CHIP SPECIFICATIONS
CO
NCEPT
CONCEPT
The 6581 Sound Interface Device (SID) is a single-chip,
single-chip. 3-voice electronic
music synthesizer/sound effec
ts generator compatible with the 65XX and
effects
similar m
icroprocessor families. SID provides wide-range high-resolution conmicroprocessor
con
trol of pitch (frequency),
(frequency), tone color (harmonic content), and dynamics (volume)_
(volume).
Specialized control circuitry minimizes software overhead
overhead,, facilitating use in ar·
ar
cade/home video games and low-cost musical instruments.
FEATURES
• 3 TONE OSCILLATORS
Range: 0-4 kHz
• 4 WAVEFORMS
WAVE FORMS PER OSCILLATOR
Triangle,
Triangle. Sawtooth,
Variable Pulse, Noise
• 3
3 AMPLITUDE MODULATORS
Range: 48 dB
• 3 ENVELOPE GENERATORS
Exponential respon
se
response
Attack Rate: 2 ms-8 s
Decay Rate:
Rate: 6 ms-24 s
lume
Sustain Level
Level:: O-peak
0-peak vo
volume
Release Rate: 6 ms-24 s
SYNCHRONIZATION
HRON IZATION
• OSCILLATOR SYNC
• RING MODULATION
DESCRIPTION
Th
e 658
thesizer "voices
The
65811 consists of three syn
synthesizer
"voices"" which can be used inin
dependent
ly or in con
junction with each other (or external audio sources) to
dependently
conjunction
create com
ple x so
unds. Each voice consists of a Tone Osc
illatorlWaveform
complex
sounds.
Oscillator/Waveform
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 propro
v
duces four waveforms at the selected frequency
ith the unique harmonic con·
frequency,, w
with
con
iding si
m ple co
ntrol of tone co
lor . Th
e vo
lum e
tent of each waveform prov
providing
simple
control
color.
The
volume
dynam
ics of the oscil
lator are controlled by the Amplitude Modu
lator under the
dynamics
oscillator
Modulator
direction of the Envelope Generator_
triggered, the Envelope Generator
Generator. When triggered,
creates an amplitude enve
lope wit
h programmable rates of increasing and
envelope
with
decreasing vol
ume. In addition to the th
ree voices, a programmable Filter is provolume.
three
pro
vided for generating complex
ic tone colors via subt
rac tive syntheses.
complex,, dynam
dynamic
subtractive
SID allows the microprocessor to read the changing output of the third
v
v
Oscillator and third En
velope Generator. T
hese outp
uts can be used as a
Envelope
These
outputs
source of modulation information for creating vibrato
vibrato,, frequency/filter sweeps
and sim
ilar effects. The third
th ird osci
ll ator can also act as a random number
similar
oscillator
generator for games. Two AlD
rters are provided for in
terfacing SID with
A/D conve
converters
interfacing
potentiometers. Th
ese can be used for "paddles
These
"paddles"" in
in a game environment or as
n process external audio
front panel controls in a music synthesizer. SID ca
can
signals, allowing multiple SID chips to be daisy-chained or mixed in complex
polyphonic systems.
systems.
t61
161
0
0000
0
Q
4,<>OCl
-
cl °
-
- oo -
o
0
00000000
0
":'::~ 8o~a03il :g
|HEX>
REG-
O
-ATK?
__
0
_00
__
00
--
00
0000
__
--
OOOCl
--
--
__
QI;>QOO
000000
00
__
-
-
c;8 g:;5g 152
-
162
n_n_
AIK,
STN..
NOISE
ATK3
STNa
-
", - o - o -
__
-0
-
_
... ~
J'
RES;
...
',J Vi
~ aJ
--,.
-
<:> '" '"
0
Ej
Es
PVj
PX3
~PX,
py.
VOL3
LP
FILIEX
o3
PY;,
P*6
°6
PY,
CI..
°i
PX5
PX6
PX,
BP
HP
l:
'Cto :> :: ::-~ !
e
E,
o -
3 OFF
rJ,'
CI..
0,
Q--O
RESo
"
RES,
-
OIl
PCs
FC0
FC,"
FC,
FC;,
FC,
E,
Ej
0 0
z z
:: ::::
.!:3
REAOONLY
o
ENV,
READONLY
F1EA0 0NLY
HF.ADONLY
WHITE ONLY
WRITE ONLY
WRIIEONLY
WHITE ONt.V
WRITE ONLY
WHITf ONLr
>
Eo
OSC3JRANDOM
Oo
o,
O2
POT Y
PY0
py,
Misc.
POT X
MODE/VOL
RES'FIll
PX,,
VOL0
FILI 1
PX,
;
PX3
filt
VOL,
1
FC HI
FC LO
Filler
SUSIAINiRE LEASE
ATTACKIDECAY
WRITF ONLY
CONTROl HFC.
WHITE ONLY
WHITE ONLY
VOL,
FILT
DCYy
■
WHI
PWLO
."..
WHITE ONLY
~ ~ ~ ~ ~
RESa
FC,
HLSn
DCY,
GATE
SYNC
RIS,
HLfi,
DCY^
PW0
PWB
PW9
FREO HI
1
a
3
ft)
ID
70
11)
Q
V.I.I
LTl
WHITE ONI Y
~
FCB
g ::
RLS3
PW2
PW,o
PW,
~ !fii~t;!;
... a o :z:
F,o""
FREQ LO
Voice 3
SUSTAINJHEIEASE
WRIIEONLY
(TJ
a"
0
Tob ie 1. SID Reg ist er Map
WHITE ONLY
!:.
-
STNu
STN,
:'
0CY3
Fo
FILS,,
ATIACKIDECAY
CONTROL REG
~
FC,
ATKo
ATK,
..:: In '"
TEST
HLS,
RLS;.
DCY0
GAFE
WRITE ONLY
,.. !:. !:. ,..
FC,0
PW3
PW,,
-
..
PW4
_ _
-
PWS
'-- ~ ! ,
■v,7~
DCY,
SYNC
DCYy
PW HI
5555555
w
Ww
-
PW6
Fl(
RLSj
I
-
—b ■
SIN,,
STN,
TEST
DCY3
I
PW,
STN?
STN3
ATK0
ATK,
PW8
PW9
WHIIEONLY
WHI1F ONLY
PWLO
WF1HEONLY
FREQ HI
WRITE ONLY
FHEO LO
tfolce 7
aUSTAINiHELEASE
WRITF ONLY
~ ~ ~ ~ ~
F,.'~
ATK.i
pw0
PW,
WING
RLSo
RLS,
RLSj
ATTACK/nrCAY
WRITE ONLY
[>CY0
OCY,
CONTROL REG
GATE
SYNC
WHITE ONLY
1>W HI
PWa
WHITE ONLY
WRITE ONLY
PW LO
freo m
WHITE- ONLY
TYPE
...
Fib
nxL
ATKa
PW,,
-
-
PW3
PW,
PW5
Voice 1
FREQ LO
~PW0
DCY?
PW,
__£°
"- -'
NOISE
-
-
RLS3
STN0
STN,
TEST
PW2
F9
f;
2: ::: 222:
~ :: :: 3: ::
PWG
DCY3
ATK0
PW,,
ATK,
PW3
*~
Jp-w4
-F;
PW5
°* -
REG
,.. !; !:. ,.. ,.. !:. !:.
PWr
STN?
rLTL
ATK3
PW6
FG
NOISE
PW~
°7
F1EG NAME
5555555
... ...... ...
ro
'; 0 0 0 " ' 0 0 0
0
<01"
0
ADDRESS
~
a
o
<
0
"<01
a
.
A
CD
—r
ll
a.
ro
o o
>o
o
m it
o S
A 5"
uV
ro
CO
<° CD
-i
Th ere are 29 eight-bit registers in SID which control the generation of sound.
These regi sters are ei ther WRITE-only or READ-only and are listed below in
Table 1.
o; ro
m
i—
O
X
—A1
z
o
o
o
SID CONTROL REGISTERS
>
0
n
-
<:I
-
APPENDIX SS
APPENDIX
and PRINTER
PRINTER COMMANDS
COMMANDS and
and
DISK and
DISK
STATEMENTS
STATEMENTS
The following
following BASIC
BASIC commands
commands and
and statements
statements let
let you
you perform
perform aa variety
variety of
of
The
operations on
on disk
disk drives
drives and
and any
any compatible
compatible Commodore
Commodore printer.
printer.
operations
CLOSE
CLOSE
TYPE: I/O
I/O Statement
Statement
TYPE:
FORMAT: CLOSE < file
file number
number >
>
FORMAT:
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
Action:
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·
number
ment and the section on INPUT/OUTPUT
INPUT/OUTPUT programming).
When working
work ing with
with storage
storage devices
devices like
like disks,
disks, the
the CLOSE
CLOSE operation
operation stores
stores
When
any incomplete buffers
buffers to the device.
device. When this is
is not performed,
performed, the file will
unreadable on the disk.
disk. The CLOSE operation
operation isn't
isn't as
as necessary
necessary with other
other
be unreadable
v
v
devices,
devices, but
but it does free
free up
up memory for
for other
other files.
files. See your
you r external device
device
manual for more details.
manual
Statement:
EXAMPLES of CLOSE 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]
v
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
ied in a prior OPEN statement.
specified
The string, when specified,
s is handy for tit
ling printouts,
specified, is sent to the file. Thi
This
titling
etc.
When this command is in effect, any PRINT statements and LIST commands
wil
willl not display on the screen, but will send the text in the same format to the
lifile.
le.
To re·direct
T# command should send
re-direct the output back
back to the screen, the PRIN
PRINT#
a blank
ting data
blank line to the CMO
CMD device before
before CLOSEing,
CLOSEing. so it will stop expec
expecting
(called ""un-listening"
un-l istening" the device).
Any system error (like ?SYNTAX
7SYNTAX ERROR)
ERROR) will cause outpu
outputt to return
return to the
screen. Devices
Devices aren't un-listened
un-listened by this, so you should send a blank
blank like
like after
an
r printer
ore details.)
an error condition.
condition. (See
(See you
your
printer or disk
disk manual
manual for m
more
details.)
163
163
-■
—
EXAMPLES of
of CMD
CMD Statement:
Statement:
EXAMPLES
OPEN 4,4:
4, 4: CMD
CMD 4,
4, ""TITLE"
LIST: REM
REM LISTS
LISTS PROGRAM
PROGRAM ON
CN
TITLE" :: LIST:
OPEN
PRINTER
PRINTER
PRINT#
PRINTS 4: CLOSE 4: REM
REM UN·LlSTENS
UN-LISTENS AND CLOSES PRINTER
PRINTER
10
10
20
30
30
40
50
60
70
1, 8, 4, ""TEST":
REM CREATE SEQ FILE
FILE
OPEN 1,8,4,
TEST": REM
REM OUTPUT TO TAPE FILE,
FILE, NOT
NOT SCREEN
CMD 8: REM
FOR L =
= 1
1 TO 100
FOR
PRINT
ER IN
PRINT L:
L: REM
REM PUTS
PUTS NUMB
NUMBER
IN DISK
DISK BUFFER
BUFFER
NEXT
NEXT
PRINTS 1: REM
REM UNLISTEN
UNLISTEN
PRINT#
CLOSE 1: REM WRITE UNFINISHED BUFFER, PROPERLY
PROPERLY
FINISH
fl
g
GET#
TYPE:
I/O Statement
TY
PE: 1/0
FORMAT: GET#
GETS (<file
number> , (variable
< variable list
list>
FORMAT:
file number>,
>
Action: This statement reads characters
characters one·at·a·time
one-at-a-time from the device or file
specified. It works the same as the GET statement,
statement, except that the data comes
specified.
from a different place than the keyboard.
keyboard. If no character is received
received,, the variable
_
m
is set to an empty string (equ
al to lIt')
(equal
"") or to 0 for numeric variables. Characters
Ifflim key code (ASC code
used to separate data in files,
files , like the comma (,) or IIll!Il:II
of 13),
13), are received like any other character.
character.
When used with device #3 (TV screen), this statemenl
statement will read characters
one by one from the screen. Each use of GET#
one
GET# moves the cursor 11 position to
ght. The character at the end of the log
ical line is changed to a CHR$
CHR$ (13),
the ri
right.
logical
(13),
the
EEII key
key code.
code.
the Im!ID
EXAMPLES of GETS
GET# Statement
5
5
GETS
GET# 1,
1, A$
AS
10
3: GETS
10 OPEN 1,
1,3:
GET# 1,Z7S
1, Z7S
20 GETS
GET# 1,
1, A,
A, B,
B, CS,
CS, DS
OS
164
164
_
#
INPUT#
INPUT#
v
TYPE: I/O
I/O Statement
Statement
TYPE:
FORMAT tNPUT#
INPUTS < file
file number
number>
variable
list >>
FORMAT
>,, < variab
le list
<
<
Action:
is is
Action: Th
This
is usually
usually the
the fastest
fastest and
and easiest
easiest way
way to
to retrieve
retrieve data
data stored
stored in
in aa
file
riab les of
harac ters in
file on
on disk.
disk. The
The data
data is
is in
in the
the form
form of
of whole
whole va
variables
of up
up to
to 80
80 ccharacters
in
length
length,, as
as opposed
opposed to
to the
the one·at·a·time
one-at-a-time method
method of
of GET#.
GET#. First,
First, the
the file
file must
must
have been
been OPENed,
OPENed, Ihen
then INPUT#
INPUT# can
can lill
fill Ihe
the variables.
variables.
have
The
The INPUT#
INPUT# command
command assumes
assumes a variable is
is finished
finished when
when itit reads
reads a
RETURN
RETURN code
code (CHR$(13)),
(CHR$(13)), a
a comma
comma (,), semicolon
semicolon (;),
(;), or
or colon(:). Quote
Quote marks
marks
can be
be used
used to enclose
enclose these characters
characters when writing if they are
are needed
needed (See
(See
PRINTS statement).
PRINT#
IfIf the variable type used
used is
is numeric,
numeric, and
and non-numeric
non-numeric characters
characters are received
received,,
a BAD
BAD DATA
DATA error
error results.
results. INPUT#
INPUTS can read
read strings up
up to 80 characters long,
long,
beyond which a STRI
STRING
LONG error results.
results.
beyond
NG TOO LONG
reen), this statement will read
When used
used with device #3 (the sc
screen),
read an entire
logical liline
next line.
line.
logical
ne and move the cursor down to the next
EXAMPLES of INPUT# Statement:
EXAMPLES
INPUTS 1,
1. A
10 INPUT#
INPUTS 2, AS, BS
BS
20 INPUT#
LOAD
LOAD
TYPE: Command
TYPE:
FORMAT LOAD
LOAD "" < fil
fi!e-name>
device >
> [,
[, < address
address >
> []
FORMAT
e.name > "" , < device
<
,<
<
le from disk
Action: The LOAD statement read
readss the contents of a program fi
file
into memory.
memory. That way you can use the information LOADed or change the in·
in
formati
on in some way.
formation
way. The disk unit is normally device number 8. The LOAD
closes all
fi les and, if it is used in direct mode, it performs aa CLR (clear)
(cl ear)
all open files
before reading the program.
prog ram. If LOAD is executed from within aa program,
program, the
is RU
N. This means that
that you
you can
can use LOAD to "chain" several pro
pro·
program is
RUN.
toge ther. None
None of
of the variables are cleared during a cha
in operati
on.
grams together.
chain
operation.
you are using
using fife-name
file·name pattern
pattern matching,
matching, the first file which matches
matches the
If you
pattern is loaded.
loaded. The asterisk in
in quotes by itself ("*")
('" ") causes
causes the first
fi rst file-name
file·name
in the disk
disk directory
directory to
to be
be loaded.
loaded. If the
the file-name
fi le·name used
used does not
not exist or
or ifif itit is
is
in
a program
program file,
file, the
the BASIC
BASIC error
error message
message ?FILE
?FILE NOT
NOT FOUND
FOUND occurs.
occurs.
not a
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
If
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 A$,8
AS,8
LOAD
(Uses the
the name
name in
in AS
AS to
to search)
search)
(Uses
LOAD "*",8
UUI,S
LOAD
(LOAD s first
first program
program from
from disk)
disk)
(LOADs
LOAD "$",8:LIST
" S" ,8:LlST
LOAD
(LOADs and
and LISTs
LISTs disk
disk directory)
directory)
(LOADs
LOAD "FUN",8
"FUN'\8
LOAD
(LOAD aa file
file from
tram disk)
disk)
(LOAD
SEARCHING
FOR FUN
FUN
SEARCHING FOR
v
LOADING
LOADING
READY.
READY.
LOAD "GAME
"GAME ONE",8,1
ONE" ,8,1
LOAD
SEARCHING FOR
FOR GAME
GAME ONE
ONE
SEARCHING
LOADING
LOADING
READY.
READY.
v
(LOAD aa file
file to
to the
the specific
specific memory
memory
(LOAD
location
location from
from which
which the
the program
program was
was
saved
on
the
disk)
saved on the disk)
165
165
OPEN
OPEN
TYPE: I/O
110 Statement
Statement
TYPE:
FORMAT:
FORMAT: OPEN
OPEN <file-num>
( file.num) ,, <device>
( device )
[,
(
type)
]
[,
(
mode)
]"
]
[, <type> ] [, <mode> ]"]
[,<address>]
[, ( address) ] [,"<file-name)
],"( file.name)
Action: This
This statement
statemen t OPENs
OPEN s aa channel
channel for
for input
input and/or
andlor output
output to
to aa
Action:
peripheral
peripheral device.
device. However,
However, you
you may
may NOT
NOT need
need all
all those
those parts
parts for
lor every
every OPEN
OPEN
statement. Some
Some OPEN
OPEN statements
statements require
require only
only 22 codes:
codes:
statement.
1) LOGICAL
LOG ICAL FILE
FILE NUMBER
NUMBE R
1)
2) DEVICE
DEVICE NUMBER
NU MBER
2)
The /(file·num)
is the
the logical
logical file
fi le number,
number, which
which relates
relates the
the OPEN,
OPEN, CLOSE.
CLOSE,
The
file-num ) is
CMD,
CMD, GET#,
GET#, INPUT#,
INPUT#, and
and PRINTS
PRINT# statements
statements to
to each
each other
other and
and associates
associates
logical file
file
them with
with the
the file-name
file·name and
and the
the piece
piece of
of equipment
equipment being
being used.
used. The
The logical
them
number
number can
can range
range from
from 11 to
to 255
255 and
and you
you can
can assign
assign itit any
any number
number you
you want
want in
in
that range.
range.
that
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
NOTE:
practice to
to use
use only
only numbers
numbers beiow
below 127
127 for
for file numbers.
numbers.
practice
Each peripheral device
device (printer,
(printer, disk drive) in the system
system has
has its
its own
own number
number
Each
which
answers to.
is used
(device) number
number is
used with
with OPEN
OPEN to
to specify
specify on
on
which itit answers
to. The
The ^device))
fil e exists. Peripherals
Peripherals like disk drives or printers also
which device the data file
answer to several secondary addresses. Think of these as codes which tell
each device what operation to perform. The device logical file number is used
with every GET#,
PUT#, and PRINT#.
GET#. IN
1NPUT#,
The file·name
file-name can
can 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
The
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,
data-files,
For disk files
but other numbers
ngs in
numbers have special meani
meanings
in DOS commands. You must
must use a
drive(s). (See your disk drive manual
secondary address when using your disk drivels).
for DOS
DOS command details.)
<file-name) is a string of 1·16
1-16 characters and is
is optional for printer
printer
The (file.name
fifiles.
les. IfIf the fil
e (< type>
ll automatically default to
file
type > is
is left
left out the type of file wi
will
Program file
file un
unless
mode
is given
given.. Sequential
Sequential files are
are OPENed
OPENed lor
for
the Program
less the mode
is
reading
made>
;
R
un
less
you
specify
that
files
should
be
OPENed
lor
reading <mode)> =R unless you
files should be OPENed for
writing (made»
<(mode> ;=W
is specified.
specified. A
A lile
file (<type>
can be
be used
used to
to OPE
OPEN
an ex·
exwriting
W is
type) can
N an
isting
Ie. Use
isting Relative
Relative Iifile.
Use REL
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.
you try
try to
to access
access aa file
file before
before itit is
is OPENed
OPENed the
the BASIC
BASIC error
error message
message ?FILE
?FILE
IfIf you
NOT OPEN
OPEN wi
will
occur. IfIf you
you try
try to
to OPEN
OPEN aa Iifile
for reading
reading wh
which
does not
not exist
exist
ll occur.
Ie for
ich does
NOT
the BASIC
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
the
disk lor
for writing
writing and
and the
the file·name
file-name already
already exists,
exists, the
the DOS
DOS error
error message
message FILE
FILE
disk
EXISTS occurs.
occurs. IfIf aa Iile
file is
is OPENed
OPENed that
that is
is already
already OPEN,
OPEN, the
the BASIC
BASIC error
error
EXISTS
nter Manual
message
rs. (See
message FILE
FILE OPEN
OPEN occu
occurs.
(See Pri
Printer
Manual lor
for lurther
further detailS.)
details.)
>
<
166
166
n
v
v
v
EXAMPLES of
of OPEN
OPEN Statements:
Statements:
EXAMPLES
10 OPEN
OPEN 2,
2, 8,
8, 4
4 ""DISK-OUTPUT,
10
DISK·OUTPUT,
SEQ,W"
SEQ,W"
v
(Opens
(Opens sequential
sequential file
file on
on disk)
disk) -—
For
For Write
Write
10 OPEN
OPEN 50,
50, 0
0
10
(Keyboard
(Keyboard input)
input)
10 OPEN
OPEN 12,
12, 3
3
10
(Screen
(Screen output)
output)
10 OPEN
OPEN 130,
130,4
10
4
(Printer
(Printer output)
output)
10 OPEN
OPEN 1,2,0,
1,2,0, CHRS(10)
CHR${10)
10
(Open channel
channel to
to RS·232
RS-232 device)
device)
10 OPEN 1,4,0,
1,4,0, ""STRING"
10
STRING"
(Send
(Send upper case/graphics
case/graphics to the
the
printer)
printer)
10 OPEN 1,4,7,
1,4,7, ""STRING"
10
STRING"
(Send upperllower
upper/lower case to printer)
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)
10 OPEN 1,8,1, "NAME,L" +
CHRS(X)
CHR$(X)
(Relative file OPEN (1st time) where
X is the length of the relative record)
OPEN,, 1,8,1,"
1,8,1,"NAME"
10 OPEN
NAME"
(Relative or sequential read)
PRINT#
TYPE: I/O Statement
FORMAT: PRINT#
PRINT#<file-number
variable>][<,/;>
FORMAT:
file·number )> [< variable
) ] [ (/;) (<variable>
variable > ]]...
...
<
v
v
[<
Action s: The PRINT# statement is used to write data items to a logical file. It
Actions:
device·
must use the same number used to OPEN the file. Output goes to the device(
variable>
expressions
in
number used in the OPEN statement. The
The <( variable^
in the
output·l ist can be of any type. The punctuation characters between items are
are
output-list
same as with
with the PRINT statement and they
they can be
be used in
in the same way.
the same
The effects of
of punctuation
punctuation are
are different in
in two significant respects.
respects.
The
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
If
at the
the end of
of the
the data.
data. IfIf aa comma or
or semicolon
semicolon terminates
termi nates the output-list,
output·list, the
at
carriage-return and
and line-feed
line-feed are
are suppressed.
suppressed. Regardless
Regardless of
of the
the punctuation,
punctuation ,
carriage-return
next PRINT#
PRIN T# statement
statement begins
begins output
output in
in the next
next available
available character
character posi
posi·
the next
line·feed will
will act
act as
as aa stop
stop when
when using
using the
the INPUT#
INPUT# statement,
statement, leaving
leaving
tion. The
The line-feed
tion.
an empty
empty variable
variable when
when the
the next
next INPUT#
INPUT# is
is executed.
executed. The
The line-feed
line·feed can
can be
be sup
sup·
an
pressed of
of compensated
compensated for
for as
as shown
shown in
in the
the examples
examples below.
below.
pressed
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·
The
and use
use that
that string
string in
in between
between all
all the
the other
other variables
variab les
ing variable
variable to
to CHR$(13),
CHRS(13), and
ing
when
when writing
writing the
the file.
file.
v
v
v
167
167
-
EXAMPLESofof PRINTS
PRINTH Statement
Statement
EXAMPLES
1)1)
10 OPEN
OPEN 1,8,4,
1,B,4,"MY
" MY FILE"
FILE"
10
-
(By
(By Changing
Changing the
the CHRS(13)
CHRS(13) to
to
20 R$
RS == CHRS(13)
CHRS(13)
20
30 PRINTS
PRINTH1,1;RS;2;RS;3;RS;4;R$;5
1,1;RS;2;RS;3;RS;4;RS;5
30
CHRS(44)
CHRS(44)you
you put
put aa","
"," between
between each
each
varible.
CHR$(59)
would
put
a
";"
varible. CHRS(59) would put a";"
40 PRINTS
PRINTH1,6
1,6
40
50 PRINTS
PRINTH1,7
1,7
50
2)
2)
between
between each
each variable.)
variable.}
10 COS
COS== CHR${44):
CHRS(44): CRS
CRS== CHRS(13)
CHRS(13)
10
20 PRINTS
PRINTH1,1, "AAA"CO$"BBB",
" AAA"COS " BBB",
20
AAA,BBB
AAA,BBB
CCCDDDEEE
CCCDDDEEE
" CCC";" DDO ";"EE E"CRS
"CCC";"DDD";"EEE"CRS
(carriage
return)
(carriage return)
" FFF"CRS;
"FFF"CRS;
FFF(carriage
FFF(carriage return)
re tu rn)
30 INPUTS1,
INPUTH1, AS,BCDES,FS
AS,BCDES,FS
30
3)
3)
~-
55
CRS=CHRS(13)
CR$
= CHRS(13)
10 PRINTS2,
PRINT#2, "AAA";CRS;"BBB"
"AAA";CRS;" BBB "
10
(10
blanks)AAA
(10 blanks)AAA
BBB
BBB
20 PRINT#2,
PRINTH2, "CCC";
" CCC";
20
(10
(10 blanks)
blanks) CCC
CCC
n
30 INPUTS2,
INPUTH2, A$,B$,DUMMY$,C$
AS,BS,DUMMYS,CS
30
—
SAVE
SAVE
TYPE: Command
Command
TYPE:
<
>[,
>",<
FORMAT: SAVE
<address> I]
FORMAT:
SAVE"" <file-name>
file·name " , <device-number>
device·number [, <address)
Action:
The SAVE
SAVE com
command
is used
used to
store the
the program
program that
that is
is currently
currently in
in
Action: The
mand is
to store
memory onto
onto a
a diskette
diskette file.
file. The
The program
program being
being SAVEd
SAVEd is
is only
only affected
affected by
by the
the
memory
while
SAVE is happening. The program remains in the current
command wh
ile the SAVE
computer
memory even after the SAVE operation is completed until you put
comp
uter memory
something else
else there
there by
by using
using another
another command
command.. The
The file
file type
type will
will be
be ""prg"
prg"
something
(program). The
The SAVE
SAVE statement
statement can
can be
be used
used in
in your
your programs
programs and
and execution
execution
(program).
will continue with the next
next statement
statement after the SAVE is
is completed.
When saving
saving programs
programs onto
onto a
a disk,
disk, the
the <file·name)
<file-name> must
must be
be present
present..
When
EXAMPLES
EXAMPLES of
of SAVE
SAVE Command:
Command:
FUN DISK"
,B
SAVE
SAVE ""FUN
DISK",8
(SAVES on
on disk
disk (device
(device B
8 is
is the
the disk))
disk))
(SAVES
SAVE
SAVE AS,B
A$,8
(Store on
on disk
disk with
with the
the name
name AS)
AS)
(Store
-
168
168
_
VERIFY
VERIFY
v
TYPE: Command
Command
TYPE:
FORMAT: VERIFY
VERIFY "" <file·name
<file-name>
" , <<device)
)",
device )
FORMAT:
Action:
FY command
Action: The
The VERI
VERIFY
command is
is used
used,, in
in direct
direct or
or program
program mode,
mode, to
to com·
com
pare
pare the
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.
memory. VERIFY
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
was stored
stored correctly
correctly on
on tape
tape or
or disk.
disk.
gram
For
For disk
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
ference in
in program
program text
text are
are found
found,, the
the BASIC
BASIC error
error message
message ?VERIFY
7VERIFY ERROR
ERROR
is displayed.
displayed.
is
A program
') or
program name
name can
can be
be given either in
in quotes
quotes ('''
("")
or as
as a string variable.
variable.
v
EXAMPLE of VERIFY Command:
EXAMPLE
9000 SAVE ""ME",8
ME",B
9010 VERIFY ""ME",8
ME",B
(Looks at device B
8 for the program)
v
v
v
169
169
v
INDEX
INDEX
A
A
Abbreviations , BASIC
BASIC commands,
commands, 34,
34, 128-129
128-129
Abbreviations,
Accessories, 9-11
9.-11
Accessories,
,_
Addition, 33
33
Addition,
AND operator,
operator, 117
117
AND
_
Animation, 47-48,
47-48, 67
67
Animation,
Arit hmetic, Operators,
Opera tors, 33-34,
33·34, 117
11 7
Arithmetic,
Arithmetic , Formulas,
Formulas , 138
138
Arithmetic,
Arrays, 95-96
95-96
Arrays,
ASe function,
function , 126
126
ASC
ASC II character
character codes,
codes, 133-135
133-135
ASCII
—
B
B
BASIC
BASIC
abbreviations, 34,
34 , 128-129
128·129
abbreviations,
commands, 117-119
117-1 19
commands,
numeric functions.
functions, 33-36,
33-36, 124-126
124-126
numeric
operators, 117
117
operators,
other functions,
functions, 127
127
other
string functions,
functions, 126
126
string
variables , 42-44,
42-44, 116
116
variables,
Bibl iography, 152-153
152·153
Bibliography,
arithmetic, 69-70
69-70
Binary arithmetic,
Binary
Bit, 69
Bit.
Business aids,
aids, 103-105
103-105
Business
Byte, 69
69
Byte.
C
C
Calculations,
Calculations, 33-37
133-135
CHRS codes,
codes, 61
61,, 126,
126, 133-135
C
H RS function,
fu nction , 126
CHR$
126
CLR statement
119
statement,, 119
CLR,
E key,
CLR, HOM
HOME
key, 15
15
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
ES,
POKES,
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
itor, 1,9
TV/Mon
TV/Monitor,
Ca
NT command,
CONT
command, 117
117
Co
nTRol key,
ConTRoL
key, 16
16
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
D
D
Data, loading
loading and
and saving
saving (disk),
(disk), 17-'9
17-19
Data,
DATA stat
statement,
91,, 119
119
DATA
ement, 91
DEFine statement,
statement, 120
120
DEFine
Delay loop,
loop, 64
64
Delay
DELete key,
key, 14
14
DELete
DIMension statement,
statement, 96,
96, 120
120
DIMension
Directory, 20
20
Directory,
Disk drives
drives
Disk
commands, 18·32,
18-32. 163·169
163-169
commands,
error messages,
messages. 112-115
112-115
error
Division, 34
34
Division,
Duration,
(see For
For...Next)
45
Duration , (see
.. Next) 45
DX-64, ii
OX·64,
E
E
Editing
programs, 14-15,
14-15, 41
41,, 62
62
Edit
ing programs,
END stat
statement,
120
END
ement , 120
Equal, not-equal·to,
not-equal-to, signs,
signs, 117
117
Equal,
Equations.
33-37, 117
Equatio
ns, 33-37,
Error messages, App_
App. 8, App. L
Error
Executive 64
64
Executive
installation, 3
transporting, 5
Expansion port
port,, 1
1
EXPonent function, 125
Exponentiation, 34
F
F
v
(disk),
17-31
Files, (d
isk), 17·31
Files, (Rand
(Random
20, 26-29
Files,
om Access), 20,
Files, (Relative),
(Relative), 20,
20, 24-26
Files,
Files, (Sequential),
(Sequential). 20,
20, 21-24
Files,
21·24
FOR statement,
statement, 45,
45, 120
120
FOR
127
FRE functions, 127
Function
52
Fun ction keys, 16,
16,52
Functions,
Functions, 124-127
124·127
G
G
v
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
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,
Interface,99
IEEE-48
121
IF ...THEN statement,
stat ement, 121
IF...THEN
INPUT statement.
statement , 49-50,
49·50, 121
121
INPUT
INPUn, 30.
30, 122,
122, 165
165
INPUT#.
14
INSert key,
key, 14
INSert
INTege r function,
function , 53-54,
53-54 , 125
125
INTeger
In teger variable,
variable, 42-44,
42-44 , 116
116
Integer
110 pinouts,
pinouts, 139139· 142
142
I/O
1/0 ports,
ports, 11
I/O
JJ
Joysticks , 1.I, 10
10
Joysticks.
~
KK
Keyboard , 12-17
12-17
Keyboard,
m
Ll
LEFTS function,
function, 126
126
LEFTS
^>
function , 126
126
LENgth function,
LENgth
Less than,117
than , 117
Less
122
LET statement,
sta tement , 122
LET
,->
LI ST command,
command , 40,
40, 118
11 8
LIST
command, 18,
18, 118
118
LOAD command.
LOAD
LOGarithm function,
function, 125
125
LOGarithm
40, 45
45
Loops, 40,
Loops,
Lower case
case characters,
characters , 16
16
Lower
M
M
Mathematic
s, 33-37
33-37
Mathematics,
formu
las, 138
138
formulas,
function
function table,
table, 138
138
symbols,
symbols. 33-34, 36.
36, 117
Memory
37
Memory maps,
maps, 136·1
136-137
MIDS
function
,
126
MIDS function, 126
Multiplication,
Multiplication, 33
33
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
NEXT statement
statement,, 45,
45, 122
122
NOT
NOT operator,
operator. 117
117
Numeric
Numeric variables
variables., 42-44,
42-44, 116
116
Numeric
funct
ions,
Numeric functions, 124·126
124-126
^
„
^
o0
ON
ON statement
statement,, 122
122
OP
EN statement.
OPEN
statement, 19,
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
v
v
Pp
Packing Execu
Executive
64,, 55
Packing
tive 64
Parentheses, 36
36
Parentheses,
PEEK function,
(unction, 63,
63, 125
125
PEEK
Peripherals,
9-11,
30, App.
App. S
S
11 , 30,
Peripheral
s, 9POKE statement,
statement, 63,
63, 123
123
POKE
Ports. 110,
I/O, 1
1
Ports,
POS function
function,, 127
127
POS
PRINT statemen
statement.
32-38, 123
123
PRINT
t, 32-38.
PRINTtt,, 30,
30, 123,
123, 166
166
PRINT#
Printer commands,
commands, 3()'31
30-31,, App.
App. S
S
Printer
Programs
Programs
editing, 14·15,
14-15, 41
41., 62
62
editing,
line numbering,
numbering. 39
39
line
loading/saving (disk),
(disk), 17-19,30,
17-19, 30, 118,
118, 119,
119, 168
loading/saving
Prompt,, 7,
7, 49·50
49-50
Prompt
aQ
Quotation marks,
marks, 32-33,
32-33, 37
Quotation
U
R
R
RaNDom
function, 53-54,
53-54, 125
125
RaNDom function,
Random numbers, 53-54
READ sta
statement,
91,, 124
124
READ
tement , 91
REMark sstatement,
tat ement, 124
Reserved words,
words, (see
(see Command
Command statements)
statements) 116-127
116-127
Reserved
Restore key, 15
RESTORE statement,
statement, 124
124
RESTORE
Return key, 12
RETURN
statement, 124
124
RETU
RN statement,
RIGHTS
126
RIG
H T$ function, 126
command,, 118
RUN command
118
16
RUN/STOP key, 16
S
SAVE
30, 119,
168
SAVE command, 19,
19,30,
119, 168
Saving
(disk), 19
19
Saving programs (disk),
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
function, 125
125
SINe function,
Sound
effects, 89-90
89·90
Sound effects,
SPC
127
SPC function,
function, 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
function, 126
126
SQuaRe function,
STOP
STOP command,
command , 117.
117, 124
124
v
STOP
STOP key,
key , 16
16
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
32. App.
App. LL
Syntax error,
error, 32.
SYS
SYS statement.
statement, 124
124
v
v
173
173
-
T
T
TAB function,
fun ction, 127
127
TAB
TAN function,
func tion, 126
126
TAN
TI variable,
variable, 116-117
116-117
Tl
variable, 116-117
116-1 17
TIS variable.
Tl$
Time clock.
clock, 116-117
116·117
Time
TV
TV connections,
connections, 1.
" 99
U
U
mode, 16
16
Upper/Lower Case mode,
function, 126
USR function,
User defined function, (see DEF)
DEF) 120
User
V
V
function , 126
126
VALue function,
42·44, 116
116
Variables 42-44,
array, 95-96
95-96
dimensions,
dimensions, 96
poin t, 42-44,
42·44, 116
116
floating point,
integer, 42-44.
42-44, 116
116
numeric, 42-44,
42·44, 116
($1. 42-44,
42·44 . 116
116
string ($),
_
,-,
V ERIFY command, 30,
30, 119,
119, 169
VERIFY
VOice, 79-84
79·84
Voice,
^*\
W
W
WAIT command, 124
zZ
z·ao.
Z-80,
10
—
174
w
'-'
'-'
'-'
v
v
v
MEMO
MEMO
MEMO
MEMO
--
-
"
ECUTIVE 64
64 QUICK
QUICK REFERENCE
REFERENCE CARD
CARD
ECUTIVE
u
SIMPLE VARIABLES
VARIABLES
SIMPLE
v
,,__
R....
v
No",.
.. IB3E-3B
I UI ·)8
*~1101
1 70141
!. 2 938?]5e6SUe1UI8I - 30
)'
:?
«S
v
PO !o()( f
POS(X)
' 0,,(/"
1Il
XT
S33747
,ho'CK""
1*1
J( n
S""'<;I
0
0 la
' 0 35S
lH iMioctin
• " " ."" tA·!), y ., " 19... , o. " ..... tN.. (0- 9 ) ""',""ble ~O"'''
ee,.. be ...., •• _n 1 ,100. <><, ... . bu. _'" ' .... (,," , _ " •• 'Koo;I "
.."
ARRAY VARIABLES
VARIABLES
ARRAY
v
"~
~gl .
v
SHIFT
SHIn ClINHOMl
Ct ll/HOMI
Cliorl
CIoOft
SHIFT INSKDEl
ln,e"i
INSTiDEL
INSTIOfl
Dtlfiei
0..10, ..
C'BL
When
W~.n ."
,." .. ............... <010, h • .
•• 1. <, •
lelic'i
•• • , <010' ....... tHo .. ,od '"
lIl(iJ
XYISI
o",." M _
n eSS )
1",.. ·0."", " . _
XI (SSS)
X*(S.S.S)
*.here
.. 10.,. needed
... ..ci.,d
a"ii9'''P''''
A" a* I with more *non eleven element
,-
·"". n ,, ' od ... .. ~ n" ...... .. <010 ' ••• .
f".
3IM All.*
DIY.
At . V t.
t!
Seri
3»,mum
~" m
",,,
.. ,,,",,, lublir.ptl
. "b .. " .. " lor A
A
. ..... . >' ipote
, ..... . Io'
lo· !X
! ~·
,I · Y' I)'
I ' 11' "
■ I|*|Y*
'•text
. 1. .... .. 11
" UGFIing
,·" ... nQ
J< ~ I
IXII
V
• •".n ., number
.. " ... 10.' of
of chorotlfr!
, 00'oct.,. in
,n
Rtluin
R.lurn
R.' ",~,i nunwnc .alue
' 01 ... ot
01 X
...
KAllXi!
B,Wn
RELATIONAL AND
ANO LOGICAL
RELATIONAL
LOGICAL OPERATORS
OPERATORS
v
latl
t."
G_.,.•• , I,,,..
-
lEFTKAS
lIfT
~ A~ "k:
or equal
la
tIn)
.. , Than
r...... ".
I" ..... ' '"
... 1.",01 To
AN D 1090<,,1
AND
Log.:ol
BIGHTS!Ai
""COH
n A~
Renjrn'
V~'u ..... .ighfmniT X
~ (horailtr!
"" w'~' Y
''''''0<', ', c l
.,
INPUT/OUTPUT COMMANDS
INPUTfOUTPUT
I "Him
uo 0 ,I
.
il 10"
lolie
tOAO
NII.M! •B
IOAD "NAME"
INPUT A) .jB A
10<.<1
londi. ..
n "'''I/,om
o'ogram I..,...
from d,,
dill~
INPUT
S»E
NAWE
iovei
program '"
i« "
ilnl
!.It.It
NAoMI
.9 So
••• "a "'''9''''''
..,
VI RIIY N....Y! I ~,I, •• t~o ' "'''11'''' '' .. 0. WEd
ABC
PRINTi
1
on KIHK ond •.•].■! FQ
A
■nln
ualu*
Can olio INPUT Ai
GET A] (M A
'act*-' value,
''''''Oe''
.....".,
""
,.,
DATA
OAI
. ABC
AB C
RUN
BUN " .
( ' H"'~' "'<>\I'''~ " " ",~
co .. tHo
. .. by
b.
Be ...
Kied
~ IAD . ~
0' •
A" '\1" ' " f"
"1 5' 0 .. 1
Co",.~_.
I",~ ~ ~"
v
"'<>\1'0'" ~ . ... ", ... " 1'0'"
0'011'''''' 'w",
""I,."
PRIM
~!.
O HOTUWK1
" a ..... ~ " .
BEAD
DA' ....'". ' " A ~ O. A
..••• " do ' o ""'" '" '0 " ''''
BEADmg
rhe
",AO,n
g ,".
END
CO
NI
CONT
no PE'UPN
"<>
~II U "N needed
~ .... _"
, ... ,""" .. 0 •• , " • • ol~. , ' "0'
o. I.n.
5ro~
u
0< ••" ,,'
, .... '0< ••"
X, <
(ho-otwn
of A ~
.....
''9''''''''''
Xj
o
A~
otf AI
RUN
v
p.,,,......leftmoit
It...... "
Berurn' ,
.I. ,
too:;
a 'I
Or'
'09
....
0.
( . ... ........ ""uOI,
EifHIIMn
tauoli II
v
" '"''' ' ' ' o. H
WDJlAJ » '■
..
""
AnO
SYSTEM COM
MANDS
COMMANDS
v
f.".
<ltd . . ....
thorot er if XI
G'.",.< I~ .. n
OB
OR
..
,x
D. ,w'''' ASCII
Thnn
1
......
N O'
NOT '09",,1
logical "Nor"
v
ed lo a 11-mg
, numeric .alv» ol Ai. uc
r.,,i nc nnUWer:c cha.a^ie.
CHBJlXI
~
X~
""m.'.e
Sl ~ ~ (
STRilX,
ton.er
v
al
AlO.O
Ol
o .....
000)
tirmc
liN
LEN
Addition
..
unplav mode
•• f• • ', OO"OnOI •• ,t ,010'
Divilicn
•
on"
"""lay"""',
STRINGS
ARRAYS AND STRINGS
(.""" "..
NoJ< ~ .. a''''.
.'
""po.IIo- •• co ••
tHo ...... "
rfi !iubitr.D.i 0-10) con be uied
ALGEBRAIC OPERATORS
OPERATORS
ALGEBRAIC
...
<"","',•. ," e.." .~' <.... ~
tn uiea -v.ih SHIFT itlf
.It"","" I' u",,, ,,,," 0-101 <O n be u" "
",,".>...... .....to ,100" . .... .. ....... , ,, need ' "
1>0 O''''o",oon OO
v
<"..... ,n
. " .." OnO """' ••
PRINT
I ..·o · (), .... .. . _
ul> '"
v
I . ....... <"" 0'" .... _ "". _
"',,,_ • • " ..... ' 0 Io~ ....... . Of
N o",.
Arrayi
...,,"" a*
0 1 gp to eleven
. I. ... ~ vi
u
CIK/HOME
CtlI/HOM!
A -
A
DAIA I,,,
DAlA
"g"'"
PBINTi
ilr.r.9
A""'
NII ""
"\1 A
" .... VOl". 0) A
'ob. dC'a
V..".~. 'O,,'.n!. ,,/ "'. ""'....
PROGRAM FLOW
,M ■ V
SY5 HJUJU
.....
AII
WAIT
~
T 1
X.1.Z
Jl ■mp*
ro..i cull
~
~
... " l(Oiled
O R." ~i«i
_. , lI and
.hen
AHOed ... .,,, T
U~I (~ !
It
Brnnthei 'o lin> X
I'If A-3
A ~ l 'THEN
..! N 10
tHEN
..IF 0aiietion
........ " .,is "Irun
... '''
IN "" vl_
'oIIo ~ "'1I I>On 0' . ' 0 .. ...... ' I'
IP
lFOR
OR A
-I '0
A-l
TO 10
Io
... w••• "oil• •naitmenii
' 0 ' . ........ between
b<o' .... . ~ 'Ft0 "
[nduiel
STfP
~U. 2
and in»etpanding
MIXT.
,,""
eD"''''''~d....., NU
l w.rh
""~ A
ol
no
P' ogra m. "
0'<>\1''''''
" "Fling
"'9 0'
'A' "
""'iI'0'" ~o;" _ . e_ ' .. ~" 0'
.... ... "'''
v
a ' hoc hint
GOTO X
" _ ' ~ 'O
." " . , .... "" 01 X ...
° _~
1
NEXTl
NU
v
TAB(X)
v
v
v
v
SPCIX
SF"C(X))
pit ig'or
Ilull
.. •••1 ■Mire
n' " . "'<>\1'0,",
lull 1 ,om U. A
line
I.,,,
. IB
A ...
io ~"
f."........
C_...' ..... _
,0" bo
, '00<"''''''
PRINT i X alar
111 or lin*
,If,•.;
by 1
2
t>y
Sipd
nze
St.
" ""
"ft"
end 01
of ioo<>
loop
091",
... .
Define,
GOSUB 1ODO
1000
G05Ue
Bionthe.
io .lubrouime
i.oimg
B'
o,,<~. '0
"b'ow''''~ """
"9 '"oi
L"." bon
S....... )(
>mn
Io 10
10
'0
••
A n,
0optional
..........1
l.ii. 2O00
in PIII
PRINT
iron
U»d
V
.." ."
NT "0
.. .... " "
DO1H»
from ,I
f."",,
H(.l
NEXT A
A
BETURN
,..(,*
md
di» ing p rogram
••
'1;1 .....
. " ""'''111>'<>\1'0'''
"","",n. _ ", •••"
"".. ",,"'bo.
A
aomg
9""'9
'-"9.... \1 • • " b,own ••
US
LISTT
UST
LIST A,
a IB
~."
.. I .. ~ .........
EDITING AND FORMATIING
FORMATTING COMMANDS
v
'0 ... " "'''''
Uarki end gl luhroutinr
Returni i
GOSUB
GDSUfl
iimwIiei
ON X GOTO A B
B'onchet to Xth line number on
ill
II X = I
bfonin*i m A. etc
ON X GOSUB A.B Bronchei 10 tubroulm* ot xth ling
Get th
e most out of your Commodore computer with a subscription to
the
Commodore's
Commodore's user magazines
; 0 ,. , '
a ........
POWERtPLfif C' commodore
Fun, Gam
Games
Commodore
es and Beyond with Commo
dore
Computers
e rs
Home Compul
Publisl
in ,\I.l
Mart
h.,
Puhl"hcd
qu,trt",hV III
f t 11
Th
e Micro
comput e r Ma
gazin e
The
Microcomputer
Magazine
lurii1 , '>I'lllt'mllt"
her .111111
.inif [)i
JUII"
)"1 ",.,lh'l
,COUTH
'( )\\'[1{
WAY.
P
....w ,.. devol,'d
oted '4111,1,
ilely lollh'
ii» Hi 1 "~
t'\illlll1
itnii;
g ,md
i
f.Jprdl\
\\wld
Ik 1"p.lIlrilJl):
exp.u
riel ,,'
ol
(. omn
re h'lIIlt'
hiii i' (wnp
t ompul
nj;.. It prn\,IIII',
provi
Commodore
ulmg
I,rl u.rlll!i.ible nHllJfI1"tll
ml
i mOIl
in • in Ill'W
new
produ h .•Ipplll
pplk ,lt Ullh
Ktlls,, g.UIlt".
("dill ■s, Iprogram
pHJclu\
'HIgr,Illlllllr rt: 1.,\ h"II III'<' h ·,U IIII'):',II.
iuiil-.ll-
1111.,,,,,,
FILL OUT AND MAIL TODAY
GET MORE INFORMATION FOR YOUR MONEY
Plea se sign
~ i gn me
m e up for:
for :
Please
Phone
City
Ci ty
__
yea r (~) ol
01 POWER/PLAY
POWER/PIJW a)
at •>!().(X)/year
Sm.OD/year
_ycar!s)
o
Io]
Io)
_
yc ar (~) of
of COMMODORE
CO,\lVv\ODOR[ at
,"II 515.00'year
S15.OOIyear
_year(s)
l ip
Zip
Sial e
Stale
Compul e r model:
model:
Computer
_ _ __
_ _ _ _ _ _ _ _ _ _ _ _ __
i ] Address
Addres~ Change.
Change . Enter new address
dtkJ r c~~ above
.IUUVl.' &
&. enclose
cn du ~c
)
1I11011l
ll.llllllll)l\
)( lun'
'. p,ogl
,ullmlllg
" hlllljUt"
tiW,lrt'
irmation
on (olllm.
( i
lore 'r'h'II1
systems.
proi;rjnv
linj; I.
lc(
hni(|iies,. h.H
h.trdwiiie
mlt',■Mac
r.lt Itlg
Uld .Ipplrt
IllI" \\liI.·
mg. ' 0 >l1 (( '>1111111.11.11,,',
ing..•and
j
ilii .111(11"
,1 inns hll
tor tile
\miIi1 ••
r.inj>e
oinmiidure s pI"du,
pnidui h
Is
l .1I h '''lit"
l" 01
. In\"'1\" Ih.ll
Ihmklng
issue1t IInl,IIII'
ontiiin "',lItH
ires
ot inli-rest 10
loanyon
tti.it U'I·'
use . , )1 I' thinking
.,huul
g (IUl
HIlOdllr\'
'ljUlplllt'1l1 (.
,-1 lh<lilt' lIlo,1
roul 11111
U'
nit pllll
pun h.hlJl
hasin;;
( onit
indorc lr(]in|>mi>nl
del
musl nul
nut III
ol your
nm Irt>I 11lI1p"I.·,
lipiltt'l \\
with
Ilh ( IInHmldmt'
(iKlill
"' pricf
plllt' SI.,.I
iiirc 'l.1.'g.ll1l1t"
M.iga/ini' -'lIlhl
Sulisi Oplll
tiption
^Ti.lHI \t',lf
vcir
Address _ _ _ _ _ _ _ _ _ _ _ __
Address
)
Ill"
mtllllhh IJUI,t.(,l1l1)1l
ft)vldl ', .r,1 \1·h"ll·
this 1,,·
bi-monthly
\n
)n p
provides
whidf h
t i'
it ,h.lling
sh.inil^ ,·"IU'IVI·
exclusive p"I<IU(1
product
tome, t dl'~I)"'IllLJllIl
nu.iMon
nd 11I
just
hUIIlI.',
,l tllm' ,1IIe!
.. r .ilxii
,llxlut .1I1\lh,I1':
" hrlln,iifl 1·1,,·
else ( Ioul1rn'I(I."
inlort'
h(imi
torn pi
cd tu
In km
lurnput
l' f [I .. ,'" nl'l'd
k llll\\' It) ).:1'1 1Il,l\IIIIIIII1\'I1I"\ rllt 'llI "u tili
" "
! ol rh
their
hurni
pn e: S
'-.in
(HI \I , ',tr
hunw IOlllpullng \"IWfWllt " '>uthillptlll!l pllt"
HI IMI
Name
Name
)
\Vl t t,'lv 1I',ul
lh "'IIl"1l siuden
,lud,'llhs ,lIltl
I" " ,I, .
huMiifssmiTi.
Widely
read 11\
liv ",luI
ed ,11"" -.. hU"
,tii(l 111111H'
liiimi-i, IJII'I,.,
unipiittTisls.
present
present mailing
mailing label
label
Renewal
Ren ewa l subscription
sub scription
')
)
I:ncloscd is
is my
my check
chcck or
or money
m o ney order
o rd er for
for $S _ _ __ __
Inclosed
Make check
ch etk or
or money order
ord er payable
payablc to:
10:
COMMODORE BUSINESS
BUSINESS MACHINES, INC.
COMMODORE
Meadows, 487
487 Devon Park
Pi,k Drive,
Drive, Wayne,
Wayne, PA 19087
19087
The Meadows,
New
New subscription
subscrip tion
)
Ca nadian and
and Forci
gn : POWER/PLAY$?5.00/year;
POWER/PI.AY S1S.00lyca r; COMCOM·
Canadian
Foreign:
S2S.00lycar
MODORE $25.0Qtyear
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
(i
(i
(i
n
-
COMMODORE SALES
SALES CENTERS
CENTERS
COMMODORE
v
v
Commodore
Commodore Business
Business Mochines,
Machines, Inc.
Inc.
1200 W;lsan
Wilson Dr;ve
Drive
1200
Westchester, PA
PA 19380,
19380, US.A.
U.S.A.
WeSichesler,
Commodore
Commodore Business
Business Mochines
Machines Ltd
Ltd..
3370 Pharmacy
Pharmacy Aven
Avenue,
Agincourt,
3370
ue, Ag;ncaurl,
Ontario, MIW
M1W 2K
2K4,
Canada
Onlar;o,
4 , Canada
v
Commodore
Commodore Business
Business Mochines
Machines (UK) Ltd.
Ltd
675 Ajax
Ajgx Aven
Avenue,
Trading Estate,
Estate,
675
ue, Trading
Slough Berks,
Berks, Sll
SL1 4BG
4BG,, England
England
Slough
Commodore Bueromashinen GmbH
Lvonerstrasse 38,
38, PO
PO BOX
3OX710126
lyonerslroSSe
710126
Frankfult
6000,
West
Germany
Frankl ull 6000, WeSi Germony
Italiana S.R.L.
Commodore Itoliana
Via
Conservatoire 22
22
Via COnservQlorio
Milano
20122,
Italy
M
;iono 201
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
v
v
Commodore's SX-64 computer is portable, powerful, and versatile.
The SX-64 has all the capabilities of the best-selling Commodore 64,
plus a built-in disk drive and a 5" color monitor. The SX-B4 snaps
together to form its own carrying case, and it's light enough to carry
and use anywhere.
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.
For additional programming information, consult the Commodore 64
Programmer's Reference Guide and the Commodore Peripherals Guide,
available from your bookstore or Commodore dealer.
ft commodore
COMPUTER
P/N 251249
Printed in Japan
">
/
Downloaden
Even een vriendelijke herinnering. U kunt het document hier bekijken. Maar het belangrijkste is dat onze AI het al heeft gelezen. Het kan complexe dingen in eenvoudige bewoordingen uitleggen, uw vragen in elke taal beantwoorden en u helpen snel te navigeren, zelfs in de langste of meest ingewikkelde documenten.
Advertentie