.MA26 LDA NEWB \ If bit 7 of the ship's NEWB flags is clear, skip the BPL P%+5 \ following instruction JSR SCAN \ Bit 7 of the ship's NEWB flags is set, which means the \ ship has docked or been scooped, so we draw the ship \ on the scanner, which has the effect of removing it LDA QQ11 \ If this is not a space view, jump to MA15 to skip BNE MA15 \ missile and laser locking LDX VIEW \ Load the current view into X BEQ P%+5 \ If the current view is the front view, skip the \ following instruction, as the geometry in INWK is \ already correct JSR PU1 \ Call PU1 to update the geometric axes in INWK to \ match the view (front, rear, left, right) JSR HITCH \ Call HITCH to see if this ship is in the crosshairs, BCC MA8 \ in which case the C flag will be set (so if there is \ no missile or laser lock, we jump to MA8 to skip the \ following) LDA MSAR \ We have missile lock, so check whether the leftmost BEQ MA47 \ missile is currently armed, and if not, jump to MA47 \ to process laser fire, as we can't lock an unarmed \ missile JSR BEEP \ We have missile lock and an armed missile, so call \ the BEEP subroutine to make a short, high beep LDX XSAV \ Call ABORT2 to store the details of this missile LDY #&0E \ lock, with the targeted ship's slot number in X JSR ABORT2 \ (which we stored in XSAV at the start of this ship's \ loop at MAL1), and set the colour of the missile \ indicator to the colour in Y (red = &0E) .MA47 \ If we get here then the ship is in our sights, but \ we didn't lock a missile, so let's see if we're \ firing the laser LDA LAS \ If we are firing the laser then LAS will contain the BEQ MA8 \ laser power (which we set in MA68 above), so if this \ is zero, jump down to MA8 to skip the following LDX #15 \ We are firing our laser and the ship in INWK is in JSR EXNO \ the crosshairs, so call EXNO to make the sound of \ us making a laser strike on another ship \ --- Mod: Code removed for Elite-A: ------------------> \LDA TYPE \ Did we just hit the space station? If so, jump to \CMP #SST \ MA14+2 to make the station hostile, skipping the \BEQ MA14+2 \ following as we can't destroy a space station \ \CMP #CON \ If the ship we hit is not a Constrictor, jump to BURN \BNE BURN \ to skip the following \ \LDA LAS \ Set A to the power of the laser we just used to hit \ \ the ship (i.e. the laser in the current view) \ \CMP #(Armlas AND 127) \ If the laser is not a military laser, jump to MA8 \BNE MA8 \ to skip the following, as only military lasers have \ \ any effect on the Constrictor \ \LSR LAS \ Divide the laser power of the current view by 4, so \LSR LAS \ the damage inflicted on the super-ship is a quarter of \ \ the damage our military lasers would inflict on a \ \ normal ship \ \.BURN \ \LDA INWK+35 \ Fetch the hit ship's energy from byte #35 and subtract \SEC \ our current laser power, and if the result is greater \SBC LAS \ than zero, the other ship has survived the hit, so \BCS MA14 \ jump down to MA14 to make it angry \ \ASL INWK+31 \ Set bit 7 of the ship byte #31 to indicate that it has \SEC \ now been killed \ROR INWK+31 \ \LDA TYPE \ Did we just kill an asteroid? If not, jump to nosp, \CMP #AST \ otherwise keep going \BNE nosp \ \LDA LAS \ Did we kill the asteroid using mining lasers? If not, \CMP #Mlas \ jump to nosp, otherwise keep going \BNE nosp \ --- And replaced by: --------------------------------> LDA LAS \ Set A to the power of the laser we just used to hit \ the ship (i.e. the laser in the current view) LDY TYPE \ Did we just hit the space station? If so, jump to CPY #SST \ MA14 to make it angry BEQ MA14 CPY #CON \ If the ship we hit is not a Constrictor, jump to BURN BNE BURN \ to skip the following LSR A \ Divide the laser power of the current view by 2, so \ the damage inflicted on the Constrictor is half of the \ damage our military lasers would inflict on a normal \ ship .BURN LSR A \ Divide the laser power of the current view by 2 JSR n_hit \ Call n_hit to apply a laser strike of strength A to \ the enemy ship BCS MA14 \ If the C flag is set then the enemy ship survived the \ hit, so jump down to MA14 to make it angry LDA TYPE \ Did we just kill an asteroid? If not, jump to nosp, CMP #AST \ otherwise keep going BNE nosp LDA LAS \ Did we kill the asteroid using mining lasers? If so, CMP new_mining \ then our current laser strength in LAS will match the BNE nosp \ strength of mining lasers when fitted to our current \ ship type, which is stored in new_mining. If they \ don't match, which means we didn't use mining lasers, \ then jump to nosp, otherwise keep going \ --- End of replacement ------------------------------> JSR DORND \ Set A and X to random numbers LDX #SPL \ Set X to the ship type for a splinter AND #3 \ Reduce the random number in A to the range 0-3 JSR SPIN2 \ Call SPIN2 to spawn A items of type X (i.e. spawn \ 0-3 splinters) .nosp LDY #PLT \ Randomly spawn some alloy plates JSR SPIN LDY #OIL \ Randomly spawn some cargo canisters JSR SPIN JSR EXNO2 \ Call EXNO2 to process the fact that we have killed a \ ship (so increase the kill tally, make an explosion \ sound and so on) .MA14 \ --- Mod: Code removed for Elite-A: ------------------> \STA INWK+35 \ Store the hit ship's updated energy in ship byte #35 \ \LDA TYPE \ Call ANGRY to make this ship hostile, now that we \JSR ANGRY \ have hit it \ --- And replaced by: --------------------------------> JSR anger_8c \ Call anger_8c to make this ship hostile angry, now \ that we have hit it \ --- End of replacement ------------------------------>Name: Main flight loop (Part 11 of 16) [Show more] Type: Subroutine Category: Main loop Summary: For each nearby ship: Process missile lock and firing our laser Deep dive: Program flow of the main game loop Flipping axes between space viewsContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
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: * If this is not the front space view, flip the axes of the ship's coordinates in INWK * Process missile lock * Process our laser firing
[X]
Subroutine ABORT2 (category: Dashboard)
Set/unset the lock target for a missile and update the dashboard
[X]
Configuration variable AST = 7
Ship blueprint position for the asteroid
[X]
Subroutine BEEP (category: Sound)
Make a short, high beep
[X]
Label BURN is local to this routine
[X]
Configuration variable CON = 31
Ship blueprint position for the Constrictor
[X]
Subroutine DORND (category: Maths (Arithmetic))
Generate random numbers
[X]
Subroutine EXNO (category: Sound)
Make the sound of a laser strike or ship explosion
[X]
Subroutine EXNO2 (category: Status)
Process us making a kill
[X]
Subroutine HITCH (category: Tactics)
Work out if the ship in INWK is in our crosshairs
[X]
Label MA14 is local to this routine
[X]
Label MA15 in subroutine Main flight loop (Part 12 of 16)
[X]
Label MA47 is local to this routine
[X]
Label MA8 in subroutine Main flight loop (Part 12 of 16)
[X]
Configuration variable OIL = 5
Ship blueprint position for the cargo canister
[X]
Configuration variable PLT = 4
Ship blueprint position for the alloy plate
[X]
Subroutine PU1 (category: Flight)
Flip the coordinate axes for the four different views
[X]
Subroutine SCAN (category: Dashboard)
Display the current ship on the scanner
[X]
Subroutine SPIN (category: Universe)
Randomly spawn cargo from a destroyed ship
[X]
Configuration variable SPL = 8
Ship blueprint position for the splinter
[X]
Configuration variable SST = 2
Ship blueprint position for the space station
[X]
Subroutine anger_8c (category: Tactics)
Make the current ship angry
[X]
Label n_hit in subroutine Main flight loop (Part 12 of 16)
[X]
Variable new_mining in workspace UP
The power level of mining lasers when fitted to our current ship type
[X]
Label nosp is local to this routine