Disk Image Formats

The CoCo SDC supports two different disk image formats. The primary format is referred to as the DSK format and can be used for the imaging of both floppy disks and hard disks. The secondary format, known as SDF, was created specifically for the CoCo SDC and is used for imaging floppy disks only.

No special name or extension need be assigned to an image file for the purpose of format determination. When a disk image is mounted the firmware detects which format the image uses by examining the file to see if it contains an SDF format signature. Nevertheless it is recommended that an extension which is indicative of the image format be used for identification by humans.


DSK Images

The DSK image format is named for the extension most commonly appearing on such files. Images in this format consist of a simple sector array with each sector being 256 bytes in length. This is the most common format used in the CoCo world. It is sometimes also referred to as the JVC format although that format allows for an optional header to precede the sector array. The CoCo SDC will recognize a JVC header only for the purpose of identifying the number of sides.

In order to be recognized as a simple DSK image, the file size must be an exact multiple of 256 bytes. The minimum file size is 82,944 bytes which is equal to 324 sectors or 18 tracks of a single-sided CoCo disk (enough to accommodate the Disk Basic directory track). If the file size is not a multiple of 256 then it is assumed the image contains either a JVC or VDK (Dragon) header. A sanity check of the header bytes is performed to determine if the file can be used.

The disk geometry associated with a DSK image is determined by the file size. For floppy images the number of sectors per track is always 18. There are either one or two tracks per cylinder (equal to the number of sides) and a maximum of 80 cylinders. The largest file size for a floppy image is 737,280 bytes or 2880 sectors (double-sided 80 cylinders).

An image with more than 2880 sectors is considered to be a hard disk. If a hard disk image is accessed using the floppy interface mode, only the first 1440 sectors can be used. In this situation those sectors are accessible as a single-sided 80 track floppy disk. The controller's LBA interface mode must be used to access sectors beyond the first 1440 in a hard disk image.

Disk Geometry Table for DSK Images (without header)
File Size in Bytes  Sectors    Disk Type   Cylinders    Sides  
 Less than 82,944  <  324     Invalid    
 184,320 or less  ≤ 720         FD         40     1
 368,640 or less  ≤ 1440         FD         40     2
 737,280 or less  ≤ 2880         FD         80     2
 737,536 or more   > 2880         HD         80*     1*
* only when accessed through the floppy interface mode



SDF Images

The SDF image format is used to represent floppy disks that have a non-standard layout which is anything other than 18 sectors per track and 256 bytes per sector using standard numbering of the tracks and sectors. The SDF format is similar to the DMK format supported by most CoCo emulators. It has been augmented to provide better performance within the limited resources of the Atmega328 micro controller.

The dmk2sdf program has been created for converting a DMK image to the SDF format. A Win32 command line executable along with the ANSI C source code can be downloaded using the link at the bottom of the page.


SDF File Format

An SDF file consists of a header followed by a variably-sized array of track records. The track records are arranged in ascending order corresponding to their physical position on the disk (cylinder and side).



Contents of the 512 byte File Header
Byte
Offset
 Length
in Bytes
  Description 
    0    4Format signature and version string. The ASCII characters 'SDF1' appear at the beginning of the file to identify it as a version 1 SDF image. The numeric character may be incremented in future versions. 
    4    1Number of cylinders (80 max).
    5    1Number of sides (1 or 2).
    6    1Write permission:  0x00 = Read/Write  ;  0xFF = Read-Only.
    7    1Nested sectors flag:  0x00 = NO  ;  0x01 = YES.
This byte is set to 0x01 if the disk is known to use a copy-protection scheme in which the ID field for one sector is contained within the Data field of another.
    8    504Reserved.  All remaining bytes in the header should be set to zero.


Following the File Header is the array of Track Records. Each track record begins with a 256 byte header and is then followed by 6250 bytes of raw track data. There are 150 bytes of unused padding at the end of a track record which are included to align every track on a 512 byte boundary within the file.



The fixed track size of 6250 bytes can accommodate either a single-density (125 kbps) or double-density (250 kbps) track at 300 rpm. The SDF format does NOT support 8 inch floppy disks or high density (500 kbps) images.

Any part of a track which is recorded in single-density has each byte written twice in succession. This preserves the correct spacing of data on mixed-density tracks.

Contents of the 256 byte Track Header
Byte
Offset
 Length
in Bytes
  Description 
     0     1Number of used entries in the Sector ID Table.
     1     7Reserved. All seven of the remaining Info Record bytes should be set to zero.
     8     248Sector ID Table.


Each entry in the Sector ID Table is 8 bytes in length and contains information about one sector recorded on the track. The total size of the table is 248 bytes and can accommodate a maximum of 31 sector entries for a single track. All used entries must appear sequentially from the beginning of the table. The unused entries must be filled with zeroes and placed at the end of the table.

Contents of each 8 byte Sector ID Table entry
Byte
Offset
 Length
in Bytes
  Description 
     0     2The 14 low-order bits of this 16 bit field contain the offset from the beginning of the Track Record to the first byte of the sector's ID field within the raw track data.

The two high-order bits (14 and 15) are used as flags. Bit 14 is set for a sector recorded in single-density. Bit 15 is set if the ID field has an incorrect CRC.

This 16 bit integer field is stored in little-endian order (LSB first). 
     2     2The 14 low-order bits of this 16 bit field contain the offset from the beginning of the Track Record to the first byte of the sector's Data field within the raw track data.

The two high-order bits (14 and 15) are used as flags. Bit 14 is set if the sector's Data field uses a Deleted Data Mark. Bit 15 is set if the Data field has an incorrect CRC.

This 16 bit integer field is stored in little-endian order (LSB first).
     4     1The Track Number byte copied from the sector's ID field.
     5     1The Side Number byte copied from the sector's ID field.
     6     1The Sector Number byte copied from the sector's ID field.
     7     1The Size Code byte copied from the sector's ID field.



Downloads:
dmk2sdf    - Command line tool to convert DMK images to SDF format. Includes source code.