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

Hoped to provide some words of guidance on the mess that is DSK.

Thomas Harte 2018-05-11 13:03:12 -04:00
parent 26014fb17c
commit 5a35175211

@ -122,4 +122,13 @@ So the complete sector data is formed on disk as:
256 bytes containing the high six bits of source bytes
], all encoded via the 6-to-8 table
the XOR check value, which is the same as the high six bits of the final source byte, 6-to-8 encoded
epilogue de, aa, eb
epilogue de, aa, eb
# Sector interleaving and file formats
Apple's '5 and 3' operating systems physically interleave sectors on the disk surface. The `6 and 2` operating systems do not; a raw reading of the disk surface would show sector 0, followed by sector 1, followed by sector 2, etc. Instead they apply an internal remapping of DOS logical sectors to on-disk physical sectors.
The most common type of Apple disk image — variously DSK, DO, PO and other extensions — is a sector-contents-only dump, containing the original sectors in logical order. So to map them back to real media a program must produce sectors in ordinary ascending order but pick sector contents from non-sequential parts of the file: e.g. for a DOS 3.3 image the first on-disk sector, labelled as sector 0, should contain the first sector from the file but the second on-disk sector, labelled as sector 1, should contain the 8th sector from the file.
Therefore the proper physical interpretation of that sort of disk image is tightly coupled to the internals of the specific software that created it.
Specifically, on-disk sectors 0 to 15 of a DOS 3.3 image (ordinarily having the extension DSK or DO) should contain the contents of the image sectors at offsets: `0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15` — i.e. increase by 7 at each step, and take the modulo by 15 if out of bounds. The on-disk sectors 0 to 15 of a Pro-DOS image (ordinarily PO) should contain the sectors at offsets `0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15` — i.e. increase by 8 each step, and take the module by 15 if out of bounds.