Introduction
A D64 file is a copy of a floppy disk for the Commodore 1541 disk drive, the drive used with the Commodore 64. C64 emulators load D64 files as if they were disks, and most surviving C64 software is kept in this format.
The file holds every 256-byte sector of the disk in order. A standard 35-track disk gives a file of 174,848 bytes. Some images add one error byte per sector at the end, giving 175,531 bytes, and some cover 40 tracks.
Structure
The 1541 records more sectors on the longer outer tracks. Tracks 1 to 17 have 21 sectors, tracks 18 to 24 have 19, tracks 25 to 30 have 18 and tracks 31 to 35 have 17, 683 sectors in all. The image stores them track by track, starting at track 1.
Track 18, in the middle, holds the disk’s catalogue (see BAM and directory). Sector 0 of track 18 is the block availability map (BAM), which marks the free sectors on every track and holds the disk name and ID. The directory starts at track 18 sector 1, with eight 32-byte entries per sector giving each file’s type, name, size and first sector. Files and directory sectors form chains: the first two bytes of each sector give the track and sector of the next, and the remaining 254 bytes hold data.
0Tracks 1 to 17 21 sectors each91,392 bytes91392Track 18 the BAM in sector 0, then the directory4,864 bytes96256Tracks 19 to 24 19 sectors each29,184 bytes125440Tracks 25 to 30 18 sectors each27,648 bytes153088Tracks 31 to 35 17 sectors each21,760 bytes
Sizes
Six sizes are in use. They are one format, read the same way: only the number of tracks and the optional error bytes after the sectors differ (see image sizes).
| Tracks | Sectors | Bytes | With error bytes |
|---|---|---|---|
| 35 | 683 | 174,848 | 175,531 |
| 40 | 768 | 196,608 | 197,376 |
| 42 | 802 | 205,312 | 206,114 |
In the explorer
Drop a .d64 file on the explorer to see:
- the tree of the file: every track, and in it every sector, each named for what it is (BAM, a directory sector, sector n of a file, free, an orphan the BAM marks used that nothing reaches, or a sector two files share) with its error byte if the image has them. The BAM and each directory entry show their fields;
- a picture of the whole disk, one square a sector with a legend, the directory as a table, a table of the tracks (the BAM’s counts against what the chains use) and a table of all the sectors;
- every file as something you can open: a PRG in the .PRG viewer (BASIC listing, SYS entry, 6510 disassembly), a SEQ file as text converted from PETSCII, and any other file, or the raw bytes of a SEQ file, as bytes;
- the problems found, listed, with the disk still opening: the checks include a chain that loops, a sector two files use, a free count that disagrees with the BAM’s bitmap, a size field that disagrees with the chain and errors in the error bytes.
The options bar sets the track count and the error bytes (detected from the size), the BAM layout of tracks 36 to 40 (detected, see BAM entries for tracks 36 to 40) and the character set for names and text.
Not described
Known, not yet covered
- Reference: the other changed BAM bytes of GEOS-formatted disks (GEOS).
- Viewer: the GEOS INFO block (icon and description) is not shown, a GEOS VLIR file opens as its records joined end to end, and the size field of a GEOS file is not checked.
- Viewer: graphics characters in names and text are mostly shown as U+FFFD (mapping); every disk is read as a C64 disk, so the character sets of the VIC-20, PET and C128 are not told apart.
- Viewer: the sibling Commodore disk formats are separate formats with their own pages and viewers: D71, D81, D80, D82, G64 and X64. This viewer reads only the 1541’s .D64.
Unknown
- Reference: where PrologicDOS puts the disk ID and DOS type once it has moved the name (BAM extensions); the viewer shows no ID for such a disk.
- Reference: the order in which Commodore’s DOS picks the first sector of a file (only observed).
- Viewer: no real image on the Mac has 40 or 42 tracks, error bytes, a REL file or a GEOS file, so those readings are checked on built images only. There is no emulator on the Mac that mounts disk images; the viewer’s directories and file contents were compared with an independent reader written for the tests and with the
.prgfiles beside the nine real images.
Links
Software
Reference
- VICE manual, The D64 disk image format – section 17.5, the main source of these pages
- Peter Schepers, Commodore disk image formats (unusedino.de) – the layout the VICE manual builds on, with the REL and GEOS pages by Immers, Neufeld, Doherty, Varga and Forster