mirror of
https://github.com/TomHarte/CLK.git
synced 2024-09-29 16:55:59 +00:00
Adds information on '4 and 4' encoding.
parent
7d2f5504e6
commit
f0c05ef915
@ -35,4 +35,31 @@ As above, sync words lie in the gaps between sectors and between the header and
|
|||||||
|
|
||||||
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'.
|
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.
|
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.
|
||||||
|
|
||||||
|
# '4 and 4' Encoding
|
||||||
|
Sector header content is encoded in '4 and 4' form regardless of the encoding in use for sector contents.
|
||||||
|
|
||||||
|
'4 and 4' encoding encodes the source byte b, with bits b7, b6, b5 ... b0 as the two on-disk bytes:
|
||||||
|
|
||||||
|
1 b7 1 b5 1 b3 1 b1
|
||||||
|
1 b6 1 b4 1 b2 1 b0
|
||||||
|
|
||||||
|
Which is equivalent to FM encoding other than in bit order. The bits are ordered different to allow for efficient decoding:
|
||||||
|
|
||||||
|
(((1 b7 1 b5 1 b3 1 b1) << 1) | 1) & (1 b6 1 b4 1 b2 1 b0) = original byte
|
||||||
|
|
||||||
|
A complete sector header is formed on disk as:
|
||||||
|
|
||||||
|
three bytes prologue: 0xd5, 0xaa, 0x96
|
||||||
|
two bytes: '4 and 4' encoded volume
|
||||||
|
two bytes: '4 and 4' encoded track
|
||||||
|
two bytes: '4 and 4' encoded sector
|
||||||
|
two bytes: '4 and 4' encoded check value — the exclusive OR of (volume, track, sector)
|
||||||
|
three bytes epilogue: 0xde, 0xaa, 0xeb
|
||||||
|
|
||||||
|
`track` counts upwards from zero for the outermost track. `sector` counts upward from zero for the first sector on a track.
|
||||||
|
|
||||||
|
`volume` has at least two context-dependent meanings. In both of Apple's operating systems it defaults to `254` for Disk II-compatible media and in Pro DOS is used to confirm the volume *type*. Some software prefers to use it as volume *number*, for distinguishing different disks or sides of a disk. It should be written as `254` unless there is a reason to do otherwise.
|
||||||
|
|
||||||
|
In principle the entire disk contents could have been encoded in '4 and 4' form, to give exactly the same data density as FM encoding. In practice the more-efficient '5 and 3' encoding was the first to be deployed.
|
Loading…
Reference in New Issue
Block a user