Download as pdf or txt
Download as pdf or txt
You are on page 1of 208

T _ 5 _

1. ^ 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
Downloaded from www.Manualslib.com manuals search engine
USER'S
USER'S GUIDE
GUIDE STATEMENT
STATEMENT
"This
" This equipment
equipment generates
generates and
and uses
uses radio
radi o frequency
frequency energy.
energy. If11 itit is
is not
not pro
pro-
perly
perly installed
instal led and
and used
used in
in strict
strict accordance
accordance with
with the
the manufacturer's
manufacturer's instruc
instruc-
tions,
tions , this
this equipment
eq ui pment may
may interfere
interfere with
with radio
rad io and
and television
televisi on reception.
reception. This
This
machine
machine has
has been
been tested
tested and
and found
found to
to comply
comply with
with the
the limits
limits for
for aa Class
Class BB
computing
computing device
device in
in accordance
accordance with
with the
the specifications
specifications in
in Subpart
Subpart JJ of
of Part
Part 15
15
of
o f FCC
FCC Rules,
Rules, which
which are
are designed
designed to
to provide
provide reasonable
reasonable protection
protection against
against
such
such interference
interference in
in aa residential
residential installation.
installation . IfIf you
you suspect
suspect interference,
interfe rence , you
you
can
can test
test this
this equipment
equipment byby turning
turning ifif off
off and
and on.
on. If11 you
you determine
determine that
that there
there is
is in
in·
terference
terference with
with radio
radio or
or television
television reception,
recept ion , try
try one
one or
or more
more of
of the
the following
followi ng
measures to
measures to correct
correct it:
it :
•• reorient the
reorient the receiving
receiving antenna
antenna
• move
move the
the computer away
away from
from the
the receiver
receiver
• change
change the
the relative positions
pos itions of
of the
the computer
compute r equipment
eq uipment and
and the
the receiver
rece ive r
• plug
plug the
the computer
computer into
into aa different
different outlet
outlet so
so that
that the
the computer
computer and
and the
the
receiver are
are on
on different
different branch
branch circuits.
If necessary,
necessary, consult
consult your
yo ur Commodore
Commodore dealer
dealer or
or an
an experienced
experienced radio/televi
radio/televi-
sion
sion technician for additional
additional suggestions.
suggestions. You may
may also
also wish to consult
consu lt the
following booklet,
booklet, which was prepared byby the Federal
Federal Communications
Communications Com-Com-
mission:
mission:
"How
" How to
to Identify
Identify and Resolve Radio-TV
Radi o·TV Interference Problems"
Problems" This
Th is booklet
is available from the U.S. Government Printing Office,
Office, Washington.
Washington, D.C. 20402.
20402,
Stock No. 004-000-00345-4."
004-000·00345·4."

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
-

TTHE INFORMATION IN
H E INFORMATION IN TH
THIS MANUAL HAS
IS MANUAL HAS BEEN
BEEN REV
REVIEWED AND IS
I EWED AND IS BELIEVED
BELIEVED TO TO BE
BE ry
ENTIRELY
ENTIRE RELIABLE.
L Y RELI ABLE , NONO RESPON
RESPONSIBILITY, HOWEVER, IS
SIBI LI TY, HOWEVER, IS ASSUMEO
ASSUMED FO
FOR fNACCURACIES.
R INACCURACIES.
TTHE
HE MMATERIAL
AT ERIA L IIN THIS
N TH MANUAL
IS MAN IS FOR
U A L IS FOR INFO
INFORMATION PURPOSES
RMA T ION PUR ONLY, AND
POSES ONLY, AND IS
IS SUB
SUBJECT
JEC T
TO CH ANGE WITHOUT NOTICE
TO CHANGE WITHOUT NOTICE. __

THIS
TH MANUAL IS
IS MANUAL IS COPYRIGHTED
COPYRIGHTED ANDAN D CONTA
CONTAINS PROPRIETARY INFORMATI
INS PROPRIETARY INFORMATION. NO PART
ON . NO PART OFOF
TTHIS PUBLICATION
H IS PUB LICA TI ON M MAY BE REP
A Y BE REPRODUCED,
RODUCED, ST STORED
O RED ININ AA RE
RETRIEVAL SYSTEM,
T R IEVA L SY OR TTRANS
ST EM, OR RANS·
MMITTED
ITT ED IIN
N ANY ANY FORM
FORM OR
OR BYBY ANY
ANY M MEANS.
EANS, EELECTRONIC, MECHANICAL,
L ECTRON I C, MECHANICA PHOTOCOPYING,
L , PHOTOCOPY I NG,
RECORDING OR
RECORDING OR OTHERW
OTHERWISE. WITHOUT
ISE. WIT THE
HOU T TH PRIOR
E PR WRITTEN PERMISSION
IOR WRITTEN PERMISSION OF OF COM!\10DORE
COMMODORE
BUS INESS t\.l
BUSINESS ACHINES, INC
MACHINES. INC ^

Copvrigh!©1983
CoPV by Commodore
r ighl© l g83 bv Commodore Busin
Business Machines.
ess Machi nes, I Inc
nc
All
All ngh ! s reserved.
rights reserved.

Downloaded from www.Manualslib.com manuals search engine


v
v
v TABLE OF
TABLE OF CONTENTS
CONTENTS
v CHAPTER 1
CHAPTER 1
v SETTING UP
SETTING UP
v Unpacking and
Unpacking and Setting
Setting UpUp the
the Executive
Executive 64 64 Computer.
Computer . . . . • . • . . . . . . . . .. 33
Transporting the
Transporting the Executive
Executive 6464 . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . 55
Troubleshooting chart:
Troubleshooting chart: Executive
Executive64 64 . . . . . . . .. ......... ... .•.• ...... 66
Color Adjustment.
Color Adjustment . . . . . . . . . . . . . . . . . . . . . .. .. ...........•. • . . .. 77
Expanding Your
Expanding Your System
System With
With Optional
Optional Peripherals
Peripherals . . . . . . . • . • . • . . . . . . . 99

CHAPTER 2
GETTING STARTED
Communicating with your your64: Keyboard . . . . . . . . • . . . . . . . . . . • . • . . ..
64: The Keyboard 12
12
Loading and Saving Programs
Loadi ng and Saving Programs. . . . . . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . .. 17
17
How to Load
How Load Prepackaged Software . . . . . . . . . . . . • . . . . . . . . • . • . . . . . . .. 118
B
How to Format
How Format a New
New Disk . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . . . . . . .. 19
19
How to Save Programs.
How Programs . . . . . . . . . . . . . • . . . . . . . . . . • . • . . .. 19
Listing
Li Directory of Programs on a Disk
sting a Directory Disk . . . . . . . . . . . . . . . . . . . . .. 20
Files
Files. ............................. . . •... . . ...• . • . . . . . ... 20
Sequential Files ............................•......... .. . .. .... . 21
Files
Relative Fi les ...........................................•.•.... 24
v Random Access File ...................... . . . . . . . . . . • . • . • . . .. 26
Chart of BASIC Commands for Disks and Printers. Printers .. . . • .• . . . •. .• . . .. 30

CHAPTER 33
BEGINNING BASIC
Printing and Calculating . . . . . . . . . . . . . . • . . . . . . . • . . . . . . . . . . • . . . . . . .. 32
Mathematical Functions ........... ... . . . .. . .. .. ..•...... . ... . ... 33
Multiple
Multiple Calculations
Calculations onon One Line
Line .............. . . . . . •.. . . ... .• .•... 35
Execution
Execution Order in Calculations
Calculations . . . . . . . . . . . . . . . . . . . . • . • . • . 36
36
Combining PRINT'S
PRI NT' s Capabilities
Capabilities .....• . . . . ... . ....•. •. .... . ........ 37

v CHAPTER 4 4
WRITING SIMPLE
SIMPLE PROGRAMS
PROGRAMS IN
IN BASIC
BASIC
Line
Line Numbers
Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . .. 39
39
The
The GOTO
GOTO Statement
Statement . . . . . . . . . . . . • . . . . . . . . . . . . . . • . . . . . . . . . . • . • . .. 4040
Using
Using the
th e LIST
LIST Command
Command ... . . . . . . . .. . . ... . . . . • . .. . . . •.• . ........ 40 40
Editing
Edit ing Tips
Tips. ...... .......•..............•....... ... . ....... 41
41
How
How to
to Use
Use Variables
Variables ........... ..... . . . . . • . . . . . . . . . . . . • . .. 42
42
Using
Using FOR...NEXT
FOR. .. NEXT Loops
Loops .. ...• . . . . .... . .• .•.• . . . ...... . • . ..I...... .. .... 45
45
v
v

Downloaded from www.Manualslib.com manuals search engine


CHAPTER 55
CHAPTER
ADVANCED BASIC
ADVANCED BASIC
Introduction
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . 46
46
Simple
SimpleAnimation
Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . . . . . . . 47
47
INPUT
INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . ... 49
49
Using
Using the
the GET
GETStatement
Statemen t for for Data
Data Input
Input. . . . . . . . . . • . . . . . . . . . . 51
51
Using
Using GET
GETto to Program
Program Function
Function Keys Keys ................•. • ....•. • ..... 52
52
Random
Random Numbers
Numbers and and Other
Other Functions
Funct ion s ..... . . . ..•.. . ... . .• . •. . . .... 53
53
Guessing
Guessing Game
Game . . . . . . . . . . . . . . . . . . . . . . . . ............ 55 55
Your
Your Roll
Roll .. . ...... ... ..... .. ..... . ...... • . ... .. .. . . . .•... . ..... 56 56
Random
Random Graphics
Graphics . . . . . . . • . • . .. . . .. . . . . . • . • . . . .. . . . . . • . . . . . . . . . .. 57
57

CHAPTER 66
CHAPTER
COLOR GRAPHICS
COLOR GRAPHICS
How
How to
to Use
Use Colorand
Color and Graphics
Graphics on
on YourComputer
Your Computer . . . . . . . . . . . . . . • . . . 58
58
Printing
Printing Colors
Colors . . . . . . . . . . . . . . . . . . . . ........ . 59
59
ColorCHRS
Color CHR$ Codes
Codes. . . . . . . . . . . . . . . . . . . . . .. ....... . • . . . . . 61
61
How
How toto Use PEEKS
PEEKs and and POKEs
POKEs. . . . . . . . . . . . . . . . . • . • . . . . . . . . . . 63
63
Screen Graphics
Screen Graphics. .................•............•.. . 64
64
Screen Memory Map
Screen Memory Map . . . . . ......•...•.•......•...•......... . 65
65
Color Memory Map
Color Memory Map . . . . . . . . . . . . . . . . . . • . . . . . . . . • . . . . . . . . . . • . . . . .. °6
66
More
More Bouncing
Bouncing Balls
Balls . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . . 67
67

CHAPTER 7
INTRODUCTION TO SPRITES
Bits, Bytes
Bits, Bytes and
and Sprites
Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . • . • . • . . . . . . . . . . .. 69
69
Creating Sprites
Creating Sprites . . . . . . . . . . . . . . .. . . . . ........• . •. . ......• . • . .. 7?
72
More on Sprites: Colors and Extra Movement . . . . . . . . . . . . . . . • . . . • . . . .. 78

CHAPTER 8
MAKING MUSIC ON YOUR COMPUTER: FOR
NON-PROGRAMMERS
NON·PROGRAMMERS
Structure of
Structure of aa Sound
Sound Program
Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . .. 79
79
Sample Sound
Sample Sound Program
Program . . . .. .. . . . .• .. .•. .. . . . . .•.•. .. . . °^
85
Playing aa Song
Playing Song on on Your
Your 64
64 .. .. .. .. . .. .. .. .. .. . .. .. .. .. . 87
87
Creating Sound
Creating Sound Effects
Effects . . . . . . . . . . • . • . . . . . . . . • . . . • . . . . . . • . • . • .. "
89

CHAPTER 9
CHAPTER
ADVANCED DATA
ADVANCED DATA HANDLING
HANDLING
READ and
READ and DATA
DATA Statements
Statements . . . . . . . . . . . . . . • . . . . . . . . . . • . . . . . . . . . . 91
91
Calculating Averages . . . . . . . . . . . . . • . • . . . . . . . . • . . . . . . . . . . . . .
Calculating Averages. 93
93
Subscripted
Subscri Variables ............ .. . . . ........•. . ............
pted Variables 95
95
Dimensioning Arrays
Dimensioning Arrays . . . . . . . . . ......•. 96
96
Simulated Dice
Simulated Dice Roll
Roll with
with Arrays
Arrays. ..... ....•... .... .. . 97
97
Two-dimensional
Two- Arrays.
dimensional Arrays . . .... . . . . . ..... .. . • . • . .. . .. . . • . • . .... "
99

Downloaded from www.Manualslib.com manuals search engine


APPENDICES
Software ..................•......... .•.•.. ...... . . . ... 103
Available Software 103
Description
Descripti of DOS
on of DOS Error
Error Messages
Messages .....•. • . • . •.• .. . . .. • . • .. . . . .... 112 112
Executive 64 BASiC
Executive BASIC ...... ......... . ............ . ..... 116 116
BASIC Keywords
Abbreviations for BASIC Keywords . ............. . 128
. ... 128
Display Codes
Screen Display ........ .......•.•.. 130
. . . .... 130
CHR$ Codes ......... ... ......... • .•... . ........ . ..... 133
ASCII and CHR$ 133
Memory Maps
Screen and Color Memory Maps ...... . .. . •.• .•. •. • . . •...•.. . •.. ... 136 136
Deriving
Deri Mathematical Funcl
ving Mathemalical Functions
ions ....•.......................•..... 138 138
Pinouts for Input/Output
Pinouts Input/Output Devices
Devices ......... ....... ........ ..... . ..... 139 139
Programs to Try ..................... .... . ........ ...... .. 143
BASIC Programs to Executive 64 BASIC
Converting Standard BASIC BASIC ......•. .... 146
Messages .............. .... ............................... 147
Error Messages
Values . . . . . . . . . . . .
Music Note Values. .......... . ...... 149
Bibliography . . .
Bibliography. . .............. .. • .• .•.• . •.. ..•.• .•.• .. . .... 152
Register
Sprite Regi ster Map . . . . . . . . . . . . . .. .•.•.•.. . . ...•... . ... 154
Register
6566/6567 (VIC-II) Chip Regi ster Map . . . . . . . . . . . . .. . . ........•..... 157
Executive 64 Sound Control Setti Settingsngs ................. . ..... • .•• . ... 158
Device(SID)
6581 Sound Interface Device (SID) Chip Specifications ... . . . . • . • . . • .. .. 161
Disk and Printer Commands and Statements . . .. . .. . ......... • ..... 163

INDEX .... .. . . . . . . . .. . .... .. .. .. . . . . . .. .. .. . .. . . . . ... . ... ..170


no

Downloaded from www.Manualslib.com manuals search engine


-

()

f.1

()

n
n

Downloaded from www.Manualslib.com manuals search engine


v
v

v INTRODUCTION
The Commodore Executive
The Executive 6464 is one
one of the best
best values in the home com·com
v
puter industry. You can use use your
your 64K color
color computer
computer for for everything from
v business applications to household paperwork to excit exciting games. The 64 offers
ing games. offers
(64K), lots of color
you lots of memory (64K), color(16
(16 different colors), lots of sound (music
v prepackag
and sound effects), and lots of fun and practical uses. You can use prepackag·
easy-to-learn BASIC.
ed software, or you can write your own programs in easy·to·learn BASIC. All
software designed for the Commodore 64 on disk or cartridge also runs on the
Executive 64.
Executive
v
Executive 64 models (the SX-64 and the DX-64)
The Executive DX-64) have all the capabilities of
selling
the best sell ing Commodore 64, plus one or two disk drives and a 5" color
monitor bubuilt-in. Executive 64 snaps together to form its own carrying case,
ilt·in. The Executive case,
and it's light enough to carry and use anywhere.
easy-to-read user's guide contains all the information you need to set up
This easy·to·read
v
properly,
your equipment properl DX-64.
y, understand how to operate your new SX-64 or DX-64,
how to create your own simple BASIC programs.
and learn how
This user's guide is intended to introduce you to computers, but it is beyond
v the scope of this manual to tell you everything you need to know about com· com
puters or about BASIC. However, this guide does refe referr you to a variety of
v
publications that explain the topics we present here in more detail. These
v publications include the Commodore 64 Programmer's Reference Guide and
our Introduction to BASIC series.
v For those of you who don't want program,, you won
wan t to learn how to program won't't have to
whole book to learn how to use Commodore prepackaged
search through the whole
v games, or other prepackaged,
programs and games, prepackaged, third party software. We've put all
the information you need to know right up front in Chapters 1 1 and 2.
2.

SPRITE GRAPHICS
Many exciting features are waiting for you inside your Executive 64. Your
Your
new computer gives you the microcomputer industry's most advanced
v graphics, which
graphiCS, which we call
call SPRITE GRAPHICS. Sprite graphics let you:
SPRITE GRAPHICS.
• Design your
yo ur own pictures
pictures in different colors, just like the ones you see on
arcade-type
arcade· type video games.
games.
o Animate
Ani mate as
as many as 88 different
differe nt overlapping sprites
sprites at once.
• Double a sprite's size.
Double a sprite's size.
• Move
Move your
your creations anywhere
anywhere on the the screen.
o Pass
Pass images
images in in front
front or
or behind
behind each
each other.
other.
• Use
Use automatic
automatic collision
collision detection
detection that
that tells
tells the
the computer
computer toto do
do whatever
whatever you
you
want
want when
when sprites
sprites touch
touch each
each other.
You
You can
can use
use these
these features
feat ures to
to write
write games
games and
and educational
educati onal software.
software. In
In addi
addi-
tion,
tion, you'll
you'll see
see sprites
sprites used
used inin the
the preprogrammed
preprogrammed software
software you
you buy
buy from
from Com
Com·
modore.
modore.

v
v

Downloaded from www.Manualslib.com manuals search engine


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).
•• AA 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
the 64
64 computers
computers let
let you
you connect
connect your
your audio
audio output to
to almost any high·quality
high-quality
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 byby connecting
connecting your
your Executive
Execu tive 64 to
to other pieces of equipment,
equ ipment, known
as
as peripherals,
peripherals, which
which include
include accessories
accessories like
like these:
these:
•• The
The VIC-1541
VIC·1541 disk
disk drive
drive (as many as five at aa time).
ti me).
•• The
The VIC
VIC 1525,
1525, 1526,
1526, and MPS·801
MPS-801 dot matrix printers,
printers, and the 1520
printer/plotter,
printer/pl otter, for
for printed
printed copies of your programs, letters, etc.
programs, letters, etc.
•• The
The 1600
1600 VICMODEM for access through your telephone to the massive
databases of
of larger
larger computers, services of hundreds of specialists
computers, and the selVices
and aa variety
and vari ety of
of information
information networks.
•• The Commodore 1701/1702
The 1701 /1 702 color monitor.
monitor.
•• The
The Z-80
Z·80 microprocessor,
microprocessor, for access to CP/M"
CP/M * *,, which offers a variet
variety ap
y of ap·
plications software.
plications software.
Commodore wants you to really enjoy your new Executive 64. As you learn,
bear
bear in
in mind
mind that
that programming takes time to learn. Be patient with yourself as
you go
you go through the USER'S
USER'S GUIDE.
GUIDE. Before you start,
start, please take a
a few minu tes
minutes
to fill
to fill out and
and mail in the owner/registration
owner/registrati on card that came with your computer
computer.
This
Thi s will ensure that your new computer is properly registered with Com·
Com
Headq uarters and that you receive the most up-ta-date
modore Headquarters up-to-date information
information
regarding future
regarding fut ure enhancements
enhancements for
for your
your system.
system.

NOTE: Many programs are under development while this manual


NOTE: manual is
is being
being pro·
pro
duced. Please
duced. Please check
check with
with your local Commodore dealer and with Commodore
Commodore
User's Magazines
User's Magazines and Clubs, which wi ll keep you up·to·date
will up-to-date on
on the
the many
many ap·
ap
plications programs
plications programs being
being written
written all
all over
over the
the world
world for
for the
the Commodore
Commodore 64
64 and
and
Executive 64.
Executive 64.

•Commodore 64 and
·Commodore 64 and Executive
Executive 64
64 are
are trademarks
trademarks of
of Commodore
Commodore Electronics
Electronics
Ltd
Ltd..
.. CP/M is
**CP/M is a
a reg istered trademark
registered trademark of
of Digital
Digital Research
Research,, Inc.
Inc. Specificat ions are
Specifications are
subject to change.
subject to change.

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
1
CHAPTER 1
SETTING UP
• Unpacking and Setting Up the Executive 64 Computer
• Transporting the Executive 64 n
• Troubleshooting Chart: Executive 64
• Color Adjustment
Expanding
• Expand ing Your Systems With Optional Peripherals

RELEASE
BUTTONS

()

GAME CARTRIDGE AUDIO/VIDEO


AUDIO/ VIDEO SERIAL USER
PORTS
PORTS PORT CONNECTOR PORT PORT POWER SOCKET

FUSE
POWER
SWnCH

Downloaded from www.Manualslib.com manuals search engine


STORAGE ISX-64
ISX-64ONLY}
O.'#L"I
STORAGE
-
MONITOR
MONITOR
CONTROL PANEL
ROLPANEL
CO NT

DISK DRIVE

aiSK DRIVE
HANDLE
HANDLE LIGHT
lOC
LOCK
I(
HINGE

I- --
S" COLOR
MONITOR

v O_BAS
KEYBOARD-TO-BASE
E
KEYBOARO-T
CONNECTOR
CONNECTOR

BASE_TO.
KEYBOARD
CONNECTOR

Downloaded from www.Manualslib.com manuals search engine


UNPACKING
UNPACKING AND SETTING
SEITING UP
UP THE EXECUTIVE
EXECUTIVE 64
COMPUTER
COMPUTER
Remove
Remove your
you r Executive
Executive 64
64 carefully
carefully from its
its packaging.
packaging. Inside you should
should
find these
these items:
• The
The Executive
Exec utive 64
64 computer
computer
'• A black carrying
carryin g case that contains
con tains two white boxes.
boxes. One box contains aa
power cord:
cord ; the other
other contains aa smaller
smaller cable
cable for connecting the
the keyboard.
keyboard.
If
It any
any of these items is missing
missi ng when you
you first unpack your Executive 64,
contact
contact your
you r dealer
dealer immediately
immediate ly for replacement.
Before you
you begin
begin setting up your
you r Executive
Exec utive 64 for the first time, take a few
minutes
mi nutes to examine the diagrams in this
thi s section. Look over your computer,
yo ur computer,
noting the locations of thethe outlet, called
cal led ports,
ports , where peripheral devices are
are
plugged
plu gged into the
the computer.
computer. Note the ON/OFF switch, switch, the
Ihe power cord outlet,
and the handle
hand le locks. This
Th is examination
examinat ion will simplify
simplify the set up
up procedure.
Follow
Foll ow these instructions each time
tim e you set up up your Executive
Exec utive 64:
1. Stand the Executive
Exec utive 64 on its end
en d so that the front of the computer and the
the
handle are on top.
top.
2.
2. Unlock the handle. The locks are
are located at the base of each side of the
handle, just under the
handle, the circular
ci rcu lar blue hinges. Note that there are three dots
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.
4. Relock the handle lock tabs so the handle is stable. stable. Make sure both lock n
tabs are locked and that the handle is secured. secured.
5. Set the computer down careful carefully ly so that the handle serves as the front sup-
sup
port.
6. Remove the front fro nt cover of the Executive 64 by pushing down the dark grey
buttons
button s at the top of the cover. Hold down the buttons while you ease the
top of the cover towards yo you. Lift out the bottom of the cove
u. lift 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 carrying
rryin g case when you first chec checked contents
ked the co ntents of the
Executive
Exec 64. The larger,
utive 64. larger, angled end of the cable goes into a slot on the
bottom of the computer located just under the disk drive. drive. You sh
should
ould lift up
the computer base to see how this plug connect connects.s. Note the corresponding
2 rows of holes where the pl plug goes. Hold the plug with the rows of pins
ug goes.
perpendicular to the computer base. In In other words
words,, the pins don't go in
first;; they should be on the side facing the back end of the computer. Push
first
the plug up and in unlil until it is securely installed.
installed.
Plug
8. Plu g the other end of th the keyboard.
e cable into the port in the back of the keyboard.
Note that the plug goes in only one way. Make sure the plug is sec secure.
ure.
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
computer,
co mpu ter, and move the switch back and forth until you see the white cir- cir
cle on one si side
de of the switch. When the computer is OFF, OFF. the cicircle
rcle is
SHOWING
SHOWING..
10. Plu
10. Plugg in the power cord. cord. This cord goes in the back near the power switch.
Note that the plug goes in on onlyly one way. Make sure the cord is secure. Plug
the other end into a standard 120 volt outlet for three prong plugs.

Downloaded from www.Manualslib.com manuals search engine


11, Turn the computer on with the power switch discussed in step 9. When the
11.
computer
compu on,, the red disk drive light (or lights, if you have two drives)
ter is on
come on and in a few seconds the screen displays the power-on message:
SX-64 BASIC V2.0 *""
SYSTEM 38911 BASIC BYTES
64K RAM SYSTEM BYTES FREE
v READY.
READY.

12. Adjust
Adj ust the picture
picture,, if necessary. The backg round color shou
background ld be white,
should white, the
should
border shou flight blue·green),
ld be cyan (light blue-green), and the characters should be blue.
The picture controls are behind the small door with the Commodore logo.
This door is on the right front as you face the monitor. Use the button to
open the door. The control knobs are identified inside the door. door. Use them
would
as you wou ld use the adjustments on a TV set. Note that the top knob con· con
trols
tro the
is th volume
e vo your Executive 64.
lume for your
v
Now yo u're ready to begin using your Executive 64. If you have any problems,
you're
trouble-shooting chart. Before you use the disk drive,
consult the trouble'shooting drive, be su
sure
re to
consult Chapter 2.

v 4

Downloaded from www.Manualslib.com manuals search engine


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. 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.
2. Remove any cartridges.
3. Turn off and disconnect any peripheral devices that are attached to your
computer.
4. Remove the power cord from the back end of the computer.
5. the keyboard connection cable from the keyboard,
Unplug the 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. Unlock the tabs on each side of the handle's base.
10. base. The tabs are un
unlocked
locked
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 com- com
puter's base.
base.
12.
12. Relock the tabs.
tabs. The tabs are locked when they are in the side positions,
not in the center position.
position. Make sure both tabs are locked and that the hanhan-
dle is secure.
13.
13. Attach the carrying case containing
containi ng the cords to the Executive 64's hand
handle.
le.
The Executive 64 is now ready to be carried wherever you go. Be sure to han
han-
dle the Executive 64 carefully when you transport it.

Downloaded from www.Manualslib.com manuals search engine


v
TROUBLESHOOTING CHART:
TROUBLESHOOTING CHART: Executive
Executive 64
64

Symptom
Symptom Cause
Cause Remedy
Remedy

Indicator Light
Indicator Light Computer not
Computer not Make
Make sure
sure power
power switch
switch
not "On"
not "On" "On"
"On" isis in
in "On"
"On" position
position

Power
Power cable
cable not
not Check
Check power
power socket
socket for
for
plugged in
plugged in loose or
loose or disconnected
disconnected
power
power cable.
cable.
v
Power supply
Power supply not
not Check
Check connection
connection
plugged in
plugged in with
with wall
wall outlet
outlet

Bad fu
Bad fuse in
se in Take
Take system
system to
to
computer
computer authorized dealer
authorized dealer for
for
replacement
replacement of
of fu se
fuse
No picture
No picture Power not
Power not ON
ON Check
Check previous
previous remed ies
remedies
Malfunction
Malfunction Take
Take system
system toto
authorized
authorized Commodore
Commodore
dealer for repair
Random pattern on Cartridge not Turn
Turn off
off power
power and
and
monitor when properly installed rein sert cartridge
reinsert cartridge
cartridge
cartridg e is in
Picture
Pict with
ure wit poor
h poor Poorly
Poorl y adjusted Adjust picture
Adjust picture controls
controls
or no
or no color
coior picture
picture
Excess background Volume too Adj ust volume
Adjust volume control
control
noise high

v Picture
Picture OK,
OK, but no
no Volume
Volume too Adjust volume
Adjust volume control
control
sound
sound low

Disk
Disk won't
won't LOAD
LOAD Disk
Disk improperly
improperly Remove disk;
Remove disk; insert
insert
inserted
in serted according to
according to directions
directions
(see Chapter
(see Chapter 2)
2)
Drive
Drive door
door noi
not Make sure
Make sure door
door is
is
v closed
closed secure
secure

Bad
Bad disk
disk Insert another
Insert another disk
disk
Malfunctioning
Malfunctioning Take system
Take system to
to
drive
drive authorized dealer for
authorized dealer for
repai r
repair

v
Downloaded from www.Manualslib.com manuals search engine
CURSOR
CURSOR

The
The flashing
flashing square
square under
under READY
READY isis called
called the
the cursor.
cursor. It's
It's aa marker
marker that
that
shows
shows where
where what
what you
you type
type on
on the
the keyboard
keyboard will
will be
be displayed
displayed onon the
the screen.
screen.As
As
(l
you type, the cursor moves ahead one space as the original cursor position is
you type, the cursor moves ahead one space as the original cursor position is
replaced
rep laced with
with the
the character
character you
you typed.
typed. Try
Try typing
typing onon the
the keyboard
keyboard and and watch
watch (l
the
the cursor
cursor move
move while
while characters
characters you
you type
type are
are displayed
displayed onon the
the screen.
screen .

COLOR ADJUSTMENT
COLOR ADJUSTMENT
There
There is
is aa simple
simple way
way to
to get
get aa pattern
pattern of
of colors
colors on
on the
the monitor
monitor so
so youyou can
can
easily
easily adjust
adjust the
the set.
set. Even
Even though
though you
you may
may not
not be
be familiar
familiar with
with the
the operation
operation of of
the
the computer
computer right
right now,
now, just
just follow
follow along,
along, and
and you'll
you'll see
see how
how easy
easy itit is
is to
to use
use
your computer.
your co mputer.
First,
First , look
look on
on the
the left
left side
side of
of the
the keyboard
keyboard and
and locate
locate the
the key
key marked
marked
II!iiDI .
ISTI1 . ThisThis stands
stands for
for ConTROL
ConTROL andand is
is used,
used, in
in conjunction
conjun ction with
with other
other
keys, to
keys, to instruct
instruct the
the computer
computer to
to do
do aa specific
specific task.
task.
To
To use
use aa control
control (unction,
fun ction, you
you hold
hold down
down the II!iiDI key while
the »**<:;.* wh ile pressing
pressing aa
second key.
second key. —■■■■ mm
Try
Try this:
this: hold
hold the II!iiDI key
the KUiil key while
while also
also pressing
pressing the the Q D key.key. Then
Then
release both
both keys.
keys. Nothing
Nothing obvious should
should have
have happened,
happened , butbut ifif you
you touch
tou ch any
key now,
now, the
the screen will
wil l show
show the
the character displayed in in reverse
reverse type,
type, rather
rather
than normal type — like
- like the opening message
message of anything
anything youyou typed eariler.
Held down the
Hold Mbai:!.,., .
;he HJ.mJ.U What happens9 did th
happens? If you did thee above procedure
procedure cor-
cor
rectly, you sh
rectly , you should
ould see a light blue bar
bar move across the screen and then move
down to Mb3i:"\-)
to the next line as long as the fciJ.m-T.^ is
i ■ pressed.
presse I

-
READY

Downloaded from www.Manualslib.com manuals search engine


Now. hold
Now, hold EIilI
KUiil while
while pressing
pressing anyany ofof the
the other
other number
number keys.
keys. Each
Each of of
them has
them has aa color
color marked
marked onon the
the front.
front. Anything
Anything displayed
displayed fromfrom this
this point
point wi
will be
ll be
in that
in that color.
color. For example, hold EIilI
hold E3 and and the
the D Q key key and
and release
release both.
both.
Now hold the
Watch the
Watch the displa,y.
display. The bar
bar is
is now
now inin yellow!
yellow! In In aa like
like manner
manner you
you can
can change
change
the bar
the bar to
to any
any of the other
other cocolors indicated on
lors indicated on the the number
number keys
keys byby holding
holding
EIilI
EES and and the
the appropriate
appropriate,- key.
key.
Change the
Change the bar
bar to
to a
a few
few more
more different
different colors
colors and and then
then adj
adjust the color
ust the color and
and
tint contro
tint controls on yo
ls on your monitor so
ur monitor so the
the display
display matches
matches the the co
color you selected.
lor you selected.
The display
The display should
should appear
appear something
something like like this:
this:

II RED BAR
D GREEN BAR
D BLUE BAR
D YELLOW BAR

At this pOint
point everything is properly adjusted and work working correctly. The
ing correctly.
language. However,
following chapters will introduce you to the BASIC language. However, you can
immediately start using some of the many prewritten applications and games
knowing
available without know ing anything about computer programming.
Each of these packages contains detailed information abou aboutt how to use the
suggested,, though,
program. It is suggested though, that you read th
through
rough the first few chapters of
this manual to become more familiar with the operation
operat ion of your
you r new system.
system.

Downloaded from www.Manualslib.com manuals search engine


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
capabilities of
of your
your computer.
computer. These
These peripherals
peripherals include:
include:
•• storage devices
storage devices
•• pri nters and
printers and plotters
plotters n
•• monitors
monitors
• modems
• modems forfor telecommunications
telecommunications r-.
•• game
game attachments
attachments
•• speech and
speech and graphics
graphics modules
modules
•• desktop controllers
desktop controllers ~

STORAGE DEVICES
STORAGE DEVICES
Disk Drives
Disk Drives
Commodore's
Commodore's disk
disk drives
drives let
let you
you store
store large
large amounts
amounts of of information
information on
on 5Va
5'A""
floppy
floppy diskettes.
diskettes. Diskettes
Diskettes offeroffer fast
fast storage
storage and and retrieval,
retrieval , and
and they
automatically
automatically keep
keep track of
of all
all your
your files
fi les in
in aa directory,
directory, oror table
table of
of contents,
contents, that
you
you can
can display
display on
on your
your screen
screen or or print
print onon aa printer.
pri nter.
The
The SX-64
SX-64 is
is equipped
equipped with
with one
one built-in
built-in disk
disk drive;
drive; the
the DX-64
DX-64 has
has two
two drives.
drives.
In
In addition,
addition , you
you can add
add extra
extra disk
disk drives
drives by
by daisy-chaining them
them to
to your
your com
com-
puter.
puter. Daisy-chaining
Daisy-chaining means
means connecting one drive to the computer,
computer, and
and then
connecting additional drives to each other.
By
By acquiring the Commodore
Commodore 6464 IEEE Interface Expansion
Expansion Card,
Card , you can also
attach any IEEE disk drive, such as Commodore's CBM
CBM 8050 or 4040 Dual Flop
Flop·
py Disk Drives,
Drives, to the Executive
Exec utive 64.
64.
Chapter 22 contains detailed information on using disk drives.

PRINTING AND PLOTTING DEVICES


Prin ters
Printers n
1526, or MPS·801
You can attach Commodore's 1525, 1526, MPS-801 Printers to the Ex·
Ex
64. These models
ecutive 64. 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, such as Commodore's 6400 letter
printer, 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 1520
Commodore's 1520 Printer/Plotter
Printer/Plotter prints
prints and
and draws
draws graphics
graphics inin four
four colors
colors
(black, bl
(black, blue, red,, and
ue, red and green).
green). With
With the 1520, you
you can
can draw
draw barc
bar charts, pies, and
harts, pies, and aa
va riety of
variety of complex
complex graphics.
graphics.

THE 170111702
THE 1701/1702 MONITOR
MONITOR

Commodore's 14"
Commodore's 14" color
color monitor
monitor offers
offers aa superior
superior color
color picture
picture with
with high
high
resolution
reso that enhances
lu tion that enhances yo
your computing
ur co experience. This
mputing experience. This moni
monitor can
tor ca be con-
n be con
nected 10
nected to the
the Exec
Executive 64. The
utive 64. The monitor
monitor is
is connec
connected to the
ted to the compu
computer by an
ter by an
8-pin DIN
8·pin DIN cable.
cable. The
The 1701
1701/1702 Color Monitor
/1702 Color Monitor User's
User's Guide
Guide that
that comes
comes with
with the
the
monitor clearly
monitor clearly explains
explains connections.
connections. You You can
can also
also consult
consult Appendix
Appendix II for
for infor-
infor
mation about
mation about the
the pinouts
pinouts in
in the
the 8-pin
8-pin connector.
connector.

NOTE: You
NOTE: You can
can also
also use
use aa 5-p
5-pin cable to
in cable to con
connect
nect aa monit
monitor to the
or to the Executive
Executive 64.
64.
Just
Just plug
plug itit into
into the
the 8·pin
8-pin connector.
connector.

Downloaded from www.Manualslib.com manuals search engine


v
MODEMS FOR
MODEMS FOR TELECOMMUNICATIONS
TELECOMMUNICATIONS

The 1600
The 1600 VICMODEM
VICMODEM

Commodore's inexpensive
Commodore's inexpensive 1600
1600 VICMODEM
VICMODEM leislets you
you use
use your
your telephone
telephone to
to
connect your
connect your Executive
Executive 64
64 to
to other
other computers
computers and
and computer
computer services.
services. These
These
computer services
computer services include
include CompuServe,
CompuServe, TheThe Commodore
Commodore Information
Information Net·
Net
work. The
work, The Source,
Source, Dow
Dow Jones
Jones News/Retrieval,
News/Retrieval, and
and others.
others.

v THE Z·BO
THE Z-80 MICROPROCESSOR
MICROPROCESSOR AND
AND CP/M"
CP/M"' OPERATING
OPERATING SYSTEM
SYSTEM

The Z-80
The Z-80 microprocessor
microprocessor turns
turns your
your Executive
Executive 64
64 into
into a
a dual
dual microprocessor
microprocessor
home computer.
home computer. The
The Z.aO
Z-80 gives
gives you
you access
access to
to the
the popular
popular CP/M
CP/M Operating
Operating
System, which ofters
System, offers a
a vari
variety software applications, includi
ety of software including wordprocess-
ng wordprocess·
ing., wide
ing widely-used business
ly-used busi programs, high
ness programs, high level computer languages (e.g.,
COBOL,
CO FORTRAN), and other uselul
BOL, FORTRAN), useful programs.

ATTACHMENTS FOR
ATIACHMENTS FOR GAMES AND OTHER USES

offers joysticks, paddles,


Commodore ofters paddles, and trackballs that enhance game·
game-
piaying on your computer. These attachments also have other appl
playing applications.
ications. For
example, the joystick works with Commodore's MAGIC DESKT"
example, DESK™ software
perform
series, which lets you perf com
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 Modulele makes your Executive 64 talk. The module
comes with aa built-in utterances, and,
bu ilt·in vocabulary of 235 utterances, and, with software support,
support,
it can speak
speak in different voices.
voices. The Module is easily programmed in BASIC andand
also works with preprogrammed software on disk and cartridge. Some of Com 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
Commodore provides
provides aa variety
variety of
of graphics
graphics programming
programming aids,
aids, including
including the
the
SUPEREXPANDER
SUPER EXPANDER 64 64 cartridge,
cartridge, which adds
adds easy-to-learn
easy·to·learn graphic
graphic plotting
plotting and
and
music
music programming
programming commands
commands to to BASIC;
BASIC; SIMON'S
SIMON 'S BASIC,
BASIC, which adds
adds 118
11 8
powerfu l new
powerful new commands
commands to to BASIC,
BASIC, including
including programming
programming help
help and
and graphics
graphics
commands:
commands; andand LOGO,
LOGO, an an easy-to-learn
easy·to·learn progamming
progamming language
language with
with TURTLE
TURTLE
graphics.
graphics.

10
10

Downloaded from www.Manualslib.com manuals search engine


SPECIAL DESKTOP
SPECIAL DESKTOP CONTROLLER
CONTROLLER
Commodore
Commodore will
will soon
soon introduce
introduce aa special
special device
device that
that controls
controls the
the screen
screen as
as
you
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·
tional
tional enhancement
enhancement forfor Commodore
Commodore Software
Software products,
products, such
such as
as the
the MAGIC
MAGIC
DESK Series.
DESK Series.

MUSIC ATTACHMENTS
MUSIC ATTACHMENTS
Commodore
Commodore will
will also
also soon
soon offer
offer aa Musical
Musical Keyboard
Keyboard andand aa 3-pad
3-pad percussion
percussion
attachment
attachment called
called the
the Digi-drumrM.
Digi-drum™. Both
Both products
products will
will include
include special
special software
software
packages.
packages. These
These attachments
attachments will
will increase
increase the
the music
music making
making capabilities
capabilities of
of
the 64
the 64 computers.
computers.

CONNECTING TO
CONNECTING TO A
A STEREO
STEREO SYSTEM
SYSTEM
The
The sound
sound and
and music-making
music-making capabilities
capabilities of
of the
the Executive
Execut ive 64
64 can
can be
be enhanc
enhanc-
ed
ed by
by connecting
connecting your
your computer
computer to
to aa high
high quality
quali ty amplifier and
and stereo
stereo speakers.
speakers.
The
The 8-pin
8-pin DIN
DIN cable
cable discussed
discussed in
in the 1701/1702
170111702 Color
Color Monitor
Monitor section
section can also
also
be
be used
used to
to connect your
your computer
computer to
to an
an amplifier.
amplifier.

DESIGNING A
A COMPUTER SYSTEM FOR YOUR NEEDS
Commodore offers a variety of peripherals that
offers a th at let you create your own own
customized computer system.
system. We offer different types of storage,
storage, printing,
printing, and
telecommunications
tel devices so
ecommunications devices so you
you can
can choose
choose what's
what's best
best for
for you
you.. For
For more
more
information about
information about Commodore
Commodore peripherals,
peripherals, read
read The
The Commodore
Commodore Peripherals
Peripherals
magazines
Guide and the Commodore magazi nes discussed in Appendix
Appendi x R R and consult
your Commodore dealer.

11
11

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
CHAPTER 2
GETTING STARTED
GEITING
•• Communicating
Communicating with
with your
your 64:
64: The
The Keyboard
Keyboard
• Loading
Load Programs
ing and Saving Programs
How to Load
• How Load Prepackaged
Prepackaged Software
• How to Format
How Formal a New
New Disk
Disk

• How to Save Programs


How
•• Listing aa Directory
Directory of
of programs
programs on
on a Disk

•• Fi
Files
les
• Sequential Files
• Relative Files
•• Random Access
Random Access Files
Files

• 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.
regular
The keyboard looks like a regu lar typewriter,
typewriter, but the computer has special
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 The
Th e RETURN key tells the computer to look at
what you typed and put this information inin
memory.
memory. The RETURN key also moves the cursor
to the next line.
to

NOTE: Memory is
NOTE: is all
all the information the com
com-
knows without
puter currectly knows without needing
needing you
you to tell
tell 0
it where to
it to look.
look.
SHIFT The SHIFT
The SH IFT key
key works
works like like the
the shift
shift key
key on
on aa
typewriter: itit lets
regular typewriter: lets you
you print
print capital
capital letters
letters
or the
or the top
top characters
characters on
on double
double character
character keys.
keys.

mm
t::jJ
- \\
~-'
~
m ~-'
'\

12
12

Downloaded from www.Manualslib.com manuals search engine


When
When you
you are
are using
using the
the graphics
graphics on
on the
the front
front of
of
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
keys at
at the
th e right
right side
side of
01 the
the keyboard,
keyboard, the
the SHIFT
SHIFT
key
key gives
gives you
yo u the
the functions
fun ctions on
on the
the FRONT
FRONT of
of the
the
key
key (f2,
(f2, f4,
f4, f6,
f6, and
and f8).

13
13

Downloaded from www.Manualslib.com manuals search engine


KEYS THAT
KEYS THAT LET
LET YOU
YOU MAKE
MAKE CHANGES
CHANGES
CRSR
CRSR The cursor
The cursor is
is the
the little
little colored
colored rectangle
rectangle that
that n
marks
mark your
s you place on
r place on the
the screen.
screen. There
There are
are two
two
CuRSoR keys:
CuRSoR keys: n
ttCRSR+
CRSR. moves the
moves the cursor
cursor up
up and
and down
down
■•-CRSR-*-
-CRSR - moves the
moves the cursor
cursor left
left and
and right
right

You must
You must use
use the
the SHIFT
SHIFT key
key with
with thethe
t+ CRSR
CRSR+ key to
. key to move
move the
the cursor
cursor up,
up, and
and with
with
the +* CRSR
CRSR-*- key to move
- key move the
the cursor
cursor to
to the left.
left.
You don't
You don't have
have to keep
keep tapping
tapping a CRSR
CRSR key
key to
get it
get it to move more
move more than one
one space. Just hold itit
Just hold
down until
down until the cursor is
is where you want
want it.
it.
INST/DEL
INSTIDEL DEL stands for DELete.
DEL DELete. When you press the
DEL key,
DEL key, the cursor moves
moves back
back a space and
that's
erases the character that' s there.
PRINT ""ERROR"#B
ERROR" #.
PRINT ""ERROR"B
ERROR" .
middle
When you DELete in the middl e of a line, move
cursor
the cu rsor just to the left of the character you
want to DELete.
FIX
FI ITAGAINS,
X IT AGAINS, SAM
FIX
FI X IT AGAINSB
AGAINS . SAM
Then press the key. Th
th e DEL key. Thee characters to the
right
ri ght automatically move over to close up the
space.
space.

FIX
FI X IT AGAIN,
AGAIN , SAM
INST stands
stands for INSerT.
INSerT. You have to use the
SHIFT
SHI FT key with
wi th the
th e INST/DEL
INSTIDEL key when you
yo u want
want
to
to insert characters
charac ters in a line.
If you've
you 've left some characters out of a line,
line, use
the
the CRSR keys to to move the
the cursor back to
to the
the er
er·
ror.
ror.

WHILE
WH ILE UU WERE OUT
WHILE
WHILE.■ WERE
WERE OUT
Then,
Then, while
while you
you hold
hold down
down thethe SHIFT
SHI FT key,
key,
press the INST/DEL
press the INST/DEL key until you have enough
until you have enough
space to
space to add
add the
the missing
missing characters. INST
characters. INST
doesn't
doesn't move
move the
the cursor;
cursor; itit adds
adds space
space between
between
the
the cursor
cursor and
and the
the character
character to
to its
its right.
right.
WHILE
WHILE.■ U
U WERE
WERE OUT
OUT
WHILE
WH ILE YOU
YOU WERE
WERE OUT
OUT
Use
Use the
the DEL
DEL and
and INST
INST keys
keys together
together to
to fix
fix
wrong
wrong characters.
characters .
WE'RE NUMBER
WE'RE NUMBER TWO!
TWO!
WE'RE
WE'RE NUMBER ! !
NUMBER
WE'RE
W E'RE NUMBER ■
NU MBER. !
WE'RE NUMBER
WE'RE NUMBER ONE!
ON E !
14
14

Downloaded from www.Manualslib.com manuals search engine


'-" CLR/HOME HOME moves th the
e cursor back to the upper left
corner of the screen. This is called the ""HOME"
HOME"
~
position.
stands
CLR stand CLeaR. When you use the
s for CLeaR.
SHIFT key with the CLRlHOME
CLR/HOME key, the screen
~ CLeaRs and the cursor returns to the home
positon.
'-"
RESTORE The RETORE key returns the computer to its
RESTOREing
normal state by RESTOREi condi
ng the default condi-
(e.g., the default screen color is blue,
tions (e.g., blue, the
v default for 1I/O
/0 chips is OFF, etc.) RESTORE does
things
such thin screen,, returning it to the
gs as clear the screen
'-'
original color,
original color, and turn off the picture-
picture- and sound-
making chips.
'"'
v NOTE:
NOTE: For RESTORE to work,
work, you must hold
while
down the STOP key whi le you press the
v RESTORE key.
RESTORE
For example,
example, suppose you've just played
piayed a
turned
music program that also turn yourr screen red
ed you
'-' and yellow while it LISTed the program. When you
press STOP and RESTORE at the end of the pro pro-
'-' gram, the last note from the program wi ll cease,
will
your screen will turn blue and the only thing
'"'
;..)
displayed
displayed will be the READY prompt.

...-J

--'
v

'-'

'-"

'-'
~

'-"

'-'

15
15

Downloaded from www.Manualslib.com manuals search engine


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
can program to
to perform
perform aa variety
variety of tasks.
tasks. The
The explanation
explanation of
of the
the GET
GET state
state·
in Chapter 55 tells
ment in tells you
you how
how toto program
program function
function keys.
CTRl
CTRL The ConTRoL
ConTRol key lets you set colors and do do
other
other special
special tasks
tasks called control
control functions.
functions.
To set
To set colors,
colors, hold down
down the
the CTRL
CTRl key while
white
press the
you press the key with
with the
the color
color you want.
want. You
You
can get eight more cotors with the ~
more colors C^ key.
6 also
Chapter 6 also has more about colors.
To get aa control
control function,
function , hold
hold the CTRL
CTRl key
down
down while
wh ile you press the other key. Control
Cont rol func
func·
tions
tions are commonly used in prepackaged soft soft·
ware such as a word processing
processing system.
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 lets you load a
RUN a program automatically
automatical ly
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. ~
1. [Cs| lets
lets you
you switch
switch back
back and
and forth between
fonh between
the upper and lower case display mode (the let· let
ters and characters on the tops of the keys) keys}
and the upper case/graphic display mode (capi·(capi
tal letters and the graphics on the fronts of the
the
keys).
To switch modes, press the ~ C= and SH SHIFT
IFT
keys at the same time.
your64,
When you first turn on your is in the up·
64, it Is up
case/graphic
per case/g mode, which means that
raphic mode,
everything you type in is in capital letters.
mode, you can also print
When you are in this mode,
graphics
all the graph ics on the fronts of the keys.
• To print the graphic on the right side of a
key, hold down the SH SHIFT
IFT key while you
press the key with the graphic you want to
print. You can on only
ly print the right side
graphics when you are in the upper
case/graphic mode.
print
• To pri nt the graphic on the left side of a key,
hold down the ~ ,O key while you press the
graphic key. YouYou" can print the left side
graphic in either mode.

16

Downloaded from www.Manualslib.com manuals search engine


_

r;-~
~

2. The ~
2. The [C=j key
key also
also lets
lets you
you use
use the
the second
second set
set of
of
eight colors shown on the color keys. keys.JTo
To get
these other co lors, hold down the ~
colors, [CE key
you
while yo number for the color you
u press the number

want.

— LOADING AND SAVING PROGRAMS

-
Executive
The Exec cartridge. Th
utive 64 accepts programs from disk or cartridge. This
is means you
can use prewritten software simplsimply important, the 64
y by loading it. But more important,
lets you save your own programs tor for reuse. To reuse a program you wrote and
disk, all you do is load and run it.
saved on disk,
Prepackaged software on disk or cartridge designed for the Commodore 64
runs
also run Executive
s on the Exec utive 64.

17
17

Downloaded from www.Manualslib.com manuals search engine


HOW
HOW TO
TO LOAD
LOAD PREPACKAGED
PREPACKAGED SOFTWARE
SOFTWARE
Loading Cartridges
Loading Cartridges
You
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.
64.
The programs
The programs include
incl ude aa wide
wide variety
va riety of
of business
business and
and personal
personal applications.
applications. The
The
games are
games are just
just like
like real
real arcade
arcade games,
games, not
not imitations.
imitations.
Follow these
Follow these steps
steps to
to load
load games
games and
and other
other cartridges:
cartridges:
1. Turn
1. Turn OFF
OFF your
your Executive
Executive 64.
64.
YOU MUST
YOU MUST TURN
TURN OFF
OFF YOUR
YOUR EXECUTIVE
EXECUTI VE 64
64 BEFORE
BEFORE YOU
YOU INSERT
INSERT OR
OR
REMOVE
REMOVE CARTRIDGES.
CARTRIDGES. IF
IF YOU
YOU DON'T.
DON'T, YOU
YOU MAY
MAY DAMAGE
DAMAGE THE
THE CAR
CAR·
TRIDGE AND
TRIDGE AND THE
THE COMPUTER.
COMPUTER.
2. Insert the
2. Insert the cartridge
cartrid ge in
in the
the slot
slot on
on the
the top
top of
of your
your computer.
compu ter.
3. Turn
3. Turn on
on your
your 64.
64.
4. Begin
4. 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·
tion sheet.
tion sheet.

Loading Disks
Disks,
Disks, which
which are often
often called
called "floppy
" floppy disks",
disks ", are
are really easy to
to use.
use.
The
The steps are
are the same
same for loading
loading preprogrammed disks and disks that that you
program yourself.
you rself.
1.
1. insert
Insert aa disk into your disk drive. Make
Make sure the label on the disk is facing up.
Put the disk in so that the labelled end goes in last. Look for a little notch on
on
the disk (it might be covered with
with a little piece of tape). This
Thi s notch must be
on the left side as you put in the disk,
disk, assuming that you're
you 're facing your com·
com
puter. Be sure the disk is all the way in.in.
2. Close the protective gate on the disk drive after you insert the disk. Just
push down the lever.
3. Type LOAD ""PROGRAM
PROGRAM NAM NAME".
E" , 8. The 8 is the code for disks. You need to
type it here to let the computer know you you're
're loading a disk.
NOTE: You can LOAD th
NOTE: thee first program by using the ·' sign in place o
off the
program name:
name: LOAD " .
"*"," , 8.
4. Press the RETURN key.
4. key. The disk will spin and your screen will
wi ll say:
SEARCHING FOR PROGRAM NAME
LOADING
READY
•■

RUN when the screen says READY and the cursor appears. Your soft·
5. Type RUN soft
~is~~u~
ware is ready to use. n

n
18
18 n
Downloaded from www.Manualslib.com manuals search engine
HOW TO FORMAT A NEW DISK
new. unprogrammed disk for the first time, you need to
When you're using a new,
headering,, prepares your disk by do-
format it. Formatting, which is also called headering do
ing things like dividing the disk into blocks. Formatting also creates a directory
that you use as a table of contents for the files yoyou
u save on the disk. DO NOT
header a preprogrammed disk.
You oonly disks, not disks that already have programs on
nly have to format new disks,
unless
them unl ess you want to erase the entire disk and reuse it.
disk, use this special version of the OPEN and NEW com·
To format a new disk, com
mands:
mands:
NO: <name> , < id Y '
1,8.15,liN0:<name>.<id>"
OPEN 1,8,15,"
v NO tells the computer to header (N
(NEW) 0. If you have a DX-64,
EW) the disk in drive O. DX-64,
disks
header disk 0.
s in drive O.
The name you use in this command goes in the directory as the name of the
v entire disk. Give the disk any name up to 16 characters.
'-' The id is any two characte
characters.
rs. Give the disk any id you want,
want, but you should
give every disk a different id code.
off. type CLOSE 1
When the disk drive light goes off, 1 and press return.

BE CAREFUL! Headering a disk erases all information on the disk, disk, if there is
any. Header only a new disk
disk or a disk you are willing to erase.
erase. Here are some ex-
ex
amples of OPEN comm
commands
ands that header aa disk:
disk:

OPEN 1,8,
1,8,15,"N0:MYFILE.A3"
15," NO:MYFILE,A3"
OPEN 1,8,15,"NO:$RECORDS,02"
1,8,15,"N0:$RECORDS,02"

Now that you know how to header aa disk, you are ready to use disks to write
write
and save programs on your
your Executi
Executive
ve 64. Appendix
Appendi x SS contains more informa-
informa
tion on the OPEN command.

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
When you change aa SAVEd
SAVEd program,
program, you
you have to SAVE it again if you
you want
want to
keep the new
new version.
version .
When
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
one.
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
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.
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
computer
computer that you're
you 're using
usi ng aa disk.
disk.
2.
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
message when
when the
the program
program is
is saved:
saved:
v SAVING
SAVING "PROGRAM
"PROGRAM NAME"
NAME"
OK
OK
v
READY
READY

19
19

Downloaded from www.Manualslib.com manuals search engine


LISTING
LISTING A
A DIRECTORY
DIRECTORY OF
OF PROGRAMS
PROGRAMS ON
ON A
A DISK
When you
When you SAVE
SAVE programs
programs on
on aa disk,
disk, the
the computer
comp uter automatically
automatically makes
makes aa ^
table of contents,
table contents, or
or aa DIRECTORY,
DIRECTORY, of the
the names
names of
of the
the programs
programs on
on the
the disk.
disk.
You
You can
can display this
this directory
directory to
to see
see what
what programs
programs are on
on your
yo ur disk.
disk. Follow
Follow
these steps:
these steps:
-—i

1.
1. Key
Key in:
in: LOAD
LOAD "$",8
"$",8 and press RETURN.
RETURN . The
Th e computer
computer displays
displays this
this
message:
message: <■

SEARCHING FOR $ m
LOADING
READY
READY ^

in: LIST and press RETURN


2. Key in: ft

Your
Your programs names are
are displayed on your
your screen. _

FILES
There
Th ere are two types of files that you
yo u can store:
1.
1. PROGRAM FILES, which store BASIC or machine language programs.programs.
FILES, which store numeric and string data that you can use in pro
2. DATA FILES, pro·
grams. A unit of a data file is called a
a RECORD;
RECORD; each record can contain one ^
or
or more pieces of data.

There are three types of data files


files,, which differ in the way data records are
stored and accessed
accessed:: ^

1.
1. SEQUENTIAL FILES,
FILES, which store data in records in the order you input the
data. Data records are accessed sequentially,
sequentially, which means that you can 't go
can't
directly to record 10;
10; you must read the file from beginning to end. ^
2. RELATIVE FILES, which let you access data records directly by positioning
a pointer relative
pOinter to any record relat ive to the beginning of the file,
file, which means that
you can go directly to record 10. 10.
3. RANDOM ACCESS,
ACCESS, or user files,fites , which store data records according to yo ur
your
design.
des file
ign. Unlike the other fil types, these files are not maintained by the disk
e types, ^
operating
operat system.
ing sys tem. You must design and maintain them yourself.

20
20

Downloaded from www.Manualslib.com manuals search engine


SEQUENTIAL FILES
SEQUENTIAL
FORMAT FOR
FORMAT FOR OPENING
OPENING A SEQUENTIAL
SEQUENTIAL FILE:
FILE:

file#,, device#, cchannels.


OPEN file# hannel#, "■'O:name.type,direction"
O:name,type,direction"
The file number
The number is is the same as in in all your other applications of of the OPEN
statement, and itit is
is used
used throug
throughout program
hout the prog refer to this particular
ram to refer particular file.
The device# isis usually
usually 8. The channel# is is a data channel, number
number 2 throug
through 14. It
h 14.11
is convenient to use the same number
is number for bothboth the channel#
channel^ and file# file#,, to keep
keep
straight.
them stra The
ight. Th name is
e name is the file name
name (no wild cards or patternpattern 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
below. by using the first letter (P, S, U, U, R).
R). Th
Thee direction
must be READ
must be READ or or WRITE. You can
You can useuse just the first
first letter (R or W).
(R or W).
FILE TYPE MEANING
PRG Program
SEQ Sequential
USR User
REL Relative

v EXAMPLES
EXAM OPENING
PLES OF OPENI SEQUENTIAL
NG SEQU FILES:
ENTI AL FILES:
8, 2,
OPEN 2, 8, 2, "O:
"0:DATA, S, W"
DATA, S, W

8, 8, 8,
OPEN 8, 8, "O:
"0:Program,
Program , P, R"
OPEN A, C, "0:" + A$ +
B, C,
A, B, "u,
"U, W"

If the file already exists,


exists, you can use the replace option in the OPEN state·
state
ment. Simply add the @O:@0: before the file's
fi le's name in the OPEN statement.
EXAMPLE OF SEQUENTIAL FILE WITH REPLACE OPTION:
OPTION :
OPEN 2, 8, 2,
2,8, 2, "@
■'@0:DATA,S,WM
O:DATA,S,W"
The 0: should
shou ld always precede the name
name of the fifile
le or the drive will only
only allow
al low
you to use 2
2 of the available buffers.
bu ffers.

WRITING TO AND
AND READING FROM
FROM A
A SEQUENTIAL FILE
PRINT#
PRINT# and
and INPUTS
INPUT# and GET#
GET#
The
The PRINTS
PRINT# command works exactly
exactly like
like the
the PRINT statement,
statement, except
except that
output is re-directed
re·directed to
to the
the disk
disk drive. The
The reason
reason for the special emphasis
emphasis on
on
the
the word
word exactly
exactly is
is that
that all
all the
the formatting capabilities
capabilities of
of the
the PRINT
PRINT statement,
statemen t,
as
as applies
applies to
to punctuation
punctuation and
and data
data types,
types, applies
applies here
here too.
too. ItIt just
just means that
you
you have
have to
to be
be careful
caref ul when
when putting
putting data
data into
into your
your files.
FORMAT
FOR MAT FOR
FOR WRITING
WR ITING TO
TO FILE
FILE WITH
WITH PRINTS:
PRINT#:
PRINTS
PRIN T# files,
file# , data
data list
list
The file# is
is the
the one
one from the
the OPEN
OPEN statement when
when the file
fil e was
was created.
created.
The
The data
data list
list is
is the
the same
same as
as the
the regular
reg ular PRINT
PRINT statement
statement —
- aa list
list of
of variables
variables
and/or
and/or text
text inside
inside quotes.
quotes. However,
However, you
you must
mu st be
be especially
especially careful
careful when
when
writing
writing data
data so
so that
that itit is
is as
as easy
easy as
as possible
possible to
to read
read back
back again
again later.
later.
v

21
21

Downloaded from www.Manualslib.com manuals search engine


When using
When using the
the PRINT#
PRINT# statement,
statement, ifif you
you use
use commas
commas (,)
(,) to
to separate
separate items
items
in
in the
the list,
list, the
the items
items will
will be
be separated
separated by
by some
some blank
blank spaces,
spaces, as
as ifif itit were
were be
be-
ing
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.
In
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
se-
quen tial file
quential 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":

col
char
char 10 14

The
The eof
eat stands
stands for
for the
the end-of-file
end-at-tile marker.
marker. String
Stri ng data
data entering
entering the
the file
file goes
goes in
in
byte by
byte by byte,
byte, including
including spaces.
spaces.
For
For instance,
instance, let's
let's set
set up
up some
some variables
variables with
with the
the statement
statement A$=
A$= "HELLO":
" HELLO" :
B$=
B$= "ALL":
"ALL" : C$=
C$= "BYE".
" BYE". Here
Here is
is aa picture
picture of
of aa file
file after
after the
the statement
statement PRINTS
PRINT#
5, A$:
5, A$; B$;
BS; C$:
CS:

..Jur
h.. ,
\ Il \ l I LI LIUI ' I L
H
!
[■
2
I.
.1
1.
i
0
5
A
6
L
7
L
U
B
'*
Y
10
b.
11
CR
U
eof
IJ

CR stands
stands for the CHRS
CHRS code 13, the
the carriage return,
return, which is automatically
automatically
PRINTed at the
the end of every PRINT or PRINT#
PRINT# statement unless there
there is aa com-
com
ma or
or semicolon at the end of the
the line.
line.

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 ab-
ab
breviat ion.
breviation.

FORMAT
FOR MAT FOR INPUT# STATEMENT:
INPUT# STATEMENT:
INPUT# file# , variable list
INPUTS file#,

When using IN INPUTS


PUT# to read data, there is no way to tell that it's not supposed
string. You need something in the file to act as a separator.
to be one long string.
Characters
Charac semicolon. The
ters to use as separators include the CR, a comma or a semicolon.
CR can be added easily by just using one variable per line in the PRINT# state-
CR state
automatically. The statement PRINT#
ment, and the system puts one there automatically. PRINTS 5,
PRINTS 5,
A$: PRINT# 5, B$: PRINT#
PRINTS 5, C$ puts a CR after every variabl
variable written,, pro-
e being written pro
the
viding th separation
e proper separati INPUTS5, A$,
on for a statement like INPUT#5, A$, B$, C$. A line like
Z$=",":PRINTS5.
ZS= "," :PRINT# 5, A$Z$ BSZSCS
AS Z$ B$ willl do the job as wel
Z$ C$ wil well,
l, and in less space. The
file after that line looks like this:

i L 0 A L L B Y 1. CR eol
II L

7 9 IU II 12 U 14 IS
s 6
8
1
\.that
hll ' 1 4
-

Putting commas between


Putting between variab
variables
les results in lots of extra space on the disk
being used.
being used. A statement like
like PRINT#
PRINTS 5,5. A$, BS makes
makes a file that looks like:

H b 1. L 0 ■\ L L CR eol

di.hj[
lJf I 2 3 4 b 7 8 10 12 13 i4 :j 24

22
22

Downloaded from www.Manualslib.com manuals search engine


Numeric data
Numeric data written
written in
in the
the file takes
takes the form of a a string
string,, as
as ifif the
the STR$ fufunc
nc-
had been
tion had been performed
performed on on itit before
before wri
writing out. The first character
ting it out. character wi will be a
ll be a
space if
blank space if the
the number
number is is positive,
positive, and
and aa minus signsign ((-)
- ) ifif the number
number is
negative.
negati number, and the last
ve. Then comes the number, last character
character is
is the cu
cursor right
rsor right
format
character. This fo information for the INPUT#
rmat provides enough information INPUTS statement
numbers if several are
to read them in as separate numbers are wri
written special
tten with no other spec ial
separators.
separat ors. ItIt is
is somewhat wastef
wasteful can
ul of space, since there ca be two unused
n be unused
characters ifif the numbers are positive.
Here is a picture
Here picture of the file after the statement PRINT#
PRINT#5,1; perform
5, t; 3; 5; 7 is perform-
v ed:

CR euf

io I2 13 IS
v

GET#
disk, one charac
The GET# retrieves data from the disk, character time.
ter at a time.
STATEMENT:
FORMAT FOR THE GET# STATEM ENT:
GET# file#,
file# , variable
variable list
including the
Data comes in byte by byte, including the CR,
CR, comma,
comma, and other separating
characters.
charac ters. It is much safer to use string variables when using the GET# state-
state
ment. You will get a BASIC error message if string string data is received where aa
number was requrequested, butt not vice-versa.
ested, bu
EXAMPLES
EXAM PLES OF GET#
GET# STATEMENT:
GET#
GET# 5,
5, A$
GET# A,
A, B$,
B$, C$,
C$, D$
D$
GET 5,
5, A
The GET# statement is is extremely
ex tremely useful
usefu l when
when examining files with unknown
unknown
contents,
contents, like aa file that
that may have
have been
been damaged
damaged by an an experimental program. It
is
is safer than INPUT#
INPUT# because there there is
is aa limit
limit to the number
number of
of characters
charac ters allow
al low-
ed
ed between
between separators
separators of of INPUT
INPUT variables.
va ri ables. With
With GET#,
GET#, you
you receive every
every
character,
characte r, and
and you
you can
can examine
examine separators
separat ors as as well as
as other
other data.
data.

23
23

Downloaded from www.Manualslib.com manuals search engine


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
OPEN 2,2,8,
8, 2, " FILE,L," ++ CHR$(100)
2, I*FILE,L1" CHR$(100)
OPEN
OPEN F.
F, 8,8, F.
F, A$
A$ ++ ",L,"
", L," ++ CHR$(O)
CHR$(Q)
OPEN
OPEN A,
A, B,
B, C,
C, "TEST,L,"+
" TEST,L," + CHR$(33)
CHR$(33)

RELATIVE
RELATIVE FILE
FILE FORMAT
FORMAT
'
DATA
DATA BLOCK
BLOCK
BYTE
BYTE DEFINITION
DEFINITION
0,1
0,1 Track
Track and
and sector
sector of
of next
next data
data block.
block.
2- 256
2—256 254
254 bytes
bytes of
of data.
data. Empty
Empty records
records contain
contain FFFF (all
(all binary ones) in
the first byte followed by 00 (binary all
the first byte foll owed by 00 (binary al l zeros) to the end of the
record.
record. Partially
Partially filled
filled records are
are padded with nulls (00).
(00).

SIDE
SIDE SECTOR
SECTOR BLOCK
BLOCK

BYTE
BYTE DEFINITION

0,1
0,1 Track
Track and
and sector
sector of next side sector block.
block.

22 Side sector
Side sector number.
number. (0-5)
33 Record length.
4,5
4,5 Track and sector of first side sector (number 0)

6,7
6,7 Track and sector of second side sector (number 1)

8,9
8,9 Track and sector of third side sector (number 2)

10,11
10,11 Track and sector of fourth side sector (number 3)
3)

12,13
12,13 Track and sector of fifth side sec tor (number 4)
sector

14,15
14,15 Track and sector of sixth side sector (number
Track (number 5)

16- 256
16—256 Track
Track and
and sector
sector pOinters
pointers to
to 120
120 data
data blocks.
blocks.

execution,, the DOS first checks to see


Upon execution see if
if the file
file exists.
exists. IfIf it
it does,
does,
then nothing happens.
then happens. The on ly way to erase an
only an old
old re lat ive file
relative file is
is by
by using
using the
the
SCRATCH command
SCRATCH command,, but
but not
not by
by using
using the
the replace
replace option.
option.

24
24

Downloaded from www.Manualslib.com manuals search engine


FORMAT FOR
FORMAT FOR OPENING
OPENING AN EXISTING
EXISTING RE
RELATIVE FILE:
LATIVE FILE:
file#,, device#, channel#, "name"
OPEN file# "name"

In this case, the DOS


In DOS automatically knows that
that it
it is
is a relative fil
file.
e. This syntax,
one shown in
and the one in the above section
section,, both
both al
allow reading or
low either reading or w
writing
riti ng to
file..
the file
In order to read or write, you must, before
In before any operation, position the file
pointer to the correc
pOinter correctt record
record position.
position.

The
Th e position command is sent to the command channel (15), so you must
In the following example, 15
open an additional file for the command channel. In 15
is the file number of the command channel, and 8 is the file number of the
is
relative file.
relative
15,8,15
OPEN 15,8, 15
8,8.8
OPEN 8,8,8
FORMAT FOR POSITION COMMAND:
PRINT#file#, ""P"
PRINT#file#, CHR$(channel# + 96) CHR$(rec#lo) CHR$(rec#hi)
P" CHRS(channel#
CHRS(position)
CHR$(position)
EXAMPLES
EXAM PLES OF POSITION COMMAND:
PRINT#15, P" CHR$(CH + 96) CHR$(R1
PRINT#15, ""P" CHR$(R1)) CHR$(R2)
CHR${R2) CHR$(P)
CHR$(P)
v
PRINT#15, ""P" CHR$(R1)) CHR$(R2) CHR$(P)
P" CHR$(4 + 96) CHR$(R1 CHR$(P)
The 2-byte format for the record number is needed because one byte can only
numbers, and we can have over 700 records in the file.
hold 256 different numbers, file_ The
rec# 10
lo contains the least significant part of the address,
address, and the rec# hi is the
v most significant part. This could be translated to the actual record number by
the formula REC#
REC#= = REC HI *" 256 + REC LO. LO.
If the record number is known, the high and low bytes can be determined as
follows:
fol lows:
REC# HI=INT(REC#/256)
HI = INT(REC#1256)
REC# LO= REC#—REC#
REC#-REC# Hl'256
HI"256
'-'
EXAMPLE:
EXAM PLE:
v
PRINT#15,
PRINT#15, "P"
" P" CHR$(4 +
+ 96)
96) CHR$(R1)
CHRS(R1) CHR$(R2)
CH RS(R2) CHR$(0)
CH R$(O)
If REC# = 540:
540: R2=
R2 = INT(540/256)
INT(5401256) ...
__ _so
so R2
R2 = 22
R1 = 540-R2"256 .. .__. so
R1=540—R2*256 so R1=28
R1 = 28
Let's
Let's assume
assume we
we have
have aa mailing
mailing list.
list. The
Th e list
list consists
consists of
of 88 pieces
pieces of data,
data, ac
ac-
cording
cording to
to this
this chart:
chart:

Field
Field Name
Name Length
Length
state
state 22
first
first name
name 12
12 zip code
zip code g9
last
last name
name 15
15 phone
phone number
number 10
10
address
add ress line
line 11 20
20
address
address line
line 22 20
20 - --- -- -
city
city 12
12 TOTAL
TOTAL 100
100
v

25
25

Downloaded from www.Manualslib.com manuals search engine


This
This isis how
how the
the record
record length
length isis determined.
determined. We
We would
would probably
probably want
want toto
allow
allowan
an extra
extracharacter
characterininlength
length for
foreach
eachfield,
field ,to
toallow
allowfor
forseparations;
separa tions;other
other·
wise
wise the
the INPUT#
INPUT# command
command would
would pick
pick up
up aa much
much longer
longer piece
piece of
of the
the file
file than
than
needed,
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
108 characters
108 characters per
per record.
record.
When
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
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, create a record# 1000 as soon as
you expect the file to be 1000 records long, creat e a rec ord# 1000 as soon as the
the
file
file isis created.
created. This
This will
will force
force the
the DOS
DOS to
to create
create all
all intermediate
intermediate records,
records, mak
mak-
ing later
ing later use
use of
of those
those records
records much
much faster.
faster.
EXAMPLE OF
EXAMPLE OF CREATING
CR EATING LARGE
LARG E FILE:
FILE:
OPEN
OPEN 1,8,
1,8, 15:
15: OPEN
OPEN 2,2,8,
8,2,
2, "0:REL,L,"
"0:REL,L," +CHR$(60)
+CHR$(60)
PRINT#1,
PRINT#l , "P"
"P" CHR$(2+96)
CHR$(2 + 96) CHR$(0)
CHR$(O) CHR$(4)
CHR$(4) CHR$(1)
CHR$(l)
PRINT#2, "END"
PRINT#2, " END"
CLOSE 2:
CLOSE 2: CLOSE
CLOSE 11

RANDOM FILES,
FILES, OR USER
USER FILES
FILES
Random
Random files
files let you access
access and
and update
update each
each of
of the individual
individual 256-byte
256·byte
blocks
blocks of
of data
data stored
stored on
on the disk.
disk. As was mentioned
mentioned in
in the first chapter,
chapter, there
are a
a total of
of 683
683 blocks on
on the diskette, of which 664
664 are
are free onon aa blank
blank
diskette. Each
Each block
block of data really means
means 11 Track and
and sector of the
the same
same name.
name.
The diskette is
The diskette is divided
divided into
into tracks,
tracks, which
which are
are laid
laid out
out as
as concentric
concentric circles
circles on
on
the surface of the diskette. There are 35 different tracks,
tracks, starting with track 11 at
the
the outside of the diskette toto track 35 at the center. Track 18 is used for the
the center.
directory, and the DOS fills up the diskette from the center outward.
directory,
subdivided
Each track is subd ivided into sectors. Because there is more room on the
outer tracks, there are more sectors there. The outer tracks contain 21 sectors
each. The table below shows the
each, while the inner ones only have 17 blocks each.
numbe
numberr of
of sectors pe
perr track.

Block Format
Track and Block Format

TRACK NUMBE
NUMBERR RANGE
SECTOR RANG E TOTAL BLOCKS
TOTAL BLOCKS

11 to 17
17 o0 to 2020 21
21
18
18 to 24
24 o0 toto 18
18 19
19
25
25 to
to 30
30 o0 toto 17
17 18
18
31
31 to
to 35
35 o0 toto 16
16 17
17

The DOS
The DOS contains
contains commands
commands for for read
reading and writing
ing and writing directly
directly to
to any
any track
track
and sector
and sector on
on the
the diskette.
diskette. There
There are
are also
also commands
commands forfor checking
checking toto see
see which
which
blocks (tracks
blocks (tracks && sectors)
sectors) are
are available,
available, and
and for
for marking
marking off
off used
used blocks.
blocks.
NOTE: You
NOTE: You must
must be be sure
sure to
to mai
maintain this
ntain th information, especially
is information, especially when
when there
there are
are
other types
other types of
of files
files on
on the
the disk.
disk. Fail
Failure to do
ure to do so
so cou
could corrupt other
ld corrupt other files
files..
These commands
These commands are are transmitted
transmitted through
through the
the command
command channel
channel (channel#
(channel
15), and tell the disk what to do with the data. The data must be read later
15), and tell the disk what to do with the data. The data must be read later
through
through one
one ofof the
the open
open data
data channels.
channels.

26
26

Downloaded from www.Manualslib.com manuals search engine


OPENING
OPENING AA DATA
DATA CHANNEL
CHANNEL FOR
FOR RANDOM
RANDOM ACCESS
ACCESS
When
When working
working with
with random
rand om access
access files,
files, you
you need
need toto have
have 22 channels
channels open
open
to
to the
the disk:
disk: one
one for
for the
the commands,
commands, and and thethe other
other for
for the
the data.
data. The
The command
command
channel
channe l isis OPENed
OPENed to to channel
channel 15,
15, just
just like
like other
other disk
disk commands
commands you've
you 've en
en·
countered
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·
ting
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
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
OPEN file*,
file#, device#,
device#, channel*,
channel#, "#"
" #"
or
or

OPEN
OPEN file#,
file# , device#,
device#, channel*,
channel#, "#buffer#"
" #buffer#"
v EXAMPLES
EXAMPLES OF
OF OPENING
OPENING RANDOM
RANDOM ACCESS
ACCESS DATA
DATA CHANNEL:
CHANNEL:
OPEN 5,
OPEN 5, 8,
8, 5,
5, "#"
" #"
OPEN A,
OPEN A, B,
B, C,
C, "#2"

BLOCK·READ
BLOCK-READ

FORMAT FOR BLOCK-READ


BLOCK·READ COMMAND:
COMMAND:
PRINT#file#,
PRINT#file#, "BLOCK-READ:"
" BLOCK·READ:" channel;
channel; drive; track;
track; sector
or abbreviated
or abbreviated as
as
PRINT#file#, "B-R:"
PRINT#file#, " B·R:" channel; drive; track; sector
sector
This command
command will move one block of data from the diskette into the
selected channel. Once this operation has been performed, the INPUTS
INPUT# and
GET# statements can read the information.

BLOCK-WRITE
BLOCK-WRITE

BLOCK-WRITE command is the exact oppOSite


The BLOCK·WRITE opposite of the BLOCK·READ
BLOCK-READ
command. First you must fill up a data buffer wiwith information,
th your informati on , then you
write that buffer to the correct location on the disk.
FORMAT FOR BLOCK-WRITE COMMAND:
PRINT#file#, ""BLOCK-WRITE:"
PRINT#file#, BLOCK-WRITE:" channel; drive; track; sector
or abbreviated as
PRINT#filefl
PRINT#filelf,, ""B-W:"
B·W:" channel; drive; track; sector
v
When the data is is being put
put into
into the buffer,
buffer, a pOinter in the DOS
pointer in DOS keeps track
how many
of how 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

Downloaded from www.Manualslib.com manuals search engine


BLOCK-ALLOCATE
BLOC K·ALLOCATE
In
In order
order to
to safely
safely use random
use ra files
ndom fil along with
es along with regular
regular files
files,, your
your programs
programs
must check the BAM (Block Availability Map) to find available
must check the BAM (Block Availabil ity Map) to find available blocks, andblocks, and
change the BAM to reflect that you've used them. Once you update
change the BAM to reflect that you've used them. Once you update the BAM, the BAM,
your
your random
random files
files will
will be safe -— unless you perform the VALIDATE command.
command.

FORMAT FOR THE


FORMAT FOR BLOCK-ALLOCATE COMMAND:
THE BLOCK·ALLOCATE COMMAND:

PRINT#file#,
PRINT#file#, "BLOCK-ALLOCATE:"
"BLOCK·ALLOCATE:" drive; track; sector
drive; track;
If
If you
yo u try
try aa block
block that
that isn't available, error message to
available, the DOS will set the error to
number 65,65, NO BLOCK,
BLOCK, and set the track and bl block next
ock numbers to the next
available
available track and bl
block
ock number. Therefore,
Therefore, any time you attempt to write aa
block
block to
to the disk,
diSk, you must first try to allocate that block. If that block isn't
available,
available, read the next block available from the error channe
channell and the
thenn allocate
that
that block.
bl ock.

BLOCK-FREE
BLOCK·FREE
The
The BLOCK-FREE
BLOCK·FREE command
com mand is the opposite of BLOCK·ALLOCATE,
BLOCK-ALLOCATE, in that itit
frees
frees aa block
bl ock that you
you don't
don't want to use anymore for use by the sys system.
tem. ItIt is
is
vaguely
vaguely similar
si milar to the
the SCRATCH
SCRATCH command for files,files, since it doesn't really erase
any
any data
data from the disk
disk —
- just
just frees the entry,
entry, in this case just in the BAM
BAM..

FORMAT
FORMAT FOR BLOCK-FREE
BLOCK·FREE COMMAND: 0
PRINT#file#,
PRINT#file#, "BLOCK-FREE:"
" BLOCK·FREE:" drive;
drive; track; sector "
or
or abbreviated
abbreviated as
as
PRINT#file#,
PRINT#fi le#, "B-F:"
"B·F:" drive;
drive; track;
track; sector

USING
USING RANDOM
RANDOM FILES
The
The most
most common
common methodmethod for keeping track of which bl
blocks
ocks on the disk you
used,
used , is
is to
to build
bu ild up
up aa sequential file to go with each file.
each random fil e. Use this file to
keep
keep aa list
list of
of record,
record, track,
track, and sector locations. This
Thi s means that there are 3
channels
channe ls open
open to
to the
the disk
disk for
for each
each random
ran dom file:
fil e: one for the com
command channel,,
mand channel
one
one for
for the
the random
random data,
data, and
and the
the other for the sequential data. Thi
seq uential data. Thiss also means
that
that there
there are
are 22 buffers
buffers that
that you're filling
filling up at the same time.
time.

28
28

Downloaded from www.Manualslib.com manuals search engine


v

BUFFER-POINTER
BUFFER·POINTER
pointer keeps track of where the last piece of data was wri
The buffer painter written.
tten. It
pointer for where the next piece of data is to be read. By changing
also is the painter
pointer's location within the buffer,
the buffer painter's buffer, yo
youu can get random access to the
individual bytes within a block. This way, you can subdivide each block into
records.
example, let
For example, let's hypothetical
's take a hypotheti mailing
cal mai ling list. The information such as
name, address,
name, address, etc.,
etc., will take up a total of 64 characters maximum. We cou could
ld
divide each block of the random access file into 4 separate records records,, and by
track, sector,
knowing the track, sector, and record numbers, we can access that indiviindividual
dual
record.
FORMAT FOR BUFFER·POINTER
BUFFER-POINTER COM
COMMAND:
MAND:
PRINT#file#,
PRINT#fil e# , ""BUFFER-POINTER:" channel; location
BUFFE R-POINTER:" channel;
or abbreviated as
PRINT#file#, ""B-P:"
PRINT#file#, channel;; location
B-P:" channel
EXAMPLE OF SETIING
EXAMPLE SETTING POINTER
POINTER TO 64TH CHARACTE
CHARACTERR OF BUFFER:
BUFFE R:
v
PRINT# 15,
15, ""B-P:" 5; 64
B·P:" 5;

USER1 and USER2


USER2
generally
The user commands are general ly designed to work with machine language
(see the next chapter for more on this). The USER1
USER 1 and USER2
US ER2 commands areare
special versions of the BLOCK-R
BLOCK-READ BLOCK-WRITE commands, but ...
EAD and BLOCK-WRITE
with an important difference: the way USER1
USER1 and USER2 work with the buffer·
buffer-
v pointer.
pOinter.
The BLOCK-READ
BLOCK·READ command reads up to 256 charactecharacters,
rs, but slops
stops reading
when the buffer-pointer
buffer,pointer stored with the block says that block
bl ock is finished.
fin ished. The
USER1 command
command performs
performs the BLOCK-READ
BLOC K·RE AD operation, but
but first forces the
pointer to 255 in order to read the entire block of data from the disk.
painter disk.
FORMAT FOR USER1
USER1 COMMAND
v
PRINT#file#,
PRINT#file#, "U1:"
" U1 :" channel;
channel; drive;
drive; track;
track; sector
sec tor
or
or

v PRiNT#file#,
PRINT#file#, "UA:"
"UA:" channel; drive;
dri ve; track; sector
sec tor
There is no
no difference
difference between
between the U1
U1 and UA designations for this com
com-
mand.
mand.
v
The
The BLOCK-WRITE
BLOCK-WRITE command writes the contents of the buffer to the block block
on
on the disk
disk along with the value ofof the buffer-pointer.
buffer,pointer. The USER2 command
writes
writes the buffer
buffer without
without disturbing
disturbing the buffer-pointer
buffer-painter value
value already
already stored
stored on
on
that
that block of
of the diskette.
diskette. This
This is
is useful
useful when aa block is to be read in in with
with
BLOCK-READ,
BLOCK·READ, updated
updated through the BUFFER-POINTER
BU FF ER·POINTER and and PRINT#
PR INT#
statements,
statements, and
and then
then written
written back
back to
to the
the diskette with
with USER2.
FORMAT
FORMAT FOR
FOR USER2
USER2 COMMAND:
COM MAND:
PR)NT#file#,
PRINT#file# , "U2:"
" U2:" channel;
channe l; drive;
drive; track;
track; sector
sector
v or
or

PRINT#file#.
PRINT#file#, "UB:"
" UB:" channel:
channel ; drive;
drive; track;
track; sector
sector

29
29

v
Downloaded from www.Manualslib.com manuals search engine
CHART
CHART OF
OF BASIC
BASIC COMMANDS
COMMANDS FOR
FOR DISKS
DISKS AND
AND PRINTERS
PRINTERS
This
This chart
chart lists
lisls the
Ihe BASIC
BASIC commands
commands and
and statements
slalemenls that
that are
are used
used to
to per
per-
form
form operations
operations with
with disk
disk drives.
drives. Commands
Commands marked
marked with
with aa "• sign
sign can
can also
also be
be
used
used toto direct
direct output
output to
to printers
printers when
when you
you use
use the
the printer
printer device
device number,
number. which
which
is
is 4.
4. Disk
Disk Operating
Operating Systems
Systems (DOS)
(DOS) error
error messages
messages areare described
described in in Appendix
Appendix
B.
B.

Command Function
Command Function Examples
Examples

CLOSE'■
CLOSE Ends file
Ends file or
or CLOSE 11
CLOSE closes
closes file
file 1,
1. which
which
closes channel must
must have
have been
been
to aa device
to device previously
previously OPENed
OPENed
with
with the
the same
same
number
number
CMD'■
CMD Redirects output
Redirects output OPEN
OPEN 1,8,'1SCOTT"
1.8."SCOn" file
file must
must be
be OPENed
OPENed
from screen
from screen to
to first
first
device named
device named CMD
CMD11 sends
sends file
file 11 output
output to
to
disk
OPEN
OPEN 1,4:CMD
1.4:CMD 11 sends output
output to
to
printer

GET#
GET# Reads characters OPEN
OPEN 1,8,"SCOTT"
1.8."SCOn" OPENs
OPENs file 11 on disk.
one by one from GET# 1,A$
1.A$ reads from
from file 1;
1;
device named in assigns data to A$
OPEN statement GET# 1,A,B,C
1.A.B.C reads from file 1;
1;
assigns data to A,
A.
B, then C
then B. C then
back to A, etc.
A. etc.
LOAD Brings programs LOAD .."*",8
.. ·.8 loads 11st
st program
into current on disk
memory from disk LOAD ""SCM",8
SCM " .8 loads file SCM from
disk
LOAD "$".8
"$",8 loads file directory
(key in LIST to
{key
display)
INITIALIZE Returns drive to the OPEN 15.8.15."1"
15,8,15,"!" OPENs command
same state as when channel (15). When
you turned it on. command channel is
Use when error OPEN,. the
OPEN
prevents disk INITIALIZE command
operations. device
is sent to the device
named (the disk
named
drive, device 8).
drive.
INPUT#
1NPUT# Retrieves
Retrieves data 1,8,"MEYER"
OPEN 1.8."MEYER" OPENs file 11 on disk
stored on disk INPUT# 1.A.B
INPUT# 1,A,B reads data.
reads data, assigns
to variables
to variables AA and
and B
B

NEW
NEW Headers
Headers diskette. 15,8.15"N0:
OPEN 15.8.15" NO: OPENs file SCM. NO
Also erases SCM.01" means NEW
means NEW disk in
diskette. drive 0. SCM is
drive O. SCM is the
the
name of
name of the disk. 01
is
is the disk
disk id.

30

Downloaded from www.Manualslib.com manuals search engine


v
_

v
OPEN *
OPEN· Opens channel for 1,8,8,"D,W""
OPEN 1,8,8,"D,W opens file D on disk.
input or output W means write to
to a peripheral file.. 8 is the
file
secondary address,
required for disk. See
Appendix S.
OPEN 1,4 opens channel to
printer
prin ter
1,8.0
OPEN 1,8,0 opens file 11 to read
from disk
PRINT# *• Writes data to a OPEN 1,B,8,"SCM"
OPEN 1,8,8,"SCM" opens disk file 11 to
file write
PRINTS 1,"
PRINT# 1,"A";"B"
A" ;" B" writes A and B B to
1
file 1
1
CLOSE 1 writi ng to file 1
ends writing 1
v
RENAME
RENAM E Changes a file OPEN 15,8,15,"R: RENAMES
RENAM Es fifile
le 15.
name. newname
new name = old
name"
v
15,8,15,-R:
OPEN 15,8,15,"R: RENAMEs
RENAMES file
SCM = MEYER"
SCM= MEYER,
MEY ER, changing it
to SCM
SAVE Stores program SAVE ""SCM",8
SCM",8 stores file
fi le SCM on
disk
SCRATCH Erase files from
from OPEN 15,8,15"S:
OPEN Erases file GMS
disk GMS"
OPEN
OP EN 15,8,15"S: Erases all files that
M*"
M* " start with M.

VALIDATE Reorganizes disk. OPEN 15,8,15," V"


OPEN 15,8,15,"V" 15.
Validates file 15.
Collects blocks OPEN 15,8,15,
15,8,15, Validates fi le 15.
file 15.
taken up by by "VALIDATE"
improperly CLOSEd
files.
fil es. Do not use
with Random
Ran dom
Access
Access (User)
(User) Files.
Files.
v VERIFY
VERIFY Compares
Compares program
program SAVE
SAVE "SM",8
"SM",8 puts
puts current program
in current
current memory on disk
to
to stored program
program " SM" ,8
VERIFY "SM",8 SAV Ed
compares SAVEd
version
vers ion of
of SM
SM with
with
version
versio n still
sti ll in
in cur
cur·
rent
rent memory
memory to
to verify
program
correct program
storage
storage

Appendix
Appendix S
S and
and the
the Commodore
Commodore 64
64 Programmer's
Programmer's Reference
Reference Guide
Gu ide contain
contain
more
more information
information about
about these BASIC
BASIC commands and
and statements.
statements.
The 64 Programmer's
The Programmer's Reference
Reference Guide
Guide explains
explains all
all BASIC
BASIC version
vers ion 2.0
2.0 com
com·
v mands
mands and
and statements.
sta tement s. The
The Commodore
Commodore Peripheral
Peripheral Guide
Guide contains
conta ins more
more
detailed
detail ed information
information and
and sample
sample programs
programs for
for using
using disk
disk drives
drives and
and printers.
pri nters.
There
There books
books are
are available
available at
at bookstores
bookstores and
and from
from your
yo ur Commodore
Commodore dealer.
dealer.

31
31

Downloaded from www.Manualslib.com manuals search engine


-

n
n

—■

—■

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
CHAPTER
CHAPTER 33
BEGINNING BASIC
BEGINNING BASIC
•• Printing and
Printing and Calculating
Calculating
•• Mathematical Functions
Mathematical Functions
•• Multiple Calculations
Multiple Calculations On
On One
One Line
line
• Execution
Execution Order
Order in
in Calculations
Calculations
•• Combini ng PRINT'S
Combining PRINT's Capabilities
Capabilities

PRINTING
PRINTING AND CALCULATING
CALCULATING
If you
If you don't know
know BASIC,
BASIC, this
this section
section teaches
teaches you
you how
how to
to do
do some
some simple
simple
things like
things like print
print words
words and
and calculate
calculate problems.
problems.
The PRINT statement tells
The tells the 64 computer
the 64 computer to
to print
print something
something on
on the
the screen.
screen.
PRINT
PRINT is
is one
one of
of the
the most useful
useful and
and powerful
powerful commands in
in the
the BASIC
BASIC
language. You
language. You can
can use itit to
to display
display just
just about anything,
anything, including graphics
graphics and
and
the
the results of computations.
computations. To
To use
use the PRINT
PRINT command,
command , follow these steps:
1.
1. Key in
in the word
word PRINT.
PRINT. This
This tells the
the computer what kind of job
job you want
want it
do.
to do.
2. Key in a
a quotation
quotation mark.
mark. This tells
tel ls the
the computer
computer where the message you
you
want to print begins.
3. Key in
in whatever you want to print on the
the screen.
4. Key in a closing quotation mark. This tells the computer where the message
you want to print ends.
you
5. Press the RETURN key.
key. This
Thi s tells the computer to follow your instructions,
which in this case is to print your message exactly as you typed it.

When you follow these steps,


steps, the computer prints your message and
displays the READY prom pt. It looks lilike
prompt. ke this:
PRINT ""II LOVE
LOVE MY COMMODORE" You key in this and press RETURN
II LOVE
LOVE MY COMMODORE The computer prints this
READY

The
Th e Executive 64 prints whatever you enclosed in quotes. Remember to key
in both quotation marks.
If you make a mistake in your PRINT statement, useuse the INSTfDEL
INST/DEL key to cor-
cor
rect your error. You like before you press
You can change as many characters as you like
the RETURN key.
mistake that you didn
If you made a mistake didn't
't catch before you pressed the RETURN
Instead, it displays an error
key, the computer can't follow your instructions. Instead,
help you figure out what you did wrong. For example:
message to help
?SYNTAX
7SYNTAX ERROR
ERROR

IfIf you get this message,


message, check over what you typed in to see where you made
mistake.
a mistake. The computer is very precise,
is precise, and it can
can't instructions
't follow in stru ct ions that
contain spelling errors or other mistakes.
contain mistakes. To avoid mimistakes, be sure you type
stakes, be
things in in the correct form.
Remember th
Remember that best way to get
at the best get to know
know BASIC
BASIC and
and your 64
64 is
is to try dif-
dif
ferent things and see what happens.
happens.

32

Downloaded from www.Manualslib.com manuals search engine


v

v USING
USING PRINT
PRINT TO
TO CALCULATE
CALCULATE
You
You can
can use
use PRINT
PRINT to
10 do
do more
more than
Ihan just
just display
display what
what you
you put
put in
in quotation
quotation
marks.
marks. You
You can
can also
also use
use itit to
to perform
perform calculations
calcu lations and
and automatically
automatically display
display
th e results.
the results. Follow
Follow these
these steps:
steps:
1. Key
1. Key in
in PRINT
PRINT
2.
2. Key
Key in
in the
the calculation
calculation you
you want
wa nt to
to solve.
solve. DON'T
DON'T enclose
enclose itit in
in quotation
quotation
marks.
marks.
3.
3. Press
Press the
the RETURN
RETURN key.
key. The
The computer
computer displays
displays the
th e answer
answer followed
followed by
by the
the
READY prompt.
READY prompt.
v Here's
Here's an
an example:
example:
PRINT
PRINT 12 + 12
12 + 12 Type
Type this
this line
line and
and press
press RETURN
RETURN
24
24
v The computer
comp uter displays
displays
READY
READY The
v •

Be
Be sure you
you leave off the
the
the answer
answer
the quotation
quotation marks when
when you
you want
want the computer
computer to
to
solve
solve aa problem.
problem. If you type the
the problem
problem inside quotation
quotation marks,
marks, the
the computer
computer
v assumes youyou just
just want
want to
to display
display the
the problem, not solve it. For example:
PRINT "12 + 12"
" 12 + in this
Key in this line
12 + 12
12 + 12 and press RETURN
and RETURN
u READY
READY The computer displays
displays


■ what 's in
what's in quotes
So all you have to do to use PRINT as a calculator is omit the quotation
marks. You can use PRINT to add,
add, subtract, multiply
multiply and divide.
divide. You can also
v use exponents and perform advanced mathematical functions such as figuring
figu rin g
square roots.

MATHEMATICAL FUNCTIONS

ADDITION

( + ) to tell the computer to add numbers.


Use the plus sign (+) numbers. Remember to
press RETURN after you type PRINT and the calculation. ThiThis com
s tells the com-
puter to follow your instructions.

SUBTRACTION
Use the minus
minus sign (-) to subtract. Press the RETU RN key at th
RETURN thee end of the
calculation. For example:
PRINT 12 - 9
12-9 in this and RETURN
Key in RETURN
3 this
The computer displays thi s

MULTIPLICATION
MULTIPLICATION

Use the asterisk ((*)


Use multiply. You can
* ) to multiply. can't use the conventional x because
't use because
the computer would think it's it's the letter
letter x, not
not the multiplication
multiplication sign. Press
Press
u RETURN
RETURN at the end of the ca lculation. For
calculation. For example:

PRINT 12
PRINT 12 ** 12
12 Key in
Key in this and RETURN
RETURN
144
144 The
The compu
computer ter displays this

33
33

Downloaded from www.Manualslib.com manuals search engine


-

DIVISION
DIVISION
Use the
Use the slash mark
mark (~
(/) for divisio
division. Press the
n. Press the RETURN
RETURN key
key after you
you type
type the
the
calculation. For
calculation. For example:
,—,

PRINT 144/12
PRINT 144/12 Key in
Key in this and RETURN
RETURN
12
12 The computer displays this

EXPONENTIATION
EXP ONENTIATION
Use the up arrow ((t
Use t )) to raise a number
number to a power. Press the RETURN
RETURN key
after you type the calculation. For example, to find 12 to the fifth power, type
this:
PRINT 12 tt 5 RETURN
Key in this and RETURN
248832 The computer displays this

This is the same as:
PRINT 12 • 12 •* 12 •* 12 •* 12
248832 .—V

TIP:
TIP:
BASIC has shortcuts that make programming even faster. One shortcut is abo ab
keywords. For example,
breviating BASIC keywords. example, you can use a ?? in place of PRINT.
book, we
Throughout this book, we'll BASIC keywords.
'll show you other abbreviations for BASIC
Appendix D D lists these abbreviations and shows what is displayed on the
screen when you type the abbreviated form
form..

"

~-

34
34

Downloaded from www.Manualslib.com manuals search engine


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-
?3 * 5 _ 7+2
7 + 2 Key in this and RETURN
10 The computer displays this
v
So far our examples have used small numbers and simple problems. But the
v 64 can do much more complex calculations. The next example adds large
numbers.
Notice that 78956.87 doesn't have a comma between the 8 and the 9. You
BASIC. BASIC thinks commas indicate new
can't use commas this way in BASIC.
v numbers,
numbers, so it would think 78,956.87
78.956.87 is tw
twoo numbers:
numbers: 78 and 956.87. Remember
to press RETURN after you type the problem.
? 1234.5 + 3457.8 + 78956.87
?
83649.17
83649. 17
The next example
The example uses a ten digit number. The 64 can work with numbers
that have up to ten dig
digits,
its, but can only display nine digits in the answer. So the
64 rounds numbers that are more than nine digits. Numbers five and over are
v rounded up,
up, and numbers four and under are rounded down. This means that
12123123.5. Because of rounding,
12123123.45 is rounded to 12123123.5. rounding, the computer
doesn't give the same answer you'd get if you added these numbers by hand. In
this case,
case, the answer is 12131364.817. You can see the difference ro rounding
unding
v
makes.
makes.
?
? 12123123.45
12123123.45 + 345.78 + 7895.687
v 12131364.9
The
The 64 prints
pri nts numbers between 0.01
0.01 and
and 999,999,999 using standard nota·
nota
tion,
tion , except for leaving out
out commas in large numbers.
numbers. Numbers outside this
range are printed using scientific notation. Scientific notation lets you
yo u express
a
a very large or very small
smal l number
number as aa power of
of 10. For example:
v
?123000000000000000
? 123000000000000000
v 1.23E+17
1.23E + 17
Another way of expressing this number is is 1.23
1.23 *" 10
10 117.
! 17. The
The 64 uses scien
scien-
tific notation
notation for
for numbers with lots of digits
digits to
to make them easier to read.
read.
There
There is
is a limit to
to the numbers
numbers the
the computer
computer can handle,
hand le, even
even using scien
scien·
tific
tific notation.
notation. These
The se limits are:
v
Largest
Largest numbers: +/- 1.70141183E + 38
1.70 141183E+38
v Smallest numbers:
numbers: +/-
+ / - 2.93873588E-39
2.93873588E - 39

35
35

Downloaded from www.Manualslib.com manuals search engine


EXECUTION
EXECUTION ORDER
ORDER IN
IN CALCULATIONS
CALCULATIONS
IfIf you
you tried
tried to
to perform
perform some
some mixed
mixed calculations
calculations ofof your
your own,
own , you
you might
might not
not
have
have gotten
gotten the
the results
results you
you expected.
expected. This
This is
is because
because the
the computer
computer performs
performs
calculations
calculations in
in aa certain
certain order.
order.
In this
In this calculation:
calculation:
20 ++ 8/2
20 8/2
the
the answer
answer is is 14
14 ifif you
you add
add 2020 to
to 88 first,
fi rst, and
and then
then divide
divide 2828 by
by 4.4. But
But the
the answer
answer
is 24 ifif you
is 24 you first
first divide
divide 88 by by 2,
2, and
and then
then add
add 20
20 and
and 4.
4.
On
On thethe 64,
64, you
you always
always get
get 24
24 because
because the the computer
computer always
always performs
performs calcula
calcula·
tions
tions inin 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
general
general movement,
movement, some some types
types of of calculations
calc ulations take
take precedence
precedence over over others.
others.
Here is
Here is the
the order
order of
of precedence:
precedence:
First:
First: - minus
minus sign
sign for
for negative
negative numbers,
numbers, not
not for
for subtraction.
subtraction.
Second:
Second: tt exponentiation, left
exponentiation, left to
to right
right
Third:
Third: */
"I multiplication
multiplication and
and division,
division, left
left to
to right
right
Fourth:
Fourth: +
+ -- addition
addition and
and subtraction,
subtraction, left
left to
to right
right
This
This means
means that
that the
the computer
computer checks
checks the
the whole
whole calculation
calculation for
for negative
negat ive
numbers
numbers before
before doing
dOing anything
anythi ng else.
else. Then
Then itit looks
looks for
for exponents;
exponents; then
then it per
per·
forms
forms all
al l multiplication
multi plication and
and division;
division; then
then itit adds
adds and
and subtracts.
subtracts.
This
This explains why
why 20 + 88 /1 22 is 24:
20 + 24: 88 is
is divided
divided by
by 22 before
before 20
20 is
is added
added
because
because division
division has
has precedence
precedence over
over addition.
addition.
There
There is
is an
an easy way toto override the order
order of
of precedence: enclose any
calculation
calcu lation you want solved first
firs t in
in parentheses. IfIf you add parentheses to the
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 + 15 " (2 -- 3)
??30
15
(30 + 15)"
??(30 15) * (2 -- 3)
-45
last example has
The last has two calcu
calculations in parentheses.
lations in parentheses. As usual,
usual, they're
left to right,
evaluated from left right, and then the rest
rest of
of the problem
problem is
is solved.
solved. When
have more
you have more than one
one calcul
calculation in paren
ation in parentheses, can furthe
theses, you can furtherr con
control
trol the
order by
order by using parentheses
parentheses withi
within parentheses. The problem
n parentheses. problem in
in the
the innermost
innermost
parentheses is
parentheses is solved
solved fifirst. For example:
rst. For example:

30 +
?? 30 + (15
(15 "' (2
(2 -- 3))
3))
15
15
In this
In this case,
case, 33 isis subtracted
subtracted from
from 2,
2, then
then 15
15 is
is multiplied
multiplied by
by -- 1,
1, and
and -- 15
15 is
is
added to
added to 30.
30. As
As you
you experiment
experiment wi
with solving calculations,
th solving calculations, you'll
you'll get
get fami
familiar
liar
with the
with the order
order in
in which
which mixed
mixed calculat
calculations are solved.
ions are solved.
36
36

Downloaded from www.Manualslib.com manuals search engine


COMBINING
COMBINING PRINT'S
PRINT'S CAPABILITIES
CAPABILITIES
The
The 64
64 computers
computers let let you
you combine
combine the the two
two types
types of
of print
print statements
statements thatthat
you've
you've read
read about
about inin this
this book.
book. Remember
Remember that that anything
anything you
you enclose
enclose inin quota
quota-
v tion
tion marks
marks isis displayed
disp layed exactly
exactly as
as you
you type
type it.
it.
v The
The next
next example
example shows
shows how how youyou cancan combine
combine the the types
types ofof PRINT
PRINT
statements.
statements. TheThe equation
equation enclosed
enclosed in in quotes
quotes is is displayed
displayed without
without being
being solved.
solved.
'-' 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
the PRINT
PRINT statement
statement {semicolon
(semicolon means
means no no space).
space).
'-'
?? "5
" 5 *• 99 == ";
"; 55 *• 99 You
You key
key in
in this
this and
and RETURN
RETURN
55 •• g9 =
= 45
45 The
The computer
computer displays
displays this
this
Remember,
Remember, only only the
the second
second part
part of
of the
the statement
statement actually
actually solves
solves the the calcula
calcu la-
tion.
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
the
the parts
parts of
of aa mixed
mixed PRINT
PRINT statement
statement withwith some
some punctuation
punctuation for
for itit to
to work
work the
the
way
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
space
space between
between thethe two
two parts
parts when they're
they're displayed.
displayed. AA semicolon
semicolon leaves
leaves out
out
v space.
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
When you use a comma to separate parts of a PR INT statement, the comma comma
works as a tab,
tab, sending
sending each
each result into
into the
the next
next zone.
zone. For
For example:
example:
?" 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 + (-
6,2 t13,6/4,100 48)
(-48)
'-' 6
6 --22 8
8 0.5
[1.5
52
Here's the difference when you use semicolons:
semicolons:

? 2 '* 3;4
3:4 -- 6;2 ,t 3;6 4:100 + (- 48)
3:6 f/ 4;100
v 6
6-2 - 2 8 1.51.5 52

use the difference between


You can use between the comma and the semicolon in
in format-
format
ting PRINT
PRINT statements to create complex displays.

37
37

Downloaded from www.Manualslib.com manuals search engine


-

n
-

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
CHAPTER 4
WRITING SIMPLE PROGRAMS IN BASIC
• Numbers
Line Nu mbers
• The GOTO Statement
• Using the LIST Command
• Editing Tips
• How to Use Variables
FOR...NEXT
• Using FOR. .. NEXT Loops
n
you
So far this book has shown yo You've
u how to do simple things with your 64. You 've
n
experimented
experim typing
ented with typ single
in g si instructions
ngle lines of in computer
structions into your comput er and
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.
you'll
But you 'll probably want to use your computer to do more complex jobs that
combine
use more than one statement. When you combin e a number of statements into
PROGRAM, you can use the fu
a PROGRAM, fullll power of your 64.
To see how easy it is to write your
you r first program
fi rst prog ram on the 64, follow these steps:
Ihe 64,
1. Clear the screen by holding down the SHIFT key while you press the
1.
CLR/HOME key.
CLRlHOME
in NEW and press RETU
2. Key in RETURN.
RN . This clears out information that might still
your
be in the computer's memory after yo experimenting.
ur expe ri menting.
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
RETURN,, you
line and press RETURN you'll computer
'll notice that the comp uter doesn't respond to
the PRINT command right away like it did before when you typed in the same
commands.
kind of com mands. This is because you are now beg beginning
inning the command
with a line number (10). When you us use numbers, the computer knows
e line numbers,
you're
that yo program,, so it waits for you to finish keying in the whole
u're writing a program
following
program before follow ing any of your instructions.
5. Key in RUN and press RETURN. The RUN command tells the computer that
you've
you finished
've fin keying
ished keyi you're
ng in program statements, and you your
're ready to have your
instructions followed. Here's what happens when yo
youu RUN this program:
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTI VE 64
EXECUTIVE
EXECUTIVE
EXECUTIVE 64
EXECUTI VE 64
EXECUTIVE
EXECUTIVE 64

38

Downloaded from www.Manualslib.com manuals search engine


6. Stop
6. 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
continues follow your
your orders by
by printing
printing EXECUTIVE
EXECUTIVE 64
64 over and
and over
over un·
un
interrupt wi
til you interrupt with RUN/STOP key.
th the RUN/STOP key. Here's
Here's how
how your screen looks
looks when
when
press STOP.
you press
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
v EXECUTIVE 64
EXECUTIVE
EXECUTIVE 64
EXECUTIVE
v 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
you program. They also tell the computer in what order you want the
're writing a program.
executive. Without line numbers to te
statements in your program to executive. tell com
ll the com·
puter when to follow which instruction, the computer doesn't know what to do
first.
fi rst.
longer and more comp
The longer complex
lex your program is, the more important it is to
remember that the computer relies on you to tell it WH
WHEN
EN to do things, as well
as WHAT to do. One good thing about this is that you can key in line 20 before
line 10 because the computer just checks the line numbers to find out the order
for executing the program
program.. The computer doesn
doesn't
't check for the order your lines
the
appear on th screen.
e screen.
Another advantage of line numbers is that you can use the number to refer to
the statement on the line. When you want to go back and repeat the execution
of aa statement, all
al l you do is refer to it by line
line number in
in a
a GOTO statement,
statement, as
you did
did in the
th e example
example above.

39
39

Downloaded from www.Manualslib.com manuals search engine


THE GOTO
THE GOTO STATEMENT
STATEMENT
When you
When you told
told the
the computer
computer to
to RUN
RUN the
the sample
sample program
program above,
above, EXECUTIVE
EXECUTIVE
64
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·
ment in
ment in line
line 20.
20.
The
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. I)
Then
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
the next
the next line.
line. ()
You can
You 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
that's
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 ,
even
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 .
In
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
line 20. There,
line 20. 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
do
do what
what line
line 10
10 says
says toto do.
do. So,
So, the
the program
program prints
prints the
the message
message in in line
li ne 10
10 again,
again,
and
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 soso on.
on.
Thi s repetition
This repetition is
is called
called aa LOOP. Because the
LOOP. Because the example
example doesn't
doesn' t give
give the
the com
com·
puter
puter aa way
way out ofof the
the loop,
loop, the
the circle
circle repeats endlessly.
end lessl y. You
You have
have toto halt
halt the
the cy
cy·
interrup ting the program with the RUN/STOP key.
cle by interrupting
It's best to
It's to include
include aa statement in
in your program that
that ends the
the loop
loop so
so you
you
don't
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
later in
later in this chapter.

USING THE LIST COMMAND


Now that you've interrupted execution of the sample program, key in LIST on
your screen.
screen . Your program is now displayed intact because it's
it's still in the com
com-
puter's memory, even though you interrupted the program's execution.
puter's memory, execution. The only
difference is that the computer changed your your?? into the word PRINT.
PRINT. This
doesn't program, it's just the way the computer does things. When
doesn' t affect your program,
you use the LIST command,
command, the computer also displays the lines of the pro·
pro
order, even if you entered the lines out of order.
gram in correct numerical order,
One of the important differences between
between writ
writing
ing programs and entering
single lilines
nes in the immediate/calculator mode is that you permanen
permanently
tly lose an
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.
here, you can change the program, SAVE it,
From here, it, or RUN it again.

40
40

Downloaded from www.Manualslib.com manuals search engine


EDITING TIPS
EDITING TIPS
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,
change line, the
the 64
64 offers
offers you
you aa number
number of
of editing
editing options.
options.
1.
1. You
You can
can retype
retype aa line
line any
any time,
time, and
and the
the computer
computer automatically
automatically substitutes
substitutes
the
the new
new line
tine for
for the
the old
old one.
one. All
All you
you have
have to
to do
do to
to replace
replace aa line
line is
is use
use the
the
same
same line
line number.
number. For
For example:
example:
10 ?? "My
10 " My name
name is
is Sarah"
Sarah "
20 ?? "I
20 was born
" I was born in
in California"
California"
20 ?? "I
20 " I live
live in
in Pennsylvania"
Pennsylvania"
RUN
RUN
MyMy name
name isis Sarah
Sarah
II live
live in Pennsylvania
in 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
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 second
the second line 20 is
line 20 is still
still part
part of
of the
the program,
program.
2.
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
and
and pressing
pressing the
the RETURN
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
is gone,
is gone, and
and so
so is
is the
the line
line number.
number.
3.
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·
sor
sor back
back to
to the
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
you
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
replace the old line. Remember to
to use
use the
the INST/DEL
INST/DEL key
key to insert or
or delete.
delete.
When you
you finish editing,
editing, you can check your program again to verify changes
by
by keying in the LIST command.
com mand. Remember that LIST LIST also puts
pu ts lines in
numerical
numeri cal order
order if you've
you 've keyed them in out of order.
order.
Try editing our sample program by adding a a semicolon to the
the end of the line,
line,
EXECUTIVE
changing EXECUTI VE to COMMODORE,
COMMODORE, and omitting the 64. After you 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 COMMODOR
COMMODORE COMMODOREE COMMODORE COMMODORE
COMMODORE COMMODORE COMMODOR
COMMODORE COMMODORE
E COMMODORE
BREAK IN 10
READY

41
41

Downloaded from www.Manualslib.com manuals search engine


HOW TO USE VARIABLES
stands lor
A variable is a symbol that slands for a value. Somelimes
Sometimes Ihe
the value of a
before you RUN a program. One of the purposes 01
variable is unknown belore of a pro·
pro
variable. Look at this line from a
gram may be to find one or more values for a variable.
program:
10 X = 28 +
+ Y

equation,
In this equal X and Yare
ion, X Y are variables. Suppose X X slands
stands for Ihe
the number of
days in a month. One of Ihethe best th things
ings about a variable is th that
at you can reuse it
in a prog
in program, can stand fo
ram, so X can forr the days in aallll the months, not just one month.
This is where Y Y comes in. All monmonthsth s have 28 days,
days, so Y stands for the days
over 28. Later in this chapter there's a prog ram that gives values to these two
program
variables.
Th
Thee most important thing
thi ng now is understandi
understanding ng how vari ables work,
variables work, because
variables allow you to do complex tasks with you computer. Variables also let
you write programs that are very reusable.
n
Imagine that your computer contains a bunch of little slots, like a bank of r
mail boxes. When you write a program,
program, you can use some of these slots to hold
hold
values. All you
you do is give a name to the slots you need,
need, and during the program
you can put values into each slot by using the slot's name.
name. For example, in the
above, we used two slots by naming one X
equation above, X and one Y. At the beginning
program, these slots have names, but they're empty.
of a program, empty. Here's what happens
when you put aa value in Y's slot:
X Y
3

Now the variable Y


Y has the val
value
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
Here's how the program
program looks:
10
10 X
X = 28 + YY
28 +
20
20 Y
Y = 33
30 ? "THE NUMBER
30 NUMBER OF DAYS
DAYS IN MAY IS";X
IS";X
RUN
RUN
THE
TH E NUMBER
NUMB ER OF DAYS IN
IN MAY IS
IS 31
31
Here's
Here's another
another program
program that
that uses
uses variables:
variables:
10
10 X%
X % = 15
15
20 X
X = 23.5
23.5
30
30 X$
X$ = 'TOTAL:11
"TOTAL:"
40
40 Y
Y == X%
X% ++ XX
50
50 ?? X$;Y
X$;Y

42
42

Downloaded from www.Manualslib.com manuals search engine


When
When you
yo u RUN
RUN the program, the
the program, the imaginary
imaginary slots
slots look
look like
like this
this after
after line
line 30
30 is
is ex-
ex
ecuted:
ecuted:
x% X X$ Y
15 23.5 TOTAL:

When
When you
you RUN
RUN the program. Y
the program, Y gets a val
value:
ue: 38.5

The
The above
above example
example uses
uses the
the three types of
th ree types of variab
variables:
les:

v POSSIBLE
POSSIBLE
TYPE
TYPE SYMBOL
SYMBOL DESCRIPTION EXAMPLES VALUES
Integer %
% whole numbe
numbers
rs X%
A /o,, A1 %
/o 15,102,3
Text
Text string
stri ng $S characters
characters in X$. AB$
X$, ""TOTAL",
TOTAL",
quotes ""DAY 1"
DAY 1"
Floating
Floating read (decimal) X, AB
X, 23.5, 12,
point
point or whole num
numbers
bers +2
1.3E+2
1.3E

Be
Be sure
sure you
you use
use the
the right variable types in your programs. If you try to do
something
something like
like assign aa text string to an integ
integer variable,, your program won
er variable won't
't
work.
work .
There
There are a few
few other
other things
th ing s to keep in
in mind when you ass
assign
ign names to
variables:
variables:
•• A
A variable
variable name
name can
can have
have one or two characters, not cou
counting special
nting the special
symbol
symbol used
used with
with integer and text string variables.
•• You
You can
can use
use more
more than
than two alphabetic characters in
in a variable name, but
but the
computer
computer only
only recognizes the first two. So the computer would
comp uter wou ld think PA,
PA.
PARTNO
PARTNO and
and PAGENO
PAGENO are the same variable
variab le referring to the same ""slot".
slot" .
•• A
A program
program is
is easier
easier for people to read when you use longer variable names,
but
but when
when you
you use
use more
more than two characters in
in a name,
name, be sure the first two
are
are unique.
unique.
•• You
You can
can use
use X,
X, X%,
X% , and
and XS
X$ in
in one program because the special symbols % %
and $ make each variable
and $ make each vari able name unique.
uniqu e. The same is true of A2, A2%,
A2 , A2% , and
A2$.
A2$.
•• The
The first
fi rst character
charac ter must
must be alphabetic (A to Z). The second and any later
characters
characters cancan be
be either alphabetic or numeric (0(0 to 9). Remember that the
computer
comp uter ignores
ignores every
every character after
after the second unles
unless s it's a % or $ in the
third position.
third position.
•• Variable
Variable names
names can't
can ' t contain
contain BASIC keywords,
keywords, which
wh ich are also called reserv·
reserv
ed
ed words.
words. These
These are
are thethe words
word s like PRINT and RUN that are part of the
BASIC
BASIC language.
language. Appendix
Appendix D D lists
lists all
all the
the BASIC
BASIC reserved words.
wo rd s.

v
43
43

Downloaded from www.Manualslib.com manuals search engine


Here's
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
example
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.
NEW
NEW
10X;1
10 .05
X = 1.05
20Y;3oo
20 Y = 300
30Z;X·Y
30 Z = X * Y
40 PRINT
40 PRINT "SEATS
"SEATS AVAILABLE:";Y
AVAILABlE: ";Y
50 PRINT
50 PRINT "TICKETS
" TICKETS AVAILABLE:";Z
AVAllABlE:";Z
60Y;Y+1
60 Y = Y + 1
70 PRINT
70 PRINT "OVERBOOKING
" OVERBOOKING POINT:";Y
POINT:";Y
RUN
RUN
SEATS AVAI LABlE: 300
SEATS AVAILABLE: 300 a
TICKETS AVAILABLE:
TICKETS AVAILABLE: 315
315
OVERBOOKIN G POINT:
OVERBOOKING POINT: 301
301
lines (10
Lines (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.
Notice that
Notice that at
at line
line 40,
40, the
the value
val ue for
for YY is
is 300.
300.
Line
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
shows
shows that
that aa variable
vari able can
can have
have more
more than
than one
one value
value in
in aa program.
program.
Line
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
make
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
algebra,
algebra, but this kind of
kind of statement is commonly used in programming.. It
common ly used in programming It
means:
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
replace the first value
va lue of
of the variable
variable with
with this new
new value. YouYou can also use
statements like
statements like these:
these: ^
Y ; Y - 1
YrY-1
Y; Y
Y = Y +
+ X X
Y =
Y Y 12
; Y/2
Y =
Y ; Y·(X+2)
Y ' (X + 2)

44
44

Downloaded from www.Manualslib.com manuals search engine


USING
USING FOR/NEXT
FOR/NEXT LOOPS
LOOPS
We
We mentioned
mentioned loops
loops earlier
earlier in in this
th is chapter
chapter during
during the
the explanation
explanation ofof the
the
GOTO
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
lines in
lines in aa program.
program.
The
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
number
num ber of
of times
ti mes aa segment
segment ofof aa program
program isis executed.
executed. The
The FOR
FOR statement
statement sets
sets
aa limit
limit on
on the
the number
num ber ofof times
times the
the loop
loop will
wi ll execute
execute by
by assigning
assig ning aa range
range of
of
v
values
values to
to aa variable.
variabl e. For
For example:
exampl e:
FOR COUNT
FOR COUNT == 11 TO
TO 44
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 toto see
see ifif
the
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
continues
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 -
ample,
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
chapter, here's
chapter, here's what
what happens:
happens:
10 FOR
10 FOR CT = 11 TO
TO 44
20 ?? "EXECUTIVE
20 " EXECUTIVE 64
64 "; "COUNT=
"; "COUN T = ";CT
";CT
30 NEXT
30 NEXT CT
CT
RUN
RUN
v EXECUTIVE 64
EXECUTIVE 64 COUNT=
COUNT = 11
EXECUTIVE 64
EXECUTIVE 64 COUN T= 22
COUNT=
EXECUTIVE 64 COUNT= 3
EXECUTIVE 64
EXECUTIVE COUNT= 44
COUNT=

Now that you've added


added the FOR/NEXT
FOR/NEXT loop,
loop, you don't have to break
yo u don't break in with
execution.
the STOP key to halt the program's execution.
This FOR/NEXT loop works like this:

Line
Li ne 10 gives the variable
the va range
riable CT a rang e of values from 11 to 4, and tells
te lls the com,
com
puter to execute the next lines until CT equals 4.
Line 20 tells the computer to print EXECUTI
EXECUTIVE VE 64.
64.
Line 30 tells the computer to add 11 to ththe value
e current val ue of CT. As long as the
value
val remains
ue of CT rema within
ins withi n the range of 1 1 to 4, the program repeats
repeats,, and EX,
EX
ECUTIVE 64 is PRINTed again.again. When CT equals 4, line 20 executes one more
time. When line 30 again adds 1 1 to CT,
CT. the computer knows that CT is now out
range.. So the computer stops executing the loop,
of range loop, and the program ends by
itself.

45
45

Downloaded from www.Manualslib.com manuals search engine


"

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
-

CHAPTER 55
CHAPTER
*-
ADVANCED BASIC
ADVANCED BASIC
•• Introduction
Introduction

•• Simple An imation
Simple Animation

•• INPUT
IN PUT
•• Using
Using the
the GET
GET Statement
Statement for
for Data
Data Input
Input
•• Using
Using GET
GET to
to Program
Program Function
Function Keys
Keys ^

•• Random
Ran dom Numbers
Numbers and
and Other
Other Functions
Functions

•• Guessing Game
Guessing Game
(->
•• Your Roll
Your Roll
•• Random Graphics
Random Graphics

INTRODUCTION
INTRODUCTION
The
The next
next few
few chapters
chap ters are
are for
for people
people who
who are
are familiar
familiar with
with BASIC
BASIC program
program·
ming
ming language
language and
and the
the concepts
concepts necessary
necessary to
to write advanced
advanced programs.
prog rams.
Those
Those of
of you
you who
who are
are just
just starting
st arting to
to learn
learn how
how to
to program
program maymay find
find some
some of
of
the information
information too technical to understand completely.
comp letely. But
But you'll
you 'll find some
some
simple
simple examples
examples that
that are
are written
wri tten for
for new
new users in two
users in two chapters.
chapters, SPRITE
SPRITE
GRAPHICS and CREATING
GRAPH ICS and SOUND. These
CREATING SOUND. examples will
These examples will give you a
give you a good
good idea
idea
of how to use the sophisti
sophisticated
cated graphics and sound capabilities
capabili ties available on
yo ur Exec
your utive 64.
Executive 64.
If you want to learn more about writin writing
g programs in BASIC, check the
bibliography
bibli ography inin the
the back
back ofof this
this manual
manual (Appendix
(Appendix N).
N).
IfIf you
you are
are already
already familiar
familiar with
with BASIC
BASIC programmi
programming, the following
ng, the following chapters
chapters
will help
will help you
you get
get started
started with
with advanced
advanced BASIC
BASIC prog
programming techniques.
ramm ing techn You'll
iques. You 'll
find extensive
find extensive information
information about
about advanced
advanced prog
programming
rammin g inin th
the COMMODORE
e COMMODORE
64 PROGRAMMER'S
64 PROGRAMMER'S REFERENCEREFERENCE GUIDE,GUIDE, which
which is
is available
available through
through your
your
local Commod ore
local Commodore dealer. dealer.

46
46

Downloaded from www.Manualslib.com manuals search engine


SIMPLE ANIMATION
capabilities
You can use some of the 64's graphic capa putting
bilities by putt whatt
ing together wha
you've
you manual, along with a few new conce
've learned so far in this manual, concepts.
pt s.
following program to see what you can do wit
Try entering the foltowing withh graphics.
Notice that you can include cursor controls and screen commands WITHIN a
PRINT statement. When you see something like < <CRSR > in a program
CRSR left >
listi ng, hold down the SHIFT key and press the <
listing, < -
- CRSR
CRSR -- >
> key. The screen
the
shows th left, which
e graphic representation of a cursor left, which is two vertical reversed
bars. The graphic represen
bars. representation
tation of the SHIFTed CLRlHOME
CLR/HOME key is a reversed
heart.

INDICATES NEW
NEW COMMAND
10 REM BOUNCING BALL
"(CLR/HOME^
20 PRINT "(CLR/HOME "
25 FOR XX = 1 TO 10: PRINT "(CRSR/DOWN)"
"(CRSR/DOWN)":NEXT
:NEXT
30 FOR BL = 1 1 TO 40
40 PRINT" . (CRSR LEFT)";:REM
LEFT)";:REM is a SHIFT - Q
aSHIFT-Q
50 FOR TM
FOR TM =\i TO 5
= 1 TO 5 ----~~----
NEXTTM THESE SPACES
THESE
60 NEXT TM
ARE INTENTIONAL
ARE INTENTIO NAL
70 NEXT BL
75 REM MOVE
MOVEjBALL
BALL RIGHT TO LEFT
80 FOR BL =/40 =
40 TO 11 STEP - - 11
PRINT ""^CRSR
90 PRINT LEFT) (C
(CRSR LEFT) (CRSR LEFT) (CRSR LEFT)";
RSR LEFT)
FOR
100 FO R TM = 11 TO 55
110 NEXTTM
110 NEXT TM
120 NEXT BL
130 GOTO 20

TIP:
All words in this text will
wi ll be completed on on one line. However, as
line. However as lonq
long as
as you
yo u
don 't hit
don't hit £ ' ;liIli'Ii'
your
your 64
64 wil
wi ll automatically to the
au tomatica lly move to the next
next line even
even in
in thp
the
middle
midd le of aa word.
word.

When
When this
this program RUNs,
RUNs, it displays aa bouncing
bouncing ball
ball moving across the
screen from left
screen left to right
ri ght and
and back again. Take
Take aa close
close look at the
the program
program to
to see
how this
th is is done.
done.
Line
Line 10
10 is
is aa REMark
REMark that
that tells
tel ls you
you what
what the
the program
program does.
does. A
A REMark
REMark state
state-
ment
ment has no
no effect on
on the program itself.
itself.
Line
Line 20
20 clears
clears the screen.
screen.
Line
Line 25
25 PRINTs
PRINTs tenten cursor-down
cursor-down commands.
commands. This Thi s just
just positions
positions the
the ball
ball in
in
the
th e middle
middle ofof the
the screen.
screen. Without
Without this
this line,
li ne, the
the ball
ball would
wo uld move
move across
across the
the top
top
line
li ne of the
the screen.
screen.
Line
Line 30
30 sets
sets up
up aa loop
loop to
to move
move the ball
bal l 40
40 columns
column s from left to right.
Line
Line 40
40 does
does three
three things:
things:
1.
1. PRINTs
PRINTs aa space
space to
to erase
erase the
the previous
previous ball
ball positions
positions.
2.
2. PRINTs
PRINTs the
the ball.
ball.
3.
3. Performs
Perform s aa cursor-left
cursor·left to
to get
get ready
ready to
to erase
erase the
the current
current ball
ball position
positi on again.
again.

47
47

Downloaded from www.Manualslib.com manuals search engine


-

Line
line 50
50 and
and 60 60 set
se t up
upaa loop
loop that
that slows
slows downdown the the ball's
ball's movement.
movemen t.WithoutWithou t
this
this loop,
loop, the
the ball
ball would
wo uld move
move tootoo fast
fast for
fo ryou
you toto see
see clearly.
clearly.
Line
line 70
70 completes
completes the the loop
loop set
set up
up inin line
line 3030 to
to PRINT
PRINT balls
balls onon the
the screen.
screen.
Each
Each time
tim e the
the loop
loop executes,
executes, the the ball
ball moves
moves another
anotherspace
space to to the
the right.
right. As
As you
you
can
can see
see from
from thethe illustration,
illustration, the the program
program contains
contains aa loop
loop within
within aa loop.
loop. You
You
can
can include
include up up toto ten
ten loops
loops within
within aa loop.
loop. TheThe only
only time
time you
you getget inin trouble
trouble isis
when
when thethe loops
loops cross
cross overover each
each other.
ot her. The
The loops
loops have
have toto be
be NESTED
NESTED inside inside
each
each other.
other. In
In other
other words,
words, ifif you
you start
start loop
loop AA and
and then
then start
start loop
loop BB inside
insi de loop
loop
A. you must finish loop B (the inside loop) first.
A, you must finish loop B (the inside loop) first.
When
When you're
you 're writing
writing aa program
program with wit h loops,
loops, it's
it's aa good
good idea
idea toto draw
draw arrows
arrows
from
from the
the beginning
beginning to to the
the end
end ofof the
the loops.
loops. IfIf your
your loops
loops cross,
cross , the
th e computer
computer
can't
can't figure
figure out
out what
what you
you want,
want, so
so itit can't
can't execute
execute your
your program.
program .
Lines
lines 80
80 through
through 120120 just
just reverse
reverse thethe steps
steps inin the
the first
first part
part of
of the
the program,
program,
and
and move
move the
the ball
bal l from
from right
right toto left.
left. Line
line 9090 is
is slightly
slightly different
different from
from line
line 40
40
because
because the
the ball
ball is
is moving
moving in in the
the opposite
opposi te direction,
direc ti on, and
and you
you have
have to
to erase
erase the
the
ball
ball to
to the
the right
right and
and move
move toto the
the left.
left.
Line
line 130
130 sends
sends thethe program
program backback to to line
line 20
20 to
to start
start the
the whole
whole process
process over
over
again.
again.
For
Fo r aa variation
variati on on
on the
the program,
prog ram , change
change line
line 40
40 to
to read:
read:
40
40 PRINT
PRINT "<SHIFT>
" <SHIFT> < Q>"
0 >"
Run
Run the
the program
program and
and see
see what
what happens
happens now.
now. Because
Because you
you left
left out
out the
the cursor
curso r
control,
cont rol , each
each ball
ball remains
remains on
on the
the screen
screen until
until it is
is erased
erased by
by the
the ball
ball moving
moving
right to left in
in the
the second
second part of
of the program.
program.

48
48

Downloaded from www.Manualslib.com manuals search engine


INPUT
INPUT
Up to
Up 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. Once
RUNs. Once you
you executed
executed the the program,
program, you you couldn
couldn't change or
't change or add
add anything.
anything.
The INPUT
The INPUT statement
statement lets
lets you
you send
send information
information to to aa program
program WHILE
WHILE itit is
is RUN·
RUN-
ning. Not
ning. Not only
only does
does the
the program
program actact on
on this
this information
information you
you supply,
supply, but
but the
the pro·
pro
gram won't
gram won't continue
continue until
until you
you supply
supply it.it.
To get
To 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.
short program.

10 INPUT
10 INPUT A$
A$
20 PRINT ""YOU
20 PRINT TYPED ";AS
YOU TYPED ";A$
PRINT
30 PRINT
40 IF AS = "STOP"
IF A$ "STOP" THEN END
END
50 GOTO
50 GOTO 1010
RUN
RUN
? GO
? GO
YOU TYPED GO
YOU TYPED GO

? CONTINUE
YOU TYPED CONTIN
CONTINUE
UE
? STOP
YOU TYPED STOP
Here's what happens in this program:
Line 10 tells the comp
computer
uter to display a question mark to prompt you to INPUT
a value for AS,
AS, and to wait until you
you supply the value before contin
continuing
uing the pro·
pro
gram execution.
Line 20 PRINTS
PRINTs aa message and the INPUT value, and line 30 PRINTs a blank
line.
line.
Line
Line 40 tells the computer to end the program
program immediately
immediately IF the value you
INPUT
IN PUT for AS
A$ is STOP.
STOP.
Line
Line 50
50 returns the program
program to line
line 10
10 so
so you can INPUT
INPUT another value. IF
IF line
line
40
40 is
is true because
becau se the
the last
last value you
you INPUT
INPUT for A$
AS was STOP,
STOP, then line
line 50
50 isn't
isn't
executed.
executed.
You
You can
can INPUT
INPUT numeric
numeric or
or string
string variables,
variables, and
and you
you can
can have
have the INPUT
INPUT
statement
statement print
print aa message
message along
along with
with aa question
question mark
mark to
to describe
describe the
the kind
kind of
of
INPUT
INPUT the
the computer
computer is
is waiting
waiting for.
for. For
For example,
example, here's
here's what
what happens
happens when
when you
you
add
add aa prompt
prompt message
message to
to line
line 10
10 of
of the
the previous
previous example:
example:
10
10 INPUT
INPUT "KEEP
" KEEP GOING";A$
GOING"; A$ Prompt
Prompt message
message can't
can 't
RUN
RUN be
be more
more than
than 38
38
KEEP
KEEP GOING?
GOING? GOGO characters
characters
YOU
YOU TYPED
TYPED GO
GO
v KEEP
KEEP GOING?
GOING? STOP
STOP
YOU
YOU TYPED
TYPED STOP
STOP

v
v

49
49

Downloaded from www.Manualslib.com manuals search engine


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
presented so
sofar,
far,including
including the
the INPUT
IN PUTstatement.
statement.

NEW
NEW
11 REM
REM TEMPERATURE
TEMPERATURE CONVERSION
CONVERSION PROGRAM
PROGRAM
55 PRINT "(CLR/HOME)"
PRINT " (CLRlH OM E)"
10
10 PRINT
PRINT "CONVERT
"CONVERT FROM
FROM FAHRENHEIT
FAHRENHEIT OR
OR CELSIUS
CELSIUS (F/C)":INPUT
(F/C)": INPUT A$
AS
20
20 AS == ""THEN
IF AS
IF "" THEN 10
10
30
30 IF AS == "F"THEN
IF AS " F" THEN 100
100
40
40 IF <>
"c" THEN
IF A$O"C"
AS THEN END
END
50
50 INPUT
INPUT "ENTER
" ENTER DEGREES
DEGREES CELSUIS:
CELSU IS: ";C" ;C
60
60 FF == (C*9)/5
(C ' 9V5+ 32
+ 32
70
70 PRINT
PRINT C;"
C;" DEG. CELSIUS == ";"; F;"
DEG. CELSIUS F;" DEG.
DEG. FAHRENHEIT"
FAH RENHEIT"
80
80 PRINT
PRINT
90
90 GOTO 10
GOTO 10
100
100 INPUT
INPUT "ENTER
"ENTER DEGREES
DEGREES FAHRENHEIT:
FAHRENHEIT: ";F ";F
110
110 C = (F-32)'5/9
C = (F-32)'5/9
120
120 PRINT
PRINT F:"
F;" DEG.FAHRENHEIT
DEG.FAHRENHEIT == ";C:" ";C;" DEG.
DEG . CELSIUS"
CELSIUS"
130
130 PRIN T
PRINT
140
140 GOTO 10
GOTO 10

Line
Lin e 10
10 uses
uses the
the INPUT
INPUT statement
statement to
to print
print aa prompt
promp t message
message and
and to
to wait
wait for
for
you to
you to type in aa value
type in value for
for A$.
AS.
Lines
Lines 20.
20, 30
30 and
and 40
40 check what
what you
yo u typed
typed in
in and
and tell
tell the
the computer
computer where
where to
go
go next.
next. Line
Li ne 20
20 tells
tells the
the computer
computer to
to go
go back
back to
to line
line 10
10 and
and ask
ask for
for INPUT
IN PUT again
again
IF
IF nothing
nothing waswas typed
typed inin (IF
(IF just
just RETURN
RETURN was
was pressed).
pressed). Line
Line 30
30 tells
tel ls the
the com
com-
puter to go straight to line
line 100
100 and perform
perform the
the Fahrenheit-to-Celsius
Fahrenheit-to-Ce lsius conver
conver-
sion IF the val ue you
value you typed for
for A$
AS is
is F.
F.
Line 40
Line 40 checks
checks to
to be
be sure
sure that
that you
you haven't
haven't typed in anything
typed in anything beside
beside F
F or
or C.
C. IF
IF
you have, line 40 ends the program. IF yo youu typed in a C, C. the computer
automatically moves
automatically moves to
to line
line 50
50 to
to perform
perform the
the Celsius-ta-Fahren
Celsius-to-Fahrenheit conversion..
heit conversion
ItIt may
may seem
seem like
like too
too much
much detail
detail to
to include
include all
all these
these IF
IF statements
statements to
to ccheck
heck
what you INPUT. But But this is a good programming
programming practice that can spare you a
lot of frustration. You should always try to be be sure that your program
program takes care
of
of allall possibilities.
possibilities.
Back to the example:
Back example: once
once the program
program knows
knows what
what type of conversi
conversion
on to
make, the
make, the calculations are made.
made. Then
Then the program
program PRINTs
PRINTS the temperature
you
you entered
entered and
and the
the converted
converted temperature.
temperature.
The calcu
The calculation this
lation thi program performs
s program performs isis just
just straight
straight math,
math, using
using the
the slan-
stan
dard formula
dard formula for
for temperature
temperature conve
conversion. After the
rsion . After the calculation
calculation finishes
finishes and
and the
the
answer is
answer is PRINTed
PRINTed., the
the program
program loops
loops back
back and
and starts
starts over.
over.
Here's aa sample
Here's sample exec
execution of th
ution of this program::
is program
CONVERT
CO FROM FAHRENHEIT
NVERT FROM FAHRENHEIT OR OR CELSIUS
CELSIUS (F/C):
(F/C): ?F
?F
ENTER
ENTER DEGREES FAHRENHEIT: 32
DEGREES FAHRENHEIT: 32
32 DEG
32 FAHRENHEIT =- 00 DEG
DEG.. FAHRENHEIT DEG.. CELSIUS
CELSIUS

CONVERT FROM
CONVERT FROM FAHRENH
FAHRENHEIT OR CELSIUS
EIT OR CELSIUS (F/C):
(F/C): ??
After you
After you RUN
RUN this
this program,
program, you
you might
might want
want to
to save
save itit on
on disk.
disk. This
This program,
program,
as wel
as welll as
as others
others in
in this
this manual,
manual, can
can fo
form part of
rm part of yo
your program library.
ur program library.

n
50
50
n
Downloaded from www.Manualslib.com manuals search engine
n
USING THE GET STATEMENT FOR DATA INPUT
press
GET lets you input one character at a time from the keyboard without press·
ing the RETURN key.
key. This really speeds up entering data in many cases.
When you RUN a program that has a GET statement, whatever key you press
include
is assigned to the variable you inc exam
lude in the GET statement. Here's an exam·
ple:
pie:
11 < CLRlHOM E >"
PRINT ""<CLR/HOME>"
10 AS: IF A$
GET A$: AS ;= """
" THEN 10 No space between
20 PRINT A$;
A$; quotes
30 GOTO 10
Line
Li ne 11 clears the screen.
Line
li keyboard.. In
ne 10 lets you type in any key on the keyboard In effect
effect,, the loop in line 10
tells
tel computer
ls the comp uter to wait until you type in a key before moving to line 20.
Line 20 displays the keys you type on the screen.
line screen.
Line 30 sends the program back to GET another character.
line character. It's important to
remember that the character you type in won won't't be displayed uniessyou
unless you PRINT it
screen, as we've done in line 20.
to the screen,
The IF statement
slatement in line 10 is very important. GET continually works,works, even if
you
yo INPUT, which waits for your response),
u don't press a key (unlike INPUT, response), so the se·
se
continually
cond part of line 10 contin ually checks the keyboard until you hit a key.
Try leaving out the second part of line 10 10 and see what happens.
To stop this program,
program, press the RUN/STOP
RUN/STOP and RESTORE
RESTORE keys.
You can easily rewrite the beginning of the temperature conversion program
to use GET instead of INPUT. If you've SAVEd this program, program, LOAD it and
change lines 10 and 20 like this:
10 PRINT "CONVERT FROM FAHRENHEIT OR CELSIUS (F/C)"
20 GET A$: IF AS
A$ =
; "" THEN 20

51
51

Downloaded from www.Manualslib.com manuals search engine


USING
USING GET
GET TO
TO PROGRAM
PROGRAM FUNCTION
FUNCTION KEYS
KEYS
As
Asyou'll
you 'llrecall
recall from
froman anearlier
earlierchapter,
chapter,wewetold
toldyou
youthat
thatthe
thekeys
keyson
onthe
theright
right
side of the keyboard {f1 through f8) are function keys that you can program toto
side of the keyboard (f 1 through f8) are function keys that you can program
performaavariety
perform variety ofof tasks.
tasks.
Here's how
Here's how to
to program
program aa function
function key:
key:
1.1. Use
Use aaGET
GETStatement
Statement to
to read
read the
the keyboard.
keyboard.
2.2. 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
function
function key
key you
you want
want to
to use.
use. Every
Every character
characteronon the the keyboard
keyboard has
has aaunique
unique
CHR$
CHR$ number.
number. For
Forexample,
example, thethe CHRS
CHR$ code
code of
of f f1
1 isis 133.
133. Appendix
Appendix FFlists
liststhe
the
CHR$ code for
CHR$ code for all
all keys.
keys.
3.
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
to do.
to do.
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·
med,
med,and
and the
the key
key will
will follow
follow the
the instructions
instructions you
you gave
gave itit in
in the
the THEN
TH EN statement.
statement.
For example:
For example:
10 GETA$:
10 GET A$: IF
IF AS
A$ == ""THEN
" " THEN 10
10
20 IF
20 IF AS=CHR$(137)THEN
AS = CHR$(137) TH EN A$=CHR${14)
A$ = CHR$(14)
30
30 IF
IF A$=CHR$(134)THEN
A$= CHR$(134) TH EN A$=
A$= "YOURS
"YOURS TRULY" + CHR$(13)
TRULY" +CHR$(13)
Line
Line 10
10 tells
tells the
the program
program to
to assign
assign the
the key
key you
you press
press toto the
the variable
variable AS.
AS. As
As
you'll
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
the keyboard
the keyboard for
for input.
input.
Line
Line 2020 programs
programs function
function key
key 2,
2, CHR$(137).
CHR$(137). LineLine 20
20 tells
tells the
the computer
computer to to
make
make AS A$ equal
equal toto CHR$(14)
CHR$(14) ifif you press function
you press key 2.
func ti on key CHRS(14) is
2. CHR$(14) is the
the switch
switch
from upper to
from upper to lower case letters
lower case letters on
on the
the keyboard.
keyboard. WhenWhen you
you RUN
RUN this
this program,
program,
you'll see
you'll see that
that the
the characters
characters onon the
the screen
screen immediately
immediately makemake this switch if
this switch if you
you
press f2.
press f2.
Line
Li 30 programs
ne 30 programs function
function key
key 3,
3, CHR$(134).
CHR$(134). LineLine 30
30 te
tells the computer
lls the computer to to
make A$
make A$ equal
equal to
to the
the character
character string
string YOU
YOURS TRULY and
RS TRULY and CHR$(13)
CHR$(13) if if you
you press
press
program execution. CHR$(13) is
f3 during program is the code for the RETURN
RETURN key. key.
TH
THE E CHR$
CHRS codes for the function keys keys are:

f1
f1 == CHRS(133)
CHR$(133) f2
f2 == CHRS(137)
CHRS(137)
f3
f3 == CHRS(134)
CHRS(134) f4
f4 == CHR$(138)
CHR$(138)
f5
f5 =- CHR$(135)
CHR$(135) f6
f6 == CHR$(139)
CHRS039)
f7
f7 == CHR$(136)
CHR${136) f8
f8 == CHRS(140)
CHRS(140)
The COMMODORE
The COMMODORE 64 64 PROGRAMMER'S
PROGRAMMER'S REFERENCE
REFERENCE GUID
GUIDE has more
E has more in·
in
formation about
formation about programming
programming function
function keys
keys.. You
You can
can purchase
purchase this
this extensive
extensive
guide from
guide from you
your local Commodore
r local Commodore dealer.
dealer.

52
52

Downloaded from www.Manualslib.com manuals search engine


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.
Functions are like built·in BASIC. The great advantage of
built-in functions is that you don't have to type in a number of statements
these built·in
Instead, all you do is
every time you want to perform a specialized calculation. Instead,
type the command for Ihe ihe funct
function
ion you want and the computer does all the rest.
built-in funct
These built·in functions (SQR), finding out the
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.
random
One function you can have a lot of fun with is the rand function,,
om number 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 upup random numbers. For exam· exam
ple, yo
pie, you'd
u'd need to do this to simulate the tossing of dice. Of course you could
wouid
write a program that wou numbers, bu
ld generate these random numbers, butt it's much
easier to be able to do this just by cal
calling
ling upon the prewritten RaNDom number
function.
works, try this short program:
To see how RND works,
NEW
10 FOR X = 11 TO 10 IF YOU LEAVE OUT THE COMMA.
COMMA, YOUR
20 PRINT RND
RND(1),
(1), NUMBERS APPEARS AS 11 COLUMN
LIST OF NUMBERS
30 NEXT
When you RUN this program,
program, the screen displays:
displays:

.789280697 .664673958
.256373663 .0123442287
.682952381
.682952381 3.90587279E-04
3.90587279E - 04
.402342724 .879300926
.158209063 .245596701
Your numbers don'tdon't match? It woul
wouldd be incredible if they did because the
program generates a completely
completely random list of tenten numbers.
If you RUN the program a a few more time, you'll see that the the results are
always different. Though
Th ough the numbers don't have a
don 't have a pattern, you'll
you' ll notice aa few
cons istencies about the list the
consistencies the program
program displays.
displays.
v For one thing,
thing , the results are always between 11 and 0. 0, but never equal to 11 or
0.
O. For
For another,
another, the
the numbers
numbers are
are real
real numbers (with decimal points).
pOints).
Now,
Now, we started out to
to simulate dice tosses,
tosses, and
and the
the results from this
this pro
pro.
gram aren't
gram aren't exactly
exactly what
what we're
we're looking for. Now we'll
we'll add
add aa few more
more features
to
to this
this program
program to get what we
we want.
want.
First,
First, add
add this line
line to
to the program
program to replace line 20,
20, and RUN the program
program
aaain:
again:
20
20 PRINT 6*RND(1),
6'RND(1),
RUN
RUN
3.60563664 4.52687513
4.52687513
5.48602315
5.48602315 1.09650123
1.09650123
3.10045018
3. 10045018 4.39052168
4.39052168
3.91302584 5.06321506
5.0632 1506
2.32056144
2.32056144 4.10781302
4.1078 1302

v
v
53
53

Downloaded from www.Manualslib.com manuals search engine


"

Now
Now we've
we've got
got results
results larger
larger than
than 1.
1, but
but still
still have
have real
real numbers.
numbers. To
To solve
solve this,
this,
we'll use
we'll use another
another function.
fu nction.
The
The INT
INT function
function converts
conve rts real
real numbers
numbers to
to integer
integer (whole)
(whole) numbers.
numbers. So
So try
try
replacing line 20
replac ing line 20 again:
again:
20
20 PRINT
PRINT INT(6'RND(1)),
INT(6 " RND(1)), "
RUN
RUN

2
2 3
3 1
100
2
2 4
4 5
5 5
5 ~
o
0 11

Now
Now we're
we're even
even closer
closer to
to our
our goal,
goal, but
but you'll
you 'll notice
notice that
that the
the numbers
numbers range
range
from
from 11 to
to 5,
5, not
not 11 to
to 6. So
So as aa final step,
step, we'll
we 'll replace line
line 20 again:
20 PRINT
20 PRINT INT(6'RND(1)) + 11
INT(6" RND(1)) +
Now
Now when
when you
you RUN
RUN the
the program,
program, you'll
you'll get
get the
the results
results you
you want.
want.
When
When you
you want
want to
to generate
generate aa range
range ofof real
real numbers instead
instead of
of whole
whole
numbers,
numbers, the
the formula is
is slightly
slightly different
different because
because you
you must
must subtract
subtract the
the lower
lower
limit of
of the range from the upper
upper limit. For
For example,
example, you
you can generate
generate random
numbers 25 by typing:
numbers between 11 and 25 typing:
20 PRINT
20 PRINT RND(1)'(25-1) + 11
RND(1)" (25- 1) +
The
T he general
general formula for generating random numbers
numbers in a certain range is:
NUMBER = RND{1)
RND(1) *(UPPER
"(UPPER LIMIT -
- LOWER + LOWER LIMIT
LOWER LIMIT) +

54

Downloaded from www.Manualslib.com manuals search engine


GUESSING GAME
GUESSING GAME
Here's
Here's aa game
game thatthat uses
uses random
random numbers.
numbers. This
This game
game not
not only
only uses
uses the
the RND
RND
function,
function , but
but itit also
also introduces
introduces some
some additional
additional programming
programming theory.
theory .
When
When you
you RUN
RUN thisthis program,
program , the
the computer
computer generates
generates aa random
random number,
number, NM,NM ,
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
11
22
55
REM NUMBER
REM
PRINT
INPUT
NUMB ER GUESSING
GUESSIN G GAME
"(CLR/HOME)"
PRINT "(CLRlHOME)"
IN PUT -'ENTER
"ENTER UPPER
GAME

UPPER LIMIT
LIMIT FOR
FOR GUESS
GUESS ";LI
";LI
-------.r----'--_
INDICATES
INDICATES NO
NO
10
10 NM =
NM = INT(LI*RND(1))+1
INT(LI·RND(l))+ 1 SPACE
SPACE AFTER
AFTER
15
15 =
CN = 00
CN QUOTATION
QUOTATION MARK
MARK
20
20 PRINT
PRINT "I'VE
" I'VE GOT
GOT THE
THE NUMBER.":PRINT
NUM BER.": PRINT
30
30 INPUT "'WHAT'S
INPUT "WHAT'S YOUR
YOU R GUESS";
GU ESS"; GU
GU
35
35 CN =
CN = CN
CN +
+ 11
40
40 IFGU>NM
IF GU > NM THEN
TH EN PRINT
PRINT "MY
" MY NUMBER
NUMBER IS
IS LOWER":
LOWER": PRINT:GOTO
PRINT:GOTO 30
30
50
50 IF
IF GU<
GU < NM
NM THEN
THEN PRINT
PRINT "MY
" MY NUMBER
NUMBER IS
IS HIGHER":
HIGHER" : PRINT:GOTO
PRINT:GOTO 30
30
60
60 PRINT
PRINT "GREAT!
" GREAT! YOU
YOU GOT
GOT MY
MY NUMBER"
65
65 PRINT
PRINT "IN
" IN ONLY
ONLY "';
"; CN
CN ;"GUESSES.":PRINT
;"GUESSES." :PRINT
70
70 PRINT
PRiNT "DO
" DO YOU
YOU WANT
WANT TO
TO TRY ANOTHER
ANOTHER (Y/N)";
(YIN)";
80 GET
80 GET AN$:
AN $: IF
IF AN$=""
AN$= ,'" THEN
THEN 80
80
90 IF
90 IF AN$
AN$ == "Y"
" Y" THEN
THEN 22
100 IF
100 IF AN$<
AN$ >"N" <>
"N" THEN 70
110 END
110 END
You
You can specify how
how large
large the
the number will
wil l be
be at the start
start of
of the program.
'-' Then,
Then, it's up to you to guess what the number is.
A sample
sample run follows
fo llows along with an explanation.
explanation .

ENTER UPPER LIMIT FOR GUESS? 25


v I'VE
I'VE GOT THE NUMBER.

WHAT'S YOUR GUESS ?


? 15
MY NUMBER IS HIGHER.

WHAT'S YOUR
YOUR GUESS ? 20
MY NUMBER IS LOWER.
v
WHAT'S YOUR GUESS ? 19
19
GREAT
GREAT!! YOU GOT MY
MY NUMBER
IN
IN ONLY 3 GUESSES.

DO YOU WANT TO TRY ANOTH


DO ANOTHER (Y/N)?
ER (YIN)?

55
55

Downloaded from www.Manualslib.com manuals search engine


~

The IFfTHEN
IF/THEN statemen
statementt (li nes 40-60)
(lines 40-60) compare your guess to the random
number (NM) generated by line 10. 10. If your guess is wrong,
wrong , the program tell s you
tells
whether yo ur guess is higher or lower than NM
your NM..
Each titime
me yo u make a guess,
you guess, line 35 adds 1 1 to CN
CN.. CN is a counter that keeps
track of how many guesses you take to get the riright ght number. Th e purpose of
The
this
thi game, of course,
s game, course, is to guess the number in as few tri
tries
es as possible.
When you get the right answer,
answer, the prog ram displays the message,
program message. GREAT
GREAT!!
YOU GOT MY NUMBER,
NUMBER, and tel ls you how many guesses you look.
tells took.
Remember that the program ccreates each time
rea tes a new random number each tim e you
play the game
game.. .
You might want to add a few lines to the program that also specify the lower
range of numbers generated by this game.
game.

PROGRAMMING
PROGRAMM ING TIPS:
lines
In line 50. a colon separat
s 40 and 50, separates multiple
es mu ltiple statements on a single line.
Th is not on
This ly saves typing
only typing time,
time, but it also conserves memory space.
Also notice that the IFfTHEN
IF/THEN statements in these two lines PRINT some thi ng
something
before
bef ore branching to another liline.
ne.

YOUR ROll
ROLL
The fo llowing program simulates the throw of two
following Iwo dice. You can play this lit·
dice. You lit
tle game by itself,
tie itseif, or use it as part of a larger game.

5 PRINT "Care to try you


yourr luck?"
10 RED DICE = ";
PRINT ""RED INT(RND(1)'6)+ 1
";INT(RND(1)*6)+1
20 WH ITE DICE = ";INT(RND(1)'6)+
PRINT ""WHITE ";INT(RND(1)*6)+11
30 ""PRESS
PRESS SPACE BAR FOR ANOTHER ROLL" ROLL":PRINT
:PRINT
40 GET A$: IF A$ = """" THEN 40
50 IF A$ = CHR$(32)
CHR${32) THEN 10

From
F ro m what yoyou've random
u've learned about BASIC and rand numbers,
om nu you can
mbers , see if you
what's
follow what program.
's going on in this progra you
m. As yo recall
u may reca ll from the section on
programming
programm keys, CHR$(32) is the cha
ing the function keys, character
racter string code for the
space bar.

56

Downloaded from www.Manualslib.com manuals search engine


v RANDOM
RANDOM GRAPHICS
GRAPHICS
"-" As
As aa final
final note
note on
on random
random numbers,
numbers, and
and as
as an
an introduction
introduction to
to designing
designing
graphics, try
graphics, try entering
entering and
and RUNning
RUNning this
thi s program:
program:
10
10 PRINT <
PRINT ■1<CLR/HOME>"
" CLRlHOME >"
20 PRINT
20 CHRS(205.5 ++ RND
PRINT CHR$(205.5 RND (1));
(1));
30 GOTO
30 GOTO 20
20
The
The function
function CHRS
CHR$ (CHaracter
(CHaracter String)
String) gives
gives you
you aa character,
character, based
based on on aa stan
stan·
v dard
dard code
code number
number from
from 00 to
to 255.
255. Every
Every character
character the
the 64
64 can
can print
print is
is encoded
encoded
this
this way.
way. Appendix
Append ix FF lists
lists the
the CHRS
CHR$ codes
codes for
for all
all keys.
keys.
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
ASC (for the
the standard
standard ASCII
ASCII code).
code). Type:
Type:
PR INT ASCf'X")
PRINT ASC("X")
v
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
graphics characters.
characters. You
You must
must enclose
enclose the
the character
character in
in quotation
quotation marks.
marks.
Here's an
Here's an example:
example:
PRINT ASC("G")
PRINT ASC("G")
71
The CHRS
The CHR$ function
function is
is the
the opposite
opposite of
of ASC.
ASC.
PRINT CHR$(71)
PRINT CHR$(71)
G
G

If you
If you type:
type:
PRINT CHR${205);CHR$(206)
PRINT CHR$(205);C HR$(206)
the computer displays the two right side graphics on the M M and N N keys,
keys, which
are the characters used in the little maze program you you just tried.
The formula 205.5 + RND(1
RND(1)) tells the computer to pick a random number bet· bet
ween 205.5 and 206.5 There is fifty-fifty
fifty· fifty chance that the random number will be
CHRS ignores fractional values, so half the time the
above or below 206. CHR$
printed,, and the rest of the time code 206 is
character with code 205 is printed
displayed.
displayed.
You can experiment with this program by adding or subtracting a couple of
tenths from 205.5. This gives either character a greater chance of being
displayed.
displayed.
v

v
v

57
57

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
-

CHAPTER
CHAPTER 66
COLOR AND
COLOR AND GRAPHICS
GRAPHICS
•• How
How to
to Use
Use Color
Color and
and Graphics
Graphics on
on Your
Your Computer
Compu ter
•• Prin ting Colors
Printing Colors
•• Color CHR$
Color CHR$ Codes
Codes
•• How to
How to Use
Use PEEKs
PEEKs and
and POKES
POKEs
•• Screen Graphics
Screen Graphics
• Screen
Screen Memory
Memory Map
Map
• Color Memory
Color Memory Map
Map
• More
More Bouncing Balls
Balls

HOW
HOW TO USE
USE COLOR
COLOR AND GRAPHICS
GRAPHICS ON YOUR COMPUTER
So
So far
far this
this book has presented
presented some of the the sophisticated
sophisticated computing
capabilities
capabilities of
of your
your 64.
64. But one
one of
of the
the most
most exciting
exciting features
features of your
your new com
com·
puter
puter is its outstanding
outstanding ability
abi lity to produce 16
16 different colors
colo rs and aa lot of dif
dif·
fe rent graphics.
ferent
You've
You 've already
al ready seen
seen aa very simple
simple demonstration
demonstration of the graphics in the
the boun
boun-
cing
cing ball program and
and in the maze program at the end of the last chapter. This
chapter introduces you to new concepts that explain graphic and color
programming, and that suggest
programming, for creating your
sugges t ideas for your own games and advanc-
advanc
ed animation.

<-

58

Downloaded from www.Manualslib.com manuals search engine


PRINTING COLORS
When you tried the color ali gment tes
aligment testt in Chap ter 1,
Chapter 1, you discovered that you
colors
can change text co lors by simply holding down the CTR CTRL L key and pressing one
of the color keys.
The 64 offers a full range of 16 colors. Though only eight colors are printed on
you
the color keys, yo u can get eight more by holding down the C = - key and press-
press
key. Here's a list of the colors:
ing a color key.


KEYBOARD COLOR: DISPLAY KEYBOARD COLOR DISPLAY
milD ~D
.~
BLACK ■ ORANGE ••
milD WHITE III ~D BROWN
BRO WN fJ
m
~ ~EI ~
*
RED
C YAN

PURPLE
~


ii
0n
~a
~D
LT
LT.. RED

GRAY
G RAY 11

GRAY 2
..
1
~
« i

ii
II
GREEN ~D IT.
LT. GREEN

milD
BLUE
YELLOW
=
B
m
m
~D
~D
LT
LT.. BLUE

GRAY 3 ..
0□
••

When we showed you


you the boucing ball program in the last chapter, you saw
that keyboard commands,
commands, such as cursor movement,
movement, can be written into PRINT
statements.
state ments. In
In the
the same way you
you can a
also
lso add text color c
changes
hanges to your pro
pro-
'-' grams.
grams.

'-'

'-'

v
v
v
v

59
59

Downloaded from www.Manualslib.com manuals search engine


Type
Type NEW and trytry experimenting
experimenting with
with changing
changing colors.
colors. Hold
Hold down
down the
the CTRL
CTRL
key
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
R
R key.
key. Now hold
hold down
down thethe CTRL key again
again and
and press
press the
th e 22 key.
key. Release
Release the
the
CTRL key
CTRL 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
letters, and type
letters, type out the
the word
wo rd RAINBOW
RAINBOW like this:
10
10 PRINT",
PRIN T" r R.
Rr A.
A r II r B rO r w"
t N.B.O.W"

mIIaOODDDD
You'll
You'll recall
recal l that cursor
cu rsor controls appear as
as graphic
graphic characters in
in the PRINT
PRINT
statement. Color controls areare also
also represented as
as graphic characters. The color
chart printed above shows the graphic characters that appear with each each color.
color.
Because ofof the graphic characters
characte rs that are displayed when you select color
keys, your PRINT statement will
keys, will look strange,
strange, but when you RUN
RUN the
th e program,
program ,
you' ll see that
you'll that only the
the text of the message is displayed. The letters in
in the
the
au tomatical ly change colors
message automatically colo rs according
according to the color
co lor controls you plac
plac·
ed in
in the PRINT statement.
Now try making up some examples of your own
own,, mixing any nu
number
mber of colors
within a single PRINT statement. Don't forget
lorget the second se
sett of colors
colors that you
can get by holding down the ~
can Cs key while you press a color key.
key
TIP:
TIP:
After you
you RUN aa program with color or mode (reverse) changes,
changes, you' ll notice
you'll
that the READY prompt and any add itional text yo
additional youu key in is the same as the
last co lor or mode change you made. To get back to the normal display, press
color
these keys together:
RUN /STOP and RESTORE
RUN/STOP

60

Downloaded from www.Manualslib.com manuals search engine


COLOR
COLOR CHRS
CHR $ CODES
CODES
Before
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
the
the CHRS
CHRS codes
codes for
for all
all keys
keys on on the
the keyboard.
keyboa rd .
As
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
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
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
last
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 ~ and
or [CKJ and
the colo r key in a PRINT statement.
the color key in a PRINT statement.
For example,
For example, trytry this:
this:
NEW
NEW
10
10 PRINT
PRINT CHR$(147)
CHR$(147) :: REM
REM < CLR/HOME <
CLR/HOM E > >
20
20 PRINT
PRINT CHR$(28):-'CHR$(28)
CHR$(28);"CHR$(28) CHANGES
CHANG ES ME
ME TO?"
TO? "
RUN
RUN

CHRS(28) CHANGES
CHR$(28) CHANGES ME
ME TO?
TO?
When
When you
you RUN
RUN this
this program,
program, the the screen
screen clears
c lears before
before the
the message
message in in line
line 20
20
is PRINTed. The
is PRINTed. The texttext should be red now.
now.
In
In many
many cases,
cases, you'll
you 'll find
find that it's much
much easier to useuse the CHRS function
funct ion toto
change
change colors,
colors, especially
especially if youyou want to to experiment.
experiment. The
The next
next page
page shows
shows
another
ano ther way
way to
to get
get a rainbow
rainbow of of colors.
colors. There
There are
are aa number
number ofof similar
sim ilar lines in
in
the program (40(40 through
through 110).
110), so use
use the editing
editing keys to spare
spare yourself aa lot of
typing.
typing . See the notes at the the end of the program listing
listing to
to refresh
refres h your memory
on editing procedures.
v
NEW
11 REM AUTOMATIC COLOR
REM AUTOMATIC COLOR BARS
5 PRINT CHR$(147)
CHR$(147) :: REM CHR$(147)
CHR$(147)= = CLR/HOM
CLR/HOMEE
PRINT
10 PRIN T CHRS(18); " ";:REM
";:REM REVERSE BAR
20 CL = INT(8· RND(1»+1
INT(8*RND(1))+1
30 ON CL GOTO 40,50,60,70,80,90,100,1 10
40.50.60,70.80.90.100,110
40 PRINT CHRS(5);: GOTO 10
50 PRINT CHRS(28);:
CHRS(28):: GOTO 10
60 PRINT CHRS(30);: GOTO 10
70 PRINT
PRINT CHR$(31);:
CHRS(31):: GOTO 1010
80 PRINT CHRS(144);:
PRINT CHR$(144);: GOTO 10
90 PRINT
PRINT CHRS(156);: GOTO 1010
v 100
100 PRINT
PRINT CHR$(158);:
CHRS(158);: GOTO
GOTO 10
10
11
1100 PRINT
PRINT CHRS(159);:
CHR$(159);: GOTO 1010

Type
Type lilines
nes 55 through
through 40
40 normally.
normally. Your
Your display
display should
should look
look like
like this:
this:
v

11 REM
REM AUTOMATIC
AUTOMATIC COLORCOLOR BARS
BARS
55 PRINT
PRINT CHR$(147): REM
CHR$(147): REM CHR$(147)=
CHR$(147)= CLR/ HOME
CLR/HOME
10 PRINT
10 PRINT CHRS(18);
CHRS(18); "" "";:REM REVERSE BARS
;: REM REVERSE BARS
v 20
20 CL
CL =
= INT(8· RND(1 »+ 1
INT(8*RND{1))+1
30
30 ON
ON CL
CL GOTO
GOTO 40,50,60,70,80,90,100,11 0
40,50,60,70,80,90,100,110
v 40
40 PRINT
PRINT CHR$(5);:
CHR${5);: GOTO
GOTO 1010

v

61
61

Downloaded from www.Manualslib.com manuals search engine


EDITING NOTES:
EDITI NG NOTES:
Use
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
the 44 of
the 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
parentheses.
parentheses. Press
Press SHIFT
SH IFT and
and INST/DEL
INST/DEL toto open
open upup aa space,
space, and
and keykey in
in 28.
2S.
Now just press RETURN with the cursor anywhere on the line.
Now just press RETURN with the cursor anywhe re on the line.
The display
The display should
should look
look like
like this
this now:
now:

NEW
NEW

11 RE M AUTOMATIC
REM AUTOMATIC COLOR
COLOR BARS
BARS
PR INT CHR${147):
55 PRINT CHR$(147): REM
REM CHR$(147)=
CHR$(147} = CLR/HOME
CLR/ HOM E
10 PRINT
10 PRINT CHR$(18);
CHR$(1S); " ;: REM REVERSE
" ;:REM REVERSE BAR
BAR
20 CL
20 CL =
= INT(8*RND<1))+1
INT(S ·RND(1))+ 1
30 ON
30 ON CL
CL GOTO
GOTO 40,50,60,70,80,90,100,110
40,50,60, 70,SO,90, 100,1 10
50 PRINT
50 PRINT CHR$(28);:
CHR$(2S);: GOTO
GOTO 10
10

Don't
Don't worry
worry about
about line
line 40;
40; it's
it's still
still there,
there, as
as you
you can see
see by
by LISTing
liSTing the
the pro
pro·
gram. Follow
Fol low the same steps
steps to
to modify
mod ify line 40 with
with aa new
new line
line number and
and
CHR$
CHR$ code until
until you've entered all remaining lines.
al l the remaining li nes. As aa final
fina l check,
check, LIST
the entire
enti re program
program to make
make sure all the lines are
are right before
before you
you RUN
RUN it.
You probably understand the
the color
co lor bar program except for line 30. Here's
Here's aa
brief explanation of how this program
prog ram works.
wo rks.
Line 5
line 5 prints
pri nts the CHR$ code for CLR/HOM
CLR/HOME.
E.
Line 10
line 10 turns on reverse type and prints 5 spaces,
spaces, which
wh ich turn out to be a bar
since they're reversed.
reversed . The first time through the program,
program, the bar is light blue,
blue,
the normal screen display color.
Line 20 uses the random function to select at random a color between 11 and
S.
8.
Line 30 uses a variation of the IFITHEN
line IF/THEN statement,
statement, called ON/GOTO,
ON/GOTO, which
lets the program choose from as list ofof line numbers whe
wherere the program will go
next. If the
Ihe ON variable (in this case CL) has a value of 1,
1, the program goes to
2. the
the first line number listed (here it's line 40). If the variable has a value of 2,
listed, and so on.
program goes to the second line listed,
Lines 40 through 110 just convert the ra
lines random
ndom key colors to the appropriate
CHR$ code for that cocolor
lor and return the program to line 10 to PRINT a section
again..
of the bar in that color. Then the whole process starts again
See if you can figure out how to produce 16 random colors. Expand
ON/GOTO
ON /GOTO to handle the additional colors and add the remaining CHR$ codes.

62
62

Downloaded from www.Manualslib.com manuals search engine


HOW TO
HOW TO USE
USE PEEKS
PEEKS AND
AND POKES
POKES
PEEKS and POKES
PEEKS POKES let
let you search around inside
inside your
your computer's memory
memory
and stick
and stick things
things in
in exactly
exactly where
where you
you want
want them
them..
You'll
You recall that
'll recall that in
in Chapter 4 we explained variables as
as being
being like
like little slots
in the computer's memory,
in memory, with the variable name
name as the slot
slot's Well,,
's address. Well
imagine some more
imagine more specially defined slots in in the computer that stand for for
memory locations
specific memory locations and that have
have numbers
numbers for addresses.
looks at these memory
Your 64 looks memory local
locations
ions to see what the screen's
background and border
background 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 by
music by POKEing a different value intointo the specific memory slots.
Imagine some memory
Imagine memory slots looking something like this:

I 53~80 I I 53~81 I
53280
2
53281
1
53282
53282 53283
' -"'53"'2"'83;;--1

BORDER BACKGROUND
COLOR COLOR
The first two slots are the memory locations for the border and background
screen. We've put 2, the value for RED in the border color box,
colors on your screen. box,
1, the value for WHITE in the background color box. Now try typing this:
and 1,
POKE 53281,7 RETURN
The background color of your screen wil wil!l change to yel
yellow
low because we put
the value 7, for yellow, in the location that controls backgound color.
Try POKEing different values into the background color location and see
what result you get
get.. Here's a
a list of the values to POKE for each color available
on your 64:
0 BLACK 8 ORANGE
1
1 WHITE 9
9 BROWN
2
2 RED 10
10 light RED
3 CYAN 11
11 GRAY 11
4
4 PURPLE 12
12 GRAY 22
5
5 GREEN 13
13 light GREEN
GREEN
6 BLUE 14
14 light BLUE
BLU E
7
7 YELLOW
YELLOW 15
15 GRAY 3 3
Here's
Here's aa little
little program that you can
can use to
to display
display various
various border and
and
background
background color
color combinations:
combinations:
NEW
10
10 FOR
FOR BA
BA = 0TO
0 TO 15
15
20
20 FOR
FOR BO
BO = 0TO
0 TO 15
15
30
30 POKE
POKE 53280.BA
53280,BA
40
40 POKE
POKE 53281,BO
53281,BO
50
50 FOR
FOR XX = 11 TO
TO 500:
500: NEXT
NEXT XX
60
60 NEXT
NEXT BO:
BO: NEXT
NEXT BA
BA
RUN
RU N

v
v

63
63

Downloaded from www.Manualslib.com manuals search engine


This
This program
program uses
uses two
two simple
simple loops
loopstoto POKE
POKEvarious
variousvalues
values toto change
change the
the
background
background andand border
border colors.
colors. Line
Line 50
50 contains
contains aa DELAY
DELAY loop,
loop, which
which just
just
slows the
slows the program
program down
down aa little
little bit.
bit.
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,
background color, try
try this:
this:
?PEEK (53280)
?PEEK (53280) AND
AND 15
15
PEEK
PEEK looks
looks atat aa whole
whole byte,
byte, but
but colors
colors only
only use
use half
half aa byte,
byte,called
called aa nybble.
nybble.
To
To PEEK
PEEK just
just this
this nybble,
nybble, you
you have
have to
to add
add the
th eAND
AND 1515toto your
your PEEK
PEEK statement.
statement.
IfIf you
you used
used this
this PEEK
PEEK after
after RUNning
RUNning thethe previous
previous program,
program,you'dyou'd get
get 15
15 as
as the
the
answer
answer because
because the the last
last border
border color
color POKEd
POKEd was was GRAY
GRAY 3,3, which
which isis 15.
15.
In
In general,
general, PEEK
PEEK letslets you
you see
see what
what value
value isis currently
currentl y in
in aa specific
specific memory
memory
slot.
slot. Try
Try adding
adding thisth is line
line to
to your
you r program
program to to display
display the
the values
values ofof BORDER
BORDER and and
BACKGROUND as
BACKGROUND as the
the program
program RUNs.
RUN s.
25
25 PRINT
PRINT CHR$(147);
CHR$(147); "BORDER
"BORDER == ";"; PEEK(53280)
PEEK(53280) AND
AND 15,
15,
BACKGROUND == ";"; PEEK
""BACKGROUND PEEK (53281)
(53281) AND
AND 15
15

SCREEN GRAPHICS
SCREEN GRAPHICS
So
So far when you've
you've PRINTed
PRINTed information,
information, the
the computer
computer has has handled
handled the inin·
formation sequentially:
sequentially: one
one character
character PRINTed
PRINTed after the next,
next, starting
starting from
from the
current cursor
cursor position,
position, except
except when you
you asked
asked for aa new
new line,
line, or used
used aa comma
in PRINT formatting.
You can PRINT
PRINT data in aa particular place by starting from aa known place on
the screen and PRINTing
PRINTing the correct number of cursor controls to format the
display.
display. But this
this takes
takes time
time and program steps.
steps.
But just as there are certain locations in the 64's memory to control color,
color,
there are also
there are also memory
memory locations
locations that
that you
you can
can use
use to
to control
control screen locations.
screen locations.

64
64

Downloaded from www.Manualslib.com manuals search engine


_

SCREEN MEMORY
SCREEN MEMORY MAP
MAP
The 64's
The 64's screen
screen can
can hold 1000
1000 characters (40(40 columns byby 25 lines), so
so there
there
are 1000
are 1000 memory locations
locations set aside to represent
represent what is on thethe screen. Imag-
Imag
ine the screen as a grid,
ine grid, 40 by 25, with
with each square standing for one one memory
location.
location.
Each memory location can contain one of the 256 different characters the 64
Each
can display (see Appendix E). E). Each
Each of these 256 characters is represented by a
number from 0 to 255. IfIf you POKE POKE the value for a character into a speci specific
fi c
screen memory location, that character wi will
ll be displayed in that specific screen
location.
Here's a grid that represen
Here's represents ts your screen, complete with the numbers of each
screen memory
memory location.
location.

COLUMN
COLUMH
10 20
10 JO 39
106)
1063

1024
.064
106'
104
IID~
Il144
U
184
1184
m
122J
264
1264
304
1304
344
1344
v 3S4
1384
1424
m
464
1464
JO i
504
ISD~
544
15u
584~
158
624
!62~
664
166J
v 704
110J
744
1744
784
1784
824
1824 10
8G4
IBM
v 904
190J
944
19H
9E4
19M
\t
202]
mi
"

65
65

Downloaded from www.Manualslib.com manuals search engine


The
The64's
64'sscreen
screenmemory
memorynormally
normallybegins
beginsatatmemory
memorylocation
location1024
1024and
andends
ends
atatlocation
location2023.
2023. Location
Location1024
1024isisthe
the upper
upperleft
leftcorner
cornerofofthe
thescreen.
screen.Location
Location
1025
1025isisthe
theposition
positionofofthe
the next
nextcharacter
charactertotothe
theright,
right,and
andsosoon.
on.Location
Location 1063
1063
isisthe
the right-most
right·most position
positionofofthe thefirst
first row.
row. Following
Followingthethe last
lastcharacter
characterininaarow,
row ,
the
the next
next location
location isis the
the left-most
left·most character
character onon the
the next
next row
row down.
down.
Suppose
Supposeyou you want
want totocontrol
control aaball
ball bouncing
bouncingon
on the
thescreen.
screen.The
The ball
ball isis ininthe
the
middle
middle of
of the
the screen,
screen, column
column 29,29, row
row 12.
12. The
The formula
formula for
for calculating
calculating the the
memory location
memory location on
on the
the screen
screen is:
is:
POINT 1024 ++ XX ++ 40
POINT == 1024 40'■ Y— row
y - row
II column
column
where
where XX is
is the
the column
co lu mn and
and YY is
is the
the row.
roV/.
Therefore, the memory location of the
Therefore, the memory location of the ball
ball is:
is:
POINT 1024 ++ 20
POINT == 1024 20 ++ 480—row
480 - row (40x12)
(40x12)
POINT
POINT == 1524
1524 II -column
column
Clear
Clear the
the screen
screen with
with SHIFT
SHIFT and
and CLR/HOME
CLR/HOME and
and type:
type:
POKE 1524,81—character
POKE 1524,81- character code
code
I—
L - location
Iocation
This
Thi s POKE
POKE statement
statement makes
makes aa ball
ball appear
appear inin the
the middle
middle ofof the
the screen.
screen. You
You
have
have placed
placed aa character
character directly
directly into
into screen
screen memory
memory without
without using
using the
the PRINT
PRINT
statement.
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
the screen
the screen background.
background.

COLOR
COLOR MEMORY MAP
MEMORY MAP
You can change the color of the ball that appeared by altering another range
of
of memory.
memory. Type:
Type:

POKE 55796,2- color


55796.2—color
I location
L-Iocation
Th is changes
This changes the
the ball's
ball's color
color to
to red.
red.
Every spot
Every spot on
on the
the 64's
64's screen
screen has
has TWO
TWO memory
memory locations:
locations: one for the
character code,
character code, and
and one
one for
for the
the color
color code.
code. The
The color
color memory
memory mapmap begins
begins atat
location 55296
location 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
the same color
color codes,
codes. 00 through
through 15,
15, that
that you
you used
used toto change
change border
border and
and
background colors,
background colors, to
to directly
directly change
change character
character color.
color.
We can
We can modify
modify the
the formula
formula for
for calculating
calculating screen
screen memory
memory locat
locations to give
ions to give
us the
us the locations
locations to
to POKE
POKE colors.
colors. Here's
Here's the
the new
new formula:
formula:
COLOR
COLOR PRINT 55296 +
PRINT == 55296 X +
+ X + 40
40 •* Y - row
Y—row
II column
column

66
66

Downloaded from www.Manualslib.com manuals search engine


v MORE BOUNCING BALLS
us
Here's a revised bouncing ball program that directly prints on the screen us·
ing POKEs rather than cursor controls within PRINT statement
statements.s. When you
pro
RUN this version, you'll see that it's much more flexible than the earlier pro·
gram and it leads up to programming more sophisticated animation.
NEW
10 PRINT" SHIFT CLR/HOME "
v 20 POKE 53280,7 :: POKE 53281,6
X = 1 : Y - 1
30 X=l:Y=l
v 40 DX = 1
OX 1 ::DY
OY == : 11
50 POKE 1024 + X + 40'Y,81 40*Y,81
60 FOR T = 1 1 TO
TC 10 :: NEXT
70 POKE 1024 + X X + 40'Y,32
40*Y,32
B0 X = X
80 X + OX DX
v IFX < = OORX>=
90 IFX<= 0 OR X> = 39 THEN OXDX = -OX
-DX
Y = Y
100 Y Y ++ OYDY
110 IF Y
Y<< = 0 OOF
OR! Y> = 24 THEN OY
DY = --DY
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
Y variables in line 30 keep track of the bali's
ball's current row and col·
col
umn position. The DX
OX and DY variables in line 40 are the horizontal and vertical
direction o off the bali's movement. When a + 11 is added to the value of X, the ball
ball's movemenL
moves to the right; when -- 1 1 is added,
added, the ball moves to the left. lefL A
A+ + 11 added to
Y
Y moves the ball down aa row, and aa -- 1 1 added to Y Y moves the ball up a row. row .
Line 50 puts the ball on the screen at the c current
urrent X,Y position
position.. Line 60 is a a
loop, which is included to keep the ball on the screen long enough for you
delay loop,
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.


Line 9090 tests to see if thethe ball
bal l has reached oneone of the side walls,
walls, and reverses
the
the ball's
ball's direction if there's
there 's aa bounce. Lines 100 100 and 110110 do
do the
the same thing
thing for
the
the top and bottombottom walls.
Line
Line 120120 sends thethe ball
ball back to to display and moves the the ball
ball again.
You can
You can change
change the
the ball to any any other
other character by changing the the code in line
v 50 from 81 81 to
to another character code.
If you
If you change
change DX OX oror DY
OY toto 00 the
the ball bounces
bounces straight
strai ght instead
instead of diagonally.
We
We cancan also add
add aa little intelligence to the bouncing
intelligence to the bouncing ball program.
program. So So far the
only thing you you checked
checked for is is whether
whether thethe ball
ball is
is going out of bounds
bounds on the the
screen.
screen. TryTry adding
adding the
the following lines lines to
to the
the program:
program:
21
21 FOR
FOR LL = 11 TO
TO 10
10
25
25 POKE
POKE 1024
1024 ++ INT(RND(1)* 1000).166
INT(RNO(1)'1000),166- CHRSCODE
-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
Lines 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
PEEKs
PEEKs toto 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

Downloaded from www.Manualslib.com manuals search engine


n
()

n
n

**
Downloaded from www.Manualslib.com manuals search engine
Downloaded from www.Manualslib.com manuals search engine
CHAPTER 77
CHAPTER
INTRODUCTION TO
INTRODUCTION TO SPRITES
SPRITES
•• Bits,
Bits, Bytes
Bytes and
and Sprites
Sprites
•• Creating
Creating Sprites
Sprites
•• More on
More on Sprites:
Sprites: Colors
Colors and
and Extra
Extra Movement
Movement

In
In previous
previous chapters,
chapters, we've
we've shown
shown you
you how
how to
to use
use graphic
graphic symbols
symbols inin PRINT
PRINT
statements
statements to
to create
create animation
animation and
and other
other visual
visual effects.
effects.
In
In chapter
chapter 6,6, we
we also
also showed
showed you
you how
how to
to POKE
POKE character
character codes
codes in
in specific
specific
screen
screen memory
memory locations,
locations, which
which put
put characters
characters directly
directly on
on the
the screen
screen inin the
the
place you
place you selected.
selected.
In
In both
both ofof these
these cases,
cases, you
you have
have toto create
create objects
objects from
from existing
existing graphic
graphic sym
sym-
bols,
bols, so
so these
these methods
methods take
take aa lotlot of
of work.
work. When
When you
you want
want to
to move
move the
the object,
object,
you
you must
must use
use aa number
number of of program
program statements
statements toto keep
keep track
track of
of the
the object
object and
and
move
move itit to
to aa new
new place.
place. And
And sometimes
sometimes the the shape
shape and
and resolution
resolution ofof the
the object
object
isn't
isn't as
as good
good asas you'd
you 'd like
like itit to
to be
be because
because of of the
the limitations
limitations of
of using
using graphic
graphic
symbols.
symbols.
You
You can
can eliminate
eliminate aa lotlot of
of these
these problems
problems by by using
using sprites
sprites in
in animated
animated se se-
quences.
quences. A A sprite isis aa high-resolution
high-resolution porgrammable
porgrammable object object that you can makemake
into just
just about any shape by using using BASIC commands. Ail All you have
have to do to
move
move the
the object
object isis simply
simply tell
tell the
the computer
computer the the position where
where you'd
you'd like
like the
the
sprite to go. The computer takes care of the rest.
But this isn't
But this isn't all
all you
you can
can do
do with
with sprites. For example
sprites. For example,, you
you can
can change
change their
their
color, you can tell if one object collides with another, you can make them go in
front and behind each other, and you can easi easilyly expand their size.
You have to learn a few more details about your 64 and the way it hand handlesles
numbers before you can use sprites. It's not difficult, though, so just
numbers before you can use sprites. It's not difficult, though, so just follow the follow the
examples and
examples and you'
you'llll be
be maki
making your own
ng your own sprites
sprites dodo amaz
amazing things in
ing things in no
no time.
time.

68
68

Downloaded from www.Manualslib.com manuals search engine


v
BITS, BYTES,
BITS, BYTES, AND
AND SPRITES
SPRITES
v Before
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
things
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.
Think of your computer's memory as a collection of BYTES, whichh break
Think o f your computer's memory as a co llec ti on of BYTES, whic break
down
down into into eight
eight BITS
BITS per
per byte.
byte. AA bit,
bit, which
which isis the
the smallest
smalles t amount
amount of of informa
informa·
tion
tion aa computer
computer can can store,
store, can
can have
have only
only two
two values:
val ues: ON ON oror OFF.
OFF. WhenWhen aa bitbit isis
ON,
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 ofo f 0.
O.
When
When you you program
program your
your computer,
computer, what wh at you're
you're doing
doing isis turning
turnin g bits
bi ts ON
ON or or
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
and OFF
OFF bitsbits sends
sends aa different
different message
message to to the
the computer,
computer, you you can
can dodo incredible
inc redible
things wi th your
things with your 64.
64.
IfIf you
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
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
with th e number
number of
of bits:
bit s:
NO. OF
NO. OF NO. OF
NO. OF
BITS
BITS VALUES
VALUES POSSIBLE
POSSIBLE COMBINATIONS
COMBINATIONS
11 22 tt 11 ON
ON 11
2
= 2 OFF
OFF 0
0
2
2 22 t2
t 2 ON
ON and
and ON
ON 11 11
4
= 4 ON and
ON and OFF
OFF 11 0
0
OFF
OFF and
and ON
ON o
0 11
OFF and OFF 0
000

3
3 213
2 t 3 ON
ON and ON
ON and
and ON
ON 1111
11
8
= 8 and OFF
ON and ON and 11 11 0
0
ON and OFF and
and ON 10
10 11
ON and OFF and OFF 11 0
000
OFF and ON and ON o
0 1111
OFF and OFF and ON 00 1
001
OFF and ON and OFF o0 11 0
OFF and OFF and OFF 0 00
000
v
As you can see, the number of possible values equals 2 raised to the power
bits. In other words, if you have 8 bits,You
of the number of bits. bits,you have 218,or
2t8,or 256,
256, dif-
dif
Eight
ferent combinations of bits. Eig dif
ht bits equal a BYTE, so a byte can store 256 dif-
ferent values.
bits are OFF, the byte equals zero;
When all eight bits zero: when all eight bits are ON
ON.,
lowest of the 256 combinations,
the byte equals 255 (since zero counts as the lowest
naturally
naturally the highest
highest value is 255 rather
rather than 256).
Any combination of a byte's ON's and OFF's, or 11's 's and O0's,
's, converts to a
base 10)
decimal (i.e., base 10) value between 0 and 255. Here's a way to figure out the
byte when you have
value of the byte have different combinations of ON and OFF bits: bits:

v Draw aa table for the eight bits


Draw bits and fill in
in 1
1's bits and O's
's for ON bits 0's for OFF bits.
bits.
Across the top of the the table, write 128,
128, 64,
64, 32, 16,
16, 8, 4, 2, and 1.
1. Th
These numbers
ese numbers
v are 2 17,
are 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 11 2 t 0. or
or 2 to
to the
the power
power of
of each
each of
eight bits,
the eight bits, with
with the
the bits
bits numbered
numbered 0 through
through 7. ForFor example:
example:

128
128 64
64 32
32 16
16 88 4 2 1
1
1 00 11 11 0 11
0 00 1

Now add
Now add up
up Ihe
the values
values of
of the
the ON
ON bits
bits to
to find
find the
the value
value of
of the
the byte:
byte:

128 +
128 32 +
+ 32 16 +
+ 16 4 +
+ 4 + 11 = 181
181 =
69
69

Downloaded from www.Manualslib.com manuals search engine


Here's aa table
Here's tabte showing
showing BINARY
BINARY to
to DECIMAL
DECtMAL conversion.
conversion. AA zero
zero indicates
indicates
that
that aa bit
bit is
is OFF,
OFF, and
and aa 11 shows
shows that
that aa bit
bit is
is ON.
ON . To
To find
find out
out the
the value
value of
of the
the en
en-
tire byte,
tire byte, just
just add
add up
up the
the DECIMAL
DECtMAL value
va lue of
of each
each ON
ON bit,
bit, just
just as
as we
we did
did above.
above.

BINARY TO
BINARY TO DECIMAL
DECIMAL CONVERSION
CONVERSION

Decimal
Decimal Value
Value
128
128
0
64
6'
0
0
32
32
0
0
16
16

0
0
88
0
0

4

0
0
22

0
0
11

11 2|0
210
0
0 0
0 0
0 0
0 0
0 0
0 11 0
0 7\
2111 —
0
0 0
0 0
0 0
0 00 11 0
0 0
0 2]
2122
0
0 0
0 0
0 0
0 11 0
0 0
0 0
0 2T3 -
213
0
0 0
0 0
0 J1 0
0 0
0 0
0 0
0 2?4
21'
0
0 0
0 11 0
0 0
0 0
0 0
0 0
0 2T5
2)5
0
0 11 0
0 0
0 0
0 0
0 0
0 0
0 2|6
216
11
- 0 0
0 0 0
0 0
0 0
0 0
0 2f7
217
~

TIP:
TIP:
Converting binary
binary numbers
numbers to their
their decimal
decimal values
values is the basis
basis for
for creating
data
data to represent and manipulate
mani pulate sprites.
sprites. Here's a program that does these
conversions (or
for you.
you . Since you'll be using
using this program
program often,
often , you should enter
enter
and save it.
5
5 REM BINARY TO DECIMAL CONVERTER
10
10 INPUT ""ENTER
ENTER 8-BIT BINARY NUMBER :";A$
12
12 IF LEN (A$)< <>
(A$) > 8 THEN PRINT ""88 BITS PLEASE
PLEASE...":
... ": GOTO 10
10
15 TL = 0 C = 0
0::C
20 FOR X = 8 TO 1 1 STEP - - 11 :: C = C + 1
1
30 TL = TL + VAL(MIDS(A$,C,I»'2
VAL(MID$(A$.C.1))*2 t(X-l)
t(X-1)
40 NEXT
NEXTXX
50 PRINT AS;" ;" = ";TL;" DECIMAL"
AS; " BINARY "•■;"
60 GOTO 10
At line 10 you enter a binary number as the string A$. Line 12 uses the LEN
digits. If you didn't,
(length) function to check to be sure you entered 8 binary digits.
the program asks for more and repeats line 10.10.
15, TL keeps track of the binary number's decimal val
In line 15, value, in
ue, and C in·
being
dicates which bit is bei ng worked on as the program goes through the loop.
value
Line 30 updates the val VALand
ue of TL. Appendix C explains the VAL MIDS func-
and MID$ func
tions.
PRINTS the binary and decimal values of the byte.
Line 50 PRINTs byte. Line 60 returns the
program to the beginning.

70

Downloaded from www.Manualslib.com manuals search engine


AA block
block ofof bytes
bytes strun
strungg together makes up up a REG REGISTER. For sprite·making,
ISTER. For sprite-making,
each register
each register isis only
only one byte
byte long. Each
Each register
register controls a a different functi
function.
on.
v
For examp
For example, ENABLE REGISTER
le, the ENABLE REGISTER control
controls whether the sprite is ON or
s whether or OFF;
the
th EXPAND X REG
e EXPAND REGISTER
ISTER cancan make
make the sprite longer,
longer, etc.
etc. When you work with
sprites, keep in in mind that a REG REGISTER BYTE that does a
ISTER is a BYTE a specific job.
v registers
A series of regi makes up a chart called a REGISTER
sters makes REGISTER MAP.
MAP. You can find
the register map for the VIC chip in in Appendix P. P.
Now, another important thing about bytes
Now, bytes isis that each byte
byte has
has a speci
specific ad
fi c ad·
dress inin 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,
contactt with bytes than you are when you program in BASIC
you're in closer contac
because you're worki workingng directly with byte addresses. When you work with
sprites,
sprit directly
es, you are direc controlling
tl y con tro lling which bits are ON and which are OFF.
To understand how to use sprites, you need to be able to figure exactly which
bytes you want to use. In this chap chapter, formulas
ter, we'll give you formu finding
las for findi ng the
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
71
71
v
v
Downloaded from www.Manualslib.com manuals search engine
~-

CREATING SPRITES
controlled
Sprites are control (VIC-II chip) in the 64.
ted by their own video display chip (VIC·II
The chip does all the work of creating and keeping track of characters and
graphics, creating colors.
graphics, colors, and moving the graphics around. All
Ail you have to do is
tell the computer three things about the sprite:
• What it should look like
• What color it should be
• Where it should appear
inter
The sprite's display chip has 46 different ON/OFF locations that act like inter·
locations.
nal memory locat ions. Each of these locations breaks down into a series of 8
bytes, and each byte can be either ON or OFF. So this means you
bytes, you have 368
ON/OFF locations for sprites. By POKEing the appropriate decimal val value
ue in the
location, you can control the formation and movement of your
proper memory location,
aboul this later.
sprites. We'll give you more detail about
In addition to showing you sprite display chip locations,
locations, we'll show you how
to use some of the 64's main memory to store data that defines the sprites.
Finally, we'll use eight memory locations directly after the screen memory to
tell the computer exactly which memory area each sprite will get its data from.
Sounds like aa lot of details,
details, but don't worry,
worry, you'll get the hang of it as we go '"'
through some examples.
Before you get started,
started, here are some important things to know about 0.
sprites:
• Sprites are usually displayed in a special high resolution mode which turns
the screen into a
a 320 dot wide by 200 dot high area.
area.
• Each sprite
sprit e object is 24 dots wide
wide by 21 dots high.
• You can control up to eight sprites at a
a time. The sprites are numbered 00 to 7.
• Each sprite has individual color control.
contro1. n
• There's a sprite multi-color mode.
• You can use sprite-to-sprite
sprite·ia-sprite and sprite-to-background collision
col lision detection. n
But first you need to know what VIC-II
VIC·II chip
chip locations control the functions
you need.
need. Remember that the sprites' chip
ch ip has 46 different ON /OFF
/O FF locations.
Here's aa partial
partial map
map that shows some of these locations, which are called
registers.
registers. Appendix
Appendix P P has
has aa complete
comp lete VIC
VIC chip register map.
map, but the registers
you'll need for
for sprites
sprites are
are listed
listed here:
Registers Description
o
0 X
X coordinate
coordinate of sprite
sprite 00
11 Y
Y coordinate
coordinate of
of sprite
sprite 00
2-15
2·15 X
X and Y
Y coordinates, paired
paired like registers 00 and
and 11 for sprites
1-7
1·7
16
16 Most
Most significant
signi fi cant Bit
Bit —
- XX coordinate
coordi nate
21
21 Sprite appear:
appear: A=
A = appear,
appear, 0=
0 = disappear
disappear
23 Expand
Expand sprite
sprite in
in Y
Y direction
direction
29
29 Expand
Expand sprite
sprite in
in X
X direction
direction
39-46
39-46 Sprite
Sprite 0-7
0·7 color
color

72

Downloaded from www.Manualslib.com manuals search engine


program
Now we'll show you how to write a prog ob
ram to create and move a sprite ob-
ject. Here are some things you'll learn to do:
o• Make the sprite(s) appear on the screen by POKEing into location 21 21., the
register that turns ON sprites.
o• pointer (memory locations 2040-2047) to show where sprite
Set the sprite pOinter
data should be read from.
o• memory.
POKE actual data into memory.
o• Move the sprite around by using a loop to update X X and Y coordinates.
Y coordinat es.
o• object,
Expand the sprite objec t, change colors, perform a variety of special tasks.
Suppose you want to create a ball balloon
oon and have it float around. You can
design the balloon in a 24 by 21 dot grid (see page 74). 74).
nextt step is to convert the graphic design into data
The nex lata the computer can
v use. Use a piece of lined paper or graphic paper to set up ud a sample grid that is
v 21 spaces down and 24 spaces across. Divide the 24 squares across the top in· in
to three sections,
sections, and number the squares in each secti sec'ion series
on with this seri es of
128,64,32,
numbers: 128,64, 16,8,4.2,1
32, 16, illustration). T'lese
8,4, 2, 1 (see the illustration). ~ i-3se numbers are 2 2 t 7,
7,
2 t16,
2 2 t 5,
6,2 5, 2 t14,
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 you're
're using. Recall that the eigh eightt sprites are numbers 0
through 7. 7.
Number the squares down the left side 1-21 for each row. Write the word data
v 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
square. Think of the squares
sq uares that aren't filled as OFF. OFF, and give each each of them a
zero.
zero.

Now youyou need to separate each row into thirds so you can convert the ONs
and OFFs
OFFs into pieces of data the computer can read. Dividing the rows is sim sim·
ple
pie since you've
yo u've already split each row into into three sections.
sections.
Now each section of each row has eight squares, squares, and each set of eight
squares is is equal toto one piece
piece of data ca called
lled aa BYTE.
BYTE. This
Thi s means youyou have three
bytes per row.row .
Startin g on the
Starting th e first
first row of the balloon drawing
drawing and working from from the left, the
first eight squares are blank (0), (0), so the value for that
for th at series (byte) is 0.
O.

73
73
v

Downloaded v
from www.Manualslib.com manuals search engine
-

SERIES
SERIES SERIES SERIES

118
128 31
32
I1
88 2
:
128 32
28 2
I
128 ;31
3
8 1
64 16 4 11 64 16 4 11 64 16 A 1

4+m+t
5 +-1-+++
6 +-1-+++
) +-1-+++
~ 1:0 tt!tj::j:
~ II

11 m S H
13
14+t++t+ t-+-
15
16 ++:t+rn:t+
-t
I) ++++ 1-++-++
18 +t++t+I+++
19 ++++I-++-+++-
10 + +++ I-++-+++-
11 +-II-+I-+-++t+++
10 I15
COLUMN

The middle series of squares looks lilike


ke this (remember that a 1
1 is a fil led dot
filled
and a a
0 is a blank dot):

128 64 32
SZ 16
16 8 4 2 1
n
o0 1 1 1 1 1 1

it it it it ir it it ti
o0+64+32+16+8
+ 64 + 32 + 16 + 8 + 44+ + 22+1
+ 1 = 127

74

Downloaded from www.Manualslib.com manuals search engine


eight
The third series of ei ght squares also contains only blanks, so it also equals
So, the data fo
zero. So, forr the first line is:
is:

DATAO,
DATA 127,0
0, 127, °
calculated
The three series of dots that make up row two are calc this:
ulated like thi s:

Series
Se 1:
rie s 1: I 0 I 0 0 0 0 0 0 1

1 ~

Series 2,
Series 2: eel > 1 } 1 1
1 1
1 1
] 1
1

if iT it it it 1t iT 1t
128 64
128+64+32
32 + + + 16 + 8
16+8 +
+44 +
+22 + 11 = 255

Series 3: I 1I I I 0 0 0 0 0 0
iT 1T
128 + 64
+ = 192

The data for the


the second row is:
DATA 1,
1,255,
255, 192
Use this method to convert the three series of eight re
ei ght squares in each of the re-
maining rows.
Once you have done the rest of the conversions, yo
youu have the data you
you need
to make the
the balloon.
ball oon.
Type in
in the following
fol lowi ng program:
11 REM UP, UP, AND AWAY
UP, UP,
5
5 PRINT "(CLRlHOME)"
"(CLR/HOME)"
10
10 V
V = 53248:
53248 : REM
REM START
START OF DISPLAY CHIP
11
11 POKE V
V + 21,4 :: REM ENABLE
ENABLE SPRITE 22
12 POKE 2042,13
2042,13 :: REM SPRITE
SPRITE 22 DATA
DATA FROM 13TH BLK
BLK

v
20
20
30
30
40
40
FOR N
FOR
FOR X
POKE
N = 0 TO 62:
X =
PO KE V
= 0 TO
TO 200
V + 4,X:
°°
62: READ Q:
200
4,X: REM UPDATE
Q : POKE 832+ N,Q:
J
UPDATE X X COORDINATES
NEXT
N,Q: NEXT
GETS ITS INFO.
FROM DATA
50
50 POKE VV++ 5,X:
5,X: REM UPDATE Y Y COORDINATES
60
60 NEXTX
NEXT X INFO. READ IN
70
70 GOTO 30 FROMQ
200 DATA
DATA 0,127,0,1,255,192,3,255,224,3,231,224
210 DATA
DATA 7,217,240,7,223,240,7,217,240,3,231,224
7,217,240,7,223,240,7,217,240,3,231 ,224
220
220 DATA
DATA 3,255,224,3,255,224,2,255,160,1,127,64
230
230 DATA
DATA 1,62,64,0,156,128,0,156,128,0,73,0,0,73,0
1,62,64,0,156,128,0,156,128,0,73,0,0,73,0
240
240 DATA
DATA 0,62,0,0,62,0,0,62,0,0,28,0
0,62,0,0,62,0,0,62,0,0,28,0

v
v

75
75

Downloaded from www.Manualslib.com manuals search engine


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
tion located inin memory.
memory.
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
equals 63
63 bytes
bytes (504/8
(504/8 bits).
bits). SoSo each
each sprite
sprite isis 63
63 bytes
bytes plus
plus 11byte
bytewhich
which isis the
the
sprite's
sprite's place
place holder,
holder, or
or pointer.
pOinter. The The pointers
painters for for each
each ofof 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,
Normally, the pOinters begin at location 2040 for sprite 0, through 2047
the pointers begin at location 2040 for sprite 0. through 2047 for for
sprite 7:7:
sprite
2040
2040 2041
2041 2042
2042 2043
2043 2044
2044 2045
2045 2046
2046 2047
2047
sprite sprite
sprite
0 1 22 33 44 55 66 77

Line
line 10
10 in
in the
the program
program sets
sets VV to
to the
the VIC
VIC chip's
chip's starting
starting memory
memory location.
location.
Then
Then later
later in
in the
the program
program youyou can
can get
get the
the VIC
VIC chip
chip memory
memory location
location you
you want
want
just
just by
by adding
adding thethe appropriate
appropriate register
register number
number toto V.
V.
Line
line 11
11 makes
makes sprite
sprite 22 appear
appear byby POKEing
POKEing aa 44 into
into the
the SPRITE
SPRITE ENABLE
ENABLE
REGISTER
REGISTER (21).
(21). Why
Why POKE
POKE aa 4?4? Because
Because 44 is
is the
the decimal
decimal value
value for
for 22 to
to the
the se
se·
cond
cond power.
power. Recall
Recall that
that thethe decimal
decimal value
value for
for aa sprite
sprite is
is 22 to
to the
the power
power ofof the
the
number
number ofof the
the sprite.
sprite. IfIf you
you wanted
wanted to to turn
turn ON
ON sprite
sprite 3,
3, you'd
you'd use
use this
this state
state·
ment:
ment: POKE
POKE VV + + 21,8.
21,8. YouYou turn
turn aa sprite
sprite ON
ON byby POKEing
POKEing the the decimal
decimal value
value for
for
the sprite into the sprite enable register (21). Here's how register 21 looks after
the sprite into the sprite enable register (21). Here's how register 21 looks after (]
line 11
line 11 turns
turns ON
ON sprite
sprite 2:
2:

R~;
1 8
128 64
64 32 16 8 4 2 1 decima
1 decimal
REG. values
21 1 :
0 1 0
0 1 3002 1 :0 1 :0 1 41 1 0
: 1 o
0

7 6 5 4 3 22 1 o0 sprite
sprite
number
number

If you wanted to turn ON both sprites 2 and 3, 3. you'd add 8 and 4, 4. the decimal
values for the sprites, and use this statement: POKE V + 21,12
12 tells the computer where to lind
Line 12 find the data for sprite two. Recall that
pointer
the pOin ter for sprite 2 is memory location 2042. This line POKEs a 13 into into spri
sprite
te
pointer, which means
2's pOinter, means that sprite 2's data will be be kept
kept in the 13th13th series of
sprite bytes.
bytes.
Line 20 puts
line puts data intointo the 63 bytes
bytes that make
make upup a sprite. READ
READ Q Q gets the
data from the DATA
data DATA statements in in lines
lines 200 through 240. The 832 832 in
in the POKE
POKE
statement is
statement is the
the location
location ofof the
the 13th
13th block
block ofof sprile
sprite bytes.
bytes. AsAs the
the loop
loop in
in line
line 20
READs data,
READs data, the values
values areare POKEd
POKEd intointo the
the 63
63 sprite
sprite bytes
bytes located
located inin block
block 13.13.
Lines 30
lines 30 through
through 50 50 control
control the
the sprite's
sprite's movement
movement across
across thethe screen.
screen. line
Line 4040
POKEs the
POKEs the value
value of
of XX into
into the
the VIC
VIC chip
chip register
register location
location (4)
(4) that
that represents
represents the the
sprite 2'5
sprite 2's X
X coordinate.
coordinate. The
The X
X coordinate
coordinate represents
represents horizontal
horizontal movement.
movement. Line
Line
50 POKEs
50 POKEs thethe current
current value
value of of XX into
into the
the register
register location
location (5)
(5) that
that stands
stands for
for
sprite 2's
sprite 2's Y
Y coordinate,
coordinate, oror ve
vertical movement. This
rt ical movement. This loop
loop moves
moves the
the sprite
sprite DOWN
DOWN
and
and TOTO THE
THE RIGHT.
RIGHT.
line
Line 70
70 starts
starts the
the program
program over over again.
again.
Lines 200 through 240 contain the data
lines 200 through 240 contain the data for
for the
the sprite.
sprite.
Try adding
Try adding the
the following
following line
line and
and RUN
RUN the
the program
program again:
again:

25 POKE
25 V +
POKE V + 23,4:
23,4: POKE + 29,4:
POKE VV-f 29,4: REM
REM EXPAND
EXPAND SPRITE
SPRITE

76
76

Downloaded from www.Manualslib.com manuals search engine


v
Now the
Now the balloon
balloon has
has doubled
doubled inin size
size because
because you
you POKEd
POKEd the
thedecimal
decimal valuevalue
v forsprite
for 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, direction,
tical, direction, and
and into
into register
register 29,
29. which
which con
controls
trols aa sprite
sprite's expansion in
's expansion in the
the
v X, or
X, or horizontal
horizontal direction.
direction.
Now try
Now try adding
adding sprite
sprite 33 to
to your
your screen
screen by
by entering
entering these
these lines:
lines:
11
11 POKE VV ++ 21
POKE 21,12
,12
v 12
12 POKE 2042,13:
POKE 2042.13: POKE
POKE 2043,13
2043.13
30
30 FOR X
FOR X == 11 TO
TO 190
190
45
45 POKE V
POKE V ++ 6,X
6,X
55
55 POKE V + 7,190 -- X
POKE V + 7,190 X

Line 11
Line 11 turns
turns ONON sprites
sprites 22 and
and 33 byby POKEing
POKEing their
their combined
combined decimal
decimal values
values
(4 and
(4 and 8)8) into
into the
the sprite
sprite enable
enable register
register (21).
(21).
Line
Lin 12 te
e 12 tells the computer
lls the computer to to find
find the
the data
data for
for the
the sprites
sprites in
in the
the 13th
13th block
block of
of
VIC chip
VIC chip memory.
memory. Recall
Recall that
that 2042
2042 is is sprite
sprite 2's
2's pOinter,
pointer, and
and 2043
2043 is is sprite
sprite 3's.
3's.
Lines 45
Lines 45 and
and 5555 move
move sprite
sprite 33 around
around by by POKEing
POKEing values
values into
into sprite
sprite 3's
3's X
X and
and
YY coordinates
coordinates (V (V + 66 and
and VV + + 7).
7).
The following lines lines put
put sprite 4 4 on
on the
the screen,
screen, too:
too:
11
11 POKE V
POKE V + 21
21,28
,28
12
12 POKE 2042,13:
POKE 2042.13: POKE
POKE 2043,13:
2043.13: POKE
POKE 2044,13
25
25 POKE V
POKE V + 23,12:
23,12: POKE
POKE VV + 29,12
29 12
48
48 POKE V
POKE V + 8,X
8,X
58
58 POKE V
POKE V + 9,100
9,100
v
Line 11 turns ON sprites 2,3, 2,3, and 4 4 by POKEing their comb combined
ined decimal
values
val ues (4, 8,8, and 16)
16) into the spri
sprite
te enable register (21).
Line 12 tells the computer to find the data for all three sprites in the 13th
block of
block of memory.
memory.
Line 25 doubles
doubles the size of sprites 22 and 33 by POKEing their combined
decimal value into the registers that control sprite expansionexpansion (23 and and 29).
29).
Lh.e
Li,.e 48
48 moves sprite 44 along the X X axis (horizontally).
(horizontally).
Line 58 positions sprite 44 halfway
halfway down
down the screen at location
location 100.
100. Before,
Before,
we've changed the the YY coordinate throughout the program
program by by using
using aa loop
loop (see
(see
line
line 50
50 in
in the
the original
original program).
program). But
But now
now the
the value for
for the
the YY coordinate
coordinate for
for sprite
sprite
01 ++ 9)9) stays
44 (V stays the
the same
same during
during the
the program.
program. This
This means
means that
that sprite
sprite 44 only
only
moves
moves horizontally.
horizontally.

77
77

Downloaded from www.Manualslib.com manuals search engine


MORE
MORE ON
ON SPRITES:
SPRITES: COLOR
COLOR AND
AND EXTRA
EXTRA MOVEMENT
MOVEMENT
Changing
Changing aasprite's
sprite'scolor
color isis even
even easier
easierthan
than moving
moving itit around
around the
the screen.
screen.
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
numbered 00 through
through 15.15. Chapter
Chapter 66 andand Appendix
Appendix GG list list the
the colors
colors and and their
their
codes.
codes. . ,_
Suppose
Supposeyou you want
want to
tochange
changesprite
sprite1 1's'scolor
colortoto light
lightgreen,
green,whose
whosecode code isis13.
13.
Just
Just enter
enterthis
this statement:
statement: POKE
POKE VV ++ 45,1345,13(assuming
(assuming you you set
set VVtoto 53248,
53248,thethe
VIC chip
VIC chip starting
starting memory
memory location).
location).
When
When you
you ranran the
the sprite
spri te program
program inin thisthis chapter,
chapter, youyou probably
probably noticed
noticed that
that
the
the sprites
sprites never
never moved
moved all
all the
the way
way to to thethe right
right edge
edge of of the
the screen.
screen. This
This hap
hap·
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
is 320 dots wide.wide.
There's
There's aa register
register onon the
the memory
memory map map that that lets
lets you
you move
move an an object
object across
across
the
the entire
enti re screen.
screen. ThisThis register,
reg ister, location
locati on 16, 16, is
is called
called the
the MOST
MOST SIGNIFICANT
SIGNIFICANT
BIT
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
the
the sprite
sprite toto aa horizontal
horizontal spot
spot between
between 256 256 and
and 320.
320.
Here's
Here's how
how the the MSB
MSB works:
works: after
after you've
you've movedmoved the the sprite
sprite toto XX location
location 255,
255,
POKE
POKE thethe sprite's
sprite's decimal
decimal value
value into
into register
register 16. 16. For
For example,
example, to to move
move sprite
sprite 66
to
to horizontal
horizontal locations
locations 256
256 through
through 320,
320, use use this
this statement:
statement:
POKE VV +
POKE + 16,64
16,64
Then
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:
FOR
FOR X
X =
= 00 TO
TO 63:
63: POKE
POKE V
V +
+ 64,X:
64,X: NEXT
NEXT

The
The following program revises
following program revises the original balloon
the original program so
balloon program so that
that sprite 2
sprite 2
moves all the way across the screen
moves all the way across the screen: :
10
10 V = 53248: POKE V+21,4:
V=53248: V + 21,4 : POK
POKEE 2042,13
20 FOR N = 0 TO 62: 62 : READ Q : POKE 832+ N,Q :: NEXT
25
25 POKE
POKE V V++ 5,
5, 100
100
30
30 FOR
FOR X X == 00 TO
TO 255
255
40
40 POKE
POKEV V+4,X
+ 4.X
50
50 NEXT
NEXT
60 POKE
POKE V+ 16,4
V+16,4
70
70 FOR
FOR X = 0 TO
X = 0 TO 6363
80
80 POKE
POKEV+4, X
V+ 4, X
90
90
100
NEXT
NEXT
POKE
'"'
100 POKE V V++ 16,0
16,0 r..
110
110 GOTO
GOTO 30 30

Line 60
line 60 sets
sets the
the most
most sign
significant bit for
ificant bit for sprite
sprite 2.2.
liLines 70 through
nes 70 through 90 90 contain
contain the
the loop
loop that
that moves
moves sprite
sprite 22 across
across screen
screen loca·
loca
tions 256
tions 256 through
through 320.320.
liLine 100 turns
ne 100 turns OFF
OFF the the MSB
MSB so so that
that sprite
sprite 22 can
can gogo back
back toto the
the left
left edge
edge ooff
the screen.
the screen. In
In other
other words,
words, when
when the
the MSB
MSB isis ON
ON,, the
the sprite
sprite can
can only
only move
move from
from
locations 256
locations 256 through
through 320.320. You
You have
have to
to turn
turn the
the MSB
MSB backback OFF
OFF before
before you
you can
can
move the sprite from locations 0 through
move the sprite from locations 0 through 255. 255.
The best
The best way
way to to learn
learn about
about sprites
sprites isis to
to experiment
experiment with with them.
them. TheThe Com·
Com
modore64
modore 64Progra
Programmer's Reference Guide
mmer's Reference Guidehas hasmore
more information
informationaboutabout sprites.
sprites.

78
78

Downloaded from www.Manualslib.com manuals search engine


CHAPTER

MAKING MUSIC
ON YOUR COMPUTER:
FOR NON-PROGRAMMERS

Downloaded from www.Manualslib.com manuals search engine


CHAPTER 88
CHAPTER
MAKING
MAKING MUSIC
MUSIC ON
ON YOUR
YOUR COMPUTER:
COMPUTER:
FOR NON-PROGRAMMERS
FOR NON·PROGRAMMERS -

•• Structure
Structure of
of aa Sound
Sound Program
Program
•• Sample
Sample Sound
Sound Program
Program
Playing aaSong
•• Playing Song on
on Your
Your 64
64
•• Creating
Creating Sound
Sound Effects
Effecls

Your
Your 64's
64's sound-making
sound·making features
fealures let
lei you
you make
make music
music and
and sound
sound effects.
effects. This
This
chapter
chapter is
is an
an introduction
introduction to
to using
using your
your computer's
computer's sound
sound chip,
chip, the
the SID
SID chip.
chip.
The
The Commodore
Commodore 64 64 Programmer's
Programmer's Reference
Reference Guide
Guide has
has extensive
extensive information
information
about music-makinng.
about music·makinng.

STRUCTURE
STRUCTURE OF
OF A
A SOUND
SOUND PROGRAM
PROGRAM
Before
Before we
we begin
begin explaining
explaining how
how to
to program
program the
the sound
sound chip,
chip, we
we want
want you
you to
to
understand
understand aa little
little about
about the
the important
important SID
SID chip
chip memory
memory locations
locations associated
associated
with
with sound-making.
sound-making. These
These locations
locations include:
include:

•• Volume
Volume
•• Waveform
Waveform
•• High and
High and low
low frequency
frequency
• The envelope generator:
generator:
Attack -
Decay
Decay
Sustain
Sustain
Rel ease
Release

VOLUME: There
VOLUME: There are
are 16
16 volume
volume levels.
ievels. To
To set
set the
the volume,
volume, POKE
POKE the
the level
level you
you
want (0-15) at memory location 54296.
want (0·15) 54296. Zero turns the volume OFF.
OFF.
You only
You only have
have to
to set
set the
the volume
volume once
once at
at the
the beginning
beginning of
of your
your program.
program. Thi
Thiss
setting
volume sett ing controls all three of the 64's voices.
WAVEFORM: Th
WAVEFORM: The waveform control
e waveform control STARTS
STARTS and
and STOPS
STOPS EACH
EACH NOTE.
NOTE. Each
Each
voice
vo has its
ice has its own
own waveform
waveform memory
memory location
location that
that lets
lets you
you define
define four
four different
different
types of
types of waveform
waveform by by POKEing
POKEing the start/stop
start/stop numbers
numbers for
for the waveform
waveform you
want. There
want. There areare four
four waveform
waveform types'
types-

Sawtooth:
Sawtooth:

79
79

Downloaded from www.Manualslib.com manuals search engine


Triangular:

v
v
Pulse (variable rectangular waves):
v

r— PULSE
PUlSE WIDU.
WIDTH--

~
'-- '--

White noise (used mainly for sound effects):


effects):

80
60

Downloaded from www.Manualslib.com manuals search engine


This
This chart
chart shows
shows the
the waveform
waveform memory
memory locations
locations for
for each
each voice:
voice:

WAVEFORM
WAVEFORM MEMORY
MEMORY LOCATIONS
LOCATIONS

VOICE 11
VOICE VOICE
VOICE 22 VOICE
VO ICE 33

54276
54276 54283
54283 54290
54290

This
Thi s chart
chart shows
shows each
each waveform's
waveform 's start
start and
and stop
stop numbers.
numbers. These
Th ese are
are the
the
numbers
numbers you
you POKE
POKE into
into the
the memory
memory location
locati on for
for the
the voice
voice you're
you 're programming:
programming:

NOTE
NOTE START/STOP
START/STOP NUMBERS
NUMBERS

TRIANG LE
TRIANGLE SAWTOOTH
SAWTOOTH PULSE
PU LSE NOISE
NOISE
ON/OFF
ON/OFF ON/OFF
ON/OFF ON/OFF
ON /OFF ON/OFF
ON/OFF

17/16
17/16 33/32
33/32 65/64
65/64 129/128
129/128

For
For example,
example, this
th is statement
statement STARTS
STARTS aa sawtooth
sawtooth waveform in
In voice
vOice 1,
1, and
and
STOPS
STOPS a triangle waveform in
in voice 2:
2:
POKE
POKE 54276,33:
54276,33: POKE 54283,16
54283,16

FREQUENCY:
FREQUENCY: A A sound's pitch is determined by the FREQUEN
FREQUENCY CY of the sound
sou nd
you produce when you make music.
waves you music. For
For each note in a music or sound
POKEs: one for the high frequency
program, you must include two separate POKEs:
byte,
byte, and one for the low frequency byte.
byte. The MUSICAL NOTENOTE VALUE
VALUE TABLE in
Appendix M M shows you the POKEs you need to play any note in the 64's eight
oc tave range.
octave
The
Th e high and low frequency memory locations are different for each voice
use, so you can program all three voices independently. Thi
you use, This lets
s let s you
effects.
create 3-voice music and exotic sound effects.
voice's
Here's a chart of the memory locations for each voice frequen
's high and low frequen-
cy bytes:
bytes:

VOICE
VOICE FREQUENCY
FREQUENCY POKE NUMBER
POKE NUMBER

11 HIGH
HIG H 54273
54273
11 LOW
LOW 54272
54272
22 HIGH
HIGH 54280
54280
22 LOW
LOW 54279
54279
33 HIGH
HIGH 54287
54287
33 LOW
LOW 54286
54286

81
81

Downloaded from www.Manualslib.com manuals search engine


v
'-' Appendix M contains a list of all the high and low frequency POKE va values
lues for
each note. Each note in each of the eight ococtaves
taves has two different numbers.
play a musical note, you must POKE the note's high frequency va
To playa value
lue into
want,, and PO
the high frequency location of the voice you want POKE fre
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:
POKE 54273,33 .. . ...... ...... .... .. .... .... ............... ............... . set high frequency
10 POKE
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
5 =
FORL = 54272
54272TO54296:POKEL,0:NEXT
TO 54296:POKEL,0:NEXT ...... SID chip
clear SID
10 V = 54296:W = 54276:A =
10V=54296:W=54276:A = 54277: .................... variables
use variab les to save
S== 54278:
54278:HH=
= 54273:
54273:LL=
= 54272 typing time
20 POKEV,15:POKEA,190:POKES,89 ................. POKE vol,
VOl, attach/decay
sustain/release
POKEH,33:POKEL,135
30 POKEH ,33:POKEL,135 ................................... POKE hi/lo freq. notes
POKEW.33:FORT=
40 POKEW,33:FORT = H0200:
1TO200:NEXT NEXT ...... .......... start note, let it play
50 POKEW,32
POKEW.32 ............... ................ .......... .. ... ....... . stop note

The ENVELOPE GENERATOR: when a note is first


firs t struck,
struck, it rises from zero
volume to its peak volume. The RATE
RATE at which this rise occurs is ca
called
lled the
ATTACK. Then the note falls from the peak to some middle·range
middle-range vol
volume.
ume. The
RATE of the note's
note's fall is called the DECAY. mid·range vol
DECAY. The mid-range ume itself is call
volume call·
ed the SUSTAIN LEVEL.
LEVEL When the note stops playi
playing,
ng, it falls from the
the SUSTAIN
level to zero vol
level volume.
ume. The RATE of this fall is ca
called
lled the RELEASE. Here's a
the RELEASE. a
sketch of the four phases of a note:

v
SUSTAIN LEV EL - - --....,---~
SUSTAIN LEVEL---/ 1 . ----,.
, ' ,
, I
A : 0 : 5 , R:

NOTE:
NOTE: ATTACK,
ATTACK, DECAY,
DECAY, and RELEASE are
are RATES.
RATES. SUSTAIN
SUSTAIN is
is aa LEVEL.
LEVEL.

v
82
82

Downloaded from www.Manualslib.com manuals search engine


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
locations. rings is
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
you must COMBINE ATTACK ATIACK and DECAY settings by adding them. Then you
total in a POKE statement.
enter the total
The ATTACK
ATIACK rates occupy the 2 2 tt 7,
7, 2 t 6,2
6, 2 t 5,
5, and 2 t 4
4 bits,
bits, so th
thee
128,64.
values are 128, 32, and 16. DECAY rates are 2 t 3,2 t 2,
64, 32, 2,2
2 t 1,and
I , and 2 t 0,0.
8, 4,
or 8, 4, 2, and 1. Suppose you want to set a HIGH ATIACKATTACK rate and a LOW
DECAY rate: add Ihe the high attack value (128) to the
Ihe low decay value (2), and
POKE 130 to Ihe the appropriate memory location.
This chart shows you what numbers to POKE for ATTACK ATIACK and DECAY rates:

HIGH
HI GH MEDIUM LOW LOWEST HIGH MED. LOW LOWEST
ATTACK
AITACK ATTACK
AITACK ATTACK
AITACK ATTACK
AITACK DECAY DECAY DECAY DECAY

128
128 64 32 16 8 4 2 1
1

NOTE: You can increase the ATTACK


ATIACK rate by adding together all
all the ATTACK
ATIACK
values: 128 + 64 + 32 + 16 = = 240, which is the MAXIMUM ATTACK
ATIACK RATE.
You
You can increase the DECAY rate by adding together all the DECAY values:
8 + 44 + 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, and vice ve
zero, versa. example, if you POKE 54277,64,
rsa. For example, 54277,64, you're sett
setting
ing a
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 MAX
(8+4+2+ 1)
(8+4+2+1)

POKE 54284,255 2 MAX


MAX MAX
(128+64 +32+ 16
+ 32+16 +8+4+2+1)
+ 8+4 + 2+1)

83

Downloaded from www.Manualslib.com manuals search engine


Here's aa sample
Here's sample program
program Ihal
that illuslrales
illustrates whal
what you
you can
can do
do with
with allackldecay
attack/decay
settings:
sellings:
10 FORL
10 FORL=54272TO54296:POKEL0:NEXT...
= 54272T054296:POKEL,0:NEXT ... Clears Clears Ihe
the SID
SID chip
chip
20 POKE54296J5
20 POKE54296,15 ..... .. Set maximum
............................... Sel maximum volume volume
30 POKE54
30 POKE54277,64
277,64 ......... ...... ... ........ .. ............. Sel Set allackldecay
attack/decay
40 POKE54273,162:POKE54272,37
40 POKE54273.162:POKE54272,37 ............... POKE POKE oneone no
note in voice
Ie in voice 11
50 PRINT"PR
50 PRINT-PRESS
ESS ANY ANY KEY KEY" Screen message
" ................. ....... Screen message
60GETK$:IFK$=""THEN60
60 GETK$:IFKS= " " THEN60 ....... .................. Check Check thethe keyboard
keyboard
70 POKE54276,17:FORT
70 POKE54276,17:FORT= 1TO200:NEXT..... Slart
= H0200:NEXT Start triangle
triangle waveform
waveform
80 POKE54276,16:FORT
80 POKE54276,16:FORT= 1TO50:NEXT
= H050:N EXT ..... .. Stop Stop note
note
90GOTO50
90 Repeat execution
GOT050 ........ ........................ ........ ..... ...... .. Repeat execution

After you RUN


After RUN the
the program
program a few times, try
try changing the ATIACKID
ATTACK/DECAY
ECAY
setting by
setting by changing
changing line
line 30:
30:

POKE 54277,190
30 POKE
RUN the program again and notice
Now RUN notice the difference in
in the note.
note. Try other
combinations
comb of attack and decay settings to get an idea
inations of idea of how you can use
attack/decay rates to create a variety of sound effects.
different allackldecay
SETTING.. Like ATTACK/DECAY,
SUSTAIN/RELEASE SETIING ATIACKIDECAY, SUSTAIN/RELEASE
share a byte. But remember that this sharing doesn't mean that SUSTAIN and
LEVEL, while release,
RELEASE are alike. SUSTAIN is a LEVEL, release, allack
attack and decay are
RATES.
SUSTAIN is a proportion of maximum volume. You
You can sustain, hold,,
sustain, or hold
notes and sounds at any of 16 volume levels.
This table shows you what numbers to POKE for sustain/re
sustain/release
lease values:

HIGH
HIGH MEDIUM LOW LOWEST HIGH MED. LOW
LOW LOWEST
LOWEST
SUSTAIN
SUSTAIN SUSTAIN SUSTAIN
SUSTAIN SUSTAIN
SUSTAIN RELEASE
RELEASE RELEASE
RELEASE RELEASE
RELEASE RELEASE
RELEASE

128
128 64
64 32
32 16
16 8
8 4
4 2
2 11

NOTE:
NOTE: You
You can increase
increase the SUSTAIN
SUSTAIN level by adding together
together all
all the
the SUSTAIN
SUSTAIN
values: 128
128 + + 64
64 ++ 32
32 ++ 16
16 = 240,
240, which
which is is the
the MAXIMUM
MAXIMUM SUSTAIN
SUSTAIN LEVELLEVEL. AA
SUSTAIN
SUSTAIN level
level of
of 128
128 is
is approximately
approx imately 50%50% of of volume. You
You can increase
increase the
the
RELEASE
RELEASE rate by by adding
adding together
together all
all the
the RELEASE
RELEASE values:
values: 88 +
+ 44 ++ 22 ++ 11 =
15,
15, which
which is
is the
the MAXIMUM
MAXIMUM RELEASE
RELEASE RATE.
RATE.
Combine
Combine the
the sustain
sustain level
level and
and release
release rate
rate the
the same
same way
way you
you combine
combine thethe at
at-
tack
tack and
and decay
decay rates:
rates: add
add the
the two
two values
values andand POKE
POKE the
the total
total to
to the
the memory
memory
location
location of
of the
the voice
voice you
you want.
want.
To
To see
see the
the effects
effects of
of the
the sustain
sustain level
level setting
selling add
add this
this line
line to
to the
the last
last sample
sample
program:
program:

35
35 POKE
POKE 54278,128
54278,128
Now
Now RUN
RUN thethe program
program again
again and
and note
note the
the change.
change. With
With line
line 35,
35, we
we tell
tell the
the
v computer to sustain the note at a HIGH SUSTAIN LEVEL (128). You can vary the
comp uter to sustain the note at a HIGH SUSTAIN LEVEL (128). You can vary the
v duration
duration of
of aa note
note by
by changing
changing the the count
count inin line
line 70.
70. Remember
Remember that that the
the sustain
sustain
level
level maintains
maintains aa note
note atat aa proportion
proportion ofof the
the volume
volume asas the
the note
note falls
falls from
from its
its
peak
peak volume:
volume: this
this isn't
isn't the
the same
same thing
thing as
as the
the note's
note's duration.
duration.
To
To see
see the
the effect
effect of
of the
the release
release rate,
rate, try
try changing
changi ng line
line 35
35 to
to POKE
POKE 54278,89
54278 ,8~
(sustain
(sustain == 80,
80, release
release == 9).
9).

84

Downloaded from www.Manualslib.com manuals search engine


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
ing music
musicon
onyour
yo ur64:
64 :
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 forfor waveform,
wave form , attack
attack rate,
rate ,
etc
etc.You
Youcan
canplay
play 1,2.
1,2,or 3 voice
or3 voice together,
together,but
but this
this program
program only
only uses
uses voice
voice 1.1.
22. Clear
Clearthe
the SID
SID chip:
chip: 55 FORL= 54272 TO
FORL =54272 TO 54296:
54296: POKEL,0:NEXT
POKEL,O: NEXT
3.3. Set
Set VOLUME:
VOLU ME: 10
10 POKE54296.15
POKE54296,15
4.
4. Set
Set ATTACK/DECAY
ATIACKIDECAY rates:
rates: ,-,
to
to define
define how
how fast
fas t aa note
note rises
ri ses
to
to and
and falls
falls from
from its
its peak
peak
volume
vo lume level
level (0-255):
(0·255): 20
20 POKE54277.190
POKE54277,190
5.
5. Set
Set SUSTAIN/RELEASE
SUSTAI N/RE LEASE to
to
define
define level
level to
to hold
hold note
note and
and „
rate
rate to
to release
release it:
it : 30
30 POKE54278,248
POKE54278,248
6.
6. Find
Find note
note you
you want
want to
to play
play in
in
the TABLE
the TABLE OFOF MUSICAL
MUSICAL
NOTES
NOTES in
in App.
App. M
M and
and enter
en ter
the HIGH-FREQ.
the HIGH·FREO. and
and LOW-
LOW·
FREO. values
FREQ. values for
for that
that note
note
(each
(each note
note requires
req uires 22 POKEs):
POKEs): 40
40 POKE54273,16:POKE54272,195
POKE54273,16:POKE54272,195
7. Start
7. Start WAVEFORM
WAV EFORM (here,
(h ere,
TRIANGLE):
TRIANG LE): 50
50 POKE54276.17
POKE54276,17
8. Enter
8. Enter aa timing
timing loop
loop to
to time
time be
be·
tween
tween notes
no tes (we
(we use 250
250 for aa
quarter
quarter note):
note): 60 FORT
FORT= 1TO250:NEXT
= 1T0250:NEXT
9. STOP
9. STOP note
note by
by turning
turn ing off
off
chosen
chosen waveform:
wave form: 70 POKE54276,16
Here's
Here's aa longer program that
longer program that further demonstrates your
furthe r demonstrates your 64
64's music-making
's music-making
abilities:
abilities:
NEW
NEW
5
5 REM MUSICAL SCALE ......................... .
REM MUSICAL
7 FORL=54272TO54296:POKEL0:NEXT
7 FORL = 54272T054296: POKEL,0:NEXT clears clears SIDSID chip
chip
10 POKE
10 POKE 54296,15
54296,15 .......... ... ........................ sets sets vovolume
lu me
20 POKE54277,7:POK
POKE54277,7:POKE54278,133 E54278,133 ............ sets sets ald/s/r
a/d/s/r
50 READ A
50 READ A ......................... ............... ......... READs 1st
READs 1st number
number fromfrom line
line 110
110
55 IF A= - 1 THENEND
55 IF A= -1 THENEND .... ....................... ENDS loop
ENDs loop
60 READ
60 READ B B ................................................. READsREADs 2nd 2nd number
number
80POKE54273APOKE54272,B
80 POKE54273,A:POKE54272,B ..... .......... POKE POKEs 1st number
s 1st number fromfrom line
line 110
110 as
as
HI-FREO and
HI·FREO and 2nd
2nd number
number as as LOW·
LOW-
FREO.
FREQ.
85 POKE54276,17
85 POKE54276.17 .... ... ... .......................... starts
starts note
note
90 FORT= 1TO250:NEXT:POKE54276,16 lets note
90 FORT = 1T0250:NEXT:POK E54276, 16 lets note play,
play, then
then stops
stops itit
95 FORT= 1TO50:NEXT
95 FORT = 1T050:NEXT .... ....................... sets time for RELEASE, time
sets time for RELEASE, time be·be
tween
tween notes
notes
100
100 GOT020
GOTO20 ....... ..... ....... ... .......... ...... ........ res tart s prog
restarts ram
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 DATA
120 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 partpart of
of
numbers
nu mbers == one one nonote (16 and
te (16 and 19 19 == ^
4th
4th oc tave C)
octave C)
999 DATA·1
999 DATA-1 ............................................... ENDs ENDs program
program (see (see line
line55)
55)

85
85

Downloaded from www.Manualslib.com manuals search engine


_

You can
You can change
change toto aa sawtooth
sawtooth wave wave byby changing
changing lineline 85
85 to
to read
read
POKE54276.33 and
POKE54276,33 and line
line 90
90 to to read
read FORT;
FORT= n0250:NEXT:POKE54276,32.
1TO250:NEXT:POKE54276,32.
Changing the
Changing the waveform
waveform can
can dramatically
dramatically change
change Ihe
the sound
sound your
your computer
computer
produces.
prod uces.
You can
You can also
also change
change the
the sound
sound in in other
other ways.
ways. For
For example,
example, you
you can
can change
change
the harpsichord·like
the harpsichord-like sound
sound in in the
the previous
previous program
program toto aa banjo-like
banjo-like sound
sound by by
changing the
changing the ATTACK/DECAY
ATTACK/DECAY rate rate of
of each
each note.
note. Do
Do this
this by
by changing
changing line
line 20
20 to
to
read:
read:
20 POKE54277,3:
20 POKE54277.3:POKE54278,0 creates banjo
POKE54278,0 ............... creates banjo effect
effect by
by setting
setting zero
zero
SUSTAIN
SUSTAIN

As this program
As program demonstrates,
demonstrates, your
your 64
64 can sound
sound like
like aa variety
variety of
of musical
musical in-
in
struments.
v

v_

v
v

86
86

Downloaded from www.Manualslib.com manuals search engine


-•

PLAYING A SONG ON YOUR 64


play a line from a song,
The next program lets you playa song, ""Michael
Michael Row Your Boat
Ashore".
Ashore" . The program uses the PULSE waveform, which is a variable width rec-
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
note, 375 for a dotted quarter note,
quarter note, note, 500 for a half note,
note, and 1000 for a
songs, you can increase or decrease
whole note. When you program your own songs, «
these numbers to match a particular tempo or your own musical taste.
F0RL
2 FOR = 54272TO54296: POKEL,O:
L =54272T054296: POKEL,0: NEXT
S = 54272
5 S= m
POKES+
10 POKES POKES+
+ 24,15: POKES POKES+
+ 5,88: POKES POKES+
+ 3,15: POKES + 2,15: POKES
POKES++ 6,89
20 READH: IFH = -- nHENEND
1THENEND fl
30 READL
40 READD
60 POKES+
POKES+1.H: 1,H: POKES,L: POKES+4,65
POKES + 4,65 ^
70 FORT = nOD: NEXT: POKES
FORT=1TOD: POKES+ + 4,64
FORT=1TO50:
80 FORT = n050: NEXT ~
90 GOTO 20
DATA33,135,250,42.62.250.50.60,250.42,62.125.50.60,250
100 DA TA33, 135,250,42,62,250,50,60,250,42,62,125,50,60,250
105 DATA56,99,250 m
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 r\
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
to this variable. For example, POKES+ 24,15 POKEs 15 to the volume regis ter,
register,
which is 54296,
54296, or 54272 + 24. m
Line 10 POKEs values into:
1. The vo lume register: POKES + 24,15
volume g
2. Voice 1, ATTACK/DELAY
An ACKIDELAY rat es: POKES
rates: + 5,88
POKES+5.88
POKES+
3. Pulse width: POKES POKES+
+ 3,15 and POKES + 2,15
4. Voice 1, SUSTAIN level/RELEASE rate: POKES
POKES+ + 6,89 ^

Line 20 READs the first number from the DATA statement. If that number is
- 1,, the program ENDs automatically. This occurs when the final DATA state-
-1 state
ment (line 120) is read. /-.
Line 30 READs the second number from the DATA list.
Line 40 READs the third number from the DATA list. *
Line 60 POKEs:
1. The value for H H that was assigned in the READH statement in line 20. Until
-- 1
1 is read
read,, this value is assigned to the HIGH FREQUENCY register.
register. ^
2. The value for L that was assigned in the READL statement in line 30. This
value is assigned to the LOW FREQUENCY register. Together these two r<
POKEs determine the pitch for one note.
3. The value that turns ON the variable pulse waveform for voice 1.

87
H7

Downloaded from www.Manualslib.com manuals search engine


v
Line 70
Line 70 uses
uses aa loop
loop toto set
set the
the duration
duration forfor the
the note
note being
being played.
played. TheThe valvalue
ue
for D
for D is
is assig
assigned
ned inin the
the READ
READ statement
statement in in line
line 40.
40. As
As you
you can
can see,
see, the
the nunumbers
mbers
in the
in the DATA
DATA lilists are clus
sts are clustered into threes:
tered into threes: the
the first
first number
number (e.g.
{e.g.,, 35)
35) is
is th
the high
e high
frequency val
frequency value for
ue fo r aa note,
note, the
the second
second number
number (e.g.,
(e.g., 135)
135) isis the
the lowlow frequency
frequency
value for
value for the
the same
same note,
note, and
and the
the ththird number (e.g.,
ird number {e.g., 250)
250) sets
sets thethe durati
duration for
on for
that note (e.g.. a quarter
that note (e.g., a quarter note C).note C).
Line 80
Une 80 is
is a
a timing
timing loop
loop that
that determines
determines re release time between
lease time between notes.notes.
Line
Li ne 9090 sends
sends thethe program
program back
back toto READ
READ the the number
number set set for
for another
another note.
note.
Lines 100
Lines 100 through
through 120 120 contain
contain all
all the
the DATA
DATA for for Ihe
the line
line from
from thithis song.
s song.

'-'

'-'

'-'
v
v
'-'

'-'

v
V

'-'
V

'-'
v

'-'
88
-'

Downloaded v
from www.Manualslib.com manuals search engine
-

CREATING
CREATING SOUND
SOUND EFFECTS
EFFECTS
Your
Your 64's
64's SID
SID chip
chip lets you
you create
create aa wide
wide variety
variety of
of sound
sound effects,
effects, such
such as
as an
an
explosion during
during aa game,
game, or
or aa buzzer that
that warns
warns you when
when you've
you've made
made aa
mistake.
mistake.
Here
Here are
are just aa few
few suggestions for
for creating
creating sound
sound effects:
1.
1. Vary
Vary rapidly
rapid ly between two
two notes to create
create aa tremor
tremor sound.
2. Use
Use the multivoice
multivoice effects to
to play more than
than one voice
vo ice at a time,
time, with each
voice
voice independently
independently controlled,
controll ed , so
so you
you have different
different noises at once.
once. Or use
one voice as
as an echo or
or response to
to another voice.
vo ice.
3, Use
3. Use the different pulse widths
widths to
to create different sounds.
4.
4. Use the
the NOISE WAVEFORM
WAV EFORM to make white noise
nOise to accent tonal
tonal sound ef
ef·
fects,
fects , create explosion
explosion noises,
nOises , gunshots,
gunshots, footsteps,
foots teps , or
or alarms. When you
you
use
use the noise
noise waveform
waveform with the
the same musical notes that create music,
music, you
can create different
can di fferent types of white noise.
noise.
5. Combine several
5. several HIGH/LOW
HI GH/LOW FREQUENCIES
FREQUENCIES in rapid succession across dif
dif·
ferent
fe rent octaves.
6. Try POKEing the extra note settings in Appendix M.
M. ~

Here are some sample The Commodore 64 Pro


sample sound effects programs. The Pro·
grammer's Reference Guide
G ui de contains
contain s more examples
examp les as well as more informa
informa-
tion on creating sound effects.

DOLL CRYING

NEW
54272TO54296:POKEL,0:NEXT
5 FORL= 54272T054296: POKEL,O:N EXT .... Clears SID chip
10 S
S== 54272
24.15 ... ............. ..
20 POKES+ 24,15 Sets volume
. .......... Sets volume ^
30 POKES+ 4,65 .................... . .............. Turns ON pulse waveform in
voice
vo ice 11 -->-
40 POKES+ 5,15 .................... .. ........ .. ........ Sets attack/decay rate
POKES + 5,15
50FORX=200TO5STEP-2
50 FOR X = 200T05STEP - 2 .......... .. .... Sets timing loop for RELEAS
RELEASEE or
time between notes
POKES-f
60 POKES 1,40:POKES,X:NEXT
+ 1,40:POKES,X: NEXT. .. ...... Sets hi/lo frequencies
70FORX=
70 150TO5STEP-2
FOR X = 150T05STE timing loop
P - 2 ........................ Sets faster liming
1.40:POKES,X:NEXT
80 POKES + 1,40:POKES,X: NEXT ................ Sets hi/lo frequencies
POKES+
90 POKES 4T64 ........................................... Turns OFF pulse waveform
+ 4,64

89

Downloaded from www.Manualslib.com manuals search engine


SHOOTING
NEW
54272TO54296:POKEL,0:NEXT .... Clears SID
5 FORL= 54272T054296:POKEL,0:NEXT SID chip
10 S= 54272
20 FORX= 15TOOSTEP-1 ...
20FORX=15TO0STEP-1 .. ..... Sets up volume loop
30 POKES + 24,X
30POKES+24.X .. ................................ POKEs X X to vol. register.
40 POKES+ 4,129 ............... .. ......... Starts NOISE waveform
50 POKES+ 5,15 .................... .. .. .. ......... Sets ATTACK/DECAY rate
60 POKES
POKES+ + 1,40.....
1,40 .. .. .. ...... .. ............... Sets high frequency
70 POKES,200:NEXT .............. .. Sets low frequ ency
frequency
80 POKES+ 4,128 ........... NOISE waveform
.. .... Stops NOISE
90 POKES + 5,0
5.0 ............ .. .. .............. .. POKEs 0 to attack/decay
100 GOT020
100GOTO20 ................. ...... ........... Repeat
Repeatss program
The loop that begins in line 20 sets up fading volume so that the sound of the
starts at high vo
gunshot starls lume (15) and fades to 0 as the loops executes.
volume executes.
v Press the RUN/STOP key to end this program.
As we've said before, the best way to learn a new area of programming is to
v experiment.

'--'
v
v

v
v
v

v
v
v

v
v
v

v
90
v
v
Downloaded from www.Manualslib.com manuals search engine

Downloaded from www.Manualslib.com manuals search engine


••

••

••

• 9
• CHAPTER


•• ADVANCED
•• DATA HANDLING
••

••

••

••

••


••

Downloaded from www.Manualslib.com manuals search engine
CHAPTER
CHAPTER 99
ADVANCED
ADVANCED DATA
DATA HANDLING
HANDLING
•• READ and
READ and DATA
DATA Statements
Statements
•• Calculating Averages
Calculating Averages
•• Subscripted Variables
Subscripted Variables
•• Dimensioning Arrays
Dimensioning Arrays
•• Simulated Dice
Simulated Dice Roll
Roll with
with Arrays
Arrays
•• Two-dimensional Arrays
Two-dimensional Arrays

READ
READ AND
AND DATA
DATA STATEMENTS
STATEMENTS
So far
far we've
we 've shown
shown you how how to
to assign
assign values to to variables
va riables directly (A = 2),
and
and how
how to to assign
assign values
values while
wh ile the
the program
program isis RUNning
RUNning (INPUT
(I NPUT andand GET).
GET].
But
Bu t often
often you'll
you 'll find that
that neither
neither way
way suits
suits your
your needs
needs for fo r variable
variable assign
assign·
ment
ment in
in aa program,
program, especially
especially when
when you
you have
have large
larg e amounts
amounts of of data.
data.
In the
the chapter
chapter 77 when
when we
we introduced
introduced sprites,
sprites, wewe used
used READREAD and and DATA
DATA
statements to to assign
assign values
values for sprites.
sprites. Here's
Here's aa short
short program
program that shows shows you
how these
how these two statements
statement s work
work together:
together:

10 READ X
READX
20 PRINT "X IS
PRINT IS NOW :";X
N0W:";X
30
30 GOTO 10
GOTO 10
40 DATA 1, 34,
34, 10.5, 16, 234.56
10.5, 16,

RUN

X IS
IS NOW:
NOW : 1
1
X IS
X IS NOW ::34
34
X
X IS NOW:
NOW : 10.5
X
X IS
IS NOW : 16
X
X IS
IS NOW:
NOW : 234.56

DATA ERROR IN 10
?OUT OF DATA
READY

91
91

Downloaded from www.Manualslib.com manuals search engine


Line 10
Line 10 READs
READs aa value
value from
from Ihe
the DATA
DATA statement
statement atat line
line 40
40 and
and assigns
assigns the
the
value to
value to X.
X.
v Lin
Linee 30
30 teils
tells the
the computer
computer toto re tu rn to
return to line
line 10,
10, whe re the
where the READ
READ assigns
assigns the
the
next
nex value
t va lue inin the
the DATA
DATA statement
statement to to X.
X. The
The loop
loop continues
continues until
until all
all the
the DATA
DATA
v values are
values are read
read..
There are
There are a
a few
few important
important rules
rules you
you must
must remember
remember when
when you
you use
use DATA
DATA
v
statements:
statements:
•• Follow
Follow the
the DATA
DATA statemen
statement format
t form precisely:
at precisely:
v 40 DATA
40 DATA 1,
1, 34,
34, 10.5,
10.5, 16,
16,234.65
234.65
Comma separates
Comma separates each
each item
item

•• Use:
Use:
-— integer
integer numbers
numbers (e.g., 34),
v -— real
real numbers
numbers (e.g., 234.65),
-— numbers
numbers expressed in in scientific notati
notation (e.g.,, 2.4E
on (e.g. + 04),
2.4E+04),
v -— words (as long as you use a string variable in in the READ
READ statement),
but DON
but DON'T use:
'T use:
-— variables or
-— arithmetic operations
items
in DATA statements. The item treated as slrings
s listed below are Irealed strings if you try
only
to READ them, and you can on ly READ them as strings with string variables
in the READ statement
in statement..

DATA A. 2*5. B + 2
23/56, 2·5,
A, 23156,

statement, you can only get values from a DATA state-


When you use a READ statement, state
ment because the two slatements
statements work as partners. Each time you READ a
value,
va lue, the computer knows to move to ththe value
e next val ue in the DATA statement. In
effect, there's a painter
effect, pointer in the computer that keeps track of your place in in the
DATA statement. After READing the first val value,
ue, the DATA statement
statemen t looks like
this:

40
40 DATA 1.
1, 34. 10.5, 16.
34, 10.5, 16, 34.56
t
pointer
p6inter
When the last DATA
DATA value has
has been assigned to the variable in
in the READ
statement
statement and
and the computer
computer tries
tries to
to execute
execute the
the loop
loop again,
again, the
the OUT OF
OF DATA
DATA
ERROR
ERROR is
is displayed.
displayed .
Here's an
an example
example that
that shows
shows one way
way to
to avoid
avoid the
the OUT OF
OF DATA
DATA ERROR.
ERROR.
v NEW
NEW
v
10
10 FOR
FOR XX =
= 11 to
to 33
v 15
15 READ
READ A$
A$
20
20 PRINT
PRINT "A$
" A$ IS
IS NOW
NOW :: ";
"; A$
A$
30
30 NEXT
NEXT
40
40 DATA
DATA THIS,
THIS, IS,
IS, FUN
FUN
v
......, RUN
RUN

v AS
A$ IS
IS NOW
NOW: THIS
THIS
A$ IS NOW
A$IS NOW : IS
IS
v AS
A$ IS
IS NOW
NOW: FUN
FUN
READY
READY
92
92
v

Downloaded v
from www.Manualslib.com manuals search engine
This
This time
time we
Vie put
put the
the READ
READ statement
statement inside
inside aa FOR/NEXT
FOR/N EXT loop
loop that
that limited
limited
the
the number
number ofof READings
READings toto equal
equal the
the numbers
numbers of
of items
items in
in the
the DATA
DATA statement.
statemen t.
As
As long
long as
as you
you know
know how
how many
many items
items will
will be
be in
in your
yo ur DATA
DATA statements,
statements, this
this
method
meth od is
is fine.
fine. But
But often
often either
either you
you won't
won't know
know or
or you
you won't
won't want
want to
to bother
bother to
to
count.
count.
Sometimes
Sometimes the
the best
bes t way
way to
to avoid
avoid an
an OUT
OUT OF
OF DATA
DATA ERROR
ERROR is
is to
to end
end your
you r
DATA statement
DATA statement with
with aa FLAG.
FLAG. AA flag
flag is
is some
some value
value that
that would
wou ld not
not ordinarily ap-
ordinaril y ap
pear in
pear in your
your DATA
DATA list,
list, such
such as
as aa negative
negalive number,
number, aa very
very large
large number,
number, aa very
very
small
small number,
number, or
or aa special
special word,
word, such
such as
as END
END or
or STOP.
STO P. When
When you
you use
use aa flag,
flag ,
add
add an
an IF/THEN
IFITHEN statement
statement to
to tell
tell the
the computer
computer to
to branch
branch to
to another
another part
part of
of the
the
program when
program when the
the flag
flag is
is read.
read. For
For example:
example:
10 READ A
10 READ A
15
15 IF
IF A
A < < OTHEN
0 THEN END
END
20 DATA
20 DATA 13,35,29,
13, 35, 29, -999
-999
25 PRINT
25 PRINT "TOTAL
" TOTAL = ";
"; A
A
30 GOTO
30 GOTO 10
10
This
This program
program READsand
READs and PRINTS
PRINTs aa value
value for A
A until
until it reaches -999.
- 999. Line
line 15
15
tells
tells the computer
computer to
to END
END the
the program
program immediately
immediately when
when aa negative
negative value
value is
read.
There
There is also
also aa way to
to reuse
reuse the items in
in aa DATA
DATA statement by RESTOREing
the
the data pointer
pOinter to
to the
the beginning of the
the DATA
DATA list. Try adding this line:
45 RESTORE
45
to the second program in
in this chapter and RUN it again. You
You'll
'll see that the data
pointer has been RESTOREd
pOinter RESTOREd to the first item in
in the DATA list,
list, and that you
yo u can
all the items.
reREAD all

CALCULATING AVERAGES
Here's a program that READs a set of numbers from a DATA list and
calculates their average. This program also uses a flag to tell the computer
when to stop READi
READingng DATA.

NEW

5 T=O
T = 0 :CT=O
: CT = 0
10 READ
READX X
20 IF X = -- 11 THEN 50: REM CHECK FOR FLAG
25CT=CT
25 CT = CT +1 + 1
30 T = T + X:X : REM UPDATE TOTAL
40 GOTO 10 ^
PRINT ""THERE
50 PRINT THERE WWERE
ERE "; CT;"VALUES READ"
60 PRINT " TOTAL
PRINT "TOTAL = ";T
PRINT "AVERAGE = "";; T/CT
70 PRINT " AVERAG E
80 DATA
DATA 75, 80, 62, 91
91,, 87,
37, 93, 78, -1
- 1

RUN
RUN
TH ERE WERE 7 VALU
THERE ES READ
VALUES
TOTAL = 566
AV ERAGE = 80.8571429
AVERAGE

93
93

Downloaded from www.Manualslib.com manuals search engine


Line 5 sets CT,
line CT. the CounTer, and T, the Total
Total,, to zero.
Line 10 READs a value from the DATA list and assigns it to X.
line
Line 20 checks to see if the va
line value (- 1). If it is, then the
lue read to X is our flag (-1).
skips
program ski ps lines 25-40 and goes straight to line 50. 50.
Line 25 adds one to CT, the counter,
line counter, if the value of X is not the flag.
Line 30 adds X to T, the running total.
line
Line 40 sends the program back to repeat line 10.
line 10.
Line 50,
line 50. which isn'
isn'tt executed until liline
ne 10 READs the flag flag,, PRINTs
PRINTS the
number of values read (CT).(CT).
Line 60 PRINTs
line PRINTS the total of the numbers read (T). (T).
Line 70 PRINTs
line PRINTS the average.
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
READs s a name and
calculates
some scores and then calcula the
tes th scores.
e average of the scores.

NEW

10 READ N$,A,B,C
N$;'"S
20 PRINT N$" WERE: "
" S SCORES WERE' ";A;"
A" "'";B;"
B'" "";C
'C
30 PRINT ""AND
Aim THE AVERAGE IS: ''';(A';
";(A+ B+ 8
+ C)/3
(;)13
40 PRINT: GOTO 10 10
50 DATA MIKE, 190, 185,
MIKE, 190, 185, 165,
165, DICK,
DICK, 225,
225, 245, 190
60 DATA JOHN,
JOHN, 155,155, 185,205,
185, 205, PAUL,
PAUL, 160,
160, 179, 187

RUN

MIKE'S SCORES WERE: 190 185 165


AND
AN D THE AVERAGE IS :: 180

DICK'S
DICK'S SCORES WERE: 225 245 190
190
AND
AND THE AVERAGE IS:
IS : 220
v
v

Line
line 10
10 READs aa value
val ue for
for each of the variables.
variables. The
The DATA statement lists
lists its
its
items
items in
in the same
same order that
that the
the READ
READ statement
statement expects to to find them. In
In other
other
words,
words, there's
there's aa name to
to go with
with the
the string
strin g variable,
variab le, and
and numbers
numbers toto go
go with
with the
integer
in teger variables.
variables.

v
v
v 94
94

Downloaded from www.Manualslib.com manuals search engine


SUBSCRIPTED
SUBSCRIPTED VARIABLES
VARIABLES
So
So(ar
farwe've
we'veonly onlyused
usedsimple
simpleBASIC
BASICvariables
variablessuch
suchasasXXand
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
namesthanthan all
all the
the com
com-
binations
binations of of letters
letters and
and numbers
numbers available
available inin BASIC,
BASIC, but
but you
you might
mightwantwant toto be
be
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 soso that
that they
they are
are obviously
obviously
grouped together.
grouped together, For
For example:
example:
A (0), A{1),
A(0), A (1), AA (2),
(2), AA (3)
(3)
The
Th e numbers
numbers inin parentheses
parentheses are
are the
the SUBSCRIPTS
SUBSCRIPTS of of variable
variable A.
A, Be
Be aware
aware
that
that the
the variable
variab le A1
A1 does
does NOT
NOT equal
equal the
the subscripted
subscri pted variable
variable AA (1).
(1),
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) AA (4-1)
A (X) A(X+1) (4 - 1) A(2tX)
A (2 t X)
The
The expressions
expressions within
within the
the parentheses
parentheses are
are evaluated
evaluated according
according to
to the
the same
same
rules
rules for
for arithmetic
ari thmetic operations
operations outlined
outlined in
in Chapter
Chapter 3.3,
Subscripted
Subscripted variables,
variables , like
like simple
simple variables,
variables, name
name aa memory
memory location
location within
within
the
the computer.
computer. But
But only
only subscripted
subscripted variables
variables name
name values
values that
that are
are organized
organized in
in-
to an
to an ARRAY.
ARRAY,
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
table, of related
related values.
values,
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)
PRINT CHR$(147)
10
10 INPUT "HOW
" HOW MANY
MANY NUMBERS :";X
20 FOR A
20 =
A = 11 TO
TO X
X
30 PRINT ""ENTER
ENTER VALUE
VALU E # ";
";A;:INPUT
A;: INPUT B(A)
40 NEXT
50 =
SU = a0
60
60 FOR A =
FOR A - 11 TO
TO X
X ^
70 SU = SU + B(A)
SU
80 NEXT
NEXT
90 PRINT :: PRINT "AVERAGE = "; SU/X
PRINT

RUN
RUN

HOW
HOW MANY NUMBERS :?
MANY NUMBERS :? 5
5
ENTER
ENTER VALUE
VALUE# # 11 ??125
125
ENTER
ENTER VALUE
VALUE # 2 ?? 167
#2 167
ENTER
ENTER VA LUE ##3
VALUE 3 ?? 189
189
ENTER
ENTER VA LUE ##4
VALUE 4 ?? 167
167
ENTER
ENTER VALUE
VALUE ##55 ?? 158
158

AVERAGE == 161
AVERAGE ,2
161.2

95
95

Downloaded from www.Manualslib.com manuals search engine


Line
Li ne 55 clears
clears the screen.
Line
Li ne 10
10 asks you to enter the total INPUT
to tal number of items you'll IN PUT at liline 30.
ne 30.
Line
Li ne 20
20 sets up
up aa loop that makes A the subscript for the array
array B. The loop
loop
adds
adds 11 to A
A for every execution. This updates array B. B.
Line
Li ne 30
30 prompts you to INPUT a value for the subscripted variable B (A).
v Lines
Li nes 50 through 80 keep a running total (SU) of the numbers INPUT.
INPUT.
Line
Li ne 90
90 PRINTs
PRI NTs the average.
average.
v Each
Each time
time the INPUT loop executes, 1, so th
executes, A is increased by 1, thee next value
entered
entered is
is assigned to
to the next element in array B. At the end of the prog
program, ar
ram, ar-
v
ray
ray B
B looks like this:
this:

B
B (D
(1) 125
125
v
B (2)
B (2) 167
167
v B (3)
B (3) 189
189
B
B (4)
(4) 167
167
B
B (5) 158

After
After you INPUT
INPUT all
all the values,
values, they are stored in
in array B.
B. You can
can now
now ac-
ac
cess
cess these
these values
va lues just
just by using the subsc
subscripted variables.
ripted variab les. For example, see
v
what
what happens
happens when you add these lines:
v
100
100 PRINT B(X-1)
PRINT B (X - 1)
v 120 PRINT B
120 PRINT (3)
B(3)
130
130 PRINT B(X-3)
PRI NT B (X - 3)

DIMENSIONING ARRAYS
If
If you try
try to enter more than ten numbers in an array, you'll get
get a DI
DIMENSION
MENSION
v ERROR. Arrays of moremore then ten elements need to be predefined in a DI DIMEN
M EN-
SION
SION statement. For example,
example, if you
yo u want an array to hold 25 values, you'd wr
write
ite
v this
th is statement
statement in your program:
prog ram:
DIM BB (25)
DIM (25)
You
You can
can also
also use
use aa variable in a
variable in DIMension statement.
a DIMension statement. For
For example,
example, in
in the
the
last program
last program you could
co uld have used this statement since X equaled the total
v number of
number of values
values in
in array B:
v 15 DIM
15 DIM B
B (X)
(X)
But be
But be careful
care fu l when
whe n you
you use
use variables
vari ables to
to define
define arrays:
arrays: once
once an
an array
array is
is
DIMensioned, it can't
DIMensioned, can 't be reDIMensioned
re DI Mensioned in
in ano ther part of the program. So
another
v don't use
don't use aa variable
variable whose
whose value
value will
will change in the program.
You can
You can use
use more
more than
than one
one array in a program
program,, and you can DIMension the
themm
all on
all on the
the same
same line:
line:
v 10 DIM
10 DI M A
A (12),
(12), B
B (35),
(35), C
C (3,5)
(3,5)
v Arrays A
Arrays A and
and B
B are
are one-dimensional
one-d imensional arrays,
arrays, but
but C
C is
is a
a two·d imens ional array.
two-dimensional array.
One-dimensional arrays
One-dimensional arrays just
just have
have ROWS
ROWS of
of data,
data, but
but two-dimens ional arrays
two-dimensional arrays
v have both
have both rows
rows and
and columns
columns of
of data,
data, just
just like
like a
a chart.
chart. Array
Array C
C has
has 33 rows
rows and
and 5
5
v columns . Rows are always listed first in a DIMension statemen
columns. Rows are always listed first in a DIMension statement. t.

v
v 96
96

Downloaded from www.Manualslib.com manuals search engine


SIMULATED DICE ROLL WITH ARRAYS
complex
As you begin writing more comp you'll
lex programs, you 'll find that subscripted
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 SIMULATION : PRINT CHR$(147)
REM DICE SIMULATION:
10 INPUT ""HOW
HOW MANY ROLLS:";X
20 FOR L = 1 1 TO X
30 R = INT(6
R INT(6'RND(1))+1
" RN D(1))+ 1
40 F(R) = F(R) + 1 1
50 NEXT L
60 PRINT ""FACE",
FACE" , ""NUMBER
NUMBER OF TIMTIMES"
ES"
70 FOR C = 1 1 TO 6 :: PRINT C, F(C): NEXT
m

Line 10 asks you how many times yo u'll throw the dice iin the simulated roll.
you'll
Line 20 sets up a loop to count the number of dice rolls so that the program
ends on the Xth roll.
Line 30 makes R R equal to the random number rolled.
Line 40 sets up the array F,
F, for FAC
FACE,
E, which keeps track of how many times
each face turns up. Whatever value R R acquires in in the dice roll becomes the
array, and line 40 adds one to the appropriate array vari
subscript for the array, variable.
able.
For example,
example, even/
every time a 22 is thrown,
thrown , FF (2) is increased by one.
Line 70 PRINTs
PRINTs the number of times each face shows up. up. Here's a sample
RUN:

HOW MANY ROLLS: ?


? 1000
1000
FACE
FACE NUMBER OF TIMES
TI MES
11 148
148
2 176
3 178
A4 166
166
5
5 163
163
66 169

97

Downloaded from www.Manualslib.com manuals search engine


would
Now we'll show you how much longer your program wou ld be if you didn't
use an array:
10 INPUT ""HOW ROLLS:";X
HOW MANY ROLLS:"; X
v 20 FOR L = 11 TO X
30 INT(6*RND(1))+1
R = INT(6 'RND(1))+ 1
v 40 IF R =
= 1 1 THEN F1 = F1 + 1 : NEXT
41 IF R =
R = 2 THEN F2 =
F2 + 1 : NEXT
42 R =
IF R = 3 THEN F3 = F3 + 1 : NEXT
43 R = 4
IF R 4 THEN F4 = F4 + 1 : NEXT
44 IF R =
= 5 THEN F5 = F5 + 1 : NEXT
45 R =
IF R = 6 TH EN F6 = F6 + 1 : NEXT
THEN
60 FACE",, ""NUMBER
PRINT " FACE" NUMB ER OF TIMES"
70 1, Fl
PRINT 1, F1
71 2, F2
PRINT 2,
72 PRINT 3, F3
73 PRINT
PR 4, F4
INT 4,
74 5, F5
PRINT 5,
v 75 PRINT 6, F6
v As yo
youu can see, the program has twice pro
twi ce as many lines. The longer the pro·
gram,
gram , the more space and time you can save when you use arrays.
arrays.
v

v
v

98
98

Downloaded from www.Manualslib.com manuals search engine


TWO-DIMENSIONAL
TWO·DIMENSIONAL ARRAYS
ARRAYS
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:
For example: -

AA (4.6) has 44 ROWS


(4 ,6) has ROWS
and 66 COLUMNS
and COLUMN S
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: 0.

0o 1 22 33 44 55 66

You'll
You' ll notice
notice that there's
there 's aa zeroth
zeroth row and
and column,
column, so
so when you
you DiMension
DIMens ion A A n
(4,6), you're
(4,6), yo u're creating an array with 5
5 rows and 7 columns,
7 colum ns, or 35 elements.
elements. n
You
You can
can access
access any element of
any element of a
a two-dimensional
two-di mensional array
array by
by using
using its row and
its row and
column subscri
column subscripts. For exampl
pts. For example, suppose you
e, suppose you want to assign
want to 255 to
assign 255 to A (3,4):
A (3 ,4): n
10 LET A(3.4)
10 A(3,4) = 255
Here's what th
thee grid looks like now:

o0 122 33 44 55 66

o0
1

22

33 255
255

44

Two-dimensional
Two-d arrays follow
imensional arrays follow the
the same
same rul
rules as one·dimensional
es as one-dimensional arrays:
arrays:
DIM ensioning:
DIMensioning: DIM A
DIM A (20,20)
(20.20)
Assigning
Assigning data
data values:
values: A(1.1)
A(1, =
1) = 255255
Assigning
Assigning val ues to
values to
other
other val ues:
values: AB == A(1,1)
AS A(1,1)
PRINTi ng val
PRINTing ues:
values: PRINT
PRINT A(1,1)
A(1.1)

m
99
99

Downloaded from www.Manualslib.com manuals search engine


Here's an
Here's an example
example of
of how
how two-dimensional arrays
arrays can
can be
be used.
used. This example
example
keeps track
keeps track of
of responses
responses to
to a
a club
club questionnaire like
like this:
this:

CLUB QUESTIONNAIRE
CLUB
ARE YOU IN
Q1: ARE IN FAVOR
FAVOR OF RESO
RESOLUTION
LUTION #1?
11 -— YES 2 -— NO
NO 3 -— UNDECI
UNDECIDED
DE D
...., Let's
Let 's suppose there are four questions, so the array, which we'll call A, will be
DIMensioned A(4,3). Here's
DIMensioned Here's how
how the array table looks:
looks:
v
YES NO
NO UNDECIDED
UNDECIDED

QUESTION
QU ESTI ON 11

QUESTION
QU ESTI ON 2

QUESTION
QU ESTI ON 3

QUESTION 4

pro
The program that keeps track of the responses is on the next page. This pro·
gram uses many of the programming techniques that have been presented so
far.
far.
PRINT
Lines 30-65 PRI NT the questions in numerical order and ask you to INPUT the
response.
Line 70 adds one to the appropriate array element. Remember that R R is the
number, and the questions are in rows. C
question number, C is the response number,
number, and
the responses are in columns.
Line 90 asks if you have another set of responses to IN INPUT.
PUT.
Lines 110 and 120 tell the program where to go, go, depending on your response
to line 90.
Lines 130-170
130-1 70 PRINT thethe total
total number
nu mber of each
each response.
Each time you you INPUT aa response at at line
li ne 61,
61 , liline
ne 70 updates the right
rig ht element
of the
the array. Recall the R R is the question
question number and C C is
is the response number,
number,
v so if your response to to question
question 22 is 33 (undecided),
(undecided), line 70 adds one to to array ele
ele-
ment A{2,3).
A(2,3)_
You'll
You 'll notice
noti ce that we
we didn't use
use the
the zeroth
zeroth row and columncolum n inin this
th is example.
example.
You
You don't
don't have to to use
use this row
row and column,
colum n, butbut remember
remember that
that they
they are
are always
always
present
present in in even/
every array
array you
you use.
use.

v
100
100
Downloaded from www.Manualslib.com manuals search engine
SHIFT

20
20 PRINT"" (CLRI
PRINT <CLR/HOME>
HOME> ""
30 FOR
FO RRR = 1 1 TO 4 4 ~
40 PRINT
PRIN T "QUESTION # :: "; R R
50 1-YES 2·NO
PRINT " 1·YES 2-NO 3·UNDECI
3-UNDECIDED" DED"
60 PRINT ""WHAT
WHAT WAS THE RESPNSE :: ";
61
61 GET C:
GET C: IF
IF CC (1<1 oror C>
C> 3 3 THEN
THEN 61 61
65 PRINT C: PRINT
70 A(R,C) = A(R,C) +: + : REM UPDATE ELEMENT
80 NEXT R R
85 PRINT
90 PRINT ""DO
DO YOU WAN WANT T TO ENTER ANOTHER"; ANOTHER": PRINT
""RESPONSE
RESPONSE (Y (Y/N)";
I N)";
100 GET A$ :: IF A$ = " " THEN 100
A$ = "Y" THEN 20
110 IF AS
120IFAS
120 IF A$ (><> ""N" THEN 100
N" THEN 100
130 PRINT
130 <
PRINT "" <CLR/HOME
CLRI HOME > > ";"THE
";"THE TOTAL TOTAL RESPONSES
RESPONSES
WERE:":PRINT
W ERE:": PRINT
SPC(18);"RESPONSE"
140 PRINT SPC(18);" RESPONSE" ~
"QUESTION","YES'VNO","UNDECIDED"
141 PRINT "QU ESTlON","YES" ,"NO"," UNDECIDED"
142 PRINT
142 PRINT .....................................
" .""
150 FOR R R = 1 1 TO 4 4
160 PRINT R, R, A(R,1),
A( R,1), A(R,2), A(R,3)
A(R,3)
170 NEXT R R
RUN

QUESTION # :: 1
1
1-YES 2-NO 3-UNDECIDED
1·YES 2·NO 3·UNDECIDED
WHAT WAS TH THE E RESPONSE :: 1
1

QU ESTION # : 2
QUESTION#:2 ^
1-YES 2·NO
1·YES 2-NO 3·U
3-UNDECIDED
NDECIDED
WHAT WAS THE RE RESPONSE
SPONSE :: 1
1

And so on.
on ...

TOTAL
THE TOTA WERE:
L RESPONSES W ERE:
RESPONSE
QUESTION YES NO UNDECIDED
UN DECIDED
11 6 1
1 0
2 5
5 2 0
0
3 7
7 0 0
A
4 2
2 4
4 1
1

101
1(11

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
-

APPENDICES
APPENDICES
INTRODUCTION
INTRODUCTION

Now
Now that
that you've
you 've gotten
gotten toto know
know your
you r 64,64, we
we want
want youyou to to know
know thatthat ourour
customer
customer support
support does
does not
not stop
stop here.
here. You
You may
may not
not know
know itTit, but
but Commodore
Commodore
has
has been
been inin business
business for
for over
over2323years.
years. InInthe
the1970's
1970'swe
we introduced
introduced the thefirst
fi rst self-
sel f·
contained
contained personal
personal computer
compu ter (the
(the PET).
PET). We We have
have since
si nce become
become the the leading
leading
computer
computer company
company in in many
many countries
countri es ofof the
the world.
world. Our
Our ability
ability toto design
design and and
manufacture
man ufac tu re our
our own
own computer
computerchips
chips lets
lets ususbring
bring you
you new
new and
and better
bett er personal
personal
computers
computers at at prices
pri ces way
way below
be low what
what you'd
you'd expect
expect for
for this
this level
level of
of technical
tec hnical
excellence.
excellence.
Commodore
Commodore isis committed
committed to to supporting
supporting you.
you, the
the end
end user.
user. We
We also
also assist
assist
you
you by by supporting
supporting the the dealer
dealer whowho sold
sold you
you your
your computer,
computer, magazines
magazines that that
publish
publish how-to
how·to articles
articles showing
showing you you new
new applications
applica tions oror techniques,
techn iques, andand soft
salt·
ware
ware developers
developers who who produce
produce programs
programs on on cartridge
cartridge and
and disk
disk for
for use
use with
with your
your
computer.
co mputer. We We encourage
encourage you you toto establish
establish or
or join
join aa Commodore
Commodore "user "user club"
club"
where
where you you can
can learn
learn new
new techniques,
techniques, exchange
exchange ideas
ideas and
and share
share discoveries.
discoveri es.
We
We publish
publi sh two
two separate
separate magazines
magazi nes which
which contain
contain programming
program mi ng tips,
tips , informa
informa·
tion
tion onon new
new products
products andand ideas
ideas for computer
computer applications.
applications. (See
(See Appendix
Appendix N). N).
In
In North
North America.
America, Commodore
Commodore provides
provides aa -Commodore
" Commodore Information Net- Net· ^
work"
work" on on the
the CompuServe
CompuServe Information
Information Service.
Service. ToTo use
use this
this network,
network, all all you
need
need is is your
your 64
64 computer
computer andand our
our low
low cost
cost VICMODEM
VICMODEM telephone
telephone interface cart cart·
ridge (or oth er compatible
ridge (or other compatible modem).
The following
following APPENDICES
APPENDICES containcontain charts,
charts, tables, and other
other information
information
which
which help you you program your you r Executive 64 faster
faste r and more
more efficiently.
efiiciently. They
also include important information on the wide variety of Commodore CommOdore products
you may be interested in, in. and a bibliography listing of over 20 books and
magazines which can help you develop your programming skills and keep you
current on the latest information concerning your computer and peri peripherals.
pherals.

102
102

Downloaded from www.Manualslib.com manuals search engine


APPENDIX A
AVAILABLE SOFTWARE

PROGRAMMING AIDS & COMPUTER LANGUAGES


C64 101 -— ASSEMBLER 64
experienced
Designed for experien programmers.
ced Assembly language prog in
rammers. Package in-
everything
cludes everythi ng needed to create, assemble,
assemble, load and execute 6500 series
Assemb ly language code. Macro assembler ·• Two machine language monitors
Assembly
• Editor and loaders ·• Support routines ·• User manual.

C64 103 -— DISK BONUS PACK


experienced
The Commodore 64 DISK BONUS PACK introduces the experi in
enced and in-
personal comput
experienced user to our exciting personal computer.
er. You will
will find: entertain-
entertain
assist
ment games, utilities to ass ist in your programming, music and video programs
abilities
to demonstrate the abilit 64, and several educational and personal
ies of the 64, personal pro-
pro
grams.

C64 104 —- SUPER EXPANDER (VSP)


The SUPER EXPANDER 64 is a powerful extension of the BASIC language.
Previously, you had to Peek or Poke speci
Previously, specific
fic memory registers in order to ac
ac-
cess many of the computer's feat
features.
ures. This package provides the commands
you need to use Commodore's
Commodore's graphics, music, and sound capabilities.
graphics, mUSiC,

C64 105
105 -— LOGO
LOGO is an educati
educational
onal language for students.
students. Because LOGO is so ve verr-
satile, it is simple enoug
satile, enoughh for pre-schoolers and sophisticated enough to
challenge college graduates.
graduates. A A small triangular cursor,
cursor, called a Turtle,
Turtle, is used
to draw the graphics.
LOGO includes the following
foll owing features: four different types of screens;
cataloging commands; a a TRACE command
com mand for programming
programming and debugging;
debugging;
LIST
LI ST processing; and
and the ability
abi lity to
10 read music,
mUSiC, graphics,
graphics, and text files
fi les previous
previous-
ly created
c reated with LOGO.
LOGO.

C64 106
106 —
- PILOT
PILOT for the 64 is the most
mos t powerful
powerfu l version
version of PILOT
PILOT available. With
With this
program,
prog ram, you
yo u can
ca n define
define your
yo ur own
own characters,
characters, create
create colorful,
colorful, movable
movable objects
called
called sprites,
sprites, and
and create
create music and and aa variety of
of sound effects. This is a
superior
superior instructional
instructional tool
tool .. .... educators
educators can write their
their own
own software which
which
combines fun.
fu n, entertainment,
entertainment, and and learning.
learn ing. Programs written
writt en on
on COMMON
PILOT
PILOT can
can also
also be
be run
run without any conversions. Also, Also, aa RUN-ONLY
RUN -ONLY VERSION
VERSION of
the
the program
program is is included.
included.

C64 107
107 —
- PET
PET EMULATOR
Converts
Convert s most
most software
so ftware designed
designed for
for Commodore
Commodore PET computers to
to soft
soft-
ware
wa re for
for your
yo ur 64.
64. A
A valuable
valua ble teaching
teaching tool
tool utilizing
utilizing your
your 64
64 and
and PET
PET educational
educational
software.
soft wa re.

103
103

Downloaded from www.Manualslib.com manuals search engine


C64 109
C64 109 —
- SCREEN
SCREEN EDITOR
EDITOR
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
your
your64 64 by
by letting
lettingyou
you create
create and
andedit
edityour
yourown
ownscreens.
screens.This
This programming
programming tool tool
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
Data field
field definition
definition and
and editing;
editing; Cursor
Cursor movement
movement from from field
field to
to field,
fi eld, both
both
backwards
backwards and
and forwards;
forward s; Quick
Quick screen
screen design
design capabilities.
capabi li lies.

C64
C64 110
110 —
- CP/M'
CP/M 2.2
2.2 OPERATING
OPERATING SYSTEM
SYSTEM
The
The CP/M'
CP/M ~ 2.2
2.2 Operating
Operating System
System turns
turns your
your 64
64 into
into aa dual
dual processor
processor home
home
computer.
comp uter. This
This system
system lets
lets you
you expand
expand the
the software
software applications
applications you
yo u can
can use
use
with
with your
your 64.
64. When
When you
you add
add this
this easy-to-install
easy-to-install system,
system, you
you can
can begin
begin using
using
some
some ofof the
the many
many available
available CPIW
C P/M!> programs,
programs, including
including widely
widely used
used business
business
applications,
applications, word
word processing,
processing, and
and high
high level
level computer
computer languages.
languages.
■CP/M
' CP/M isis aa registered
registered trademark
Irademal1l oi
0 1Digital
Oigital Research.
Research, Inc.
Inc

BUSINESS
BUSINESS SOFTWARE
SOFTWARE -
- FOR
FOR HOME
HOME AND
AND OFFICE
OFFICE
C64 200
C64 200 —
- EASY
EASY CALC
CALC 64
64
EasyCatc
EasyCalc 64
64 is
is an
an easy-to-use
easy-to-use electronic
electronic spread
spread sheet.
sheet. EasyCatc
EasyCalc has
has editing
editing
functions
functions and
and help
help screens,
screens, and
and itit lets
lets you
you print
print bar
bar charts
charts and
and individually
individually for
for-
matted
matted tables.
tables. EasyCalc
EasyCalc also
also lets
lets youyou view
view up
up to
to four
fou r pages
pages at
at once
once onon the
the
screen.
screen.

- EASY FINANCE II
C64 202 —
Shows you
you how to make the most out of your hard-earned money by
(or you. Principal,
calculating 12 loan concepts for payment, last payment
Principal, regular payment, payment,,
and remaining balance are just some of the functions EASY FINANCE can
programming
determine. You need absolutely no programmi knowledge
ng know ledge to use this
product.

C64 204 -— EASY MAIL 64


Now your
Now 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
EasyMail has
addresses, simplify label printing. EasyMaii has all the features you need to
prepare special mailings
prepare mailings by
by searching your address fifiles
les for specific categories
Especially useful
such as zip code. Especially useful for cl
clubs businesses. Here
ubs and small businesses. Here are
some of EasyMail's features: Entry, change, or deletion of name and address
some of EasyMail's features : Entry, change, or deletion of name and address by by
name or
name or number;
number; One
One oror two
two abreast
abreast address
address labels;
labels; A
A com
complete printout of
plete printout of all
all
the data
the data in
in your
your rec
records; A HELP
ords ; A HELP function
function that
that you
you can
can reques
requestt at
at any
any time.
time.

C64
C64 207
207 -— EASY
EASY SCRfPT
SCRIPT
Powerful word
Powerful word processor
processor with
with table
table producing
producing capabilities;
capabilities: comprehensive
comprehensive
printer controls: easy up-date facilities; easy document handling
printer controls; easy up-date facilities; easy document handling and and much,
much.
much
much more.
more.

C64
C64 208
208 -- EASY
EASY SPELL
SPELL 6464
Now you
Now you can
can prod
produce flawless wri
uce flawless writing! EasySpell 64 offers
ting ! EasySpel164 offers all
all these
these features:
features:
Automatically corrects
Automatically corrects spelling
spelling errors;
errors; Counts
Counts the the words
words in in your
your manuscript;
manuscript:
Has aa built-in
Has built-in 20,000
20,000 word
word lexicon
lexicon that
that lets
lets you
you add
add words
words notnot already
already stored
stored
there; Is
there; Is designed
designed to to be
be used
used with
with EasyScript
EasyScript 64, 64, anan easy-to-use
easy-to-use word-word-
processor. Because
processor. Because youyou can
can add
add toto the
the lexicon,
lexicon. EasySpel1
EasySpell can can easily
easily bebe
adapted for
adapted for writing
writing reports
reports in
in specialized
specialized fields
fields such
such asas medicine,
medicine, law,law, and
and
science. All
science. All you
you do
do isis add
add the
the words
words you
you use
use to
to the
the lexicon!
lexicon!

104
104

Downloaded from www.Manualslib.com manuals search engine


v
C64 210 -— WORD/NAME MACHINE
easy-to-leam and easy·
Commodore's most easy·to·learn easy-to-use
to·use wordprocessing package.
Designed for beginners and perfect for letters, address lists, and notes. Some
programs, Word Machine and
of the features available in these companion programs,
Easy-to-understand menus that let you choose what you want
Name Machine: Easy·to·understand
do; Overtyping
to do; Overtyping,, inserting,
inserting, and deleting of text; Three print formats: Draft
Draft,, In·
In
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
easy-to-use
address file; Prints an easy· to·use telephone and name and address book;
Prints name and address labels.

C64 212 -— EASY FINANCE II


Helps you make the right financial decisions by showing you how to make
mosi out of sixteen investment concepts. The program ca
the most calculates
lculates such
v internal rate of
functions as future investment value, initial investment, and internal
FINANCE
return. EASY FINANC E II is very clear and easy to use;
use; you need absolutely no
programming knowledge to use this product.

C64 213 -— EASY FINANCE III


Is an advanced ve
version
rsi on of EASY FINANCE II; it shows you how to make the
concepts.. Financial terms and practices
most out of sixteen more investment concepts
are clarified and functions such as discount commerc
commercial paper, financial
ial paper,
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
right decisions about production, inventory, control
control,, compensation,
compensation , and much
more. Lease purchase analysis, depreciation switch, and optimal order quantity
are some of the
the 21
2t functions this
this program will calculate
calcu late for you.

C64 215 —
- EASY FINANCE V
V
yo u how to make the most out of statistics such as
Shows you as payoff matrix
analysis,
analYSiS, regression analysis forecast
forecasting,
ing, and apportionment by ratios.
rati os. It is
is
completely pre-programmed
pre ·programmed and very easy to use. With
With just
iust aa few simple
si mple
v
keystrokes, you
you can
can improve your finances!
finances!

C64
C64 216
216 —
- THE
TH E MANAGER
MANAG ER
General
General data
data base to
to handle
handle user created
created files.
files. Interfaces
Interfaces with
with Wordprocess
Word process·
ing,
ing, accumulates
accumulates totals
totals on
on screen
screen and creates
creates subfiles.
subfiles. Sorts
Sorts from
from any
any field.
field.
Powerful
Powerful report
report printing
printing capabilities.
capabili tie s.

C64
C64 220
220 —
- GENERAL LEDGER
LEDGER
Customized
Customized Chart-of-Accounts.
Chart·of·Accou nts. Convenient
Convenient entry
entry of
of cash
cash receipts:
receipts;
disbursements;
disbu rsemen ts ; general
general journal
journal transactions.
transactions. Interfaces with other
other accounting
accounting
modules
modules for
for automated
automated posting
posting of
of G/L
GIL transactions.
transactions . Maintains
Maintains account
account
balances monthly,
balances monthly, quarterly,
quarterly, yearly,
yearly, previous
previ ous quarters
quarters and
and years.
years. Departmental
Departmental
reporting
reportin g and
and many
many other
other features.
features.
v

v
105
105

Downloaded from www.Manualslib.com manuals search engine


C64221
C64 221 —
- RECEIVABLE/BILLING
RECEIVABLE/BILLING
Maintains
Maintainscustomer
customermaster
masterfile.
file. Automatic
Automatic billing
billingwith
withcredit
creditchecking,
checking ,item
item
descriptions,
descriptions, unitunit pricing,
pricing, and
and extensions
extensions when
when interfaced
interfaced with
with Order
Order
Entry/Point-of-Sale
Entry/Point-o f-Saleandand Inventory
Inventory Management
Management Modules.
Modules. Flexible
Flexi blebilling
billingofofany
any
item
itemand
and unit
unit price
pricewhen
when used
usedasasstand-alone
stand-alonesystem.
system.Automatically
Automatically posts
postsbill
bill·
ings.
ings. Interfaces
Interfaces with
with the
the general
general ledger
ledgerforforautomated
automated postings.
postings.Automatically
Automatically
ages
ages open
open receivables
recei vables byby 30.
30,60,
60, 9090 day
day categories.
categories.

C64
C64 222
222 —
- ACCOUNTS
ACCOUNTS PAYABLE/CHECKWRITING
PAYABLE/CHECK WRITING
Maintains
Maintainsvendor
vendor master
masterfile.
fi le. Automatic
Automatic aging
agingof
of open
open invoices.
invoices. Automatical
Automatical·
lyIy combines
combines invoices
invoices by
by vendor
vendor and and prints
prints checks
checks with
with full
full remittance
remittance detail.
detail.
Provides
Provides open
open item
item aging
aging report
report by by30,60,90
30, 60, 90day
daycategories.
categories. Interfaces
Interfaces with
with the
the
general ledger
general ledger for
for automated
automated postings.
postings.

C64 223
C64 223 —
- PAYROLL
PAYROLL
Master
Master record
record ofof each
each employee
employee pay
pay activity.
activity. Automatically
Automatically calculates
calculates period
period
pay
pay amount
amount including
including all
all tax
tax and
and miscellaneous
miscellaneous deductions.
deductions. Prints
Prints payroll
payroll
checks
checks with
with full
full pay
pay deduction
deduction detail.
detail. Comprehensive
Comprehensive management
management reporting
reporting
including
including W2's
W2 's and
and 941's.
941 's. General
General ledger
ledger interface
interface for
for automated
automated postings.
postings.

C64 224
C64 224 —
- INVENTORY
INVENTORY MANAGEMENT
MANAGEMENT
Perpetual
Perpetual inventory
inventory records
records for
for all
all stock
stock items.
items. Processes
Processes stock
stock receipts,
receipts,
stock
stock issues,
issues, stock
stock orders,
orders , and
and stock
stock adjustments
adjustmen ts with
with full
full audit
audit trail.
trail. Optional
Optional
interface
interface to
to Order
Order Entry/Point-of-Sale
Entry/Point-of-Sale for
for automated
automated billing
billing of
of inventory
inventory items
items
and
and automated
automated stock-on-hand
stock-on -hand reduction.
reduct ion. Capability
Capability to
to selectively
selectively calculate
calculate re
re-
order level
order level and economic order
and economic order quantity
quantity by inventory category. Assists
inventory category. manage
Ass ists manage·
reports.
ment in parts ordering by generating shortage and re-order reports.

GAMES & RECREATION

C64 601 -—JUPITER


C64601 LANDER
JUPITER LANDER Keyboard
Joystick or Keyboard
You must carefully land your spacecraft on the
You must carefully land your spacecraft on the only only solid landing site on
landing site on
long as
Jupiter. As long 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 602
C64 602 -— KIC
KICKMAN
KMAN Joystick or
Joystick or Keyboard
Keyboard
. InIn KICKMAN
KICKMAN,, you you maneuver
maneuver aa clever
clever unicyclist
unicyclist who
who scores
scores paints
points by
by catch-
catch
ing balloons, ghosts, and PAC-MAN. KICKMAN uses his head and his feet to
Ing balloons, ghosts, and PAC-MAN. KICKMAN uses his head and his feet to
catch the
catch the falling
falling objects.
objects. During
During some
some phases
phases ofof the
the game,
game, KICKMAN
KICKMAN bursts
bursts
the
the balloons
balloons toto score
score pOints.
points.

C64
C64 603
603 -— SEAWOLF
SEAWOLF Paddles
Paddles
As the
As the commander
commander ofof aa torpedo
torpedo boat,
boat, you
you must
must sink
sink all
all enemy
enemy ships.
ships. Your
Your
targets are fast-moving P.T. boats, cruisers, and freighters. You can play
targets are fast·moving P.T. boats, cruisers, and freighters. You can play
SEAWOLF
SEAWOLF with
with one
one or
or two
two players.
players.

C64
C64604
604-— SPEED/BINGO
SPEED/BINGOMATH MATH Joystickor
Joystick orKeyboard
Keyboard
These two
These two math
math games
games help
help you
you bubuild math skills
ild math skills and
and have
have fun
fun at
at the
the same
same
time.
time. SPEED
SPEED MATH
MATH gives
gives you
you aa time
time limit
limit toto solve
solve aavariety
varietyof
of math
math problems.
problems.
BINGO MATH
BINGO MATH asks
asks you
you to
to solve
solve math
math problems
problems and and use
use the
the answer
answer to to play
play
BINGO.
BINGO. You
You can
can play
play against
against the
the clock
clock or or against
against your
your friends.
friends.

106
106

Downloaded from www.Manualslib.com manuals search engine


C64605
C64 605 - - RADAR
RADARRAT RATRACE
RACE Joystickor
Joystick orKeyboard
Keyboard
InIn RADAR
RADAR RAT RAT RACE,
RACE, youyou are
are aa mouse
mouse trying
trying to
to score
score points
points by
by eating
eating ten
ten
pieces of
pieces of cheese
cheese randomly
randomly placed
placed inin aa maze.
maze. While
While you
you search
search for
forthe
the cheese,
cheese,
you're
you pursued by
're pursued by rats
rats, and you
, and you must
must avoid
avoid deadly
deadly black
black cats.
cats. You
You have
have three
three
lives and
lives and limited
limited time
time toto score
score pOints.
points.

C64 606
C64 606 -— CLOWNS
CLOWNS Paddles
Paddles
Score paints
Score points in
in CLOWNS
CLOWNS by by popping
popping aa skyfu
skyfull of
of colored
colored balloons.
balloons. You
You have
have
two CLOWNS,
two CLOWNS, one one onon aa seesaw,
seesaw, and
and one
one sailing
sailing through
through the
the air
air bursting
bursting
v balloons.
bal When the
loons. When the clown
clown comes
comes down,
down, you
you must
must catch
catch him
him with
with the
the seesaw
seesaw
and send
and send the
the other
other clown
clown up
up to
to pop
pop balloons.
balloons.

C64 609
C64 609 -- VISIBLE
VISIBLE SOLAR
SOLAR SYSTEM
SYSTEM Keyboard
Keyboa rd
You are
You are the
the commander
commander of of aa spaceship
spaceship on on aa journey
journey through
through our
our Solar
Solar
System. The
System. The ship
ship has
has aa cru
cruising range of
ising range of over
over 11 billion
billion miles
miles and
and is
is packed
packed with
with
computerized equipment
computerized equipment to to help
help you
you discover
discover more
more about
about the
the planets
planets that
that you
you
visit.
visit.

C64 610
C64 610 -- TOOTH
TOOTH INVADERS
INVADERS Joystick
Joyslick
In this game for
In for children,
children, the
the evil
evil O.K.
D.K. spreads plaque
plaque on your teeth. You
You
must floss
must floss and
and clean
clean the
the teeth
teeth before
before they
they fallout.
fall out. As
As each
each tooth
tooth is
is ccleaned,
leaned , itit
glows and changes color. You can kill kill O.K.
D.K. by
by running
running over him,
him, but
but he always
comes back!
comes back! When
When you
you succeed
succeed in
in cleaning
cleaning all
all the
the teeth,
teeth, a
a shower
shower of
of fluoride
fluoride
rains down
rains down from
from a
a cloud.
cloud.

C64 613
C64 613-LAZARIAN
- LAZAR IAN Joystick
Joystick
You are
You are the pilot
the pi of a
lot of a space
space fighter
fighter stationed
stationed in
in a
a remote
remote sector
sector of
of the
the galaxy.
galaxy
Your mission is to rescue stranded starships and to defend your sector against
aa variety
variety of
of threats.
threats. Th
There are three
ere are three phases
phases in
in the game, and
the game, and you
you get
get three ships
th ree ships
to
to complete
comp lete your
your mission.
mi ssion.

C64
C64 614
614 —- OMEGA
OMEGA RACERACE Joystick,
Joystick, Paddles,
Paddles, Keyboard
Keyboard
You
You are
are an
an Omegan
Omegan ship
ship competing
competing against
against the
the Droids,
Droids, the
the most
most powerful
powerfu l
force
force in
in the
the galaxy.
galaxy. You
You must
must destroy
destroy the
the enemy
enemy ships
ships and
and the
the photon
photon and
and
vapor
vapor mines
mines the
the Droids
Oroids have
have planted
planted in
in space.
space.

C64
C64 616-LEMANS
616 - LEMANS Paddle
Paddle
Your
Your car
car is
is at
at the
the pole
pole position
position in
in the
the LeMans
LeMans Grand
Grand Prix.
Prix . You
You must
must pass
pass as
as
many
many cars
cars as
as possible
possible to
to score
score enough
enough points
pOints to
to stay
stay in
in the
the race.
race. The
The race
race
takes
takes you
you over
over hazardous
hazardous terrain,
terrain , including
includ in g icy
icy roads,
roads , divided
divided highways,
highways, dark
dark
roads,
roads, and
and dangerous
dangerous curves.
curves. You
You must
must be
be careful
careful not
not to
to wreck
wreck your
your car
car as
as you
you
race
race to
to the
the finish
finish line.
line.

C64
C64 617
617 -
- PINBALL
PINBALL SPECTACULAR
SPECTACULAR Paddle
Paddle
PINBALL
PINBALL SPECTACULAR
SPECTACU LAR isis like
like playing
playing pinball
pinball on
on your
your 64.
64. This
This game
game offers
offers
fast
fast action
action and
and great
great sound
sound effects.
effects.

C64
C64625-ZORKI
625 - ZORK I Keyboard
Keyboard(Disk)
(Disk)
ZORK I involves the Great Underground Empire; it confronts you with perils
ZORK I invo lves the Great Underground Empire; it confronts you with perils
and
and predicaments
predicaments ranging
ranging from
from the the mystical
mystical to
to the
the macabre.
macabre. You
You strive
strive toto
discover
discover the
the Twenty
Twenty Treasures
Treasures ofof ZORK
ZORK and
and escape
escape with
with them
them and
and your
your life!
life!

107
107

Downloaded from www.Manualslib.com manuals search engine


C64
C64626
626—
- ZORK
ZOR KIIII 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
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 r\
ZORK I.I.
ZORK

C64
C64627
627 —
- ZORKZORK III
III Keyboard
Keyboard
ZORK
ZORK IIIIII involves
involves aa delightful
del ightful and
and curious
curious place
place with
with ancient
ancient high-arched
high-arched
aqueduct
aqueduct systems,
systems, swirling
swirling mists
mists of
of the
the Land
Land of
of Shadow,
Shadow, and
and aa brilliant
bri lliant pit
pit of
of
fire.
fire. You
You should
should use
use logical
logical problem-solving
problem-solving in
in this
this game;
game; ZORK
ZORK III
II I gives
gives you
you aa
theme, morals,
theme, morals, and
and meaning
meaning inin your
your adventures.
adventures.

C64
C64 628
628 —- DEADLINE
DEADLI NE Keyboard
Keyboard
You
Yo u are
are the
the chief
chief ofof detectives
delectives trying
trying to
to solve
solve thethe murder
murder of
of aa millionaire
mi ll ionaire
philanthropist.
philanthropist. You
You have
have twelve
twelve simulated
sim ulated hours
hours to
to uncover
uncover the
the truth
truth before
before thethe
wrong
wrong will
will is
is read
read to
to the
the eager
eager heirs.
hei rs. The
The mystery
mystery isis confusing,
confusing, and
and it's
it's easy
easy toto
get
get lost
lost as
as you
you try
try to
to piece
piece together
together aa convincing
convincing case
case before
before it's
it's too
too late.
late.

C64 629 —
C64629 - STARCROSS
STARCROSS Keyboard
Keyboard
STARCROSS
STARCROSS is
is another
another mind-bending
mind-bending science
science fiction
fiction adventure
adventure game.
game. You
You
are
are aa space
space prospector
prospector in
in aa one-person
one-person ship
ship searching
search ing for
for black
black holes.
holes. You
You
couldn't
cou ldn't afford
afford the best
best equipment,
equipment, so
so you must
must do
do your best
best with aa smart-
smart-
aleck computer
computer and a mass
mass detector.
detector.

C64 630 —
- SUSPENDED Keyboard
SUSPENDED
SUSPE NDED takes place on aa computer-controlled
compu ter-controlled planet that is facing
fac ing aa
catastrophe. The
catastrophe. main computer
The main computer has
has just malfunctioned; you
just malfunctioned; you take control and
take control and
guide six robots to help you manually maintain the planet while they try to
repairr the cause of the com
discover and repai computer's
pu ter's breakdown.

ART &
& MUSIC

C64 402 -— MUSIC MACHINE


The MUSIC
The MUSIC MACHI
MACHINE cartridge turns
NE cartridge turns your
your 64
64 keyboard
keyboard into
into a
a music
music syn-
syn
thesizer. Now
thesizer. Now you
you can
can fully
fully use
use the
the music-making
music-making capabilities
capabilities of
of your
your compute
computerr
even ifif you
even you can't
can't program
program itit or
or don'
don'tt kn
know how to
ow how to play
play music.
music. The
The MUSIC
MUSIC
MACHI
MACHINE NE is
is both
both fun and educational.

C64 403
C64 403 -— MUSIC
MUSIC COMPOSER
COMPOSER
You
Yo don't have
u don't have to
to be
be a musician
musician to
to make
make music
music onon your
your 64.
64. This
This package
package
teaches you
teaches you everything
everything you
you need
need to
to know
know toto play
play songs
songs and
and create
create sound
sound ef-
ef
fects on
fects on your
your computer.
computer. The
The manual
manual also
also suppl
supplies sample songs
ies sample songs for
for you
you to
to
play.
play.

EDUCATION &
EDUCATION & LEARNING
LEARNING AIDS
AIDS

C64 310
C64 310 -— EASYLESSON
EASYLESSON 64 64 and
and EASYQUIZ
EASYQUIZ 64 64
EasyLesson and
EasyLesson and EasyOuiz
EasyQuiz let
let yo
you use your
u use your 64
64 as
as aa teaching
teaching tool.
tool. With
With these
these
two programs,
two programs, you you can
can easily
easily create
create lessons
lessons andand tests
tests onon topics
topics that
that you
you
choose. Here are some of the things you can do with these
choose. H ere are some of the thi ngs yo u can do with these ed ucation pro- education pro
grams: CCreate
grams: reate aa pool
pool of
of qquestions
uestions to to use
use as
as aa lesson;
lesson: CClassify questions
lassify ques into as
ti ons into as
many as
many as seven
seven categories;
categories; Print
Print out
out each
each lesson
lesson or
or quiz
quiz you
you create;
create; Shuffle
Shuffle test
test
questions be
questions before each qquiz;
fore each Give the
ui z; Give the lest
test in
in either
either flash
flash card
card or
ormultiple
multiple choice
choice
form at.
format.

108
108

Downloaded from www.Manualslib.com manuals search engine


PUBLIC
PUBLIC DOMAIN
DOMAIN SERIES
SERIES
C64
C64 700
700 —- BUSINESS
BUSINESS 1I
This
This package
pac kage contains
contai ns fourteen
fourteen programs
programs that
that cover
cover aa variety
variety of
of business
business ap
ap-
plications.
plications. The
The programs
programs include
include calculating
calcu lating interest,
interest, simulating
simulating business
business
operations,
operations, and
and simulating
simulating stock
stock transactions.
transactions.

C64 701
C64 701 —- GEOGRAPHY
GEOGRAPHY II
This
This educational
educat ional package
package contains
contains thirteen
thi rteen quizzes
quizzes about
about countries,
countries, states,
states,
and
and their
their capitals.
capitals. There
There is
is also
also aa program
program that
that lets
lets you
you print
print out
out aa map
map of
of
England.
England.

C64 702
C64 702 —
- ENGLISH
ENGLISH II
14 programs
14 prog rams that
that teach
teach you
you more
more about
about English.
Engl ish. Word
Word games,
games, poetry,
poetry, word
word
defin itions, and
definitions, and parts
parts of
of speech.
speech.

C64 703 -
C64 - ENGLISH
ENGLISH IIII
16
16 programs
programs help
help sharpen your
your language
language skills.
skills. Spelling
Spelli ng and
and vocabulary
vocabulary
drills,
dri lls, lessons
lessons about homonyms,
homonyms, verb
verb forms,
forms, and
and punctuation.

704 —
C64 704 - ENGLISH III
Collection
Collection of
of 15
15 programs
programs from Commodore's
Commodore's English language series con
con-
more about the parts of speech.
centrating on teaching you more

- ENGLISH IV
C64 705 —
15
15 more English language programs —
- drills on rhyming
rhyming,, unscrambling
words, and spelling.
words, and spelling.

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


This
Thi English
s part of the Eng series
lish language seri mostly
es is made up most ly of tests on word
wo rd
meanings, spelling, and vocab
meanings, vocabulary. 12 programs in all.
ulary. 12

C64 708 -— ENGLISH VII


The seventh collection of English language programs offers 3 challenging
wo rd games.
word

C64 709 -— MATHEMATICS I


in arithmetic, gives you algebra lessons, and
Educational package drills you in
challenges yo
youu wi th math games.
with

C64 710 -— MATHEMATICS II


Math
Math ed ucational package
educational package includes
includes 15
15 programs.

C64 711 -— MATHEMATICS


MATHEMATICS III
math education prog
Collection of math programs lessons and drills on metric
rams offers lessons metric
conversion,
conversio factoring,
n, fac probability,
toring , probabil math,, and algebra.
ity, math algebra. Total of 15
15 programs.
programs.

109
109

Downloaded from www.Manualslib.com manuals search engine


C64 712
C64 712 —
- MATHEMATICS
MATHEMATICS IV
Fourteen more
Fourteen more math
math education
education programs. Lessons
Lessons and
and drills
drills cover
cover factoring
factoring
and algebra.
algebra.

C64 713
C64 713 —
- MATHEMATICS V
V
Fifteen
Fifteen more
more math
math education
education programs.
programs. Learn while
while you
you have
have fun.
fun .

C64 714 —- MATHEMATICS


MATHEMATICS VI VI
Collection of
of math
math education
education programs including
including more
more drills,
drills, quizzes,
quizzes, and
and
games. 15
math games. 15 programs.
programs.

715 —
C64 715 - MATHEMATICS
MATH EMATICS VII
VII
Sixteen advanced math programs —
advanced math - prime
prime numbers, and
and roots.

C64 716 — - MATHEMATICS


MATH EMATICS VIM VIII
Final
Fi nal package in in the math
math education series contains eleven programs. InIn·
eludes dri lls,
cludes drills, games, and lessons on algebra, trigonometry
algebra, trigonometry,, slopes and lac·
fac
tari ng.
toring.

- COMPUTER SCIENCE II
C64 717 —
thirteen
These thi rteen programs show you
you more about using your computer. The
programs lists, drawi
programs include sorting lists, drawing
ng graphics, and creating animation.

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
chemistry and other sciences.
sciences.

C64 720 -— SCIENCE III


12 more science education programs,
programs, including a variety of
of scientific areas.

C64 721 -— SCIENCE IV


education so
This education software
ftware package contains an assortment of lessons and
particularly
quizzes on various sciences, particu biology.
larly biology.
n
C64 722 -— TECHNOLOGY II
This package of ten programs covers a variely
variety of topics re lated to technology
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


famous people.
This package offers four challenging quizzes on history and lamous
fascinating
There is also a fascinat nineteenth century American
ing simulation of nineteenth
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

Downloaded from www.Manualslib.com manuals search engine


C64 725
C64 725 —
- GAMES
GAMES IIII
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
games and aa simulation
simulation of
o f Hi-Q.
Hi·a.

C64 726
C64 726 —- GAMES
GAMES IIIIII
More
More fun
fun and
and educational
educational games
games that
that let
let you
you play
play and
and learn
learn on
on your
you r 64.
64. Seven
Seven
games in
games in this
thi s collection.
coll ection.

111
111

Downloaded from www.Manualslib.com manuals search engine


APPENDIX BB
APPENDIX
DESCRIPTION
DESCRIPTION OF
OF DOS
DOS ERROR
ERROR MESSAGES
MESSAGES
NOTE: Error
NOTE: Error message
message numbers
numbers less
less than
than 20
20 should
should be
be ignored
ignored with
with the
the excep
excep·
tion
tion of
of 01
01 which
which gives
gives information
information about
about the
the number
number of
of files
files scratched
scratched with
with the
the
SCRATCH command.
SCRATCH command.

20:
20: READ ERROR
READ ERROR (block
(block header
header not
not found)
found)
The
The disk
disk controller
controller is
is unable
unable toto locate
locate the
the header
header of
of the
the requested
requested data
data
block.
block. Caused
Caused byby an
an illegal
illegal sector
sector number,
number, oror the
the header
header has
has been
been
destroyed.
destroyed.

21 :
21: READ ERROR
READ ERROR (no
(no sync
sync character)
character)
The
The disk
disk controller
controller is
is unable
unable to
to detect
detect aa sync
sync mark
mark on
on the
the desired
desired track.
track.
Caused
Caused by
by misalignment
misalignment of
of the
the read/writer
read/w ri ter head,
head, no
no diskette
diskette is
is present,
present, or
or
unformatted
unformatted or
or improperly
improperly seated
seated diskette.
diskette. Can
Can also
also indicate
indicate aa hardware
hardware
failure.
failure.

22:
22: READ ERROR
READ ERROR (data
(data block
block not
not present)
present)
The
The disk
disk controller
controller has
has been
been requested to to read or
or verify
verify aa data
data block
bl ock that
that
was
was not
not properly
properly written.
wri tt en. This
Th is error
error message
message occurs in in conjunction
conjunction with
with
the
the BLOCK
BLOCK commands
com mands and and indicates
indicates an
an illegal
illegal track
track and/or
and/or sector
sector rereo
quest.
quest.

23: READ ERROR (checksum


(checksum error
error in data block)
This error
error message indicates
ind icates that there is an error
error in one or more
more of
of the
data bytes. The
Th e data has been read into the DOS memory, but the
memory, bul
checksum
checks um over
over the data is in error. This
Thi s message may also indicate
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
indicate
message may also ind icate grounding problems.

25:
25: WRITE ERROR (write·verify
(write-verify error)
This
Thi controller
s message is generated if the contro ll er detects a mismatch between
the data in the DOS memory.
the written data and Ihe

26: WRITE PROTECT


PROTECT ON
message is
This message is generated wh
whenen the controller has been requested to
write
write a data block while the wri protect switch is depressed. Typically,
te protect
this is caused byby using
using a diskette wiwith
th a write a protect tab over the
notch.
notch.

27: READ ERROR


READ ERROR (checksum
(checksum error inin header)
header) '"
has detected an
The controller has an error
error in
in the header
header of
of the requested
requested data
data
block. The
block. The bl
block has not
ock has not been
been read
read into
into the DOS
DOS memory.
memory. This message
message ,...,
may
may also
also indica te grounding
indicate grounding problems.
problems.

112
112

Downloaded from www.Manualslib.com manuals search engine


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 pre- pre
time, the error message is generated. The error is caused by a
determined time,
"-' hardware
bad diskette format (the data extends into the next block), or by hard ware
failure..
failure

w 29: DISK 10ID MISMATCH


ac
This message is generated when the controller has been requested to ac-
oc
cess a diskette which has not been initialized. The message can also oc-
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.
— of fi
Typically, this is caused by an illegal number of file names, or patterns are
le names,
example, two file names may appear on the left side of
illegally used. For example,
the COpy
COPY command.

— 31: SYNTAX ERROR (invalid command)


The DOS does not recognize the command. The command must start in
the first position.
v-

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: SYNTAX ERROR (no file given)
The file name was left ou
outt of a command or the DOS does not recognize it
as
as such.
such. Typically,
Typically, a colon (:) has been left out of the command.

39 SYNTAX ERROR (invalid command)


This
This error may result ifif the command sent to command channel
channe l (secon
(secon·
dary address 15)
15) is unrecognized by the
the DOS.
DOS.
v
50: RECORD
RECORD NOT NOT PRESENT
Result of
of disk reading past
past the
the last record through
through INPUT#.
INPUT#, or GET# com
com·
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.
INPUT or
or GET should not be attempted after this error
error is detected without
without
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
Since the
the carriage
carriage return which
which is sent
sen t as
as a record
record terminator
terminator is
is counted
counted
in
in the
the record
record size,
size , this
this message
message will
will occur
occ ur if the
the total
total characters
characte rs in the
the
record
record (including
(including the
the final carriage
carriage return)
return) exceeds
exceeds the
the defined
defined size.
size.

52:
52: FILE
FILE TOO
TOO LARGE
LARGE
Record
Record position
position within
within aa relative file indicates
indicates that
that disk
disk overflow will
will
~ result.
resul t.
v
113
113

Downloaded from www.Manualslib.com manuals search engine


r.

60: WRITE FILE OPEN (')


This
Thi s message is generated when a write fifile
reading.
being opened for read ing.
le that has not been closed is ,..,
61: FILE NOT OPEN '"'
This message is generated when a file is being accessed that has not
DOS. Sometimes, in this case,
been opened in the DOS. 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
exists thee diskette.

64: FILE TYPE MISMATCH


The file type does not match the file type in the directory entry for the re-
re
quested file.

65: NO BLOCK
occurs
This message occ conjunclion with the B·A
urs in conjunction B-A command. It indicates
that the block to be allocated has been previously allocated. The
parameters indicate the track and sector avai
available
lable with the next highest
number. (0)T then all blocks higher in number
number. If the parameters are zero (0),
are in use.
use.

66: ILLEGAL TRACK AND SECTOR


The DOS has attempted to access a
a track or block which does not exist in
the format being used. This may indicate a problem reading the pOinter
pointer to
the next block.

67: ILLEGAL
ILLEGAL SYSTEM T OR S
TOR S
This
Th is special
spec ial error message indicates an illegal system track or sector.

70: NO CHANNEL (available)


The requested channel
chann el is not available,
available , or
or all
all channels
chan nels are in
in use. A
A max
max- r-.
imum of five sequential
sequen tial files may
may bebe opened
opened at one time to to the DOS.
DOS.
Direct access channels
channels may have
have six opened fifes.
files.

71:
71: DIRECTORY
DIRECTORY ERROR
ERROR (')
The BAM
BAM does not match
match the
the internal count.
count. There
There is
is aa problem
problem in
in the
BAM
BAM allocation
allocation or the BAM
rect this
this problem,
BAM has been
problem, reinitialize
reinitialize the
been overwritten
overwritten in DOS
the diskette
diskette to
DOS memory.
to restore the
memory. To
the BAM
BAM in
To cor
cor-
in memory.
"
Some active
BAM
active files may be terminated by the corrective
BAM = Block
Block Availability
Availability Map
Map
correct ive action.
action. NOTE:
NOTE: '"'
72:
72: DISK
DISK FULL
FULL
Either
Either the
the blocks
blocks on
on the
the diskette
diskette are
are used
used or
or the
the directory
directory is at its
its entry
entry ",...,
limit.
limi t. DISK
DISK FULL
FULL is
is sent
sent when
when two
two blocks
blocks are
are available
available on
on the
the 1541
1541 to
to
allow
allow the
the current
currenl file
file to
to be
be closed.
closed.

114
114

Downloaded from www.Manualslib.com manuals search engine


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·
version
sion cannot be written upon with the other ve rsion because the format is
different. This error is displayed whenever an attempt is made to write
non-compatible format. (A utili·
upon a disk which has been formatted in a non·compatible utili
ty routine is available to assist in convert
converting another.)
ing from one format to another.)
This
Th is message may also appear after power up. 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

Downloaded from www.Manualslib.com manuals search engine


APPENDIX C
APPENDIX C
EXECUTIVE
EXECUTIVE 64
64 BASIC
BASIC
This
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
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-
volved.
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,
along
along with
with concise
concise descriptions.
descriptions. Please
Please experiment
experiment with
with these
these commands.
commands.
Remember,
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
best
best way
way to
to learn
learn computing
comp uting is
is by
by experimenting.
experimen tin g.
This
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
operations in
operations in BASIC.
BASIC. These
These include:
include:
1.
1. Variables
Variables and
and Operators:
Operators: describes
describes the
the different
different type
type of
of variables,
va riable s, legal
legal
variable
variable names,
names , and
and arithmetic
arith metic and
and logical
logical operators.
operators.
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,
editing , storing,
storing , and
and erasing.
erasing.
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.
4. Functions:
Functions: describes
describes the
the string,
string, numeric,
numeri c, and
and print
print functions.
functions .

VARIABLES
VARIABLES
The 64 uses three types of variables in BASIC. These are real
real numeric,
numeric, in
in-
teger numeric,
numeric , and string (alphanumeric) variables.
Variable names may
may consist of a single letter, a letter followed
fol lowed by a number,
numbe r,
or two
or two letters.
letters.
An integer variable is specified by using the percent (% (%)) sign after th
thee
variable name. String variables have the dollar sign ($) after their name.

EXAMPLES
Real Variable Names: A, A5, BZ
A. A5,
Integer Variable
Integer Variable Names
Names:: A%,
A%. A5 %, Bl%
A5%. BZ%
String Variable Names:
Names: AS,
A$, A5$,
A5S. BZ$
BZS
ARRAYS are lists of variables with the same name, name, using numbers
numbers called
subscripts
su elementt of the array. Arrays are defined using the DI
bscripts to specify the elemen DIMM
statement,, and
statement and may
may contain
contain floating po
point, integer, or
int , integer, or string variables. The array
array
name is
variable name is fol
followed by a set of parentheses
lowed by parentheses ( enclosing
) enclosi number of
ng the number
va riables in
variables in the list.
list.

A(7), BZ %(1 1), AS(50),


BZ%(11), A$(50). PT(20,20)
PT(20.20) n
NOTE: There
NOTE: There are
are three variable
variable names
names wh which are reserved
ich are reserved forfor use
use byby the
the 64,
64.
and may
and may not not be
be defined
defined by by you.
you. These
These variab
variables are: ST,
les are: ST. TI,
Tl, and
and TITl$. ST is
$. ST is aa
status variable
status variable wh which relates to
ich relates to inpuUoutput
input/output operations.
operations. TheThe value
value of of ST
ST will
will
change if
change if there
there is
is aa problem
problem loading
loading aa program
program fromfrom disk
disk or
or tape.
tape.
Tl and
TI and TISTl$ are
are variables
variables which
which relate
relate to
to the
the real
real-time clock built
·time clock built into
into the
the 64.
64.
The variable Tl is updated every 1/60th of a second. It starts at 0 when the com
Th e va riable TI is updated every 1I60th of a second. It starts at 0 when the com-
puter is
puter is turned
turned on,
on. andand is
is reset
reset only
only by
by changing
changing the the value
value ofof TIS.
Tl$.

116
116
n

Downloaded from www.Manualslib.com manuals search engine


TI$
Tl$ is a siring
string which is constantly updated by the system. The first two
hours, the 3rd and 4th characters the number
characters contain the number of hours,
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" AM..
101530" sets the clock to 10:15 and 30 seconds AM
off,, and starts at zero when
This clock is erased when the computer is turned off
on.
the system is turned back on.

OPERATORS
arithmetic
The arithmet ic operators include the following signs:
+ Addition
- Subtraction
Multiplication
Multiplica tion
/ Division
Divisi on
t (exponentiation)
Raising to a power (exponen ti ation)
On a li
line containing
ne contain operator, there is a set order in
ing more than one operator, in which
occur. If several operations are used together on the same
operations always occur.
liline,
ne, the computer assigns priorities as follows: First, exponentiation. Next,
Next,
division, and last, addition and subtraction.
multiplication and division,
You can change the order of operations by enclosing within parentheses the
calculation to be performed first. Operations enclosed in parentheses will take
place before other operations.
There are also operations for equalities and inequalities:

= Equal To
<
< Less Than
>
> Greater
Grea ter Than
< =-
< Less Than or Equal To
>=
>= Greater Than or Equal To
<>
< '/ Not Equal To
To
....... Finally,
Fi nally, there
Ihere are three logical operators:
v AND
OR
'-' NOT
NOT
_ These
These are
are used most often
often to join
join multiple formulas in
in IF .
...
. . THEN
THEN
statements.
statements . For
For example:
IF A
IF A = B
BAND C = D
AND C D THEN
TH EN 100
100 (Requires both parts
parts to
to be
be true)
true)
IF
IF A
A = B
B OR
OR C
C= D
D THEN
THEN 100
100 (Allows
(Allows either part to
to be
be true)
true)

COMMANDS
COMMANDS

CONT
CO NT (Continue)
(Continue)
This
This command
command is is used
used to
to restart
restart the
the execution
execution of
of aa program
program which
wh ich has
has been
been
stopped
stopped by
by either
either using
using the
the STOP
STOP key,
key, aa STOP
STOP statement,
statement. or or an
an END
END statement
statement
within
within the
the program.
program. The
The program
program will
will restart
restart at
at the
the exact
exact place
place from
from where
where itit left
left
off.
off.
v

117
117

Downloaded from www.Manualslib.com manuals search engine


CON T will
CONT 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
even
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
caused
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
a CANT
a CAN 'T CONTINUE
CONTINUE ERROR.
ERROR.

LIST
The LIST
The LI ST command
command allows you you to
to look at lines
lines of
of aa BASIC program in in
memory. You
You can ask for the
the entire program
program to
to be displayed,
displayed, or
or only
only certain
certain line
numbers.
LIST ShowS entire program
Shows
LIST 10-
10 - Shows 10 until end
only from line 10
LIST 10
10 Shows 10
only line 10
LIST
LI ST -
- 10
10 Shows lines from
from beginning
begi nn ing until 10
10
LIST
LI ST 10-20
10·20 Shows line from
line from 10
10 to 20,
20, inclusive
incl usive

LOAD

This command is used to transfer


transfe r a program from disk into memory so the
the
program can be used. The command is followed by a program name enclosed
quotes. The name is followed by a comma and a number or numeric
within quotes.
variable,
variable , which acts as a device number to indicate where the program is com
com-
ing from.
The disk drive is device #S.
#8.

LOAD AS,S
LOAD A$,8 for prog
Looks for program
ram whose name is in the variable A$
LOAD
LOAD ""HELLO"T8
HELLO",S program
Looks for prog called
ram cal led HELLO on the disk dri
drive
ve
LOAD ""*",8
"',S Looks for fifirst
rst program on disk

NEW
N EW
This command erases the entire program in memory, and also clears out any
variables that may have been usedused.. Unless the program was SAVEd,
SAVEd, it is lost.
BE CAREFUL WHENWHE N YOU USE THIS COMMAND.
COMMAND.
command
The NEW com mand can also be used as a BASIC program statement. When
program
the prog reaches
ram reac line, the prog
hes this line, program
ram is erased. This is useful if you want
to leave everything neat when the program is done.

RUN
program, once the program is loaded
This command causes execution of a program,
RUN,, the computer will start
into memory. If there is no line number following RUN
with the lowest line number. If a line number is designated, the program will
start executing from the specified line.
RUN Starts program at lowest line number
RUN 100 Starts execution at line 100
RUN
RU NX UNDEFINED
UND EFINED STATEMENT ERROR. You must always specify
line number,
an actual line number, not a variable representation

11S
118

Downloaded from www.Manualslib.com manuals search engine


SAVE
SAVE
This command
This command will
will store
store the
the program
program currently
currently in
in memory
memory on
on disk.
disk.
Type SAVE
Type SAVE followed
followed by
by aa name
name in
in quotes
quotes or
or aa string
string variable;
variable; the
the comp
computer
uter
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
SAV A$,8
E A$,8 Stores on
Stores on disk
disk with
with name
name in
in A$
AS
SAVE ""HELLO",8
SAVE HELLO",8 Stores
Stores on
on disk
disk with
with name
name HELLO
HELLO

VERIFY
VERIFY
This
Thi command causes
s command causes Ihethe com
computer to check
puler 10 check the
the program
program on on disk
disk against
against
the one
the one inin memory.
memory. This
This is
is proof
proof that
that the
the program
program isis ac
actually
tually SAVEd, in in case
case the
the
disk is
disk is bad,
bad, or
or something
something wenwentt wrong
wrong during
during the SAVE.
SAVE.
VERIFY followed by by a program
program name,
name, or aa string variable,
variable, will
will search for that
that
program and then cheCk.
program check. Device
Device nu
number is included
mber is included with the veri
verify command,
fy command.
command.
~ VERIFY ""HELLO",8
HELLO",8 HELLO on disk, then checks
Searches for HELLO

~ STATEMENTS
CLOSE
This command completes and closes any files used by OPEN statements.
The number following CLOSE is the file number to be cclosed.
losed.
CLOSE 2 Only file #2 is closed

CLR
CLR
This command
command will will erase any
any variables
variables in memory, but
in memory, bu t leaves
leaves the
the program
program
itself intact.
intact. This
Thi s command is automatically
automatically executed when aa RUN command is is
given.
given.

CMD
CMD
CMD
CMD sends
sends the
the output
output which normally
normally would
wou ld go
go to the
the screen
screen (i.e.,
(i.e., PRINT
PRINT
statements,
statements, LISTs,
LISTs, but
but not
not POKEs
POK Es onto
on to the
the screen)
screen) to
to another
another device
device instead.
ins lead.
This
This could
could be
be aa printer,
printer, or
or aa data
data file on
on disk.
disk. This
This device
device or
or file
file must
must bebe OPEN-
OPEN-
ed
ed first.
first. The
The CMD
CM D command
command must must be
be followed
followed by
by aa number
number oror numeric
numeric variable
variable
referring
referring to
to the
Ihe file.
fi le.
OPEN
OPEN 1,4
1,4 OPENs
OPENs device
device #4,
#4, which
which is
is the
the printer
printer
CMD
CMD11 All
All normal
normal output
output now
now goes
goes to
to printer
printer
LIST
LIST The
The program
program listing
listing now
now goes
goes toto the
the printer,
printer, not
not the
the
scree n
screen

To
To send
send output
outpu t back
back to
to the
the screen,
screen, CLOSE
CLOSE the
the file
lile with
with CLOSE
CLOS E 1.1.

DATA
DATA
This
Th is statement
statemen t isis followed
fol lowed by
by aa list
list of
of items
items to
to be
be used
used by
by READ
READ statements.
statements.
Items
Items may
may be
be numeric
numeric values
values oror test
tes t strings,
strings, and
and items
items are
are separated
separated by by com
com -
mas.
mas. String
String items
items need
need not not be
be inside
in side quote
quote marks
marks unless
unless they
they contain
contain space,
space,
colon,
colon , or
or comma.
comma. IfIf two
two commas
com mas havehave nothing
nothi ng between
between them,
them , the
the value
val ue will
wi ll be
be
READ
READ as
as aa zero
ze ro for
for aa number,
number, or
or an
an empty
empty string.
string.
v DATA
DATA 12,
12, 14.5,
14.5, "HELLO,
" HELLO, MOM",
MOM ", 3.14,
3. 14, PART1
PART1

119
119

Downloaded from www.Manualslib.com manuals search engine


DEF FN
DEF FN
This
This command
command allows
allows you
you to
to define
define aa complex
complex calculation
calculation as
as aa function
function with
with
aa short
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
program,
program , this
this can
can save
save time
time and
and space.
space.
The
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
long).
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
the
the function
function name.
name. Following
Following the
the name
name isis aa set
set of
of parentheses
parentheses enclosing
enclosing aa
numeric
numeric variable.
variable. Then
Then follows
follows the
the actual
actual formula
formu la that
that you
you want
want to
to define,
define, with
with
the
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
number for
number for the
the variable.
variable.

10 DEF
10 DEF FNA{X)
FNA(X) = 12*(34.75
12"(34.75 - XI.3)
- XI.3)
20
20 PRINT
PRINT FNA(7)
FNA(7) t
t
T J
| 77 is
IS inserted
X is
X IS m
Insefl e<! where
In lr\e
wnele
rormula
the formula

For this
For this example,
example, the
the result
result woud
woud be
be 137.
137.

DIM

When you use more


more than
than 11
11 elements of an array,
array, you must execute a DIM
DIM
statement for the array.
array . Keep
Keep in mind that the whole
whole array takes up
up room in
in
memory,
memory, so
so don't create
c reate an array much larger
larger than you'll
yOu'll need. To figure the
number of variables
va ri ables created with DIM.
DIM , multiply
multi ply the total number of elements
plus one in each dimension of the array.
array .
10 DIM A$(40).
10 A$(40), B7(15), CC%(4,4,4)
CC % (4,4,4)

41 ELEMENTS
41 16 ELEMENTS
ELEMENTS 125
125 ELEMENTS
ELEM ENTS

You can dimension more than one array in a DIM statement. However, be
careful not to dimension an array more than once.

END
statement,, the program halts,
When a program encounters an END statement halts, as if it ran
out of lines. You may use CON
CONT program.
T to restart the program.

FOR ....
. . TO ..
.... STEP

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:
(Var. Name) = (S
FOR (Var. (Start
tart of Count) TO (End of Count) STEP (Count By)
The loop variable will be added to or subtracted from during the program.
specified., STEP is assumed to be 1. The start count and end
Without any STEP specified
coun
countt are the limits to the value of th e loop variable.
the

FOR L = 1
10 FOR 1 TO 10
10 STEP .1
20 PRINT
PRINT LL
30 NEXT
NEXT LL

the
The end of th may be
e loop value may be followed by
by the word STEP and another
number or
number or va
variable. In this case
ri able. In case,, the value foll
following STEP
ow in g STE is added
P is added each time in-
in
1. Th
stead of 1. This count
is allows you to co or by
un t backwards, or by Iraclions.
fractions.

120
120

Downloaded from www.Manualslib.com manuals search engine


GET
GET
The GET
The GET statement
statement allows
allows you
you toto get
get data
data from
from the
the keyboard,
keyboard, one
one character
character
at a time. When GET is executed, the character that is typed is assigned to
at a tim e. When GET is executed, the charac ter that is typed is assigned to the
the
variable.
variabl e. IfIf no
no character
character is
is typed
typed,, Ihen
then aa null
null (empty)
(empty) character
character isis assigned.
assigned.
GET is
GET is fol
followed by aa variable
lowed by variable name,
name, usual
usuallyly aa string
string variable.
variable. IfIf aa numeric
numeric
variable
variab was used
le was used and
and aa nonnumeric
nonnumeric key
key depressed
depressed,, the
the program
program would
would halt
halt
with an
with an error
error message.
message. The
The GET
GET statement
statement may
may be
be placed
placed into
into aa loop,
loop, check
checking
ing
for any
for any empty
empty result.
result. This
This loop
loop will
will contin
continue until aa key
ue until key is
is hit
hit..

v 10 GET
10 GET A$:
AS: IF
IF A$
A$ == ....""THEN 10
THEN 10

GET#
GET#
GET# statement
The GET# statement is
is used
used with
with a previously OPENed
OPENed device or
or file,
file, to input
one character at aa time from that device or
or file
file..

v GET#1,A$
GET #1 ,AS
input one character from a data file.
This would input

GOSUB
GOTO, except the computer remembers which
This statement is similar to GOTO,
program line it last executed before the GOSUB. When a line with a RETURN
encountered,
statement is encoun tered , the program jumps back to the statement im·
im
following
mediately fo This
llowing the GOSUB. Th yourr pro·
is is useful if there is a routine in you pro
gram that occurs in
in several parts of the program. Instead of typing the routine
over, execute GOSUBs each time the routine is needed.
over and over,
20 GOSUB
20 800
GOSUB 800

GOTO OR
OR GO
GO TOTO
When aa statement with the GOTO command is is reached,
reached , the next line to be
be
executed will
will be the one with the
the line
line number following the
the word
word GOTO.
GOTO.

IF
IF .... .THEN
. THEN
IF
IF ...
... THEN
TH EN lets
lets the
the computer
computer analyze
analyze aa situation
siluation and
and take
take two
two possible
poss ible
courses
co urse s ofof action,
action , depending
depending on on the
th e outcome.
ou tcome. IfIf the
the expression
expres sion isis true,
true , the
the
statement
statement following THEN THEN is is executed.
executed . This
This may
may bebe any
any BASIC
BASIC statement.
statement.
IfIf the
the expression
expression is is false,
false, the
the program
program goes
goes directly
directly to
to the
the next
next line.
line.
The
The expression
expression being
bei ng evaluated
evaluated may may bebe aa variable
variable or
or formula,
form ula, in
in which
which case
case itit
is
is considered
cons idered true
true ifif nonzero,
nonze ro, and
and false
fal se ifif zero.
zero. In
In most
most cases,
cases, there
there is
is an
an ex
ex-
pression
pression involving
involving relational
relational operators
operators (=,
( ;;;; , < < ,, >> , <=>=
< :;;; , > :;;; , <>
< >
AND,
AND, OR
OR NOT).
NOT).
10
10 IF
IF XX >
> 10
10 THEN
THEN END
END

INPUT
INPUT
The
The INPUT
INPUT statement
slatement allows
allows the
the program
program to
to get
get data
data from
from the
the user,
user, assign
assign·
ing
ing that
that data
data to10 aa variable.
variable. The
The program
program will
will stop,
stop, print
print aa question
question mark
mark (?)
(?) on
on
the
the screen,
screen, and
and wait
wait for
for the
the user
user toto type
type in
in the
the answer
answer and and hit
hit RETURN.
RETURN .
INPUT
INPUT isis followed
foll owed byby aa variable
va riab le name,
name, or
or aa list
list of
of variable
va riable names,
names, separated
separated
by
by commas.
commas. AA message
message maymay be be placed
placed within
within quote
quote marks,
marks, before
bef ore the
the list
list of
of
variable
variable names
names toto be
be INPUT.
IN PUT. IfIf more
more than
than one
one variable
variable isis to
to be
be INPUT,
INPUT,they
they must
must
be
be separated
separated by
by commas
commas when
when typed.
typed .
10
10 INPUT
INPUT -PLEASE
'·PLEASE ENTER
ENTER YOUR
YOUR FIRST
FIRST NAME";A$
NAME "; A$
v
20
20 PRINT
PRINT "ENTER
" ENTER YOUR
YOU R CODE
CODE NUMBER";:!NPUT
NUMBER" ;:INPUT BB

121
121

v www.Manualslib.com manuals search engine


Downloaded from
INPUH
INPUTtf
INPUT#
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.
10 INPUT#1,
10 IN PUT#1, AA

LET
LET
LET
LET is
is hardly
hardly ever
ever used
used in
in programs,
programs , since
since itit is
is optional,
optional, but
but the
the statement
statement is
is
the
the heart
heart of
of all
all BASIC
BASIC programs.
programs. The
The variable
variable name
name which
which isis to
to be
be assigned
assigned the
the
result
resuit of
of aa calculation
ca lculation is
is on
on the
the left
left side
side of
of the
the equal
equal sign,
sign, and
and the
the formula
formula on
on
the right.
the ri ght.
10 LET
10 LET A = 55
A =
LET D$ = "HELLO"
20 LET " HELLO"

NEXT
NEXT
NEXT is
NEXT is always
always used
used in
in conjunction
conjunction withwith the
the FOR
FOR statement.
statement. When
When the the pro
pro·
gram
gram reaches
reaches aa NEXT
NEXT statement,
statement , itit checks
checks the
the FOR
FOR statement
statement to
to see
see ifif the
the limit
limit
of
of the
the loop
loop has
has been
been reached.
reached . IfIf the
the loop is not
not finished,
finished, the
the loop
loop variable
variable is
is in
in·
creased by the specified STEP value. If the loop
loop is
is finished,
finished , execution proceeds
w ith the statement following
with following NEXT.
NEXT.
NEXT may be followed
foll owed by aa variable
variable name,
name, or list
list of
of variable
variable names,
names,
separated by
by commas. If there
there are
are no names listed,
listed, the
th e loop
loop started
started is the one
being completed.
comp leted. If variables
variab les are given,
give n, they are completed in order
order from
from left to
to
right.
right.

10 FOR X
10 X = 11 TO 100: NEXT

ON
ON
This command turnsturn s the
the GOTO and GOSUB comma commands special versions
nds into special vers ions
of the IF statement. ON is followed by a formu formula,
la, which is evaluated. If the
result of the calcu
calculation one, the first line on the list is executed;
lation is one, result
executed ; if the resull
2, the second liline
is 2, ne isis executed,
executed, and so on. If the result is 0, negative, or larger
than
than the list of numbers,
numbers, the next line executed wi willll be the statement fofollowing
ll owing
the ON
ON statement.

10 INPUT X
20 ON X GOTO
GOTO 10,20,30,40,50
10.20,30,40,50

OPEN
The OPEN statement allows the 64 to access devices such as the disk for
data, a printer, or even the screen. OPEN is foll followed (0-255), to
owed by a number (0·255),
following
which all followi number
ng statements will refer. There is usually a second number
after the fifirst,
rst , which is
is the device number.
The
Th numbers
e device nu are::
mbers are

°0 Screen
4 Printer
Printer
8 Disk
Disk

122
122

Downloaded from www.Manualslib.com manuals search engine


Following the
Following the device
device number
number may
may be
be aa third number,
number, separated again
again byby a
comma, which
comma, which isis the secondary
secondary address.
In the case
In case of
of the
the disk, the number
number refers
refers to
to the buffer,
buffer, or channel,
channel, number.
number. InIn
printer, the secondary address controls features like
the printer, like expanded printin
printing.
g. See
Commodore 64
the Commodore 64 Prog
Programmer's Reference
ra mmer's Referen Manual for more
ce Manual more detail
details.
s.
10 OPEN 1,0
10 1,0 OPENs
OPEN s the SCREEN as a device
2,8,8,"D"
20 OPEN 2,8,8," D" OPENs
OPEN s reading,, file to be
the disk for reading be searched for
D
is D
30 OPEN 3,4 OPENs printer
the printer
40 OPEN 4,8,15 OPENs
OPEN s the data channel on the disk
CLOSE. CMD, GET#, INPUT#, and PRINT#,
Also see: CLOSE, PRlNT#, system variable ST, and
Appendix
Appe nd ix B.

v POKE
formulas.. The first location is a
POKE is always followed by two numbers, or formulas
location;
memory locati on; the second number is a decimal val value
ue from 0 to 255, which
willl be placed in the memory location
wil location,, rep
replacing
lacing any previously stored valvalue.
ue.
POKE 53281
10 POKE 53281.0
,0
4096' 13
20 S = 4096"1 3
POKES+
30 POKE S + 29,8

PRINT
the
The PRINT statement is th use, but there are a
e first one most people learn to use,
number of variations to be aware of. PRINT can be fo followed
llowed by:
Text String with
with quotes
Variable
Variab le names
Functions
Functions
Punctuation
Punct uation marks

v Punctuation marks are used to help format the data on the screen. screen. The com
com-
ma divides the screen
screen into four columns,
co lumns, while the semicolon
sem ico lon suppresses all
spacing. Either
Ei ther mark
mark can be
be the last symbol on on aa line.
li ne. This
Thi s results in
in the
th e next
thing PRINTed acting as if it were
we re aa continuation of the same PRINT statement.
stat emen t.
10
10 PRINT "HELLO"
" HELLO"
20
20 PRINT "HELLO",A$
" HELLO",A$
30
30 PRINT A+B
A+ B
40
40 PRINT J;
J;
60
60 PRINT A,B,C,D
A,B,C,D
Also
Also see:
see: POS,
POS, SPC
SPC and
and TAB
TAB functions
fu ncti ons

PRINTS
PRINT#
There
There are
are aa few
few differences
differences between
between this
thi s statement
statement and and PRINT.
PRINT. PRINTS
PR INT# is
is
followed
followed by
by aa number,
number, which
which refers
refe rs to
to the
the device
device or or data
data file
file previously
previously
OPENed.
OPENed. This
This number
number is
is followed
followed by
by aa comma
comma and and aa list
list to
to be
be printed.
printed. The
The com
com·
ma
ma and
and semicolon
semicolon have
have the
th e same
same effect
effect as
as they
they do
do in
in PRINT.
PRINT. Please
Please note
note that
that
some
some devices
devices may
may not
not work
work with
wi th TAB
TAB and
and SPC.
SPC.
100
100 PRINT#1."DATA
PRINT#l ,"DATA VALUES";
VALU ES"; A%,
A%, B1,
Bl , C$
C$

123
123

Downloaded from www.Manualslib.com manuals search engine


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
program,, or give additional instructions. REM statements
plain a section of the program
in no way affect the operation of the program,
program, except to add to its length. REM
may be fo llowed
followed by any text.

RESTORE
program, the pOinter
When executed in a program, pointer to which an item in a DATA state·
state
ment wiwillll be READ next is reset to the first item in the list. This gives you the
re-READ
ability to re·R information.
EAD the in RESTORE stands by itself on a line.
formation. RESTORE

RETURN
This statement is always used in
in conjunction with GOSUB. When the pro·
pro
RETURN,, it will go to the statement immediately following
gram encounters a RETURN
the GOSUB comma nd. If no GOSUB was previously issued
command. issued,, a RETURN
WITHOUT GOSUB
GOSUB ERROR wi ll occur.
will

STOP
This statement will hal
haltt program execution. The message,
message. BREAK IN xxx will
displayed,, where xxx is the line number contain
be displayed containing
ing STOP. The program may
be restarted by USing
using the CONT command. STOP is normally used in
in debugging
a program.

SYS
SYS is followed by a decimal number or numeric value in the range 0·65535.
0-65535.
The program will then beg in executing the machine language program start
begin ing
starting
at that memory location. This is similar to the USR function
function,, but does not allow
parameter passing.

WAIT
WAIT is used to halt the program until the contents of a memory locat ion
location
changes in a speci fi c way. WAI
specific WAITT is followed by a memory location (X) and up to
variables.
two var iables. The format is:
WA IT X,Y,Z
WAIT

The contents of the memory location are first exclusive·ORed


exclusive-ORed with the third
number, if presen
number, present, logically
t, and then log ically ANDed with the second number. If the
is ze
result is zero,
ro, the program goes back to that memory location and checks
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

Downloaded from www.Manualslib.com manuals search engine


ATN(X) (arctangent)
angle, measured in radian
Returns the angle, radians,
s, whose tangent is X.

COS(X) (cosine)
'-' cosine
Returns the value of the cos X, where X is an angle measured in ra·
ine of X, ra
dians.

v EXP(X)
mathematical
Returns the value of the mathemat ica l constant e(2.71827183) raised to the
Ihe
power of X.

FNxx(X)
FN xx(X)
Returns the val
value user-defined functio
ue of the user·defined function DEF FN
n xx created in a OEF FNxx(X)
xx(X)
statement.

INT(X)
Returns the truncated value of X,
X, that is,
is. with all the decimal places to the
riright the
ght of th removed.. The result wil
e decimal point removed willl always be less than
than,, or equal
v
to, X. Thus, with
Thu s, any negative numbers wit h decimal places will become the integer
less than their curre nt value.
current

LOG(X) (logarithm)
Will
Will return the natural log of X. The natural log to the base e (see EXP(X».
EXP(X)). To
convert to log base 10,
10, simpy divide by LOG(10).
LOG(10).

PEEK(X)
0-65535, giving a
Used to find out contents of memory location X, in the range 0·65535,
result
resuit from 0-255. PEEK is often used in conjunction with
in conjunct ion wi th the POKE statement.
statemen t.
v
RND(X) (random
{random number)
RND(X) returns a random number in the range 0·1. 0-1. The first random number
should be generated by the form formula RND(-TI)
ula RND( - TI) to start things off differently
every time. After this, X should be a 1 1 or any positive number. If X is zero,
zero, the
result wi ll
will be the same random number as the last one.
A negat
A negativeive value for X will reseed the generator. The use of the same negative
number for X wiwill result
ll resu "random"
lt in the same sequence of "random numbers.
" numbers.
v formula
The fo generating
rm ula for generat number between
ing a number between X and Y is:

N = RND(1),
RND(1)*(Y-X)+X
(Y - X)+ X
where,
where.
v
Y is the upper limit
X is the lower range of numbers desired.

SGN(X) (sign)
This
Thi returns
s function ret negative,
urn s the sign (positive, negat ive, or zero) of X. Th
Thee result will
be + 11 if positive, 0 if zero,
zero , and - 1
- 1 if negative.
negat ive.
v
SIN(X) (sine)
v SIN(X) is the trigonometric function.
trigo nometric sine fu nction. The result will be the sine of X,
X,
in radians.
where X is an angle in

125

v
Downloaded from www.Manualslib.com manuals search engine
SQR(X) {square
SQR(X) (s quare root)
root)
This
This function
function will
will return
return the
the square
square root
root of
of X,
X, where
where XX is
is aa positive
positive number
number or
or
O. IfIf XX is
0. is negative,
negative, an
an ILLEGAL
ILLEGAL QUANTITY
QUANTITY ERROR
ERROR results.
resuits.

TAN(X) (tangent)
TAN(X) (tangent)
The
The result
result will
will be
be the
the tangent
tangent of
of X,
X, where
where XX is
is an
an angle
angle in
in radians.
radians.

US~
USR(X) ~
When
When this
this function
function is
is used,
used , the
the program
program jumps
jumps to
to aa machine
mach ine language
language pro
pro·
gram
gram whose
whose starting
starting point
point is
is contained
contained in
in memory
memory locations.
locations. The
The parameter
parameter XX .-.
is
is passed
passed to
to the
the machine
machine language
language program,
program, which
which will
will return
return another
another value
value
back to
to the
the BASIC
BASIC program.
program. Refer
Refer to
to the
the Commodore
Commodore 64
64 Programmer's
Programmer's
Reference
Reference Manual
Manual for
for more
more details
details on
on this
this function
function and
and machine
machine language
language pro
pro-
gramming.
gramming.

STRING FUNCTIONS
ASC(XS)
ASC(XS)
This
Thi s function will
will return the
the ASCII
ASCII code
code of
of the
the first character of X$.
XS.

CHRS(X)
CHR$(X)
This
This is the opposite of ASC,
ASC, and returns aa string character
character whose ASCII
ASCII code
is X.
isX.

LEFTS(XS,X)
Returns a string containing the leftmost X
X characters of $X.
SX.

LEN(XS)
LEN{X$)
Returned will be the number of characters (includ
(including
ing spaces and other sym
sym-
bols) in the string XS.
X$.

MIDS(XS, S,X)
MID^XS.S.X)
willll return a string containing X
This wi X characters starting from the Sth
character in X$.

RIGHTS(XS,X)
RIGHTS(X$,X)
X$.
Returns the rightmost X characters in XS.

STRS(X)
This
Thi s will return a string which is identical to the PRINTed version of X.

VAL(XS)
This
Thi opera
s function converts X$ into a number, and is essentially the inverse opera-
tion from STR$. The string is examined from the leftmost
leftmost character to the right,
right,
recognizable
for as many characters as are in recog number format.
nizable number
lOX
10 X = VAL(" 123.456")
VALC'123.456") X = 123.456
10
10 X = VAL(" 12A13B")
VAL("12A13B") X =
X = 12
12
10
10 X = VAL("RIU017"
VAL("RIU017")) X = 0
10
10 X = VAL(" -1.23.45.67")
VAL("-1.23.45.67") X = --1.23
1.23

126
126

Downloaded from www.Manualslib.com manuals search engine


OTHER
OTHER FUNCTIONS
FUNCTIONS
FRE(X)
FRE(X)
This
This function
functi on returns
returns the
the number
number ofof unused
unused bytes
bytes available
avai table in
in memory,
memory,
regardless of
regardless 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
if the
if number of
the number of unused
unused bytes
bytes is
is over
over 32K.
32K.

POS(X)
POS<X)
This
This function
funct ion returns
returns the
the number
number of
of the
the column
co lumn (0-39)
(0-39) at
at which
which the
the next
next
PRINT statement
PRINT statement will
wi ll begin
begin on
on the
the screen.
screen. XX may
may have any value
have any value and
and is
is not
not
used.
used.

SPC(X)
SPCpC)
This is
This is used
used in
in aa PRINT
PRINT statement
statement to
to skip
ski p XX spaces
spaces forward.
forward.

TAB(X)
TAB(X)
'-J TAB
TAB is
is also
also used
used in
in aa PRINT
PRINT statement;
statement ; the
the next
next item
item to
to be
be PRINTed
PRINTed will
wi ll be
be
in column
in column X.

127
127

Downloaded from www.Manualslib.com manuals search engine


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.
Look. like Looks like
Com- Abbrevi- this on Com- Abbrevi- this on
mand
mond ation
otion screen mand
mond ation screen
screen

ABS A EI:IID B Am END


END E EI:IID
E Ullbl N
N E 2
E [2]
AND A EI:IID N A [2] EXP
EXP E EI:IID
E BfflSl xX E
E ~
_Aj

ASC A EI:IID S A~ FN NONE


NO NE FN

ATN A EI:IID T A[] FOR F EI:IID 0 F


0
CHR$ C EI:IID H c[] FRE F EI:IID R F [;J
CLOSE
CLO SE CL EI:IID 0
CL CLO GET G lilIID E G El

CLR C EI:IID L C D GET# NONE


NO NE GET#

CMD C EI:IID M cIS! GOSUB


GOSUB GO EI:IID
GO Ulljil SS GO~
GO V

CONT C EI:IID 0 C D GOTO


Goro G Ulllal
G EI:IID O0 G
G [
0
COS
cos NONE
NONE COS
co s IF NONE IF

DATA
DATA D EI:IID
D ETTTal A DD~
Q INPUT NONE INPUT
IN PUT

.'
DEF
DEF D EI:IID E DEl INPUT# I EI:IID N [2]
DIM
DIM i) eh3 i
D D INT
INT NONE INT
INT

128
128

Downloaded from www.Manualslib.com manuals search engine


~

'-'
Looks like Looks like
looks
'-' Com
Com· Abbrevi
Abbrevi- this on Com
Com- Abbrevi
Abb revi- this on
mand
mond at ion
ation scree
screenn mond
mand ation screen
V
LEFTS LE rmID F LEQ RIGHT$
RIGHTS R rmID I RW
'-'
LE
LENN NONE LEN RN
RNDD R rmID N R[ZJ
'-'

v
LET L rmID
L EHE E El RUN R rmID u RW

LI ST
LIST rmID W SAVE S rmID A S~
v LOAD rmID o
a 0 SGN S rmID G s[O

v LOG NONE LOG SI N


SIN S rmID I SEJ

V MID$
MIDS

NEW

NEXT
MrmID
NONE

N rmID
I MW

NEW

N
El
SPC(

SQR

STATUS
S rmID P

S rmID
S

ST
ST
EflT; Q S.
s O

ST

NOT N rmID a nD
NO STEP stB!!!
ST rmID E STD

ON NONE ON STOP s rmID


S eui T s[O
V
OPEN OrmID P 00 STRS
STR$ ST rmID
ST ^ R STQ
v
OR NONE OR SYS
srs s rmID
S E2E Y S []
PEEK P rmID E pEl TAB
TAB(! T rmID
T BHT; A TT~
g]
POKE P rmID a pO TAN NONE TAN

pas
POS NONE pas
POS THEN t rmID
T E!Uj H T[]

PRINT ? ? TlME
TIME TI
Tl TI
Tl
v

'-'
PRINT#
PRINT # P rmID R P
Id TIMES Tl$
TIS Tl$
TIS

V
READ R rmID E REl USR U rmID
U EH S U~
u[v)
REM NONE REM VAL v rmID
V ET!T A vV~
5]
v RESTORE RE rmID S RE~ VERIFY v rmID
V EH E vEl

V RETUR N RE rmID
RE tSIUI T
T RE [[] WAIT WrmID A W~
V

V
v

v
v

129
V
v
Downloaded from www.Manualslib.com manuals search engine
APPENDIX EE
APPENDIX
SCREEN
SCREEN DISPLAY
DISPLAY CODES
CODES
The
The following
following chart
chart lists
lists all
all of
of the
the characters
characters built
built into
into the
the 64's
64's character
cha racter
sets.
sets. ItIt shows
shows which
which numbers
numbers should
should be
be POKEd
POKEd into
into screen
screen memory
memory (locations
(locat ions
1024-2023}
1024-2023) to
to get
get aa desired
desired character.
ch aracter. Also
Also shown
shown is
is which
which character
character cor
cor-
responds
respon ds to
to aa number
number PEEKed
PEEKed from
from the
the screen.
screen .
Two
Two character
charact er sets
set s are
are available,
available, but
but only
on ly one
one set
set at
at aa time.
time. This
Thi s means
means that
that
you
yo u cannot
cannot have
have characters
characters from
from one
one set
set on
on the
th e screen
screen atat the
the same
same time
time you
you
have
have characters
characte rs from
from the,other
the other set
set displayed.
displayed. The
The sets
sets are
are switched
switched by by holding
holding
down
down the Ii!:W and
the ETUI and 'C=' keys [QJ
keys simultaneously.
simultaneousl y_
From
From BASIC,
BASIC, POKE
POKE 53272,21
53272,21 will
will switch
switch to
to upper
upper case
case mode
mode and
and POKE
POKE
53272,23 switches
53272.23 switches to
to lower
lower case.
case.
Any
Any number
number on
on the
the chart
chart may
may also
also be
be displayed
displayed in
in REVERSE.
REVERSE. The
Th e reverse
reverse
character
character code
code may
may be
be obtained
obtain ed by
by adding
adding 128
128 to
to the
the values
values shown.
shown.
If
II you
you want
want toto display
display aa solid
solid circle
ci rcle at
at location
location 1504,
1504, POKE
POKE thethe code
code for
for the
the
circle
circle (81)
(81) into
into location
location 1504:
1504: POKE
POKE 1504,81.
1504,81.
There
There is is aa corresponding
corresponding memory
memory location
location to
to control
cont rol the
the color
color of
of each
each
character
character displayed
displayed on
on the
the screen
screen (locations
(locations 55296-56295).
55296·56295). ToTo change
change the
the color
color
of
of the
th e circle
circle to
to yellow
yel low (color
(color code
code 7)
7) you
yo u would
would POKE
POKE the
the corresponding
corresponding
memory
memory location
location (55776)
(55776) with
with the
the character
cha racter color:
co lor: POKE
POKE 55776,7.
55776,7.
Refer
Refer to
to Appendix
Appendi x G
G for the
the complete
complete screen
screen and
and color
co lor memory
memory maps,
maps, along
along
wit h color codes.
with

NOTE: The
The following
follow ing POKEs display
display the
the same
same symbol in
in set 11 and 2:
2: 1.
1, 27-64.
27·64,
91-93, 96-104,106-121 , 123-127.
91-93. 96-104, 106-121, 123-127.

SCREEN CODES
1
SET 1 SET 2 POKE 1
SET 1 SET 2 POKE 1
SET 1 SET 2 POKE

@
@ o0 C c 3 F
F f 6
A a 1 oD d 4 G
G g 7
Bb2Ee5Hh
E e 5 H h 8
B b 2

""

130
130

Downloaded from www.Manualslib.com manuals search engine


-'

'-'
SET 11 SET 2 POKE SET 11 SET 2 POKE
POKE SET 11 SET 2 POKE
V

V 9 % 37 ~ A 65

V J 10 & 38 m
CD B
B 66

'--'
K k 11
11 39 B
El C 67

V
L 12 40 B
El D 68

v
M m 13 41
41
Q
El E 69

v
N
N n 14 42 U
D F 70

0O o
0 15 + 43 []
D G 71
V
P P
P 16 44 a
[] H 72
v
v
Q
Q q
q 17 45 W I 73
R
R r 18 46 ~
a J 74
v
S s
S 19 47 □
EJ K 75
v
T t 20 0 48 0D L 76

U
U uu 21
21
49
S
is] M 77

v
V Vv 22 2 50 00 N
N 78
'-' w
W w
w 23 3 51
51
0□ o
0 79
'-' X x
X 24 4 52
0 P
p 80
v yY y
y 25 5 53 II] Q
Q 81
v z
Z z
z 26 6 54 □
D R
R 82
v 27 7 55 ~ S 83

'-' £ 28 8 56 [] T 84

v 29 9 57 W U
U 85

v i 30 58 ~ V 86

'-' -
SPACE
31

32 <
59

60
D
l±l
W
w

X
87
88
v
33 61 [] Y
Y 89
v
34 > 62 [1] z
Z 90
# 35 ? 63 EB 91

$ 36 El 64 IJ 92

v
131
131

v
Downloaded from www.Manualslib.com manuals search engine
SET 11 SET 2 POKE SET 11 SET 2 POKE SET 11 SET 2 POKE

rnCD 93 ~ ~ ,05
105 E
[J ,17
117

liD 6l!l 94 0 ,06


106 a
[) ,118
,8

3
~ ~ 95 [8 ,07
107 □
U ,,9
119

H
~

. C.
SPACE 96 ,08
108 ,120
20

E
IJ 97 [g ,09
109 ~
U ,2,
121

H 98 6J '110
,0 a
0 0
0 ,122
22

n
0 99 □
U ',,
111 E
ILJ ,23
123 -

D
0 ,00
100
ca ,,2
112
a
~ ,24
124


0 ,0,
101
B
El ,,3
113 H
I:J ,25
125

II ,102
02 53 '114
,4 H
~ ,26
126

0 ,103
03 BJ ,,5
115 ~
S ,27
127
,....,

~ ,04
104 0 ,,6
116
r.
Codes Irom
from ,128-255
28-255 are reversed images of codes 0-,
Images 01 0-127.
27.

'-

,32
132 —

Downloaded from www.Manualslib.com manuals search engine


v
v
v APPENDIX F
'-' ASCII AND CHR$ CODES
This appendix shows you what characters will appear if you PRINT CHR$(X),
X. It will also show the values obtained by typing
for all possible values of X.
'-'
PRINT ASC("x"),
ASC(" x"), where x is any character you can type. type. This is useful in
v statement,
evaluating the character received in a GET statem ent , converting upper/lower
case, and printing character based commands (like switch to upper/lower case)
case,
v quotes.
that could not be enclosed in quotes.
"-'

v PRINTS CHR5
CHA$ PRINTS CHRS
CHR$ PRINTS CHR$
CHA$ PRINTS
PAINTS CHRS
CHA$

-•
n
V 0 17 34 3 51
51

'-' 18 #
# 35 4 52
'-' 2 19 $ 36 5 53

v 3 II 20 % 37 6 54

v
v

'-'

'"
v
-
DIS"'ES _~8
4
5
6
7
21

22
23
23

24
24

25
&
&

(
)

38
39
40
41
41

42
7
8
9
55
56

57
58

59

'H"'ES _~99 26 +
+ 43 C 60

-•
v
10 27 44 61
v
11
11 28
28 - 45 :::> 62
v
12
12 ag 29
29 46 ? 63

-
v
IiID!II 13
13 30 / 47 @
@ 64
64

v t:
SWITCH TO
14 31 0
0 48
48 A
A 65
LOWER CASE

'-' 15
15
lID 32 1 49
49 B
B 66

v 16
16 33 2
2 50 C
C 67
67

v
v

v
v
'-'
v

'-' 133
133

'-'
Downloaded from www.Manualslib.com manuals search engine
PRINTS CHRS PRINTS CHRS PRINTS CHAt PRINTS CHRS

--
D 68 97 @) 126 Grey 3 155
E 69 CD 98 l"1IIIJ 127 156
F 70 El 99 128 riI 157
G 71 EJ 100 Ora nge 129 158
H 72 Ll 101 130 159
I 73 g 102 131 IB 160
J 74 [] 103 132 (] 161
K
L
M
75
76
77
0
bJ
[3
104
105
106
11
13
15
133
134
135

0
0
162
163
164
N 78 EJ 107 17 136 0 165
0 79 0 108 12 137 II 166
P 80 IS] 109 14 138 0 167
a 81 0 11 0 16 139 ~ 168
R 82 0 111 18 140 ~ 169
S 83 0 112 1liIIII1II!m141 0 170
T 84 II 11 3 ' ~142 rn 171
U 85 0 114 143 c:. 172
v
W
X
86
87
88
~
0
115
116
117
•.. III
144
145
146
[l3
6J
Q
173
174
175
Y 89 ~ 118 III 147 ca 176
Z 90 D 11 9
II 148 E:l 177
[ 91 ~ 120 Brown 149 EIl 178
£ 92 121 11 . Red 150 BJ 179
J 93 [l] 122 Grev 1 151 0 180
1 94 tE 123 Grev 2 152 (] 181

-El 95
96
IJ
CD
124
125
Lt . Gr een

Lt . Blue
153
154
[J
U
182
183
I

134
134

Downloaded from www.Manualslib.com manuals search engine


w

PRINTS CHRS
CHAt PRINTS CHRS
CHR$ PRINTS CHRS
CHAt PRINTS CHRS

~ 184 0 186 H
~ 188 ~
H 190
~ 185 ~ 187 e:J 189 ~
V 191
191

CODES 192-223 SAME AS 96-127


CODES 224-254 SAME AS 160-190
v CODE 255 SAME AS 126
v
'--'

'--'

'--'

'-'
'--'

'--'

'--'
v

'--'
v
V

'--'

'-'
v
v
v
v
v
v
135
135

Downloaded from www.Manualslib.com manuals search engine


-

APPENDIX
APPENDIX G
G
SCREEN
SCREEN AND
AND COLOR
COLOR MEMORY
MEMORY MAPS
MAPS
The
The following
fol lowing charts
charts list
li st which
which memory
memory locations
loca tions control
cont rol placing
placing characters
characters
on
on the
the screen,
screen, which
which locations
locati ons are
are used
used to
to change
change individual
indi vi dual character
character colors,
colors,
and
and they
they show
show character
character color
color codes.
codes.

SCREEN
SCREEN MEMORY
MEMORY MAP
MAP
COLUMN
COLUMN
10 20
20 HJO J9
1063
■ -■

II

1024-~~1
1024-
.1064
■ : •. ~'lqH 'H
, __;+1 1· - rTl'.
j!-! -pt , -
'- L- - ~~
!.::JJ 0 ~

::■
\I :
1\0,',
--::
1\8'
1184
\22:
' : ' __ • :- _
~

__
, .....
____ ___ _
_ _
___ ,

_~ .
__
_ 0_ ,' • •
_
_ ._ .
+- _ ••
__

~~ _____
.. I
126 ~
1264 _~_ _ . tI ~ I '

V
lJOJ: ~~~. r"* . L-__ _ - - - - - , -
IH~
mt '-t~~-·! .-~. ' I ... +----
I' - -,+-----
■ ■■■■
138'
1424
UN
1.164
1464
150~:
■■
L--.......t.
_
,

'-11;=-'--
.

._ .
• •
-1---
• I __ +
j +-
+- .-
_ . -...
_ _!_
I
. •- •_

' .. • _' _' .
t- . ~
-0.- ••
.~- 10 ~
- - _ . _ -

. ---~

15.1.1
1541 i i '
I~ J .•
1584 -
162.1
■ '■
- _. +- i ...■

166.1
■■■ :
: - :. •_ ___

:~~~ +~.: ~ . ~::~~


....

■:: f-"
11&!
1J8J
r-----[:, —
1814
1824

186~
■■■ I
1904
1904
11344
gJ~
\....---.-_-

:
I H+rH
' 10

198. —
19841 i

The
Th e actual values to POKE into a color memory location to change a
ch aracter's color are:
character's

o0 BLACK 8 ORANGE —

11 WHITE 9 BROWN
2 RED
RED 10 U ght RED
Light
3 CYAN 11 GRAY 1
11GRAY1
4 PURPLE 12 GRAY 2
5 GR EEN
GREEN Light
13 Li ght GREEN
6 BLUE
BLUE 14 Ughl
Light BLUE
7 YELLOW 15 GRAY 3

136
136

Downloaded from www.Manualslib.com manuals search engine


For example, to change
For change the color ofof a character
character located
located at the upper
upper left-hand
left-hand
w

corner
corn er ooff the screen to red
red,, type:
type: POKE
POKE 55296,2_
55296,2.

COLOR MEMORY MAP


v
COLUMN
COLUMN
10 20
10 3D 39
v sms
55335
I
55296-
m96
55336
m36 !- /-I! !ttLl
ssm
55376
55416
55~16 I
55456
55456
L_-±-W: --
55J96
S5J96
ssm
55536
[E¢[~ , pi ! 1_--;-1 :..:
55576
miG
55616
55656
I' 'f __
...!f
-i I -
_L
-- 1-'
55655
55696
55696 -- 1100 ~
9
55736
5)136
.-H, ,, i -
55776
m76
55816 i
'
I It · , , -; I
55856
mS6
55896 - - -r: +
55936 I I
55976
S6016
56016
56056 I i
56096
v 56135
56 in
56116
56215
56216
_..J.. ,... i 10

56255
56155
- -I
ff
56295
56m

v
w

137
137

v
Downloaded from www.Manualslib.com manuals search engine
APPENDIX HH
APPENDIX
DERIVING
DERIVING MATHEMATICAL
MATHEMATICAL FUNCTIONS
FUNCTIONS
Functions
Functions that
that are
are intrinsic
intrinsic to
to 64
64 BASIC
BASIC may
may be
be calculated
calculated as
as follows:
follows:

FUNCTION
FUNCTION BASIC
BASIC EQUIVALENT
EQUIVALENT
SECANT
SECANT SEC(X)=1/COS(X)
SEqX) = lICOS(X)
COS ECANT
COSECANT CSC(X)
csqX) == 1/SIN{X)
1ISIN(X) -

COTA NGENT
COTANGENT COT{X)=1/TAN(X)
COT(X) = 11T AN(X)
INVERSE SINE
INVERSE SINE ARCSIN(X)=ATN(X/SQR(-X'X+1))
ARCSIN (X)= ATN(XlSQR( - X· X+ 1))
INVERSE COSINE
INVERSE COS INE ARCCOSfX}=
ARCCOS(X) = -ATN<X/SQR
- ATN (XlSOR
(-X'X+1))
(-X·X+1)) ++ ff/2
}[ 12
INVERSE SECANT
INVERSE SECANT ARCSEC(X) = ATN(X/SQR(X'
ARCSEqXI=ATN X-
(XlSQR(X ·X - 1))
1))
INVERSE COSECANT
INVERSE COSECANT ARCCSC(X)
ARCCSqX) == ATN(XJSQR(X*
ATN(XlSQR(X · XX -- 1))
1))
+
+ (SGN(X)-TJr/2)
(SGN(X) - 1· }[ 12)
INVERSE COTANGENT
INVERSE COTANGENT ARCOT(X)
ARCOT(X) =
= ATN{X)
ATN (X) +
+ Jt/2
}[ 12
HYPERBOLIC SINE
HYPERBOLIC SINE SINH(X)b
SINH(XI = (EXP(X)
(EXP(X) -
- EXP(-
EXP( - X))/2
X))12
HYPERBOLIC COSINE
HYPERBOLIC COSINE COSH(X)
COS H(X) = (EXP(X)
(EXP(X) ++ EXP(
EXPI-- X))/2
X))12
HYPERBOLIC TANGENT
HYPERBOLIC TANGENT TANH(X) = EXP(-
TANH (X)= EXP( - X)/(EXP(x) + EXP
XIIIEXP(xl+ EXP
1- x))"2+ 1
HYPERBOLIC SECANT
HYPERBOLIC SECANT SECH(X)
SECH (X) =
= 2/(EXP(X)
2J(EX P(X) +
+ EXP(
EXP( -
- X)}
X))
HYPERBOLIC COSECANT
HYPERBOLIC COSECANT CSCH(X)
CSCH(X) =
= 2/{EXP(X)
2J(EX P(X) -
- EXP(
EXP( -
- X))
X))
HYPERBOLIC COTANGENT COTH(X)=EXP(-X)/(EXP(X)
COTH (X) = EXP( - X)I(EXPIX)
-EXP(-X))"2+1
- EXP(- X))·2+ 1
INVERSE
IN VERSE HYPERBOLIC SINE ARCSINH(X)= LOG(X + SQRIX
ARCSINHIX)= LOG(X+ SQR(X'X+
· X+ 1))
1))
INVERSE HYPERBOLIC COSINE ARCCOSH(X)
ARCCOSH(X)== LOG(X
LOG(X +
+ SQRIX
SQR(X"· X
X -- 1))
1))
INVERSE HYPERBOLIC TANGENT ARCTAN
ARCTANHH(X) = LOGI(1
IX) = LOGf(l +
+ X)/(1
X)111 - X))/2
- X))12
INVERSE HYPERBOLIC SECANT ARCSECH(X)
ARCSECH IX) =- LOG((SQR
( - X· X+ 1)+ 1/X)
COSECANT
INVERSE HYPERBOLIC COS ECANT ARCCSCH(X)=
ARCCSCH LOG((SGN(X)"SQR
IX) = LOGI(SGN (X)" SQR
(X*X+1/x)
IX · X+ 11x)
INVERSE HYPERBOLIC
INVERSE HYPERBOLIC COTANGENT ARCCOTH(X)=LOG((X+1)/{X-1))/2
ARCCOTH IX) = LOG(IX + 1)I(X - 1))1 2

138
138

Downloaded from www.Manualslib.com manuals search engine


_

v
APPENDIX II
APPENDIX
PINOUTS FOR
PINOUTS FOR INPUT/OUTPUT
INPUT/OUTPUT DEVICES
DEVICES
This appendi
This appendixx isis designed
designed to
to sh
show you what
ow you what connec
connections may be
tions may be made
made to
to
the Exec
the Executive 64.
utive 64.
1)1) Game
Game 1I/O
/0 4)
4) Serial /0 (Disk/Printer)
Serial 1I/O (Disk/Printer)
2) Cartridge Slot
2) Cartridge Slot 5)
5) Modulator
Modulator Output
Output
3) Audio/Video
3) Audi ol Video 6) User Port
6) User Port

Control Port
Control Port 1
1

Pin
Pin Type
Type Note
Note
11 JOYAO
JOYAO
22 JOYA1
JOYAl
33 JOYA2
JOYA2
44 JOYA3
5 POT AY
POT AY
66 BUTTON A/LP
sunON A1LP
77 + 5V
+5V MAX.
MAX. 50mA
50mA
8 GND
9 POT AX
POT

1 2 3 4 5
o 0 000

o 0 o 0
6 7 8 9

Control
Control Port
Port 22
Pin
Pin Type
Type Note
Note
11 JOYB0
JOYSO
22 JOYB1
JOYSI
33 JOYB2
JOYS2
44 JOYB3
JOYS3
55 POT
POT BY
BY
66 BUTTON
sunON BS
77 + 5V
+5V MAX. 50mA
MAX. 50mA
88 GND
GND
99 POT
POT BX
SX
v
v
v

v 139
139

Downloaded from www.Manualslib.com manuals search engine


Cartridge
Cartridge Expansion
Expansion Slot
Slot
Cartridge Expansion
Cartridge Expansion Slot
Slot
Pin
Pin Type
Type Pin
Pin Type
Type
11 GND
GND 12
12 BA
BA
22 + 5V
+5V 13
13 DMA
DMA
33 + 5V
+5V 14
14 D7
D7
44 IRQ
IRQ 15
15 D6
D6
55 R/W
R/W 16
16 D5
D5
66 Dot Clock
Dot Cl ock 17
17 D4
D4
77 I/O 11
I/O 18
18 D3
D3
88 GAME
GAME 19
19 D2
D2
99 EXROM
EXROM 20
20 D1
D1
10
10 I/O
I/O 22 21
21 DO
DO
11
11 ROML
ROML 22
22 GND
GND

Pin
Pin Type
Type Pin
Pin Type
Type
A
A GND
GND N
N A9
A9
B
B ROMH
ROMH P
P A8
A8
C
C RESET
RESET R
R A7
A7
D
D NMI
NMI S
S A6
A6
E
E S 02
S02 T
T A5
AS
F
F A15
A15 U
U A4
A4
H
H A14 V
V A3
A3
JJ A13
A1 3 w
W A2
K
K A12 X
X A1
A1
L All
A11 Y
Y A0
AO
M
M Al0
A10 z
Z GND

I ::::::::::::::::::::::
xIZ Y
r W \I U T S"';> N III L!( J H F
XWVUTSOPNMIKJHF DC B A
EDCBA
E
I

140
140

Downloaded from www.Manualslib.com manuals search engine


'-" Audio/Video:
AudiolVi deo' 8 Pin
Pin Type Note
11 LUM/SYNC
LUM /SYNC Luminance/SYNC
Luminan (monocio) output
ce/SYNC (monoclo)
2 GND
3 AUDIO OUT
4 VIDEO OUT Composit signal output
v 5 AUDIO IN
6 COLOR OUT Chroma signal output
7 NC connection
No connection
88 NC No connection

v
v

Serial
Serial I/O

Pin
Pin Type

11 SERIAL SRQIN
2
2 GND
3
3 SERIAL ATN IN/OUT
IN/O UT
4
4 SERIAL CLK IN/OUT
w
5
5 SERIAL DATA
DATA IN/OUT
6
6 RESET
RESET

v
v

141
141
v
Downloaded from www.Manualslib.com manuals search engine
User 1/0
User I/O

Pi n
Pin Type
Type Note
Note
~
11 GND
GND
22 + 5V
+5V MAX. 100mA
MAX.100mA
3
3 RESET
RESET
4
4 CNTl
GNTI
5
5 SP1
SP1 -
6
6 CNT2
GNT2
7
7 SP2
SP2
B
8 PC2
PG2
9
9 SEA. ATN
SER. ATN IN
IN
10
10 9
9 VAC
VAG MAX. 100mA
MAX.100mA
11
11 9
9 VAC
VAG MAX.
MAX. 100mA
100mA
12
12 GND
GND

Pin Type
Type Note
Note
A
A GND
GND
B
B FLAG2
C
G PBO
PBO
D
D PB1
-
EE PB2
F
F PB3
PB3
H
H PB4
JJ PB5
K PB6
L PB7
M
M PA2 —
N
N GND

1 2
12 3
3 ..4 5 6 7
7 8 9 10 11 12
12

::::::::::::
ABC 0 E F H J K L M N
ABCDEFHJKLMN

142
142

Downloaded from www.Manualslib.com manuals search engine


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 pr i nt"~jctto
Dr nffljotto JjiM
i «• butt~rfi~ld'l
butterf i *l d"
120 inpuf'Puant
input"f' wanl iinstructions";z*:ifasc<zS>=7SgDto250
n st r uctions";o::i : i fasc( ;;:t ) =78got o250
130 print"~t ry
prinf'Ptry gu~ss the
to gue-ss th~ mystery
Myst~ry 5-\~tt~r
5-letter word"
word"
140 print "~y ou
pr i nf'Syou 9u~ss only
must guess on ly Il ~gal 5-1.tt~r"
egal 5-letter"
150 prinfwords,
print"words, tootoo..."
••• •·
160 pr i nf'you will be-
print"you the number
b~ told th+ nUffib~r of
Df matches"
matches"
170 pr i nt"(or 'jots')
print"(or guess."
' Jots ') of your gu+ss."
130 prlnt"flhlnt:
180 prinf'Phint: UII;'
the trid.
trick iiss to lIarl,}
vary sligrltly"
slightly"
190 print"
print" from on~
frOM gu~ss to the
one guess th~ next;
n~ x t; so that"
that "
200 print" iif gu~ss 'balet-,'
you guess
f 'jOll 'batch' and get 2 jots"
210 print"
print" might try 'bolch'
you Might 'botch' o or 'chart'"
r 'char t' "
220 print"
print" for
fo r the
th~ nne>:t
e xt guess..."
gU~5S • •• "
250 data bxbsf,ipccz,dbdif,esfbefpggb«
bxbsf.rpccz.dbdif,esfbe,pqgbM
hpshf, ibud
260 data hpshf. i bud i ,d
, d.ju
j l.l jj llll,kp
« , kpmmz
rflll'l:L.,, It,z
Ibzblb\
270 data sbkbisbkbi,infwfm,njnjd,boofy,qjqfs
,llIIfwfm.njn j d,boofy , qjqfs
230
~SO data rrvftu,sjwfs,gsfttrpuufs.fwfou
vft u,s j wfs,qsftt,puufs . fwfou
29
2900 data wfb ;<fbuf,fyupni,nvtiz,afcsb,gjaaz
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
310 data cPPu cppui~.M , inzjoh,trvbu,hbvaf,pxjoh
z j oh,tr v bu.hbvaf,p x joh
320 data ulsff,tjhiu
uisff,tjhiu,bynft,hsvnq,bsfob
. bYhft.hsvnq,bsfob
330 data rvbsu,dsffq,cfmdi,qsftt,tqbsl
rvbsu.dsff':',cfMdi ,qsftt.tqbsl
3A0
340 data sb~bs.svsb~,t
sbebs.svsbmrtnfinnifgsp>:or*s.jgu
n f~M,gsp x O,e Sj 9U
■100
400 nn=50
= 50
■ilO dim
410 d i M n$(n),z<5),y(5)
nS ( n ) ,~ ( 5),y ( 5)
420 for j=ltj = 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
500 g=O:nt=n*(rnd(l)*n+l)
g=0 :nt =n t Crnd( 1 1*n+ l )
510
510 print "Pi " ~i have
hav~ a five I~tt~r word:":ifr:0goto560
f iv p letter word :": ifr ~ Ogot oS60
520 print
520 print "guess
"gu~ ss (with ( wit h legal wor ds)"
l ~ga t words)"
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, "
550 pr i nt "you
print " you have...."
have . . . . "
560
560 g=g+l:input "your " you r word";zS
word "; zS
570 if
570 If len < z* )) '■~ >■ Sthenpr
\.n(zS 5thpn pr iln nf'you
t " you must guess
gu~ss aa
5-letter
S-l~tt~r word!":goto560
word ~" :gotoS 60
5S0
S80 v=0:h=0:m=0
v=O:h=O:m=O
590
590 fDrj=lto5
forJ=lto5
600
600 z=asc
z ( ~id S (z ' .j,l»
= asc(«id«(zi,j,l)):y : y=asc(0Id S ( n S ,j.l
= asc(inid«<nt,j 1 )-1:ify
,1))-1: = 64theny
ify = 64th~ny =
=990
610
610 iIfz ( 650r= > 90th~ npr il nt"
f z*.65orz>90thenpr nt "that·s
that' s not
not a
a word '~"" ::goto560
uord goto560
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 i.fv
fv==Oarv=5thenpri nt "come
0orv=5thenc-r i nt "coM O? an .. what
on..what kInd
kind af
of
a
a uord
ward is
is that?":goto560
that ?" : gato56 0
670
670 fo r
for j=lto5:y=y(j>
j=lto5 :y= ~(j)
680
6S0 fo r
for kk=lto5:if4=Z(kltl"l.nh=~,+1::<". ) = O :got o700
= 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 "
v 720
72 0 iI fg<30goto560
fg <30goto560
730
7 30 pr i nt " !I ''d
prtnt" d-bet tf-r
. t,o?tt~r tell
tpll you.,
yo u . . word
word was
was '";
v
143
143

Downloaded from www.Manualslib.com manuals search engine


~

7 40 forj-Ho5:pr
7 40 fo r J=lloS :prlnl chr i ((yeJ»
i ntchr* y ( j ) ) ;;: n@ x t J
:n*>:tj
7 50 pr
750 prlnt
mt "" ':golo810
:gotoS10
s ao pr
300 print"ljou
i nf'you got qot it It inI n only"j
o n l 'J ";g;",]W?Ss ... s . "
g;"guesses."
Input"~anoth~
3 10 in
S10 puf'S anotherr word" ~ord " gz*
;=i
r=l:i
82 0 r=l
S20 : i ff asc
asc (( z«
zt) ~ } 7Sgo
)'.> 78 goto5
toSOO 00

1 r€'tll
re in "'' ':0-
*** SE'OUE'nc ...
stouenc?
22 r€-tll
ram
.
... ,. from
3
3
4
4
r*w
r"'H1

5 r^-ni
re la *- *
r"'/Il
.....
r @nI * " co
***

66 rr •=■... mtll s,,~


> *- 5of

K « man
f rO DI pet
soft~ar
l ,o:: 371
t· o t'O::
mont t gogOtA",r
371
mer u
u s ... r group
r'''' t. user
tusre... •?
orout,
@>:):c:t,an'1o<-
c h a n >j e

lJ vv iI 11
I 1©0:- .• pa
00 1S 936
18936
77 re rE'(11
in
bO ~O dim d I to a$(26> a t e 26)
100100 r*a"abcd«-fghi
= S="abcdE'fg h i iif:k linnor-qrstuvw:;u~" It(j n or,qrsl u v ,", ~:u=''
11 0 zl$
110 zIS = =""12345678901234t.67S90123456"
1 234567890 1 ~3 4 ~67390 1 ~3456"
200~OO print"3PPenter
prlnt"'~~€-nt -? r length ' ... ngth of of string
s trIn g to t o be
bE' ss-aue-ncedP"
s ... a u ~nCE'd~"
220~20 int,ut ""Ma
incut >: iIIIlU
in 3 >; in u mtll length
l ... nath 15 I S 26
26 "-.
" i s'/.
s?'
2SQ~30 If sm/.<A
if s% < l or or eX s% ~ 26 ~6 then th ... n 200200
22 44 00 s=sX
S= 57-
300 for
300 f or i=l I =1 to to 5s —
3 10 a*<
310 a"I)=toIJt.(::t
i)=mid«(zt.i,1) . l.l )
320 next
320 n ... ::t i m
4 00 rein
400 r eto randomizerandOtol ::e string s t r I ng
4:00 for
420 f o r i=l 1=1 to to 5s fM
4 30 k=int(rnd(1>»S+1)
430 f: =lntC rnd ( l )rs +l)
44 0 tt=st(i)
440 t"= a t ( I ) —
450 ate at<i)=at(k> I )=ato.)
1,60 a to. )=t t
4 70 next
470 nO? i:t Ii
480 gasul,
1,80 gosub 'f~O ?50 —
~Y;:j t=0
595 l;O
600 rrein
600 ... m rreverse... v ... rs ... substrIng
substr i no r"»
605
6 05 t=t. t=i+l +l
6610
10 Iinput nt,ut "IIOw "Now ',lan many ';! 1..0
lo r' €-v",rs-? "";rX
r*-v>?r$t? ; riC ,-«,
620 If i f r% rX-0 =O goto gotu 900
630 If if r7. rZ>0 ~O a andn d riC rX , =s goto ooto 650 ^
640 orlnt orint "toust "must be bet w...... n 11 and "is
b~ between ";s:: go to 6610
goto 10
650 r=lnt(rZ
r=int(rX/2) /:!) ^
660 for 1=1 to rr
70 U
6670 tt =a = st< t e i) i ) -.
680
6S0 at(, att i )=a i (r7.- 1 +1)
>=3*(r%-i+i>
6YO
6V0 a at s (rr.-I+
Cr%-i + } 1 )=t
J=lt t ^
700 nne^.t o? ), t Ii
I~{l
750 90Sll~'
gosub "'~O
950 ^
800
^00 c=c=l: l: for II»2 ':~ to s
8£10
10 If
if a t (!l >a t.( I - I ) goto 8SiO
3*(i)>3t(i-1) 050
820
S20 cc=0 =0
830
S30 nne;:t
... ~: t Ii
8840
40 If
if c =O goto 600
c=0
850
S50 pcrint
r I nt "~ ~ou did
"0gou did it In
in "~ i t;" ~ triPS"
";t;" tries"
YOO
V00 r",M
re« cho:-cf:check for for an oth~r gaM'"
another game
9910
10 Input
incut "~~ant "flwant to lo play
day agaagainIn ";4"; ut '
y20
'120 'if
f lleft* (ut.
... ft i Cu i.I1 )="IJ"
) = "ij" or 'Jy«="ak"
t ="I')I-\" or yy*t ="
= "l" goto
1 " ooto ~O
200O
930
930 o:-nd
end
9~0
950 ,.r
print I nt
960
960 print lleft»(zlt.5l~ft t(zIS. s)
970
'i/o ffor
o r 1= i=l1 to ss:: e,rlnt
print a8*(iJiine>lt
i (ll ; : n E'>: t Ii
9S0 [,r
9BO print
I nt ""B"
fI "
9'10
9V0 rreturn
... turn (^

ThIS
This pr o ~r im (Oullesy
program of G~
touitesy ot ne Du
Gene ls
Deals l^,

144
144

Downloaded from www.Manualslib.com manuals search engine


90 PHI
:?(. PEM F-! PIRHO
At '0 ft E','E:(IAF'(I
EVBORFD
v 100
100 print's
P RIIIT " ~ ~ a ~Jsi ~J«j !i ~jn ~ ai ~ v\ Ii ~I 'i ~ n Ii lm~ ~ni ••'■
110 F'PItIT"
1\(' PR1HT" ~~ ;) I!I
i<l ~31J II Hi'l I!.I
!•_! fit
H ii ~J r<_< ~J
''I I1 I~I
iig ?.!
.I "
v 12Q PRIlIT"
120 print11 :1 :j {lJ
m Jt'j
lj Ii H ;t| aj
!J i!Jjj Ii ~Jy :~ :«n Ii I!J
i>j :'y.1 "u
1136 r tIT" ja II II I II I1 II I I1 II I I1 I[""
PRINT11
~· C' PF.:
1140 PRINT"
... 0 PPItIT flQ 11·1
" ;11~' JH IEIE IF"
fPIT IV |UII
IT I"'IU I rio|0|P!@
IP I(!! IJ*f 1If"
T"
150 PF~
150 PRINT" ';PH(E ' F(IP
p)'H.PhCE'
IHT " .!r FOR ·:;.I)LO
SOLO OF' OF: POL
FOLVPHONIC"
'r'F'HOt II (;"
v 150 PRIIIT"
1'::13 PRINT".5J-'F1
.tVFI.F;:. ,F3,F5,F7'
F5.F:- ' C'CTA\/ OCTflVE SELECTION"
E '::·El.ECTII)H"
170
1:-0 PRIHT1'H"F2.F4.F£,Fa'
PF:ItIT"!I'F 2. r-·\ .Fo:: .F B · 1·MRVEFOPM.iV IA V EF(,p r'I .~l' ·

v l!5i?
1:;0 PR1HT"HRMG
PR I I/T"HAti(' 011. Oii - ';ETTil"::;
SETTING UP UP FFEC'UFREQUEHCV TABLE..."
E IIC',' TAE:LE . . . ..
!19@
':.n 3=13*4096+1924iOIMF<26>iDIMf
·;=1~: + -lO :.!.l';+102-1 : [ . r,.,F · ';:: '; ,.- : 011-11 ':25:" C255)
200 FORI=a0TO2SsPOf
FOR I =(tT02'3 : F(' f E ·;:· ... r .-O;NE;:T
ES+I (1 : 'lE: :T
210
.:: 10 F 11=7040
= 7" 1)41) ::FORI=1 FOP. I"" 1 r02':- rO2esF':27-I : F' :;:.:- - I '=F '=F11 t*-5. 5. :?+S+30 ~:O ::F1=F1. '2 rf '-•: 1/
F I =F 1. -::: l.'ll
1': . ::NE::T
IIE::T
v 220
'::1(1 ~: J;= " ('121·' ::EP,:".T';'r':-I.l1 :.:"X';:'I':! -- io ( r"
K*o"iP2W3ERST6V7UI900P@-*£
230
'::::0 FOPI = I1TOLEN'^
FOP! TOLEII-1 -Fr ·■ ::11 ·ff:,(·"lIO ■ FViC f.H tO*> .t ' I'K'*,
r ,r I '>J> >■! aHEXT
· "" t:t tE:: T
240
~ ..W FRINT'TJ
PRHIT":J
250
~=.o FlT=0
HT =0 :jOE=0DE=O : :3U=15 .1..1<: 1 '3 :sRE-S
FE:.:' ::SV=SU+ ';'./.,.';:.1.' + L';loi-REtflVafl^-lS+DE:
loPE : A '.,' ".HT'" 16+C'E :
WV=16sH=0
(·IV = I';' : ! j=O ::M=I 1'1 ", i ::0C=4
1)( :::4 :iHB=25t;:
L;E:=': ':..:: : .:-'"->"
2S9
~.:. O FOR I "OT
FOR! =9T02 ')2 ::POKES+5+I
F (lIE ':: - ,:.+ I t*7 7 .-flT*l€+DE
riT t I';' .. DE ::P0KES+6+I*7
POLE ': ... 6+ I ;. 7 '- ::SU+lS-i-RE
I) " l';.,F E
:270
71) POkE" : .... ';:': .,. I +7 •-4000HND255
POKES-t-2-t-£*? 4(u)(,t=it 10255 ::Fi> POI E'; ES+3-*-I*7
... ;:.,. I .. :- •-4000. r25t" ::HEi
4(\(":0. ''::50::: I IE: :T IT
2S0
'=: G~ ~) POKES+24
PQK E·: .... .: 4 •. 1 15sREM+16*-64
'5 : PEr·l ~ 1 .; .... ,:: .~ ::POt ES+23
F 0 1 E';:. +.=:-::: •-77
300
:;:00 GETR4:IFfl*=""THEH300
(,ETA t : I FAr"." "THEil:'':'')
310
3 1') FR=F>' K'
FR",F k- ~SC fliC'fll) · A.t: , .■ '. ■.1H:T=V-f7:CF=r5-<-T+4
'H : T = ..... .. 7 : CF' .. ·; .. T ....\ ::1J F FFP=ZTWEM500
FF' ::::THEII':.('O
v 2-20
:;:.~ O POKEs+^vT.ZiPEM
POKE:c_ .. .£. .. T ,: : FE!,' F r 1/ I ·;. H DEC.
FIHI1H DEC'iU'i ',,: u·;
325
3~ 5 P0KES+5+T,ZjREM
?OI'r ; .. 5·.. T .: : ?El-l FFIMI5H It I r ·::.H flTT/REL
ATT. '!='EL
v 330
::::0 P0KECR,S:P0kECR,3:REM
POKE ( P ,:::: : POh.EC P • (\ : F'EI-! F FIX I:' (OFF IF F
34Q
3·'1) PCKES+T.FP-HBfIHT-"FR.-'HE.'
POI,tE '; ... T .FP-He· " ltIT· FF! . "HI::· :;PEH PEt'l ':::ETSET LO LO
3S0
J5(' POKES+1
POV E ·: .+l t-T .FP.'HB
.. T .FP. ·HE: ::PEM F·E/-l ·;·ET SET HI
360
30;
:0 POKES+&+T,SViREM
POVE·;+,; ... T . ·3··... : FEtl SET ;ET DEC. "SUS
DE':. ":;1)-;
365
>;-5 POKES+S+T,flV;FEM
;::")1 E ·;+5 ... T .1'1'. / : FElt ':SET ET flTT/REL
ATT. 'FEL
370
?7(1 P0KECP..MV+1
POt E CP .ltl'·... + 1 :F0RIh1T0SO*HTiNEXT
: F (lr. I", 1 T050 + HT : t IE :: T
375
;'75 POKECR,WV:REH
P')I E(P. J..j'·/ :FE t-l FI)L': PULSE E
3S0
:'::::1) I F ? = 1THEtl'·/ ....·' ~ 1 : ! r '·..'", ~: THE II'.,i= ')
IFP=1THEHV=V+1:IFV=3THENV=0
400
.11)(, GOTO
I:;OT(' 300:;;'(11)
v
500
5(11) IFhJ="S"THE1
IFA ..: = " ii " THE I 11' !E-1=1
1 = 1 :0C=4
: (n: ",4 :G0T03S0
: (·(lTI):2(")
5
51 (. IR=2!0C=3
J FA:t= " ~ " THEI Ht;.:. : (n: :=:.~: :OOTHi : (,OTI):100 00
,:. ~ (\ J FA .! :" II" THEI If·I=·1 M=-1 :0C-2: ,)(::.=: :OOT03G@
: (·OTI)~ ('0:'
'3:::0 I FA:t;;"II"TI-IEtU·l =-8 ",·; :OC
: 0)(,:, : (,')T');'(":'
= l[ :G0T030G
54@
':.-I\) IFPiS
I FAx",, = "3"THEHl-J=0
" !t" THEt n-l=~:' iWV=lw : (.O T'):; ,:.,=.
:~J''''= i':· sG0T0300
530
55(' IIFAI="
FRJ= "K" .\: "T THEt
I-I E tH (Ua I,. Il :: UV=
l l ·.'=:2 ?2 :: GO(.o TO SCO
r .:I:;·(Il)
559
5-=0 IFH**"M"THEHW=£:NV=e-4 :':'('j.:.:;.:,,:o
IFH.r= " ~ " T J-. E t!Ll =':: ; 1·\'/= ':: .. :G0T030'3
570
':,";"0 IFh-C="
1 F~ r= " B"THENW=3jUV=!128
tI " THEtal= :; : \·1\·' = i ,:: .3 : GOTO
(.I)TO:<:500 O:II)
580
5'~ IJ IFR*ss"
rFA I:::" "THEIiP=l-P
"THEliP ",I-P :G0T0JO0 : (,I)T':':.(u)
'3::...:.
590 IFfl*»"3"THEH2S0
I FA .r o>" ;]" T!1Et I~ ('(o
v 500
~.•:1\) GOTO
':.O T(' 500
~:(.n
:.:.>:.
:;:■:»-« PPIHT"HIT
P ~· ttIT"HIT fl
~ VI EV"
E',"
v S10
:;: \ 1) L-ETR-t:
('E TI;~ : [FH.r = ""THEIi.5lij
rF~l.r", ""jHE!;;I':' :l-iflIT
: I·j "';iT FOP
F('F hi
~ , Ij EV
E'?'
>20
-;'::0 PPIMTftf:RETURN
F·PIHT,.; . : f.ETI .IFil

NOTES:
NOTES:
Line
Line 100
100 uses
uses (SHIFT
(S H IFT CLR(HOME).
CLA /H OME). Line 530
Line u ses (17)
530 uses (17)
(CTRL
(C TAL 91.1CTRL
9).(C TAL )).(SHIFT
)).(SHIFT B).
B). Line 540
Line u ses (12)
540 uses (12)
Line
Line 150
150 uses
use s (CRSR
(CASA DOWN)
DOWN ) Line 550
Line uses (II)
550 uses (1 4)
Line
Line 240
240 uses
uses (CRSR
(CASA UP)
UP) Line 560
Line u ses (f6)
560 uses (16)
Line
Line 500
500 uses
uses (11)
(11) Line
Li ne 570
570 uses
uses (f8)
(18)
Line
Line 510
510 uses
uses (13)
(13) Line
Line 590
590 uses
uses (SHIFT
(S HIFT CLR/HOME)
CLA /HOME )
v Line
Line 520
520 uses
uses (151
( 15 )

145

Downloaded from www.Manualslib.com manuals search engine


APPENDIX KK
APPENDIX
CONVERTING
CONVERTING STANDARD
STANDARD BASIC
BASIC PROGRAMS
PROGRAMS
TO
TO EXECUTIVE
EXECUTIVE 64
64 BASIC
BASIC
IfIf you
you have
have programs
programs written
written in
in aa BASIC
BASIC other
other than
than Commodore
Commodore BASIC,
BASIC,
some
some minor
minor adjustments
adjustments may
may be
be necessary
necessary before
be fore running
running them
them on
on the
the 64.
64.
We've
We've included
included some
some hints
hints to
to make
make the
the conversion
conversion easier.
easier.

String Dimensions
String Dimensions
Delete
Delete allall statements
statements that that are
are used
used to
to declare
declare the
the length
length of
of strings.
strings, AA state
state,
ment
ment such
such as as DIM
DIM AS(IJ).
A$(I ,J), which
which dimensions
dimensions aa string
string array
array for
for JJ elements
elements oiof
length
length I,I, should
should be be converted
converted to to the
the Commodore
Commodore BASIC BASIC statement
statement DIMDIM AS(J).
AS(J),
Some
Some BASICS
BASICs use use aa comma
com ma or or ampersand
ampersand forfor string
str ing concatenation.
concatenation, Each
Each of
of
these
these must
must be be changed
cha nged to to aa plus
plus sign,
sign, which
wh ich isis the
the Commodore
Commodore BASIC BASIC
operator for
operator for string
string concatenation.
concatenati on.
In
In Commodore
Commodore 64 64 BASIC,
BASIC, the the MIDS,
MIDS, RIGHTS,
RIGHTS, and
and LEFTS
LEFTS functions
functions areare used
used
to
to take
take substrings
substrings of
of strings.
strings, Forms
Forms such
such as
as A$(1)
AS(1) to
to access
access the
the Ith
Ith character
character in
in
A$,
A$ , or
or A$(I.J)
A$(I ,J) to
to take
take aa substring
substring of
of AS
A$ from
from position
position II to
to J.
J, must
must be
be changed
changed as
as
follows:
follows:

Other
Other BASIC
BASIC Commodore
Commodore BASIC
BASIC
A$(l)
A$(I) = XS
X$ AS = LEFT$(A$,l-1) + X$+MID$(AS.I
LEFT$(A$,1- 1)+X$+MI + 1))
D$(AS,I+1
A$(I.J)
A$(I,J) = X$ AS
A$ = LEFT$(A$,1-1)+X$+MID$(AS,J + 1)
LEFT$(A$,1- 1)+ X$+ MID$(A$,J 1)

Multiple Assignments
Multiple Assignments
To set B
B and C equal zero, some BASICs
equal to zero, BASlCs allow statements of the form
form::
10 LET B
B =
= C =
= 0
Commodore BASIC on the 64 would interpret the second equal sign as a
logical operator and set B = --11 if
If C 0. Instead,
C = 0, Instead, conve
convert this
rt th to:
is statement to:
10
10CC = 0: B = 0
0 : B 0

Multiple
Multiple Statements
BASICS use
Some BASICs use aa backslash
backslash (/) to separate multiple
multiple statements on a line.
line.
With Commodore
With Commodore BASIC,
BASIC, separate allall statements by
by a
a colon
colon (:).

MAT
MAT Functions
Functions
Programs using
Programs using the
the MATMAT funct
functions available on
ions available on some
some BASICs
BASICS must
must be
be
rewritten using
rewrillen using FOR
FOR ...
. . . NEXT
NEXT loops
loops to
to execute
execute properly.
properly.

146
146

Downloaded from www.Manualslib.com manuals search engine


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
pecting numeric data.

BAD
BAD SUBSCRIPT The program was trying to reference
reference an element of an array
is outside of the range specified in the DIM statement
whose number is statement..

BREAK
BREA execution
K Program execu tion was stopped because you hit the STOP key.
CAN'T CONTINUE ThThe CONT
e CON will
T command wi not work, either because the pro·
ll not pro
v RUN., there has been an error, or a line has been edited.
gram was never RUN
required
DEVICE NOT PRESENT The req I/O
10 device was not available for an OPEN,
uired 1
CLOSE,
CLOS INPUT#. or GET#.
E, CMD, PRINT#, INPUT#,
DIVISION BY ZERO Division by zero is a mathematical oddity and not allowed.
v loan
EXTRA IGNORED Too many items of data were typed in response to an INPUT
statement. Only the first few items were accepted.
FILE NOT FOUND No file with that name exists.
FILE NOT OPEN Th The
e file
fi le specified in a CLOSE,
CLOSE, CM
CMD. INPUTS,, or
D, PRINT#, INPUT#
GET#, must first
GET#, lirst be OPENed.
OPENed .
FILE OPEN An attemp
attemptt was made to open a
a file using the number of an already
open file.
FORMULA TOO COMPLEXCOMPLEX The string expression being evaluated should shoul d be
split into at least two parts
two part s for
fo r the system
sys tem to work with,
wi th, or a formula has too
many parentheses.

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.
ILLEGAL
ILLEGAL QUANTITY
QUANTITY A A number used
used as the
th e argument of
of aa function or
or statement
v is
is out
ou t of
o f the
the allowable
allowab le range.
range .
LOAD
LOAD There
There is
is aa problem
problem with
with the
the program
program on
on disk.
disk.
MISSING
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
v 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
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·
ing
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
FOR
FOR statement.
statement.
NOT
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
was
was specified
specified to
to be
be for
for output
outpu t only.
only.
NOT
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
v specified
spec ified as
as input
input only.
only.

147
147

Downloaded from www.Manualslib.com manuals search engine


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
allowed, 884E + 38.
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,
ten, and any subsequent DI Ms will
DIMs will
cause this error.
REDO FROM START Character data was typed in during an INPUT statement
when numeric data was expected. Just re·type
re-type the entry so that it is correct,
correct, and
the program will continue by itself.
RETURN WITHOUT GOSUB A RETURN statem
statement encountered, and no
ent was encountered,
GOSUB command has been issued.
STRING TOO LONG A string can contain up to 255 characters.
7SYNTAX ERROR A statement is unrecognizable by the 64. A missing or extra
?SYNTAX
parentheses,
parentheses, misspelled keywords, etc.

time.
TOO MANY FILES You tried to OPEN more than 10 files at one time.
in place of a string,
TYPE MISMATCH This error occurs when a number is used in string,
or vice-versa.
vice-versa.

UNDEF'D FUNCTION A user defined function was referenced, but it has never
UNDEF'D
been defined using the DEF FN statement.
UNDEF'D
UNDEF' D STATEMENT An attempt was made to GOTO or GOSUB or RUN a
line number that doesn't exist.
VERIFY The program on disk does not match the program currently in memory.

148

Downloaded from www.Manualslib.com manuals search engine


APPENDIX M
APPENDIX M
MUSIC NOTE
MUSIC NOTE VALUES
VALUES
This appendix
This appendix contains
contains aa complete
complete list
list of
of Not
Note#, actual note,
e#, actual note, and
and the
the values
values
to be
to be POKEd
POKEd into
into the
the HI
HI FREQ
FREQ and
and LOW
LOW FREQFREQ registers
registers of
of the
the soun
sound chip
d ch to
ip to
produce
prod the
uce th indicated
e ind note.
icated note.

MUSICAL
M NOTE
USICAL NOTE OSCILLATOR
OSCIL FREQ
LATOR FREQ
00 C-0
C·O . 268
268 11 12
12
11 C#-0
C#·O 284 11 28
28
2 0D-0
·0 301 11 45
u 3 0D#-0
#·0 318 11 62
4 E-0
E·O 337 11 81
81
5 F-0
F·O 358 11 102
102
6 F#-0
F#·O 379 11 123
123
7 G-0
G·O 401 11 145
88 G#-0
G#·O 425 11 169
99 A-0
A·O 451
451 11 195
195
10 A#-0
A#·O 477 11 221
11 B-0
B·O 506 11 250
16 C-1l
C· 536 2 24
17 C#-1
C#·1 568 2 56
18 D-1
0 ·1 602 2 90
19 D#-1
0 #·1 637 2 125
20 E-1
E·l 675 2 163
21 F-1
F·l 716 2 204
204
22
22 F#-1
F#·l 758 2 246
23 G-1
G·l 803 3 35
24
24 G#-1
G#·l 851 3 83
25
25 A-1
A· l 902 3
3 134
134
26
26 A#-1
A#· l 955
955 3
3 187
187
27 B-1
B·l 1012
1012 3
3 244
244
32
32 C-2
C·2 1072
1072 44 48
48
33
33 C#-2
C#·2 1136
1136 44 11
112 2
34
34 D-2
0·2 1204
1204 44 180
35
35 D#-2
0 #·2 1275
1275 44 25 1
251
36
36 E-2
E·2 1351
1351 55 71
71
37
37 F-2
F·2 1432
1432 55 152
152
38
38 F#-2
F#·2 1517
1517 55 237
237
39
39 G-2
G·2 1607
1607 66 71
40
40 G#-2
G#·2 1703
1703 6 6 167
167
41
41 A-2
A·2 1804
1804 77 12
12
42
42 A#-2
A#·2 1911
1911 77 119
119
43
43 B-2
B·2 2025
2025 77 233
233
48
48 C-3
C·3 2145
2145 88 97
97

149
149

Downloaded from www.Manualslib.com manuals search engine


MUSICAL NOTE
MUSICAL NOTE OSCILLATOR
OSCILLATOR FREQ
FREQ
49
49 C#-3
C#-3 2273
2273 88 225
225
50
50 0-3
D-3 2408
2408 99 104
104
51
51 0#-3
D#-3 2551
2551 99 247
247
52
52 E-3
E-3 2703
2703 10
10 143
143
53
53 F-3
F-3 2864
2864 11
11 48
48
54
54 F#-3
F#-3 3034
3034 1111 218
218
55
55 G-3
G-3 3215
3215 12
12 143
143
56
56 G#-3
G#-3 3406
3406 13
13 78
78
57
57 A-3
A-3 3608
3608 14
14 24
24
58
58 A#-3
A#-3 3823
3823 14
14 239
239
59
59 8-3
B-3 4050
4050 15
15 210
210
64
64 C-4
C-4 4291
4291 16
16 195
195
65
65 C#-4
C#-4 4547
4547 17
17 195
195
66
66 0 -4
D-4 4817
4817 18
18 209
209
67
67 0#-4
D#-4 5103
5103 19
19 239
239
68
68 E-4
E-4 5407
5407 21
21 31
31
69
69 F-4
F-4 5728
5728 22
22 96
96
70 F#-4 6069
6069 23
23 181
181
71 G-4 6430
6430 25
25 30
30
72
72 G#-4 6812
6812 26 156
156
73
73 A-4 7217
7217 28 49
74 A#-4 7647 29 223
75 8-4
B-4 8101 31 165
80 C-5 8583 33 135
81 C#-5 9094 35 134
82 0-5
D-5 9634 37 162
83 0#-5
D#-5 10207 39 223
84 E-5 10814 42 62
85 F-5 11457 44 193
86 F#-5 12139 47 107
107
87 G-5 12860 50
50 60
88 G#-5 13625 53 57
89 A-5 14435
14435 56 99
90 A#-5 15294
15294 59 190
190
91
91 8-5
B-5 16203
16203 63 75
96 C-6 17167
17167 67 15
15
97
97 C#-6 18188
18188 71
71 12
12
98 0-6
D-6 19269
19269 75
75 69
69
99
99 0#-6
D#-6 20415
20415 79
79 191
191
100
100 E-6
E-6 21629
21629 84
84 125
125
101
101 F-6
F-6 22915
22915 89
89 131
131
102
102 F#-6
F#-6 24278
24278 94
94 214
214
103
103 G-6
G-6 25721
25721 100
100 121
121
104
104 G#-6
G#-6 27251
27251 106
106 115
115
105
105 A-6
A-6 28871
28871 112
11 2 199
199
106
106 A#-6
A#-6 30588
30588 119
119 124
124

150
150

Downloaded from www.Manualslib.com manuals search engine


-

MUSICAL NOTE OSCILLATOR FREQ


107 B-6
B·6 32407 126 151
112 C-7
C·7 34334 134 30
113 C#-7
C#·7 36376 142 24
114 D-7
D·7 38539 150 139
115 D#-7
D#·7 40830 159 126
v 116 E-7
E·7 43258 168 250
117 F·7
F-7 45830 179 6
118 F#-7
F#·7 48556 189 172
119 G-7
G·7 51443 200 243
120 G#-7
G#·7 54502 212 230
121 A-7
A·7 57743 225 143
122 A#-7
A#·7 61176 238 248
123 B-7
B·7 64814 253 46

SETTINGS
FILTER SETIINGS

Location Contents
54293 (0-7)
Low cutoff frequency (0·7)
v
54294 (0-255)
High cutoff frequency (0·255)
54295 Resonance 4-7)
(bits 4·7)
Filter voice (bitt 2)
3 (bi
Filter voice 2 (bit 1)
v Filter voice 1 (bit 0)
1
54296 High pass (bit 6)
Bandpass (bit 5)
Low pass (bit 4)
0-3)
Volume (bits 0·8)

v
151
151

Downloaded from www.Manualslib.com manuals search engine


APPENDIX N
APPENDIX N
BIBLIOGRAPHY
BIBLIOGRAPHY
Addison-Wesley
Addison-Wesley "BASIC
" BASIC and
and the
the Personal
Personal Computer".
Computer", Dwyer
Dwyer and
and
Critchfield
Critchfield

Compute
Compute "Compute's
"Compute's First
First Book
Book of
of PET/CBM"
PET/CBM "
Cow bay Computing
Cowbay Comput ing "Feed
" Feed Me,
Me, I'm
I'm Your
Your PET
PET Computer",
Computer" , Carol
Carol
Alexander
Alexander
"Looking
" Looking Good
Good with
with Your
Your PET".
PET", Carol
Carol Alexander
Alexande r
"Teacher's
" Teacher's PET —
- Plans,
Plan s, Quizzes,
Quizzes, and Answers"
Creative Computing
Creative Computing "Getting
"Ge ttin g Acquainted
Acquainted With
Wi th Your
Your VIC
VIC 20".
20", T.
T. Hartnell
Hartnell
Dilithium Press
Dilithium Press "BASIC
" BASIC Basic-English
Basic·English Dictionary
Dictionary for
for the
the PET",
PET" ,
Larry Noonan
Larry Noonan
"PET
" PET BASIC".
BASIC" , Tom
Tom Rugg
Rug g and
and Phil
Ph il Feldman
Feldman
Faulk Baker
Faulk Bake r Associates ""MOS
MOS Programming
Programming Manuai",
Manual", MOS
MOS Technology
Technology
Hayden Book
Hayden Book Co. "BASIC
" BASIC From
From the Ground
Ground Up",
Up" , David
David E. Simon
Simon
"1
" I Speak
Speak BASIC to My PET".
PET" , Aubrey Jones,
Jones, Jr.
Jr.
""Library
Library of PET Subroutines",
Subroutines" , Nick
Ni ck Hampshire
Hampsh ire
"PET Graphics", Nick Hampshire
""BASIC Handbook, Apple. TRS·80,
BASIC Conversions Handbook, TRS-80, and
PET", David A. Brain, Phi
A. Brain, Phillip
llip R. Oviatt., Paul J.
R. Oviatt
Paquin, and Chandler P.
Paquin, P. Stone

Howard W. Sams ""The


The Howard W W. Sams Crash Course in
Microcomputers", Louis E. Frenze
Microcomputers", Frenzel,l, Jr.
""Mostly
Mostly BASIC: Applications for Your PET",
Howard
Howard Berenbon
""PET Interfacing".
PET Interfacin g", James M. Downey and Steven
M. Rogers
""VIC
VIC 20 Programmer's Reference Guide", A. Finkel,
Finkel.
P. Higginbottom
P. Higginbottom., N. Harris, and M.
M. Tomczyk

Littl e, Brown & Co.


Little, "Computer Games for BuBusinesses,
sinesses, Schools, and
Homes". J. Victor Nagigian
Homes", Nagigian,, and Wi
William
lliam S. Hodges
""The Tutor:
The Computer Tut Learning
or: Learn ing Activities for
Homes and Schools"
Homes Schools"., Gary WW. Orwig
Orwig,, University of
Florida, and William S. Hodges
Central Florida, Hodges

McGraw·Hill
McGraw-Hill ""Hands-On PET".. Herbert
Hands·On BASIC With a PET" Herbert D.
D.
Peckman
Peckman
""Home Use o
Home and Office Use off VisiCalc", D.
D. Castlewitz,
Castlewitz.
and l.
L Chisauki

t52
152

Downloaded from www.Manualslib.com manuals search engine


Osborne/McGraw-Hill
Osborne/McGraw·Hill ""PET/CBM Personal Computer
PET/CBM Personal Computer Guide",
Guide", Carroll
Carroll S.
S.
Donahue
Donahue
"PET Fun
"PET Fun and
and Games",
Games". R.R. Jeffries
Jeffries and
and G.G. Fisher
Fisher
""PET and the
PET and the IEEE",
IEEE", A.
A. Osborne
Osborne and and C.
C. Donah
Donahueue
""Some Common BASIC
Some Common BASIC Programs
Programs for for the
the PET",
PET", l.
L
Poole, M.
Poole, M. Borchers,
Borchers, and
and C.
C. Donahue
Donahue
""Osborne CP/M User
Osborne CP/M User Guide"
Guide",, Thom
Thorn Hogan
Hogan
""CBM Professional Computer
CBM Professional Computer Guide"
Guide"
"The PET
"The PET Personal
Personal Computer
Computer Guide"
Guide"
""The Book"., Russell
The 8086 Book" Russell Rector
Rector and George
George Alexy
Alexy
P. C.
P. C. Publications
Publications ""Beginning Self-Teaching Computer Lessons"
Beginning Self·Teaching Lessons"
Prentice-Hall
Prentice·Hall Personal Com
"The PET Personal Computer Beginners",
puler for Beg inners" , S.
Dunn
Dunn and V. Morgan
Morgan

Reston Publishing
Reston Publishing Co. ""PET IEEE 488 Bus
PET and the IEEE Bus (GPIB)",
(GPIB)". Eugene
Eugene Fisher
Fisher
and C.C.W.
W. Jensen
""PET
PET BASIC -— Training Your PET Computer"
Computer",,
Ramon Zamora, Wm. F. Carrie, and B. Albrecht
""PET Recreation",
PET Games and Rec L
reati on", M. Ogelsby, l.
D. Kunkin
Lindsey, and D.
""PET BASIC". Richard Huskell
PET BASIC",
""VIC Recreation"
VIC Games and Recreati on"
Telmas Courseware ""BASIC T. A.
BASIC and the Personal Computer", T. A.
Ratings Dwyer,
Dwye M. Critchfield
r, and M.
Total Information
Total "■'Understanding PET/CBM. Vol. 1,
Understanding Your PET/CBM, 1,
Services BASIC Programming"
David Schultz
"Understanding Your VIC", David

Commodore
Commodore Magazines provide you with
with the
the most up-to-date
up·to·date information
information for
your Executive 64.
64. Two of the most popular publications
publications that you
yo u should
should
seriously
seriousl y consider
consider subscribing
subscribing to
to are:
COMMODORE
COMMODORE —
- The Microcomputer Magazine is
is published
published bi-monthly
bi·monthly and
and is
is
available
available by
by subscription
subscription {$15.00
($15.00 per
per year.
year, U.S.,
U.S., and
and $25.00
$25.00 per year,
year, worldwide).
worldwide).
POWER/PLAY
POWER /PLAY —
- The Home Computer Magazine
Magazine is
is published
published quarterly
quarterly and
and is
is
available
available by
by subscription
subscription ($10.00
($10.00 per
per year,
year, U.S.,
U.S., and
and $15.00
$15.00 per
per year
year worldwide).
worldwide).

153
153

Downloaded from www.Manualslib.com manuals search engine


APPENDIX
APPENDIX 00
SPRITE
SPRITE REGISTER
REGISTER MAP
MAP

Register
Register
Dec
Dec
#

He,
Hex DBl
D87 DM
D86 DB5
D85 D84
D84 D83
D53 D82
DB2 D81
DBl D80
DBO
00 00 SOX?
SOX7 SOXO
SOXO SPRITE
SPRITE 00 XX
Component
Component

l1 11 SOY7
SOY7 SOYO
SOya SPRITE
SPRITE 00 YY
Component
Component

22 22 SIX?
S1X7 S1XO
SlXO SPRITE
SPRITE 11 XX
SlY? SIYO
S1YO SPRITE
SPRITE 11 YY
33 33 S1Y7

44 44 S2X7
S2X7 S2XO
S2XO SPRITE
SPRITE 22 XX

55 55 S2Yl
S2Y7 S2YO
S2YO SPRITE
SPRITE 22 YY
66 66 S3X7
S3X7 S3XO
S3XO SPRITE
SPRITE 33 XX
77 71 S3Y7
S3Y7 S3YO
S3YO SPRITE
SPRITE 33 YY
54Xl S4XO SPRITE
SPRITE 44 XX
8B 8B S4X7 54XO
9 9 $4Y7
S4Y7 S4YO
S4YO SPRITE
SPRITE 44 YY
9 9

10
10 A
A S5Xl
S5X7 S5XO
S5XO SPRITE
SPRITE 55 X
X
11 B S5Y7
S5Y7 S5YO
S5YO SPRITE
SPRIT E 55 Y
Y
11 B
12 C S6X7
S6X7 S6XO
S6XO SPRITE
SPRITE 66 X
X
12 C
13
13 D
0 56Yl
S6Y7 S6YO
S6YQ SPRITES
SPRITE 6 Yy
E S7X7 SPRITE 7
7X
"
14 E S7XO SPRITE
Component
Component
X

15 F S7Y? S7YO
S7YO SPRITE 7
SPRITE 7 Y
Y
15 F S7Y7
Component
Component
16
16 10
10 S7X8 56XB
S6X8 ssxa
ssxa 54XB
S4X8 S3X8 S2X8
S2XB S1X8
SlX8 S0X8
SOXB MSB 01
MSB of X
X
COORD.
COORD.
17
17 11
11 RCB
RCB ECM BMM RSEL YSCL2 YSCL1
BMM BLNK ASEL YSCLO
Sell VSCLO Y
Y sCROLL
SCROLL
MODE
MODE
lB 12 RCl
RC7 RGG
RC6 RC5
RC5 RC4
RC4 RC3
RC3 RC2
RC2 RC1
RCl RCO
RCO RASTER
RASTER
18 12
19
19 13 lPX7
LPX7 LPXO
LPXQ LIGHT PEN
UGHT PEN X
X

20 lPY7 LPYO
---- -
LIGHT PEN
UGHT PEN Y
Y
20
"14 LPY7

154
154

Downloaded from www.Manualslib.com manuals search engine


Register
Dec
De<:
•tt
Hex D87
087 D86
086 D85
085 D84
084 D83
083 D82
DB2 D81
DBl D80
DBO
21 15 SE7 SEO SPRITE
ENABLE
(ON/OFF)

22 16 N.C.
N .C. N.C. RST MCM CSEL I"SCl2 XSCL1l XSCLO
XSCL2 XSCL X SCROLL
MODE

23 17 5EXY7
EXY7 SEXYO
SEXYQ SPRITE
EXPAND YY

24 l18
B VS13 VS12 VS11
VSll VS10
VSlO CB13 CB12
CB 12 CB11
CBll N.C,
N.C. SCREEN
Character
Memory

25 19 IRQ
lRO N.C. N.C. N.C. ISSC
LPIRQ lSSC ISBC
Isac RIRQ Interupt
Request's

26 1A
lA N.C.
N.C. N.C. N.C.
N.C. N.C.
N.C. MLPI MISSC M1SB(
MLPi I"'SSC MISBC MRIRQ Interupt
Requestt
Reques
MASKS
27 1B
lB BSP7 BSPO Background-
Background·
Sprite
PRIORITY
28 1C
lC SCM7 SCMO Multicolor
Multicofor
SPRITE
SPRITE
SELECT

29 1D
10 SEXX7
EXX7 SEXXO SPRITE
EXPAND XX

30 1E
lE SSC7 SSCO Sprite·Sprite
Sprite-Sprite
COLLISION
31 IF
lF SBC7 SBCO Sprite-
Sprite·
Background
COLLISION

Register #
# Register ##
Dec Hex Color Dec Hex Color

32
32 20 BORDER COLOR 39
39 27
27 SPRITE
SPRITE 00 COLOR
COLOR
3:
33 21
21 BACKGROUND 40
40 28
2B SPRITE
SPRITE 11 COLOR
COLOR
COLOR 0
0
41 29
29 SPRITE
SPRITE 22 COLOR
COLOR
34
34 22
22 BACKGROUND
BACKGROUND
COLOR
COLOR 11 42
42 2A
2A SPRITE 33 COLOR
COLOR

35
35 23
23 BACKGROUND
BACKGROUND 43
43 2B
2B SPRITE 4~ COLOR
SPRITE COLOR
COLOR
COLOR 22 44
44 2C
2C SPRITE
SPRITE 55 COLOR
COLOR
36
36 24
24 BACKGROUND
BACKGROUND 45
45 2D
20 SPRITE
SPRITE 66 COLOR
COLOR
COLOR
COLOR 33
46
46 2E
2E SPRITE
SPRITE 77 COLOR
COLOR
37
37 25
25 SPRITE
SPRITE
MULTICOLOR
MULTlCOLOR 00
38
38 26
26 SPRITE
SPRITE
MULTICOLOR
MULTICOLOA 11

v
155
155

Downloaded from www.Manualslib.com manuals search engine


COLOR
COLOR CODES
CODES

Dec
Dec He,
Hex Color
Color Dec
Dec He,
Hex Color
Color
00 0
0 BLACK
BLACK 8B aB ORANGE
ORANGE
11 11 WHIT E
WHITE 9
9 9
9 BROWN
BROW N
22 22 RED
RED 10
10 A
A LT.
LT. RED
RED
33 3
3 CYAN
CVAN 11
11 B
B GRAY
GRAY 11
44 44 PURPLE
PURPLE 12
12 C
C GRAY
GRAY 22
5
5 5
5 GREEN
GREEN 13
13 D
D LT.
LT. GREEN
GREEN
6
6 6
•■ BLUE
BLUE 14
14 E
E LT.
LT. BLUE
BLUE
77 7
7 YELLOW
YELLOW 15
15 F
F GRAY
GRAY 33

LEGEND
LEGEND
ONLY
ONLY COLORS
COLORS 0-7
0-7 MAY
MAY BE
BE USED
USED IN
IN MULTICOLOR
MULTICOlOA CHARACTER
CHARACTER MODE
MODE

' r.

156
156

Downloaded from www.Manualslib.com manuals search engine


APPENDIX P
APPENDIX P
6566/6567 (VIC-II)
6566/6567 (VIC-II) CHIP
CHIP REGISTER
REGISTER MAP
MAP
The 6566/6567
The 6566/6567 are
are multi·purpose
multi-purpose co color video con
lor video controller devices for
troller devices for use
use in
in
both computer
both computer video
video term
terminals and video
inals and video game
game applications.
applications. Both
Both devices
devices con·
con
tain 47
tain 47 control
control registers
registers which
which are
are accessed
accessed via via aa standard
standard 8·bit
8-bit micro-
micro
processor bus
processor bus (65XX)
(65XX) and
and will
will access
access up
up to
to 16K
16K of
of memory
memory forfor display
display informa·
informa
tion. The
tion. The vari
various operating modes
ous operating modes and
and options
options within
within each
each mode
mode areare described.
described.

ADDRESS
ACO I US D&7
001 DB6
0" DBS
0" DB4
08' DB3
Oil 0DB2
82 DB1
0"' DBO
0'0 OESCII,-rION
DESCHIPTION

00
00 ((100)
$00) M0X7
MOX7 M0X6
MOX6 M0X5
MOX5 M0X4
MOX" M0X3
MOX) MOX2
M0X2 MOX
M0X1I Moxa
MOXO MOB
MOB 00 )(X-po»ition
, OOIlI;on
01
01 (SOD
(SO l) M0Y7
MOV7 M0Y6
MOY6 M0Y5
MCYS M0Y4
MOY" MOY)
M0Y3 MO'(2
M0Y2 MOV
M0Y1I MOYO
M0Y0 MOB
MOB 00 Y'CMu rl ion
Y-poiition

02
0' (S02)
(S0 21 M!X7
MIX] M1X6
MIX6 MIX5
M l ;J(5 M1X4
M I X" MIX]
M1X3 MIX2
M1X2 MIX
M1X1I M1XO
MIXO MO
MOBB 11 X- PO l llio n
X-povtion
03
0' (103))
(SOJ M1Y7
M 1Y7 M1Y6
MIY6 M1Y5
M I l'S M IrA
MIY4 M 1V)
M1Y3 M112
MIY2 M1Yl
M1Y1 MIYO
M1Y0 MOB
MOB 11 Y, pO l ilion
Y-poiition
004
' ($04)
(S04 ) M2X7
M'lXl M2X6
M2X6 M2X5
M2XS M2X4
M2X 4. M2X3
M2X3 M2X2
M2X2 M2X1
M2X l M2XO
M2X0 M08
MOB '22 X- O<I1",on
X-ponIion

005
' (105))
(S05 M2Y7
M2Y7 M2Y6
M2 Y6 M2 '(5
M2Y5 M2Y4
M'lV" M2Y3
M'lV) M2Y2
M2Y2 M2 YI
M2Y1 M2 YO
M2Y0 "·oo''''on
MOB '22 Y-po»iliof>
MOB
06
06 (106)
(1061 M3X7
M3X7 M3X6
MJ X6 M3X5
M)X5 M3X4
M3 XA M)X3
M3X3 M)X2
M3X2 M)XI
M3X1 MJ XO
M3X0 MOB
MOS J3 X·oo,,,,O"
X-po»ilion
07
07 (S07)
(S07) M3Y7
MlY7 M3Y6
M)Y6 M3Y5
M) Y5 M3Y4
M)Y" M3Y3
M)Y) M3Y2
M) Y'l M)Y1
M3Y1 M3'(0
M3Y0 Moe
MOB 33 Y·p.o l i" on
Y-poiilion
v OB
O' iS08)
(S08) M4X7
M J, X7 MM4X6
4 X6 M4X5
M4 X5 M4X4
M 4 X4 M4X3
M4X3 M 4 X2
M4X2 M4
M4X1 XI M4
M4X0 XO Moe
MOB 4* X· POII' ,on
X-poiition
so
09 (109)
(S09) M4Y7
M 4 Y7 M4Y6
MH6 M4Y5
M4 Y5 M4Y4
M4 Y4 M4Y3
M 4 Y3 M
M4Y24 Y2 M4
M4Y1 YI M4Y O MO B 44 Y. pol i, io n
M4Y0 MOB Y-poiition
10
10 (SOA)
(SOA) M5X7
M5X7 M5X6
.'.15 '1. 6 M5X5
M5X5 M5X4
M5XJ, M5X3
M5 X3 M5X2
M5 X2 .'.15'1.
MSX11 .'.15 '1.0 X· ~O I " ' On
M5X0 Mo
MOB e 55 X-pontpon
11
II ilOB))
(SOe M5Y7
M5Y7 M5Y6
M5Y6 MSY5
M5Y,5 M5Y4
M,5 Y4 M5Y3
M5 Y3 M5Y2 M
M5Y15Y I M5YO
M5YQ MO
MOB B 5S Y. i>o.n ,on
Y-poiition
12 (IOC)) M6X7 M6X6
M6 X6 M6X5
.'.16 '1. ,5 M6X4
M6XJ, M6X3
.'.16 '1. 3 .'.16 '1. 2

,.""
(SOC M6X7 M6X2 M6X1I
M6X .'.16
M6X0 '1.0 MOB
MOB 6 X.pO"lion
13 (SOD))
(SOD M6Y7
M6Y7 M6Y6 M6Y5
M6Y,5 M6Y4 M6Y3 M6Y2
M6Y2 M6Y!
M6 YI M6Y
M6Y0 O MOB 66 Y· po.",on
MOB Y-poiition
11 llOE))
(SO£ M7X7
M7X7 M7X6 M7X5
M7XS M7X4
M7XJ, M7X3
.'.17'1.3 M7X2
M 7X2 M7X1
.'.17 '1.1 .'.17
M7X0 '1. 0 .'.loa 77 X·.,Oll' ,on
v If (10F)
(SOF) M7Y7 M7Y6 M7Y5 M7Y4
Mm M7Y3
MOB X-ponrion
M7Y2 Y ·~O I "' on
"
16 ($10)
(S IO ) M7XS
M7X8 M6X8
M6X8 M5XB
MSX8 M4X8
M 4 X8 M3X8 M2X8
M7YII
M7Y
M I X8
M6YO
M6Y0
.'.10 '1. 8
Moe
MOB 77 Y-poinion

"
17 (til)
(S 1 1) P.CB
Re. ECM
OCM BMM DEN
OEN RSEL
M1X8 M0X8 MSa
MSB o
off X·pOI
X-pontioi" ,o n

"
18
IB (112)
(S 12) RC7
'07 RC6
' CO RC5
'CO RC4
,C '
IIS
RC3
'el
H
RC2
'C'
"
Y2 VI
"
'RC1
CI
YO
'0
RCO
'CO
SSe••» I-•*!
. ~'

Roite r 'regnter
IIotl.r .9'''.'
19 ($13)
(S 131 lLPXB
PX8 lLPX7
PX7 lLPX6
PX6 LPX5
lPXS lLPX4
PXJ, lLPX3
PX3 lLPX2
P X2 lLPXl
PXl l. gh , Pen
Ughi p. n X)(
"0
'20
21
21
1114)
is 141
(115)
(S I S)
LPY7
lP
M7E
M7!
Y7 lLPY6
M4E
MOE
PY6 LPY5
lPY5
M5E
M"
"Y<
LPY4

M4E
M' E
IPY3
LPYJ
M3E
MlE
lLPY2
PY2
M2E
LPY
.PY1I

MI!
MtE
lIPYO
PY O
MOE
'gh, P.
lLight Penn Y
Y
.'1108 Enable
MOB Enob l.
22
"
23
($16)
(S 16)
(117)
-

M7YE
-
— RES
RES MCM
MCM C5EL
CS El X2
X2 XI XO
xo See te»t
Se !. d
M6YE
,."
2*
(S I7)
(SIB)
(S 18 )
M7YE
VMI3
VM I 3
M6YE
VM12
VM I 2
M5YE
MSYE
VM1
VM I 1I
M4YE
M 4 YE
VM10
VM IO
M3YE
M3 YE
CB13
Ce l 3
M2YE
CB)2
C 6 12
Ml Y£E
M IY
CB1I
C BI I
MO
-
YE
MOYE MOB Y-e*oond
MOB Y-e_ r::ond
Memory Pomteri
Memory Po,n' e "
25 (119) IRQ
IRQ - - - IL'
""
(S 19) — — — ILP IMMC
IMMC IMBC
IMBC IRST
III Sf I n!e ''v
Interr ~ 1 Regiitor
jpt II e g itle .
2-,

27
IDA)
(S IA)
'SIB)
-

M7DP
-

M6DP
-

M5DP
-

M4DP
EIP
fL '
M3DP
EMMC
eM MC EMBC
EMB C EIISf
ERST Eno b leb Inier'jpi
Enob In1etru p.
27 n i B) M 7 DP M6DP MSDP M40P M3DP M2DP
M20P M I DP
M1DP .'.l OO P
MODP M O B-O
MOB AT A Priority
DATA P" o to 'V

,.
28
28
29
3D
(SIC)
(S IC )
(SID)
(S I D)
($>E>
IS I f)
M7MC
M 7MC
M7XE
M7xe
M7M
M7M
M6MC
M6M C
M6XE
M6XE
M6M
M'M
M5MC
MSM C
M5XE
M SX E
M5M
M5M
M4MC
M 4 MC
M4XE
M4XE
M4M
M.M
M3MC
M3MC
M3XE
M3x e
M3M
M'M
M2MC
M2MC
M3XE
M2XE
M2M
M'M
M I MC
MIMC
MIXE
M I XE
.'11 1M
M1M
MOMC
M0MC
MOM
MOXE
MOM
MOM
M O B Multicolor
MOB
MO B X-siponO
MOB X- upo nd
MO B-MOB
MOB
Se l
M ull 'colot Sel

Co llo • •on
'0 MOS Collision
31 (S1F)
(S I F) M7D
M70 M6D
MOO M5D
M5 0 M40
M. O M3D M20 MIO MOO

""
M'O M2D MID MOD MO B_D ATA Collision
MOB-DATA Col l",on
32 (120)
($10 ) -
— —- -
— -
— EC3
Eel EC2
EO EC I
EC1 fCO
ECO hle to o)'. Coior
Exter, Co Ot
33

,.
II (121)
(S2 1) -
— —- —- -
— B0C3
.Oel B0C2
.0<2 8 0C I
B0C1 BOCO
' DCO Bl"gd 00
Bkgd - 0 Color
C o lo .
34 (122)
(s n ) -
— —
- —- -
— B1C3
61C3 BIC2
8 1C2 B1C!
81C I BIC O
B1C0 8i; g d #1
Bkgd - I Color
Co lo.
35
" (S23)
(S23 ) -— —
- —- -
— B2C3
82C3 B2C2
82C2 B2CI
B2 C I BKO
B2C0 Bl"gd #2
Bkgd _ 2 Color
Co lo .
36 (S34)
- - - - "'3
" 83C3
B3C3 33C3
(S2 4) — — — — fl3C2 B3C1
83C I B3C0
B3CO Bi; gd #3 Color
Bkgo Co lo .
37
31 (125)
(S2 S) -
— —- —- -
— MM03
MM03 MM0 2
MM03 MM01
MMO' MM OO
MM00 MOB Multicolor
MOB Mu il ico lot #0
' 0
:=
"3. (126)
(S26 ) -
— —
- —
-- -
— MM
MM13
I3 MM12
MM I2 MM11
MM I. MM10
MM IO MOS M ul" cOIOt #1
MO B Multicolor
"
j9 l$27)
(S2 7 ) —- —
- — —- M0C3
MaC) M0C2
MOC2 M0C1
MaC I MOCO
M0C0 MOB 00 Color
MOB C o lo .
0
.,. 0 ($38)
(S28 ) —- —
- —- —- M)C3
MICJ MIC2
MIC2 M1C!
M IC I M IC a
M1C0 MOB 1 I Color
MOB Co lo .

.,.,
1 H29)
(S29 ) —
- —
- —- —
- M2C3
M2C3 M2C2
M2C2 M2 C I
M2CI M2 CO
W2C0 MO B 3"1 Color
MOB Co lo.
- - -
.,..
2 (12A)
($1A) — — —

- M3c)
M3C3 M3C2
M3C2 M3C1
M3C ' M3 CO
M3C0 M O B 3J Color
MOB Cole r
3 (S2B)
( UB) —

- —
-- —- —
- M4C3
M 4CJ M4C2
M 4C2 M 4CI
M4C1 M4CO
M4C0 MOB 44 Color
MOB Colo '
-
.
4 (12C)
(SK I -
— — —- — M5C3
MSC 3 M5C2
MSC2 M5C1
MSC I MSCO
M5C0 MOB 5S Color
MOB Colo'
5 (J2D)
($:2 0 ) -
— — - — - —- M6C3
M6CJ M6C2
M6C2 M6C I
M6C1 M6CO
M6C0 MOe i6 Color
MOB Colo,
46 :$2E>
($:2E ) -
— — - —- —- M7C3
M 7C 3 M7C2
M7C2 M7C1
M 7C I M7 CO
M7C0 MOB 77 Color
MOB C o lor

NOT
•°° 3' - I '

v
157
157
v

Downloaded from www.Manualslib.com manuals search engine


APPENDIX
APPENDIX Q
Q
EXECUTIVE 64
EXECUTIVE 64
SOUND
SOUND CONTROL
CONTROL SETTINGS
SETTINGS
This
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
programs,
programs ,according
according toto which
which of of the
the 64's
64's 33 voices
voices you
you want
want toto use.
use. To
To set
set or
or ad
ad-
just
just aa sound
sound control
control in
in your
your BASIC
BASIC program,
program,just just POKE
POKE the
the number
number from from thethe se
se·
cond
cond column,
column, followed
followed byby aa comma
comma (,) (,)and
and aa number
number from
from the
the chart...
chart ... like
like this:
this:
POKE
POKE 54276.17
54276,17 (Selects
(Selects aa Triangle
Triangle Waveform
Waveform for for VOICE
VOICE 1).1).
Remember
Remember that that you
you must
must set
set the
the VOLUME
VOLUM E beforebefore you
you can
can generate
generate sound.sound.
POKE54296
POKE54296 followed
followed byby aa number
number up up toto 15
15 toto set
set the
the volume
volume for for all
all 33 voices.
voices.
ItIt takes
takes 22 separate
separate POKEs
POKEs to to generate
generate each each musical
musical note.
note. For
For example
example
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,
Also, you
you aren't
aren't limited
limited toto the
the numbers
numbers shown
shown inin the
the tables.
tables. IfIf 33
33 doesn't
doesn' t
sound
sou nd "right"
" 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
than
than those
those shown,
shown, add add two
two oror more
more SUSTAIN
SUSTAIN numbers
numbers together.
together. (Examples:
(Examples:
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·
tack
tack rate,
rate, POKE54277.20
POKE54277,20 provides
provides aa lowlow attack
attack rate
rate (16)
(16) and
and aa medium
medium decay decay ("',
rate (4).
rate (4).

*-

158
158

Downloaded from www.Manualslib.com manuals search engine


v

TO CONTROL FOLLOWED BY ONE OF THESE NUMBERS


THIS SETTING: (0 to 15 ... or... 0 to 255 depending on range)
v
TO PLAY A NOTE D# 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 190 75

v WAVEFORM POKE TRIANGLE SAWTOOTH PULSE NOISE

54276 17 33 65 129

PULSE RATE (Pulse Waveform)

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)
v
ATTACK/DECAY POKE ATK4 ATK3 ATK2 ATK1 DEC4 DEC3 DEC2 DEC1

54277 128 64 32 16

SUSTAINfRELEASE POKE SUS4 SUS3 SUS2 SUS1 REL4 REL3 REL2 REL1
54276 128 64 32 16

TO PLAY A NOTE C# D# F# G# A#

HIGH FREQUENCY 54230 33 39 59


LOW FREQUENCY 54279 135 223 193 190

WAVEFORM POKE TRIANGLE SAWTOOTH PULSE NOISE

54283 17 33 65 129

v PULSE RATE (Pulse Waveform)

HI PULSE 54282 A value ot 0 to 15 (for Pulse waveform only)


LO PULSE 54281 A value of 0 to 255 (for Pulse waveform only)

ATTACHJDECAY
ATTACKJOECAY POKE ATM ATK3 ATK2 ATK1 DEC4 DEC3 DEC2 DEC1

54284 128 64 32 16 1

SUSTAIN/RELEASE POKE SUS4 SUS3 SUS2 SUS1 REL4 REL3 REL2 REL1
54285 128 64 32 16

TO PLAY A NOTE C# D# G# Aft

HIGH FREQUENCY 54287 35 37 42 44 47 50 53 56 59 63


LOW FREQUENCY 54286 135 134 162 223 62 193 107 60 57 99 190 75

WAVEFORM POKE TRIANGLE SAWTOOTH PULSE NOISE

v 54290 17 33 65 129

PULSE RATE (Pulse Waveform)

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 DEC4 DEC3


v
54291 128 64 32 16

SUSTAIN/RELEASE POKE SUS4 SUS3 SUS2 SUS,


SUS1 REL4 AEL3
REL3 AEl2 RELI
54292 128 64 32 16 8 2

v
159

Downloaded from www.Manualslib.com manuals search engine


TRY THESE SETTINGS TO SIMULATE DIFFERENT INSTRUMENTS
Instrument
Instromenl Waveform Attack/Decay
Attack/Deca y Sustain/Release Pulse Rate

Piano Pulse 9 0 Hi.Q,


Hi-0. Lo-255
~
Flute
F lute Triangle 96 0 Not applicable
Harpsichord Sawtooth 9 0 Not appl icable
applicable
Xylophone Triangle 9 0 Not applicable
Organ Triangle 0 240 Not applicable
Colliape Triangle 0 240 Not applicable
Accordian Triangle 102 0 Not applicable
applic able
Trumpet Sawtooth 96 0 Not applicable

MEANINGS OF SOUND TERMS


ADSR
ADSA -— Attack/Decay/Sustain/Release
AttackiDecaylSustainlRelease
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
at which falls from
w hich volume fa11s trom sustain level

Waveform -— "shape" of
o( sound wave

Pulse
Pulse — tone Quality
- lone quality of Pulse Waveform

NOTE: AttacWDecay
NOTE: and Sustain/Release
Attack/Decay and SustairWRelease settings
settings should
should always
always be POKEd
POKEd In
in your
your program
program BEFORE
BEFORE
is POKEd.
the Waveform IS POKEd.

160

Downloaded from www.Manualslib.com manuals search engine


APPENDIX R
R
6581 SOUND INTERFACE DEVICE (SID)
CHIP SPECIFICATIONS
CONCEPT
CO NCEPT
The 6581 Sound Interface Device (SID) is a single-chip,
single-chip. 3-voice electronic
effects
music synthesizer/sound effec ts generator compatible with the 65XX and
microprocessor
similar m con
icroprocessor families. SID provides wide-range high-resolution con-
trol of pitch (frequency),
(frequency), tone color (harmonic content), and dynamics (volume)_
(volume).
overhead,, facilitating use in ar·
Specialized control circuitry minimizes software overhead 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. Sawtooth,
Triangle,
Variable Pulse, Noise
• 3
3 AMPLITUDE MODULATORS
Range: 48 dB
• 3 ENVELOPE GENERATORS
response
Exponential respon se
Attack Rate: 2 ms-8 s
Decay Rate:
Rate: 6 ms-24 s
Level:: O-peak
Sustain Level 0-peak vo lume
volume
Release Rate: 6 ms-24 s
SYNCHRONIZATION
• OSCILLATOR SYNC HRON IZATION
• RING MODULATION

DESCRIPTION
The
Th 65811 consists of three syn
e 658 synthesizer "voices"" which can be used in-
thesizer "voices in
dependent ly or in con
dependently junction with each other (or external audio sources) to
conjunction
complex
create com sounds.
ple x so Oscillator/Waveform
unds. Each voice consists of a Tone Osc illatorlWaveform
Generator,
Generator, an Envelope Generator and an Amplitude Modulator_
Modulator. The Tone
Oscillator controls the pitch of the voice over a wide range_
range. The Oscillator pro-
pro
frequency,, w
duces four waveforms at the selected frequency with
ith the unique harmonic con·con
v tent of each waveform prov
providing simple
iding si control
m ple co ntrol of tone co
color. The
lor . Th volume
e vo lum e
dynam ics of the oscil
dynamics lator are controlled by the Amplitude Modu
oscillator lator under the
Modulator
direction of the Envelope Generator_
Generator. When triggered,
triggered, the Envelope Generator
envelope
creates an amplitude enve with
lope wit h programmable rates of increasing and
decreasing vol ume. In addition to the th
volume. ree voices, a programmable Filter is pro-
three pro
complex,, dynam
vided for generating complex dynamic subtractive
ic tone colors via subt rac tive syntheses.
SID allows the microprocessor to read the changing output of the third
Oscillator and third EnEnvelope
velope Generator. T These outputs
hese outp uts can be used as a
source of modulation information for creating vibratovibrato,, frequency/filter sweeps
similar
and sim ilar effects. The third oscillator
th ird osci ll ator can also act as a random number
generator for games. Two AlD A/D conve
converters
rters are provided for ininterfacing
terfacing SID with
potentiometers. ThThese
ese can be used for "paddles
"paddles"" in
in a game environment or as
v front panel controls in a music synthesizer. SID ca can
n process external audio
signals, allowing multiple SID chips to be daisy-chained or mixed in complex
v polyphonic systems.
systems.

t61
161

Downloaded from www.Manualslib.com manuals search engine


o; ro -i
—r o

a
<
o
~
.
ADDRESS REG- F1EG NAME REG <° CD
A

"<01

<01"
"-
|HEX> Voice 1
TYPE o
Table 1.

°7 °* - __£°

cl °
ro
a 0 0 FG
*~ f; FREQ LO WHITE- ONLY
o
-F; CO

o
4,<>O-
0 0 Q F9 freo m WRITE ONLY uV CD
z

-
—A1

Cl
0 0 0 PW~ PW6 PW5 Jp-w4 PW3 PW2 PW, ~PW0 PW LO WHITE ONLY

-
X

0000
PW,, PWa 1>W HI WHITE ONLY
O

O
NOISE rLTL TEST SYNC GATE CONTROL REG WRITE ONLY
i—

--
ATK3 ATK? ATK, ATK0 DCY3 DCY? OCY, [>CY0 ATTACK/nrCAY WRITF ONLY

- oo -
... ...... ...

'; 0 0 0 " ' 0 0 0


2: ::: 222:
~ :: :: 3: ::
,.. !; !:. ,.. ,.. !:. !:.
5555555

:'::~ 8o~a03il :g
STN? STN, STN0 RLS3 RLSj RLS, WRITE ONLY

Downloaded from www.Manualslib.com manuals search engine


RLSo aUSTAINiHELEASE

tfolce 7

0
__

00000000
FHEO LO WF1HEONLY
0
FREQ HI WHI1F ONLY
a"

--
_00
PWr PWG PW5 PW, PW3 PW, pw0 PWLO WHIIEONLY
(TJ

-
m
- - - -
"- -'

PW,, PW9 PW8 PW HI WRITE ONLY

-
WING

__

0000
...

NOISE nxL TEST SYNC GAFE CONTROL REG WRIIEONLY


SID CONTROL REGISTERS

ATKa ATK, ATK0 DCY0 LTl


ATK.i DCY3 DCYy DCY, ATIACKIDECAY WHITE ONLY A 5"

--
__
~ ~ ~ ~ ~

00

000000
c;8 g:;5g 152
STN3 STN? STN, SIN,, RLSj RLS;. HLS, FILS,, SUSTAINJHEIEASE WHITE ONI Y Q
Voice 3 70

I
I
11)
Fo FREQ LO V.I.I 1 .".. ■ o S

162
ro ID

__
--
--

00
—b ■ Fl( ■v,7~ F,o"" FREO HI WHITE ONLY
Fib F,.'~
o

..
PW, PW6 PWS PW4 PW3 PW2 PW, PW0 PWLO WHITE ONLY
ft) m it

'-- ~ ! ,

__
w
,.. !:. !:. ,..

00
- - - - PW,, PW,o PW9 PWB WHI WHITE ONLY
>o

-
~

:'
NOISE TEST SYNC GATE CONTROl HFC. WRITF ONLY o o

_ _
n_n_ 3

", - o - o -
..:: In '"

__
!:.

OOOCl
ATK3 AIK, ATK, ATKo 0CY3 DCY^ DCY, DCYy ATTACKIDECAY WHITf ONLr
Tob ie 1. SID Reg ist er Map

-
g ::

_
e
... a o :z:

OIl
~ ~ ~ ~ ~
~

Ww
5555555

'Cto :> :: ::-~ !

QI;>QOO
STN.. RIS, SUSIAINiRE LEASE WRITE ONLY

-0
STNa STN, STNu RLS3 HLfi,
~ !fii~t;!; HLSn

" Filler

-
- - - FC;, FC," FC0 FC LO WHITE ONt.V

-
...
FC,0 FCB FC, PCs FC, FC, WRIIEONLY

J'
FC, FC HI

--,.

-
... ~
',J Vi
RESa RES; FILIEX

rJ,'
RES, RESo FILT 1 filt ; FILI 1 RES'FIll WRITE ONLY

0
l:
~ aJ
CI..

CI..

Q--O
HP VOL, VOL0 WHITE ONLY

-
3 OFF BP LP VOL3 VOL, MODE/VOL

Misc.
PX, PX6 PX5 ~PX, PX3 PX3 PX, PX,, POT X HF.ADONLY
ro

o -
PY, PY;, py. PVj py, PY0 POT Y F1EA0 0NLY a.
P*6

-
>

<:> '" '"


0, °6 °i o3 O2 o, Oo OSC3JRANDOM READONLY

-
0
0 0
>

:: ::::
z z

<:I
.!:3

E, Es Ej Ej E, Eo ENV, REAOONLY
These regi sters are ei ther WRITE-only or READ-only and are listed below in

ll
Th ere are 29 eight-bit registers in SID which control the generation of sound.

n
APPENDIX
APPENDIX SS
DISK
DISK and
and PRINTER
PRINTER COMMANDS
COMMANDS and
and
STATEMENTS
STATEMENTS
The
The following
following BASIC
BASIC commands
commands and
and statements
statements let
let you
you perform
perform aa variety
variety of
of
operations
operations on
on disk
disk drives
drives and
and any
any compatible
compatible Commodore
Commodore printer.
printer.

CLOSE
CLOSE
TYPE: I/O
TYPE: I/O Statement
Statement
FORMAT: CLOSE < file
FORMAT: file number
number >
>
Action:
Action: This
This statement
statement shuts
shuts off
off any
any data
data file
fi le or
or channel
channel to
to aa device.
device. The
The file
file
number
number is
is the
the same
same as
as when
when the
the file
file or
or device
device was
was OPENed
OPENed (see
(see OPEN
OPEN state
state·
ment and the section on INPUT/OUTPUT
INPUT/OUTPUT programming).
When
When working
work ing with
with storage
storage devices
devices like
like disks,
disks, the
the CLOSE
CLOSE operation
operation stores
stores
any incomplete buffers
buffers to the device.
device. When this is is not performed,
performed, the file will
be unreadable
unreadable on the disk.
disk. The CLOSE operation
operation isn't
isn't as
as necessary
necessary with other
other
devices,
devices, but
but it does free
free up
up memory for
for other
other files.
files. See your
you r external device
device
v
manual
manual for more details.
v
EXAMPLES of CLOSE Statement:
Statement:
10 CLOSE 1
10 1
20 CLOSE X
30 CLOSE
CLOSE 9 *• (1
(1 + J)
+ J)

CMD
TYPE: I/O Statement
FORMAT: CMD < file number >
> I,string)
[,string]

Action: This statement switches the primary output device from the TV
screen to the file specified. This file could be on disk, printer,printer, or an I/O device
like the modem. The file number must be specif specified
ied in a prior OPEN statement.
specified, is sent to the file. Thi
The string, when specified, This titling
s is handy for tit ling printouts,
etc.
When this command is in effect, any PRINT statements and LIST commands
willl not display on the screen, but will send the text in the same format to the
wil
lifile.
le.
re-direct the output back
To re·direct back to the screen, the PRIN
PRINT#T# command should send
blank line to the CMO
a blank CMD device before
before CLOSEing,
CLOSEing. so it will stop expec
expecting
ting data
(called ""un-listening"
un-l istening" the device).
v 7SYNTAX ERROR)
Any system error (like ?SYNTAX ERROR) will cause outpuoutputt to return
return to the
Devices aren't un-listened
screen. Devices un-listened by this, so you should send a blank blank like
like after
an error condition.
an condition. (See
(See you
your printer or disk
r printer disk manual
manual for m
more details.)
ore details.)

163
163

Downloaded from www.Manualslib.com manuals search engine


-■

EXAMPLES of
EXAMPLES of CMD
CMD Statement:
Statement:

OPEN 4,4:
OPEN 4, 4: CMD
CMD 4,
4, ""TITLE"
TITLE" :: LIST:
LIST: REM
REM LISTS
LISTS PROGRAM
PROGRAM ON
CN
PRINTER
PRINTER
PRINTS 4: CLOSE 4: REM
PRINT# REM UN·LlSTENS
UN-LISTENS AND CLOSES PRINTER
PRINTER

10
10 1, 8, 4, ""TEST":
OPEN 1,8,4, REM CREATE SEQ FILE
TEST": REM FILE fl
20 REM OUTPUT TO TAPE FILE,
CMD 8: REM FILE, NOT
NOT SCREEN
30
30 FOR L =
FOR = 11 TO 100
40 PRINT L:
PRINT L: REM
REM PUTS
PUTS NUMB
NUMBER IN DISK
ER IN DISK BUFFER
BUFFER g
50 NEXT
NEXT
60 PRINTS 1: REM
PRINT# REM UNLISTEN
UNLISTEN
70 CLOSE 1: REM WRITE UNFINISHED BUFFER, PROPERLY PROPERLY
FINISH

GET#
TYPE:
TY I/O Statement
PE: 1/0
FORMAT: GET#
FORMAT: GETS (<file number> , (variable
file number>, < variable list
list>>
characters one·at·a·time
Action: This statement reads characters one-at-a-time from the device or file _
specified. It works the same as the GET statement,
specified. statement, except that the data comes
from a different place than the keyboard.
keyboard. If no character is received
received,, the variable m
(equal
is set to an empty string (equ "") or to 0 for numeric variables. Characters
al to lIt')
files , like the comma (,) or IIll!Il:II
used to separate data in files, Ifflim key code (ASC code
of 13),
13), are received like any other character.
character. _
When used with device #3 (TV screen), this statemenl statement will read characters
one
one by one from the screen. Each use of GET# GET# moves the cursor 11 position to
the ri
right.
ght. The character at the end of the loglogical
ical line is changed to a CHR$ (13),
CHR$ (13),
the EEII key
the Im!ID key code.
code. #

EXAMPLES of GETS
GET# Statement
5
5 GETS
GET# 1,
1, A$
AS
10
10 OPEN 1, 3: GETS
1,3: GET# 1,Z7S
1, Z7S
20 GETS
GET# 1,
1, A,
A, B,
B, CS,
CS, DS
OS

164
164

Downloaded from www.Manualslib.com manuals search engine


INPUT#
INPUT#
v TYPE: I/O
TYPE: I/O Statement
Statement
FORMAT tNPUT#
FORMAT INPUTS < file <
file number
number>>,, < variab
variable <
list >>
le list
Action: Th
Action: This is usually
is is usually the
the fastest
fastest and
and easiest
easiest way
way to to retrieve
retrieve data
data stored
stored inin aa
file on
file on disk.
disk. The
The data
data is
is in
in the
the form
form of
of whole
whole va variables
riab les ofof up
up to
to 80
80 ccharacters
harac ters inin
length,, as
length 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
have been OPENed,
OPENed, Ihenthen INPUT#
INPUT# can
can lill
fill Ihe
the variables.
variables.
The INPUT#
The INPUT# command
command assumesassumes a variable is is finished
finished when
when itit reads
reads a
RETURN code
RETURN 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,,
BAD DATA
a BAD DATA error
error results.
results. INPUT#
INPUTS can read read strings up up to 80 characters long, long,
beyond which a STRI
beyond STRING
NG TOO LONG LONG error results.
results.
When used used with device #3 (the sc screen),
reen), this statement will read read an entire
logical liline
logical ne and move the cursor down to the next next line.
line.

EXAMPLES of INPUT# Statement:


EXAMPLES
INPUTS 1,
10 INPUT# 1. A
INPUTS 2, AS, BS
20 INPUT# BS

LOAD
LOAD
TYPE: Command
TYPE:
FORMAT LOAD
FORMAT LOAD "" < fil <
fi!e-name>
e.name > "" , < device ,<
device >
> [,
[, < address
address >
> []<
Action: The LOAD statement read readss the contents of a program fi
file
le from disk
memory. That way you can use the information LOADed or change the in·
into memory. in
formation
formati on in some way.way. The disk unit is normally device number 8. The LOAD
all open files
closes all fi les and, if it is used in direct mode, it performs aa CLR (clear)
(cl ear)
before reading the program.
prog ram. If LOAD is executed from within aa program,
program, the
program is RUN.
is RU N. This means that that you
you can
can use LOAD to "chain" several pro pro·
grams together.
toge ther. None
None of
of the variables are cleared during a cha
chain operation.
in operati on.
If you
you are using
using fife-name
file·name pattern
pattern matching,
matching, the first file which matches
matches the
pattern is loaded.
loaded. The asterisk in in quotes by itself ("*") ('" ") causes
causes the first
fi rst file-name
file·name
in
in the disk
disk directory
directory toto be
be loaded.
loaded. If the
the file-name
fi le·name usedused does not
not exist oror ifif itit is
is
not a a program
program file,
file, the
the BASIC
BASIC error
error message
message ?FILE ?FILE NOTNOT FOUND
FOUND occurs.
occurs.
If
If you use
use the
the secondary
secondary address
address of of 11 this will
will cause the program
program to to LOAD
LOAD to 10
the
the memory
memory location
locati on from
from which
which itit was
was saved.
saved.
EXAMPLES
EXAMPLES of of LOAD
LOAD Command:
Command:
LOAD
LOAD A$,8
AS,8 (Uses
(Uses the
the name
name in
in AS
AS to
to search)
search)
LOAD "*",8
LOAD UUI,S (LOADs
(LOAD s first
first program
program from
from disk)
disk)
LOAD
LOAD "$",8:LIST
" S" ,8:LlST (LOADs
(LOADs and
and LISTs
LISTs disk
disk directory)
directory)
LOAD
LOAD "FUN",8
"FUN'\8 (LOAD
(LOAD aa file
file from
tram disk)
disk)
SEARCHING
SEARCHING FOR
FOR FUN
FUN
LOADING
LOADING
READY.
READY.
v
LOAD
LOAD "GAME
"GAME ONE",8,1
ONE" ,8,1 (LOAD
(LOAD aa file
file to
to the
the specific
specific memory
memory
SEARCHING
SEARCHING FOR
FOR GAME
GAME ONE
ONE location
location from
from which
which the
the program
program was
was
LOADING
LOADING saved on the disk)
saved on the disk)
READY.
READY.
v 165
165

Downloaded from www.Manualslib.com manuals search engine


OPEN
OPEN
TYPE: I/O
TYPE: 110 Statement
Statement
FORMAT:
FORMAT: OPEN OPEN <file-num>
( file.num) ,, <device>
( device ) [,<address>]
[, ( address) ] [,"<file-name)
],"( file.name)
[, <type> ] [, <mode> ]"]
[, ( type) ] [, ( mode) ]" ]
Action:
Action: This
This statement
statemen t OPENs
OPEN s aa channel
channel for
for input
input and/or
andlor output
output to
to aa
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.
statement. Some
Some OPEN
OPEN statements
statements require
require only
only 22 codes:
codes:
1) LOGICAL
1) LOG ICAL FILE
FILE NUMBER
NUMBE R
2) DEVICE
2) DEVICE NUMBER
NU MBER
The
The /(file·num)
file-num ) is is the
the logical
logical file
fi le number,
number, which
which relates
relates thethe OPEN,
OPEN, CLOSE.
CLOSE,
CMD,
CMD, GET#,
GET#, INPUT#,
INPUT#, and and PRINTS
PRINT# statements
statements to to each
each other
other and
and associates
associates
them
them with
with the
the file-name
file·name andand the
the piece
piece of of equipment
equipment being
being used.
used. The
The logical
logical file
file
number
number can
can range
range from
from 11 to
to 255
255 and
and youyou can
can assign
assign itit any
any number
number you
you want
want in
in
that range.
that range.

NOTE:
NOTE: File
File numbers
numbers over
over 128
128 were
were really
really designed
designed for
for other
other uses
uses so
so it's
it's good
good
practice
practice to
to use
use only
only numbers
numbers beiow
below 127
127 for
for file numbers.
numbers.

Each
Each peripheral device
device (printer,
(printer, disk drive) in the system
system has
has its
its own
own number
number
which
which itit answers
answers to.
to. The
The ^device))
(device) number is used
number is used with
with OPEN
OPEN to
to specify
specify on
on
which device the data file
fil e exists. Peripherals
Peripherals like disk drives or printers also
answer to several secondary addresses. Think of these as codes which tell n
each device what operation to perform. The device logical file number is used
with every GET#,
GET#. IN PUT#, and PRINT#.
1NPUT#,
The file·name
The file-name cancan also
also be
be left
left out,
out, but
but later
later on
on in
in your
your program
program you
you can
can NOT
NOT
call the file by name if you have not already given it one.
files,, the secondary addresses 2 thru 14 are available for data·files,
For disk files data-files,
numbers have special meani
but other numbers meanings in DOS commands. You must
ngs in must use a
secondary address when using your disk drivels). drive(s). (See your disk drive manual
for DOS DOS command details.)
The (file.name
fifiles.
les. IfIf the fil
>
<file-name) is a string of 1·16 1-16 characters and is is optional for printer
printer
file
e (< type>
type > is is left
left out the type of file wi will
ll automatically default to
Program file
the Program file un
unless
less the mode mode is given
is given.. Sequential
Sequential files are are OPENed
OPENed lorfor
reading <
reading <mode)> =R unless you
writing (made»
writing
made>
<(mode> ;=W
; R
W is
un less
is specified.
you
specified. A
specify
A lile
that
file (<type>
type) can
files should be OPENed for
files
can be
should
be used
be
used to
OPENed
to OPE
OPEN
lor
an ex·
N an ex-
isting Relative
isting Relative Iifile. Use REL
Ie. Use REL lor for (type)
<type> with with Relative
Relative liles.
files. Relative
Relative and
and Se·
Se
quential
quential liles files are
are for
for disk
disk only.
only.
IfIf you
you try
try to
to access
access aa filefile before
before itit is
is OPENed
OPENed the the BASIC
BASIC error
error message
message ?FILE
?FILE
NOT OPEN
NOT OPEN wi will occur. IfIf you
ll occur. you try try to
to OPEN
OPEN aa Iifile for reading
Ie for reading wh which does not
ich does not exist
exist
the BASIC
the BASIC error
error message
message ?FILE ?FILE NOT NOT FOUND
FOUND will will occur.
occur. IfIf aa file
file is
is OPENed
OPENed to to
disk lor
disk for writing
writing and and the
the file·name
file-name already
already exists,
exists, thethe DOSDOS error
error message
message FILE
FILE
EXISTS occurs.
EXISTS occurs. IfIf aa Iilefile isis OPENed
OPENed that that is is already
already OPEN,OPEN, the the BASIC
BASIC error
error
message FILE
message FILE OPENOPEN occu occurs. (See Pri
rs. (See Printer Manual lor
nter Manual for lurther
further detailS.)
details.)

166
166

Downloaded from www.Manualslib.com manuals search engine


v
v EXAMPLES of
EXAMPLES of OPEN
OPEN Statements:
Statements:
v 10 OPEN
10 OPEN 2,
2, 8,
8, 4
4 ""DISK-OUTPUT,
DISK·OUTPUT,
SEQ,W"
SEQ,W" (Opens
(Opens sequential
sequential file
file on
on disk)
disk) -—
For
For Write
Write
10 OPEN
10 OPEN 50,
50, 0
0 (Keyboard
(Keyboard input)
input)

10 OPEN
10 OPEN 12,
12, 3
3 (Screen
(Screen output)
output)

10 OPEN
10 OPEN 130,
130,44 (Printer
(Printer output)
output)

10 OPEN
10 OPEN 1,2,0,
1,2,0, CHRS(10)
CHR${10) channel to
(Open channel to RS·232
RS-232 device)
device)
10 OPEN 1,4,0,
10 1,4,0, ""STRING"
STRING" (Send
(Send upper case/graphics
case/graphics to the
the
printer)
printer)

10 OPEN 1,4,7,
10 1,4,7, ""STRING"
STRING" upper/lower case to printer)
(Send upperllower printer)
10 OPEN 1,5,7, ""STRING"
10 STRING " (Send
(Send upperllower
upper/lower case to printer
with device #5)
10 OPEN 1,8,15,
1,8,15, ""COMMAND'
COMMAND" (Send
(Send a command to disk)
v
10 OPEN 1,8,1, "NAME,L" + (Relative file OPEN (1st time) where
CHRS(X)
CHR$(X) X is the length of the relative record)
OPEN,, 1,8,1,"
10 OPEN 1,8,1,"NAME"
NAME" (Relative or sequential read)

PRINT#
TYPE: I/O Statement
FORMAT: PRINT#
FORMAT: <
PRINT#<file-number
file·number )> [< variable [<
variable>][<,/;>
) ] [ (/;) (<variable>
variable > ]]...
...
Actions:
Action s: The PRINT# statement is used to write data items to a logical file. It
must use the same number used to OPEN the file. Output goes to the device- device·
number used in the OPEN statement. The The <( variable^
( variable> expressions in the
in
output-list
output·l ist can be of any type. The punctuation characters between items are are
the same
same as with
with the PRINT statement and they they can be be used in in the same way.
The
The effects of of punctuation
punctuation are are different in in two significant respects. respects.
If
If no
no punctuation
punctuation finishes the list, list, aa carriage-return
carriage-return and and aa line-feed
line-feed are
are written
written
at
at the
the end ofof the
the data.
data. IfIf aa comma or or semicolon
semicolon terminates
termi nates the output-list,
output·list, the
v carriage-return
carriage-return and and line-feed
line-feed are are suppressed.
suppressed. Regardless
Regardless of of the
the punctuation,
punctuation ,
the next
next PRINT#
PRIN T# statement
statement beginsbegins output
output in in the next
next available
available character
character posiposi·
v tion.
tion. The
The line-feed
line·feed will
will act
act as as aa stop
stop when
when using
using the the INPUT#
INPUT# statement,
statement, leaving
leaving
an
an empty
empty variable
variable when
when the the next
next INPUT#
INPUT# is is executed.
executed. The The line-feed
line·feed cancan be
be sup
sup·
pressed
pressed of of compensated
compensated for for as
as shown
shown in in the
the examples
examples below.below.
The
The easiest
easiest way
way to
to write
write more
more than
than one
one variable
variable to to aa file
file on
on disk
disk is
is to
to set
set aa str
str·
ing
ing variable
variable to
to CHR$(13),
CHRS(13), and and useuse that
that string
string in in between
between all all the
the other
other variables
variab les
when
when writing
writing the
the file.
file.
v

v
v 167
167

Downloaded from www.Manualslib.com manuals search engine


-

EXAMPLESofof PRINTS
EXAMPLES PRINTH Statement
Statement

1)1)
10 OPEN
10 OPEN 1,8,4,
1,B,4,"MY
" MY FILE"
FILE" -

20 R$
20 RS == CHRS(13)
CHRS(13) (By
(By Changing
Changing the
the CHRS(13)
CHRS(13) to
to
30 PRINTS
30 PRINTH1,1;RS;2;RS;3;RS;4;R$;5
1,1;RS;2;RS;3;RS;4;RS;5 CHRS(44)
CHRS(44)youyou put
put aa","
"," between
between each
each
40 PRINTS
40 PRINTH1,6
1,6 varible. CHR$(59) would put
varible. CHRS(59) would put a";"a ";"
50 PRINTS
50 PRINTH1,7
1,7 between
between each
each variable.)
variable.}
2)
2)
10 COS
10 COS== CHR${44):
CHRS(44): CRS
CRS== CHRS(13)
CHRS(13)
20 PRINTS
20 PRINTH1,1, "AAA"CO$"BBB",
" AAA"COS " BBB", AAA,BBB
AAA,BBB CCCDDDEEE
CCCDDDEEE
"CCC";"DDD";"EEE"CRS
" CCC";" DDO ";"EE E"CRS (carriage
(carriage return)
return)
" FFF"CRS;
"FFF"CRS; FFF(carriage
FFF(carriage return)
re tu rn)
30 INPUTS1,
30 INPUTH1, AS,BCDES,FS
AS,BCDES,FS
3) ~-
3)
55 CRS=CHRS(13)
CR$ = CHRS(13)
10
10 PRINTS2,
PRINT#2, "AAA";CRS;"BBB"
"AAA";CRS;" BBB " (10
(10 blanks)AAA
blanks)AAA
20 PRINT#2,
20 PRINTH2, "CCC";
" CCC"; BBB
BBB
(10
(10 blanks)
blanks) CCC
CCC n
30 INPUTS2,
30 INPUTH2, A$,B$,DUMMY$,C$
AS,BS,DUMMYS,CS

SAVE
SAVE
TYPE: Command
TYPE: Command
FORMAT: SAVE
FORMAT: <
SAVE"" <file-name> >",<
file·name " , <device-number>
device·number [, <address) >[,
<address> I]
Action: The SAVE
Action: The SAVE com
command
mand isis used
used to store the
to store the program
program that
that is
is currently
currently in
in
memory onto
memory onto a
a diskette
diskette file.
file. The
The program
program being
being SAVEd
SAVEd isis only
only affected
affected by by the
the
command wh while SAVE is happening. The program remains in the current
ile the SAVE
computer
comp memory even after the SAVE operation is completed until you put
uter memory
something else
something else there
there by
by using
using another
another command
command.. The
The file
file type
type will
will be
be ""prg"
prg"
(program). The
(program). The SAVE
SAVE statement
statement cancan be
be used
used in
in your
your programs
programs and and execution
execution
next statement
will continue with the next statement after the SAVE is is completed.
When saving
When saving programs
programs onto
onto aa disk,
disk, the
the <file·name)
<file-name> mustmust bebe present
present..

EXAMPLES
EXAMPLES of
of SAVE
SAVE Command:
Command:

SAVE FUN DISK"


SAVE ""FUN ,B
DISK",8 (SAVES on
(SAVES on disk
disk (device
(device B
8 is
is the
the disk))
disk))

SAVE
SAVE AS,B
A$,8 (Store on
(Store on disk
disk with
with the
the name
name AS)
AS)

168
168

Downloaded from www.Manualslib.com manuals search engine


_

VERIFY
VERIFY
TYPE: Command
TYPE: Command
FORMAT: VERIFY
FORMAT: VERIFY "" <file·name
<file-name> " , <<device)
)", device )
v
Action: The
Action: The VERI
VERIFY command is
FY command is used
used,, in
in direct
direct or
or program
program mode,
mode, toto com·
com
pare the
pare the contents
contents of
of aa BASIC
BASIC program
program file
file on
on disk
disk with
with the
the program
program currently
currently in
in
memory. VERIFY
memory. VERIFY is
is norr]1ally
normally used
used right
right after
after aa SAVE,
SAVE, to
to make
make sure
sure that
that the
the pro·
pro
gram was
gram was stored
stored correctly
correctly on
on tape
tape or
or disk.
disk.
For disk
For disk files (device
(device number
number 8),
8), the file·name
file-name must
must be
be present.
present. IfIf any
any dif·
dif
ference in
ference in program
program text
text are
are found
found,, the
the BASIC
BASIC error
error message
message ?VERIFY
7VERIFY ERROR
ERROR
is displayed.
is displayed.
program name
A program name can
can be
be given either in
in quotes
quotes ('''
("") or as
') or as a string variable.
variable.

v EXAMPLE of VERIFY Command:


EXAMPLE
9000 SAVE ""ME",8
ME",B
9010 VERIFY ""ME",8
ME",B 8 for the program)
(Looks at device B

169
169

v
Downloaded from www.Manualslib.com manuals search engine
INDEX
INDEX
A
A
Abbreviations,
Abbreviations , BASIC
BASIC commands,
commands, 34,
34, 128-129
128-129
Accessories, 9-11
Accessories, 9.-11 ,_
Addition, 33
Addition, 33
AND operator, 117
AND operator, 117 _
Animation, 47-48,
Animation, 47-48, 67
67
Arit hmetic, Operators,
Arithmetic, Opera tors, 33-34,
33·34, 117
11 7
Arithmetic,
Arithmetic , Formulas,
Formulas , 138
138
Arrays, 95-96
Arrays, 95-96 —
ASC function , 126
ASe function, 126
ASC II character
ASCII character codes,
codes, 133-135
133-135

B
B
BASIC
BASIC
abbreviations, 34,
abbreviations, 34 , 128-129
128·129
commands, 117-119
commands, 117-1 19
numeric
numeric functions.
functions, 33-36,
33-36, 124-126
124-126
operators, 117
operators, 117
other functions,
other functions, 127
127
string functions,
string 126
functions, 126
variables,
variables , 42-44,
42-44, 116
116
Bibl iography, 152-153
Bibliography, 152·153
Binary arithmetic, 69-70
Binary arithmetic, 69-70
Bit, 69
Bit.
Business aids,
Business aids, 103-105
103-105
Byte, 69
Byte. 69

C
C
Calculations,
Calculations, 33-37
codes, 61
CHRS codes, 61,, 126,
126, 133-135
133-135
CHR$
C fu nction , 126
H RS function, 126
CLR statement
statement,, 119 119 ,_,
CLR,
CLR, HOM
HOME E key,
key, 1515
Clock,1 16-117
Clock, 116-117 ^
CLOSE statement
statement,, 30, 30, 119,
119, 163
Color
Color ^
adj ustment , 7-8
adjustment,
keys
keys,, 16
memory map, map, 66,66, 137
PEEKS and POK POKES,ES,
screen and border,
border, 63-64
Commands,
Commands, BASIC, 117·119 117-119
Commodore key key,, (see
(see graphics keys) 16
Connections,
optional,
optional. 9·" 9-11
rear,
rear, 1,3
1,3 '•"*
TV/Mon
TV/Monitor,itor, 1,9
Ca
CONTNT command,
command, 117 117
Co nTRol key,
ConTRoL key, 1616
COSine
COSine function
function,, 125 125
CuRSoR
CuRSoR keys,keys. 14 14
Correcting
Correcting errors
errors,, 14·15
14-15
Cursor,
Cursor, 7 7

170
170

Downloaded from www.Manualslib.com manuals search engine


D
D
Data, loading
Data, loading and
and saving
saving (disk),
(disk), 17-'9
17-19
DATA stat
DATA statement,
ement, 9191,, 119
119
DEFine statement,
DEFine statement, 120
120
Delay loop,
Delay loop, 64
64
DELete key,
DELete key, 14
14
DIMension statement,
DIMension statement, 96,96, 120
120
Directory, 20
Directory, 20
Disk drives
Disk drives
commands, 18·32,
commands, 18-32. 163·169
163-169
error messages,
error messages. 112-115
112-115
Division, 34
Division, 34
Duration, (see For
Duration , (see For...Next) 45
.. Next) 45
DX-64, ii
OX·64,

E
E
Editing
Edit programs, 14-15,
ing programs, 14-15, 41
41,, 62
62
END stat
END statement,
ement , 120120
Equal, not-equal·to,
Equal, not-equal-to, signs,
signs, 117
117
Equations.
Equatio 33-37, 117
ns, 33-37,
Error messages, App_
Error App. 8, App. L
Executive 64
Executive 64
installation, 3
transporting, 5
Expansion portport,, 1
1
EXPonent function, 125
Exponentiation, 34

F
F
(disk),
Files, (d 17-31
isk), 17·31
Files, (Rand
Files, (Random om Access), 20,
20, 26-29
Files, (Relative),
Files, (Relative), 20,
20, 24-26
Files, (Sequential),
Files, (Sequential). 20,
20, 21-24
21·24
v FOR statement,
FOR statement, 45,45, 120
120
FRE functions, 127 127
Function
Fun ction keys, 16, 52
16,52
Functions,
Functions, 124-127
124·127

G
G
Game
Game controls
controls and
and ports,
ports, 1,
" 10
10
GET statement,
statement, 51-52.
51-52, 121
121
GET#
GET# statement,
statement , 121,
121 , 164
164
Getting
Getting started,
started , 12-20
12-20
v GOSUB
GOSUB statement,
statement , 121
121
GOTO
GOTO (GO
(GO TO)
TO) statement,
sta lemen l , 40,
40, 121
121
Graphic
Graphic keys,
keys, 13.
13, 16
16
Graphic
Graphic symbols,
symbols, (see
(see graphic
graphic keys)
keys) 13,
13, 16.
16, 64.
64, App.
App. EE and
and FF
Greater
Grea ter than,
than, 117
117
v H
H
Headering
Headeri ng disks,
disks. 19
19
Hyperbolic
Hyperboli c functions,
functions, 138
138
v

171
171

Downloaded from www.Manualslib.com manuals search engine


-

IEEE·48 Interface,
IEEE-48 Interface,99
IF ...THEN statement,
IF...THEN 121
stat ement, 121
INPUT statement.
INPUT statement , 49-50,
49·50, 121
121
INPUn, 30.
INPUT#. 30, 122,
122, 165
165
INSert key,
INSert 14
key, 14
INTege r function,
INTeger function , 53-54,
53-54 , 125
125
In teger variable,
Integer variable, 42-44,
42-44 , 116
116
110 pinouts,
I/O pinouts, 139-
139· 142
142
ports, 11
1/0 ports,
I/O

JJ
Joysticks , 1.I, 10
Joysticks. 10
~

KK
Keyboard , 12-17
Keyboard, 12-17
m
Ll
LEFTS function,
LEFTS function, 126
126 ^>
LENgth function , 126
LENgth function, 126
Less than,117
Less than , 117 ,->
LET statement,
LET 122
sta tement , 122
LI ST command,
LIST command , 40,
40, 118
11 8
LOAD command, 18,
LOAD command. 18, 118
118
LOGarithm function,
LOGarithm function, 125
125
Loops, 40, 45
Loops, 40, 45
Lower case
Lower case characters,
characters , 16
16

M
M
Mathematic s, 33-37
Mathematics, 33-37
formu las, 138
formulas, 138
function
function table,
table, 138
138
symbols,
symbols. 33-34, 36. 36, 117
Memory
Memory maps,
maps, 136·1 37
136-137
MIDS function ,
MIDS function, 126 126
Multiplication,
Multiplication, 3333
Music,
Music, 1"
11. 79·88
79-88

N
N
Names
Names ^
prog ram, 19
program, 19
variable,
variable, 42·44,
42-44, 116
116 „
NEW
NEW command,
command, 19, 19, 3D,
30, 118
118
NEXT statement,, 45,
NEXT statement 45, 122
122 ^
NOT
NOT operator,
operator. 117
117
Numeric
Numeric variables
variables., 42-44,
42-44, 116
116
Numeric
Numeric functions, 124·126
funct ions, 124-126

o0
ON
ON statement
statement,, 122
122 ^
OPEN
OP statement, 19,
EN statement. 19, 30.
30. 122-123.
122-123, 167-168
167-168
Operators,
Operators, -^
arithmetic,
arithmetic, 33·37,
33-37, 117
117
logical,
logical, 117
117 ^
re lational, 117
relational, 117

172
172

Downloaded from www.Manualslib.com manuals search engine


v Pp
Packing Execu
Packing Executive
tive 6464,, 55
Parentheses, 36
Parentheses, 36
PEEK function,
PEEK (unction, 63,63, 125
125
v Peripherals,
Peripheral 9-11,
s, 9- 30, App.
11 , 30, App. S S
POKE statement,
POKE statement, 63, 63, 123
123
Ports. 110,
Ports, I/O, 1
1
POS function
POS function,, 127
127
PRINT statemen
PRINT statement. 32-38, 123
t, 32-38. 123
PRINTtt,, 30,
PRINT# 30, 123,
123, 166166
Printer commands,
Printer commands, 3()'31 30-31,, App.
App. SS
Programs
Programs
editing, 14·15,
editing, 14-15, 4141., 62
62
line numbering,
line numbering. 39 39
loading/saving (disk),
loading/saving (disk), 17-19,30,
17-19, 30, 118,
118, 119,
119, 168
Prompt,, 7,
Prompt 7, 49·50
49-50

aQ
Quotation marks,
Quotation marks, 32-33,
32-33, 37

R
R
RaNDom function, 53-54,
RaNDom function, 53-54, 125
125
Random numbers, 53-54
READ sta
READ statement, 91,, 124
tement , 91 124
REMark sstatement,
tat ement, 124
U Reserved words,
Reserved words, (see
(see Command
Command statements)
statements) 116-127
116-127
Restore key, 15
RESTORE statement,
RESTORE statement, 124124
Return key, 12
RETURN
RETU statement, 124
RN statement, 124
RIGHTS
RIG 126
H T$ function, 126
command,, 118
RUN command 118
RUN/STOP key, 16 16

S
SAVE
SAVE command, 19, 30, 119,
19,30, 168
119, 168
Saving
Saving programs (disk),
(disk), 19
19
Screen
Screen memory
memory maps,
maps, 65-66.
65·66, 136
136
SGN,
SGN , function,
function, 125
125
Shift
Shift key,
key, 12-13
12·13
SINe
SINe function,
function, 125
125
Sound
Sound effects,
effects, 89-90
89·90
SPC
SPC function,
function, 127
127
SX-64
SX·64 features,
features, 1-2
1·2
SPRITE
SPRITE EDITOR,
EDITOR, ii
SPRITE
SPRITE graphics,
graphics, 69-78
69·78
SQuaRe
SQuaRe function,
function, 126
126
STOP
STOP command,
command , 117.
117, 124
124
STOP
STOP key,
key , 16
16
v
String
Siring variables,
variables, 42-44,
42·44 , 116
116
STR$
STA$ (unctions,
func tio ns, 126
126
Subscripted
Subscripted variables,
variables , 95
95
Subtraction,
Subtraction, 33
33
Syntax
Syntax error,
error, 32.
32. App.
App. LL
SYS
SYS statement.
statement, 124
124

v
v 173
173

Downloaded from www.Manualslib.com manuals search engine


-

T
T
TAB fun ction, 127
TAB function, 127
TAN func tion, 126
TAN function, 126
Tl
TI variable,
variable, 116-117
116-117
Tl$
TIS variable.
variable, 116-117
116-1 17
Time clock.
Time clock, 116-117
116·117
TV
TV connections,
connections, 1." 99

U
U
Upper/Lower Case mode,
mode, 16
16
function, 126
USR function,
User defined function, (see DEF)
User DEF) 120

V
V
function , 126
VALue function, 126
Variables 42-44,
42·44, 116
116
95-96
array, 95-96
dimensions,
dimensions, 96
poin t, 42-44,
floating point, 42·44, 116
116 _
integer, 42-44.
42-44, 116
116
numeric, 42-44,
42·44, 116 ,-,
string ($),
($1. 42-44,
42·44 . 116
116
V ERIFY command, 30,
VERIFY 30, 119,
119, 169
Voice,
VOice, 79-84
79·84
^*\
W
W
WAIT command, 124

zZ
z·ao.
Z-80, 10

174

Downloaded from www.Manualslib.com manuals search engine


w

'-' MEMO
MEMO

'-'
'-'

v
v
v

Downloaded from www.Manualslib.com manuals search engine


MEMO
MEMO

--

"

Downloaded from www.Manualslib.com manuals search engine


u ECUTIVE
ECUTIVE 64
64 QUICK
QUICK REFERENCE
REFERENCE CARD
CARD
SIMPLE VARIABLES
SIMPLE VARIABLES
v ,,__ No",. ' 0,,(/"
PO !o()( f
POS(X) I . ....... <"" 0'" .... _ "". _
CIK/HOME
CtlI/HOM! "',,,_ • • " ..... ' 0 Io~ ....... . Of
R.... XT
1Il *~1101
1 70141
.. IB3E-3B
I UI ·)8
v !. 2 938?]5e6S-
:? Ue1UI8I - 30
)'
SHIFT
SHIn ClINHOMl
Ct ll/HOMI Cliorl
CIoOft . " .." OnO """' •• <"..... ,n
«S S33747
S""'<;I 1*1
J( n 0
0 la
' 0 35S
lH iMioctin ,ho'CK""
v • " " ."" tA·!), y ., " 19... , o. " ..... tN.. (0- 9 ) ""',""ble ~O"'''
SHIFT INSKDEl ln,e"i

.."
ee,.. be ...., •• _n 1 ,100. <><, ... . bu. _'" ' .... (,," , _ " •• 'Koo;I "

ARRAY VARIABLES
ARRAY VARIABLES
INSTiDEL
INSTIOfl

C'BL
Dtlfiei
0..10, ..

W~.n ."
When
<"","',•. ," e.." .~' <.... ~
,." .. ............... <010, h • .

v "~ N o",.
•• 1. <, •
lelic'i
PRINT
•• • , <010' ....... tHo .. ,od '"
~gl . o",." M _ XYISI
lIl(iJ
I ..·o · (), .... .. . _ n eSS )
v 1",.. ·0."", " . _ XI (SSS)
X*(S.S.S)
tn uiea -v.ih SHIFT itlf

Arrayi
...,,"" a* ul> '"
. I. ... ~ vi
0 1 gp to eleven .It"","" I' u",,, ,,,," 0-101 <O n be u" "
rfi !iubitr.D.i 0-10) con be uied
tHo ...... " ""po.IIo- •• co •• on"
*.here ... ..ci.,d
.. 10.,. needed ",,".>...... .....to ,100" . .... .. ....... , ,, need ' "
A" a* I with more *non eleven element
a"ii-
9'''P'''' """lay"""',
unplav mode

·"". n ,, ' od ... .. ~ n" ...... .. <010 ' ••• .


1>0 O''''o",oon OO
u •• f• • ', OO"OnOI •• ,t ,010'
ALGEBRAIC
ALGEBRAIC OPERATORS
OPERATORS
ARRAYS AND STRINGS
STRINGS
v
(.""" ".. ...
NoJ< ~ .. a''''.
,- DIY.
3IM All.*

LEN
liN IXII
t!
At . V t.

J< ~ I
Seri
~" m
'•text
",,,3»,mum
.. ,,,",,, lublir.ptl
. ..... . >' ipote
. 1. .... .. 11
tirmc

V
" UGFIing
,·" ... nQ
• •".n ., number
Rtluin .. " ... 10.' of
al AlO.O
o .....
of chorotlfr!
Ol
000)
, 00'oct.,. in
,n
f".
. "b .. " .. " lor A
, ..... . Io'
lo· !X
! ~·■ I|*|Y*
A
,I · Y' I)'
I ' 11' "

X~
.' Divilicn

• Addition
Sl ~ ~ (
STRilX, R.lurn ""m.'.e
R.' ",~,i nunwnc .alue
' 01 ... ot
01 X
...
v KAllXi!
ton.er

B,Wn
ed lo a 11-mg

, numeric .alv» ol Ai. uc


RELATIONAL
RELATIONAL AND
..
LOGICAL OPERATORS
ANO LOGICAL
~
OPERATORS
CHBJlXI

..
r.,,i nc nnUWer:c cha.a^ie.

,x

D. ,w'''' ASCII f.".


v t."
latl Thnn
1......
<ltd . . ....

G_.,.•• , I,,,.. thorot er if XI


" '"''' ' ' ' o. H
- tIn)
.. , Than or equal
r...... ". la
I" ..... ' '"
lIfT ~ A~ "k:
lEFTKAS p.,,,......leftmoit
Berurn' , It...... " X, <
(ho-otwn
..... 0< ••" ,,'
of A ~

v G'.",.< I~ .. n ... 1.",01 To


""COH n A~
BIGHTS!Ai .I. ,
Xj Renjrn' ''9''''''''''
V~'u ..... .ighfmniT X
~ (horailtr! , .... '0< ••"
o A~
otf AI
NOT '09",,1
logical "Nor"
N O'
WDJlAJ » '■ "" w'~' Y ''''''0<', ', c l .,
v AND Log.:ol
AN D 1090<,,1 AnO
.. ""
OR
OB '09 ....
too:; a 'I Or'
0.
EifHIIMn tauoli II
( . ... ........ ""uOI, I "Him il 10"
uo 0 ,I lolie
. INPUTfOUTPUT
INPUT/OUTPUT COMMANDS
COMMANDS
SYSTEM COM MANDS INPUT A) .jB A PRINTi 1 on KIHK ond •.•].■! FQ

v tOAO NII.M! •B
IOAD "NAME" 10<.<1 n "'''I/,om
londi. .. from d,,
o'ogram I..,... dill~ INPUT ABC A
S»E
!.It.It NAoMI
NAWE .9 So ••• "a "'''9''''''
iovei program '" i« " ..,
ilnl ■nln ualu* Can olio INPUT Ai

VI RIIY N....Y! I ~,I, •• t~o ' "'''11'''' '' .. 0. WEd GET A] (M A


v 'act*-' value,
''''''Oe'' ....."., no PE'UPN
"<> ~II U "N needed
~ .... _"

v ""
RUN
BUN " .
RUN ( ' H"'~' "'<>\I'''~ " " ",~ o. I.n.
OAI
DATA. ABC
AB C , ... ,""" .. 0 •• , " • • ol~. , ' "0'
co .. tHo
Be ...
Kied
. .. by
b. ~!.
BEAD " a ..... ~ " .
O HOTUWK1
~ IAD . ~ 0' • A" '\1" ' " f" DA' ....'". ' " A ~ O. A

u ,.,
5ro~

END
"1 5' 0 .. 1 ..••• " do ' o ""'" '" '0 " ''''
",AO,n
BEADmg g ,".
rhe DAIA I,,,
DAlA "g"'"
CO NI
CONT Co",.~_. "'<>\1'0'" ~ . ... ", ... " 1'0'" PRIM A - A PBINTi
""' ilr.r.9
NII "" A-
"\1 A " .... VOl". 0) A
I",~ ~ ~" 0'011'''''' 'w", ""I,." 'ob. dC'a
v V..".~. 'O,,'.n!. ,,/ "'. ""'....
PROGRAM FLOW

,M ■ V GOTO X Brnnthei 'o lin> X


SY5 HJUJU Jl ■mp* ro..i cull a ' hoc hint It A ~ l 'THEN
I'If A-3 ..! N 10 ..IF 0aiietion
........ " .,is "Irun tHEN
... ''' IN "" vl_
'oIIo ~ "'1I I>On 0' . ' 0 .. ...... ' I'
IP
0'<>\1''''''
P' ogra m. " " "Fling
no "'9 0'
ol
'A' "
.....
WAIT AII ~ T 1
X.1.Z ""'iI'0'" ~o;" _ . e_ ' .. ~" 0' '0 ... " "''''' ~." "".. ",,"'bo.
.... ... "''' ~ ~
.hen
... " l(Oiled _. , lI and
O R." ~i«i lFOR A-l
OR A TO 10
-I '0 [nduiel
Io ... w••• "oil• •naitmenii b<o' .... . ~ 'Ft0 "
' 0 ' . ........ between
v AHOed ... .,,, T " _ ' ~ 'O ~U. 2
STfP 1 NEXTl
NU ,,"" eD"''''''~d....., NU
and in»etpanding MIXT. ""~ A
l w.rh A
U~I (~ ! ." " . , .... "" 01 X ... ° _~ aomg
9""'9 from ,I
f."",, Io 10
'0 10 by 1
t>y 2 Sipd
St. nze
" ""
'-"9.... \1 • • " b,own •• .. I .. ~ ......... ,If,•.;
NEXT A
H(.l A Define,
091",... . "ft"
end 01
of ioo<>
loop A n,
•• 0optional
..........1
FORMATTING COMMANDS
EDITING AND FORMATIING GOSUB 1ODO
G05Ue 1000 B' o,,<~. '0
Bionthe. io .lubrouime
"b'ow''''~ """
i.oimg
"9 '"oi
v US
LISTT Ilull
.. •••1 ■Mire
n' " . "'<>\1'0,",
pit ig'or
l.ii. 2O00

UST
LIST A,
a IB f."........
lull 1 ,om U. A
I.,,, io ~"
A ... . IB
line BETURN Uarki end gl luhroutinr Returni i

C_...' ..... _ ,0" bo L"." bon


v ,..(,*
•• md
'1;1 ..... di» ing p rogram
. " ""'''111>'<>\1'0''' , '00<"''''''
iimwIiei GDSUfl
GOSUB
TAB(X) ON X GOTO A B B'onchet to Xth line number on
U»d
V in PIII
.." ." PRINTNT "0 .. .... " "
iron S....... )(
v "","",n. _ ", •••"
DO1H» >mn
ill II X = I bfonin*i m A. etc
ON X GOSUB A.B Bronchei 10 tubroulm* ot xth ling
SPCIX
SF"C(X)) PRINT i X alar 111 or lin*

v
v

Downloaded from www.Manualslib.com manuals search engine


Downloaded from www.Manualslib.com manuals search engine
the
Get th e most out of your Commodore computer with a subscription to
Commodore's user magazines
Commodore's
; 0 ,. , ' a ........
POWERtPLfif C' commodore
Fun, Gam
Games
es and Beyond with Commo
Commodore
dore The
Th Microcomputer
e Micro Magazine
comput e r Ma gazin e
Computers
Home Compul e rs
Publisl
Puhl"hcd qu,trt",hV III
in ,\I.l
Mart h.,
f t 11 lurii1 , '>I'lllt'mllt"
JUII" her .111111
.inif [)i
)"1 ",.,lh'l ,COUTH
'( )\\'[1{ Widely read 11\
\Vl t t,'lv 1I',ul liv ",luI
ed ,11"" -.. hU"
huMiifssmiTi.
lh "'IIl"1l siuden
,lud,'llhs ,lIltl liiimi-i, IJII'I,.,
,tii(l 111111H' I" " ,I, .
unipiittTisls.
P ....w ,.. devol,'d
WAY. oted '4111,1,
ilely lollh'
ii» Hi 1 "~
t'\illlll1 g ,md
itnii; i f.Jprdl\Ik 1"p.lIlrilJl):
exp.u \\wld riel ,,'
ol this 1,,·
Ill" bi-monthly \n
mtllllhh IJUI,t.(,l1l1)1l
)n p ft)vldl ', .r,1 \1·h"ll·
provides whidf h t i'
it ,h.lling
sh.inil^ ,·"IU'IVI·
exclusive p"I<IU(1
product
(. omn
Commodore re h'lIIlt'
hiii i' (wnp
t ompul nj;.. It prn\,IIII',
ulmg provi i.ible nHllJfI1"tll
I,rl u.rlll!- ml i mOIl
in • in Ill'W
new irmation
1I11011l on (olllm.
ll.llllllll)l\ ( i lore 'r'h'II1
)( lun' systems. proi;rjnv
'. p,ogl linj; I.
,ullmlllg lc( hni(|iies,. h.H
" hlllljUt" h.trdwiiie
tiW,lrt'
produ h .•Ipplll
pHJclu\ pplk ,lt Ullh 'HIgr,Illlllllr rt: 1.,\ h"II III'<' h ·,U IIII'):',II.
("dill ■s, Iprogram
Ktlls,, g.UIlt". iuiil-.ll- mlt',■Mac ing..•and
r.lt Itlg j ilii .111(11"
Uld .Ipplrt ,1 inns hlltor tile \miIi1 ••
IllI" \\liI.· r.inj>e
mg. ' 0 >l1 (( '>1111111.11.11,,',
oinmiidure s pI"du, pnidui hIs
tome, t dl'~I)"'IllLJllIl
hUIIlI.', nd 11I
,l tllm' ,1IIe!
nu.iMon just
.. r .ilxii iifl 1·1,,·
,llxlut .1I1\lh,I1': else ( Ioul1rn'I(I."
inlort' h(imi
" hrlln,- issue1t IInl,IIII'
l .1I h '''lit" ontiiin "',lItH l" 01
ires 1111.,,,,,,
ot inli-rest 10 . In\"'1\" Ih.ll
loanyon tti.it U'I·'
use . , )1 I' thinking
Ihmklng
torn pi
lurnput cd tu
l' f [I .. ,'" nl'l'd In km
k llll\\' It) ).:1'1 1Il,l\IIIIIIII1\'I1I"\ rllt 'llI "u tili! ol rh
their
" " .,huulnit pllll
pun h.hlJl
hasin;; ( onit
g (IUl indorc lr(]in|>mi>nl
HIlOdllr\' del
'ljUlplllt'1l1 (. lilt' lIlo,1
,-1 lh<- musl nul
nut III roul 11111
ol your nm Irt>-
U'
hurni
hunw IOlllpullng \"IWfWllt " '>uthillptlll!l pllt" pn e: S '-.in (HI \I , ',tr
HI IMI lipiltt'l \\
I 11lI1p"I.·, with (iKlill
Ilh ( IInHmldmt'iiirc 'l.1.'g.ll1l1t"
M.iga/ini' -'lIlhl
Sulisi Oplll
tiption plllt' SI.,.I
"' pricf ^Ti.lHI \t',lf
vcir

FILL OUT AND MAIL TODAY GET MORE INFORMATION FOR YOUR MONEY
Please ~ i gn me
Plea se sign m e up for:
for :
Name
Name Phone
__ yea r (~) ol
_ycar!s) 01 POWER/PLAY
POWER/PIJW a)
at •>!().(X)/year
Sm.OD/year
Address _ _ _ _ _ _ _ _ _ _ _ __
Address
_ yc ar (~) of
_year(s) of COMMODORE
CO,\lVv\ODOR[ at
,"II 515.00'year
S15.OOIyear
City
Ci ty Sial e
Stale l ip
Zip _ _ __
Canadian
Ca nadian and Foreign:
and Forci gn : POWER/PLAY$?5.00/year;
POWER/PI.AY S1S.00lyca r; COM-
COM·
Compul e r model:
Computer model: _ _ _ _ _ _ _ _ _ _ _ _ __ MODORE $25.0Qtyear
S2S.00lycar
I:ncloscd is
Inclosed is my
my check
chcck or
or money
m o ney order
o rd er for
for $S _ _ __ __
o
i ] Address
Addres~ Change.
Change . Enter new address
dtkJ r c~~ above
.IUUVl.' &
&. enclose
cn du ~c
present
present mailing
mailing label
label Make check
ch etk or
or money order
ord er payable
payablc to:
10:
Io] Renewal
Ren ewa l subscription
sub scription COMMODORE
COMMODORE BUSINESS
BUSINESS MACHINES, INC.
Io) New
New subscription
subscrip tion The Meadows,
Meadows, 487 Pi,k Drive,
487 Devon Park Drive, Wayne,
Wayne, PA 19087
19087

) ) ) ) ') ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )

Downloaded from www.Manualslib.com manuals search engine


(i

(i

(i

Downloaded from www.Manualslib.com manuals search engine


COMMODORE SALES
COMMODORE SALES CENTERS
CENTERS

v Commodore Business
Commodore Business Mochines,
Machines, Inc.
Inc.
1200 W;lsan
1200 Wilson Dr;ve
Drive
v Westchester, PA
WeSichesler, PA 19380,
19380, US.A.
U.S.A.

Commodore Business
Commodore Business Mochines
Machines Ltd
Ltd..
3370 Pharmacy
3370 Pharmacy Aven
Avenue, Agincourt,
ue, Ag;ncaurl,
Ontario, MIW
Onlar;o, M1W 2K2K4, Canada
4 , Canada

Commodore Business
Commodore Business Mochines
Machines (UK) Ltd.
Ltd
v 675 Ajax
675 Ajgx Aven
Avenue, Trading Estate,
ue, Trading Estate,
Slough Berks,
Slough Berks, Sll
SL1 4BG
4BG,, England
England

Commodore Bueromashinen GmbH


Lvonerstrasse 38,
lyonerslroSSe 38, PO
PO BOX
3OX710126
710126
Frankfult 6000, West Germany
Frankl ull 6000, WeSi Germony

Italiana S.R.L.
Commodore Itoliana
Via Conservatoire 22
Via COnservQlorio 22
Milano
M 20122,
;iono 201 Italy
22, 110 1'1
v
Commodore Information Center
Center
5 Onion Road
5 On;on
Lane
lane Cove 2066
2066 NSW,
NSW, Australia
Au slral ;a

Commodore
Commodore Computer
Computer B.V.B. V.
Marksingel
Mar s; ngel 2e481
2e4811I N.V.
NY Breda
Breda
Postlrus
POSilru s 720,
720, 480
~80 3aS
3aS Breda,
Breda, Netherlands
NClher lands

Commodore
Commodore AG(Schweiz)
AG(Schweiz)
Aeschenvorstadt
Aesc henvorSi ad I 57
57
401 0 Basel,
40 10 Basel, Switzerland
Sw dzcr land

Downloaded from www.Manualslib.com manuals search engine


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
Downloaded from www.Manualslib.com manuals search engine

You might also like