From: jsw@thalia.microunity.com (Jeff Weinstein)
Subject: Re: Apple II disk controllers
Organization: MicroUnity Systems Engineering, Inc.
Date: Mon, 13 Apr 1992 18:30:32 GMT

In article <1992Apr13.031758.46006@link-1.ts.bcc.ac.uk>, zcakilh@ucl.ac.uk (Miss Chee Mei Yeoh) writes:
> Steve Watt (steve@wattres.sj.ca.us) writes
>  
> > The disk controller on the Apple II was a sight to see. The programmer      
> > got to drive the stepper phases herself [and] read and write the
> > stream directly. None of this modern easy one-chip-does-all-the-hard-
> > work. It made some truly devious protection schemes available.
>                                                                             
> Quite. :-) I was at a friend's home one evening working on a nybble          
> copier (written with the mini-assembler, and when my integer card
> broke down, in hex :-) On the faith of all the publicly available
> documentation at the time, we all 'knew' that the drive motor could
> be moved in increments of half a track; it was impossible to do
> better and I (and a friend, now a medical student) asserted as much.  
> Just then, another friend called to say that quarter-track seeking    
> was, after all, possible. :-) Needless to say, I felt a complete      
> fool at the time.

  If I recall correctly the quarter track method involved moving
the stepper alternately between two half-tracks quickly enough that
it would not actually be able to move.  The stepper would not actually
stay at a quarter track by itself.  So you would do something like
this:

	1) start at a half track

	2) tell stepper to move up to next half track

	3) wait for HALF the time it takes for the stepper to move
		a half track interval

	4) tell the stepper to move back down

	5) write some data, you have only as much time as it takes the
		mechanical stepper to reverse direction and start moving

	6) tell the stepper to move back up

	7) write more data, again waiting only as much time as it
		takes for the head mechanism to reverse itself

	8) repeat steps 4 through 7 until you have written the entire
		track

  The result of this method was that the read/write head would sort of
wobble back and forth between two half-tracks.  As long as the wobble
wasn't more than the resolution of the head you were ok.  There were
some variations on this scheme that used a spiral pattern, moving out
a quarter track at a time.

ObHack:  I wrote the "fixcat" program for "Bag of Tricks II".  Fixcat
is the apple dos equivalent of unix fsck.  For BOT II we added support
for ProDOS, which had a tree structured file system rather than just
a single level directory.  Because directories could be nested arbitrarily
deep(ProDOS did support hard disks, so size wasn't limited to a single
floppy) I had to use recursive techniques.  The stack on the 6502 was
only 256 bytes deep, so I had to keep a parallel stack for my data,
using a couple of location in page zero as the stack pointer.  I did use
the real stack for subroutine return addresses.  BTW, this is the same
technique used by Manx's Aztec C compiler...

	--Jeff

Jeff Weinstein - X Protocol Police
MicroUnity Systems Engineering, Inc.
jsw@microunity.com
Any opinions expressed above are mine.