The ATR format was invented by Nick Kennedy for his SIO2PC. It is a 16-byte header followed by the disk’s sectors in order. There is no formal specification; this page follows Jindřich Kubec’s ATR File Format Description and the APE emulator’s Disk Image FAQ (atarimax.com), which numbers the header bytes from 1, so its byte 8 is offset 7 here. All numbers are little-endian.
Header
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
0 | 2 | uint16 | wMagic | 0x0296, stored 96 02: the sum of the character codes of NICKATARI. |
2 | 2 | uint16 | wPars | Size of the disk image in paragraphs (size ÷ 16), low 16 bits. |
4 | 2 | uint16 | wSecSize | Sector size: 128 (0x80) or 256 (0x100). |
6 | 1 | uint8 | btParsHigh | The high part of the size in paragraphs, added by revision 3.00 (APE: “Extended paragraphs”). Neither source gives the formula for combining it with wPars. The size in paragraphs is btParsHigh × 65,536 + wPars, units of 65,536 paragraphs (1 MiB); that is how the writer in the atari5200 emulator builds its headers, and how the explorer reads them. Files over 1 MiB are rare. |
7 | 4 | uint32 | dwCRC | APE’s 32-bit authentication CRC; the algorithm is not described. Kubec marks it “added by APE?”. |
11 | 4 | – | dwUnused | Unused. |
15 | 1 | bits | btFlags | APE: bit 0 write protect, bit 1 sealed (authenticated) image, bits 2–7 unused. |
Sectors
Sectors are numbered from 1, as the Atari numbers them, and stored in order straight after the header: sector n starts at 16 + (n − 1) × sector size for 128-byte sectors.
Kubec: if the sector size is over 128, the first three sectors should be 128 bytes long (the APE FAQ notes a double-density drive sends the first three boot sectors as 128 bytes), so sector n (n ≥ 4) starts at 16 + 384 + (n − 4) × 256. Kubec adds that a few files make those sectors 256 bytes long instead.
The APE FAQ gives the ATR equivalents of the three Atari disk formats: 720 sectors of 128 bytes (single density), 1,040 sectors of 128 bytes (1050 enhanced density), and 720 sectors of 256 bytes (double density). The sizes below follow from those.
| Disk | Sectors | Sector size | Paragraphs | File size |
|---|---|---|---|---|
| Single density | 720 | 128 | 0x1680 (5,760) | 92,176 bytes |
| Enhanced density (1050) | 1,040 | 128 | 0x2080 (8,320) | 133,136 bytes |
| Double density | 720 | 256 (first three 128) | 0x2CE8 (11,496) | 183,952 bytes |
What the sectors hold depends on the disk operating system that wrote them. The boot sectors and the Atari DOS 2 file system are described on their own pages; the other file systems (MyDOS, SpartaDOS and others) are not.
The two double density layouts
Kubec’s description says the first three sectors of a double density image are 128 bytes long, and that a few files make them 256 bytes long instead. Both exist, and a reader tells them apart by the length of the sector data: with 128-byte boot slots it is 384 + 256 × n bytes (so it leaves 128 when divided by 256); with 256-byte slots it is a multiple of 256, the boot data in the first 128 bytes of each slot. The atari5200 emulator’s ATR reader makes the same choice from the remainder, and the explorer gives the same answer for every image tested against it. The options bar can override it.
XFD: the same sectors without a header
An .xfd file is the sectors of an ATR with the 16 header bytes cut off: nothing says
how big a sector is. A reader goes by the file size: 92,160 bytes is 720 sectors of 128 bytes,
133,120 is 1,040 sectors of 128, and 183,936 or 184,320 is 720 sectors of 256 (the first with
128-byte boot slots, the second with 256-byte slots). Another size is read as 128-byte sectors
unless it is a multiple of 256 above 92,160. These size rules are the explorer’s own, a
judgement from the three standard disks, not from a specification; the options bar overrides
them. The explorer treats XFD and ATR as one format with two containers, so everything else on these
pages applies to both.
Example
00000000 96 02 80 16 80 00 00 00 00 00 00 00 00 00 00 00 ................
Reading it: magic 96 02; size 0x1680 paragraphs, 92,160
bytes of sectors; sector size 0x80, 128; high size byte 0; no CRC; not
read-only. Sector 1 starts at offset 16.