From the Sinclair wiki page “TR-DOS filesystem”, read through a summarising fetch tool: “our words”. Offsets inside a sector are in bytes from the start of the sector; the image is read in plain order.
Geometry
256-byte sectors, 16 to a track, one or two sides, 40 or 80 tracks a side. The tracks of a double-sided disk are numbered logically in the order h0t0, h1t0, h0t1 and so on up to h1t79 (logical track 159), so sector s of logical track
t is at byte (16 × t + s) × 256 of the image whatever the geometry. Sector numbers in descriptors count from 0. Files are stored whole, in one run, not fragmented; the first file starts at logical track 1, sector 0.
Catalogue
Track 0, sectors 0 to 7 (the first 2,048 bytes): 128 descriptors of 16 bytes. A deleted file’s name starts with the byte $01. The page says a zero byte at the start of the disk information sector marks the end of the catalogue and
marks that as uncertain; the viewer treats a descriptor whose first byte is 0 as an empty entry and reports descriptors after it.
File descriptor
| Offset | Size | Meaning |
|---|---|---|
$00 | 8 | Name, padded with spaces; a first byte of $01 marks a deleted file |
$08 | 1 | Type: B BASIC, C CODE, D data array, # stream file |
$09 | 2 | BASIC: the total size including variables, without the start-line bytes. Array: bit 7 set, bit 6 set for a numeric array and clear for a character array, bit 5 set; the low bits are unreliable. CODE: the load address. Stream: not used |
$0B | 2 | BASIC: the start of the variables. CODE and array: the length in bytes |
$0D | 1 | The length in sectors |
$0E | 1 | The first sector |
$0F | 1 | The first logical track |
A BASIC file’s start line is not in the descriptor: it follows the program’s end marker $80 as the token $AA and a little-endian word. The viewer does not read it.
Disk information, track 0 sector 8
At byte $800 of the image.
| Offset | Size | Meaning |
|---|---|---|
$00 | 1 | 0 marks the end of the catalogue (uncertain, see above) |
$01–$E0 | 224 | Not used, often zero; free for information from the program that made the disk |
$E1 | 1 | The sector of the first free place |
$E2 | 1 | The logical track of the first free place |
$E3 | 1 | Disk type: $16 80 tracks double-sided, $17 40 double-sided, $18 80 single-sided, $19 40 single-sided |
$E4 | 1 | The number of files |
$E5 | 2 | The number of free sectors |
$E7 | 1 | The TR-DOS ID, $10 |
$E8 | 1 | Not used: 0 |
$E9 | 9 | Not used: spaces |
$F3 | 1 | Not used: 0 |
$F4 | 1 | The number of deleted files |
$F5 | 8 | The disk label |
$FD | 3 | Not used: zero |
The viewer checks that the type byte and the image size agree, that the ID is $10, that the file count equals the descriptors that are not deleted (our reading: the page does not say whether deleted files are counted), that the deleted count equals the deleted descriptors, and that the free sector count equals the sectors after the first free place (our reading of how the count is made).
Files
A file is its number of sectors from its first sector and track on, whole sectors, in one run; CODE and array files fill their sectors only as far as the length in the descriptor says. The viewer reports a first sector above 15, data on track 0, data past the end of the image, data overlapping another file’s and a length bigger than the sectors hold.
Not described
Known, not yet covered
- BASIC tokenisation, the stored start line and array contents.
Unknown
- Whether the number of files counts deleted ones; the end-of-catalogue marker.