Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Commodore D64, D71 and D81 disk images

From ReverseEngineering.wiki
Format
Platforms Platform:Commodore 64
Magic none (identified by size)
Extensions .d64 .d71 .d81
On this wiki Facts · Code · Notes · Topics

Sector dumps of Commodore 1541 (D64, 35 tracks, 174848 bytes), 1571 (D71, two sides) and 1581 (D81, 80 tracks of 10 x 512-byte sectors) disks; D64 uses four speed zones with 21/19/18/17 sectors per track and may append one error byte per sector.

Identification

No magic: images are recognised by size. A 35-track D64 is 683 sectors x 256 = 174848 bytes; 40 tracks is 768 sectors (196608), 42 tracks 802 sectors. MAME also accepts the same size plus one byte per sector (683 extra bytes, 175531 total), the per-sector error-code table that some tools append.

D64 layout

Sectors are stored in order track 1 sector 0 onward, 256 bytes each. Sectors per track: tracks 1-17 have 21, 18-24 have 19, 25-30 have 18, 31-35 (and the extension tracks 36-42) have 17. The four zones also set the drive bit-cell speed, which is why a raw GCR copy (Format:G64 GCR disk image) carries a speed zone per track. Track 18 holds the directory: sector 0 is the header/BAM (block availability map) and sector 1 onward the directory. Byte offset of a (track, sector) is the sum of the sectors in the earlier tracks times 256; track 18 sector 0 starts at 0x16500, and the disk id (2 bytes) sits at +0xA2 of that sector (file offset 0x165A2). BAM sector (VICE vdrive, GPL-2.0-or-later): +0/+1 track and sector of the first directory sector (18, 1), +2 DOS format byte 'A' (0x41), +3 0x80 on a 1571 (double sided), BAM entries from +4 at 4 bytes per track (free-sector count, then a 3-byte bitmap), disk name 16 bytes at +0x90 padded with 0xA0, disk id (2 bytes) at +0xA2, DOS type "2A" at +0xA5. VICE keeps tracks 36-40 at +0xC0 (SpeedDOS extension only). Directory entries are 32 bytes (8 per sector): file type at +2 (low 3 bits: 0 DEL, 1 SEQ, 2 PRG, 3 USR, 4 REL, 5 CBM partition, 6 DIR; 0x20 replacement, 0x40 locked, 0x80 closed), first track/sector at +3/+4, name 16 bytes at +5 padded with 0xA0, REL side-sector track/sector at +0x15/+0x16 and record length at +0x17, size in blocks as u16 little endian at +0x1E. Facts: Fact:Commodore D64, D71 and D81 disk images/struct/D64 BAM sector (track 18 sector 0), Fact:Commodore D64, D71 and D81 disk images/struct/D64 directory entry (32 bytes).

D71 and D81

D71 is two D64 sides (683 sectors x 2 = 349696 bytes), side 1 following side 0; The second-side BAM lives on track 53, sector 0 (VICE: BAM track 18 + 70/2; Fact:Commodore D64, D71 and D81 disk images/behavior/D71 second BAM on track 53). D81 is a 3.5-inch MFM disk, 80 tracks x 2 sides x 10 sectors of 512 bytes presented as 40 logical 256-byte sectors per track (819200 bytes); MAME's table puts the header at 0x61800 (track 40 sector 0) followed by two BAM blocks and the first directory block at 0x61B00.

Related

Format:G64 GCR disk image for protected disks, Platform:Commodore 64.

Sources

MAME src/lib/formats/d64_dsk.cpp, d71_dsk.cpp and d81_dsk.cpp (BSD-3-Clause), commit 1d7a454ed79e97d35d2a9f127ac029ead94711d6.

VICE-Team/svn-mirror (GPL-2.0-or-later) vice/src/diskconstants.h 54-66, 98-112, vdrive/vdrive-bam.h 33-48, vdrive-bam.c 997-1030, 1530-1534, vdrive-dir.h 34-55, cbmdos.h 81-90, commit 22cf0cc8eee4dae54f55ff7a738cf0cb7eaa258f.

Code & repositories

  • https://github.com/mamedev/mame @ 1d7a454ed79e97d35d2a9f127ac029ead94711d6 · license: BSD-3-Clause (declared by the contributor; GitHub's detector did not recognize COPYING)
    MAME src/lib/formats/*_dsk.cpp and tzx_cas.cpp: floppy and tape image loaders
    Tested on: source read, not run: source reading only · checked 2026-10-18; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • https://github.com/VICE-Team/svn-mirror @ 22cf0cc8eee4dae54f55ff7a738cf0cb7eaa258f · license: GPL-2.0-or-later (declared by the contributor; GitHub's detector did not recognize a license file)
    VICE emulator source: src/diskconstants.h, src/cbmdos.h and src/vdrive/vdrive-bam.*, vdrive-dir.* (BAM and directory layout)
    Tested on: source read, not run: source reading only · checked 2026-10-18; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries