| Ant Attack | How the game works |
1 RANDOMIZE USR (PEEK 23635+256*PEEK 23636+53)which is PROG plus 53: the machine code sitting after the line's own ENTER. That code loads the big block to $5C00 -- the system variables -- and everything above, to the top of memory. It replaces the running BASIC program with the game's own, 8K of it, and survives doing so because nothing returns to the old program: LD-BYTES is entered with LOADED pushed as its return address. LOADED checks the flags and DE the ROM left (a tape error or a short load resets the machine), switches to interrupt mode 2, and then starts the game's BASIC the way ENTER would: RESTART_BASIC types
RUN into the edit line and jumps into the ROM's statement loop. The header's own auto-run line, 1, starts the loader; nothing would start the game's BASIC that the block brings in, so the game starts it itself.
w) is a rescue.
| Offset | What |
|---|---|
| +$00, +$01, +$02 | x, y and height |
| +$03 | first sprite frame: the boy $DC, the girl $6C, ants $F8 |
| +$04 | facing, 0-3: y up, x up, y down, x down |
| +$05 | frames spent falling |
| +$06 | frames left stunned; $FF on an ant is paralysed for good |
| +$07 | flags: bit 0 may stand on the other person, 1 jump, 2 move, 3 never falls (never set), 4 steps up a one-block rise |
| +$08 | animation frame, or with bit 7 set a sprite frame outright |
| +$09 | explosion countdown, after which the object goes home |
| +$0A-+$0C | home: x, y and height |
| +$0D, +$0E | an ant's speed and its count; the rescued person's state and last distance to the player |
| +$0F | what just happened to it, for HANDLE_EVENTS: a step, a bad fall, a bite, a blast |
sp, which is 2 (half speed) for the first four levels and one more for every four rescues after that.
MOVE_ANT steps the ant the way it faces and compares its distance from the player before and after. Closer: it walks on, and within three cells turns to face the player. Not closer: it stops and turns left or right at random (RANDOM). There is no path-finding; the city's walls do the rest.
A grenade (THROW_GRENADE: S, D, F or G throw for 2, 4, 8 or 16 frames) explodes where it is when the time runs out. BLAST_ANT blows up any ant at the same height within four cells ("GOOD SHOT!") and stuns one within seven. The grenade is checked against the player's and the rescued person's cells on every frame of its flight, not just the last: anything it meets on the way is blown up.
LD DE,31, that routine's own first instruction; both are entered three bytes in, since DRAW_SCENE has already set DE.