Skip to navigation

BBC Micro Elite

Main loop: Main flight loop (Part 7 of 16)

Name: Main flight loop (Part 7 of 16) [View in context] Type: Subroutine Category: Main loop Summary: For each nearby ship: Check for us docking, scooping or colliding
The main flight loop covers most of the flight-specific aspects of Elite. This section covers the following: * Continue looping through all the ships in the local bubble, and for each one: * Check how close we are to this ship and work out if we are docking, scooping or colliding with it
LDA INWK+31 \ Fetch the status of this ship from bits 5 (is ship AND #%10100000 \ exploding?) and bit 7 (has ship been killed?) from \ ship byte #31 into A JSR MAS4 \ Or this value with x_hi, y_hi and z_hi BNE MA65 \ If this value is non-zero, then either the ship is \ far away (i.e. has a non-zero high byte in at least \ one of the three axes), or it is already exploding, \ or has been flagged as being killed - in which case \ jump to MA65 to skip the following LDA INWK \ Set A = (x_lo OR y_lo OR z_lo), and if bit 7 of the ORA INWK+3 \ result is set, the ship is still a fair distance ORA INWK+6 \ away, so jump to MA65 to skip the following BMI MA65 LDX TYPE \ If the ship type is negative then this indicates a BMI MA65 \ planet or sun, so jump down to MA65 to skip the \ following CPX #SST \ If this ship is the space station, jump to ISDK to BEQ ISDK \ check for docking AND #%11000000 \ If bit 6 of (x_lo OR y_lo OR z_lo) is set, then we BNE MA65 \ are still a reasonable distance away, so jump to \ MA65 to skip the following CPX #MSL \ If this ship is a missile, jump down to MA65 to skip BEQ MA65 \ the following CPX #OIL \ If ship type >= OIL (i.e. it's a cargo canister, BCS P%+5 \ Thargon or escape pod), skip the JMP instruction and JMP MA58 \ continue on, otherwise jump to MA58 to process a \ collision LDA BST \ If we have fuel scoops fitted then BST will be 127, \ otherwise it will be 0 AND INWK+5 \ Ship byte #5 contains the y_sign of this ship, so a -1 \ here means the canister is below us, so this result \ will be negative if the canister is below us and we \ have a fuel scoop fitted BPL MA58 \ If the result is positive, then we either have no \ scoop or the canister is above us, and in both cases \ this means we can't scoop the item, so jump to MA58 \ to process a collision