Skip to navigation


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

[Commodore 64 version]

Name: Main flight loop (Part 1 of 16) [Show more] Type: Subroutine Category: Main loop Summary: Seed the random number generator Deep dive: Program flow of the main game loop Generating random numbers
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DEATH calls via M% * Main game loop (Part 2 of 6) calls via M% * MVTRIBS calls via NOMVETR

The main flight loop covers most of the flight-specific aspects of Elite. This section covers the following: * Seed the random number generator
Other entry points: M% The entry point for the main flight loop NOMVETR The re-entry point in the main game loop for when there are no sprites to move
.M% LDA K% ; We want to seed the random number generator with a ; pretty random number, so fetch the contents of K%, ; which is the x_lo coordinate of the planet. This value ; will be fairly unpredictable, so it's a pretty good ; candidate STA RAND ; Store the seed in the first byte of the four-byte ; random number seed that's stored in RAND LDA TRIBCT ; If TRIBCT is non-zero then we have some Trumbles in BEQ NOMVETR ; the hold, so jump to MVTRIBS to move their sprites JMP MVTRIBS ; around the screen, if applicable ; ; The MVTRIBS routine jumps back to NOMVETR when it has ; finished moving Trumbles around .NOMVETR