This page last updated 07-Jan-01
What's 3D Ant Attack? Find out on the homepage of Sandy White, the author of the game.
While tidying out the attic, I came across some old notes I made while
hacking at Ant Attack on my wee Sinclair ZX Spectrum many years ago; here's the
bulk of what I could actually read. No guarantees are made as to its
completeness, presentation, or accuracy :) . For convenience, the player is
usually referred to as "boy" and the player's hapless mate as "girl".
Somewhere I also have a sparsely-annotated disassembly of the program; if I
find it I'll put it up here.
POKE 32895,12: POKE 32897,4: POKE 32905,8
- Changes the rotation
keys from M and Symbol-Shift to N and M; this makes rotating easier when running
the game under certain emulators, notably the Psion Series 5 one.
POKE 35105,7: POKE 36068,1
- Allows you to jump while standing on
the roof of a tall building (ie 6 blocks high). This may have unexpected side
effects but I haven't seen any yet. For the technically minded, the first poke
changes the maximum altitude you can jump to, and the second lets the engine
draw sprites that high up.
POKE 34754,0: POKE 34758,255
- Grenades will paralyse ants rather
than blow them up.
The city (shown here in all its glory) is mapped in the upper 16k of memory. Each vertical column is represented by one byte - there are 128x128 columns of city space. On this map, the data starts at the left, runs along the top-left wall to the top, then repeats for the next row, until finally the last 128 bytes represent the front wall of the city.
Of each byte, the lower 6 bits indicate the presence of blocks at various heights - Bit 0 (LSB) is a block resting on the ground, Bit 5 is the highest block possible. I think Bit 7 (MSB) is a flag indicating that there is a sprite somewhere in this column. Further, the appropriate bit (it should always be bit 0!) is set in the city byte to indicate the presence of an ant, for collision-detection purposes.
The image to the right is a graphical dump of game memery from 8000-BFFF. The
sprite graphics are clearly visible. Each sprite is 16x16 pixels, represented by
64 bytes of data. For each pixel row (they're stored top-to-bottom), the four
bytes are:
xxxx-7FFF | BASIC Program etc. |
8000-8FFF | Machine code. |
9000-97FF | Text messages. |
9A00-9FFF | Graphics for ammo box and girl. |
A000-AFFF | Screen buffer. |
B000-B17F | ? |
B180-B41F | Buffer holding visible area of city. |
B420-B449 | Data storage B436-7 is the countdown timer. |
B450-B47F | Erm... some kind of table of sprite graphic addresses? |
B480-B48F | Sprite data for boy. |
B490-B49F | Sprite data for girl. |
B4A0-B4AF | Sprite data for grenade/box. |
B4B0-B4BF | Sprite data for ant 1. |
B4C0-B4CF | Sprite data for ant 2. |
B4D0-B4DF | Sprite data for ant 3. |
B4E0-B4EF | Sprite data for ant 4. |
B4F0-B4FF | Sprite data for ant 5. |
B500-B6FF | Data for something? |
B700-BFFF | Graphics for boy, plane, grenade, explosion and ants. |
C000-FFFF | City data. |
One of the program's interesting features is the routine used to display messages during the game. It uses the ROM text printing routines, and can therefore use all the standard control codes for colour changes and cursor positioning. In addition, the routine uses code 125 to change the colour attribute of the whole view, code 126 to display the contents of a memory location in decimal, and codes 128 and above to produce sounds. The messages are:
1 | NASTY FALL! |
2 | "HELP - I FELL!" |
3 | (explosion) GOOD SHOT! |
4 | Display ammo counter. |
5 | Grenade detonation. |
6 | SILLY! YOU BLEW YOURSELF UP! (death march) |
7 | BITTEN! |
8 | Display boy life. |
9 | HOW COULD YOU? AFTER ALL WE'VE BEEN THROUGH? |
10 | "THEY GOT ME" |
11 | Display girl life. |
12 | "MY HERO! TAKE ME AWAY FROM ALL THIS!" |
13 | CONGRATULATIONS! |
14 | EATEN ALIVE |
15 | "I'VE BEEN EATEN ALIVE" |
16 | PARALYSED AN ANT! |
17 | YOU ARE A REAL HERO (etc) |
There are in fact only 8 sprite objects in the game; the boy and girl, five ants, and a grenade (while not being used, it hides outside the city in the form of an ammo box).
This data is usually addressed by the game using the IX register.
Offset | Boy | Girl | Grenade/Box | Ant |
0 | Current X-coordinate (lower-left to upper-right on default view). | |||
1 | Current Y-coordinate (upper-left to lower-right on default view). | |||
2 | Current Z-coordinate (height). | |||
3 | Pointer to graphics data. | |||
4 | Current direction. | |||
5 | Counts depth of fall. | |||
6 | Sleep countdown; 255=forever (paralysed ant). | |||
7 | Bit 0 = allows sprite to stand on other human sprite. Bit 1 = jumping. Bit 2 = walking. Bit 3 = makes sprite immune to gravity. Bit 4 = auto-jump when hitting an obstacle. Set for girl and grenade, works for boy, sort-of works for ants. | |||
8 | Sprite frame: 0=standing, 1=walking, 2=crouching, 3=laying, 4=falling. | Sprite frame: 0=standing, 1=walking. | ||
9 | Explosion frame counter. | |||
A | Initial X-coordinate. | |||
B | Initial Y-coordinate. | |||
C | Initial Z-coordinate (height). | |||
D | 0=lost,1=found. | Initial walking speed delay count. | ||
E | Distance from boy while lost. | Walking speed delay count. | ||
F | Bit 0 = walking. Bit 1 = fell too far. Bit 2 = got bitten. Bit 3 = blown up. |