DEEP SPACE (16K ZX81)
by Adrian Spriddell
from Your Computer February 1983), Pages 60-62

Stars and planets may be standard fare for your megatrawler, but black
holes, white dwarfs and anti-matter will give you indigestion on a cosmic
scale in Adrian Spriddell's ZX-81 game.

With the growing number of video inverters on the market for the ZX-81, I
thought it was about time some games were written for use with one.

"Deep Space" is mostly in BASIC with four short machine-code routines to
animate the display.

A galactic megatrawler is cruising through the computer-generated universe
eating stars. Black holes, white dwarfs and anti-matter are already in the
program but as is it in BASIC, you can add your own pet horrors at will.

Attacks by alien craft are frequent, although escape from these is possible
by engaging "hyperdrive" to re-materialise in a fresh - and unknown -
universe. The game can develop in different ways depending on whether you
prefer to stay and fight or run and hide.

It will, of course, run perfectly well on any 16K ZX-81 but the display
loses a deal of its visual effect. Hints are given later for a suggested
improvement if you wish to try.

The variables are as follows:

S              High score
A              Shield strength
B              Game score
C and G        Initial numbers of stars and white dwarfs in each line of the display
D and E        Define the position of your ship
P              Top left-hand corner of the screen - all other points on the display
               are calculated from this
W              Initially a white dwarf, changed under attack to an alien spacecraft
T              Part of the random number multipler. Reduce this to 1000 to make
               attacks come faster
F              Your current position on the screen
H              Denotes attacks and black holes
M              Defines the first print position in the line in which the stars need
               to be reprinted after scrolling
N              Adjust the unprinting position of your ship which will no longer be
               in line 12 after a scroll

V, X, Y and Z are used to call the various machine-code routines and have
no particular significance themselves. V is the title page background X and
Y are the scrolls up and down and Z inverts the display file.

Line 45-70 print the initial universe and line 72 tests to see whether or
not it is composed of anti-matter and sends you the "End of game" routine
at line 450 if it is. The main loop starts at line 80. If you are altering
the game, keep this loop as short as possible or you will slow things down
unnecessarily.

Lines 85-87    Check whether a star, dwarf or alien has been encountered and send you the
               approrpriate sub routine.
Line 90        Random-number generator.
Line 110       Steers your spacecraft horizontally.
Lines 120-121  Take you out of the loop to scroll in either direction.
Line 122       Sends you to the subroutine at line 600 to make a hyperspace jump.
Line 130       Returns you to the start of the loop.
Lines 140-153  Print the correct numbers of starts after using the scroll routines at 300 or 400.
               Both these work in the same way with 300 scrolling down and 400 scrolling up.
Lines 460-470  Restore your shields to full power and increment your score by 10 if you manage
               to catch an alien.
Line 500       Checks the random number multiplier to see if you are being attacked.
Line 520       Switches to attack mode.
Line 529       Checks for a direct hit.
Line 550       Pokes the alien ships.
Line 560-570   Adjust and check your shields.
Lines 600-620  Produce the white dwarf crash whilst.
Lines 701-708  Make the stars sparkle as they are eaten.

If you want to alter the initial title page or instruction routine do
ensure that you return the machine code to Game Scroll by Poking 16580,0
otherwise you will have columns of stars printed each time you move upwards.

As you play the game you will find that you are much more likely to be
attacked in a hevaily-populated universe than in a dead one, and that there
are universes in which you stand a good change of catching alien ships and
building a high score.

If you do not have a video inverter, the display can be greatly inproved by
using the alternate machine code that yields a white on black display.
