Skip to navigation

BBC Micro Elite

Program flow of the main game loop

The sequence of events in the main game loop and the main flight loop

References: TT170, MLOOP, M%

Here is a high-level look at the main program flow, from the title screen to the end of life as we know it, via the main game loop and the main flight loop. The following is mainly about the flight aspects of the game, as the docked screens don't really have much of a flow, they just get shown when the relevant keys are pressed.

Each section is broken down into parts that mirror the structure of the source code, so it should be easy enough to find the relevant parts mentioned below.

Title sequence

1/2 TT170

  • Show "load commander?" title screen (TITLE)
  • Process loading of commander file, if selected
  • Copy last saved commander NA% to current commander TP
  • Show "press fire or space" title screen (TITLE)
  • Set target system to home system
  • Process arrival in system closest to target

2/2 BAY

  • Set the docked flag
  • Jump to the docked section of the main game loop (FRCE, see below) with f8 "pressed" to show Status Mode

Main game loop

1/6 (potentially called from part 2)

  • Spawn a trader


  • Call the main flight loop (M%, see below)
  • Clear any expired in-flight messages from the screen
  • On 255 out of 256 iterations, skip straight to MLOOP in part 5
  • Potentially spawn a trader by jumping up to part 1
  • Potentially spawn a cargo canister or an asteroid


  • Potentially spawn a cop, with a higher chance if we've been bad


  • Potentially spawn a lone bounty hunter, a Thargoid, or a group of 1-4 pirates

5/6 MLOOP (main entry point for main game loop)

  • Cool down the lasers
  • Update the dashboard (DIALS)
  • If this is not a space view, scan for cursor keys

6/6 FRCE (entry point for displaying a specific screen)

  • Process function keys and other non-flight keys (TT102)
  • If docked, loop back to part 5 (MLOOP)
  • If in-flight, loop back to part 2

Main flight loop

1/16 M% (main entry point for main flight loop)

  • Seed the random number generator


  • Calculate the alpha and beta angles from the current pitch and roll


  • Scan for flight keys and process the results

Now start looping through all the ships in the local bubble, and for each one, do parts 4-12:


  • Copy the ship's data block from K% to INWK
  • Set XX0 to point to the ship's blueprint (if this is a ship)


  • If an energy bomb has been set off and this ship can be killed, kill it and increase the kill tally



  • Check how close we are to this ship and work out if we are docking, scooping or colliding with it


  • Process us potentially scooping this item


  • Process docking with space station, which can take us to the main loop via BAY (if we dock successfully) or DEATH (if we don't)


  • Remove scooped item after both successful and failed scoopings
  • Process collisions, which can lead to DEATH


  • If this isn't the front space view, flip the ship coordinates' axes (PLUT)
  • Process missile lock
  • Process our laser firing


  • Draw the ship (LL9)
  • Process the removal of killed ships

Loop back up to part 4 to do the next ship in the local bubble until we have processed them all


  • Show energy bomb effect (if applicable)
  • Charge shields and energy banks


  • Spawn a space station if we are close enough to the planet


  • Perform an altitude check with the planet, which can lead to DEATH
  • Perform an an altitude check with the sun, which can also lead to DEATH
  • Process fuel scooping


  • Process laser pulsing
  • Process E.C.M. energy drain
  • Call the stardust routine if we are on a space view (STARS)
  • Return from the main flight loop



  • We have been killed, so display the chaos of our destruction above a "GAME OVER" sign
  • Clean up a number of variables and workspaces, ready for the next attempt
  • Jump up to TT170 to start the whole process again