Skip to navigation

Elite on the BBC Micro and NES

Version analysis of TACTICS (Part 5 of 7)

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: TACTICS (Part 5 of 7) Type: Subroutine Category: Tactics Summary: Apply tactics: Consider whether to launch a missile at us Deep dive: Program flow of the tactics routine
This section considers whether to launch a missile. Specifically: * If the ship doesn't have any missiles, skip to the next part * If an E.C.M. is firing, skip to the next part

Code variation 1 of 2A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

* Randomly decide whether to fire a missile (or, in the case of Thargoids, release a Thargon), and if we do, we're done
* Randomly decide whether to fire a missile, and if we do, we're done
.ta3 \ If we get here then the ship has less than half energy \ so there may not be enough juice for lasers, but let's \ see if we can fire a missile LDA INWK+31 \ Set A = bits 0-2 of byte #31, the number of missiles AND #%00000111 \ the ship has left BEQ TA3 \ If it doesn't have any missiles, jump to TA3 STA T \ Store the number of missiles in T JSR DORND \ Set A and X to random numbers AND #31 \ Restrict A to a random number in the range 0-31 CMP T \ If A >= T, which is quite likely, though less likely BCS TA3 \ with higher numbers of missiles, jump to TA3 to skip \ firing a missile LDA ECMA \ If an E.C.M. is currently active (either ours or an BNE TA3 \ opponent's), jump to TA3 to skip firing a missile DEC INWK+31 \ We're done with the checks, so it's time to fire off a \ missile, so reduce the missile count in byte #31 by 1 LDA TYPE \ Fetch the ship type into A

Code variation 2 of 2Related to the Electron version

The Electron version has no Thargoids, which also means no ships can launch Thargons.

This variation is blank in the Electron version.

CMP #THG \ If this is not a Thargoid, jump down to TA16 to launch BNE TA16 \ a missile LDX #TGL \ This is a Thargoid, so instead of launching a missile, LDA INWK+32 \ the mothership launches a Thargon, so call SFS1 to JMP SFS1 \ spawn a Thargon from the parent ship, and return from \ the subroutine using a tail call
.TA16

 JMP SFRMIS             \ Jump to SFRMIS to spawn a missile as a child of the
                        \ current ship, make a noise and print a message warning
                        \ of incoming missiles, and return from the subroutine
                        \ using a tail call