Disk images

From Ninerpedia
Revision as of 16:17, 5 April 2011 by Mizapf (talk | contribs)
Jump to navigation Jump to search

In order to use floppy disks in an emulator we have to deliver their contents to the emulator in an appropriate format. Floppy disks are actually two-dimensional things, but files in a computer are a sequence of bytes, so we have to arrange the floppy content somehow.

Floppy disks have a structured storage area, as shown here. We cannot see these structures as they are just result of magnetizing tiny areas on the surface. Disks where these structures can be defined as required are also called soft-sectored.

Structure of data on a floppy disk

The image shows two tracks, the outermost track, and the next one in the direction of the center. Inside each track, a certain number of data areas are defined called sectors. There is no standard concerning the number of sectors, their arrangement, and the sequence of tracks.

Between the sectors the tracks contain meta-information, in particular the sector number, track number, side number (0 or 1), CRC code (for error checking), and bit sequences to allow the controller to locate the beginning and end of the whole track and of the sectors. The meta-information is usually only of interest for the floppy controller chip, and many chips consume these bytes and do not forward them to the computer system. The WD1771 controller in the original TI disk controller, however, does forward all these information, so they can be used for diagnostic purposes or for sophisticated copy protection schemes (e.g. using an uncommon arrangement of sectors in the track).

Hence, we have two options of saving the disk contents to a file:

  • Save the complete track including meta-information in the file.
  • Save the contents of the sectors as we won't make much use of the meta-information anyway.

In the first case we would store the complete track, then append the next track, and so on, until all tracks are stored in the file. (We have to agree on how to handle the two sides, though.) In the second case we would read all sectors sequentially from the disk and store their contents in the file. As every sector has equal size there is no problem in locating the contents of a given sector within the file.

Track.png

Note that sectors are always numbered from 0 to the maximum count within the track.