Skip to navigation


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

[Commodore 64 version]

Name: Main flight loop (Part 16 of 16) [Show more] Type: Subroutine Category: Main loop Summary: Process laser pulsing, E.C.M. energy drain, call stardust routine Deep dive: Program flow of the main game loop
Context: 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: * Process laser pulsing * Process E.C.M. energy drain * Jump to the stardust routine if we are in a space view * Return from the main flight loop
.MA23 LDA LAS2 ; If the current view has no laser, jump to MA16 to skip BEQ MA16 ; the following LDA LASCT ; If LASCT >= 8, jump to MA16 to skip the following, so CMP #8 ; for a pulse laser with a LASCT between 8 and 10, the BCS MA16 ; laser stays on, but for a LASCT of 7 or less it gets ; turned off and stays off until LASCT reaches zero and ; the next pulse can start (if the fire button is still ; being pressed) ; ; For pulse lasers, LASCT gets set to 10 in ma1 above, ; and it decrements every vertical sync (50 times a ; second), so this means it pulses five times a second, ; with the laser being on for the first 3/10 of each ; pulse and off for the rest of the pulse ; ; If this is a beam laser, LASCT is 0 so we always keep ; going here. This means the laser doesn't pulse, but it ; does get drawn and removed every cycle, in a slightly ; different place each time, so the beams still flicker ; around the screen JSR LASLI2 ; Redraw the existing laser lines, which has the effect ; of removing them from the screen LDA #0 ; Set LAS2 to 0 so if this is a pulse laser, it will STA LAS2 ; skip over the above until the next pulse (this has no ; effect if this is a beam laser) .MA16 LDA ECMP ; If our E.C.M is not on, skip to MA69, otherwise keep BEQ MA69 ; going to drain some energy JSR DENGY ; Call DENGY to deplete our energy banks by 1 BEQ MA70 ; If we have no energy left, jump to MA70 to turn our ; E.C.M. off .MA69 LDA ECMA ; If an E.C.M is going off (ours or an opponent's) then BEQ MA66 ; keep going, otherwise skip to MA66 DEC ECMA ; Decrement the E.C.M. countdown timer, and if it has BNE MA66 ; reached zero, keep going, otherwise skip to MA66 .MA70 JSR ECMOF ; If we get here then either we have either run out of ; energy, or the E.C.M. timer has run down, so switch ; off the E.C.M. .MA66 LDA QQ11 ; If this is not a space view (i.e. QQ11 is non-zero) BNE oh ; then jump to oh to return from the main flight loop ; (as oh is an RTS) JMP STARS ; This is a space view, so jump to the STARS routine to ; process the stardust, and return from the main flight ; loop using a tail call ;JMP PBFL ; This instruction is commented out in the original ; source