Skip to navigation

Elite on the BBC Micro and NES

Technical information for Elite over Econet

Details of how Elite over Econet works

Elite doesn't normally load from an Econet fileserver. The main reason is that Econet uses various blocks of memory in the BBC's memory map, and Elite uses the same blocks of memory. It's therefore no surprise that loading Elite over Econet causes memory clashes that crash the computer.

The solution, therefore, to getting Elite to run over Econet is to prevent this memory clashing. Most versions of Econet don't allow you to change the memory locations that it uses, so instead we have to update Elite so it avoids using memory that Econet needs to use.

On top of this, the BBC Master version needs to deal with NMIs from Econet, as otherwise network activity can fatally interrupt the game, and the interface for saving and loading commander files needs to work with the hierarchical filing system used by Econet (NFS), which is quite different to the standard disc filing system (DFS) that Elite normally uses.

We'll take a look at the solutions below, but if you want to follow along, the accompanying repository contains all of the changes that I've made to Elite to make it work over Econet. Specifically, the elite-over-econet repository includes the updated code as submodules, so to find all the changes, search the source files for "Mod:" in either the econet branch of 6502sp-elite-beebasm or the econet branch of master-elite-beebasm.

Preventing memory clash
-----------------------

The first challenge when getting Elite to load over Econet is to prevent Elite from using memory locations that are reserved for Econet. Elite already avoids using memory that is reserved for the MOS, such as pages &2 and &D, but the following Econet-specific memory blocks clash with the game:

  • Zero page locations from &90 to &9F (Econet tends to leave the first six bytes of this block alone, but the whole block is reserved, so we should try to vacate it to be sure)
  • Pages &B and &C, so that's &0B00 to &0CFF
  • On the BBC Micro, Econet also pushes PAGE up by rather more than DFS; on disc systems PAGE gets set at &1900, while on Econet systems with DFS still available it rises two pages higher to &1B00, and the lowest Econet can get is &1200 (when DFS is disabled), which is still &100 bytes higher than the lowest DFS PAGE value of &1100

For the first one - freeing up 16 bytes in zero page - we only need to worry about the BBC Master version. In the 6502 Second Processor version, it's the I/O Processor (i.e. the BBC Micro) that deals with file operations, so it's the memory map of the I/O Processor code that we need to worry about, and not the Parasite code that runs in the co-processor. Elite hardly uses any of zero page in the I/O Processor, so all that needs doing there is to move the variables so they don't clash with &90 to &9F.

The BBC Master version is trickier, but a lot the hard work was already done when adding music to Elite, as the music player requires ten bytes in zero page to work properly (see the technical information for musical BBC Micro Elite for details). Finding a further six bytes on the Master version isn't too hard either, as there are some locations that aren't used at all, and there's also plenty of spare memory in the WP workspace at &0E41, so we can move some of the less used zero page variables there, at the expense of an extra byte in each instruction that accesses these variables (memory we can easily spare).

Freeing up &0B00 to &0CFF is pretty easy too. On the 6502 Second Processor version this part of the I/O processor's memory is only used for the TINA hook, which we can safely ignore as we don't need to use it here. On the Master version, &0B00 to &0CFF is only used by the ship heap for the ship hangar, and as we don't use pages &9 and &A, it's an easy change to move the hanger heap to &0900 to &0AFF instead.

Finally, what about the high value of PAGE on the BBC Micro? Again, this is easy; the I/O Processor code loads at &2300 anyway, which is well above the value of PAGE with Econet fitted, so there is nothing to do here.

So we now have versions of Elite that shouldn't clash with Econet, at least in terms of memory. Let's look at what else needs to be done.

Playing nicely with NFS and NMIs
--------------------------------

Now that Elite should run happily without clashing with Econet, we need to update any DFS-specific code to work with the hierarchical NFS. We also need to ensure that the BBC Master version deals with NMIs correctly, as otherwise the Master will get interrupted by network traffic while we're trying to play Elite (the BBC Micro doesn't appear to have the same issue with NMIs).

The good news is that the BBC Master Compact variant, released by Superior Software in 1987, contains most of what we need. This is BBC Master 128 Elite, updated to work with ADFS, which is also hierarchical. As part of this, the disk access menu was changed to make more sense with the single ADFS drive on the Compact - so things like "drive number" were removed and replaced by a request for a directory name, and the catalogue code was updated to display files in a single column and across multiple pages, as there's too much information to fit two columns on one screen. Finally, routines were added to claim and release the NMI workspace before and after file access, which is exactly what we need to implement for Econet.

It turns out that the Compact's updates work nicely with NFS, with just a few tweaks needed to the OS commands for switching to the commander file directory (which is $.E in the ADFS version, but we want to switch to $.Elite in the user's main directory for Econet Elite). The code changes are also suitable for porting to the I/O Processor code in the 6502 Second Processor version, to update the file menu for NFS. A few OS command strings need the drive number removing in the Parasite code, but that's it.

The next step is to rename the game binaries so we can deploy them all into one folder, so I chose ELTxx as a file format, with the xx part reflecting the original file name (so I.CODE becomes ELTIC, BCODE becomes ELTBC, and so on). These binary files go into the $.Elite directory on the server, and then we just need a couple of tiny binaries to go into the fileserver's library under the names *EliteM and EliteSP, which *DIR into $.Elite and run the relevant game (these binaries are built in the elite-over-econet repository).

And there you have it - Elite loading over Econet.