pub enum Format {
FourAndFour,
FiveAndThree,
SixAndTwo,
}Expand description
The different nibble encoding formats used for Apple disk images. These are required because of hardware requirements with Apple disk drives. Not all 256 possible byte values could be written to disk.
The first requirement for hardware required that the high bit always be set. Second, at least two adjacent bits need to be set. Third, at most one pair of consecutive zero bits.
This leaves 34 valid disk bytes, in the range from AA to FF. Two of these bytes are reserved: 0xAA and 0xD5
This led to the “4 and 4” encoding format. This splits the byte into two bytes, one containing the odd bytes and one containing the even bytes. Other encoding formats satisify these properties while allowing more efficient data usage.
Variants§
FourAndFour
Four and four splits each data byte into two disk bytes, containing the odd and even bits.
b_7 b_6 b_5 b_4 b_3 b_2 b_1 b_0 -> 1 . . . b_7 b_5 b_3 b_1, 1 . . . b_6 b_4 b_2 b_0 Used in earlier versions of DOS before DOS 3
FiveAndThree
5 and 3 uses 5 bits of the data in the disk byte Used in DOS versions from DOS 3 to DOS 3.2.1
SixAndTwo
6 and 2 uses 6 bits of the data in the disk byte This was enabled by changes in the disk ROM that allowed two consecutive zero bits. Used in DOS 3.3