Introduction
An ATR file is a copy of a floppy disk for the Atari 8-bit computers: the 400, 800, XL and XE. It is the standard disk format of Atari emulators, and devices that connect a real Atari to a PC or memory card serve ATR files to it as if they were disks.
An ATR is a short header followed by every sector of the disk in order. It does not
record timing or bad sectors, so some copy-protected disks need other formats. The same sectors
without the header are called an .xfd file: the explorer reads both as one format
with two containers (see Header and sectors).
A file dropped on any page opens in the explorer. It shows the header and every sector, labelled by what it is. A disk written by Atari DOS 2.0 or 2.5 is read as a file system: the free-sector map and the directory are listed, each file’s chain of sectors is followed, and each file opens as a file of its own: a program through the XEX viewer, ATASCII text as text. A bootable disk’s boot sectors are disassembled. The container, the sector size, the way a double density image stores its boot sectors and whether to read DOS 2 are choices in the options bar, set from the file when it says.
Structure
The 16-byte header starts with the bytes 96 02. Then come the size of
the image in units of 16 bytes, split into a low word and a high byte, and the sector
size: 128 bytes for single and enhanced density, 256 for double density. The remaining
bytes are flags and unused space. All values are little-endian.
The sectors follow, numbered from 1. On a double density disk the first three sectors, which hold the boot code, are 128 bytes each, as the Atari reads them, and the rest are 256 bytes. A standard single density disk has 720 sectors, giving a 92,176-byte file.
0Header96 02, image size, sector size, flags16 bytes16Sectors 1 to 3 the boot sectors128 bytes each400Sectors 4 onwards in order128 or 256 bytes each
Disk sizes
| Disk | Sectors | Sector size | ATR file | XFD file |
|---|---|---|---|---|
| Single density (90 KB) | 720 | 128 | 92,176 bytes | 92,160 bytes |
| Enhanced density (130 KB) | 1,040 | 128 | 133,136 bytes | 133,120 bytes |
| Double density (180 KB) | 720 | 256, the first three 128 | 183,952 bytes | 183,936 bytes (or 184,320 when the boot sectors take 256-byte slots) |
Other sizes exist (double sided, hard disk images, 512-byte sectors); the explorer reads any whole number of 128- or 256-byte sectors and says when the size is not a whole number.
What is on the disk
The ATR says nothing of the disk’s contents. Most disks were written by Atari DOS 2.0 or 2.5, which the explorer reads: the VTOC, directory and file chains. A disk can also be a game that boots straight from its boot sectors and uses no file system. MyDOS, SpartaDOS and DOS XL disks have other layouts; they are shown as sectors and described only in outline.
Not described
Known, not yet covered
- Reference and viewer: MyDOS, SpartaDOS and DOS XL file systems (subdirectories, long sector links, bitmaps in other places). They are documented by their authors, but no real disk was available to check a decoder against, so those disks show their sectors only. See Atari DOS 2 and others.
- Viewer: disks with bad sectors and copy protection. An ATR does not record them; other disk image formats (ATX, PRO) do, and are different files that are not read.
- Viewer: the second boot stage. A boot disk usually loads a loader that reads more sectors; the explorer disassembles only the sectors the first stage names.
Unknown
- Reference: no real ATR or XFD was available on this machine while these pages
were written. The header and sector layout were checked against the code of an emulator
(sector counts and every sector’s bytes), and the DOS 2 file system against built disks. The
second VTOC of DOS 2.5 (which bytes of sector 1024 hold what) is now sourced from the raw
source of
atr.cin jhallen/atari-tools, and bit 7 of a sector’s byte count from the AtariMax DOS chapter; the DOS 2.5 flag$03and the MyDOS flag bits come from one secondary web page (Thunderdome) only. None of it could be checked against a real disk, and what DOS 2 itself writes in those bits is not documented in the sources read.