[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apple floppy adaptor. I'm stuck!



Linards Ticmanis wrote:

> Tristan Mumford wrote:
> 
>> Well look at that. I don't seem to be alert enough to fully comprehend
>> how the two dimensional array works but it does tell me some interesting
>> things.
> 
> Small explanation of that code in plain English (well, more or less):
> 
> Whenever a magnet is *either* turned off *or* on while the drive motor
> is running, do all of the following:
> 
>   Look up the row of the table that corresponds to the current state of
>   all four magnets, as they are AFTER the turning on or off happens
> 
>   In that row, look up the column that corresponds to the *remainder*
>   of the following division: current quarter track number, divided by 8
> 
>   Add the number you find at that row and column to the current quarter
>   track number to get the new quarter track number.
> 
>   If the new number is less than 0 (or more than your maximum quarter
>   track,) then make it 0 (or maximal).
> 
> You can then take the difference between the old and new positions (both
> rounded to half tracks this time) and send that many pulses to the drive.
> 
 I get it now. Very nice indeed.
Here's a copypaste of my second stepping translator.
headStep() deals with trackcounting, headbump stopping etc.
This bit of code was a quick hack so I had something that I knew worked. Ie
no fancy tricks.


      curr = (input_a() & 0xF); //masking out other bits.

      if(prev!=curr)
      {
        switch(curr)
        {
                case 0: //all phases off
                {
                        /*
                        Don't step and don't touch "prev".
                        If "prev" is altered the routine won't know
                        what direction to move the head.
                        */
                        break;
                }
                case 1: //phi0
                {
                        if( prev == 8 )
                                headStep(IN);
                        else
                                headStep(OUT);
                        prev = curr;
                        break;
                }
                case 2: //phi1
                {
                        if( prev == 1 )
                                headStep(IN);
                        else
                                headStep(OUT);
                        prev = curr;
                        break;
                }
                case 4: //phi2
                {
                        if( prev == 2 )
                                headStep(IN);
                        else
                                headStep(OUT);
                        prev = curr;
                        break;
                }
                case 8: //phi3
                {
                        if( prev == 4 )
                                headStep( IN );
                        else
                                headStep( OUT );
                        prev = curr;
                        break;
                }
                default:
                {
                        //ignore other states.
                        break;
                }
        } // end of "switch(curr)"
      } //end of "if(prev!=curr)"

-- 
-----> http://members.dodo.com.au/~izabellion1/tristan/index.html <-----
=====       It's not pretty, it's not great, but it is mine.       =====