Skip to navigation


List of all subroutines

[Commodore 64 version]

This index contains every subroutine and entry point that appears in the source code for the Commodore 64 version of Elite, grouped by category. An entry points is a label within a subroutine that is called from outside the subroutine, which typically implements a subset or variation of the functionality of the parent subroutine.

Charts
------

hmSelect the closest system and redraw the chart crosshairs
HME2Search the galaxy for a system
TT103Draw a small set of crosshairs on a chart
TT105Draw crosshairs on the Short-range Chart, with clipping
TT114Display either the Long-range or Short-range Chart
TT123Move galactic coordinates by a signed delta
TT16Move the crosshairs on a chart
TT180Contains an RTS
TT22Show the Long-range Chart
TT23Show the Short-range Chart

Copy protection
---------------

ChecksumChecksum the code from $1000 to $9FFF and check against S%-1

Dashboard
---------

ABORTDisarm missiles and update the dashboard indicators
ABORT2Set/unset the lock target for a missile and update the dashboard
BUMP2Bump up the value of the pitch or roll dashboard indicator
cntrApply damping to the pitch or roll dashboard indicator
COMPASUpdate the compass
DIALS (Part 1 of 4)Update the dashboard: speed indicator
DIALS (Part 2 of 4)Update the dashboard: pitch and roll indicators
DIALS (Part 3 of 4)Update the dashboard: four energy banks
DIALS (Part 4 of 4)Update the dashboard: shields, fuel, laser & cabin temp, altitude
DILThe range of the indicator is 0-16 (for the energy banks)
DIL-1The range of the indicator is 0-32 (for the speed indicator)
DIL2Update the roll or pitch indicator on the dashboard
DILXUpdate a bar-based indicator on the dashboard
DILX+2The range of the indicator is 0-64 (for the fuel indicator)
djd1Auto-recentre the value in X, if keyboard auto-recentre is configured
DOTDraw a dash on the compass
ECBLBLight up the E.C.M. indicator bulb ("E") on the dashboard
ECBLB2Start up the E.C.M. (light up the indicator, start the countdown and make the E.C.M. sound)
MSBARDraw a specific indicator in the dashboard's missile bar
msblobDisplay the dashboard's missile indicators in green
PZWFetch the current dashboard colours, to support flashing
RE2+2Restore A from T and return from the subroutine
REDU2Reduce the value of the pitch or roll dashboard indicator
SCANDisplay the current ship on the scanner
SP1Draw the space station on the compass
SP2Draw a dot on the compass, given the planet/station vector
SPBLBLight up the space station indicator ("S") on the dashboard
WPSHPSClear the scanner, reset the ball line and sun line heaps

Drawing circles
---------------

BLINEDraw a circle segment and add it to the ball line heap
CHKONCheck whether any part of a circle appears on the extended screen
CIRCLEDraw a circle for the planet
CIRCLE2Draw a circle (for the planet or chart)
DOHFXImplement the #DOHFX command (update the hyperspace effect flag)
HFS1Don't clear the screen, and draw 8 concentric rings with the step size in STP
HFS2Draw the launch or hyperspace tunnel
LAUNMake the launch sound and draw the launch tunnel
LL164Make the hyperspace sound and draw the hyperspace tunnel
TT128Draw a circle on a chart
TT14Draw a circle with crosshairs on a chart

Drawing lines
-------------

EDGESDraw a horizontal line given a centre and a half-width
HL6Contains an RTS
HLOINDraw a horizontal line from (X1, Y1) to (X2, Y1)
HLOIN2Remove a line from the sun line heap and draw it on-screen
LASLIDraw the laser lines for when we fire our lasers
LASLI-1Contains an RTS
LASLI2Just draw the current laser lines without moving the centre point, draining energy or heating up. This has the effect of removing the lines from the screen
LL118Move a point along a line until it is on-screen
LL118-1Contains an RTS
LL145 (Part 1 of 4)Clip line: Work out which end-points are on-screen, if any
LL145 (Part 2 of 4)Clip line: Work out if any part of the line is on-screen
LL145 (Part 3 of 4)Clip line: Calculate the line's gradient
LL145 (Part 4 of 4)Clip line: Call the routine in LL188 to do the actual clipping
LL147Don't initialise the values in SWAP or A
LL30LL30 is a synonym for LOIN and draws a line from (X1, Y1) to (X2, Y2)
LOIN (Part 1 of 7)Draw a line: Calculate the line gradient in the form of deltas
LOIN (Part 2 of 7)Draw a line: Line has a shallow gradient, step right along x-axis
LOIN (Part 3 of 7)Draw a shallow line going right and up or left and down
LOIN (Part 4 of 7)Draw a shallow line going right and down or left and up
LOIN (Part 5 of 7)Draw a line: Line has a steep gradient, step up along y-axis
LOIN (Part 6 of 7)Draw a steep line going up and left or down and right
LOIN (Part 7 of 7)Draw a steep line going up and right or down and left
NLINDraw a horizontal line at pixel row 23 to box in a title
NLIN2Draw a screen-wide horizontal line at the pixel row in A
NLIN3Print a title and draw a horizontal line at row 19 to box it in
NLIN4Draw a horizontal line at pixel row 19 to box in a title
TT15Draw a set of crosshairs

Drawing pixels
--------------

CPIX2Draw a single-height dash on the dashboard
CPIX4Draw a double-height dot on the dashboard
PIXELDraw a 1-pixel dot, 2-pixel dash or 4-pixel square
PIXEL2Draw a stardust particle relative to the screen centre
PX4Contains an RTS

Drawing planets
---------------

PL2Remove the planet or sun from the screen
PL2-1Contains an RTS
PL21Return from a planet/sun-drawing routine with a failure flag
PL44Clear the C flag and return from the subroutine PL6 Contains an RTS
PL6Contains an RTS
PL9 (Part 1 of 3)Draw the planet, with either an equator and meridian, or a crater
PL9 (Part 2 of 3)Draw the planet's equator and meridian
PL9 (Part 3 of 3)Draw the planet's crater
PLANETDraw the planet or sun
PLS1Calculate (Y A) = nosev_x / z
PLS2Draw a half-ellipse
PLS22Draw an ellipse or half-ellipse
PLS3Calculate (Y A P) = 222 * roofv_x / z
PLS4Calculate CNT2 = arctan(P / A) / 4
PLS5Calculate roofv_x / z and roofv_y / z
PLS6Calculate (X K) = (A P+1 P) / (z_sign z_hi z_lo)
WP1Reset the ball line heap
WPLS2Remove the planet from the screen

Drawing ships
-------------

DOEXPDraw an exploding ship
EE51Remove the current ship from the screen, called from SHPPT before drawing the ship as a point
EXS1Set (A X) = (A R) +/- random * cloud size
LL10-1Contains an RTS
LL66A re-entry point into the ship-drawing routine, used by the LL62 routine to store 128 - (U R) on the XX3 heap
LL70+1Contains an RTS (as the first byte of an LDA instruction)
LL81+2Draw the contents of the ship line heap, used to draw the ship as a dot from SHPPT
LL9 (Part 1 of 12)Draw ship: Check if ship is exploding, check if ship is in front
LL9 (Part 2 of 12)Draw ship: Check if ship is in field of view, close enough to draw
LL9 (Part 3 of 12)Draw ship: Set up orientation vector, ship coordinate variables
LL9 (Part 4 of 12)Draw ship: Set visibility for exploding ship (all faces visible)
LL9 (Part 5 of 12)Draw ship: Calculate the visibility of each of the ship's faces
LL9 (Part 6 of 12)Draw ship: Calculate the visibility of each of the ship's vertices
LL9 (Part 7 of 12)Draw ship: Calculate the visibility of each of the ship's vertices
LL9 (Part 8 of 12)Draw ship: Calculate the screen coordinates of visible vertices
LL9 (Part 9 of 12)Draw ship: Draw laser beams if the ship is firing its laser at us
LL9 (Part 10 of 12)Draw ship: Calculate the visibility of each of the ship's edges
LL9 (Part 11 of 12)Draw ship: Add all visible edges to the ship line heap
LL9 (Part 12 of 12)Draw ship: Draw all the visible edges from the ship line heap
PTCLS2Draw the explosion along with an explosion sprite
SHPPTDraw a distant ship as a point rather than a full wireframe

Drawing suns
------------

FLFLLSReset the sun line heap
RTS2Contains an RTS
SUN (Part 1 of 4)Draw the sun: Set up all the variables needed to draw the sun
SUN (Part 2 of 4)Draw the sun: Start from the bottom of the screen and erase the old sun line by line
SUN (Part 3 of 4)Draw the sun: Continue to move up the screen, drawing the new sun line by line
SUN (Part 4 of 4)Draw the sun: Continue to the top of the screen, erasing the old sun line by line
WPLSRemove the sun from the screen
WPLS-1Contains an RTS

Drawing the screen
------------------

BLUEBANDClear two four-character borders along each side of the space view
BLUEBANDSClear a four-character border along one side of the space view
BOMBOFFSwitch off the energy bomb effect
BOXJust draw the border box along the top and sides
BOX2Draw the left and right edges of the border box for the space view
BOXSDraw a horizontal line across the screen at pixel y-coordinate X
BOXS2Draw a vertical line for the left or right border box edge
clssClear the screen, move the text cursor to the top-left corner and jump back into the CHPR routine to print the next character
CLYNSClear the bottom three text rows of the space view
COMIRQ1The split screen and sound interrupt handler (the IRQ interrupt service hardware vector at $FFFE points here)
DET1Show or hide the dashboard (for when we die)
DOVDU19Implement the #SETVDU19 command (change mode 1 palette)
TRADEMODEClear the screen and set up a trading screen
TT66Clear the screen and set the current view type
TT66simpClear the whole screen inside the border box, and move the text cursor to the top-left corner
TTX66Clear the top part of the screen and draw a border box
TTX66KClear the whole screen or just the space view (as appropriate), draw a border box, and if required, show the dashboard
wantdialsShow the dashboard on-screen
WSCANWait for the vertical sync
zonkscannersHide all ships on the scanner

Equipment
---------

cContains an RTS
eqSubtract the price of equipment from the cash pot
EQSHPShow the Equip Ship screen
errBeep, pause and go to the docking bay (i.e. show the Status Mode screen)
presGiven an item number A with the item name in recursive token Y, show an error to say that the item is already present, refund the cost of the item, and then beep and exit to the docking bay (i.e. show the Status Mode screen)
prxReturn the price of a piece of equipment
prx-3Return the price of the item with number A - 1 c Contains an RTS
qvPrint a menu of the four space views, for buying lasers
refundInstall a new laser, processing a refund if applicable

Flight
------

DCS1Calculate the vector from the ideal docking position to the ship
DENGYDrain some energy from the energy banks
dockEdPrint a message to say there is no hyperspacing allowed inside the station
DOCKITApply docking manoeuvres to the ship in INWK
DOENTRYDock at the space station, show the ship hangar and work out any mission progression
ee3Print the hyperspace countdown in the top-left of the screen
ESCAPELaunch our escape pod
GhyPerform a galactic hyperspace jump
hypStart the hyperspace process
LO2Contains an RTS
LOOK1Initialise the space view
me1Erase an old in-flight message and display a new one
me2Remove an in-flight message from the space view
mes9Print a text token, possibly followed by " DESTROYED"
MESSDisplay an in-flight message
MJPProcess a mis-jump into witchspace
OOPSTake some damage
ou2Display "E.C.M.SYSTEM DESTROYED" as an in-flight message
ou3Display "FUEL SCOOPS DESTROYED" as an in-flight message
OUCHPotentially lose cargo or equipment following damage
PLUTFlip the coordinate axes for the four different views
ptgCalled when the user manually forces a mis-jump RTS111 Contains an RTS
RTS111Contains an RTS
SESCPSpawn an escape pod from the current (parent) ship
SHDCharge a shield and drain some energy from the energy banks
SIGHTDraw the laser crosshairs
TT110Launch from a station or show the front space view
TT147Print an error when a system is out of hyperspace range
TT18Try to initiate a jump into hyperspace
TTX110Set the current system to the nearest system and return to hyp
TTX111Used to rejoin this routine from the call to TTX110
WARPPerform an in-system jump
wWStart a hyperspace countdown
wW2Start the hyperspace countdown, starting the countdown from the value in A
zZ+1Contains an RTS

Keyboard
--------

CTRLScan the keyboard to see if CTRL is currently pressed
DK4Scan for pause, configuration and secondary flight keys
DKJ1Read joystick and flight controls
DKS2Read the joystick position
DKS3Toggle a configuration setting and emit a beep
DKS4Scan the keyboard to see if a specific key is being pressed
DKSANYKEYScan a specific column in the keyboard matrix for a key press
DOKEYScan for the seven primary flight controls and apply the docking computer manoeuvring code
FLKBFlush the keyboard buffer
FREEZERejoin the pause routine after processing a screen save
outContains an RTS t As TT217 but don't preserve Y, set it to YSAV instead
PAUSE2Wait until a key is pressed, ignoring any existing key press
RDKEYScan the keyboard for key presses
tAs TT217 but don't preserve Y, set it to YSAV instead
T95Print the distance to the selected system
TT102Process function key, save key, hyperspace and chart key presses and update the hyperspace counter
TT17Scan the keyboard for cursor key or joystick movement
TT214Ask a question with a "Y/N?" prompt and return the response
TT217Scan the keyboard until a key is pressed
U%Clear the key logger and reset a number of flight variables
YESNOWait until either "Y" or "N" is pressed
ZEKTRANClear the key logger

Loader
------

BEGINInitialise the configuration variables and start the game
COLDConfigure memory, set up interrupt handlers and configure the VIC-II, SID and CIA chips
CopyZeroPage (Disk Loader 2)Copy a page of data in a specified direction between zero page and the page at $CE00, omitting the first two bytes
DEEORS (Game Loader)Decrypt a multi-page block of memory
Elite GMA loader (Part 1 of 4) (Disk Loader 2)Skip past the table of track and sector numbers if present
Elite GMA loader (Part 2 of 4) (Disk Loader 2)Offer the option of a fast loader and run the disk protection code in the GMA3 file
Elite GMA loader (Part 3 of 4) (Disk Loader 2)Run the Elite loader in the GMA4 file
Elite GMA loader (Part 4 of 4) (Disk Loader 2)Load the GMA5 and GMA6 binaries and start the game
Elite loader (Part 1 of 7) (Game Loader)Unscramble the loader code and game data
Elite loader (Part 2 of 7) (Game Loader)Copy the game data to their correct locations
Elite loader (Part 3 of 7) (Game Loader)Configure the memory layout and the CIA chips
Elite loader (Part 4 of 7) (Game Loader)Configure the VIC-II for screen memory and sprites
Elite loader (Part 5 of 7) (Game Loader)Configure the screen bitmap and copy colour data into screen RAM
Elite loader (Part 6 of 7) (Game Loader)Copy colour data into colour RAM and configure more screen RAM
Elite loader (Part 7 of 7) (Game Loader)Set up the sprite pointers, make a copy of the dashboard bitmap in DSTORE% and copy the sprite definitions to SPRITELOC%
filename (Disk Loader 1)A wildcarded filename that matches the first GMA file on disk
load3 (Disk Loader 2)Jump to the entry point in elite-loader
LoadGMAFile (Disk Loader 2)Load a specific GMA file
LODATA (Game Loader)The binaries for recursive tokens and the game font
mvblock (Game Loader)Copy a number of pages in memory
mvsm (Game Loader)Copy 280 bytes in memory
NMIpissoffAcknowledge NMI interrupts and ignore them
OfferFastLoader (Disk Loader 2)Offer the option of using the fast loader, if we haven't already, and set up the fast loader if it is chosen
PrintString (Disk Loader 2)Print the null-terminated string at offset X in loaderScreens
RelocateLoader (Disk Loader 1)Load and run the GMA1 loader file
RunGMA (Disk Loader 1)Load and run the GMA1 loader file
S%Checksum, decrypt and unscramble the main game code, and start the game
SetUpFastLoader (Disk Loader 2)Set up the fast loader so that calls to the Kernal's file functions use the fast loader routines instead
SetUpGMAFile (Disk Loader 2)Configure the filename parameters to load a specific GMA file
SHIPS (Game Loader)The binaries for the ship blueprints
STARTUPSet the various vectors, interrupts and timers

Main loop
---------

FRCEThe entry point for the main game loop if we want to jump straight to a specific screen, by pretending to "press" a key, in which case A contains the internal key number of the key we want to "press"
GOINWe jump here from part 3 of the main flight loop if the docking computer is activated by pressing "C"
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
Main flight loop (Part 1 of 16)Seed the random number generator
Main flight loop (Part 2 of 16)Calculate the alpha and beta angles from the current pitch and roll of our ship
Main flight loop (Part 3 of 16)Scan for flight keys and process the results
Main flight loop (Part 4 of 16)For each nearby ship: Copy the ship's data block from K% to the zero-page workspace at INWK
Main flight loop (Part 5 of 16)For each nearby ship: If an energy bomb has been set off, potentially kill this ship
Main flight loop (Part 6 of 16)For each nearby ship: Move the ship in space and copy the updated INWK data block back to K%
Main flight loop (Part 7 of 16)For each nearby ship: Check whether we are docking, scooping or colliding with it
Main flight loop (Part 8 of 16)For each nearby ship: Process us potentially scooping this item
Main flight loop (Part 9 of 16)For each nearby ship: If it is a space station, check whether we are successfully docking with it
Main flight loop (Part 10 of 16)For each nearby ship: Remove if scooped, or process collisions
Main flight loop (Part 11 of 16)For each nearby ship: Process missile lock and firing our laser
Main flight loop (Part 12 of 16)For each nearby ship: Draw the ship, remove if killed, loop back
Main flight loop (Part 13 of 16)Show energy bomb effect, charge shields and energy banks
Main flight loop (Part 14 of 16)Spawn a space station if we are close enough to the planet
Main flight loop (Part 15 of 16)Perform altitude checks with the planet and sun and process fuel scooping if appropriate
Main flight loop (Part 16 of 16)Process laser pulsing, E.C.M. energy drain, call stardust routine
Main game loop (Part 1 of 6)Spawn a trader (a Cobra Mk III, Python, Boa or Anaconda)
Main game loop (Part 2 of 6)Call the main flight loop, and potentially spawn a trader, an asteroid, or a cargo canister
Main game loop (Part 3 of 6)Potentially spawn a cop, particularly if we've been bad
Main game loop (Part 4 of 6)Potentially spawn a lone bounty hunter, a Thargoid, or up to four pirates
Main game loop (Part 5 of 6)Cool down lasers, make calls to update the dashboard
Main game loop (Part 6 of 6)Process non-flight key presses (docked keys)
MAL1Marks the beginning of the ship analysis loop, so we can jump back here from part 12 of the main flight loop to work our way through each ship in the local bubble. We also jump back here when a ship is removed from the bubble, so we can continue processing from the next ship
me3Used by me2 to jump back into the main game loop after printing an in-flight message
MLOOPThe entry point for the main game loop. This entry point comes after the call to the main flight loop and spawning routines, so it marks the start of the main game loop for when we are docked (as we don't need to call the main flight loop or spawning routines if we aren't in space)
NOMVETRThe re-entry point in the main game loop for when there are no sprites to move
TT100The entry point for the start of the main game loop, which calls the main flight loop and the moves into the spawning routine

Market
------

BAY2Jump into the main loop at FRCE, setting the key "pressed" to the Inventory key
dnPrint the amount of money we have left in the cash pot, then make a short, high beep and delay for 1 second
gnumGet a number from the keyboard
NWDAV4Print an "ITEM?" error, make a beep and rejoin the TT210 routine
NWDAVxxUsed to rejoin this routine from the call to NWDAV4
tnprWork out if we have space for a specific amount of cargo
tnpr1Work out if we have space for one tonne of cargo
TT151Print the name, price and availability of a market item
TT152Print the unit ("t", "kg" or "g") for a market item
TT160Print "t" (for tonne) and a space
TT161Print "kg" (for kilograms)
TT163Print the headers for the table of market prices
TT167Show the Market Price screen
TT16aPrint "g" (for grams)
TT208Show the Sell Cargo screen
TT210Show a list of current cargo in our hold, optionally to sell
TT213Show the Inventory screen
TT219Show the Buy Cargo screen
varCalculate QQ19+3 = economy * |economic_factor|

Maths (Arithmetic)
------------------

ADDCalculate (A X) = (A P) + (S R)
DORNDGenerate random numbers
DORND2Make sure the C flag doesn't affect the outcome
DV41Calculate (P R) = 256 * DELTA / A
DV42Calculate (P R) = 256 * DELTA / z_hi
DVID3B2Calculate K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo)
DVID4Calculate (P R) = 256 * A / Q
DVIDTCalculate (P+1 A) = (A P) / Q
FMLTUCalculate A = A * Q / 256
FMLTU2Calculate A = K * sin(A)
GC2Calculate (Y X) = (A P) * 4
GCASHCalculate (Y X) = P * Q * 4
itsoffContains an RTS
LCASHSubtract an amount of cash from the cash pot
LL120Calculate (Y X) = (S x1_lo) * XX12+2 or (S x1_lo) / XX12+2
LL121Calculate (Y X) = (S R) / Q and set the sign to the opposite of the top byte on the stack
LL122Calculate (Y X) = (S R) * Q and set the sign to the opposite of the top byte on the stack
LL123Calculate (Y X) = (S R) / XX12+2 or (S R) * XX12+2
LL128Contains an RTS
LL129Calculate Q = XX12+2, A = S EOR XX12+3 and (S R) = |S R|
LL133Negate (Y X) and return from the subroutine LL128 Contains an RTS
LL28Calculate R = 256 * A / Q
LL28+4Skips the A >= Q check and always returns with C flag cleared, so this can be called if we know the division will work
LL31Skips the A >= Q check and does not set the R counter, so this can be used for jumping straight into the division loop if R is already set to 254 and we know the division will work
LL38Calculate (S A) = (S R) + (A Q)
LL5Calculate Q = SQRT(R Q)
LL61Calculate (U R) = 256 * A / Q
LL62Calculate 128 - (U R)
MADCalculate (A X) = Q * A + (S R)
MAS3Calculate A = x_hi^2 + y_hi^2 + z_hi^2 in the K% block
MCASHAdd an amount of cash to the cash pot
MLS1Calculate (A P) = ALP1 * A
MLS2Calculate (S R) = XX(1 0) and (A P) = A * ALP1
MLTU2Calculate (A P+1 P) = (A ~P) * Q
MLTU2-2Set Q to X, so this calculates (A P+1 P) = (A ~P) * X
MLU1Calculate Y1 = y_hi and (A P) = |y_hi| * Q for Y-th stardust
MLU2Calculate (A P) = |A| * Q
MU1Copy X into P and A, and clear the C flag
MU11Calculate (A P) = P * X
MU5Set K(3 2 1 0) = (A A A A) and clear the C flag
MU6Set P(1 0) = (A A)
MULT1Calculate (A P) = Q * A
MULT12Calculate (S R) = Q * A
MULT3Calculate K(3 2 1 0) = (A P+1 P) * Q
MULTS-2Calculate (A P) = X * A
MULTUCalculate (A P) = P * Q
MUT1Calculate R = XX and (A P) = Q * A
MUT2Calculate (S R) = XX(1 0) and (A P) = Q * A
MUT3An unused routine that does the same as MUT2
PIX1Calculate (YY+1 SYL+Y) = (A P) + (S R) and draw stardust particle
SPS2Calculate (Y X) = A / 10
SQUAClear bit 7 of A and calculate (A P) = A * A
SQUA2Calculate (A P) = A * A
TAS1Calculate K3 = (x_sign x_hi x_lo) - V(1 0)
TIS1Calculate (A ?) = (-X * A + (S R)) / 96
TIS2Calculate A = A / Q
TIS3Calculate -(nosev_1 * roofv_1 + nosev_2 * roofv_2) / nosev_3
TT113Contains an RTS
VCSU1Calculate vector K3(8 0) = [x y z] - coordinates of the sun or space station
VCSUBCalculate vector K3(8 0) = [x y z] - coordinates in (A V)

Maths (Geometry)
----------------

ARCTANCalculate A = arctan(P / Q)
FAROFCompare x_hi, y_hi and z_hi with 224
FAROF2Compare x_hi, y_hi and z_hi with A
LL51Calculate the dot product of XX15 and XX16
mDo not include A in the calculation
MA9Contains an RTS
MAS1Add an orientation vector coordinate to an INWK coordinate
MAS2Calculate a cap on the maximum distance to the planet or sun
MAS4Calculate a cap on the maximum distance to a ship
NO1Contains an RTS
NORMNormalise the three-coordinate vector in XX15
PROJProject the current ship or planet onto the screen
SPS1Calculate the vector to the planet and store it in XX15
SPS1+1A BRK instruction
SPS3Copy a space coordinate from the K% block into K3
SPS4Calculate the vector to the space station
TA2Calculate the length of the vector in XX15 (ignoring the low coordinates), returning it in Q
TAS2Normalise the three-coordinate vector in K3
TAS3Calculate the dot product of XX15 and an orientation vector
TAS4Calculate the dot product of XX15 and one of the space station's orientation vectors
TAS6Negate the vector in XX15 so it points in the opposite direction
TIDYOrthonormalise the orientation vectors for a ship

Missions
--------

BAYSTEPGo to the docking bay (i.e. show the Status Mode screen)
BRIEFStart mission 1 and show the mission briefing
BRIEF2Start mission 2
BRIEF3Receive the briefing and plans for mission 2
BRISClear the screen, display "INCOMING MESSAGE" and wait for 2 seconds
BRPPrint an extended token and show the Status Mode screen
BRPSPrint the extended token in A, show the Status Mode screen and return from the subroutine
DEBRIEFFinish mission 1
DEBRIEF2Finish mission 2
MVTRIBSMove the Trumble sprites around on-screen
NOSPRITESDisable all sprites and remove them from the screen
PAS1Display a rotating ship at space coordinates (0, conhieght, 256) and scan the keyboard
PAUSEDisplay a rotating ship, waiting until a key is pressed, then remove the ship from the screen
TBRIEFStart mission 3
THERECheck whether we are in the Constrictor's system in mission 1

Moving
------

MV40Rotate the planet or sun's location in space by the amount of pitch and roll of our ship
MV45Rejoin the MVEIT routine after the rotation, tactics and scanner code
MVEIT (Part 1 of 9)Move current ship: Tidy the orientation vectors
MVEIT (Part 2 of 9)Move current ship: Call tactics routine, remove ship from scanner
MVEIT (Part 3 of 9)Move current ship: Move ship forward according to its speed
MVEIT (Part 4 of 9)Move current ship: Apply acceleration to ship's speed as a one-off
MVEIT (Part 5 of 9)Move current ship: Rotate ship's location by our pitch and roll
MVEIT (Part 6 of 9)Move current ship: Move the ship in space according to our speed
MVEIT (Part 7 of 9)Move current ship: Rotate ship's orientation vectors by pitch/roll
MVEIT (Part 8 of 9)Move current ship: Rotate ship about itself by its own pitch/roll
MVEIT (Part 9 of 9)Move current ship: Redraw on scanner, if it hasn't been destroyed
MVS4Apply pitch and roll to an orientation vector
MVS5Apply a 3.6 degree pitch or roll to an orientation vector
MVT1Calculate (x_sign x_hi x_lo) = (x_sign x_hi x_lo) + (A R)
MVT1-2Clear bits 0-6 of A before entering MVT1
MVT3Calculate K(3 2 1) = (x_sign x_hi x_lo) + K(3 2 1)
MVT6Calculate (A P+2 P+1) = (x_sign x_hi x_lo) + (A P+2 P+1)
SFS2Move a ship in space along one of the coordinate axes

Save and load
-------------

BRKBKSet the standard BRKV handler for the game
CHECKCalculate the checksum for the last saved commander data block
CHECK2Calculate the third checksum for the last saved commander data block (Commodore 64 and Apple II versions only)
DOSVNImplement the #DOSVN command (update the "save in progress" flag)
FILEPRDisplay the currently selected media (disk or tape)
GTDRVGet an ASCII disk drive number from the keyboard
GTNMEWFetch the name of a commander file to save or load
JAMESONRestore the default JAMESON commander
KERNALSETUPSet up memory and interrupts so we can use the Kernal functions and configure the file system device number and filename
LODLoad a commander file
LORSet the C flag and return from the subroutine
OTHERFILEPRDisplay the non-selected media (disk or tape)
SVEDisplay the disk access menu and process saving of commander files
tapeerrorPrint either "TAPE ERROR" or "DISK ERROR"
TR1Copy the last saved commander's name from NA% to INWK
TRNMECopy the last saved commander's name from INWK to NA%

Sound
-----

april16Start playing the docking music, irrespective of the current configuration settings
BDENTRYStart playing a new tune as background music
BDirqhereThe interrupt routine for playing background music
BDlab1Apply vibrato before cleaning up and returning from the interrupt routine
BDlab19Increment the music data pointer in BDdataptr1(1 0) and fetch the next data byte into A
BDlab21Clean up and return from the interrupt routine
BDlab23Apply a vibrato frequency change to voice 3
BDlab24Apply a vibrato frequency change to voice 2
BDlab3Fetch the next two music data bytes and set the frequency of voice 1 (high byte then low byte)
BDlab4Set the voice control register for voice 1 to value1
BDlab5Fetch the next two music data bytes and set the frequency of voice 2 (high byte then low byte) and the vibrato variables
BDlab6Set the voice control register for voice 2 to value2
BDlab7Fetch the next two music data bytes and set the frequency of voice 3 (high byte then low byte) and the vibrato variables
BDlab8Set the voice control register for voice 3 to value3
BDRO1Process music command <#1 fh1 fl1> to set the frequency for voice 1 to (fh1 fl1) and the control register for voice 1 to value1
BDRO10Process music command <#10 h1 l1 h2 l2 h3 l3> to set the pulse width to all three voices
BDRO11Process music command <#11>, which does the same as command <#9> and restarts the current tune
BDRO12Process music command <#12 n> to set value4 = n, which sets the rest length for commands #8 and #15
BDRO13Process music command <#13 v1 v2 v3> to set value1, value2, value3 to the voice control register values for commands <#1> to <#3>
BDRO14Process music command <#14 vf fc cf> to set the volume and filter modes, filter control and filter cut-off frequency
BDRO15Process music command <#15> to rest for 2 * value4 interrupts
BDRO2Process music command <#2 fh1 fl1> to set the frequency for voice 2 to (fh2 fl2) and the control register for voice 2 to value2
BDRO3Process music command <#3 fh1 fl1> to set the frequency for voice 3 to (fh3 fl3) and the control register for voice 3 to value3
BDRO4Process music command <#4 fh1 fl1 fh2 fl2> to set the frequencies and voice control registers for voices 1 and 2
BDRO5Process music command <#5 fh1 fl1 fh2 fl2 fh3 fl3> to set the frequencies and voice control registers for voices 1, 2 and 3
BDRO6Process music command <#6> to increment value0 and move on to the next nibble of music data
BDRO7Process music command <#7 ad1 ad2 ad3 sr1 sr2 sr3> to set three voices' attack and decay length, sustain volume and release length
BDRO8Process music command <#8> to rest for value4 interrupts
BDRO9Process music command <#9> to restart the current tune
BDskip1Process the next nibble of music data in BDBUFF
BEEPMake a short, high beep
BELLMake a standard system beep
coffeeReturn from the interrupt routine, for when we are making sound effects
coffeeexRestore the memory configuration and return from the subroutine
ECMOFSwitch off the E.C.M.
EXNOMake the sound of a laser strike or ship explosion
EXNO3Make an explosion sound
HYPNOISEMake the sound of the hyperspace drive being engaged
MUTOKCHProcess a change in the docking music configuration setting
NOISEMake the sound whose number is in Y
NOISE2Make a sound effect with a specific volume and release length
NOISEOFFTurn off a specific sound effect in whichever voice it is currently playing in
SOFLUSHReset the sound buffers and turn off all sound channels
SOINTProcess the contents of the sound buffer and send it to the sound chip, to make sound effects as part of the interrupt routine
SOUL3bCheck whether this is the last voice when making sound effects in the interrupt routine, and return from the interrupt if it is
SOUL8Process the sound buffer from voice Y to 0
SOUR1Contains an RTS
startatStart playing the title music, if configured
startat2Start playing the music at address (A X) + 1
startbdStart playing the docking music, if configured
stopatStop playing the current music coffeeex Restore the memory configuration and return from the subroutine
stopbdStop playing the docking music

Stardust
--------

FLIPReflect the stardust particles in the screen diagonal and redraw the stardust field
nWqCreate a random cloud of stardust
NWSTARSInitialise the stardust field
STARSThe main routine for processing the stardust
STARS1Process the stardust for the front view
STARS2Process the stardust for the left or right view
STARS6Process the stardust for the rear view

Start and end
-------------

BR1 (Part 1 of 2)Show the "Load New Commander (Y/N)?" screen and start the game
BR1 (Part 2 of 2)Show the "Press Fire or Space, Commander" screen and start the game
DEATHDisplay the death screen
DEATH2Reset most of the game and restart from the title screen
DFAULTReset the current commander data block to the last saved commander
QU5Restart the game using the last saved commander without asking whether to load a new commander file
RES2Reset a number of flight variables and workspaces
RESETReset most variables
TITLEDisplay a title screen with a rotating ship and prompt
TT170Main entry point for the Elite game code

Status
------

BADCalculate how bad we have been
BAYGo to the docking bay (i.e. show the Status Mode screen)
cmnPrint the commander's name
cmn-1Contains an RTS
cshPrint the current amount of cash
EXNO2Process us making a kill
fwlPrint fuel and cash levels
STATUSShow the Status Mode screen

Tactics
-------

ANGRYMake a ship hostile
fq1Used to add a cargo canister to the universe
FR1Display the "missile jammed" message
FR1-2Clear the C flag and return from the subroutine
FRMISFire a missile from our ship
FRS1Launch a ship straight ahead of us, below the laser sights
GOPLMake the ship head towards the planet
HI1Contains an RTS
HITCHWork out if the ship in INWK is in our crosshairs
SFRMISAdd an enemy missile to our local bubble of universe
TA151Make the ship head towards the planet TA9-1 Contains an RTS
TA9-1Contains an RTS
TACTICS (Part 1 of 7)Apply tactics: Process missiles, both enemy missiles and our own
TACTICS (Part 2 of 7)Apply tactics: Escape pod, station, lone Thargon, safe-zone pirate
TACTICS (Part 3 of 7)Apply tactics: Calculate dot product to determine ship's aim
TACTICS (Part 4 of 7)Apply tactics: Check energy levels, maybe launch escape pod if low
TACTICS (Part 5 of 7)Apply tactics: Consider whether to launch a missile at us
TACTICS (Part 6 of 7)Apply tactics: Consider firing a laser at us, if aim is true
TACTICS (Part 7 of 7)Apply tactics: Set pitch, roll, and acceleration
yetanotherrtsContains an RTS

Text
----

BPRNTPrint a 32-bit number, left-padded to a specific number of digits, with an optional decimal point
CHPRPrint a character at the text cursor by poking into screen memory
CHPR2Character print vector handler
crlfTab to column 21 and print a colon
DASCDASC does exactly the same as TT26 and prints a character at the text cursor, with support for verified text in extended tokens
dec27Contains an RTS
DETOKPrint an extended recursive token from the TKN1 token table
DETOK2Print an extended text token (1-255)
DETOK3Print an extended recursive token from the RUTOK token table
dn2Make a short, high beep and delay for 1 second
DOCOLImplement the #SETCOL command (set the current colour)
DOXCMove the text cursor to a specific column
DOYCMove the text cursor to a specific row
DTENPrint recursive token number X from the token table pointed to by (A V), used to print tokens from the RUTOK table via calls to DETOK3
DTSPrint a single letter in the correct case
exPrint a recursive token
FEEDPrint a newline
INCYCMove the text cursor to the next row
MT1Switch to ALL CAPS when printing extended tokens
MT13Switch to lower case when printing extended tokens
MT14Switch to justified text when printing extended tokens
MT15Switch to left-aligned text when printing extended tokens
MT16Print the character in variable DTW7
MT17Print the selected system's adjective, e.g. Lavian for Lave
MT18Print a random 1-8 letter word in Sentence Case
MT19Capitalise the next letter
MT2Switch to Sentence Case when printing extended tokens
MT23Move to row 10, switch to white text, and switch to lower case when printing extended tokens
MT26Fetch a line of text from the keyboard
MT27Print the captain's name during mission briefings
MT28Print the location hint during the mission 1 briefing
MT29Move to row 6 and switch to lower case when printing extended tokens
MT5Switch to extended tokens
MT6Switch to standard tokens in Sentence Case
MT8Tab to column 6 and start a new word when printing extended tokens
MT9Clear the screen and set the current view type to 1
plfPrint a text token followed by a newline
plf2Print text followed by a newline and indent of 6 characters
pr2Print an 8-bit number, left-padded to 3 digits, and optional point
pr2+2Print the 8-bit number in X to the number of digits in A
pr5Print a 16-bit number, left-padded to 5 digits, and optional point
pr6Print 16-bit number, left-padded to 5 digits, no point
prqPrint a text token followed by a question mark
prq+3Print a question mark
qwPrint a recursive token in the range 128-145
R5Make a beep and jump back into the character-printing routine at CHPR
RR4Restore the registers and return from the subroutine RRafter A re-entry point from the clss routine to print the character in A
RR4SA jump point that restores the registers and returns from the CHPR subroutine (so we can use a branch instruction to jump to RR4)
RRafterA re-entry point from the clss routine to print the character in A
SETXCAn unused routine to move the text cursor to a specific column
SETYCAn unused routine to move the text cursor to a specific row
spcPrint a text token followed by a space
TT11Print a 16-bit number, left-padded to n digits, and optional point
TT162Print a space
TT162+2Jump to TT27 to print the text token in A
TT26Print a character at the text cursor, with support for verified text in extended tokens
TT27Print a text token
TT41Print a letter according to Sentence Case
TT42Print a letter in lower case
TT43Print a two-letter token or recursive token 0-95
TT44Jumps to TT26 to print the character in A (used to enable us to use a branch instruction to jump to TT26)
TT45Print a letter in lower case
TT46Print a character and switch to capitals
TT48Contains an RTS
TT60Print a text token and a paragraph break
TT67Print a newline
TT67XPrint a newline
TT68Print a text token followed by a colon
TT69Set Sentence Case and print a newline
TT73Print a colon
TT74Print a character
TTX69Print a paragraph break
VOWELTest whether a character is a vowel
WHITETEXTSwitch to white text

Tube
----

newosrdchThe custom OSRDCH routine for reading characters
PUTBACKReset the OSWRCH vector in WRCHV to point to USOSWRCH

Universe
--------

cplPrint the selected system name
GINFFetch the address of a ship's data block into INF
GTHGSpawn a Thargoid ship and a Thargon companion
GVLCalculate the availability of market items
hy5Contains an RTS
hyp1Process a jump to the system closest to (QQ9, QQ10)
hyp1+3Jump straight to the system at (QQ9, QQ10) without first calculating which system is closest. We do this if we already know that (QQ9, QQ10) points to a system
hyRContains an RTS
jmpSet the current system to the selected system
KILLSHPRemove a ship from our local bubble of universe
KS1Remove the current ship from our local bubble of universe
KS2Check the local bubble for missiles with target lock
KS3Set the SLSP ship line heap pointer after shuffling ship slots
KS4Remove the space station and replace it with the sun
NwS1Flip the sign and double an INWK byte
NWSHPAdd a new ship to our local bubble of universe
NWSPSAdd a new space station to our local bubble of universe
ohContains an RTS SPIN2 Remove any randomness: spawn cargo of a specific type (given in X), and always spawn the number given in A
PDESCPrint the system's extended description or a mission 1 directive
pingSet the selected system to the current system
SFS1Spawn a child ship from the current (parent) ship
SFS1-2Add a missile to the local bubble that has AI enabled, is hostile, but has no E.C.M.
SOLARSet up various aspects of arriving in a new system
SOS1Update the missile indicators, set up the planet data block
SPINRandomly spawn cargo from a destroyed ship
SPIN2Remove any randomness: spawn cargo of a specific type (given in X), and always spawn the number given in A
talPrint the current galaxy number
TT111Set the current system to the nearest system to a point
TT111-1Contains an RTS
TT146Print the distance to the selected system in light years
TT20Twist the selected system's seeds four times
TT24Calculate system data from the system seeds
TT25Show the Data on System screen
TT54Twist the selected system's seeds
TT70Display "MAINLY " and jump to TT72
TT72Used by TT70 to re-enter the routine after displaying "MAINLY" for the economy type
TT81Set the selected system's seeds to those of system 0
yplPrint the current system name
ypl-1Contains an RTS
ZeInitialise the INWK workspace to a hostile ship
ZINFReset the INWK workspace and orientation vectors

Utility routines
----------------

backtonormalDisable the keyboard, set the SVN flag to 0, and return with A = 0
BRBRThe standard BRKV handler for the game
CLDELAYDelay by iterating through 5 * 256 (1280) empty loops
DEEORUnscramble the main code
DEEORSDecrypt a multi-page block of memory
DELAYWait for a specified time, in either 1/50s of a second (on PAL systems) or 1/60s of a second (on NTSC systems)
mvbllopOnly copy Y bytes, rather than a whole page
mvblockKCopy a specific number of pages in memory
SETL1Set the 6510 input/output port register to control the memory map
SWAPPZEROA routine that swaps zero page with the page at $CE00, so that zero page changes made by Kernal functions can be reversed
SWAPPZERO (source disk variant)A routine that swaps zero page with the page at $CE00, so that zero page changes made by Kernal functions can be reversed
ZEBCZero-fill pages $B and $C
ZEROReset the local bubble of universe and ship status
ZES1Zero-fill the page whose number is in X
ZES1kZero-fill the page whose number is in X
ZES2Zero-fill a specific page
ZES2kZero-fill a specific page
ZESNEWZero-fill memory from SC(1 0) to the end of the page