Contents

Technical Documentation - Basics of data storage on floppy disks

Some definitions

Floppy disk

Magnets create a magnetic field and have a north pole and a south pole. Identical poles repel themselves while different poles attract themselves.
A floppy disk is a data storage media in the shape of a disk whose surface is coated with a magnetic material on both sides. After being manufactured, there is no significant magnetic field produced by this coating. However, when a strong enough external magnetic field is applied onto the material, it will get magnetized and remain in that state (until another external magnetic field is applied). There are two opposite ways to magnetize the material on the disk surface, corresponding to opposite orientations of the magnetic field. Different areas of the disk surface can be magnetized with opposite polarities and that is the basis of magnetic storage of information.
Floppy disks exist in different sizes. Here is an example of a 3.5 inch floppy disk and its internal structure:
Game - Chaos Strikes Back - UK - Atari ST - Game Disk - Front - Scan Game - Chaos Strikes Back - UK - Atari ST - Game Disk - Back - Scan Floppy Disk

Floppy disk drive

The electromechanical device used to read and write data on floppy disks. Its main components include a spindle motor to rotate the disk, a head to read/write data to disks and a second step-by-step motor to move the head across a radius of the disk.
Floppy Disk Drive

Floppy disk controller (FDC)

An electronic chip connected to the floppy disk drive and designed to manage it. In a computer, programs can only interact with the FDC and never directly with the floppy disk drive. Some FDC chips are 'dumb' and most of the required processing to read/write data occurs in software executed by the CPU. This design had cheaper hardware requirements. Software processing also allowed many customizations and was extensively used by developers of copy protection schemes. Other FDC chips are 'smart' and perform most of the required processing in hardware. In this case less customizations are possible as most parameters are enforced by the FDC that can only manage a limited set of formats and variations.

Organizing data on the disk

The physical surface of a floppy disk is homogeneous. However, this surface is logically divided into smaller parts to make it easier to read and write small amounts of data at a time. First, the surface is divided into tracks. A track is a circular area on the floppy disk. On figure 1, the orange area represents a track. Tracks are numbered starting at 0 and the first track is on the outer edge of the surface. The innermost track depicted in green represents the last track.
Each track is divided into smaller parts called sectors. On most systems, the number of sectors is the same in all tracks, and the drive rotates the floppy disk at a constant angular speed (usually 300 rpm, or 360 rpm in Japanese systems) so that the drive's head will spend the same amount of time above all sectors, no matter which track they are part of. For example, on figure 1, the red area represents a sector on track 0, the first track. The yellow area represents another sector. While the actual length of these two sectors are very different (the outermost being much longer), they both contain the same amount of data. Note that on this figure, the sectors of all tracks are aligned but this is usually not the case on most floppy disks.
Figure 1
Floppy Disk Structure
On Apple systems (old Macintosh and Apple IIGS), the number of sectors is not the same in all tracks, and the drive rotates at constant linear speed (and thus variable angular speed) to ensure the drive's head will spend the same amount of time above each sector.

A sector is the smallest area that can be read or written: if you want to read a single byte of data from the floppy disk, you need to read the whole sector and then extract the byte you want from this sector data. Similarly, if you want to write a single byte of data to the floppy disk, you must first read the content of the sector where the byte will be written, modify the byte you want in memory and then write back the whole sector.

When the drive starts to write data to the floppy disk, there is some imprecision to where exactly it will start. In order to avoid any overlap while writing a particular sector, there are areas called 'gaps' between each sector and also between the beginning and end of a track. These gaps provide some tolerance for the start and end locations of sectors. Gaps do not contain any useful user data.

Storing binary data using magnetic states

Floppy disks are designed to record digital data, which are series of bits of information ('0' and '1' values). For that purpose, only two different magnetic states are required (contrary to analog recording like on audio tapes).
The floppy disk surface is virtually divided into small areas. When a whole area is magnetized in the same way, this creates a significant magnetic field, also called a 'magnetic flux'. Information is stored on the disk by creating series of areas where magnetization is oriented in the same way, thus creating two types of magnetized areas: 'north poles areas' or 'south poles areas'. Binary data is stored using these two states, but they do not directly map to bit values (zeros and ones). In fact, each bit is stored using two adjacent magnetized areas, forming what is called a 'bit cell':

  • Two areas with different magnetizations (a north pole and a south pole, in any order) represent a '1' bit. Such a bit cell is said to contain a 'flux reversal' or 'flux transition'.
  • Two areas with identical magnetization (two north poles or two south poles) represent a '0' bit. Such a bit cell does not contain a 'flux reversal'.

This scheme is necessary because when reading information from the floppy disk, the drive is not able to detect the magnetization of an area as a north pole or a south pole. It can only detect flux reversals.
As a result, data on a track is stored as areas of opposite magnetization, which is illustrated on figure 1 by the small zoomed portion of a sector.

Changing the orientation of the magnetization (in order to write information to the disk) or detecting flux reversals (in order to read information from the disk) relies on the physical phenomenon named 'electromagnetic induction' that has two aspects:

  • A changing magnetic field will create an electric current in a nearby electric circuit. Note that a constant magnetic field will not create any current. This is why only flux reversals can be detected and not the absolute magnetization of the surface.
  • The flow of electricity in an electric circuit produces a magnetic field.

These two aspects are used in the head of a floppy disk drive. The head contains a small coil and is the part of the disk drive that is the closest to the disk surface (without touching it) and allows reading and writing.

Reading and writing data

In order to write data to the disk, the computer sends binary data that is converted to a current in the head coil. This current is reversed when a '1' bit is sent and remains the same when a '0' bit is sent. The current in the coil produces a magnetic field whose direction depends on the way the current is flowing in the head. The magnetization on the disk surface will then change its orientation to align with the magnetic field produced by the head coil. By using the appropriate electrical signal, it is thus possible to create areas on the disk oriented in one way or the other.

In order to read data from the disk, the head is not powered. While moving above the disk surface, the flux reversals on the media will induce electric pulses in the head coil. The presence of an electric pulse is translated to a '1' bit and the absence of pulse is translated to a '0' bit.

Detecting a '1' bit is fairly easy as a pulse is generated, but detecting a '0' bit requires some timing: the floppy disk controller has to wait for some time before concluding that no flux reversal occurred when one could have occurred. This is why the FDC requires an accurate synchronization of its clock with the flow of electrical pulses coming from the head of the floppy drive.
If there was a large number of consecutive '0' bits written on the disk, it would be difficult for the FDC to accurately count these bits. This means arbitrary user data cannot be written directly to the disk and an encoding scheme is required to ensure no long series of '0' bits is ever written on the disk.

Encoding / decoding data

All computers that Dungeon Master and Chaos Strikes Back were released for use the 'Modified Frequency Modulation' (MFM) encoding (Atari ST, Amiga, PC, PC-9801, X68000 and FM-Towns) except the Apple IIGS that uses an encoding known as 'Group Coded Recording 6 and 2' (GCR).

On Atari ST, the floppy disk controller takes care of the MFM encoding/decoding, and only manipulates decoded sector data in memory. The raw MFM data as stored on disk is not accessible to programs.
On Amiga, the floppy disk controller does not perform the encoding/decoding. It manipulates raw MFM data in memory and the actual decoding is performed in software. Most of the time, the operating system takes care of the decoding assuming the standard Amiga format is used, but a program can bypass this step and provide its own routines to process the raw MFM data. In fact, it is even possible to implement programs to read/write other encodings.
On Apple IIGS, the process is similar to Amiga. A program can provide its own routines to process raw GCR data in memory.

You can get more details about MFM encoding on Technical Documentation - Detailed analysis of Atari ST Floppy Disks of Dungeon Master and Chaos Strikes Back and about GCR encoding on Technical Documentation - Copy Protection of Dungeon Master for Apple IIGS.


Powered by Drupal   Valid XHTML 1.0 Strict