AmstradCPC6128 Hypertext en Sinewalker
AmstradCPC6128 Hypertext en Sinewalker
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
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
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.
- - - .-- - - - - - - - - -
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.
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.
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.
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 ....
----~~----~
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.
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:
Chapter 1 Page 1
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
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
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:
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
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
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.
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
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':
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:
- - - ---
Shutter
OPEN
I
I
I
----------- ---A-----_________ _
I
I
I
Shutter
CLOSED
Write Protection ON
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
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
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.
-
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 [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]
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:
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
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:
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
Chapter 1 Page 21
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
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]
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:
--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]
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
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;
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:
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).
Chapter 1 Page 26
Foundation Course
If your name were Fred and your age 18, on the screen you will see:
1
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
- --
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]
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
.... 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]
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.
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 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:
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:
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]
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
27
Type:
?8
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]
(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
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
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]
Foundation Course
Chapter 1 Page 37
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.
.
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
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
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:
If you have connected an additional disc drive to the system, the message will say:
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
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.
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.
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
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.
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]
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]
Chapter 1 Page 44
Foundation Course
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
[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
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.
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
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
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]
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
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]
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]
.... which changes the colour of all the previous characters typed in with PEN
number 1.
Type in:
c Ls [RETURN]
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.
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
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:
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
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.
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
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
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:
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
Chapter 1 Page 64
Foundation Course
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)
Foundation Course
Chapter 1 Page 65
10
20
30
40
50
60
70
80
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
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>.
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.
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
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.
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.
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
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
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
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.
Foundation Course
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:
Foundation Course
Chapter 1 Page 77
If you have connected an additional disc drive to the system, the message will say:
Copy
Format
Verify
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
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:
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.
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
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
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.
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
Chapter 1 Page 84
Foundation Course
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:
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.
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
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
d$=STRING$(UI,"X")
IBANKOPEN,2~
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 .
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.
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:
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:
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:
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
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
Chapter 2 Page 6
Beyond Foundations
RENUM
LI ST
You should now see:
10
20
30
40
50
60
70
80
90
Beyond Foundations
Chapter 2 Page 7
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:
Beyond Foundations
Chapter 2 Page 9
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.
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
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"
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:
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:
Beyond Foundations
Chapter 2 Page 13
440
450
460
470
480
490
500
510
520
530
540
550
560
run
Chapter 2 Page 14
Beyond Foundations
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
.... 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>
HH'J
.... requires that brackets be typed around the <numeric expression> of which the
COSine is required, e.g:
PRINT COS(4S)
Chapter 3 Page 1
.... 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
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
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
Chapter 3 Page 3
AFTER
AFT E R <timer delay>[, <timer number>] GO SUB <line number>
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
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
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
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>]
BREAK
(See ON BREAK CONT, ON BREAK GOSUB, ON BREAK STOP)
Chapter 3 Page 6
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
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> )
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
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
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
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
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
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
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
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
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
.... which deletes the whole program.
Associated keywords: CH A I N MER GE. RE NUM
DERR
DERR
LOAD "xyz.abc"
Chapter 3 Page 16
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
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
DRAW
DRAW <x co-ordinate> , <y co-ordinate> [ , [<ink>][, <ink mode> ]]
DRAWR
DRAW R <x offset> , <y offset> [ , [<ink>][, <ink mode>]]
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.
ELSE
(See I F)
Chapter 3 Page 20
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>
Chapter 3 Page 21
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
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>
Chapter 3 Page 23
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
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
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>
Chapter 3 Page 26
EVERY
EVE RY <time period>[, <timer number>] GO SUB <line number>
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>]
Chapter 3 Page 28
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
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
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
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 ....
Chapter 3 Page 32
INK
INK <ink> , <colour> [, <colour>]
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 .... '.
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
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
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:
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
JOY
JOY ( <integer expression> )
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>
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.]]]
Chapter 3 Page 38
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
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
.... 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
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> )
!'
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
MASK
MASK [<integer expression>][, <first point setting>]
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
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
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
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>
Chapter 3 Page 46
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>]]
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>
PRINT NOT 0
-1
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
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
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
ON <expression> GOSUB
ON <selector> GO SUB <list of: <line number>
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
Chapter 3 Page 51
ON <expression> GOTO
ON <selector> GOT 0 <list of: <line number>
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
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
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>
OPENOUT
OPE N0 UT <filename>
Chapter 3 Page 53
OR
<argument> 0 R <argument>
"aLan"<"bob" OR "dog">"cat" THEN PRINT "correct" ELSE PRINT "wrong"
correct
IF
OR
PRINT 0 OR 0
0
PRINT
OR 0
1
ORIGIN
OR I GIN <x>, <y>[, <left>, <right>, <top>, <bottom>]
Chapter 3 Page 54
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
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
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>]
Chapter 3 Page 56
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
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
Chapter 3 Page 57
PLOTR
PLO T R <x offset> , <y offset> [ , [dnk>][, <ink mode> ]]
POKE
PO KE <address expression> , <integer expression>
Chapter 3 Page 58
POS
PO S ( # <stream expression> )
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).
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>]
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
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:
(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: # # # # # # , # #
**
(Specifies two digit positions.) Specifies that any leading spaces be replaced
by asterisks.
Example template: **######,. ##
Chapter 3 Page 61
**
$$
**$
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:
Chapter 3 Page 62
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: \
\
&
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
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
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>
Chapter 3 Page 65
REMAIN
REM A I N ( <timer number> )
10
20
30
40
50
60
70
80
run
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
RESTORE
RE SI 0 RE [<line number>]
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.
RETURN
RETURN
Chapter 3 Page 68
RIGHT$
RIG H-T $ ( <string expression> , <required length> )
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
Chapter 3 Page 69
ROUND
R0 UND ( <numeric expression, [ , <decimals,])
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
SAVE
SAV E dilename>[, diletype>][, <binary parameters>]
SAVE "discfiLe.xyz",P
.... saves the file in Protected BASIC mode.
SAVE "discfiLe.xyz",A
.... saves the file in ASCII mode.
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
Chapter 3 Page 71
SGN
S GN ( <numeric expression> )
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
SOUND
SOU ND <channel status> , <tone period>[, <duration> [, <volume>
[, <volume envelope> [ , <tone envelope> [ , <noise period> ]]]]]
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).
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 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
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
Chapter 3 Page 75
SPEED KEY
SP EED KEY <start delay> , <repeat period>
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:
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
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
.... 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
Chapter 3 Page 77
STEP
(See FOR)
STOP
STOP
STR$
S T R$ ( <numeric expression> )
Chapter 3 Page 78
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.
SWAP
(See WIN D0 W S WAP)
SYMBOL
S YMB0 L <character number> , <list of: <row>
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)
SYMBOL 255,1,3,7,15,31,63,0,0
Chapter 3 Page 80
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.
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>]
Chapter 3 Page 82
TAGOrr
TAG 0 F FI # <stream expression> I
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
Chapter 3 Page 83
TEST
T EST ( <x co-ordinate> , <y co-ordinate> )
10 CLS
20 PRINT
30 PRINT
40 PRINT
50 PRINT
run
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> )
THEN
(See I F)
Chapter 3 Page 84
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)
Chapter 3 Page 85
TRorr
TRON
TROFF
TRON
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> )
Chapter 3 Page 86
USING
(See P RI NT USIN G)
VAL
VA L ( <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> )
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,
Chapter 3 Page 88
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>
Chapter 3 Page 89
WINDOW SWAP
WIN D0 W SW AP <stream expression> , <stream expression>
WRITE
WR I T E [# <stream expression> ,][ <write list>]
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:)
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
XOR
PRINT 0 XOR 0
0
XOR 0
Chapter 3 Page 91
XPOS
XPOS
YPOS
YPOS
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
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:
**
*'*
**
**
**
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.
Chapter 4 Page 1
Chapter 4 Page 2
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.
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.
IS
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.
Chapter 4 Page 5
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
Chapter 4 Page 6
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.
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.
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
Chapter 4 Page 8
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
.... 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
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
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:
&
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.
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
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.
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
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:
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.
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
Broken in
Ifthe file does not successfully load, read the paragraph entitled 'Read errors' earlier
in this section.
Chapter 4 Page 14
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:
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
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:
Chapter 4 Page 16
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.
IDIR
IDRIVE
IERA
IREN
IUSER
.... are executed to disc, regardless of whether cassette operation has been selected.
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.
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.
Chapter 5 Page 2
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>
.BAS
.BIN
.BAK
COM
SUB
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.
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>
.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.
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
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
*.
*. BAS
DIRECTORY
Match
BERT.BAS
FRED1.BAS
FRED2.BAS
FRED3.BAK
FRED3.BAS
FINISH.BAS
BERT.BAS
FRED1.BAS
FRED2.BAS
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
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
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.
Chapter 5 Page 7
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
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.
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
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.
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).
Chapter 5 Page 12
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 *
<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 *
All other
on disc
LOAD"FILE"
ITAPE
SAVE"FILE"
IDISC
H=HIMEM
MEMORY <s>-1
LOAD"FILE"
ITAPE
SAVE"FILE",B,
Binary
on tape *
IDISC
MEMORY H
<note 2>
ASCII
on tape *
LOAD"FILE"
ITAPE
SAVE"FILE",A
IDISC
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"
<change discs>
ICPM
PIP B:=FILE
AMSDOS
SAVE"FILE",A
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
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
Chapter 5 Page 15
.... 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>: wr ; t e fa; l
.... Hardware error writing disc. Recommended action is to eject and re-insert the disc,
then type R.
Chapter 5 Page 16
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.
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.
Chapter 5 Page 18
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
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
[CONTROl]B
[CONTROl]Q
.... or....
[CONTROL]!)
[CONTROl]C
[CONTROL] [ESC]
Abandon.
[CONTROl]E
[CONTROL] [RETURN]
[CONTROl]F
!)
[CONTROl]G
[ClR]
[CONTROl]H
[DEL]
Backspace delete.
[CONTROl]1
rrAB]
[CONTROl]J
chapter 5 Page 19
[CONTROl]K
[CONTROL] [ClR]
[CONTROl]M
[RETURN]
.... or ....
[ENTER]
[CONTROl]P
[CONTROl]Q
[CONTROl]R
[CONTROL] [ENTER]
[CONTROl]S
[ESC]
[CONTROl]U
[CONTROl]W
[COPY]
[CONTROl]X
[CONTROL] [DEL]
[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
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.
Chapter 5 Page 21
ERA PIP.COM
ERA B:PIP.COM
ERA *.BAS
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.
ASCII text file, unpredictable and possibly undesirable side-effects may occur.
TYPE KEYS. CCP
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
Chapter 5 Page 22
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:
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.
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
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.
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 ....
.... 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
Chapter 5 Page 26
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:
DEVICE
Chapter 5 Page 27
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 <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
Chapter 5 Page 28
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]
Chapter 5 Page 29
RENAME
RENAME *.SAV=*.BAK
.SAV
Chapter 5 Page 30
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
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:
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
Chapter 5 Page 32
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.
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.
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:
Chapter 6 Page 34
FILECOPY *.COM
FILECOPY PIP.COM
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.
Chapter 5 Page 35
(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:
**
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
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.
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).
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:
**
**
*
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.
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 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.
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
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.
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:
to triangLe
repeat 3 [fd :edge rt 120]
end
We can test this by typing:
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
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
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
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.
m; le s
?bf [1 2 3]
[2 3]
bl
(but last) Outputs all but the last element in the input object.
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]
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.
*
memberp
Outputs T RUE ifthe first input object is an element of the second input object.
*
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.
word
Outputs a word made up of the input words.
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
*
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
?- 10 5
5
?10-5
5
?* 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.
make
Makes the input-named variable the value of the input object.
*
namep
Outputs T RUE if the input word identifies a defined variable.
?namep "chocoLate
FALS E
Introduction to Logo
Chapter 6 Page 17
thing
Outputs the value of the input-named variable.
Procedures:
*
define
Makes the input definition list the definition ofthe specified procedure name.
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
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]
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.
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
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.
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.
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.
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.
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.
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.
*
pps
Displays the non-standard property pairs of all objects in the workspace.
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
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
?di r
[TRIANGLE HOUSE]
?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)> ]
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.
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.
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.
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
.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:
**
**
**
*
**
**
***
**
For a complete guide to the BASIC and firmware for the CPC6128, consult AMSOFT
manuals, SOFT 967 and SOFT 968 respectively.
Chapter 7 Page 1
1.
Writing a character
2.
3.
Obeying the control codes marked with an asterisk in the list ahead.
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
Name
&00 0
NUL
&01 1
SOH
&02 2
STX
&03 3
ETX
&04 4
EOT
Oto2
&05 5
ENQ
Oto255
&06 6
ACK
&07 7
BEL
BS
&08 8
Parameter
Meaning
No effect. Ignored.
Oto255
Chapter 7 Page 3
Name
Value
Parameter
Meaning
&09 9
* TAB
&OA 10
&OB 11
* VT
&OC 12
FF
CR
&OD 13
LF
&OE 14
SO
Oto15
&OF 15
SI
Oto 15
&10 16
* DLE
&11 17
* DC1
&12 18
* DC2
&13 19
* DC3
Chapter 7 Page 4
Value
Name
Parameter
Meaning
&15 21
NAK
&16 22
SYN
Oto 1
&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
1 to80
1 to80
1 to25
1 to25
Chapter 7 Page 5
Value
Name
Parameter
&1B 27 ESC
Meaning
No effect. Ignored.
&1C 28 FS
Oto 15
Oto31
Oto31
&1D 29 GS
Oto31
Oto31
&1E 30 RS
&1F 31
US
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
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.
Chapter 7 Page 7
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
JOYSTICK 0
JOYSTICK 1
26
36
IFIRE21r'RE
58
5A 11
58
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
N/A
G I N/A
I~=!,::::::::=!,::::::::==
~12"'9=;:=1"'3=O~;=:1"'~1:;:=;
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~
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
Chapter 7 Page 22
JOYSTICK 0
JOYSTICK 1
IFIRE211
FIRE
1I
76
77
IFIRE2jj FIREl j
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
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
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
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
Chapter 7 Page 27
9 Subscript out of
rang~
11 Division by zero
May occur in real division, integer division, integer modulus or in exponentiation.
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.
Chapter 7 Page 28
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
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
Chapter 7 Page 30
AMSDOS error
DERR value
Cause of error
oor 22
14
1 42 (128+ 14)
15
1 43 (128+ 15)
16
17
18
1 46 (128+ 18)
19
1 47 (128+ 19)
Directory is full.
20
148 (128+20)
Disc is full.
21
149 (128+21)
22
150 (128+22)
File is Read/Only.
26
1 5 4 (128+ 26)
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
1
2
3
4
5
6
7
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:
Chapter 7 Page 32
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
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
;:
;:
::
::
Chapter 7 Page 35
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
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
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
Tape Socket
VIEWED FROM REAR
0
o
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
=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
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
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
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
(.
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
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.
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
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
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.
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.
Chapter 7 Page 45
h
I
I
I
I
I
I
1
1
I
:
I
I
I
I
I
:
Lj
NOTE l' DEPENDS ON EXTERNALLY FITTED ROMS-&A6FC WHEN NO EXTERNAL ROMS FITTED
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
The example below shows this scheme in operation when HIMEM is lowered in
conjunction with loading an RSX.
100
110
120
130
140
150
11
I
I
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.
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.
Chapter 7 Page 48
Characters in the range &00 to &IF are interpreted as control codes as follows:
&07
BEL
Sounds a beep.
&08
BS
&OA
LF
&OD
CR
&lB
ESC
Disable status line. Disc system messages will appear with CRT
output. CRT may use the bottom line of the screen.
[ESC]1
[ESC]2 <n>
USA
France
Germany
UK
Denmark
Sweden
Italy
Spain
Chapter 7 Page 49
[ESC]3 <m>
[ESC]A
[ESC]B
[ESC]C
[ESC]D
[ESC]E
[ESC]H
[ESC]I
[ESC]J
[ESC]K
[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
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.
[ESC]b <cp>
CPC6128
Zero intensity
HalfIntensity
Full intensity
Colour bits
00 binary
01 or 10 binary
11 binary
[ESC]c <cp>
[ESC]d
[ESC]e
[ESC]f
[ESCb
[ESC]k
[ESC]l
[ESC]o
[ESC]p
[ESC]q
[ESC]r
[ESC]u
[ESC]v
Chapter 7 Page 51
[ESC]w
[ESC]x
[ESC1y
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
Chapter 7 Page 52
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.
Chapter 7 Page 53
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~~~
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
ChapterS
More
out the Bank
anagerll
11 1111
**
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'.
Chapter 8 Page 1
Chapter 8 Page 2
The command:
I S eRE ENS WA P, [<screen section> , J<screen number> , <screen number>
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
Chapter 8 Page 3
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.
Chapter 8 Page 4
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.
IBANKOPEN,111J
IBANKWRITE,@r%,"123 testing",11J
IBANKWRITE,@r%,w$
The command:
End of File error. The requested record number's address exceeds 64K.
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:
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
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
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'.
11l1li
Chapter 9 Page 1
The generally accepted reference points for personal computers are now:
2.
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
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.
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.
Syntax error
Chapter 9 Page 4
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~:;;;;;----
__
Chapter 9 Page 5
Chapter 9 Page 6
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.
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
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?
Chapter 9 Page 9
1
(16
o
o
o + o
+ 2 +
1)
19
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
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.
Chapter 9 Page 11
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
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.
Chapter 9 Page 13
**
**
*
**
**
*
*
*
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
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.
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
(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.
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>
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
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
10
20
30
40
50
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!"
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
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:
1010
0110
AND result
OR result
XORresult
0010
1110
1100
Chapter 9 Page 20
*
****
*
*
* * * *
*
*
* ** * *
*
* **
********
=
=
=
=
=
=
=
=
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
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? ....
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:
Chapter 9 Page 23
\";"test string"
test s
.... 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.)
too L0 n g
- 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.
Chapter 9 Page 24
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.
** "
**
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.
Chapter 9 Page 25
A"
tttt
11
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
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:
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
.... 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
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
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
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:
30 READ a$(i)
40 NEXT
50 FOR ;=0 TO 8
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
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
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
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:
Chapter 9 Page 33
1000
1010
1020
1030
1040
1050
1060
1070
1080
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
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
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
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
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
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
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
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.
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
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
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
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:
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:
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
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):
Chapter 9 Page 47
10
20
30
40
50
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
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.
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:
MASK
&X~~1111~~,~
115
125
135
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:
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:
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
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:
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.
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.
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.
Chapter 9 Page 53
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
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.
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.
10
20
30
40
50
60
70
80
90
Chapter 9 Page 56
230
'240
250
260
270
280
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.
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
Chapter 9 Page 58
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
Chapter 9 Page 60
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
Chapter 9 Page 61
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.
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 Retrieve a screen
to Exchange screens
[RETURN]
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.
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.
4.
Licence Agreement
Appendix 1 Page 1
2. Licence
You may:
1.
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.
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.
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.
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
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 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.
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.
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.
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).
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.
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.
Appendix 3 Page 1
Appendix 3 Page 2
Bomber
A variation on a classic theme! For one player against the computer. Keyboard only.
10
20
30
40
Appendix 3 Page 3
520
530
540
550
Appendix 3 Page 4
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
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).
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
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
Electric fencing
Try to 'foil' your opponent! For two players only. Keyboard or Joysticks.
Appendix 3 Page 9
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
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
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
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
Appendix 3 Page 15
780
790
800
810
820
830.
840
850
860
870
880
890
900
910
920
P%=0:VRX%=0~~RY%=0
Appendix 3 Page 16
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
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
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
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
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
Appendix 3 Page 20
Appendix 3 Page 21
Appendix 3 Page 22
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
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
780
790
800
810
820
830
840
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
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
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
Appendix 3 Page 28
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
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
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
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
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
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
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
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
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
Index
Appendix 4 Page 13
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