MGT filesystem

The filesystem described here is used with the MGT DISCiPLE, +D and SAM Coupé. There are several DOSes which use this filesystem (and extensions thereof), including:


 * GDOS (DISCiPLE)
 * G+DOS (+D)
 * SAMDOS (SAM Coupé)
 * UniDOS (DISCiPLE / +D)
 * Beta DOS (DISCiPLE / +D)
 * Master DOS (SAM Coupé)

Disks must be formatted to 10 sectors per track, with 512-byte sectors. Either single-sided or double-sided disks may be used, and up to 80 tracks may be used per side. Sectors are numbered 1..10, and tracks are numbered 0..79 for the first side, and 128..207 for the second side.

The disk is divided two parts. The first is a root directory (consisting of at least the first four tracks on side one). Each directory entry occupies 256 bytes, which gives a minimum of 80 entries (slots) on a disk. Beta DOS and Master DOS allow the root directory to be extended by up to 35 tracks, giving a maximum of 780 slots in Beta DOS. On the SAM, the first sector of track four is used as a boot sector and is (usually) allocated to the first file written to the disk — for this reason, only 78 additional slots can be used in track 4, giving a maximum of 778 slots in Master DOS.

The remaining space on the disk can be allocated to files. In UniDOS, contiguous sectors can also be allocated to subdirectories, using the same directory entry system described above. In almost all cases, the last two bytes in any sector used by a file contain the address (track number, followed by sector number) of the next sector in that file (although this does not apply to UniDOS subdirectories). For the last sector in a file, the track number and address at the end of that sector are set to 0.

Files of certain types include a 9-byte header, and a small amount of special file information is also stored in each file's directory entry. The format of this data varies depending on the file's type.

Some extra information may be stored in the very first directory entry. This includes the number of additional tracks reserved for the directory entry (under Beta DOS and Master DOS), a disk label (Master DOS) and a randomly generated disk ID (Master DOS).

File types

 * 0: Erased
 * 1: ZX BASIC
 * 2: ZX numeric array
 * 3: ZX string array
 * 4: ZX code
 * 5: ZX 48K snapshot
 * 6: ZX Microdrive
 * 7: ZX screen
 * 8: Special
 * 9: ZX 128K snapshot
 * 10: Opentype
 * 11: ZX execute
 * 12: UniDOS subdirectory
 * 13: UniDOS create
 * 16: SAM BASIC program
 * 17: SAM numeric array
 * 18: SAM string array
 * 19: SAM code
 * 20: SAM screen
 * 21: MasterDOS subdirectory (not available under BetaDOS)
 * 22: SAM Driver application
 * 23: SAM Driver bootstrap
 * 24: EDOS NOMEN
 * 25: EDOS system
 * 26: EDOS overlay
 * 28: HDOS Hdos
 * 29: HDOS Hdir
 * 30: HDOS Hdisk
 * 31: HDOS Hfree/Htmp