FORMULA 1
by P Crighton
from ZX Computing Jun/Jul.1985

Get into gear with P. Crighton's version of this
ever-popular game, driven all the way from Gravesend.


Apart from the enjoyment of this game in itself, there is an
interesting High-Score routine which can be easily adapted
to work within your own programs.

This is really two programs that have been combined to
produce one program. The first two lines dimension the
arrays required by the high score routine. then there is the
game itself, between lines 10 and 200, and finally a high
score routine situated from line 9000 to the end. The high
score routine requires about 2.5K of memory, and the game
needs enough memory for a full display file, i.e. 3.25K.
Together they require just 4K of memory.

In the driving skill game a road scrolls up the screen and
you must steer your car, an 'H', down the road with the
cursor keys '5' and '8', avoiding the black road edges and
other cars, symbolised by inverse 'H's, which increase as
your score increases. Your car leaves a trail of tyre marks
behind as it travels. When you crash your score is displayed
at the bottom of the road and the program executes the high
score routine. If your score was lower than the fifth high
score then the routine informs you and prints the five
highest scores. If you gain a high score then you are asked
to enter your initials and again the high scores are
printed. When printing the high scores, if two or more
scores are identical then they are given equal placings.

The high score routine could be used with almost any other
game provided that the program it is to be used with obeys
certain rules. First, the program must not use the arrays B
or B$. The score must be held in the variable S, and lastly
line 9230 must contain either a RETURN, if the routine was
called by a GOSUB instruction, or a GOTO to return it to the
game, but at a line after the arrays mentioned above have
been dimensioned.


Detailed notes about the program

Lines 2 & 3     dimension the arrays required by the high score routine
Lines 10-60     set up the variables used by the driving skill game
Lines 70-90     alter the position of the road
Line 120        peeks the display file at the next position of the car
Line 130        increases the score
Line 140        prints the road and your car
Line 150        prints the inverse Hs to represent the other cars
Line 160       jumps back to line 60 if you have not crashed
Lines 170-190   flash your car when you crash
Line 200        prints your score at the bottom of the road
Lines 9000-9010 form a pause loop at the beginning of the high score routine
Line 9030       checks if your score is lower than the fifth high score
Lines 9040-9070 move the high scores down one place until it reaches the
                point where your score is to be placed and then jumps to
                line 9180
Line 9180       enters the subroutine to get initials
Lines 9190-9200 enter your score as a high score
Lines 9210-9310 print the high scores
Line 9320       jumps back to the game
Lines 9400-9470 form a subroutine to save the program and high scores on tape
Lines 9500-9530 subroutine to print lower score than the fifth high score
Lines 9600-9740 is a subroutine to print equal placings
Lines 9800-9830 subroutine to obtain initials


Variables used for the game

C,D             co-ordinates for the road
F               for/next loops
S               score
W               display file peek for a crash
X,Y             co-ordinates for car
Z               co-ordinates of previous position of car


Variables used for the high score routine

B(x)            high score x
B$(x)           initials x
F               for/next loops
G               for/next loops
I$              current initials
S               current score
X               for/next loops
Z$              save name


Graphics notes

Line 140        2 inverse spaces, 4 graphic As, 2 inverse spaces, 1 graphic H
Line 150        1 inverse H
Line 180        1 inverse H
Line 9220       9 inverse spaces, inverse "HIGHEST SCORES", 9 inverse spaces


-- end of file --
