Good description of Apple ][ disk controller
eric at brouhaha.com
Mon Mar 21 15:33:37 CST 2005
> I am pretty surprised that I can't find any good technical descriptions of
> the Apple ][ disk controller. It's not in the DOS manual and, come to
> think of it, I can't think of any publication Apple came out with that
> describes it. I wonder why this is?
Because Apple considered it somewhat proprietary. Though there's
a patent on it:
There's also a patent on the later IWM chip, which was basically
a single chip version with a few improvements:
> I want to know what's going on in the PROMs,
You want the book "The Apple II Circuit Description", or "The Apple IIe
Circuit Description", by Winston Gayler. Out of print, of course, but
you can get a copy for the low, low price of only $250 from an Amazon
> and why
> the certain rules of encoding data are why they are (i.e. first bit of
> every disk byte must be set,
The bits shift in from the right, and there's no counter. The only
way you can tell that the complete "nybble" has been read is that the
MSB of the shift register is set.
> no more than one set of consecutive zeros in any byte, etc.)
The restriction on no more than one consecutive zero (with the older
13-sector state machine), or no more than two consecutive zeros (with
the newer 16-sector state machine) is required because the state
machine cannot reliably discrimiate the length of a long period of
time with no transitions. For example, it couldn't accurately
distinguish four empty bit times on a drive that was slightly fast
from three empty bit times on a drive that was slightly slow.
For the 13-sector state machine, there could never be two consecutive
zeros, and there were 34 valid nybbles that met that criterion. Two of
those, D5 and AA, were used for provide a unique pattern for the start
of address and data marks. The remaining 32 are used to encode 5 bits
of data (2**5 == 32).
The 16-sector state machine was redesigned to allow it to accurately
discriminate slightly longer delays between transitions, allowing the
use of two consecutive zero bits, but never three or more. There are
81 valid nybbles with that constraint. This is not enough to encode
seven bits, but it is enough for six (2**6 == 64). Even with the extra
two codes used for marks, only 66 nybble values are required, so 17 of
the 81 have to be chosen as invalid. By adding the somewhat arbitrary
prohibition of two double-zeros in a nybble, the number of valid
nybbles is reduced to 72, which is still 6 more than necessary. A
few more are also eliminated; I don't recall whether there was an
easily stated criterion that was used to eliminate the remaining 6.
When I say "somewhat arbitrary", that's not completely true. One
of the criterion for choosing which of the 81 possible nybbles should
be used for the actual data encoding is that it had to be possible in
a very small amount of 6502 code to generate the decode table, because
that had to be done in the 256-byte boot PROM along with the rest of
the code needed to enable drive 0, recalibrate (seek to track 0), find
sector 0, read it in, and jump to it. Both the 13-sector and 16-sector
disk boot PROMs are amazing examples of virtuoso 6502 programming.
But then, basically everything about the Disk II controller design
and software is incredibly amazing.
More information about the cctech