The DSK format comes from the CPCEMU emulator; the extended format was added later so
that copy-protected disks with irregular tracks could be stored. Both describe the disk
as the Amstrad’s µPD765 floppy controller sees it: tracks, sector IDs and status bytes.
This page follows the Sinclair Wiki’s DSK format page and MAME’s reader
(src/lib/formats/dsk_dsk.cpp). Numbers
are little-endian.
Disk information block
The first 256 bytes of the file.
| Offset | Size | Standard DSK | Extended DSK |
|---|---|---|---|
0x00 | 34 | MV - CPCEMU Disk-File, CR LF, Disk-Info, CR LF. Readers check only MV - CPC. | EXTENDED CPC DSK File, CR LF, Disk-Info, CR LF. Readers check EXTENDED. |
0x22 | 14 | Name of the program that made the file | Name of the program that made the file |
0x30 | 1 | Number of tracks | Number of tracks |
0x31 | 1 | Number of sides, 1 or 2 | Number of sides, 1 or 2 |
0x32 | 2 | Size of every track, including its 256-byte track information block | Unused |
0x34 | 204 | Unused | Track size table: one byte per track and side, the size divided by 256. 0 means the track was not formatted and is not stored. |
Track blocks follow from offset 256, in the order track 0 side 0, track 0 side 1, track 1 side 0, and so on (one side only for single-sided disks). The block of a given track starts at 256 plus the sizes of all the tracks before it.
Track information block
The first 256 bytes of each track block; the sector data follows at +256.
| Offset | Size | Name | Description |
|---|---|---|---|
0x00 | 12 | Signature | Track-Info, CR LF. |
0x0C | 4 | – | Unused. |
0x10 | 1 | Track number | – |
0x11 | 1 | Side number | 0 or 1. |
0x12 | 2 | – | Unused in the Sinclair Wiki’s description; any later meaning is not covered here. |
0x14 | 1 | Sector size | The size code N used when the track was formatted; sectors are 128 × 2N bytes (2 means 512). |
0x15 | 1 | Number of sectors | Sectors on the track; 0 for a track with no sectors. |
0x16 | 1 | Gap 3 length | The gap used when formatting. |
0x17 | 1 | Filler byte | The byte the sectors were filled with when formatted, often E5. |
0x18 | 8 each | Sector information list | One entry per sector, in the order they occur on the track; see below. |
Sector information
| Offset | Size | Name | Description |
|---|---|---|---|
0 | 1 | C | Track number in the sector’s ID field. |
1 | 1 | H | Side number in the ID. |
2 | 1 | R | Sector number in the ID (Sinclair Wiki: 1–9 on +3 disks; others use 40–49 and C0–C9). |
3 | 1 | N | Size code in the ID. |
4 | 1 | ST1 | The controller’s status register 1 after reading the sector. |
5 | 1 | ST2 | Status register 2. |
6 | 2 | Data length | Extended format: the bytes stored for this sector. Unused in the standard format, where every sector is 128 × 2N bytes of the track’s size code. |
MAME’s reader (src/lib/formats/dsk_dsk.cpp) uses these status bits:
| Bit | ST1 | ST2 |
|---|---|---|
0x04 | Set: no data is stored for the sector | – |
0x20 | CRC error (MAME: in the ID field, or a bad data CRC) | CRC error in the data field |
0x40 | – | Deleted data |
MAME treats a sector with a data CRC error that is not deleted as “weak”. The other bits of the controller’s status registers are not described by the sources read for this page.
Example
00000000 45 58 54 45 4E 44 45 44 20 43 50 43 20 44 53 4B EXTENDED CPC DSK
00000010 20 46 69 6C 65 0D 0A 44 69 73 6B 2D 49 6E 66 6F File..Disk-Info
00000020 0D 0A …
00000030 28 01 00 00 13 13 13 13 13 13 13 13 13 13 13 13 (...............
Reading it: the extended signature; 40 tracks (0x28), one side; every
track 0x13 × 256 = 4,864 bytes, which is a 256-byte track information
block and nine 512-byte sectors.