The Complete Spectrum 02
The Complete Spectrum 02
The Complete Spectrum 02
ADotobose
Publication
TURN YOUR COMPUTER INTO A PROFESSIONAL
GAMES WRITING MACHINE FOR FUN AND PROFIT!
LASER BASIC adds 100 new commands to Sinclair Basic.
These extended commands are semi-compiling so graphic animation
— is extremely fast. LASER BASIC
——— includes, extended interpreter,
/ sprite/graphic designer, fully
7 documented program and 2 sets
pre-defined sprites.
• Up to 255 software $prltes can be defined, each with its own
user selectable dimensions (up to 7 screens wide!)
.rTUORC iPRXTt:
• Operations can be carried out, on or between screen
windows, sprites and sprite windows;
• Sprites can be block ‘PUT’ or can use one of three logical
operations - AND, OR and XOR.
•• Sprites and screen windows can be pixel scrolled in any
direaion, mirrored, enlarged, spun. Inverted or cleared.
• Procedures with local variables and parameter passing.
• TRON and TROF (trace facility).
• 16 bit PEEK and POKE.
• RENUMBER and REM renumber.
• Non destruaive MOVE with 2 frame anirnatlon.
• Collision deteaion and pattern recognition facilities.
OUT NOW FOR THE SPECTRUM 48K/
SPECTRUM+ ON CASSETTE ALSO
£14.95
available
NOW!
Microdrive compatible.
30 Beginners
Variables come under the microscope. We show how to use them in your first program.
Discovering Discs
Planning on buying a disc drive? Here’s all you need to make up your mind.
u:
^ J
...... ...^ vv ■ -V -- ^ - - -i ; ... .■„„;, - ....
Microdrives
■ ^ The facts about them and how to make the most of the additional commands.
----^-
Ready reference
57 Get the facts at your fingertips as we summarise the Spectrum’s graphics commands.
. .............—...—-—---—-----N ■
p-icp
’ooo—
00—0
■*■■—00
CO Take a byte
Take the mystery out of the way your Spectrum handles binary numbers.
. ........ ."'■'■'I
AA code
Start machine code programming by learning how to PEEK, POKE and CALL.
70 Upgrade
" Short of memory? Here are some of the options to expand your RAM power.
LETting on about variables we got an error message. Now, somehow, x stands for
2 and when we use PRINT on x we get the number 2 on
On the L key of your Spectrum you’ll see the keyword screen. What’s happened is that the:
LET. When L is pressed in response to the flashing K
cursor, LET appears magically at the bottom of the LET x=2
screen, use it to type in:
has told the Spectrum that from now on the letter x will
LET x=2 stand for the number 2. Anywhere an x: is used in a
and press Enter. All you get for your trouble is an OK PRINT statement - and in other statements as we’ll see
message at the bottom of the screen and that’s it. It’s - the Spectrum knows that it stands for 2. Notice that
not too impressive until you try: it’s:
PRINT X PRINT X
Variables vary
Let’s set up a variable called number with:
LET nuinber=3
So now, whenever I use number the Spectrum will
realise that it’s a variable name I’m using and substitute
the number 3 in its place. Try:
PRINT number, number*2, numbei^l
it has no problems, provided that a previous LET has PRINT number, number*2, numbei^l
told it what x stands for. It just uses 2 wherever it finds The result is:
a: and carries on with the sum as before. To be formal,
the letter jc is what is known as an identifier or variable 4 8
name. The statement: 3
across number. The second LET has overruled the first show how the pay is worked out. When the variable
one. The variable number was 3 but it’s now 4. As you gets a value then the pay can be worked out.
can see, the value given to a variable name by a LET
isn’t a once and for all thing. It can vary as later LETs
give it a new value. And that is why they’re called A first program
variables. The name stays the same, the value it Let’s put what we’ve learnt about PRINT, LET and
represents varies. variables together and create a program. Type in the
These variables are powerful things. Try: following four lines, remembering to press Enter after
LET number=5 each one.
PRINT number,number+2, number-1 10 LET first=l
followed by: 20 LET second=2
30 LET sum=first+second
LET number=6 40 PRINT sum
PRINT number, number+2, number-1
If you find you ve made a mistake in a line that
and: you’ve entered, just retype the whole line again. On
LET number=99 pressing Enter, the new, correct line will replace the old
PRINT number,number+2, number-1 one.
The first thing you should notice is that instead of
Each time we get different results but each time the starting with a keyword, as was the case in our previous
print list: examples, these lines begin with a number. The next
PRINT number,number4'2, number-1 thing is that when they are typed in, nothing happens.
Entering:
stays the same. By the simple task of using LET to vary
the value of number the same print list can produce lots LET first=l
of different results. at least gives us an OK message. All we get for:
If you find the concept of variable strange it
shouldn’t be. We use them all the time. If I tell you that 10 LET first=l
I’ll pay you £2 for each hour you work then you know is a copy of the line on the screen. It’s the same with the
that your pay will be two times the number of hours other three lines. What’s happening?
you worked or, more formally: The rule is that when a statement is entered just by
pay=2*hours itself, the Spectrum obeys it immediately. When it
starts with a number in the range 1 to 9999, the micro
If you work 10 hours you’ll expect £20, if you work doesn’t obey the line but keeps it in memory as it knows
15, £30. As the hours vary, so does your pay. You’re it is going to use it later. So, as well as appearing on the
using hours as a variable. It’s a value that can change.
screen, a copy of:
One week it may be 5, the next 40 but whatever it is you
still know that by using that value in: 10 LET first=l
20 LET second=2
pay=2*hours
30 LET sum=first+second
you’ll get the right answer. The variable name is used to 40 PRINT sum
40 / The Complete Spectrum
be done quiet easily.
Editing programs
Whenever a line is typed in there is always a
chevron, >, between the number and keyword of
When you’re entering programs, you’ll often that line. So entering:
find typing errors creep in. What do you do if you
10 PRINT “Hello Mum”
wanted to enter the line:
10 PRINT 2*variable
and pressing Enter, results in:
lOPRINT “Hello Mum”
and you get something like:
10 PRINT 2*varable appearing on the screen. Adding a new line such
as:
which you obviously don’t want?
20 PRINT “Hello Dad”
If you spot your mistake before you press
Enter, then all you have to do is to use Caps Shift has the top of the screen becoming:
and the cursor control keys (5 and 8) in the usual
10 PRINT “Hello Mum”
way. While the line is still at the bottom of the
20>PRINT “Hello Dad”
screen it can be modified using the techniques
already covered. Notice that the chevron now points to the latest
If you’ve already hit Enter then things are line.
different. There’s nothing on the bottom line to It we’ve made a mistake and want to edit the
modify. The line sits there at the top of the screen line with the chevron, all we have to do is press
in all its incorrect glory. One course of action is to the Caps Shift key and the 1 key at the same time.
just type in the whole line again. The new line The result is that a copy of the marked line
automatically replaces the old line. So, if you appears at the bottom of the screen. There it can
had: be edited in the normal way. When it’s corrected,
10 PRINT 2*varable pressing Enter sends it back into the micro,
overwriting the old, incorrect line.
all you have to do to correct it is type in: However it s not always the last line we
10 PRINT 2*variable entered that wants correcting. Often we notice
that it is an earlier one. The remedy is simple. The
correctly. chevron can be moved up or down the listing
The trouble with this is that all your previous using the Caps Shift and 6 or 7 keys. Once the
typing is wasted. You have to type the whole line chevron is beside the line with the mistake. Caps
over again. It would be better if somehow the Shift and 1 transfer it to the bottom line to be
offending line could be made to reappear 'at the edited as normal. Once the line is modified,
bottom of the screen. Then it could be modified in pressing Enter sends it back to the micro,
the normal manner. The Spectrum allows this to replacing the incorrect line.
is held inside the micro. When the Spectrum is told to RUN something it
These numbered lines make up a computer program. looks in its memory for the lowest line number and
When the Spectrum is told to run the program, it looks executes that statement first. In this case the lowest line
for the line with the lowest number and obeys the number is 10 so the micro obeys the statement:
statement following that. Once that is done it looks for
LET first=I
the next lowest line number and obeys that. It carries
on, obeying each line in sequence, until it runs out of giving the numeric variable first the value 1. It then
lines to obey. Then the program stops. This is all a looks for the next line number and finds it is 20 so it
program is: An ordered set of instructions that the goes on to processing:
micro obeys, each one in turn.
LET second=2
1 Buy RiMronics
1 Wafadrive 1 money
Centronics port^
More preferable to
than £120? high capacity and
^Magic Button?^
Beta-Plus
ijgSmes?
Triton QD i
1 “
Opus D iscovery
1
I
storage and retrieval of data
with the microdrive filing system
REGULAR, CONDENSED, OR
EXTENDED FACES.
BATTERY OR MAINS
OPERATED.
A maxim which eloquendy describes the most home computers and popular software.
Brother HR-5. Perfecdy portable, the battery or mains operated
Less than a foot across, it’s nonetheless loaded HR-5 weighs less than 41bs.
with features. Which is really something to shout about
But there’s one thing the HR-5 won’t give you.
Earache. I PLEASE SEND ME MORE DETAILS OF THE REMARKABLE BROTHER |
HR-5 PRINTER
For the annoying ‘clickety clack’ many printers
NAME
produce is mercifully absent from the HR-5.
ADDRESS.
Quiedy efficient, it delivers high definition dot
matrix text over 80 columns at 30 c.p.s.
The HR-5 also has something of an artistic bent
Being capable of producing uni-directional
graph and chart images together with bi-directional
L- TELNO..
-j
text
It will also hone down characters into a
condensed face, or extend them for added emphasis.
Incorporating either a Centronics parallel
brother,
or RS-232C interface, the HR-5 is compatible with The future at your fingertips.
DEPARTMENT P, BROTHER OFHCE EQUIPMENT DIVISION, JONES + BROTHER, SHEPLEY STREET, AUDENSHAW, MANCHESTER M34 5JD. TELEPHONE: 061-330 6531.
TELEX: 669092. BROTHER SHOWROOM: 83 EUSTON ROAD, LONDON NWl TELECOM GOLD: 83: JBC002. BROTHER INDUSTRIES LIMITED, NAGOYA, JAPAN.
St
age: AC
/'vaF: ^-
^^efcPOOL telephone:
age: 1-'
record no. -
--
age: 1'^
--
AGE:: 27
27
manage your money! Features: Number record no.
295
:;:;Q'no"" B : l
4136.72
2850.14
403.60
180.69
■348.62 -.49.70
276.91 109.83 106.07'
101.61
234.68
"139.21
'113.95 "l67.18
85.46
"l04.40
55.73 GRAPHirR
34.80
20.49
^OT RL
Page 1
spent
Of the
Showing tho ^ '^^'ocessot'
^PPtions avaiiablo^^ »^^'intout lafc
1 ab 1 ^
_i_ road
4GT0N
B0923
lemonstraf 1
T—= -i.bbr!°^^-cE ssor showing
OTBU SPEHT
M
^^7
. copy/copies of
Mini Office for Spectrum 48k/Spectrum +
□ I enclose cheque made payable to
Database Publications Ltd.
for £_
I wish to pay by
□ Access □ Visa No. __ .Expiry date.
Signed____
f Signature Name
Address
Or send S.A.E. for the New D.K.Tronics Spectrum Catalogue
d^lronks
DK Tronics Ltd., Unit 6, Shire Hiil industrial Estate, Saffron Walden,
Essex CB11 3AQ. Telephone: (0799) 26350 (24 hrs) 5 lines
Microdrives:
The commands
expioined
Saving and Loading
SAVING and loading with microdrives obviously The special commands you’ll
requires different commands from the ones used for the need when you use microdrives
cassette recorder. There are a number of reasons why
the syntax of the new commands has to be more
complex than the old. For one thing, something must
be added simply to distinguish the microdrives from the
tape. Then the existence of the filing system means that
you must use a program name when loading, as there MERGE and VERIFY
are likely to be several programs on the cartridge, in no
particular order. You can MERGE or VERIFY Basic programs from
Furthermore, you can LOAD and SAVE from the microdrive in the same way as with cassette. However
network port and the RS232 port, as well as from the programs that have been saved to microdrive with a
drives, so more identifiers are needed to specify them. RUN-on-LOAD line number will not merge. This fact
And finally there are extra functions associated with a allows commercial programs to be protected from
file structure, such as formatting and cataloguing, copying.
which need their own instructions.
All the necessary extra bits, plus a deal of
punctuation that seems quite unnecessary but cannot Formatting
be omitted, makes the syntax of the new commands
long winded and unwieldy. There is, however, one When you buy a new blank microdrive cartridge the
quick short cut that can be used to good effect. If you first thing you must do is FORMAT it. This process
put a program with the name “run” on a cartridge, it runs through the loop of tape, testing it and placing
can be loaded automatically just by giving the markers on it, and makes a map so that the computer
computer a RUN command. This only works if the knows which parts are usable and which it should
RUN is the first command given after power-up or a avoid, such as the join where the loop is spliced. When
NEW, but it is very useful all the same. formatting a cartridge, you can give the cartridge itself
Many people write a little menu-driven loading a name which will appear in the catalogue.
utility and put it on to every cartridge, giving it the Some experts recommend that you FORMAT the
name “run”. This program displays a catalogue of the cartridge several times on the trot when you first get it,
cartridge and prompts you to type in the name of the to give it a good workout before committing any
program you want to load, without all the complicated program to it. You will find that each time you format a
bits. Such a program might go like this: cartridge it will format to a different capacity and you
may wish to maximise the storage available by
lU CAT 1
20 INPUT “NAME TO LOAD? ”;a$
30 LOAD ♦“ni”;l;a$
40 STOP
100 SAVE ♦“iii”;l;“run” LINE 10
110 REM Line 100 used to SAVE this program
As you can see in line 100, when using microdrives
there is a lot to type before you even get to the name of
the program. The asterisk (*) is used to kick the
Interface 1 “shadow” ROM into life. The“m” specifies
microdrive rather than network, and so on. The 1
indicates that it is microdrive number one you are using
(this is needed even if you only have one). The “LINE
10” part is exactly like the cassette command - it
makes the program run from line 10 automatically
when it loads.
The quotation marks and semicolons sprinkled
through the syntax are only there because the
Spectrum is using the same ROM subroutines to
process microdrive commands as it uses for PRINT
items, so you must include them even though they
convey no essential information.
formatting repeatedly until you get a high figure for
storage capacity (use the CAT function to find out the Standard Spectrum channels
capacity). You usually get about 90k of storage on
-—-------
each cartridge, and if a new one won’t give you at least
85k it is substandard. k The keyboard in input or the lower screen in
Formatting a cartridge erases it completely, so once output. (Obviously you can not output to the
you have put a program on a cartridge you must take keyboard or input from the screen.)
care not to use FORMAT accidentally. You may think s The upper 22 lines of the screen, output only.
that it is an unlikely mistake to make, but it has P The ZX printer, again output only.
happened to others!
The FORMAT command is also used to set the At---—-
baud rate for the RS232 port and to assign station Interface 1 extends the number '
numbers for the network. ofchannels, adding:
---——-'
The Catalogue t Text output via the RS232 port. Used for
listing, doesn’t send unprintable characters,
Each cartridge has a catalogue kept on it which is
and expands Basic keyword tokens into
automatically updated to include everything you save
spelled out form. Works in input but ignores
to the cartridge. The command CAT 1 will give you a
8th bit. Must have baud rate set with
list of the programs on the cartridge in drive 1, plus the FORMAT.
name you gave to the cartridge itself, and the number of b Binary data in and out via the RS232 port
kilobytes of space left free.
(full eight bits). The baud rate must have
The catalogue unfortunately does not tell you which been set with FORMAT.
names on the list are Basic programs and which are n Network input and output, requires a
blocks of code or data. If you try to load a ‘‘program” station number.
which is actually a code block, and so on, you will get a m Microdrive in and out, requires drive number
“Wrong file type” error report, but it still won’t tell you and file name.
what the file actually is. It is also possible to save a file
with an invisible name, which puts an even greater Figure I
strain on the memory.
technique is, the more difficult it will be to understand.
Still, this is often the case, and so it is with the Extended
Erasing Basic commands for channels and streams.
There is no need for an ERASE command with Behind these fluvial names lurk even more
cassette storage since you merely record over the old complicated machine code data manipulation routines.
program, but you need a way to remove redundant files The names are meant to simplify things by
from the microdrive. Formatting wipes all the concentrating the mind on the function of the
programs on a cartridge, but by using the ERASE commands, rather than the intricacies of the
command you can remove just the one named computer’s operations.
program. Channels are devices that data can be sent to or
This is particularly necessary when you are in the received from. Streams are the routes that the data
process of writing a program and saving moves along. These are logical devices and routes, not
partially-completed versions to microdrive from time physical ones. Each channel is an input or output
to time. Unless you give each save a new name, which routine in the Spectrum or Interface 1 ROM, and the
will quickly fill the cartridge, you will have to erase the streams are really a way to assign labels so you can
old version before saving the new one. This is because pick which channels you wish to use.
the microdrive cannot have two programs in a There are 16 possible streams in the Spectrum, but
catalogue with the same name. How would it be able to the first four are already assigned to link various
choose between them when loading? channels used by the normal Basic commands. PRINT
Microdrive cartridges can be protected against for instance uses stream#2, which is linked to the upper
accidental erasure by removal of the write protect tab. screen output channel. When you use PRINT#0 or
This is much the same as the record prevention tab on a PRINT i^l, you divert the output via the streams
cassette - it stops not only erasure and formatting, but ordinarily only used by the Basic editor, and the print
any saving operation as well, so it is only of use for appears in the lower two lines of the screen.
permanent program storage, not for changeable files of You can assign the streams from 4 to 15 to any of
data. the channels by using the OPEN # command and
CLOSE#will close it again. CLOSE#is important,
especially with microdrive data files, as just printing to
Channels and Streams a file does not actually put the data on the cartridge
until the file is closed. The channels are identified by
The Extended Basic in the Interface 1 ROM has single letters enclosed in quotes. These letters and the
powerful facilities for directing the flow of data from channels they represent are shown in Figure I.
one device to another, called channels and streams. By assigning a stream to the RS232 “t” channel and
Actually these are at work in the standard Spectrum as LISTing to that stream, you can LIST a program on a
well, but they are transparent to the user - that is, you full size printer. Or you can PRINT to the stream. You
don’t notice them. When the Interface 1 is fitted you can even send the catalogue down the stream with a
can program the channels and streams to very useful CAT command, to print out the microdrive catalogue.
purposes, and the people you buy your software from When saving and loading programs to the
can use them to make life easier for you. microdrive you don’t have to open a stream, you just
There is, as far as I know, no law of programming use an asterisk after the SAVE or LOAD, followed by
that states that the more powerful and flexible a the microdrive identification bits and pieces. However
50 / The Complete Spectrum
handling a data file is made easier by using streams. one that has been left out is a rename command. If you
You can open a stream to a file on the microdrive and want to rename a program or file on microdrive, you
then PRINT the data to the file via the stream. have to save it under the new name and erase the file
with the old name.
The MOVE command
MOVE will move data from one channel to another,
Cartridge care
via the assigned streams. This is a very flexible The tape in microdrive cartridges is subject to a good
command which can send a microdrive file to the deal of wear. There is nothing you can do about this
screen, the network, or even another microdrive file. except make sure that you don’t lose your programs
You could even use it to connect the keyboard directly when the cartridge expires. You do this by making
to the RS232 printer port. MOVE will open and close back-up copies. The back-ups don’t have to be on
the streams automatically, but it only works on data. cartridge, cassette tape will do. You aren’t supposed to
To send program files whizzing around the place you use them, just keep them safe to avert a disaster when a
must first load them and then SAVE or LIST them to cartridge goes wrong. This advice applies to discs, too,
the stream of your choice.
but many people have reported more than usual
More information on how to use the various reliability problems with microdrives, and extra care is
channels and streams associated with the drives, warranted.
network and RS232, is in the manual that comes with
You must not turn the power to the computer on or
the microdrives. Luckily, you won’t need channels and off while a cartridge is inserted in the drive, nor remove
so on to begin with, or maybe ever, because this part is a cartridge while the drive is running.
not simple. A number of books have been written to try These actions are almost certain to corrupt at least
to make the microdrives easier to understand, but part of what is stored on the cartridge and make it
whatever you do, don’t lose the manual. unreadable.
The cartridges are mechancially delicate
and should be kept in their cases when not in use.
Ashtrays, cups of tea, and the tips of magnetic
Most of the facilities offered by disc operating systems screwdrivers all display a disturbing attraction for
are available in the microdrive’s Extended Basic. The unprotected cartridges.
Closes stream x. Sends any data left in buffer to file or MERGE * channel;options T key. Ext Mode
network.
Like cassette MERGE but from channel specified.
ERASE “m”;x;“name” 7 key. Ext Mode
Erases file “name” from cartridge in microdrive x. MOVE xTOy 6 key, Ext Mode
Moves data from x to y, where x and y are either stream
FORMAT “m”;x;“name” 0 key. Ext Mode numbers of channel identifiers. Streams are
automatically opened when x or y are channels. This
Formats cartridge in drive x, and names it “name”.
command will not terminate until an end of file marker
This erases anything already stored on the cartridge.
is reached, and this only happens when the source is the
Every cartridge must be formatted before it can be
used. network or microdrive.
Sets the network station number to x (range 0 to 64). Opens stream x. Stream should not already be open.
RGB
The better sort of monitor uses RGB signals, which
stands for red, green, and blue. The Spectrum only has
Dashing away with
what are called “colour difference” signals available.
These correspond to red minus yellow, blue minus
a soidering iron
yellow and luminance plus sync. %
A special monitor is available for the Spectrum from IF you have never, ever, before messed about
Microvitec that will make sense of these signals, and with solder and veroboard, connecting dinky
very good it is too, although expensive. It attaches to electronic gubbins together into oscillators that
the edge connector with no fuss, and gives an extremely didn’t oscillate or amplifiers that did, then
sharp picture with no “dot crawl”, the small scale perhaps you shouldn’t read this.
shimmering you’ll see. This is really a RGB type A computer is about as complicated a piece of
monitor with some extra circuitry to cope with colour circuitry as comes, and it is not the ideal training
difference signals. ground for a keen learner with a new soldering
iron. So if you’re still with me. I’ll assume you
know how to solder. It can’t be taught from print
Composite video anyway.
The easiest place to get at the composite video
The other type of monitor uses a composite video signal is the point where it feeds into the TV
signal. In composite video, all the colour signals have modulator. You can find the modulator quite
been coded together into one complex signal, so you easily. It is the little metal box with the socket
need only one coaxial conductor to carry it around the where you plug in the TV aerial lead. You will
place, which is why this is the type of video signal that have to open the computer case to get at it.
the television companies themselves use in most of their At one end of the box, there are two wires
monitoring equipment. There is a composite video leading in. The nearest of these to the TV socket
signal available on the Spectrum board, but it may not is the composite video signal, the other is the
be present at the edge connector. modulator’s power supply. You need only solder
From about Issue 3 onwards the composite video the core of your coaxial lead to the signal wire,
signal was brought out to the edge connector, where it and the outer sheath to the metal box itself, for an
can be found on the underside of the board, fourteenth earth. Fit the other end of the coax with the right
pad from the non-slotted end of the connector. Earlier kind of plug for your composite monitor, usually
issues were supplied with an open link, which meant a BNC or phono type, and you’re away.
you had to open the case and make a join to get the
52 / The Complete Spectrum
so that you can gauge the effect on the screen.
Give it a tweak! This is not dangerous to you, as the voltages are
all very low, but you must take care not to touch
Besides dedicated monitors, you can get components other than the presets with the end
television sets that have composite video inputs, of your screwdriver, as even a momentary short
usually meant for use with video cameras. These circuit could damage the computer. These
will accept the colour video from the Spectrum presets go through their whole range of
and provide an improvement over the TV signal adjustment in a single 360 degree turn, so you
because you have cut out the modulator in the need only turn the screw a tiny amount to make a
computer and the demodulator in the TV set, so difference. Take care not to bend the keyboard
the signal is messed about much less. However, ribbon cables about too much, as they are fragile
bypassing the modulator won’t eliminate dot and tear easily.
crawl, because that is introduced during the There are two preset capacitors and two
coding into the composite video signal, not variable resistors all in a row. The two nearest to
during modulation. the TV modulator with the little brass screws are
The Issue 1 and 2 circuit boards have preset the capacitors. They are used to trim the
controls for setting up the colour signal circuits. frequencies of the two crystals that control the
These are adjusted at the factory and you are computer clock and the colour sync. The one
meant to leave them alone, but it is possible to nearest the modulator is the clock trimmer, and
effect a useful improvement to the Spectrum’s this is the one you tweak to minimise dot crawl.
display by tweaking them to suit your particular The colour sync trimmer should only be adjusted
TV set. Indeed, some TVs would not work in if you have no colour at all, and even then you
colour with these early Spectrums until this was should first check that the problem is not the
done - and some still wouldn’t work after it was tuning of the television set itself.
done! The two furthest from the modulator are the
First let us eliminate those Spectrums which colour balance controls. These don’t have proper
will not gain anything from this exercise. All screw heads, only an oblong slot, and you may
Spectrum Pluses and the later rubber keyboard have difficulty finding a screwdriver to fit
Spectrums with Issue 3 circuit boards do not properly. One controls the balance between red
even have the presets fitted. Instead they have and yellow and the other between blue and yellow
improved ULA circuitry that is self adjusting. and both together effect the green.
sr You won’t be able to turn a TV into a monitor These should be tweaked to give good colours,
»r with a few twists of a screwdriver. It may be best but also to obtain a nice neutral white. Obviously
e to leave your pots alone if the display is anything you will want to run a program or give instruc¬
like reasonable. After all, you might make it tions to the computer to get some colours into the
worse. If your whites are yellow or you have display to judge by.
trouble getting the colour to lock, then tweaking It is possible to get into a complete muddle and
ought to help. If your only complaint is dot crawl, mess up the display entirely. Don’t panic if this
then you should be able to get an improvement, happens, just make a cup of tea and have a good
but it will come and go. You should do these think about what you’re doing. There is nothing
adjustments when the computer is warmed up, as permanent or irretrievable about any of the
they tend to drift as the temperature changes. adjustments you’re making, and eventually it will
Adjustments must be made with the power on. come right.
10 INK 2
20 PRINT “HELLO HELLO” As the previous example shows, INK and PAPER
30 PRINT INK 6;“HELLO HELLO” can be mixed freely so that different coloured writing
40 PRINT “HELLO HELLO” can be produced on different backgrounds. The next S
program shows this further. This time RND is used to |H|
Line 30 is the clever bit, because it selects colour 6, select random foreground and background colours.
yellow, and prints the message “HELLO HELLO”
without altering the “general” INK 2 - red - selected
by line 10. When INK is included in statements in this 10 INK INT (RND*8) fl
way it must be followed by a semi-colon, otherwise the 20 PAPER INT (RND*8) 9
Spectrum gets confused and generates an error. 30 PRINT “This Is a message” 9
The second command associated with colour is 40 GO TO 10 9
54 / The Complete Spectrum
special effects with "
INK numbers 8 and 9
AS far as INK and PAPER are concerned the
numbers 8 and 9 are distinctly odd. They are
special in that they don't directly specify a new
colour but indicate the way in which the new
colour will be found. Let's see what effect they
have on INK.
If INK 8 is chosen, the foreground colour that
appears depends upon the current foreground
colour of the position being printed to. Therefore
.J if a yellow character is overprinted with a letter
A, the A will take on the colour already present —
yellow in this case.
This has the advantage that, ifyou're altering
something on a screen you've already set up, the
alterations don't stand out since they're made in
the foreground colour of the original. Ifyou like,
it's a sort of transparent ink. Key in this program
and see what happens:
10 INK 1
20 PRINT “I’M IN BLUE”
30 INK 2
40 PRINT “I’M IN RED”
50 INK 8
60 PRINT AT 0,0;“ALSO IN BLUE”
6 Yellow
PAPER 8 works like INK 8, altering the
7 White background colour to that of the current print
8 Transparent position. PAPER 9, contrast, works in a similar
manner to its INK equivalent but uses the current
9 Contrast
INK (foreground) colour to determine the new
background colour.
Table I: INK colours
7
PLOT x,y Q key N
Places an INK spot at pixel coordinates x,y, subject to
□V
INVERSE and OVER. Moves the start position for
DRAW to x,y. The pixel coordinates are:
x= across the screen left to right, from 0 to 225
y= up the screen from the bottom, from 6 to 175.
As above, but draws a curve between the two points of Returns a 1 if the pixel at x,y is INK, or a 0 if it is
an angle z, where z is expressed in radians. PAPER.-
(Experiment!)
(highest first).
required, starting with the highest first. For example, if
2. If you succeed then put a 1 in that column
I were to encode 161 in binary I would say, “Well, I can
number and continue to subtract other columns
use 128, so that leaves me 33 to find. 33 can be made up
from the remainder. If not put a 0 in that column.
of 32 and 1 so that does it: 128+32+1=161. So I
If you have not done all eight columns repeat from encode it as:
step 1.
Figure I should make it clearer. 128 64 32 16 8 4 2
In practice, when faced with encoding a number % 1 0 1 0 0 0 0
from denary to binary I tend to do it in my head, seeing = %10100001
which column values will add together to make the sum
After a while you’ll find this way quite simple.
rV MMM., A
7 6 5 4 3 2 1 0
Bit number
1 0 I 0 0 0 0 1
64 32 16 8 4 2 1
Bit value 128
{
2f7 2t6 2f5 2t4 2f3 2f2 2tl 2t0
Bit value 128 64 32 16 8 4 2 1
I I 0 0 1 0
CARD NO.
EXPIRY DP
SIGNATURE
NAME_
(BLOCK CAPITALS PLEASE)
ADDRESS _
POSTCODE
Trying to play all the games you can g4t for the Sinclr!
(About 5,000 trmes.)
1
How would you like to be blasted out of
the sky by anti-aircraft guns?
indair"
BRABHAM STRAIGHT
DRUIDS
i
)RNE
i ~T .
• . .1.
!
. .
\
1.
Name
Address
Postcode
iterface
Kempston Prop!
Access/
subroutine is called.
conditions. These are: anywhere near to placing such number of screens per
• The difference between pictures, or frames, as I second on to your TV and would run out of memory |
shall refer to them from now on, must be small. after about a third of a second. F
• The time interval between frames must be small. Fortunately there are ways around this. First you J
• The time taken to draw a picture must be much can get away with about 10 frames a second. Second, f
shorter than the interval between frames. and more important, you need only animate a small ?
• Any apparent difference between two consecutive section of the screen. Third, the same piece of |
frames should be regular. For example, if a ball animation can often be used over and over again. I
moves three pixels between frames 1 and 2 it should To see these ideas in action, try out Listings I and II I
move three pixels between frames 2 and 3. (A pixel which demonstrate the two main types of animation.
is the smallest dot of colour the Spectrum can put on Listing III combines these techniques to give very |
your screen.) sophisticated results. These last two examples make |
There are of course always exceptions. As with use of the speed at which the Spectrum can print strings
every conjuring trick, the timing is critical. Here timing of characters and change the system variable C HARS. f
refers to the speed at which one frame is replaced with In the next instalment I’ll detail the construction of a ;
another. The following examples show the normal walking character and give a listing enabling you to test |
number of frames per second shown in different media. your own animated graphics. f
loving
Sets RAM TOP to 39999.
static
Pokes into place the data for the
at the
graphic characters.
Sets up A$ which contains all
the characters needed for the
program.
The pokes to change CHARS so
that it points to the correct area
of RAM.
3000 to 3014 Hold data for the 15 graphics
characters needed
Redefines the normal character
set if a key is held down - this is I
how you exit the program.
2838 RETURN
2998 REN 6RAPHIC8 DATA
2991 REN
2992 REN
5 ^N|A8,8,8,8,8,8,8
JJ ;;; 78,66,8,8,6,8
‘‘•‘‘.133,133,141,155,78,66
u IJI! *>*'2^36,36,66,133,133
3884 DATA 141,155,78,68,6,8.8 8
3183 data 8,8,8,8;8,J,8:8’"’“’“
1f •'®.*.>.».N.38,32
2 i If'' 1,4
3812 DATA 2,8,6,16,32,3,1,18
813 DATA 42,88,132,136,8,32,77,17
%10I0
now write
Value in Value in
16’s column I’s column
%1000 001
Anyway, enough of this number theory. Let’s do command. Try it now. Enter:
some machine code. Last month we discovered that all
machine code was was a sequence of bytes in memory LET X=USR 28672
that gave the micro certain tasks. All you did was point The micro “gosubs” to &7000 (28672) and does
the micro at the first byte of the machine code and say what the byte tells it. In this case it merely says “go
go. back”, and you end up back in Basic. All right, nothing
That gives us three problems. First of all we have to spectacular has happened - but it worked, so
decide where in memory to put our machine code. congratulations. You’ve just run your first machine
Secondly we have to actually put the correct sequence code program.
of bytes into those memory locations. Lastly we have Let’s try something that does a bit more than this
to tell the micro to go and do the machine code though, to prove we’re really running code. As we said
instructions! last month, the firmware is full of machine code
To answer the first point, we’re going to store the routines that keep the micro going. And those routines
machine code at &7000 - 28672 in decimal. Never are there for you to call on - they’re already written.
mind exactly why for the moment. Let’s use one. There’s a routine that starts at &0D6B
Secondly, to get the correct value bytes in memory (3435 decimal) that clears the screen. To demonstrate
we use the POKE command. The rather inelegantly it, let’s call it directly from Basic by entering:
termed POKE needs two parameters, or numbers to go
with it, separated by a comma. It needs the location we LET X=USR 3435
want altering, followed by the number we want it As you’ll see, it works. What I want to do, though, is to
68 f The Complete Spectrum
Memory address |1 28672 28673 28674 28675
Contents of
memory location 205 107 13 201
1
CALL lo byte hi byte I
Meaning of the subroutine RETurn
above bytes at address Address of subroutine from whence
specified by next required by previous byte you came
two bytes (lo byte first)
call this routine from one of my own machine code if it’s there. When you are ready, call your routine with:
programs. After all, I might want to clear the screen in
the middle of one of my magnificent machine code LET X«USR 28672
creations, and I don’t want to have to go into Basic to and your screen should clear. Well done - your first
do it. machine code program that actually has a visible
The Z80 has a useful instruction that lets us call (or effect. Type some rubbish on to the screen, then:
“gosub”) to another machine code routine - the code
for it is &CD (205). You give the Z80 the address you LET X=USR 28762
want it to ‘‘gosub” to in the two bytes directly following again. As you’ll see, your routine is still there. Now
the &CD in memory. So to clear the screen with the take care with your machine code programs - it’s ail
routine at &0D6B you might think we want the too easy to
i crash your machine or wipe out your
following sequence of bytes in memory: ]
program. For instance, try:
LET X=USR 0
and you’ll see what I mean. If you now try the routine,
You’d be wrong though. The Z80 expects memory you’ll see that your code has gone. It’s often tiny errors
addresses to be given to it ‘‘back to front” - that is, lo that cause such disasters. The solution is simple —
byte first, followed by hi byte. So to call the routine at check and recheck before each Enter.
&0D6B the sequence is: As I mentioned last time, you can get special
programs called assemblers that let you type in your
programs in the more meaningful mnemonics rather
than as a list of bytes. If you wrote the above program
on an assembler and then listed it, it would look
The mnemonic for &CD is CALL, by the way. something like Figure IX.
However, we’ve missed out something very important
in our program - the RET (&C9). So our compiete address opcodes mnemonics
sequence of bytes, starting at memory location &7000 7000 CD 6B OD CALL &0D6B
(28672), would be: 7003 C9 RET
Figure VIII illustrates the program. The mnemonics are what would be typed into the
Now let’s get the program into memory. Enter: assembler. The address column shows the address of
POKE 28672,205 the starting byte for each instruction, and the opcodes
POKE 28673,107 column shows the opcode and associated data bytes
POKE 28674,13 for each instruction.
POKE 28675,201 • Well that*s aUfor this time. In the next part qf the
series well be looking at better ways of entering
If you like, you can check up on it with PEEK to machine code — and learning some new instructions.
The Complete Spectrum / 69
RAM
upgrade
Stuck with 16k? We help point
the way to adding extra memory
to earlier Spectrums
A notable exception
If you have the very early Issue 1 Spectrum, then it is
not at all easy to fit an upgrade internally, so don’t try.
You would just destroy its antique value. Issue 1
Spectrums can be identified by the fact that the rubber
keys are grey rather than bluish. If you still aren’t sure,
open it up and you will find the issue number printed on
the circuit board.
You will also notice that it isn’t fitted with a flock of
empty sockets, but only two, which is why it is difficult
to fit the chips. In fact these sockets are meant for
fitting an upgrade circuit board that used to be supplied
by Sinclair. Issue I hasn’t been made since 1982
though, so there aren’t that many about.
In PartThree...
We help you explore further into the
ever-growing world of the Spectrum!
Databases - what they are and how to get the best from them.
Printers and interfaces - why you need them, and how they work.
Speech - how it can give an extra dimension to your Spectrum.
Upgrades - we compare all the latest Spectrum keyboards.
Breakdowns - what to do if your Spectrum ever lets you down.
And there are the regular features on Basic, machine code, and
colourful articles on graphics and animation techniques.
Plus pages of hints and tips to help you get the best from your
Spectrum.
On sale March 7
i A
>
^ BATTLE SCENES. if
■
1'
u.
SPECTRUM48k
Ocean House • 6 Central Street Manchester • M2 5NS • Telephone 061 832 6633 • Telex 669977
Ocean Software is available from selected branches of:(^^),WHSMITH ,^^SSSB!S,WOOiWORTHXUSKiS.Rumbe\ows,Greens
Spectrum Shops and all good software dealers.Trade enquiries welcome.
I £99.95
Rec. price
Our price 1 £69.95
SAVING 1 £30.00
K background colour.
Table 1: INK colours
The Saga 3
Elite Keyboard
Give your Spectrum the sheer
elegance it deserves with this
top-of-the-range keyboard from
Saga. It’s the finest you can buy.
With the keyboard and the number
pad you get a total of 87 keys, and SUITABLE FOlR: Rec. price 1 £79.95
a massive 27 of them are Spectrum 48k y Our price 1 £69.95
auto-shifted. Spectrum + y SAVING 1 £10.00
DKTronics 3 Channel
Speech Sound
Synthesiser Synthesiser
There’s an almost infinite Add a totally new dimension to
vocabulary tucked away in this your sound. Program music
popular speech synthesiser. It’s with harmonies, explosions,
extremely easy to use, as zaps, and more. Comes
everything you want your with an audio amplifier
Spectrum to say is entered in and a pad - mounted
normal English. The result is 4" speaker.
realistic speech that is ^
instantly recognisable.
SUITABLE FOR: SUITABLE FOFi.
Spectrum Spectrum y
Spectrum + y Spectrum +■ y
Opus
^o;
Discovery
In one simple step you can
transform your Spectrum into a
complete computer system. It
combines a powerful disc drive with
a wide range of interfaces capable of
running printers, monitors, joysticks
and other peripherals. No other
system can offer your Spectrum so
niany options.
Put yourself in the picture with the Standard ront single height
most revolutionary add-on yet created standard font double height
for the Spectrum. Draw on the screen Bot. font sittBlc hea9ht
as youVe never been able to before. Bold font double height
Bring your pictures to life with aaai tont s inglb hb ight
glowing colours. And put windows,
icons and pull-down menus into your mi PonT mm
own programs! Italic font sinsie hei.ght
Italic font dOUttO hOiSht
EXt CUTE
«our
CrtNCEL
Brother Printer
A feature-packed printer from one of
Japan’s best-known manufacturers,
it prints on both thermal and
ordinary plain paper.
SPECTRUM
ZV rATBR il-^1
way 11 iiiusi oe loiioweo oy a semi-coion, oinerwise me
30 PRINT “This Is a message”
Spectrum gets confused and generates an error.
The second command associated with colour is
40 GO TO 10
54 / The Complete Spectrum
e software offers
Dawn of a new age!
Laser Basic is the first in a
powerful range of development
tools for fast programming.
All the
skill and
tension of
The chart-topping international
3 part adventure show jumping
comes on captured in
two cassettes - this gripping
and will give you simulation.
many hours of
enjoyment! Rec. price \ £7.95
Our price I £5.95
SAVING I £2.00
Rec. price \ £9.95
Our price | £7.95
SAVING 1 £2.00
ONLY £3.95
£ P
The Complete Spectrum Peripherals
Parts 3-6; Speech Synthesiser. . £19.95 9043
UK, Eire . .£6.00 9013 * DualJoystickport. . £10.00 9044
Europe . .£10.00 9014 _ * Programmable Joystick Interface . . £18.95 9045
Overseas . .£18.00 9015 * 3 Channel Sound Synthesiser . . £22.95 9046
Issue No. 1: Lightpen . . £14.95 9047
UK, Eire . .£1.75 9016 Parallel Centronics Interface . . £29.95 9048
Europe . .£2.25 9016 Formula 1 Joystick. .. £13.95 9049
Overseas . .£2.75 9016 — Formula 1 Joystick and Interface ...,. £18.90 9062
Add an extra 95p and we'll also
send you Issue 1. 9020 CZl
Software^
Binder Laser Compiler .£7.95 9057
UK . £3.95 9030 Laser Basic .£10.95 9055
Europe/Overseas.£6.95 903 Never Ending story.£7.95 9058
They Sold a Million .£7.95 9059
Rambo .£5.95 9060
Showjumping .£5.95 9061
Dust Covers Mini Office .£3.95 9001
Spectrum Dust Cover 5 or more items — deduct .£5.00 9099
UK .
Europe/Overseas.
Spectrum + Dust Cover
£3.95
£6.9 5
9035
9036 B Disc Drive
UK .
Europe/Overseas.
£3.95
£6.95
9037
9038 B OPUS DISCOVERY 1
Includes all interfaces
and power supply (UK only) £149.95 9100 □
Keyboards
Saga 3 Elite (UK only).£69.9 5 9041
DK'Ironies Keyboard (UK only) ....£27.95 9042 B. Printer
BROTHER HR5
ZX Spectrum
Includes 4 fonts
and paper (UK only) £89.95 9101 □
Expansion Pack
(UKonly) . £69.95 9040 □ AMX Mouse
Order at any time of the day or night Complete with
interface and software (UK only). £59.95 9102 \ |
Telephone Orders: Orders by Prestel:
061-429 7931 Key *89, then 614568383
AH prices include postage, packing and VAT
Don't forget to give your name, address and credit card number Overseas orders sent exclusively by Air Mail TOTAL
□ A ccess/Mastercharge/Eurocard
[ L.J_l_J Li i 1 J 1 1 1 1 i 1 1 1 1 1
□
Cheque/PO made payable
to Database Publications Ltd.
Name _
Address
Post Code
Signed
Don't forget to provide: Your address, your cheque/credit card No.
C/) Q m Tl H
00 c 30
o
o O o m ®
TT 3-T3 m O
*0 o
TUCK INTO FLAP
CD 0)
O o
■1 O 3
o wa
Wi 30
C
£
o <0 CD
s4 0)
a T3
z CD
O
< i-f
C
3