1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-30 22:29:56 +00:00

Started page.

Thomas Harte 2018-05-10 10:04:46 -04:00
parent cb3b4663af
commit 7d2f5504e6

@ -0,0 +1,38 @@
# Physical Encoding
Apple's GCR encoding was designed in reaction to FM encoding, and uses the same data density and bit clock. However in its more efficient '6 and 2' form, it uses only two-thirds as much disk surface area as FM to encode the same data. It predates and is not as efficient as MFM encoding.
Two forms of Apple GCR were used during the Apple II's lifetime: '5 and 3' and '6 and 2'. Each name refers to the number of bits of information you get from each 8 flux transition windows on a disk. '5 and 3' is therefore less efficient than '6 and 2' because only five bits of information are decoded from each eight flux windows, rather than six.
GCR disks have a third encoding of data, '4 and 4' which is very similar to FM. It is used only for sector metadata, not for sector contents themselves.
## Track Layout
Apple's track layout derives from that of FM data: for each sector there is a header, then a gap, then the data, then another gap.
The gaps contain synchronisation information, allowing the controller to align its read window with the on-disk data.
A header consists of the sector's track and sector number, the disk's volume identifier, and a check value. Each of those is one byte long. The check value is a simple exclusive OR of the other values.
The data consists of 256 bytes of information plus a check byte. As with the header, the check byte is a simple exclusive OR of the other values.
## Flux window content rules
The Disk II utilises an 8-bit lsb-to-msb shift register. It shifts at the on-disk data rate. It will shift in 1s wherever a flux transition is found on the disk and 0s where the flux transition is absent.
If the MSB of the register is 0, it will shift immediately upon detecting the flux transition. If the msb is 1, it will pause slightly before shifting in the next bit.
This is to allow adherence to a rule that for the purpose of synchronisation, encoded bytes will always have the msb set. The archetypal polling loop to obtain the next byte from the Disk II is:
.loop LDA shift_register
BPL .loop
A further constraint is imposed by the analogue-to-digital conversion that looks for flux transitions; its automatic gain control is prone to amplifying noise into signal if more than two consecutive flux windows pass without a transition in them.
Applying those two constraints — the msb set and no more than two consecutive zeros — motivates '6 and 2' encoding as the number of bytes with that property is between 64 and 128, making 6 the easiest number of bits to encode in a byte for base two.
Steve Wozniak who designed the '6 and 2' encoding had previously been under the impression that the rule was that there could be no more than a single consecutive zero bit; the less-efficient '5 and 3' encoding is the result of conforming to that stricter constraint.
## Sync words
As above, sync words lie in the gaps between sectors and between the header and data parts of sectors.
A sync word is simply an `ff` encoded byte followed by as many zeroes as the content rules will allow: a single zero for '5 and 3', or two zeroes for '6 and 2'.
Given the top-bit-set rule, a series of sync words has the effect of bringing a CPU polling loop as above into phase with the start of each sync word.