Skip to navigation


BBC Micro disc Elite memory map

Memory usage in the enhanced disc version of Elite

Although it isn't quite as impressive as the cassette version when it comes to memory usage, the disc version of BBC Micro Elite is no slouch when it comes to squeezing every last byte out of the BBC Micro. For a start, the code spills out onto the disc, with a separate code file for flight, 16 individual files containing ship blueprints, and a further code file for when we are docked. That's why launching and docking are accompanied by so much disc activity; unlike the cassette version, the code for the disc version of Elite most definitely does not fit into a BBC Micro, at least not all at the same time.

But even with the luxury of being able to swap out the main code block when launching and docking, the disc version takes up almost every spare inch of the BBC Micro, particularly with the flight code, which is such a tight squeeze that it needs to take over the print buffer in order to fit.

The game starts with us being docked at a station, so let's take a look at the memory map for when the docked code is loaded.

Docked memory map (T.CODE)
--------------------------

This is the initial memory map for when the game starts, or when we dock and the docked code has loaded. The memory map changes slightly when we launch from the space station, as detailed in the next section, but most of the following is consistent throughout the game.

  +-----------------------------------+   &FFFF
  |                                   |
  | Machine Operating System (MOS)    |
  |                                   |
  +-----------------------------------+   &C000
  |                                   |
  | Paged ROMs                        |
  |                                   |
  +-----------------------------------+   &8000
  |                                   |
  | Missile blueprint (MISSILE.bin)   |
  |                                   |
  +-----------------------------------+   &7F00 = SHIP_MISSILE
  |                                   |
  | Memory for the split-screen mode  |
  |                                   |
  +-----------------------------------+   &6000
  |                                   |
  | &5F55-&5FFF unused when docked    |
  |                                   |
  +-----------------------------------+   &5F55
  |                                   |
  | Main game code (T.CODE)           |
  |                                   |
  +-----------------------------------+   &11E2 = S%
  |                                   |
  | Break handler for flight code     |
  |                                   |
  +-----------------------------------+   &11D5 = BRBR1
  |                                   |
  | Last saved commander file         |
  |                                   |
  +-----------------------------------+   &117C = S1%
  |                                   |
  | IRQ1 handler, mode 1 palette data |
  |                                   |
  +-----------------------------------+   &1100 = TVT1
  |                                   |
  | DFS general workspace             |
  |                                   |
  +-----------------------------------+   &1000
  |                                   |
  | WP workspace or disc catalogue    |
  |                                   |
  +-----------------------------------+   &0E00 = WP
  |                                   |
  | DFS general workspace             |
  |                                   |
  +-----------------------------------+   &0D9D
  |                                   |
  | CATD routine in DFS NMI workspace |
  |                                   |
  +-----------------------------------+   &0D7A = CATD
  |                                   |
  | DFS general workspace             |
  |                                   |
  +-----------------------------------+   &0D00 = LS%
  |                                   |
  | Ship line heap descends from LS%  |
  |                                   |
  +-----------------------------------+   SLSP
  |                                   |
  .                                   .
  .                                   .
  .                                   .
  .                                   .
  .                                   .
  |                                   |
  +-----------------------------------+   &0ABB when all ship slots are used
  |                                   |
  | Ship data blocks ascend from K%   |
  |                                   |
  +-----------------------------------+   &0900 = K%
  |                                   |
  | MOS sound/printer workspace       |
  |                                   |
  +-----------------------------------+   &0800
  |                                   |
  | Sine, cosine and arctan tables    |
  |                                   |
  +-----------------------------------+   &07C0 = SNE
  |                                   |
  | Recursive text tokens (WORDS.bin) |
  |                                   |
  +-----------------------------------+   &0400 = QQ18
  |                                   |
  | MOS keyboard input buffer         |
  |                                   |
  +-----------------------------------+   &03E0
  |                                   |
  | &03D0-&03DF unused                |
  |                                   |
  +-----------------------------------+   &03D0
  |                                   |
  | UP workspace                      |
  |                                   |
  +-----------------------------------+   &0300 = UP
  |                                   |
  | MOS general workspace             |
  |                                   |
  +-----------------------------------+   &0200
  |                                   |
  | 6502 stack descends from &01FF    |
  |                                   |
  +-----------------------------------+
  |                                   |
  .                                   .
  .                                   .
  .                                   .
  .                                   .
  .                                   .
  |                                   |
  +-----------------------------------+
  |                                   |
  | Heap space ascends from XX3       |
  |                                   |
  +-----------------------------------+   &0100 = XX3
  |                                   |
  | Zero page workspace               |
  |                                   |
  +-----------------------------------+   &0000 = ZP

Another point to note is that the WP workspace at &0E00-&0FD2 uses the same memory as the disc catalogue. On DFS discs, the disc catalogue takes up sectors 0 and 1, and the Disc Filing System loads these two sectors into pages &E and &F so it can work with the disc's file catalogue data without needing constant disc access. Elite uses the same part of memory to store flight-specific data, such as line heaps and stardust coordinates, in the WP workspace, which is acceptable as the flight code doesn't require disc access (you can only save or load commander files when docked).

The only issue is that this obviously corrupts the disc catalogue, so before doing any disc activity, Elite calls the CATD routine at &0D7A, which reloads sectors 0 and 1 into pages &E and &F. This routine is itself tucked away in the middle of the DFS workspace, this time in a safe spot in the NMI vector workspace that persists between disc operations.

Flight memory map (D.CODE)
--------------------------

The memory map for flight is, with two exceptions, the same as for when we are docked. The main difference is that instead of loading a single code file (T.CODE) as we do when we dock, we instead load two files when we launch. First, the flight code file (D.CODE) gets loaded at &11E2 and called, and then the first thing this code does is load one of the ship blueprint files (D.MOA to D.MOP) straight after the end of D.CODE at location &5600. Together, the main flight code and chosen ship blueprint file take up the same part of the memory map as the main docked code (i.e. &11E2-&5FFF), like this:

  .                                   .
  .                                   .
  .                                   .
  |                                   |
  +-----------------------------------+   &6000
  |                                   |
  | Ship blueprints file (D.MOA-MOP)  |
  |                                   |
  +-----------------------------------+   &5600 = XX21
  |                                   |
  | Main game code (D.CODE)           |
  |                                   |
  +-----------------------------------+   &11E2 = S%
  |                                   |
  .                                   .
  .                                   .
  .                                   .

Between them, the main flight code and ship blueprint file take up every single byte between &11E2 and the start of screen memory at &6000. They only manage to fit because the main flight code doesn't contain the two-letter token table at QQ16 (unlike the docked code, which does contain this table). It is still needed during flight, however, so just before it loads the flight code, the docked code copies this 64-byte token table to location &0880, so the flight code can use it there (the copying is done in routine TT110 which gets called when the launch key is pressed).

This memory location is normally used by the MOS print buffer, but as we don't use the printer in this version of Elite, this is a safe location. During flight, then, this part of the memory map looks like this:

  .                                   .
  .                                   .
  .                                   .
  |                                   |
  +-----------------------------------+   &0900 = K%
  |                                   |
  | MOS sound workspace               |
  |                                   |
  +-----------------------------------+   &08C0
  |                                   |
  | Two-letter token lookup table     |
  |                                   |
  +-----------------------------------+   &0880 = QQ16_FLIGHT
  |                                   |
  | MOS sound workspace               |
  |                                   |
  +-----------------------------------+   &0800
  |                                   |
  .                                   .
  .                                   .
  .                                   .

Apart from these two differences, the docked and flight code share the same memory map.