Next: , Previous: , Up: The emulator file formats   [Contents][Index]


17.10 The D82 disk image format

(This section was contributed by Peter Schepers and slightly edited by Marco van den Heuvel.)

This is a sector-for-sector copy of an 8250 floppy disk. The file size for an 8250 image is 1066496 bytes. It is comprised of 256-byte sectors arranged across 154 tracks, with a varying number of sectors per track for a total of 4166 sectors. Track counting starts at 1 (not 0) and sector counting starts at 0 (not 1), therefore a track with 29 sectors will go from 0 to 28.

The original media (a 5.25" disk) has the tracks laid out in circles, with track 1 on the very outside of the disk (closest to the sides) to track 77 being on the inside of the disk (closest to the inner hub ring). Commodore, in their infinite wisdom, varied the number of sectors per track and data densities across the disk to optimize available storage, resulting in the chart below. It shows the sectors/track for a D82. Since the outside diameter of a circle is the largest (versus closer to the center), the outside tracks have the largest amount of storage.

Track RangeSectors/track# Sectors
1-39291131
40-5327378
55-6425275
65-7723299
78-116291131
117-13027378
131-14125275
142-15423299
Track#Sect#SectorsInD82 Offset
1290$000000
22929$001D00
32958$003A00
42987$005700
529116$007400
629145$009100
729174$00AE00
829203$00CB00
929232$00E800
1029261$010500
1129290$012200
1229319$013F00
1329348$015C00
1429377$017900
1529406$019600
1629435$01B300
1729464$01D000
1829493$01ED00
1929522$020A00
2029551$022700
2129580$024400
2229609$026100
2329638$027E00
2429667$029B00
2529696$02B800
2629725$02D500
2729754$02F200
2829783$030F00
2929812$032C00
3029841$034900
3129870$036600
3229899$038300
3329928$03A000
3429957$03BD00
3529986$03DA00
36291015$03F700
37291044$041400
38291073$043100
39291102$044E00
40271131$046B00
41271158$048600
42271185$04A100
43271212$04BC00
44271239$04D700
45271266$04F200
46271293$050D00
47271320$052800
48271347$054300
49271374$055E00
50271401$057900
51271428$059400
52271455$05AF00
53271482$05CA00
54251509$05E500
55251534$05FE00
56251559$061700
57251584$063000
58251609$064900
59251634$066200
60251659$067B00
61251684$069400
62251709$06AD00
63251734$06C600
64251759$06DF00
65231784$06F800
66231807$070F00
67231830$072600
68231853$073D00
69231876$075400
70231899$076B00
71231922$078200
72231945$079900
73231968$07B000
74231991$07C700
75232014$07DE00
76232037$07F500
77232060$080C00
78292083$082300
79292112$084000
80292141$085D00
81292170$087A00
82292199$089700
83292228$08B400
84292257$08D100
85292286$08EE00
86292315$090600
87292344$092800
88292373$094500
89292402$096200
90292431$097F00
91292460$099C00
92292489$09B900
93292518$09D600
94292547$09F300
95292576$0A1000
96292605$0A2D00
97292634$0A4A00
98292663$0A6700
99292692$0A8400
100292721$0AA100
101292750$0ABE00
102292779$0ADB00
103292808$0AF800
104292837$0B1500
105292866$0B3200
106292895$0B4F00
107292924$0B6C00
108292953$0B8900
109292982$0BA600
110293011$0BC300
111293040$0BE000
112293069$0BFD00
113293098$0C1A00
114293137$0C3700
115293156$0C5400
116293185$0C7100
117273214$0C8E00
118273241$0CA900
119273268$0CC400
120273295$0CDF00
121273322$0CFA00
122273349$0D1500
123273376$0D3000
124273403$0D4B00
125273430$0D6600
126273457$0D8100
127273484$0D9C00
128273511$0DB700
129273538$0DD200
130273565$0DED00
131253592$0E0800
132253617$0E2100
133253642$0E3A00
134253667$0E5300
135253692$0E6C00
136253717$0E8500
137253742$0E9E00
138253767$0EB700
139253792$0ED000
140253817$0EE900
141253842$0F0200
142233867$0F1B00
143233890$0F3200
144233913$0F4900
145233936$0F6000
146233959$0F7700
147233982$0F8E00
148234005$0FA500
149234028$0FBC00
150234051$0FD300
151234074$0FEA00
152234097$100100
153234120$101800
154234143$102F00

The BAM (Block Availability Map) is on track 38. The D82 is 154 tracks and so the BAM is contained on 38/0, 38/3, 38/6 and 38/9. The BAM interleave is 3.

The directory is on track 39, with 39/0 contains the header (DOS type, disk name, disk ID’s) and sectors 1-28 contain the directory entries. Both files and the directory use an interleave of 1. Since the directory is only 28 sectors large (29 less one for the header), and each sector can contain only 8 entries (32 bytes per entry), the maximum number of directory entries is 28 * 8 = 224. The first directory sector is always 39/1. It then follows a chain structure using a sector interleave of 1 making the links go 39/1, 39/2, 39/3 etc.

When reading a disk, you start with 39/0 (disk label/ID) which points to 38/0 (BAM0), 38/3 (BAM1), 38/6 (BAM2), 38/9 (BAM3, and finally to 39/1 (first dir entry sector). When writing a file to a blank disk, it will start at 38/1 because 38/0 is already allocated.

Below is a dump of the header sector 39/0:

    00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
    -----------------------------------------------
00: 26 00 43 00 00 00 73 61 6D 70 6C 65 20 64 38 30
10: A0 A0 A0 A0 A0 A0 A0 A0 65 72 A0 32 43 A0 A0 A0
20: A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
…
F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
BytesDescription
$00-$01T/S pointer to first BAM sector (38/0)
$02$43 ’C’ is for DOS format version
$03Reserved
$04-$05Unused
$06-$16Disk name, padded with 0xA0 ("sample d82")
$170xA0
$18-$19Disk ID bytes "er"
$1A0xA0
$1B-$1CDOS version bytes "2C"
$1D-$200xA0
$21-$FFUnused

Below is a dump of the first directory sector, 39/1

    00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
    -----------------------------------------------
00: 27 02 82 26 01 54 45 53 54 A0 A0 A0 A0 A0 A0 A0
10: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 01 00
20: 00 00 82 26 02 54 45 53 54 32 A0 A0 A0 A0 A0 A0
30: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 01 00
40: 00 00 82 26 04 54 45 53 54 33 A0 A0 A0 A0 A0 A0
50: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 05 00
60: 00 00 82 26 0B 54 45 53 54 34 A0 A0 A0 A0 A0 A0
70: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 09 00
80: 00 00 82 26 14 54 45 53 54 35 A0 A0 A0 A0 A0 A0
90: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 0C 00
A0: 00 00 82 28 00 54 45 53 54 36 A0 A0 A0 A0 A0 A0
B0: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 01 00
C0: 00 00 82 28 01 54 45 53 54 37 A0 A0 A0 A0 A0 A0
D0: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 01 00
E0: 00 00 82 28 02 54 45 53 54 38 A0 A0 A0 A0 A0 A0
F0: A0 A0 A0 A0 A0 00 00 00 00 00 00 00 00 00 01 00

The first two bytes of the directory sector ($27/$02) indicate the location of the next track/sector of the directory (39/2). If the track is set to $00, then it is the last sector of the directory.

When the directory is done, the track value will be $00. The sector link should contain a value of $FF, meaning the whole sector is allocated, but the actual value doesn’t matter. The drive will return all the available entries anyways. This is a breakdown of a standard directory sector:

BytesDescription
$00-$1FFirst directory entry
$20-$3FSecond dir entry
$40-$5FThird dir entry
$60-$7FFourth dir entry
$80-$9FFifth dir entry
$A0-$BFSixth dir entry
$C0-$DFSeventh dir entry
$E0-$FFEighth dir entry

This is a breakdown of a standard directory entry:

BytesDescription
$00-$01Track/Sector location of next directory sector ($00 $00 if not the first entry in the sector)
$02File type
$03-$04Track/sector location of first sector of file
$05-$1416 character filename (in PETASCII, padded with $A0)
$15-$16Track/Sector location of first side-sector block (REL file only)
$17REL file record length (REL file only, max. value 254)
$18-$1DUnused
$1E-$1FFile size in sectors, low/high byte order ($1E+$1F*256). The approx. filesize in bytes is <= #sectors * 254

The file type field is used as follows:

BitsDescription
0-3The actual file type
4Unused
5Used only during SAVE-@ replacement
6Locked flag (Set produces ">" locked files)
7Closed flag (Not set produces "*", or "splat" files)

The actual file type can be one of the following:

BinaryDecimalFile type
00000DEL
00011SEQ
00102PRG
00113USR
01004REL

Values 5-15 are illegal, but if used will produce very strange results.

17.10.1 Non-Standard & Long Directories

Most Commdore floppy disk drives use a single dedicated directory track where all filenames are stored. This limits the number of files stored on a disk based on the number of sectors on the directory track. There are some disk images that contain more files than would normally be allowed. This requires extending the directory off the default directory track by changing the last directory sector pointer to a new track, allocating the new sectors in the BAM, and manually placing (or moving existing) file entries there. The directory of an extended disk can be read and the files that reside there can be loaded without problems on a real drive. However, this is still a very dangerous practice as writing to the extended portion of the directory will cause directory corruption in the non-extended part. Many of the floppy drives core ROM routines ignore the track value that the directory is on and assume the default directory track for operations.

17.10.2 BAM layout

The BAM only occupies up to four sectors on track 38, so the rest of the track is empty and is available for file storage. Below is a dump of the first BAM block, 38/0. A D82 will contain four BAM sectors, 38/0, 38/3, 38/6 and 38/9. Each entry takes 5 bytes, 1 for the free count on that track, and 4 for the BAM bits.

    00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
    -----------------------------------------------
00: 26 03 43 00 01 33 1D FF FF FF 1F 1D FF FF FF 1F
10: 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D
20: FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF
30: FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF
40: FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF
50: 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F
60: 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D
70: FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF
80: FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF
90: FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF
A0: 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F
B0: 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1B
C0: F6 FF FF 1F 1B FC FF FF 1F 1B FF FF FF 07 1B FF
D0: FF FF 07 1B FF FF FF 07 1B FF FF FF 07 1B FF FF
E0: FF 07 1B FF FF FF 07 1B FF FF FF 07 1B FF FF FF
F0: 07 1B FF FF FF 07 1B FF FF FF 07 1B FF FF FF 07
BytesDescription
$00-$01T/S pointer to second BAM sector (38/3)
$02DOS version byte (0x43=’C’)
$03Reserved
$04Lowest track covered by this BAM (0x01=1)
$05Highest+1 track covered by this BAM (0x33=51)
$06-$0ABAM for track 1. The first byte shows the "blocks free" for this track, the remaining 4 show the BAM for the track.
$0B-$0FBAM for track 2
$FB-$FFBAM for track 50

Being bit-based, the BAM entries need some explanation. The first track entry in the above BAM sector is at offset 06, "1D FF FF FF 1F". The first number is how many blocks are free on this track ($1D=29) and the remainder is the bit representation of the usage map for the track. These entries must be viewed in binary to make any sense. First convert the values to binary:

 FF=11111111, FF=11111111, FF=11111111, 1F=00011111

In order to make any sense from the binary notation, flip the bits around.

            111111 11112222 222222
 01234567 89012345 67890123 456789…
 -------------------------- ---------
 11111111 11111111 11111111 11111000
 ^                              ^
 sector 0                  sector 28

Since we are on the first track, we have 29 sectors, and only use up to the bit 28 position. If a bit is on (1), the sector is free. Therefore, track 1 is clean, all sectors are free. Any leftover bits that refer to sectors that don’t exist, like bits 29-31 in the above example, are set to allocated.

Second BAM block 38/3

    00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
    -----------------------------------------------
00: 26 06 43 00 33 65 1B FF FF FF 07 1B FF FF FF 07
10: 1B FF FF FF 07 19 FF FF FF 01 19 FF FF FF 01 19
20: FF FF FF 01 19 FF FF FF 01 19 FF FF FF 01 19 FF
30: FF FF 01 19 FF FF FF 01 19 FF FF FF 01 19 FF FF
40: FF 01 19 FF FF FF 01 19 FF FF FF 01 17 FF FF 7F
50: 00 17 FF FF 7F 00 17 FF FF 7F 00 17 FF FF 7F 00
60: 17 FF FF 7F 00 17 FF FF 7F 00 17 FF FF 7F 00 17
70: FF FF 7F 00 17 FF FF 7F 00 17 FF FF 7F 00 17 FF
80: FF 7F 00 17 FF FF 7F 00 17 FF FF 7F 00 1D FF FF
90: FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF
A0: 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F
B0: 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D
C0: FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF
D0: FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF
E0: FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF
F0: 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F
BytesDescription
$00-$01T/S pointer to third BAM sector (38/6)
$02DOS version byte (0x43=’C’)
$03Reserved
$04Lowest track covered by this BAM (0x33=51)
$05Highest+1 track covered by this BAM (0x65=101)
$06-$0ABAM for track 51. The first byte shows the "blocks free" for this track, the remaining 4 show the BAM for the track.
$0B-$0FBAM for track 52
$FB-$FFBAM for track 100

Third BAM block 38/6

    00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
    -----------------------------------------------
00: 26 09 43 00 65 97 1D FF FF FF 1F 1D FF FF FF 1F
10: 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D
20: FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF
30: FF FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF
40: FF 1F 1D FF FF FF 1F 1D FF FF FF 1F 1D FF FF FF
50: 1F 1D FF FF FF 1F 1B FF FF FF 07 1B FF FF FF 07
60: 1B FF FF FF 07 1B FF FF FF 07 1B FF FF FF 07 1B
70: FF FF FF 07 1B FF FF FF 07 1B FF FF FF 07 1B FF
80: FF FF 07 1B FF FF FF 07 1B FF FF FF 07 1B FF FF
90: FF 07 1B FF FF FF 07 1B FF FF FF 07 19 FF FF FF
A0: 01 19 FF FF FF 01 19 FF FF FF 01 19 FF FF FF 01
B0: 19 FF FF FF 01 19 FF FF FF 01 19 FF FF FF 01 19
C0: FF FF FF 01 19 FF FF FF 01 19 FF FF FF 01 19 FF
D0: FF FF 01 17 FF FF 7F 00 17 FF FF 7F 00 17 FF FF
E0: 7F 00 17 FF FF 7F 00 17 FF FF 7F 00 17 FF FF 7F
F0: 00 17 FF FF 7F 00 17 FF FF 7F 00 17 FF FF 7F 00
BytesDescription
$00-$01T/S pointer to fourth BAM sector (38/9)
$02DOS version byte (0x43=’C’)
$03Reserved
$04Lowest track covered by this BAM (0x65=101)
$05Highest+1 track covered by this BAM (0x97=151)
$06-$0ABAM for track 101. The first byte shows the "blocks free" for this track, the remaining 4 show the BAM for the track.
$0B-$0FBAM for track 102
$FB-$FFBAM for track 150

Fourth BAM block 38/9

    00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
    -----------------------------------------------
00: 27 01 43 00 97 9B 17 FF FF 7F 00 17 FF FF 7F 00
10: 17 FF FF 7F 00 17 FF FF 7F 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
BytesDescription
$00-$01T/S pointer to first directory sector (39/1)
$02DOS version byte (0x43=’C’)
$03Reserved
$04Lowest track covered by this BAM (0x97=151)
$05Highest+1 track covered by this BAM (0x9B=155)
$06-$0ABAM for track 151. The first byte shows the "blocks free" for this track, the remaining 4 show the BAM for the track.
$0B-$0FBAM for track 152
$15-$19BAM for track 154
$1A-$FFNot used

Next: The D90 disk image format, Previous: The D80 disk image format, Up: The emulator file formats   [Contents][Index]