LDA TYPE \ If this is not a missile, skip the following CMP #MSL \ instruction BNE P%+5 JMP TA20 \ This is a missile, so jump down to TA20 to get \ straight into some aggressive manoeuvring CMP #14 \ If this is not a large ship that can spawn smaller BNE TN7 \ ships (e.g. an Anaconda or Dragon), which will be in \ slot 14 in the ship files, jump down to TN7 to skip \ the following JSR DORND \ Set A and X to random numbers CMP #200 \ If A < 200 (78% chance), jump down to TN7 to skip the BCC TN7 \ following LDX #15 \ Set X to the ship in slot 15, which will be the kind \ of ship that the large ship in slot 14 can spawn \ (e.g. an Anaconda can spawn a Worm, while a Dragon can \ spawn a Sidewinder) JMP TN6 \ Jump to TN6 to spawn the Worm and return from \ the subroutine using a tail call .TN7 JSR DORND \ Set A and X to random numbers CMP #250 \ If A < 250 (97.5% chance), jump down to TA7 to skip BCC TA7 \ the following JSR DORND \ Set A and X to random numbers ORA #104 \ Bump A up to at least 104 and store in the roll STA INWK+29 \ counter, to gives the ship a noticeable roll .TA7 LDY #14 \ Set A = the ship's maximum energy / 2 LDA (XX0),Y LSR A CMP INWK+35 \ If the ship's current energy in byte #35 > A, i.e. the BCC TA3 \ ship has at least half of its energy banks charged, \ jump down to TA3 LSR A \ If the ship's current energy in byte #35 > A / 4, i.e. LSR A \ the ship is not into the last 1/8th of its energy, CMP INWK+35 \ jump down to ta3 to consider firing a missile BCC ta3 JSR DORND \ Set A and X to random numbers CMP #230 \ If A < 230 (90% chance), jump down to ta3 to consider BCC ta3 \ firing a missile LDX TYPE \ Fetch the ship blueprint's default NEWB flags from the LDA E%-1,X \ table at E%, and if bit 7 is clear (i.e. this ship BPL ta3 \ does not have an escape pod), jump to ta3 to skip the \ spawning of an escape pod \ By this point, the ship has run out of both energy and \ luck, so it's time to bail LDA #0 \ Set the AI flag to 0 to disable AI, hostility and STA INWK+32 \ E.C.M., so the ship's a sitting duck JMP SESCP \ Jump to SESCP to spawn an escape pod from the ship, \ returning from the subroutine using a tail callName: TACTICS (Part 4 of 7) [Show more] Type: Subroutine Category: Tactics Summary: Apply tactics: Check energy levels, maybe launch escape pod if low Deep dive: Program flow of the tactics routineContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
This section works out what kind of condition the ship is in. Specifically: * If this is a large ship that can spawn smaller ships, such as an Anaconda or a Dragon, then consider spawning (22% chance) a Worm * Rarely (2.5% chance) roll the ship by a noticeable amount * If the ship has at least half its energy banks full, jump to part 6 to consider firing the lasers * If the ship is not into the last 1/8th of its energy, jump to part 5 to consider firing a missile * If the ship is into the last 1/8th of its energy, and this ship type has an escape pod fitted, then rarely (10% chance) the ship launches an escape pod and is left drifting in space
[X]
Subroutine DORND (category: Maths (Arithmetic))
Generate random numbers
[X]
Variable E% (category: Drawing ships)
Ship blueprints default NEWB flags
[X]
Configuration variable MSL = 1
Ship blueprint position for the missile
[X]
Subroutine SESCP (category: Flight)
Spawn an escape pod from the current (parent) ship
[X]
Label TA20 in subroutine TACTICS (Part 7 of 7)
[X]
Label TA3 in subroutine TACTICS (Part 6 of 7)
[X]
Label TA7 is local to this routine
[X]
Label TN6 in subroutine TACTICS (Part 2 of 7)
[X]
Label TN7 is local to this routine
[X]
Temporary storage, used to store the address of a ship blueprint. For example, it is used when we add a new ship to the local bubble in routine NWSHP, and it contains the address of the current ship's blueprint as we loop through all the nearby ships in the main flight loop
[X]
Label ta3 in subroutine TACTICS (Part 5 of 7)