SCRAM-81 for Sinclair ZX-81
by Philip Harwood
from Your Computer, November 1983 (part 1)

Philip Harwood takes you through hazardous canyons
in the first part of his Scramble-like program for the ZX-81.


THIS PROGRAM, SIMILAR to the arcade game Scramble, reflects all the
usual features, including the six different levels, on-screen scoring
and fuel gauge, bombing and firing, missiles and fuel dumps etc., and
consists of about 4K of data and 3K of machine code. It has been split
into two major sections: the moving background which includes all the
enemy missiles and targets; and the cover screen which superimposes
the aircraft and bombs onto the background and deals with the scoring,
fuelling and the main controlling.

All the machine code is stored in REM statements and should be entered
in hexadecimal using the hex loader provided. This hex loader will
allow machine code to be input from the start address which it is
given in decimal, starting at 16514. The machine code can also be
listed for the correcting of errors.

The first page of this program is concerned only with the background
and initial space should be reserved by typing a REM statement - line
1 - with 521 characters; this can be edited to create lines 2 to 7.
Now enter REM statements 8 to 13 with the lengths indicated in table
[1.1]. Check the start and finish addresses for each line number by
POKEing the end addresses with 128 and listing the lines to make sure
that the black squares are at the ends of the lines.

Only when you are sure that all the lines are of the correct length
must you enter the hex loader. Lines 50 and 6999 are required because
of the BASIC programs which help to test the machine code. [Line 50
was missing from the hex loader listing (it probably should have been
GOTO 7000) and line 6999 was a REM (he probably meant the STOP at
6998). JimG] Lines 1-8 and 13 contain the 4K data for the background
terrain. Actual machine code only appears in lines 11 and 12.

Enter all the data for REM 1 and SAVE it onto a cassette. Saving at
regular intervals is important, especially before RUNning machine
code. Next enter all the machine-code sub-routines into REM 11 -
addresses 20704 to 21073. These routines can be tested by BASIC
programs. Now enter the data for REM 10.

Enter lines 100 to 170 of the BASIC test program and RUN 100. A moving
background with missiles which take off, should appear. If the program
crashes immediately, check addresses from 20704 to 20845. If a crash
appears at a random point - check the data.

Between the first few levels, there is a filler screen which enables a
smooth change between the levels. Enter this data into REM 13 - 21260
to 21324 - and lines 180 to 230 of the test program. Run 100.

This complete, enter the data for REMs 2 and 3. Enter lines 235 to 400
of the test program. Check addresses 20846 to 20983 and/or the data if
a crash occurs.

The data for the height of entry, counting down from the top of the
screen, is held in REM 9 - 20330 to 20459. Enter this data and also
the data in REM 4 for the background.

The distance between the arrows can be increased only: address 20989
holds half the distance between the arrows. Enter lines 405 to 570 of
the test program to test this level. If this level works, then all the
machine code in REM 11 is entered correctly and tested by now. Level
three uses addresses 20984 to 21073.

As levels 4, 5 and 6 use the same subroutines as before, it is not
necessary to have BASIC to control/test them. Enter the data in REMs 5
to 8 as before. The BASIC must now be converted to machine code which
ideally should be called by a single RAND USR statement. This machine
code is contained in REM 12 - the background controller - 21080 to
21253. Enter this code and check it.

Delete the BASIC test program, line by line, and insert the following:

100 POKE 20476,1
110 POKE 20474,0
120 POKE 20475,0
130 POKE 20476,((PEEK 20476)-1)
140 CLS
150 PRINT AT 1,0;"(32 x graphic G)"
160 RAND USR 21080
170 IF INKEY$="" THEN GOTO 160
180 GOTO 110

The complete background should now be available. If a crash appears at
a random point, check the relevant data for the background. Pressing
any key should start the background at the beginning of the current
section. Level six repeats itself until the break key is pressed.


Table 1.1. Data storage for part one - background.

  Rem  Length  Start add  End add  Type
-----------------------------------------------------------------
   1    521      16514     17034   data
   2    521      17041     17561   data
   3    521      17568     18088   data
   4    521      18095     18615   data
   5    521      18622     19142   data
   6    521      19149     19669   data
   7    521      19676     20196   data
   8    121      20203     20323   data
   9    130      20330     20459   data
  10    232      20466     20697   data
  11    370      20704     21073   m/c
  12    174      21080     21253   m/c
  13     65      21260     21324   data



SCRAM-81 for Sinclair ZX-81
by Philip Harwood
from Your Computer, December 1983 (part 2)

Philip Harwood completes his Scramble-type game for the ZX-81
with details of aircraft movement and firing systems.


WE NOW MOVE INTO part two of the program for Scram-81. This is where
the aircraft and other features of the game are added. Reserve more
space for the machine code by creating REM statements 14 to 18 of
lengths indicated in table [2.1]. Check the addresses as before.

The aircraft and bombs etc. are held on a separate screen which is
superimposed onto the background and erased just before the background
is moved. The time of erasure is kept to an absolute minimum to avoid
any excess flickering of the screen. Enter the machine code for REM
14. This deals with the movement of the aircraft.

In addition to the last BASIC program, add or change the following:

131 LET F=20499
132 FOR G=1 TO 6
133 POKE F,22
134 POKE F+1,3
135 POKE F+2,0
136 LET F=F+3
137 NEXT G
138 POKE 20488,185
139 POKE 20489,2
141 POKE 20480,0
142 POKE 20486,21
143 POKE 20487,3
155 RAND USR 21331
170 RAND USR 21355
180 IF PEEK 20480=0 THEN GOTO 155

The aircraft should now appear and is controlled by the keys A - up, Z
- down and M - forward. Note that two keys can be pressed simultaneously
to give diagonal movement. There is a limit to how far the aircraft
can move forward, this can be adjusted by POKEing address 21506.

REM 15 contains seven subroutines:

Screen score            21557-21583
Score character convert 21584-21602
Fuel gauge              21603-21643
Refuelling              21644-21680
Down scroll             21681-21721
Crash flash             21722-21746
Success graphics        21747-21856

These subroutines cannot be tested properly at the moment but they
should he entered just now.

Bombing and firing is held in REM 16. This should he entered.
Also add:

172 RAND USR 21978  - firing
173 RAND USR 22074  - bombing
174 RAND USR 21603  - fuel gauge

Keys 1 to 5 operate the bombs and Return fires the bullets. There is a
maximum of two bombs and four bullets. Before Running - 100 - add the
following lines in Basic:

151 PRINT AT 0,0; "SCORE 00000"
152 POKE 16418,0
153 PRINT AT 23,0; "FUEL (25 x graphic 6) graphic H"

Enter REMs 17 and 18. These are the two main reset/controller
programs. If the machine code has been entered correctly type:
	RAND USR 22411
and the complete game should RUN. To break into it, press the zero
key. If it works, then congratulations, if not then check the machine
code for part two. If you wish to add a title page then POKE addresses
22801 and 22775 with 201. This will let the program return to BASIC at
the end of every game where a title page in BASIC can he added.

To complete the program, delete all the BASIC except the initial REM
statements and add:

50-100	title page (if desired)
150 RAND USR 22411
160 GOTO 50


Table 2.1.

  Rem  Length  Start add  End add  Type  Purpose
-----------------------------------------------------------------
  14    220      21331     21550   m/c   move the aircraft
  15    300      21557     21856   m/c   subroutines
  16    323      21863     22185   m/c   bombing and firing
  17    213      22192     22404   m/c   reset subroutines
  18    393      22411     22803   m/c   drive/controller program

