Skip to navigation

Elite on the BBC Micro

BBC Master memory map

Memory usage in the smoothest version of Elite

The main advantage of the BBC Master compared to the standard BBC Micro is extra memory, and given how tightly packed things are in standard Elite, it's a very welcome addition. The main benefit is that it allows the Master version to use the same mode 1/2 split screen as the 6502 Second Processor version, thus giving four colours in the space view and eight colours in the dashboard.

What the Master doesn't do, perhaps surprisingly, is use this extra memory to implement flicker-free ship drawing. The Master certainly has much smoother ship animation, but there aren't any clever memory techniques in use here - the lack of flicker is down to an improvement in the ship-drawing algorithm rather than any shenanigans with bank-switching or swapping screen memory; even in a Master, there still isn't enough free memory to maintain two copies of the screen.

Let's take a quick look at the extra memory available in the Master, and how it fits into the memory map.

The Master's extra memory
-------------------------

The Master's extra memory comes in three main chunks, and Elite uses all of them.

  • First of all, sideways RAM bank 6 is switched into main memory at &8000 to &BFFF. In the BBC Micro, this address range always contains one of the paged ROMs (such as BASIC), but in the Master it's available as user RAM, so we can use it for storing the ship blueprints, text tokens and so on.
  • Next up is shadow RAM, also known as LYNNE, which sits alongside the main memory. We can switch the memory block from &3000 to &7FFF between main memory and shadow RAM, and we can also set up LYNNE to host the screen memory, from &4000 to &7DFF. In this way screen memory doesn't steal RAM from the main memory, and we can just switch to shadow RAM to poke our graphics directly to the screen.
  • Finally, the Master also supports an area of memory called HAZEL from &C000 to &DFFF, which can be used for the current filing system workspace. Filing system memory requirements are a real pain in the standard BBC Micro, where, for example, the disc filing system pushes the start of user memory (PAGE) from &0E00 to &1900. HAZEL fixes this problem and takes the extra load, leaving PAGE alone and freeing up a lot of extra memory for Elite.

Throughout the source code, you will see memory access being switched between shadow and main RAM. This is done by updating bits 1 and 2 of the Access Control Register at SHEILA &34. This switching aside, the rest of the extra memory just maps into the main memory space, and we can use it as normal.

BBC Master memory map
---------------------

This setup gives us a generous memory footprint when compared to the BBC Micro, though the Master version of Elite still manages to fill most of it up. Here's the memory map of Elite on the BBC Master.

    +-----------------------------------+   &FFFF
    |                                   |
    | Machine Operating System (MOS)    |
    |                                   |
    +-----------------------------------+   &C000
    |                                   |
    | &B200-&BFFF unused                |
    |                                   |
    +-----------------------------------+   &B200
    |                                   |
    | Text tokens, sin/cos tables       |
    |                                   |
    +-----------------------------------+   &A000 = QQ18
    |                                   |
    | &9D95-&9FFF unused                |
    |                                   |
    +-----------------------------------+   &9D94
    |                                   |
    | Ship blueprints (SHIPS.bin)       |
    |                                   |                         Shadow RAM
    +-----------------------------------+-- &8000 = XX21 -------------------+
    |                                   |                                   |
    | &7F48-&7FFF unused                |                                   |
    |                                   |                                   |
    +--------------------- &7F48 = F% --+                &7E00-&7FFF unused |
    |                                   |                                   |
    |                                   |                                   |
    |                                   |                                   |
    |                                   +-- &7E00 --------------------------+
    |                                   |                                   |
    |                                   |                     Screen memory |
    |                                   |                                   |
    | Main game code (BCODE.bin)        +-- &4000 --------------------------+
    |                                   |                                   |
    |                                   |              Zero page swap space |
    |                                   |                                   |
    |                                   +-- &3000 --------------------------+
    |                                   |
    |                                   |
    |                                   |
    +-----------------------------------+   &1300 = TVT3
    |                                   |
    | &12AA-&12FF unused                |
    |                                   |
    +-----------------------------------+   &12AA
    |                                   |
    | WP workspace                      |
    |                                   |
    +-----------------------------------+   &0E41 = WP
    |                                   |
    | Ship line heap descends from WP   |
    |                                   |
    +-----------------------------------+   SLSP
    |                                   |
    .                                   .
    .                                   .
    +-----------------------------------+   &0900
    |                                   |
    | MOS sound/printer workspace       |
    |                                   |
    +-----------------------------------+   &0800
    .                                   .
    .                                   .
    .                                   .
    |                                   |
    +-----------------------------------+   INF
    |                                   |
    | Ship data blocks ascend from K%   |
    |                                   |
    +-----------------------------------+   &0400 = K%
    |                                   |
    | MOS VDU and tape workspace        |
    |                                   |
    +-----------------------------------+   &0300
    |                                   |
    | MOS general workspace             |
    |                                   |
    +-----------------------------------+   &0200
    |                                   |
    | 6502 stack descends from &01FF    |
    |                                   |
    +-----------------------------------+
    |                                   |
    .                                   .
    .                                   .
    .                                   .
    .                                   .
    .                                   .
    |                                   |
    +-----------------------------------+
    |                                   |
    | Heap space ascends from XX3       |
    |                                   |
    +-----------------------------------+   &0100 = XX3
    |                                   |
    | Zero page workspace               |
    |                                   |
    +-----------------------------------+   &0000 = ZP

The memory map is fairly straightforward, but it's worth mentioning the zero page swap space in shadow RAM at &3000. Whenever the game does any filing system work, such as cataloguing discs or saving commander files, it first swaps out the top part of zero page (&0090 to &00EF) with a copy that's been stored at start of LYNNE. This part of zero page is used by the MOS to store various filing system variables, so this process effectively stores a "filing system-compatible" version of zero page in LYNNE, and swaps it in whenever we do any filing work. This enables the game to share this part of zero page with the operating system, but without corrupting the filing system.