The Elites written for the 6502 processor (the BBC Micro, Acorn Electron, BBC Master and 6502 Second Processor versions, and in the same layout Elite: The New Kind, the C rewrite) save a commander as a file of exactly 256 bytes. Only the first 76 bytes mean anything: they are the game’s commander data block, copied from memory. The commander’s name is not in the block; it is the name of the file. Two checksums at the end let the game refuse a file that has been edited.
The explorer reads such a file when its extension is .cdr (the
extension is not part of the original game, which has none) and it is 256 bytes long
with both checksums right. It then works the galaxy out from the seeds in the file and
draws it: see the galaxy generator.
The commander block
Byte numbers are offsets in the file. Numbers are little-endian, except the cash, which has its most significant byte first. Names in capitals are the game’s variable names in Mark Moxon’s commented source.
| Offset | Size | Variable | Field | Description |
|---|---|---|---|---|
0 | 1 | TP | Mission status | Bits 0 and 1: mission 1, the Constrictor. Bits 2 and 3: mission 2, the Thargoid plans. See below. Zero in the cassette version, which has no missions. |
1 | 1 | QQ0 | Present system x | The galactic x coordinate of the system the commander is in, 0 to 255. |
2 | 1 | QQ1 | Present system y | The y coordinate, 0 to 255. The galactic chart shows it halved. |
3 | 6 | QQ21 | Galaxy seeds | Three 16-bit seeds, s0, s1 and s2, low byte first: the seeds of system 0 of the galaxy the commander is in. The default is 4A 5A 48 02 53 B7, that is &5A4A, &0248 and &B753, the seeds of Tibedied. |
9 | 4 | CASH | Cash | Tenths of a credit, an unsigned 32-bit number with the most significant byte first. 00 00 03 E8 is 1000 tenths, 100.0 Cr. |
13 | 1 | QQ14 | Fuel | Tenths of a light year, at most 70 (7.0 light years). |
14 | 1 | COK | Competition flags | Bits kept for the competition code the game printed on saving. See below. |
15 | 1 | GCNT | Galaxy number | 0 to 7; shown in the game as 1 to 8. Each galactic hyperdrive jump adds one, and the seeds roll with it. |
16 | 4 | LASER | Lasers | One byte each for the front, rear, left and right views: 0 for none, otherwise bits 0 to 6 are the laser’s power and bit 7 is set for a laser that stays on. Pulse laser 15 (0F), beam laser 143 (8F), mining laser 50 (32) and military laser 151 (97); the last two are in the disc and Master versions. |
20 | 2 | Unused | They belonged to the up and down lasers that were dropped. Zero. | |
22 | 1 | CRGO | Cargo capacity | Two more than the hold’s tonnes: 22 is the standard 20 t, 37 the cargo bay extension’s 35 t. |
23 | 17 | QQ20 | Cargo hold | How much of each good is held, in the order of the market list: Food, Textiles, Radioactives, Slaves, Liquor/Wines, Luxuries, Narcotics, Computers, Machinery, Alloys, Firearms, Furs, Minerals, Gold, Platinum, Gem-Stones, Alien Items. Tonnes, except gold and platinum in kilograms and gem-stones in grams. |
40 | 1 | ECM | E.C.M. system | 0 not fitted, FF fitted. |
41 | 1 | BST | Fuel scoops | 0 or FF. |
42 | 1 | BOMB | Energy bomb | 0, or 7F when fitted. |
43 | 1 | ENGY | Energy unit | 0 not fitted; non-zero fitted (the game writes 1 for the extra energy unit; the energy banks refresh by this number plus one). |
44 | 1 | DKCMP | Docking computer | 0 or FF. |
45 | 1 | GHYP | Galactic hyperdrive | 0 or FF. |
46 | 1 | ESCP | Escape pod | 0 or FF. |
47 | 4 | Unused | Zero in the default commander. | |
51 | 1 | NOMSL | Missiles | 0 to 4. |
52 | 1 | FIST | Legal status | 0 Clean, 1 to 49 Offender, 50 and more Fugitive. |
53 | 17 | AVL | Market quantities | How much of each good the market of the present system has, same order as the hold. 0 means none for sale. |
70 | 1 | QQ26 | Market random byte | A random byte picked for each visit to a system; with the system’s economy it fixes that visit’s prices and quantities. |
71 | 2 | TALLY | Kills | Ships destroyed, 16 bits, low byte first. See the rating. |
73 | 1 | SVC | Save count | 128 for a new commander; the game halves it at every save and does nothing else with it. |
74 | 1 | CHK2 | Second checksum | The first checksum EOR A9. |
75 | 1 | CHK | Checksum | The game’s checksum of bytes 0 to 73. See below. |
76 | 180 | Padding | The game saves a whole 256-byte page. In files saved by the game these bytes are not part of the commander, and the explorer reports how many are not zero but does not reject them. |
The checksums
The game’s CHECK routine starts with A = 73 and then, for each byte from
number 73 down to number 1, adds the byte before it plus the carry of the last addition
and exclusive-ors the result with the byte itself. In C, as Elite: The New Kind writes
it:
acc = 0x49; carry = 0;
for (i = 0x49; i > 0; i--) {
acc += block[i-1] + carry;
carry = acc >> 8;
acc &= 255;
acc ^= block[i];
}
The result is stored at 75 and the same value EOR A9 at 74. When the game
loads a file it computes the checksum again; a mismatch of the first stops the load
(the game loops forever, or in the New Kind refuses the file), and a mismatch only of
the second sets bit 7 of the competition flags, which marks the commander as tampered
with. The commodity bytes and everything else take part in the sum, so any edit has to
be followed by a new checksum.
For the default commander the game’s own source gives the checksum as 03
and the second as AA; the routine above gives 03 for that block.
Kills and the rating
| Rating | Kills |
|---|---|
| Harmless | 0 to 7 |
| Mostly Harmless | 8 to 15 |
| Poor | 16 to 31 |
| Average | 32 to 63 |
| Above Average | 64 to 127 |
| Competent | 128 to 511 |
| Dangerous | 512 to 2559 |
| Deadly | 2560 to 6399 |
| Elite | 6400 and more |
Mission status
| Bits | Value | Meaning |
|---|---|---|
| 0–1 | 0 | Mission 1, the Constrictor: not started |
| 0–1 | 1 | In progress, hunting for the ship |
| 0–1 | 3 | The Constrictor killed, not yet debriefed |
| 0–1 | 2 | Mission and debrief complete |
| 2–3 | 0 | Mission 2, the Thargoid plans: not started |
| 2–3 | 1 | In progress, plans not picked up |
| 2–3 | 2 | In progress, plans picked up |
| 2–3 | 3 | Complete |
Bits 4 to 7 are not used by the disc version’s source.
Competition flags
When the game is loaded it ORs a bit into these flags to say which version it is, and sets bit 7 if the second checksum was wrong. The sources that were read give:
| Bit | Meaning |
|---|---|
| 0 | The commander forced a mis-jump into witch space by hand |
| 1 | Saved by the cassette version |
| 2 | Saved by the disc version before its refund bug was fixed |
| 5 | Saved by the disc version after the fix |
| 7 | The file was altered (the second checksum did not match) |
Bits 3, 4 and 6 are set by other versions (such as the Master and the second processor) whose source was not read for this page; the explorer lists them as bits without a meaning.
Worked example: the default commander
The 76 bytes of the commander the cassette version starts with (everything after byte 75 is padding), as the game’s source defines them:
0000 00 14 AD 4A 5A 48 02 53 B7 00 00 03 E8 46 00 00
0010 0F 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030 00 00 00 03 00 10 0F 11 00 03 1C 0E 00 00 0A 00
0040 11 3A 07 09 08 00 00 00 00 80 AA 03
Byte 1 and 2 are 20 and 173, Lave; bytes 3 to 8 are the seeds; 00 00 03 E8
is 100.0 Cr; 46 is a full 7.0 light years of fuel; 0F at 16 is
a pulse laser in front; 16 is the standard 20 t hold; 03 at 51
is three missiles; the seventeen bytes from 53 are what Lave’s market has; 80
is the save count, and AA 03 the checksums.
Other versions
Elite: The New Kind writes the same 256 bytes (its source puts 04 in the
competition flags, FF for the equipment and 20 in the save count).
The Commodore 64 and Apple II versions have a third checksum, one byte longer, and a
different checksum routine; the NES version encrypts its file; Elite-A changes the
layout. These are not read by the explorer.
Sources
- Commander save files – Mark Moxon’s deep dive, and the NA%, CHECK, SVE and STATUS routines of his BBC Micro cassette and disc sources (github.com/markmoxon)
- Elite: The New Kind – the C source, file.c (save_commander_file, load_commander_file, checksum)