0% found this document useful (0 votes)
325 views

AmstradCPC6128 Hypertext en Sinewalker

Manual

Uploaded by

Pavlocky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
325 views

AmstradCPC6128 Hypertext en Sinewalker

Manual

Uploaded by

Pavlocky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 520

Introduction

AMSTRAD CPC6128
Integrated Computer/Disc System
A Logical Progression
AMSTRAD's hugely successful CPC464 and CPC664 systems have provided a sound
basis for further development, and now we proudly present the CPC6128.
In keeping with our policy of compatibility, the CPC6128 will operate with software
from both the CPC664 and CPC464 systems - but additionally provides a further 64K
bytes of RAM for use with CP/M and other user applications.

CP/MPlus
CP/M Plus (also known as CP/M 3.1) provides very easy access to the library ofCP/M
80 software. The 61K TPA means that any CP/M 80 program will find room to run,
and provide ample space for data. CP/M Plus is compatible with CP/M 2.2, although
we have provided both versions to ensure that applications developed using firmware
features in the AMSTRAD CP/M 2.2 systems will operate without modification.
CP/M Plus includes many enhancements that improve the performance of the
system, and most existing CP/M 2.2 software can take advantage of these facilities
without conflict. The CP/M Plus system incorporates a specific terminal emulation
feature whereby software that is configured to use screen handling characteristics
_similaLto_VT52and.Zenith-Z19/Z29-terminals-can-be installed-without further
customisation.

GSX
The Graphics Extension System supplied with this version of CP/M Plus enables
applications programs to address printers/plotters and the screen using standard
instructions that extend the concept of CP/M program portability beyond the text
screen. Software that takes advantage of GSX will be able to be interfaced with a
number of graphics devices to provide hard copy of graphs, diagrams etc.

Dr. LOGO
Digital Research's LOGO continues to make inroads into computer education - and
the increased memory of the 6128 has permitted extensions to the Dr. LOGO first
used under CP/M 2.2. Programs will of course be upwards compatible from
AMSTRAD CP/M 2.2.
Introduction

CPC 6128

Disc
The CPC664 set the standard for the future with its built in disc system, and the
CPC6128 continues to bring low cost disc computing to increasingly demanding and
exacting users who want personal computer performance at a home computer price.
The discs from all AMSTRAD systems are interchangeable, although programs that
take advantage of the advanced features of CP/M Plus and GSX will obviously not
work on models without these facilities.
Finally, the CPC6128 is supported by one of the largest consumer electronics
organisations in the country, and the AMSTRAD computer users' club with its
authoritative monthly magazine is already firmly established as the leading source
of news and information.

Software
The CPC6128 runs all CPC664 and CPC464IDDIl disc software, and virtually all
CPC464 cassette software (with a cassette unit connected to the CPC6128 of course),
giving the owner an instant and enviable choice of software from AMSOFT's
extensive range, as weB as the products of many independent vendors.

AMSOFT
A di vision of

CONSUMER ELECTRONICS PLC.


Copyright 1985 AMSOFT, AMSTRAD Consumer Electronics plc.

Neither the whole nor any part of the information contained herein, nor the product described in this manual, may
be adapted or reproduced in any material form except with the prior written approval of AMSTRAD Consumer
Electronics plc. ('AMSTRAD').
The product described in this manual, and products for use with it are subject to continuous development and
improvement. All information of a technical nature and parti~ulars of the product and its use (including the
information and particulars in this manual) are given by AMSTRAD in good faith. However, it is acknowledged
that there may be errors or omissions in this manual. A list of details of any amendments or revisions to this
manual can be obtained by sending a stamped, self addressed envelope to AMSOFT Technical Enquiries. We ask
that all users take care to submit their reply paid user registration and guarantee cards.
You are also advised to complete and send off your Digital Research User registration card.

CPC 6128

Introduction

AMSOFT welcome comments and suggestions relating to the product or to this


manual.
All correspondence should be addressed to:

AMSOFT
Brentwood House,
169 Kings Road,
Brentwood,
EssexCM144EF
All maintenance and service on the product must be carried out by AMSOFT
authorised dealers. Neither AMSOFT nor AMSTRAD can accept any liability
whatsoever for any loss or damage caused by service or maintenance by unauthorised
personnel. This guide is intended only to assist the reader in the use of the product,
and therefore AMSOFT and AMSTRAD shall not be liable for any loss or damage
whatsoever arising from the use of any information or particulars in, or any error or
omission in, this guide or any incorrect use of the product.

Dr. LOGO, CPIM, CP/M Plus, GSX, and DR Graph are trademarks ofDigital Research Inc.
Z80 is a trademark ofZilog Inc.
IBM and IBM PC are trademarks ofInternational Business Machines Inc.
Z19, Z29, and H89 are trademarks of Zenith Data Systems Inc.
VT52 is a trademark of Digital Equipment Corp.
AMSDOS, CPC6128, CPC664, and CPC464 are trademarks of AMSTRAD.

- - - .-- - - - - - - - - -

First Published 1985.


- --- - - - -SecondEditionSummer1985.-- - - - Third Edition Winter 1985.

Compiled by Ivor Spital


Written by Ivor Spital, RolandPerry, William Poel, CliffLawson, with acknowledgements to Locomotive Software Ltd.
Contributions by Alexander Martin, David Radisic, Ken Clark.
Published by AMSTRAD.
Typeset by KAMSETtypesetting graphics (Brentwood).
AMSTRAD is a registered trademark of AMSTRAD Consumer Electronics plc.
Unauthorised use of the trademarks or word AMSTRAD is strictly forbidden.

Introduction

CPC 6128

IMPORTANT
You must read this ....

Installation Notes
1.

Always connect the Mains Lead to a 3-pin plug following the instructions
contained in part 1 of the Foundation course.

2.

Never attempt to connect the system to any Mains Supply other than
220-240V ~ 50Hz.

3.

There are no user serviceable parts inside the system. Do not attempt to gain
access into the equipment. Refer all servicing to qualified service personnel.

4.

To avoid eye-strain, the monitor should be placed as far away as possible from
the keyboard and operated in an adequately lit room. The monitor
BRIGHTNESS control should be kept to as Iowa setting as possible.

5.

The computer should be placed centrally in front of the monitor, but as far away
from the screen as possible. For maximum data reliability, the disc drive section
of the computer should NOT be placed directly in front ofthe monitor, but to the
right of it. Do not place the computer close to any source of electrical
interference.

6.

Always keep disc dri ves and discs away from magnetic fields.

7.

If you are operating a 2-drive system, keep the interconnecting ribbon cable to
the 2nd drive, away from Mains Leads.

8.

Do not block or cover any ventila tion holes.

9.

Do not use or store the equipment in excessively hot, cold, damp, or dusty areas.

Operation Notes
(Don't worry if you are a little baffled by the technical jargon in this section; the
importance of these warnings will become clearer as you work through this manual.)
1.

Never switch the system on or off with a disc in the drive. Doing so will corrupt
your disc, losing valuable programs or data.

Warnings

CPC 6128

2.

Always make back-up (duplicate) copies of discs which contain valuable


programs. It is especially important to make back-up copies ofthe master CP/M
system discs provided with the 6128. Should you otHerwise accidentally lose or
corrupt your discs, replacing them could prove expensive.

3.

Make sure that you do not accidentally overwrite your master CP/M system
discs, by ensuring that the Write Protect holes on the discs are always open.

4.

If you are operating a 2-drive system, i.e. if you have purchased an additional
AMSTRAD FD1, always switch on the 2nd disc drive before switching on the
computer.

5.

Never touch the floppy disc surface itself, inside its protective casing.

6.

Do not eject a disc while it is being read from or written to.

7.

Always remember that formatting a disc will erase any previous contents.

8.

The internal disc interface occupies a small portion ofthe memory that in some
cases, was used by commercial writers of cassette based software for the
AMSTRAD model CPC464. These cassettes will not operate properly with the
6128 + Cassette unit. If you have any queries regarding cassette based software
compatibility, contact AMSOFT on Brentwood (0277) 230222. Note however,
that most major AMSOFT software titles are available on disc for the 6128.

The licence agreement for your CP/M system discs, (which are electronically
serial-number encoded) permit their use on a single computer system only. In
particular this means that you are prohibited from giving any other person a
_<!isc with YOUR serial-numbered copy of CP/M on it. Carefully read the End
User Program Licence Agreement TAppenaixl)~-towards-tlie endoCthis manual.

9.

CPC 6128

Warnings

Contents
Chapter I
Foundation Course
Setting up
Connecting peripherals
Floppy discs
Keyboard familiarisation
Loading software, and the 'Welcome' program
Introduction to BASIC keywords
Introduction to disc operations
Modes colours and graphics
Sound
Introduction to AMSDOS and CP/M
Introduction to the Bank Manager

Chapter 2
Beyond Foundations
Writing a simple program
Evolution and afterthoughts
Using an array
Introducing a menu
Loading and saving variables to disc
Editing and line numbering
--'I'idying-upa-progmm--------------- ------ --

Chapter 3
Complete List of AMSTRAD CPC6128 BASIC Keywords
Description of notation used
Alphabetical listing of keywords comprising:
Keyword
Formal syntax
Example
Description
Special notes (where applicable)
Associated keywords

CPC6128

Contents

Chapter 4
Using Discs and Cassettes
Backup master disc
Getting started with CP/M Plus
Use of Help files
Single and multiple drive operation
Copying files
BASIC disc applications
Getting started with GSX

CP/M2.2
Operation with cassettes

ChapterS
AMSDOS and CP/M
AMSDOS:
Introduction to AMSDOS
Disc directory
Filenames filetypes and headers
Wild cards
Summary of AMSDOS commands
Manipulating and copying files
Reference guide to error messages

CP/M:
Introduction to CP/M
---- Bootiiig-CP7M Plus-- - - - - -- - ---- - -- -- - - Direct Console Mode
Transient programs
Managing peripherals
Working with CP/M 2.2

Chapter 6
Introduction to LOGO
What is LOGO?
Dr. LOGO procedures
Editing programs and procedures
Operating hints

Contents

CPC6128

Chapter 6 continued....
Summary of Dr. LOGO primitives covering:
Word and list processing
Arithmetic operations
Logical operations
Variables
Procedures
Editing
Printer functions
Text screen
Graphic screen
Turtle Graphics
Workspace management
Property lists
Disc files
Keyboard andjoystick
Sound
Flow of control
Exception handling
System primiti ves
System variables
System properties

Chapter 7
For Your Reference ....
----~~----~

Cursor locations and control code extensions


Interrupts
ASCII and graphics characters
Key references
Sound
Error messages
BASIC keywords
Planners
Connections
Printers
Joysticks
Disc organisation
Resident System eXtensions (RSX's)
Memory
CP/M Plus Terminal Emulator
CP/M Plus character set

CPC6128

Contents

Chapter 8
More about the Bank Manager....
Using the second 64K of memory
Storing screen images:
Hardware bank switching
Swapping screens
Copying screens
Pseudo-file operation:
Creating a RAMdisc
Current record
Reading, writing, and searching for strings
RAMfile example program

Chapter 9
At Your Leisure ....
General:
The world of microcomputers
Hardware and software
Comparing computers
Some popular misconceptions
How a computer deals with your instructions
The digital world
- --Bitsand-bytes-- - --------- ------- ----------------- ------------- - - __
The BIN ARY number system
The HEXADECIMAL number system
CPC6128 Specific functions:
Character set
Variables
Logic
User defined characters
Print formatting
Windows
Interrupts
Data
Sound
Graphics
Graphics using the second 64K of memory
Screen Designer program

Contents

CPC6128

Appendices
Appendix 1 End User Program Licence Agreement
.
Appendix 2 Glossary of Terms
Appendix 3 Some Programs For you ....
Bustout
Bomber
Telly tennis
Electric fencing
Amthello
Raffles
Appendix 4 Index

CPC6128

Contents

Chapterl
Foundation Course
Part 1: Setting Up ....
The CPC6128 can be set up with either:
1. The AMSTRAD GT65 Green Tube Monitor
2. The AMSTRAD CTM644 Colour Monitor
3. The AMSTRAD MP2 Modulator/Power Supply and a domestic (UHF) colour
TV receiver.

Fitting a Mains Plug


The CPC6128 operates from a 220-240Volt~ 50Hz Mains supply. Fit a proper Mains
Plug to the Mains Lead of either the GT65, CTM644, or MP2. If a 13 Amp (BS1363)
Plug is used, a 5 Amp Fuse must be fitted. The 13 Amp Fuse supplied in a new plug
must NOT be used. If any other type of Plug is used, a 5 Amp Fuse must be fitted
either in the Plug or Adaptor or at the Distribution Board.

Important
The wires in the Mains Lead are coloured in accordance with the following code:
Blue : Neutral
Brown :Live
As the colours of the wires in the Mains Lead of this apparatus may notcorrespond
with the coloured markings identifying the terminals in your plug, proceed as
follows:
The wire which is coloured BLUE must be connected to the terminal which is marked
with the letter 'N' or coloured Black.
The wire which is coloured BROWN must be connected to the terminal which is
marked with the letter 'L' or coloured Red.
Disconnect the Mains Plug from the Supply Socket when not in use.
Do not attempt to remove any screws, nor open the casing ofthe computer, monitor, or
Modulator/Power supply unit. Always obey the warning on the rating label which is
located underneath the case ofthe CPC6128 and MP2, and on the rear cabinet ofthe
GT65 and CTM644:

WARNING -LIVE PARTS INSIDE. DO NOT REMOVE ANY SCREWS


Foundation Course

Chapter 1 Page 1

Connecting the computer to a monitor


(If you are using the CPC6128 with the MP2 Modulator/Power supply, skip to the
next section.)

1.

Make sure that the monitor is not plugged into the Mains supply socket.

2.

Connect the lead from the front of the monitor, which is fitted with the larger
(6-pin DIN) plug, into the rear socket of the computer marked MONITOR.

3.

Connect the lead from the front of the monitor, which is fitted with the smaller
(5V DC) plug, into the rear socket on the computer marked 5V DC.

4.

Connect the lead from the back of the computer, which is fitted with a small
(12V DC) plug, into the socket at the front ofthe monitor.

FRONT OF MONITOR
REAR PANEL OF COMPUTER

JOOOOOUuooooouoo

Chapter 1 Page 2

Foundation Course

Connecting the computer to an MP2


Modulator/Power supply unit
The MP2 is an additional item that you may wish to purchase if you are currently
using your CPC6128 computer with the GT65 green tube monitor. The MP2 enables
you to to use the computer with your domestic colour TV and thereby enjoy the full
colour facilities of your CPC6128 computer.
The MP2 should be positioned next to the right hand end ofthe CPC6128.
1.

Make sure that the MP2 is not plugged into the Mains supply socket.

2.

Connect the lead from the MP2 which is fitted with the larger (6-pin DIN) plug,
into the rear socket ofthe computer marked MONITOR.

3.

Connect the lead from the MP2 which is fitted with the smaller (5V DC) plug,
into the rear socket on the computer marked 5V DC.

4.

Connect the lead from the MP2 which is fitted with an aerial plug, into the
AERIAL or ANTENNA socket of your TV set.

5.

Connect the lead from the back of the computer, which is fitted with a small
(12V DC) plug, into the socket at the rear of the MP2.

Foundation Course

Chapter 1 Page 3

Switching on - CPC6128 and GT6S/CTM644


system
(If you are using the CPC6128 with the MP2 Modulator/Power supply, skip to the
next section.)

Having connected up the system as shown previously, insert the Mains Plug into the
Supply socket and switch on. Press the POWER button at the bottom right hand
corner of the monitor so that it is set to the IN position. When the button is set to the
OUT position, the Mains supply to the system is OFF.
Switch on the computer using the POWER switch on the back panel.
The red ON lamp at the top right of the keyboard should be illuminated, and the
monitor will display the following picture:

AMstrad 128K Microco~put.r (v3)


.1985 A~strad Consu~er ElectronicsLPdlC
and Loco~otive Softwaret .
BASIC 1.1
Ready

To avoid unnecessary eye-strain, adjust the control marked BRIGHTNESS until the
display is adequately bright for comfortable viewing, without glare or blurring ofthe
characters on the screen.
The BRIGHTNESS control will be found on the lower front panel ofthe GT65, or at the
right hand side of the CTM644.
If you are using the GT65 green monitor, you may need to adjust the CONTRAST and
Vertical HOLD controls on the lower front panel.
The CONTRAST should be adjusted to the minimum setting consistent with
comfortable viewing.
The Vertical HOLD control on the GT65 is marked V-HOLD, and should be adjusted so
that the display is correctly positioned in the middle of the screen, without jitter' or
'roll'.

Chapter 1 Page 4

Foundation Course

Switching on - CPC6128 and MP2


Modulator/Power supply system
Having connected up the system as shown previously, insert the Mains Plug into the
Supply socket.
Switch on the computer using the POWER switch on the back panel.
The red ON lamp at the top right of the keyboard should be illuminated, and you must
now tune in your TV set to receive the signal from the computer.
If you have a TV with push-button channel selection, press a channel button to select
a spare or unused channel. Adjust the corresponding tuning control in accordance
with the TV set manufacturer's instructions (the signal will be approximately at
channel 36 if your TV has a marked tuning scale), until you receive a picture that
looks like:

Aftstrad 128H MicrocOMPuter (v3)


1985 AMstrad ConsuMer Electronics PdlC
and LOCOMotive Software Lt .
BASIC 1.1
Ready

Tune in the TV set accurately until the clearest picture is seen. The writing will be
gold/yellow on a deep blue background.
If your TV has a rotary programme selector knob, turn the tuning knob until the
above picture appears and remains perfectly steady. (Again, at approximately
channel 36) .

Foundation Course

Chapter 1 Page 5

Other Connections....
If you wish to connect any other peripherals to the standard system, namely:
Joystick(s)
Cassette unit
Printer
2nd disc drive
External amplifier/speakers
Expansion device(s)
.... details will be found in part 2 ofthis Foundation course.
Finally, check that you have observed the following warnings given at the beginning
of this manual, in the section entitled 'IMPORTANT':
INSTALLATION NOTES 1,2,4,5,6,7,8
OPERATION NOTE 1

Chapter 1 Page 6

Foundation Course

Part 2: Connecting your


peripherals ....
This section explains how the various peripherals, or add-ons, are connected to the
CPC6128 system. Details concerning the use of these devices will be found in the
appropriate sections ofthis manual.

Joystick
The AMSOFT joystick model JY2 is an additional item that you may wish to
purchase if you are using the 6128 computer with games software which incorporates
the facility for joystick control and 'firing'.
Connect the plug fitted to the JY2 lead into the socket marked JOYSTICK on the
computer. The 6128 can be used with two joysticks; the !?econd joystick should be
plugged into the socket on the first joystick.
The AMSOFT joystick model JY1 is also suitable for use with this computer.
Further information onjoysticks will be found later in this manual.
The AMSTRAD Light pen model LP-1 may be connected to this socket.

Programs may be loaded from, or saved to tape instead of disc. The commands which
instruct the computer to direct data to and from disc or tape are explained later in this
manual.
To connect your cassette unit to the 6128, you will require the AMSOFT CL1lead, or
any other equivalent standard cassette-interconnecting lead.
Insert the end of the lead with the larger (5-pin DIN) plug, into the socket marked
TAPE on the computer.
Insert the plug at the end of the Blue cable into the socket on your cassette unit
marked REMOTE or REM.
Insert the plug at the end of the Red cable into the socket on your cassette unit
marked MIC, COMPUTER IN, or INPUT.
Insert the plug at the end of the White cable into the socket on your cassette unit
marked EAR, COMPUTER OUT, or OUTPUT.
Foundation Course

Chapter 1 Page 7

It is important to remember that the successful transfer of data between the 6128 and
cassette is largely dependent upon the correct setting of the LEVEL or VOLUME
control on your cassette unit. If you cannot seem to load or save programs properly,
experiment with different LEVEL control positions until the optimum setting is
found.

Printer
The 6128 may be used with any Centronics compatible parallel printer. If you intend
to connect an AMSTRAD printer to the 6128, simply use the interconnecting lead
provided with the printer.

If you wish to use any other Centronics compatible printer, you will require the
AMSOFT PL1 printer interconnecting lead.
Connect the end of the lead which is fitted with the flat edge-connector plug, into the
socket marked PRINTER at the rear ofthe computer.
Connect the other end ofthe lead which is fitted with a Centronics style plug, into the
socket at the rear of the printer. If the printer is equipped with security clips at each
side ofthe socket, these may be clipped into the cut-outs at the side of the printer plug.
Details of printer operation will be found later in this manual.

A 2nd disc drive (AMSTRAD FD 1)


The AMSTRAD FD1 may be added to the system as a 2nd disc drive. The advantages
. o(a2-driVeSystem-wiICbe partlcuw.rlY-apparenCto the-regular CP/M user, since
many programs are configured to run with the library program disc inserted in one
drive, and the working data files stored on a disc in the second drive.
Operation under CP/M always requires that a program be loaded from disc (there is
no access to the ROM BASIC). Since CP/M allows the use of multiple files by an
overlay technique that permits programs that are larger than the RAM memory, the
actual library disc may contain so many program files that there is little workspace
left for the data.
Thanks to the versatility ofthe utilities provided with your 6128 system disc, you can
do all necessary file maintenance; copying, erasing etc, on a single disc drive.
However a second drive will certainly speed up these processes and reduce the scope
for accidents.
To connect the FD1 to the 6128, you will require the AMSOFT DI2 disc interconnecting lead.

Chapter 1 Page 8

Foundation Course

Connect the end of the lead which is fitted with the larger edge-connector plug, into
the socket marked DISC DRIVE 2 at the rear ofthe computer.
Connect the other end ofthe lead which is fitted with a smaller plug, into the socket at
the rear of the FD1 disc drive.
DON'T FORGET - Before connecting or disconnecting the 2nd disc drive, make sure
that any discs are removed from both drives, and that the system is switched off. If
connections are altered while the system is on, it is likely that the program in the
computer's memory will be corrupted. Always save any valuable programs before
meddling with connections!

When the FD1 is connected to the 6128, FIRST switch on theFD1 using the slide
switch on the rear panel of the disc drive, THEN switch on the 6128 using the slide
switch on the rear panel of the computer. Both the green and red indicators on the
front panel of the FD1 should be illuminated. The 2-drive system will then be ready to
operate.
Details of2-drive operation will be found later in this manual.

External amplifier/speakers
The 6128 may be connected to a stereo amplifier and speakers to enjoy the full
3-channel capabilities of the computer.
The input lead to your stereo amplifier should be terminated with a 3.5mm stereo
jack plug, which should be inserted into the socket marked STEREO on the computer.
The connections to the jack plug are:
Plug tip - Left channel
Plug inner ring - Right channel
Plug rear shaft - Ground (Common)
The 6128 will provide a fixed voltage signal out of the STEREO socket, and you should
therefore use the controls on the amplifier itself to regulate volume, balance and
tone.
High impedance headphones will also operate with the 6128, however the volume
will not be adjustable by the VOLUME control on the computer. Low impedance
headphones, such as those usually used with stereo systems, will not operate directly
plugged into the computer.
Details concerning the directing of sound to the required output channel will be found
later in this manual.

Foundation Course

Chapter 1 Page 9

Expansion devices
Expansion devices such as serial interfaces, modems, light pens, ROMs etc may be
connected to the 6128, using the socket marked EXPANSION at the rear of the
computer.
The AMSTRAD RS232C Serial Interface may be connected to this socket.
The AMSOFT speech synthesiser/amplifier model SSA2 may also be connected to
this socket.
Details of connections to the EXPANSION socket will be found in the chapter entitled
'For your reference .... '.
Finally, check that you have observed the following warnings given at the beginning
of this manual, in the section entitled 'IMPORTANT':
INSTALLATION NOTES 6,7
OPERATION NOTES 4,8

Chapter 1 Page 10

Foundation Course

Part 3: About Discs ....


The AMSTRAD CPC6128 uses 3 inch compact floppy discs. We strongly recommend
that for reliable data-to-disc transfer, you use only AMSOFT CF2 compact floppy
discs. Discs made by leading manufacturers however, may also be used.

Insertion
Each side of a disc may be used separately. A disc should be inserted with its label
facing outward from the drive, and with the side that you wish to use face up:

Foundation Course

Chapter 1 Page 11

Write Protection
In the left hand corner of each side of a blank disc, you will see an arrow pointing to a
small shuttered hole. This is called the Write Protect hole, and facilitates protection
against erasure or 'overwriting':

Write Protect hole

When the hole is closed, data can be 'written' onto the disc by the computer. When the
hole is open ;however, the disc will not allow data to be written onto it, thus enabling
you to avoid accidental erasure of valuable programs.
Various compact floppy disc manufacturers employ different mechanisms for
opening and closing the Write Protect hole. The operation may be carried out on the
AMSOFT CF2 compact floppy disc as follows:
To open the Write Protect hole, slide the small shutter located at the left hand corner
ofthe disc, and the hole will be opened:
- - - ---

Write Protect hole (OPEN)

Shutter
OPEN

I
I
I

----------- ---A-----_________ _
I
I
I

Shutter
CLOSED

Write Protection ON

Write Protection OFF

1'0 close the Write protect hole, simply slide the shutter to its closed position.
Chapter 1 Page 12

Foundation Course

Some other compact floppy discs employ a small plastic lever located in a slot at the
left hand corner:

Write Protect
hole
(CLOSED)

To open the Write Protect hole on this type of disc, slide the lever towards the middle
of the disc, using the tip ofa ball-point pen or similar object:

Slide Lever
towards middle
of disc

Write Protect
hole
(OPEN)

Note that regardless ofthe method employed to open and close the Write Protect hole,
opening the hole in all cases facilitates protection against overwriting.

IMPORTANT
Always ensure that the Write Protect holes on your master CP/M system discs
package are open.
Foundation Course

Chapter 1 Page 13

When Your Disc is in


At the front of the computer's disc drive, you will see a red indicator lamp, and a push
button for Eject:

Indicator
Lamp

-----j~~--------~~~d......+--

Eject
Button

Indicator Lamp
This indicates that data is being read from, or written to tliedisc-:-- -- - -- - ------ - - - If a 2nd disc drive is connected, the red indicator on the 2nd disc drive (Drive B) will
illuminate constantly. It will extinguish when the main disc drive within the
computer (Drive A) is reading or writing to disc.

Eject Button
Pressing in the Eject button allows you to remove your disc from the drive.
Finally, check that you have observed the following warnings given at the beginning
of this manual, in the section entitled 'IMPORTANT':
OPERATION NOTES 1, 3,4, 5,6

Chapter 1 Page 14

Foundation Course

Part 4: Getting Started....


Before we start loading software and saving programs to disc, let's get familiar with
some of the keys on the computer. Those of you who are experienced in using
computers may skip this section.
With the computer switched on and the opening message on the screen, we're going to
find out what the various keys do ....

The cursor keys 0. -0 Q il (at the bottom right hand corner ofthe keyboard) move
the position of the cursor (the small solid block) on the screen.
Press each of the cursor keys in turn, and you will see the cursor move about the
.. __.S.creen. ________ _ _ _ _ _ __
~

i.-

.--

RETURN
The [RETURN] key enters the information that you have typed into the computer.
After the [RETURN] key is pressed, a new line is started on the screen. Each
instruction that you type into the computer should be followed by pressing the
[RETURN] key.
From now on, we will show [RETURN] as meaning press the [RETURN] key after each
instruction or program line.
Foundation Course

Chapter 1 Page 15

Under normal circumstances (by default), this key has the same effect as [RETURN]
and can be used as such. However, like the function keys on the numeric keypad, the
[ENTER] key may be re-defined for other uses. This will be explained later in the
manual.

This key is used to delete a character to the left of the cursor on the screen (for
example a letter or a number) which is not required.
Type in a bed and you will see that the letter d is positioned to theleftofthe cursor. If
you decide that you do not want the letter d, press [DEL] once and you will see the d
removed. If you press [DEL] and continue to hold it down, the letters ab c will also be
removed.

SHIFT

There are two [SHIFT] keys. If you press either of these and hold it down whilst typing
a character,acapitaUetteLoL upp_eL~~(LsYIDJJQtwilJ l:lP~il~_o1l1~~sg~~n--,_
Type in the letter e then hold down the [SHIFT] key and type in the letter e again. On
the screen you will see:

eE
Now type in a few spaces by holding down the space bar. Try the following using the
number keys which are on the top line ofthe keyboard, above the letter keys. Type in
the number 2, then hold down the [SHIFT] key and type in the number 2 again. On
the screen you will see:"

2"
You can now see what happens when the [SHIFT] key is held down whilst pressing a
character key. Experiment by pressing any ofthe character keys, either on their own,
or together with the [SHIFT] key.

Chapter 1 Page 16

Foundation Course

CAPS
LOCK

This has a similar operation to [SHIFT] except that you only have to press it once.
From then on each letter that you type in will be in capitals, although the number
keys will not be shifted.
Press [CAPS LOCK] once, then type in:

abcdef123456
On the screen you will see:

ABCDEF123456
You will notice that although all the letters are shifted to capitals, the numbers have
not been shifted to symbols. If you wish to type in a shifted symbol while
[CAPS LOCK] is in operation, simply hold down the [SHIFT] key before pressing a
number key. Type in the following while holding down the [SHIFT] key:

abcdef123456
On the screen you will see:

ABCEDF!"#$%&
If you wish to return to small (lower case) characters again, press the [CAPS LOCK]
key once again.
-

Ifyou wish to ty~ in caJ>italletters and shifted uppeuase_sYnlhokwithouthaving_to


---constantly hold down the [SHIFT] key, this can be carried out as follows:

I[,--_CO_N_TR_OL~III,--_ft_t~--J
Holding down the [CONTROL] key, then press the [CAPS LOCK] key once. This
performs the function of a 'SHIFT LOCK'. Now type in:

abcdef123456
On the screen you will see:

ABCDEF!"#$%&
Note that it is still possible to type in numbers while [CONTROL] and [CAPS LOCK]
are in operation, by using the number keys
to f9) at the right ofthe keyboard.

cm

Foundation Course

Chapter 1 Page 17

Holding down the [CONTROL] key and pressing [CAPS LOCK] once, will return you
to the mode that you were previously in, (i.e. either lower case or capital letters-only).
If you have returned to the capital letters-only mode, simply press [CAPS LOCK] once
again to return to the lower case mode.

This key is used to clear a character within the cursor.


Type in AB CDE FGH. The cursor will be positioned to the right ofthe last letter typed
(H). Now press the cursor left key Qfour times. The cursor will have moved four
places to the left, and will be superimposed over the top of the letter E.
.
Notice how the letter E is still visible within the cursor. Press the [CLR] key once and
you will see that the letter E has been cleared and the letters FGH have each moved
one space to the left with the letter F now appearing within the cursor. Now press the
[CLR] key again and hold it down. You will see how the letter F is cleared followed by
the letters G and H.

This key is used to [ESC]ape from a function that the computer is in the process of
carrying out. Pressing the [ESC] key once will cause the computer to temporarily
pause in its function, and will continue again if any other key is pressed.
__Pressing the [ES~] key twice will cause the computer to completely [ESC]ape from
the function which it is carrying out. The computer is then ready.for you to type iIi--some more instructions.

Important
When you reach the right hand edge of the screen by entering 40 characters on a line,
the next character will automatically appear on the following line at the left edge of
the screen. This means that you should NOT press [RETURN] as those of you
accustomed to typewriters might press a carriage return towards the right edge of a
page.
The computer does this automatically for you, and will react to an unwanted
[RETURN] by printing an error message - usually a S y n t a x err 0 r, either there
and then, or when the program is run.

Chapter 1 Page 18

Foundation Course

Syntax Error
If the message: S y n t a x err 0 r appears on the screen, the computer is telling you
that it does not understand an instruction that you have entered.
For example type in:
pr i n t t [RETURN]

On the screen you will see the message:

Syntax error
The message appears because the computer has not understood the instruction:
printt
If you type a mistake in the line of a program, such as:

10 p r i n t t "a be" [RETURN]


The S y n t a x err q r message will not appear until the instruction is processed by
the computer when the program is run.
Type in:

run [RETURN]
(This command tells the computer to carry out the program that you have just typed
into the memory.)
On the screen you will see:

Syntax error in 10
10 IDrintt "abe"
---'I'his-me~sagetellsyou in-w hich-linethe error has occurred,and displays the program -line, together with the editing cursor so that you can correct the mistake.
Press the cursor-right key ~ until the cursor is over the t in pr in t t. Now press the
[CLR] key to remove the unwanted t , then press the [RETURN] key to enter the
corrected line into the computer.
Now type in:

run [RETURN]
.... and you will see that the computer has accepted the instruction, and has printed:

abe
Finally, check that you have observed the following warnings given at the beginning
ofthis manual, in the section entitled 'IMPORTANT':
INSTALLATION NOTES 4,5
OPERATION NOTE 1

Foundation Course

Chapter 1 Page 19

Part 5: Loading Software and


games ....
Welcome to those of you who skipped here from the beginning of the previous section!
As a quick demonstration ofthe speed ofloading disc software, switch on the system,
then insert Side 4 of your master CP/M discs package into the drive (i.e. the label 'Side
4' should be uppermost).
Type in:

run

11

r 0 i n t i me. de m [RETURN]
11

After a few seconds the program will have loaded into the memory. Answer the
question on the screen as to whether you are using a green monitor; (Type Y for Yes,
or N for No), and you will then see a continuous demonstration of the game 'Roland in
Time' on the screen. It may even persuade you to go out and buy a copy ofthe game!
When you have finished watching the demonstration, you may 'escape' from the
program by simultaneously holding downthe [CONTROL] and [SHIFT] keys then
pressing the [ESC] key. This has the effect of completely resetting the computer, and
may be used whenever you wish to start afresh. (You do not need to remove any disc
from the drive when resetting the computer in this way).

If the program hasn't loaded, study any error message on the screen to see where you
went wrong:

Drive A: disc missing


Retry, Ignore or Cancel?
.... means that you have either not inserted your disc correctly, or, if you have a
2-drive system, that you have inserted it into Drive B.

ROINTIME.DEM not found


.... means that you have either inserted the wrong disc, (or the wrong side of the disc),
or you have not carefully and precisely typed in the name, R0 I NT I ME. DE M

Bad command
.... means that you have probably mis-typed R0 I NT I ME. DE M by introducing an
unwanted space or punctuation mark.

Chapter 1 Page 20

Foundation Course

Type mismatch
.... means that you have omitted the quotation marks"

Syntax error
.. ,.means that you mistyped the word run

Drive A: read fai L


Retry, Ignore or CanceL?
.... means that the computer has failed to read data from your disc. Check that you
have inserted the correct disc and press R to Retry. This message will appear if ever
you corrupt your disc by switching the system on or off while the disc is in the drive.
Once you ha ve learned how to make back -u p copies of discs, always do so for val uable
programs, and especially for your master CPIM system discs package.

Loading AMSOFT software and the WELCOME


program
Having hopefully whetted your appetite for the lighter side of computing, let's load a
game ....
Insert your software disc in the drive, and type in:

r u 1'1 "d i s c" [RETURN]


After a few seconds, your game will be loaded and ready to play.
Try typing in: run" d; se" with Side 4 of your master CPIM system discs package
inserted into the drive, and you will see and hear the CPC6128 continuous 'Welcome'
demonstration.
When you have finished watching 'Welcome', reset the computer using the
[CONTROL] [SHIFn and [ESC] keys.
The above instruction (r un" d ; se") will load most of the AMSOFT range of disc
software, but you may come across the odd occasion where you have to type in
something else. In all cases however, the loading instructions will be found on the
label of the software disc, which should always be carefully followed.
Finally, check that you have observed the following warnings given at the beginning
of this manual, in the section entitled 'IMPORTANT':
INSTALLATION NOTE 6
OPERATION NOTES 1,5,6
Foundation Course

Chapter 1 Page 21

Part 6: Let's Compute ....


So far, we know what we must and mustn't do with the computer, and how to set it up
and connect peripherals. We know what some of the keys on the computer do, and how
to load software. Now we'll look at some of the instructions that you can type in to
make things happen ....
Like you or I, the computer can only understand instructions in a language that it
knows, and that language is called BASIC, (short for Beginners' All-purpose
Symbolic Instruction Code). The words in BASIC's vocabulary are called 'keywords'
and each ofthem tell the computer to perform a specific function. All languages must
conform to the rules of grammar, and BASIC is no exception. Here, grammar is
referred to as 'Syntax', and the computer will always be kind enough to tell you if
you've made a S y n t a x err 0 r !

An introduction to AMSTRAD BASIC keywords


In the chapter entitled 'Complete list of AMSTRAD CPC6128 BASIC keywords', you
will find a description of all the keywords found in AMSTRAD BASIC. We will
introduce some of the more commonly used BASIC keywords in this section.

CLS
To clear the screen, type in:
c Ls [RETURN]

You will notice that the screen clears and the word Rea d y with the cursor. will
appear at the top left of the screen.
Note that you can use upper case (CAPITAL) or lower case (small) letters to enter any
BASIC keyword into the computer.

PRINT
This is used whenever you want characters, words or figures in a program to be
printed. Type in the following instruction line:
p r i n t "h eLL 0 " [RETURN]

Chapter 1 Page 22

Foundation Course

On the screen you will see:


he L L0

The quotation marks"" are used to tell the computer what should be printed.
he L L0 appeared on the screen as soon as the [RETURN] key was pressed. Type in:
c Ls [RETURN]

.... to clear the screen.

RUN
The previous example showed a single instruction line. However, as soon as the
[RETURN] key was pressed, the instruction was carried out then forgotten. It is
possible to store a series of instructions in the computer to be carried out in a specified
order. This is achieved by writing a 'program'. The sort of BASIC instructions that
you write in a program are the same as just shown, but in front c;>f each instruction
line, a line number is typed in. If there is more than one line in the program, these line
numbers tell the computer the order in which to carry out or 'run' the program. When
[RETURN] is pressed, the line is stored in the memory until the program is run. Now
type in:

1 0 pr i n t "h eLL 0" [RETURN]


Notice that when [RETURN] was pressed, he L L0 was NOT printed on the screen,
but instead was entered into the computer's memory as a one-line program. To carry
out that program, the word run must be used. Type in:
run [RETURN]
. I

--Y:ouwill nowsee -he-L-L-oprintedonthescreen;- . - . - -----.----Note that instead of continually typing in: pr; n t, you can use the? question-mark
symbol, for example:
10 ? "he L Lo" [RETURN]

LIST
After a program has.been stored in the memory, it is possible to check what has been
typed in by 'listing' the program. Type in:
.
Lis t [RETURN]

On the screen you will see:


10 PRINT "heLLo"

.... which is the program stored in the memory.

Foundation Course

Chapter 1 Page 23

Notice how the word PR I NT is now in capitals. This means that the computer has
accepted PR I NT as a known BASIC keyword.
Type in: c Ls [RETURN] to clear the screen. Note that although the screen is cleared
when you type in: cL s [RETURN], your program is not erased from the computer's
memory.

GOTO
The GOT 0 keyword tells the computer to go from one line to another in order to either
miss out a number oflines or to form a loop. Type in:
HI p r i n t "h eLL 0" [RETURN]
20 goto 10 [RETURN]

Now type:
run [RETURN]

.... and you will see he L L0 printed continuously on the screen, one under another on
the left side. The reason for this, is that line 20 ofthe program is telling the computer.
to go to line 1 0 and carry on processing the program from there.
To pause the running of this program, press [ESC] once. To start it again, press any
other key. To stop it running so that other instructions can be typed in, press [ESC]
twice.
Now type in:
-c-L-s- [RETURN]- - .... to clear the screen.
To see the word h eLL 0 printed continuously on each line, one next to another filling
the whole of the screen, type in the previous program but with a semi-colon; after
the quotation marks"
Type in:
1 0 pr i n t

20 go t

"h eLL 0 " ; [RETURN]

10 [RETURN]

run [RETURN]

Note that the semicolon; tells the computer to print the next group of characters
immediately following the previous one, (unless the next group of characters is too
large to fit on the same line).

Chapter 1 Page 24

Foundation Course

Escape from this program by pressing [ESC] twice. Now type in line 10 again, but
this time, use a comma, instead of a semicolon;

10 pr i n t "h eLL 0", [RETURN]


run [RETURN]
You will now see that the comma , has told the computer to print the next group of
characters 13 columns away from the first group of characters. This feature is useful
for displaying information in separat~ columns. Note however, that if the number of
characters in a group exceeds 12, the next group of characters will be displaced
forwards by another 13 columns, so as to always maintain a space between columns.
This figure of 13 columns is adjustable by use of the Z0 NE command, described later
in this manual.
Again, to escape from this program, press [ESC] twice. To clear the computer's
memory completely, 'hold down the [CONTROL] [SHIFT] and [ESC] keys in that
order, and the computer will reset.

INPUT
This command is used to let the computer know that it is expecting something to be
typed in, for example, the answer to a question.
Type the following:

10 input "how oLd are you";age [RETURN]


20 print "you Look younger than";age;
" yea r soL d ." [RETURN]
r-un-[RETURN]- -' -------------- --------- -------- -------On the screen you will see:

what is your age?


Type in your age then [RETURN]. If your age was 18, the screen would then show:

you Look younger than 18 years oLd.


This example shows the use of the; n put command and a number variable. The
word age was put into the memory at the end ofline 1 0 so that the computer would
associate the word age with whatever numbers were typed in and would print these
numbers where the word age is on line 20. Although we used the expression age in
the above for the variable, we could have just as easily used a letter, for example b.

Foundation Course

Chapter 1 Page 25

Reset the computer to clear the memory, ([CONTROL] [SHIFT] and [ESC] keys). If
you had wanted an input made up of any characters, (letters or letters and numbers),
the dollar sign $ must be used at the end of the variable. This type of variable is called
a 'string variable'.
Type in the following program: (Note that in line 20 you must put a space after the
in he L L0 and before the min my).

1 0 ; n put " what ; s you r n a me" ; n a me $ [RETURN]


20 pr; n t "h e II 0 "; n a me $; " my n a me ; s R0 n a l d" [RETURN]
run [RETURN]
On the screen you will see:

What ;s your name?


Type in your name then [RETURN]
If the name that you entered was Fred, you will see on the screen:

Hello Fred my name ;s Ronald


Although we used n a me $ in the above example for the name string variable, we
could have just as easily used a letter, for example a $. Now we will combine the
above 2 examples into one program.
Reset the computer by pressing [CONTROL] [SHIFT] and [ESC]. Type in the
following:
5 c l s [RETURN]
1 0 ; n put " what ; s you r n a me" ; a $ [RETURN]
-- -20 - ;-n p u-t- !lwha t- -;-s - yo ur--ag e-"i b- [R&TURN]-- - - - --- -- - ----- - - 30 print "1 must say ";a$;" you dont
loo k " ; b; " yea r sol d" [RETURN]
run [RETURN]
In this program we have used 2 variables, a $ for the name and b for the age. On the
screen you will see:

what ;s your name?


Now type in your name (e.g. F red), then [RETURN].
You will then be asked:

what ;s your age?


Now type in your age (e.g. 18), then [RETURN].

Chapter 1 Page 26

Foundation Course

If your name were Fred and your age 18, on the screen you will see:
1

must say Fred you dont look 18 years old

Editing a Program
If any ofthe lines in the program had been typed incorrectly, resulting in a S y n t a x
err 0 r or other error message, it would be possible to edit that line, rather than type
it out again. To demonstrate this, let's type in the previous program incorrectly:
c l ss [RETURN]
1 0 i n put "w hat i s you n a me" ; a $ [RETURN]
2 0 i n put "w hat i s you rag e " ; b [RETURN]
30 print "1 must say";a$;" you dont
loo k" ; b; "yea r sol d" [RETURN]
5

There are 3 mistakes in the above program:


In line 5 we typed in c Ls s instead of c Ls .
In line 10 we typed in you insteadofyo u r.
In line 30 we forgot to put a space between say and the quotation marks"
There are 3 main methods of editing a program. The first is to simply type in the new
line again. When a line is retyped and entered, it replaces the same numbered line
currently in the memory.
Secondly, there is the editing cursor method.
-

Lasfly~thefeistlie copYcursor metliocI-

- --

Editing Cursor Method


To correct the mistake in line 5
Type:

ed itS [RETURN]
Line 5 will then appear under line 3 0 with the cursor superimposed over the c in
cL s s
To edit out the extra s in c Lss, press the cursor right key ~ until the cursor
appears over the last s, then press the [CLR] key. You will see the s disappear.

Foundation Course

Chapter 1 Page 27

Now press [RETURN] and line 5 will now be corrected in the memory. Type in:
L; 5 t .[RETURN]

.... to check line 5 is now correct.


The AUT 0 command, described later in this manual, may be used to edit a number of
successive lines in a similar manner to that described in the Editing Cursor Method.

Copy Cursor Method


The copy cursor is another cursor (in addition to the one already on the screen) which
comes into view when you hold down [SHIFT] and press one ofthe cursor keys. It then
detaches itself from the main cursor and can then be moved around the screen
'
independently.
To correct the mistakes in line 1 0 and 30, hold down the [SHIFT] key then press the
cursor up key 0. until the copy cursor is positioned over the very beginning of line
1 0. You will notice the main cursor has not moved, so there are now two cursors on
the screen. Now press the [COPy] key until the copy cursor is positioned over the
space between you and n a me. You will notice that line 1 0 is being re-written on the
last line and the main cursor stops at the same place as the copy cursor. Now type in
the letter r. This will appear on the bottom line only.
The main cursor has moved but the copy cursor stayed where it was. Now press the
[COPy] key until the whole of line 1 0 is copied. Press [RETURN] and this new line
10 will be stored in the memory. The copy cursor disappears and the main cursor
positions itself under the new line 1 0. To correct the second mistake, hold down
[SHIFT] and press the cursor up key 0. until the copy cursor appears over the
very beginning ofline 30.
Press [COPy] until the copy cursor is positioned over the quotation marks next to
say. Now press the space bar once. A space wiil be inserted on the bottom line. Hold
down the [COPy] key until the whole ofline 30 is copied, then press [RETURN].
You can now list the program to check that it is corrected in the memory by typing in:
Lis t [RETURN]

NOTE: To move the cursor quickly (during editing) to the left or right hand end of a
line, hold down the [CONTROL] key then press the left Qor right I) cursor key once.
Now reset the computer by pressing [CONTROL] [SHIFT] and [ESC] keys.

IF
The I F and THE N commands ask the computer to test for a specified condition, then
take action depending upon the result ofthat test. For example, in the instruction:
Chapter 1 Page 28

Foundation Course

i f 1 + 1 =2 the n pr i n t "c 0 r re et" [RETURN]

.... the computer will test for the specified condition, and then take action accordingly.
The keyword E LSE can be used to inform the 1FT HEN command as to what
alternative action the computer should take if the tested condition is false, for
example:
i f 1 + 1 =0 the n p r i n t "c 0 r r e et" e Lse p r i n t " wr 0 n g" [RETURN]

We will now extend the previous program with the use of the i f and the n
commands.
Type in the following: Notice that we have added two symbols. <means less than, and
is next to the M key. >means greaterthan,and is next to the < (less than) key.
5
10
20
30
40
50
60

c Ls [RETURN]

input "what is your name";a$ [RETURN]


i n put " what i s you rag e " ; age [RETURN]
i fag e < 1 3 the n 60 [RETURN]
i fag e < 20 the n 70 [RETURN]
i fag e > 1 9 the n 80 [RETURN]
print "So ";a$;", you are not quite a
tee nag era t " ; age; " yea r soL d" : end [RETURN]
70 print "So ";a$;", you are a teenager
at" ; age; "yea r soL d" : end [RETURN]
80 print "Oh weLL ";a$;", you are no
L0 n ~ e r_~ t_ee_ n'!~L~r ~t";_ ~g_e ; "yea r!i Q 1 d" [RETURN]

To check this program is correct, type:


Lis t [RETURN]

Nowtypein:
run [RETURN]

Now answer the questions prompted by the computer and see what happens.
You can now see what effect the I F and THE N commands have in a program. We
have also added the wcrd END at the end of lines 60 and 70. The keyword END is
used literally to end the running of a program. If END wasn't there in line 60, the
program would continue to run, and carry out lines 70 and 80.

Foundation Course

Chapter 1 Page 29

Likewise, if END wasn't there in line 70, the program would continue to run, and
carry out line 80. The colon : before the word END separates it from the previous
instruction. Colons : can be used to separate two or more instructions -on one
program line. We have also added line 5 to clear the screen at the start of the
program. We will do this from now on in the following programs to make things look
neater.
Reset the computer by pressing [CONTROL] [SHIFT] and [ESC] keys.

FOR and NEXT


The FOR and NE XT commands are used when you want to carry out a specified
operation a number of times. The instructions for the specified operation must be
enclosed by the FOR NEX T loop.
Type in:
5' c Ls [RETURN]

1 0 for a = 1 to 1 0 [RETURN]
20 pr i n t " 0 per a t ion nu mb er" ; a [RETURN]
3 0 ne x t a [RETURN]
run [RETURN]
You will see that the operation in line 20 has been carried out 10 times, as instruct~d
by the FOR command in line 10. Note also that the value of the variable a is
increased by 1 each time.
The keyword S T E P may be used to inform the FOR NEX T command how much the
variable should be 'stepped' per operation. For example, change line 1 13 to:

1 0 for a = 1 0 to 50s t e p 5 [RETURN]


run [RETURN]
Negative steps may also be used, for example:

1 0 for a = 1 00 to 0 s t e p -1 0 [RETURN]
run [RETURN]

REM
REM is short for REMark. The instruction tells the computer to ignore anything that
follows it on the line. Hence you can use REMarks to inform you of, for example, the
title of a program, or the use of a variable, as follows:

10 REM Zap the invaders [RETURN]


20 L=5 :REM number of Lives [RETURN]

Chapter 1 Page 30

Foundation Course

The single quote mark ' (which can be typed by holding down [SHIFT] and pressing
the 7 key) can be used as a substitute for : REM. For example:

HI I Zap the i n v a d e r s [RETURN]


20 L=5 I nu mb e r 0 f l i ve s [RETURN]

GOSUB
If there are a set of instructions within a program which are to be carried out a
number of times, these instructions need not be typed in repeatedly every time they
are needed in the program; instead, they can be made into a 'sub-routine' which when
required, can be called into action by the command GO SUB followed by the line
number. The end of the G0 SUB -routine is marked by typing in the instruction
RE TURN. At this point the computer will return to the instruction that immediately
followed the GO SUB command which it had just obeyed.
For example, in the following program:

10
20
30
40
50
60
70

80

a=2
PRINT "here is the";a;"times table"
FOR b=1 TO 12
c=a*b
PRINT a;"x";b;"=";c
NEXT
PRINT
I

90 a=5
100 PRINT "here is the";a;"times table"
110 FOR b=1 TO 12
120 c=a*b
- -- -1-3 0 -P RI NT- a;-" x ";b-; "= " ; c---- - - --- -- -- -140 NEXT
150 PRINT
160
170 a=8
180 PRINT "here is the";a;"times table"
190 FOR b=1 TO 12
200 c=a*b
210 PRINT a;"x";b;"=";c
220 NEXT
230' PRINT
240 I
250 a=9
260 PRINT "here is the";a;"times table"
270 FOR b=1 TO 12
280 c=a*b
290 PRINT a;"x";b;"=";c
300 NEXT
310 PRINT
Foundation Course

Chapter 1 Page 31

.... you can see a number oflines which have to be repeated at various points in the
program, for example the section from line 260 to 31 0. Let's make that section into
a sub-routine and add the instruction RE TURN at the end. Then, we'll call the
sub-routine using the command GOSUB 260 whenever we want to use it. The
program now looks like this:

10 a=2
15 GOSUB 260
80 I
90 a=5
95.GOSUB 260
160 I
170 a=8
175 GOSUB 260
240 I
250 a=9
255 GOSUB 260
256 END
257 I
260 PRINT "here is the";a;"times tabLe"
270 FOR b=1 TO 12
280 c=a*b
290 PRINT a;"x";b;"=";c
300 NEXT
310 PRINT
315 RETURN
See how-much-tedious_typing we've sayed_ours~lyeslWellJiesigIlJl(L~mb:l'()utine are
a principal part of computing. They lead to 'structured' programs, and develop good
programming habits.
Always bear in mind when writing sub-routines, that you do not necessarily have to
Jump into' the sub-routine at the same point, i.e. its beginning. A sub-routine written
from lines 5 00 to 800 can be called by: G0 SUB 5 0 0, or G0 SUB 640, or G0 SUB

790.
Note in the above program, that the instruction END is used in line 256. Otherwise
the program would naturally continue after line 2 5 5 , and would carry outline 2 60,
which is NOT required unless called by GO SUB.

Chapter 1 Page 32

Foundation Course

Simple Arithmetic
Your computer can be used as a calculator quite easily.
To understand this, carry out the following examples. We will use the? symbol
instead of typing pr; n t in this section. The answer will be printed as soon as the
[RETURN] key is pressed.

Addition
(use [SHIFT] and ; keys for plus)
Type:
? 3 +3 [RETURN]

(Note that you do NOT type in the equals sign =)


Type:
? 8 +4 [RETURN]

12

Subtraction
(useunshifted = key for minus)
Type:
? 4 - 3 [RETURN]
1

Type:
? 8 - 4 [RETURN]

Multiplication
(Use [SHIFT] and: keys for multiply (* means x)
Type:
? 3 *3 [RETURN]
9

Type:

? 8 4 [RETURN]

32

Foundation Course

Chapter 1 Page 33

Division
(use unshifted ? key for divide (/ means -;- )
Type:
? 3/3 [RETURN]

Type:
? 81 4 [RETURN]

Integer Division
(use \ for division with removal of the remainder)
Type:
? 1 Ql \ 6 [RETURN]
1

Type:
? 2 Ql \ 3 [RETURN]
6

Modulus
(use MOD to obtain the remainder portion after integer division)
TY'pe: ___ .
? 1 Ql MO D 4 [RETURN]

2
Type:
? 9 MO D 3 [RETURN]
Ql

Square Root
To find the square root of a number, use s q r ( ). The number that you want the
square root of should be typed inside the brackets.
Type:
? s q r ( 1 6) [RETURN] (this means V16)
4

Chapter 1 Page 34

Foundation Course

Type:
(HHl ) [RETURN]

?sqr
10

Exponentiation
(use unshifted key for exponentiation)
Exponentiation is when a number is raised to a power of another. For example 3
squared (3 i 2),3 cubed (3 i 3) etc.
Type:
?3

3 [RETURN] (this means 33)

27

Type:
?8

4 [RETURN] (this means 84)

4096

Cube Root
You can quite easily calculate cube roots by using a similar method to the last
- e x a m p l e . - - - --- ._. ---- To find the cube root of27 (3 Y27)
Type:
? 27
3

i ( 1 /3)

[RETURN]

To find the cube root of 125


Type:
? 1 25
5

(1 /3) [RETURN]

Foundation Course

Chapter 1 Page 35

Mixed Calculations
(+,-,*,/)
Mixed calculations are understood by the computer, but they are calculated within
certain priorities.
First priority is given to multiplication and division, then addition and subtraction.
These priorities apply only to calculations containing only these four operations.
If the calculation was:

3+7-2*7/4
You may think this would be calculated as:

3+7-2 *7 14
= 8 *7 14

= 56/4
= 14

In fact it is calculated as:

3+7-2*7/4
=3+7-14/4
=3+7-3.5
=10-3.5
=6.5
Prove this by typing in this calculation as it is written:
Type:
? 3 + 7 - 2 * 7 1 4 [RETURN]

6.5
You can change the way the computer calculated this by adding brackets. The
computer will deal with the calculation inside brackets prior to the multiplication
etc, outside the brackets. Prove this by typing in the calculation including brackets.
Type:
? (3+7-2) *714 [RETURN]
14

Chapter 1 Page 36

Foundation Course

The priority of ALL mathematical operators is as follows:

MOD

* and /
\

+and-

Exponentiation
Modulus
Unary minus (declares a number as negative)
Multiplication and division
Integer division
Addition and Subtraction

Further Exponents
If you want to use very large or very small numbers in calculations, it is sometimes
useful to use scientific notation. The letter E is used for the exponent of numbers to
the base 10. You may use either lower case e or upper case E.
For example 300 is the same as 3xl02. In scientific notation, this is 3 E2. Similarly,
0.03 is the same as 3x10-2. In scientific notation this is 3 E- 2. Try the following
examples.
You can type in:
? 30* 10 [RETURN]
300
or you can type:
? 3 E1 * 1E 1 [RETURN]

300
?3000*f000 [RETURN] ....
3000000

or.-...

?3E3*1 E3 [RETURN]

?3000*0.001 [RETURN] .... or .... ?3E3*1E-3 [RETURN]


3

Foundation Course

Chapter 1 Page 37

Part 7: Save It ....


Now that you've exercised your fingers by typing in a few instructions, you'll
probably want to know how to save a program from the computer onto disc, and how
to load it bl:!ck from disc into the computer.
Even if you are familiar with cassette saving and loading, it is worth pointing out
some important information which must be observed when dealing with disc
program files.
The 2 most apparent differences will be that firstly, a new blank disc cannot simply be
taken out of its wrapper and recorded onto, as is the case with cassettes. A new disc
must be first be 'formatted', and this process will be explained in a moment.
The other point worth mentioning here, is the importance of correctly 'naming' disc
files. Cassette filenames generally conform to very loose standards, varying greatly
in length, being at times omitted. Not so with discs. Disc filenames must conform
strictly to CP/M standards, and will be explained later in this section.

Formatting discs for use


Before writing any data onto a new blank disc, the disc itself must first be formatted.
Formatting can be likened to building a series of shelves and dividers onto a disc prior
to the storage of information on those shelves; in other words, laying down an
organised framework around which data can be put in or taken out.
Formatting divides the disc into 360 distinctly separate areas:

Track 39

14---

Outer Case

Sector

--+-- Track 0
3
Chapter 1 Page 38

Foundation Course

There are 40 tracks from the outside of the disc (Track 0), to the inside (Track 39), and
the circumference ofthe disc is divided into 9 sectors.
Each track in a sector can store up to 512 bytes of data; hence the total available space
on each side of a disc is 180Kbytes.
.

First Steps Using the Master CP/M System Discs


Package
To prepare a new blank disc for reading and writing your own programs onto, you will
need to format the new disc. This is carried out using Side 1 of your master CP/M
system discs package (supplied with the computer).
Switch the system on, and insert Side 1 of the master system discs package into the
drive.

If you are operating 2 disc drives, always insert Side 1 into the main disc drive within
the computer (Drive A)
Type in:
I c p m [RETURN]

(Y ou will find the bar symbol I by holding down [SHIFT] and pressing the @key.)
After a few seconds you will see the following message at the top of the screen:

CP/M PLus

Amstrad Consumer ELectronics pLc

This is a'S i 9 non' message indicating that the computer is now under the control of
the CP/M Plus operating system. You will also see the letter A> together with the
cursor displayed on the screen. This is a prompt, (similar to Rea d y during normal
BASIC operation) indicating that the computer is awaiting your instructions.
Once you are operating CP/M, you cannot enter BASIC commands into the computer,
as these will not be understood.
Iffor example, you type in the BASIC command:
c Ls [RETURN]

The Computer will return your entry, together with a question mark:

CLS?
... .indicating that it does not understand your command.

Foundation Course

Chapter 1 Page 39

To look briefly at some of the CP/M commands, type in:

d i r [RETURN]
On the screen you will see a D I.Rectory ofCP/M and utility COMmands, one of which
is D I S CKIT 3. Type in:

d i s c kit 3 [RETURN]
After a few moments, you will see the DISC KIT opening message at the top of the
screen, followed by:

One drive found


This message tells you that you are running the DISC KIT utility program, and the
computer has detected that you are operating only one disc drive (the one within the
computer).

If you have connected an additional disc drive to the system, the message will say:

Two drives found


At the bottom of the screen, you will see the following:

Copy

Format

Verify
Exit from program
This is known as the main DISC KIT menu. The numbers in boxes refer to the
function keys at the right hand end of the keyboard (marked fQl, 11,14, and f7), and
pressing one ofthese keys takes you to your selected menu choice.
Note that pressing function key number 0 at this point will exit from the DISC KIT
program back to CP/M Direct Console Mode (the A > prompt).
We now want to format a disc, so press function key number 4( 14).
BEWARE

FORMATTING A PREVIOUSLY RECORDED DISC WILL ERASE ITS CONTENTS

Chapter 1 Page 40

Foundation Course

You will now see a new menu offering you a choice of different formats, namely:

System format

Data format

Vendor format

Exit menu

As before, we can now press one of the function keys (f3, f6, or f9) to select the type of
format we want. Each of these different formats will be explained later in the
manual, but for now, select Data format by pressing function key number 6.
Note that pressing the. key (below f3, f6, and f9) exits from the Format mode back to
the main DISC KIT menu.
Having pressed function key number 6, (and assuming that you have not connected
an additional disc drive to the computer) you will see the message:

GJ

Format as Data
Any other key to exit menu

At this point, you should remove your master CP/M system disc, and insert the disc
that you wish to format. The side of the disc to be formatted should be placed face-up
irftne drive.
.
Now press the Y key, (Y for Yes, meaning 'go-ahead and format the disc').
The disc will be formatted, tracks 0 to 39; the current track number being indicated at
the top left of the screen.
You will not be able to format a disc which has its write protect hole open. Attempting
to do so will result in the message:

Disc write-protected
Insert disc to format
R-etry or C-anceL
.... whereupon you should type C to Cancel, remove the disc, and insert the correct disc
for formatting, with its write protect hole closed.

Foundation Course

Chapter 1 Page 41

Make sure that you don't close the write protect hole on a disc that contains programs
you want to keep, and NEVER close the write protect holes on your master CPIM
system discs package.
When formatting is completed, you will be asked to remove your newly formatted disc
from the drive, then to press any key to continue.
Having done so, you will be able to format another disc by inserting it and pressing Y
again. This may be repeated any number of times until you have formatted all the
discs you require in that particular format.
When you have finished formatting, press any key (other than Y) to return to the
main DISC KIT menu once again.
The menu options Cop y and Ve r i f y will be dealt with later in this manual, but for
now, having learnt to format with CPIM, reset the computer using [CONTROL]
[SHIFT] [ESC].
Always keep the master copies of your CPIM system discs in a safe place, as they are
literally the key to your system. Later in this manual, you will be shown how to make
'working copies' of your system discs, so that you can keep your master copies safely
locked away.

Formatting on a 2-drive system


Follow the instructions above, selecting the For ma t option from the main DISC
KIT menu by pressing key f4, then select Da t a for ma t by pressing key f6.
At this point you will be shown a third menu offering you the choice of drive on which
to format:

Format A:

Format B:

Exit menu

Choosing the option For ma t B : (key f5) will enable you to leave your system disc
(Side 1) in Drive A, while you place the disc to be formatted in Drive B.
After selecting For mat B:, you may then either press Y to go ahead with
formatting, or any other key to exit to the main DISC KIT menu.

Chapter 1 Page 42

Foundation Course

If you have selected the For ma t A : option (key f8), you MUST then remember to
remove your system disc from Drive A, and instead insert the disc to be forma tted.
Don't forget - NEVER RISK OVERWRITING YOUR MASTER CP/M SYSTEM
DISCS.
Now that we have a formatted blank disc (or two), we can start to manipulate BASIC
programs to and from disc.

Saving a Program in Memory onto Disc


Having typed a program into the computer's memory, save it onto disc by typing in:
s a v e "f; Le n a me" [RETURN]

Note that the naming of the program is obligatory.


A filename on disc consists of 2 parts (fields). The first part is obligatory and can
contain up to 8 characters. Letters and numbers may be used but NO spaces or
punctuation marks. This first field usually contains the name of the program.
The second field-is optional. You can use up to 3 characters, but again no spaces or
punctuation. The 2 fields are separated by a dot.
If you do not specify a second field, the system will automatically label it with a token
of its own, such as . BA S for BASIC files or BIN for binary (machine code) files.
As an example of saving to disc, write a short program into the memory, insert a
formatted disc, then type in:
- save" e x amp Le" [RETURNr

After a few seconds, the prompt Rea d y will appear on the screen, and the program
will have been saved onto disc. (If not, check any error message on the screen to
establish whether you either forgot to insert your disc into the correct drive, forgot to
close the write protect hole, or mistyped the command.)

Catalog
After saving the above program, type in:
cat [RETURN]

Foundation Course

Chapter 1 Page 43

On the screen you will see:

Drive A: user 0
EXAMP LE. BAS 1 K

177K free
The filename will be displayed, including any specified or token second field, together
with the file length (to the nearest higher Kbyte). The amount offree space on the disc
will also be displayed.

Loading from Disc


Programs may be loaded from disc then run, using the commands:

loa d

11

f i l e n a me 11 [RETURN]

run [RETURN]
.... or they may be run directly using the command:

run

11

f i le n a me

11

[RETURN]

Note that protected programs may be run directly only.

IAandlB
If you are operating an additional disc drive, you may specify which Drive (A or B)
that you require a function to be performed on by typing in:
I a [RETURN]

.... or ....
I b [RETURN]

.... before issuing the S AVE, CAT, or LOA 0 commands.

Chapter 1 Page 44

Foundation Course

Copying Programs from Disc to Disc


Using the commands already learnt in this section, it can be seen that disc to disc
program copying is performed simply by loading the program into the memory from
the original (source) disc, removing the source disc, and saving the program onto the
new (destination) disc.
To save a program from disc to disc using 2 disc drives, you may prefer to insert your
source disc into, for example, Drive B, and your destination disc into Drive A. To copy
a program in this way , type in:
I b [RETURN]
Load "f i Lename" [RETURN]
I a [RETURN]
s a v e "f i Le n a me" [RETURN]

There are four ways in which files may be SAVEd by the CPC6128. In addition to
ordinary BASIC file saving, by:
s a ve " f i Le n a me" [RETURN]

.... there are three alternative methods, for more specialised purposes:

ASCII Files
s av e "f i Le n a me" , a [RETURN]

Adding the suffix, a instructs the computer to save the program or data in the form
of an ASCII text file. This method of saving data applies to files created by
wordprocessors and other applications programs, and its use will be further discussed
as applications are encountered.

Protected Files
s a v e " f i Len a me" , p [RETURN]

Adding the suffix , p tells the computer to protect the data so that the program
cannot be LIS Ted after LOA Dingit, or RU Nningit then stopping its execution using
the [ESe] key function.

Foundation Course

Chapter 1 Page 45

Programs saved in this way can only be run directly, using the commands:
run " f i Le n a me" [RETURN]

.... or ....
c ha in" f i Le n a me" [RETURN]

If you anticipate wanting to edit or alter the program, you should also keep a copy for
yourself in unprotected form, i.e. without the, p suffix.

Binary Files
s a v e "f i Le n a me" , b, <starting address> , <length in bytes>
[ , <optional entry point> ] [RETURN]

This option allows you to perform a binary save where a complete block of data in the
computer's RAM is stored onto disc exactly as it occurs in the memory. It is necessary
to instruct the computer where the section of memory you need to save starts, how
long it is, and if required, the memory address at which to start execution should the
file be run as a program.

Screen Dump
This binary save feature allows data from the screen memory to be stored directly
onto disc in the form of a screen dump. The contents ofthe screen will be saved exactly
as it is seEm, using the command:
sav e

"s ern dum p" , b , 491 5 2 , 1 6384

[RETURN]

.... where 49152 is the starting address of the screen memory, and 16384 is the
length of the screen memory that you wish to save.
To call it back onto the screen, type in:
Loa d "s ern dum p" [RETURN]

More information on using the system to manipulate program files between discs
(and cassette), will be found later in this manual.
Finally, check that you have observed the following warnings given at the beginning
of this manual, in the section entitled 'IMPORTANT':
INSTALLATION NOTES 5,6,7
OPERATION NOTES 1,2,3,4,5,6,7,9

Ch~pter

1 Page 46

Foundation Course

Part 8: Understanding Modes,


Colours and Graphics ....

The Amstrad CPC6128 Colour Personal Computer has three modes of screen display
operation: Mode 0, Mode 1, and Mode 2.
When the computer is first switched on, it is automatically in Mode l.
To understand the different modes, switch on the computer and press the number 1
key. Hold it down until two lines are full of 1 'so If you now count the number of 1 's on a
line, you will see that there are 40. This means that in Mode 1, there are 40 columns.
Press [RETURN] - you will get a S y n t a x err 0 r message, but don't worry, this is
just a quick way of getting back to the Rea d y message that tells you the computer is
waiting for your next instruction.
Now type in:
mod e 0 [RETURN]

You will see that the characters on the screen are now larger. Press the number 1 key
again and hold it down until two lines are full of 1 'so If you count the number of 1 's on
a jip.e,3_ou will see there are 20. This means that in Mode 0, there are 20 columns.
Press [RETURN] again.
Now type in:
mod e 2 [RETURN]

You will see that this is the smallest mode, and if you again type in a line of 1 's, you
will count 80. This means that in Mode 2 there are 80 columns.
To recap:
Mode 0 = 20 columns
Mode 1 = 40 columns
Mode 2 = 80 columns
Finally, press [RETURN] once again.

Foundation Course

Chapter 1 Page 47

Colours
There is a choice of27 colours. These are shown on a green monitor (GT65) as various
shades of green. If you purchased the GT65 monitor, you can buy the AMSTRAD MP2
Modulator/Power supply in order to use the computer's colour facilities on your
domestic colour T. V.
In Mode 0, up to 16 of the 27 available colours can beputonto the screen at any time.
In Mode 1, up to 4 ofthe 27 colours can be put onto the screen at any time.
In Mode 2, up to 2 ofthe 27 colours can be put onto the screen at any time.
You are able to change the colour of the 80 R"D ER, the PAP ER (the area where the
characters can appear) or the PEN (the character itselD, all independently of each
other.
The 27 colours available are listed in Table 1, each with their INK colour reference
number.
For convenience, this table also appears on the panel at the top right hand side ofthe
computer.

MASTER COLOUR CHART


Ink
No.

Colour/Ink

Ink
No.

Colour/Ink

Ink
No.

Colour/Ink

Black

Green

18

Bright Green

Blue

10

Cyan

19

Sea Green

Bright Blue

11

Sky Blue

20

BrightCyan

2
-

-- -

---

Red

12

Yellow

21

Lime Gie-en -

Magenta

13

White

22

Pastel Green

Mauve

14

Pastel Blue

23

PastelCyan

Bright Red

15

Orange

24

Bright Yellow

Purple

16

Pink

25

Pastel Yellow

Bright Magenta

17

Pastel Magenta

26

Bright White

Table 1: The INK numbers and colours

As explained earlier, when the computer is first switched on, it is in Mode 1. To return
to Mode 1 from a different mode, type in:
mod e 1 [RETURN]

Chapter 1 Page 48

Foundation Course

The screen display


PEN

BORDER
PAPER

The 80 RDE R is the area surrounding the PAP ER. (Note that when the computer is
first switched on, the 80 RDE Rand PAP E R are both blue). The characters on the
screen can only appear inside the border. The PA PER is the background area behind
a character, while the PEN writes the character itself.
Now we will explain how the colours that you see on the screen are selected, and how
you can change these to your own choice.
When you first switch on, or reset the computer, the 80 RDE R is always set to colour
number 1. Look up number 1 on the master colour chart, and you will see that colour
number lislHue. The colour of the border can be changed by using tlie command:
80 RDE Rfollowed by the colour number. To change the border to white, type in:
border 13 [RETURN]

So far, so good. Now for the tricky bit ....


When you first switch on, or reset the computer, PAP E R number 0, and PEN number
1 are always automatically selected. This does NOT mean that you look up numbers
oand 1 on the master colour chart a~d away you go ....
The important thing to remember is that 0 and 1 are PAP E Rand PEN numbers;
they are NOT ink colour numbers. To understand this, imagine having 4 pens on your
desk numbered 0,1,2, and 3, and being able to fill each of these pens with any colour of
your choice out of27 bottles of ink, numbered 0 to 26. It can be seen therefore, that pen
number 1 is not necessarily always the same colour; as it can be filled with a different
ink, in fact you could fill each of the 4 pens with the same ink.

Foundation Course

Chapter 1 Page 49

So it is with the computer. Using the PEN and INK commands, you can select the pen
number, and then the ink colour for that pen.
Remembering that we are operating in Mode 1 (40 columns), look at Table 2 below,
and you will see from the first and third columns, that PEN number 1 corresponds to
INK colour number 24. Now look up INK number 24 on the master colour chart
(Table 1) and you will see that the colour listed is bright yellow, i.e. the colour of the
characters on the screen when you first switch on.

DEFAULT SETTINGS
Paper/Pen No.

Ink Colour
Mode 0

Ink Colour
Model

Ink Colour
Mode2

24

24

24

20

20

24

26

24

24

20

24- - -

10

12

24

24

10

14

20

11

16

24

12

18

13

22

24

24

14

Flashing 1,24

20

15

Flashing 16,11

24

Table 2: PAPER/PEN/MODE/INK reference

Chapter 1 Page 50

Foundation Course

The PAP ERIP E NI INK relationships given in Table 2 are not fixed however. They are
the default settings when you switch-on or reset the computer. You can change them
by using the INK command. The command has two parts (or 'parameters'). The first
part is the number of the PA PER or PEN that you are going to fill with ink, and the
second part is the colour of the ink itself. The two parts of the command are separated
by a comma ,
So, now that we know that we are using PEN number 1 , let's change the colour ofthe
INK in that pen, to orange.
Type in:
ink 1, 1 5 [RETURN]

.... and you will see that the characters on the screen have changed colour.
The background colour can also be changed using the INK command. We know that
PAP ER number 0 is selected at switch on, so let's change the colour of the INK in
PA PER number 0 to green (colour number 9) by typing in the command:
ink 111,9 [RETURN]

Now let's use a different pen altogether. Type in:


pen 3 [RETURN]

Notice how only the colour of the new characters (after the command) changes.
You're using PEN number 3 now, and you will see from Tables 1 and 2 that the INK
initially loaded into PEN number 3 is colour number 6 (bright red). Change it to pink
by typing in:
ink 3, 1 6 [RETURN]

Remember, 3 is the colour of the pen that you selected earlier with the command:
pen 3, and that 1 6 is the ink colour - pink.

Foundation Course

Chapter 1 Page 51

Now let's change to a new paper. When a new paper is selected, the previous
background colour behind the characters will NOT change because that colour was
'printed' by a different PAP ER. To see this, type in:
paper 2 [RETURN]

Once again use Tables 1 and 2 to see why thebackground colour for PAP E R number
2 is bright cyan. Change it to black by typing in:
ink 2,0 [RETURN]

On the screen now, we have characters written by PEN numbers 1 and 3, on a


background of PAP E R numbers 0 and 2. INKs can be changed in aPE N or PAP E R
that you are not currently using. For example, type in:
ink 1, 2 [RETURN]

.... which changes the colour of all the previous characters typed in with PEN
number 1.
Type in:
c Ls [RETURN]

.... to clear the screen.

It should now be possible for you to instruct the computer to return to its original
colours TElue border- and background with bright yellow characters) using the
80 RDE R, PA PER, PEN, and INK commands. See if you can do so. If you can't, then
reset the computer using the [CONTROL] [SHIFT] and [ESC] keys.

Flashing Colours
It is possible to make the colour of the characters flash between one colour and
another. This can be achieved by adding an extra colour number to the INK
command of the PEN.
To see the characters on the screen flashing between bright white and bright red,
reset the computer using [CONTROL] [SHIFT] [ESC], and type in:
ink 1,26,6 [RETURN]

Chapter 1 Page 52

Foundation Course

In this case, 1 is the PEN number, while 26 is the colour brig,ht white, and 6 is the
alternate colour, bright red.

It is also possible to make the colour of the PAP E R behind the characters flash
between one colour and another. This can be achieved by adding an extra colour
number to the INK command for the PAP ER.
To see the PAP ER flashing between green and bright yellow behind the characters,
type in:
ink 0,9,24 [RETURN]

In this case 0 is the PAP E R number, while 9 is the colour green, and 24 is the
alternate colour bright yellow.
Now reset the computer using [CONTROL] [SHIFT] [ESC]
Note from Table 2 that in mode 0, two of the PENs (numbers 14 and 15), together
with two of the PA PE Rs (numbers 14 and 15) are default flashing colours. In other
words, their INK commands have been pre-programmed with an extra colour
parameter.
Type in the following:
mod e 0 [RETURN]
pen 15 [RETURN]

on the screen you will see the word Rea d y flashing between sky blue and pink.
Now type in:
paper 14 [RETURN]
- c Ls . [RETURN]
.

You will now see that in addition to the word Rea d y flashing between sky blue and
pink, the background PAP E R is also flashing between yellow and blue.
PEN and PAP E R !lumbers 1 4 and 1 5 may be re-programmed using the INK
command to other flashing colours, or to one steady colour.
Finally, it is possible to make the B0 RDE R flash between two colours by adding an
extra colour number to the B0 RDE R command. Type in:
b 0 r de r 6,9 [RETURN]

You will now see that the B0 RDE R is flashing between bright red and green. Note
that the border may be set to anyone, or pair ofthe 27 colours, regardless of whether
you are operating in mode 0,1, or 2.
Now reset the computer using [CONTROL] [SHIFT] [ESC]
Foundation Course

Chapter 1 Page 53

For further demonstration of the colours available, type in the following program,
then run it.
1 0 MOD E 0 [RETURN]
20 rat e = 6 0 0: REM set s s pe e d 0 f pro 9 r a m [RETURN]
30 FOR b=0 TO 26 [RETUF\N]
40 LOCATE 3,12 [RETURN]
50 BORDER b [RETURN]
60 PR I NT 11 b 0 r d ere 0 L0 U r 11 ; b [RETURN]
70 FOR t=1 TO rate [RETURN]
80 NE XTt, b [RETURN]
90 CLG [RETURN]
100 FOR p=0 TO 15 [RETURN]
110 PAPER P [RETURN]
1 20 PR I NT 11 pap e r 11 ; P [RETURN]
130 FOR n=0 TO 15 [RETURN]
140 PEN n [RETURN]
1 50 PR I NT 11 pen 11 ; n [RETURN]
160 NE XT n [RETURN]
1 70 FOR t = 1 TOr ate * 2 [RETURN]
1 80 NE XTt, P [RETURN]
190 MODE 1 [RETURN]
200 B 0 RDER 1 [RETURN]
21 0 PAP ER 0 [RETURN]
220 PEN 1 [RETURN]
230 INK 0, 1 [RETURN]
240 INK 1, 24 [RETURN]
run [RETURN]

IMPORTANT
In the above program, and in later chapters and listings in this manual, BASIC
keywords will appear in upper case (CAPITAL) letters. This is how keywords
appear when a program is LIS Ted by the computer. In general it is preferable
that you type instructions or programs using lower case (small) letters, since it will
help you spot typing mistakes when Ll STing the program - (because the
mis-typed BASIC keyword will NOT be converted to upper case).
For the remainder of this Foundation course, we will list programs in both upper
and lower case, so that you get accustomed to this aspect of operation.
A variable's name, such as x or a $, will NOT be converted to upper case when the
program is LIS Ted although the computer will recognise the name regardless of
whether it appears in upper or lower case in the program.

Attention
From this point in the manual, you will not be instructed to press the [RETURN]
key after each line. Therefore it is assumed that you will do it automatically.

Chapter 1 Page 54

Foundation Course

Graphics
There are a number of character symbols in the computer's memory. To print anyone
of these, we use the keyword:

chr$( )
Inside the brackets should be the symbol number, which is in the range from 32 to
255.
Reset the computer, [CONTROL] [SHIFT] [ESC], then type in:

print chr$(250)
Don't forget to press [RETURN]. On the screen you will see character number 2 5121,
which is a man walking to the right.
To see all the characters and symbols appear on the screen together with their
associated numbers, type in the following program, once again remembering to press
[RETURN] after each line.

10 for n=32 to 255


20 print n;chr$(n);
30 next n
run
For your reference, the range of characters together with their respective numbers
appear in the chapter entitled 'For your reference .... '.

LOCATE
This command is used to reposition the character cursor to a specified part of the
screen. Unless changed by the l 0 cat e command, the character cursor starts at the
top left corner of the screen, which corresponds to x,y co-ordinates 1,1 (x is the
horizontal position and y is the vertical position). In mode 1 there are 40 columns and
25 lines. Therefore, to position a character in the centre ofthe top line in mode 1, we
would use 20,1 as the x,y co-ordinates.
To see this, type in: (remember to [RETURN] each line)
mod e 1 .... screen clears, cursor moves to top left.

10 Locate 20,1
20 print chr$(250)
run
Foundation Course

Chapter 1 Page 55

Just to prove that this is on the top line, type in:

border 0
The B0 RDE R will now be black and you will see the man at the middle of the top line
of the screen.
In mode 0, there are only 20 columns, but the same 25 lines. Ifyou now type in:

mode 0
run
.... you will see that the man now appears at the top right corner of the screen. This
happens because the x co-ordinate 20, is the last column in mode O.
In mode 2, there are 80 columns and 25 lines. Using the same program, you will
probably be able to guess where the man will appear. Type in:

mode 2
run
Return to mode 1 by typing in:

mode 1
Now experiment for yourself, modifying the L0 cat e and ch r $ ( ) numbers to
position various characters anywhere on the screen. Just for example, type in:

Locate 20,12:print chr$(240)


You will see an arrow in the centre of the screen. Note that in this instruction:

20 was the horizontal (x) co-ordinate (in the range 1 to 40)


1 2 was the vertical (y) co-ordinate (in the range 1 to 25)
240 was the character symbol number (in the range 32 to 255)
To get the character symbol 250 to be repeated across the screen, type in the following
program:

10 CLS
20 FOR x=1 TO 39
30 LOCATE x,20
50 PRINT CHR$(250)
60 NEXT x
70 GOTO 10
run
Press [ESe] key twice to break.

Chapter 1 Page 56

Foundation Course

\
In order to remove the previous character from the screen before printing the next
character, type in:

50 print" ";chr$(250)
(This new line 5 0 automatically replaces the previously typed in line 5 0.)
Now type in:

run

FRAME
To improve the movement of the character across the screen, add the following line:

40 .frame
The F RAME command synchronises the movement of objects on the screen to the
display frame scanning frequency. If that's a bit technical for you,just remember that
the command should be used whenever you want to move characters or graphics
around the screen smoothly.
This program can be further enhanced to improve the movement by adding some
delay loops and by using a different returning character symbol.
Type in:
Lis t

Now add the following lines to the program:

70 FOR n=1 TO 300: NEXT n


80 FOR x=39 TO 1 STEP -1
90 LOCATE x,20
100 FRAME
110 PRINT CHR$(251);" "
120 NEXT x
130 FOR n=1 TO 300:NEXT n
140 GOTO 20
run

Foundation Course

Chapter 1 Page 57

PLOT
Unlike the L0 CAT E command, PLO T may be used to determine the position of the
graphics cursor, using pixel co-ordinates. (A pixel is the smallest possible segment of
the screen).
Note that the graphics cursor is not visible and is different from the character cursor.
There are 640 horizontal pixels by 400 vertical pixels. The x,y co-ordinates are
positioned with respect to the bottom left corner of the screen, which has x,y
co-ordinates of 0,0. Unlike the LO CAT E command used for characters, the
co-ordinates do not differ between modes 0,1, or 2.
To see this, first reset the computer using [CONTROL] [SHIFn [ESC], then type in:

pLot 320,200
A small dot will appear in the centre of the screen.

Now change the mode by typing in:

mode 0
pLot 320,200
You will see the dot is still in the centre but is now larger. Change the mode again and
type in the same command to see the effect in mode 2:

mode 2
pLot 320,200
The dobs still in the centre, but is now much smaller.
Plot several dots over the screen in various modes, in order to accustom yourself with
this command. When you have finished, return to mode 1 and clear the screen by
typing in:

mode

DRAW
First reset the computer using [CONTROL] [SHIFn [ESC]. The DRAW command
draws a line from the current graphics cursor position. To see this in more detail,
draw a rectangle on the screen by using the following program.
We start by repositioning the graphics cursor with a PLO T command, then DRAWing
a line from the graphics cursor position, up towards the top left corner, then from
there to the right corner etc, etc. Type in:

Chapter 1 Page 58

Foundation Course

5 cLs
10 pLot
20 draw
30 draw
40 draw
50 draw
60 go to
run

10,10
10,390
630,390
630,10
10,10
60

Press [ESe] twice to break from this program.


(Notice line 60 of this program; the computer is told to 'loop' around line 60 again
and again, until you 'break' from the program by pressing [ESe] twice. This sort of
instruction is useful if you do not want the computer to automatically 'break' at the
end of a program and display the Rea d y prompt that usually appears on the screen.)
Now add the following lines to the program, to draw a second rectangle inside the
first. Type in:

60 pLot 20,20
70 draw 20,380
80 draw 620,380
90 draw 620,20
100 draw 20,20
110 goto 110
run
Again, press [ESe] twice to break from this program.

MOVE
The M0 VE command operates in a similar manner to PLO T, in that the graphics
cursor is moved to the position specified by the x,y co-ordinates; however the pixel
(dot) at the new graphics cursor location is NOT plotted.
Type in:

cLs
move 639,399
Although we can see no sign of it on the screen, we have moved the graphics cursor to
the top right corner.
Let's prove it by drawing a line from that position to the centre of the screen, by
typing in:

draw 320,200
Foundation Course

Chapter 1 Page 59

Circles
Circles can either be plotted or drawn. One method of forming a circle is to plot the
x,y, co-ordinates of each point on the circumference of a circle. Refer to the diagram
below and you will see that point 'p' on the circumference can be plotted using x and y
co-ordinates. These are:

x=19Ql*cos(a)
y=190*sin(a)

8N

EDGE OF
SCREEN

320

Plotting the points of a circle.


In previous programs we have plotted points with respect to the bottom left corner of
the screen. Ifwe wanted to position a circle in the centre of the screen we would have
to plot the centre of the circle at co-ordinates 320,200 then position all points of the
circle relative to the centre position, by adding on the centre position co-ordinates.
A program to plot a circle would then be like this. Type in:

new
10 CLS
20 DEG
30 FOR a=1 TO 360
40 MOVE 320,200
50 DRAW 320+190*COS(a),200+190*SIN(a)
60 NEXT
run
Chapter 1 Page 60

Foundation Course

Note the use of the keyword NEW before typing in this program. This tells the
computer to clear any program in the memory (in a similar manner to [CONTROL]
[SHIFT] [ESC]). However the screen itself is not cleared.
The radius of the circle can be reduced by lowering the 190 figure (190 refers to
pixels).
To see the effect of the circle being plotted differently (in radians), delete line 20 from
the program by typing in:

20
To see a solid circle drawn by lines from the centre, edit line 50, replacing the word
pLo t with the word d raw. (Line 50 will then be):

50 draw 320+190*cos(a),200+190*sin(a)
Try this with and without line 20 again.
You will note that line 60 of this program is NE XT instead of NE XTa. It is
permissible to simply type 'N EXT' on its own; the computer will work out which FOR
expression the NE XT is to be associated with. In programs where there are numerous
FOR and N ~ XT loops however, you may wish to add the variable's name after the
word NE XT in order to identify the NE XT statement when studying the program.

ORIGIN
In the preyious program we used the M0 VE command to establish the centre of a
circle, then added the x,y co-ordinates to this centre position. Instead of adding these
centre co-ordinates to the point plotted, we can use the 0 RIG I Ncommand. This will
position each of the x,y co-ordinates relative to the 0 RIG IN. To see this, type in:

new
10 cls
20 for a=1 to 360
30 origin 320,200
40 plot 190*cos(a),190*sin(a)
50 next
run

Foundation Course

Chapter 1 Page 61

To plot four smaller circles on the screen, type in the following program:

new
1'" CLS
2'" FOR a=1 TO 36'"
3'" ORIGIN 196,282
4'" PLOT S"'*COS(a),S"'*SIN(a)
S'" ORIGIN 442,282
6'" PLOT S"'*COS(a),S"'*SIN(a)
7'" ORIGIN 196,116
8'" PLOT S"'*COS(a),S"'*SIN(a)
9'" ORIGIN 442,116
1"'''' PLOT S"'*COS~a),S"'*SIN(a)
11'" NEXT
run
To see a different way of creating a circle, type in the following program:

new
1'" MODE 1
2'" ORIGIN 32"',20'"
3'" DEG
4'" MOVE "',19'"
S'" FOR a='" TO 36'" STEP 1'"
6'" DRAW 19"'*SIN(a),19"'*COS(a)
7'" NEXT
run
This time a line is DRA Wn from co-ordinate to co-ordinate around the circumference
of the circle. Note how the circle is drawn much quicker than it is plotted.
Once again observe the effect of removing the DEG command, by deleting line 30,
then RUN ning the program again.

FILL
The F ILL command is used to fill an area ofthe screen which is enclosed by drawn or
edge of screen/graphics window boundaries.
Reset the computer, [CONTROL][SHIFT] [ESC], then type in:

new
1'" cls

2'" move
3'" draw
4'" draw
S'" draw
run

2"',2'"
62"',2'"
31"',38'"
2"',2'"

Chapter 1 Page 62

Foundation Course

On the screen you will see a triangle. Move the graphics cursor to the centre of the
screen by typing in:

move 320,200 .
Using the keyword F ILL followed by a pen number, for example 3, we will now
F ILL the screen using the specified pen, from the current graphics cursor position
(centre screen) to the drawn boundaries. Type in:
f iLL 3

Now move the graphics cursor outside the triangle by typing in:

move 0,0
See what happens when you type in:
f iLL 2

The computer has used pen number 2 to F ILL the area bounded by the drawn lines
and by the edges of the screen.
Now alter the program by typing in the following lines, and see what happens:

50 draw 50,50
60 move 320,200
70 fiLL 3
run
You will note that any gaps in the drawnbollhaarieslettne--inkIrom tnepen'seep'
through!
This point is further demonstrated by F I L Ling first a plotted circle, then a drawn
circle. Type in:

new
10 CLS
20 FOR a=1 TO 360
30 ORIGIN 320,200
40 PLOT 190*COS(a),190*SIN(a)
50 NEXT
60 MOVE -188,0
70 FILL 3
run

Foundation Course

',--,

'.
j

.~

Chapter 1 Page 63

Now try:

new
10 MODE 1
20 ORIGIN 320,200
30 DEG
40 MOVE 0,190
50 FOR d=0 TO 360 STEP 10
60 DRAW 190*SIN(d),190*COS(d)
70 NEXT
80 MOVE -188,0
90 FILL 3
run

( (n

We can make the outline of the circle to be filled invisible, by setting the pen ink to
the same colour as the paper ink. Add:

45 GRAPHICS PEN 2:INK 2,1


run
The GRAP HIe S PEN command selects the pen to be used for drawing graphics on
the screen. The INK command then specifies the ink colour for that pen, which in this
case, is the same as for the paper (i.e. colour number 1).
Finally, type in this demonstration program:

new
10 MODE 0:BORDER 13
20 MOVE 0,200:DRA~L6A~,_2QJ0_
30 FOR x=80 TO 560 STEP 80
40 MOVE x,0:DRAW x,400
50 NEXT:MOVE-40,300
60 FOR c=0 TO 7
70 MOVER 80,0:FILL c
80 MOVER 0,-200:FILL c+8
90 MOVER 0,200:NEXT
100 GOTO 100
run
The colours of the filled areas can be changed after the fill. Type in:

100
110
120
130
run

SPEED INK 30,30


BORDER RND*26,RND*26
INK RND*15,RND*26,RND*26
FOR t=1 TO 500:NEXT:GOTO 110

Chapter 1 Page 64

Foundation Course

Further details ....


For a more comprehensive guide to graphics on the CPC6128, see the section
'Graphically speaking' in the chapter entitled 'At your leisure .... '.
To conclude this section, here are a few graphics demonstration programs which
incorporate a lot of the programming commands and keywords that you should now
understand. Each of the programs draws continuous patterns on the screen.

new
10 BORDER 0:GRAPHICS PEN 1
20 m=CINT(RND*2):MODE m
30 i1=RND*26:i2=RND*26
40 IF ABS(i1-i2)<10 THEN 30
50 INK 0,i1:INK 1,i2
60 s=RND*5+3:0RIGIN 320,-100
70 FOR x= -1000 TO 0 STEP 5
80 MOVE 0~0:DRAW x,300:DRAW 0,600
90 MOVE 0,0:DRAW -x,300:DRAW 0,600
100 NEXT:FOR t=1 TO 2000:NEXT:GOTO 20
run
10 MODE 1:BORDER 0:PAPER 0
20 GRAPHICS PEN 2:INK 0,0:i=14
30 EVERY 2200 GOSUB 150
40 flag=0:CLG
50 INK 2,14+RND*12
60 b%=RND*5+1
70 c%=RND*5+1
80 ORIGIN 320,200
90 FOR a=0 TO 1000 STEP PI/30
100 x%=100*COS(a)

110 MOVE x%,y%


120 DRAW 200*COS(a/b%),200*SIN(a/c%)
130 IF flag=1 THEN 40
140 NEXT
150 flag=1:RETURN
run

Foundation Course

Chapter 1 Page 65

10
20
30
40
50
60
70
80

MODE 1:BORDER 0:DEG


PRINT "PLease wait"
FOR n=1 TO 3
INK 0,0:INK 1,26:INK 2,6:INK 3,18
IF n=1 THEN sa=120
IF n=2 THEN sa=135
IF n=3 THEN sa=150
IF n=1 THEN ORIGIN 0,-50,0,640,0,400 ELSE ORIGIN 0,0
,0,640,0,400
90 DIM cx(5),cy(5),r(5),Lc(5)
100 DIM np(5)
110 DIM px%(5,81),py%(5,81)
120 st=1:cx(1)=320:cy(1)=200:r(1)=80
130 FOR st=1 TO 4
140 r(st+1)=r(st)/2
150 NEXT st
160 FOR st=1 TO 5
170 Lc(st)=0:np(st)=0
180 np(st)=np(st)+1
190 px%(st,np(st=r(st)*SIN(Lc(st
200 py%(st,np(st=r(st)*COS(Lc(st
210 Lc(st)=Lc(st)+360/r(st)
220 IF Lc(st) < 360 THEN 180
230 px%(st,np(st)+1)=px%(st,1)
240 py%(st,np(st)+1)=py%(st,1)
250 NEXT st
260 CLS:cj=REMAIN(1):cj=REMAIN(2)
270 cj=REMAIN(3):INK 1,2:st=1
280 GOSUB 350
290 LOCATE 1,1
300 EVERY 25,1 GOSUB 510
310 EVERY 15,2 GOSUB 550
320 EVERY 5,3 GOSUB 590
330 ERASE cx,cy,r,Lc,np,px%,py%:NEXT
340 GOTO 340
350 cx%=cx(st):cy%=cy(st):Lc(st)=0
360 FOR x%=1 TO np(st)
370 MOVE cx%,cy%
380 DRAW cx%+px%(st,x%),cy%+py%(st,x%),1+(st MOD 3)
390 DRAW cx%+px%(st,x%+1),cy%+py%(st,x%+1),1+(st MOD 3)
400 NEXT x%
410 IF st=5 THEN RETURN
420 Lc(st)=0
430 cx(st+1)=cx(st)+1.5*r(st)*SIN(sa+Lc(st
This program continues on the next page
Chapter 1 Page 66

Foundation Course

440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620

cy(st+1)=cy(st)+1.5*r(st)*COS(sa+lc(st
st=st+1
GOSUB 350
st=st-1
lc(st)=lc(st)+2*sa
IF (lc(st) MOD 360)<>0 THEN 430
RETURN
ik(1)=1+RND*25
IF ik(1)=ik(2) OR ik(1)=ik(3) THEN 510
INK 1,ik(1)
RETURN
ik(2)=1+RND*25
IF ik(2)=ik(1) OR ik(2)=ik(3) THEN 550
INK 2,ik(2)
RETURN
ik(3)=1+RND*25
IF ik(3)=ik(1) OR ik(3)=ik(2) THEN 590
INK 3,ik(3)
RETURN

Foundation Course

Chapter 1 Page 67

Part 9: Using Sound....


Sound is generated by a loudspeaker within the computer itself. If you are using an
MP2 ModulatorlPower supply and a domestic television, set the TV's volume control
to a minimum.
The level of sound can be adjusted by use of the VOLUME control at the rear of the
computer. The sound can also be fed to the auxiliary input socket of your stereo
system, using the socket on the computer marked STEREO. This will enable you to
listen to the sound generated by the computer in stereo, through your hi-fi
loudspeakers or headphones. Instructions on connecting to the computer's STEREO
socket will be found in part 2 of this Foundation course.

The SOUND Command


The SOU NDcommand has 7 parts ('parameters'). The first two of these must be used;
the rest are optional. The command is typed in as:
SOU ND<channel status> , <tone period> , <duration> , <volume> , <volume envelope> ,
<tone envelope> , <noise period,

It looks pretty complicated, but if we analyse each parameter, we can soon get to grips
with it. Let's look at the parameters one by one ....

Channel Status
To keep things simple at the moment, regard the <channel status, as the reference
number for the sound channel. There are 3 sound channels, and for now we will use
the <channel status, number 1 .

Tone Period
<Tone period, is a technical way of defining the pitch of the sound, or in other words,
'what note it is' (i.e. do re mi fa so, etc). Each note has a set number, and this number is
the <tone period,. Refer to the chapter entitled 'For your reference .... ', and you will see
that the note middle c (do), has a tone period of 2 3 9 .

Chapter 1 Page 68

Foundation Course

Now reset the computer [CONTROL] [SHIFT] [ESC] , and type in:

10 sound 1,239
run
You will hear a short note which is middle c lasting 0.2 second.
If you don't hear anything, make sure that the VOLUME control on the computer is
not set to zero, then type RUN again.

Duration
This parameter sets the length of the sound, in other words, 'how long it lasts'. The
parameter works in units of 0.01 (one hundredth) ofa second, and if you don't specify
the <duration>, the computer will assume a figure of 20, which is why the note you
just heard lasted 0.2 second, i.e. 0.01 multiplied by 20.
To make the note last for 1 second, a <duration> of 1 00 would be be used; to make it
last 2 seconds, 200 would be used. Type in:

10 sound 1,239,200
run
You will hear the note middle c lasting 2 seconds.

Volume
This parameter specifies the starting volume of a note. The number is in the range 0
to 1 5. A <volume> figure of 0 is minimum, while 1 5 is maximum. If no number is
used, 1 2 is assumed. Type in:

10 sound 1,239,200,5
run
Note the volume of this sound. Now type it in using a higher volume number:
\

10 sound 1,239,200,15 }
run
You will hear that this is much louder.

foundation Course

Chapter 1 Page 69

Volume Envelope
To make the volume vary within the duration of the note, you can specify a volume
envelope using the separate command EN V. You can in fact make a number of
different volume envelopes, and like the SOU ND command, each has its own
reference number. If you have created a volume envelope with a reference number of
1 , and you wish to use it in a SOU ND command, then where the parameter <volume
envelope> is required, type in 1. Creating volume envelope will be explained
shortly.

Tone Envelope
To make the tone or pitch vary within the duration ofthe note, you can specify a tone
envelope using the separate command ENT. You can in fact make a numher of
different tone envelopes, and like the SOU ND command, each has its own reference
number. If you have created a tone envelope with a reference number of 1, and you
wish to use it in a SOU ND command, then where the parameter <tone envelope> is
required, type in 1. Creating a tone envelope will be explained shortly.

Noise
<Noise> is the last parameter ofthe SOU NDcommand. A range of noise is available by
varying the <noise> parameter between 1 and 3 1 . Add a <noise> parameter of 2 at the
end of the SOU ND command and listen to the effect. Then change the <noise>
parameter to 27 and listen to the difference. Type in:
10 sound 1,239,200,15",2
Note the two 'blank' parameters (",) before the <noise> parameter of 2. This is
because we haven't created a <volume envelope> nor a <tone envelope>.

Creating a Volume Envelope


The volume envelope command is EN V. In its simplest form, the command has 4
parameters: The command is typed in as:
ENV <envelope number> , <numberofsteps> , <size of step> , <time per step>

As before, let's look at the parameters one by one.

Chapter 1 Page 70

Foundation Course

Envelope Number
This is the reference number (between 0 and 15) given to a particular volume
envelope so that it can be called up in the SOU NDcommand.

Number of Steps
This parameter specifies how many different steps of volume you want the sound to
pass through before it ends. For example, in a note which lasts 10 seconds, you may
wish to have 10 volume steps of 1 second each. In such a case, the <number of steps>
parameter used should be 1 0.
The available range of <number of steps> is 0 to 1 27.

Size of Step
Each step can vary in size from a volume level of 0 to 1 5 with respect to the previous
step. The 16 different volume levels are the same as those you will hear in the sou ND
command. However, the <size of step> parameter used can be between -1 28 and
+ 1 27; the volume level re-cycling to 0 after each 1 5.

Time per Step


This parameter specifies the time between steps in 0.01 second (hundredths of a
second) units. The range of <time per step> numbers is 0 to 255, which means that the
longest time between steps is 2.56 seconds (0 is treated as 256).
Note therefore, that the <number of steps> parameter multiplied by the <time per step>
parameter shouldn't be greater than the <duration> parameter in the SOU ND
command, otherwise the sound will finish before all the volume steps have been
passed through.
(In such a case, the remaining contents of the volume envelope are discarded.)
Likewise, if the <duration> parameter in the SOU ND command is longer than the
<number of steps> multiplied by the <time per step> ,'the sound will continue after all of
the volume steps have been passed through, and will remain constant at the final
level.
To experiment with the volume envelope, type in the following program:

10 env "1,10,1,100
20 sound 1,142,1000,1,1
run

Foundation Course

Chapter 1 Page 71

Line 20 specifies a SOU NDwith a tone period of 1 42 (international a), lasting for 10
seconds with a start volume of 1 , and using volume envelope number 1, conisting of
10 steps, raising the volume'ofeach step by 1, every 1 second (100 x 0.01 second).
Change line 1 0 in each of the following ways and then run to hear the effect of
changing the envelope:

10
10
10
10
10
10

env
env
env
env
env
env

1,100,1,10
1,100,2,10
1,100,4,10
1,50,20,20
1,50,2,20
1,50,15,30

And finally try this:

10 env 1,50,2,10
You will notice that half way through the sound, the level remains constant. This is
because the number of steps was 50 and the time between each step was 0.1 second.
Therefore the length of time during which the volume varied was only 5 seconds, but
the <durati0n> parameter in the SOUND command in line 20 was 1000, i.e. 10
seconds.
TrY.' experimenting yourself, to see what type of sounds you can create.

If you wish to create a more intricate volume envelope, the 3 parameters: <number of
steps>, <size of step> ,<timeperstep>mayberepeatedattheendofthe ENV command
up to 4 more times, to specify a different 'section' of the same envelope.

Creating a Tone Envelope


The tone envelope command is ENT. In its simplest form, the command has 4
parameters: The command is typed in as:
ENT <envelope number> , <number of steps> , <tone period of step> , <time per step>

Once again, let's look at the parameters one by one.

Envelope Number
This is the reference number (between 0 and 1 5) given to a particular tone envelope
so that it can be called up inthe SOU NDcommand.

Chapter 1 Page 72

Foundation Course

Number of Steps
This parameter specifies how many different steps of tone (pitch) you want the sound
to pass through before it ends. For example, in a note which lasts 10 seconds, you may
wish to have 10 tone steps of 1 second each. In such a case, the <number of steps>
parameter used should be 1 0.
The available range of <number of steps> is 0 to 239.

Tone Period of Step


Each tone step can vary in the range - 1 28 to + 1 27 with respect to the previous step.
Negative steps make the pitch of the note higher; positive steps make the pitch ofthe
note lower. The shortest tone period is 0. This must be remembered when
formulating the tone envelope. The full range oftone periods is shown in the chapter
entitled 'For your reference .... '.

Time per Step


This parameter specifies the time between steps in 0.01 second (hundredths of a
second) units. The range of <time per step> numbers is 0 to 2 5 5, which means that the
longest time between steps is 2.56 seconds (0 is treated as 256).
Note therefore, that the <number of steps> parameter multiplied hy the <time per step>
parameter shouldn't be greater than the <duration> parameter in the SOU ND
command, otherwise the sound will finish before all the tone steps have been passed
through. (In such a case, the remaining contents of the tone envelope are discarded.)
Likewise, if the <duration> parameter in the SO UN D command is longer than the
<number of steps> multiplied by the <time per step>, the sound will continue after all of
the tone steps have been passed through, and will remain constant at the final tone
pitch.
To experiment with the tone envelope, type in the following program:

HI ent 1,1111111,2,2
2111 sound 1,142,2111111,15,,1
run
Line 20 specifies a SOU ND with a tone period of 1 42 (international a) lasting for 2
seconds with a start volume of 1 5 (max), without a volume envelope (represented by
a blank parameter, ,) and with tone envelope number 1 .
Line 1 0 is tone envelope number 1 consisting of 1 00 steps, increasing the tone
period (reducing the pitch) by 2, every 0.02 second (2 x 0.01 second).

Foundation Course

Chapter '1 Page 73

Now change line 10 in each of the following ways, and then RUN to hear the effect of
changing the tone envelope:

10 ent 1,100,-2,2
10 ent 1,10,4,20
10 ent 1,10,-4,20
Now replace the sou n d command and the tone envelope by typing in:

10 ent 1,2,17,70
20 sound 1,71,140,15,~1
30 goto 10
run
Press [ESe] twice to break.
Now you can put the volume envelope, tone envelope, and sou n d command together
.
to create various sounds. Start with:

10 env 1,100,1,3
20 ent 1,100,5,3
30 so~nd 1,142,300,1,1,1
run
Then replace line 2 0 by typing in:

20 ent 1,100,-2,3
run
Now replace all the lines by typing in:

10 env 1,100,2,2
20 ent 1,100,-2,2
30 sound 1,142,200,1,1,1
run

If you wish to create a more intricate tone envelope, the 3 parameters: <number of
steps, , <tone period of step' , <time per step' may be repeated at the end of the ENT
command up to 4 more times, to specify a different 'section' of the same envelope.
Try some more variations for yourself. Add some <noise, to the SOU NDcommand, and
try adding some extra sections to the volume and tone envelopes.
The chapter entitled 'Complete list of AMSTRAD CPC6128 BASIC Keywords'
contains full details of the various sound commands. If you are interested in the more
melodius aspects of sound, see the section, 'The Sound of Music' which you will find in
the chapter entitled 'At your leisure .... '.
Chapter 1 Page 74

Foundation Course

Part ID: Introducing AMSDOS and


CP/M....
What is AMSDOS? ....
When the computer is switched on or reset, the system defaults to operation under
'AMSDOS'. AMSDOS is an abbreviation of AMStrad ,Disc Operating System, and
offers the following file handling commands and functions:
LOAD "fi lename"
RUN "filename"
SAVE IIf; lename"
CHAIN "fi lename"
MERGE "fi lename"
CHAIN MERGE "fi lename"
OPENIN "fi lename"
OPENOUT "fi lename"
CLOSEIN
CLOSEOUT
CAT
EOF
INPUT #9
LINE ,INPUT #9
LIST #9
PRINT #9
WRITE #9

In addition, AMSDOS provides a number of extra commands for disc management.


These commands are called external commands, and are preceded with a bar symbol
I. (You will find the I symbol by holding down [SHIFT] and pressing the (j} key.)
Some of the more common external commands that you will use are:

la
Ib
I tap e (which can be sub-divided into I tap e i n and I tap e 0 ut)
Id; s c (which can be sub-divided into I d i se. i n and Id; se. 0 ut)
The commands I a and I b are used on a 2-drive system, to tell the computer which
drive to direct any subsequent disc command.

Foundation Course

Chapter 1 Page 75

Typing in for example:


la

Load "fi Lename"


.... will tell the computer to load the specified program from a disc placed in Drive A.
If neither I a nor I b is entered or the computer is reset, the system will default to
Drive A.
If you are t'sing only the disc drive within the computer, this can be regarded as Drive
A, and I a or I b commands need not be issued. Entering I b when no additional disc
drive is connected, will result in the message on the screen:

Drive B: disc missing


Retry, Ignore or CanceL
to which you should respond C (to Cancel).

What if I want to use cassette? ...


The command I tap e tells the computer to perform all loading and saving etc.,
commands to an external cassette unit instead of to disc. Unless I tap e is entered,
the computer will always default to disc operation when switched on or reset.
To return to disc operation after I tap e has been specified, type in:

Idisc
Alternatively, you may for example wish to load in from cassette and save out to disc.
You may then use the command:

Itape.in
This command tells the computer to read data in from cassette, but continue to write
data out onto disc (by default).
Similarly, to read data in from disc and save out onto cassette, you will first need to
type in: I d i se. into countermand the previously issued I tap e i n (above),
then: I tap e 0 ut to tell the computer to write data out onto cassette.

It can be seen therefore that I tap e i n and I tap e 0 u t countermand


I d i se. i n and I d i se. 0 ut respectively, and vice versa.
Further information on directing data to and from discs (and cassette), will be found
in the chapters entitled 'Using Discs and Cassettes' and 'AMSDOS and CP/M'
(Chapters 4 and 5).
Chapter 1 Page 76

Foundation Course

Program copying between discs, and cassette


In part 7 of this Foundation course, you learned how to format a new blank disc using
the DI S CKIT 3 program on Side 1 of your master CP/M system discs package. You
also learned how to copy a program from one disc to another. Now, using the
commands:

Itape Idisc Itape.in Itape.out Idisc.in Idisc.out la Ib


.... you will be able to perform loading and saving to a disc placed either in Drive A or
Drive B (if connected), or to a cassette unit (if connected).
Other external commands:

Idir Idrive lera Iren luser


.... are dealt with later in this manual, in the chapter entitled 'AMSDOS and CPIM'
(Chapter 5).

Copying a Whole Disc


The entire contents of a disc can be copied from one to another using the DI SCKIT 3
program on Side 1 ofthe CP/M system discs package.
You may use this method to make back-up copies of the master system discs
themselves.
Insert Side 1 of the system disc package into the computer's disc drive, and type:

Icpm
After the A> prompt, type:

disckit3
After a few seconds, you will see the DISC KIT opening message at the top of the
screen, followed by:

One drive found


This message tells you that you are running the DISC KIT utility program, and the
computer has detected that you are operating only one disc drive (the one within the
computer).

Foundation Course

Chapter 1 Page 77

If you have connected an additional disc drive to the system, the message will say:

Two drives found


At the bottom of the screen, you will see the following:

Copy

Format

Verify

Exit from program

This is known as the main DISC KIT menu. The numbers in boxes refer to the
function keys at the right hand end ofthe keyboard (marked f0, f1, f4, and f7), and
pressing one of these keys takes you to your selected menu choice.
Note that pressing function key number 0 at this point will exit from the DISC KIT
program back toCP/M Direct Console Mode (the A> prompt).
We now want to copy a disc, so press function key number 7 (f7).

BEWARE
COPYING ONTO A PREVIOUSLY RECORDED DISC WILL ERASE ITS CONTENTS

Copying on a I-drive system


Assuming that you are using a i-drive system (i.e. you have NOT connected an
additional drive), you will then see the message:

Copy
Any other key to exit menu

At this point, you should remove your master CP/M system disc, and insert the disc
that you wish to copy from. If you wish to copy the CP/M system disc itself, simply
leave it in the drive.

Chapter 1 Page 78

Foundation Course

When the disc that you wish to copy from is in the drive, press the Y key, (Y is for Yes,
meaning 'go-ahead and copy the disc').
The format of the disc will be examined by the computer, and displayed at the top of
the screen for your information.
After a while, you will see the message:

Insert disc to WRITE


Press any key to continue
At this point, you should take the disc that you are copying out of the drive. Then
insert the disc for copying onto, and press any key.
Information about the format of the disc to be copied onto (even if it is a new
unformatted disc) will be indicated at the top of the screen.
If the disc that you wish to copy onto is not correctly formatted (or not formatted at
all), this will be taken care of during copying, and you will see a message such as:

Disc isn't formatted (or faulty)


Goi ng to format whi le copyi ng
Di sc wi II be system format
.... or some other similar message, depending upon the discs that you are copying
between.
When the computer is again ready for the disc to copy from, it will display the
.
.
message:

Insert disc to READ


Press any key to continue
.... and you should re-insert the disc to copy from.
After repeating this process a few times, the contents of the first disc will be copied
onto the second disc, and the message:

Copy completed
Remove disc
Press any key to continue
.... will appear, whereupon you should follow the instructions on the screen, which
give you the option to either copy another disc (by typing Y) or 'exit'ing to the main
DISC KIT menu.

Foundation Course'

Chapter 1 Page 79

Write protection
Note that you will not be able to copy onto a disc which has its write protect hole open.
Attempting to do so will result in the message:

Disc write-protected
Insert disc to WRITE
R-etry or C-anceL
.... whereupon you should type C to Cancel, remove the disc, and insert the correct disc
for copying onto, with its write protect hole closed.
Make sure that you don't close the write protect hole on a disc that contains programs
you want to keep, and NEVER close the write protect holes on your master CPIM
system discs package.

Copying on a 2-drive system


Follow the instructions above, loading the DI S CKIT 3 program from Side 1, then
select the Cop y option from the main DISC KIT menu by pressing key 17.
At this point, you will receive a further menu:

Read from A:

. Read from B:

Exit menu

Copying on a 2-drive system means that you do not have to repeatedly insert and
remove the discs for copying to and from. The above menu allows you to select the
drive into which you wish to place the disc that you are copying from. Press key f8 to
copy from the disc in Drive A.

Chapter 1 Page 80

Foundation Course

A third menu will then be displayed:

Write to A:

Write to B:

Exit menu

This menu offers a choice of drive into which you wish to place the disc for copying
onto. You may, if you wish, select the same drive as that for copying from, but it will
mean that you will have to repeatedly change discs, and you won't be taking
advantage of your 2-drive system.
For greater ease andspeed of copying, press key f6 to copy onto the discin Drive B.
Now place the 2 discs into the appropriate drives, and type Yto commence copying.
Once again, information about the format of both discs will be displayed on the
screen, and if the disc to copy onto is not correctly formatted, (or not formatted at all),
this will be taken care of during copying.
After copying, the following message will be displayed:

Copy completed
Remove both discs
Press any key to continue
.... and you must remove BOTH discs before you can perform any further operations.
You may then repeat the copying process by typing Y, or exit to the main DISC KIT
menu by pressing any other key.

Verifying discs
The DI S CKIT 3 program also provides you with the facility to verify (check) a disc.
Information about the format of the disc is displayed, and all files on the disc are read.
Any errors present in the files are reported on the screen.
To verify a disc, insert Side 1 of your system discs package, and type:

Icpm

Foundation Course

Chapter 1 Page 81

At the A> prompt, type:

disckit3
Select the Ve r ; f y option from the main DISC KIT menu (key f1), and then follow
the instructions on the screen.
If you are operating a 2-drive system, you will be given the option to verify a disc
either in Drive A or Drive B.
When the disc that you wish to verify is inserted in the drive, type Y to commence
verifying.
When verifying is completed, the following message will be displayed:

Verify compLeted
Remove disc
Press any key to continue
If you are operating a 2-drive system; you will be requested to remove BOTH discs,
and you must do so before you can perform any further operations. You may then
repeat the verifying process by typing Y, or exit to the main DISC KIT menu by
pressing any other key.

Using the DISC KIT program on CP/M 2.2


If you wish to format, copy, or verify discs created on or for the CPC664 or
CPC464+ DDIl (which both use CP/M 2.2), a DISC KIT program has been provided
on Side 4 of your system discs package for this purpose. The program is called
DI S CKIT 2, and operates in the same manner as DI S CKIT 3 ,just described.
To run DI S CKIT 2, insert Side 4 of your system discs package into the computer's
disc drive, and type:

Icpm
After you receive the CP/M 2.2 'sign-on' message and the A> prompt, type:

disckit2
From then on, simply select the required menu options and follow the instructions
displayed, as previously described for DI S CKIT 3.

NOTE - During copying, the DI S CKIT 2 program utilises the screen memory for
data. You will therefore see random patterns appear on the screen while copying is
being performed.
.

Chapter 1 Page 82

Foundation Course

Further Information
Further information about using the programs provided on your master CP/M
system discs package will be found in Chapters 4 to 9 ahead.
Finally, check that you have observed the following warnings given.at the beginning
of this manual, in the section entitled 'IMPORTANT':
INSTALLATION NOTES 5,6,7
OPERATION NOTES 1,2,3,4,5,6,7,9

Foundation Course

Chapter 1 Page 83

Part 11: Introducing the Bank


Manager....
Using the second 641{ of memory
The CPC6128 contains 128K of RAM (Random Access Memory) in two lots of64K.
CPIM Plus uses the fu11128K all the time, but BASIC does not normally use the
second 64K - orily the available memory in the first 64K. It would be a pity to leave
the extra 64K completely unused when programming in BASIC, so a program has
been provided to make special use of this extra memory. The program offers some
extra commands that make it possible to use the second 64K of RAM as either a
storage space for screen images, or as a storage space for strings.
The program providing these extra commands is known as the 'BANK MANAGER'
where 'bank' is a technical term used to describe a section of memory.

Using the BANK MANAGER for screen images


The 6128 is displaying a screen image all the time. To do this, it requires 16K of
memory in which to store the information about the colour and brightness of every
pixel (dot) on the screen. The 6128's memory allows up to six screen images (each in a
16K block) to be present in the computer's memory at anyone time. The BANK
MANAGER provides the facilities for you to juggle and display up to five of the six
possible screens from BASIC.
When you first switch on, the screen is displayed from a 16K block of memory (which
we will call 'Block 1') out of the first 64K. The other four screens are held in the second
64K of memory and are called Block 2, Block 3, Block 4, and Block 5.
Only Block 1 (from the first 64K) can be used to actually display a screen. Therefore,
to see a screen stored in the second 64K (Blocks 2 to 5), it is necessary to move the
required screen into Block 1. The BANK MANAGER provides all the commands
needed to move screens around, such as I S eRE ENCO PYwhich simply transfers one
screen to another, overwriting the contents of the existing screen; and
IS eRE ENS WA P which exchanges the contents of two screens.
Like the AMSDOS commands introduced earlier in this chapter, the BANK
MANAGER uses 'external commands' which start with the bar symbol I (obtained
by typing [SHIFn@).

Chapter 1 Page 84

Foundation Course

How to use the BANI{ MANAGER


Reset the computer [CONTROL] [SHIFT] [ESC], then insert Side 1 of your system
discs package and type:

RUN "BANKMAN"
The loading procedure is detailed in Chapter 7 part 13 on RSX's (Resident System
eXtensions), and it is advisable to have some understanding about RSX's and also
about reserving memory space, before. using these routines in your programs.
However, to try the following examples, you will not need to understand the loading
procedure.
Type:

MODE
PRINT "THIS IS THE DEFAULT SCREEN"
ISCREENSWAP,1,2
The text should have disappeared. You are now looking at what used to be stored as
Screen 2 (in Block 2). If the machine has just been switched on, this will probably be a
random pattern. To clear this pattern, type:

MODE 1
.... then type:

PRINT "THIS IS SCREEN 2"


ISCREENSWAP,1,2
Your original text reappears. If you now repeat the I S eRE ENS WAP , 1 , 2
command, you can see that the contents of the two screens are being exchanged. You
can swap the contents of any of the five screens with each other, but bear in mind that
only when you do a swap involving Screen 1 will the display be altered.
The other command available is I S eRE EN COP Y. This allows you to copy one screen
onto another, overwriting it with a new image.
Type:

MODE
PRINT "THIS IS A SCREEN TO COPY"
ISCREENCOPY,2,1

Foundation Course

Chapter 1 Page 85

The contents of Screen 1 are copied into Screen 2. If you reverse the parameters by
typing:

MODE 1
ISCREENCOPV,1,2
.... the contents of the currently displayed screen are overwri tten from screen 2.
So the first parameter is the screen to copy to; the second parameter is the screen to
copy from.
When copying screens, note that you will produce a disjointed display if the screens'
MOD Es are different, or if the viewing screen has been 'scrolled' since the last MOD E
command. The BANK MANAGER's screen commands are intended for use with
pictorial screens rather than text screens, as scrolling is less likely to have occurred.

Using the BANK MANAGER for String Storage


There are four more commands provided by the BANK MANAGER, which allow the
use of the additiona164K of memory as a filing system for string variables.
Most programs can be divided into two parts: firstly, the actual program instructions,
and secondly, the data that the program uses. A good example of this is a database
program such as an address book. Such a program would use an array of strings to
store the names and addresses ofthe people listed in the book.
Strings can be stored in the second 64K of memory, one after another, end to end. The
memory that the strings are stored in can be divided into compartments, which are
called records. A record can be of any fixed length between 2 and 255 characters,
whereas the length of a string in BASIC varies according to its contents. The purpose
of a record is to provide standard sized compartments, like a set of pigeon holes, in
which to store the untidy string information. Each operation to store or retrieve data
from a record is automatically followed by a step to the next record, ready for the next
operation. The record to be used for the next operation is called the 'current record'
and will be used automatically unless a different record is specified.
We call this system of memory management a 'RAMdisc'. This is because it operates
in a similar way to random access disc systems, but using RAM instead.
Read the following descriptions of the various commands so that you understand
what each command is for, ifnot how to use it, then go on to tryout the examples.
The first of the RAMdisc commands is I BAN KO PEN. This command specifies how
many characters of string information each record can contain. Its syntax is:

IBANKOPEN,n
Where n is a number specifying the amount of characters in the record. The value n
can be in the range 0 to 255, but values of 0 and 1 will have strange effects.
Chapter 1 Page 86

Foundation Course

I BAN KW RI T E stores a string into the current record. The current record is then
incremented to point at the record after the one that has just been written, ready for
the next operation. Its syntax is:

IBANKWRITE,@r%,a$
.... Of ....

IBANKWRITE,@r%,a$,n
.... where r %is an integer variable in which a code is returned giving information
about the operation. a $ is a string variable containing the characters to be written
into the record. In the first of the two examples, the record is the current record. In the
second example, the optional parameter n specifies the record to be written to.

I BAN KREA 0 examines the current record, and returns its contents in a string. The
current record is then incremented to point at the record after the one that has just
been read, ready for the next operation. Reading the contents of a record does not
change it, so the record can be read over and over again. The syntax for I BAN KREA 0
is:

IBANKREAD,@r%,a$
.... or ....

IBANKREAD,@r%,a$,n
.... where r% is an integer variable in which a code is returned giving information
about the operation. a $ is a string variable into which the contents of the record is
read. In the first of the two examples, the record is the current record. In the second
example, the optional parameter n specifies which record is to be read from.
The last command is I BAN K FIN D. This command searches through. the records
trying to find a particular string. Ifthe string is found, then the number ofthe record
in which it is found, is returned. The syntax for I BAN K FIN 0 is:

IBANKFIND,@r%,a$
.... or ....

IBANKFIND,@r%,a$,n
.... or ....

IBANKFIND,@r%,a$,n,m

Foundation Course

Chapter 1 Page 87

.... where r % is an integer variable in which either the record number (where the
string was found) or a code indicating that it was not found, is returned. a $ is the
string to search for. The optional parameter n, specifies which record to begin
searching from. If n is unspecified, then the search will start at the current record.
The second optional parameter m specifies at which record to end the search even if a
match is not yet found.lfm is omitted, the search continues through the whole 64K,
which may overrun the end of the data you have written.
Now try this out. If you have already run the BANK MANAGER program to look at
the screen swapping commands, and have not reset the computer, then the extra
commands will currently be resident in memory. If not, you will need to insert Side 1
of your system discs package, and type:

RUN "BANKMAN"
Now type:

IBANKOPEN,20
This sets the record length to 20 characters and sets the current record to be O.
Now type:

a$="FIRST ENTRY"+SPACE$(9)
.... which sets up a $ to be exactly 20 characters long.
Now type:

r%=0
.... to initialise r %.
Now type:

IBANKWRITE,@r%,a$
This will write a $ into the first record (record 0). Now type:

d$=SPACE$(20)
IBANKREAD,@r%,d$,0
PRINT d$
The first command sets up d $ to contain 20 spaces. This is enough room to contain the
contents of the record when it is read. The second command reads record number 0
and places the result in d $. As the current record would now be stepped to record 1
(by the previous I BAN KW R I T E operation) it is necessary to specify record 0, as the
record to read. Remember - if no record number is specified, then the current record is
read. Finally the result ofthe reading operation is printed out. Therefore d $ ought to
contain'F I RST ENTRY'and9spaces.

Chapter 1 Page 88

Foundation Course

Now type this:

b$="TWO"+SPACE$ (17)
c$="THREE"+SPACE$(1S)
IBANKWRITE,@r%,b$,1
IBANKWRITE,@r%,c$
This puts b $ and c $ into records 1 and 2. Again the optional parameter in the first
/ BAN KW RI T E command is used, allowing record 1 to be specified as the record in
which to place b $. The current record number is thereafter set to the following
record, so it is unnecessary to specify in which record to put c $ - it will be placed in
record 2 automatically.
Type:

PRINT r%
The result of PR IN Ting r %after the above example should be 2. This number can
either be considered as the last record operated on, or as the current record minus one.
In the above example the last record operated on was 2 and the next record will be 3.
The purpose of this 'return code' is to provide information about the operation just
carried out. A successful operation will return a positive number indicating a record
number; an unsuccessful operation will return a negative number indicating an error
code. There are two possible errors that can be returned by /B ANKW RI T E and
/ BANKREAD. These are:
-1

Indicates that the end of the file has been reached. This happens when all the
records have been used up or a record has been specified that does not exist.

-3

Indicates a bank switching failure. This should never happen.

Try some further examples:

d$=STRING$(UI,"X")
IBANKOPEN,2~

FOR n=1 to 3: IBANKWRITE,@r%,d$:NEXT


This will set up d $ to contain 20 X's. / BAN KO P EN resets the current record to be 0,
so the / BAN KW RI T E command will overwrite the contents of records 0,1, and 2 with
d$.
Now type:

a$="FIRST"
IBANKWRITE,@r%,a$,~

Foundation Course

Chapter 1 Page 89

This puts the word" FIR S T" into record 0, overwriting some of the X's. Now reset
d $ to spaces by:

d$=SPACE$(20)
Now type:

IBANKREAD,@r%,d$,0
This reads back record 0 into d $.
To recap the steps taken so far:
All three records contain X's. Into record 0 has been added the word " FIR S T " . d $
has then been filled with spaces. Finally, record 0 has been read back into d $. Now
type:

PRINT d$
The result should be "F I RS TX XXX XXXXXXX XXXX". This illustrates an
important consideration when using these commands. If the string being placed into
a record does not completely fill that record, the old characters that have not been
overwritten will remain in the record. Therefore, it is advisable to put a string of
spaces or CHR$ ( 3 2 ) 's into the record before storing fresh information in it. This
avoids reading back a string and finding that it has characters which were not
intended to still be in it. The same consideration should also be made to the string into
which the record will be read. If the string is longer than the length ofthe record, then
there will be characters left unchanged at the end of the string. That is why d $ was
cleared (filled with spaces) before reading record 0 into it.

It is possible to write a string into a record which is too short to accept the complete
string. If this happens, the excess characters will be ignored.
Likewise, it is also possible to read the contents of a long record into a short string.
and once again, excess characters (read from the record) will be ignored. In normal
string operations, BASIC would automatically extend the string to accept the
additional characters but this does not happen within an external command.
Finally the I BAN KFIN D command. This allows the records to be searched for a
particular entry. For example, if record number 24 starts with the word " FRED" ,
this could be found with the command:

IBANKFIND,@r%,"FRED"
This is extremely useful for database programs where for example, a name, or
address, is being searched for.

Chapter 1 Page 90

Foundation Course

I BAN KFIN D will start at the current record, and will work its way through the
records until it reaches the searched-for string, or the end ofthe second 64K in which
the records are stored.
It is possible to specify therecord number at which to start from, by including a record
number at the end of the command.
A further record number, after the starting record number, can be included to specify
the record at which to end the search.

I BAN KFIN D can be used to look for a string which does not lie at the start of a
record. To do this, CHR$ ( e )'s are used in the character positions before the
significant characters to be searched for. The CH R$ ( e)'s will be treated as
'wildcards' (like ?'s in CP/M filenames) which means that they count as 'any
character'. An example of this would be:

a$=STRING$(10,0)+IFRED"
IBANKFIND,@r%,a$,0
This would find the first occurrence of the word" F RED" (lying between the eleventh
and fourteenth character positions). The first ten characters could contain a phone
number or some other information that I BAN KFIN Dwould ignore.
The number of the record in which the string was found is placed in the integer
variable r %used for the return code (if the word" F RED" was found), otherwise the
return code will contain - 2 .

Further details ....


Further information about the BANK MANAGER will be found in Chapter 8, and
you should study parts 13 and 14 of Chapter 7 on the subject of using RSX's.
Finally, check that you have observed the following warnings given at the beginning
of this manual, in the section entitled 'IMPORTANT':
OPERATION NOTES 1,2,3,9

Foundation Course

Chapter 1 Page 91

Well, that concludes this 11 part Foundation course on the CPC6128. By now you
should know what most of the keys on the keyboard do, how to use some of the simpler
BASIC commands, how to format a brand new disc so that it's ready to use, and how to
perform some of the most elementary disc functions, i.e. LOA 0 ing, S AVEing,
CA Taloguing etc, together with a few AMSDOS, CP/M, and BANK MANAGER
commands.
The chapters that follow, look at the more specialised aspects of computing and
AMSTRAD BASIC. There's an in-depth guide to the disc drive section of the unit,
with sections on AMSDOS and CP/M, and you will be started off on the road to a new
language - Dr. LOGO from Digital Research.
Good luck, and happy reading!

Chapter 1 Page 92

Foundation Course

Chapter 2
Beyond FoundationslIlSlBlI
So you've read the Foundation course and you have the computer
switched on in front of you. You've already learnt how to make it
carry out an operation several times over using a FOR NEX T
loop, and how to make it test I F a condition is true THE N do
something.
Well, you're soon going to tire of seeing your name printed all over the screen, and
will want to get on with some serious computing - something useful or entertaining.
The chapter after this, lists each ofthe AMSTRAD BASIC keywords at your disposal,
together with a description ofthe 'syntax', and what the keyword is used for. Armed
with this list, the scope of what you can then make the computer do is limited only by
your imagination.

If you have never used a computer before, the idea of actually 'programming' may fill
you with apprehension. Fear not! It's a lot easier than you think, and certainly a lot
easier than the technology and jargon would have you believe. Think of BASIC not as
a new language, but as a variation of English with some words abbreviated to speed
things up. In other words, don't think of C LS as 3 letters of magic code, but instead as,
CLear Screen.
Try not to be afraid of BASIC, and you'll soon find yourself enjoying the business of
programming, as well as the fruits of your endeavours. Programming can be a very
rewarding exercise, especially when you're a beginner experimenting with the
machine and the language. Always remember that as long as you make sure that you
don't accidentally write onto your master CP/M system discs, nothing you type in can
actually harm the computer, and it's always worth trying something new.

So where do I start?
Starting is often the most difficult part of the program for the beginner. However,
what you should avoid doing, is plunging straight in and hacking away at the
keyboard without any forethought.
One ofthe first things you should establish, is what exactly you want the program to
do, and how you want the results to be presented to you (in other words, what the
screen should look like as the program runs).
Having decided this, you can then start writing a program to fulfil your
requirements, all the time thinking of how to make the program flow smoothly from
beginning to end, with the minimum of jumping around using GOT 0 here and GOT 0
there. A good program will be easy to follow when listed, and will not land you in a
hopeless muddle when you try to fault find, or 'de-bug' as they say in computer talk.

Beyond Foundations

Chapter 2 Page 1

Fortunately, BASIC is a very forgiving language and will often help you by
producing error messages on the screen when you go wrong. BASIC also allows you to
have 'afterthoughts', and new lines of program can be sandwiched in between the
existing lines with a minimum offuss.

Writing a simple program


OK let's get going. We'll write a program to keep a record of our friends' names and
telephone numbers. We'll call the program 'Telephone book'. Now let's apply the
above rules: 'What should the program do?' and 'How should the results be
presented?'
Well, the program should let you enter up to say, 100 names and 'phone numbers for
storage. When you want a number, you should be able to type in the name and get
back the number. In addition, if you're not sure how one of the names was originally
entered, you should be able to display a complete list of all the information on the
screen. Notice by the way, that we're automatically starting to consider the question
of how the results ofthe program are to be presented.
Right, let's put finger to keyboard! We'll start off with the title at the beginning:

10 REM teLephone book


You don't have to put a title in a program, but when you start to accumulate quite a
few programs, it helps to be able to know at a glance which is which.
Next, we know that we want to be able to IN PUT (put in) a string of characters
(somebody's name) into a variable; we'll call that variable NAME$. The same applies
to the telephone number, and we'll call that variable T E L$.
Remember those example programs from the Foundation course? They used the
IN PUT command for you to enter the value ofthe variable, so if we type in:

20 INPUT "enter the name";NAME$


30 INPUT "enter the teLephone number";TEL$

run
You could enter the name, for example: Joe. You could then enter the 'phone number,
for example: 0277 230222
The program has stored the information, but hasn't produced any printed results on
the screen. A section of program is therefore needed to retrieve the information, then
display it. To get the values of NAME$ and T E L $ at the moment, we'd use commands
like:

PRINT NAME$ .... and .... PRINT TEL$

Chapter 2 Page 2

Beyond Foundations

But hang on! We said that we want to be able to store up to 100 names and 100 'phone
numbers in the program. Surely we don't have to write a program with two hundred
I NPUT commands, each with a different variable name, and then two hundred
PR I NT commands to produce a list on the screen??? Don't worry, computers make
provision for this with what's known as an 'array'. An array allows you to use one
variable (such as NAME$) which can have any number of 'dimensions' (in our
program, we require 100). Then, when you want to get at the contents ofthe variable,
you use the variable's name followed by its reference number (inside brackets). This
reference number is called a 'subscript' and the expression NAME $ ( 27) for
example, is called a 'sub scripted variable'. Now if we use a number-variable as the
subscript, for example NAME $ ( x ) , we can then process the whole list of variables
from 1 to 100 by changing the value of x in a FOR NE XT loop, i.e. FOR x = 1 TO 1 00.
As the value of x increases by 1, so the subscript value changes and refers to a
different 'element' or name in the NAME$ array.
We want two arrays; one for NAM E$, and one for T E L$, each with a dimension of 100
elements. Before we can start using an array, we must declare its DIMensions at the
outset. We'll overwrite lines 20 and 30 with these statements:

20 DIM NAME$(100)
30 DIM TEL$(100)
Having established our variables, let's write some program that will firstly enable us
to enter the names and numbers into the arrays, for later retrieval. Add:

40 FOR x=1 TO 100


50 INPUT;" name";NAME$(x)
60 INPUT" phone";TEL$(x)
70 NEXT
run
This is all very well, but we may not want to enter all 100 names at once. What's
more, the way that the program presents itself on the screen is most unsatisfactory.
What's needed here is a bit of tidying up. Firstly, before taking input of each new
name and number, let's rid the screen of all the previous superfluous text, by
C Learing'the Screen each time. Add:

45 CLS
Now, how do we get the computer to know that we've finished inputting information
for the moment? Pressing [ESC] would stop the program alright, but as soon as you
typed RUN again, you'd lose all the values of your carefully entered variables!
Beyond Foundations

Chapter 2 Page 3

Here's what we can do instead. As the program takes input of a new name, we'll make
the program check that at least something has been typed in for the value of
NAME $ ( x ) , in other words, check whether the value of NAME $ ( x) is an ~empty
string' or not. I F it is, THE N we'll make the program stop taking any more input. Did
you get the clue on how we can do this? Add:

55 IF NAME$(x)='"' THEN 80
80 PRINT "no more input"
Also, so that the program tells you how to stop inputting, add:

47 PRINT "Press [RETURN] to end input"


Now let's write some program to PR I NT the information you've stored, firstly in the
form of a list. Add: .
.

90 FOR x=1 TO 100


100 PRINT NAME$(x);" ";TEL$(x)
110 NEXT
Once again the program doesn't know when to stop, before reaching the lOOth
element of the array, so let's add:

95 IF NAME$(x)="" THEN 120


120 PRINT "list finished"
Line 9 5 detects whether NAME $ ( x) is an empty string, and I F so, THE N stops
printing by bypassing lines 1 00 and 11 0.
And so to the next of our requirements. We'll now write some program that searches
for a particular name that you enter. Add:

130
140
150
160
170
180
190
run

INPUT "find";SEARCH$
FOR x=1 TO 100
IF INSTR(NAME$(x),SEARCH$)=0 THEN 180
PRINT NAME$(x);" ";TEL$(x)
END
NEXT
PRINT "name not found"

Chapter 2 Page 4

Beyond Foundations

There's a new command in line 150 - INS T R. It tells the computer to INterrogate
the first STRing expression to find the first occurence of the second string expression,
in other words, it searches NAME $ ( x) for SEA RCH$ (which is the variable you
input in line 130 containing the name that you're looking for). If INS T R doesn't find
it (or any part of it), it gives out a value ofO, which is used here to make the program
pass to line 1 80 and try again with the NE XT value of x. If the program has passed
through all values of x up to 100, it then continues to line 1 90 and tells you that it
hasn't found the name. If however it does find the name, INS T R will not produce a
value of 0, and the program will then pass from line 1 50 to 1 60 and print the name
and phone number, then END at line 1 70.
As you can see, our program is developing quite rapidly now, but there's still so much
to be done. Let's sit back for a moment and consider some drawbacks ofthis program,
starting with the way in which the program runs: First you type in the information,
then you get a list back, then you search for a specific name.

What if?
Well, what if you don't want to do it in that order? What if you want to start by
searching for a name that you stored in the program yesterday? And what if you want
to add some more names and numbers to those already there? These are all aspects of
the program that you have to think about and find solutions for; it's what
programming is all about. As previously mentioned, BASIC is kind enough to let you
sandwich afterthoughts into the program, but a good programmer will have
anticipated these problems beforehand.
Another major problem with this program is that the values of the variables in the
arrays are all stored in a part of the computer's memory that is cleared whenever you
RUN a program. You'll not want to have to type in all the information every time you
use the program, so you'll need the option of being able to save the values of all the
NAME$ and T E L $ variables before you switch off, together with the option to load in
the values of the variables whenever you run the program.

Solutions
The first ofthese problems (i.e. the order in which things are carried out) can be dealt
with by writing the program so that when it runs, you get a choice of the various
functions that it can perform. This type of program is called 'menu-driven', and in
effect displays a menu on the screen from which you can select an option. If you've
ever used one of those cash dispensers outside the bank, then you'll have already
operated a menu-driven computer program! Let's add a menu to this program:

Beyond Foundations

Chapter 2 Page 5

32 PRINT
33 PRINT
34 PRINT
35 PRINT
36 PRINT
37 INPUT
38 ON ms

" 1 enter info"


"2. Lis t info"
"3. search"
"4. save info"
"5. Load info"
"enter menu seLection";ms
GOSUB 40,90,130

85 RETURN
125 RETURN
170 RETURN
200 RETURN
As you can see, we've made the program print the menu of options, then take I NPUT
of your selection, putting it into the variable ms. The command 0 N ms GO SUB in line
38 tells the program that if ms 1 then GO to the first SUB-routine line number
(40); if ms =2 then GO to the second SUB-routine line number (9 0), and so on.

As each of the functions are now sub-routines called by the 0 N ms GO SUB command,
they must each have aRE T URN command at the end, hence we have added all those
RE T URN commands above.
Do you remember what the RE TU RN command does? It makes BASIC return from
the sub-routine to the point in the program immediately following the appropriate
GO SUB command, so in this case it returns to the instruction after line 38 (which
means that the program will continue at line 40 - the 'enter info' point!) We don't
want that to happen, so we must add:

39 GOTO 32
.... to make the program loop back and display the menu once again. Now RUN the
program again to see how far we've progressed.

OK let's have a look at the listing ofthe program for a moment. (If the program is still
running, press [ESe] twice.) Type in:

LI ST
This is what you should have so far:

10
20
30
32
33
34
35

REM teLephone book


DIM NAME$(10Q1)
DIM TEL$(100)
PRINT " 1 . enter i nf 0"
PRINT "2. Lis t info"
PRINT "3. search"
PRINT "4. save info"

Chapter 2 Page 6

Beyond Foundations

36 PRINT "5. Load info"


37 INPUT "enter menu seLection";ms
38 ON ms GOSUB 40,90,130
39 GOTO 32
40 FOR x=1 TO 100
45 CLS
47 PRINT "press [RETURN] to end input"
50 INPUT;" name";NAME$(x)
55 IF NAME$(x)="" THEN 80
60 INPUT" phone";TEL$(x)
70 NEXT
80 PRINT "no more input"
85 RETURN
90 FOR x=1 TO 100
95 IF NAME$(x)="" THEN 120
100 PRINT NAME$(x);" ";TEL$(x)
110 NEXT
120 PRINT "List finished"
125 RETURN
130 INPUT "find";SEARCH$
140 FOR x=1 TO 100
150 IF INSTR(NAME$(x),SEARCH$)=0 THEN 180
160 PRINT NAME$(x);" ";TEL$(x)
170 RETURN
180 NEXT
190 PRINT "name not found"
200 RETURN
You'll see that in certain parts of the program, we're starting to run out of lines to
insert instructions, so let's create some more space and tidy things up by
RE NU Mberingthelines. Type in:

RENUM
LI ST
You should now see:

10
20
30
40
50
60
70
80
90

REM teLephone book


DIM NAME$(100)
DIM TEL$(100)
PRINT "1. enter i nfo"
PRINT "2. List info"
PRINT "3. search"
PRINT "4. save info"
PRINT "5. Load info"
INPUT "enter menu seLection";ms

Beyond Foundations

Chapter 2 Page 7

100 ON ms GOSUB 120,210,270


110 GOTO 40
120 FOR x=1 TO 100
130 CLS
140 PRINT "press [RETURN] to end input"
150 INPUT;" name''';NAME$(x)
160 IF NAME$(x)='"' THEN 190
170 INPUT" phone";TEL$(x)
180 NEXT
190 PRINT "no more input"
200 RETURN
210 FOR x=1 TO 100
220 IF NAME$(x)='"' THEN 250
230 PRINT NAME$(x);" ";TEL$(x)
240 NEXT
250 PRINT "List finished"
260 RETURN
270 INPUT "find";SEARCH$
280 FOR x=1 TO 100
.
290 IF INSTR(NAME$(x),SEARCH$)=0 THEN 320
300 PRINT NAME$(x);" ";TEL$(x)
310 RETURN
320NEXT
330 PRINT "name not found"
340 RETURN
That's better. Now on with the program! We'll now add an instruction, so that
whenever you enter some new names and 'phone numbers, the computer will add
them to the existing entries, by placing them in the first element of the array that it
finds to be empty. This time, we'll use the new command LE Nto tell us the LENgth of
the string. We'll specify the following:
I F the LENgth of NA ME $ ( x) is greater than 0, i.e. if there's already an entry in
that element of the array, THE Njump to line 1 80 (which steps to the NE XT element
in the array).
Notice again how similar the above instruction in English is, compared to the
equivalent BASIC instruction just below. I told you that BASIC isn't really a
different language!!!

135 IF LEN(NAME$(x>0 THEN 180


Such a simple solution isn't it? Problems like these can always be sorted out with your
list of BASIC keywords and a little thought. There's nearly always at least one
command that will satisfy your programming needs, and the more you program, the
more you'll be able to find instant solutions 'off the top of your head'.
Chapter 2 Page 8

Beyond Foundations

Now to the matter of saving the contents of the variables so that they can be loaded
back in when the program is run. Part 7 of the Foundation course explained how to
save the program itself, using the S AVE command. However the program itself is
only a framework which lets the variable values be put in (at the keyboard) and taken
out (at the screen). When you S AVE the program, you are saving only that
framework, not the values of the variables.
Hence we must write a section of program that will save the values of the variables
onto disc. We do this by creating a separate 'data file'.
First we 0 PEN an 0 UTput file and specify a name for it such as "d a t a". Then we
WRIT E the values of the variables NAME $ (x) and T E L$ (x) from 1 to 100, into
the file, and finally we CL 0 SE the 0 UTput file and RE T URN to the menu. Let's add it
to the program from line 350 onwards. To save us typing in each new line number,
we'll use the command:

AUTO 350
., .. which will start AUT Omatic line numbering from the required line:

350
360
370
380
390
400
410

OPENOUT "data"
FOR, x=1 TO 100
WRITE #9,NAME$(x),TEL$(x)
NEXT
CLOSEOUT
PRINT "data saved"
RETURN

After you have typed in line 410 and pressed [RETURN], press [ESC] to stop the
AUT Omatic line numbering.
Now we need to add an extra number to the list of numbers in the 0 N ms GO SUB
command in line 1 00. This is because we have added another option for the menu to
select. Therefore E DI T line 1 00 to add this extra number:

100 ON ms GOSUB 120,210,270,350


Now, whenever you select menu option number 4, the program will save all the
information that you entered, onto disc.
Notice that in line 3 70, where the program WRI T Es the values of NAME$ ( x) and
T E L $ ( x ) onto disc, the expression # 9 is used after the word WR I T E. The # sign is a
'stream director', in other words, it tells the computer which 'stream' to send the data
to. The computer has 10 streams:
Directing data to streams 0 to 7 (# 0 to # 7) will result in it appearing on the screen
because streams # 0 to # 7 are 'screen streams' or WIN DO Ws.

Beyond Foundations

Chapter 2 Page 9

Directing data to stream # 8 sends data to the printer (if connected).


Finally, directing data to stream # 9 sends it to the disc drive, which is what we have
done in line 3 7 0.

If I may digress ....


A few words now about the AUT 0 command which we used a moment ago. If you
leave out the line number andjust type in:

AUTO
.... the computer will commence line numbering from 10, advancing by 10 each time
[RETURN] is pressed. If you have previously used lines 1 0, 20, 30 etc, each line's
contents will be displayed on the screen as you pass through it (by pressing [RETURN]

each time). When each line appears on the screen, it may be edited before pressing
[RETURN], thus providing a quick method of continuously editing regularly
successive program lines.

Back to the program ....


We've now added the instructions to save the information to disc, so the final main
section of this program will load the data back from disc, ready for use. Therefore, we
must add yet another menu option to the list of numbers in line 100. Edit line 100
again, as follows:

100 ON ms GOSUB 120,210,270,350,420


Now for the instructions to load the information. We start by 0 P E Ningthe I Nputfile
from disc called "d a t a ". Then we take IN PUT from disc (stream # 9) of all the
values of the variables NAME $ ( x) and T EL $ ( x) from 1 to 100, and lastly we
CL 0 SE the I Nput file and RE T URN to the menu. Type in:

420
430
440
450
460
470
480

OPENIN "data"
FOR x=1 TO 100
INPUT #9,NAME$(x),TEL$(x)
NEXT
CLOSEIN
PRINT "data Loaded"
RETURN

Chapter 2 Page 10

Beyond Foundations

The end of the beginning....


So now we have written a program which fulfils the requirements that we set out to
achieve when we decided 'what the program has to do'. All that remains now, is to
improve the way that 'the results are presented' on the screen.

The beginning of the end....


Let's add some instructions to tidy up the presentation of the program:

34 MODE 1
This establishes the screen mode, and clears the screen at the start of the program.
Now add:

36 WINDOW #1,13,30,10,14
Don't be put off by this seemingly complicated instruction. What we're doing here is
creating a small window on the screen to put the menu into. After the word WIN D0 W,
we first specify which stream number this window is for, remember we can use 8
screen streams from # 0 to # 7. Now bearing in mind that all items printed on the
screen use stream # 0 unless otherwise instructed, we won't use stream # 0 for our
little window, otherwise everything that the program prints will be sent to it. Instead
we'll specify another stream between # 1 and # 7, and as you can see, we've chosen
# 1. The four numbers that follow # 1, tell the computer what size the WIN D0 W
should be, and it couldn't be easier; the numbers specify the left, right, top, and
bottom edges of the window, and refer to text column and row numbers (the same as
those used in the L0 CAT E command). So in our example, after specifying that it's
stream # 1 we're using, we say that the left edge of the window starts at column 13,
the right edge ends at column 30, the top edge starts at row 1 0, and the bottom edge
ends at row 14.
Now to make all our menu options print in stream (W I ND0 W) # 1 , we'll have to edit
lines 40 to 80 as follows:

40,
50
60
70
80

PRINT
PRINT
PRINT
PRINT
PRINT

#1, " 1 .
#1,"2.
#1,"3.
#1,"4.
#1,"5.

enter info"
Lis t info"
search"
save info"
Load info"

Let's now add:

85 LOCATE 7,25
Beyond Foundations

Chapter 2 Page 11

This L 0 CAT Es where the menu I NPUT statement in line 90 will appear, so that it
looks neater.
So that the screen is always cleared when the menu is returned to, edit line 11 0 to:

110 GOTO 34
So that the screen is always cleared when one of the' menu options is selected, add:

95 CLS
Finally, we'll just add the following three lines to make the program pause before
returning to the menu:

103 LOCATE 9,25


105 PRINT "press any key for men""
107 IF INKEY$="" THEN 107
Line 1 0 3 tells the computer where to print the message given in line 1 0 5 . Line 1 0 7
I Nterrogates the KEYboard to see what $tring variable is being input (by a key
being pressed). I F it detects that an empty string is being input (because no key is
pressed), THE N the program loops back to the same instruction again and again,
until INK E Y$ finds that the string is not empty because a key has been pressed. This
is a useful way of creating a pause in a program, as BASIC will not pass to next line
until a key is pressed.
So there it is; the finished program. Or is it? Well, you could make it have the facility
to amend and delete names and 'phone numbers, to sort the list into alphabetical
order, to 'print-out' the list on a printer, or if you're really ambitious, to make the
program produce the signals to automatically dial the number after you've typed in
the name - with of course, the permission of British Telecom to connect your 'phone to
the computer! Nevertheless all these enhancements to the program are possible, and
in truth you can go on forever improving and streamlining a program, especially
when you've got a computer system as powerful as the 6128. No, we've got to draw the
line somewhere, and this is where we'll leave our 'telephone book', hopefully having
learned a thing or two about the art of writing a program from scratch. Tidy up the
program by typing in:

RENUM
.... and then save it to disc, or throw it away. You never know though, it might come in
handy for keeping a record of your friends' names and telephone numbers!

Chapter 2 Page 12

Beyond Foundations

Final listing:

10 REM teLephone book


20 DIM NAME$(100)
30 DIM TEL$(100)
40 MODE 1
50 WINDOW #1,13,30,10,14
60 PRINT #1,"1. enter info"
70 PRINT #1,"2. List info"
80 PRINT #1,"3. search"
90 PRINT #1,"4. save info"
100 PRINT #1,"5. Load info"
110 LOCATE 7,25
120 INPUT "enter menu seLection";ms
130 CLS
140 ON ms GOSUB 190,290,350,430,500
150 LOCATE 9,25
160 PRINT "press any key for menu"
170 IF INKEY$="" THEN 170
180 GOTO 40
190 FOR x=1 TO 100
200 CLS
210 IF LEN(NAME$(x))>0 THEN 260
220 PRINT "press [RETURN] to end input"
230 INPUT;" name";NAME$(x)
240 IF NAME$(x)="" THEN 270
250 INPUT" phone";TEL$(x)
260 NEXT
270 PRINT "no more input"
280 RETURN
290 FOR x=1 TO 100
300 IF NAME$(x)="" THEN 330
310 PRINT NAME$(x);" ";TEL$(x)
320 NEXT
330 PRINT "List finished"
340 RETURN
350 INPUT "find";SEARCH$
360 FOR x=1 TO 100
370 IF INSTR(NAME$(x),SEARCH$)=0 THEN 400
380 PRINT NAME$(x);" ";TEL$(x)
390 RETURN
400 NEXT
410 PRINT "name not found"
420 RETURN
430 OPENOUT "data"

Beyond Foundations

Chapter 2 Page 13

440
450
460
470
480
490
500
510
520
530
540
550
560
run

FOR x=1 TO 100


WRITE #9,NAME$(x),TEL$(x)
NEXT
CLOSEOUT
PRINT "data saved"
RETURN
OPENIN "data"
FOR x=1 TO 100
INPUT #9,NAME$(x),TEL$(x)
NEXT
CLOSEIN
PRINT "data Loaded"
RETURN

Chapter 2 Page 14

Beyond Foundations

Chapter 3 Complete list of


Amstrad CPC6128 BASIC keywords

IMPORTANT
It is vital that you understand the terminology and notation that
we use in this chapter. You will see various types ofbrackets used
when explaining how a particular command is typed in; each of
these types of brackets has a specific meaning) and you should
note them well.

Any part of a command not shown enclosed by brackets is required as given. For
example, the command END takes the form:
END

.... and you must type in the word END literally.


Where an item is enclosed in angled brackets <>for example:
<line number>

.... you are NOT required to type the brackets, nor the words within them. The
example above shows you the type of data required in the command. For example:
EDI T <line number>

., .. means that you should type in:


EDIT

HH'J

Round brackets ( ) MUST be typed in literally. For example:


COS (<numeric expression

.... requires that brackets be typed around the <numeric expression> of which the
COSine is required, e.g:
PRINT COS(4S)

Complete List of Keywords

Chapter 3 Page 1

Finally, square brackets enclose optional items in a command or function. For


example:
RUN [,line number>]

.... means that you do not have to follow the keyword RUN with a parameter, but that
you can expand the command by adding the optional parameter <line number>.
Hence, the command could be typed in as:
RUN .... or .... RUN

100

Special Characters
&or &H
&X

Prefix for hexadecimal constant


Prefix for binary constant
Prefix for stream director

Data types
Strings may be from 0 to 255 characters long. A <string expression> is an expression
which yields a value oftype string. Strings may be appended to one another using the
+ operator, as long as the resulting string is no greater than 255 characters long.
Numeric data can be either integer or relll. Integer data is held in the range -32768
to 32767 and real data is held to a little over nine digits of precision in the range
1. 7E +38 with the smallest value above zero approximately 2.9E-39.
A <numeric expression> is any expression that results in a numeric value. It may
simply be numbers, or it may be a numeric variable, or it may be numbers operated on
by v~riables;just about anything that is not a <string expression>.
A <~tream expression> refers to a <numeric expression> which identifies a screen
window, printer, or disc, where the text is required to 'stream'.
A <list of:<item> describes a parameter which comprises a list of items separated by
commas. The list may contain one, or any number of items, limited by line length.
Type markers are:

%
I

Integer
Real (The default)
String

Chapter 3 Page 2

Complete List of Keywords

Please note that AMSTRAD CPC6128 BASIC keywords are listed here using the
form:

KEYWORD
Syntax
Example
Description
Associated keywords
Keywords are either:
COMMANDS : operations that are executed directly.
FUNCTIONS : operations that are brought into action as arguments
in an expression.
OPERATORS : acting upon mathematical arguments.
BASIC converts all keywords entered in lower case letters to UPPER CASE when a
program is LIS Ted. The examples shown in this chapter use UPPER CASE, since
this is how the program will appear when LIS Ted. Hence you should enter using
lower case, as you will be able to spot typing errors more readily since the mis-typed
keyword will still be displayed in lower case when LIS Ted.
For a comprehensive guide to AMSTRAD CPC6128 BASIC, see the Concise BASIC
specification SOFT 967.

Keywords ....
ABS
AB S ( <numeric expression> )

PRINT ABS(-67.98)
67.98
FUNCTION: Returns the ABSolute value of the given expression. This means that
negative nu~bers are returned as positive.
Associated keywords: S GN

Complete List of Keywords

Chapter 3 Page 3

AFTER
AFT E R <timer delay>[, <timer number>] GO SUB <line number>

10 AFTER 250 GOSUB 60:CLS


20 PRINT "Guess a Letter in 5 seconds"
30 a$=INKEY$:IF fLag=1 THEN END
40 IF a$<>CHR$(INT(RND*26+97 THEN 30
50 PRINT a$;" is correct. You win"
55 SOUND 1,478:S0UND 1,358:END
60 PRINT "too Late. I win"
70 SOUND 1,2000:fLag=1:RETURN
run
COMMAND: Calls a BASIC sub-routine after a given period of time has elapsed. The
<timer delay> parameter specifies the period of time in units of 0.02 (fiftieths) second.
The <timer number> (in the range 0 to 3) specifies which of the four delay timers are to
be used. Timer 3 has the highest priority; timer 0 (the default timer) has the lowest.
Each ofthe timers may have a sub-routine associated with it
Further information concerning interrupts will be found in part 2 of the chapter
entitled 'At your leisure .... >.
Associatedkeywords: EVERY, REMAIN, RETURN

AND
<argument> AND <argument>
IF "aLan"<"bob" AND "dog">"cat" THEN PRINT "correct" ELSE PRINT "wrong"
correct
I F "bob"<"aLan" AND "cat">"dog" THEN PRINT "correct" ELSE PRINT "wrong"
wrong
IF "aLan"<"bob" AND "cat">"dog" THEN PRINT "correct" ELSE PRINT "wrong"
wrong
PRINT1AND1
1

PRINT0AND0

o
o

PRINT1AND0

OPERATOR: Performs bit-wise boolean operation on integers. Result is


both argument bits are 1 .

0 unless

Further information concerning logic will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: 0 R, NOT, X0 R
Chapter 3 Page 4

Complete List of Keywords

ASC
AS C ( <string expression

PRINT ASC(lx")
120
FUNCTION: Returns the numeric value of the first character in the <string
expression> .
Associated keywords: CH R$

ATN
AT N ( <numeric expression> )

PRINT ATN(1)
0.785398163
FUNCTION: Calculates the Arc- TaN gent of the <numeric expression>.
Note that DEG and RA D can be used to force the result of the above calculation to
degrees or radians respectively.
Associated keywords: COS, DE G, RA D, SIN, TAN

AUTO
AUT 0 [<line number>][, <increment>]

AUTO 100,50
COMMAND: Generates line numbers AUT Omatically. The optional <line number>
parameter sets the first line to be generated in case you wish to generate lines from a
particular point in the program. If the parameter is omitted, line numbers will be
generated from line 1121 onwards.
The optional <increment> sets the number of lines to leave before generating the
following line number. If the parameter is omitted, the line numbers will increase by
1121 each time.
If a line number is generated which is already in use, then the contents of the line will
be displayed on the screen and may be edited if required. The displayed' line will be
replaced in the memory when [RETURN] is pressed.
To stop automatic line numbering, press [ESC].
Associated keywords: none

Complete List of Keywords

Chapter 3 Page 5

BIN$
BIN $ ( <unsigned integer expression> [, <integer expression>] )

PRINT BIN$(64,8)
01000000
FUNCTION: Produces a string of B I Nary digits representing the value of the
<unsigned integer expression>, using the number of binary digits instructed by the
second <integer expression> (in the range 0 to 16). If the number of digits instructed is
too great, the resulting expression will be filled with leading zeros; if the number of
digits instructed is too small, the resulting expression will NOT be shortened to the
instructed number of digits, but will be produced in as many digits as are required.
The <unsigned integer expression> to be converted into binary form must yield a value
in the range -32768 to 65535.
Associated keywords: DE C$, HEX $, S T R$

BORDER
B0 RDE R <colour> [, <colour>]

10 REM 729 border combinations!


20 SPEED INK 5,5
30 FOR a=0 TO 26
40 FOR b=0 TO 26
50 BORDER a,b:CLS:LOCATE 14,13
60 PRINT "border";a;",";b
70 FOR t=1 TO 500
80 NEXT t,b,a
run
COMMAND: Changes the colour of the border on the screen. If two colours are
specified, the border alternates between the two at a rate determined in the S P E E D.
INK command. The range of border colours is 0 to 26.
Associated keywords: S P E E DIN K

BREAK
(See ON BREAK CONT, ON BREAK GOSUB, ON BREAK STOP)

Chapter 3 Page 6

Complete List of Keywords

CALL.
CALL <address expression> [, <list of: <parameter>]

CALL 0
COMMAND: Allows an externally developed sub-routine to be called from BASIC.
The above call completely resets the computer.
Not a command to be used by the unwary.
Associated keywords: UNI

CAT
CAT

CAT
COMMAND: CAT alogs the disc. Displays in alpha-numeric order, the full names of
all files found, together with each file's length (to the nearest higher Kbyte). The free
space left on the disc is also displayed, together with Drive and User identification.
Cataloguing does not affect the program currently in memory.
Associated keywords: LOA D, RUN, S AVE

CHAIN
CH A I N <filename> [ , <line number expression>]

CHAIN "testprog.bas",350
COMMAND: Loads a program from disc into the memory, replacing the existing
program. The new program then commences running, either from the beginning, or
from a line specified in the optional <line number expression>.
Protected files, (S AVEd by , p ) can be loaded and run by CH A I Ning.
Associated keywords: CH AI N MER GE, LOA D, MER GE

Complete List of Keywords

Chapter 3 Page 7

CHAIN MERGE
CH A I N MER G E <illename> [, <line number expression> ]
[, DEL E T E <line number range> ]

CHAIN

ME~GE

"newrun.bas",750,DELETE 400-680

COMMAND: Loads a program from disc, merges it into the current program in the
memory, then commences running the resultant program, either from the beginning,
or from a line specified in the optional <line number expression>. Ifbefore a program is
CH A I N MER GEd, it is required to delete part ofthe original program, the DEL ET E
<line number range> option may be used.
Note that line numbers in the old program which exist in the new program to be
CH A I N MER GEd, will be over-written by the new program lines.
Pr Jtected files, (S AVEd by , p ) can NOT be loaded and run by CH AI N MER GEing.
Associated keywords: CH AIN, DEL ET E, LOA D, MER GE

CHR$
CHR$ ( <integer expression> )

10 FOR x=32 TO 255


20 PRINT x;CHR$(x),
30 NEXT
run
FUNCTION: Converts an <integer expression> in the range 0 to 255, to its CHaRacter
$ tring equivalent, using the AMSTRAD character set shown in part 3 of the chapter
entitled 'For your reference .... '.
Note that 0 to 31 are control characters; hence the above example prints CH R$ (x)
in the range 32 to 255.
Associated keywords: AS C

CINT
C I NT ( <numeric expression> )

10 n=1.9999
20 PRINT CINT(n)
run
2
FUNCTION: Returns the value of the <numeric expression>, Converting it to a
rounded IN Tegerin the range -32768 to32767.
Associated keywords: C REA L, F I X, I NT, R0 UND, UNT

Chapter 3 Page 8

Complete List of Keywords

CLEAR
CLEAR
CLEAR

COMMAND: Clears all variables to zero or null. All open files are abandoned, all
arrays and user functions are erased, and BASIC is set to radians mode of calculation.
Associated keywords: none

CLEAR INPUT
CLEARINPUT
10
20
30
40
50

CLS
PRINT "Type ; n Letters now!"
FOR t=1 TO 3000
NEXT
CLEAR INPUT

run
COMMAND: Discards all previously typed input from the keyboard, still in the
keyboard buffer.
To see the effect of this command, RUN the above program and type in letters when
asked to do so. Then delete line 50 of the program and RUN again, noting the
difference.
Associated keywords: INK E Y, IN KE Y$, JOY

CLG
C LG [<ink>]
LOCATE 1,20
CLG 3

COMMAND: CLears the Graphics screen to the graphics paper colour. If the <ink> is
specified, the graphics paper is set to that value.
Associated keywords: C LS, GRAP HI CSPA PER, INK, 0 RIG I N

Complete List of Keywords

Chapter 3 Page 9

CLOSEIN
CLOSEIN

CLOSEIN
COMMAND: CLOS Esany I Nputfile from disc. (See 0 PEN IN).
Associated keywords: EO F, 0 PEN I N

CLOSEOUT
CLOSEOUT

CLOSEOUT
COMMAND: CLO S Esany OUTputfiletodisc. (See 0 P ENOUT).
Associated keywords: 0 PEN 0 UT

CLS
CL S[# <stream expression>]

10 PAPER#2,3
20 CLS#2
run
COMMAND: CLears the given Screen stream (window) to its paper ink. If no <stream
expression> is given, screen stream # ~ i~ cleared.
Associatedkeywords: CLG, INK, PA PER, WIN 0 OW

CONT
CONT

CONT
COMMAND: CON Tinues program executIOn, either after the [ESCI key has been
pressed twice, or after a S TOP command has been encountered in the program.
CON T will only continue to execute the program if it has not been altered, and if it is
not a protected program.
Direct commands may be entered before CON Tinuing.
Associated keywords: S TOP
Chapter 3 Page 10

Complete List of Keywords

COPYCHR$
COP ye HR$ ( # <stream expression> )

10 CLS
20 PRINT "top corner"
30 LOCATE 1,1
40 a$=COPYCHR$(#0)
50 LOCATE 1,20
60 PRINT a$
run
FUNCTION: COPies a CHaRacter from the current position in the stream (which
MUST be specified). The above program copies a character from location 1,1 (top left),
and reproduces it at location 1,20.
Ifthe character read is not recognised, a null string is returned.
Associated keywords: L0 CAT E

cos
COS ( <numeric expression> )

DEG
PRINT COS(45)
0.707106781
FUNCTION: Calculates the COS ine of the <numeric expression>.
Note that DEG and RA D can be used to force the result of the above calculation to
degrees or radians respectively.
Associated keywords: AT N, DE G, RA D, SIN

CREAL
eRE A L ( <numeric expression> )

10 a=PI
20 PRINT CINT(a)
30 PRINT CREAL(a)
run
3

3.14159265
FUNCTION: Returns the value of the <numeric expression>, Converting it to REA L.
Associated keywords: C I NT

Complete List of Keywords

Chapter 3 Page 11

CURSOR
CUR S0 R [<system switch>][ , <user switch>]

10 CURSOR 1
20 PRINT "question?";
30 a$=INKEY$:IF a$="" THEN 30
40 PRINT a$
50 CURSOR 0
run
COMMAND: Sets the system switch or the user switch to the cursor, on or off. The
<system switch> and <user switch> parameters must be either 0 (oft) or 1 (on). In the
above INK E Y$ command, where the cursor is not normally visible, the cursor has
been turned on by the <system switch> setting of 1 (in line 10).
The cursor is displayed whenever both the <system switch> and the <user switch> are
on (1). The <system switch> is automatically turned on for the command IN PUT, but
is turned off for I NKEY$.

It is recommended that the cursor be turned offwhen printing text to the screen.
Either switch parameter may be omitted, but not both. If a switch parameter is
omitted, that particular switch state is not changed.
Associated keywords: L0 CAT E

DATA
DAT A <list of: <constant>

10 FOR x=1 TO 4
20 READ name$,surname$
30 PRINT name$;" ";surname$
40 NEXT
50 DATA Hi Lda,Ogden,Bet,Lynch
60 DATA Rita,Fairclough,Mavis,Ri Ley
run
COMMAND: Declares constant data for use within a program. Data may be read into
the variable by the REA D command, after which the 'pointer' moves on to the next
item in the DA T A list. The RES TOR E command may be used to move the pointer to a
specified DAT A position.
Further information concerning data will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: REA D, RES TOR E
Chapter 3 Page 12

Complete List of Keywords

DEC$
oE C$ ( <numeric expression> , <format template> )
PRINT DEC$(10t7,"#########,.##")
10,000,000.00
FUNCTION: Returns aD E Cimal string representation of the <numeric expression>,
using the specified <format template> to control the print format of the resulting
string.
The format template may contain ONLY the characters:

The use of these 'format field specifiers' is described under the keyword PR I NT
USING.
Associatedkeywords: BIN $, HE X$, PR I NT US I NG, S T R$

DEFFN
DE F F N<function name>[ ( <formal parameters] =<expression>

10 t=TIMEl300
20 DEF FNcLock=INT(TIME/300-t)
30 EVERY 100 GOSUB 50
40 GO TO 40
50 PRINT "program was run";
60 PRINT FNcLock;"seconds ago"
70 RETURN
run
COMMAND: 0 E Fines a FuNction. BASIC allows the program to define and use
simple value returning functions. 0 E F F N is the definition part of this mechanism
and creates a program-specific function which works within the program in the same
way that for example COS operates as a built-in function of BASIC.
(Note in the above example how the value ofthe function F Ne L0 c k is continually
updated even if the program is paused by pressing [ESC] once, or stopped by pressing
[ESC] twice, then CON T inuing.)
Associated keywords: none

Complete List of Keywords

Chapter 3 Page 13

DEFINT
DE FIN T <list of: <letter range>

10 DEFINT n
20 number=123.456
30 PRINT number
run
123
COMMAND: Sets the DE Fault for a variable to type IN Teger. When a variable is
encountered without an explicit type marker (! % $), the default type is assumed.
This command sets the default for variables with the specified first letter(s) to type
INTeger. There may be a list of first letters such as:

DEFINT a,b,c
.... or there may be an inclusive range of first letters such as:

DEFINT a-z
Associated keywords: DE F REA L, DE F ST R

DEFREAL
DE F REA L <list of: <letter range>

DEFREAL x,a-f
COMMAND: Sets the DE Fault for a variable to type REA L. When a variable is
encountered without an explicit type marker (! % $), the default type is assumed.
This command sets the default for variables with the specified first letter(s) to type
REA L. There may be a list of first letters such as:

DEFREAL a,b,c
.... or there may be an inclusiverange of first letters such as:

DEFREAL a-z
Associated keywords: DE FIN T, DE F ST R

Chapter 3 Page 14

Complete List of Keywords

DEFSTR
DE F S T R <list of: <letter range>

H?J DEFSTR n
20 name="Amstrad"
30 PRINT name
run
Amstrad
COMMAND: Sets the DE Fault for a variable to type STRing. When a variable is
encountered without an explicit type marker (! % $), the default type is assumed.
This command sets the default for variables with the specified first letter(s) to type
STRing. There may be a list of first letters such as:

DEFSTR a,b,c
.... or there may be an inclusive range of first letters such as:

DEFSTR a-z
Associated keywords: DEFl NT, DE F REA L

DEG
DEG

DEG
COMMAND: Sets DEGrees mode of calculation. The default condition for the
functions SIN, COS, TAN, and AT N is radians. DE G resets BASIC to degrees until
instructed otherwise by the commands RA D, and NEW, C LEA R, LOA D, RUN etc.
Associated keywords: AT N, COS, RA D, SIN, TAN

Complete List of Keywords

Chapter 3 Page 15

DELETE
DEL ET E <line number range>

DELETE 100-200
COMMAND: Deletes part of the current program as defined in the <line number
range> expression.
The first or last number in the <line number range> may be omitted to indicate
' .... from the beginning of the program', or ' .... to the end of the program', Le:

DELETE -200
.... or ....

DELETE 50.... or ....

DELETE
.... which deletes the whole program.
Associated keywords: CH A I N MER GE. RE NUM

DERR
DERR

LOAD "xyz.abc"

XYZ .ASC not found


Ready
PRINT DERR
146
FUNCTION: Reports the last error code returned by the disc filing system. The value
of DERR may be used to ascertain the particular Disc ERRor that occurred. See the
listing of error messages given in the chapter entitled 'For your reference .... '.
Associated keywords: ER L, ERR, ERR 0 R, 0 N ERR 0 R GOT 0, RES UME

Chapter 3 Page 16

Complete List of Keywords

DI
01

10 CLS:TAG:EVERY 10 GOSUB 90
20 X1=RND*320:X2=RND*320
30 Y=200+RND*200:C$=CHR$(RND*255)
40 FOR X=320-X1 TO 320+X2 STEP 4
50 DI
60 MOVE 320,0,1:MOVE X-2,Y:MOVE X,Y
70 PRINT" ";C$;:FRAME
80 EI:NEXT:GOTO 20
90 MOVE 320,0:DRAW X+8,Y-16,0:RETURN
run

COMMAND: Disables Interrupts (other than the [ESe] interrupt) until re-enabled
explicitly by E I or implicitly by the RE T URN at the end of an interrupt sub-routine.
Note that entering an interrupt sub-routine automatically disables interrupts of an
equal or lower priority.
'
The command is used to make the program literally execute without interruption
- for example when two routines within a program are competing for use of resources.
In the example above, the main program and the interrupt sub-routine are competing
for use of the graphics display.
Fur.ther information concerning interrupts will be found in part 2 of the chapter
entitled 'At your leisure .... '.
Associated keywords: AFT ER, E I, EVE RY, REM A I N

Complete List of Keywords

Chapter 3 Page 17

DIM
DI M<list of: <sub scripted variable>

10 CLS
20 DIM friend$(5),phone$(5)
30 FOR n=1 TO 5
40 PRINT "Friend number";n
50 INPUT "Enter name";friend$(n)
60 INPUT "Enter teL.number";phone$(n)
70 PRINT
80 NEXT
90 FOR n=1 TO J
100 PRINT n;friend$(n),phone$(n)
110 NEXT
run
COMMANDi DIMensions an array. DI M allocates space for arrays and specifies
maximum subscript values. BASIC must be advised of the space to be reserved for an
array, or it will default to 10.
An array is identified by a <subscripted variable> where one variable name is used
with a range of subscript numbers, S0 that each 'element' of the array has its own
individual value. Control of the array can then be achieved by for example FOR
NE X T loops, which can step through the array, processing each element in turn.
Note that the lowest value of the subscript is zero (Le. the first available element in
the array).
Arrays can be multi-dimensional, and each element of such an array is referenced by
its position within the framework of the array. For example, in an array dimensioned
by:

DIM position$(20,20,20)
.... an element of the array would be referenced for example:

position$(4,5,6)
Associated keywords: ERA S E

Chapter 3 Page 18

Complete List of Keywords

DRAW
DRAW <x co-ordinate> , <y co-ordinate> [ , [<ink>][, <ink mode> ]]

10 MODE 0:BORDER 0:PAPER 0:INK 0,0


20 x=RND*640:y=RND*400:z=RND*15
30 DRAW x,y,z
40 GO TO 20
run
COMMAND: Draws a line on the graphics screen, from the current graphics cursor
position to the absolute position specified in the x,y co-ordinates. The <ink> in which to
draw the line may be specified (in the range 0 to 15).
The optional <ink mode> determines how the ink being written interacts with that
already on the graphics screen. The 4 <ink mode>s are:
0: Normal
1: XOR (eXclusive OR)
2:AND
3:0R
Associated keywords: DRAW R, GRAP HIe S PEN, MASK

DRAWR
DRAW R <x offset> , <y offset> [ , [<ink>][, <ink mode>]]

10 CLS:PRINT "coming upstairs?"


20 MOVE 0,350:FOR n=1 TO 8
30 DRAWR 50,0
40 DRAWR 0,-50
50 NEXT:MOVE 348,0:FILL 3
60 GOTO 60
run
COMMAND: Draws a line on the graphics screen, from the current graphics cursor
position to the relative position specified in the <x and y offset>s. The <ink> in which to
draw the line may be specified (in the range 0 to 15).

Complete List of Keywords

Chapter 3 Page 19

The optional <ink mode> determines how the ink being written interacts with that
already on the graphics screen. The 4 <inkmode>s are:

0: Normal
1: XOR (eXclusive OR)
2:AND
3:0R
Associated keywords: DRAW, GRAP HI CS PEN, MASK

EDIT
E DI T ,line number>
EDIT 20

COMMAND: Displays the program line specified in the ,line number> on the screen
together with the cursor, ready for editing.
Associated keywords: AUT 0, L I S T

El
El
El
COMMAND: Enables I nterrupts which have been disabled by the DI command.

If interrupts are disabled in an interrupt sub-routine, they are automatically


re-enabled when BASIC encounters the RE T URN command at the end of the
sub-routine.
Further information concerning interrupts will be found in part 2 of the chapter
entitled 'At yourleisure .... '.
Associated keywords: AFT E R, Dl, EVE RY, REM AI N

ELSE
(See I F)

Chapter 3 Page 20

Complete List of Keywords

END
END

END
COMMAND: Ends the execution of a program, and returns to direct mode. Any
number of END commands may appear in a program, and one is automatically
assumed after the final line of a program.
Associated keywords: S TOP

ENT
ENT <envelope number>[, <envelope section> ][, <envelope section>]
[, <envelope section> ][, <envelope section>]
[, <envelope section>]

10 ENT 1,10,-50,10,10,50,10
20 SOUND 1,500,200,10,,1
run
COMMAND: Sets the Tone ENvelope specified in the <envelope number> (in the
range 1 to 15), which is used in conjunction with the SOU ND command. If the
<envelope number> is negative (in the range -1 to -15), the envelope repeats until the
end of the duration ofthe SOU NDcommand.
Each of the <envelope section>s may contain either 2 or 3 parameters:
If3 parameters are used, these are:
<number of steps> , <step size> , <pause time>

Parameter 1: <number of steps>


This parameter specifies how many different steps oftone (pitch) you want the sound
to pass through during the envelope section. For example, in a section of a note which
lasts 10 seconds, you may wish to have 10 tone steps of 1 second each. In such a case,
the <number of steps >parameter used should be 10.
The available range of <number of steps> is Oto 239.

Complete List of Keywords

Chapter 3 Page 21

Parameter 2: <step size>


This parameter must be in the range -128 to +127. Negative steps make the pitch of
the note higher; positive steps make the pitch of the note lower. The shortest tone
period is O. The full range of tone periods is shown in the chapter entitled 'For your
reference .... '.

Parameter 3: <pause time>


This parameter specifies the time between steps in 0.01 second (hundredths of a
second) units. The range of <pause time> numbers is 0 to 255 (where 0 is treated as
256), which means that the longest time between steps is 2.56 seconds.
If2 parameters are used, these are:
<tone period> , <pause time>

Parameter 1: <tone period>


This parameter gives a new absolute setting for the tone period. (See Parameter 2 of
the SOU N Dcommand.)

Parameter 2: <pause time>


This parameter specifies the pausing time in 0.01 second (hundredths of a second)
units. The range of <pause time> numbers is 0 to 255 (where 0 is treated as 256), or
2.56 seconds.

General
Note that the total length of all the ,pause time>s should not be greater than the
<duration> parameter in the SOU N Dcommand, otherwise the sound will finish before
all the tone steps have been passed through. (In such a case, the remaining contents of
the tone envelope are discarded.)
Likewise, if the <duration, parameter in the SOU ND command is longer than the
total length of all the ,pause time,s, the sound will continue after all ofthe tone steps
have been passed through, and will remain constant at the final tone pitch.
Up to 5 different <envelope section>s, (each made up of the above 2 or 3 parameters)
may be used in an ENT command.
The first step of a tone envelope is executed immediately.
Each time a given tone envelope is set, its previous value is lost.
Specifying an <envelope number, with no ,envelope section>s cancels any previous
setting.
Further information concerning sound will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: EN V, SOU N D
Chapter 3 Page 22

Complete List of Keywords

ENV
EN V <envelope number> [ , <envelope section>][, <envelope section>]
[, <envelope section>][, <envelope section>]
[, <envelope section>]

10 ENV 1,15,-1,10,15,1,10
20 SOUND 1,200,300,15,1
run
COMMAND: Sets the Volume ENvelope specified in the <envelope number> (in the
range 1 to 15), which is used in conjunction with the SOU NDcommand.
Each ofthe <envelope section>s may contain either 2 or 3 parameters:
If3 parameters are used, these are:
<number of steps> , <step size> , <pause time>

Parameter 1: <number of steps>


This parameter specifies how many different steps of volume you want the sound to
pass through during the envelope section. For example, in a section of a note which
lasts 10 seconds, you may wish to have 10 volume steps of 1 second each. In such a
case, the <number of steps> parameter used should be 10.
The available range of <number of steps> is 0 to 127.

Parameter 2: <step size>


Each step can vary in size from a volume level of 0 to 15 with respect to the previous
step. The 16 different volume levels are the same as those you will hear in the SOU ND
command. However, the <step size> parameter used can be between -128 and +127;
the volume level re-cycling to 0 after each 15.

Parameter 3: <pause time>


This parameter specifies the time between steps in 0.01 second (hundredths of a
second) units. The range of <pause time> numbers is 0 to 255 (where 0 is treated as
256), which means that the longest time between steps is 2.56 seconds.

Complete List of Keywords

Chapter 3 Page 23

If2 parameters are used, these are:


<hardware envelope> , <envelope period>

Parameter 1: <hardware envelope>


This parameter specifies the value to send to the envelope shape register of the
sound chip.

Parameter 2: <envelope period>


This parameter specifies the value to send to the envelope period registers of the
sound chip.
Knowledge of hardware is assumed when using hardware envelopes. Unless you
have such knowledge, it is suggested that you use a software envelope incorporating
a suitable <pause time> parameter.

General
Note that the total length of all the <pause time>s should not be greater than the
<duration> parameter in the SOU NDcommand, otherwise the sound will finish before
all the volume steps have been passed through. (In such a case, the remaining
contents of the volume envelope are discarded.)
Likewise, if the <duration> parameter in the SOU ND command is longer than the
total length of all the <pause time>s, the sound will continue after all of the volume
steps have been passed through, and will remain constant at the final level.
Up to 5 different <envelope section>s, (each made up of the above 2 or 3 parameters)
may be used in an EN V command.
The first step of a volume envelope is executed immediately.
Each time a given volume envelope is set, its previous value is lost.
Specifying an <envelope number> with no <envelope section>s cancels any previous
setting.
Further information concerning sound will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: ENT, SOU N D

Chapter 3 Page 24

Complete List of Keywords

EOF
EOF

10 OPENIN "keys.wp"
20 WHILE NOT EOF
30 LINE INPUT #9,a$
40 PRINT a$
50 WEND
60 CLOSEIN
run
FUNCTION: Tests to see if the disc input is at End Of File. Returns -1 (true) ifno file
is open or file is at the end, otherwise returns 0 (false).
Associated keywords: 0 PEN IN, C LOS E I N

ERASE
ERA S E <list of: <variable name>

DIM a(100),b$(100)
ERASE a,b$
COMMAND: Erases the contents of an array no longer required, reclaiming the
memory for other use.
Associated keywords: DI M

ERL
ERL

10 ON ERROR GOTO 30
20 GO TO 1000
30 PRINT "error is in line";ERL
40 END
run
FUNCTION: Reports the Line number of the last ERror encountered. In the above
example you will see that the error is in line 213, and has been reported so by the ER L
function.
Associatedkeywords: DERR, ERR, ERROR, ON ERROR GOTO, RESUME

Complete List of Keywords

Chapter 3 Page 25

ERR
ERR

GOTO 500
Line does not exist
Ready
PRINT ERR
8
FUNCTION: Reports the number of the last ERRor encountered. See the listing of
error messages given in the chapter entitled 'For your reference .... '. In the above
example you will see that ER Rornumber 8 is a 'L in e doe s no t ex i s t' error.
Associatedkeywords: DERR, ERL, ERROR, ON ERROR GOTO, RESUME

ERROR
ERR 0 R <integer expression>

10 IF INKEY$="" THEN 10 ELSE ERROR 17


run
COMMAND: Invokes the error specified in the <integer expression>. A listing of error
messages 1 to 32 is given in the chapter entitled 'For your reference .... '. BASIC will
treat the ERR 0 R .as if it had been detected as genuine, and will jump to any error
handling routine, as well as reporting the appropriate values of ERR and ER L.
ERR 0 R accompanied by an <integer expression> in the range 33 to 255 can be used to
create customised error messages, as shown in the following example:

10 ON ERROR GOTO 100


20 INPUT "enter one character";a$
30 IF LEN(a$)<>1 THEN ERROR 100
40 GOTO 20
100 IF ERR=100 THEN 110 ELSE 130
110 PRINT CHR$(7)
120 PRINT "I said ONE character!"
130 RESUME 20
run
Associatedkeywords: ERL, ERR, ON ERROR GOTO, RESUME

Chapter 3 Page 26

Complete List of Keywords

EVERY
EVE RY <time period>[, <timer number>] GO SUB <line number>

10 EVERY 50,1 GOSUB 30


20 GO TO 20
30 SOUND 1,20
40 RETURN
run
COMMAND: Calls a BASIC sub-routine at regular intervals. The <time period>
specifies the interval in units of 0.02 (fiftieths) second.
The <timer number> (in the range 0 to 3) specifies which ofthe four delay timers are to
be used. Timer 3 has the highest priority; timer 0 (the default timer) has the lowest.
Each ofthe timers may have a sub-routine associated with it.
Further information concerning interrupts will be found in part 2 of the chapter
entitled 'At your leisure .... '.
Associated keywords: AFT ER, REM AI N

EXP
EX P ( <numeric expression> )
PRINT EXP(6.876)
968.743625
FUNCTION: Calculates 'E' to the power given in the <numeric expression>, where 'E'
is approximately 2.7182818 - the number whose natural logarithm is 1.
Associated keywords: LOG

FILL
FILL <ink>

10 MODE 0
20 FOR n=1 TO 500
3111 PR1NT "0";
4111 NEXT
5111 pencolour=2+RND*13
60 FILL pencolour
7111 GOTO 50
run
COMMAND: Fills an arbitrary area of the graphics screen. The edges of the area are
bounded by lines drawn either in the current graphics pen ink or in the ink being used
to fill (in the range 0 to 15).
The fill starts from the current graphics cursor position, If this position lies on an
edge, nothing will be filled.
Associated keywords: GRAP HIe S PEN
Complete List of Keywords

Chapter 3 Page 27

FIX
F I X( <numeric expression> )

PRINT FIX(9.99999)
9

FUNCTION: Removes the part of <numeric expression> to the right of the decimal
point, rounding towards zero.
Associated keywords: CI NT, I NT, R0 UND

FN
(See DE F FN)

FOR
FOR <simple variable> = <start> TO <end> [S T E P .<size>]

10 FOR n=2 TO 8 STEP 2


20 PRINT n;
30 NEXT n
40 PRINT ",who do we appreciate?"
run
COMMAND: Carries out the body of program between the FOR and NEX T
commands, a given number of times, stepping the control variable between a <start>
and <end> value. Ifthe S T E P <size> is not specified, 1 is assumed.
The S T E P <size> may be specified as a negative <numeric expression> in which case
the value of the <start> parameter must be greater than that of the <end> parameter,
otherwise the control variable will not be stepped.
FOR NEX T loops may be 'nested', i.e. one may be carried out within another, within
another, and so on.

Assigning the variable's name to the NE XT command is optional as BASIC will


automatically find which FOR command is to be associated with an 'anonymous'
NEXT.
Associated keywords: NE XT , S T E P, TO

Chapter 3 Page 28

Complete List of Keywords

FRAME
FRAME

10 MODE 0
20 PRINT "FRAME off"
30 TAG
40 MOVE 0,200
50 FOR x=0 TO 500 STEP 4
60 IF f=1 THEN FRAME
70 MOVE x,200
80 PRINT" ";CHR$(143);
90 NEXT
100 IF f = 1 THEN RUN
110 CLS
120 TAGOFF
130 PRINT "FRAME on"
140 f=1
150 GOTO 30
run
COMMAND: Synchronises the writing of graphics on the screen, with the frame
flyback of the display. The overall effect of this is that character or graphics
movement on the screen will appear to be smoother, without 'flickering' or 'tearing'.
Associated keywords: TAG, TAG 0 F F

FRE
F R E ( <numeric expression> )
F RE ( <string expression> )

PRINT FRE(0)
PRINT FRE("")
FUNCTION: Establishes how much FREe memory remains unused by BASIC. The
form F RE ( " ") forces a 'garbage collection' before returning a value for available
space.
NOTE - BASIC uses only the first 64K of the memory.
Associated keywords: HI MEM, MEM 0 RY

Complete List of Keywords

Chapter 3 Page 29

GOSUB
GO SUB ,line number>

GOSUB 210
COMMAND: GOes to a BASIC SUB-routine by branching to the specified ,line
number>. The end of the sub-routine itself is marked by the command RE T URN,
whereupon the program continues execution from the instruction after the invoked
GO SUB command.
Associated keywords: RE T URN

GOTO
GOT 0 ,line number>

GOlO 90
COMMAND: GOes TO a specified line number.
Associated keywords: none

GRAPHICS PAPER
GRAPH I CS PAPE R <ink>
10 MODE 0
20 MASK 15
30 GRAPHICS PAPER 3
40 DRAW 640,0
run

COMMAND: Sets the <ink> of the graphics paper, i.e. the area behind graphics drawn
on the screen. When drawing continuous lines, the graphics paper will not be seen. In
the above example, the MASK command enables a broken line to be drawn, and the
graphics paper to be seen.
The graphics paper's ink (in the range 0 to 15) is used for the 'paper' area of characters
written when TAG is in operation, and as the default when clearing the graphics
window, using C LG.
Associated keywords: CLG, GRAPHICS PEN, INK, MASK, TAG, TAGOFF

Chapter 3 Page 30

Complete List of Keywords

GRAPHICS PEN
GRA PH le S PEN [<ink>][, <background mode>]

10
20
30
40
50
60

MODE 0
GRAPH !CS PEN 15
MOVE 200,0
DRAW 200,400
MOVE 639,0
FILL 15

run

COMMAND: Sets the <ink>, (in the range 0 to 15) to be used for drawing lines and
plotting points. The graphics <background mode> can also be set to either:

o:Opaque background
1:Transparentbackground
(Transparent background affects the graphics paper of characters written with TAG
on, and the gaps in dotted lines.)
Either parameter may be omitted, but not both. If a parameter is omitted, that
particular setting is not changed.
Associated keywords: GRAP HIe SPA PER, INK, MASK, TAG, TAG 0 F F

HEX$
HEX $ ( <unsigned integer expression> [, <field width> ] )

PRINT HEX$(255,4)
00FF
FUNCTION: Produces a $tring of HEXadecimal digits representing the value of the
<unsigned integer expression>, using the number of hexadecimal digits instructed by
the <field width> (in the range 0 to 16). If the number of digits instructed is too great,
the resulting expression will be filled with leading zeros; if the number of digits
instructed is too small, the resulting expression will NOT be shortened to the
instructed number of digits, but will be produced in as many digits as are required.
The <unsigned integer expression> to be converted into hexadecimal form must yield
a value in the range -32768 to 65535.
Associated keywords: BIN $, DE C$, S T R$, UNT

Complete List of Keywords

Chapter 3 Page 31

HIMEM
HIMEM

PRINT HIMEM
42619
FUN CTI 0 N: Returns the address of the HIghest byte of MEMory used by BASIC,
(which may be altered by the MEMO RY command).
NOTE - BASIC uses only the first 64K of the memory.
Associated keywords: F RE, ME M0 RY, S YMB0 L, S YMB0 L AFT E R

IF
I F <logical expression> THE N <option part> [E LSE <option part>]

10 MODE 1
20 x=CINT(RND*100)
30 PRINT "Guess my number (0 to 100)"
40 INPUT n
50 IF ,n<x THEN PRINT n;"is too low.,,"
60 IF n>x THEN PRINT n;"istoo high .. ,"
70 IF n=x THEN 80 ELSE c=c+1:GOTO 40
80 PRINT "Well done, you got it in";
90 PRINT c+1;"guesses!"
run
COMMAND: Determines whether the <logical expression> is true, in which case the
first <option part> is executed. If the <logical expression> is false, any <option part>
specified in the EL SE clause is executed, otherwise BASIC passes onto the next line.
I F THE N commands may be nested to any depth, and are terminated by end ofline.
Therefore it is NOT possible to have further statements which are independent of the
I F THE N command, on the same line.
Where the result of the <logical expression> requires that a line should be jumped to,
the command may be given as either:
Examples ....

IF .a =1 THE N 100
.... or ....

IF a=1 GOTO 100


.... or ....

IF a=1 THEN GOTO 100


Associated keywords: EL SE, GOT 0, THE N

Chapter 3 Page 32

Complete List of Keywords

INK
INK <ink> , <colour> [, <colour>]

10 MODE 1:PAPER 0:PEN


20 FOR p=0 TO 1
30 FOR i=0 TO 26
40 INK p,i
50 LOCATE 16,12:PRINT "ink";p;",";i
60 FOR t=1 TO 400:NEXT t,i,p
70 INK 0,1:INK 1,24:CLS
run
COMMAND: Assigns colour(s) to a given ink. The <ink> parameter describes the ink
reference> which must be an integer expression in the range 0 to 15, for use in the
appertaining PEN or PAP E R command. The first <colour> parameter should be an
integer expression yielding a colour value in the range 0 to 26. If an optional second
<colour> is specified, the ink alternates between the two colours, at a rate determined
by the S P E E DIN Kcommand.
Associated keywords: GRAPHICS PAPER, GRAPHICS PEN, PAPER, PEN,
SPEED INK

INKEY
INK E Y ( <integer expression> )

10 IF INKEY(55)<>32 THEN 10
20 PRINT "You I ve pressed [SHI FT] and V"
30 CLEAR INPUT
run
FUNCTION: I Nterrogates the KEYboard to report which keys are being pressed.
The keyboard is scanned every 0.02 (fiftieth) second.
The function is useful for spotting whether a certain key is down or up, by detecting
the returned value of -1 (which occurs regardless of [SHIFT] and [CONTROL] key
status).
The above example detects when [SHIFT] and V (key number 55) are pressed together,
then ends the program. An illustration of key numbers will be found in the diagram
at the top right hand side of the computer, and in the chapter entitled 'For your
reference .... '.

Complete List of Keywords

Chapter 3 Page 33

The state of [SHIFT] and [CONTROL] in conjunction with the key specified in the
<integer expression> is identified as follows:
Value returned

[SHIFT]

[CONTROL]

specified key

-1
0
32
128
160

UP/DOWN
UP
DOWN
UP
DOWN

UP/DOWN
UP
UP
DOWN
DOWN

UP
DOWN
DOWN
DOWN
DOWN

Associated keywords: CLEA R I NPUT, INK E Y$, JOY

INKEY$
INKEY$

10 CLS
20 PRINT "SeLect Yes or No (Y/N)?"
30 a$:;:INKEY$
40 IF a$="" THEN 30
50 IF a$="y" OR a$="Y" THEN 80
60 IF a$="n" OR a$="N" THEN 90
70 GOTO 30
80 PRINT "You have seLected YES":END
90 PRINT "You have seLected NO"
run
FUNCTION: I Nterrogates the KEYboard, returning the current $tring reflecting
any key that is pressed'. If no key is pressed, INK E Y$ returns an empty string. In the
above example, lines 40 and 70 tell the program to loop back to line 30 after
interrogating the keyboard string.
Associated keywords: CLEA R I NPUT, INK E Y

INP
I NP ( <port number> )

PRINT INP(&FF77)
255
FUNCTION: Returns the I NPut value from the I/O address specified in the <port
number>.
Associated keywords: 0 UT, WA I T

Chapter 3 Page 34

Complete List of Keywords

INPUT
I NPUT [# <stream expression> , J[; J[ <quoted string> <separator> ]
<list of: <variable>

10 MODE 1
20 INPUT "Give me two numbers for multiplication,
(separated by a comma)";a,b
30 PRINT a;"times";b;"is";a*b
40 GOTO 20
run
COMMAND: Accepts data input from the stated stream, (from stream # 0 if not
specified).
The first, optional semicolon [; ] suppresses the carriage return/line feed that will
otherwise occur after the command is executed.
The <separator> must either be a semicolon or comma. A semicolon causes a question
mark to be displayed; a comma suppresses the question mark.
If an entry is made that is ofthe wrong type such as if the letter 0 is typed instead of a
(zero) when I NPUT ing a numeric variable, then BASIC will respond with:

?Redo from start


.... and any original prompt text that you programmed.
All responses from the keyboard must be terminated by pressing the [RETURN] key.
Associated keywords: LI NE I NPUT

Complete List of Keywords

Chapter 3 Page 35

INSTR
INS T R ( [<start position> , J<searched string> , <searched for string> )

10 CLS
20 aLphabet$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
30 INPUT "Enter a Letter";a$
40 b$=UPPER$(a$)
50 PRINT b$;" is number";
60 PRINT INSTR(aLphabet$,b$);
70 PRINT "in the aLphabet.":PRINT
80 GOTO 40
run
FUNCTION: Searches the first <searched string> expression to find the <searched for
string> expression> and reports the position of its first occurrence within the <searched
string>. If the <searched for string> does not occur within the <searched string>, then 0
is reported.
The position at which to start searching the <searched string> is optionally specifiable
using the <start position> parameter which must yield an integer number in the range
1 to255.
Associated keywords: none

INT
I NT ( <numeric expression> )

PRINT INT(-1.995)
-2
FUNCTION: Rounds the number to the nearest smaller I NTeger, removing any
fractional part. Returns the same value as F I Xfor positive numbers, but returns one
less than F I X for negative numbers which are not already integers.
Associated keywords: CI NT, F I X, R0 UND

Chapter 3 Page 36

Complete List of Keywords

JOY
JOY ( <integer expression> )

10 PRINT "To stop the program - If;


20 PRINT "operate joystick"
30 IF JOY(0)<>0 THEN END
40 GOTO 10
run
FUNCTION: Reads a bit-significant result from the JOY stick specified in the
<integer expression> (either 0 or 1).
Decimal
Bit
O:Up
1: Down
2: Left
3: Right
4: Fire 2
5: Fire 1

1
2
4
8
16
32

Hence for example, if the main 'fire' button (Fire 2) on the first joystick is pressed
while the joystick handle is being '-moved left, the function JOY ( 0) returns a
decimal value of20, corresponding to 16 (Fire 2) + 4 (Left).
Further information concerning joysticks will be found in the chapter entitled 'For
your reference .... '.
Associatedkeywords: CLE AR IN PU T, IN KE Y

I{EY
KEY <expansion token number> , <string expression>

KEY 11,"border 13:paper 0:pen 1:ink 0,13:


ink 1,0:mode 2:list"+CHR$(13)
.... now press the [ENTER] key.
COMMAND: Assigns the <string expression> to the key's <expansion token number>
specified. Thirty-two expansion tokens are supported, in the range 0 to 31, these
occupying the key values 128 to 159. Keys 128 (0 on numeric keypad) to 140
([CONTROL] [ENTER]) are by default assigned to print numbers 0 to 9, a decimal
point, [RETURN] and RUN" [RETURN] - (for cassette operation), but may be
re-assigned to other <string expression>s as required. Expansion tokens 13 to 31 (key
values 141 to 159) are empty strings by default, but may be be expanded and assigned
to keys, using the KEY DE F command described in the next example.

Complete List of Keywords

Chapter 3 Page 37

The <expansion token number> given in the KEY command may be in the range 0 to
31, or optionally 128 to 159 to reflect the key values. (See the key illustrationjn the
chapter entitled 'For your reference .... '.)
A total of 120 characters may be expanded into the <string expression>s. Attempting
to over-expand will produce an 'I mpro per a r gum en t' error (5).
Associated keywords: KEY DE F

KEY DEF
KEY DE F <key number> , <repeat>[, <normal>[, <shifted> [ , <control.]]]

KEY 159,"this is the tab key"


KEY DEF 68,1,159
.... now press the [TAB] key.
COMMAND: DE Fines the KEY values to be returned by the specified <key number>
in the range 0 to 79 {for an illustration of key numbers, refer to the diagram at the top
right hand side of the computer, or to the chapter entitled 'For your reference .... '). The
<normal>, <shifted>, and <control> parameters should contain the values required to be
returned when the key is pressed, alone, together with [SHIFn, and together with
[CONTROL], respectively. Each ofthese parameters is optional.
The <repeat> parameter enables you to set the key auto-repeat function on or off (1 or
0), the rate of auto-repeat being adjustable by use of the S PE ED KE Y command.
In the above example, key 159 (equivalent to expansion token 31) is first assigned to
an expansion string, then the KE Y DE F command defines key 68 (the [TAB] key)
to auto-repeat (1 ), and to return the <normal. value 1 59 when pressed alone.
In the above example, normal action would be restored by:

KEY DEF 68,0,9


.... where 9 is the normal ASCII value for [TAB]
Associated keywords: KEY, S P E ED KEY

Chapter 3 Page 38

Complete List of Keywords

LEFT$
LE FT $ ( <string expression> , <required length> )
10 CLS
20 a$="AMSTRAD"
30 FOR n=1 TO 7
40 PRINT LEFT$(a$,n)
50 NEXT
run

FUNCTION: Returns the number of characters (in the range 0 to 255) specified in the
<required length> parameter, after extracting them from the LE FT of the <string
expression>. If the <string expression> is shorter than the <required length>, the whole
<string expression> is returned.
Associated keywords: MI D$, RIG HT $

LEN
LE N ( <string expression> )
10 LINE INPUT "Enter a phrase";a$
20 PRINT "The phrase is";
30 PRINT LEN(a$);"characters Long."
run

FUNCTION: Returns the total number of characters (i.e. the LENgth) of the <string
expression>.
Associated keywords: none

LET

LET <variable> <expression>


LET x=100

COMMAND: Assigns a value to a variable. A remnant from early BASICs where


variable assignments had to be 'seen coming'. Has no use in AMSTRAD BASIC apart
from providing compatibility with the programs supplied in early BASIC training
manuals. The above example need only be typed in:
x=.100

Associated keywords: none


Complete List of Keywords

Chapter 3 Page 39

LINE INPUT
LI NE IN PUT [# <stream expression> ,][;][ <quoted string> <separator>]
<string variable>
10 LINE INPUT "Type a Line of text";a$
20 CLS
30 PRINT "The variabLe a$ now equaLs:-"
40 PRINT a$
run

COMMAND: Accepts input of an entire line of text from the stream indicated, (from
stream # 0 if not specified). The first, optional semic'olon [;] suppresses the carriage
return/line feed that will otherwise occur after the command is executed.
The <separator> must either be a semicolon or comma. A semicolon causes a question
mark to be displayed; a comma suppresses the question mark.

LIN E IN PUT from the keyboard is terminated by pressing the [RETURN] key.
LIN E IN PUT from disc (or cassette) stream # 9 is terminated by a received
carriage return, or by the <string variable> being assigned 255 characters, whichever
is the sooner.
Associated keywords: I NPUT

LIST
LIS T [<line number range>][, # <stream expression>]
LIST 100-1000,#1

COMMAND: Lists program lines to the given stream. Stream # 0 is the default
screen stream, and # 8 is the printer. LIS Ting may be paused by pressing [ESC]
once, and re-started by pressing the space bar. Pressing [ESC] twice will abandon the
listing and return to direct mode.
The first or last number in the <line number range> may be omitted to indicate
'" "from the beginning of the program', or'"" to the end of the program', i.e:
LIST -200

Chapter 3 Page 40

Complete List of Keywords

.... or ....
LIST 50-

.... or ....
LI ST
.... which lists the whole program.
Associated keywords: none

LOAD
LOA 0 dilename> [ , <address expression>]
LOAD "discfi Le.xyz",&2AFB
COMMAND: Loads a BASIC program from disc into memory, replacing any existing
program. Specifying the optional <address expression> will cause a binary file to be
loaded at that address, rather than the address from which it was saved.
A Protected BASIC program can NOT be loaded using the LOA 0 command as it will
be immediately deleted from memory. Instead, use the RUN or CH AIN co""'mands.
Associated keywords: CH AIN, CHAI N MER GE, MER GE, RUN, S AVE

LOCATE
L0 CAT E[# <stream expression> , ]<x co-ordinate> , <y co-ordinate>
10
20
30
40
50

MODE 1
FOR n=1 TO 20
LOCATE n,n
PRINT CHR$(143);"Location";
PRINT n;",";n

60 NEXT
run

COMMAND: Locates the text cursor at the stream indicated, to the position specified
by the x and y co-ordinates, with 1,1 being the top left corner of the stream (window).
Stream # 0 is the default stream.
Associated keywords: WIN 0 0 W

Complete List of Keywords

Chapter 3 Page 41

LOG
LOG ( <numeric expression> )

PRINT LOG(9999)
9.21024037
FUNCTION: Calculates the natural LOGarithm of the <numeric expression> which
must be greater than zero.
Associated keywords: EX P, LOG 1 0

LOG10
LOG 1 0 ( <numeric expression> )

PRINT LOG10(9999)
3.99995657
FUNCTION: Calculates the LOGarithm to base 10 of the <numeric expression>
which must be greater than zero.
Associated keywords: EX P, LOG

LOWER$
LOW E R$ ( <string expression> )

10 a $ =" SEE HOW THE LE TT ERS CH ANGET 0


20 PRINT LOWER$(a$+"LOWER CASE")
run

!'

FUNCTION: Returns a new string expression which is a copy of the specified <string
expression> but in which all alphabetic characters in the range A to Z are converted to
lower case. The function is useful for processing input which may come in mixed
upper/lower case.
Associated keywords: UPP E R$

Chapter 3 Page 42

Complete List of Keywords

MASK
MASK [<integer expression>][, <first point setting>]

10 MODE 0:INK 5,21:INK 8,16


20 MOVE -100*RND,400*RND
30 WHILE XPOS<640
40 FOR x=1 TO 8
50 MASK 21' (8-x)
60 DRAWR 32,0,x,1:MOVER -32,0
70 NEXT
80 MOVER 34,0
90 WEND:GOTO 20
run
COMMAND: Sets the 'mask' or template to be used when drawing lines. The binary
value of the <integer expression> in the range 0 to 255, sets the bits in each adjacent
group of8 pixels to ON (1), or OFF (0).
The <first point setting> determines whether the first point of the line is to be plotted
(1) or not plotted (0).
Either of the parameters may be omitted, but not both. If a parameter is omitted, that
particular setting is not changed.
Associated keywords: DRAW, DRAWR, GRAPHICS PAPER, GRAPHICS PEN

MAX
MA X ( <list of: <numeric expression> )

10 n=66
20 PRINT MAX(1,n,3,6,4,3)
run
66
FUNCTION: Returns the MAXimum value from the <list of: <numeric expression>s.
Associated keywords: MI N

Complete List of Keywords

Chapter 3 Page 43

MEMORY
MEM 0 RY <address expression>

MEMORY &20AA
COMMAND: Allocates the amount of BASIC memory available by setting the
address of the highest byte.
NOTE -BASIC uses only the first 64K ofthe memory.
Associated keywords: FRE, HIMEM, SYMBOL, SYMBOL AFTER

MERGE
MER GE <filename>

MERGE "newLoad.bas"
COMMAND: Loads a program from disc, and adds it to the current program in the
memory.
Note that line numbers in the old program which exist in the new program to be
MER GEd, will be over-written by the new program lines.
Protected files, (S AV Ed by , p) can NOTbe ME RG Edinto the current program.
Associated keywords: CHAIN, CHAIN MERGE, LOAD

MID$
MID $ ( <string expression> , <start position>[, <sub-string length>])

10 MODE 1:Z0NE 3
20 a$="ENCYCLOPAEDIA"
30 PRINT "Show me how to speLL ";a$
40 PRINT "OK .... ":PRINT
50 FOR n=1 TO LEN(a$)
60 PRINT MID$(a$,n,1),
70 FOR t=1 TO 700:NEXT t,n
80 PRINT:PRINT
90 INPUT "Now enter another word";a$
100 GOTO 50
run

Chapter 3 Page 44

Complete List of Keywords

FUNCTION: Returns a new sub-string, commencing at the <start position> of the


<string expression>, being <sub-string length> characters long. If the <sub-string
length> parameter is not specified, the remainder of the <string expression> afJ-er the
<start position> is returned.
If the <start position> is greater than the total length of the <string expression>, then
an empty string is returned. The range of <start position> is 1 to 255. The range of
<sub-string length> is 0 to 255.
Associated keywords: LE FT$, RIG HT $

MID$
MI D$ string variable> , <insertion position> [ , <new string length>] )
=<new string expression>

10 a$="heLLo"
20 MID$(a$,3,2)="XX"
30 PRINT a$
run
heXXo
COMMAND: Inserts the <new string expression> into the string specified by the
<string variable>, commencing at the dnsert position>, and occupying <new string
length> number of characters.
Note that when using MID $ as a COMMAND, a <string variable> such as a $ must be
used, and NOT a string constant such as 11 h eLL 0 11
Associated keywords: LE FT $, RIG HT$

MIN
MI N ( <list of: <numeric expression> )

PRINT MIN(3,6,2.999,8,9,)
2.999
FUNCTION: Returns the MI Nimum value from the <list of: <numeric expression>s.
Associated keywords: MAX

Complete List of Keywords

Chapter 3 Page 45

MOD
<argument> MOD <argument>

PRINT 10 MOD 3
1

PRINT 10 MOD 5

OPERATOR: Returns the remainder after dividing the first <argument> by the
second <argument> and removing any integer component - MODulus.
Associated keywords: none

MODE
MOD E <integer expression>

10 m=m+1:IF m>2 THEN m=0


20 MODE m
30 PRINT "this is mode";m
40 PRINT "now press a key"
50 IF INKEY$='"' THEN 50 ELSE 10
run
COMMAND: Changes the screen mode (0,1 or 2), and clears the screen to ink 0 (which
may not be the current paper ink). All text and graphics windows are reset to the
whole screen, and text and graphics cursors are homed to their respective origins.

Associated keywords: 0 RIG IN, WIN DO W

Chapter 3 Page 46

Complete List of Keywords

MOVE
M0 V E <x co-ordinate> , <y co-ordinate>[, [<ink>][, <ink mode>]]

10 MODE 1 :TAG
20 x=RND*800-100:y=RND*430
30 MOVE x,y
40 PRINT "I moved here";
50 GOTO 20
run
COMMAND: Moves the graphics cursor to the absolute point specified by <x
co-ordinate> and <y co-ordinate>. The optional <ink> parameter may be used to change
the graphics pen ink, in the range 0 to 15.
The optional <ink mode> determines how the ink to be written next, will interact with
that already on the graphics screen. The 4 <ink mode>s are:
O:Normal
1: XOR (eXclusive OR)
2:AND
3:0R
Associated keywords: MOV E R, 0 RIG I N, XPO S, YPO S

MOVER
M0 VER <x offset> , <y offset> [ , [<ink>][, <ink.mode>]]

10 MODE 1:TAG:MOVE 0,16


20 PRINT "Life has its";
30 FOR n=1 TO 10
40 MOVER -32,16
50 PRINT "ups";:NEXT:PRINT " and";
60 FOR n=1 TO 10
70 MOVER -64,-16
80 PRINT "downs";:NEXT
run
COMMAND: Moves the graphics cursor to a point relative to its current position. The
relative position is specified by <x offset> and <y offset>. The optional <ink> parameter
may be used to change the graphics pen ink, in the range 0 to 15.
The optional <ink mode> determines how the ink to be written next, will interact with
that already on the graphics screen. The 4 <ink mode>s are:
O:Normal
1 : XOR (eXclusive OR)
2:AND
3:0R
Associated keywords: M0 VE, 0 RIG I N, XPO S, YPO S

Complete List of Keywords

Chapter 3 Page 47

NEW
NEW

NEW
COMMAND: Deletes the current program and variables in the memory. Key
definitions are not lost, display characteristics i.e. MOD E, PEN, PAP ER, INK etc, are
not changed, and the screen is not cleared.
Associated keywords: none

NEXT
NEX T [<list of: <variable)]

10 FOR a=1 TO 3
20 FOR b=0 TO 26
30 MODE 1
40 PEN a:BORDER b
50 PRINT "pen";a;"border";b
60 FOR c= 1 TO 500
70 NEXT c,b,a
run
COMMAND: Marks the end of a FOR loop. The NEX T command may be anonymous,
or may refer to its matching FOR. Note from the above example that the <list
of: <variable)s must appear in reverse order to their matching FOR commands, so that
'nested' loops do not overlap.
Associated keywords: FOR, S T EP, TO

NOT
NOT <argument>

IF NOT "aLan"<"bob" THEN PRINT "correct" ELSE PRINT "wrong"


wrong
IF NOT "cat">"dog" THEN PRINT "correct" ELSE PRINT "wrong"
corre'ct
PRINT NOT -1

PRINT NOT 0
-1

OPERATOR: Performs bit-wise operations on integers. Inverts each bit in the


argument.
Further information concerning logic will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: AND, 0 R, X0 R
Chapter 3 Page 48

Complete List of Keywords

ON BREAK CONT
ON BREAK CaNT

10 ON BREAK CONT
20 PRINT "The program wi LL CONTi nue when you try
*Break* using [ESC]":PRINT
30 FOR t=1 TO 1000:NEXT:GOTO 20
run

to

COMMAND: Cancels the action of the [ESC] key from stopping the program, and
instead CON Tinues execution. Care should be taken when using this command, as
the program will continue until the computer is completely reset; hence you should
S AVE such a program before RUNning it.
ON BREAK CaNT may be disabled within a program by ON BREAK STOP.
Associated keywords: ON BREAK GOSUB, ON BREAK STOP

ON BREAK GOSUB
ON BREAK GOSUB <line number>

10 ON BREAK GOSUB 40
20 PRINT "program running"
30 GOTO 20
40 CLS:PRINT "Pressing [ESC] If;
50 PRINT "twice caLLs GOSUB-routine"
60 FOR t=1 TO 2000:NEXT
70 RETURN
run
COMMAND: Instructs BASIC to jump to the sub-routine specified in the <line
number> when the [ESC] key is pressed twice.
Associated keywords: ON BREAK CaNT, ON BREAK STOP, RETURN

Complete List of Keywords

Chapter 3 Page 49

ON BREAK STOP
ON BREAK STOP

10 ON BREAK GOSUB 40
20 PRINT "program running"
30 GOTO 20
40 CLS:PRINT "Pressing [ESC] ";
50 PRINT "twice caLLs GOSUB-routine"
60 FOR t=1 TO 2000:NEXT
65 ON BREAK STOP
70 RETURN
run
COMMAND: Disables the ON BREAK CONT and ON BREAK GOSUB
command, so that future operations of the [ESC] key stop the program. In the above
example, the 0 N BR EA K GO S UBcommand will operate once only, as it is then
disabled by line 65 in the 0 N BR EAK sub-routine.
Associated keywords: ON BR EAK CONT, ON BR EA K GOS UB

ON ERROR GOTO
ON ERROR GOTO ,line number>

10 ON ERROR GOTO 60
20 CLS:PRINT "If error is found, ";
30 PRINT "then List the' program"
40 FOR t=1 TO 4000:NEXT
50 GOTO 100
60 PRINT "Error detected in Line";
70 PRINT ERL:PRINT:LIST
run
COMMAND: Jumps to the
program.

specifi~d

,line number> when an error is detected in the

The form of the command 0 N ERR 0 R GOT 0 0 turns off the error trap, and
restores normal error processing by BASIC.
See also the RES UME commando.
Associated keywords: DERR, ERL, ERR, ERROR, RESUME

Chapter 3 Page 50

Complete List of Keywords

ON <expression> GOSUB
ON <selector> GO SUB <list of: <line number>

10 PAPER 0:PEN 1:INK 0,1


20 CLS:PRINT "MENU OF OPTIONS":PRINT
30 PRINT "1 - Change border":PRINT
40 PRINT "2 - Change pen":PRINT
50 PRINT "3 - Change mode":PRINT
60 INPUT "Enter your selection";x
70 ON x GOSUB 90,110,130
80 GOTO 20
90 b=b-1:IF b<0 THEN b=26
100 BORDER b:RETURN
110 p=p-1:IF p<2 THEN p=26
120 INK 1,p:RETURN
130 m=m-1:IF m<0 THEN m=2
140 MODE m:RETURN
run

COMMAND: Selects a sub-routine line to jump to, depending upon the value of the
<selector>, which should be a positive integer expression in the range 0 to 255. The
order of the <selector> values determines the <line number> to be selected from the <list
of: <line number>s. In the above example, selecting 1 makes BASIC jump to line 90,
selecting 2jumps to line 110,and3jumpstoline 130.
If the value of the <selector> is zero, or is higher than the amount of <line number>s
listed in the command, then no sub-routine line will be selected.
Associated keywords: RE T URN

Complete List of Keywords

Chapter 3 Page 51

ON <expression> GOTO
ON <selector> GOT 0 <list of: <line number>

10 CLS:PRINT "MENU OF OPTIONS":PRINT


20 PRINT "1 - List program":PRINT
30 PRINT "2 - Edit and add":PRINT
40 PRINT "3 - CataLog disc":PRINT
50 INPUT "Enter your seLection";n
60 ON n GOTO 80,90,100
70 GOTO 10
80 LIST
90 AUTO
100 CAT
run
COMMAND: Selects a line to jump to, depending upon the value of the <selector>,
which should be a positive integer expression in the range 0 to 255. The order of the
<selector> values determines the <line number> to be selected from the <list of: <line
number>s. In the above example, selecting 1 makes BASIC jump to line 80, selecting
2 jumps to line 90, and 3 jumps to line 1 0 0.

If the value of the <selector> is zero, or is higher than the amount of <line number>s
listed in the command, then no line will be selected.
Associated keywords: none

ONSQGOSUB
ON SQ channel

GO SUB <line number>

10 ENV1,15,-1,1
20 ON SQ(1) GOSUB 60
30 MODE 0:0RIGIN 0,0,200,440,100,300
40 FOR x=1 TO 13:FRAME:MOVE 330,200,x
50 FILL x:NEXT:GOTO 40
60 READ s:IF s=0 THEN RESTORE:GOTO 60
70 SOUND 1,s,25,15,1
80 ON SQ(1) GOSUB 60:RETURN
90 DATA 50,60,90,100,35,200,24,500,0
run

Chapter 3 Page 52

Complete List of Keywords

COMMAND: GOes to a BASIC SUB-routine when there is a free slot in the given
Sound Queue. The <channel> should be an integer expression yielding one of the
values:
1: for channel A
2: for channel B
4: for channel C
Further information concerning sound will be found in part 2 ofthe chapter entitled
'At your leisure .... '.
Associatedkeywords: RETURN, SOUND, SQ

OPENIN
OPE NI N dilename>

10 REM OPEN an INput file from disc


20 OPENIN "datafi le":INPUT #9,a,a$
30 CLOSEIN:PRINT "The 2 values are:"
40 PRINT:PRINT a,a$
run
COMMAND: 0 PENs an I Nput file from disc, for use in the current program. The
I Nputfileto 0 PEN must be an ASCII file.
The above example will only work after you have created the file shown in the next
example (under 0 PEN 0 UT).
Associatedkeywords: CLO SE I N, EO F

OPENOUT
OPE N0 UT <filename>

10 REM OPEN an OUTput file to disc


20 INPUT "give me a number variable";a
30 INPUT "give me a string variable";a$
40 OPENOUT "dataf i le"
50 WRITE #9,a,a$
60 CLOSEOUT:PRINT "Data saved onto disc"
run
COMMAND: 0 PEN san 0 UTput file to disc.
Associated keywords: CLOS EO UT

Complete List of Keywords

Chapter 3 Page 53

OR
<argument> 0 R <argument>
"aLan"<"bob" OR "dog">"cat" THEN PRINT "correct" ELSE PRINT "wrong"
correct

IF

IF "bob"<"aLan" OR "cat">"dog" THEN PRINT "correct" ELSE PRINT "wrong"


wrong
IF "aLan"<"bob" OR "cat">"dog" THEN PRINT "correct" ELSE PRINT "wrong"
correct

PRINT

OR

PRINT 0 OR 0
0
PRINT
OR 0
1

OPERATOR: Performs bit-wise boolean operation on integers. Result is 1 unless both


argument bits are 0.
Further information concerning logic will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: AND, NOT, X0 R

ORIGIN
OR I GIN <x>, <y>[, <left>, <right>, <top>, <bottom>]

10 MODE 1:BORDER 13:TAG


20 ORIGIN 0,0,100,540,300,100
30 GRAPHICS PAPER 3:CLG
40 FOR x=550 TO -310 STEP -10
50 MOVE x,206
60 PRINT "This is a graphics window";
70 FRAME:NEXT:GOTO 40
run
COMMAND: Sets the graphics origin points 0,0 to the position specified by the
co-ordinates <x> and <y>.
A graphics window's dimensions may also be set by specifying the last four optional
parameters. If the co-ordinates specified for the graphics window describe points
beyond the edge of screen, then the edge of the graphics window is taken as edge of
screen.
Associated keywords: CLG

Chapter 3 Page 54

Complete List of Keywords

OUT
OUT <port number> , <integer expression>
OUT &FBF4,&FF

COMMAND: Sends the value in the <integer expression> (in the range 0 to 255) 0 UT
to the address specified in the <port number>.
Not a command to be used by the unwary.
Associated keywords: I NP, WA I T

PAPER
PAP ER[# <stream expression> , ] <ink>

10
20
30
40
50

MODE 0:PEN 0:INK 0,13


FOR p=1 TO 15
PAPER p:CLS
LOCATE 7,12:PRINT "paper";p
FOR t=1 TO 500: NEXT t,p .

run
COMMAND: Sets the background ink for characters. When characters are written to
the text screen, the character cell is filled with the paper <ink> (in the range 0 to 15)
before the character is written, (unless the transparent mode has been selected).
If the <stream expression> is omitted, the PAP E R ink for stream # III is assumed by
default.
The number of different PAP ERinks supported is dependent upon the screen MOD E.
Associated keywords: GRA PHI CS PA PER, INK, PEN

Complete List of Keywords

Chapter 3 Page 55

PEEK
PE EK ( <address expression> )

10 MODE 1:Z0NE 7
20 WINDOW 1,40,1,2:WINDOW #1,1,40,3,25
30 PRINT "memory"':address"
40 LOCATE 20,1:PRINT "memory-contents"
50 FOR n=0 TO 65535
60 p=PEEK(n)
70 PRINT #1,n,"(&";HEX$(n);")";
80 PRINT #1,TAB(20);p,"(&";HEX$(p);")"
90 NEXT
run
FUNCTION: Reports the contents of the Z80 memory location specified in the
<address expression> which should be in the range &0000 to &FFFF (0 to 65535). In
all cases PE EK will return the value at the RAM address specified (not the ROM),
and will be in the range &00 to &FF (0 to 255).
Associated keywords: PO KE

PEN
PEN [# <stream expression> ,][ <ink>][, <background mode>]

10 MODE 0:PAPER 0:INK 0,13


20 FOR p=1 TO 15
30 PEN p:PRINT SPACE$(47);"pen";p
40 FOR t=1 TO 500:NEXT t,p:GOTO 20
run
COMMAND: Sets the <ink> (in the range 0 to 15) to be used when writing to the given
screen stream, (stream # 13 ifnot specified). The <background mode> parameter can be
set to transparent (1) or opaque (0).
Either of the last 2 parameters may be omitted, but not both. If a parameter is
omitted, that particular setting is not changed.
Associated keywords: PAP ER

Chapter 3 Page 56

Complete List of Keywords

PI
PI

PRINT PI
3.14159265
FUNCTION: Returns the value of the ratio between circumference and diameter of a
circle.
Associated keywords: DEG, RA D

PLOT
PLO T <x co-ordinate> , <y co-ordinate>[, [<ink>][, <ink mode>]]

10
20
30
40
50
60
70
80
90

MODE 1:BORDER 0:PAPER 0:PEN 1


INK 0,0:INK 1,26:INK 2,13,26:DEG
FOR x=1 TO 360:0RIGIN 320,200
DRAW 50*COS(x),50*SIN(x),1
PLOT 100*COS(x),25*SIN(x):NEXT
ORIGIN 0,0:t=TIME+700:WHILE TIME<t
PLOT RND*640,RND*400:WEND
PLOT RND*640,RND*400,2
GOTO 90

run

COMMAND: Plots a point on the graphics screen, at the absolute position specified in
the x,y co-ordinates. The <ink> in which to plot the point may be specified (in the range
oto 15).
The optional <ink mode> determines how the ink being written interacts with that
already on the graphics screen. The 4 <ink mode>s are:
0: Normal
1 : XOR (eXclusive OR)
2:AND
3:0R
Associated keywords: GRA PHI CS PEN, PLOT R

Complete List of Keywords

Chapter 3 Page 57

PLOTR
PLO T R <x offset> , <y offset> [ , [dnk>][, <ink mode> ]]

10 REM use cursor keys to draw Lines


20 BORDER 0:GRAPHICS PEN 1
30 MODE 1:PLOT 320,200
40 IF INKEY(0)=0 THEN PLOTR 0,1
50 IF INKEY(1)=0 THEN PLOTR 1,0
60 IF INKEY(2)=0 THEN PLOTR 0,~1
70 IF INKEY(8)=0 THEN PLOTR -1,0
80 IF INKEY(9)=0 THEN 30:REM copy=cLear
90 GOTO 40
run
COMMAND: Plots a point on the graphics screen at the specified position <x offset>
and <y offset>, relative to the current graphics cursor position. The <ink> in which to
plot the point may be specified (in the range 0 to 15).
The optional <ink mode> determines how the ink being written interacts with that
already on the graphics screen. The 4 <ink mode>s are:
0: Normal
1 : XOR (eXclusive OR)
2:AND
3:0R
Associatedkeywords: GRA PHI CS PEN, PLO T,

POKE
PO KE <address expression> , <integer expression>

10 FOR m=49152 TO 65535


20 POKE m,100
30 NEXT
run
COMMAND: Writes the value of the <integer expression> (in the range 0 to 255)
directly into the Z80 memory (RAM) at the specified <address expression>.
Not a command to be used by the unwary.
Associated keywords: PE EK

Chapter 3 Page 58

Complete List of Keywords

POS
PO S ( # <stream expression> )

10 MODE 1:BORDER 0:LOCATE 8,2


20 PRINT "use cursor left/right keys"
30 WINDOW 1,40,12,12:CURSOR 1,1
40 FOR n=1 TO 19:PRIN1 CHR$(9);:NEXT
50 IF INKEY(1)<>-1 THEN PRINT CHR$(9);
60 IF INKEY(8)<>-1 THEN PRINT CHR$(8);
70 LOCATE #1,2,24
80 PRINT #1,"text cursor ";
90 PRINT #1,"horizontal position =";
100 PRINT #1,POS(#0):GOTO 50
run
FUNCTION: Reports the current horizontal PO Sition of the text cursor relative to
the left edge of the text window. The <stream expression> MUST be specified, and does
NOT default to #0.

PO S ( # 8) reports the current horizontal carriage position for the printer, where 1 is
the extreme left hand edge.
PO S ( # 9) reports the logical position in the disc file stream, i.e. the number of
printing characters sent to the stream since the last carriage return.
Associated keywords: VP 0 S, WIN DO W

PRINT
PR I NT[# <stream expression> ,][ <list of: <print items>]

10 a$="small"
20 b$="this is a larger string"
30 PRINT a$;a$
40 PRINT a$,a$
50 PRINT
60 PRINT b$;b$
70 PRINT b$,b$
run
COMMAND: Prints the <list of:<printitem>s to the given stream, (to stream #0 ifno
<stream expression> is specified).

Complete List of Keywords

Chapter 3 Page 59

Note that when a semicolon; is used to tell the computer to print the following <print
item> next to the preceding item, BASIC first checks to see if the following <print
item> can fit onto the same line. Ifnot, it will be printed on a new line regardless of the
semicolon.
Note also that when a comma, is used to tell the computer to print the following
<print item> in the next print zone, BASIC first checks to see that the preceding item
has not exceeded the length of the current zone. If it has, the following <print item> is
printed in a further zone.

PRINTSPC
PRINT TAB
PR I NT[# <stream expression> ,][ <list of: <print item>][; ]
[S P C ( <integer expression> ) ][ <list of: <print item> ]
PR I NT[# <stream expression> , ][<list of:<printitem>][;]
[T AB ( <integer expression> ) ][ <list of: <print item>]

10 PRINT "this is spc function"


20 FOR x=6 TO 15
30 PRINT SPC(5)"a";SPC(x)"b"
40 NEXT
50 PRINT "this is tab function"
60 FOR x=6 TO 15
70 PRINT TAB(5)"a";TAB(x)"b"
80 NEXT
run
S P C prints the number of spaces specified in the <integer expression>, and will print
any following <print item> immediately next to the spaces, (assuming that the
following <print item> will fit onto the line). Hence it is not necessary to terminate
S P Cwith a semicolon.

TAB prints the number of spaces relative to the left edge of the text window, and will
print any following <print item> immediately next to the spaces, (assuming that the
following <print item> will fit onto the line). Hence it is not necessary to terminate
TAB with a semicolon. If the current position is greater than the required position,
then a carriage return is executed, followed by spaces to reach the required position
on the next line.

Chapter 3 Page 60

Complete List of Keywords

PRINT USING
PR I NT[# <stream expression>][<list of: <print item> ][;]
[U SING <formattemplate>][<separator><expression>]

10 FOR x=1 TO 10
20 n=100000*(RNDtS)
30 PRINT "goods";USING "########,.##";n
40 NEXT
run
PR I NT US I NG enables you to specify the print format of the expression returned
by the PR I NT command. This is achieved by specifying a <format template> to which
the printed result must correspond. The <separator> is a comma or semicolon. The
<format template> is a string expression which is constructed using the following
'format field specifiers':

Numeric Formats
Within the number:

Each # specifies a digit position.


Example template: # # # # # #
Specifies the position ofthe decimal point.
Example template: # # # # # # # #

(Specifies one digit position.) May appear BEFORE the decimal point only.
Specifies that digits before the decimal point are to be divid~d into groups of
three (for thousands), separated by commas.
Example template: # # # # # # , # #

Around the number:

(Specifies two digit positions.) Specifies that a sign be printed immediately


before the first digit or decimal point (after any leading sign). Note that the
will occupy one ofthe digit positions.
Example template: ######,. ##

**

(Specifies two digit positions.) Specifies that any leading spaces be replaced
by asterisks.
Example template: **######,. ##

Complete List of Keywords

Chapter 3 Page 61

**

(Specifies three digit positions.) Acts * * and options combined, i.e.


leading asterisks and sign.
Example template: **######,. ##

$$

(Specifies two digit positions.) Specifies that a $ sign be printed


immediately before the first digit or decimal point (after any leading sign).
Note that the $ will occupy one ofthe digit positions.
Example template: $$######,. ## .

**$

(Specifies three digit positions.) Acts as * * and $ $ options combined, i.e.


leading asterisks and $ sign.
Example template: **$######,. ##

Specifies that + or - is to be printed, as appropriate. If the + appears at the


beginning of the template, the + sign is printed immediately before the
the number (and any leading currency sign). Ifthe + appears at the end of
the template, the sign is printed after the number (and any exponent
part).
Example template: +# # # # # # # #

The - sign may only appear at the END of a template. It specifies that - is
to be printed after any negative number (and exponent part). If the
number is positive, a space will be printed. A - sign is printed before a
negative number by default, unless countermanded by the use of this
template.
Example template: # # # # # # # # -

t t t t

Specifies that the number is to be printed using the exponent option. The
t t t t in the template should appear AFTER the digit positions, but
BEFORE any trailing + or - sign.
Example template: # # # # # t t t t +

The <format template> for a number may not exceed 20 characters. Numbers are
rounded to the number of digits printed.

If the format template is too small for the input expression, for example:

PRINT USING "####";12345678


.... the printed result is NOT shortened to fit the template, but is instead printed in its
entirety, preceded by a %sign, to indicate 'format failure'.

Chapter 3 Page 62

Complete List of Keywords

String Formats
10 CLS:a$="abcdefghijklmnopqrst"
20 PRINT "input expression= ";a$
30 PRINT:PRINT "! specifier= ";
40 PRINT USING "!";a$
50 PRINT:PRINT "\spaces\ specifier= ";
60 PRINT USING "\
\";a$
70 PRINT:PRINT "& specifier= ";
80 PRINT USING "&";a$
90 GOTO 90
run
Specifies that only the first character of the string is to be printed.
Example template: !
\ <spaces> \
Specifieb that only the first x characters of the string are to be printed, where x
is equal to the length of the template (including the back-slashes).
Example template: \
\

&

Specifies that the entire string is to be printed 'as is'.


Example template: &

The <format template> for a string may not exceed 255 characters.
Both numeric and string <format template>s may be represented by string variables,
for example:

10 a$="######,.##"
20 b$="!"
30 PRINT USING a$;12345.6789;
40 PRINT USING b$;"pence"
run
Further information concerning print formatting wHl be found in part 2 of the
chapter entitled 'At your leisure .... '.
Associated keywords: S P C, TAB, US I NG, Z0 NE

Complete List of Keywords

Chapter 3 Page 63

RAD
RAD

RAD
COMMAND: Sets RADians mode of calculation. BASIC defaults to radians when the
computer is switched on or reset, or when the commands NEW, CLEAR, or LOAD,
RUN, etc, are issued.
Associated keywords: AT N, COS, DEG, SIN, TAN

RANDOMIZE
RAN DO MI Z E [<numeric expression>]

RANDOMIZE 123.456
PRINT RND
0.258852139
COMMAND: Randomizes the number 'seed' specified in the <numeric expression>.
BASIC's random number generator produces a pseudo-random sequence in which
each number depends on the previous number, commencing at a given number seed.
The sequence is always the same. RAN DO MI Z E sets the new initial value for the
random number generator either to the specified value, or to a value entered by the
user if the <numeric expression> is omitted.
RAN DO MI Z E T I ME produces a sequence that is difficult to repeat.
Associated keywords: RN D

READ
REA D <listof:<variable>

10 FOR n=1 TO 8
20 READ a$,c
30 PRINT a$;" ";:SOUND 1,c:NEXT
40 DATA here,478,are,426,8,379,notes
50 DATA 358,of,319,a,284,musicaL,253,scaLe,239
run
COMMAND: Reads data from DAT A statements and assigns it to variables,
automatically stepping the 'pointer' to the next item in the DAT A statement
afterwards. The RES TOR E command can be used to return the pointer to the
beginning of a DAT Astatement.
Further information concerning data will
'At your leisure .... '.
Associated keywords: DATA, RES TOR E

Chapter 3 Page 64

he found in part 2 of the chapter entitled

Complete List of Keywords

RELEASE
RE LEA S E <sound channels>

10 SOUND 65,1000,100
20 PRINT "Press R to release the sound"
30 IF INKEY(50)=-1 THEN 30
40 RELEASE 1
run
COMMAND: Releases sound channels which are set to a 'hold' state in the SOU ND
command.
The parameter <sound channels> must yield an integer value in the range 1 to 7,
which operates as follows:
1 : Releases channel A
2 : Releases channel B
3 : Releases channel A and B
4 : Releases channel C
5 : Releases channel A and C
6 : Releases channel Band C
7 : Releases channel A and Band C
Further information concerning sound will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: SOU ND

REM
REM <rest ofline>

10 REM Intergalatic Hyperspace Mega-Monster


Invaders Deathchase by AMSOFT
20 REM Copyright AMSOFT 1985
COMMAND: Inserts aRE Mark into a program. The <rest ofline> is ignored by BASIC,
and may contain any characters, including colons : which normally separate
statements.
A single quote character ' can be used in place of : REM in all applications EXCEPT
in DAT A statements, where the ' is treated as part of an unquoted string.
Associated keywords: none
Complete List of Keywords

Chapter 3 Page 65

REMAIN
REM A I N ( <timer number> )

10
20
30
40
50
60
70
80
run

AFTER 500,1 GOSUB 40


AFTER 100,2 GOSUB 50
PRINT "program running":GOTO 30
REM this GOSUB-routine will not be called
as it is disabled in line 80.
PRINT:PRINT "Timer 1 will now be If;
PRINT "disabled by REMAIN."
PRINT "Time-units remaining were:";
PRINT REMAIN(1)

FUNCTION: Returns the REM A I Ning count from the delay timer specified in <timer
number> (in the range 0 to 3), and disables it.
Further information concerning interrupts will be found in part 2 of the chapter
entitled 'At your leisure .... '.
Associated keywords: AFT ER, DI, El, EVE RY

RENUM
RE NUM [<new line number>][, [<old line number>][, <increment>]]

10 CLS
20 REM this will be line 123
30 REM this will be line 124
40 REM this will be line 125
RENUM 123,20,1
LIST
COMMAND: RE NUMbers program lines.
The parameter <old line number> specifies the current existing line number at which
renumbering is to commence. If <old line number> is omitted, renumbering will
commenr.p from the beginning of the program.
The parameter <new line number> specifies the new starting line number for the
renumbered lines. If <new line number> is omitted, the renumbered program will
start at line 1 0.
The parameter <increment> specifies the numeric step between each of the
renumbered lines. If <increment> is omitted, the value ofthe numeric step will be 1 0.
RE NUM takes care of all GO SUB, GOT 0 and other line calls. However, line number
references within string expressions, such as those issued in KEY commands, are not
altered; neither are line refere,nces within REM statements, nor the <line number
expression> in a CHAI Nor CHAI N MER GE command.
Line numbers are valid in the range 1 to 6 5 5 3 5.
Associated keywords: DEL E T E, LIS T
Chapter 3 Page 66

Complete List of Keywords

RESTORE
RE SI 0 RE [<line number>]

10 READ a$:PRINT a$;" If;


20 RESTORE 50
30 FOR t=1 TO 500:NEXT:GOTO 10
40 DATA restored data can be read again
50 DATA and again
run
COMMAND: Restores the position of the 'pointer' back to the beginning of the DAT A
statement specified in the optional <line number>. Omitting this parameter restores
the pointer back to the first DAT A statement.
Further information concerning data will be found in part 2 of the chapter entitled
'At your leisure ... .'.
Associated keywords: DATA, REA D

RESUME
RES UM E [<line number>]

10 ON ERROR GOTO 60
20 FOR x=10 TO 0 STEP-1:PRINT 1/x:NEXT
30 END
40 PRINT "go here after error"
50 END
60 PRINT "error no.";ERR;"in line";ERL
70 RESUME 40
r.un
COMMAND: Resumes normal execution of a program after an error has been
trapped and processed by an 0 N ERR 0 R GOT 0 command. If the <line number> to
RES UME at is not specified, the program will re-commence execution from the same
line in which the error was first trapped. Try removing the <line number> parameter
in the above example, then RUN again.

70 RESUME
run
Associatedkeywords: DERR, ERL, ERR, ERROR, ON ERROR GOTO,
RESUME NEXT
Complete List of Keywords

Chapter 3 Page 67

RESUME NEXT
RESUME NEXT

10 ON ERROR GOTO 90
20 PRINT "press [RETURN] each time"
30 INPUT "1";a
40 INPUT "2";a
50 i npot "3";a :REM syntax error!
60 INPUT "4";a
70 INPUT "5";a
80 END
90 PRINT "error no.";ERR;"in Line";ERL
100 RESUME NEXT
run
COMMAND: Resumes normal execution of a program after an error has been
trapped and processed by an 0 N ERR 0 R GOT 0 command.
RES UMEN EX T will re-commence execution from the line after that in which the
error was first trapped.

Associatedkeywords: DERR, ERL, ERR, ERROR, ON ERROR GOTO, RESUME

RETURN
RETURN

10 GOSUB 50:PRINT "after the gosub":END


50 FOR n=1 TO 20
60 PRINT "sub-routine"
70 NEXT:PRINT
80 RETURN
run
COMMAND: Marks the end of a sub-routine. BASIC returns from the sub-routine to
the statement immediately after the GO SUB command which invoked it.
Associated keywords: GO SUB

Chapter 3 Page 68

Complete List of Keywords

RIGHT$
RIG H-T $ ( <string expression> , <required length> )

10 MODE 1:a$="CPC6128 computer"


20 FOR n=1 TO 16:LOCATE 41-n,n
30 PRINT RIGHT$(a$,n)
40 NEXT
run
FUNCTION: Returns the number of characters (in the range 0 to 255) specified in the
<required length> parameter, after extracting them from the RIG HT of the <string
expression>. If the <string expression> is shorter than the <required length>, the whole
<string expression> is returned.
Associated keywords: LE FT $, MI D$

RND
RND[ ( <numeric expression> ) ]

10 RANDOMIZE
20 FOR x=1 TO -1 STEP -1
30 PRINT "rnd parameter=";x
40 FOR n=1 TO 6
50 PRINT RND(x)
60 NEXT n,x
run
FUNCTION: Returns the next RaN Dom number m sequence if the <numeric
expression> has a positive value or is not specified.
If the <numeric I?xpression> yields a value of zero, RN D returns a copy of the last
random number generated.

If the <numeric expression> yields a negative value, a new random number sequence
is started, the first number of which is returned.
Associated keywords: RAN DO MI Z E

Complete List of Keywords

Chapter 3 Page 69

ROUND
R0 UND ( <numeric expression, [ , <decimals,])

10 FOR n=4 TO -4 STEP-1


20 PRINT ROUND (1234.5678,n),
30 PRINT "with integer expression";n
40 NEXT
run
FUNCTION: Rounds the <numeric expression, to a number of decimal places or
power often specified in the <decimals, parameter. If <decimals, is less than zero, the
<numeric expression, is rounded to give an absolute integer with <decimals, number
of zeros before the decimal point.
Associated keywords: AB S, Cl NT, F I X, IN T

RUN
RUN <string expression,

RUN "disc"
COMMAND: Loads a BASIC or binary program from disc and commences execution.
Any previously loaded BASIC program is cleared from the memory.
Protected BASIC programs may be run directly in this manner,..
Associated keywords: LOA D

RUN
RUN [<line number,]

RUN 200
COMMAND: Commences execution of the current BASIC program, from the
specified <line number, parameter, or from the beginning of the program if the
parameter is omitted. RUN resets the value of all current program variables to zero or
null.
Protected programs may NOT be run in this manner, after loading.
Associated keywords: CON T, END, STOP
Chapter 3 Page 70

Complete List of Keywords

SAVE
SAV E dilename>[, diletype>][, <binary parameters>]

SAVE "di scfi Le.xyz"


.... saves the file in normal unprotected BASIC mode.

SAVE "discfiLe.xyz",P
.... saves the file in Protected BASIC mode.

SAVE "discfiLe.xyz",A
.... saves the file in ASCII mode.

SAVE "discfi Le.xyz",B,81H'l0,3000,8001


""saves the file in Binary mode. In this example, saves the area of the computer's
memory starting at address 8 0 0 0; the length of the file being 3 0 0 0 bytes; the
optional entry point address being 8 0 01 .
COMMAND: Saves the program currently in the memory to disc. A Binary file is an
area of memory saved to disc. The Binary parameters are:
<start address> , <file length> [ , <entry point>]
The screen memory can be saved as a Binary file. This is known as a 'screen dump'
and can be performed using the command:

SAVE "screen",B,&C000,&4000
Then, to load it back onto the screen:

LOAD "screen"
Associated keywords: CHAIN, CHAI N MER GE, LOA D, MER GE, RUN

Complete List of Keywords

Chapter 3 Page 71

SGN
S GN ( <numeric expression> )

10 FOR n=200 TO -200 STEP-20


20 PRINT "SGN returns";
30 PRINT SGN(n);"for a vaLue of";n
40 NEXT
run
FUNCTION: Determines the SiG N of the <numeric expression>. S GN returns -1 if
<numeric expression> is less than zero, returns 0 if <numeric expression> equals zero,
and returns 1 if <numeric expression> is greater than zero.
Associated keywords: AB S

SIN
SIN ( <numeric expression> )

10 CLS:DEG:ORIGIN 0,200
20 FOR n=0 TO 720
30 y=SIN(n)
40 PLOT n*64~/720,198*y:NEXT
50 GOTO 50
run
FUNCTION: Calculates the S I Ne ofthe <numeric expression>.
Note that DE G and RA D can be used to force the result of the above calculation to
degrees or radians respectively.
Associated keywords: AT N, COS, DE G, RA D, TAN

Chapter 3 Page 72

Complete List of Keywords

SOUND
SOU ND <channel status> , <tone period>[, <duration> [, <volume>
[, <volume envelope> [ , <tone envelope> [ , <noise period> ]]]]]

10 FOR z=0 TO 4095


20 SOUND 1,z,1,12
30 NEXT
run
COMMAND: Programs a sound. The command takes the following parameters:

Parameter 1: <channel status>


The <channel status> parameter must yield an integer in the range 1 to 255. The
parameter is bit significant, with each bit of the binary value of <channel status>
signifying the following:
Bit 0: (decimal 1) send sound to channel A (Least significant bit)
Bit 1: (decimal 2) send sound to channel B
Bit 2: (decimal 4) send sound to channel C
Bit 3: (decimal 8) rendezvous with channel A
Bit 4: (decimal 16) rendezvous with channel B
Bit 5: (decimal 32) rendezvous with channel C
Bit 6: (decimal 64) hold sound channel
Bit 7: (decimal 128) flush sound channel (Most significant bit)
Hence a <channel status> parameter of 6 8 for example, would mean:
Send to channel C (4), with a hold state (64).

Parameter 2: <tone period>


This parameter defines the pitch of the sound, or in other words, 'what note it is' (i.e.
do re mi fa so, etc). Each note has a set number, and this number is the <tone period>.
See the chapter entitled 'For your reference .... '.

Parameter 3: <duration>
This parameter sets the length of the sound, in other words, 'how long it lasts'. The
parameter works in units of 0.01 (one hundredth) of a second, and if you don't specify
the <duration>, the computer will default to 20 (one fifth of a second).

Complete List of Keywords

Chapter 3 Page 73

If the <duration> parameter is zero, the sound will last until the end of the specified
volume envelope.
If the <duration> parameter is negative, the specified volume envelope is to be
repeated AB S ( <duration times.

Parameter 4: <volume>
This parameter specifies the starting volume of a note. The number is in the range 0
to 15. A <volume> figure of 0 is off, while 15 is maximum. Ifno number is specified, the
computer will default to 12.

Parameter 5: <volume envelope>


To make the volume vary within the duration of the note, you can specify a volume
envelope using the separate command EN V. You can in fact create up to 15 different
volume envelopes referenced in the range 1 to 15. The <volume envelope> parameter
calls up the appropriate volume envelope reference number for use in the SOU ND
command.
Refer to the description of the EN V command.

Parameter 6: <tone envelope>


To make the tone or pitch vary within the duration ofthe note, you can specify a tone
envelope using the separate command ENT. You can in fact create up to 15 different
tone envelopes referenced in the range 1 to 15. The <tone envelope> parameter calls up
the appropriate tone envelope reference number for use in the SOU ND command. If
you have specified a negative envelope number in the ENT command, use the
absolute value of that number (i.e. without the negative sign) in this <tone envelope>
parameter of the SOU NDcommand.
Refer to the description of the ENT command.

Parameter 7: <noise>
A range of white noise is available, which can be switched off or added to the sound by
varying the <noise> parameter between 0 and 31.
Further information concerning sound will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associatedkeywords: ENT, ENV, ON SQ GOSUB, RE LEAS E, SQ

Chapter 3 Page 74

Complete List of Keywords

SPACES
SPA CE$ ( <integer expression

10 MODE 1
20 PRINT "Put 9 spaces between me";
30 PRINT SPACE$(9);
40 PRINT "and you!"
run
FUNCTION: Creates a string of spaces of the given length, (in the range 0 to 255)
specified in the <integer expression>.
Associated keywords: S PC, S T R I NG$, TA 8

SPC
(See P R I NT S PC)

SPEED INK
S P E E DIN K <period 1> , <period 2>

10 BORDER 7,18
20 FOR i=30 TO 1 STEP-1
30 SPEED INK i,i
40 FOR t=1 TO 700:NEXT t,i
run
COMMAND: Sets the rate of alternation between two ink colours specified in an INK
or 80 RDE R command. <period 1> specifies the time, in units of 0.02 (fiftieths) second
for the first colour to be used; <period 2> sets the time for the second colour.
You must exercise careful judgement to avoid mesmeric effects when selecting
colours and repeat rates!
Associated keywords: 80 R DER, INK

Complete List of Keywords

Chapter 3 Page 75

SPEED KEY
SP EED KEY <start delay> , <repeat period>

10 CLS:FOR k=7 TO 1 STEP-2


20 PRINT "type your name, then [RETURN]"
30 SPEED KEY k,k
40 LINE INPUT a$:NEXT
50 PRINT "That's a funny name!"
run
COMMAND: Sets the rate of keyboard auto repeat. The <start delay> parameter
specifies the time, in units of 0.02 (fiftieths) second before auto repeat starts. The
<repeat period> parameter sets the interval between each auto repeat of a key.
S P EED KEY will operate only on keys which auto repeat by default, or which have
been set to auto repeat by the KEY DE F command.

When intending to use small values of <start delay>, it is wise to pre-program one of
the numeric keys to return the keyboard to its default SP EED KEY setting of
30,2. This can be achieved by the command:

KEY 0,"SPEED KEY 30,2"+CHR$(13)


.... which will reset S PE ED KEY to its default values when the 0 key on the
numeric keypad is pressed.
Associated keywords: KEY DE F

SPEED WRITE
S PE ED WR I T E dnteger expression>

SPEED WRITE 1
COMMAND: Sets the speed at which data is to be saved or written to a cassette unit
(if connected). The cassette can be written at either 2000 baud (bits per second) ifthe
<integer expression> is 1, or at the default rate of 1000 baud ifthe <integer expression>
is O. When loading a file from tape, the computer automatically selects the correct
reading speed as it loads.
For higher data reliability, it is recommended that you use S PE ED WRI T E 0
(default).
The S P E ED WR I T E command has no effect upon disc operation.
Associated keywords: 0 PEN 0 UT, SAV E
Chapter 3 Page 76

Complete List of Keywords

SQ
S Q ( <channel

10 SOUND 65,100,100
20 PRINT SQ(1)
run
67
FUNCTION: Reports the state of the Sound Queue for the specified <channel> which
must be an integer expression, yielding one ofthe values:
1 : for channel A
2 : for channel B
4 : for channel C
The S Q function returns a bit significant integer, comprising the following bit
settings:
.
BitsO,1,and2
Bits 3, 4, and 5
Bit6
Bit 7

: the number offree entries in the queue


: the rendezvous state at the head of this queue
: the head of the queue is held
: the channel is currently active

.... where BitO is the least significant bit, and Bit 7 is the most significant bit.

It can be seen therefore, that if Bit 6 is set, Bit 7 cannot be set, and vice versa.
Similarly if Bits 3, 4, or5 are set, Bits 6 and 7 cannot be set.
Further information concerning sound will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: 0 N S Q GO SUB, SOU ND

SQR
S QR ( <numeric expression> )

PRINT SQR(9)
3
FUNCTION: Returns the S Quare Root of the specified <numeric expression>.
Associated keywords: none

Complete List of Keywords

Chapter 3 Page 77

STEP
(See FOR)

STOP
STOP

10 FOR n=1 TO 30:PRINT n:NEXT


20 STOP
30 FOR n=31 TO 60:PRINT n:NEXT
run
cont
COMMAND: Stops execution of a program, but leaves BASIC in a state where the
program can be resumed by the CON T command. S TOP may be used to interrupt the
program at a particular point when de-bugging.
Associated keywords: CON T, END

STR$
S T R$ ( <numeric expression> )

10 a=&FF :REM 255 hex


20 b=&X1111 :REM 15 binary
30 c$="***"
40 PRINT c$+STR$(a+b)+c$
run
*** 270***
FUNCTION: Converts the <numeric expression> to a decimal STRing representation.
Associated keywords: BIN $, DE C$, HEX $, VA L

Chapter 3 Page 78

Complete List of Keywords

STRING$
S T RI NG$ ( <length> , <character specifier> )

PRINT STRING$(40,"*")
****************************************
FUNCTION: Returns a string expression consisting of the specified character
repeated the number of times (in the range 0 to 255) specified in the <length>. Note
that the above example could be entered as:

PRINT STRING$(40,42)
****************************************
.... where the <character specifier> 42 refers to the ASCII value of the character
equivalent to PR I NT S T RI NG$ ( 40, CH R$ ( 42) ) .

* i.e.

Associated keywords: SPA CE$

SWAP
(See WIN D0 W S WAP)

SYMBOL
S YMB0 L <character number> , <list of: <row>

10 MODE 1 :SYMBOL AFTER 105


20 row1=255:REM binary 11111111
30 row2=129:REM binary 10000001
40 row3=189:REM binary 10111101
50 row4=153:REM binary 10011001
60 row5=153:REM binary 10011001
70 row6=189:REM binary 10111101
80 row7=129:REM binary 10000001
90 row8=255:REM binary 11111111
100 PRINT "Line 110 re-defines the Letter i (105),
Type in some i IS and see! Then List the program."
110 SYMBOL 105,row1,row2,row3,row4,row5,row6,row7,row8
run
COMMAND: Re-defines the shape of a character on the screen. Each of the
parameters must yield an integer in the range 0 to 255.

Complete List of Keywords

Chapter 3 Page 79

To allocate space in the CPC612S's memory for a newly defined character, the
computer must first be prepared by issuing the command:

SYMBOL AFTER

.... where x is equal to or less than the character number you wish to re-define.
The command S YMB0 L is then issued, followed firstly by the character number x.
Regardless of whether or not the value of x specifies a character which is directly
typeable at the keyboard, the re-defined character can be printed on the screen by
issuing the command:
PRINT CHR$(x)

After S YMB0 L x, there are up to S parameters which specify the S individual


horizontal rows of the character, starting from the top. Each of the parameters can be
in the range 0 to 255. The binary representation of each of the S parameters
determines the pattern of that particular row in the finished character.
For example, if the first ofthe S parameters is 1, then the top row ofthe character has
a binary representation of 00000001. Where the 1 appears, the section of the
character is printed in the PEN colour; where a 0 appears, the section of the character
is not visible because it is printed in the PA PER colour. Therefore the top row of this
newly defined character has a dot in the top right hand corner. Continuing this
example, we will specify the other 7 parameters as 3, 7 , 1 5 , 3 1 , 63 , 0, 0 - the
binary representation of aIlS parameters then being:
parameter (row) 1: 00000001 binary: (decimal 1)
parameter (row) 2: 00000011 binary: (decimal 3)
parameter (row) 3: 00000111 binary; (decimal 7)
parameter (row) 4: 00001111 binary: (decimal 15)
parameter (row) 5: 00011111 binary: (decimal 31)
parameter (row) 6: 00111111 binary: (decimal 63)
parameter (row) 7: 00000000 binary: (decimal 0)
parameter (row) S: 00000000 binary; (decimal 0)
Looking at the binary representation of the above S parameters, it should be possible
to see what the shape of the new character is going to be like. Let's assign those
parameters to character number 255 using the command:

SYMBOL 255,1,3,7,15,31,63,0,0

Chapter 3 Page 80

Complete List of Keywords

Note that the value of 0 appearing in the 2 final parameters means that you need
only type in:

SYMBOL 255,1,3,7,15,31,63
Note that you can enter the parameters in binary to save you converting the 'pattern'
of the symbol that you've created into decimal form. (Remember to use the &Xbinary
prefix.) For example:

SYMBOL 255,&X00000001,&X00000011,&X00000111,
&X00001111,&X00011111,&X00111111
.... Now, to see the character:

PRINT CHR$(255)
Assigning the above parameters to a typeable character on the keyboard would result
in the new character appearing whenever the appropriate key is pressed, or wherever
the previous character would have been printed. Furthermore, BASIC will not reject
this new character as incomprehensible, but will regard it as the equivalent of the
previous character.
Further information concerning user-defined characters will be found in part 2 of the
chapter entitled 'At your leisure .... '.
Associated keywords: S YMB0 L AFT E R

SYMBOL AFTER
S YMB0 L AFT E R <integer expression>

10 CLS
20 SYMBOL AFTER 115
30 PRINT "Line 40 re-defines the s ";
40 SYMBOL 115,0,56,64,64,48,8,8,112
50 PRINT "to s"
60 PRINT "Cancel this defintion of s,"
70 PRINT "by typi ng: SYMBOL AFTER 240"
run
COMMAND: Sets the number of permissible user defined characters (in the range 0
to 256). The default setting is 240, giving 16 user defined characters (from 240 to 255).
If the <integer expression> is 32, then all characters from 32 to 255 are re-definable ..
S YMB0 L AFT ER 256 permits no characters to be re-definable.
Whenever a S YMB0 L AFT E R command is executed, all user defined characters
are reset to their default conditions.

Complete List of Keywords

Chapter 3 Page 81

SYMB0 L AFT E R will NOT operate if invoked AFTER the value of HI MEMhas
been altered using the ME M0 RY command, or by the opening of a file buffer with
OPENI Nor OPENOUT. Under such circumstances, an 'Imprope r argument'
error (5) will be reported, (unless the previous state was S YMBO L AFT E R 256).
Further information concerning user-defined characters will be found in part 2 ofthe
chapter entitled 'At your leisure .... '.
Associatedkeywords: HI MEM, MEMO RY, S YMBO L

TAB
(See P R I NT TAB)

TAG
TAG [# <stream expression>]

10 INPUT "enter your name";a$:CLS


20 PRINT "You certainLy get around ";a$
30 TAG
40 x=LEN(a$)*17:y=50+RND*300:MOVE -x,y
50 FOR f=-x TO 640 STEP RND*7+3
60 MOVE f,y:PRINT " ";a$;:FRAME:NEXT
70 FOR b=640 TO -x STEP-RND*7+3
80 MOVE b,y:PRINT a$;" ";:FRAME:NEXT
90 GOTO 40
run
COMMAND: Sends any text specified for the given <stream expression> to be printed
at the graphics cursor position. This allows text and symbols to be mixed with
graphics, or moved pixel by pixel as opposed to character by character. The <stream
expression> defaults to # 0 if omitted.
The top left ofthe character cell is TAGged (Text At Graphics) to the graphics cursor,
and non-printing control characters (e.g. line feed and carriage return) will display if
the PR I NT statement is not terminated by a semicolon.
In the default stream (# 0), BASIC will switch off TAG when returning to direct
mode.
Associated keywords: TAG 0 F F

Chapter 3 Page 82

Complete List of Keywords

TAGOrr
TAG 0 F FI # <stream expression> I

10 MODE 2:TAG :REM Text At Graphics-on


20 year=1984:FOR x=1 TO 640 STEP 70
30 MOVE x,400:DRAWR 0,-350
40 year=year+1:PRINT year;:NEXT
50 TAGOFF :REM Text At Graphics-OFF
60 LOCATE 34,25:PRINT "YearLy figures"
70 GOTO 70
run
COMMAND: Cancels TAG (Text At Graphics) for the given <stream expression>
(stream # 0 if not specified), and re-directs text to the previous text cursor position
used before TAG was invoked.
Associated keywords: TAG

TAN
TAN numeric expression

PRINT TAN(45)
1.61977519
FUNCTION: Calculates the TANgent ofthe <numeric expression>, which must be in
the range - 200000 to + 200000.
Note that DE G and RA D can be used to force the result of the above calculation to
degrees or radians respectively.
Associated keywords: AT N, COS, DE G, RA D, SIN

Complete List of Keywords

Chapter 3 Page 83

TEST
T EST ( <x co-ordinate> , <y co-ordinate> )

10 CLS
20 PRINT
30 PRINT
40 PRINT
50 PRINT
run

"You are using pen number";


TEST<10,386)
"Try changing PENs and MODEs";
" .. then RUN again."

FUNCTION: Moves the graphics cursor to the absolute position specified by the <x
and y co-ordinate>s, and reports the value of the ink at the new location.
Associated keywords: MOV E, MOV ER, T ES T R, X POS, YPOS

TESTR
T EST R ( <x offset> , <y offset> )

10 MODE 0:FOR x=1 TO 15:LOCATE 1,x


20 PEN x:PRINT STRING$(10,143);:NEXT
30 MOVE 200,400:PEN 1
40 FOR n=1 TO 23:LOCATE 12,n
50 PRINT "pen";TESTR(0,-16):NEXT
run
FUNCTION: Moves the graphics cursor by the amount specified in the <x and y
offset>s relative to its current position, and reports the value of the ink at the new
location.
Associated keywords: MOV E, MOV ER, T EST, X POS, Y PO S

THEN
(See I F)

Chapter 3 Page 84

Complete List of Keywords

TIME
TIME

10 CLS:REM clock
20 INPUT "hour";hour
30 INPUT "minute";minute
40 INPUT "second";second
50 CLS:datum=INT(TIME/300)
60 WHILE hour<13
70 WHILE minute <60
80 WHILE tick<60
90 tick=(INT(TIME/300)-datum)+second
100 LOCATE 1,1
110 PRINT USING "## ";hour,minute,tick
120 WEND
130 tick=0:second=0:minute=minute+1
140 GOTO 50
150 WEND
160 minute=0:hour=hour+1
170 WEND
180 hour=1
190 GOTO 60
run

FUNCTION: Reports the elapsed time since the computer was last switched-on or
reset, (excluding periods when reading or writing to disc).
Each second of real time is equal to the returned value: T I ME / 3 ee.
Associated keywords: AFT ER, EVE RY, WEN D, WHI LE

TO
(See FOR)

Complete List of Keywords

Chapter 3 Page 85

TRorr
TRON
TROFF
TRON

113 TROFF:PRINT:PRINT "TRace-OFF"


213 FOR n=1 TO 8
313 PRINT "program runn;ng":NEXT
413 IF f=1 THEN END
513 TRON:PRINT:PRINT "TRace-ON"
613 f=1:GOTO 213
run
COMMAND: Traces the execution of a program by printing each line number before
carrying it out. The line number appears inside square brackets [ ] .
T R0 Nswitches TRace 0 N; T R0 F F switches TRace 0 F F.
The facility is particularly useful for studying the sequence of program line execution
just before an error occurs.
Associated keywords: none

UNT
UN T ( <address expression> )

PRINT UNT<&FF66)
-154
COMMAND: Returns an integer in the range -32768 to +32767 which is the
twos-complement equivalent of the unsigned value of the <address expression>.
Associatedkeywords: Cl NT, F I X, I NT, ROU ND

UPPER$
UP PER $ ( <string expression> )

113 CLS:a$="my, how you've grown!"


213 PRINT UPPER$(a$)
run
FUNCTION: Returns a new string expression which is a copy of the specified <string
expression> but in which all alphabetic characters in the range A to Z are converted to
upper case. The function is useful for processing input which may come in mixed
upper/lower case.
Associated keywords: LOW E R$

Chapter 3 Page 86

Complete List of Keywords

USING
(See P RI NT USIN G)

VAL
VA L ( <string expression> )

10 CLS:PRINT "I know my times tables!"


20 PRINT:PRINT "Press a key (1 to 9)"
30 a$=INKEY$: IF a$="" THEN 30
40 n=VAL(a$):IF n<1 OR n>9 THEN 30
50 FOR x=1 TO 12
60 PRINT n;"X";x;"=";n*x
70 NEXT:GOTO 20
run
FUNCTION: Returns the numeric VA Lue, (including any negative sign and decimal
point) of the first character(s) in the specified <string expression>.

If the first character is not a number, then 0 is returned. If the first character is a
negative sign or decimal point followed by non-numeric characters, a 'T y P e
m; s mate h' error (13) will be reported.
Associated keywords: S T R$

VPOS
VP 0 S ( # <stream expression> )

10 MODE 1:BORDER 0:LOCATE 8,2


20 PRINT "use cursor up/down keys"
30 WINDOW 39,39,1,25:CURSOR 1,1
40 LOCATE 1,13
50 IF INKEY(0)<>-1 THEN PRINT CHR$(11);
60 IF INKEY(2)<>-1 THEN PRINT CHR$(10);
70 LOCATE #1,3,24
80 PRINT #1,"text cursor ";
90 PRINT #1,"vertical position =";
100 PRINT #1,VPOS(#0):GOTO 50
run
FUNCTION: Reports the current Vertical PO Sition of the text cursor relative to the
top of the text window. The <stream expression> MUST be specified, and does NOT
default to #0.
Associated keywords: PO S, WIN D0 W
Complete Licot of Keywords

Chapter 3 Page 87

WAIT
WA I T <port number, , <mask,[, <inversion,]

WAIT &FF34,20,25
COMMAND: Waits until the specified 1/0 <port number, returns a 'particular value
in the range 0 to 255. BASIC loops whilst reading the 110 port. The value read is
eXclusive 0 Red with the <inversion, and then AN Ded with the <mask, until a
non-zero result occurs.
BASIC will wait indefinitely until the required condition occurs.
Not a command to be used by the unwary.
Associated keywords: I NP, OU T

WEND
WEND

WEND
COMMAND: Marks the end of the body of program which is to be executed within the
WHI LE loop. WEN D automatically selects the WHI LE command it is to be associated
with.
Associated keywords: T I ME, WHI LE

WHILE
WHI LE <logical expression,

10 CLS:PRINT "Ten second timer":t=TIME


20 WHILE TIME<t+3000
30 SOUND 1,0,100,15
40 WEND:SOUND 129,40,30,15
run
COMMAND: Repeatedly executes a body of program while a given condition is true.
The WHI LE command defines the head ofthe loop, and specifies the condition in the
<logical expression,.
Associated keywords: T I ME, WEN D

Chapter 3 Page 88

Complete List of Keywords

WIDTH
WI DT H <integer expression>

WIDTH 40
COMMAND: Tells BASIC how many characters per line are to be printed when a
printer is connected. BASIC will then send the extra carriage return/line feed at the
appropriate time.
The computer assumes a default value of 1 32 unless a WI DT Hcommand is specified.
The command WI DT H 2 5 5 suppresses the extra carriage return/line feed
altogether, allowing printing to be 'line wrapped' by the printer. Note that carriage
returnlline feed will still be generated by a PR I NT command that isn't terminated
by a semicolon or comma.
Associated keywords: PO S

WINDOW
WIN DO W[# <stream expression> , ]<left> , <right> , <top> , <bottom>

10 MODE 0:BORDER 0:REM testcard


20 INK 0,0:INK 1,25:INK 2,23:INK 3,21
30 INK 4,17:INK 5,6:INK 6,2:INK 7,26
40 PAPER 0:CLS
50 PAPER 1:WINDOW 2,4,1,18:CLS
60 PAPER 2:WINDOW 5,7,1,18:CLS
70 PAPER 3:WINDOW 8,10,1,18:CLS
80 PAPER 4:WINDOW 11,13,1,18:CLS
90 PAPER 5:WINDOW 14,16,1,18:CLS
100 PAPER 6:WINDOW 17,19,1,18:CLS
110 PAPER 7:WINDOW 2,19,19,25:CLS
120 GOTO 120
run
COMMAND: Specifies the dimensions ofa text stream (W I NDOW) on the screen. The
values of the parameters <left>, <right>,<top>, and <bottom> should correspond with the
inclusive screen character locations consistent with the screen MOD E in use:

If the <stream expression> is not specified, BASIC defaults to stream # 0.


Further information concerning windows will be found in part 2 of the chapter
entitled 'At your leisure .... '.
Associated keywords: WIN DO W SW A P

Complete List of Keywords

Chapter 3 Page 89

WINDOW SWAP
WIN D0 W SW AP <stream expression> , <stream expression>

10 MODE 1:INK 1,24:INK 2,9:INK 3,6


20 WINDOW 21,40,13,25:PAPER 3
30 WINDOW #1,1,20,1,12:PAPER #1,2
40 CLS:PRINT " window number 0"
50 CLS #1:PRINT #1," window number 1"
60 LOCATE 1;6
70 PRINT" red window (0)";SPC(2)
80 LOCATE #1,1,6
90 PRINT #1," green window (1)"
100 FOR t=1 TO 1000:NEXT
110 WINDOW SWAP 0,1:GOTO 60
run
COMMAND: Swaps the text window specified in the first <stream expression> with
that specified in the second <stream expression>.
Both <stream expression>s must be specified, and in this case should NOT be preceded
by a # stream director.
The command may be used to re-direct messages produced by BASIC,which are
normally always sent to stream # 0.
Further information concerning windows will be found in part 2 of the chapter
entitled 'At your leisure .... '.
Associated keywords: WIN D0 W

WRITE
WR I T E [# <stream expression> ,][ <write list>]

10 REM write variabLes onto disc


20 INPUT "give me a number variabLe";a
30 INPUT "give me a string variabLe";a$
40 OPENOUT "datafiLe"
50 WRITE #9,a,a$
60 CLOSEOUT:PRINT "Data saved onto disc"
run
COMMAND: Writes the values ofthe items in the <write list> to the stream specified
in the <stream expression> . Items written will be separated by commas; strings will be
enclosed by double-quotes.
Chapter 3 Page 90

Complete List of Keywords

In this example the values of the variables which you input, are written to stream # 9
(the disc stream).
(To recall the values of those variables from disc, it would be necessary to use a
program such as follows:)

10 REM retrieve variabLes from disc


20 OPENIN "datafi Le":INPUT #9,a,a$
30 CLOSEIN:PRINT "The 2 vaLues are:"

40 PRINT:PRINT a,a$
run
Associatedkeywords: IN PUT, L IN E I NPUT

XOR
<argument> X0 R <argument>
IF "aLan"<"bob" XOR "dog">"cat" THEN PRINT "correct" ELSE PRINT "wrong"
wrong
IF "bob"<"aLan" XOR "cat">"dog" THEN PRINT "correct" ELSE PRINT "wrong"
wrong
IF "aLan"<"bob" XOR "cat">"dog" THEN PRINT "correct" ELSE PRINT "wrong"
correct

PRINT

XOR

PRINT 0 XOR 0
0

PRINT

XOR 0

OPERATOR: Performs bit-wise boolean operation on integers. Result is 1 unless both


argument bits are the same - eXclusive 0 R.
Further information concerning logic will be found in part 2 of the chapter entitled
'At your leisure .... '.
Associated keywords: AND, 0 R, NOT
Complete List of Keywords

Chapter 3 Page 91

XPOS
XPOS

10 MODE 1:DRAW 320,200


20 PRINT "graphics cursor X POSition=";
30 PRINT XPOS
run
FUN CTI 0 N: Reports the current horizontal (X) PO Sition of the graphics cursor.
Associatedkeywords: MOV E, MOV ER, 0 RIG I N, YPO S

YPOS
YPOS

10 MODE 1:DRAW 320,200


20 PRINT "graphics cursor Y POSition=";
30 PRINT YPOS
run
FUN CTI 0 N: Reports the current vertical (Y) PO S ition of the graphics cursor.
Associated keyword:;;: M0 VE, M0 VER, 0 RIG IN, XP 0 S

ZONE
Z0 NE (integer expression>

10 CLS:FOR z=2 TO 20
20 ZONE z
30 PRINT "X","X ZONE =";z:NEXT
run
COMMAND: Changes the width of the print zone (specified in PR IN T statements by
using a comma between print items). The default setting of the print zone is 13
columns, but may be changed as specified in the <integer expression> in the range 1 to
255.
Associated keywords: PR I NT

Chapter 3 Page 92

Complete List of Keywords

Chapter 4
Using Discs and Cassettes
Part 1: Discs
Making working discs
This section discusses how to make discs to use from day to day,
and introduces some facilities ofCPIM and its Utility programs.
Subjects covered:

**
*'*
**
**
**

Making a backup of the Master Discs.


Getting started with CPIM Plus.
Use of Help files.
Single and Multiple drive operation.
Copying files with PIP.
Operating with a BASIC only disc.
Turnkey AMSTRAD BASIC application.
Installing a Turnkey CPIM Plus application.
Getting Started with GSX.
Operating with CPIM 2.2.

Part 7 of the Foundation course described how to format a blank system disc, which
you can use for BASIC and games, as well as CP/M.
Part 10 of the Foundation course showed you how to make exact copies of discs with
the DI S CKIT 3 program (on Side 1 of your system discs package).
This section considers how to use discs with the programs that you want on them.

Using Discs and Cassettes

Chapter 4 Page 1

Backup Master Discs


It is most important to make a copy of the Master System/Utility discs provided with
your computer, and keep the originals safe - they will be very costly to replace if
damaged! Remember that each of the discs supplied has two sides, making four sides
in total. Every' disc, in fact, has two sides and you are free to use either side for any
purposes.
Side 1 is the most important - it contains the master copy of CP/M Plus and a set of
utility programs for handling discs. Side 2 has files for assembler programmers, and
Side 3 contains Dr. LOGO, 'Help' files, and GSX (more of which later!). Side 4
contains the CP/M 2.2 and the Dr. LOGO previously available for the AMSTRAD
models CPC664 and CPC464+ DDI1; these programs are provided for compatibility
reasons, just in case you need them. Normally they are not used.
You should regard your copies of the master discs as a 'library' of programs.
Normally, you will select the program that you require by inserting the 'library disc'
on which the program is located, rather than by copying the program onto a blank
disc and running it from there.
Once again, it has to be emphasised that the 'library discs' that you use, MUST BE
COPIES, made from the master discs package supplied with the computer.
Remember that if you are usinK a new blank disc to copy onto, the DI S CKIT 3
program (on Side 1) will format for you as well as doing the copying.

Getting started with CP/M Plus


You will be used to AMSTRAD BASIC appearing when your CPC6128 is switched on.
The BASIC will remain in charge until superseded by either a BINary program run
from AMSDOS (or cassette), or by loading CP/M PI us with the command I CPM.
Once CP/M Plus is loaded, the CPC6128 will not need to refer to Side 1 again - unless
of course, you want to run any of the utility programs contained on it. Only the
start-up disc need be a System disc; all others can be Data-only discs, which have a
greater storage capacity.
Running a program is simply a case of inserting the disc containing the required
program and typing its name. Data used by the program may be on the same, or other,
disc as the program. CP/M Plus allows the user to swap discs in the same way that
AMSDOS does. If a number of programs, with perhaps a few utilities, are required on
one disc for convenience, then use the program called PIP on Side 1, as described
later in this chapter and in Chapter 5.

Chapter 4 Page 2

Using Discs and Cassettes

Maintaining a Hi profile!
The system disc provides a special file called PRO F I LE. SUB, which contains a list
of commands that are executed automatically when CP/M Plus is started. You may
then (if you have not already done so) insert a COPY of Side 1 of the System discs, and
at the A>prompt, type:

REN PROFILE.SUB=PROFILE.ENG
.... which creates the file PRO F I LE. SUB from PRO F I LE. EN G. This profile, which
will be acted on next time CP/M Plus is started, contains the commands:

SETKEYS KEYS.CCP
LANGUAGE 3
.... to set the cursor keys to be suitable for typing CP/M commands, and to convert the
screen output to UK (from USA), effectively making [SHIFn3 display as a '' symbol.
When the keyboard has been set up with the SET KEY S KEY S CCP command,
then CP/M command lines can be edited in much the same way as a line of BASIC.
Full details of SET KEY S are given in Chapter 5 part 2.

A Helping Hand
Side 3 of your system discs package has a special program called 'Help' which is
designed to be an electronic instruction manual for CP/M Plus utility programs. To
activate this facility, insert Side 3 and type, at the A> prompt:

HELP
.... and the 'Help' program will prompt you with further questions, guiding you to the
information you require.

One Drive or Two?


When CP/M Plus is first loaded, it detects the number of disc drives attached. This
number is displayed as part of the sign-on message. Note that the process can be
fooled if the second drive has a disc partially inserted.
All error messages relating to the disc mechanisms are displayed by default, as a
banner on the 25th line of the screen. The programs themselves use only the first 24
lines of the screen.

Using Discs and Cassettes

Chapter 4 Page 3

When you have only one built-in drive, the bottom line will also display the message
'D r i ve i sA:' or 'D r i ve i s B: '. This is CP/M Plus allowing you to work
with one physical mechanism as if it was two. You will have two discs to alternate
between, and the bottom line of the screen will prompt you to insert the correct disc as
the program requires it. This mode of operation avoids the need to purchase a second
disc drive, but often requires considerable swapping of discs, which is
time-consuming and introduces the possibility of human error.

Copying files from disc to disc


A standard utility program called PIP (Peripheral Interchange Program)
provided to copy files from one disc to another.

IS

First load PIP from Side 1, by typing at the A> prompt:

PIP

.... then a new prompt will show that PIP has loaded correctly. Normally, you will
copy files from a Source disc (in Drive A:) to a Destination disc (in Drive B :). We
have already seen that in a single drive system, Drives A: and B: are the same
mechanism.
To copy one file, for example SUB MIT. CO M, type after the * prompt:
B:=A:SUBMIT.COM

To copy all the files from the Source disc to the Destination disc use the command:

8:=*.*
To exit from PIP, press [RETURN] at the * prompt.

PIP is a very sophisticated program, and further details of its operation appear in
Chapter 5.

A BASIC only disc


As already described, a System disc is normally only used as the disc for starting up
CP/M Plus. Discs used,for BASIC can therefore be Data-Only discs, which have a
slightly greater capacity.
The disc must be formatted using the DI S CKIT 3 program. To copy programs onto
this type of disc, you must use PIP (loaded from Side 1), or LOA D and S AVE them
from BASIC.
Chapter 4 Page 4

Using Discs and Cassettes

Turnkey AMSTRAD BASIC discs


If you buy an application program written in AMSTRAD BASIC for the CPC6128, it
should be ready to operate when you switch on. (The expression 'turnkey' comes from
the days when all small computers had a key-operated power switch). As with the
Master system discs package supplied with the CPC6128, it is strongly recommended
that you keep the original safe, and work from a copy.

Turnkey CP/M discs


The CP/M operating system allows you to load and run an immense library of
software which has already been written for personal computers that support CP/M.
The fundamental 'logic' of these programs has already been devised; all that is
required to use them on your 6128 is to establish them on a suitable disc, and maybe
to inform them of the particular method that the 6128 uses to operate the screen.
A set of programs on one disc designed to fulfil a specific application is called a
'package'. These packages are normally designed to work on a large ra:t:lge of different
computers, each of which has its own size of screen and way of moving the cursor
around.
The 6128 is provided with a built-in 'terminal emulator' when running CP/M Plus
programs, and the characteristics are different from the Control Codes supported by
BASIC.
Sometimes the package that you buy will have already been 'installed' for the
AMSTRAD system, or cater for it by offering an installation compatible with the
6128. If available, simply follow the instructions provided with the software for a
Zenith Z19/Z29 protocol. If the package does not have this, nor a specific AMSTRAD
variant built in, then the section ahead entitled 'Configuring a CP/M Program'
indicates some of the commands that can be sent to the 6128 screen to produce the
sorts of effects that packages require. Normally, the installation, or customisation,
procedure will involve typing in the relevant codes when requested to. Again, follow
the instructions provided with the package.
The software you have purchased must be on a disc suitable for use in this system.
Almost every different computer uses a different form of disc. Although many have
the same size of disc, this does not necessarily mean that there is any compatibility
between one and another in the information contained on them. Ask your supplier for
an AMSTRAD 3 inch version.

Using Discs and Cassettes

Chapter 4 Page 5

Creating a Turnkey CP/M disc


As well as the application program itself, it is often useful to have the utilities
SET KEY S CO M and perhaps SUB MIT. CO M (with their associated instruction
files) on the Turnkey disc.

PIP can be used to transfer the . C0 Mfiles and also to make the instruction file for
SUB MIT. In this latter mode, PIP is effectively a simple one-line-at-a-time editor.
For example, the file LOG 03 . SUB on Side 3 could have been created with the
following commands:
(Insert System disc, Side 1 in Drive A : ). Type:

PIP
(Remove System disc, insert destination disc). Type:

LOG03.SUB=CON:
SETKEYS KEYS.DRL
[CONTROL]J LOG 0 3
[CONTROL]Z

Configuring a CP/M Program


The CPC6128 supports a wide range of control codes suitable for customising a
software package to run with CP/M. Most data-processing and many other packages
require to be able to print messages at any part ofthe screen, to accept input from any
part ofthe screen and to generally understand cursor controls.
If your package has already been customised for the AMSTRAD system, then you
need not concern yourself further.

Configuring the Output from the package


The installation procedure for a package will normally consist of running a special
program (often called INS TAL) which, ifit does not support either a Z19/Z29 type of
terminal or the CPC6128 specifically, will ask a number of questions about the
parameters of the 6128 screen. The answers should be derived from the table
over leaf, which is an extract from Chapter 7 part 15.

Chapter 4 Page 6

Using Discs and Cassettes

Control
Codes

Hex

[BEL]
[BS]
[LF]
[CR]

&07
&08
&OA
&OD

Decimal
7
8
10
13

[ESC]A
[ESC]C
[ESC]E
[ESC]H
[ESC]J

&lB
&lB
&lB
&lB
&lB

[ESC]K

&lB &4B

[ESC]L
[ESC]M
[ESC]N
[ESC]Y

&lB
&lB
&lB
&lB
<c>

[ESC]d

&lB &64

27 100

[ESC]o

&lB &6F

27 111

[ESC]p
[ESC]q

&lB &70
&lB &71

27 112
27 113

&41
&43
&45
&48
&4A

&4C
&4D
&4E
&59
<r>

27
27
27
27
27

65
67
69
72
74

27 75
f

27
27
27
27
<c>

76
77
78
89
<r>

Operation
Sound Bleeper.
Move cursor back one position.
Move cursor down one line.
Move cursor to left edge of window on
current line.
Move cursor up one line.
Move cursor forward one position.
Clear screen.
Home cursor.
Clear from and including the current
cursor posi tion to end of screen.
Clear from and including the current
cursor position to right edge of screen.
Insert Line.
Delete line.
Delete character at cursor position.
Move cursor to given position on
screen. <c> is column + 32,
<r> is row + 32.
Clear from start of screen to and
including the current cursor position.
Clear from left edge of screen to and
including the cursor position.
Enter inverse video.
Exit inverse video.

Configuring the Input to the package


The programs in the package will expect to be able to interrogate the keyboard. Most
ofthe keys on the 6128 keyboard return standard values except for the cursor keys. It
is possible to use the SET KEY S utility to re-define the codes produced by the
keyboard, although where possible, it is preferable for each different package to be
configured to accept standard values.
It is an unfortunate fact that there is not a general understanding between different
items of software as to which keystroke to use for control functions. Printable
characters, and 'space', [TAB] and [RETURN] are fairly universal, but disagreement
sets in with 'backspace', and from there-on, matters get worse! Compare for example,
the different codes expected for the operation 'move cursor to start ofline':

CP/M Commands require: [CONTROl]B


Dr. LOGO requires: [CONTROl]A
.... and a typical wordprocessor might require: [CONTROl]Q S
Using Discs and Cassettes

Chapter 4 Page 7

Three useful sets of keyboard codes are provided as standard. Each configuration can
be called up from files contained on Side 1 of your system discs package:

SETKEYS KEYS.CCP
.... already described as one of the commands automatically sent by PRO F I LE. SUB,
will set up the keyboard suitably for CP/M commands.

Starting a Turnkey CP/M Package


Normally, all that is required is to type the package's main program name at the A>
prompt. For example to run a wages program called PAY R0 LL CO M, simply type:

PAYROLL
If any configurations require to be set up then perhaps a SUBmit file will be provided.
An example of this is the file LOG 0 3 SUB on Side 3. This is invoked with the
command:

SUBMIT'LOG03
The contents of the file can be seen by typing:

TYPE LOG03.SUB
.... which gives:

SETKEYS KEYS.DRL
LOG03
SETKEYS KEYS.CCP

.... to re-assign the keyboard.


.... to run the Dr. LOGO program.
.... to restore the keyboard.

Autostarting a Turnkey CP/M Package


It is possible to arrange for the CP/M Plus operating system to automatically run a
particular program from the start-up system disc. This is performed by including the
program's name at the end ofthe PRO F I LE. SUB file on that disc.

Chapter 4 Page 8

Using Discs and Cassettes

Getting started with GSX


GSX is a Graphics System eXtension which allows a CP/M program to output
graphics as well as text. It is used to draw such things as bar and pie charts, and write
headings in alternative typestyles and sizes. On the next page is a reproduction of
actual output illustrating this facility. GSX allows output to the screen, to a printer,
or to a pen plotter.
The GSX itself does not have the ability to draw pictures, any more than CP/M can do
word processing; a dedicated applications program is required. The example was
drawn using the Digital Research program 'DR Graph'. What GSX dos do, however,
is provide standard facilities for screens, printers, and plotters, so that applications
programs can be moved from one maclline to another with a minimum of
re-installation.
To create a disc suitable for running GSX programs, copy (from Side 3) the files
GS X S YS, ASS I GN. S YS, and the required device drivers, (together with the
application program itself) onto a blank formatted disc, using PIP. The file
ASS I GN S Y S contains a 'recipe' of up to three output device drivers, in reverse
order oftheir size:
21a:ddfxLr7
11a:ddhp7470
01a:ddmode2
02 a: ddmode 1
03 a: ddmode0

; Epson 7 bit printer


; pen plotter
; screen in mode 2
; screen in mode 1
; screen in mode 0

The numbers tell GSX what type of device driver each is - (Printer/Plotter/Screen).
Only one device driver at a time is actually loaded into the same area of memory,
which is why GSX needs to know how big the largest is first, in order to allocate
enough space.
A selection of drivers is provided for various 6128 screen modes, and for standard
printers. The file DRI VE RS GS X contains a summary of the ones provided with the
6128. You should read this file by inserting Side 3 and after the A> prompt, typing:
TYPE DRIVERS.GSX

... .in order to select suitable device drivers.


Most applications programs will include a GSX loader so all that you need do is type
the program name at the A> prompt. If your application do~s not have the GSX loader
installed, then copy the file GEN GRAF. CO M (from Side 3) onto your GSX working
disc, and type:
GENGRAF YOURFILE

.... where YOU R F I LE. CO M is the un-installed application. The file GENGRAF. CO M
can now be ERAsed, as YOU R F I LE. CO Mnow includes the GSX loader.
Using Discs and Cassettes

Chapter 4 Page 9

Test Diagram
Ken's wages in pence
fi 11 2 1121121.121121

10121.121121 Ti 11 121
fi 11 7 15121.121121

1121121.0121 fi 11 3
fill 4
Till 5 5121.121121

An example of GSX printer output

Working with CP/M 2.2


In contrast to CP/M Plus, CP/M 2.2 (which is a previous version) is very strict about
changing discs, and often requires you to re-load parts of the operating system from a
System Disc in Drive A: particularly when the A> prompt is returned to after
running a program. It is therefore normal to use System Discs. The single drive file
copier F I LEe 0 P Yhas to be used instead of PIP if you do'not have a second drive.

It is only recommended that you use CP/M 2.2 if you have software already running
on AMSTRAD models CPC664 or CPC464+ DDIl, whose software is not, in some
way, compatible with CPIM Plus.
Warning Some CPC664/CPC464+ DDI-l CP/M 2.2 Applications Software
contains certain installation-specific instructions, and will not operate with
CP/M Plus. In these cases it will be necessary to use the CP/M 2.2 contained on
Side 4 of your system discs package.

Chapter 4 Page 10

Using Discs and Cassettes

Part 2: Cassettes
If you wish to use a cassette unit connected to the system, (as described in part 2 ofthe
Foundation course), a number of the BASIC commands will operate differently when
the computer is set to cassette operation by the command I TAP E. Various software
messages and prompts will appear on the screen which are not seen during normal
disc operation.
NOTE - If your cassette unit's FAST-FORWARD and REWIND switches operate
under remote control, then it will be necessary during these operations to either
remove the REM (remote) plug from your cassette unit, or to type in I TAP E : CAT
in order to activate the cassette motor. Pressing [ESC] cancels this operation.
Unlike discs, filenames on cassette do not have such strict rules concerning their
form. They may be up to 16 characters long, and may contain embedded spaces and
punctuation marks. In some instances, they may be omitted altogether.
The following list describes the differences in the operation of each of these BASIC
commands. Descriptions of the commands themselves will be found in the chapter
entitled 'Complete list of AMSTRAD CPC6128 BASIC keywords'.

CAT
You will be instructed:

Press PLAY then any key:


.... whereupon you should press the PLAY button on your cassette unit, followed by
one of the keys on the computer. The tape in the cassette will start turning, and the
computer will display the names of each of the files that it finds (in sequence) on the
cassette.
Each of the blocks of a file will be displayed, followed by a single character which
indicates what sort offile it is:
$

&

is an unprotected BASIC file


is a Protected BAIC file
is an ASCII file
is a Binary file

The computer displays:

Ok
.... at the end of the line if it has read the file successfully, indicating that the file
would have loaded into memory, had the computer attempted to do so.
The CAT function will not affect the program currently in the computer's memory.

Using Discs and Cassettes

Chapter 4 Page 11

If a cassette file has been saved without a specified name, CAT will display it as:
Unnamed fiLe
CAT is terminated bypressing[ESC].

Read errors
If the above file-reading messages are not displayed, or you get the message:
Rea d err 0 r a

.... or....

Rea d err 0 r b

.... on the screen, this indicates either ofthe following:


1.

Your cassette unit is not correctly connected to the computer's TAPE socket (see
part 2 of the Foundation course).

2.

The VOLUME or LEVEL control on your cassette unit is not correctly adjusted.

3.

The tape quality is poor, or the tape is worn.

4.

The tape has been subjected to a magnetic field by being placed close to a
loud-speaker, television set, etc.

5.

You are attempting to read a cassette which has not been created for use on
AMSTRAD computer systems.

CHAIN
CHAIN MERGE
LOAD
MERGE

RUN
You need not specify the file name if you wish the first suitable file on the cassette to
be loaded. Example commands:

CHAIN
CHAIN "",100
1111

CHAIN MERGE
CHAIN MERGE "",100
CHAIN MERGE "",100,DELETE 30-70 '
1111

Chapter 4 Page 12

Using Discs and Cassettes

LOAD ""
LOAD "",&1F40
MERGE '"'
RUN "" (Note that holding down the [CONTROL] key then pressing the
[ENTER] key, executes this command. Use when running cassette
based software, after typing I, TAP E).
You will be instructed:

Press PLAY then any key:


.... whereupon you should press the PLAY button on your cassette unit, followed by
one of the keys on the computer. The tape in the cassette will start turning, and the
computer will load the file to be processed.
The screen will display the loading messages:

Loading FILENAME bLock 1


.... and as many other block numbers as there are in the file, until the file is loaded.
If the first character of the filename is ! then the above messages will be suppressed,
and you will not be required to 'press any key' for the file to load. (You must make sure
that the PLAY button on your cassette unit is down.) If your programs use the! mark
and are also required to run on disc, the ! mark will be ignored during disc operation
(when the disc filename is being read). Note that the! mark does NOT occupy one of
the character positions in the cassette or discfilename.
Abandoning the command using the [ESC] key produces the error message on the
screen:

Broken in
If the file does not successfully load, read the paragraph entitled 'Read errors' earlier
in this section.
WARNING: The internal disc interface occupies a small portion of the memory that in
some cases, was used by commercial writers of cassette based software for the model
CPC464. These cassettes will not operate properly with the CPC6128 + Cassette
unit.

Using Discs and Cassettes

Chapter 4 Page 13

Eor
POS(#9)
These functions operate on cassette as per disc.

INPUT #9
LINE INPUT # 9
OPENIN and CLOSE IN
You need not specify the filename if you wish the first suitable file on the cassette to
be loaded. Example command:

OPENIN

fIll

You will be instructed:

Press PLAY then any key:


.... whereupon you should press the PLAY button on your cassette unit, followed by
one of the keys on the computer. The tape in the cassette will start turning, and the
computer loads the first 2K bytes of the file into a portion of the memory called the
'file buffer'. Input is taken from the file buffer until it is empty, and the computer
again prompts:

Press PLAY then any key


.... and loads the next 2K bytes from the file.
The screen will display the loading messages:

Loading FILENAME bLock 1


.... and other block numbers in turn, as the file is loaded.
If the first character of the file name in the 0 PEN I N command is ! then the above
messages will be suppressed, and you will not be required to 'press any key' for the file
to load. (You must make sure that the PLAY button on your cassette unit is down.) If
your programs use the ! mark and are also required to run on disc, the ! mark will be
ignored during disc operation (when the disc filename is being read). Note that the !
mark does NOT occupy one of the character positions in the cassette or disc filename.
Abandoning file input using the [ESC] key produces the error message on the screen:

Broken in
Ifthe file does not successfully load, read the paragraph entitled 'Read errors' earlier
in this section.

Chapter 4 Page 14

Using Discs and Cassettes

LIST #9
OPENOUTandCLOSEOUT
PRINT #9
WRITE #9
You need not specify the filename if you wish the file to be saved as an Un n a me d
f i Le. Example command:

OPENOUT

1111

The first 2K bytes of the file to be saved to cassette will first be written into a portion
of the memory called the 'file buffer'. When the file buffer is full, you will be
instructed:

Press REC and PLAY then any key:


.... whereupon you should press the RECORD and PLAY buttons on your cassette unit,
followed by one of the keys on the computer. The tape in the cassette will start
turning, and the computer saves the contents of the file buffer. The computer then
refills the file buffer with the next 2K bytes ofthe file, and again prompts:

Press REC and PLAY then any key:


.... and saves the next 2K bytes to cassette.
If the file buffer is partly full and the command CLOS EO UT is encountered, the
computer will save the remaining contents of the file buffer to cassette, issuing the
prompt:

Press REC and PLAY then any key:


The screen will display the saving message:
S a v i n 9 F I LE NAME b L0 c k <x>

If the first character of the filename in the 0 PEN 0 UT command is ! then the above
messages will be suppressed, and you will not be required to 'press any key' for the file
to save. (You must make sure that the RECORD and PLAY buttons on your cassette
unit are down.) If your programs use the! mark and are also required to run on disc,
the! mark will be ignored during disc operation (when the disc filename is being
read). Note that the! mark does NOT occupy one of the character positions in the
cassette or disc filename.
Abandoning file output using the [ESC] key produces the error message on the
screen:

Broken in

Using Discs and Cassettes

Chapter 4 Page 15

Successful saving
To ensure that the file is successfully saved:
1.

Check that your cassette unit is correctly connected to the computer's TAPE
socket (see part 2 of the Foundation course).

2.

Check that the RECORD or LEVEL control on your cassette unit is correctly
adjusted.

3.

Check that you are not using inferior quality cassettes or C120s. (AMSOFT C15
cassettes are recommended.)

4.

Make sure that your cassettes are not subjected to magnetic fields by being
placed close to a loud-speaker, television set, etc.

5.

Before deleting a program from the memory after saving it, CAT alog the tape,
to verify that the program has been saved successfully.

6.

Ensure that your cassette unit is periodically maintained, and that the tape
heads are regularly cleaned.

SAVE
You need not specify the filename if you wish the program to be saved as an
Un n a me d f i Le. Example command:

SAVE '"'
You will be instructed:

Press REC and PLAY then any key:


.... whereupon you should press the RECORD and PLAY buttons on your cassette unit,
followed by one of the keys on the computer. The tape in the cassette will start
turning, and the computer will save the program.
The screen will display the saving messages:

Saving FILENAME bLock 1


.... and as many other block numbers as there are in the file, until the file is saved.

Chapter 4 Page 16

Using Discs and Cassettes

If the first character of the filename is ! then the above messages will be suppressed,
and you will not be required to 'press any key' for the file to be saved. (You must make
sure that the RECORD and PLAY buttons on your cassette unit are down.) If your
programs use the ! mark and are also required to run on disc, the ! mark will be
ignored during disc operation (when the disc file name is being read). Note that the!
mark does NOT occupy one of the character positions in the cassette or disc filename.
Abandoning the command using the [ESC] key produces the error message on the
screen:

Broken in
Read the paragraph entitled 'Successful saving', earlier in this section.

SPEED WRITE
The command operates only on cassette, and can be issued while the computer is set
to disc operation.

Error messages
Note that error messages 7, 21, 24, 25, 27, and 32 (see part 6 ofthe chapter entitled
'For your reference .... ') will be generated during cassette operation, if appropriate.

AMSDOS external commands


Input and output direction to cassette or disc, is effected by the commands:

I TAP E (which can be sub-divided into I TAP E I Nand I TAP E 0 UT)


I DI SC(which can be sub-divided into I DI se. I Nand I DI se. 0 UT)

All external commands:


lA
IB
ICPM

IDIR
IDRIVE
IERA
IREN
IUSER
.... are executed to disc, regardless of whether cassette operation has been selected.

Using Discs and Cassettes

Chapter 4 Page 17

ChapterS
AMSDOS and CP/M
Part 1: AMSDOS
Subjects covered:

**
**
**
**
**
*

Introduction to AMSDOS
Disc directory
Changing discs
Filenames and filetypes
AMSDOS headers
Filenames on 2 drives
Wildcards
Example program using AMSDOS commands
Summary of AMSDOS commands
Manipulating and copying files
Reference guide to error messages

Introduction
AMSDOS extends the AMSTRAD BASIC supplied with your computer by providing
a number of external commands, which are identified by the preceding I (bar)
symbol.
AMSDOS allows the user to change discs freely, as long as no files are in use - in
which case an error message will be displayed and there could be a loss of data ifthe
open file was being written to.

AMSDOS and CP/M

Chapter 6 Page 1

Disc directory
Every disc has two sections, the directory and the data area. The directory contains a
list of all the file names and a 'map' of whereabouts on the disc each file is to be found.
AMSDOS or CP/M can calculate the size of a particular file by inspecting its directory
entry. Calculation of the amount of space left on a disc is made by adding up all the
files in the directory and seeing how much remains unused.
Whenever a file is read, its directory entry is examined, giving the disc location.
When a new file is created, free space is allocated to it, and when a file is erased the
space is relinquished. The directory works in units of lK and can have up to 64
different entries. Large files will have one entry for every 16K although normally
this fact is hidden from the user.

Changing discs
Under AMSDOS (and CP/M Plus) a disc may be changed, or removed, whenever the
drive is not being accessed and neither the input nor output files are open on that
drive. Unlike CP/M 2.2 there is no need to 'log in' a disc.
Changing a disc while it is still being written to, may corrupt the data on the disc. If a
disc is changed while there are still files open on it, then as soon as AMSDOS detects
this, all the open files on the drive will be abandoned and an error message produced.
Any data yet to be written will be lost and the latest directory entry will not be
written to disc. However, AMSDOS can only detect this change when it reads the
directory, which it does every 16K of the file (and whenever a file is opened or closed).
Thus, potentially 16K of data could be corrupted by changing a disc while there are
still files open on it.

AMSDOS filenames and filetypes


It is standard practice to name disc files in such a way that there is an indication of
which 'type' they are. This naming convention DOES NOT 'force' the computer to use
the file in any particular way, however some programs will only accept a file when it
has the correct type of name. AMSDOS will accept any type of name, but will search
in preference for certain file types ifnot otherwise specified. (See 'AMSDOS headers'
ahead.)

Chapter 5 Page 2

AMSDOS and CP/M

Construction of filenames
The filename is constructed from two parts with a (dot) separating them. The first
part can be up to 8 characters long, and the second up to 3 characters long. Thus for
example: "R 0 I NT I ME. DE M" , " DI S CKIT 3 CO M" ,and" DI S C BA S" are all
legal filenames.
The second part of the filename is called the filetype. Filenames and filetypes can be
composed of a mixture of letters and numbers, but cannot have embedded spaces or
punctuation marks. Some common conventional filetypes are:
J

<space>

Unspecified type. May be a data file created by an 0 PEN 0 UT


"<filename>" or BASIC program saved by AMSDOS using S AVE
" <filename>" , A style.

.BAS

BASIC program saved by AMSDOS using S AVE "<filename>" or


S AVE "<filename>" , P or S AV E "<filename> BA S " , A styles.

.BIN

Program or area of memory saved by AMSDOS using S AV E


"<filename>" , B , <binary parameters> style.

.BAK

Old version of a file, where AMSDOS or a utility program has saved a


newer version of a file using an existing name. This allows the user to
back-track to the previous (BAcK-up) version ifrequired.

COM

Command file. CP/M utility programs are all of this filetype .

SUB

Instruction file for the CP/M SUB MI T program .

AMSDOS headers
AMSDOS automatically S AVEs files with a suitable type identifier, so it is not
normally necessary to specify one unless you wish to override the defaults described
previously. BASIC program files, protected BASIC program files and binary files are
saved to the disc with a header record, so that the AMSDOS command:
LOAD

11

<filename,"

.... can recognise them and take the appropriate action. If the AMSDOS command
LOA D cannot find a header, it assumes that the file is a program in ASCII, i.e. plain
text.

AMSDOS and CPIM

Chapter 5 Page 3

Notwithstanding the contents of the header, when AMSDOS is asked to LO ADa file
where no filetype is specified, then it first looks for a file oftype:
<space>

If that does not exist, it looks for a file oftype:

.BAS
.... then finally, one oftype:

.BIN
This allows the user to abbreviate the filename, i.e. not needing to specify the
filetype, in most instances.
A disc data file started with the command 0 PEN 0 UT and subsequently written to,
will have no header, and the contents will be in ASCII, i.e. piain text, from the BASIC
WRI T E, PR I NT or LIS T commands. The disc command 0 PEN I N will search for
files in the same order as LOA D, ifnofile type is specified.

Filenames on two drives


On a 2-drive system, i.e. if an additional drive has been connected to the computer,
files can exist on either drive. The computer will not automatically look for a file on
both drives, so the user must specify which drive to use. You can either employ the I A
or I B or I DRI VE commands (full description ahead) to select one or other drive, and
then use a normal filename, or alternatively you can override the default drive
assignment by specifying the drive as an A : or B: prefix to the filename. Thus, for
example:

IB
SAVE "PROG.BAS"
lA
.... and ....

lA

SAVE "B:PROG.BAS"
.... both save the program to the second drive, Drive B.

Chapter 5 Page 4

AMSDOS and CP/M

Similarly, you can override the default USE R number assignment (U SE R numbers
allow you to partition-off the directory) byspecifying the USE Rnumber (in the range
oto 15) as a prefix to the filename. Thus, fOl' example:

LOAD "15:PROG.BAS"
.... and ....

SAVE "15:PROG.BAS"
.... would load and save the program to the USE R number 15 section of the disc,
whatever the default USE R number setting. (See the IUS E R command, ahead.)
Finally, it is possible to override both default USE Rand DRI VE settings (in that
order) by specifying them together in the prefix to the filename, for example:

RUN "15B:PROG.BAS"

Wild cards
It is often required to perform some disc operation (copying, erasing, etc.) on more
than one disc file. When a filename is specified for a particular operation, AMSDOS
scans the disc directory looking for a name which exactly matches. However, it is
possible (where the command allows) to perform the operation on a group of files
where some of the characters in the filenames can be 'don't care'. This is shown by
using the character? in the 'don't care' position. If the whole block (or remainder of
the whole block) of any part of the filename is 'don't care', then the block of ?'s can be
abbreviated to the symbol *. Thus, for example, FRED. * is shorthand for
F RED. ? ? ? and F BA S is shorthand for F ? ? ? ? ? ? ? BA S

*.

Finally, the expression * . * means 'all files'.


Examples:

*. BAS

DIRECTORY

Match

BERT.BAS
FRED1.BAS
FRED2.BAS
FRED3.BAK
FRED3.BAS
FINISH.BAS

BERT.BAS
FRED1.BAS
FRED2.BAS

AMSDOS and CPIM

FRED3.BAS
FINISH.BAS

* . BA?

Match F RED? BA S

Ma tch F

FRED1.BAS
FRED2.BAS

FRED1 ~BAS
FRED2.BAS
FRED3.BAK
FRED3.BAS
FINISH.BAS

FRED3.BAS

Chapter 5 Page 5

Examples of using AMSDOS commands in a


program
To give you a good understanding of the AMSDOS commands, we recommend that
you work through the examples, referring to the relevant sections in the rest of this
chapter as you go. DO NOT type in, or run, these programs with one of your original
Master CP/M system discs installed.

Saving variables and performing a screen dump


The following example program writes to the disc, and you will therefore need a
blank (formatted) disc or working disc inserted in the drive to run the program. The
program draws a Union Jack flag, and then saves the whole screen to disc.

10 dumpfi Le$="fLagdump.srn"
20 MODE 1:BORDER 0
30 DIM coLour(2)
40 FOR i=0 TO 2
50 READ coLour(i): REM get coLours from DATA statement
60 INK i,coLour(i)
70 NEXT
80 ON ERROR GOTO 430
90 OPENIN "param.dat" I test if fi Le exists
100 CLOSEIN:ON ERROR GOTO 0
110 IF errnum=32 AND DERR=146 THEN CLS:
GOTO 160 I fiLe doesnt exist
120 CURSOR 1:PRINT liDo you want to overwrite
oLd fi Le? Y/N ";
130 a$=INKEY$:ON INSTR(" YN",UPPER$(a$
GOTO 130,150,140:GOTO 130
140 PRINT a$:PRINT "Program abandoned":END
150 PRINT a$:CURSOR 0
160 OPENOUT "param.dat"
170 WRITE #9,dumpfi Le$,1: REM save fi Lename and mode
180 FOR i=0 TO 2
190 WRITE #9,coLour(i): REM save coLours
200 NEXT i
210 CLOSEOUT
220 CLS
230 gp=1:GRAPHICS PEN gp:w=125
240 x=-65:a=240:y=400:b=-150:GOSUB 400
continued on the next page
Chapter 5 Page 6

AMSDOS and CPIM

250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
run

y=0:b=150:GOSUB 400
x=575:a=-240:y=400:b=-150:GOSUB 400
y=0:b=150:GOSUB 400
gp=2:GRAPHICS PEN gp:w=40
a=240:x=-40:y=400:b=-150:GOSUB 400
x=0:y=0:b=150:GOSUB 400
a=-240:x=640:y=0:b=150:GOSUB 400
x=600:y=400:b=-150:GOSUB 400
ORIGIN 0,0,256,380,0,400:CLG 1
ORIGIN 0,0,0,640,150,250:CLG 1
ORIGIN 0,0,280,352,0,400:CLG 2
ORIGIN 0,0,0,640,168,230:CLG 2
SAVE dumpfi Le$,b,&C000,&4000
DATA 2,26,6
END
MOVE x,y:DRAWR a,b:DRAWR w,0:DRAWR -a,-b
MOVE x+a/2+w/2,y+b/2:FILL gp
RETURN
errnum=ERR:RESUME NEXT

Note the use of DA T and. SRN filetypes. These filetypes are used to remind us of
what is in the file, rather than because they have any inherent significance. The file
PAR AM DA T will be an ASCII data file without a header, whilst F LA GDUM P SRN
is an AMSDOS binary file with a header.
Note how the program deliberately tries to read from the file PAR AM DA T before
writing to it, in order to establish if the file already exists. If the file does NOT exist,
then an error is reported by BASIC; the error is trapped by the program, and
execution proceeds without interruption. If the file DOES already exist, then no error
is reported, and the program automatically asks if you wish to overwrite the existing
file.
The particulars of the screen dump, namely the screen mode, palette colours and
name of file containing the actual information, are saved into a parameter file. This
illustrates the use of a data file to WRI T E program variables (d u mp f i Le $) and
constants ( 1 ), saving them for use by another program.

AMSDOS and CPIM

Chapter 5 Page 7

Loading the screen back


The following example is a general purpose screen dump displaying program, using a
parameter file to control its action. Note how variables are I NPUT from the data file,
with the EO F function allowing automatic variation in the size of the file. It is
important that the screen dump displayed by this program was saved with the screen
in a known position in memory, otherwise the result will be 'skewed'. This is ensured
by the saving program executing a MOD E command and thereafter being careful not
to cause the screen to scroll.

10 DIM coLour(15): REM Provision for 16 coLours


20 OPENIN "param.dat"
30 INPUT #9, fi Lename$,screenmode
40 i =0
50 WHILE NOT EOF
60 INPUT #9,coLour(i)
70 INK i,coLour(i)
80 i=i+1
90 WEND
100 CLOSEIN
110 MODE screenmode:BORDER 0
120 LOAD fi Lename$
run

Summary of AMSDOS external commands


lA
lA
COMMAND: Set default drive to Drive A. Equivalent to ID R I VE with parameter A.
(The main drive within the computer is Drive A.)

IB
IB
COMMAND: Set default drive to Drive B. Equivalent to I DR I VE with parameter B.
(The main drive within the computer is Drive A.)

Chapter 5 Page 8

AMSDOS and CP/M

ICPM
ICPM
COMMAND: Switch to alternative disc environment by loading the operating
system from a system disc. The operating systems supplied with the computer are
CP/M Plus and CP/M 2.2.
This command will fail if the computer's drive does not contain a system disc with

CP/M. Copies of Side 1 will load CP/M Plus, whereas copies of Side 4 will load the
older CP/M 2.2 operating system.

IDIR
I DI R [, <string expression>]

IDIR,"*.BAS"
COMMAND: Display the disc directory (In CP/M style), and free space. If the string
is assumed.
expression is omitted, the wild-card

*.*

I DISC
IDISC
COMMAND: Equivalent to the two commands I DI SC I Nand I DI SC 0 UT

I DISC.IN
IDISC.IN
COMMAND: Use disc as file input medium.

I DISC.OUT
IDISC.OUT
COMMAND: Use disc as file output medium.

AMSDOS and CPfM

Chapter 5 Page 9

I DRIVE
, DR I VE , <string expression>

IDRIVE,"A"
COMMAND: Set the default drive. This command will fail if AMSDOS is unable to
read the disc in the requested drive.

IERA
, ERA, <string expression>

IERA,"*.BAK"
COMMAND: Erases all files which match the filename and which are not Read/Only.
Wild cards are permitted.

IREN
, RE N, <string expression> , <string expression>

IREN,"NEWNAME.BAS","OLDNAME.BAS"
COMMAND: Give a file a new name. Any other file with the chosen new name must
not already exist. Wild cards are not permitted.
The USE R (see IUS E R ahead) parameter may be specified within the <string
expression>s to override any default settings. For example, the command
, R EN, " 0 : NEW BA S " , " 1 5 : 0 L D BA S" will rename the file in USE R 1 5
called "0 L D BA S " , to a file called "N E W BA S" in USE R 0, regardless of any
default or previously issued settings of , USE R.

I TAPE
'TAPE
COMMAND: Equivalent to the two commands' TAP E I Nand' TAP E 0 UT. Used
if an external cassette unit is connected.

Chapter 5 Page 10

AMSDOS and CP/M

ITAPE.IN
ITAPE.IN

COMMAND: Use tape as file input medium. Used if an external cassette unit is
connected.
.

ITAPE.OUT
'TAPE.OUT

COMMAND: Use tape as file output medium. Used if an external cassette unit is
connected.

I USER
, USE R, <integer expression>

IUSER,3
COMMAND: Determines which of up to 16 individual sections of the directory (in the
rangeOto 15), disc functions (e.g. CA T, LOA D, , DI Retc.) are to be performed on.
A file on one USE R number may be transferred to another, by a , RE N command. For
example, 'R EN, " 1 5 : EXAMP LE. BA S " , " '" : EXAMP LE. BA S" transfers a file
from USE R number '" to USE R number 1 5, although the name of the file itself
(E XAMP LE. BA S) is not changed.

Copying files from disc to disc


AMSDOS fues with hea.ders
It is possible to copy this type offile in the CP/M environment using PIP (see part 2 of
this chapter). Any file created by AMSDOS which has a header record (see 'AMSDOS
headers', previously described) will be copyable as a whole - disc to disc - but in
general the contents of the file will not be understood by any CP/M programs.

ASCIIfues
Files created by AMSDOS without headers are generally in ASCII, and are both
copyable and understood by CP/M programs. In particular it should be possible to
exchange ASCII program files, ASCII data files and ASCII text files freely between
AMSDOS and CP/M programs.
AMSDOS and CP/M

Chapter 5 Page 11

Read/Only files
It is possible, using CP/M, to set any file to be Read/Only, and/or set to a special
System status in the directory. Such attributes can only be set or reset in the CP/M
environment, but are honoured by AMSDOS. For further details, see part 2 of this
chapter (SET utility).

Copying files between disc and cassette


There is no support in CPIM Plus for accessing tape files and copying them to disc, nor
for making tape files from disc. !fit is required to copy files in this way, then CP/M 2.2
(on Side 4 of your system discs package) must be used. CP/M 2.2 contains the utilities
CLOA Dand CS AVE for these purposes, and are used as shown in the tables ahead.

File copying procedures


The tables ahead cover copying files of all sorts between disc and tape (if connected).
It assumes that no additional disc drive is connected. It is not possible to copy
protected BASIC programs to and from tape at all, nor to copy a binary file (such as a
machine code video game) to or from tape unless the load addresses are known.
Further details of the programs PIP, CLOA Dand CS AVE are given in part 2 ofthis
chapter.
See the next 2 pages for the copying tables ....

Chapter 5 Page 12

AMSDOS and CP/M

COpy FROM:
cOPYTO:

AMSTRADBASIC
on tape *

AMSTRAD BASIC
on tape *

Binary
on tape *

ASCII da ta
on tape *

(TAPE
LOAD"FILE"
<change tapes>
SAVE"FILE"
(DISC

Binary
on tape *

H=HIMEM
(TAPE
MEMORY <s>-1
LOAD"FILE"
<change tapes>
SAVE"FILE" ,B,
<s>, <I> [, <r>]
(DIS-C
MEMORY H
<note 2>

ASCII
on tape *

(TAPE
LOAD"FILE"
<change tapes>
SAVE"FILE",A
(DISC

AMSTRADBASIC
on disc *

(TAPE
LOAD"FILE"
(DISC
SAVE"FILE"

ASCII
on disc

(TAPE
LOAD"FILE"
(DISC
SAVE"FILE",A

Binary
on disc *

*File has a header

<Insert CP/M 2.2 disc>


(CPM
CLOAD"FILE",TEMP
<change tapes>
CSAVETEMP ,"FILE"
ERA TEMP
AMSDOS
<note 1>

<Insert CP/M 2.2 disc>


(CPM
CLOAD "FILE"
AMSDOS
H=HIMEM
(TAPE
MEMO RY <s>-1
LOAD"FILE"
(DISC
SAVE"FILE" ,B,
<s>,<L[,<r>]
MEMORY H
<note 2>

<note 1> Requires free disc space for temporary file " T EMP" .
<note 2> <s> is start address offile, <1> is length, <r> is optional run address.
AMSDOS and CPIM

Chapter 5 Page 13

COpy FROM:
cOPYTO:

AMSTRADBASIC
on tape *

AMSTRAD BASIC ASCII data AMSDOS Binary


on disc *
on disc
on disc *

All other
on disc

LOAD"FILE"
ITAPE
SAVE"FILE"
IDISC
H=HIMEM
MEMORY <s>-1
LOAD"FILE"
ITAPE
SAVE"FILE",B,

Binary
on tape *

<s> , <1'[, <r> 1

IDISC
MEMORY H
<note 2>

ASCII
on tape *

LOAD"FILE"
ITAPE
SAVE"FILE",A
IDISC

<Insert CPIM 2.2 disc>

<Insert CPIM 2.2 disc>

ICPM
CSAVE FILE
AMSDOS

ICPM
CSAVE FILE
AMSDOS
<note 3>

or
<Insert CPIM 2.2 disc>

ICPM
CSAVE FILE
AMSDOS
AMSTRADBASIC
on disc *

LOAD "FILE"
<change discs>

SAVE"FILE"

. or
<Insert CPIM Plus disc>

ICPM
PIP B:=FILE
AMSDOS
ASCII
on disc
AMSDOSBinary
on disc *
All other
on disc

LOAD"FILE"

<Insert CPIM Plus disc>

<change discs>

ICPM
PIP B:=FILE
AMSDOS

SAVE"FILE",A

<Insert CPIM Plus disc>

ICPM
PIP B:=FILE
AMSDOS
<Insert CPIM Plus disc>

ICPM
PIP B:=FILE
AMSDOS
* File has a header
<note 2, <s' is start address offile, <I, is length, <r, is optional run address ..
<note 3, Destination file cannot be used directly by BASIC. However this option is
useful as a low cost transportation or backup medium. The file can be copied back
toadiscby CLOAD" F I LE" ,(underCPIM2.2).

Chapter 5 Page 14

AMSDOS and CPIM

Reference guide to AMSDOS error messages


When AMSDOS cannot carry out a command for some reason, it will display an error
message. If there is a problem with the hardware, the error message is followed by the
question:

Retry, Ignore or CanceL?


R causes the operation to be repeated, possibly after the user has taken some
preventative action.
I causes the computer to continue as if the problem had not occurred, which will often
lead to unexpected and possibly inconvenient results.
C causes the operation to be cancelled, which will often lead to a further error
message.

Error message meanings


Unknown command
.... The command is not spelt correctly.

Bad command
.... The command cannot be carried out for some reason. Syntax error or inappropriate
hardware configuration.
<iilename> a Lrea dye x ; s t s

.... User is trying to rename a file with a name that's already in use.
<iilename> not f

0U

nd

'" .File does not exist.


Dr ; ve <drive>: d; re c tor y f u LL

.... N 0 more room in the disc directory for a new entry.


Dr ; ve <drive>: d; s c f u L L

.... N 0 more room on the disc for new data.

AMSDOS and CPIM

Chapter 5 Page 15

Dr i ve <drive>: d i sce h a n 9 e d , c l 0 sin 9 <filename>


.... Disc has been changed with files still open on it.
<filename> ; s read on ly

.... File cannot be operated on because it is Read/Only. Files can only be set Read/Only
or ReadIWrite in the CP/M environment.

Dr ; ve <drive>: d; s cm; s sin 9


.... No disc in drive, or disc is not seated and spinning properly. Recommended action
is to eject and re-insert the disc, then type R.

Dr ; ve <drive>: d ; se; s wr ; t e pro tee t e d


.... Attempt has been made to write on a disc with the Write Protect hole open. To use
the disc, eject, close the write protect hole, re-insert the disc, and then type R.

Dr ; ve <drive>: rea d fa; l


.... Hardware error reading disc. Recommended action is to eject and re-insert the disc,
then type R.

Dr ; ve <drive>: wr ; t e fa; l
.... Hardware error writing disc. Recommended action is to eject and re-insert the disc,
then type R.

Fa; led to load CP/M


.... Read error loading CP/M during the I CPM command, or you are not using a valid
system disc containing CP/M. Note that trying to load CP/M from a Data format disc
will produce a 'read fail' error.

Chapter 5 Page 16

AMSDOS and CPIM

Part2:CP/M
CP/MPlus
Subjects covered:

**
**
*

Introduction to CP/M
BootingCP/MPlus
Direct Console Mode
Transient programs
Managing peripherals
Working with CP/M 2.2

CP/M Plus is a disc operating systeni.1t is a special program which gives you access to
the full power of your CPC6128. The 128K of RAM is used to the full, with over 61K
available to user programs. CP/M incorporates random access to data files and the
CPC6128 implementation includes a sophisticated VDU emulator.
Because CP/M is available for so many different computers, it means that there are
thousands of applications packages available for you to choose from, and a whole
wealth of knowledge and experience for you to draw upon.
Full details of CP/M Plus including information on how to write your own programs,
and information on the AMSTRAD implementation ofCP/M Plus, are contained in
SOFT971 - A Guide to CP/M Plus, as well as other AMSOFT and independent
publications.

Introduction
The CP/M operating system provides a way for you to communicate with the
computer, and manipulate files and peripherals. Special commands (and programs
on the disc called utilities) are there to help you get on with the main task - which is
running your applications programs with your data.

AMSDOS and CPIM

Chapter 5 Page 17

Needless to say, it is possible to become quite an expert at how CP/M and all the
various utilities work, and at times, such expertise can be very useful in helping out
when we get into trouble. Most of us, however, only need to know enough to get us
started, and the rest of this chapter is designed to introduce all the features and
facilities without obscuring the vital facts with too many frills.
Whereas BASIC has its Direct Mode and the 'R e a d y' prompt, CP/M has a Direct
Console Mode and is identified by the A> or B> prompt. Certain built-in commands
are available but the majority of the 'housekeeping' work is done by loading and
running 'transient programs'. They are called 'transient' because they are only in the
computer (loaded from the disc) while you are using them, as opposed to being
built-in.
As well as standard CPIM error messages, the system also generates a number of
specialised hardware error messages which can be distinguished by the fact that they
normally appear on the bottom line of the screen in a 'banner' form.

CP/M Plus on the disc


The major part of CP/M Plus resides in a special file which has the filetype ' EMS',
and is found on Side 1 of the system discs package. The computer loads CP/M from
this file into the memory using a two stage process.
Initially, the AMSDOS command I CPM loads the first sector oftrack O. On a system
disc this sector has been arranged to be a program which then loads the EMS file
into memory. The remainder of the system tracks are unused.

Early moming start profile


During the loading process, when CP/M Plus is first activated, if the file
PRO F I LE. SUB is present on the disc, then the instructions.in that file are
SUB MI Tted. This facility can be used to re-arrange the keyboard, customise the
screen output, initialise a printer and even auto-start an application program. In
chapter 4 we saw how to rename the profile file supplied on Side 1 in order to activate
it.
While the profile file is working, a small temporary file is opened on the disc, which
must therefore be write-enabled. This is why the master disc itself cannot include a
recognisable profile file.

Chapter 5 Page 18

AMSDOS and CPIM

Profile files can be constructed using a word processor, text editor (such as ED CO M),
or even from BASIC. The small BASIC program below could have been used to
generate the file PRO F I LE. SUB:

10
20
30
40

OPENOUT "PROFILE.SUB"
PRINT #9,"SETKEYS KEYS.CCP"
PRINT #9,"LANGUAGE 3"
CLOSEOUT

Console control codes


In the CP/M environment, a variety of special key operations are used. These
keystrokes replace the action of the [ESC]ape and cursor keys used in AMSTRAD
BASIC. The control codes below are assigned after running the command:

SETKEYS KEYS.CCP
.... where both the transient program SET KEY S CO M and the command file
KEY S CCP are found on Side 1 of the system discs package.
Control
Code

Key

Action

[CONTROl]A

Moves the cursor one character to the


left.

[CONTROl]B

[CONTROl]Q
.... or....
[CONTROL]!)

Moves the cursor to the beginning of the


line. If the cursor is already at the
beginning, moves to the end.

[CONTROl]C

[CONTROL] [ESC]

Abandon.

[CONTROl]E

[CONTROL] [RETURN]

Physical carriage return.

[CONTROl]F

!)

Moves cursor one character to the right.

[CONTROl]G

[ClR]

Deletes character under cursor.

[CONTROl]H

[DEL]

Backspace delete.

[CONTROl]1

rrAB]

Moves cursor to the next tab stop.

[CONTROl]J

AMSDOS and CPIM

Send command line.

chapter 5 Page 19

[CONTROl]K

[CONTROL] [ClR]

Delete to end ofline.

[CONTROl]M

[RETURN]
.... or ....
[ENTER]

Send command line.

[CONTROl]P

Hardcopy toggle. Turn onJofflog of all


screen output to printer.

[CONTROl]Q

Resume screen output.

[CONTROl]R

[CONTROL] [ENTER]

Retype command line.

[CONTROl]S

[ESC]

Halts the screen output from CPIM. Use


[CONTROl]Q to resume.
Discard line.

[CONTROl]U
[CONTROl]W

[COPY]

Recall last-typed command line.

[CONTROl]X

[CONTROL] [DEL]

Delete from beginning ofline to cursor.

[CONTROl]Z

End of text.

Filenames
Many of the commands take filenames as a parameters, and where specified, the
filename may contain wild-cards (see the section entitled 'Wild cards' in part 1 of this
chapter). All filenames will be forced to upper case.
Direct Console Commands and most utility programs do NOT require that filenames
are contained in double quotes" " . Remember that filenames can have an A: or B :
prefix to force CP/M to use the appropriate drive.
Therefore a typical CP/M command is:
TYPE KEYS.CCP

.... where T YP E is the function required, meaning 'display on the screen', and
KEY S CCP is a file name specifying which file we wish to see.

Cl;Iapter 5 Page 20

AMSDOS and CP/M

Switching default drives


If you have an additional disc drive connected, then it is possible to switch the default
drive selection between Drive A and Drive B by typing A: or B: at the B> or A>
prompt. That prompt, of course, tells you the current default drive. Adding the A:
and B : prefix to filenames overrides, but does not reset, the default drive setting.

Direct Console Commands


There are a number of Direct Console Commands which can be typed at the A> or B>
prompt. Each command can be abbreviated, and although the simple functions
described below are genuinely built-in, there are also more sophisticated transient
commands with the same name.

DIRcommand
DI R lists the D I Rectory of the disc. The filenames are not sorted into any particular
order, but the position of the file name in the D I R display indicates the position of
that file's entry in the disc directory. Wild cards are permitted. Files set with the
'S YS' attribute will not be listed.

DIR
DIR
DIR
DIR
DIR

B:
*.BAS
B:*.BAS
PIP.COM.

will list files on the default drive.


will list files on Drive B :
will list files oftype BA S
will list files oftype BA S on Drive B :
will list only the file PIP. CO M(ifit exists).

DIRSYS or DIRS command


DI RS YS or DI RS lists only those directory entries with the'S YS' attribute set.
Otherwise it operates as DI R. The S YS attribute is described later.

ERASE or ERA command


ERA is used to ERAse files from the directory. Only the directory entry is erased, so
the data is still in the data section ofthe disc until the space is re-used by another file;
however, the information is nevertheless not recoverable. Wild card filenames are
permitted, and if used, ERA will ask for confirmation. ERA does not list the filenames
that are deleted. If any file about to be erased is found to be Read/Only then the
command will abort. The Read/Only attribute is described later.

AMSDOS and CPIM

Chapter 5 Page 21

will erase the file PIP. C0 M


will erase the file PIP. CO Mon Drive B
will erase all BAS files

ERA PIP.COM
ERA B:PIP.COM
ERA *.BAS

RENAME or REN command


RE N allows you to REName an existing file. The new filename is specified first,
followed by then the existing filename.lfthe new file name already exists, an error
message will be displayed.

Wild cards in the filenames are outside the scope of RE N as a built-in command, and
require R E NAME. C0 M, the transient program.

RE N NEW NAME. BA S 0 LDNA ME. BA S

RENB: NEW NAME. BA S 0 LDNA ME. BA S

will rename the file 0 L DNA ME. BA S


toNEWNAME.BAS
will rename the file 0 L DNA ME. BA S
to NEWNAM E. BAS,onDriveB.

TYPE or TYP command


T YP E asks for the specified file to be T YP Ed onto the screen. If the file is not an

ASCII text file, unpredictable and possibly undesirable side-effects may occur.
TYPE KEYS. CCP

.... will display the file KEY S C CP

USER or USE command


USE R changes the current user number. CPIM Plus starts with the current user
number set to O. Normally you can only access files identified with the current user
number, thus providing a way of partitioning-off the directory.

A file in User 0, with the'S YS' attribute set can be accessed from all other user
numbers. This is a very powerful facility for making utility and applications
programs available to all user numbers, without having an actual copy of them in
each user area.
USER 3

.... will set the current user number to 3.

Chapter 5 Page 22

AMSDOS and CPIM

Transient commands
To perform more sophisticated file management than permitted by the Direct
Console Mode, you must employ one ofthe various utility programs provided. These
are invoked merely by typing the program name, possibly followed by a filename
and/or some parameters. You have probably already used DI S CKIT 3.
The commands fall into a number of categories as indicated below. Full
documentation of these programs is extensive, and further information is contained
in the HE LP files (on Side 3 of your system discs package) and in SOFT971- A Guide
toCP/MPlus.
The commands DI S CKIT 3, SET KEY S, SET LS T, SET S I 0, PAL ETT E;
LA NGUAGE and AMS DOS, together with the GSX Screen Device Drivers and the
installation of LOG03 are designed by AMSTRAD, and work exclusively on the
AMSTRAD system. They will not work on any other CP/M system.

It is possible to enter multiple commands on a single line, where the commands are
separated by an exclamation mark. For example:

LANGUAGE 3!SETKEYS KEYS.WP

Peripheral Management
DI S CKIT 3 is a complete disc formatter, copier and checker. It is quicker to format
whilst copying than to format and then copy. Comprehensive menus indicate which
keystrokes (mainly from the function key area of the keyboard) should be made.
Vendor format discs are a special form of System disc intended for software
distribution, although Data format discs are perhaps more suitable for this activity
in the CP/M Plus environment.

WARNING
The licence agreement for your CP/M (which is electronically serial-number
encoded) permits its use on a single computer system only. In particular this
means that you are prohibited from giving any other person a disc with YOUR
serial-numbered copy of CP/M on it. Because copies of Side 1 of your master
package will include your CP/M (in the. EMS file) on it, you must be careful not
to sell, exchange, or in any other way part with, any disc with that file on it.

AMSDOS and CP/M

Chapter 6 Page 23

Language characters
The CPC6128 has a full set of international characters. The LA NGUAGE command
exchanges certain of these characters so that simple software can display alternative
and accented characters on the screen. Further details are contained in part 16 ofthe
chapter entitled 'For your reference ... .'.
The command:
LANGUAGE 3

.... will set the 6128 to the UK displayed character set, which swaps the # and signs
(compared to the default USA set).

Colours
The default colours ofCP/M Plus on the 6128 (with colour monitor) are bright-white
characters on a blue background. These colours can be changed by the PAL ET T E
command, which takes a number of parameters, one for each ink - ink 0 includes the
background and border area; ink 1 is for the text. Each colour is represented by a
number in the range 0 to 63, which can be used to gauge the colour's intensity
(brightness) on a green monitor.
It is possible to specify any number of inks, from one to sixteen, although only the first
two will be visible in 80 column mode.
The command:
PALETTE 63,1

.... will reverse the normal settings of ink 0 and ink 1, giving a background of
bright-white (63) with text in blue (1).
Use the values in the following table to select the colours (or intensities) that you
require. You can use either the hex or decimal representation as you prefer.

Chapter 5 Page 24

AMSDOS and CP/M

Colour

Hex

Decimal

Black
Blue
Bright blue
Red
Magenta
Mauve
Bright red
Purple
Bright magenta
Green
Cyan
Sky blue
Yellow
White

&00
&02
&03
&08

0
2
3
8
10

&OA

&OB
&OC
&OE
&OF
&20
&22
&23
&28

&2A

11
12
14
15
32
34
35
40
42

Colour

Hex

Decimal

Pastel blue
Orange
Pink
Pastel magenta
Bright green
Sea green
Brightcyan
Limegreeh
Pastel green
Pastelcyan
Bright yellow
Pastel yellow
Bright white

&2B
&2C
&2E
&2F
&30
&32
&33
&38

43
44
46
47
48
50
51
56
58
59
60
62
63

&3A
&3B
&3C
&3E
&3F

Keyboard
The codes generated by the keyboard can be altered by the SET KEY S command. This
allows suitable codes to be assigned to keys and to expansion tokens. The actual codes
must be written into a file, whose name is then presented to the SET KEY S command.
The command file can be created by a text editor, by PIP, or even from BASIC. For
example:

SETKEYS KEYS.TST
.... where the file KE Y S T ST contains:
E &8C "D I RiM" expansion token 12
8 N S C "t H" backspace = [CONTROl]H, ASCII 08
.... will firstly redefine the [CONTROL] [ENTER] expansion token (represented by
&8C) to be the string DI R [RETURN], and then turn the cursor left key Q (key
number 8) into a backspace.
Standard files provided with the 6128 are KEY S CC P for CP/M command editing,
KEY S DRL for use with Dr. LOGO (on Side 3), and KEY S WP which is suitable for
many word processors.

AMSDOS and CP/M

Chapter 5 Page 25

Printers
Initialising printers can be performed by the command:
SET LS T dilename>

.... where <filename> contains the string, or strings to send to the printer. As with the
command file for SET KEY S, control codes can be represented by:

t <character>
.... or by ....

<character value>

.... or by ....

<control code name>

.... where control code names are ESC, FF, etc., as shown in the table of ASCII
characters in the chapter entitled 'For your reference .... '.
A useful initialising code for many printers is the value 15, setting the printer into
condensed printing.
The command:

PRINT #8,CHR$(15)
.... would set this in BASI C. In CPfM, issue the command:
SETLST CONDENSE

.... where the file CON DEN SE contains anyone of the following as a single line of text:

SI

to

t 1& F I
t 15
I

.... which are all interpreted as the decimal value 15.


Some applications programs require a screen that is 24x80. The command
SET 2 4 X 8 0 may be used to set the screen size.

Chapter 5 Page 26

AMSDOS and CPIM

The commands:

SET24X80
.... or ....

SET24X80 ON
.... turns 24 x 80 mode on, and:

SET24X80 OFF
.... turns 24 x 80 mode off.
The normal 6128 full screen size is 24 x 80, with the bottom line reserved for status
messages. Turning off 24 x 80 mode will only be noticeable if the status line is also
disabled. Refer to part 15 of Chapter 7 for details of how to turn the status line on and
off.

Serial interface
Built into CP/M Plus is support for a single channel serial Input/Output interface
(RS232). Its vital statistics can be examined by typing the command SET S 10 (with
no parameters):

SETSIO
.... or can be set using a command which may include any (or all) ofthe selections:

SETSIO, RX 1200, TX 75, PARITY NONE, STOP 1, BITS 8,


HANDSHAKE ON, XOFF OFF
.... which would set a new configuration.
Baud rates and X0 N/X 0 F F status are also affected by one ofthe assignments possible
with the DEVICE command. DEVICE deals with logical and physical devices.
Logical devices are indicated by a : colon. To examine all the current device
attributes, type:

DEVICE

AMSDOS and CPIM

Chapter 5 Page 27

.... and the attributes can be altered by commands such as:


DE VICE S I 0 [ 1 200]
DEVICE SIO[XON]
DEV ICE S 10 [NOXON]

.... sets S I 0 to 1200 baud.


.... toturnonSIO XON/XOFFprotocol.
.... to turn off S 10 XON/XO F F protocol.

The connections between logical and physical devices can be altered. Normally
CON: is set to CRT (keyboard/screen), AUX: is set to SI 0 (the optional serial
interface), and LS T : is set to LP T (the Centronics printer interface). The command:
DEVICE LST:=SIO

.... will send the printer output to the serial interface (if fitted).
Note how this is a channel re-direction, not to be confused with the file copying
facilities provided by PIP. The two commands GET <filename> and PU T <filename >
re-direct console input or output, and printer output, instructing them to use a file,
rather than the device channel.
PIP

The PIP utility (Peripheral Interchange Program) allows you to transfer


information between the computer and its peripherals.
In general, the form of the command is:
PIP <destination> = <source>

The <source> and <destination> can be either a filename, with wild-cards allowed in
the source, or a logical device. The following logical devices may be used:
As destination

As Source
CON:
AUX:

EOF:

console input
auxiliary input
an end-of-file mark

CON:
AUX:

LST:
PRN:

console output
auxiliary output
printer
a printer with added tab
expansion, line numbers and page
breaks

Examples of PIP:
PIP B:=A:*.COM

.... copy all

* . CO Mfile from Drive A : to Drive B :

Chapter 5 Page 28

AMSDOS and CP/M

PIP KEYBOARD.CPM=KEYS.CCP
.... make a copy of KEY S CCP calling it KEY BOA RD. CPM

PIP CON:=KEYS.CCP
.... send file KEY S CC P to screen (similar effect to T YPEKE YS CC P)

PIP LST:=KEYS.CCP
.... send file KEY S CC P to printer

PIP TYPEIN.TXT=CON:
.... accept keyboard input into a file called TYP E IN. TXT
Note that this last operation is terminated by the [CONTROL]Z control code, and that
in order to get a new line you must type [CONTROL]J after [RETURN] every time.
[CONTROL]J is the ASCII code for line feed.

If typed without parameters, PIP gives a prompt, and you can then enter the
commands that you require. This form of operation is particularly useful for copying
files when we do not have the PIP. CO Mfile on either the source or destination disc.
We can load in PIP from System disc Side 1, remove the System disc, and then insert
the discs that we are going to use during the copying.
To exit from PIP, press [RETURN] at the

* prompt.

Note that PIP can be used to copy files from one disc to another on a single drive
system, prompts will be automatically issued to change the disc. The source and
destination drive identifiers must differ.

System management
DI R, ERA SE, RE NA ME and T Y P E are transient programs with more facilities than
their built-in counterparts. As with many other transient programs supplied by
Digital Research, secondary parameters are specified in square brackets. Full details
are contained in the HE LP files (on Side 3 of your system discs package). A few
examples are:

DIR [FULL]

displays show file sizes and attributes

ERASE *.COM [CONFIRM]

will prompt for confirmation of each file it finds,


individually

AMSDOS and CPIM

Chapter 5 Page 29

RENAME

will ask for the old and new filenames to be


typed in

RENAME *.SAV=*.BAK

will rename all files of type . BA K to type

TYPE KEYS.WP [NOPAGE]

will suppress the screen pagination

.SAV

The file attributes of S YS (System) and R0 (Read/Only) have been mentioned


earlier. These and many other attributes can be assigned using the SET command,
which accepts wild cards.
The commands:

SET *.COM [RO]


SET KEYS.CCP [RO]
SET A: [RO]
.... set files or a drive to Read/Only status, to prevent accidental erasure.
The commands:

SET *.COM [RW]


SET KEYS.CCP [RW]
SET A: [RW]
.... reset files or a drive to Read/Write status.
The commands:

SET *.COM [SYS]


SET KEYS.CCP [SYS]
.... give files the System attribute. Files with this attribute are not shown by the DI R
command (D I RS or DI RS YS is required). However, the files are still available for
use, and in addition, if the files are located in User area number 0, they are available
to all other User area numbers.
The commands:

SET *.COM [DIR]


SET KEYS.CCP [DIR]
.... removes the System attribute.

Chapter 5 Page 30

AMSDOS and CP/M

Each disc can be assigned a label, or name, and also a password. That password will
protect the directory itself, rather than the files named in the directory. The
individual files can also be assigned a password.
SET [NAME=ROLANDJ
SET [PASSWORD=SALLYJ
SET [PROTECT=ONJ

.... act on the default disc.


SET *.*[PASSWORD=SALLYJ
SET *.*[PROTECT=READJ

.... act on files on the default disc (the wild cards

* . * used here indicate 'all files').

Date and time stamping can be activated by the I NIT DI R command (on Side 2 of
your system discs package). The commands:
INITDIR
SET [CREATE=ONJ .... or .... SET [ACCESS=ONJ .... and ....
SET [U PDATE = 0 NJ .... together with .. "
DIR [FULL]

.... will initiate and display date and time stamping on the default drive. Typing in:
DATE SET

.... is then required each time CP/M Plus is started, to set the clock. Once set, the clock
will keep reasonable time, updated automatically by the 6128 and inspected by:
DATE .... and ....
DATE CONTINUOUS

WARNING
If passwords, disc labelling, or date and time stamping have been activated,
then it is recommended that the disc is NEVER subsequently written to by
AMSDOS or CP/M 2.2, neither of which support these facilities.

AMSDOS

and CPIM

Chapter 6 Page 31

Normally, files will accessed on the default drive only, unless a particular drive is
specified. The command:

SETDEF *,A:
.... (where * refers to the default drive) instructs CP/M (when it searches for files) to
search firstly on the default drive, then on Drive A : . In other words, if the default
drive is B : then files will be found automatically even if they only exist on Drive A : .
The commands:

SET DEF [PA GEJ .... and ....


SETDEF [NOPAGE]
.... turn on and off the automatic pagination of console display.
Remember that most of the facilities of DEVICE, SET, and SET DE F particularly
where they refer to drives (rather than files or discs) need to be set up, together with
the date, each time CP/M Plus is started. This is a prime application for a suitable
PRO F I LE. SUB file.
SUB MI T is required to execute files of individual commands automatically. The
contents of the command files are text, and it is possible to include input to programs
if the first character on those lines in the . SUB file is <

The drive size, amount of space, and number of directory entries left on a disc,
together with the user areas containing files, and the disc label (if any) may be
displayed by various combinations of the S HOW command:

SHOW
SHOW
SHOW
SHOW
SHOW

B:
B:[LABELJ
B:[USERS]
B:[DIR]
B:[DRIVEJ

.... all specify statistics from Drive B :

Exit .. ing CP/M Plus


AMSDOS
This program relinquishes control from CP/M and returns to the built-in AMSTRAD
BASIC, from which the AMSDOS disc commands will be available.

Chapter 5 Page 32

AMSDOS and CP/M

Advanced programming
Side 2 of your system discs package contains a number of programs intended for use
by advanced and system programmers. It is recommended that the user consult
SOFT 971- A Guide to CP/M Plus, or other reference works.

Working with CP/M 2.2


This section is intended to highlight the differences when operating using CP/M 2.2.

CP/M 2.2 is loaded from the first two tracks of a System disc. The bootstrap sector is
different from that used to load CP/M Plus and care should be taken not to confuse
them. Although it is possible to use Vendor, IBM, and Data format discs in either disc
drive, operational considerations usually restrict their use to the second disc drive.
Unless special action is taken by the CPIM program (as F I LEe 0 PY does for
example) then CPIM 2.2 will not allow you to write to a disc unless it has been 'logged
in'. Furthermore, the type of disc format (System, Data, or IBM) is only
re-determined when a disc is logged in. For the main disc drive within the computer
(Drive A) this takes place whenever CP/M 2.2 returns to the Direct Console Mode, or
when [CONTROl]C is typed at the A> or B> prompt. For an additional drive (Drive
B) this takes place the first time that the disc in Drive B is accessed, after Drive A has
been logged in.
Should you try writing to a disc that has not been logged in, the infamous error
message:
Bdos Err on ,drive>:

RIO

.... will be displayed. Press any key to continue. If the changed disc was also of a
different format then a read or write error will occur. Type C to continue.
If you receive software on a disc in Vendor format, then in order to use it
conveniently, you may either copy it to a CPIM 2.2 system disc by using F I LEe 0 P Y
or PIP, or alternatively convert the disc to a system disc by adding your CP/M to it.
This is achei ved with the BOO T GENand S YS GEN commands. Carefully read the
End User Licence Agreement in this manual (Appendix 1).
S YSGE N (with no parameters) is a specialised copier program which prompts for a
source and destination disc, and copies the CP/M 2.2 system tracks from one disc to
another. BOO T GEN similarly copies Sector 1, track 0 (the loader) and the
configuration sector from one disc onto another.

The DI R command does not accept parameters (other than a file specifier). The
filenames are not sorted into any particular order, but the po si tion of the filename in
the DI Rdisplay indicates the position of that file's entry in the disc directory.

AMSDOS and CPIM

Chapter 5 Page 33

STAT provides some of the basic functions of SET and SHOW. The commands:

STAT
STAT A:
STAT B:
.... display disc status and free space.
The commands:

STAT *.COM
STAT DISC.BAS
.... display extended directory information about a particular file.
The commands:

STAT *.COM $R/O


STAT DISC.BAS $R/O
.... set a file to a Read/Only status, so that it cannot be accidentally erased or
overwritten.
The commands:

STAT *.COM $R/W


STAT DISC.BAS $R/W
.... set a file to ReadIWrite status, reversing the Read/Only assignment.
The commands:

STAT *.COM $SYS


STAT SECRET.BAS $SYS
.... set a file to 'System' status so that it is invisible to directory listings and file
copying programs. The file will still be available for all other purposes.
The commands:

STAT *.COM $DIR


STAT SECRET.BAS $DIR
.... set a file to 'Directory' status, reversing the 'System' assignment.
The utility F I LEe 0 P Y allows you to copy files from one disc to another using a
single drive. It copes with disc changing and gives full instructions on the screen. If a
wild-card filename is specified then F I LEe 0 P Y asks you to confirm that you indeed
wish to copy each file on an individual basis. The program informs you of each
filename as each file is copied.

Chapter 6 Page 34

AMSDOS and CPIM

FILECOPY *.COM

.... copies all files of type CO M

FILECOPY PIP.COM

.... copies the file PIP. CO M

DI S CKIT 2 performs the same functions as DI S CKIT 3, but is somewhat slower


when copying discs as it has less memory available to it.
Two utilities are available which transfer files between disc and cassette. Except for
specialist use, it is unlikely that anything other than ASCII, i.e. plain text, files can
usefully be transferred.
CL 0 AD (Cassette LOA D) can take two parameters, the first is the source (cassette)
filename, enclosed in double quotes, and the second is the destination (disc) filename.
If the destination filename is omitted, the disc file will have the same name as the
cassette file. If the source filename is omitted then C LOA D reads the' first file
encountered on the tape. If the first character of the cassette filename is ! then the
normal cassette messages will be suppressed.
Example command:

CLOAD "MY LETTER" MYLETTER.TXT


CS AVE (Cassette S AVE) can take three parameters. The first is the source (disc)
filename and the second is the destination (cassette) filename, enclosed in double
quotes. If the destination filename is omitted, the cassette file will have the same
name as the disc file. If the first character of the cassette filename is ! then the
normal cassette messages will be suppressed. If both filenames are specified, then a
third parameter may be used to specify the tape write speed; 0 for nominal 1000 baud,
1 for nominal 2000 baud.
Example commands:

CSAVE OUTPUT.TXT "OUTPUT TEXT" 1


CSAVE DATAFILE

SETUP
This utility allows you to re-d~fine the characteristics of the 6128 keyboard, the disc
drive section, and the serial interface. It also enables you to initiate various actions
when CP/M 2.2 is first loaded. Unlike the separate utilities provided with CP/M Plus,
which actually perform their duty when run, SET UP modifies the configuration
sector of a disc (which is only invoked when a disc is cold-booted). In this way, it is
similar to the action of the PRO F I LE. SUB utility.

AMSDOS and CPIM

Chapter 5 Page 35

The program is menu-driven and when a particular screen is correct, or requires no


modification, move on to the next by answering Y to the question:

Is this correct (Y/N):_


The program can be aborted by [CONTROL]C keys. When all the changes have been
made it will prompt:

Do you want to update your system disc (Y/N):_


.... giving you the opportunity to retain the existing configuration sector by typing N.
It will also prompt:

Do you want to restart CP/M (Y/N):_


.... allowing you to load and try the new configuration by typing Y.
To copy a configuration sector from one disc to another, either use BOO TGEN, or load
SET UP from the source disc, answer Y to EVERY question, inserting the destination
disc just before answering Y to the question 'D 0 yo u wan t to u pd ate yo u r
system disc

(Y/N):_'.

Characters with an ASCII value less than decimal 32 can be typed into strings by
typing a t followed by a suitable character from the set @,A - Z, [, \, ] ,> ,_
The following options are those more commonly requiring attention:

**

InitiaL command buffer:

Any characters entered here will appear as if they had been typed into the Direct
Console Mode when CP/M is first loaded. This has the effect of auto-running a
particular program at that time. Remember' to include the equivalent of the
[RETURN] key which is represented by the two characters t M
For example, to auto-run DI R, the initial command buffer should contain:
DI RiM

'" .or, to auto-run the Dr. LOGO program, the initial command buffer would contain:
SUBMIT LOG02

Sign-on string:
This is the message displayed at the top ofthe screen when CP/M is first loaded. Note
the use of t J t Mto give a carriage return/line feed effect. The early part of the
standard message sets suitable screen and border colours for working in 80 column
mode, and should be copied exactly if they are to be preserved.

Chapter 5 Page 36

AMSDOS and CP/M

Keyboard transLations:
This allows new ASCII values to be set into keys, effectively simulating the KEY 0 E F
command in BASIC. The parameters required are the key codes, and the ASCII
values to set into them. For an illustration of key numbers, refer to the diagram at the
top right hand side of the computer, or to part 4 of the chapter entitled 'For your
reference .... ' .

Keyboard expansions:
Effectively simulates the KEY command in BASIC.

Tail enders ....


The 0 I S CKIT 2, S YS GEN, BOO TGEN, F I LE COP Y, SET UP, CS AVE, and CLOA 0
commands are designed by AMSTRAD, and work exclusively with CP/M 2.2 on the
AMSTRAD system. They have no function on any other CP/M system, although other
manufacturers may supply similar utilities (often with the same names) customised
for their hardware.
The following CP/M 2.2 programs are also available on Side 4 for specialist use, and it
is recommended that the user consult SOFT159 - A Guide to CP/M, or other reference
works.

ASM
DOT
DUMP
EO
LOAD
MOVCPM
SUBMIT
XSUB

8080 Assembler.
8080 Assembly code debugging aid.
Hexadecimal file dump utility.
A simple context editor.
Converts a HEX file produced by A SMinto a CO Mfile.
Create CPIM 2.2 with new (smaller) TPA size.
Console Command Mode batch processing.
Transient program batch processing.

The above programs are for use with CP/M 2.2 (on Side 4), and should not be confused
with other programs on the CPIM Plus sides ofthe discs (Sides 1, 2, and 3).

AMSDOS and CPIM

Chapter 5 Page 37

Chapter 6
Introduction to L
This Section is intended to introduce the subject of LOGO, with
examples, and provide a guide to the commands available. It is
not intended to be an exhaustive tutorial or reference guide, and
it is recommended tha t you consult the range ofpublica tions from
AMSOFT and other independent publishers for further
information on this subject.
This chapter covers:

**
**
*

The concept of LOGO


Loadi:Q.g and Running Dr. LOGO
Turtle Graphics
Writing your own procedures
Editing your own procedures

What is LOGO?
LOGO can help you grow as a programmer, whether or not you have ever
programmed before.
LOGO is a powerful programming language that is rapidly gaining popularity
because it is so easy to learn and use.
You use procedures as building blocks to create LOGO programs. Dr. LOGO itself is a
collection of procedures, called primitives, that you use to build your own programs.
During the 1970s, a team of computer scientists and educators under the direction of
Seymour Papert, developed LOGO with turtle graphics to allow very young children
to program and use a computer.
They developed the turtle so that young learners could have, as Papert says, 'an
object to think with; a tool to help them learn in new ways'.
In the form of an arrow head, the turtle can be directed across the screen by the use of
simple commands.

Introduction to Logo

Chapter 6 Page 1

Dr. LOGO
Dr. LOGO is a thoughtful implementation of LOGO which has been specially
customised for the AMSTRAD personal computer to make it even easier to program.
Extensions have been included to make available the powerful sound facilities ofthe
6128, and program editing is made easy by the inclusion of the cursor keys.

Getting Started
To operate Dr. LOGO, insert a copy of Side 1 of your master discs package into the
computer's disc drive, and type in:

ICPM
At the A> prompt, remove the disc (Side 1) from the drive, and insert your working
copy of Side 3 (DR. LOGO & HELP).
To run Dr. LOGO, type in:
SUBMIT LOG03

.... and after a few seconds, you will see the opening 'Welcome' message, followed by
the question mark? prompt.

Dr. LOGO for CP/M 2.2


NOTE - The version of Dr. LOGO which you will find on Side 4 of your
master package has been provided in case you require a copy of Dr. LOGO
to operate with CP/M 2.2 (used on AMSTRAD models CPC664 and
CPC464+ DDIl), It is therefore not generally recommended to use the Side
4 version of Dr. LOGO on the CPC6128. The version provided on Side 3 of
your master package is Digital Research's full specification Dr. LOGO.
If you DO however wish to use the CP/M 2.2 version of Dr. LOGO, insert a
copy of Side 4 ofthe master package and type:

ICPM
At the A> prompt, type in:
SUBMIT LOG02

.... and after a few seconds, you will see the opening 'Welcome' message,
followed by the question mark? prompt.

Chapter 6 Page 2

Introduction to Logo

First Steps....
The? prompt tells you that Dr. LOGO is waiting for you to type something at the
keyboard.
Try typing in (using lower case letters):
fd 60

.... and you will see a turtle (a large arrow head) appear, which then moves forward 60
units leaving a line behind it from where it started, to where it finished. The screen
will clear giving a large graphics area and a smaller text area with the? prompt near
the bottom ofthe screen.
Dr. LOGO will often decide to re-arrange the screen so as to give either a large text
area or large graphics area, for your convenience.
Type in:
rt 90

.... and the turtle will move 90 degrees to the right.


Now type in:
fd 60

.... and another line will be drawn the same length, at right angles to the first line.
Experiment with the simple instructions f d, b k (short for back), r t and Lt (short
for left) to see what happens on the screen.

Dr. LOGO Procedures


A procedure is a list of instructions that tells Dr. LOGO how to do a task.
You will probably write your first procedures by adding to those already built into Dr.
LOGO, these are called 'primitives'.

f d, b k, r t and Lt are all built-in primitives which you may use at any time as
building blocks to write your own procedures.
Another very useful built-in primitive is cs which clears the screen and sends the
turtle to its starting position.

Introduction to Logo

Chapter 6 Page 3

Writing Cl Simple Procedure


It is easy to visualise that ifthe movements:
fd 60 rt 90
.... were to be repeated 4 times each, a square with sides of60 units would be drawn.
The same effect can be achieved by writing a simple formula:

repeat 4 [fd 60 rt 90]


Clear the screen and then try typing this in to check what happens.
To make this formula into a new procedure called '5 q U are', type:

to square
repeat 4 [fd 60 rt 90]
end
Dr. LOGO will now understand '5qua re', and each time it encounters the word
'5 q U are' it will draw a square on the screen. We could have given this procedure
any name, but we chose '5 qu a r e'toremind us what it does.
Dr. LOGO allows us to type in a whole set of commands together so the instructions:

square rt 45 square
.... will draw two squares, the second at a 45 degrees angle to the first.

Procedures with parameters


It is possible to make a procedure to which we can say 'how much', in the same way
that we can say 'how much' to a built-in procedure. To make a procedure thatwill
draw squares of different sized sides, the definition of' 5 q U are' can be altered to:

to squareanysize :side
repeat 4 [fd :side rt 90]
end
You will notice that the variable : 5 i de starts with a colon. This indicates to Dr.
LOGO that: 5 i de is a variable rather than a command.
When we use the procedure 5 q U are any 5 ; z e, the variable : 5 ; d e must have a
value. Hence the instruction 5 q U are any 5 ; z e 1 50 would produce a square
with sides of150 units.

Chapter 6 Page 4

Introduction to Logo

Try adding two procedures together and see what happens. For example from an
instruction:

cs squareanysize 100 rt 45 squareanysize 150


.... the turtle will draw two squares of differing sized sides, and one will be at a 45
degrees angle to the other.
Notice how Dr. LOGO uses an exclamation mark! to remind you that a line of
commands has split across more than one line of screen.

Using Variables to remember values


Dr. LOGO will also allow us to use variables to remember values, as well as for
passing values to a procedure.
First define a new procedure called triangle:

to triangLe
repeat 3 [fd :edge rt 120]
end
We can test this by typing:

make "edge 100


triangLe
If we want to know the value remembered by : e d 9 e we can just type : e d 9 e after
the? promptandDr. LOGO will print the value.
Finally, we can use our variable : e d 9 e in a new procedure to draw a pattern. Notice
how the value of : e d 9 e is increased by adding to its previous value so that each time
we draw the pattern, it gets bigger.

to pattern
triangLe Lt 60 triangLe rt 60
make "edge :edge+4
pattern
end
make "edge 10
cs pattern
When you have seen enough, pr~ss [ESC] to stop the program.

Introduction to Logo

Chapter 6 Page 5

Editing programs and procedures


Dr. LOGO allows us to correct typing mistakes and to alter procedures we have
defined. The editing keys to use are:
The cursor keys 0-'0-<][; which move the cursor by one character or line at a time.
The cursor keys oo~Q pressed at the same time as holding down
[CONTROL] will move the cursor up and down a page, and to the left and right of a
line.
[ClR] deletes the character under the cursor, [DEL] deletes the character to the left of
the cursor.
[RETURN] tells Dr. LOGO that you have finished editing a line of commands, or
makes a new line if you are editing a procedure.
[ESC] means abandon, and [COPy] tells Dr. LOGO that you have finished editing a
procedure.

When typing in commands or new procedures, simply edit the text in front of you on
the screen. Characters will be inserted into the text at the cursor position.
To edit an already existing procedure, use the command ed, and Dr. LOGO will
display the old version of the procedure on the screen. You may then use the
previously described methods to move the cursor around the screen, and change the
text.
Try editing the procedure' pat t ern' by typing:

ed "pattern
Experiment with the editing keys. If, when you have finished, you press [ESCl, then
Dr. LOGO will abandon what is on the screen and give you back the original unedited
version.
Type e d " pat t ern again, and after changing the number 4 to 8, press [COPy] to
exit, then re-run the procedure and see how the screen output has changed.
Remember to set the initial value into: e d 9 e

Operating hints
The workspace used by Dr. LOGO is divided into nodes. You can see how many are
left by typing:

nodes

Chapter 6 Page 6

Introduction to Logo

Occasionally, when nearly all the nodes are used up, Dr. LOGO will tidy up the
workspace and you may see the turtle pause while this happens. You can ask Dr.
LOGO to tidy the workspace by typing the command:

recycLe
This will often allow you to continue after Dr. LOGO has complained of not having
any more nodes left.

If you are using the CPIM 2.2 version of Dr. LOGO (on Side 4 of your master package),
make sure that there is plenty of disc space left before starting Dr. LOGO in case you
decide to save your procedures on disc. You can use the CAT command in AMSDOS
(see part 7 of the Foundation course) to see how much free space there is on a disc.
Now work through the following sections and try some of the examples - you won't
understand everything first time! As you learn about Dr. LOGO you will be able to
use more and more of the commands.
When you have finished with Dr. LOGO type:

bye

Summary of Dr. LOGO primitives


The following section groups together alphabetical lists of Dr. LOGO primitives
showing the inputs to use, often with an example.

NOTE
Commands indicated by an asterix * are NOT available in the CP/M 2.2 version
of Dr. LOGO (on Side 4 of your master package), and programs using these
commands will therefore not be downwards compatible with the CPC664 or
CPC464+ DDIl, running CP/M 2.2

Introduction to Logo

Chapter 6 Page 7

Word and List Processing:


(N ote that prompts? and> are shown in the following examples)

ascii
Outputs the ASCII value of the first character in the input word.

?asc;; "G
71

?asc;; "g
1133

bf
(but first) Outputs all but the first element in the input object.

?bf "srn; les

m; le s
?bf [1 2 3]
[2 3]

bl
(but last) Outputs all but the last element in the input object.

?bl "srn; les


srn; le
?bl [1 2 3 4]
[1 2 3]

char
Outputs the character whose ASCII value is the input number.

?char 83
S

Chapter 6 Page B

Introduction to Logo

count
Outputs the number of elements in the input object.
?count "six
3
?count [0 1 2 3]
4

emptyp
Outputs T RUE if the input object is an empty word or an empty list, otherwise
outputs FA LS E.
?emptyp "

TRUE
?emptyp []

TRUE
?emptyp [x]
FA LS E
?make "x []
?emptyp :x

TRUE

first
Outputs the first element ofthe input object, removes list's outer brackets.
?first "zebra

z
?first [1 2 3]
1

(put
(firstput) Outputs a new object formed by making the first input object the first
element in the second object.
?fput IfS "mi Les
sm; Les
?fput 1 [2 3]
[1 2 3]

Introduction to Logo

Chapter 6 Page 9

item
Outputs the specified element of the input object.

?item 4 "dwarf
r

last
Outputs the last element of the input object (compare with fir s t).

?Last "skyLine
e

le
Outputs the input word with all alphabetic characters in lower case (see also u c).

?Lc "SOUTH
south

list
Outputs a list made up ofthe input objects, retains list's outer brackets (compare with
se).

?(List 1 234)
[1 2 3 4]

?List "big [feet]


[big [feet]]
?<List)
[]

listp
Outputs T RUE if the input object is a list, otherwise outputs FA LSE.

?Listp "mother
FALSE
?Listp [father brother sister]
TRUE

Chapter 6 Page 10

Introduction to Logo

Iput
(lastput) Outputs a new object formed by making the first input object the last
element in the second input object.

?Lput "s "pLuraL


pLuraLs
?Lput "s [pLuraL]
[pLuraL s]

*
memberp
Outputs T RUE ifthe first input object is an element of the second input object.

?memberp "y "onLy


TRUE
?memberp "chocoLate [[vani LLa][chocoLate][strawberry]]
FA LS E

?memberp [chocoLate] [[vani LLa][chocoLate][strawberry]]


TRUE

*
numberp
Outputs T RUE ifthe input object is a number.

?numberp 374.926
TRUE
?numberp "six
FALSE

?numberp first [2 4 6 8]
TRUE

piece
Outputs an object that contains the specified elements ofthe input object.

?piece 4 7 "Kensington
sing
?piece 2 4 [Nana John MichaeL Wendy TinkerbeLL]
[John MichaeL Wendy]
Introduction to Logo

Chapter 6 Page 11

se
(sentence) Outputs a list made up of the input objects, removes list's outer brackets
(compare with Lis t) ..

?make "instr_list rl
repeat 4 [fd 50 rt 90]
?run (se "cs :instr_list "ht>
Note that the underline character between ins t rand Lis t is obtained by
pressing [SH 1FT] 0

shuffle
Outputs a list that contains the elements of the input list in random order.

?shuffle [a b c d]
[c b d a]

ue:
Outputs the mput word with all alphabetic characters in upper case (compare with.
Le).

?uc "jones
JONES

where
Outputs a number calculated from the most recent successful me mb e r p expression.

?memberp "v "river


TRUE
?show where
3

word
Outputs a word made up of the input words.

?word "sun "shine


sunshine

Chapter 6 Page 12

Introduction to Logo

wordp
Outputs T RUE if the input object is a word or a number.

?wordp "hello
TRUE

?wordp []
FA LS E

Arithmetic Operations:
*

arctan
Outputs the arc-tangent (in degrees) of the input number.

?arctan 0

?arctan 1

45

cos
Outputs the cosine of the input number of degrees.

?cos 60
0.5

int
Outputs the integer portion of the input number.

?int 4/3
1

quotient
Outputs the integer division of the two input numbers.

?quotient 14 4
3

?14/4
3.5

Introduction to Logo

Chapter 6 Page 13

random
Outputs a random non-negative integer less than the input number.

?random 20
7

*
remainder
Outputs the integer remainder obtained when the first input number is divided by
the second.

?remainder 7 3
1

?remainder 8 4

*
rerandom
Makes a subsequent random expression reproduce the same random sequence.

?repeat 10
1
3
7
?repeat 10
4
9
9
?rerandom
?repeat 10
5
2
9
?rerandom
?repeat 10
5
2
9

[(type random 10 char 9)J


5
3
2
0
4
[(type random 10 char 9)J
1
6
1
0
3

[(type random 10 char 9)J


3
1
0
6
2

[(type random 10 char 9)J


3
1
0
6
2

*
round
Outputs the input number rounded off to the nearest integer.

?round 3.333333
3

?round 3.5
4

Chapter 6 Page 14

Introduction to Logo

sin
Outputs the sine of the input number of degrees.
?sin 30

0.5

+
Outputs the sum of the input numbers.

?+ 2 2
4

?2+2
4

Outputs the difference of the two input numbers.

?- 10 5
5
?10-5
5

Outputs the product of input numbers.

?* 4 6
24

?4*6
24

/
Outputs the quotient of the two input numbers.

?/ 25 5
5

?25/5
5

Introduction to Logo

Chapter 6 Page 15

Logical Operations:
and
Outputs T RUE if the result of all input expressions are true.
?and <3(4)
TRUE

(7)4)

Rot
Outputs T RUE ifthe input expression is false.
Outputs FA LS E if the input expression is true.
?not <3=4)
TRUE
?not <3=3)
FA LS E

or
Outputs FA LSE if all input expressions are false.
?or "TRUE "FALSE
TRUE
?or <3=4) (1=2)
FALSE

=
Outputs T RUE if the two input objects are equal; otherwise outputs FA LSE.
? = "LOGO "LOGO
TRUE
?1=2
FALSE

>
Outputs T RUE if the first input word is greater than the second; otherwise outputs
FA LS E.
?> 19 20
FALSE

?20>19
TRUE

Chapter 6 Page 16

Introduction to Logo

<
Outputs T RUE if the first word is less than the second; otherwise outputs FA LSE.
?< 27 13
FA LS E
?13<27
TRUE

Variables:
local
Makes the input-named variable(s) accessible only to the current procedure and the
procedures it calls.

>(locaL "x "y "z)

make
Makes the input-named variable the value of the input object.

?make "side Sl?l


?:side
Sl?l

*
namep
Outputs T RUE if the input word identifies a defined variable.

?make "fLavour "chocoLate


?:flavour
chocoLate
?namep "fLavour
TRUE

?namep "chocoLate
FALS E

Introduction to Logo

Chapter 6 Page 17

thing
Outputs the value of the input-named variable.

?make "computer "amstrad


?thing "computer
amstrad

Procedures:
*

define
Makes the input definition list the definition ofthe specified procedure name.

?define "say.heLLo [[J [pr "heLLoJJ


?po "say.heLLo
to say.heLLo
pr "heLLo
?text "say.heLLo
[[J [pr "heLLoJJ
end

end
Indicates the end of a procedure definition; must stand alone at the beginning of the
last line.

?to square
>repeat 4 [fd 50 rt 90J
>end
square defined
?square

po
(print out) Displays the definition(s) of the specified procedure(s) or variable(s).

?po "square
to square
repeat 4 [fd 50 rt 90J
end
?make "x 3
?po "x
x is 3
Chapter 6 Page 18

Introduction to Logo

pots
(print out titles) Displays the names and titles of all procedures in the workspace.

?pots

text
Outputs the definition list of the specified procedure.

?to star ;five pointed star


>repeat 5 [fd 30 rt 144 fd 30 It 72]
>end
star defined
?text "star
[[] [repeat 5 [fd 30 rt 144 fd 30 It 72]]]

to
Indicates the beginning of a procedure definition.

?to square
>repeat 4 [fd 50 rt 90]
>end
square defined

Editing:
ed
(edit) Loads the specified procedure(s) and/or variable(s) into the screen editor's
buffer.

?ed "square

edall
Loads all the variables and procedures in the workspace into the screen editor's
buffer and enters the screen editor.

?edall
Introduction to Logo

Chapter 6 Page 19

edf
Loads the specified disc file into the screen editor's buffer directly from the disc, or
creates a new file and enters the screen editor with an empty buffer.

?edf "star

Printer Functions:
*
copyon
Starts echoing text to the printer.

?copyon

*
copyoff
Stops echoing text to the printer.

?copyoff

Text Screen:
ct
(clear text) Erases all text in the window that currently contains the cursor, then
positions the cursor in the upper left corner ofthe window.

?ct

*
cursor
Outputs a co-ordinate list that contains the column and line numbers of the cursor's
position within the text window.

?ct
?cursor
[0 1]

?(type [The current cursor position is\] show cursor


The current cursor position is [32 23]
Chapter 6 Page 20

Introduction to Logo

pr
(print) Displays the input object(s) on the text screen, removes list's outer brackets,
follows last input with a carriage return (compare with s how and t y pe).

?pr [a b c]
a b c

setcursor
Positions the cursor at the location specified by the input text screen co-ordinate list.

?ct
?to picture
>make "x random 2111
>make "y random 12
>setcursor list :x :y pr "*
>end
?picture

setsplit
Sets the number oflines in the split screen.

?setsplit HI

show
Displays the input object on the text screen, retains list's outer brackets, follows
input with a carriage return (compare with p rand t y pe).

?show [a b c]
[a

b c]

ts
(text screen) Selects a full text screen.

?ts
Introduction to Logo

Chapter 6 Page 21

type
Displays the input object(s) on the text screen, removes list's outer brackets, does not
follow last input with a carriage return (compare with p rand 5 how).

?type [a b c]
a b c

Graphic screen:
Note that the screen is in Mode 1, giving four colours, and that the same co-ordinate
system is used as in AMSTRAD BASIC. In other words all screen positions will be
rounded to the nearest even-numbered screen dot. Red green and blue colours can
have amounts ofO, 1, or 2.

clean
Erases the graphic screen without affecting the turtle.

?fd 50
?cLean

cs

(clear screen) Erases the graphic screen and puts the turtle at [0,0] heading (north)
with the pen down.

?rt 90 fd 50
?cs

dot
Plots a dot at the position specified by the input co-ordinate list in the current pen
colour.

?dot [50 10]

Chapter 6 Page 22

Introduction to Logo

dotc
Outputs the colour number ofthe dot at the specified input co-ordinate list, or -1 if the
location is not on the screen.

?cs
?setpc 1
?dot [-50 50]
?setpc 2
?dot [50 50]
?setpc 3
?dot [50 -50]
?dotc [50 50]
2

?dotc [-50 -50]

?dotc [1000 3000]


-1

fence
Establishes a boundary that limits the turtle to the visible graphic screen. win d 0 w
removes the boundary.

?fence
?fd 300
Turtle out of bounds

Introduction to Logo

Chapter 6 Page 23

fs
(full screen) Selects a full graphic screen.

?fs

pal
(palette) Outputs numbers representing the amount of red, green, and blue colour
assigned to a pen.

?pal 2
[0 2 2]

setbg
Sets the graphic screen background to the colour assigned to the input colour number.

?sf
[0 SS 5 FENCE 1]
(This shows that the background is set to zero.)
? pa l 0

[0 0 1]

?setbg 2
?sf
[2 SS 5 FENCE 1]

setpal
(set palette) Sets the pen colour palette. Assigns an amount of red, green, and blue to
apen.

?setpal 3 [1 1 2]
?pa l 3
[1 1 2]

Chapter 6 Page 24

Introduction to Logo

setscrunch
Sets the graphic screen's aspect ratio to the input number.

?sf
[0 SS 5 FENCE 1]
?to ci rc le
>repeat 360 [fd 1 rt 1]
>end
circle defined
?setscrunch 2
?sf
[0 SS 5 FENCE 2]
?circle
?setscrunch 2.5
?ci rc le

sf
(screen facts) Outputs information about the graphic screen. The format is:
[<bgcolour> <screen-state> <split-size> <window-state> <scrunch>] where <bgcolour> is
the background pen number, (always 0 under CP/M 2.2). <screen-state> indicates SS
(split screen), F S (full screen) or T S (text screen). <split-size> is the number of text
lines displayed on the split screen's text window, and <window-state> indicates
WIN DO W, WRAP, or FEN CE mode. <scrunch> is the aspect ratio of the screen, and
defaults to 1. It can be reset using set s c run c h (not available under CP/M 2.2).

?sf
[0 SS 5 FENCE 2.5]

ss
(split screen) Displays a window of text on the graphic screen.

?ss

window
Allows the turtle to plot outside the visible graphic screen after a wrap or fen c e
expreSSIOn.

?fence fd 300
Turtle out of bounds
?window
?fd 300
Introduction to Logo

Chapter 6 Page 25

wrap
Makes the turtle reappear on the opposite side of the graphic screen when it exceeds
the boundary.

?cs
?rt
?cs
?rt

wrap
5 fd 1000
window
5 fd 1000

Turtle graphics:
bk
(back) MO-ves the turtle the input number of steps in the opposite direction of its
heading.

?cs fd 150
?bk 50

fd
(forward) Moves the turtle the input number of steps in the direction of its current
heading.

?fd 80

home
Returns the turtle to position [0 0] (the centre of the graphic screen) heading 0
(north).
? f d 100
?rt 45 "
?fd 100
?home

Chapter 6 Page 26

Introduction to Logo

ht
(hide turtle) Makes the turtle invisible; speeds and clarifies drawing.

?ht
?cs fd 50
?st

It
(left) Rotates the turtle the input number of degrees to the left.

?Lt 90

pd
(pen down) Puts the turtle's pen down; the turtle resumes drawing.

?fd 20 pu fd 20
?pd
?fd 20

pe
(pen erase) Changes the turtle's pen colour to the background colour; the turtle
erases drawn lines.

?fd
?pe
?bk
?fd
?pd

50
25
50
fd 25

pU
(pen up) Picks the turtle's pen up; the turtle stops drawing.

?fd 30
?pu
?fd 30
?pd fd 30

Introduction to Logo

Chapter 6 Page 27

px
(pen exchange) Makes the turtle exchange the colour of any previously coloured pixel
in its trail with the reverse or logical colour compliment.

?fd 20 pu fd 20
?pd setpc 3 fd 20
?px
?bk 80

?fd 80
?pd bk 100

It
Rotates the turtle the input number of degrees to the right.

?rt 90

seth
(set heading) Turns the turtle to the absolute heading specified by the input number
of degrees; positive numbers turn the turtle clockwise; negative numbers turn the
turtle counter-clockwise.

?seth 90

setpc
(set pen colour) Sets the turtle's pen to that specified by the input number.

?setpc 1

setpos
(set position) Moves the turtle to the position specified in the input co-ordinate list.

?setpos [30 20]

Chapter 6 Page 28

Introduction to Logo

*
setx
Moves the turtle's horizontal position to the x co-ordinate specified by the input
number (see also set y).

?setx 80
?fd 100
?setx -50
?fd 50

*
sety
Moves the turtle's vertical position to the y co-ordinate specified by the input number
(see also set x).

?sety 90
?fd 20
?sety -50
?fd 50

st
(show turtle) Makes the turtle visible ifhidden.

?ht
?fd 50
?st

tf
(turtle facts) Outputs information about the turtle. The format is: [<xcor> <ycor>
<heading> <penstate> <pencolour n> <shownp >] where <xcor> is the turtle's x co-ordinate.
<ycor> is, the turtle's y co-ordinate. <heading> indicates the compass direction the
turtle is facing. <shownp> is T RUE ifthe turtle is visible. <penstate> indicates P D(pen
down), PE (pen erase), P X (pen exchange) or P U (pen up). <pencolour n> identifies the
pen's number.

?setpos [15 30]


?rt 60
?setpc 3
?pe
?ht
?tf
[15 30 60 PE 3 FALSE]

Introduction to Logo

Chapter 6 Page 29

towards
Outputs a heading that would make the turtle face the position specified in the
co-ordinate list.

?seth towards List :x :y

Workspace Management:
er
(erase) Erases the specified procedure(s) from the workspace.

?er "square

erall
Erases all the procedures and variables from the workspace.

?eraLL

em
(erase name) Erases the specified variable(s) from the workspace.

?make "side [100]


?make "angLe [45]
?:side :angLe
[100]
[45]
?ern [side angLe]
?:side
side has no vaLue

nodes
Outputs the number offree nod~s in the workspace.

?nodes
Chapter 6 Page 30

Introduction to Logo

*
noformat
Removes procedure formatting, including comments, from the workspace to free
more nodes.

?noformat

*
poall
Displays the definitions of all procedures and variables in the workspace.

?poall

*
pons
Displays the names and values of all global variables in the workspace.

?pons
medium is 40
small is 20
large is 80

*
pops
Displays the names and definitions of all procedures in the workspace.
?pops

recycle
Frees as many nodes as possible and re-organises the workspace.

?recycle
?nodes

Introduction to Logo

Chapter 6 Page 31

Property Lists:
glist
(get list) Outputs a list of all the objects in the workspace that have the input property
name in their property lists.

?gList ".DEF

gprop
(get 'property) Outputs the property value of the input property name of the
input-named object.

?make "height "72


?gprop "height ".APV
72

plist
(property list) Outputs the property list ofthe input-named object.

?pList "height
[.APV 72]

pprop
(put property) Puts the input property pair into the input-named object's property
list.

?pprop "master ".APV "Scott


?:master
Scott

*
pps
Displays the non-standard property pairs of all objects in the workspace.

?pprop "SaLLy "extension 213


?pps
SaLLy's extension is 213
?pList "SaLLy
[extension 213]

Chapter 6 Page 32

Introduction to Logo

remprop
(remove property) Removes the specified property from the input- named object's
property list.

?remprop "master".APV

Disc Files:
*

changef
Changes the name of a file in a disc directory.

?dir
[SQUARE CIRCLE STARS]
?changef "boxes "square
?di r

[BOXES CIRCLE STARS]

defaultd
Outputs the name of the current default drive.

?defauLtd
A:

dir
(directory) Outputs a list of Dr. LOGO file names on the default or specified disc;
accepts wild-cards.

?dir "a:????????
(Study part 1 of the chapter entitled 'AMSDOS and CP/M' for the use of?? ??? ? ? ?
wild-card characters. Note that the wild-card is not supported in Dr. LOGO.)

Introduction to Logo

Chapter 6 Page 33

dirpic
Outputs a list of picture file names from the default or the specified disc. Accepts an
ambiguous filename.

?dirpie "b:
[MY_PlC SQUARES STARS NOTES]

load
Reads the input-named file from a disc into the workspace.

?Load "myfiLe
?Load "b:shapes

loadpic
Re-creates the design, saved in the input-named picture file onto the graphic screen.

?Loadpie "my_pie
?Loadpie "b:my_pie

save
Writes the contents of the workspace to the input-named disc file.

?save "shapes
NOTE - Before saving, insert a formatted disc with enough free space for the file that
you wish to save. Do not save files onto your master system disc; indeed you should
NEVER even risk writing to it by closing its write-protect holes.
If you are using the CPIM 2.2 version of Dr. LOGO (on Side 4 of your master package),
you cannot change discs mid-session, so it is vital that your CP/M 2.2 Dr. LOGO
working disc has plenty of free space for programs.

Chapter 6 Page 34

Introduction to Logo

*
savepic
Writes the contents of the graphic screen to the input-named picture file.

?savepie "my_pie
? s a v e pie "b: my _p i e
NOTE - Before saving, insert a formatted disc with enough free space for the file that
you wish to save. Do not save files onto your master system disc; indeed you should
NEVER even risk writing to it by closing its write-protect holes.
If you are using the CP/M 2.2 version of Dr. LOGO (on Side 4 of your master package),
you cannot change discs mid-session, so it is vital that your CP/M 2.2 Dr. LOGO
working disc has plenty of free space for programs.

*
setd
(set drive) Makes the specified drive the default drive.

?defauLtd
A:
?di r

[BOXES CIRCLE STARS]


?setd "b:
?defauLtd
B:

?di r

[TRIANGLE HOUSE]

I{eyboard and Joystick:


buttonp
(button pressed) Outputs T RUE if the button on the specified joystick is down;
numbers 0 or 1 identify the two possible joysticks.

?to fire
>LabeL "Loop
>if (buttonp 0) [pr [fire 0!]]
>if (buttonp 1) [pr [fire 1!]]
>90 "Loop
>end
The position of the joystick is tested by padd Le.
Introduction to Logo

Chapter 6 Page 35

keyp
Outputs T RUE if a character has been typed at the keyboard and is waiting to be
read.

?to i nkey
>i f keyp Cop re] Cop "]
>end

paddle
Returns the state of either joystick 0 or 1. The positions of the joystick are indicated as
follows:
Value returned

Meaning

255

Nothing pressed
Up
Up and right
Right
Down and right
Down
Down and left
Left
Up and left

o
1
2
3
4

5
6

?paddLe 0
255
The fire buttons are tested by but ton p.

re
(read character) Outputs the first character typed at the keyboard.

?make "key re
.... then press X key ....

?:key
X

Chapter 6 Page 36

Introduction to Logo

rl
(read list) Outputs a list that contains a line typed at the keyboard; input must be
followed by a carriage return.

?make "instr_List rL
repeat 4 [fd 50 rt 90J
?:instr_List
[repeat 4 [fd 50 rt 90JJ

rq
(read quote) Outputs a word that contains a line typed at the keyboard; input must be
followed by a carriage return.

?make "command rq
repeat 3 [fd 60 rt 120J
?:command
repeat 3 [fd 60 rt 120J

Sound:
The sound commands are unique to the AMSTRAD implementation of Dr. LOGO and
are similar to their AMSTRAD BASIC counterparts.
Refer to part 9 ofthe Foundation course for further information.

sound
Put a sound into the sound queue. The format is: [<channel status> <tone period>
<duration> <volume> <volume envelope> <tone envelope> <noise>] 'The parameters after
duration are optional.

? sound [1 20 50J

env
Set up a volume envelope. The format is: [<envelope number> <envelope section(s)> ]

?env [1 100 2 20J


?sound [1 200 300 5 1J

Introduction to Logo

Chapter 6 Page 37

ent
Set up a tone envelope. The format is:[ <envelope number, <envelope section(s),]
?ent [1 100 2 20]
?sound [1 200 300 5 1 1]

release
Releases sound channels that have been set to a hold state in a sou n d command.
The channels to release are indicated as follows:
Input value

Channels released.

None
A
B
AandB
C
AandC
BandC
AandBandC

1
2
3
4

5
6

7
?reLease

Flow of Control:
bye
Exits the current session of Dr. LOGO.
?bye

co
Ends a pause caused by [CONTROL]Z, p a use or ERR ACT
?co

Chapter 6 Page 38

Introduction to Logo

go
Executes the line within the current procedure following a Lab e L expression with
the same input word.

>go "Loop

if
Executes one of two instruction lists depending on the value of the input expression;
input instructions must be literal lists enclosed in brackets.

>if (a>b) [pr [a is


>[pr [b is bigger]]

bigger]~

label
Identifies the line to be executed after ago expression with the input word.

>LabeL "Loop

op
(output) Makes the input object the output of the procedure and exits the procedure
at that point.

?op [resuLt]

repeat
Executes the input instruction list the input number oftimes.

?repeat 4 [fd 50 rt 90]

Introduction to Logo

Chapter 6 Page 39

run
Executes the input instruction list ..
?make "instr_list [fd 40 rt 90]
?run :instr_list

stop
Stops the execution of the current procedure and returns to TOP LE VEL (the ?
prompt) or the calling procedure.
?stop

wait
Stops procedure execution for the amount of time specified by the input number. The
amount oftime = input number 1160 seconds.

?wait 200

Exception handling:
catch
Traps errors and special conditions that occur during the execution of the input
instruction list.
>catch "error [+ [] [J]
>pr Cl am here]
I am here

error
Outputs a list whose elements describe the most recent error.
>catch "error [do.until.error]
>show error

Chapter 6 Page 40

Introduction to Logo

nob'ace
Turns offtrace monitoring of procedure execution (see t r ace).

?notrace

nowatch
Turns off watch monitoring of all or specified procedure(s)(see wa t ch).

?nowatch

pause
Suspends the execution of the current procedure to allow interaction with the
interpreter or editor.

>i1 :size>5 [pause]

throw
Executes the line identified by the input name in a previous cat c h expression.

?throw "TOPLEVEL

trace
Turns on trace monitoring of procedure execution.

?trace

watch
Turns on watch monitoring of all or specified procedure(s).

?watch

Introduction to Logo

Chapter 6 Page 41

System Primitives:
.contents
Displays the contents of Dr. LOGO symbol space .

.deposit
Puts second input number into the absolute memory location specified by the first
input number .

.examine
Displays the contents ofthe absolute memory location specified.

*
.in
Retrieves the current value of the input-numbered port.

*
.out
Sends the input value to the input-numbered port.

System Variables:
ERRACT
When T RUE, causes a pause when an error occurs, then returns to TOP LE VEL.

FALSE
System value.

Chapter 6 Page 42

Introduction to Logo

RE DE FP
When T RUE allows re-definition of primitives.

TOPLEVEL
t h row" TOP LE VEL will exit all pending procedures.

TRUE
System value.

System Properties:
.APV
Associated property value; the value of a global variable .

.DEF
Definition of a procedure.

.ENL
End of a procedure line that is broken by a carriage return or spaces.

.EMT

Beginning of a procedure line that is broken by a carriage return and spaces .

.PRM
Identifies a primitive.

.REM(Olj)

Remarks or comments.

Introduction to Logo

Chapter 6 Page 43

Chapter 7
For your reference ......
This chapter provides much of the reference information that you
are likely to require as you learn to use this computer.
Subjects covered:

**
**
**
*
**
**
***
**

Cursor locations and control code extensions


Interrupts
ASCII and graphics characters
Key references
Sound
Error messages
BASIC keywords
Planners
Connections
Printers
Joysticks
Disc organisation
Resident System eXtensions (RSX's)
Memory
CP/M Plus Terminal Emulator
CP/MPlusCharacterSet

For a complete guide to the BASIC and firmware for the CPC6128, consult AMSOFT
manuals, SOFT 967 and SOFT 968 respectively.

Part 1: BASIC Cursor locations and control


code extensions
In' a variety of applications programs, the text cursor may be positioned outside the
current window. Various operations force the cursor to a legal position before they
are performed, these being as follows:

For your reference ....

Chapter 7 Page 1

1.

Writing a character

2.

Drawing the cursor 'blob'

3.

Obeying the control codes marked with an asterisk in the list ahead.

The procedure for forcing the cursor to a legal position is as follows:


1.

If the cursor is to the right of the right hand edge, then it is moved to the leftmost
column of the next line down.

2.

If the cursor is to the left ofthe left hand edge, then it is moved to the rightmost
column of the next line up.

3.

If the cursor is above the top edge, then the window is rolled down a line and the
cursor is set to the top line of the window.

4.

If the cursor is below the bottom edge, then the window is rolled up a line and the
cursor is set to the bottom line of the window.

The tests and operations are done in the order given. The illegal cursor positions may
be zero or negative, which are off to the left or above the window.
Character values in the range 0 to 31 sent to the text screen do not produce a
character on the screen but are interpreted as CONTROL CODES (and should not be
injudiciously applied). Some of the codes alter the meaning of one or more of the
following characters, which are the code's parameters.
A control code sent to the graphics screen will merely print the conventional symbol
related to its function if accessed via the keyboard (e.g. &07 'BEL' - [CTRl] G). It will
execute its control function if addressed using the form of the command:
P RI NT CHR$ ( &0 7) , or P RI NT " ~ " (where the ~ is obtained by pressing
[CTRl] G within the PR I NT statement).
The codes marked * force the cursor to a legal position in the current window before
they are obeyed - but may leave the cursor in an illegal position. The codes and their
meanings are described with first their HEX value (&XX), then the decimal
equivalent.

Chapter 7 Page 2

For your reference ....

BASIC Control characters


Value

Name

&00 0

NUL

&01 1

SOH

&02 2

STX

Turn offtext cursor. Equivalent


to CUR S0 R command with a <user
switch> parameter value ofO.

&03 3

ETX

Turn on text cursor. Equivalent


to CUR S0 R command with a <user
switch> parameter val ue of 1.
Note that to display a cursor
from within a BASIC program
(other than the automatic cursor
generated when BASIC is awaiting
keyboard input), a CUR S0 R
command with a <system switch>
parameter value ofl must be
used.

&04 4

EOT

Oto2

Set screen mode. Parameter taken


MOD 4. Equivalent to a MOD E
command.

&05 5

ENQ

Oto255

Send the parameter character to


the graphics cursor.

&06 6

ACK

Enable Text Screen. (See &15 NAK


ahead.)

&07 7

BEL

Sound Bleeper. Note that this


flushes the sound queues.

BS

Move cursor back one character.

&08 8

For your reference ....

Parameter

Meaning
No effect. Ignored.

Oto255

Print the symbol given by the


parameter value. This allows the
symbols in the range 0 to 31 to
be displayed.

Chapter 7 Page 3

Name

Value

Parameter

Meaning

&09 9

* TAB

Move cursor forward one character.

&OA 10

Move cursor down one line.

&OB 11

* VT

&OC 12

FF

Clear text window and move


cursor to top left corner.
Equivalent to a CLS command.

CR

Move cursor to left edge of


window on current line.

&OD 13

LF

Move cursor up one line.

&OE 14

SO

Oto15

Set Paper Ink. Parameter taken


MOD 16. Equivalent to PAP ER
command.

&OF 15

SI

Oto 15

Set Pen Ink. Parameter taken MOD


16. Equivalent to PEN command

&10 16

* DLE

Delete current character. Fills


character cell with current
Paper Ink.

&11 17

* DC1

Clear from left edge of window


to, and including, the current
character position. Fills
affected cells with the current
Paper Ink.

&12 18

* DC2

Clear from, and including, the


current character position to
the right edge of window. Fills
affected cells with the current
Paper Ink.

&13 19

* DC3

Clear from start of window to,


and including, the current
character position. Fills affected
cells with the current Paper Ink.

Chapter 7 Page 4

For your reference ....

Value

Name

Parameter

Meaning

&14 20* DC4

Clear from, and including, the current


character position to the end of window.
Fills affected cells with the current
Paper Ink.

&15 21

NAK

Turn off text screen. The screen will not


react to anything sent to it until after an
ACK (&06 6) is sent.

&16 22

SYN

Oto 1

Parameter MOD 2. Transparent


option. 0 disables, 1 enables.

&17 23

ETB

Oto3

Parameter MOD 4
osets normal graphics ink mode
1 sets XOR graphics ink mode
2 sets AND graphics ink mode
3 sets OR graphics ink mode

&18 24

CAN

&19 25

EM

&1A 26 SUB

For your reference ....

Exchange Pen and Paper Inks.


Oto255
Oto255
Oto255
Oto255
Oto255
Oto255
Oto255
Oto255
Oto255

Set matrix for user definable


character. Equivalent to a
S YMB 0 L command. Takes nine
parameters. The first parameter
specifies which character's
matrix to set. The next eight
specify the matrix. The most
significant bit of the first
byte corresponds to the top left hand
pixel of the character cell, the least
significant bit of the last byte
corresponds to the bottom right
hand pixel ofthe character cell.

1 to80
1 to80
1 to25
1 to25

Set Window. Equivalent to a


WIN DO Wcommand. The first two
parameters specify the left and
right hand edges of the window - the
smaller value is taken as the left edge,
the larger the right. The second two
parameters specify the top and bottom
edges of the window - the smaller value
is taken as the top edge, the larger the
bottom edge.

Chapter 7 Page 5

Value

Name

Parameter

&1B 27 ESC

Meaning
No effect. Ignored.

&1C 28 FS

Oto 15
Oto31
Oto31

Set Ink to a pair of colours.


Equivalent to an INK command.
The first parameter (MOD 16)
specifies the Ink, the next two
(MOD 32) the required colours.
(Parameter values 27 to 31 are
un-defined colours.)

&1D 29 GS

Oto31
Oto31

Set Border to a pair of colours.


Equivalent to aB 0 RDERcommand.
The two parameters (MOD 32)
specify the two colours.
(Parameter values 27 to 31 are
un-defined colours.)

&1E 30 RS
&1F 31

US

Move cursor to top left hand


corner of window.
1 to80
1 to25

Move cursor to the given


position in the current window.
Equivalent to a LO CAT E command.
The first parameter gives the
column to move to, the second
gives the line.

The housekeeping of the 6128 is provided by a sophisticated real time operating


system. The operating system 'directs the traffic' through the computer from the
input to the output.

It primarily interfaces between the hardware and the BASIC interpreter - for
example the ink flashing function, where BASIC passes the parameters - and the
operating system gets on with the task, with one part determining what is required
- and the other part determining the timing of these events.
The machine operating system is generally referred to as the 'firmware', and
comprises the machine code routines that are called by the high level commands in
BASIC.

Chapter 7 Page 6

For your reference ....

If you are tempted to PO KE around in the machine memory addresses, or CALL the
sub-routines, save your program and listing before doing so, or you may regret it! The
extensive operating system firmware of the 6128 is described in SOFT 968, and is
beyond the scope ofthis introductory user manual.
In order to program extensively using machine code, it will be necessary to use an
assembler. The DEVPAC assembler from AMSOFT comprises a relocatable Z80
assembler, with editor, disassembler and monitor.

Part 2: Interrupts
The 6128 makes extensive use ofZ80 interrupts to provide an operating system that
includes several multi-tasking features, exemplified by the AFT ERand EVE RY
structures described earlier in this manual. The precedence ofthe event timers is:
Break ([ESC][ESC])
Timer 3
Timer 2 (and the three sound channel queues)
Timer 1
Timer 0
Interrupts should be included after considering the consequences of possible
intermediate variable states at the point of interruption. The interrupt sub-routine
itself should avoid unwanted interaction with the state of variables in the main
program.
The sound queues have independent interrupts of equal priority. Once a sound
interrupt has started, it is not interrupted by any other sound interrupt. This enables
sound interrupt routines to share variables with immunity from the effects
mentioned above.
When a sound queue's interrupt is enabled (by using 0 N S Q GO SUB), it will
immediately interrupt if the sound queue for that channel is not full, otherwise it will
interrupt when the current sound ends and there is room for more in the queue. The
action of interrupting disables the event, so the sub-routine must re-enable itself if
further interrupts are required.
Both attempting to issue a sound and testing the queue status will also disable a
sound interrupt.

For your reference ....

Chapter 7 Page 7

Part 3: BASIC ASCII and graphics


characters
ASCII
The table below illustrates the standard ASCII reference character set using
decimal, octal, and hex notation, together with the ASCII codes where appropriate.
Each of the 6128 character cells is also represented in detail in the following pages.

DEC OCTAL HEX ASCII characters


0
1
2
3
4
5
6
7
6
9
10
11
12
13
14
15
16
17
16
19
20
21
22
23
24
25
26
27
26
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

000
001
002
003
004
005
006
007
010
011
012
013
014
015
016
017
020
021
022
023
024
025
026
027
030
031
032
033
034
035
036
037
040
041
042
043
044
045
046
047
050
051
052
053
054
055
056
057
060
061

00
01
02
03
04
05
06
07
06
09
OA
OB
OC
OD
OE
OF
10
11
12
13
14
15
16
17
16
19
1A
1B
1C
1D
1E
1F
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F
30
31

NUL ([CTRL]@)
SOH ([CTRL]A)
STX ([CTRL]B)
En< ([CTRL]C)
EOT ([CTRL]D)
ENQ ([CTRL]E)
ACK ([CTRL]F)
BEL ([CTRL]G)
BS ([CTRL]H)
HT ([CTRL]I)
LF ([CTRL]J)
VT ([CTRL]K)
FF([CTRL]L)
CR ([CTRL]M)
SO ([CTRL]N)
SI ([CTRL]O)
DLE ([CTRL]P)
DC1 ([CTRL]Q)
DC2 ([CTRL]R)
DC3 ([CTRL]S)
DC4 ([CTRL]T)
NAK ([CTRL]U)
SYN ([CTRL]V)
ETB ([CTRL]W)
CAN ([CTRL]X)
EM ([CTRL]y)
SUB ([CTRL]Z)
ESC
FS
GS
RS
US
SP

Chapter 7 Page 8

"

%
&
I

(
)

*
,
+

"
1

DEC OCTAL HEX ASCII


50
062
32
2
51
063
3
33
52
064
4
34
53
065
35
5
54
55
56
57
58
59
60
61
62
63
64
65
66
67
66
69
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
65
86
87
68
89
90
91
92
93
94
95
96
97
98
99

066
067
070
071
072
073
074
075
076
077
100
101
102
103
104
105
106
107
110
111
112
113
114
115
116
117
120
121
122
123
124
125
126
127
130
131
132
133
134
135
136
137
140
141
142
143

36
37
36
39
3A
3B
3C
3D
3E
3F
40
41
42
43
44
45
46
47
46
49
4A
4B
4C
4D
4E
4F
50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F
60
61
62
63

6
7
8

9
:

<
=
>
?

A
B
C
D
E
f
G
H
I

J
K
L
M
N
0
P
Q

DEC
100
101
102
103
104
105
106
107
106
109
110
111
112
113
114
115
116
117
116
119
120
121
122
123
124
125
126

OCTAL HEX ASCII


144
145
146
147
150
151
152
153
154
155
156
157
160
161
162
163
164
165
166
167
170
171
172
173
174
175
176

64
65
66
67
66
69
6A
6B
6C
6D
6E
6F
70
71
72
73
74
75
76

77
76
79
7A
7B
7C
7D
7E

e
f
9

j
k

l
m
n
0

q
r
5

t
u

w
x
Y

{
I

R
S

T
U

V
W
X
Y
Z
[

\
]
t

a
b

For your reference ....

Machine specific BASIC graphics character set


The characters reproduced here are plotted on the standard 8
x 8 cell matrix used to write the screen of the 6128. User
defined characters may be grouped for special effects, and
butted next to one another. See the section 'User Defined
Characters' in the chapter entitled 'At your leisure .... '.

32 &H20

&X00100000

11

l1li

11

&H21
&X00100001

34
&H22
&X00100010

37
&H25
&X00100101

38
&H26
&X00100110

41
&H29
&X00101001

42
&H2A
&X00101010

33

35

&H23
&X00100011

39
&H27
&X00100111

40
&H28
&X00101000

43
&H2B
&X00101011

44
&H2C
&X00101100

45
&H2D
&X00101101

For your reference ....

46
&H2E
&X00101110

36
&H24
&X00100100

47
&H2F
&X00101111

48
&H30
&X00110000
Chapter 7 Page 9

49
&H31
&X00110001

50
&H32
&X00110010

51
&H33
&X00110011

52
&H34
&X00110100

53
&H35
&X00110101

54
&H36
&X00110110

55
&H37
&X00110111

56
&H38
&X00111000

57
&H39
&X00111001

58
&H3A
&X00111010

59
&H3B
&X00111011

60
&H3C
&X00111100

61
&H3D
&X00111101

62
&H3E
&X00111110

63
&H3F
&X00111111

64
&H40
&X01000000

65
&H41
&X01000001

66
&H42
&X01000010

67
&H43
&X01000011

68
&H44
&X01000100

Chapter 7 Page 10

For your reference ....

69
&H45
&X01000101

70
&H46
&X01000110

71
&H47
&X01000111

72

&H48
&X01001000

11
11
11

-I

11

73
&H49
&X01001001

74
&H4A
&X01001010

77

&H4D
&X01001101

78
&H4E
&X01001110

81
&H51
&X01010001

82
&H52
&X01010010

85
&H55
&X01 0'10101

86
&H56
&X01010110

For your reference ....

75
&H48
&X01001011

79
&H4F
&X01001111

76
&H4C
&X01001100

80
&H50
&X01010000

83
&H53
&X01010011

84
&H54
&X01010100

87
&H57
&X01010111

88
&H58
&X01011000

Chapter 7 Page 11

89
&H59

90
&H5A

91

&H5B

92
&H5C

&X01011001

&X01011010

&X01011011

&X01011100

93
&H5D

94
&H5E

&X01011101

&X01011110

97
&H61

98
&H62

99

100

&H63

&H64

&X01100001

&X01100010

&X01100011

&X01100100

101

102
&H66

103

104

&H65

&H67

&H68

&X01100101

&X01100110

&X01100111

&X01101000

105

106
&H6A

107

&H69

&H6B

108
&H6C

&X01101001

&X01101010

&X01101011

&X01101100

Chapter 7 Page 12

95
&H5F

96
&H60

&X01011111

&X01100000

For your reference ....

109

110

111

112

&H6D

&H6E

&H6F

&H70

&X01101101

&X01101110

&X01101111

&X01110000

113

&H71

114
&H72

115
&H73

&H74

&X01110001

&X01110010

&X01110011

&X01110100

116

117

118

119

&H75

&H76

&H77

120
&H78

&X01110101

&X01110110

&X01110111

&X01111000

121
&H79

122
&H7A

123

124

&H7B

&H7C

&X01111001

&X01111010

&X01111011

&X01111100

125

&H7D

126
&H7E

&H7F

&X01111101

&X01111110

&X01111111

For your reference ....

127

128
&H80

&Xi 0000000

Chapter 7 Page 13

129
&H81
&Xi 0000001

130
&H82
&Xi 000001 0

131
&H83
&X10000011

132
&H84
&Xi 00001 00

133
&H85
&X10000101

134
&H86
&X10000110

135
&H87
&X10000111

136
&H88
&Xi 0001 000

137
&H89
&Xi 0001 001

138
&H8A
&X10001010

139
&H8B
&X10001011

140
&H8C
&X10001100

141
&H8D
&X10001101

142
&H8E
&X10001110

143
&H8F
&X10001111

144
&H90
&Xi 001 0000

145
&H91
&Xi 001 0001

146
&H92
&X10010010

147
&H93
&X10010011

148
&H94
&X10010100

Chapter 7 Page 14

For your reference ....

149
&H95
&X10010101

150
&H96
&X10010110

151
&H97
&X10010111

152
&H98
&X10011000

153
&H99
&X10011001

154
&H9A
&X10011010

155
&H9B
&X10011011

156
&H9C
&X10011100

157
&H9D
&X10011101

158
&H9E
&X10011110

159
&H9F
&X10011111

160
&HAO
&Xi 01 00000

161
&HA1
&X10100001

162
&HA2
&X10100010

163
&HA3
&X10100011

&HA4
&X10100100

165
&HA5
&X10100101

166
&HA6
&X10100110

167
&HA7
&X10100111

168
&HAS
&X10101000

For your reference ....

164

Chapter" 7 Page IS

169
&HA9
&X10101001

170
&HM
&X10101010

171
&HAB
&X10101011

172
&HAC
&X10101100

173
&HAD
&X10101101

174
&HAE
&X10101110

175
&HAF
&X10101111

176
&HBO
&X10110000

177

&HB1
&X10110001

178
&HB2
&X10110010

179
&HB3
&X10110011

180
&HB4
&X10110100

181
&HB5
&X10110101

182
&HB6
&X10110110

183
&HB7
&X10110111

184
&HB8
&X10111000

185
&HB9
&X10111001

186
&HBA
&X10111010

187
&HBB
&X10111011

188
&HBC
&X10111100

Chapter 7 Page 16

For your reference ....

189
&HBD
&)(10111101

190
&HBE
&)(10111110

191
&HBF
&)(10111111

192
&HCO
&)(11000000

193
&HC1
&)(11000001

194
&HC2
&)(11000010

195
&HC3
&)(11000011

196
&HC4
&)(11000100

197
&HC5
&)(11000101

198
&HC6
&)(11000110

199
&HC7
&)(11000111

200
&HC8
&)(11001000

201
&HC9
&)(11001001

202
&HCA
&)(11001010

203
&HCB
&)(11001011

204
&HCC
&)(11001100

205
&HCD
&)(11001101

206
&HCE
&)(11001110

207
&HCF
&)(11001111

For your reference ....

208
&HDO
&)(11010000
Chapter 7 Page 17

209
&HD1
&X11010001

210
&HD2
&X11010010

III11111
211
&HD3
&X11010011

212
&HD4
&X11010100
III
III

III II1II

213
&HD5
&X11010101

214
&HD6
&X11010110

217
&HD9
&X11011001

218
&HDA
&X11011010

221
&HDD
&X11011101

225
&HE1
&X11100001

Chapter 7 Page 18

215
&HD7
&X11010111

III

II1II1 II1II

216
&HD8
&X11011000

11 11
219
&HDB
&X11011011

220
&HDC
&X11011100

222
&HDE
&X11011110

223
&HDF
&X11011111

224
&HEO
&X11100000

226
&HE2
&X11100010

227
&HE3
&X11100011

228
&HE4
&X11100100

For your reference ....

229
&HE5

230
&HE6

231
&HE7

232
&HE8

&)(11100101

&)(11100110

&)(11100111

&)(11101000

233
&HE9

234
&HEA

235
&HEB

236
&HEC

&)(11101001

&)(11101010

&)(11101011

&)(11101100

237
&HED

238
&HEE

239
&HEF

240
&HFO

&)(11101101

&)(11101110

&)(11101111

&)(11110000

241
&HF1

242
&HF2

243
&HF3

244
&HF4

&)(11110001

&)(11110010

&)(11110011

&)(11110100

245
&HF5

246
&HF6

247
&HF7

248
&HF8

&)(11110101

&)(11110110

&)(11110111

&)(11111000

For your reference ....

Chapter 7 Page 19

249

&HF9

250

251

252

&HFA

&HFB

&HFC

&X11111001

&X11111010

&X11111011

&X11111100

253

254

255

&X11111101

&X11111110

&X11111111

&HFD

Chapter 7 Page 20

&HFE

&HFF

For your reference ....

Part 4: I{ey references


Default ASCII values (HEX)

JOYSTICK 0

JOYSTICK 1
26
36

IFIRE21r'RE
58
5A 11
58

For your reference ....

5A

Chapter 7 Page 21

Expansion characters,
default locations and
values
n

, N/A 11 N/A 11 N/A 11 N/A 11 N/A 11 N/A 11 N/A IF]' N/A 11 N/A 11 N/A 11 N/A 11 N/A 11 N/A 11 N/A

B I N/A 11 N/A 11 N/A 11 N/A 11 N/A 11 N/A 11 N/A 11 N/A 11

N/A

G I N/A

11 N/A I' N/A I' N/A 11 N/A 1

11 N/A 11 N/A 11 N/A 1 N/A 11 N/A 11 N/A 1 N/A

I~=!,::::::::=!,::::::::==

11 N/A 11 N/A 11 N/A ' B / A

~12"'9=;:=1"'3=O~;=:1"'~1:;:=;

1 N/A IEJEJEJEJEJEJEJEJEJGI1~11I N/A 1111 ,

N/A

11 N/A

N lA

181

EXPANSION
CHARACTER
0(128)
1 (129)
2(130)
3(131)
4(132)
5(133)
6(134)
7(135)
8(136)
9(137)
10(138)
11 (139)
12(140)

N/A

li~

1 N/A 1 N/A 1 N/A I

DEFAULT SETTING
CHARACTER

0
1
2
3
4
5
6
7

8
9
[RETURN]
RUN"[RETURN]

ASCII VALUE
&30
&31
&32
&33
&34
&35
&36
&37
&38
&39
&2E
&OD
&52 &55 &4E &22 &OD

Note: Expansion characters 13 to 31 (141 to 159) have a null


value by default. They have values assigned using the
BASIC command KEY. and are assigned to keys using the
command KEY 0 E F.

Chapter 7 Page 22

For your reference ....

!{ey and joystick numbers

JOYSTICK 0

JOYSTICK 1

IFIRE211
FIRE
1I
76
77

IFIRE2jj FIREl j

For your reference ....

52

53

Chapter 7 Page 23

Part 5: Sound
Notes and tone periods
The table which follows, gives the recommended ,tone period> settings for notes in the
usual even tempered scale, for the full eight octave range.
The frequency produced is not exactly the required frequency because the ,tone
period> setting has to be an integer. The RELATIVE ERROR is the percentage ratio
of the difference between the required and actual frequency.

NOTE

C
C#
D
D#
E

F
F#
G
G#
A
A#
8

NOTE

C
C#
D
D#
E

F#
G
G#
A
A#
8

FREQUENCY

16.352
17.324
18.354
19.445
20.602
21.,827
23.125
24.500
25.957
27,500
29.135
30.868
FREQUENCY

32.703
34.648
36.708
38.891
41.203
43.654
46.249
48.999
51.913
55.000
58.270
61.735

Chapter 7 Page 24

PERIOD

3822
3608
3405
3214
3034
2863
2703
2551
2408
2273
2145
2025
PERIOD

1911
1804
1703
1607
1517
1432
1351
1276
1204
1136
1073
1012

RELATIVE ERROR

-0.007%
+0.007%
-0.007%
-0 .. 004 %
+0.009%
-0.016%
+0.009%
-0.002%
+0.005%
+0.012%
-0.008%
+0.011%

Octave -4

'RELATIVE ERROR

-0.007%
+0.007%
+0.022%
-0.004%
+0.009%
+0.019%
-0.028%
+0.037%
+0.005%
-0.032%
+0.039%
-0.038%

Octave-3

For your reference ....

NOTE

C
C#
D
D#
E

F
F#
G
G#
A
A#
B

NOTE

C
C#
D
D#
E

F
F#
G
G#
A
A#
B

NOTE

C
C#
D
D#
E

F
F#
G
G#
A
A#
B

FREQUENCY

PERIOD

65.406
69.296
73.416
77.782
82.407
87.307
92.499
97.999
103.826
110.000
116.541
123.471

956
902
851
804
758
716
676
638
602
568
536
506

FREQUENCY

PERIOD

130.813
138.591
146.832
155.564
164.814
174.614
184.997
195.998
207.652
220.000
233.082
246.942
FREQUENCY

261.626
277.183
293.665
311.127
329.628
349.228
369.994
391.995
415.305
440.000
466.164
493.883

For your reference ....

478
451
426
402
379
358
338
319
301
284
268
253
PERIOD

239
225
213
201
190
179
169
159
150
142
134
127

RELATIVE ERROR

+0.046%
+0.007%
-0.037%
+0.058%
-0.057%
+0.019%
+0.046%
+0.037%
+0.005%
-0.032%
-0.055%
-0.038%

Octave -2

RELATIVE ERROR

+0.046%
+0.007%
+0.081%
+0.058%
-0.057%
+0.019%
+0.046%
+0.037%
+0.005%
-0.032%
-0.055%
-0.038%

Octave-l

RELATIVE ERROR

+0.046%
-0.215%
+0.081%
+0.058%
+0.206%
+0.019%
+0.046%
-0.277%
-0.328%
-0.032%
-0.055%
+0.356%

MiddleC

Octave 0

International A

Chapter 7 Page 25

FREQUENCY

NOTE

523.251
554.365
587.330
622.254
659.255
698.457
739.989
783.991
830.609
880.000
932.328
987.767

C
C#
D
D#
E

F
F#
G
G#
A
A#
B

NOTE

C
C#
D
D#
E

F
F#
G
G#
A
A#
B

C
C#
D
D#
E

F
F#
G
G#
A
A#
B

FREQUENCY

PERIOD

1046.502
1108.731
1174.659
1244.508
1318.510
1396.913
1479.978
1567.982
1661.219
1760.000
1864.655
1975.533

60
56
53
50
47
45
42
40
38
36
34
32

FREQUENCY

NOTE

PERIOD

119
113
106
100
95
89
84
80
75
71
67
63

2093.004
2217.461
2349.318
2489.016
2637.021
2793.826
2959.955
3135.963
3322.438
3520.000
3729.310
3951.066

PERIOD

30
28
27
25
24
22
21
20
19
18
17
16

RELATIVE ERROR

-0.374%
+0.229%
-0.390%
-0.441%
+0.206%
-0.543%
-0.548%
+0.350%
-0.328%
-0.032%
-0.055%
-0.435%

Octave 1

RELATIVE ERROR

+0.462%
-0.662%
-0.390%
-0.441%
-0.855%
+0.574%
-0.548%
+0.350%
+0.992%
+1.357%
+1.417%
+1.134%

Octave 2

RELATIVE ERROR

+0.462%
-0.662%
+1.469%
-0.441%
+1.246%
-1.685%
-0.548%
+0.350%
+0.992%
+1.357%
+1.417%
+1.134%

Octave 3

The above values are all calculated from International A as follows:

FREQUENCY =440*(2t(OCTAVE+N-10)/12)))
PERIOD =ROUND(62500/FREQUENCY)
.... where N is 1 for C, 2 for C#, 3 for D, etc.

Chapter 7 Page 26

For your reference ....

Part 6: BASIC Error messages


1 Unexpected NEXT
A NE XT command has been encountered while not in a FOR loop, or the control
variable in the NE XT command does not match that in the FOR.
2 Syntax Error
BASIC cannot understand the given line because a construct within it is not legal.
3 Unexpected RETURN
ARE T URN command has been encountered when not in a sub-routine.
4 DATA exhausted
ARE ADcommand has attempted to read beyond the end ofthe last DATA.
5 Improper argument
This is a general purpose error. The value of a function's argument, or a command
parameter is invalid in some way.
6 OverfLow
The result of an arithmetic operation has overflowed. This may be a floating point
overflow, in which case some operation has yielded a value greater than 1. 7E t 38
(approx.). Alternatively, this may be the result of a failed attempt to change a
floating point number to a 16 bit signed integer.
7 Memory fuLL
The current program or its variables may be simply too big, or the control structure is
too deeply nested (nested GO SUBs, WHI L Es or FORs).
A MEM0 RY command will give this error if an attempt is made to set the top of
BASIC's memory too low, or to an impossibly high value. Note that an open file has a
buffer allocated to it, and that may restrict the values that MEM 0 RYmay use.

For your reference ....

Chapter 7 Page 27

8 Line does not exist


The line referenced cannot be found.

9 Subscript out of

rang~

One of the subscripts in an array reference is too big or too small.

10 Array aLready dimensioned


One of the arrays in a DI Mstatement has already been declared.

11 Division by zero
May occur in real division, integer division, integer modulus or in exponentiation.

12 InvaLid direct command


The last command attempted is not valid in direct mode.

13 Type mismatch
A numeric value has been presented where a string value is required or vice versa, or
an invalidly formed number has been found in REA Dor I NPUT.

14 String space fuLL


So many strings have been created that there is no further room available, even after
'garbage collection'.

15 String too Long


String exceeds 255 characters in length. May be generated by appending strings
together.

16 String expression too compLex


String expressions may generate a number of intermediate string values. When the
number of these values exceeds a reasonable limit, this error results.

Chapter 7 Page 28

For your reference ....

17 Cannot CONTinue
For one reason or another the current program cannot be restarted using CON T. Note
that CON T is intended for restarting after a S TOP command, [ESG] [ESG], or an
error, and that any alteration of the program in the meantime makes a restart
impossible.
.
18 Unknown user function
NoD E F F N has been executed for the FNjust invoked.
19 RESUME missing
The end ofthe program has been encountered while in error processing mode (i.e. in
an ON ERROR GOTO routine).

20 Unexpected RESUME
RES UME is only valid while in error processing mode (i.e. in an 0 N ERR 0 R GOT 0
routine).
21 Direct command found
When loading a file, a line without a line number has been found.

22 Operand missing
BASIC has encountered an incomplete expression.
23 Line too

long

A line when converted to BASIC internal-form becomes too big.


24 EOF met
An attempt has been made to read past end of the file input stream.
25 Fi le type error
The file being read is not of a suitable type. 0 PEN I N is only prepared to open ASCII
text files. Similarly, LOA D, RUN, etc, are only prepared to deal with file types
produced by S AVE.
For your reference ....

Chapter 7 Page 29

26 NEXT missing
Cannot find a NEX T to match a FOR command. A line number accompanying this
message indicates the FOR command to which this error applies.
27 Fi Le a Lready open
An 0 PEN I Nor 0 PEN 0 UT command has been executed before the previously opened
file has been closed.
28 Unknown command
BASIC cannot find a taker for an external command, i.e. a command preceded by a
bar I.
29 WEND missing
Cannot find aWE NDto match a WHI LE command.

30 Unexpected WEND
Encountered aWE NDwhen not in a WHI LE loop, or aWE NDthat does not match the
current WHI LE loop.
31

Fi Le not open

(See the section ahead entitled 'Disc errors'.)


32 Broken in
(See the section ahead entitled 'Disc errors'.)

AMSDOS Disc errors


There are several errors that may occur during the processing of any filing
operations. BASIC handles all such errors as ERRor number 32, however more
specific information may be returned by the function DE RR when this error number
is detected. This returns values as follows:

Chapter 7 Page 30

For your reference ....

AMSDOS error

DERR value

Cause of error

oor 22

[ESC] has been pressed.

14

1 42 (128+ 14)

The stream is not in a suitable state.

15

1 43 (128+ 15)

Hard end of file has been reached.

16

144 (128+ 16)

Bad command, usually an incorrect


filename.

17

145 (128+ 17)

File already exists.

18

1 46 (128+ 18)

File does not exist.

19

1 47 (128+ 19)

Directory is full.

20

148 (128+20)

Disc is full.

21

149 (128+21)

Disc changed while files were open.

22

150 (128+22)

File is Read/Only.

26

1 5 4 (128+ 26)

Soft end of file has been detected.

If AMSDOS has already reported an error, then bit 7 is set; hence the value of DERR
is offset by 128.
Other values returned by DERR originate from the disc controller and are bit
significant, always with bit 6 set. Bit 7 indicates whether the error has been reported
by AMSDOS (as explained above). The significance of each bit is as follows:

Bit

Significance

Address mark missing.


Not writable - disc is write protected.
No data - can't find the sector.
Drive not ready - no disc in the drive.
Overrun error.
Data error - CRC error.
Always set to 1 to indicate error from disc controller.
Set to 1 if error has already been reported by AMSDOS.

1
2
3
4
5
6
7

For your reference ....

Chapter 7 Page 31

ERR may also return 3 1 if access was attempted when no file was open. The usual
way in which one may use ERR and DERR would be to include an 0 N
ERR 0 R GOT 0 which calls a short routine that checks if ERR has the value 3 1 or
32, and if it is 32, DE RR could be interrogated to give more detailed information
regarding the nature of the error. For example:

10 ON ERROR GOTO 1000


20 OPENOUT "myfi le.asc"
30 WRITE #9,"test-data"
40 CLOSEOUT
50 END
1000 amsdoserr=(DERR AND &7F):REM mask off bit 7
1010 IF ERR<31 THEN END
1020 IF ERR=31 THEN PRINT "are you sure you've typed
line 20 correctly?":END
1030 IF amsdoserr=20 THEN PRINT "disc is full, suggest
you use a new data disc":END
1040 IF amsdoserr=&X01001000 THEN PRINT "put a disc in
the drive, then press a key":WHILE INKEY$="":
WEND:RESUME
1050 END

Part 7: BASIC Keywords


The following is a list of all AMSTRAD CPC6128 BASIC keywords. As such, they are
reserved and can NOT be used as variable names.

ABS, AFTER, AND, ASC, ATN, AUTO


BIN$, BORDER
CALL, CAT, CHAIN, CHR$, CINT, CLEAR, CLG, CLOSEIN, CLOSEOUT, CLS,
CONT, COPYCHR$, COS, CREAL, CURSOR
DATA, DEC$, DEF, DEFINT, DEFREAL, DEFSTR, DEG, DELETE, DERR, DI,
DIM, DRAW, DRAWR
EDIT, El, ELSE, END, ENT, ENV, EOF, ERASE, ERL, ERR, ERROR, EVERY,
EXP
FILL, FIX, FN, FOR, FRAME, FRE

Chapter 7 Page 32

For your reference ....

GOSUB, GOTO, GRAPHICS


HEX$, HIMEM
IF, INK, INKEY, INKEY$, INP, INPUT, INSTR, INT
JOY
KEY
LEFT$, LEN, LET, LINE, LIST, LOAD, LOCATE, LOG, LOG10, LOWER$
MASK, MAX, MEMORY, MERGE, MID$, MIN, MOD, MODE, MOVE, MOVER
NEXT, NEW, NOT
ON, ON BREAK, ON ERROR GOTO 0, ON SQ, OPENIN, OPENOUT, OR,
ORIGIN, OUT
PAPER, PEEK, PEN, PI, PLOT, PLOTR, POKE, POS, PRINT
RAD, RANDOMIZE, READ, RELEASE, REM, REMAIN, RENUM, RESTORE,
RESUME, RETURN, RIGHT$, RND, ROUND, RUN
SAVE, SGN, SIN, SOUND, SPACE$, SPC, SPEED, SQ, SQR, STEP, STOP,
STR$, STRING$, SWAP, SYMBOL
TAB, TA'.i, TAGOFF, TAN, TEST, TESTR, THEN, TIME, TO, TROFF, TRON
UNT, UPPER$, USING
VAL, VPOS
WAIT, WEND, WHILE, WIDTH, WINDOW, WRITE
XOR, XPOS
YPOS
ZONE

For your reference ....

Chapter 7 Page 33

Part 8: Planners
Text and window planner .. MODE 0 (20 columns)
>l

>l

:'!

t:

t:

:e

i!!

i!!

:!

:!

i:!

i:!

l'

l'

::

::

::

::

Chapter 7 Page 34

For your reference ....

Text and window planner .. MODE 1 (40 columns)


iil

iil

III

ill

ill

ill

::;

::;

:il

III

i!!

i!!

::\

::\

::l

::l

:;j

f;j

;;;

;;;

:<l

:<l

g:

III

ill

l!l

"

"

ill

ill

11

11

::l

::l

l:j

!ii

!ii

i!!

i!!

i!!

i!!

i::

i::

:!1

:!1

!!!

!!!

:t

:t

i:l

i:l

;:

;:

::

::

For your reference ....

Chapter 7 Page 35

Text and window planner - MODE 2 (80 columns)


li

li

I!!

I!!

i!!

i!!

1t

1t

18

18

18

18

;S

;S

&l

Ii!

Ii!

ill

ill

ill

ill

ill

ill

&l

&l

5\

5\

11

11

11

:3

f:!

fi

fi

III

III

II!

II!

!:j

!:j

ii!

ii!

III

III

III

i'ii

1j

1j

fii

fii

l!!

l!!

i2

:e

;!

;!

i2

i2

Chapter 7 Page 36

For your reference ....

Sound envelope/music planner

For your reference ....

Chapter 7 Page 37

Part 9: Connections
CPC61281nputlOutput Sockets

po! rwnn

~,,,.,,L

MONITOR SOCKET

12VDCPLUG

@ (,

,,~,L r",L~"

PRINTER SOCKET
JOYSTICK SOCKET

EXPANSION SOCKET

Joystick Socket
VIEWED

PIN
PIN
PIN
PIN
PIN

Chapter 7 Page 38

1
2
3

4
5

..

UP
DOWN
LEFT
RIGHT
SPARE

..

..

REAR

..

..

FROM

PIN
PIN
PIN
PIN

6
7
8
9

FIRE 2
FIRE 1
COMMON
COM 2

For your reference....

Monitor Socket
VIEWED

FROM

REAR

5
6
4 3 2

O~O

PIN 1
PIN 2
PIN 3

RED
GREEN
BLUE

SYNC
GND
LUM

PIN 4
PIN 5
PIN 6

Stereo Socket
RIGHT

y--LEFT

II~

GND

/\

RIGHT
GND

LEFT

PIN 1 LEFT CHANNEL


PIN 2 RIGHT CHANNEL
PIN3GND

Tape Socket
VIEWED FROM REAR

0
o

PIN 1 REMOTE SWITCH


PIN2GND
PIN 3 REMOTE SWITCH

For your reference....

3
5

PIN 4 DATA IN
PIN 5 DATA OUT

Chapter 7 Page 39

Expansion Socket
VIEWED FROM REAR

49

47

45

43

41

39

37

35

33

31

29

27

25

23

21

19

17

15

13

11

50

48

46

44

42

40

38

36

34

32

30

28

26

24

22

20

18

16

14

12

10

==============c==========
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

SOUND
GND
A15
A14
A13
A12
All
Al0
A9
A8
A7
A6
A5
A4
A3
A2
Al

PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34

PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN

AO
D7
D6
D5
D4
D3
D2
Dl
DO
+ 5v
MREO
M1
RFSH
IORO
RD
WR
HALT

35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50

INT
NMI
BUSR2
BUSAK
READY
BUS RESET
RESET
ROM EN
ROMDIS
RAMRD
RAMDIS
CURSOR
L. PEN
EXP
GND
</J

Disc Drive 2 Socket


VIEWED FROM REAR

=d===============
3

PIN1
PIN2
PIN3
PIN4
PIN5
PIN6
PIN7
PIN8
PIN9
PIN10
PIN11
PIN12
PIN13
PIN14
PIN15
PIN16
PIN 17

Chapter 7 Page 40

--

"

READY
GND
SIDE 1 SELECT
GND
READ DATA
GND
WRITE PROTECT
GND
TRACKO
GND
WRITE GATE
GND
WRITE DATA
GND
STEP
GND
DIRECTION SELECT

PIN18
PIN19
PIN20
PIN21
PIN 22
PIN23
PIN 24
PIN25
PIN26
PIN27
PIN28
PIN 29
PIN30
PIN31
PIN32
PIN 33
PIN34

GND
MOTOR ON
GND

N/C
GND
DRIVE SELECT 1
GND

N/C
GND
INDEX
GND

N/C
GND

N/C
GND

N/C
GND

For your reference ....

Printer Port
VIEWED FROM REAR
17

16

15

14

13

12

11

10

35

34

33

32

31

30

29

28

27

26

25

24

23

22

21

PIN 1
PIN 2
PIN 3
PIN 4
PIN 5
PIN 6
PIN 7
PIN 8
PIN 9
PIN 11
PIN 14
PIN 16

--

-'

STROBE
DO
D1
D2
D3
D4
D5
D6
GND
BUSY
GND
GND

PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN
PIN

19
20
21
22
23
24
25
26
28
33

20

19

GND
GND
GND
GND
GND
GND
GND
GND
GND
GND

All other pins Ne

Part 10: Printers


Printer interfacing
The 6128 allows the connection and use of an industry standard 'Centronics style
interface' printer.
The printer cable is simply constructed as a one-to-one connection between the
PRINTER socket at the rear of the computer, and the connector on the parallel
printer. Note that there are two less 'fingers' on the computer printed circuit board
than on the printer connector. This is to allow the use of a standard printed circuit
board edge connector.
The actual pin interface details are illustrated in part 9 of this chapter.
The cable should be constructed so that pin 1 from the computer connects to pin 1 on
the printer; pin 19 from the computer to pin 19 on the printer, etc, etc. However, pins
18 and 36 of the printer should NOT be connected to the computer.

For your reference ....

Chapter 7 Page 41

Note that although there are 17 fingers on the upper row of the computer's PRINTER
socket, the lower row of fingers is numbered 19 onwards (rather than 18 onwards).
This is so that every wire used, connects between exactly the SAME NUMBERED
finger of the computer's edge connector as pin ofthe socket on the printer itself.
The computer uses the BUSY signal (pin 11) to synchronise with the printer, and will
wait if the printer is OFF -LINE.
There are no user set-up commands required, and the output is directed to the printer
by specifying stream # 8 .
Although the CPC6128's PRINTER port is envisaged for use with low cost dot-matrix
printers; with a suitable interface it will support daisywheel printers, graphics
plotters, and multi-colour ink-jet printers. The key to compatibility is the standard
parallel interface.
The customised software in the AMSTRAD DMP2000 and DMP1 printers facilitate
dot-graphics operation, together with the printing of complete screen dumps.

Printer configuration
A facility is provided whereby special characters which may appear on the screen and
which are supported by the AMSTRAD DMP2000 and DMP1, will be printed even
though the character codes for the screen and printer may be different. The majority
of these symbols will only be available when the printer is switched to one of its
foreign language modes. For example:

PRINT CHR$(&A0)
/\

PRINT #8,CHR$(&A0)
/\, is printed on the printer.
This works even though the character code for a circumflex accent on the printer is
&5 E. In other words, the printer routine has recognised &A0 as one of the codes held
in a printer translation table, and has translated it to &5 E so that the same character
appearing on the screen will be printed by the printer. The code &5 E will produce a
circumflex accent on a printer no matter which language mode the printer is set to
(this is not true for all the characters in the translation table). The other characters in
the table are as shown in the following table:

Chapter 7 Page 42

For your reference....

CHR$

Printer
Character
U.K. U.S.A.
On Screen Translation

&AO
&A2
&A3
&A6
&AE
&AF

..

(.

&5E
&7B
&23
&40
&5D
&5B

France Germany

Spain

..

Pt

t
t
t

t
t
t

t
t
t

t
t

(.

t For the printed character, refer to your printer instruction manual.


The above is an extract from the default translations, which can be changed if
required. See the Firmware manual (SOFT 968) for further details.

Part 11 : Joysticks
The built-in software in the computer supports either one or two joysticks. These are
treated as part of the keyboard, and as such, may be interrogated by INK EY and
INKEY$.
Note that in the majority of cases, the main 'fire' button on ajoystick is interpreted as
'Fire 2' by the 6128.
The functions JOY ( Ql) and JOY ( 1 ) enable direct inspection of the first and second
joysticks repectively. The function returns a bit-significant result which indicates
the state of the joystick switches at the last keyboard scan.
The table below indicates the values returned by both joysticks. The JOY values are
followed by values for use in statements which take key numbers as parameters (i.e.
INK EYand KEY DE F).
STATUS

JOYCOMMAND
BIT
SET

Up
Down
Left
Right
Fire 2
Fire 1

0
1
2
3
4
5

For your reference ....

KEY VALUES

VALUE
FIRST
RETURNED JOYSTICK
1
2
4

8
16
32

72
73
74
75
76
77

SECOND EQUIVALENT
KEY
JOYSTICK
48
49
50
51
52
53

'6'
'5'
'R'
'T'
'G'
'F'

Chapter 7 Page 43

Note that when key values for the SECOND joystick are returned, the computer
cannot tell whether those values have been generated by the joystick or by the
equivalent keyboard key (indicated in the last column of the previous table). This
means that the keyboard can be used as a substitute for the second joystick.

Part 12: Disc organisation


The BIOS supports three different disc formats: SYSTEM format, DATA ONLY
format and IBM format. Under AMSDOS, the format of a disc is automatically
detected each time a disc with no open files is accessed. To permit this automatic
detection, each format has unique sector numbers.
3 inch discs are double sided, but only one side may be accessed at a time depending on
which way round the user inserts the disc. There may be a different format on each
side.

Common to all formats:


Single sided (the two sides of a 3 inch disc are treated separately).
512 byte physical sector size.
40 tracks numbered 0 to 39.
1024 byte CP/M block size.
64 directory entries.

SYSTEM format
9 sectors per track numbered &41 to &49.
2 reserved tracks.
The system format is the main format supported, since CP/M can only be loaded from
a system format disc. CPIM 2.2 also requires a system format disc to be inserted for a
warm boot. The reserved tracks are used as follows:

CP/M2.2
Track 0 sector &41
Track 0 sector &42
Track 0 sectors &43 to &47
Track 0 sectors &48 to &49
Track 1 sectors &41 to &49

CP/MPlus

: boot sector for CP!M 2.2 : boot sector for CP IM PI us


: configuration sector
: unused
}
unused
~ } CCP and BD OS

Note that VENDOR format is a special version of system format which does not
contain any system software on the two reserved tracks. It is intended for use in
software distribution.
Chapter 7 Page 44

For your reference ....

DATA ONLY format


9 sectors per track numbered &C1 to &C9.

oreserved tracks.

This format is not recommended for use with CP/M 2.2 since it is not possible to 'warm
boot' from it. However, if only CP/M Plus or AMSDOS is to be used, the DATA ONLY
format affords a little more disc space.

IBM format *CP/M 2.2 only


8 sectors per track numbered &1 to &8.
1 reserved track.
This format is logically the same as the single-sided format used by CP/M on the IBM
PC. The 6128 will read and write to IBM format discs, but will not create or copy
them.

Part 13: Resident System eXtensions


(RSX's)
External commands were introduced in Chapter 5 (about AMSDOS).
Fundamentally, an external command is a way of extending the repertoire of the
BASIC by adding new commands signalled by a I prefix. The machine instructions
for the AMSDOS new commands are included in a ROM, and the necessary
housekeeping to add the commands is carried out automatically when the 6128 starts
BASIC.

It is also possible to add further external commands (after BASIC has started) by
loading the machine instructions into RAM. Such new commands are called RSX's
and operate in exactly the same way as ROM based extensions. RSX's have to be
loaded from disc (or tape) each time the 6128 starts (or restarts) BASIC. Normally,
RSX's will be used for controlling some sort of intelligent peripheral, such as a light
pen or speech synthesiser.
Chapter 8 describes the use ofRSX's to access the 6128's second 64K of memory.

For your reference ....

Chapter 7 Page 45

Part 14: Memory


The CPC6128 contains 128K of RAM, and 48K of ROM. This is available to BASIC
1.1 as shown below. The first 64K of RAM is nominally divided into four blocks (each
of16K) numbered Block 0 to Block 3. The screen uses Block 3 and the upper section of
Block 2 is filled by system variables as indicated.

FIRST 64K OF RAM

SECOND 64K OF RAM


(unused)

h
I
I
I

FIRMWARE DATA AREA


JUMP BLOCK

I
I
I
1
1

BASIC DATA AREA

DISC ROM DATA AREA


ANY I OTHER RaMS' DATA AREA

I
:

I
I

I
I

I
:

BASlt PROGRAM AREA

Lj
NOTE l' DEPENDS ON EXTERNALLY FITTED ROMS-&A6FC WHEN NO EXTERNAL ROMS FITTED

Memory Map for BASIC 1.1

The user defined characters are initially positioned immediately above HIMEM.
HIMEM may be altered by a MEM0 RY command but is also automatically lowered by
4K to create a buffer whilst AMSDOS files are open. The number of user defined
characters can only be altered if HIMEM is unchanged since the last time they were
set (unless the last time they were set to 'no user defined characters' by a SYMB0 L
AFT ER 256 command). When BASIC starts, the user defined characters are set as
if a SYMB0 L AFT ER 2 4 0 command had been issued.

It is, therefore, prudent to collapse the user defined character area before
permanently changing HIMEM, then re-establishing the user defined characters in
the new position. This will allow subsequent programs to alter the
SYMBO L AFT ER assignment.

Chapter 7 Page 46

For your reference ....

The example below shows this scheme in operation when HIMEM is lowered in
conjunction with loading an RSX.

100
110
120
130
140
150

SYMBOL AFTER 256 I coLLapse user defined characters


rsxaddress=HIMEM-rsxLength
MEMORY rsxaddress-1
LOAD "rsxcode",rsxaddress
CALL rsxaddress I Log on rsx
SYMBOL AFTER 140 I restore user defined characters

11
I
I

FIRM WARE DATA AREA


JUMP BLOCK
BASIC DATA AREA
DISC ROM DATA AREA
ANY OTHER RQMS' DATA AREA

I
I

I
I

I
I

II
I

I
I
I
I
I

Lj
Memory Map with RSX loaded in recommended position

Additional 110
Most I/O port addresses are reserved by the computer - in particular, addresses below
&7FFF should not be used at all.

For your reference ....

Chapter 7 Page 47

It is intended that the part of the address AO - A7 should reflect the type of external
I/O device, and that address lines A8 and A9 may be decoded to select registers within
the I/O device. Of the remaining address lines, only A10 must be decoded (as low)
whilst lines All to A15 are high. Thus each device may have registers addressed as
&F8??, &F9??, &FA??, and &FB??, where ?? is in the range DC to DF for
communications interfaces, and EO to FE for other user peripherals.
Note that Z80 instructions which place the B register on the upper half ofthe address
bus (A15 - A8) must be used.

Sideways ROMs
Provision is made for additional ROMs to be selected in place of any part of the
on-board ROM. The address arbitration and bank selection logic will be contained in
a module connected to the expansion bus, but all the signals required are brought to
the expansion bus.

Part 15: CP/M Plus Terminal Emulator


In part 1 of this chapter, a table of control characters (together with their respective
actions) was illustrated. These actions are performed when text is sent to the screen
by BASIC or CP/M 2.2, and were chosen both to be simple to use and to reflect the
facilities available in the Firmware Text VDU. These facilities are unique to
AMSTRAD computers, and software must therefore be adapted to their use.
In the Business and Commercial environment ofCP/M Plus software, it is normal to
expect a range of 'standard' Text VDU facilities in order that software is easily
portable and 'installable' from one machine to another. The CP/M Plus
implementation on the 6128 includes a Terminal Emulator which provides facilities
very similar to a Zenith Z19/Z29 VDU. The installation procedure for CP/M Plus
software will normally include, as standard, an option for this type of terminal.
The facilities offered by the CP/M Plus Terminal Emulator include many of those
previously offered by the Firmware Text VDU although different control codes are
required.
There are a considerable number of new and more sophisticated operations.
Characters in the range &20 to &FF are displayed at the current cursor position. If
the cursor is not atthe right-hand column, then it is moved right by one column. If the
cursor is at the right-hand column and wrapping is enabled, then it is moved to the
left-hand column on the next line, scrolling up if necessary.

Chapter 7 Page 48

For your reference....

Characters in the range &00 to &IF are interpreted as control codes as follows:
&07

BEL

Sounds a beep.

&08

BS

Backspace. Move left one column. If the cursor is on the left-hand


column and not on the top row and wrapping is enabled, then it is
moved to the right-hand column of the row above.

&OA

LF

Linefeed. Move cursor down one line, scrolling up ifnecessary.

&OD

CR

Carriage return. Move cursor to left-hand column of current row.

&lB

ESC

Introduce an escape sequence.

All other control codes are ignored.


The following escape sequences are recognised. Any other characters following an
escape are displayed, and the cursor advanced. This feature may be used to display
the characters corresponding to control codes &00 to &IF. (Note that many
applications languages expand the control code &09 (TAB) to a number of spaces and
therefore the sequence [ESC][TAB] will often not display the character for &09.)
[ESC]O

Disable status line. Disc system messages will appear with CRT
output. CRT may use the bottom line of the screen.

[ESC]1

Enable status line. Disc system messages will appear on the


bottom line of the screen.

[ESC]2 <n>

Change character set (see part 16 of this chapter). <ll> is the


language parameter which is masked with &07. Certain
character matrices in the range &20 to &7F are swapped with
other characters in the range &80 to &FF. The action of this
command is very similar to that used to control printers which
have software-selectable international character sets.
<n>=O
<n>=l
<n>=2
<n>=3
<n>=4
<n>=5
<n>=6
<n>=7

For your reference ....

USA
France
Germany
UK
Denmark
Sweden
Italy
Spain

Chapter 7 Page 49

[ESC]3 <m>

Change screen mode. <m>=screen mode+&20. The value is


masked with &3 to give the mode 0 to 2. Mode 3 is ignored. The
screen is cleared, but the cursor position is unaffected.

[ESC]A

Cursor up. Ifon top row, then do nothing.

[ESC]B

Cursor down. If on bottom row, then do nothing.

[ESC]C

Cursor forward. If on right-hand column, then do nothing.

[ESC]D

Cursor backwards. If on left-hand column, then do nothing.

[ESC]E

Erase page. The cursor position is unaffected. This command


clears the entire screen, even ifset to 24x80 mode. (Other escape
codes will only affect the 24x80 area when 24x80 mode is set).

[ESC]H

Home cursor. Move cursor to top row, left-hand column.

[ESC]I

Reverse index. Move cursor up one row. Scroll screen down if


necessary.

[ESC]J

Erase to end of page. Includes character at cursor position. The


cursor position is unaffected.

[ESC]K

Erase to end of line. Includes character at cursor position. The


cursor position is unaffected.

[ESC]L

Insert Line. All rows below and including the cursor line are
scrolled down. The cursor row is cleared. The cursor position is
unaffected.

[ESC]M

Del~te

[ESC]N

Delete character. All characters to the right of the cursor are


shuffled left one character position. The character at the end of
the row is cleared. The cursor position is unaffected.

[ESC]Y <r> <c>

Moves cursor to given position. If position is beyond the edge of


the screen, then the cursor is moved to the edge of the screen.
<r>=row position+&20, <c>=column position+&20. The top
left-hand corner is row 0, column O.

Chapter 7 Page 50

line. All rows below and including the cursor row are
scrolled up. The bottom row is cleared. The cursor position is
unaffected.

For your reference....

[ESC]b <cp>

Set foreground colour. Affects all characters on the screen. <cp>


is the colour parameter and is masked with &3F then treated as
three 2-bit numbers each specifying the intensity of one of the
three primary colours: bits 0,1 for Blue, bits 2,3 for Red, and bits.
4,5 for Green. The 6128 provides three levels of intensity,
mapped onto the four specifiable levels as:

CPC6128

Zero intensity

HalfIntensity

Full intensity

Colour bits

00 binary

01 or 10 binary

11 binary

[ESC]c <cp>

Set background colour. Affects all the background and border


on the screen. The colour is specified as above.

[ESC]d

Erase to beginning of page. Includes character at cursor


position. The cursor position is unaffected.

[ESC]e

Enable cursor blob. To prevent unsightly flashing, the cursor is


not turned on during normal text outputting until 1110 second
after the last character was written.

[ESC]f

Disable cursor blob.

[ESCb

Save the cursor position.

[ESC]k

Restore cursor position as saved by [ESC b.

[ESC]l

Erase line. The cursor position is unaffected.

[ESC]o

Erase to beginning ofline. Includes character at cursor position.


The cursor posi tion is unaffected.

[ESC]p

Enter inverse video mode. Printable characters are written


with the foreground and background colours reversed.

[ESC]q

Exit inverse video mode.

[ESC]r

Enter underline mode. (Not supported on CPC6128)

[ESC]u

Exit uJ;lder line mode. (Not supported on CPC6128)

[ESC]v

Wrap at end ofline.

For your reference ....

Chapter 7 Page 51

[ESC]w

Discard at end ofline.

[ESC]x

Enter 24x80 mode. Some applications programs may require a


'standard' 24x80 screen. This command will enable such a
screen regardless ofthe full size of the screen which may depend
upon machine, country and whether or not the status line is
enabled. The screen is cl~ared.

[ESC1y

Exit 24x80 mode. The screen is cleared.

Part 16: CP/M Plus Character Set


In part 10 of this chapter, a printer translation table was described. The purpose of
this table is to convert certain of the characters from the BASIC and CP/M 2.2
character set into a form where they can be printed when a language selection is
made on the printer. The facility is somewhat limited because very few printers'
foreign characters actually appear in the BASIC character set.
Although this printer translation scheme still operates under CP/M Plus, the
character set has been enhanced to allow an almost complete correspondence
between the screen characters and the printed characters. (The one missing screen
symbol is the Swedish Currency Symbol replacing the $). The table below confirms
the arrangement:
23

24 40 58 5C 5D 5E 60 78 7C 7D 7E

USA
France

.lJjI~ilj~f!Ii1l1g

Germany

JI.~iiii.~:iiiiSl

UK

&.II~~~~~~~~~
---= :::--= =--- ::---=
=--- :------ =---== ~::::::
-----

=-:

==

Denmark
Sweden
Italy
Spain

CPIM Plus International Character Set

Chapter 7 Page 52

For your reference ....

Operating the machine in a foreign environment requires two actions:


1.

The printer itself should be set to the required language (often by small (DIP)
switches, though some printers allow control codes to be sent).

2.

The required screen character set must be invoked, either by the transient
command:
LANGUAG E <n>

.... or by sending
[ESC]2 <n>
.... to the Terminal Emulator.
In practice, the initialisation can be performed as part of the PRO F I LE. SUB
operation, using the LA NGUAGE and SET LS T facilities. CP/M Plus is shipped with
the USA environment, mainly because the keyboard displays a # over the 3 key. It is
common practice to operate in the UK environment when doing word processing.

7 bit software ....


Although this foreign language facility is very powerful, it has to be stressed that the
'normal' (or USA) characters which have been replaced by the 'local' foreign
characters are no longer displayable. This is a common and intractable compromise
when dealing with 7-bit software. Nearly all available software (including most
CP/M Plus utilities, Word processors, and languages) operate with only a 7 bit
character set. In the UK it is fairly well accepted that the # disappears to be replaced
by the not only in word processing (where it is regarded as desirable) but also in
program listings, e.g. LIS T 8, where it is regarded as undesirable. However, in
time, everyone becomes used to performing the mental transformation.
Unfortunately, the other foreign language transformations also replace characters
such as the vertical bar and square brackets, and although the resulting availability
of accented characters improves the readability of text, in situations where bars and
brackets are required by the application program, e.g. DI R [F U L LJ, the
readability and (if the key tops have been exchanged) the typeability is markedly
diminished. Remember that the application program is working in ASCII values,
quite oblivious to the shape ofthe characters on the screen. The problem is that with
7-bit software, there are simply not enough ASCII values to go around.

For your reference ....

Chapter 7 Page 53

Working with 8 bit character sets....


The BASIC character set has 256 different symbols, with the values 128 to 255 (&80
to &FF) containing various graphic symbols of particular use in games and home
computing (dancing men, hearts/clubs/diamonds/spades, etc.). CP/M Plus also has
256 characters available, but the second 128 are different from those in BASIC, and
reflect the International and Business flavour ofthe CP/M Plus environment:

0123456789ABCDEF

012345678.9ABCDEF

~~~~~~~~II~~~~~~

'!~I~~B~~B~~~~~~~

~R.~~I~~~~~~~2~

~l!~!!~IH~~~!~!"I~'liji'

~~~.~~.~~!~~~~~~

~!!~~fi.IHln~~~IH~~6jj

D~gB~~IIII~~~~~a

!E~~~~~~~H~lil1lUII116!!

~BB&IBE&g~~B~

ifi~lilijn!~JIBI~.liHli

~gB&~IIHI~~~~~I~

iii1iiiIHI~.iiiil~~~~

~~g~a~~gl~~~~UD~

~1!:i~B~I~~~iiili!iiHHj

~~~~I~~~~g~I~~~g

~iHi.i~~~!if!!ni~iHI~~~

Characters 0 to 127 (&00 to &7F)

Characters 128 to 255 (&80 to &FF)

The Standard CPIM Plus Character Set (USA)

Software which is capable of operating with 8 bit characters may use this character
set to access all of the foreign language characters at once, without having to
specifically change language. In this way, all the 'bar and brackets' type characters
will be available as well.
Please note that there is currently very little 8-bit software available, and that
characters in the ranges 0 to 31 and 128 to 255 will only ever appear in the form
shown above on the screen itself. Printers, on the other hand, will have their own, and
different, ideas about what these symbols will look like.

Chapter 7 Page 54

For your reference ....

ChapterS
More
out the Bank

anagerll

11 1111

Extensions to BASIC allowing access to the second 64K bank of


RAM.
Subjects covered:

**

Storing screen images


Pseudo-file operation

The memory map for BASIC 1.1 (shown in Chapter 7 part 14) indicates that 64K of
the 128K RAM is unused. The BASIC and firmware themselves reside in a ROM
which, together with the disc ROM, increase the normal memory provided from 64K
to 112K (64K RAM, 48K ROM).
Each section of16K is called a 'block', and any particular selection offour blocks (to
make 64K in total) is called a 'bank'. The technique of selecting blocks is therefore
called 'bank switching'.
The Z80 microprocessor can accomodate only 64K of memory at anyone time, so the
operating system contains instructions to switch the firmware ROM into play instead
of Block 0 of RAM, and to switch either the BASIC ROM or the disc ROM into play
instead of Block 3. This switching takes place automatically when the BASIC or
firmware is required. Bank switching of RAM merely extends this concept to include
the overlaying of RAM, rather than ROM. The switching is taken care of by an
assembler program.
The program BAN KMAN. BA S is provided on Side 1 of the system discs package. If
the program is run after BASIC has started, it will install the standard bank
management RSX code. Hence, the program is known as the 'BANK MANAGER'.
One use for the memory in the second 64K is as temporary storage space for picture
screens. Such applications may include, for example, a 'Screen Designer' program
which stores a number of different screens, or a video game which may have a number
of different screens already prepared.
Another use for the second 64K is as an extension to the variable workspace, which
can be regarded as either an extension to the string array space, or as a simple
'RAMdisc'.

More About the Bank Manager ....

Chapter 8 Page 1

Part 1: Storing screen images


Choose your screen....
The BANK MANAGER is able to switch out Block 1, and switch in one of the four
blocks from the second 64K in its place. The diagram below illustrates this action.
Note how each of the blocks from the second 64K occupies the same address space
(&4000 to &7FFF). The contents of Block 1 (probably the middle of your BASIC
program!) is preserved, and is restored when the BANK MANAGER has finished.
There are three other bank selections possible (apart from the five shown below), but
they are only useful to the implementation ofCP/MPlus.

Hardware bank switching


The BANK MANAGER supports two commands for moving screen-fulls of
information between one block and another. Blocks 4 to 7 are switched in and out
automatically as required, and the memory map is left with Block 1 switched in.

Chapter 8 Page 2

More About the Bank Manager....

The command:
I S eRE ENS WA P, [<screen section> , J<screen number> , <screen number>

.... exchanges the contents of two blocks, whereas:


I S eRE ENCO PY, [<screen section> , J<destination screen number> ,
<source screen number>

.... copies the contents of one block into another block.


The optional <screen section> parameter causes the software to copy only 1I64th ofthe
block (256 bytes out of 16K). <screen section> therefore takes values in the range 0 to
63. This mode of operation is useful ifit is required to interleave any other processing
with screen moving. A screen-swap can take around 150/300ths of a second (150
TIME-counts).
The <screen number>s required are 1 (the normal screen), and then either 2,3,4, or 5.
Copy and swap operations where the source or destination is screen 1, will operate
much faster. Be careful of the screen hardware-roll effect, as experienced when
dealing with disc screen dumps. It should be arranged that all the screen images are
constructed (and viewed) with screen 1 set to the same hardware position. The
simplest (default) position is that set by a MOD E command.

Try out the screen switching commands....


First, run the BANK MANAGER program from Side 1 of your system discs package
by:

RUN "BANKMAN"
Then type:

MOD E 1
Screen clears. Now type:
I
This is the original screen
ISCREENCOPY,3,1 'Send original screen to memory 3

CLS

More About the Bank Manager....

Chapter 8 Page 3

Screen clears again. Now type:


This is the intermediate screen
ISCREENCOPY,2,1 I Send intermediate screen to memory 2
ISCREENSWAP,2,3 I Exchange memory 2 and memory 3
ISCREENCOPY,1,3 I Restore intermediate screen from memory 3
ISCREENCOPY,1,2 I Restore originaL screen from memory 2

Finally on this subject, the last part of Chapter 9 includes a comprehensive 'Screen
Designer' program, which incorporates the screen switching facilities provided by
the BANK MANAGER.

Part 2: Pseudo-file operation


Curses filed again....
When regarded as a RAMdisc, the whole of the second 64K is divided into a'RAMfile'
comprising a number of fixed length records. The record length can be between 0 and
255 bytes, although 2 bytes is recommended as the minimum. Once the <RAMrecord
length> has been established, each record can be accessed by its <RAMrecord
number>. It is perfectly acceptable to write the RAMfile using one record length, and
read it back using another.
NOTE - The RAMfile must contain only data; there is NO facility for it to contain
program instructions.
As is common with random access disc filing schemes, there is the concept of 'current
record number'. This provides, in effect, a default record number, which is
particularly useful when auto-stepping through the RAMfile.
The command:
I BAN KO PEN, <RAMrecord length>
.... sets the fixed length of all records, initialises the current record number to zero,
but DOES NOT clear the memory in any way.
The command:
I BAN KW RI T E , @<returncode> , <string expression>[, <RAMrecord number>]
.... writes the <string expression> to the RAMfile.

Chapter 8 Page 4

More About the Bank Manager....

The <RAMrecord number> specifies which record is written. If the parameter is


omitted, then the current record number is used. The current record number is then
set to point at the next record.

If the <string expression> does not completely fill the record, then old characters
(which have not been overwritten) will remain at the end of the record. If the <string
expression> is longer than the record, then the excess characters are discarded to
avoid spillage into the next record.
<return code> is an integer variable which returns the record number written to (if the
operation was successful), or a negative error code ifthe write operation has failed in
some way.
-1

End of File error. The requested record number's address exceeds 64K.

- 3 Bank switching failure (should never happen).


Examples:

IBANKOPEN,111J
IBANKWRITE,@r%,"123 testing",11J
IBANKWRITE,@r%,w$
The command:

I BAN KREA D, @<returncode> , @<stringvariable>[, <RAMrecord number>]


.... reads a record into the <string variable> from the RAMfile.
The <RAMrecord number> specifies which record is to be read. If the parameter is
omitted, then the current record number is used. The current record number is then
set to point at the next record.
If the record contents do not completely fill the <string variable> then old characters
(which have not been overwritten) will remain at the end of the <string variable>. If
the record contents are longer than the length of <string variable>, the excess
characters are discarded, as it is not possible to increase the length of a string
variable during an external command.
<return code> is an integer variable which returns the record number read from (ifthe
operation was successful), or a negative error code if the read operation has failed in
some way.
-1

End of File error. The requested record number's address exceeds 64K.

- 3 Bank switching failure (should never happen).


Example:

IBANKREAD,@r%,i$,11J
More About the Bank Manager ....

Chapter 8 Page 5

Searching....
It is possible to search through the stored records looking for a particular entry.
The command:

I BAN K FIN D, @<return code> , <searched for string>


[, <starting record number>[, <finishing record number>]]
.... will scan all the RAMrecords. The <starting record number> specifies from which
record the search starts. If the parameter is omitted, then the current record number
is used.
The search will proceed, in steps of <RAMrecord length>, throughout the whole ofthe
second 64K of memory until a match is found.
If a <finishing record number> is specified, then the search will terminate after that
record has been tested (unless a match has been found before that point).

If the search is successful, then the current record number is set to point at the record
where the match was found (otherwise it remains unaffected).
<return code> is an integer variable which returns the record number where the
match was found (if the operation was successful) or a negative error code if the
search operation has failed in some way.
- 1 End of File. The starting record number's address exceeds 64K or exceeds the
finishing record number.

-2 No match found.
- 3 Bank switching failure (should never happen).
The <searched for string> may contain wild-cards, signalled by nulls - CH R$ ( 0 ) , and
the comparison is made with reference to either the <RAMrecord length> or the length
of the <searched for string>, whichever is the shorter.
Examples:

IBANKFIND,@r%,"123 test",0
IBANKFIND,@r%,f$,100,200

Chapter 8 Page 6

More About the Bank Manager....

Beware the mismatch....


Obvious errors, such as the wrong number of parameters, are reported as a 'Bad
Corn mand' error. However, the mechanism of external commands does not detect
errors of the 'Ty p e mism ate h' variety, and the user must ensure that the correct
form of parameters are employed.
The program below uses the RAMdisc commands to set up and interrogate a database
containing anagrams of7 -letter words. It searches for matches, and you may use wild
cards.
For example, anagrams of the word FIG URES which match with ? RUG S ?? (the
two last ?? can be left off if you wish) are F RUG S lE, F RUG S El, I RUG S FE,
I RUG S E F, ERUG S F I , and I RUG S IF.
The database takes some time to create, but then 64K is a lot of memory to fill!

10 'ANAGRAMS by ROLAND PERRY


20 ' copyright (c) AMSOFT 1985
30 '
40 'Remember to RUN "BANKMAN" before running program
50 '************************************************
60 '
70 MODE 2
80 DEFINT a-z
90 r%=0: IBANKOPEN,7
100 INPUT"What 7 letter word to scramble ";s$
110 IF LEN(s$)<>7 THEN 100
120 PRINT"Please wait . "
130 LOCATE 1,5:PRINT"Computing:"
140 FOR c1=1 TO 7
150 FOR c2=1 TO 7
160 IF c2=c1 THEN 370
170 FOR c3=1 TO 7
180 IF c3=c2 OR c3=c1 THEN 360
190 FOR c4=1 TO 7
200 IF c4=c3 OR c4=c2 OR c4=c1 THEN 350
210 FOR c5=1 TO 7
220 IF c5=c4 OR c5=c3 OR c5=c2 OR c5=c1 THEN 340
230 FOR c6=1 TO 7
240 IF c6=c5 OR c6=c4 OR c6=c3 OR c6=c2 OR c6=c1 THEN 3
30
250 FOR c7=1. TO 7
260 IF c7=c6 OR c7=c5 OR c7=c4 OR c7=c3 OR c7=c2 OR c7=
c1 THEN 320
Continued on the next page
More About the Bank Manager....

Chapter 8 Page 7

270 o$=MID$(s$,c1,1)+MID$(s$,c2,1)+MID$(s$,c3,1)+MID$(s
$,c4,1)+MID$(s$,c5,1)+MID$(s$,c6,1)+MID$(s$,c7,1)
280 LOCATE 12,5:PRINT x;o$
290 IBANKWRITE,@r%,o$
300 IF r%<0 THEN STOP
310 x=x+1
320 NEXT c7
330 NEXT c6
340 NEXT c5
350 NEXT c4
360 NEXT c3
370 NEXT c2
380 NEXT c1
390 lastrec=r%
400 REM now look them up
410 r%=0:g$=SPACE$(7)
420 PRINT:INPUT"What match do you require: use? as wil
d card: ",m$
430 m$=LEFT$(m$,7)
440 FOR x=1 TO LEN(m$)
450 IF MID$(m$,x,1)="?"THEN MID$(m$,x,1)=CHR$(0)
460 NEXT
470 IBANKFIND,@r%,m$,0,lastrec
480 IF r%<0 THEN GOTO 420
490 IBANKREAD,@r%,g$
500 PRINT g$,
510 IBANKFIND,@r%,m$,r%+1,lastrec
520 GOTO 480

Chapter 8 Page 8

More About the Bank Manager.. ..

Chapter 9
At your leisure ....
This chapter takes a leisurely look at some background
information to computing in general, and at the 6128 in
particular. It is not vital that you read this chapter before
operating the computer, but it may help you to understand a little
ofwhat's going on {under the bonnet'.

Part 1: Generally speaking.

11l1li

Zap the wotsit!


Even if the only reason that you bought your 6128 was to take advantage of the
sophisticated computer games available, you may still probably be wondering about
several aspects of the computer that come under the heading of'hardware'.
The hardware is the equipment that you can pick up and carry around, i.e. the main
computer keyboard, the monitor, the connecting leads etc. In fact, it's just about
everything that isn't specifically the 'software' - programs, manuals, and disc or
cassette based information.
Certain features of the way that the computer behaves, are produced by courtesy of
the hardware - things like the coloured display on the TV set (or monitor). It's up to
the software to make use of these hardware capabilities to produce specifically
designed characters and shapes on the screen.
The hardware actually directs the beam of electrons at the electro luminescent
surface on the inside ofthe screen of the TV tube to make it 'light up' - the software
adds order and intelligence by telling the hardware when and how to perform. It adds
timing, control and sequencing to produce the effect of a spaceship taking off, or
something more mundane like a letter appearing when you type at the keyboard.

So what makes one computer better than another?


Hardware without software is worthless. Software without hardware is equally
worthless - the value of the computer begins when the two come together to perform
various tasks. There are some very basic considerations that can be used to grade
performance of both hardware and software.

At your leisure ....

Chapter 9 Page 1

The generally accepted reference points for personal computers are now:

1. The screen resolution - the smallest discernible item on the


display.
This is a combination offactors, including the number of different colours available to
the programmer, the number of distinctly different areas that can be resolved on the
display (i.e. the pixels), and the number of text characters that can be displayed on a
single screen area.
You will find that your 6128 compares very favourably with any similarly priced
machine in each of these respects.

2.

The BASIC interpreter

Virtually every home computer includes with it a BASIC interpreter that allows the
user to start creating programs to use the hardware features. The built in
programming language (BASIC) that comes supplied with your machine is itself a
program - an immensely complicated and intricate program that has been evolved
over a million man-years of experience since BASIC was 'invented' in the USA. The
'Beginners' All-purpose Symbolic Instruction Code' is easily the most widely used
computer language in the world, and like any language, it comes in a variety oflocal
'dialects'.
The version in the 6128 is one of the most widely compatible dialects ufBASIC, arid
will also run programs written for operation under the CPIM disc operating system. It
is a very fast implementation of BASIC - in other words it performs its calculations
quickly - and whilst you may not be too concerned that one computer may take 0.05 of
a second to multiply 3 by 5 and display the answer, whereas another may take 0.075
second to do the same - where a program that draws graphics patterns on the screen
may call for many thousands of simple repetitive calculations, the difference between
0.05 and 0.075 of a second adds up to a considerable difference in performance.
You will frequently hear the term 'machine code' being used. Machine code is the raw
form ofinstruction code that can be passed to the processor. It takes less time to work
out what it's been asked to, and gets on with producing the result some 5 to 15 times
faster than an equivalent operation being passed along through the BASIC
interpreter. On the other hand, it can take 5 to 50 times longer to write an equivalent
program in machine code when compared to performing the same overall task using
BASIC.

Chapter 9 Page 2

At your leisure ....

The BASIC in your Amstrad computer is amongst the fastest and most fully featured
to be found in any home computer system, and incorporates many features that help
the experienced BASIC programmer overcome some of the inherent sluggishness of a
'high level language' interpreter to perform surprisingly dynamic visual and musical
effects.

3.

Expansibility

Most computers pay attention to the need to 'add-on' additional items of hardware:
printers,joysticks, extra disc drives. Paradoxically, some of the most successful home
computers require the addition of add-on units known as 'expansion interfaces' before
even a simple printer or joystick controller can be installed.
The purchaser. does not always think ahead to his needs in the future, because a
machine that incorporates a properly supported parallel printer (Centronics
compatible) and a games joystick port may actually be cheaper in real terms.
The 6128 computer features a built-in Centronics printer port, a port for an
additional disc drive, a cassette data (+ motor' control) socket, facilities for up to two
joysticks, a stereo sound output - and a comprehensive expansion bus that can be used
to attach a serial interface (AMSTRAD model RS232C), a MODEM, a speech
synthesiser (AMSTRAD model SSA2), a light pen, etc.

4.

Sound

The sound features of a computer determine whether or not it sounds like a bluebottle
in a empty cocoa tin - or ifit can produce an acceptable representation of an electronic
musical instrument.
The 6128 computer uses a 3 channel 8 octave sound generator, which can produce a
very acceptable musical quality with full control of the amplitude and tone
envelopes. Furthermore, the sound is divided into a stereo configuration, where one
channel provides the left output, one channel provides the right output, and the third
channel sits in the middle.
This provides considerable scope for writing programs that track the sound effects
across the screen to follow the motion of an arcade-style game.
Ultimately, you will make up your own mind about which of these features is most
important to you. We hope that you will try them all to make the most of your
computer.

At your leisure ....

Chapter 9 Page 3

Whycan't?
With all the power of modern technology, users frequently wonder why even a
machine as advanced as the 6128 is apparently unable to perform tasks seen on any
TV set. Why for instance, can't a computer animate a picture of someone walking
across the screen in a natural fashion? - why do all computers represent movement
with 'matchstick' figures?
The answer is simple yet complex. The simple answer is that you must not be
beguiled into believing that the screen of your computer has anything of the subtlety
of the screen of a TV set. A television set operates using 'linear' information that can
describe a virtually infinite range of resolution between the extremes of light and
dark across all the colours of the spectrum. This process means that in computer
terms, the display 'memory' of a full TV picture is some twenty times greater than the
converted equivalent of a home computer display.
That's only part of the problem, since to animate this picture requires that this
enormous amount of memory must be processed at high speed (around 50 times each
second). It can be done - but only by machines that cost a few thousand times more
than a home computer, at least for the time being!
Until the price of high speed memory falls dramatically (it will eventually), small
computers have to make do with a relatively small amount of memory available to
control the screen display, which results in lower resolution, and jerkier movements.
Thoughtful hardware design and good programming can go a long way to making the
best of this situation, but we are still a fair way from cheap computers that can
reproduce flowing motions and lifelike pictures in the same way that even a moderate
animated cartoon can produce.

That keyboard looks familiar ....


Why can't you simply walk up to the computer and type a page of simple text into the
machine?
Don't be mislead by the fact that the computer looks like a typewriter with an
electronic display. The screen is not a piece of electronic paper - it's a 'command
console' - jargon which means that it simply provides you with the means of
communicating with the programming language (and the programs) in the machine
memory.
Until you tell it to the contrary, the computer will try and interpret all the characters
that you type at the keyboard as being program instructions. When you press the
[RETURN] key, the computer will look through what has been typed, and ifit doesn't
make sense to the built in BASIC, it will reject the 'input' with the comment:

Syntax error

Chapter 9 Page 4

At your leisure ....

However, it may just happen that the program presently residing in your computer is
a Word Processor system, in which case you will be able to type random words, press
[RETURN] and carry on typing as 'if the system WERE operating as an electronic
piece of paper in an electronic typewriter. But to do this, you must have first loaded a
word processor program into the machine's memory.
The computer 'seems' to combine several items of equipment that have become
familiar around the home and office such as the TV-like screen and the keyboard.
You must remember that the similarities are generally strictly superficial, and that
the computer is a combination of familiar looking hardware that has an entirely
different personality ofits own!

\)
;

--~--~fiQI
--=---

";f~:;;;;;----

__

At your leisure ....

Chapter 9 Page 5

Whose afraid of the jargon?


As with all 'specialist' industries, computing has developed its own jargon as a
short-hand form of communicating complicated concepts that require many words of
'plain language' explanation. It's not just the high technology business that's guilty
of hiding itself behind an apparent smoke screen of 'buzz words', jargon and
terminology - most of us have come up against the barriers to understanding erected
by all the main professions and trades.
A major difference is that the confusion in legal jargon arises from the way the words
are used - rather than the words themselves as in the case of computing. Most people
who grow familiar with computing terminology will go out of their way to use the
words in the most straightforward possible manner, so as to minimise the complexity
of the communication. Don't be mislead by the 'plain language' used in computing, it
is not a literary subject, but a precise science, and apart from the 'syntax' of the
wording, the structure of the communication is very straightforward, and not in the
least confusing or ambiguous. Teachers of computing have not yet managed to make
an art form out of trying to analyse the exact meaning intended by a programmer in
his program construction.
Having said that, despite whether or not the meaning of a computer program is
obvious, there are still many aspects that can be analysed as either elegant or untidy,
and more emphasis is being put on a formal approach to program construction, now
that the initial mayhem brought about the micro revolution is settling down.
Computing is rapidly being understood by many young people who appreciate the
precision and simplicity of the ideas and the way they can be communicated - you
don't find too many ten year old lawyers - but you can find plenty of ten year old
programmers!

Chapter 9 Page 6

At your leisure ....

Basics of BASIC
Virtually all home computers provide a language known as BASIC, which allows
programs to be written in the nearest thing to plain language presently available.
BASIC no longer has any particular significance as to the degree ofthe sophistication
of the language, and many extremely complex and powerful programs are written
using BASIC.
However, there's no doubt that the name has attracted many newcomers for its
promise of providing a starting place in the maze of computer program languages,
and this has contributed significantly to its universality.
BASIC is a computer language that interprets a range of permitted commands, and
then performs operations on data while the program runs. Unlike the average human
vocabulary of 5000-8000 words (plus all the different ways verbs can be used etc,)
BASIC has to get by with about two hundred. Computer programs written using
BASIC have to follow rigid rules concerning the use of these words. The syntax is
precise, and any attempt to communicate with the computer using literal or
colloquial expressions (Le. plain language) will result in the cold and clinical
message:

Syntax error
This is not as restrictive as it first appears, since the language of BASIC (the syntax)
is primarily designed to manipulate numbers - the numeric data. The words are
essentially an extension of the familiar mathematical operators +/- etc., and the
most important concept for newcomers to grasp is the fact that a computer can only
work with numeric data. Information that is supplied to the CPU (Central Processor
Unit) integrated circuit is only supplied in the form of numerical data.

Number please ....


Ifa computer is used to store the complete works of Shakespeare, there will not be a
single letter or word to be found anywhere in the system. Every piece of information
is first converted into a number which the computer can locate and manipulate as
required.
BASIC interprets the words as numbers which the computer can then manipulate
using only addition, subtraction and features from Boolean logic that permit the
computer to compare data and select for certain attributes - in other words, check to
see if one number is greater than or the same as another, or to perform a defined task
if one number or another meets certain criteria.
Through the medium of the program, the computer breaks down every task into a
simple series ofYes/N0 operations.

At your leisure ....

Chapter 9 Page 7

If this process sounds cumbersome, then you're quite right, as you have uncovered the
first and most important truth about computing. A computer is primarily a tool for
performing the simplest of repetitive tasks very quickly and with absolute precision.
Thus BASIC interprets the instructions as given in the form of the program, and
translates them into the language that can be handled by the CPU. Only two states
are understood by the logic of a computer - 'yes' or 'no', represented in binary notation
as '1' and '0'. The representation in Boolean logic is simply 'true' and 'false' -there's no
such thing as a 'maybe' or 'perhaps'!

The process of switching between these two distinct states is the essence of the term
'digital', and is sometimes referred to as 'toggling'. In the world of nature, most
processes move gradually from one completely 'stable' state to another in a linear
progression. In other words, the transition is made by following the path of a line
between the two states - in an ideal digital environment the switch from one state to
the next is made in no time at all-but the physics of semiconductor science dictate
that there will be some minor delay, referred to as propagation delay - and it is the
accumulation of many of these propagation delays that provides the reason why a
computer has to spend some time processing the information before the answer comes
out.

Chapter 9 Page 8

At your leisure ....

In any case, the computer would have to wait a finite time for one task to have
finished before it can start work on the result of that first task - so there would need to
be some artificial delay imposed anyway. The digital process is black or white, and
the stages of transition via the various shades of grey have NO significance
whatso~ver. Conversely, the linear or 'analogue' progression IS via the shades of
grey.
If the ultimate answer is either 0 or 1, then there is no possibility of it being 'nearly'
correct. The fact that computers can sometimes appear to make errors when handling
numeric data is due to the limitation of the size of numbers it can process, requiring
'oversized' data to be squeezed down to fit the space available, or 'truncated', leading
to rounding errors. e.g. 999 ,999 ,999 becomes 1,000,000,000.
In a world where the only two numbers available are 0 or 1, how then do you count
beyond1?

Bits and Bytes


We just happen to be used to understanding numbers based on the decimal system
where the reference point is the number 10 - i.e. there are ten digits available to
represent quantities in range from 0 to 9 (which is used in preference to the
expression 1 to 10). The system where numbers range from 0 to 1 is the binary system,
and the units in which the system operates are called bits - an abbreviated form of
'Binary digIT'.
The relationship between bits and decimal notation is simple to understand:
It's conventional to declare the maximum number of binary digits being used by
adding leading zeros to make up the number to the full number of bits:
e.g. decimal 7 becomes:
00111 binary
.... using 5 bit notation.
In the binary system, the figures may be considered merely as indicators in columns
to specify whether or not a given power of2 is present; 1 =yes, O=no.
2 = 1
21 = 2 = 2 = 2(2)
22 = 4 = 2x2 = 2(2 1)
23 = 8 = 2x2x2 = 2(2 2)
24 = 16 = 2x2x2x2 = 2(2 3 )

At your leisure ....

Chapter 9 Page 9

.... so the columns look like:

1
(16

o
o
o + o

+ 2 +

1)

19

In order to provide a shorthand method of referring to binary digit information, the


term 'byte' is used to denote 8 bits of information. The maximum number that be
stored in a byte is then (binary) 11111111- or (decimal) 255. This implies 256 actual
variations, including 00000000, which is still perfectly valid data to a computer.
Computers tend to manipulate data in 8 bit multiples. 256 is not a very large number,
so in order to achieve an acceptable means of handling the memory, two bytes are
used to provide a method of addressing memory which is in the form of array, with a
horizontal and vertical address by which the elements of that array can be located:

0 1 2 3 4 5 6 7 8 9
0
1
2
3

4
5

6
7
8

The array can locate up to (10xl0) items of information using address numbers that
lie in the range 0 to 9. The item stored at position 3,5 is a '1' ~ as is the item at 5,5.
So a binary array of 256x256 can handle 65,536 individual locations using 8 bit
addresses for the vertical and horizontal axes of the array. So our '0' and '1' have
progressed to being capable of identifying one of 65,536 different elements.

Chapter 9 Page 10

At your leisure ....

The next level of shorthand for binary is the kilobyte (kByte or simply 'K') which is
1024 bytes. 1024 is the nearest binary multiple to the more familiar decimal use of
the term 'kilo' (1000) - and explains why a computer described as having a '64K'
memory does in fact have a memory of65,536 bytes (64 x 1024).
Thankfully, the BASIC interpreter does all the necessary conversions for you, and it
is quite possible to become a proficient programmer without a complete
understanding of binary, although an appreciation of the significance of binary will
help you spot the many 'magic' or significant numbers that inevitably crop up as you
work through the science of computing.
It's worth spending some effort to acquire an understanding of binary and the various
significant numbers 255, 1024 etc, since it is very unlikely that these will change
from being the bedrock of computer operation in the foreseeable future. The certainty
and simplicity that comes from working in only two states will prevail over the
enormously increased complexity that would result from any other number base.

However....
Simple and elegant as it is, binary notation is longwinded and prone to inaccuracy as
it cannot be easily read at a glance. Binary has a number of associated counting
systems that act as shorthand for programmers. One such number system widely
used in micro computing is called HEX (an abbreviation of hexadecimal).
Here the number is based on 16 (0 to 15), and is represented in a single character:

Decimal

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Hex
0123456789A

BC

DE

The hexadecimal system can break the eight bits of a byte into two blocks offour bits,
since 15 is a four bit number: 1111 binary. The first block indicates the number of
complete units of'15', and the second indicates the 'remainder' - and this is where the
absolute elegance of binary and hex begin to emerge.

At your leisure ....

Chapter 9 Page 11

Reconsidering the table that introduced binary notation:

Decimal

Binary

Hexadecimal

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E

F
10

An 8-bit number 11010110 (&D6 hex) can be subdivided, and then considered as two
4-bit numbers (known as nibbles). Throughout this manual, a hex based number is
introduced by the '&' symbol e.g. &D6, and this is the number base most commonly
used by programmers using assembly language techniques. An assembly language
program is the nearest most programmers get to programming directly in machine
code, since the assembly language program allows the programmer to use simple
letter 'mnemonics' to specify the actual machine code 'numbers'.
When using hex, you must first work out the value of the first digit to obtain the
number of 16's in the final number, and then add the remainder designated by the
second 'half of the hex notation to obtain the total decimal equivalent. There's a
powerful temptation to regard a number like &D6 as 13+6, or 136, but it's
(13x16)+(6) = 214.
It's the same process you use when you read a decimal number (also known as a
Denary number) such as '89' - i.e. (8x10)+(9). It just happens that multiplying by ten
is a great deal simpler, unless you've had a lot of practice at multiplying by 16.

Chapter 9 Page 12

At your leisure ....

If you've got this far without becoming too confused, then you are well on your way to
getting a grasp of the basic principles of the computer. You may even be wondering
what all the fuss is about - and you'd be quite correct. A computer is a device that
manages very simple concepts and ideas; it just happens to perform these tasks at
great speed (millions oftimes per second), and with a huge capacity to remember both
the data that has been input, and the intermediate results of the many thousands of
very simple sums along the way to the result.

If you want to pursue the theory of your computer, there are literally thousands of
books available on the subject of computing. Some will tend to leave you more
confused than you were wh~n you started reading them, but a few will actually lead
you along the way by revealing the simplicity and the fundamental relationships
that exist between the number systems, and the way that your computer deals with
them.

At your leisure ....

Chapter 9 Page 13

Part 2: More about the CPC6128


specifically....
This section gently expands upon some of the machine-specific
aspects of the 6128. Background information to these matters
will be found both in the Foundation course, and in the chapter
entitle-l 'Complete list of AMSTRAD CPC6128 BASIC keywords'.
Subjects covered in this section:

**
**
*
**
**
*
*
*

Character set
ASCII
Variables
Logic
User defined characters
Print formatting
Windows
Interrupts
Data
Sound
Graphics
Graphics Using the Extra Memory

A bit of character....
As you type at your 6128 keyboard, you should not take for granted the fact that
recognisable letters and numbers etc, appear on the screen. After all, we've already
discussed the fact that your computer is not a typewriter. What's actually happening
is a result of you pressing a combination of electrical switches. The electrical signals
produced when you press these switches are translated by the circuitry inside the
equipment to produce a pattern of dots on the screen. We recognise that pattern of
dots as a letter, number, or other character from the 6128's 'character set'.

Chapter 9 Page 14

At your leisure ....

Some of the characters that you will see are not directly accessible by pressing the
keys on the keyboard, but are only available for display using the PR I NT
CH R$ ( <number statement. This is because each element stored in the computer is
stored in the unit of data known as the 'byte' - and as just discussed in part 1 of this
chapter, a byte has 256 different possible combinations of value. As the computer has
to use at least one whole byte per character stored (whether we want it to or not - it's
the smallest denomination that the 6128 appreciates), we might as well use all 256
possible combinations, rather than simply be satisfied with the 96 or so 'standard
characters' that are printed on most typewriters - and throwaway the spare 160
possibilities.
The 'standard' range of characters is known as a 'subset'. It is classified throughout
the computer world as the 'ASCII' display system, a term derived from 'American
Standard Code for Information Interchange'. It's primarily a system that ensures the
data sent from one computer to another is in a recognisable form. The chapter
entitled 'For your reference .... ' lists the ASCII display range, together with the
additional characters available on the 6128, and the corresponding numeric codes.

How we get there ....


You are by now probably quite familiar with the program:

10 FOR n=32 TO 255


20 PRINT CHR$(n);
30 NEXT
.... which makes the computer display the character set on the screen. Let's now
examine the essence of this small program:
The first point to notice is that the computer has not been instructed to PR I NT
" a bed e f 9 h i j k Lmn ...... etc"; instead it has been asked to PR I NT CH R$ ( n ) . n
just happens to be a convenient shorthand note for a 'variable'. A variable is an item
of computer information that 'varies' according to the instructions given in the
program. (The choice of the letter n for the variable is arbitrary - it can be any
letter(s) as long as it's not a keyword.)

How can you tell what is a variable? ....


A number like 5 is fixed, it occurs between the numbers 4 and 6 - thus it is not a
variable. The character n is also fixed - it's a letter from the alphabet.

At your leisure ....

Chapter 9 Page 15

So how did the computer know the difference? Ifthe letter n had been declared to be
the alphabetical character, we would have typed n in quotation marks, i.e. "n", and
the computer would have responded with the message S y n t a x err 0 r - because
it does not understand the command sequence FOR " n " =3 2 TO 2 5 5.
Simply by using n without quotation marks, we have told the computer that n is a
variable. The definition of the FOR statement in BASIC requires that it should be
followed by a variable - so the computer assumes that whatever follows FOR is just
that.

We have also told the computer that n 32 TO 2 5 5. Thus we have declared the
range of the variable. It is in effect, a sequence starting at 32, finishing at 2 55.
Having declared this variable, we should then instruct the computer what it should
do with it -line 20 does just that:

20 PRINT CHR$(n);
This specifies that whatever the current numeric value of n, the computer should
look into its memory to s.ee which character number corresponds to that value, and
print the character on the screen.
The semicolon at the end of the line instructs the computer to prevent a carriage
return and line feed. (Otherwise each new character will be printed in the first
column of a new line.)
Line 30 tells the computer that after it has performed the task with the first value of
n in the sequence (which is 32), it should return to the line where the FOR is located,
and do the same again with the NE X T value that it assigns to the variable n. This
process is known as 'looping', and is one of the most vital and fundamental aspects of
computer programming and operation. It saves typing long repetitious sequences
manually, and you will quickly come to use it in your own programming.
When this FOR NEXT loop reaches the limit of its declared range (255), the
operation ceases and the computer then looks for the next line after line 30 - but
there isn't one, so it simply ends, and returns to direct mode, displaying the Rea d y
prompt. This tells you that the computer is ready to accept further instructions - or
you can enter RUN again and repeat the execution of the program. The program is
safely stored away in the memory and will remain there until you tell the computer
otherwise - or turn the power off.
This program neatly illustrates a fundamental point about computing - i.e.
everything the computer does is related to numbers. The computer has displayed the
alphabet - and a whole range of other characters - using a number as its reference to
the character required. When you type the key marked A, you don't ask the computer
to type an A on the screen, but you tell the computer to look into the part of its memory
that contains the numeric information to display the letter A on the screen. The
actual location of this data is defined by the numeric code that is activated by the
action of typing at the keyboard.
Chapter 9 Page 16

At your leisure ....

(Each character has a corresponding number, and these are listed in part 3 of the
chapter entitled 'For your reference .... '.)
Similarly the displayed character has nothing to do with 'writing' the letter on the
screen; once again it's all about numbers.
For example, the ASCII code for the letter A is 97. The computer doesn't understand
97 either (awkward blighter, eh?), and this number has to be translated from the
human decimal code into a code that computer can relate to - it's generally referred to
as 'machine code', and the principles underlying this aspect of the machine are
discussed earlier in this chapter.
At first, the translation from the decimal number notation we are used to in everyday
life, to the 'hexadecimal' notation of the computer will seem heavy going. Thinking of
numbers that are based on the ten unit is so natural, that to do otherwise is like
trying to eat with your knife and fork in the opposite hands.
A degree of mental dexterity must be acquired to understand hex notation, but once
you do, many things about computing will fall into place and the elegant structure of
the numbering system will become apparent.
If you are unsure about the binary and hexadecimal numbering systems, we suggest
that you thoroughly read part 1 of this chapter (if you have not already done so).

Once the computer has translated the pressing of the A key into the type of number it
understands, it looks into that part of the memory indicated, and the result is another
series of numbers that define the character. Hence the character that you see
displayed on your screen, is built up from a block of data, stored in the memory as a
numeric 'matrix':

A BLANK CHARACTER
MATRIX (GRID)

LOWER CASE a

UPPERCASEA

The elements of the matrix are rows and columns of dots. The character is displayed
by turning the required sequence of dots on or off - each dot is determined by data
stored in the computer's memory. There are 8 rows and 8 columns in each character
matrix or 'cell' on the 6128 display, and if you don't find a character you want out of
the set of 255 that are provided, then you can re-define your own characters using the
keyword S YMB0 L described later in this section.

At your leisure ....

Chapter 9 Page 17

These 'user defined characters' can be made up using any combination of 0 to 64 dots,
arranged in any order - so the 'complete' character set that uses all possible
combinations of this matrix would comprise many more different characters. Add to
this the fact that you can group blocks of characters together to form larger block
characters, and the possibilities for user-defined graphics are limited only by your
time and ingenuity.

Logic ....
A major difference between a calculator and computer is the computer's ability to
handle logical operations in applications like the conditional 1FT HEN sequence.
To do this, the logical operators treat the values to which they are applied as bit
patterns (bit-wise), and operate on the individual bits. The description and use is
entirely, well .... er logical - but it is notoriously difficult to describe logic in simple
terms without the precision of concise definitions.
The two halves of the logical expression are known as the arguments. A logical
expression comprises:
<argument> [ <logical operator> <argument> ]
where:
<argument>

is: NOT <argument>


or: <numeric expression>
or: <relational expression>
or: logical expression

Both the arguments for a logical operator are forced to integer representation, and
ERR or 6 results if an argument will not fit into the integer range.
The logical operators, in order of precedence, and their effect on each bit are:

AND

Result is 0 unless both argument bits are 1


Result is 1 unless both argument bits are 0
X0 R Result is 1 unless both argument bits are the same

oR

AND is the most commonly employed logical operator, and does NOT mean 'add'.

PRINT 10 AND 10
Results in 1 0

PRINT 10 AND 12
Results in 8.

Chapter 9 Page 18

At your leisure ....

PRINT 10 AND 1000


Results in 8 again.
This is because the numbers 1121 and 1121121121 have been converted to their binaJ
representations:
1010
1111101000
The AND operation checks each corresponding bit at a time, and where the bit in the
top AND the bottom row is the 1 , the answer is 1 :
0000001000
... which is our result of 8. The logical operator AND is used to detect when two
conditions are present simultaneously. Here's a self explanatory application:

10
20
30
40
50

INPUT "The number of the day";day


INPUT "The number of the month";month
IF day=25 AND month=12 THEN 50
CLS:GOTO' 10
PRINT "Merry Christmas!"

OR works on bits as well, where the result is 1 unless both bits from the arguments
are 121, in which case the result is 121. Using the same numbers as for the AND example:

PRINT 1000 OR 10
1002
Bit-wise:
1010
1111101000
Resulting in the answer:
1111101010
And in a program example:

10
2J:'1
30
40
50

CLS
INPUT "The number of the month";month
IF month=12 OR month=1 OR month=2 lHEN 50
GOTO 10
PRINT "It must be winter!"

At your leisure ....

Chapter 9 Page 19

The NOT operator inverts each bit in the argument (0 becomes 1, and vice versa):

113
213
313
413
513

CLS
INPUT "The number of the month";month
IF NOTCmonth=6 OR mont~=7 OR month=8) THEN 513
GOTO 113
PRINT "It can't be summer!"

Another major feature to consider is the fact that you can add together any number of
logical conditions (up to 'the maximum line length) to distiil the facts yet further.

113
213
313
413
513

INPUT "The number of the day";day


INPUT "The number of the month";month
IF NOTCmonth=12 OR month=1) AND day=29 THEN 513
CLS:GOTO 113
PRINT "This is neither December nor January, but
this might be a Leap year"

The result of a relational expression is either - 1 or 13. The bit representation for -1
is all bits of the integer = 1; for 13 all bits of the integer = 13. The result of a logical
operation on two such arguments will yield either - 1 for True, or 13 for False.
Check this by adding lines 613 and to the above program:

613 PRINT NOT(month=12 OR month=1)


713 PRINT Cmonth=12 OR month=1)
.... and when the program is run, entering 29 for the day and, say, 2 for the month
will produce the answer in line 513, and the actual values returned by the logical
expressions in lines 6 13 and 713.
Finally, X0 R (eXclusive 0 R) produces a true result as long as both arguments are
different.
The following summarises all these features in what's known as a 'truth table'. It's a
convenient way of illustrating what happens in a bit-wise logical operation.
Argument A
ArgumentB

1010
0110

AND result
OR result
XORresult

0010
1110
1100

Chapter 9 Page 20

At your leisure ....

User defined characters


One of the first applications of binary numbers that you are likely to come across will
be when designing characters for use with the S YMB0 L command. If the character is
drawn on an 8 by 8 grid then each of the eight rows can be converted to a binary
number by putting a 1 for each pixel that is to be inked and a zero for each that should
be invisible, i.e. set to the paper colour. These eight numbers are then passed to the
SYMB0 L command. For example, to define a house character:

*
****

*
*
* * * *
*
*
* ** * *
*
* **
********

=
=
=
=
=
=
=
=

0000 HH'J0
00111100
01000010
10100101
10000001
10110101
10110001
11111111

=
=
=
=
=
=
=
=

&08
&3C
&42
&A5
&81
&B5
&B1
&FF

=
8
32+16+8+4
=
+2
=
64
+4 +1
= 128
+32
= . 128
+1
+32+16 +4 +1
= 128
+32+16
+1
= 128
= 128+64+32+16+8+4+2+1

=
=
=
=
=
=
=
=

8
60
66
165
129
181
177
255

.... the command is:


SYMBOL 240,8,60,66,165,129,181,177,255
.... or ....
SYMBOL 240,&08,&3C,&42,&A5,&81,&B5,&B1,&FF
.... or ....
SYMBOL 240i&X00001000, &X00111100, &X01000010, &X10100101,
&X10000001, &X10110101, &X10110001, &X11111111
To print the user defined character, you would type:
PRINT CHR$(240)
Finally, to group blocks of characters together, you may for example specify:
semi$=CHR$(240)+CHR$(240)
PRINT semi$
.... or ....
terrace$=STRING$(15,240)
PRINT terrace$

Printing press ..

B.

PR I NT is one of the first ever commands that you use when you start to learn
computing. It's one ofthose BASIC commands that does what it says really .... or does
it? In fact there's a lot more to PR I NT than at first it seems, for instance WHERE
should it print? and HOW should it print? ....

At your leisure ....

Chapter 9 Page 21

Print formatting
The PR I NT command has several ways in which it can be used. The simplest is to
follow it by an item to be printed. This item can be a number, a string or a variable
name.

PRINT 3
3

PRINT "heLLo"
he LLo
a=5
PRINT a
5

a$="test"
PRINT a$
test
Several items may be placed in one PR IN T statement with each being separated by a
separator, or TAB or S P C.The possible separators are either a semicolon or a comma.
The semicolon causes direct continuation of printing, while a comma forces printing
to continue in the next zone. The initial zone width is 13, but may be changed using
the Z0 NE command.

PRINT 3;-4;5
3 -4 5
PRINT "heLLo ";"there"
he LL 0 there
PRINT "heLLo","there"
he Llo
there
PRINT 3,-4,5
-4
3

ZONE 4
PRINT 3,-4,5
3

-4

A point to note here is the fact that positive numbers are printed with a leading space,
while negative numbers have a leading minus sign. All numbers have a trailing
space. Strings are printed exactly how they appear between the quotes.

Chapter 9 Page 22

At your leisure....

The function S P C takes a numeric expression as a parameter, and will print as many
spaces as are specified by the expression. If the value is negative then zero is
assumed, if it is greater than the current stream (window) width, then the stream
width is assumed.

PRINT SPC(S)"hi"
hi
x=3
PRINT SPC(x*3)"hi"
hi
TAB is very similar except that it will print as many spaces as are needed so that the
item to be printed will appear in the specified column.
The stream in which all printed output will appear is window 0 unless a stream
director (#) is included before the list of items to be printed. Other streams may be
used to output to the other windows. Streams 8 and 9 are special cases - anything
printed on stream 8 will appear on the printer (if connected). Stream 9 directs output
to a disc (or cassette) file. Note however, that the WRI T E command should be used
.
instead of P RI NT for this purpose.

PRINT "hello"
hello

- window 0

PRINT #0,"hello"
he II 0

- also window 0

PRINT #4,"hello"
hello
PRINT #8,"hello"
hello

- window 4
(At the top of the screen)
- on the printer
(If connected)

TAB and S P C are fine for simple print formats, but to specify a more detailed format,
the PR I NT US I NG command, together with a suitable format template can be used.
A format template consists of a string expression containing special characters, each
of which will specify a particular type of format. These characters, called 'Format
field specifiers', are detailed in the description of the keyword PR I NT US I NG,
earlier in this manual. Some ofthe following examples however, may make their use
a little clearer.
Firstly, here are the formats available for the printing of strings:

At your leisure ....

Chapter 9 Page 23

PRINT USING "\

\";"test string"

test s

" ! " can be used to print the first character of a string.

PRINT USING "!";"test string"


t

.... But probably the most useful string format is 11 &11 This can be used to override the
string wrapping feature of BASIC if required. By default, BASIC will start the
printing of any string on a new line if it is too long to fit onto the current line. PR I NT
US I NG " & " ; can be used to override this.
(Use BO RDER 0, so that you can see the edges of the paper.)

MODE 1:LOCATE 39,1:PRINT "too Long"


- line 1
- line 2

too L0 n g

MODE 1:LOCATE 39,1:PRINT USING "&";"too Long"


to
o Long

- line 1
- line 2

A large number of templates are available for the printing of numbers. Probably the
simplest is PR I NT US I NG "# # # # # ", one digit is printed for each "#" that
appears in the template.

PRINT USING "######";123


123
The position ofthe decimal point may be included by the use of" "

PRINT USING "####.#####";12.45


12.45000
The digits before the decimal point may be grouped into threes, separated by commas
if" , " is included in the template before the decimal point.

PRINT USING "########,.####";123456.78


123,456.7800

Chapter 9 Page 24

At your leisure ....

Floating dollar and pound signs may be included in the format - i.e. a currency sign
that will always be printed directly before the first digit of the number, even ifit does
not fill the complete format. This is achieved by the use of " $ $" and " " in the
template.

PRINT USING "$$##";7


$7
PRINT USING "$$##";351
$351
PRINT USING "####,.##";1234.567
1,234.57
Note the rounding of the result.
The space before the result may be padded with floating asterisks by the use of "
in the template.

** "

PRINT USING "**####.#";12.22


****12.2
This may be combined with the currency symbols, (and then only one currency
symbolis used) - i.e. "
$ .... etc" or "* .... etc".

**

A "+" at the start of the template specifies to always print the sign of the result
before the first digit. A " +" at the end of the template prints a trailing sign.
A " - " can only be placed at the end ofthe format, and specifies that a trailing minus
sign be printed if the number is negative.

PRINT USING "+##";12


+12
PRINT USING "+##";-12
-12
PRINT USING "##+";12
12+
PRINT USING "##-";-12
12PRINT USING "##-";12
12

At your leisure ....

Chapter 9 Page 25

A"

tttt

11

format template can be used to print a number in exponentialformat.

PRINT USING "###.##t t t t";123.45


12.35E+01
When using print formats for numbers, note that if a number is too long for the
specified templ~te, then a %symbol is printed before the result, to indicate that this
has happened, and the result is NOT shortened to fit the specified template.

PRINT USING "####";123456


%123456

Want your windows done? ....


The BASIC of the 6128 provides a comprehensive method for setting up a maximum
of eight text windows. Any of the text screen driving commands may then be directed
to anyone of these windows.
The command that is used to set up a window is, simply enough: WIN DO W. This is
followed by 5 values. The first is optional and is used to specify which window is to be
defined - if omitted, then window zero is assumed, all the normal BASIC prompts and
inessages (for example, 'Re a dy') are produced in window zero. The hash symbol (#)
precedes this number to identify it as being a stream director. The next four numbers
specify the left, right, top and bottom limits of the window. These values are column
and row numbers, so they must lie in the range 1 to 80 for left/right and 1 to 25 for
top/bottom.
The following example will define WIN D0 W(stream) number 4 to start in column 7
(left) and go on to column 31 (right), and to start at row 6 (top) and go down to line 18
(bottom). Reset the computer then type:

WINDOW #4,7,31,6,18
Nothing will appear to have happened after this command, however, try typing the
following:

INK 3,9
PAPER #4,3
CLS #4
This will cause a large green rectangle to appear on the screen, and this is window
number 4. The above also shows that PAP E Rand CLS may be used with anyone of
the eight windows by the inclusion of a stream director; its omission causes the
command to operate on window 0 - the default window.
Chapter 9 Page 26

At your leisure ....

Each of the following commands may include a stream director to identify the
WIN DO Win which the command is to be carried out.

CLS
COPYCHR$
INPUT
LINE INPUT
LIST
LOCATE
PAPER
PEN
POS
PRINT
TAG
TAGOFF
VPOS
WINDOW
WRI TE
The new green window which you have put on the screen, will have obscured some of
the previous text (written on window number 0).
Text may be directed to any window by including a stre&m director in a PR I NT
statement:

PRINT #4,"heLLo there"


These words will appear at the top of the green rectangle, rather than on the
following line as would have happened if....

PRINT "heLLo there"


.... had been used. While typing in the earlier command, you will have noticed that
part of the green window was overwritten by thetext.
If you want all the normal BASIC messages to appear in window 4, then it can be
swapped with the default window (QI)byuse of the WIN DOW S WA P command:

WINDOW SWAP 12J,4


The 'R e a d y' that follows this command will be printed in the green window. The
cursor will be positioned directly beneath it. Now try typing the following:

PRINT #4,"heLLo there"

At your leisure ....

Chapter 9 Page 27

.... and the words 'hello there' will appear directly beneath the WIN DO W SW AP
command in the old window 0, which is now window 4. It may also be apparent from
this, that the current print position in each window is stored, so that even after a
WIN D0 W S WAP, text is printed part way down the new stream 4 rather than
starting at the top. Try the following:

LOCATE #4,20,1
PRINT "this is window 0"
PRINT #4,"this is window 4"
The 'w in d 0 w 0' message will appear on the line after the PR I NT, while the
'w i nd ow 4'messagewill appear at the middle of the top line of the whole screen.
Before a WIN DO Wcommand has been issued, all eight windows cover the entire
screen. This is also true after a MOD E command has been issued - so, if after using
windows you find that the cursor ends up in a very small window, just type in
MOD E 1, as shown:

MODE 1
WINDOW 20,21,7,18
MO
DE
1

Don't worry about the word 'M 0 DE' being split up - it will still work, and don't forget
to leave a space between MOD E and 1 .
Now that you know a little about the way in which windows operate - try typing in the
following short program:
10 MODE 0

20
30
40
50
60
70

FOR n=0 TO 7
WINDOW #n,n+1,n+6,n+1,n+6
PAPER #n,n+4
CLS #n
FOR c=1 TO 200:NEXT c
NEXT n

This sets up 8 overlapping windows and clears each to a different paper colour. When
the program has finished running and 'R e a d y' appears, try pressing [RETURN] a
few times to see how the scrolling of window 0 affects the coloured blocks on the
screen. However, although these coloured blocks may be scrolling, the locations of the
other windows do not actually move. Try the following:

CLS #4

Chapter 9 Page 28

At your leisure ....

.... and you will see that the 4th window is still in the same position - the new coloured
block having obscured those beneath it as one would expect. As a matter of interest,
observe the differences when you type:
LIST
LIST #4
LIST #3

A further feature of the WIN D0 Wcommand, demonstrated by the final program in


this section, is that it does not matter if you specify the left and right window
dimensions in reverse order. This means that if the value of the first parameter is
greater than the second, BASIC will automatically sort the dimensions into the
correct order. This also applies to the top and bottom window dimensions.
HI MODE 0

20
30
40
50
60
70

a=1+RND*19:b=1+RND*19
c=1+RND*24:d=1+RND*24
e=RND*15
WINDOW a,b,c,d
PAPER e:CLS
GO TO 20

If I may interrupt ....


If you haven't already noticed, a major innovation in the software of the AMSTRAD
range of computers is their unique ability to handle interrupts from BASIC - which
means that AMSTRAD BASIC is capable of performing a number of simultaneous
but separate operations within a program. Such a facility is sometimes referred to as
'multi-tasking', and it is implemented by the application of the commands AFT ER
and EVERY.
This facility is also clearly demonstrated in the way in which sound may be handled
through facilities such as queues and rendezvous.
Every aspect of timing is referred to the master system clock, which is a quartz
controlled timing system within the computer that looks after the timing and
synchronisation of events that happen in the computer - things like the scanning of
the display and clocking the processor. Where a function in the hardware is related to
time, this can be traced back to the quartz master clock.
The software implementation is the AFT E Rand EVE RYcommand, which in keeping
with the user-friendly approach of AMSTRAD BASIC, do precisely what they say; i.e.
AFT E R the time that you have preset in the command, the program will divert to the
designated sub-routine and perform the task defined therein.

At your leisure ....

Chapter 9 Page 29

The 6128 maintains a real time clock. The AFT E R command allows a BASIC
program to arrange for sub-routines to be called at some time in the future. Four
delay timers are available, each of which may have a sub-routine associated with it.
When the time specified has passed, the sub-routine is called automatically, just as if
aGO SUB had been issued at the current position in the program. When the
sub-routine finishes, using a normal RE TURN command, the main program
continues running where it was interrupted.
The EVE RY command allows a BASIC program to arrange for sub-routines to be
repeatedly called at regular intervals. Once again, four delay timers are available,
and each may have a sub-routine associated with it.
The timers have different interrupt priorities. Timer 3 has the highest priority and
timer 0 the lowest (see the chapter entitled 'For your reference .... ').

10 MODE 1:n=14:x=RND*400
20 AFTER x,3:GOSUB 80
30 EVERY 25,2 GOSUB 160
40 EVERY 10,1 GOSUB 170
50 PRINT "test your reflexes"
60 PRINT "press.the space bar.";
70 IF flag=1 THEN END ELSE 70
80 z=REMAIN(2)
90 IF INKEY(47)=-1 THEN 110
100 SOUND 1,900:PRINT "cheat!":GOTO 150
110 SOUND 129,20:PRINT "NOW":t=TIME
120 IF INKEY(47)=-1 THEN 120
130 PRINT "you took";
140 PRINT (TIME-t)/300;"seconds"
150 CLEAR INPUT:flag=1:RETURN
160 SOUND 1,0,50:PRINT ".";:RETURN
170 n=n+1:IF n>26 THEN n=14
180 INK 1,n:RETURN
AFT E Rand EVE RY commands may be issued at any time, resetting the sub-routine
and time associated with the given delay timer. The delay timers are shared by the
AFT E Rand EVE RY commands, so an AFT E R overrides any previous EVE RYfor the
given timer, and vice versa.

The DI and E I commands disable and enable timer interrupts whilst the commands
between them are executed. This has the effect of delaying a higher priority interrupt
from ever occurring during the processing of a lower priority interrupt. The REM AI N
function disables; and returns the remaining count for one of the four delay timers.

Chapter 9 Page 30

At your leisure ....

Usmgdata....
In a program that always requires the same set of information to be input at the start,
it would make more sense if there were some way of entering all the values without
having to ask the user to type them in every time. This facility is provided by the
REA Dand DAT Acommands. The word REA Dis very similar to I NPUT in that it can
be used to assign values to variables. It differs, however, in the fact that values are
read from DATAstatements, rather than prompting for input from the keyboard. The
following two examples show this:

1111 INPUT "enter 3 numbers separated by commas";a,b,c


20 PRINT "the numbers are";a;"and";b;"and";c
run
10 READ a,b,c
20 PRINT "the numbers are";a;"and";b;"and";c
30 DATA 12,14,21
run
In the same way that different items in an I NPUT statement are separated by
commas, so it is with items in a DATAstatement.
In addition to numeric values, constant strings may also be held in DATAstatements:
10 DIM a$(8)
20 FORi=0 TO 8

30 READ a$(i)
40 NEXT
50 FOR ;=0 TO 8

60 PRINT a$(i);" ";


70 NEXT
80 DATA The,quick,brown,fox,jumps,over,the,lazy,dog
run
You may notice that although the DATA contains strings, the strings are not
enclosed by double quotes "". The use of double quotes in DATA statements to
delimit (separate) strings is optional, just as they are when typing a string in answer
to an IN PUT statement. One occasion that double quotes are useful however, is when
the string DATA itself contains commas. If strings are not delimited by double quotes
under these circumstances, the REA D statement will use the commas to delimit the
strings in the DATAstatement.

At you leisure ....

Chapter 9 Page 31

10
20
30
40
50
60

READ a$
WHILE a$<>"*"
PRINT a$
READ a$
WEND
DATA The old, desolate, battered house creaked in
the wind
70 DATA "The tall, slim, dark man coughed loudly."
80 DATA *
run
The string in line 60 contains commas, so each part will be REA D and printed
separately. The string in line 70 however, is delimited by double quotes and will be
printed as a whole, as intended.
The above example illustrates the fact that data can be spread over a number oflines.
REA Dwill work down the lines in number order (60, 70, 80, etc.). Another fact that
may not be obvious is that DATA statements can be placed anywhere within a
program; before or after the REA Dstatement that picks up the information.
If a program contains more than one REA D statement, then the second REA D will
continue from the point at which the first REA Dstops:

10
20
30
40
50
60
70

DATA 123, 456, 789, 321, 654, 2343


FOR i=1 to 5
READ num
total=total+num
NEXT
READ total2
IF total=total2 THEN PRINT "the data is ok"
ELSE PRINT "there is an error in the data"

run
Try editing line 1 0 so that one of the first 5 numbers is wrong, then run the program
again. This technique of adding an extra value to the end of DATA statements which
is the sum of all the other values, is a good method of detecting errors in DAT A,
especially ifthere are a large number of DATAlines - this is known as a 'checksum'.
If a program requires mixed data (strings and numbers), it is permissible to combine
string and numeric items in REA D and DAT A statements, as long as the items are
read correctly. For instance, if the DATA contained sequences of two numbers
followed by a string - then it would only make sense to use aRE ADthat was followed
by two numeric variables, then a string variable:

Chapter 9 Page 32

At your leisure ....

10
20
30
40
50
60
70
80

DIM a(5),b(5),s$(5)
FOR ;=1 TO 5
READ a(i),b(i),s$(i)
NEXT
DATA 1,7,fred,3,9,j;m,2,2,er;c,4,6,peter,9,1,alfonzo
FOR ;=1 TO 5
PRINT s$(;),":";a(;)*b(;)
NEXT

Alternatively, you may wish to separate the different types of data:

10 DIM a(5),b(5),s$(5)
20 FOR ;=1 TO 5
30 READ a(;),b(;)
40 NEXT
50 FOR ;=1 TO 5
60 READ 's$(;)
70 NEXT
80 DATA 1,7,3,9,2,2,4,6,9,1
90 DATA fred,j;m,er;c,peter,alfonzo
100 FOR ;=1 TO 5
110 PRINT s$(;),":";a(i)*b(;)
120 NEXT
Ifthe FOR loop in line 20 is now changed to:

20 FOR ;=1 TO 4
.... then the first two attempts to read strings in line 60 will produce '9' then' 1 '. These
values are of course valid strings, but the result is not exactly what was planned! One
method by which the program could be forced to work properly, would be to include
the following commands:

15 RESTORE 80
45 RESTORE 90
The RES TOR E statement will move the DAT A-reading 'pointer' to the line specified,
and can therefore be used in a conditional statement to pick a certain block of data to
be read depending upon some criterion. For instance, in a multi-level game which has
a number of different screens, the DATA for each screen may be picked according to
some variable - for example' Leve L'. The following is just an example section of such
a program:

At your leisure ....

Chapter 9 Page 33

1000
1010
1020
1030
1040
1050
1060
1070
1080

REM section to draw the screen


IF LeveL=1 THEN RESTORE 2010
IF LeveL=2 THEN RESTORE 2510
IF LeveL=3 THEN RESTORE 3010
FOR y=1 TO 25
FOR x=1 TO 40
READ char
LOCATE x,y: PRINT CHR$(char);
NEXT x,y

2000 REM DATA for screen 1


2010 DATA 200,190,244,244,210, ...... etc.
2500 REM DATA for screen 2
25 10 DATA 100, 103,245 , 243, 2 51 ,...... etc.
3000 REM DATA for screen 3
3010 DATA 190,191,192,193,194,...... etc.
Another example use of DATA, REA D and RES TOR E might be in a program that
plays a tune. Tone period values may be REA D from DAT A statements, and
RES TOR E used to make a section repeat by moving the pointer back to the beginning
of a certain part of the music data:

10 FOR i=1 TO 3
20 RESTORE 100
30 READ note
40 WHILE note<>-1
50 SOUND 1,note,35
60 READ note
70 WEND
80 NEXT
90 SOUND 1,142,100
100 DATA 95,95,142,127,119,106
110 DATA 95,95,119,95,95,119,95
120 DATA 95,142,1)9,142,179,119
130 DATA 142,142,106,119,127,-1
run

Chapter 9 Page 34

At your leisure ....

The sound of music ....


Of all the 6128's features, the sound and envelope commands will probably seem to be
the most daunting at first sight - this needn't be the case. With a little practice you
should be able to make a whole range of different noises and even make the machine
play a complete tune with harmonies.
Let's start by having a look at the first 4 parts of a SOU ND command. These are:
channel number, tone period, duration of note, and volume. You may be wondering
what range each number has to be in.
We'll leave the first part (channel number) for a moment because it is quite
complicated. The second part (tone period) can take any whole number value from 0
to 4095, but only some of these will actually produce recognisable notes from the
musical scale - these are listed in part 5 of the chapter entitled 'For your reference .... '.
For instance the number 239 will play middle C, and 253 will play the note B below
middle C, the values 240 to 252 will play a tone, but not one that corresponds to the
piano scale. If the tone period is zero then no tone will be played - this will be useful
when using 'noise' (explained later).
The third part of the SOU ND command gives the duration of the note in units of a
hundredth of a second. The value can generally be anywhere in the range 1 to 32767.
However, if the value is zero, then the length of the note will be determined by the
'envelope' used (more ofthis later).lfthe value is negative then it indicates how many
times the envelope should be played, so -3 would mean 'repeat the volume envelope
three times' (again, this will be explained later).
The fourth part of the command is the volume. This can be from 0 to 15 (but if it is
omitted, 12 is assumed). With the simple sounds that have been made so far, the
volume remained constant for the whole time that the note played. When a 'volume
envelope' is used to vary it, then the volume part ofthe SOU NDcommand is taken as
the starting value of the note.
Now for the channel number part of the command. You might as well know now that
this is a 'bit significant' number - so you'll need to know a little about binary numbers
to fully understand it (see part 1 of this chapter).
A sound can be played on one of three possible channels, ifthe computer is connected
to a stereo amplifier, then one channel will be on the left, another on the right and the
third on both (in the middle). To choose which channel(s) that a note should be played
on, the following numbers are used:
1 channel A
2channelB
4channelC

At your leisure ....

Chapter 9 Page 35

To play on more than one channel, add up the numbers for the desired channels. For
example to play on A and C use 1 +4 = 5.

SOUND 5,284
You may be wondering why channel C is given the number 4 and not 3 as you might
expect. This is because each of these numbers is a power of two (1=2 t 0, 2=2 t 1,
4=2 t 2) so that they combine to form a binary number. If you think about a three
digit binary number, then each ofthe three digits can be either 0 or 1, and this is used
in the channel number to indicate whether the corresponding channel should be on or
off. From the above example:
5 in decimal is equivalent to 1 * 4 + 0 * 2 + 1 * 1 or 101 in binary. It follows then, that
if each column ofthis binary number is labelled C, B, and A, this gives:

C B A
1

In other words, channel C is ON, B is OFF, and A is ON. If the note was to be played on
channels A and B, then this would become:

C B A

And the binary number 011 is the same as 0*4 + 1 * 2 + 1 * 1 = 3. So the S OUN D
command would be:

SOUND 3,142
This is, of course, the same value that would be found if you just added up the
numbers for the channels to play on (remember A= 1, B=2, C=4). So to play on A and
B, the channel number is given by 1 +2 = 3.
If you didn't understand that - don't worry. As long as you can see that a combination
of channels can be chosen by adding up the numbers for each of the channels to be
used, then that's all you really need to know.
Unfortunately, there are yet more values that can be used in the channel number.
The numbers 8, 16 and 32 are used to specify that the sound should 'rendezvous' with
another channel (A, B, C respectively). You're probably wondering what is meant by
the term rendezvous. Well, up to now the sounds that we have produced have gone
straight to the specified channels. Try this:

SOUND 1,142,2000
SOUND 1,90,200

Chapter 9 Page 36

At your leisure ....

Unless you are a very slow typist, you will have noticed that you were able to type in
the second of these commands before the first had finished. This is because the sound
system is able to hold up to 5 sound commands for each channel in a 'queue'. If we
wanted a sound to play on channel A, and then two,sounds to play simultaneously on
A and B, we would need some way ofletting the computer know that the sound on B
should not start until the second note on A was ready to play - i.e. making one channel
wait for another. This is known as a rendezvous, and there are two ways in which this
can be achieved:

SOUND 1,200,1000
SOUND 3,90,200
In this, the second note is directed to A and B, so it cannot start until the note on A
finishes. The limitation with using this method (to make a note combination wait
until all channels that it should play on are free) is that the same sound will be
directed to each of the channels (in this case, 90,200 went to both A and B). The
alternative method is to use the following:

SOUND 1,200,2000
SOUND 1+16,90,200
SOUND 2+8,140,400
Here, the second note on A is made to rendezvous with the sound on B (and the sound
on B is made to rendezvous with the note on A). The advantage here is clear
- although the second note on A was different to the note on B, the two were still
linked so that neither could start until both channels were free - this is a rendezvous.
Once again the values are bit-significant:
8 = 2 t 3,16 = 2 t 4, and 32 = 2 t 5
.... so now the channel number can be seen as a binary number where the columns are
headed:
Rendezvous
C
Add 32

Rendezvous
B
Add 16

Rendezvous

A
Add8

Play on
C
Add 4

Play on

B
Add 2

Play on
A
Add 1

So for a note to play on C and rendezvous with A, you would use:

This is the binary number 1100, which is equal to 8 + 4 = 12


Hence, a channel number of 12 would tell the computer to play a note on channel C,
and wait for a note that has been marked to rendezvous with it on channel A.

At your leisure ....

Chapter 9 Page 37

If 64 (2 t 6) is added to the channel number, then this indicates that the note should
be held. In effect, this means that the note will not play until the command
RE LEA S E is used.

And finally, if 128 (2 t 7) is added to the number, then the queue of the channel
specified will be cleared (or flushed). Therefore, if you start a sound that is going to
continue for too long on a particular channel, then a quick way to stop it is to flush the
channel:

SOUND 1,248,30000
SOUND 1+128,0

(this would play for 5 minutes)


(this will stop it short)

In direct command mode, a quicker way of stopping any long sounds is to press the
[DEL] key at the start of a line; the short warning beep flushes all sound channels.
Now that we can hopefully send a sound to any of the three channels that we choose,
(with rendezvous if necessary), it would be nice to be able to produce a little more than
the rather unmelodious 'beep' that the simple SOU ND command produces. The way
to do this is to play the sound with an envelope - a pattern that defines how the note
gets louder and quieter during the short time it is playing. A note produced by an
instrument has an initial attack, where the volume rises very sharply. The volume of
the note then falls away to a lower level which is sustained for a time, after which it
fades away to zero. It is possible to give an envelope of this nature to the notes
produced by the SOU ND command. The associated EN V command is used to do this.
First let's look at a simple example:

ENV 1,5,3,4,5,-3,8
SOUND 1,142,0,0,1
The EN V must come before the SOU ND command for which it is used. To use this
envelope in a SOU NDcommand, its number is included as the fifth part of the SOU ND
command - in this case, the envelope is number 1. The first number in an EN V
command is the number of the envelope that it defines. The EN V instruction contains
information about how long the note will last and how loud it will get, so the duration
and volume parts of the SOU NDcommand are set to zero. The envelope defined above
causes the sound to be increased in 5 steps, each step ihcreasing the volume by 3, and
each step being 4 hundredths of a second long. The volume is then to be reduced in 5
steps, each step decreasing the volume by - 3, each step being 8 hundredths of a
second long. In other words, the first number identifies which envelope is being
defined, and this is then followed by two groups of three numbers, and in each of these
groups, the first number indicates by how many steps the volume is to go up or down.
The second number indicates by how much the volume is to go up or down at each of
these steps, and the third number determines by how long each step of volume is to be
held for.

Chapter 9 Page 38

At your leisure ....

The total length oftime that each section will take is equal to the first value (number
of steps) multiplied by the third value (pause time). The total increase or decrease in
volume is equal to the number of steps multiplied by the step size. The overall length
of an envelope with more than one section, is equal to the sum of the lengths of each
section.
Of course, the starting volume needn't always be 0 (as set by the SOU N0 command).
The above example produced a note that went up, then back down again. The
following will go down, then back up:

ENV 2,5,-2,1,20,0,1,10,1,1
SOUND 1,248,0,15,2
This envelope is given the number 2 and has three sections. In the first, the volume is
reduced in 5 steps of - 2. That is, it goes down by 2 at each step and there are 5 steps.
The length of each of these steps is 1 hundredth of a second. The second section
consists of 20 steps, but with 0 (zero) reduction or increase in the volume (i.e.
constant volume) per step. Again, the length of each of these steps is 1 hundredth of a
second. Finally, the third section has 10 steps, each increases the volume by 1, and
once again each step is 1 hundredth of a second long.
The SOU N0 command has a starting volume of 1 5, so after the first section the
volume will be reduced to 5, this is held constant for 20 hundredths of a second, then
gets increased to 15 in the final section of the envelope.
It is perhaps a little difficult to visualise the shape ofthese envelopes. It often helps to
draw them out on graph paper and take the values for the EN V command from this.
The following show the shape ofthe two envelopes that have been defined so far:
Relative
'vblume

Change

"
"

~-r--'-~--~~:~~~r--r--'"
.. --7.32~<~~~~r--r
.. --T.48--~~~~~W~~S
STEP COUNT 5

~Cis~~,~~ 4

At your leisure ....

STEP COUNT 5

~ZsES'f,~E~

Chapter 9 Page 39

Relative
Volume
Change
16r-:1'f-71T-8..:;:19-=;20;:.:21'j-'2=,=.2"T23,24;:.:25f"26:r-=;.27..::;26:.,::29r:30'i'-3:;.1.::;32;.:;33;:.:34r35::.r--_.... 1~0
5 T6-i7~8;:-;:-9.:r10.,11....:;12r-:1:;:...31::r
4 ...:;:15,-:;
1-+1-;.2...:;3:...:4T-+

:
-2

seconds

-4

1
I
I

-8
-8

1
1

1
1
1

-10

,-+'- - - - - - - - - - - - - - - !
STEP COUNT 20
5,
1
STEP SIZE 0
PAUSE TIME 1

stepcount ,

ster:i,ze :
paus~time

The maximum number of sections in' an envelope is 5, and each section takes 3 values,
so the EN V command can have up to 16 parts (including the first, that identifies
which of the 15 envelopes (1 to 15) is being created). If the steps up or down cause the
volume to go above 15 or below 0 then the value will wrap around; so the step above 15
is 0, and the step below 0 is 15:

ENV 3,9,5,20
SOUND 1,142,0,0,3
This simple envelope produces 9 steps, each step increasing the volume by 5, and
each step lasting 20 hundredths of a second. After the first three steps therefore, the
volume will be 15, so the next step will take it back round to 4, then 9 and so on. The
diagram on the following page shows the effect:

Chapter 9 Page 40

At your leisure ....

Relative
Volume

Change

15
14
13

10
9
8

5
4
3

20

40

80

60

90

100

120

140

160

160

STEP COUNT 9
STEP SIZE 5
PAUSE TIME 20

The range of values for the number of steps is 0 to 127. The step size can be varied
from -128 to +127 (negative values decrease the volume), and the pause time (i.e.
the time between steps) can be anywhere in the range 0 to 255.
Now that we can create a volume envelope to give a characteristic shape, we may also
want to define a characteristic tone pattern to include things such as vibrato - where
the sound 'wavers' about the main tone ofthe note.
This is done in a very similar way to that in which volume envelopes are defined.
Tone envelopes are defined using the ENT command. For example:

ENT 1,5,1,1,5,-1,1
SOUND 1,142,10,15,,1
A tone envelope is called into the SOU ND command by entering the tone envelope's
number as the sixth part ofth,e SOU NDcommand. Again the ENT must come before
the SOU NDcommand.

At your leisure ....

Chapter 9 Page 41

This first example of ENT specifies that in tone envelope number 1, there is to be 5
steps, each step increasing the tone period by 1, each step being 1 hundredth of a
second. The next section of the envelope again specifies 5 steps, this time each step
decreasing the tone period by - 1 , again each step being 1 hundredth of a second. This
is a total length of 5 + 5 = 10. Notice that this length was specified in the SOU ND
command because a tone envelope does NOT determine the length of time that a note
will play (in the same way that a volume envelope does). If the length used in the
SOU NDcommand is shorter than the length of the tone envelope, then the last part of
the tone envelope will be lost. If it is greater, then the last part of the note will play
with a constant tone. This also applies if a volume envelope is used to determine the
note length.
(Notice the absence of any number in the volume envelope part of the SOU ND
command - this is because we have not created a volume envelope for this sound.)
The majority of tone envelopes will probably be much shorter than the expected
length of the note. For this reason, a tone envelope can be made to repeat throughout
the time that the note is playing. This is done by specifying a negative envelope
number, the positive equivalent of which must be used in the SOU NDcommand:

ENT -5,4,1,1,4,-1,1
SOUND 1,142,100,12,,5
This will produce a vibrato effect on the note. When defining tone envelopes, it is
usually best if they can be made to vary symmetrically about the initial tone period,
so that when the note repeats, it will not go further and further off the initial
frequency (pitch) - try this:

ENT -6,3,1,1
SOUND 1,142,90,12,,6
You will notice that this tone will fall in frequency quite dramatically because each
time the envelope is repeated, the tone period will increase by 3 and this will happen
30 times (9 0/3). This sort of effect can be quite useful for 'warbling' notes and sirens:

ENT -7,20,1,1,20,-1,1
SOUND 1,100;400,12,,7
ENT -8,60,-1,1,60,1,1
S6UND 1,100,480,12,,8
The number of possible tone envelopes is 15 (in the range 1 to 15), with a negative
value indicating that the envelope should repeat. The number of steps (the first value
in each group of three), can be anywhere between 0 and 239. As in the volume
envelope, the step size can be from -128 to 127, and the pause time should be between
o and 255. Once again, an ENT command, like an EN V command, can have a
maximum offive sections (each containing 3 values).

Chapter 9 Page 42

At your leisure ....

The final part that can be added onto a SOU ND command is a seventh value that
indicates the level of noise which should be included in the sound. One point that
should be borne in mind when including noise in a sound, is the fact that there is only
one noise channel, so each subsequent noise period value overrides any previous one.
The noise can be added to a tone to give it a different sound, or can be used quite
separately, by setting the tone period (second part) of the SOU ND command to "', so
that only noise is present. This is of use in making percussive type sounds. Try this

ENT -3,2,1,1,2,-1,1
ENV 9,15,1,1,15,-1,1
FOR a=1 TO 10: SOUND 1,4000,0,0,9,3,15: NEXT
This could form the basis of a train noise. You will notice that this combines both
types of envelopes and noise.
The duration and volume parts of the SOU NDcommand are both set to 0 as they are
determined by the volume envelope.
Now that we can hopefully use the SOU ND, ENV and ENT commands to their full, we
can look at various other associated commands and functions.
In describing the channel number of the SOU ND command, you will remember that
by adding 64 to it, the sound was marked as 'held' so that it would remain in the
queue, without playing until released. The way in which a sound can be released is by
use of the RE LEA S E command. The word RE LEA S E is followed by a bit significant
number, where each bit is used to indicate one of the three possible channels to be
released. Once again, it is not important to fully understand this, as long as you
realise that:
4 means channel C
2 means channel B
1 means channel A
.... and a combination of channels is released by adding up the values for each of the
channels. So, to release held sounds on all three channels tlie following would be
used:

RELEASE 7
.... where 7 = 1 + 2 + 4. If no channels are held, then the RE LEA SF command is
ignored. Try the following:

SOUND 1+64,90
SOUND 2+64,140
SOUND 4+64,215
RELEASE 3: FOR t=1 TO 1000: NEXT: RELEASE 4

At your leisure....

Chapter 9 Page 43

The sounds that you might expect from these SOU ND commands are not produced
until the first RE LEA S E command which allows the sounds on channels A and B to
play. After the delay, the sound on channel C is RE LEA SEd.
There is yet another method by which more than one sound can be made to
rendezvous. When a sound is added to a queue that has the hold bit set (64 added),
then it is not just that sound which is held, but all subsequent sounds sent to that
queue. If more than four further sounds are sent to the held queue, then the machine
will pause until the queue is released, perhaps by using a sub-routine that is called
after a fixed period of time (using AFT E R or EVE RY). However this is not a
particularly good method for using the sound system, as the program that contains
the sound commands may pause from time to time as the sound queues fill up. This is
also true if a lot oflong sounds are added in quick succession. Try this:

10 FOR a=1 TO 8
20 SOUND 1,100*a,200
30 NEXT
40 PRINT "heLLo"
run
You will notice that the word 'h ell 0' does not appear instantly, but only after the
first three sounds. This is because program execution cannot continue until there is a
free space in the queue.
The BASIC contains an interrupt mechanism, rather like that used in the AFT ER
and EVE RY commands, and in 0 N B REA K G0 SUB. This enables you to specify a
sound playing sub-routine that is only called when a free space appears in the
required queue. Try this:

10 a=0
20 ON SQ(1) GOSUB 1000
30 PRINT a;
40 GOTO 30
1000 a=a+10
1010 SOUND 1,a,200
1020 IF a<200 THEN ON SQ(1) GOSUB 1000
1030 RETURN
run
You will notice that the program never pauses. The SOU NDcommand is only called
when channel A's queue (number 1) has a free slot. This condition is detected by the
ON S Q ( 1) GO SUB command in line 20. The command initialises an interrupt
mechanism that will call the sound sub-routine when a free .slot appears in the
specified queue. Once ON SQ GOSUB has been used, it must be re-initialised,
and this is done by line 1020 in the sound sub-routine. In this example, the sound
sub-routine only re-initialises itself while the value of' a' is less than 200.

Chapter 9 Page 44

At your leisure ....

In a complete program that may be moving objects on the screen, adding up totals and
the like, a background tune can be kept continually playing by having a sub-routine
called to play each note only when there is a free slot in the queue. This ensures that
the program does not pause while waiting for a free slot to appear. If the note values
for this tune were being read from DA T A statements, then the sound routine could be
set stop re-initialising itselfjust before the data is exhausted.
The number within the brackets of the 0 N SQ () GO SUB command can be 1, 2 or
4 depending on which channel queue is to be tested for a free slot.
There is a function S Q ( ) that may be used within a program to read the current state
of any of the sound channels. The number within the brackets after S Q is again 1, 2,
or 4, to specify for which channel the information should be returned. The function
returns a bit-significant number and will again require an understanding of binary
numbers to decipher it. The bits of the value returned have the following significance:
BIT

DECIMAL MEANING

0,1,2

1,2,4

16
32

5
6

64
128

Number of free spaces in the queue


Note at head of queue is marked to rendezvous with A
Note at head of queue is marked to rendezvous with B
Note at head of queue is marked to rendezvous with C
Top note in queue has hold bit set (the queue is held)
A note is currently playing

Try this simple example:


HI SOUND 2,200
20 x=SQ(2)

30 PRINT BIN$(x)
run
This will print the binary number 10000 100, in which bit 7 is set, indicating that
the channel was currently playing when the S Q function was used. The last three
digits 100, when converted to decimal give the value 4 indicating that there were 4
free entries in the queue. This function may be used to test a queue's status at a given
point within a program - unlike 0 N SQ () GO SUB which will test and react to a
queue's status at an indeterminate point.
So far, all the examples have just dealt with one or two notes of sound. Processing a
whole group of unrelated notes, for example in a piece of music, can be achieved by
listing the required notes in a DA T A statement, from where they can be REA Dinto a
SOU NDcommand:

At your leisure ....

Chapter 9 Page 45

10 FOR octave=-1 TO 2
20 FOR x=1 TO 7: REM notes per octave
30 READ note
40 SOUND 1,note/2joctave
50 NEXT
60 RESTORE
70 NEXT
80 DATA 426,379,358,319,284,253,239
run
The final example program in this section greatly elaborates on this basic principle.
The tune and rhythm play on channels A and B, using rendezvous to keep in step. The
example demonstrates one of the ways in which DAT A can be formatted so as to
include note, octave, length and rendezvous information:

10 REM line 180 gives treble clef tune


20 REM line 190 gives bass clef tune
30 DIM scale%(12):FOR x%=1 TO 12:READ scale%(x%):NEXT
40 ch1%=1:READ ch1$:ch2%=1:READ ch2$
50 CLS
60 Spd%=12
70 scale$=" a-b b c+c d-e e f+f g+g"
80 ENV 1,2,5,2,8,-1,10,10,0,15
90 ENV 2,2,7,2,12,-1,10,10,0,15
100 ENT -1,1,1,1,2,-1,1,1,1,1
110 DEF FNM$(s$,s)=MID$(s$,s,1)
120 ch1%=1:GOSUB 200
130 ch2%=1:GOSUB 380
140 IF ch1%+ch2%>0 THEN 140
150 END
160 DATA &777,&70c,&6a7,&647,&5ed,&598
170 DATA &547,&4fc,&4b4,&470,&431,&3f4
180 DATA 4cr4f4f1f1g1A1-B2C2f4g2g1A1-B6A2Cr1f1g1f1g1a1b1A1-b2C2g2A2g2f1g1a2g2f6e2c2e2c2g2e2c1-B1A2g2f4e4d
8c4f3f1c2d4-b2fr2-B2A2g2f6e2gr4C4-B1a1f1-b1g2c2-b4a
4g4fr6A2A2-B4-B2Ar2-B2A2g2f6e2g4C4-B1A1f1-B1g2C2-B4
A4g8f.
190 DATA r4f4f8f4e4c4fr8f4e2f2e4d2e2d8c8c6e2f4g4g8e4f3f
1c4dr8g4cr4e4c6f2d4c4c8fr8-e4dr8g8c4e4c6f2d4c4c8f.
200 REM send sound to channel A
210 p1$=FNM$(ch1$,ch1%)
220 IF p1$<>"r" THEN r1%=0:GOTO 240
230 r1%=16:ch1%=ch1%+1:p1$=FNM$<ch1$,ch1%)
continued on the next page
Chapter 9 Page 46

At your leisure ....

24111
25111
26111
27111
28111
29111
3111111
31111
32111
33111
34111
35111
36111
37111
38111
39111
4111111
41111
42111
43111
44111
45111
46111
47111
48111
49111
5111111
51111
52111
53111
54111
55111
run

IF p1$="." THEN ch1%=I1I:RETURN ELSE l1%=VAL(p1$)


ch1%=ch1%+1
n1$=FNM$(ch1$,ch1%)
ch1%=ch1%+1
IF n1$="+" OR n1$="-" THEN 35111
n1$=" "+n1$
nd1%=(1+INSTR(scale$,LOWER$(A1$)/2
IF ASC(RIGHT$(n1$,1>96 THEN 01%=8 ELSE 01%=16
SOUND 1+r1%,scale%(nd1%)/01%,Spd%*l1%,11I,1,1
ON SQ(1) GOSUB 2111111
RETURN
n1$=n1$+FNM$(ch1$,ch1%)
ch1%=ch1%+1
GOTO 3111111
REM send sound to channel B
p2$=FNM$(ch2$,ch2%)
IF p2$<>"r" THEN r2%=I1I:GOTO 42111
r2%=8:ch2%=ch2%+1:p2$=FNm$(ch2$,ch2%)
IF p2$="." THEN ch2%=I1I:RETURN ELSE l2%=VAL(p2$)
ch2%=ch2%+1
n2$=FNM$(ch2$,ch2%)
ch2%=ch2%+1
IF n2$="+" OR n2$="-" THEN 53111
n2$=" "+n2$
nd2%=(1+INSTR(scale$,LOWER$(n2$)/2
IF ASC(RIGHT$(n2$,1>96 THEN 02%=4 ELSE 02%=8
SOUND 2+r2%,scale%(nd2%)/02%,Spd%*l2%,11I,2
ON SQ(2) GOSUB 38111
RETURN
n2$=n2$+FNM$(ch2$,ch2%)
ch2%=ch2%+1
GOTO 48111

Graphically speaking....
This section describes the graphics facilities available. The first example builds up
slowly demonstrating each major feature in turn.
To start off with, we will divide the screen into a text window (line 40) and a graphics
window (line 3 0), setting the MOD E and a couple of flashing colours along the way
(line 20):

At your leisure ....

Chapter 9 Page 47

10
20
30
40
50

REM mask and tag in window


MODE 1:INK 2,10,4:INK 3,4,10
ORIGIN 440,100,440,640,100,300
WINDOW 1,26,1,25
CLG 2

If you RUN thIs program you will see a square of flashing colour halfway down the
right-hand side of the screen. This square has been cleared to ink number 2 (flashing
magenta/cyan) by line 50, and the origin of co-ordinates has been moved to the
bottom left hand corner of the square. The MOD E command has set the graphics
cursor to the origin of co-ordinates (X=O, Y =0) so we can draw a diagonal line across
the square with line 60:

60 DRAW 200,200,3
RUN the new program to see the effect. Now add:

80 MOVE 0,2:FILL 3
Line 80 puts the graphics cursor just inside one of the two halves of the square and
fills it with ink 3. The boundary of the fill is the edge of the graphics window (in this
case also the edge of the square) and anything drawn in the current graphics pen (3)
or anything drawn in the ink being used to fill (also 3).
Now RUN the resulting program.
To prove the point about 'fill' edges, add line 70 below. Note that it is only the fact
that the fill is in the same ink as the diagonal line that restricts the fill to half the
square.

70 GRAPHICS PEN 1
run
Edit line 80 to F ILL with ink 1 then RUN to prove this last point. Then restore it
back to the original ( F ILL 3).
Now add lines 1 00 to 1 40, which draw a box:

100
110
120
130
140
run

MOVE
DRAW
DRAW
DRAW
DRAW

Chapter 9 Page 48

20,20
180,20
180,180
20,180
20,20

At your leisure ....

The box is drawn in ink 1- because of line 7121. Ifline 7121 were omitted then we would
need to add a ' , l' either as the third parameter ofthe M0 VE command in line 1 121 121, or
the third parameter of the DRAW command in line 11 121 in order to instruct the
computer to change graphics pens.

Join the dots ....


Lines need not be solid, they can be dotted. The MASK command allows us to specify
the size of the dots. The pattern will repeat every 8 pixels and each subsequent line
will continue the dotting scheme from where the last line left off. A new MASK
command (probably with the same parameter as the current one) will reset the
dotting logic to the start of the 8 pixel pattern.
The dotting pattern is actually a single byte binary number where the bits set
indicate where to put pen ink. In our example we will use a binary constant (called up
by the '&X') indicating that we want four pixels drawn in the middle of each 8 pixel
group, with the two either side not drawn. This will give a dashed line with four
pixels on and four pixels off. To do this, add:

MASK

9~

&X~~1111~~

run
But hold on a moment! This program does not give us a smooth continuation of the
dotting around the corners as we expected. The reason for this is that each corner
point is actually plotted twice, once as the last pixel of one line, and again as the first
pixel of the next line. A clumsy way around this is to type in:

115 MOVE 18~,22


125 MOVE 178,180
135 MOVE 2~,178
run
.... which produces the desired effect. However there is a simpler way, which is to add a
second parameter', 121' to the end of the MASK command which tells the computer
NOT to plot the first point of each line. Edit line 9121 to read:
9~

MASK

&X~~1111~~,~

.... and delete the lines youjust added by typing:

115
125
135

At your leisure ....

Chapter 9 Page 49

Now RUN, and once again the dotted box is symmetrical. Note that if the second
MASK parameter is " l' the command will be reset to draw whole lines including the
first pixel.
Now look in between the dashes of the line. There is something in the bottom right
triangle which is not in the top left triangle. This is the graphics paper, which is set to
ink 2 by the CLG 2 command in line 5 0, but is invisible in the top left triangle
because it is the same colour as the background. Alter line 50 to read:

50 CLG 2:GRAPHICS PAPER 0


.... and re-run the program. The paper now shows up clearly all round the box.

It is possible to make the graphics paper invisible, or, as we call it 'transparent'. This
means that a dotted line drawn over an existing picture will preserve the gaps
between the dots. The graphics drawing is made transparent by adding a " 1 '
parameter to the GRAP HIe S PEN command. (It is reset to non-transparent or
'opaque' by a ',0' parameter). Alter line 70 to read:

70 GRAPHICS PEN 1,1


run
.... and observe the result.
As well as drawing lines (and plotting points) it is possible to write normal text
characters at the position ofthe graphics cursor. This has the advantage that we can
position the characters with much greater accuracy (within one pixel rather than
within 8 pixels) and also that we can draw characters with the added flavour of
graphics ink modes (see ahead).
To write characters at the graphics cursor location, simply position the graphics
cursor at the top left-hand corner of where you want the character to be drawn, then
issue the command TAG (or TAG # 1 etc, for other text streams) followed by normal
PR I NTing commands. The graphics cursor is automatically stepped right by 8 pixels
after each character is drawn. Add:

160
170
180
190
run

MOVE 64,108
TAG
PRINT "SALLY"
TAGOFF

(Any messages output by BASIC will be sent to the text screen irrespective of the
state of the TA G/T AGO F F switch, but it is good practice to cancel the TAG
assignment as soon as the TAGgingisover.)

Chapter 9 Page 50

At your leisure ....

But what are the arrows after the name? Well, these are carriage-return CH R$ ( 1 3 )
and line-feed CH R$ ( 1 0) symbols. The graphics drawing software translates all of
the first 32 ASCII characters into their printable versions (as if they were each
preceded by a CH R$ ( 1 ) ; when sent to the text screen). The reason for this is that
most of the first 32 control codes are meaningful.only to the text screen. By the same
token for example, if we overflow to the right of the graphics window, no wrap-around
is performed.
The carriage-return ang. line;-feed symbols can be suppressed by the normal
technique of ending the PR I NT statement with a semicolon, Le:

180 PRINT "SALLY";


run
Text sent to the graphics screen using TAG is influenced by the same GRAP HIe S
PEN commands as the line drawing. Thus currently, the name is written in
GRAP HIe S PEN 1 , and is transparent. The command:

150 GRAPHICS PEN 1,0


run
...,.will switch back to-opaque paper, whilst:

150 GRAPHICS PEN 0,1


run
.... will write with ink number 0, transparently.
Now delete line 1 50 and RUN again. Ink number 1 + transparent mode (previously
set in line 70) will be restored to the graphics pen.

Transparent characters
It is also possible to write characters to the text screen transparently, by l.1.sing one of
the control codes provided. Add:

200
210
220
230
run

PRINT #2,CHR$(22);CHR$(1)
LOCATE #2,32,14:PRINT #2,"******"
LOCATE #2,32,14:PRINT #2," ______ "
PRINT #2,CHR$(22);CHR$(0)

Line 200 sets stream # 2 to transparent mode. Note how the underlining appears to
'overstrike' the asterisks. This demonstrates that it is possible to build up composite
characters, even in multiple colours. Line 230 switches off transparent mode,
setting stream # 2 back to opaque mode.

At your leisure ....

Chapter 9 Page 51

Ink modes
It is possible to draw using a graphics ink mode which combines the current drawing
with the ink already on the screen. The final ink for each pixel is calculated by
forming the logical combination of the old ink for the pixel with the graphics ink (pen
or paper) being plotted. The logical combinations provided are XOR, AND and OR.
The ink mode can be set either as the fourth parameter of DRAW/DRAWR,
PLOT/PLOTR and MOVE/MOVER commands or by PRINTing a CHR$(23);
CH R$ ( <mode control code sequence. In each case a value of 1 sets XOR plotting, 2
sets AND plotting and 3 sets OR plotting. A value of 0 restores the 'force' mode,
where the graphics inkis used 'as is'.

The next example demonstrates the use of the XOR combination. XOR is often used
in so-called Turtle Graphics because it has the property that drawing the same
pattern twice restores the original image. Thus the square drawing routine is
executed twice (in lines 110 and 130), and the TAGged printing is also executed
twice (in lines 170 and 190). The F RAME commands cause enough delay to make
the effect visible. Note the use, in line 90, of commands without a first parameter.
This is quite in order in these commands, and simply leave the current settings ofthe
first parameter unchanged.
The third parameter (, 1) of the M0 VE command in line 2 2 0 sets the GRAP HI CS
PEN to 1, overriding the '3' set in line 60. The XOR mode is set by the fourth
parameter of the DRAW R command in line 2 3 0. Note once more the missing
parameter.
A reminder of the first-point plotting effect can be seen by removing the MASK
command in line 90. The corners of the square disappear because they are drawn
twice (at the end of one line and the start of the next) and are therefore cancelled out
by the XORing action.

10 REM XOR ink modes


20 MODE 1:INK 2,10:INK 3,4
30 ORIGIN 440,100,440,640,100,300
40 WINDOW 1,26,1,25
50 CLG 2:GRAPHICS PAPER 0
60 DRAW 200,200,3
70 MOVE 2,0:FILL 3
80 ORIGIN 440,0,440,640,0,400
90 GRAPHICS PEN ,1:MASK ,0
100 FOR y=60 TO 318 STEP 2
110 GOSUB 220
120 FRAME:FRAME
130 GOSUB 220
continued on the next page
Chapter 9 Page 52

At your leisure ....

140
150
160
170
180
190
200
210
220
230
240
250
260
270
run

NEXT
TAG
FOR y=60 TO 318 STEP 2
MOVE 96,y:PRINT CHR$(224);
FRAME:FRAME
MOVE 96,y:PRINT CHR$(224);
NEXT
END
MOVE 90,y,1
DRAWR 20,0,,1
DRAWR 0,20
DRAWR -20,0
DRAWR 0,-20
RETURN

Animation
It is possible to produce an animation effect by switching the colours assigned to inks.
Although the contents of the screen memory are unchanged, there appears to be
movement. An example ofthis is included in the 'Welcome' program on Side 4 of your
system discs package (type RUN" d; se" to see that demonstration). The simple
palette switching of that example is not enough, however, if the animated patterns
are required fo overlap. The next example uses ORing of inks to write the numbers 1
to 4 onto the screen. (The shape is determined by scanning the character printed at
the bottom left hand corner and reproducing what is found, in big block graphics.)
The numbers are written in turn using inks 1,2,4 and 8 with the OR mode turned on
-in this case with a control character sequence, see line 50.
Lines 1 60 onwards rotate the palette according to a mathematical formula which
results in one block graphics number at a time being displayed. The inks are set by
inspecting each ink in turn and determining ifit includes the binary component that
we are looking for. For example, the number 3 was drawn in ink 4 and therefore to
show the number 3 we must allocate a visible colour to all inks whose number
contains a binary 4. Those inks are:
4(0100),5(0101),6(0110),7(0111),12(1100),13(1101),14(1110),15(1111)
In a practical application the inks which require to be changed at each stage in the
animation would be calculated, and lines 1 80 to 200 would be replaced by a
speedier section ofprogram.

At your leisure ....

Chapter 9 Page 53

10 REM latch animation


20 ON BREAK GOSUB 220
30 FOR i=1 TO 15:INK i,26:NEXT
40 m(1)=1:m(2)=2:m(3)=4:m(4)=8
50 MODE 0:PRINT CHR$(23);CHR$(3);:TAG
60 FOR P=1 TO 4
70 GRAPHICS PEN m(p),1
80 LOCATE #1,1,25:PRINT#1,CHR$(48+p);
90 FOR x=0 TO 7
100 FOR y= 0 TO 14 STEP 2
110 IF TEST(x*4,y)=0 THEN 140
120 MOVE (x+6)*32,(y+6)*16:PRINT CHR$(143);
130 MOVE (x+6)*32,(y+7)*16:PRINT CHR$(143);
140 NEXT y,x,p
150 LOCATE #1,1,25:PRINT#1," ";
160 FOR p=1 TO 4
170 FOR i.= 1 TO 25:FRAME:NEXT
180 FOR i=0 TO 15
190 IF (i AND m(p=0 THEN INK i,0 ELSE INK i,26
200 NEXT i,p
210 GOTO 160
220 INK 1,26
run

Colour plane sprites


In the example above we have seen how, having written graphics in inks 1,2,4 and 8,
an animation effect can be produced by colour changing. If the same inks are used,
but the colours set up in a different way then a completely different effect can be
produced. This effect is known as 'colour planes' and is demonstrated in the example
below.

10
20
30
40
50
60
70
80

REM mountains
DEFINT a-z
INK 0,1:INK 1,26
INK 2,6:INK 3,6
FOR i=4 TO 7:INK i,9:NEXT
FOR i=8 TO 15:INK i,20:NEXT
MODE 0:DEG:ORIGIN 0,150:CLG:MOVE 0,150
FOR x=16 TO 640 STEP 16
continued on the next page

Chapter 9 Page 54

At your leisure ....

90 DRAW x,COS(x)*150+RND*100,4
100 NEXT
110 MOVE 0,0:FILL 4
120 cx=175:GOSUB 320
130 cx=525:GOSUB 320
140 SYMBOL 252,0,0,&C,&1F,&30,&7F,&FF
150 SYMBOL 253,0,6,&E,&F2,2,&F2,&FE
160 SYMBOL 254,0,&60,&70,&7F,&7F,&7F,&7F
170 SYMBOL 255,0,0,0,&F8,&EC,&FE,&FF
180 pr$=CHR$(254)+CHR$(255)
190 pL$=CHR$(252)+CHR$(253)
200 TAG:t!=TIME
210 FOR x=-32 TO 640 STEP 4
220 x2~608-x)*2)MOD 640:hL=RND*10:hr=50*SIN(x)
230 GRAPHICS PEN 8,1:MOVE x,100+hr,,3:PRINT pr$;
240 GRAPHICS PEN 2,1:MOVE x2,115+hL,,3:PRINT pL$;
250 IF (TEST(x2-2,115+hL-12) AND 8)=8 THEN 380
260 IF TIME-t!<30 THEN 260
270 FRAME:t!=TIME
280 GRAPHICS PEN 7,1:MOVE x,100+hr,,2:PRINT pr$;
290 GRAPHICS PEN 13,1:MOVE x2,115+hL,,2:PRINT pL$;
300 NEXT
310 GOTO 210
320 MOVE cx,100
330 FOR x=0 TO 360 STEP 10
340 DRAW cx+SIN(x)*50+10*RND,100+COS(x)*25+10*RND,1
350 NEXT
360 DRAW cx,100:MOVE cx,90:FILL 1
370 RETURN
380 ENT -1,1,1,1
390 SOUND 1,25,400,15,,1,15
400 FOR y=100+hr TO -132 STEP -2
410 GRAPHICS PEN 7,1:MOVE x,y,,2:PRINT pr$;
420 GRAPHICS PEN 8,1:MOVE x,y-2,,3:PRINT pr$;
430 NEXT
440 GOTO 70
run
To explain how this works we must, once again, visualise the INK number in binary.
Starting with the highest INK number (15), all the INKs with the '8' bit present (15
down to 8) are set to cyan. Then all the INKs with the '4' bit present (7 down to 4) are
set to green. INKs 2 and 3, each with the '2' bit present are set to red, and finally INK
1 is set to bright white, with INK'" remaining as blue.

At your leisure ....

Chapter 9 Page 55

On the screen the graphics are ORed into place - see lines 230 and 240. The colour
seen on the screen in any particular pixel is determined by the most significant bit of
the resultant at that point. Therefore an image in a 'more significant' plane will
always obscure an image in a 'less significant' plane, but the background will be
preserved and can be seen again if the 'more-significant' image is removed. The way
'to remove an image is to plot it using the AND ink mode with INK numbers of7 ,11,13
or 14 removing original INKs of8,4,2 and 1 respectively - see lines 280 and 290.

Graphics Using the Extra Memory


To conclude this chapter, we provide you with a comprehensive 'Graphics Screen
Designer' program that makes use of the extra 64K of RAM in the 6128.

10
20
30
40
50
60
70
80
90

'SCREEN DESIGNER by DAVID RADISIC


' copyright (c) AMSOFT 1985
'
'Remember to RUN "BANKMAN" before running program!
'*************************************************
'
ON ERROR GOTO 2740 .
DEFINT a-x
MODE 1:ch=127:cmnd=1:pn(0)=0:pn(1)=26:pn(2)=15:pn(3)
=6:pn(4)=0:pn=1:norx=1:menu=1:zzz=HIMEM
100 DIM command$(22)
110 norx$(0)="Normal":norx$(1)="XOR
":norx$(2)="Trans
p":norx$(3)="XOR
"
120 RESTORE:READ cmnds$(1),cmnds$(2):cmnd$=CHR$(16)+CHR
$(&7F)+cmnds$(1)+cmnds$(2)
130 READ cmno:FOR i=1 TO cmno:READ command$(;):NEXT
140 READ st$:IF st$<>"**" THEN cmnd$(cmnd)=st$:cmnd=cmn
d+1:GOTO 140
150 WINDOW #0,1,40,1,3:PAPER #0,0:PEN #0,1:CLS #0
160 WINDOW #1,1,40,4,4:PAPER #1,3:PEN #1,1:CLS #1
170 ORIGIN 0,0,0,640,0,334
180 x=320:y=200:MOVE x,y
190 BORDER pn(4):FOR ;=0 TO 3:INK ;,pn(i):NEXT
200 MASK 255,0:PAPER 0:PEN 1:PAPER #1,3:PEN #1,1:GRAPHI
CS PEN pn,norx
210 IF flag<>5 THEN 280
Continued on the next page

Chapter 9 Page 56

At your leisure ....

Z20 IF pn<2 THEN pntS=CHRS(240):px=(pn+1)*13 ELSE IF pn

230
'240
250
260
270
280

<4 THEN pntS=CHRS(241):px=(pn-1)*13 ELSE pntS=CHRS(


243):px=37
LOCATE px,2:PRINT pntS;
LOCATE 1,1: PRINT USING"
PEN 0 : ##
PEN 1 : ##";
pn(0);pn(1);
LOCATE 29,2:PRINT USING"Border : ##";pn(4)
LOCATE 1,3:PRINT USING"
PEN 2 : ##
PEN 3
##";
pn(2);pn(3);
LOCATE px,2:PRINT " ";
LOCATE #1,1,1:PRINT#1,USING"X :#### Y :####
";
x;y;:PRINT #1,"PLot mode: ";norxS(norx+(undraw*2

11

290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570

fI.

IF fLag=0 THEN GOSUB 2260


'
GOSUB 970
'
IF fLag>0 THEN 390
IF is='''' THEN 390
cmnd=INSTR(cmndS,iS):IF cmnd=0 THEN 390
IF cmnd=1 THEN CLG:x=320:y=200:GOTO 390
IF cmnd=2 THEN RUN 70
ON cmnd-2 GOSUB 1240,1410,1520,1640,1840,1860,1950,
2020,2090,2120,2170,2200,2660,2660,2660,2660,2390,2
330,2200
IF tx=0 AND ty=0 THEN 200
IF fLag>0 THEN 440
GOSUB 630
GOSUB 680:FRAME:GOSUB 680
GOTO 200
MOVE tempx,tempy,pn,1
ON fLag GOSUB 470,490~550,640
GOTO 200
PLOT x,y:GOSUB 630:PLOT x,y
RETURN
DRAW tempx+x,tempy:DRAW tempx+x,tempy+y
DRAW tempx,tempy+y:DRAW tempx,tempy
GOSUB 630
DRAW tempx+x,tempy:DRAW tempx+x,tempy+y
DRAW tempx,tempy+y:DRAW tempx,tempy
RETURN
MOVE tempx,tempy:DRAWR x,y
IF triside=0 THEN 580
DRAW tempxx,tempyy:DRAW tempx,tempy
Continued on the next page

At your leisure ....

Chapter 9 Page 67

GOSUB 630
MOVE tempx,tempy:DRAW tempx+x,tempy+y
IF triside=0 THEN RETURN
DRAW tempxx,tempyy:DRAW tempx,tempy
RETURN
x=x+tx:y=y+ty:RETURN
MOVE tempx,tempy:DRAW x,y
GOSUB 630
MOVE tempx,tempy:DRAW x,y
RETURN
I
draw and undraw cursor
IF fLag=5 THEN RETURN
MASK 255,1
IF fLag>1 THEN xx=tempx+x:yy~tempy+y ELSE xx=x:yy=y
720 IF fLag=4 THEN xx=x:yy=y
730 IF fLag=1 THEN xx=x:yy=y
740 IF undraw=1 THEN 820
750 GOSUB 790
760 MASK 255,0
770 IF i$=" " THEN GOSUB 2150:i$=""
780 RETURN
790 MOVE xx-4,yy,pn,1:DRAW xx+4,yy
800 MOVE xx,yy-4:DRAW xx,yy+4
810 MOVE xx,yy"xorn:RETURN
'
820 nx=1:GOSUB 1220
830 FRAME:GOSUB 1220
840 IF i$=" " THEN nx=norx:GRAPHICS PEN pn,1:GOSUB 1220
850 i$=""
860 IF fLag<>6 THEN 760
870 IF moved=0 AND j$<>"" AND (j$<CHR$(240) OR j$>CHR$(
247 THEN ch=ASC(j$):moved=1
880 IF moved=0 THEN RETURN
890 LOCATE 5,2
900 FOR i=ch-5 TO ch+5
910 PEN ABS(i<>ch)+1
920 ch$=CHR$(1)+CHR$(ABS(i+256)MOD 256)
930 IF ch=i THEN PRINT" "ch$" "; ELSE PRINT ch$;
940 NEXT
950 PEN 1:PRINT"
= "ch" " ,.
960 GOTO 760
970 ty=0:tx=0:GOSUB 680:FRAME:GOSUB 680
980 IF INKEY(0)<>-1 OR INKEY(72)<>-1 THEN ty=16
990 IF INKEY(2)<>-1 OR INKEY(73)<>-1 THEN ty=-16
1000 IF INKEY(8)<>-1 OR INKEY(74)<>-1 THEN tx=-16
580
590
600
610
620
630
640
650
660
670
680
690
700
710

Continued on the next page

Chapter 9 Page 58

At your leisure ....

1010 IF INKEY(1)<>-1 OR INKEY(75)<>-1 THEN tx=16


1020 IF INKEY(21)<>-1 OR INKEY(76)<>-1 THEN tx=tx/8:ty=
ty/8
1030 IF tx=0 AND ty=0 THEN moved=0 ELSE moved=1
1040 j$=INKEY$:;$=UPPER$(j$)
1050 IF (;$=" " OR ;$=CHR$(13 AND flag>0 THEN 1090
1060 IF flag=5 THEN 1120
1070 IF flag=6 THEN 1170
1080 RETURN
1090 ON flag GOSUB 1240,1410,1640,1860,1950,2020
1100 ;$=""
1110 RETURN
1120 IF m~ved=0 THEN RETURN
1130 IF tx>2 THEN pn=(pn+1) MOD 5 ELSE IF tx<-2 THEN pn
=ABSpn<1*5-1+pn
1140 IF ty>2 THEN pn(pn)=(pn(pn)+1) MOD 27 ELSE IF ty<2 THEN pn(pn)=ABSpn(pn)<1*27-1+pn(pn)
1150 GRAPHICS PEN pn:PEN #1,pn
1160 tx=0:ty=0:BORDER pn(pn):RETURN
1170 IF tx<0 THEN ch=ABS(ch+255) MOD 256
1180 IF ty<0 THEN ch=ABS(ch+246) MOD 256
1190 IF tx>0 THEN ch=(ch+1) MOD 256
1200 IF ty>0 THEN ch=(ch+10) MOD 256
1210 tx=0:ty=0:RETURN
1220 TAG:MOVE xx-8,yy+6,pn,nx:PRINT CHR$(ch);:TAGOFF
1230 RETURN
1240 ' C
1250 IF flag=1 THEN 1290
1260 ro=1:GOSUB 2240
1270 tempx=x:tempy=y:flag=1
1280 RETURN
1290 IF tempx=x AND tempy=y THEN 1390
1300 PLOT x,y,,1
1310 tix=MAX(x,tempx)-MIN(tempx,x):tiy=MAX(y,tempy)-MIN
(tempy,y)
1320 ti=SQRtixt2)+(tiyt2
1330 ORIGIN tempx,tempy
1340 PLOT 0,0,pn,0:MOVE 0,-ti
1350 FOR z=0 TO PI*2+0.01 STEP PI/(ti/2)
1360 DRAW SIN(z+PI)*ti,COS(z+PI)*ti,pn,norx
1370 NEXT z
1380 ORIGIN 0,0
1390 x=tempx:y=tempy:tempx=0:tempy=0:flag=0
1400 RETURN
Continued on the next page

At your leisure ....

Chapter 9 Page 59

1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530
1540
1550
1560
1570
1580
1590
1600
1610
1620
1630
1640
1650
1660
1670
1680
1690
1700
1710
1720
1730
1740
1750
1760
1770
1780
1790
1800
1810
1820

I
B
IF fLag=2 THEN 1470
ro=2:GOSUB 2240
tempx=x:tempy=y:fLag=2
x=0:y=0
RETURN
IF norx=1 THEN 1500
MOVE tempx,tempy:DRAW tempx+x,tempy"norx
DRAW tempx+x,tempy+y:DRAW tempx,tempy+y:DRAW tempx
,tempy
x=tempx:y=tempy:fLag=0
RETURN
I
F
ro=3:GOSUB 2240
GOSUB 1620:IF i$=" " THEN 1600
edgecoL=VAL(i$)
ro=4:GOSUB 2240
GOSUB 1620:IF i$=" " THEN 1600
fiLLer=VAL(i$)
MOVE x,y,edgecoL:FILL fi LLer
fLag=0:i$=""
RETURN
i$=INKEY$:IF (i$<"0" OR i$>"3") AND i$<>" " THEN 1
620
RETURN
I
T
IF fLag=3 THEN 1700
fLag=3:ro=5:GOSUB 224J
tempx=x:tempy=y
x=0:y=0
RETURN
IF triside<>0 THEN 1770
ro=6:GOSUB 2240
MOVE 0,0,pn,1:GOSUB 590
tempxx=tempx+x:tempyy=tempy+y:x=x/2:y=20
triside=1
GOSUB 550:GOSUB 590
RETU RN
IF norx=1 THEN 1800
MOVE tempxx,tempyy"norx:DRAW tempx,tempy
DRAW tempx+x,tempy+y:DRAW tempxx,tempyy
tempxx=0:tempyy=0
x=tempx:y=tempy:triside=0
tempx=0:tempy=0:fLag=0

Continued on the next page

Chapter 9 Page 60

At your leisure ....

1830
1840
1850
1860
1870
1880
1890
1900
1910
1920
1930
1940
1950
1960
1970
1980
1990
2000
2010
2020
2030
2040
2050
2060
2070
2080
2090
2100
2110
2120
2130
2140
2150
2160
2170
2180
2190
2200
2210
2220
2230

RETURN
' @
norx=1:undraw=undraw XOR 1:RETURN
' L
IF flag=4 THEN 1910
ro=7:GOSUB 2240
tempx=x:tempy=y:flag=4
RETURN
IF norx=1 THEN 1930
MOVE tempx,tempy"norx:DRAW x,y
x=tempx:y=tempy:flag=0
RETURN
' I
IF flag=5 THEN flag=0:CLS:INK 3,tmpcol:INK pn,col:
GOTO 1990
CLS:flag=5:BORDER pnCpn)
RETURN
FOR ;=0 TO 3:INK ;,pnC;):NEXT:BORDER pn(4)
IF pn=4 THEN pn=1
CLS:RETURN
' A
IF flag=6 THEN 2070
tempx=0:tempy=0:CLS
undraw=1:flag=6:norx=1:moved=1
RETURN
flag=0
RETURN
' N
norx=0
RETURN
' E
GRAPHICS PEN pn,0:TAG:MOVE xx-8,yy+6,,0:PRINT " ";
:TAGOFF
RETURN
'<SPACE>
PLOT x,y,pn,norx:RETURN
' X
norx=1
RETURN
' M
menu=menu MOD 2+1
GOSUB 2260:RETURN
i$=UPPER$(INKEY$):IF ;$="" OR INSTRCser$,;$)=0 THE
N 2230 ELSE RETURN
Continued on the next page

At your leisure ....

Chapter 9 Page 61

2240 CLS:undraw=0:PRINT cmnd$(ro);:LOCATE 1,3:PRINT"<SP


ACE> ";:IF ro=3 OR ro=4 THEN PRINT"To exit"
2250 RETURN
2260 CLS:flag=-1
2270 FOR i=1 TO LEN(cmnds$(menu
2280 ps=i+ABS(menu=2)*LEN(cmnds$(1
2290 PEN 1:PRINT"<"MID$(cmnds$(menu),i,1)">"MID$(comman
d$(ps),2,4)" ";
2300 NEXT
2310 PRINT"<CLR>
<DEL>
<SPACE>";
2320 RETURN
2330 I S
2340 GOSUB 2460:IF fi Lename$="" THEN 2370
2350 GOSUB 2550
2360 SAVE fi Lename$,b,&C000,&4000
2370 GOSUB 2260
2380 RETURN
2390 I R
2400 GOSUB 2460: IF f i Lename$="" THEN 2440
2410 GOSUB 2730
2420 LOAD fi Lename$,&C000
2430 GOSUB 2570
2440 GOSUB 2260
2450 RETURN
2460 CLS:LOCATE 10,3:PRINT"<RETURN> to Abort!";
2470 LOCATE 1,1:PRINT"Enter FiLename :";
2480 INPUT "",f; Lename$:IF f; Lename$="" THEN RETURN
2490 n=INSTR(f;Lename$,"."):IF n=0 THEN 2520
2500 IF n=1 THEN 2460
2510 f; Lename$=LEFT$(f; Lename$,n-1>
2520 fi Lename$=LEFT$(fi Lename$,8)+".scn"
2530 CLS
2540 RETURN
2550 FOR ;=0 TO 4:POKE &C000+i,pn(;):NEXT
2560 RETURN
2570 FOR ;=0 TO 4:pn(;)=PEEK(&C000+;) MOD 27:NEXT
2580 cn=0:FOR ;=0 TO 2:IF pn(i)=pn(;+1) THEN cn=cn+1
2590 NEXT:IF cn=3 THEN 2630
2600 FOR ;=0 TO 3:INK ;,pn(;):NEXT
2610 BORDER pn(4):pn=1:GRAPHICS PEN pn
2620 RETURN
2630 pn(0)=0:pn(1)=26:pn(2)=15:pn(3)=6:pn(4)=0
2640 GOTO 2600
2650 I 1, 2, 3, & 4
Continued on the next page
Chapter 9 Page 62

At your leisure ....

2660 CLS:PRINT"Do you wish to <S>tore":PRINT TAB(16)"<R


>etrieve":PRINT TAB(13)"or <E>xchange the screen
?"

26 70 s e r $ =" SRE" +C HR$ (13) : G0 SUB 2 230 : IF i $ =CHR$ ( 13) THE N


2260
2680 bnk2=(cmnd-13):bnk1=1
2690 IF i$="S" THEN CLS:GOSUB 2550:ISCREENCOPY,bnk2,bnk
1

2700 IF i$="R" THEN GOSUB 2730:ISCREENCOPY,bnk1,bnk2:GO


SUB 2570
2710 IF i$="E" THEN CLS:GOSUB 2730:GOSUB 2550:ISCREENSW
AP,bnk2,bnk1:GOSUB 2570
2720 GOSUB 2260:RETURN
2730 FOR i=0 TO 3:INK i,0:NEXT:BORDER 0:RETURN
2740 CLS:GOSUB 2600:RESUME 2260
2750 DATA "CBFT@LIANEXM","1234RSM"
2760 DATA 19,Circle,"Box ","Fi II ",Triangle,Alternate,
"Line ","Inks ",ASCII,Normal,Erase,"Xor ","Menu"
,"1st ","2nd ","3rd ","4th ",Restore,"Save ","
Menu "
2770 DATA Circle,Box,Edge colour,Filler colour,Triangle
1,Triangle 2,Line,**

The two RSX commands I S eRE ENCO P Y and I S eRE ENS WAP used in this
program are provided by the 'Bank Manager' utility on Side 1 of your system discs
package. The commands facilitate the copying and swapping of the various screens
between the appropriate memory blocks, and between the two 64K banks of memory.
You must therefore run the 'Bank Manager' utility BEFORE running the Screen
Designer program, and to do this, insert Side 1 of your system discs package, and
type:

run "bankman"
You may then run the Screen Designer program.

What happens next?


When you have run the Bank Manager utility followed by the Screen Designer
program, you will see a menu of options displayed, together with a flashing
graphics-cursor at the centre of the screen.

At your leisure ....

Chapter 9 Page 63

From then on, simply press the appropriate letter (e.g. <c, for Circle) to carry out the
desired menu option.
As a demonstration, type:

c
.... then press the cursor up key 0. until the flashing graphics-cursor moves up
about an inch from the centre of the screen.
Finally, press the <SPACE> bar to execute the Circle function, and you will then be
returned to the menu.
Typing M(for <M>enu) will transfer you to an alternative menu from where you may
<S>ave and <R>estore screens, and manipulate the contents of the <l>st, <2>nd, <3>rd,
and A> th screens (held in the second 64K bank of memory).
To use these screen functions, type the 'memory number' ( 1, 2, 3, or 4) and a further
menu will be displayed.
From this you can select:

to Store the screen

to Retrieve a screen

to Exchange screens

[RETURN]

to abort the operation

If for example, you wish to store the current screen into memory number 2, then type
2 followed by S.
When returning to the alternative menu (after a <R>estore, <S>ave, or a screen
manipulation), typing Magain will toggle back to the original menu.
Screen Designer provides a range of drawing facilities, including boxes, circles,
triangles, lines, setting/resetting points, filling, and character drawing.
When a screen has been completed, it may be saved to disc for later viewing/editing
using the <S>ave option from the alternative menu, and may be loaded back at any
time using the <R>estore option.

Well, that concludes this last chapter in the manual. By using,


analysing, and experimenting with the programs that we have
provided throughout this guide, you should have acquired a fair
understanding ofAMSTRAD BASIC and ofthe 6128 itself
Chapter 9 Page 64

At your leisure ....

Further details ....


Many AMSOFT and independent publications will furnish you
with further details of the 6128, together with the BASIC and
firm ware specifications, and information on the CPIM operating
system and the Dr. LOGO language.
Finally, we provide a set of 4 appendices which comprise: the
CPIM End User Licence Agreement, a glossary of terms, some
games programs' listings, and a, comprehensive index to the
manual.
We hope that you have found this manual informative and
interesting, and thankyou for purchasing the CPC6128.

At your leisure ....

Chapter 9 Page 65

ppendixl
Digital Research & AMSTRAD
End User Program
Licence Agreement
NOTICE TO USER PLEASE READ THIS NOTICE CAREFULLY. DO
NOT OPEN THE DISKETTE PACKAGE UNTIL YOU HAVE READ
THIS LICENCE AGREEMENT.
OPENING THE DISKETTE PACKAGE INDICATES YOUR AGREE
MENTTO BE BOUND BY THESE TERMS AND CONDITIONS.

1. Definitions
- In this Licence Agreement, the terms:
1.

DRI means DIGITAL RESEARCH (CALIFORNIA) INC., P.O. Box 579, Pacific
Grove, California 93950, owner of the copyright in, or authorised licensor of, the
program.

2.

Machine means the single microcomputer on which you use the program.
Multiple CPU systems require additional licences.

3.

Program means the set of programs, documentation and related materials in


this package, together with all ancillary updates and enhancements supplied by
DRI to you regardless of the form in which you may subsequently use it, and
regardless of any modification which you make to it.

4.

AMSTRAD means AMSTRAD CONSUMER ELECTRONICS PLC., Brentwood


House, 169 Kings Road, Brentwood, Essex CM14 4EF.
You assume responsibility for the selection of the prop'am to achieve your
intended results, and for the installation, use and results obtained from the
program.

Licence Agreement

Appendix 1 Page 1

2. Licence
You may:
1.

Use the program on a single machine.

2.

Copy the program into any machine readable or printed form for backup or
modificaton purposes in support of your use of the program on a single machine.
You may make up to 3 (three) copies of the program for such purposes. (Certain
programs, however, may include mechanisms to limit or inhibit copying. They
are marked 'copy protected'). Copying of documentation and other printed
materials is prohibited. Disassembly of code is prohibited.

3.

Modify the program and/or merge it into another program for your use on the
single machine. (Any portion of this program merged into another program will
continue to be subject to the terms and conditions of this Agreement).

4.

Transfer the program and licence to another party if you notify DRI of name and
address of the other party and the other party agrees to a) accept the terms and
conditions of this Agreement, b) sign and forward to DRI a copy of the
registration card and c) pay the then current transfer fee. If you transfer the
program, you must at the same time either transfer all copies, including the
original, whether in printed or machine readable form to the same party, or
destroy any copies not transferred; this includes all modifications and portions
of the program contained or merged into other programs.

You must reproduce and include the copyright notice on any copy, modification or
portion merged into another program.

EACH DISKETTE IS SERIALISED, AND YOU MAY NOT USE? COPY,


MODIFY, TRANSFER, OR OTHERWISE MAKE AVAILABLE TO ANY
THIRD PARTY, THE PROGRAM, OR ANY COPY, MODIFICATION OR
MERGED PORTION, IN WHOLE OR IN PART, EXCEPT AS
EXPRESSLY PROVIDED FOR IN THIS LICENCE AGREEMENT.
IF YOU TRANSFER POSSESSION OF ANY COPY, MODIFICATION
OR MERGED PORTION OF THE PROGRAM TO ANOTHER PARTY,
YOUR LICENCE IS AUTOMATICALLY TERMINATED.

Appendix 1 Page 2

Licence Agreement

3. Term
The licence is effective until terminated. You may terminate it at any other time by
destroying the program together with all copies, modifications and merged portions
in any form. it will also terminate upon conditions set forth elsewhere in this
Agreement or if you fail to comply with any term or condition ofthis Agreement. You
agree upon such termination to destroy the program together with all copies,
modifications and merged portions in any form.

4. Limited Warranty
THE PROGRAM IS ~ROVIDED 'AS IS'. NEITHER DRI NOR
AMSTRAD MAKE ANY WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
SHOULD THE PROGRAM PROVE DEFECTIVE, YOU (AND DRI OR
AMSTRAD) ASSUME THE ENTIRE COST OF ALL NECESSARY
SERVICING, REPAIR OR CORRECTION.
Neither DRI nor AMSTRAD warrant that the functions contained in the program
will meet your requirements or that the operation of the program will be
uninterrupted or error free.
However, AMSTRAD warrants the diskette on which the program is furnished, to be
free from defects in materials and workmanship under normal use for a period of
ninety (90) days from the date of delivery to you as evidenced by a copy ofyour receipt.

5. Limitations of Remedies
AMSTRAD's entire liability and your exclusive remedy shall be the replacement of
any diskette not meeting this 'Limited Warranty' and which is returned to AM SOFT
with a copy of your receipt.
IN NO EVENT SHALL DRI OR AMSTRAD BE LIABLE FOR ANY
DAMAGES, INCLUDING ANY LOST PROFITS, LOST SAVINGS, OR
OTHER SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
EVEN IF DRI OR AMSTRAD HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
OTHER PARTY.

Licence Agreement

Appendix 1 Page 3

6. Registration Card
DRI may from time to time update its programs. Updates will be provided to you only
if a properly signed registration card is on file at DRI's main office or an authorised
registration card recipient. DRI is not obligated to make any program updates, or to
supply any such updates to you.

7. General
You may not sublicence, assign or transfer the licence or the program except as
expressly provided in this Agreement. Any attempt otherwise to sublicence, assign or
transfer any of the rights, duties, or obligations hereunder is void.
This Agreement shall be governed by and construed in accordance with the laws of
England.
Should you have any questions concerning this Agreement, you may contact DRI by
writing to Digital Research Inc., p.a. Box 579, Pacific Grove, California 93950.

THIS AGREEMENT CANNOT AND SHALL NOT BE MODIFIED BY


PURCHASE ORDERS, ADVERTISING OR OTHER REPRESENTA
TIONS BY ANYONE, AND MAY ONLY BE MODIFIED BY A WRITTEN
AMENDMENT EXECUTED BY YOU AND AN AUTHORISED
OFFICER OF DRI AND AMSTRAD.
YOU ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT,
UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND
CONDITIONS. YOU FURTHER AGREE THAT IT IS THE COMPLETE
AND EXCLUSIVE STATEMENT OF THE AGREEMENT BETWEEN
YOU AND DRI AND AMSTRAD WHICH SUPERSEDES ANY PRO
POSAL OR PRIOR AGREEMENT, ORAL OR WRITTEN, AND ANY
COMMUNICATIONS BETWEEN YOU AND DRI OR AMSTRAD
RELATING TO THE SUBJECT MATTER OF THIS AGREEMENT.
THIS AGREEMENT DOES NOT AFFECT YOUR STATUTORY
RIGHTS.

Appendix 1 Page 4

Licence Agreement

Appendix 2
Glossary of Terms
Some commonly used terms from the world ofcomputing,
explained for 6128 users....

Accumulator
A memory location within the microprocessor circuit at the heart of the
microcomputer that stores data temporarily while it is being processed. Used
extensively in machine code programming - BASIC users need never know it
exists!

Acoustic coupler
Also known as an Acoustic Modem. An electronic attachment for a computer that
connects a telephone handset to .. the computer and enables the latter to
communicate over the normal voice telephone network. In this way, a computer
can communicate with public information systems such as PRESTEL, and with
other users of home computers, in order to exchange software, get data and
information etc.

Address
The number in an instruction that identifies the location of a 'cell' in a computer's
memory. By means of its address, a particular memory location can be selected so
that its contents can be found and 'read', in the case of RAM, both written <\nd
read.

Adventure game
A cult with some, and a bore to others. A text-based computer game in which the
player is invited to participate in a series of pseudo random events based on
trying to find a way around a maze or labyrinth.

Algorithm
A grandiose name for a complicated formula or sum. A sequence 'of logical and
arithmetic steps to perform a defined task in computing.

Alphanumeric
The attribute that describes the difference between a letter or number and a
graphics character.

Glossary

Appendix 2 Page 1

ALU
Arithmetic Logic Unit. The part of a microprocessor that carries out arithmetic and
logical operations - not of direct concern except.in machine code programming.

Ambiguous rile Name


A file name containing one or more wildcard characters. Ambiguous filenames refer
to more than one specific file name and are used to refer to one or more files at a time.

AMSDOS
AMStrad Disc Operating System. The program that allows Locomotive BASIC to
access disc files.

AMsorT
AMSTRAD's specialist computer support division, supplying software, peripherals,
publications, specifically to enhance the 6128 and its many applications.

AID
Analogue
A state where change between a start and finish point occurs gradually rather than
instantaneously. Computers are digital devices - most of the natural world is based
on analogue principles, thus the computer has to perform an analogue to digital (AID)
conversion before it can process data from an analogue source.

Animation
Cartoons are the best known form of animation - computer animation is based on the
concept of moving graphics to simulate the idea of 'live' movement.

Applications program
A program with a specific task rather than a general purpose software 'tool' such as
an assembler, printer driver etc.

Arcade Game
The type of moving action computer video game where for example, spacemen invade
and are vanquished, or insatiable monsters chase around a maze and gobble up the
unwary. Figures under the control of the user have to avoid all manner of unpleasant
'deaths'. Generally good for the reflexes but of little educational benefit for the
computer student.
Appendix 2 Page 2

Glossary

Architecture
The plan relationship of the databus, peripheral and CPU handling aspects of a
microcomputer.

Argument
An independent variable, e.g. in the expression x+y=z, the terms x, y, and z are
the arguments.

Array
A 2 dimensional matrix (grid) in which data is stored by addressing with the
'horizontal' and 'vertical' co-ordinates.

Artificial intelligence AI
A structure in program techniques that enables the program to learn from its past
.
experience.

ASCII
American Standard Code for Information Interchange. A commonly used way of
representing the numbers, letters and other symbols that can be entered from the
computer's keyboard or invoked using a variety of other commands.

Assembler
The practical method for programming in machine code, where the machine code
instructions are invoked by mnemonics (letters that suggest the function being
performed by the corresponding machine code routine).

Backup
A duplicate copy of information used as a safeguard in case the original is lost or
accidentally damaged. Making a backup refers to the process of duplicating a disc
or disc file.

Bar code
A computer readable printed code that can be read by optical techniques such as
scanning by a low power laser. Look at the bottom of a box of soap powder to see
an example.

Glossary

Appendix 2 Page 3

Base
The prime numeric consideration of any mathematician. The basis of any system
of number representation. The binary systernhas base 2; the decimal system has
base 10, and the hexadecimal system has the base 16.

BASIC
Beginners' All-purpose Symbolic Instruction Code. An interpretive programming
language used in almost all home computers. BASIC was specifically designed to
be easy to learn and simple to use since it allows for programs to be 'glued'
together and tested at any point in their development; as opposed to compiled
types where the complete program must be run before any aspect can be properly
tested.

Baud
A bit per second. The unit for measuring the rate at which digital data is
transmitted in serial communication systems.

BCD
Binary Coded Decimal. A coding system for decimal numbers in which each digit
is represented by a group offour binary digits.

BDOS
Basic Disc Operating System. This is the part of the CP/M operating system
which provides an interface for a user program to use the functions ofCP/M.

Benchmark
A standard task that can be given to different computers to compare their speed,
efficiency and accuracy, e.g. calculating the square root of99.999 squared.

Binary
The number system with base 2, in which all numbers are made up from the two
binary digits 0 and 1. (See part 1 of the chapter entitled 'At your leisure .... '.)

Binary number
A number represented in binary notation. Signified in 6128 programming by the
prefix &X. e.g. &X0101 = (decimal) 5.

Appendix 2 Page 4

Glossary

BIOS
Basic Input/Output System. This is the hardware dependent part of CP/M that is
written specifically for one type of computer. All the input and output to the screen,
keyboard, disc and so on is performed through the BIOS.

Bit
Shortform of BInary digiT. A binary digit is one of the two digits, represented by 0
and 1, that are used in the binary number system.

Bit Significant
Where the information contained in a number is extracted by considering the state of
each ofthe eight bits that make up the complete byte. The overall decimal value may
have no meaning.

Boolean algebra
The statement of logical relationships where there can only be two answers: true or
false. Usually signified as 1 or O.

Boot
The process ofloading an operating system into memory. When CP/M is started from
BASIC a small boot program is loaded automatically from the disc, which then loads
the rest of the operating system into memory.

Booting or Bootstrapping
Programs and operating systems don't load themselves, they are 'bootstrapped' by a
small routine in ROM (usually), that initiates the loading processes at a specific
location in memory.

Buffer
An area of memory reserved for temporarily storing, or buffering, information during
an information transfer.

Bug
A problem on a scale ranging from an 'unexpected feature' based on some obscure
aspect of the use 6f a program (e.g. if you press four keys at once, the screen changes
colour), to a sequence that completely and irrevokably crashes a computer program
and wipes the memory clean of all data.
Glossary

Appendix 2 Page 5

Built-in commands
Commands that are part of an operating system. They are always quicker than
transient commands because they are not accessed from disc.

Bus
A group of connections either within the computer, or connecting it to the outside
world that carries information on the state of the CPU, the RAM and other hardware features. The 6128 bus is presented on the circuit board connector marked
EXPANSION, at the rear of the computer.

Byte
A group of eight bits, which forms the smallest portion of memory that an 8-bit
CPU can recall from, or store in memory.

CAD
Computer Aided Design. Usually an interaction of computing power and graphics
to provide an electronic drawing board, although any calculation performed on a
computer in pursuance of a 'design' comes under the heading of CAD .

CAE"
Computer Aided Education. Further nourishment for the buzzphrases of
computing. The use of the computer to help with education. CAI (Computer Aided
Instruction) and CAL (Computer Aided Learning) are two aspects ofCAE.

Cartridge
A specially packaged memory integrated circuit containing software which can be
plugged directly into a socket specifically provided for the purpose on the
computer. Cartridge software loads and runs quickly and easily, but costs
considerably more than software supplied on disc.

Cassette
Apart from the obvious recording tape variety, a generic term that encompasses a
variety of ,packages' - including ROM software etc.

Appendix 2 Page 6

Glossary

CCP
Console Command Processor. This is a module of CP/M that interprets and
executes user input from the keyboard. Usually commands are input which the
CCP loads and executes.

Character
Any symbol that can be represented in a computer and displayed by it, including
letters, numbers and graphics symbols.

Character set
All the letters, numbers and symbols available on a computer or printer. The fact
that a character exists on a computer does not imply it is accessible on any
printer.

Character string
A piece of <variable> data, comprising a sequence of characters that can be stored
or manipulated as a single unit, e.g. a word or a collection of words.

Chip
A misleading but popular reference to any form of monolithic electronic
integrated circuit. The 'chip' is actually a small slice of specially processed silicon
material, on which the circuit is fabricated.

Clock
The reference timing system in the computer used to synchronise and schedule
the operations of the computer. A real time clock is one that maintains the hour,
date etc.

Code
Apart from the more literal implications, frequently used by programmers as an
abbreviation of 'machine code'.

Cold start
The process of booting and initialising an operating system. A cold start of CP/M
is performed when the I CPMcommand is used.

Command
A programming instruction.
Glossary

Appendix 2 Page 7

Compiler
A complex program that converts complete programs written in a high level
interpretive languages like BASIC into the direct instruction code of the
microprocessor, thereby enabling operation at much greater speeds.

Computer generations
Technological landmarks have delineated several distinct steps in computer
technology, and the groupings within these various strata are known as the
'generations' of design technologies.

Computer literacy
Another grandiose expression meaning understanding computers.

Console mode
CP/M direct mode; the A> appears on the screen, and the system awaits input of a
CP/M or utility command.

Corruption
The destruction or alteration of the contents of a disc file or memory, in an
undesirable and potentially unrecoverable manner.

CP/M
Control Program for Microcomputers. A disc based operating system by Digital
Research that provides a standard systems interface to software written for a
wide range of microprocessor based computer systems.

CPU
Central Processing Unit. The component at the heart of any computer system that
interprets instructions to the computer and causes them to be obeyed, in a
microcomputer, the CPU is the microprocessor device itself.

Cursor
A movable marker, indicating where the next character is to appear on the
screen.
Appendix 2 Page 8

Glossary

Cursor control keys


Keys that move the Cursor around the screen, and are frequently used to control
the direction of action in arcade games, indicated by arrows printed on the top.

Daisy-wheel printer
A printer that can produce high quality or 'typewriter quality' documents. Printed
characters are created by the impact ofletters against the ink or film ribbon.

Database
An array of any type of data in a variety of computer addressable formats.

Data capture
The term which describes the collection of data from any outside sources that are
linked in some way to a central computer.

Debugging
The process of fixing the bugs in a program by a combination of 'suck it and see'
and more scientific methods.

Decimal notation
Also known as the Denary system, for numbers with base 10, using the digits
9, representing numbers of units , tens, hundreds, thousands and so on.

to

Default
The value assumed in the absence of any user output. For example, when CP/M i.s
started Drive A : is assumed to be the default drive.

Delimiter
(See Separator)

Diagnostic
A message automatically produced by a computer to indicate and identify an error
in a program.

Glossary

Appendix 2 Page 9

Digital
Describes the transition of a changing quantity in terms of discrete steps rather
than by a continuous process. The opposite of analogue.

Digitiser
A means of plotting analogue information into a computer. Commonly referred to
in conjunction with graphics tablets.

Directory
A section of disc containing entries for each file on the disc. A list of the contents
ofadisc.

Disc (or disk)


A flat, thin circular piece of plastic, coated on one or both sides with a magnetic
oxide surface and used as a medium for storing data. The disk is housed in a
protective envelope, with access for the reading head provided by a 'window'. On a
3" disc the window is covered by a metallic shutter, which automatically slides
across when the disc is out ofthe disc drive.

Disc drive
The mechanism used to spin and access the data on the surface of the disc.

Documentation
The manuals that are supplied with computers or software to explain how
are operated.

th~y

DOS
Disc Operating System. The software that controls all the operations of a disc
drive.

Dotmatrix
A rectangular grid of dots on which a character can be displayed by the selection
of certain dots.

Double sided
A disc that can store information on both sides. A double sided disc drive can
access both sides of a disc without the need to turn the disc over.
Appendix 2 Page 10

Glossary

Download
The transfer of information from one computer to another - the computer
receiving the data is generally referred to as the machine downloading. The other
end of the link is uploading.

Dr. LOGO
Digital Research's version of LOGO, a programming language with a graphics
turtle.

Dumb terminal
A computer terminal that simply acts as a medium for input and output without
any processing of the information passing through. Note that a mindless terminal
is one where even the display drive electronics are absent, and that the screen
display information is fed in as pure video.

Edit
To correct or make changes to data, a program or text.

Editor
A program that is usually in the ROM of the computer, which enables the editing
process to be carried out.

EPROM
Erasable Programmable Read only Memory. Similar to the PROM, except that
the data contained in the chip can be erased by ultra-violet light, and new
program recorded. An EEPROM is similar, except that it may be electronically
erased.

Expression
A simple or complex formula used within a program to perform a calculation on
data -the expression will usually define the nature of the data it can handle. In
Dr. Logo an expression consists of a procedure name followed by any necessary
inputs to the procedure.

Fifth generation computers


Mainly large mainframe computers that are promised to arrive with the ability
for self-programming using the developments of artificial intelligence.

Glossary

AppendiX 2 Page 11

File
A collection of data, generally stored on cassette or disc.

File name
The name of a file. In Dr. Logo a file name can consist of up to 8 alphabetic or
numeric characters. In CP/M or AMSDOS, an additional three character file type,
preceded by a dot is allowed.

Firmware
Software contained in ROM - a cross between pure software and pure hardware.

Fixed-point number
A number represented, manipulated and stored with the decimal point in a fixed
specified position.

Floating-point number
A Real number, manipulated and stored with its decimal point permitted to settle
in the required position. The method is particularly useful when dealing with
large numbers.

Floppy disc
(See Disc)

Flowchart
A diagrammatic representation of the progression of program steps and logical
processes tracing the sequence of events during program execution.

Forth
A high speed programming language, with speed and complexity falling between
a High-level language and Machine code. Not a beginners' language.

Function key
A key on the keyboard that has been assigned a specific task - which it may
execute in addition to, or instead of the main purpose inscribed upon that key.

Appendix 2 Page 12

Glossary

Gate
Logical gates permit the passage of data when certain conditions are fulfilled.
There are many different types of gate (OR, AND, XOR etc).

Graphics
The part of the screen display of the computer that is not related to the display of
'characters'. Graphics encompasses the drawing and plotting of lines, circles,
patterns, etc.

Graphics character
A shape or pattern specially designed to be useful in creating images.

Graphics cursor
Similar to the text cursor, but addressing the graphics screen. An invisible
concept on the 6128 - but nevertheless an indispensible facility for locating drawn
graphics. Not to be confused with graphics characters which are still part of the
'character set', and are printed at the text cursor.

Graphics mode
Early microcomputers required to be specifically set to either handle characters or
graphics. Modern personal computers are capable of mingling text and graphics
simultaneously.

Graphics tablet
A device that plots the co-ordinate points of a given picture or drawing for
manipulation within the computer. A form of AID.

Handshaking
A sequence of electronic signals which initiates, checks and synchronises the
exchange of data between a computer and a peripheral, or between two
computers.

Hard Copy
Paper print-out of a program or other text - or of a graphics display. The
transitory screen equivalent is known as 'soft copy'.

Glossary

Appendix 2 Page 13

Hardware
The electronic and mechanical parts of a computer system - anything that isn't
software or firmware.

Hexadecimal (or HEX)


The number system with base 16. Hexadecimal numbers are signified in 6128
programming by the prefix & or &H. e.g. &FF = (decimal) 255. (See part 1 of the
chapter entitled 'At your leisure ... .'.)

Hex file
An ASCII representation of a command or machine code file.

High-level language
Languages like BASIC, which are written in 'near litera1' form, where the actual
language does most of the work of interpreting. Slower than machine code
orientated programs, but far simpler to understand.

IEEE-488
One of the standard Interfaces for connecting devices to a microcomputer. Similar
to - but not wholly cOlllpatible with -the Centronics parallel interface.

Information technology
Anything relating to the use of electronics in the processing of information and
communications: wordprocessing, data communications, PRESTEL, etc.

Initialise
Switch on a system, or declare specific values for variabl~s before beginning to
execute the body of program - e.g. dimensioning arrays, declaring variables to be
integers, etc.

Input
Anything that enters the computer memory from its keyboard, disc unit, serial
interface or other input source.

Instruction
A request/command to a computer to perform a particular operation. A collection
or sequence of instructions form a program.
Appendix 2 Page 14

Glossary

Instruction set
The prime logical and mathematical processes carried out by the microprocessor.
Every high level instruction (including assembler mnemonics) have to be capable
of being distilled down to an instruction that is recognised by the computer's
CPU. A single high level command may invoke a large number of elements from
the CPU's instruction set.

Integer
A whole number with no decimal point.

Integer number
A number with no. fractional part, i.e. a number with no part to the right of the
decimal point - as opposed to a real number which is the integer part plus the
fractional part.

Integrated circuit
A collection of electronic circuit components miniaturised and built onto a single
piece of silicon. (See also Chip)

Intelligent tenninal
A terminal where as well as handling the requirements of the computer's input
and output, local processing power is also available when the terminal is 'offline'.

Interactive
Usually a reference to programs where the hardware computer prompts the user
to provide various types of input - ranging from controlling the spaceship in an
arcade game, to answering questions in educational programs. The action of the
user has an effect in 'real time' on the behaviour of the program.

Interface
The way in and out of a computer, both in electrical and human terms. The 6128
interface is the keyboard (input), and the screen (output) - as well as the facility
for the connection of user peripherals to the various sockets.

Glossary

Appendix 2 Page 15

Interpreter
A further extension of the analogy of computer instruction sets and language. The
element of the' system software that interprets the high level language to the
level that can be understood by the CPU. e.g It converts BASIC code as entered
via the keyboard into the computer's own internal language.

I/O
Input/Output.

Iteration
One of the elements of. computing. The computer performs all tasks by breaking
them down into the simple tasks that can be handled by the CPU. To do this, the
computer must go to and fro' between many simple elements until a given
condition is fulfilled.

Joystick
An input device that generally replaces the function of the cursor keys, and
makes games playing faster and easier.

K
A short form of the metric measure prefix for 1000, 'kilo' - which in computing
has come to be widely used to refer to a 'kilobyte' - which is actually 1024
(decimal) in view ofthe binary association of2 raised to the power oflO.

Keyboard
The matrix of alphanumeric key switches, arranged to provide the means of
typing commands and other information into the computer.

Keyword
A word whose use in the computer program or language is reserved for a specific
function or command.

Least significant bit


In a binary number, the Least Significant Bit (LSB) is the bit at the extreme
right hand end of the expression.

Appendix 2 Page 16

Glossary

Light Pen
Another alternative input method, using a pen or 'wand'.

Line number
BASIC and some other languages use programs that are arranged in line number
order.

Lisp
The acronym formed from LISt Processor language. Another high level computer
language.

Logic
The electronic components that carry out the elementary logical operations and
functions, from which every operation of a computer is ultimately built up.

Logical device
The representation of a device that may be different to its physical form. For
example the CP/M logical device LS T may be assigned to the Centronics port or
perhaps the VDU.

LOGO
The name of a programming language derived from the Greek word logos, which
means word. Logo is designed to teach the fundamentals of computer
programming.

Loop
A process in a program that is executed repeatedly by the computer until a
certain condition is satisfied.

Low-level language
Such as 'assembly language'. A programming language in which each instruction
corresponds to the computer's machine code instruction.

LSI
Large Scale Integration., The development of integrated circuits, packing more
functions onto ever smaller pieces of silicon.

Glossary

Appendix 2 Page 17

Machine Code
The programming language that is directly understood by a microprocessor, since
all its commands are represented by patterns of binary digits.

Machine readable
A medium of data or any other information that can be immediately input to a
computer without additional work on keyboarding etc.

Man-machine interface
A point of interaction between the computer and the operator: keyboard, screen,
sound etc.

Matrix
The arrangement of the dots that form the character cell on the screen, or on the
print head of a 'dot matrix' printer. Also a term used in mathematics and
computer science to encompass arrays.

Memory
The computer's parking lot for information and data, neatly arranged in .logical
rows with each item individually accessible. Either known as RAM (random
access memory) where information can be both stored and retrieved, or ROM,
where the information may be read, but not re-written in another form. Discs and
tape are examples of 'bulk memory', although the term has evolved to mean the
memory that is directly addressed by the CPU.

Memory map
The layout of the memory, showing the various addresses, and the allocation of
the memory to specific functions, such as the screen, the disc operating system
etc.

Menu
A bill of fare of the different options that may be carried out by the program in
the computer, left to the user to select.

Microprocessor
An integrated circuit that sits at the heart of a microcomputer and executes the
instructions that are presented to it by the BASIC intepreter, in order to control
the various output devices and options.
Appendix 2 Page 18

Glossary

Modem
A MOdulator DEModulator that connects the computer's I/O to a telephone line or
other serial data transmission medium - including fibre optics. (See also Acoustic
coupler)

Monitor
The screen section of a computer terminal system, and also a term describing a
machine language program that provides access to the fundamental machine
operation of the computer.

Mouse
An upside-down 'tracker' or 'roller ball'. Pushed around a table top by hand, a
mouse is generally used to move a cursor around the screen. Originally designed
to overcome the fear of keyboards and make software appear more 'user friendly'.

MSB
The Most Significant Bit of a binary number, i.e. the bit at the left end of the
binary expression.

Network
When two or more computers are linked together to exchange data and
information - either by wiring, or via MODEMs.

Nibble
Half a byte: a four bit expression. Each of the hexadecimal digits in the
expression &F6 represents 'one nibble'.

Node
A unit of storage in the LOGO workspace. Typically one node consumes 4 bytes of
memory space.

Noise
The 6128 sound facilities include the ability to inject a variable amount of random
noise to create effects such as explosions.

Glossary

Appendix 2 Page 19

Numeric keypad
The area on the keyboard where number keys are grouped to facilitate entry of
numeric data, and in the case of the 6128, to provide the additional facility of user
definable function keys.

OCR
Optical Character Recognition. A means of reading printed or written characters
with an optical reader and translating them directly into computer readable data.

Octal
A number system to the base of 8, where each digit (0-7) is constructed from three
Bits.

Off line
A computer peripheral - usually a display terminal or a printer - that is not actively
connected to, or accessible by, the main processing unit.

On line
The opposite ofOffline.

Operating system
The attendant in the 'parking lot' referred to under the entry for Memory. Software
that allocates precedence and timing to the operations ofthe computer.

Operator
The part of an arithmetic expression that causes one number to operate on another,
e.g. + - * / etc.

Output
Anything that comes from a computer as the result of some computational function.

Overwrite
Erase an area of memory by replacing its contents with new data.

Appendix 2 Page 20

Glossary

Paddle
An alternative name for ajoystick. Also referred to as a 'games paddle'.

Page zero
This refers to the region of memory in a CP/M environment between &0000 and
&0100 which is used to hold vital system parameters.

Paperware
Another description for the printed 'hardcopy' of computing. Occasionally
computers launched before they have actually finished development are described
as a 'paperware exercise'.

Parallel interface
The 6128 printer interface supports a parallel printer, which means that each
data line from the bus is connected to a corresponding input on the printer. Data
is transferred many times more quickly using a parallel interface than it is
through a serial interface, since the serial interface must first format each byte,
and frame it with synchronisation information.

Pascal
A high-level structured programming language that must be compiled before it
will execute - and therefore runs very quickly. Generally the next language that
the keen BASIC student will pursue.

PEEK
The BASIC function that looks directly into the computer's memory, and reports
the value at the specified location.

Peripheral
Printers, modems, joysticks, cassette units - anything that plugs into the
computer to expand its capabilities.

Physical device
An actual device, consisting of hardware, that exists. Physical devices may be
represented by logical devices.

Glossary

Appendix 2 Page 21

Pixel
The smallest accessible area of the screen that can be controlled by the hardware.

Plotter
A specific type of printer that draws 'longhand' using pens rather than an impact
print head. Used for technical and graphical drawing output.

POKE
The statement in BASIC that is used to place a value in a specified memory
location.

Port
A specifically addressable point on the interface for input or output of data.

Portahility
Other than the literal use, means the ability for software to operate on different
makes of computer - usually as a result of a compatible operating system, such as
Digital Research's CP/M.

Primitives
Procedures, operations or commands that make up Dr. Logo; the built-in
procedures.

Printer
Any hardcopy method for printing out text.

Procedure
A series of expressions or program statements that dictate how to perform a
particular task.

Program
A combination of instructions that cause the computer to execute a task. It can be
anything from a simple machine code 'routine' to a complete applications
program, such as a wordprocessor.

Appendix 2 Page 22

Glossary

Programming language
The medium through which the program is written, being comprised of rigid rules
on the use of words, numbers and the sequence in which they are implemented.

PROM
Programmable Read Only Memory. An integrated memory circuit that once
written with data, cannot be erased. (See also EPROM)

Prompt
A short message or character sequence reminding the user that some type of
input is expected. For example, the CPIM prompt is the> and the Dr.Logo prompt
is the? character.

PSU
Power Supply Unit. The means of converting the domestic mains electricity
supply into the necessary voltages to operate the computer (and peripheral
devices).

QWERTY keyboard
The colloquial term to describe a keyboard with the conventional UK or US
typewriter key layout.

RAM
Random Access Memory. Memory that may be both read from, and written to,
using the internal circuitry of the computer during the normal course of program
execution.

Random access
The ability to read and write information in memory or on a disc in any desired
order.

Random number
A number that is generated by the computer program that is neither repeatable,
nor predictable. The 6128 is capable of generating a pseudo random number
sequence.
Glossary

Appendix 2 Page 23

Raster
A system of 'writing' on the screen where the images are built from a number of
horizontal scan lines. (Raster scan).

Read only RIO


An attribute assigned to a disc, a disc file or a disc drive that prevents writing or
changing of data.

Read write RIW


An attribute assigned to a disc, a disc file or a disc drive that allows both reading and
writing of data.

Real number
A number that has both integer and fractional parts. i.e. both sides of the decimal
point are used.

Real time
Events that occur before your eyes, as opposed to those which only become evident
after the termination of the process that produced them.

Record
A group of bytes in a file. CP/M uses 128 byte records.

Recmsion
The series of repeated steps (also sometimes imprecisely described as reciprocation)
within a program or routine in which the result of each repeated cycle of events is
related to the previous one.

Refresh
To update information, either on the screen of a VDU, or in the memory. Need not be a
destructive process, but merely reinforcing whatever was already present in memory
or on the screen.

Register
A transient memory location within the CPU that is used for temporary storage.

Appendix 2 Page 24

Glossary

Remark
A non-executing statement in a program that is included to remind the programmer
what part of the program he is doing, and to date and time stamp that particular
'edition'.

Reserved word
A word which has particular significance to the computer program, and cannot be
used other than in its pre-defined context. For example, BASIC will not accept the
word NEW as a vr riable - it is already 'reserved' for another purpose.

Resolution
The ability to determine where one element of the display ends, and the next one
begins. Also loosely applied to the ability of a computer to perform arithmetic
manipulations on large numbers.

Reverse Polish notation


(RPN) A method of describing arithmetic operations favoured by some calculator
manufacturers, where the operators ( +, -, *, /) are placed behind the values to which
they apply.

RF Modulator
The means by which the video signals from the computer are encoded and
'transmitted' to the aerial of a standard TV set.

ROM
Read Only Memory. Generally with reference to semiconductor memory systems:
once written, neither erasable, nor re-writable.

Routine
A part of the program that performs a 'routine' task. A 'sub' program that resides
either within a main program, or may exist as a separate module for incorporation
into a variety of applications programs. e.g. A program to derive a 12 hour display
from the system's clock may be considered as a routine.

Glossary

Appendix 2 Page 25

RS232C
A specific standard for serial data communications interfaces. Devices at both ends of
the data link using an RS232 interf~ce require to be 'configured' to the particular
conditions of the RS232 data standard used. Compare this with the Centronics
parallel interface where the interconnection is virtually standard everywhere.

Screen Editor
A text or program editor where the cursor may be taken to any part of the screen
display in order to alter the characters appearing there.

Scrolling
The term describing the way in which the screen display 'rolls up' when the display
fills up to the bottom, and needs to make space for the next line of entry or output to
appear.

Sector
A block of data on a disc. The AMSTRAD disc system uses a sector size of 512 bytes.

Separator
A separator performs the same function as a delimiter, i.e. marking the boundary
between reserved words and other elements of the program or data.

Serial interface
Although this term nearly always refers to an RS232 interface, other serial
standards exist for the sequential transmission of computer data.
.

Simulation
A technique for emulation of real life interactive processes using the computer, such,
as flight simulation, driving simulation etc.
.

Single sided
Refers to a disc which has only one side available for data storage.

Soft key
(See UDK - user defined key)

Appendix 2 Page 26

Glossary

,~

Software
Programs themselves. May be based on disc, cassette, ROM, etc.

Software engineering
A grandiose expression meaning computer programming, implying a structured and
considered approach, as opposed to arbitrary techniques.

Sound generator
The part of a computer (it may be either hardware or software) that creates the sound
and noise.

Speech recognition
The conversion of the spoken word into machine readable instructions.

Speech synthesis
Generation of simulated speech using a combination of hardware and software.

Spreadsheet
A program that allows rows and columns of numbers to be entered and arithmetically
manipulated. Changing one entry causes all the associated calculations to be re-run,
and produces an updated result.

Sprite
A screen character that moves freely around the display, generated by specific
hardware or software that allows it to appear and disappear apparently at random.

Stack
An area of memory allocated for 'stacking' information, but where only the last entry
on the stack can be recalled.

Statement
An instruction, or sequence of instructions, in a computer program.

Glossary

AppendiX 2 Page 27

Stream
The route used for the output from the computer. e.g. the screen, the printer, or the
disc.

String
A type of data comprising an assortment of characters that may not be treated as a
numeric variable. It may be purely numeric, but it is not treated as such unless
specifically converted to a corresponding numeric variable by the appropriate
command.

Structmed programming
A logical and premeditated programming technique that results in programs that
flow from 'top to bottom', with clearly described steps.

Sub-routine
(See routine)

Syntax error
When the rules of the program are broken by the incorrect use of keywords and
variables, BASIC will prompt the user with this message.

System tracks
Tracks reserved on the disc for the CPIM system.

Terminal
A keyboard input device, with either a VDU screen or teletype typewriter output
system.

TPA
Transient Program Area. An area in memory commencing at &0100 where CP/M
user programs run and store data.

Track
Tracks are concentric rings on a disc. Each track holds a fixed number of sectors. The
tracks and sectors are written to a specific area of a disc during formatting.

Appendix 2 Page 28

Glossary

Transient program
A CP/M utility program such as PIP, which can be loaded into the TPA and run by
typing its name at the keyboard.

Truncated
A number or string that has been shortened by removal of leading or trailing
characters. Where intentional, the process may involve rounding the value. Where
unintentional, the extra characters are simply discarded to enable the number or
string to fit the available space.

Truth table
The results of a logical operation are either 'true' or 'false'. The computer interprets
these as being either 1 or 0, and the truth table lists the possible results of a logical
operation (I FA> B THE Ne) accordingly.

Turnkey
A word used to describe a program which executes automatically when the system is
booted.

Turtle
A graphic symbol, in the shape of an arrow head, that functions as a graphic cursor on
the Dr.Logo graphic screen.

Turtle graphics
The graphics image left on the screen by the movement of a turtle. As the turtle
moves it leaves a trace of its path on the screen.

Turtle step
The smallest distance a turtle can move. Normally one pixel.

UDK
User defined keys. The 6128 has up to 32 keys which may be redefined to perform a
variety oftasks.

Unsigned number
A number with no prefix to signify whether its value is positive or negative.
Glossary

Appendix 2 Page 29

Utility
Any complete program used to perform a common operation, such as sorting data or
copying files.

Utility program
A program on disc that enables the user to perform certain operations. (See Transient
program)

Variable
An item included in a computer program that can be identified by name, but whose
actual value may be made to vary during the execution of a program.

Warm start
This is performed when [CTRL]C is pressed during CP/M. A warm start re initialises
the disc sub-system and returns control to CP/M ready for commands to be entered.

Wildcard character
Either of the characters * or ? Dr.Logo only supports the? character. The *
wildcard character simply means any number of? s. When referencing files, wildcard
characters are used to make up an ambiguous file name. Any? s in the file name refer
to any alphabetic or numeric character.

Write protection
A safeguard used to prevent re-writing of a disc or disc file. A write protected disc or
file is Read Only.

XYZy
A magic word to get out of sticky corners in adventure games.

Appendix 2 Page 30

Glossary

Appendix 3
Some Programs For You ....
Bustout
So simple yet so addictive! For one player against the computer. Keyboard or
Joystick.

10 'BUSTOUT by ALEXANDER MARTIN


20 'copyright (c) AMSOFT 1984
30 '
40 MODE 1:BORDER 1:INK 0,1:INK 1,26:INK 2,24:INK 3,6
50 SPEED KEY 15,2
60 ENV 1,1,18,0,11,0,10
70 ENT 1,10,2,2
80 ENV 3,1,0,16,5,-3,2
90 ENV 2,5,3,3,1,-21,22,9,-3,2
100 ENT -2,10,2,2,5,-7,1,2,11,3,2,-4,8
110 '
120 '
130 MOVE 30,32:DRAWR 0,400,1:MOVE 610,32:DRAWR 0,400,1
140 PEN 3:LOCATE 3,1:PRINT STRING$(36,143)
150 PEN 2:LOCATE 3,2:PRINT STRING$(36,143)
160 PEN 1:FOR r=5 TO 6:LOCATE 3,r:PRINT STRING$(36,143)
:NEXT r
170 bx=9
180 lives=5:score=0
190 PEN 1:GOSUB 680:CLEAR INPUT
200 IF INKEY$<>CHR$(32) AND JOY(0)<16 THEN 200
210 LOCATE 11,23:PRINT SPACE$(20):LOCATE 1,24:PRINT SPA
CE$(40);
220 GOSUB 690:GOSUB 660:GOTO 280
230 '
240 '
250 LOCATE bx,24:PRINT" ";STRING$(4,131);" ":RETURN
260 '
270 '
280 xa=1:ya=1:IF INT(RND*2)=1 THEN xa=-xa
290 PEN 1:GOSUB 250
300 ORIGIN 0,400
310 x=bx+4:y=11:x1=x:y1=y
320 '
330 '
340 x1=x+xa:y1=y+ya
continued on the next page
Some Programs for you ....

Appendix 3 Page 1

350 IF x1=3 OR x1=38 THEN xa=-xa


360 GOSUB 540
370 IF y1=24 AND x1>bx+1 AND x1<bx+6 THEN ya=-ya:y1=y12:S0UND 130,44,8,7,1,1:a=x>bx+5)OR(x<bx+2:IF a=
-1 THEN xa=xa*a:x1=x1+xa:y1=y1+1
380 IF y1=25 THEN LOCATE x,y:PRINT" ":GOTO 500
390 GOSUB 250
400 t=TEST16*x1)-1,-(16*y1)-1)
410 IF t<>0 THEN ya=-ya:xz=x1:yz=y1:y1=y1+ya:GOSUB 590:
IF t=2 THEN score=score+10:GOSUB 660
420 IF t=3 THEN score=score+20:GOSUB 660
430 IF t=1 THEN score=score+5:GOSUB 660
440 IF y1=1 THEN ya=1
450 LOCATE x,y:PRINT " ":LOCATE x1,y1:PRINT CHR$(233):x
=x1:y=y1
460 IF y=1 OR x=3 OR x=38 THEN SOUND 129,78,8,7,1,1
470 GOTO 340
480 I
490 I
500 lives=lives-1:S0UND 132,19,46,12,2,2:IF lives=0 THE
N GOTO 620
510 GOSUB 660:GOTO 280
520 I
530 I
540 IF (INKEY(8)=0 OR INKEY(74)=0) AND bx>2 THEN bx=bx2:RETURN
550 IF (INKEY(1)=0 OR INKEY(75)=0) AND bx<32 THEN bx=bx
+2:RETURN
560 RETURN
570 I
580 I
590 LOCATE xz,yz:PRINT " ":RETURN
600 I
610 I
620 IF score>=hiscore THEN hiscore=score
630 GOSUB 660:score=0:lives=5:GOTO 130
640 I
650 I
660 SOUND 130,0,20,13,3,0,31:LOCATE 1,25:PRINT TAB(4)"H
ISCORE";hiscore;
670 LOCATE 18,25:PRINT"SCORE";score:LOCATE 30,25:PRINT"
LIVES"; lives: RETURN
680 LOCATE 11,23:PRINT"PRESS SPACE TO START":RETURN
690 LOCATE 1,25:PRINT SPACE$(40);:RETURN

Appendix 3 Page 2

Some Programs for you....

Bomber
A variation on a classic theme! For one player against the computer. Keyboard only.

10
20
30
40

'BOMBER by DAVE TOWN


'copyright (c) AMSOFT 1984
'
MODE 1:CLS:INK 0,0:BORDER 0:INK 1,18:INK 2,6:INK 3,4
:INK 5,15:INK 6,2:INK 7,24:INK 8,8:INK 9,26:INK 10,1
0:INK 11,20:INK 12,12:INK 13,16:INK 14,14:INK 15,21
50 SYMBOL AFTER 240:SYMBOL 241,&40,&60,&70,&7F,&7F,&3F,
&7,&0:SYMBOL 242,&0,&32,&7A,&FE,&FA,&F2,&E0,&0
60 score=0:hiscore=0:plane$=CHR$(241)+CHR$(242):x=2:y=2
:drop=0:a=2:b=2
70 GOSUB 480
80 CLS
90 PEN 2:LOCATE 1,15:INPUT"Enter skilL
0 (ACE) to 5 (
NOVICE) : ",skilL
100 IF ski LL<0 OR ski Ll>5 GOTO 90
110 skiLL=skiLL+10
120 LOCATE 1,15:PRINT CHR$(18);:LOCATE 1,15:INPUT"Enter
speed 0 (FAST) to 100 (SLOW) : ",rate
130 IF rate>100 OR rate<0 GOTO 120
140 '
150 'BuiLdings
160 '
170 MODE 0:FOR base=5 TO 15:FOR height=21 TO INT(RND(1)
*8+skilL) STEP -1:LOCATE base,height:PEN base-2:PRI
NT CHR$(143)+CHR$(8)+CHR$(11)+CHR$(244);:NEXT :NEXT
180 PLOT 0,20,4:DRAW 640,20,4
190 LOCATE 1,25:PEN 2:PRINT"SCORE";score;:LOCATE 13,25:
PRINT"HI";hiscore;
200 '
210 'Main Game
220 '
230 LOCATE x-1,y:PRINT"
";
240 PEN 1:LOCATE x,y:PRINT pLane$;:PEN 2
250 IF y=21 AND x=15 THEN GOTO 290:ELSE GOTO 340
260 '
270 'Landed
280 '
290 FOR c=0 TO 1000:NEXT
continued on next page

Some Programs for you....

Appendix 3 Page 3

300 score=score+100-(ski ll*2):ski ll=ski ll-1:x=2:y=2:a=2


:b=2:drop=0
310 IF ski ll<10 THEN ski ll=10:rate=rate-20
320 IF rate<0 THEN rate=0
330 GOTO 150
340 FOR c=0 TO rate:NEXT
350 x=x+1
360 IF x=18 THEN LOCATE x-1,y:PRINT CHR$(18);:x=2:y=y+1
:LOCATE x,y:PEN 1:PRINT pLane$;:PEN 2
370 a$=INKEY$:IF a$=" " AND drop=0 THEN drop=1:b=y+2:a=
x

380 IF y=21 THEN drop=0


390 IF drop=1 THEN LOCATE a,b:PRINT CHR$(252);:LOCATE a
,b-1:PRINT" ";:b=b+1:IF b>21 THEN LOCATE a,b:PRINT"
";:LOCATE a,b-1:PRINT" ";:a=0:b=0:drop=0:S0UND 3,4
000,10,12,0,0,10
400 ga=(a-0.5)*32:gb=400-(b*16):bomb=TEST(ga,gb)
410 IF bomb>0 THEN GOTO 670
420 gx=x+1.5)*32):gy=408-(y*16):crash=TEST(gx,gy)
430 IF crash>0 GOTO 570
440 GOTO 230
450 '
460 'Instructions
470 '
480 LOCATE 1,2:PEN 1:PRINT"You are piloting an aircraft
over a des-erted city and must clear the bui ldings
in order to land and refuel. Your air- craft move
s across the screen from left to right.";:PRINT
490 PRINT:PRINT"On reaching the right, the aircraft
returns to the l~ft A LINE FURTHER DOWN. You have a
and you can.drop them
n unLimited supply of bombs
on the buildings below by pressing the SPACE BAR.
";:PRINT
500 PRINT:PRINT"Each time you land, the height of the
buildings or the speed of your aircraft increases.
";:PRINT:PRINT:PRINT"ONCE YOU HAVE RELEASED A BOMB,
YOU WILL NOT BE ABLE TO RELEASE ANOTHER UNTIL THE
FIRST HAS EXPLODED !!!!";
510 PEN 2:LOCATE 1,24:PRINT:PRINT"Press any key to star
t . ";

520
530
540
550

a$=INKEY$: IF a$='"' GOTO 520


RETURN
'
'Collision
continued on the next page

Appendix 3 Page 4

Some Programs for you....

560 I
570 LOCATE x-1,y:PRINT CHR$(32)+CHR$(32)+CHR$(32)+CHR$(
253)+CHR$(8)+CHR$(238)+CHR$(8);
580 FOR t=1 TO 10:S0UND 7,4000,5,15,0,0,5:PEN t:PRINT C
HR$(253)+CHR$(8)+CHR$(238)+CHR$(8)+CHR$(32)+CHR$(8)
;:FOR tm=0 TO 50:NEXT:NEXT:PEN 2
590 CLS:LOCATE 1,5:PRINT"You scored";score;
600 IF score>hiscore THENhiscore=score:LOCATE 1,8:PRIN
T"TOP SCORE!!";
610 score=0:LOCATE 1,12:PRINT"Press R to restart";
620 a$=INKEY$:IF a$="r" OR a$="R" GOTO 630 ELSE GOTO 62

630 PEN 1:MODE 1:x=2:y=2:a=2:b=2:GOTO 90


640 I
650 I Bombed bui Ldi ng
660 I
670 LOCATE a,b-1:PRINT" "+CHR$(8);:PEN 4:FOR tr=1 TO IN
T(RND(1)*3)+1:score=score+5:S0UND 3,4000,10,12,0,0,
10:LOCATE a,b:FOR t=0 TO 4:PRINT CHR$(253)+CHR$(8)+
CHR$(32)+CHR$(8);:NEXT:b=b+1
680 IF b=24 THEN b=b-1
690 NEXT
700 LOCATE 6,25:PRINT score;:drop=0:a=x:b=y:GOTO 230

Some Programs for you ....

Appendix 3 Page 5

Telly tennis
The one that started it all, but still great fun! For two players, or one player against
the computer. Keyboard or Joystick(s).

10 'TELLY TENNIS by DAVID RADISIC


20 'copyright (c) AMSOFT 1985
30 '
40 DEFINT a-z
50 comp=1
60 ENV 1,=11,20,=9,5000
70 MODE 1:INK 0,10:BORDER 10:INK 1,26:INK 2,18:INK 3,0
80 GOSUB 710
90 GOSUB 150
100 GOSUB 330
110 GOSUB 420
120 LOCATE 13,1:PRINT USING"#### ";score1;
130 LOCATE 35,1:PRINT USING"#### ";score2;
140 GOTO 100
150 PEN 2
160 x(1)=3:y(1)=5
170 x(2)=37:y(2)=22
180 edge$=CHR$(233):edge2$=STRING$(2,207)
190 LOCATE 1,3:PRINT STRING$(39,edge$):PRINT STRING$(39
,edge$)
200 FOR i=1 TO 19
210 PRINT edge2$;TAB(38);edge2$
220 NEXT
230 PRINT STRING$(39,edge$):PRINT STRING$(39,edge$);
240 WINDOW #1,3,37,5,23
250 CLS#1
260 SYMBOL 240,0,60,126,126,126,126,60,0
270 bat$="I"+CHR$(8)+CHR$(HD+"I"
280 clr$=" "+CHR$(8)+CHR$(10)+" "
290 ball$=CHR$(240)
300 PEN 3
310 LOCATE 2,1:PRINT"Player
0";:LOCATE 24,1:PRIN
T"Player 2:
0";
320 RETURN
330 n=INT(RND*2):CLS #1:scored=0
340 PEN 3
350 FOR ;=1 TO 2:LOCATE x(;),y(i):PRINT bat$;:NEXT
360 ON n GOTO 390
continued on the next page
Appendix 3 Page 6

Some Programs for you ....

370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710

xb=21:dx=1
GOTO 400
xb=19:dx=-1
yb=12:dy=INT(RND*3)-1
RETURN
GOSUB 600
oxb=xb:oyb=yb
GOSUB 500
IF note>0 THEN SOUND 129,note,50,15,1
LOCATE oxb,oyb:PRINT" If;
LOCATE xb,yb:PRINTbaLl$
IF scored=0 THEN 420
RETURN
LOCATE xb+dx,yb+dy:ch$=COPYCHR$(#0)
note=0
IF ch$=" " THEN xb=xb+dx:yb=yb+dy:RETURN
IF ch$="I" THEN dx=2-dx-2:dy=INT(RND*3)-1:note=200:
RETURN
IF ch$=LEFT$(edge2$,1) THEN 570
IF ch$=edge$ THEN dy=2-dy-2:note=250
RETURN
IF dx>0 THEN score1=score1+1 ELSE score2=score2+1
scored=1:note=2000
RETURN
p(1)=(INKEY(69=0)+(INKEY(72=0)+ABSINKEY(71=
0)+(INKEY(73=0*2
IF comp=1 THEN p(2)=ABS(y(2)<yb)*2+(y(2yb):GOTO 6
30
p(2)=(INKEY(4=0)+(INKEY(48=0)+ABSINKEY(5=0)
+(INKEY(49=0*2
PEN 3
FOR i=1 TO 2
LOCATE x(i)/y(i)+p(i):ch$=COPYCHR$(#0)
IF ch$=" " THEN LOCATE x(i),y(i):PRINT clr$;:y(i)=y
(i )+ROUND(p(; )/2)
LOCATE x(i),y(i):PRINT bat$;
NEXT
PEN 1
RETURN
PEN 2:PRINT:PRINT TAB(15)"Ping-Pong":PRINT TAB(15)"
_________ '1

720 PEN 3:PRINT:PRINT TAB(14)"To move bats:


730 PRINT:PRINT:PEN 1
740 PRINT" Player 1
Player 2
Direction":PRI
NT
continued on the next page

Some Programs for you....

Appendix 3 Page 7

75"
76"
77"
78"
79"
8""
81"
82"
83"

PRINT"
A
6
UP"
PRINT"
Z
3
DOWN":PRINT
PEN 3:PRINT:PRINT TAB(14)"Or joysticks"
PRINT:PRINT:PRINT:PRINT
PEN 2
PRINT TAB(6)"SeLect <1> or <2> pLayers"
i$=INKEY$:IF i$<>"1" AND i$<>"2" THEN 81"
IF i$="1" THEN comp=1 ELSE comp="
MODE 1:RETURN

Appendix 3 Page 8

Some Programs for you ....

Electric fencing
Try to 'foil' your opponent! For two players only. Keyboard or Joysticks.

10 'ELECTRIC FENCING by ALEXANDER MARTIN


20 'copyright (c) AMSOFT 1985
30 '
40 DEFINT a-z
50 MODE '0
60 GOSUB 980
70 GOSUB 1370
80 GOSUB 270
90 GOSUB 1520
100 GOSUB 1370
110 GOSUB 1270
120 '
130 '
140 REM start
150 IF finished THEN GOTO 100
160 GOSUB 240
170 FRAME:IF p1dir THEN GOSUB 570 ELSE FRAME:FRAME
180 FRAME:IF p2dir THEN GOSUB 620 ELSE FRAME:FRAME
190 IF p1sa=-1 THEN GOSUB 670
200 IF p2sa=-1 THEN GOSUB 720
210 GOTO 140
220 '
230 '
240 IF
THEN 380 ELSE 480
250 '
260 '
270 CLS:PEN 6
280 PRINT:PRINT"
CHOOSE CONTROL"
290 PRINT:PRINT:PRINT:PRINT"press J/K then ENTER"
300 LOCATE 4,10:PRINT"JOYSTICK";TAB(5);"OR KEYS"
310 LOCATE 12,10:IF j THEN PRINT"*":ELSE PRINT" "
320 LOCATE 12,11:IF j THEN PRINT" ":ELSE PRINT"*"
330 IF NOT(INKEY(45 THEN j=-1
340 IF NOT(INKEY(37 THEN j=0
350 IF NOT(INKEY(18 THEN RETURN ELSE 310
360 '
370 '
380 p1=JOY(0):p2=JOY(1)
390 p1dir=(p1 AND 1)*-1+(p1 AND 2)*0.5
continued on the next page
Some Programs for you ....

Appendix 3 Page 9

400 p2dir=(p2 AND 1)*-1+(p2 AND 2)*0.5


410 IF P1 AND 16 THEN p1sa=p1sa-1:IF p1sa=-1 THEN AFTER
15 GOSUB 770
420 IF P2 AND 16 THEN p2sa=p2sa-1:IF p2sa=-1 THEN AFTER
15 GOSUB 770
430 IF p1sa THEN p1dir=0
440 IF p2sa THEN p2dir=0
450 RETURN
460 '
470 '
480 p2dir=INKEY(4)=0)*1)+INKEY(5)=0)*-1)
490 p1dir=INKEY(69)=0)*1)+INKEY(71)=0)*-1)
500 IF INKEY(63)=0 THEN p1sa=p1sa-1:IF p1sa=-1 THEN AFT
ER 15 GOSUB 770
~10 IF INKEY(10)=0 THEN p2sa=p2sa-1:IF p2sa=-1 THEN AFT
ER 15 GOSUB 770
520 IF p1sa THEN p1dir=0
530 IF p2sa THEN p2dir=0
540 RETURN
550 '
560 '
570 pt=p1wp+p1dir:IF pt>25 OR pt<6 THEN RETURN ELSE p1w
p=pt
580 p1dir=0
590 PEN 1:LOCATE 3,p1wp:CLS #3:PRINT CHR$(209);:RETURN
600 '
610 '
620 pt=p2wp+p2dir:IF pt>25 OR pt<6 THEN RETURN ELSE p2w
p=pt
630 p2dir=0
640 PEN 2:LOCATE 18,p2wp:CLS #5:PRINT CHR$(211);:RETURN
650 I
660 '
670 PAPER #4,4:WINDOW #4,4,17,p1wp,p1wp:CLS#4:FRAME:FRA
ME
680 PAPER #4,0:CLS#4
690 GOTO 570
700 I
710 I
720 PAPER #6,5:WINDOW #6,4,17,p2wp,p2wp:CLS#6:FRAME:FRA
ME
730 PAPER #6,0:CLS#6
740 GOTO 620
750 I
continued on the next page
Appendix 3 Page 10

Some Programs for you ....

760 '
770 pwpe=(p1wp=p2wp):IF p1sa AND NOT(p2sa) AND pwpe THE
N p1sc=p1sc+1:S0UND 132,120,10,0,1,0:PRINT#1,a$(p1s
c);:IF p1sc=9 THEN 860
780 IF p2sa AND NOT(p1sa) AND pwpe THEN p2sc=p2sc+1:S0U
ND 132,100,10,0,1,0:PRINT#2,a$(p2sc);:IF p2sc=9 THE
N 860
790 IF p1sa THEN SOUND 132,40,70,0,1,1
800 IF p2sa THEN SOUND 132,56,70,0,1,1
810 p1sa=0
820 p2sa=0
830 RETURN
840 '
850 '
860 PEN 6
870 LOCATE 6,10:PRINT"GAME OVER"
880 IF p1sc=9 THEN INK 1,2,20:INK 2,0 ELSE INK 2,6,17:1
NK 1,0
890 SOUND 129,1000,0,12,3:S0UND 130,900,0,12,3
900 WHIL E INK EY$ <>" " : WEN D
910 t!=TIME:WHILE t!+2000>TIME:WEND
920 WHILE INKEY$="":WEND
930 CLS
940 finished=-1
950 RETURN
960 '
970 '
980 a$(0)="111101101101111"
990 a$(1)="001001001001001"
1000 a$(2)="111001111100111
1010 a$(3)="111001111001111
1020 a$(4)="100100101111001
1030 a$(5)="111100111001111
1040 a$(6)="111100111101111
1050 a$(7)="111001001010010
1060 a$(8)="111101111101111
1070 a$(9)="111101111001001"
1080 FOR n=0 TO 9
1090 howLong=LEN(a$(n
1100 FOR n2=1 TO howLong
1110 IF MID$(a$(n),n2,1)="1"THEN MID$(a$(n),n2,1)=CHR$(
143)ELSE MID$(a$(n),n2,1)=CHR$(32)
1120 NEXT n2,n
1130 '
continued on the next page
Some Programs for you ....

Appendix 3 Page 11

1140
1150
1160
1170
1180
1190
1200
1210
1220
1230
1240
1250
1260
1270
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530

'
b$="ELECTRIC FENCING"
c$=CHR$(32)+CHR$(164)+" Alexander Martin"
ENV 1,=9,2000:ENT -1,6,3,1
ENV 2,127,0,0,127,0,0,127,0,0,127,0,0,127,0,0
ENV 3,=9,9000
'
'
BORDER 0
INK 0,12:PEN #4,1:PEN #6,2:PEN #1,1:PEN #2,2:PAPER
#1,3:PAPER #2,3:PEN #0,6
RETURN 'FROM SETTING UP CONSTANTS
'
'
INK 0,12:INK 1,2:INK 2,6:INK 3,13:INK 4,20:INK 5,1
7:INK 6,20
WINDOW #3,3,3,6,25:WINDOW #5,18,18,6,25
WINDOW #1,3,5,1,5:WINDOW #2,16,18,1,5:WINDOW #7,1,
20,1,5:PAPER #7,3
CLS:CLS#7:PRINT#1,a$(0);:PRINT#2,a$(0);:p1sc=0:p2s
c=0:p1wp=5:p2wp=24:p1dir=1:p2dir=1
GOSUB 570:GOSUB 620
SOUND 1,1000,0,12,2:S0UND 2,900,0,12,2
p1sa=0:p2sa=0:finished=0
RETURN 'FROM GAME SHEET RESTORE
'
'
CLS
PEN 7
FOR n=1 TO LEN(b$)
LOCATE 2+n,10
FOR n2=LEN(b$) TO n STEP-1
PRINT MID$(b$,n2,1)
LOCATE 2+n,10
SOUND 135,20*n2,5,12,2,1
NEXT n2,n
SOUND 135,100,0,13,3,1,20
PEN 6:PRINT:PRINT:PRINT:PRINT c$
FOR n=1 TO 5000:NEXT
RETURN
'
'
IF j THEN RETURN
CLS
continued on the next page

Appendix 3 Page 12

Some Programs for you....

1540
1550
1560
1570
1580
1590
1600
1610
1620
1630

LOCATE 7,5
PRINT"CONTROLS"
PRINT
PRINT" PLAYER1 PLAYER2"
PRINT
up
6"
PRINT" A
PRINT" Z
down
3"
PRINT" X
fire
7"
t!=TIME:WHILE t!+1000>TIME:WEND
RETURN

Some Programs for you ....

AppendiX 3 Page 13

Amthello
The thinking person's game. Try to surround and capture your opponent's squares
without leaving your own squares onen to capture! For one player against the
computer. Keyboard only.

10
20
30
40
50
60
70
80

'AMTHELLO by M.J.GRIBBINS
'copyright (c) AMSOFT 1984
'
BORDER 14
CLEAR
MODE 1:PEN 0:PAPER 1:CLS
INK 0,0:INK 1,14:INK 2;18:INK 3,26
LOCATE 2,3:PEN 3:PRINT"A":LOCATE 3,4:PRINT"M":LOCATE
4,5:PRINT"T":LOCATE 5,6:PRINT"H"
90 LOCATE 6,7:PRINT"E":LOCATE 7,8:PRINT"L":LOCATE 8,9:P
RINT"L":LOCATE 9,10:PRINT"0"
100 WINDOW #1,2,39,22,25:PAPER #1,1:PEN #1,0:CLS #1
110 PEN 0
120 LOCATE #1,8,1:PRINT #1,"BLACK ALWAYS PLAYS FIRST"
130 LOCATE #1,1,3:PRINT #1,"PRESS B OR W TO CHOOSE BLAC
K OR WHITE"
140 B$=INKEY$:IF B$='"' THEN 140
150 IF B$="W" OR B$="w" THEN Q%=3:N%=0:GOTO 210
160 IF B$="B" OR B$="b" THEN Q%=0:N%=3:GOTO 210
170 CLS #1:LOCATE #1,4,3
180 PRINT #1,"
BLACK OR WHITE ONLY"
190 FOR T=0 TO 1000:NEXT T
200 GOTO 140
-, 210 DIM C%(10,10),P%(9,9),C1%(8),C2%(8),CX%(.9),CY%(9)
220 I1%=2:J1%=2:12%=7:J2%=7
230 FOR 1%=0 TO 9
240 C%(I%,0%)=6:C%(0,I%)=6
250 C%(9,I%)=6:C%(I%,9)=6
260 NEXT 1%
270 FOR 1%=1 TO 8
280 READ C1%(I%),C2%(I%)
290 FOR J%= 1 TO 8
300 READ P%(I%,J%)
310 C%<I%,J%)=6
320 NEXT J%:NEXT 1%
330 C%(4,4)=3:C%(4,5)=0:C%(5,4)=0:C%(5,5)=3
continued on the next page
Appendix 3 Page 14

Some Programs for you ....

340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510

FOR K%~1 TO 58
READ AR%,BR%,CR%,DR%
PLOT AR%,BR%:DRAW CR%,DR%,0
NEXT K%
GOSUB 1460
IF Q%=3 GOTO 770
CLS #1:INPUT #1," WHICH LINE DO YOU WANT ";E%
IF E% <1 OR E% >8 GOTO 400
LOCATE #1,1,3:INPUT #1,"WHICH COLUMN DO YOU WANT ";
D%
IF D% <1 OR D% >8 GOTO 420
IF C%(D%,E%)=6 GOTO 480
CLS #1:LOCATE #1,5,2:PRINT #1,"THAT SQUARE IS ALREA
DY 0 CC UPIED !"
FOR T=1 TO 1000:NEXT T
GOTO 400
PLOT 270+(30*D%),70+(30*E%):DRAW 290+(30*D%),89+(30
*E%),Q%
PLOT 290+(30*D%),70+(30*E%):DRAW 270+(30*D%),89+(30
*E%),Q%
GOTO 540
FOR M%= 0 TO 19 STEP 2:PLOT 270+(30*D%),70+M%+(30*E
%)

520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720

DRAW 290+(30*D%),70+M%+(30*E%),6:NEXT M%
GOTO 400
VRX%=0
FOR K%=1 TO 8
VR%=0:C3%=D%:C4%=E%
C3%=C3%+C1%(K%):C4%=C4%+C2%(K%)
IF C%(C3%,C4%)=N% GOTO 590 ELSE 600
VR%=VR%+1:GOTO 570
IF C%(C3%,C4%)=6 GOTO 610 ELSE 620
NEXT K%:GOTO 670
IF VR%=0 GOTO 610 ELSE 630
VRX%=VRX%+VR%
C3%=C3%-C1%(K%):C4%=C4%-C2%(K%)
IF C%(C3%,C4%)=6 GOTO 610 ELSE 660
C%(C3%,C4%)=Q%:GOTO 640
IF VRX%=0 GOTO 680 ELSE 710
CLS #1:PRINT #1," THIS IS NOT A POSSIBLE CHOICE"
FOR T=1 TO 1000:NEXT T
GOTO 510
E%=E%:D%=D%:VRX%=VRX%
CLS #1:PRINT #1,"YOU HAVE PLAYED LINE NUMBER ";E%
continued on the next page

Some Programs for you ....

Appendix 3 Page 15

730 PRINT #1,"


AND COLUMN NUMBER ";D%
740 LOCATE #1,2,4:PRINT #1,"THAT GIVES YOU ";VRX%;" SQU
ARES(S)"
750 C%(D%,E%)=Q%:GOSUB -1710
760 GOSUB 1460
770 CLS #1:LOCATE #1,10,2:PRINT #1,"NOW IT'S MY TURN ..
. ! 11

780
790
800
810
820
830.
840
850
860
870
880
890
900
910
920

P%=0:VRX%=0~~RY%=0

IF 11%*J1%=1 AND I2%*J2%=64 GOTO 860


FOR K%=2 TO 7
IF C%(2,K%) <> 6 THEN 11%=1
IF C%(7,K%) <> 6 THEN 12%=8
IF C%(K%,2) <> 6 THEN J1%=1
IF C%(K%,7) <> 6 THEN J2%=8
NEXT K%
FOR 1%=11% TO 12%
FOR J%=J1% TO J2%
IF C%(I%,J%)=6 GOTO 1030
NEXT J%:NEXT 1%
IF P% > 0 GOTO 1000
IF PAS%=1GOTO 920 ELSE 940
CLS #1:PRINT #1," DEADLOCK! I MUST PASS ALSO.GAME
OVER"
930 FOR T=1 TO 1000:NEXT T:GOTO 1550
940 CLS #1:LOCATE #1,18,2:PRINT #1,"1 MUST PASS"
950 GOSUB 2720
960 IF PAS%=1 GOTO 970 ELSE 990
970 CLS #1:PRINT #1,"DEADLOCK! YOU MUST PASS ALSO.GAME
OVER"
980 FOR T=1 TO 1000:NEXT T:GOTO 1550
990 GOTO 400
1000 IF LC%=0 THEN LC%=1:RANDOMIZE LC%:RL%=RND(LC%)
1010 CX1%=CX%(RL~):CX2%=CY%(RL%)
1020 GOTO 1220
1030 VRX%=0
1040 FOR K%=1 TO 8
1050 VR%=0:C3%=I%:C4%=J%
1060 C3%=C3%+C1%(K%)~C4%=C4%+C2%(K%)
1070 IF C%(C3%,C4%)=Q% GOTO 1080 ELSE 1090
1080 VR%=VR%+1:GOTO 1060
1090 IF C%(C3%,C4%)=6 GOTO 1100 ELSE 1110
1100 NEXT K%:GOTO 1130
1110 IF VR%=O% GOTO 1100 ELSE 1120
1120 VRX%=VRX%+VR%:GOTO 1100
continued on the next page

Appendix 3 Page 16

Some Programs for you....

1130
1140
1150
1160
1170
1180
1190
1200
1210
1220
1230
1240
1250
1260
1270
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510

IF VRX%=0 GOTO 890


IF P%(I%,J%) < P% GOTO 890
IF P%(I%,J%) > P% GOTO 1160 ELSE 1170
P%=P%(I%,J%):VRY%=VRX%:LC%=0:CX%(0)=I%:CY%(0)=J%:G
OTO 890
IF VRY% > VRX% GOTO 890
IF VRY% < VRX% GOTO 1190 ELSE 1200
LC%=0:VRY%=VRX%:CX%(0)=I%:CY%(0)=J%:GOTO 890
LC%=lC%+1:CX%(LC%)=I%:CY%(LC%)=J%
GOTO 890
CX2%=CX2%:CX1%=CX1%:VRY%=VRY%
CLS #1 :PRINT #1," I CHOOSE LINE NUMBER ";CX2%.
PRINT #1,"
AND COLUMN NUMBER ";CX1%
LOCATE #1,1,4:PRINT #1,"THAT GIVES ME ";VRY%;" SQU
ARE<S)"
PLOT 270+(30*CX1%),70+(30*CX2%):DRAW 290+(30*CX1%)
,89+<30*CX2%) ,N%
PLOT 290+(30*CX1%),70+(30*CX2%):DRAW 270+(30*CX1%)
,89+(30*CX2%),N%
FOR T=1 TO 1000:NEXT T ,
FOR K%=1 TO 8
VR%=0:C3%=CX1%:C4%=CX2%
C3%=C3%+C1%(K%):C4%=C4%+C2%(K%)
IF C%(C3%,C4%)=Q% GOTO 1330 ELSE 1340
VR%=VR%+1:GOTO 1310
IF C%(C3%,C4%)=6 GOTO 1350 ELSE 1360
NEXT K%:GOTO 1400
IF VR%=0 GOTO 1350
C3%=C3%-C1%(K%):C4%=C4%-C2%(K%)
IF C%(C3%,C4%)=6 GOTO 1350
C%(C3%,C4%)=N%:GOTO 1370
C%(CX1%,CX2%)=N%
GOSUB 2720
GOSUB 1460
IF PAS%=1 GOTO 1440 ELSE 1450
CLS #1:PRINT #1,"
YOU MUST PASS":FOR T=1 TO 10
00:NEXT T:GOTO 770
GOTO 400
FOR 1%=1 TO 8
FOR J%=1 TO 8
FOR M%=0 TO 19 STEP 2
Z%=270+(30*I%):H%=70+(30*J%):W%=H%+M%
PLOT Z%,W%:DRAW Z%+20,W%,C%(I%,J%)
NEXT M%:NEXT J%:NEXT 1%
continued on the next page

Some Programs for you ....

Appendix 3 Page 17

1520
1530
1540
1550
1560
1570
1580
1590
1600
1610
1620
1630
1640
1650
1660
1670
1680
1690
1700
1710
1720
1730
1740
1750
1760
1770
1780
1790
1800
1810
1820
1830
1840
1850
1860
1870
1880

X%=X%+1
IF X%=61 GOTO 1550
RETURN
CQ%=0:CN%=0
FOR 1%=1 TO 8
FOR J%=1 TO 8
IF C%(I%,J%)=Q% THEN CQ%=CQ%+1
IF C%(I%,J%)=N% THEN CN%=CN%+1
NEXT J%:NEXT 1%
IF CQ% > CN% GOTO 1680
IF CQ%=CN% GOTO 1630 ELSE 1650
CLS #1:LOCATE #1,25,2:PRINT #1,"DEADLOCK"
END
CLS #1:LOCATE #1,5,1:PRINT #1,"YOU HAVE ";CQ%;" SQ
UARES;I HAVE ";CN%
LOCATE #1,11,3:PRINT #1,"1 HAVE WON ... !!!!"
END
CLS #1:LOCATE #1,5,1:PRINT #1,"YOU HAVE ";CQ%;" SQ
UARES;I HAVE ";CN%
LOCATE #1,5,3:PRINT #1,"WELL DONE. YOU HAVE WON I I
"
END
IF C%(2,2)=Q% AND (C%(3,1)=N% OR C%(1,3)=N%) GOTO
1720 ELSE 1730
P%(3,1)=1:P%(1,3)=1
IF C%(7,7)=Q% AND (C%(8,6)=N% OR C%(6,8)=N%) GOTO
1740 ELSE 1750
P%(8,6)=1:P%(6,8)=1
IF C%(2,7)=Q% AND (C%(1,6)=N% OR C%(3,8)=N%) GOTO
1760 ELSE 1770
P%(1,6)=1:P%(3,8)=1
IF C%(7,2)=Q% AND (C%(6,1)=N% OR C%(8,3)=N%) GOTO
1780 ELSE 1790
P%(6,1)=1:P%(8,3)=1
IF D%=1 OR D%=8 OR E%=1 OR E%=8 GOTO 1820
IF CX1%=1 OR CX1%=8 OR CX2%=1 OR CX2%=8 GOTO 1820
RETURN
FOR J%=1 TO 8 STEP 7
FOR 1%=2 TO 7
IF C%(I%,J%)=N% GOTO 1850 ELSE 1860
P%(I%+1,J%)=21:P%(I%-1,J%)=21
IF C%(J%,I%)=N% GOTO 1870 ELSE 1880
P%(J%,I%+1)=21:P%(J%,I%-1)=21
NEXT 1%
continued on the next page

Appendix 3 Page 18

Some Programs for you ....

1890
1900
1910
1920
1930
1940
1950
1960
1970
1980

FOR 1%=2 TO 7
IF C%(I%,J%)=Q% GOTO 1910 ELSE 1920
P%(I%+1,J%)=2:P%(I%-1,J%)=2
IF C%(J%,I%)=Q% GOTO 1930 ELSE 1940
P%(J%,I%+1)=2:P%(J%,I%-1)=2
NEXT I%:NEXT J%
P%(1,2)=1:P%(1,7)=1:P%(2,1)=1:P%(7,1)=1
P%(2,8)=1:P%(7,8)=1:P%(8,2)=1:P%(8,7)=1
FOR 1%=2 TO 7
IF C%(1,I%-1)=Q% AND C%(1,I%+1)=Q% THEN P%(1,I%)=2
5

1990 IF C%(8,I%-1)=Q% AND C%(8,I%+1)=Q% THEN P%(8,I%)=2


5

2000 IF C%(I%-1,1)=Q% AND C%(I%+1,1)=Q% THEN P%(I%,1)=2


5

2010 IF C%(I%-1,8)=Q% AND C%(I%+1,8)=Q% THEN P%(I%,8)=2


5

2020
2030
2040
2050
2060
2070
2080
2090
2100
2110
2120
2130
2140
2150
2160
2170
2180
2190
2200
2210
2220
2230
2240
2250
2260
2270
2280

NEXT 1%
FOR J%=1 TO 8 STEP 7
FOR 1%=4 TO 8
IF C%(J%,I%) <> N% GOTO 2140
IC%=I%-1:IF C%(J%,IC%)=6 GOrO 2140
IF C%(J%,IC%)=Q% GOTO 2080 ELSE 2090
IC%=IC%-1:GOTO 2070
IF C%(J%,IC%)=6 ~OTO 2110
GOTO 2140
IF IC%=0 GOTO 2140
IF C%(J%,I%+1)=Q% AND C%(J%,IC%-1)=6 GOTO 2140
P%(J%,IC%)=26
IF C%(I%,J%) <> N% GOiO 2230
IC%=I%-1:IF C%(IC%,J%)=6 GOTO 2230
IF C%(IC%,J%)=Q% GOTO 2170 ELSE 2180
IC%=IC%-1:GOTO 2160
IF C%(IC%,J%)=6 GOTO 2200
GOTO 2230
IF IC%=0 GOTO 2230
IF C%(I%+1,J%)=Q% AND C%(IC%-1,J%)=6 GOTO 2230
P%(IC%,J%)=26
NEXT 1%
FOR 1%=1 TO 5
IF C%(J%,I%) <> N% GOTO 2340
IC%=I%+1:IF C%(J%,IC%)=6 GOTO 2340
IF C%(J%,IC%)=Q% GOTO 2280 ELSE 2290
IC%=IC%+1:GOTO 2270
continued on the next page

Some Programs for you....

Appendix 3 Page 19

2290
2300
2310
2320
2330
2340
2350
2360
2370
2380
2390
2400
2410
2420
2430
2440
2450
2460
2470
2480
2490
2500
2510
2520
2530
2540
2550
2560
2570
2580
2590
2600
2610
2620
2630
2640
2650
2660
2670

IF C%(J%,IC%)=6 GOTO 2310


GOTO 2340
IF IC%=9 GOTO 2340
IF C%(J%,I%-1)=Q% AND C%(J%,IC%+1)=6 GOTO 2340
P%(J%,IC%)=26
IF C%(I%,J%) <> N% GOTO 2430
IC%=I%+1:IF C%(IC%,J%)=6 GOTO 2430
IF C%(IC%,J%)=Q% GOTO 2370 ELSE 2380
IC%=IC%+1:GOTO 2360
IF C%(IC%,J%)=6 GOTO 2400
GOTO 2430
IF IC%=9 GOTO 2430
IF C%(I%-1,J%)=Q% AND C%(IC%+1,J%)=6 GOTO 2430
P%(IC%,J%)=26
NEXT I%:NEXT J%
IF C%(1,1)=N% GOTO 2450 ELSE 2460
FOR 1%=2 TO 6:P%(1,I%)=20:P%(I%,1)=20:NEXT 1%
IF C%(1,8)=N% GOTO 2470 ELSE 2480
FOR 1%=2 TO 6:P%(I%,8)=20:P%(1,9-1%)=20:NEXT 1%
IF C%(8,1)=N% GOTO 2490 ELSE 2500
FOR 1%=2 TO 6:P%(9-I%,1)=20:P%(8,I%)=20:NEXT 1%
IF C%(8,8)=N% GOTO 2510 ELSE 2520
FOR 1%=3 TO 7:P%(I%,8)=20:P%(8,I%)=20:NEXT 1%
IF C%(1,1) <> 6 THEN P%(2,2)=5
IF C%(1,8) <> 6 THEN P%(2,7)=5
IF C%(8,1) <> 6 THEN P%(7,2)=5
IF C%(8,8) <> 6 THEN P%(7,7)=5
P%(1,1)=30:P%(1,8)=30:P%(8,1)=30:P%(8,8)=30
FOR 1%=3 TO 6
IF C%(1,I%)=N% THEN P%(2,I%)=4
IF C%(8,I%)=N% THEN P%(7,I%)=4
IF C%(I%,1)=N% THEN P%(I%,2)=4
IF C%(I%,8)=N% THEN P%(I%,7)=4
NEXT 1%
IF C%(7,1)=Q% AND C%(4,1)=N% AND C%(6,1)=6 AND C%(
5,1)=6 THEN P%(6,1)=26
IF C%(1,7)=Q% AND C%(1,4)=N% AND C%(1,6)=6 AND C%(
1,5)=6 THEN P%(1,6)=26
IF C%(2,1)=Q% AND C%(5,1)=N% AND C%(3,1)=6 AND C%(
4,1)=6 THEN P%(3,1)=26
IF C%(1,2)=Q% AND C%(1,5)=N% AND C%(1,3)=6 AND C%(
1,4)=6 THEN P%(1,3)=26
IF C%(8,2)=Q% AND C%(8,5)=N% AND C%(8,3)=6 AND C%(
8,4)=6 THEN P%(8,3)=26
continued on the next page

Appendix 3 Page 20

Some Programs for you....

2680 IF C%(2,8)=Q% AND C%(5,8)=N% AND C%(3,8)=6 AND C%(


4,8)=6 THEN P%(3,8)=26
2690 IF C%(8,7)=Q% AND C%(8,4)=N% AND C%(8,5)=6 AND C%(
8,6)=6 THEN P%(8,6)=26
2700 IF C%(7,8)=Q% AND C%(4,8)=N% AND C%(5,8)=6 AND C%(
6,8)=6 THEN P%(6,8)=26
2710 RETURN
2720 PAS%=0
2730 FOR 1%=1 TO 8
2740 FOR J%=1 TO 8
2750 IF C%(I%,J%)=Q% GOTO 2780
2760 NEXT J%:NEXT 1%
2770 PAS%=1:RETURN
2780 FOR K%=1 TO 8
2790 VR%=0:C3%=I%:C4%=J%
2800 C3%=C3%+C1%(K%):C4%=C4%+C2%(K%)
2810 IF C3% < 1 OR C3% > 8 GOTO 2820 ELSE 2830
2820 NEXT K%:GOTO 2760
2830 IF C4% < 1 OR C4% > 8 GOTO 2820 ELSE 2840
2840 IF C%(C3%,C4%)=N% GOTO 2850 ELSE 2860
2850 VR%=VR%+1:GOTO 2800
2860 IF C%(C3%,C4%)=Q% GOTO 2820 ELSE 2870
2870 IF VR% > 0 THEN RETURN
2880 GOTO 2820
2890 DATA 1,0,30,1,20,10,10,20,1,30,1,1,1,1,3
2900 DATA 3,3,3,1,1,0,1,20,3,5,5,5,5,3,20,-1,1,10,3,5
2910 DATA 0,0,5,3,10,-1,0,10,3,5,0,0,5,3,10,-1
2920 DATA -1,20,3,5,5,5,5,3,20,0,-1,1,1,3,3,3,3,1,1,1,1,30,1,20,10,10,20,1,30
2930 DATA 263,100,263,120,270,130,255,130,255,130,255,1
40,255,140,270,140
2940 DATA 270,140,270,150,270,150,255,150,255,160,270,1
60,270,160,270,180
2950 DATA 270,180,255,180,270,170,255,170,270,190,270,2
10,270,200,255,200
2960 DATA 255,200,255,210,255,220,270,220,270,220,270,2
30,270,230,255,230
2970 DATA 255,230,255,240,255,240,270,240,255,250,270,2
50,270,250,270,260
2980 DATA 270,260,255,260,255,250,255,270,270,280,270,3
00,270,300,255,300
2990 DATA 255,310,255,330,255,330,270,330,270,330,270,3
10,270,310,255,310
3000 DATA 255,320,270,320
continued on the next page
Some Programs for you ....

Appendix 3 Page 21

3010 DATA 310,355,310,375,350,355,335,355,335,355,335,3


65,335,365,350,365
3020 DATA 350,365,350,375,350,375,335,375,365,355,380,3
55,380,355,380,375
3030 DATA 380,375,365,375,380,365,365,365,410,355,410,3
75,410,365,395,365
3040 DATA 395,365,395,375,425,355,440,355,440,355,440,3
65,440,365,425,365
3050 DATA 425,365,425,375,425,375,440,375,455,375,455,3
55,455,355,470,355
3060 DATA 470,355,470,365,470,365,455,365,485,375,500,3
75,500,375,500,355
3070 DATA 515,375,515,355,515,355,530,355,530,355,530,3
75,530,375,515,375
3080 DATA 515,365,530,365

Appendix 3 Page 22

Some Programs for you....

Raffles
Break into His Lordship's house and steal the booty. Lots of obstacles to trip you up,
lights to switch on, and you must beware of the dog! For one player against the computer. Keyboard or Joystick.

10
20
30
40
50

'RAFFLES by DAVID RADISIC


'copyright (c) AMSOFT 1985
'
MODE 0:INK 0,0:BORDER 0:INK 1,26:INK 2,15:INK 3,25
INK 4,14:INK 5,24,12:INK 6,0:INK 7,0:INK 8,0:PAPER #
1,7
60 deLay=200
70 DIM objx(5,20),objy(5,20),gemx(5,20),gemy(5,20)
80 GOSUB 380
90 GOSUB 720
100 pause=200:GOSUB 340
110 IF gems=0 THEN GOSUB 970
120 PEN 4
130 FOR i=10 TO 12
140 LOCATE 15,i :PRINT"SWAG";
150 NEXT
160 PAPER 0:CLS#2:PAPER 8
170 GOSUB 1170
180 GOSUB 1230
190 GOSUB 1370
200 GOSUB 1510
210 IF rm=0 THEN GOSUB 1900
220 IF dead=0 THEN 160
230 pause=100:GOSUB 340
240 PAPER 0:CLS:PEN 1
250 LOCATE 4,3:PRINT"Do you want";
260 LOCATE 4,5:PRINT"Another game";
270 PEN 5:LOCATE 9,7:PRINT"Y/N";
280 i$=UPPER$(INKEY$):IF i$<>"Y" AND i$<>"N" THEN 280
290 IF i$="N" THEN MODE 2:PEN 1:STOP
300 RUN
310 IF dog=1 THEN RETURN
320 dog=1:dogx=minx(rm):dogy=miny(rm)
330 RETURN
340 FOR Loop=1 TO pause
350 FRAME
360 NEXT
370 RETURN
continued on the next page

Some Programs for you ....

Appendix 3 Page 23

380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770

rm=1:xp=6:yp=4:man$=CHR$(224):dog=0:stoLen=0
SYMBOL 240,8,8,8,8,8,8,8,8
SYMBOL 241,0,0,0,0,255,0,0,0
SYMBOL 242,0,0,0,0,15,8,8,8
SYMBOL 243,0,0,0,0,248,8,8,8
SYMBOL 244,8,8,8,8,248,0,0,0
SYMBOL 245,8,8,8,8,15,0,0,0
SYMBOL 246,8,12,13,14,12,12,8,8
SYMBOL 247,8,12,12,14,13,12,8,8
SYMBOL 248,8,24,88,56,24,24,8,8
SYMBOL 249,8,24,24,56,88,24,8,8
SYMBOL 250,0,0,255,129,129,129,255,0
SYMBOL 251,28,20,20,20,20,20,20,28
SYMBOL 252,0,0,255,255,255,255,255,0
SYMBOL 253,28,28,28,28,28,28,28,28
SYMBOL 255,195,165,60,126,90,60,36,24
ENT 1,12,-4,1
ENT -2,=1000,60,=3000,40
ENV 1,10,1,5,2,-4,1,2,-1,20
windw$(1)=STRING$(2,250):windw$(2)=CHR$(251)+CHR$(8
)+CHR$(10)+CHR$(251)+CHR$(8)+CHR$(10)+CHR$(251)
door$(1)=STRING$(2,252):door$(2)=CHR$(253)+CHR$(8)+
CHR$(10)+CHR$(253)+CHR$(8)+CHR$(10)+CHR$(253)
switch$(1,0)=CHR$(246):switch$(1,1)=CHR$(247)
switch$(2,0)=CHR$(248):switch$(2,1)=CHR$(249)
gem$=CHR$(144):obj$=CHR$(233):dog$=CHR$(255)
hit$=CHR$(246)+CHR$(248)+CHR$(247)+CHR$(249)+CHR$(2
52)+CHR$(253)+CHR$(250)+CHR$(251)+gem$+obj$+dog$,
RESTORE 3010
.~
FOR i=1 TO 5
READ minx(i),miny(i),maxx(i),maxy(i)
READ d i r ( i , 1 ) , d i r ( i ,2) , d i r ( i ,3) , d i r (i ,4)
NEXT
WINDOW #1,minx(rm)-1,maxx(rm)+1,miny(rm)-1,maxy(rm)
+1
WINDOW #2,1,14,1,25
CLS #1:PAPER #0,8
RETURN
ORIGIN 50,50
INK 6,24,12
RESTORE 3060
GOSUB 1280
LOCATE 3,20
PEN 5:PRINT">";
continued on the next page

Appendix 3 Page 24

Some Programs for you ....

780
790
800
810
820
830
840

PEN 1:PRINT"Escape Routes";


PEN 5:PRINT"<";:PEN 1
LOCATE 10,2:PRINT"IN";
pause=300:GOSUB 340
CLS:LOCATE 1,3:IN~ 6,0
PEN 1:PRINT man$;" You The Thief":PRINT
PEN 2:PRINT LEFT$(door$(1),1);LEFT$(door$(2),1);" D
oors":PRINT
850 PEN 3:PRINT switch$(1,0);switch$(2,0);" LightSwitch
(OFF)"
860 PEN 3:PRINT switch$(1,1);switch$(2,1);" LightSwitch
(ON)":PRINT
870 PEN 4:PRINT LEFT$(windw$(1),1);LEFT$(windw$(2),1);"
Windows":PRINT
880 PEN 5:PRINT gem$;" Precious Gems":PRINT
890 PAPER 1:PEN 0:PRINT obj$;" Obstructions ":PEN 1:PA
PER 0:PRINT
900 PEN 1:PRINT dog$;" The Dog"
910 PEN 5:PRINT:PRINT:PRINT
920 PRINT" Use Joystick":PRINT"
Or Cursor keys"
930 dummy=REMAIN(1)
940 AFTER deLay*4,1 GOSUB 340
950 RETURN
960 '
970 'Generate Gems/obstacLes
980 '
990 FOR room=1 TO 5
1000 gemr=INT(RND*8)+2:objr=INT(RND*10)+5
1010 minx=minx(room):miny=miny(room):maxx=maxx(room):ma
xy=maxy(room)
1020 FOR i=1 TO gemr
1030 x=INT(RND*(maxx-minx+1+minx
1040 y=INT(RND*(maxy-miny+1+miny
1050 gemx(room,i)=x:gemy(room,i)=y
1060 gems=gems+1
1070 NEXT i
1080 FOR i=1 TO objr
1090 x=INT(RND*(maxx-minx+1+minx
1100 y=INT(RND*(maxy-miny+1+miny
1110 objx(room,i)=x:objy(room,i)=y
1120 NEXT i
1130 gems(room)=gemr:obj(room)=objr
1140 NEXT room
1150 CLS
continued on the next page

Some Programs for you ....

Appendix 3 Page 25

1160
1170
1180
1190
1200
1210
1220
1230
1240
1250
1260
1270
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530
1540
1550
1560
1570

RETURN
ON rm GOTO 1180,1190,1200,1210,1220
RESTORE 2670:RETURN
RESTORE 2740:RETURN
RESTORE 2810:RETURN
RESTORE 2880:RETURN
RESTORE 2960:RETURN
PAPER 0:READ rm$:PAPER 8
WINDOW #1,minx(rm)-1,maxx(rm)+1,miny(rm)-1,maxy(rm
)+1 :CLS #1
PEN 1:LOCATE 1,1:PRINT SPACE$(19);
LOCATE 1,1:PRINT "Room :";rm$;
IF Lights(rm) THEN INK 7,10:INK 8,10 ELSE INK 7,0:
INK 8,0
READ a$:IF a$="END" THEN RETURN
IF a$="D" THEN 2180
IF a$="W" THEN 2260
IF a$="L" THEN GRAPHICS PEN 1:GOTO 2340
IF a$="S" THEN 2420
IF a$="F" THEN GRAPHICS PEN 6:GOTO 2340
PRINT"***ERROR ***";
STOP
'
'DispLay gems/objects
'
PEN 6
FOR i=1 TO obj(rm)
LOCATE objx(rm,i),objy(rm,;)
PRINT obj$;
NEXT
PEN 5
FOR ;=1 TO gems(rm)
LOCATE gemx(rm,i),gemy(rm,;)
PRINT gem$;
NEXT
PEN 1:LOCATE xp,yp:PRINT man$;
RETURN
xf=0:yf=0:PEN 1
IF INKEY(0)<>-1 OR INKEY(72)<>-1 THEN yf=-1
IF INKEY(2)<>-1 OR INKEY(73)<>-1 THEN yf=1
IF INKEY(8)<>-1 OR INKEY(74)<>-1 THEN xf=-1
IF INKEY(1)<>-1 OR INKEY(75)<>-1 THEN xf=1
IF xf=0 AND yf=0 THEN 1630
LOCATE xp+xf,yp+yf:ht$=COPYCHR$(#0)
continued on the next page

Appendix 3 Page 26

Some Programs for you ....

1580
1590
1600
1610
1620
1630
1640
1650
1660
1670
1680
1690
1700
1710
1720
1730
1740
1750
1760
1770
1780
1790
1800
1810
1820
1830
1840
1850
1860
1870
1880
1890
1900
1910
1920
1930
1940
1950
1960
1970

IF ASC(ht$239 AND ASC(ht$)<246 THEN 1510


IF ht$<>" " THEN 1660
LOCATE xp,yp:PRINT " ";
PAPER 0:LOCATE 15,5:PRINT"
";:PAPER 8
xp=xp+xf:yp=yp+yf
LOCATE xp,yp:PRINT man$;
IF dog>0 THEN dog=dog MOD 2+1:IF dog=2 THEN 2550
GOTO 1510
hit=INSTR(hit$,ht$):char=ASC(MID$(hit$,hit,1
ON hit GOTO 1690,1690,1690,1690,1750,1750,1850,190
0,1970,2090,2650
GOTO 1600
IF hit>2 AND hit<5 THEN char=char-1
IF hit<3 THEN char=char+1
PEN 3:LOCATE xp+xf,yp+yf:PRINT CHR$(char);
Lights(rm)=Lights(rm) XOR 1
IF Lights(rm) THEN INK 7,10:INK 8,10 ELSE INK 7,0:
INK 8,0
GOTO 1510
IF xf<>0 AND yf<>0 THEN 1630
IF xf<0 THEN dir=4 ELSE IF xf>0 THEN dir=3
IF yf<0 THEN dir=1 ELSE IF yf>0 THEN dir=2
IF dir(rm,dir)=-1 THEN 1630 ELSE rm=dir<rm,dir)
IF dog>0 THEN GOSUB 310
IF dir=1 THEN xp=6:yp=maxy(rm)
IF dir=2 THEN xp=6:yp=miny(rm)
IF dir=3 THEN xp=minx(rm):yp=13
IF dir=4 THEN xp=maxx(rm):yp=13
RETURN
IF xp>5 AND xp<8 THEN 1880
IF xp<6 THEN dir=4 ELSE dir=3
GO TO 1780
IF yp>13 THEN dir=2 ELSE dir=1
GOTO 1780
PAPER 0:CLS:PEN 1
LOCATE 3,3:PRINT"You have escaped";
LOCATE 9,5:PRINT"with";
IF gems=stoLen THEN LOCATE 8,7:PRINT"ALL"; ELSE LO
CATE 9,7
PRINT USING" ##";stoLen;
PEN 5:LOCATE 9,9:PRINT"Gems";
dead=1:RETURN
LOCATE xp,yp:PRINT" ";:xp=xp+xf:yp=yp+yf
continued on the next page

Some Programs for you ....

Appendix 3 Page 27

1980
1990
2000
2010
2020
2030
2040
2050
2060

;=0
;=;+1
IF ;>gems(rm) THEN 1510
IF gemx(rm,;)<>xp OR gemy(rm,;)<>yp THEN 1990
IF ;=gems(rm) THEN 2050
gemx(rm,;)=gemx(rm,gems(rm
gemy(rm,;)=gemy(rm,gems(rm
gems(rm)=gems(rm)-1:stolen=stolen+1
MOVE 400,150+(stolen*2),1,1:DRAW 520,150+(stolen*2

2070
2080
2090
2100
2110
2120
2130
2140
2150
2160
2170
2180
2190
2200
2210
2220
2230
2240
2250
2260
2270
2280
2290
2300
2310
2320
2330
2340
2350
2360
2370
2380
2390
2400

SOUND 129,248,10,12,0,1
GOTO 1980
no;se=INT(RND*15)
SOUND 1,30~0,10,no;se,0,0,10
PAPER 0:LOCATE 15,5:PRINT"Crash ";:PAPER 8
IF no;se<10 OR delay=50 THEN 1630
delay=delay-50
dummy=REMAIN(1)
AFTER delay*4,1 GOSUB 310
GOTO 1630
'
'Draw doors
'
READ no,dr$
IF dr$=IV" THEN dr=2 ELSE dr=1
PEN 2
p;c$~door$(dr):GOSUB 2500
GOTO 1280
'
'Draw windows
'
READ no,w;$
IF W;$="V" THEN w;=2 ELSE w;=1
PEN 4
p;c$=w;ndw$(w;):GOSUB 2500
GOTO 1280
'
' Draw lines
'
READ x1,y1,x2,y2
MOVE x1,y1,,0
DRAW x1,y2,,0:DRAW x2,y2,,0
DRAW x2,y1,,0:DRAW x1,y1,,0
GOTO 1280

) ,1 ,1

continued on the next page

Appendix 3 Page 28

Some Programs for you ....

2410
2420
2430
2440
2450
2460
2470
2480
2490
2500
2510
2520
2530
2540
2550
2560
2570
2580
2590
2600
2610
2620
2630
2640
2650
2660
2670
2680
2690
2700
2710
2720
2730
2740
2750
2760
2770
2780
2790
2800
2810
2820
2830

'
'Draw switches
'
READ no,sw$
IF sw$="L" THEN sw=1 ELSE sw=2
PEN 3
pic$=switch$(sw,0):GOSUB 2500
GOTO 1280
'
'Pri nt char
'
READ x,y:LOCATE x,y:PRINT pic$;
no=no-1:IF no>0 THEN 2520
RETURN
PEN 1:LOCATE dogx,dogy:PRINT" ";
man$=CHR$(225)
IF (dogx=xp AND dogy=yp) OR (dogx=xp+xf AND dogy=y
p+yf) THEN 2650
IF dogx<xp THEN dogx=dogx+1
IF dogx>xp THEN dogx=dogx-1
IF dogy<yp THEN dogy=dogy+1
IF dogy>yp THEN dogy=dogy-1
LOCATE dogx,dogy:PRINT dog$;
SOUND 1,0,RND*40,10,1,2,31
GOTO 1510
PRINT"SNAP";
dead=1:RETURN
DATA HaLLway
DATA L,64,308,226,4
DATA D,2,H,6,3,6,22
DATA D,2,V,4,12,9,11
DATA S,1,L,4,11
DATA S,1,R,9,14
DATA END
DATA Lounge
DATA L,2,308,258,4
DATA D,1,V,10,12
DATA W,1,H,6,3
DATA W,1,V,2,12
DATA S,2,R,10,11,10,15
DATA END
DATA Dining room
DATA L,2,308,258,4
DATA W,1,V,10,12
continued on the next page

Some Programs for you ....

Appendix 3 Page 29

2840
2850
2860
2870
2880
2890
2900
2910
2920
2930
2940
2950
2960
2970
2980
2990
3000
3010
3020
3030
3040
3050
3060
3070
3080
3090
3100
3110
3120
3130
3140
3150
3160
3170

DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
,DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA

W,1,H,6,3
D,1,V,2,12
S,2,L,2,11,2,15
END
Kitchen
L,2,276,384,4
D,2,H,6,5,6,22
W,1,H,10,22
W,1,V,14,13
D,1,V,2,13
S,1,L,2,16
END
Pantry
L,2,276,256,4
D,1,V,10,12
S,1,R,10,11
END
5,4,8,21,0,4,3,2
3,4,9,21,-1,-1,1,-1
3,4,9,2i,-1,-1,-1,1
3,6,13,21,1,0,-1,5
3,6,9,21,-1,-1,4,-1
L,64,308,480,100
F,250,98,294,102
F,250,306,294,310
F,390,94,430,106
F,390,302,430,314
F,474,240,488,270
F,474,124,488,154
F,58,240,72,270
L,226,308,322,180
L,160,180,480,100
L,64,180,160,100
END

If you've enjoyed these games, you may like to join the


AMSTRAD COMPUTER USERS' CLUB. As well as
many other benefits and privileges, you get a free
monthly magazine which includes program listings for
games and 'utilities', special features, free competitions,
and up to the minute information -from the source!
Appendix 3 Page 30

Some Programs for you ....

Appendix 4
Index
(N ote that all references given in this index correspond to chapter
and page number, e.g. 1.44 refers to Chapter 1 page 44.)

.A
lA ................................................................................................. 1.44 1.75 5.8
ABS :................................................................................................................ 3.3
Aerial socket (TV) ........................................................................................... 1.3
AFTER ................................................................................................... 3.4 9.29
Amplifier (external) ..................................................................... 1.9 1.68 7.39
AMSDOS ............................................................................... 1.75 5.1 5.7 5.32
AMSDOSerrormessages ........................................................... 5.15 7.31 7.32
AND ....................................................................................................... 3.4 9.18
AND (LOGO) ................................................................................................ 6.16
Animation ..................................................................................................... 9.53
.APV ............................................................................................................... 6.43
ARCTAN ...................................................................................................... 6.13
Arithmetic operations .......................................... ...................... 1.33 7.27 7.28
Arithmetic operations (LOGO) .................................................................... 6.13
Arrays .................................................................................. 2.3 3.18 3.25 7.28
ASC .................................................................................................................. 3.5
ASCII ..................................................................................................... 7.8 7.21
ASCII characters ............................................................................ 7.8. 7.9 9.15
ASCII files ................................................. 1.45 3.71 5.4 5.11 5.13 5.14 7.29
ASCII (LOGO) ................................................................................................ 6.8
ASM .............................................................................................................. 5.37
ASSIGN.SYS .................................................................................................. 4.9
ATN ................................................................................................................ 3.5
AUTO ..................................................................................................... 2.10 3.5
AUX .............................................................................................................. 5.28

B
I B ..................................................................... ~ ........................... 1.44 1.75 5.8
Backup discs ................................................................................................. ,. 4.2
I BANK FIND ........................................................................................ 1.87 8.6
BANK MANAGER ....................................................................... 1.84 8.1 9.63
I BANKOPEN ....................................................................................... 1.86 8.4

Index

Appendix 4 Page 1

I BANKREAD ....................................................................................... 1.87 8.5


I BANKWRITE ..................................................................................... 1.87 8.4
BASIC .................................................................................... 1.22 3.1 7.32 9.7
BASIC files .......................................................................................... 1.45 3.71
BF .................................................................................................................... 6.8
BIN$ ................................................................................................................ 3.6
Binaryfiles ........................................................................ 1.46 3.71 5.13 5.14
Binarynumbers .............................................................................................. 9.9
Bit ................................................................................................................... 9.9
BK ................................................................................................................. 6.26
BL .................................................................................................................... 6.8
BOOTGEN .................................................................................................... 5.33
BORDER ......................................................................................... 1.49 3.6 7.6
BREAK ........................................................................................................... 3.6
BRIGHTNESS control .................................................................................... 1.4
BUTTONP .................................................................................................... 6.35
BYE ........................................................................................................ 6.7 6.38
Byte ................................................................................................................. 9.9

c
CALL .............................................................................................................. 3.7
CAPSLOCKkey ........................................................................................... 1.17
Cassette operation .................................... 1.7 1.76 4.11 5.12 5.13 5.14 5.35
CAT ........................................................................................................ 1.43 3.7
CAT (cassette) ............................................................................................... 4.11
CATCH ......................................................................................................... 6.40
CHAIN ............................................................................................................ 3.7
CHAIN (cassette) .......................................................................................... 4.12
CHAIN MERGE ............................................................................................. 3.8
CHAINMERGE(cassette) ........................................................................... 4.12
CHANGEF ................................................................................................... 6.33
CHAR .............................................................................................................. 6.8
Characters ......................................................... 1.55 7.9 7.43 7.52 7.54 9.14
Checksum ..................................................................................................... 9.32
CHR$ ............................................................................................ 1.55 3.8 9.16
CINT ............................................................................................................... 3.8
Circles ........................................................................................................... 1.60
CLEAN ......................................................................................................... 6.22
CLEAR ............................................................................................................ 3.9
CLEAR INPUT ............................................................................................... 3.9
CLG ................................................................................................................. 3.9
CLOAD ....................................................................................... 5.13 5.14 5.35

Appendix 4 Page 2

Index

CLOSEIN ............................................................................................. 2.10 3.10


CLOSEIN (cassette) ..................................................................................... 4.14
CLOSE OUT ........................................................................................... 2.9 3.10
CLOSEOUT (cassette) .................................................................................. 4.15
CLRkey ........................................................................................................ 1.18
CLS ............................................................................................... 1.22 3.10 7.4
CO ................................................................................................................. 6.38
Colours ........................................................................................ 1.48 1.54 5.24
CON .............................................................................................................. 5.28
Configuration sector ............................................................................ 5.35 5.36
Configuringprograms/packages ............................................................. 4.6 4.7
Connecting a mains plug ................................................................................ 1.1
Connecting up the computer ........................................................................... 1.2
Connecting peripherals .............................................. 1.7 7.38 7.39 7.40 7.41
CONT ................................................................................................... 3.10 7.29
.CONTENTS ................................................................................................. 6.42
CONTRAST control ........................................................................................ 1.4
Control characters ................................................................................. 7.3 9.51
Control codes ........................................: ........................ 5.19 7.1 7.3 7.49 9.51
Copy cursor editing ....................................................................................... 1.28
COPYCHR$ .................................................................................................. 3.11
Copying discs ................................................................................................ 1.77
Copying files ............................................................. 1.45 1.77 5.11 5.13 5.14
COpy key ............ :........................................................................................ 1.28
COPYON ...................................................................................................... 6.20
COPYOFF .................................................................................................... 6.20
COS ............................................................................................................... 3.11
COS (LOGO) ................................................................................................. 6.13
COUNT ........................................................................................................... 6.9,
CP/M ............................................................................................................. 5.17
CP/M2.2 ................................................................... 1.82 4.10 5.31 5.33 6.2
I CPM ..................................................................................................... 1.39 5.9
CREAL .......................................................................................................... 3.11
CRT ............................................................................................................... 5.28
CS .................................................................................................................. 6.22
CSAVE ........................................................................................ 5.13 5.14 5.35
CT .................................................................................................................. 6.20
Cube root ....................................................................................................... 1.35
CURSOR ................................................................................................ 3.12 7.3
CURSOR (LOGO) ......................................................................................... 6.20
Cursor keys ............................................................................................ 1.15 6.6

Index

Appendix 4 Page 3

D
DATA .......................................................................................... 3.12 7.27 9.31
Data only format ......................................................................... 1.41 5.33 7.45
DATE ............................................................................................................ 5.31
Date/time stamping ...................................................................................... 5.31
DC sockets ................................................................................................ 1.2 1.3
DDT ............................................................................................................... 5.37
DEC$ ............................................................................................................. 3.13
.DEF .............................................................................................................. 6.43
DEFAULTD ................................................................................................. 6.33
DEFFN ................................................................................................ 3.13 7.29
DEFINE ........................................................................................................ 6.18
DEFINT ........................................................................................................ 3.14
DEFREAL ..................................................................................................... 3.14
DEFSTR ........................................................................................................ 3.15
DEG .............................................................................................................. 3.15
DELkey ........................................................................................................ 1.16
DELETE ....................................................................................................... 3.16
.DEPOSIT ..................................................................................................... 6.42
DERR ................................................................................. 3.16 7.30 7.31 7.32
DEVICE ............................................................................................... 5.27 5.28
DI ......................................................................................................... 3.17 9.30
DIM ............................................................................................... 2.3 3.18 7.28
I DIR ............................................................................................................... 5.9
DIR(CPIM) ................................................................................. 1.40 5.21 5.29
DIR (LOGO) .................................................................................................. 6.33
DIRPIC ......................................................................................................... 6.34
DIRS .............................................................................................................. 5.21
DIRSYS ......................................................................................................... 5.21
I DISC .................................................................................................... 1.76 5.9
Discdrive(additional) ................................ 1.8 1.14 1.40 1.42 1.80 5.4 7.40
DISC DRIVE 2 socket ........................................................................... 1.9 7.40
I DISC.IN ............................................................................................... 1.76 5.9
DISCKIT2 ......................................................................................... 1.82 5.35
DISCKIT3 ................................................................................ 1.40 1.77 5.23
Disc organisation .......................................................................................... 7.44
I DISC.OUT ........................................................................................... 1.76 5.9
Discs .............................................................................................. 1.11 1.38 4.1
DOT ............................................................................................................... 6.22
DOTC ............................................................................................................ 6.22
Dottedlines .......................................................................................... 3.43 9.49
DRAW .................................................................................................. 1.58 3.19
DRAWR ........................................................................................................ 3.19
I DRIVE ........................................................................................................ 5.10
DRIVERS.GSX ............................................................................................... 4.9
Dr. LOGO ........................................................................................................ 6.2
DUMP ................................................. ;......................................................... 5.37
Appendix 4 Page 4

Index

E
ED ................................................................................................................. 5.37
ED (LOGO) ................................................................................................... 6.19
EDALL .......................................................................................................... 6.19
EDF ............................................................................................................... 6.20
EDIT .................................................................................................... 1.27 3.20
Editing ................................................................................................ ;......... 1.27
Editing (LOGO) ..................................................................................... 6.6 6.19
El .......................................................................................................... 3.20 9.30
EJECT button ............................................................................................... 1.14
ELSE .................................................................................................... 1.29 3.20
EMPTYP .......................................................................................................... 6.9
.EMT ............................................................................................................. 6.43
END ............................................................................................................... 3.21
END (LOGO) ............................................................................. ~ ................... 6.18
.ENL .............................................................................................................. 6.43
ENT ............................................................................................. 1.72 3.21 9.41
ENT (LOGO) .................................................................................................. 6.38
ENTER key ................................................................................................... 1.16
ENV ............................................................................................ 1.70 3.23 9.38
ENV (LOGO) ................................................................................................ 6.37
Envelope planner .......................................................................................... 7.37
EOF ...................................................................................... 3.25 4.14 5.8 7.29
EOF (CP/M) .................................................................................................. 5.28
ER ................................................................................................................. 6.30
ERA ............................................................................................................... 5.21
I ERA ............................................................................................................ 5.10
ERALL .......................................................................................................... 6.30
ERASE .......................................................................................................... 3.25
ERASE (CP/M) ......... ;.......................................................................... 5.21 5.29
ERL ............................................................................................................... 3.25
ERN .............................................................................................................. 6.30
ERR ...................................................................................................... 3.26 7.32
ERRACT ....................................................................................................... 6.42
ERROR ......................................................................................................... 3.26
ERROR(LOGO) ............................................................................................ 6.40
Error messages ............................................................................................. 7.27
Errormessages(AMSDOS) ........................................................ 5.15 7.31 7.32
Errornumbers .............................................................................................. 7.27
ESC key ................................................................................................ 1.18 3.49
EVERY ................................................................................................ 3.27 9.29
.EXAMINE ................................................................................................... 6.42
EXP ............................................................................................................... 3.27
Expansion characters .......................................................................... 3.37 7.22
EXPANSION socket ............................................................................ 1.10 7.40
Exponentiation .................................................................................... 1.35 1.37
Externalcommands ............................................................. 1.90 4.17 7.30 8.7
Index

Appendix 4 Page 5

F
FALSE .......................................................................................................... 6.42
FD ................................................................................................................. 6.26
FENCE ......................................................................................................... 6.23
FILECOPY .......................................................................................... 4.10 5.34
FILL ............................................................................................ 1.62 3.27 9.48
FILL (LOGO) ................................................................................................ 6.23
FIRST .............................................................................................................. 6.9
FIX ................................................................................................................ 3.28
Flashingcolours .................................................................................. 1.52 3.75
Floppydiscs .......................................................................................... 1.11 1.38
Flush sound channels .......................................................................... 3.73 9.38
FN ................................................................................................................. 3.28
FOR ........................................................................... 1.30 3.28 7.27 7.30 9.16
Format (print) ...................................................................................... 3.61 9.22
Format (disc) ............................................................. 1.38 1.40 1. 79 5.33 7.44
FPUT .............................................................................................................. 6.9
FRAME ................................................................................................ 1.57 3.29
FRE ............................................................................................................... 3.29
FS .................................................................................................................. 6.24

G
GENGRAF ...................................................................................................... 4.9
GLIST ........................................................................................................... 6.32
GO ................................................................................................................. 6.39
GOSUB ....................................................................................... 1.31 3.30 7.27
GOTO ................................................................................................... 1.24 3.30
Graphics ............................................................................. 1.47 1.55 9.47 9.56
GRAPHICS PAPER ............................................................................ 3.30 9.50
GRAPHICS PEN ........................................................................ 1.64 3.31 9.48
GPROP .......................................................................................................... 6.32
GSX ................................................................................................................. 4.9

B
Hardware ............................................................................................... 7.46 8.1
Headphones ........................................................................................... 1.9 1.68
HELP .................................. '............................................................................ 4.3
HEX$ ............................................................................................................ 3.31
Hexadecimalnumbers .................................................................................. 9.11
HIMEM ................................................................................................ 3.32 7.46
Holdsoundchannels ............................................................................ 3.73 9.38
HOME ........................................................................................................... 6.26
HT ................................................................................................................. 6.27
Appendix 4 Page 6

Index

I
IBM format .......................................................................................... 5.33 7.45
IF .......................................................................................................... 1.28 3.32
IF (LOGO) ..................................................................................................... 6.39
.IN ................................................................................................................. 6.42
Indicator lamp (disc) .................................................................................... , 1.14
INK ............................................................................................... 1.50 3.33 7.6
INKEY ................................................................................................. 3.33 7.43
INKEY$ ...................................................................................... 2.12 3.34 7.43
Inkmodes ............................................................................................... 7.5 9.52
INP ................................................................................................................ 3.34
INPUT ...................................................................... ........... 1.25 2'.2 3.35 7.28
INPUT (cassette) .......................................................................................... 4.14
Inserting discs ....................... ,................. ,....... ,.. ... .. ... ....... .. ... .... ... ........... .. ... 1.11
INSTR .................................................................................................... 2.5 3.36
INT ................................................................................................................ 3.36
INT (LOGO) .................................................................................................. 6.13
Interrupts .............................................................................................. 7.7 9.29
I/O ........................................................................................................ 7.38 7.47
ITEM ............................................................................................................ , 6.10

J
JOY ...................................................................................................... 3.37
Joystick commands (LOGO) ........................................................................ ,
Joysticks .......... .......................... .......... ........ ............ ............ 1. 7 7.21 7.23
JOYSTICK socket ................................................................................. 1.7

7.43
6.35
7.43
7.38

KEY .................................................................................. " ................. 3.37


KEY DEF ................................................................................... , 3.38 7.22
Keyboard ........................................................ , 1.15 5.25 7.21 7.22 7.23
KEYP ............................................................................................................
KEYS.CCP ............................................................................................ 4.3
KEYS.DRL ...................................................................................................
KEYS.WP .....................................................................................................
Keywords ................................................................................... ,.. 1.22 3.1

7.22
7.43
7.43
6.36
5.25
5.25
5.25
7.32

L
LABEL .......................................................................................................... 6.39
LANGUAGE ........ .' ....................................................................... 4.3 5.24 7.53

Index

Appendix 4 Page 7

LAST ............................................................................................................. 6.10


LC .................................................................................................................. 6.10
LEFT$ ........................................................................................................... 3.39
LEN ........................................................................................................ 2.8 3.39
LET ............................................................................................................... 3.39
LINE INPUT ................................................................................................ 3.40
LINE INPUT (cassette) ................................................................................ 4.14
LIST ............................................................................................ 1.23 1.54 3.40
LIST (LOGO) ................................................................................................ 6.10
LISTP ............................................................................................................ 6.10
LOAD ................................................................................................... 1.44 3.41
LOAD (cassette) ............................................................................................ 4.12
LOAD (CP/M) ............................................................................................... 5.37
LOAD (LOGO) .............................................................................................. 6.34
Loadingsoftware .......................................................................................... 1.20
Loading the Welcome program ..................................................................... 1.21
LOADPIC ..................................................................................................... 6.34
LOCAL .......................................................................................................... 6.17
LOCATE ....................................................................................... 1.55 3.41 7.6
LOG ............................................................................................................... 3.42
LOG10 ........................................................................................................ 3.42
Logic ............................................................................ 3.4 3.48 3.54 3.91 9.18
Logical operations (LOGO) ........................................................................... 6.16
LOGO .............................................................................................................. 6.1
LPT ............................................................................................................... 5.28
LPUT ............................................................................................................ 6.11
LST ................................................................................................................ 5.28
LT .................................................................................................................. 6.27
LOWER$ ....................................................................................................... 3.42

M
Machine code .................................................................................................. 7.7
Mains plug connections .................................................................................. 1.1
MAKE ........................................................................................................... 6.17
MASK .................................................................................................. 3.43 9.49
MAX .............................................................................................................. 3.43
MEMBERP ................................................................................................... 6.11
MEMORy ................................................................................... 3.44 7.27 7.46
Memory (machine) ........................................................ 1.84 7.46 8.1 8.2 9.56
Menu ............................................................................................. 2.5 3.51 3.52
MERGE ......................................................................................................... 3.44
MERGE (cassette) ........................................................................................ 4.12

Appendix 4 Page 8

Index

MID$ .................................................................................................... 3.44 3.45


MIN ............................................................................................................... 3.45
MOD ..................................................................................................... 1.34 3.46
MODE ........................................................................................... 1.47 3.46 7.3
Modulator/power supply (MP2) ............................................. 1.3 1.5 1.48 1.68
Monitor ........................................................................................................... 1.2
MONITOR socket ........................................................................... 1.2 1.3 7.39
MOVCPM ..................................................................................................... 5.37
MOVE .................................................................................................. 1.59 3.47
MOVER ........................................................................................................ 3.47
Musical notes ................................................................................................ 7.24
Music planner ............................................................................................... 7.37

N
NAMEP ........................................................................................................
NEW .............................................................................................................
NEXT ............................................................... 1.30 1.61 3.48 7.27 7.30
NODES .................................................................................................. 6.6
NOFORMAT ................................................................................................
NOT ..................................................................................................... 3.48
NOT (LOGO) .................................................................................................
NOTRACE ....................................................................................................
NOWATCH ..................................................................................................
NUMBERP ...................................................................................................

6.17
3.48
9.16
6.30
6.31
9.20
6.16
6.41
6.41
6.11

o
ONBREAKCONT ....................................................................................... 3.49
ONBREAKGOSUB ..................................................................................... 3.49
ONBREAKSTOP ........................................................................................ 3.50
ONERRORGOTO ...................................................................... 3.50 7.29 7.32
ON GOSUB ............................................................................................ 2.6 3.51
ON GOTO ..................................................................................................... 3.52
ON indicator .......................................... ............. ............... .......... ............ 1.4 1.5
ONSQGOSUB ............................................................................. 3.52 7.7 9.44
OP ................................................................................................................. 6.39
OPENIN ............................................................................. 2.10 3.53 7.29 7.30
OPENIN (cassette) ....................................................................................... 4.14
OPENOUT ..... ;.............................................................................. 2.9 3.53 7.30
OPENOUT(cassette) ................................................................................... 4.15
Operators ............................................................................................. 1.33 9.18
OR ........................................................................................................ 3.54 9.19

Index

Appendix 4 Page 9

OR (LOGO) ...................................................................................................
ORIGIN ................................................................................................ 1.61
OUT ..............................................................................................................
OUT (LOGO) ................................................................................................

6.16
3.54
3.55
6.42

p
PADDLE ........................................................................................................ 6.36
PAL ............................................................................................................... 6.24
PALETTE ..................................................................................................... 5.24
PAPER .......................................................................................... 1.49 3.55 7.4
Passwords ..................................................................................................... 5.31
PAUSE ..................... ,.................................................................................... 6.41
PD ................................................................................................................. 6.27
PE .................................................................................................................. 6.27
PEEK ............................................................................................................ 3.56
PEN ............................................................................................... 1.49 3.56 7.4
Peripherals .............................................................................................. 1.7 9.3
PI ................................................................................................................... 3.57
PIECE ........................................................................................................... 6.11
PIP ......................................................................................................... 4.4 5.28
Planners ............................................................................. 7.34 7.35 7.36 7.37
PLIST ............................................................................................................ 6.32
PLOT .................................................................................................... 1.58 3.57
PLOTR .......................................................................................................... 3.58
PO ................................................................................................................. 6.18
POALL .......................................................................................................... 6.31
POKE ............................................................................................................ 3.58
PONS ............................................................................................................ 6.31
POPS ............................................................................................................. 6.31
POS ...................................................................................................... 3.59 4.14
POTS ............................................................................................................. 6.19
POWERswitch ........................................................................................ 1.4 1.5
PPROP .......................................................................................................... 6.32
PPS ................................................................................................................ 6.32
PR .................................................................................................................. 6.21
PRINT ......................................................................................... 1.22 3.59 9.22
Print formatting .................................................................................. 3.61 9.22
PRINTSPC .......................................................................................... 3.60 9.23
PRINTTAB ......................................................................................... 3.60 9.23
PRINT USING ..................................................................................... 3:61 9.23
PRINTER socket .................................................................................... 1.8 7.41
Printers ....................................................................... 1.8 5.26 7.41 7.42 7.43
.PRM ............................................................................................................. 6.43

Appendix 4 Page 10

Index

PRN ...............................................................................................................
PROFILE ............................................................................................... 4.3
Protected files ...................................................................................... 1.45
PU .................................................................................................................
PX .................................................................................................................

5.28
5.18
3.71
6.27
6.28

Q
Queue(sound) ...................................................................... 3.52 3.77 7.7 9.44
QUOTIENT .................................................................................................. 6.13

R
RAD .............................................................................................................. 3.64
RAMdisc ................................................................................................ 1.86 8.4
RANDOM ..................................................................................................... 6.14
Random access ....................................................................................... 5.17 8.4
RANDOMIZE ............................................................................................... 3.64
Randomnumbers .......................................................................................... 3.69
RC ................................................................................................................. 6.36
READ ................................................................................. 3.64 7.27 7.28 9.31
Read errors (cassette) ................................................................................ ~ .. 4.12
Read/Onlyfiles .................................................................. 5.12 5.30 5.34 7.31
RECYCLE ............................................................................................. 6.7 6.31
REDEFP ....................................................................................................... 6.43
RELEASE ............................................................................................ 3.65 9.43
RELEASE (LOGO) ....................................................................................... 6.38
REM .............................................................................................. 1.30 2.2 3.65
.REM ............................................................................................................. 6.43
REMAIN .............................................................................................. 3.66 9.30
REMAINDER ............................................................................................... 6.14
REMPROP .................................................................................................... 6.33
REN .......................................................................................................... ,... 5.22
IREN ............................................................................................................ 5.10
RENAME ............................................................................................. 5.22 5.30
Rendezvous sound channels ................................................................ 3.73 9.37
RENUM ................................................................................................. 2.7 3.66
REPEAT ....................................................................................................... 6.39
RERANDOM ................................................................................................ 6.14
Resettingthecomputer ....................................................................... 1.20 1.21
RESTORE ............................................................................................ 3.67 9.33
RESUME .............................................................................................. 3.67 7.29
RESUME NEXT ........................................................................................... 3.68
RETURN .................................................................................... 1.31 3.68 7.27

Index

Appendix 4 Page 11

RETURN key ....................................................................................... 1.15 1.18


RIGHT$ ................................................................ :....................................... 3.69
RL .................................................................................................................. 6.37
RND .............................................................................................................. 3.69
RQ ................................................................................................................. 6.37
ROINTIME.DEM program ....................................................................... '" 1.20
ROUND ........................................................................................................ 3.70
ROUND(LOGO) ........................................................................................... 6.14
RS232 .................................................................................................. 5.27 9.3
RSX ............................................................................................................... 7.45
RT .................................................................................................................. 6.28
RUN ............................................................................................ 1.23 1.44 3.70
RUN (cassette) .............................................................................................. 4.12
RUN (LOGO) ................................................................................................ 6.40
Running the Welcome program .................................................................... 1.21

s
SAVE .......................................................................................... 1.43 1.45 3.71
SAVE (cassette) ............................................................................................ 4.16
SAVE (LOGO) .............................................................................................. 6.34
Savingtocassette ......................................................................................... 4.16
Saving variables ............................................................................. 2.9 3.90 5.6
SAVEPIC ...................................................................................................... 6.35
Screen Designer program ............................................................................. 9.56
Screen dump ................................................................................. 1.46 3.71 5.6
I SCREENCOPY .......................................................................... 1.85 8.3 9.63
I SCREENSWAP ......................................................................... 1.85 8.3 9.63
SE .................................................................................................................. 6.12
Serial interface ...................................................................................... 5.27 9:3
SET ............................................................................................................... 5.30
SET24X80 ......................................................................................... 5.26 5.27
SETBG .......................................................................................................... 6.24
SETCURSOR ................................................................................................ 6.21
SETD ............................................................................................................. 6.35
SETDEF ........................................................................................................ 5.32
SETH ............................................................................................................ 6.28
SETLST ........................................................................................................ 5.26
SETKEYS .............................................................................................. 4.3 5.25
SETPAL ........................................................................................................ 6.24
SETPC .......................................................................................................... 6.28
SETPOS ........................................................................................................ 6.28
SETSCRUNCH ............................................................................................ 6.25
SETSIO ......................................................................................................... 5.27

Appendix 4 Page 12

Index

SETSPLIT ..................................................................................................... 6.21


Settingup ........................................................................................................ 1.1
SETUP .......................................................................................................... 5.35
SETX ......................................................................................................... , ... 6.29
SETY ............................................................................................................. 6.29
SF .................................................................................................................. 6.25
SGN ............................................................................................................... 3.72
SHIFT keys ................................................................................................... 1.16
SHOW (CP/M) ............................................................................................... 5.32
SHOW (LOGO) ............................................................................................. 6.21
SHUFFLE ..................................................................................................... 6.12
SidewaysROMS ........................................................................................... 7.48
SIN ................................................................................................................ 3.72
SIN (LOGO) .................................................................................................. 6.15
SIO ................................................................................................................ 5.28
Software ............................................................................. 1.20 1.21 7.53 7.54
SOUND .............................................................................. 1.68 3.73 7.24 9.35
SOUND (LOGO) ........................................................................................... 6.37
Sound commands (LOGO) ............................................................................ 6.37
Sound envelope planner ............................................................................... 7.37
SPACES ........................................................................................................ 3.75
SPC ...................................................................................................... 3.75 9.23
Speakers (external) ............................................................................... 1.9 1.68
Speechsynthesiser ................................................................................ 1.10 9.3
SPEED INK .................................................................................................. 3.75
SPEEDKEY ................................................................................................. 3.76
SPEEDWRITE .................................................................................... 3.76 4.17
Sprites ........................................................................................................... 9.54
SQ ......................................................................................................... 3.77 9.45
SQR ...................................................................................................... 1.34 3.77
Square root ........................................................................................... 1.34 3.77
SS .................................................................................................................. 6.25
ST ........................................................... :...................................................... 6.29
STAT ............................................................................................................. 5.34
STEP .................................................................................................... 1.30 3.78
Stereo ..................................................................................................... 1.9 1.68
STEREO socket ............................................................................ 1.9 1.68 7.39
STOP ............................................................................................................. 3.78
STOP (LOGO), ............................................................................................... 6.40
Storage space (disc) ..................................................................... 1.38 1.39 1.44
STR$ ............................................................................................................. 3.78
STRING$ ...................................................................................................... 3.79
String variables ................................................................................... 1.26 7.28
SUBMIT ................................................................................................. 4.8 5.32
SWAP ............................................................................................................ 3.79

Index

Appendix 4 Page 13

Switching on ............................................................................................ 1.4 1.5


SYMBOL ...................................................................................... 3.79 7.5 9.21
SYMBOL AFTER ................................................................................ 3.81 7.46
Syntax error ......................................................................................... 1.19 7.27
SYSGEN ....................................................................................................... 5.33
System format ............................................................................. 1.42 5.33 7.44

T
TAB ...................................................................................................... 3.82 9.23
TAG ...................................................................................................... 3.82 9.50
TAGOFF .............................................................................................. 3.83 9.50
TAN .............................................................................................................. 3.83
I TAPE ................................................................................................. 1.76 5.10
I TAPE.IN ........................................................................................... 1.76 5.11
I TAPE.OUT ........................................................................................ 1.76 5.11
TAPE socket .......................................................................................... 1.7 7.39
Terminalemulator ................................................................................ 4.5 7.48
TEST ............................................................................................................. 3.84
TESTR .......................................................................................................... 3.84
TEXT ............................................................................................................ 6.19
Text/window planners ................................................................ 7.34 7.35 7.36
TF .................................................................................................................. 6.29
THEN ................................................................................................... 1.28 3.84
THING .......................................................................................................... 6.18
THROW ........................................................................................................ 6.41
TIME ............................................................................................................. 3.85
TO ................................................................................................................. 3.85
TO (LOGO) .................................................................................................... 6.19
Tone envelope ............................................................................. 1.72 8.21 9.41
TOPLEVEL .................................................................................................. 6.43
TOWARDS ................................................................................................... 6.30
TRACE .......................................................................................................... 6.41
Transparent writing .............................................................................. 7.5 9.51
TROFF .......................................................................................................... 3.86
TRON ............................................................................................................ 3.86
TRUE ............................................................................................................ 6.43
TS .................................................................................................................. 6.21
Turnkey discs/packages .......................................................................... 4.5 4.8
TV receiver ..................................................................................... 1.3 1.5 1.68
TYP ............................................................................................................... 5.22
TYPE (CP/M) ....................................................................................... 5.22 5.30
TYPE (LOGO) ............................................................................................... 6.22

Appendix 4 Page 14

Index

u
UC .................................................................................................................
Unnamed file .............................................................................. 4.12 4.15
UNT ..............................................................................................................
UPPERS ........................................................................................................
USE ...............................................................................................................
USER ............................................................................................................
I USER ..........................................................................................................
User defined characters .............................................................. 3.79 7.46
Userdefinedkeys ............................................................... 3.37 7.21 7.22
USING ............................................ ,.................................................... 3.87

6.12
4.16
3.86
3.86
5.22
5.22
5.11
9.21
7.23
9.23

v
VAL ............................................................................................................... 3.87
Variables .................................................................................... 1.25 7.32 9.15
Variables (saving) .......................................................................... 2.9 3.90 5.6
VDU'emulator ............ ,.......................................................................... 4.5 7.48
Vendor format ............................................................................. 1.41 5.33 7.44
Verifying discs .............................................................................................. 1.81
Vertical hold control .......................................................................... .............. 1.4
Vibrato .......................................................................................................... 9.42
VOLUME control .................................................................................. 1.9 1.68
Volume envelope ........................................................................ 1.70 3.23 9.38
VPOS ............................................................................................................ 3.87

w
WAIT ............................................................................................................ 3.88
WAIT (LOGO) ............................................................................................... 6.40
Wake-up message .................................................................................... 1.4 1.5
WATCH ........................................................................................................ 6.41
Welcome program ......................................................................................... 1.21
WEND .................................................................................................. 3.88 7.30
WHERE ........................................................................................................ 6.12
WHILE ........................................................................................ 3.88 7.27 7.30
WIDTH ......................................................................................................... 3.89
Wild cards ....................................................................................................... 5.5
WINDOW ............................................................................ 2.11 3.89 7.5 9.26
WINDOW (LOGO) ........................................................................................ 6.25
Window planners ........................................................................ 7.34 7.35 7.36
WINDOW SWAP ................................................................................. 3.90 9.27

Index

Appendix 4 Page 15

WORD ...........................................................................................................
WORDP ........................................................................................................
WRAP ...........................................................................................................
WRITE .......................................................................................... 2.9 3.90
WRITE (cassette) ..........................................................................................
Write protection ................................................................................... 1.12

6.12
6.13
6.26
9.23
4.15
1.80

x
XOR ..................................................................................................... 3.91 9.20
XPOS ............................................................................................................ 3.92
XSUB ............ :............................................................................................... 5.37

y
YPOS ............................................................................................................ 3.92

z
ZONE ................................................................................................... 3.92 9.22

Appendix 4 Page 16

Index

0
0
0
0
()

0
C
0

t .
I

iI

I
II

o
o
o

I .

l)

o
o
JAABPCA01D

You might also like