Bank 7 source (Part 2 of 4)Bank 7 source (Part 4 of 4) Bank 7 source (Part 2 of 4)Bank 7 source (Part 4 of 4) Home page Using this site Home page Start at the very beginning Quick start guide All you need to know to start exploring this site All about this project Project history, building the source and more All about this project About this project The story of how this project came to be Terminology used in this commentary Read this before you explore the source code Building Elite from the source How to build your own working copy of Elite Useful links A collection of links to pages I've found useful during this project Acknowledgements The giants on whose shoulders this project stands Site history A short history of this site's development Site map A top-level map of this website To-do list Code that could benefit from a bit more analysis Playing with the Elite source code Playing 6502 Elite in the 21st century How to play all the versions of Elite analysed here Deep dive articles Over 120 articles on how Elite weaves its magic Index Index of all deep dive articlesDiscover how Elite works under the hood Deep dives Memory maps Details of memory usage in the different versions Memory maps BBC Micro cassette Elite memory map Memory usage in the classic version of Elite, where space is really tight BBC Micro disc Elite memory map Memory usage in the enhanced disc version of Elite Acorn Electron Elite memory map Memory usage in the smallest and most basic version of Elite 6502 Second Processor Elite memory map Memory usage in the Tube-based version of Elite Commodore 64 Elite memory map Memory usage in the musical version of Elite BBC Master Elite memory map Memory usage in the smoothest version of Elite NES Elite memory map Memory usage in the only console-based version of Elite The main loop The main game loop and task scheduler The main loop Program flow of the main game loop The sequence of events in the main game loop and the main flight loop Scheduling tasks with the main loop counter How the main loop counter controls what we do and when we do it Splitting the main loop in the NES version How the main flight loop is split and shared with the combat demo The split-screen mode Elite's custom and split-screen modes The split-screen mode The split-screen mode in BBC Micro Elite Elite's famous split-screen mode, dissected and explained in detail The split-screen mode in Commodore 64 Elite How the VIC-II makes it easy to implement the Commodore version's split screen The split-screen mode in NES Elite How the NES version implements a split-screen mode without hardware timers Simulating the local bubble Spawning and managing ships in our local bubble Simulating the local bubble The local bubble of universe The data structures used to simulate the universe around our ship A sense of scale Space is big, but just how large are the star systems in 8-bit Elite? The space station safe zone Details of the calculations behind the space station safe zone Ship data Ship blueprints and ship data blocks Ship data Ship blueprints Specifications for all the different types of ship in the universe Comparing ship specifications A detailed comparison of in-game statistics for the different ships in Elite Ship data blocks Storing data for each of the ships in the local bubble of universe The elusive Cougar They say it is vanishingly rare... but just how rare is the mysterious Cougar? Simulating the universe Procedural galaxies, system seeds, market prices Simulating the universe Galaxy and system seeds How system data is extracted from the galaxy and system seeds Generating system data The algorithms behind the procedural generation of system data Generating system names Producing system names from twisted seeds and two-letter tokens Twisting the system seeds How the system seeds are twisted to produce entire galaxies of stars Market item prices and availability The algorithms behind the generation of each system's cargo market Moving and rotating in space Pitching, rolling and moving in 3D vector space Moving and rotating in space Pitching and rolling Applying our pitch and roll to another ship's orientation in space Pitching and rolling by a fixed angle How other ships manage to pitch and roll in space Program flow of the ship-moving routine A breakdown of the routine that moves the entire universe around us Rotating the universe What happens to the rest of the universe when we rotate our ship? Orientation vectors The three vectors that determine a ship's orientation in space Tidying orthonormal vectors Making the orientation vectors orthonormal, and why this matters Flipping axes between space views Details of how the different space views are implemented Docking and docking computers How to dock safely with a space station Docking and docking computers Docking checks The checks that determine whether we are docking... or just crashing The docking computer How the docking computer steers us home in the enhanced versions of Elite Keyboards, joysticks and controllers Reading and logging Elite's multiple controls Keyboards, joysticks and controllers The key logger Supporting concurrent in-flight key presses using a key logger Reading the Commodore 64 keyboard matrix Scanning the Commodore 64 keyboard without using the operating system Bolting NES controllers onto the key logger How the NES version simulates a joystick and keyboard Tactics and combat Ranks, weapons and intelligent enemy ships Tactics and combat Combat rank The long, long road from Harmless to Elite In the crosshairs How the game knows whether an enemy is being hit by our laser fire Program flow of the tactics routine How ships and missiles work out attack patterns... or how to run away Advanced tactics with the NEWB flags How the enhanced versions of Elite give their ships a bit more personality The scanner and dashboard The 3D elliptical scanner and other indicators The scanner and dashboard The 3D scanner The maths behind Elite's famous 3D elliptical scanner The dashboard indicators How the bar-based dashboard indicators display their data Drawing pixels Poking pixels directly into screen memory Drawing pixels Drawing monochrome pixels on the BBC Micro Poking screen memory to display monochrome pixels in the space view Drawing colour pixels on the BBC Micro Poking screen memory to display colour pixels in the dashboard view Drawing pixels in the Electron version Poking pixels into screen memory in the Acorn Electron version of Elite Drawing pixels in the Commodore 64 version Updating the bitmap screen in the Commodore 64 version of Elite Drawing pixels in the NES version How the NES version pokes pixels into the console's tile-based screen Extended screen coordinates The extended 16-bit screen coordinate system behind the space view Drawing text Poking text characters into screen memory Drawing text Drawing text How Elite draws text on-screen by poking character bitmaps directly into screen memory Fonts in NES Elite The three different fonts used in the Nintendo version of Elite Drawing lines Line-drawing algorithms and efficient clipping Drawing lines Bresenham's line algorithm The main line-drawing algorithm used to draw non-horizontal lines Line-clipping Efficiently clipping an extended line to the part that's on-screen Drawing lines in the NES version Using tiles as stepping stones when drawing lines on the NES Drawing ships Drawing 3D wireframes and flicker-free ships Drawing ships Drawing ships The main routine for drawing 3D wireframe ships in space Back-face culling How Elite draws solid-looking 3D ships by only drawing visible faces Calculating vertex coordinates Determining whether a ship's vertex is visible or hidden from us Flicker-free ship drawing How the BBC Master version reduces when drawing ships Backporting the flicker-free algorithm Applying the BBC Master's flicker-free algorithm to the other versions Drawing circles and ellipses Circles, ellipses, hyperspace and docking effects Drawing circles and ellipses Drawing circles The routines that draw planets and the hyperspace and docking tunnels The ball line heap How we remember the lines used to draw circles so they can be redrawn Drawing ellipses How Elite draws ellipses for the planet's crater, meridian and equator Drawing planets Craters, meridians and the dots of Saturn Drawing planets Drawing craters The algorithms behind the huge craters of planets like Diso Drawing meridians and equators The algorithms behind the meridians and equators of planets like Lave Drawing Saturn on the loading screen How the loader draws the dot-based Saturn in Elite's epic loading screen Drawing suns and explosions Shimmering suns and glittering explosion clouds Drawing suns and explosions Drawing the sun Drawing and storing the sun, and the systems on the Short-range Chart Drawing explosion clouds Drawing and storing explosion clouds for ships whose luck runs out... Stardust How the tiny particles of moving stardust work Stardust Stardust in the front view The algorithms behind the stardust particles in the front view Stardust in the side views The algorithms behind the stardust particles in the side views Missions The three missions in the 6502 versions of Elite Missions The Constrictor mission Hunting high and low for the stolen Constrictor The Thargoid Plans mission Evading the Thargoid threat in the depths of the third galaxy The Trumbles mission Furry fun in the Commodore 64 and NES versions of Elite Text Text tokenisation and the "goat soup" algorithm Text Printing text tokens Printing recursive text tokens, two-letter tokens and control codes Extended text tokens The extended text token system in the enhanced versions of Elite Extended system descriptions The famous "goat soup" algorithm that generates those strange and wonderful system descriptions Printing decimal numbers How to print big decimal numbers with decimal points and padding Multi-language support in NES Elite How the NES version supports English, German and French text Maths Arithmetic, geometry and random numbers Maths Adding sign-magnitude numbers Doing basic arithmetic with sign-magnitude numbers Calculating square roots The algorithm behind the square root routine Shift-and-add multiplication The main algorithm behind Elite's many multiplication routines Multiplication and division using logarithms Faster multiplication and division routines by using logarithm lookup tables Shift-and-subtract division The main algorithm behind Elite's many division routines The sine, cosine and arctan tables The lookup tables used for the planet-drawing trigonometric functions Generating random numbers The algorithm behind Elite's random number generation routines Saving and loading Commander files and competition codes Saving and loading Commander save files A description of each and every byte in the saved commander file The competition code All the information that's hidden in the Elite competition code Version-specific deep dives BBC Micro disc Elite Using a disc drive to create canonical Elite BBC Micro disc Elite Swapping between the docked and flight code Using the BBC's disc drive to swap out the game binaries when launching and docking Ship blueprints in the BBC Micro disc version How the BBC Micro disc version loads its ship blueprints into memory 6502 Second Processor Elite Tube APIs, scroll texts, speech support and more 6502 Second Processor Elite 6502 Second Processor Tube communication How the 6502 Second Processor version of Elite talks over the Tube The 6502 Second Processor demo mode All about the Star Wars-esque scroll text in the Tube-based version of Elite The TINA hook Adding your own custom code to the 6502 Second Processor version using TINA Secrets of the Executive version Infinite jumps, retro-futuristic fonts, speech support... and Pizzasoft? Commodore 64 Elite Colours, music, sprites and remote development 6502 Second Processor Elite Colouring the Commodore 64 bitmap screen Adding a distinctive dash of colour to the Commodore 64 dashboard Sprite usage in Commodore 64 Elite Laser crosshairs, colourful explosions and lots of cuddly, furry Trumbles Sound effects in Commodore 64 Elite Making the most of the SID sound synthesiser Music in Commodore 64 Elite The music driver behind the iconic Blue Danube and the catchy Elite Theme Building Commodore 64 Elite from the source disk How to build Commodore 64 Elite from the original BBC Micro source disk Developing Commodore 64 Elite on a BBC Micro Sending Elite between 8-bit machines with the Programmer's Development System NES Elite Elite on the Nintendo Entertainment System NES Elite Comparing NES Elite with the other versions The features that make NES Elite so unique Understanding the NES for Elite The NES architecture and how it applies to Elite Splitting NES Elite across multiple ROM banks Details of the MMC1 controller and the 128K game ROM The pattern and nametable buffers How the NES version achieves its beautifully smooth wireframe graphics Bitplanes in NES Elite Squeezing two patterns into one tile using separate bitplanes Drawing vector graphics using NES tiles The art of the impossible: vector graphics on the NES Views and view types in NES Elite Configuring all the different views in the console version Image and data compression How images and data are compressed in NES Elite Displaying two-layer images The beautiful pixel art of the commander and system images Sprite usage in NES Elite Stardust, scanners, images, crosshairs and more The NES combat demo How the scroll text and combat practice works Auto-playing the combat demo The magic of watching Elite playing itself Sound effects in NES Elite The largest set of sound effects in all the 6502 Elites Music in NES Elite How David Whittaker's music module plays The Blue Danube Elite-A How Angus Duggan modified the original Elite Elite-A Making room for the modifications in Elite-A How Angus Duggan found enough spare memory for Elite-A's modifications Buying and flying ships in Elite-A What it's like to save up for and fly your dream ship in Elite-A Ship blueprints in Elite-A The enhanced logic behind Elite-A's sophisticated ship blueprints system The Encyclopedia Galactica Inside the encyclopedia, Elite-A's most recognisable modification The I.F.F. system Friend or foe? Adding ship information to the 3D scanner Fixing ship positions Why Elite spawns certain ships in certain places, and how Elite-A fixes this Special cargo missions Procedurally generating delivery missions and tracking progress Delta 14B joystick support All the controls of Elite in one single handset - the future is here! Tube communication in Elite-A How the 6502 Second Processor version of Elite-A talks over the Tube The original source files How the original Elite-A source was written, edited and compiled Elite hacks Universe editor, flicker-free, teletext and more Index Index of all Elite hacksA list of all the Elite hacks on this site Elite hacks Elite Compendium The best way to play all the hacked and enhanced versions of Elite Elite Compendium About the Elite Compendium Bringing all the best Elite hacks together in one feature-packed disc Playing the Elite Compendium How to download and play the Elite Compendium Technical information Details of all the hacks and enhancements in the Elite Compendium Elite Universe Editor Create your own Elite universes and "press play" to bring them to life Elite Universe Editor An introduction to the Elite Universe Editor Create your own Elite universes and "press play" to bring them to life Playing the Elite Universe Editor How to download and play the Elite Universe Editor A summary of keys All the keys used in all the different versions of the Elite Universe Editor Instructions for the BBC version Full instructions for the Elite Universe Editor on the BBC Micro and Master Instructions for the Commodore 64 version Full instructions for the Elite Universe Editor on the Commodore 64 Technical information Details of how the Elite Universe Editor works under the bonnet Flicker-free Elite Improved ship drawing on the BBC Micro, Commodore 64 and Commodore Plus/4 Flicker-free Elite An introduction to flicker-free Elite Improved ship drawing on the BBC Micro, Commodore 64 and Commodore Plus/4 Playing flicker-free Elite How to download and play flicker-free Elite, on both the BBC and Commodore Technical information Details of how flicker-free Elite weaves its magic Teletext Elite The disc version of BBC Micro Elite, converted to run in teletext Teletext Elite An introduction to Teletext Elite The disc version of BBC Micro Elite, converted to run in teletext Playing Teletext Elite How to download and play Teletext Elite Instructions for Teletext Elite Full instructions for Teletext Elite on the BBC Micro Technical information Details of how Elite was converted to use teletext Elite over Econet Elite that loads over an Econet network and supports live multiplayer scoreboards Elite over Econet About Elite over Econet Adding Econet support and multiplayer scoreboards Playing Elite over Econet How to download and play Elite over Econet Installing Elite over Econet How to install Elite on an Econet fileserver The Elite multiplayer scoreboard Running multiplayer Elite competitions with a live Econet-based scoreboard Technical information Details of how Elite over Econet works Elite 3D BBC Micro Elite in full anaglyph 3D - just add a pair of fancy coloured glasses Elite 3D About Elite 3D Taking 8-bit Elite into another dimension with anaglyph 3D and coloured specs Playing Elite 3D How to download and play Elite 3D, and how to configure the anaglyph settings Configuring Elite 3D How to configure the anaglyph settings in Elite 3D Technical information Details of how Elite 3D works BBC Micro Elite... with music! The title and docking music from the Commodore 64, shoehorned into BBC Micro Elite BBC Micro Elite... with music! About the musical version of BBC Micro Elite BBC Micro and BBC Master Elite, with added title and docking music Playing musical BBC Micro Elite How to download and play the musical version of BBC Micro Elite Technical information How the Commodore 64's music was ported to Elite on the BBC Micro BBC Master disc Elite The disc version of BBC Micro Elite, converted to run on the BBC Master BBC Master disc Elite About BBC Micro disc Elite on the BBC Master The disc version of BBC Micro Elite, converted to run on the BBC Master Playing BBC Micro disc Elite on the BBC Master How to download and play the original disc version of Elite on the BBC Master Technical information Details of how disc Elite was converted from the BBC Micro to the BBC Master Indexes to the source code A-Z indexes, code usage analysis and more Indexes to the source code BBC Micro cassette source code indexes A-Z indexes and indexes by category for the BBC Micro cassette version of Elite A-Z indexes for the BBC Micro cassette version A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for the BBC Micro cassette version List of all subroutines by category Subroutines in the BBC Micro cassette version of Elite List of all variables by category Variables in the BBC Micro cassette version of Elite List of all workspaces by category Workspaces in the BBC Micro cassette version of Elite List of all macros by category Macros used in the BBC Micro cassette version of Elite BBC Micro disc source code indexes A-Z indexes and indexes by category for the BBC Micro disc version of Elite A-Z indexes for the BBC Micro disc version A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for the BBC Micro disc version List of all subroutines by category Subroutines in the BBC Micro disc version of Elite List of all variables by category Variables in the BBC Micro disc version of Elite List of all workspaces by category Workspaces in the BBC Micro disc version of Elite List of all macros by category Macros used in the BBC Micro disc version of Elite Acorn Electron source code indexes A-Z indexes and indexes by category for the Electron version of Elite A-Z indexes for the Electron version A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for the Electron version List of all subroutines by category Subroutines in the Electron version of Elite List of all variables by category Variables in the Electron version of Elite List of all workspaces by category Workspaces in the Electron version of Elite List of all macros by category Macros used in the Electron version of Elite 6502 Second Processor source code indexes A-Z indexes and indexes by category for the 6502 Second Processor version of Elite A-Z indexes for the 6502 Second Processor version A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for the 6502 Second Processor version List of all subroutines by category Subroutines in the 6502 Second Processor version of Elite List of all variables by category Variables in the 6502 Second Processor version of Elite List of all workspaces by category Workspaces in the 6502 Second Processor version of Elite List of all macros by category Macros used in the 6502 Second Processor version of Elite Commodore 64 source code indexes A-Z indexes and indexes by category for the Commodore 64 version of Elite A-Z indexes for the Commodore 64 version A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for the Commodore 64 version List of all subroutines by category Subroutines in the Commodore 64 version of Elite List of all variables by category Variables in the Commodore 64 version of Elite List of all workspaces by category Workspaces in the Commodore 64 version of Elite List of all macros by category Macros used in the Commodore 64 version of Elite BBC Master source code indexes A-Z indexes and indexes by category for the BBC Master version of Elite A-Z indexes for the BBC Master version A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for the BBC Master version List of all subroutines by category Subroutines in the BBC Master version of Elite List of all variables by category Variables in the BBC Master version of Elite List of all workspaces by category Workspaces in the BBC Master version of Elite List of all macros by category Macros used in the BBC Master version of Elite NES source code indexes A-Z indexes and indexes by category for the NES version of Elite A-Z indexes for the NES version A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for the NES version List of all subroutines by category Subroutines in the NES version of Elite List of all variables by category Variables in the NES version of Elite List of all workspaces by category Workspaces in the NES version of Elite List of all macros by category Macros used in the NES version of Elite Elite-A source code indexes A-Z indexes and indexes by category for Elite-A A-Z indexes for Elite-A A-Z index of the source code An index of every subroutine, entry point, variable, workspace and macro in the source code Source code cross-references Every label and variable in the source code and where they are used Indexes by category for Elite-A List of all subroutines by category Subroutines in Elite-A List of all variables by category Variables in Elite-A List of all workspaces by category Workspaces in Elite-A List of all macros by category Macros used in Elite-A Indexes of variations Indexes of variations and code usage How code is shared between the different versions of Elite, and how it varies between versions Indexes of variations and code usage All shared code that contains variations Code that appears in multiple versions and which differs between versions All shared code that contains no variations Code that appears in multiple versions and which is the same in all versions Version-specific routines Code that appears in just one version of Elite Source code statistics Instruction counts and other source code stats Source code statistics Code statistics for the BBC Micro cassette version A breakdown of the BBC Micro cassette source code by category, type and number of instructions Code statistics for the BBC Micro disc version A breakdown of the BBC Micro disc source code by category, type and number of instructions Code statistics for the Acorn Electron version A breakdown of the Acorn Electron source code by category, type and number of instructions Code statistics for the 6502 Second Processor version A breakdown of the 6502 Second Processor source code by category, type and number of instructions Code statistics for the Commodore 64 version A breakdown of the Commodore 64 source code by category, type and number of instructions Code statistics for the BBC Master version A breakdown of the BBC Master source code by category, type and number of instructions Code statistics for the NES version A breakdown of the NES source code by category, type and number of instructions Code statistics for Elite-A A breakdown of the Elite-A source code by category, type and number of instructions My software archaeology sites Mark Moxon's Software Archaeology Elite on the 6502 Aviator on the BBC Micro Revs on the BBC Micro Lander on the Acorn Archimedes My writing sites Mark Moxon's Travel Writing Walking Land's End to John o'Groats Tubewalker: The Tube, on Foot Contact details and more Mark Moxon's Homepage