Click Here To Go To The Your Computer Archive



Written By Nick Sheard


Cover Art
Click Here To Enlarge Loading Screen

Loading Screen
Click Here To Enlarge Opening Screen

Opening Screen
Click Here To Enlarge Screenshot

Game Screenshot

Tanks

TANKS In Action

Tanks is an arcade-style game for the BBC Micro with Operating System OS 1.2. The program features machine-code, flicker-free, high-resolution graphics, with independent rotation of the tanks' turrets and chassis, music, animated lives and a high-resolution title page.

To get the program saved on tape, first type in listing 1 and save it as TANKS1, then type in listing 2 and save it as TANKS2 on a different tape. Run TANKS2 and a series of rotations of tank's chassis, turrets and trees will appear on the screen followed by the message "Record then RETURN".

Start your tape recording straight after TANKS1 and press RETURN. Finally, type in listing 3 and save it as TANKS3 after TANKSDATA. To load the game CHAIN "TANKS1", which will draw the title page and automatically load the other sections.

When the whole program has loaded, the instructions will be displayed. The object of the game is to destroy all enemy tanks - those with crosses on their turrets - by cleverly chasing and ambushing them. You score 100 points for each tank destroyed and 1,000 points for each screen completed.

After losing a life or on starting a new game your tank automatically drives from the barracks at the top right of the screen, to the centre of the screen ready for action, during which the music plays. At the end of the game the last score and the highest score are displayed.

In writing the game the first problem was that, to obtain the necessary independence of rotation of a tank's chassis and turret, a total of 128 3-by-3 character matrices had to be defined, or 1,152 characters, or 9,216 numbers would have had to be typed in. This is obviously a massive waste of memory and would be very prone to error.

The alternative was to separate the turret and chassis into different characters and overlay one of the eight different rotations of each on to the other. This can be done using the BASIC function OR, which affects the bits of two numbers when written in binary such that:

01010100 OR 00110101 = 01110101

It can be seen from this that if there is a 1 in any or both of the corresponding positions of the numbers then a 1 will appear in the corresponding position in the answer. Only where there is a 0 in both of the corresponding positions of the numbers does a 0 appear in a corresponding position in the answer. Thus:

8 OR 53 = 117

Unfortunately, using OR is too slow to produce flicker-free graphics and so I wrote a machine-code subroutine which appears at line 1940 in listing 3. ORA is the equivalent function to OR in assembly language and takes the form:

LDA (first number)
ORA (second number)
STA (on screen)

As you can see I have directly accessed the screen for ease and speed and so second processors must be disconnected before running the program.

With the program altered to accept this only 24 3-by-3 character matrices are required, that is 1,728 numbers to be typed in, which is still too prone to error. The solution was simple, use the BBC's processing power to rotate the shapes - from just two of the most important rotations of each shape entered from the keyboard - to create the remaining rotations and store them in the memory before the game begins. Listing 2 does this by reflecting the shapes in varying lines.

With this entered and working correctly only six of the 128 3-by-3 character matrices that will appear on the screen have to be defined.

If you wish to have a copy of the game, but do not have the time to type it in, it is available from N Sheard, 2 Ashbrook Drive, Prestbury, Cheshire SK10 4BY, on cassette for £4 including P&P.