
SINCLAIR PROGRAMS
May/June 1982
ZX80 Contents

AVOIDING THE ZX-80 OVERFLOW
CHASVADERS
GRAFFITI
POETRY
STOPWATCH
WIZARD WIZ
ZX80 STRING SORT (1K ZX80)


AVOIDING THE ZX-80 OVERFLOW

WITH MOST mathematical operations on the ZX-80, care must be
taken to avoid arithmetic overflow. That can be done by
defining input limits to avoid a program crash but it can
involve a good deal of calculating.

This program, by G A Rooker of Hendon, demonstrates a better
method of avoiding arithmetic overflow, in this case for an
exponentiation calculation.

Lines 80 to 120 test to see if the expression 32767/A**B is
less than unity. If it is, then A**B is obviously greater
than 32767 and the calculation at line 130 is avoided. The
principle can be applied to other calculations. The program
fits in 1K.


- - - - -
CHASVADERS

FROM 15-year-old Charles King-Cox of Appleby is a
self-titled version of 1K ZX-80 Space Invaders. Five
Chasvaders are landing on earth and you - equipped with the
best technology earth can muster, a 1K, old ROM ZX-80 - must
stop them. Unfortunately, the game is impossible to win,
because if you destroy them all they produce another five.
That continues until you are blown up or the Chasvaders land.

You have two missile bases - Earth has spared no expense in
its defence. One of the bases is positioned somewhere
beneath the invader on the right and you have to wait until
it is directly above you to fire, which you do by pressing
F. You have only five shots for each brace of Chasvaders.

The plucky player scores 200 for every Chasvader destroyed,
although you lose 10 points for every shot you fire. There
is a bonus of 50 if you shoot all five invaders, making a
grand total for the round of 1,000. The highest score we
could obtain playing the game in office was 3570. Try to
beat that.

Keeping pressing NEWLINE over and over again to keep the
invasion under way, unless you want to fire, when you press
F before NEWLINE.


- - - - -
GRAFFITI

GRAFFITI is written for a 1K ZX-80 and fills the screen with
large letters; a 32-letter message can be fitted on to a 1K
machine with four lines of eight characters each.

Messages are entered eight characters at a time and if an
inverse letter is wanted, for example A, enter it as NOT A.
That still counts as one character. To put a quotation mark
in the message, enter shift H ie (**).

Graffiti is from The Gateway Guide to the ZX-81 and ZX-80 by
Mark Charlton. Published by Interface of 44-46 Earls Court
Road, London W8 6EJ.

[I've reviewed the 'corrupt' listing of the ZX80 program GRAFFITI from
[Sinclair Programs May/June 1982. I've noticed that lines 110 and 140 were
[incorrect compared to the magazine listing. I've corrected the program and
[it now runs ok.

[To avoid confusion using the program, I suggest amending the second
[paragraph of the instructions for the program to state that NOT is obtained
[by pressing SHIFT and 1:

["Messages are entered eight characters at a time and if an inverse letter is
[wanted, for example A, enter it as NOT A [NOT is obtained by pressing
[SHIFT+1]. That still counts as one character. To put a quotation mark in the
[message, enter shift H ie (**). "                                      PaulF]



- - - - -
POETRY

A VALIANT attempt to write poetry within 4K is made
by Poetry. It is very slow, taking up to five minutes to
write a single poem, which fills the screen. The words used
are stored in four long strings and the computer searches
the string until it finds an asterisk; it then uses the word
which follows that randomly-selected asterisk. From time to
time the ZX-80 will stop writing to let you admire what it
has written. A tap on NEWLINE will re-start it. To make it
run on a ZX-81, change the way random numbers are generated
and change lines 70 and 140 to LET A$=A$(2 TO).

Change all the asterisks in the strings into the letter X
and change the 222 in lines 90 and 150 into 63. If you run
it in slow, delete line 120.

Poetry is from the The Gateway Guide to the ZX-81 and ZX-80
by Mark Charlton. Published by Interface of 44-46 Earls
Court Road, London W8 6EJ.

[I've compared the 'corrupt' listing of the ZX80 program POETRY from Sinclair
[Programs May/June 1982 with the original version published in The Gateway
[Guide to the ZX80 and ZX81. I found that line 150 was not reproduced
[correctly in the Sinclair Programs listing. I've corrected this and believe
[the program is now functioning as intended.

[The Gateway book shows a poem created and states that the author has
[punctuated the output. Although the fixed program still appears to output
[gibberish, I think this is simply what it does and it is left up to the user
[to mentally insert punctuation. I suggest adding the following text (taken
[from the Gateway book) to the bottom of the instructions for the program to
[make this limitation more apparent:

[Note that it is up to the user to mentally punctuate the
[output from the program, as described and shown in the
[The Gateway Guide to the ZX-81 and ZX-80 page 92:

["To show how 'great' are the poems the computer can write,
[here is one (which I have punctuated) written by the program.

[IN FEAR, LOVERS PASSING
[IF ONLY PARTING -
[BUT PARTING IN FEAR.
[LOVERS SHARING,
[IF ONLY SHARING QUICKLY
[IF ONLY SUNLIGHT.

[BOTH APPEARED,
[APPEARED.
[GENTLY IN FEAR.......LOVE

[BOTH LOVERS,
[PARTING LOVE, LOVE.
[SUNLIGHT APPEARED, TO PARTING
[PASSING, SHARING.
[PARTING LOVERS QUICKLY.

[It can take five minutes to write a single poem which fills]
[the screen."                                          PaulF]


- - - - -
STOPWATCH

ANDREW GOODRIGHT from Cheam, Surrey, sent this ZX-80
Stopwatch game, in which you have to guess the time elapsed
from a starting point, the ZX-80 naming a time and the
playing, starting and stopping the clock. The computer also
rates your efforts.

You get 10 points if you are within two seconds of the
correct time, eight points for being within two to three
seconds of the time, six points for four to six seconds,
three points if you are between seven and 10 seconds, and no
points if you are more than 10 seconds out.

The variables:

J - The number of tries the player has had.
P - The player's score.
N - The time for which the player is aiming.
TE - The time the player achieves.

Note that the program works by accessing the ZX-80 frame
counter - addresses 16414 and 16415. Goodright has used the
popular convention of an underlined asterisk (*) to indicate
a space in this listing.


- - - - -
WIZARD WIZ

WIZARD WIZ, or a plastic version of it, is better known as
Mastermind marketed by Invicta. The computer picks a
three-digit code using the numbers one to nine, without
repeating any digits. You enter your guess for the number -
as one three-digit number - and then press NEWLINE.

A correct digit in the correct location will give you a
'black' - an inverse digit - while a correct digit in the
wrong place will score a 'white'. There are 10 guesses
allowed to crack the code but remember not to use the same
digit more than once in a single guess.

The program is written for a ZX-80 but will need more memory
on a ZX-81 and needs the following changes. In line 40 alter
the way the random number is generated and add INT before
the brackets on the right-hand side of the equals sign in
lines 100, 110, 120, 290, 300 and 310.

Wizard Wiz is from The Gateway Guide to the ZX-81 and ZX-80
by Mark Charlton, published by Interface of 44-46 Earls
Court Road, London W8 6EJ.


- - - - -
ZX80 STRING SORT (1K ZX80)
by John Edwards
from Sinclair Programs 1 (May/June 1982), page 30

THE ZX80 String Sort routine, which occupies only 306 bytes,
was written by John Edwards of Coventry. He writes: "The
only place to store strings in the ZX-80 is in the VARS
store, there being no DIM A$. So to sort strings into
alphabetical order, it is necessary to work in that section".

Lines 7 to 18 allow you to enter eight strings, each called
A$ at first and then POKEd to H$ to A$. Subroutine 48 looks
through 110 bytes of VARS to find the address of A$ to H$
(134 to 141) and stores that numerical information in A (0
to 7). Subroutine 30 swaps the names of two adjacent strings.

Lines 71 to 80 are a bubble sort. The POKEs change the A and
B in line 75 to become B$ and C$, C$ and D$, D$ and E$, and the
like as I changes. That saves a good deal of space - and typing;
16674/7 is the number of bytes from the start of the program (+16424)
to the A$ and B$ on line 75.

To search all the VARS section, use:

   40 LET L=PEEK (16394)+PEEK (16395)*256
   48 FOR Q=0 TO L-V

Lines 73 and 74 will also need altering.

[I've investigated the 'corrupt' listing of the ZX80 program STRING SORT from
[Sinclair Programs May/June 1982. The program clever self-modifies the BASIC
[program when perform the bubble sort. However, lines 73 and 74 which POKEd
[16675 and 16378 need to be 16674 and 16677.

[I've created a bug fixed version of the program and also revised the
[instructions to match. I've made the instructions a little clearer as to
[what the program is doing (I've changed the paragraph starting 'Lines 71 to
[80...' onwards).                                                      PaulF]

- - - - -