3

The last official version of the Sinclair ZX Spectrum was the +3, released after the company was owned by Amstrad. It included a 3-inch floppy disk drive as used on other Amstrad computers.

But even before this, several aftermarket companies released floppy drive interfaces/controllers. Though there was variation I have read that one format, TR-DOS became a de-facto standard.

For emulation purposes I can find documentation on the file formats used for disk images of both +3 and TR-DOS.

But so far I can't find anything on the format of the files stored on those disks.

I'm assuming the format has to differ from that of files saved on cassette tapes since those require things such as synchronization tones.

Where can I find documentation of the file format of machine code files stored on these offical and de-facto standard Spectrum disk drives? Or if they're simple as I expect they are, we can probably just include it in an answer.

In particular, I'm expecting there might be a header including an address in RAM where the code will be loaded, a length field, an address in RAM where code execution is to begin, perhaps there's a magic word identifier?

I don't even know if such files execute automatically as soon as they're loaded or if you must load them with one command and start them with another.

I only ever owned an original 48K Spectrum. I'd already moved onto the Amiga 1000 by the time these later Spectrums were available so I never used them.

1
  • D40/D80 MDOS stored the files almost identically to tape files ... (no tone pulses just the header data) the extentions where *.P for BASIC and *.B for code or binary data ...
    – Spektre
    Commented Apr 21, 2020 at 17:01

2 Answers 2

6

The original Spectrum +3 manual has a comprehensive description of the disk format:

http://www.worldofspectrum.org/ZXSpectrum128+3Manual/chapter8pt27.html

For TR-DOS, it's worth knowing that the .TRD file format is a simple sector-by-sector dump of the disk contents with no additional headers, so any description of the .TRD format (such as this one on zx-modules.de) is, by extension, a description of the on-disk file format.

3
  • Thanks. I hadn't found that +3 manual yet in my searches. And that info on .TRD is much clear than what I'd stumbled across so far too! Commented Apr 21, 2020 at 8:26
  • 1
    And as a slight aside: TR-DOS is a standard from after the original Western commercial life of the machine; but if you’re interested in the MGT Disciple and +D, they share their on-disk layout with the SAM Coupé and you can find documentation of both at faqwiki.zxnet.co.uk/wiki/MGT_filesystem
    – Tommy
    Commented Apr 21, 2020 at 13:28
  • @Tommy: Yes I was intending to look at Sam Coupe files, which is from where I think I found that I needed to know about TR-DOS. I've got to say I'm really having trouble following the doc in the wayback machine by comparing to the hex of a TRD file. Maybe I'm tired or old but maybe it's not too clear. Commented Apr 21, 2020 at 14:19
3

TR-DOS

Files themselves have no header at all. Metadata is stored in the directory section of the disk, along with the filename.

The metadata has a type field, which is also the file extension. Depending on this field you interpret some of the other fields in different ways. "B" for Basic programs. "C" for machine code, or any binary file really such as screenshots. "D" for "data array files". "#" for "serial/random access files" AKA "print files". Code files include an address where the code will be loaded and begin execution. Basic program files can include a line number to begin running at. Other file extensions are treated like code files.

BUT some files do have a footer! Basic files and "data array files" have four extra bytes following the regular data. These bytes are not counted in the fields which indicate the length of the file. For Basic programs, one of the fields is the auto-start line number.

file body of Basic program files:
=======================================================================
Offset        |Type       +Length:        Description:
--------------+-----------+--------------+-----------------------------
+0            |byte array |[file length] |data of the Basic program
+[file len]   |char, char |2             |param 2 indicator: #128, #170
+[file len]+2 |word       |2             |autostart line num: 0..9999

+3DOS

Files may have a 128-byte header:

Bytes 0...7 - +3DOS signature - 'PLUS3DOS'
Byte 8      - 1Ah (26) Soft-EOF (end of file)
Byte 9      - Issue number
Byte 10     - Version number
Bytes 11...14   - Length of the file in bytes, 32 bit number,
            least significant byte in lowest address
Bytes 15...22   - +3 BASIC header data
Bytes 23...126  - Reserved (set to 0)
Byte 127    - Checksum (sum of bytes 0...126 modulo 256)

The BASIC header data field has this format:

|----------------|-----|-----|-----|-----|-----|-----|-----|
|   Byte         |  0  |  1  |  2  |  3  |  4  |  5  |  6  |
|----------------|-----|-----|-----|-----|-----|-----|-----|
|Program         |  0  |File length|8000h/LINE |prog offset|
|Numeric array   |  1  |File length| xxx |name | xxx | xxx |
|Character Array |  2  |File length| xxx |name | xxx | xxx |
|Code            |  3  |File length| load addy | xxx | xxx |

Some sources indicate more types such as 4, "Snapshot" and 5, "long file". But I think those are extensions on some emulator or modern peripherals for using SD cards.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .