[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Apple floppy adaptor. I'm stuck!
- Subject: Re: Apple floppy adaptor. I'm stuck!
- From: Tristan Mumford <xtristan.xmumford@xgmail.xcom>
- Date: Thu, 22 Feb 2007 11:06:37 +1100
- Newsgroups: comp.sys.apple2
- References: <45d5a6a4$0$52925$c30e37c6@lon-reader.news.telstra.net> <cvydnaZg2JJRmEvYnZ2dnUVZ_oSnnZ2d@comcast.com> <45d65274$0$52912$c30e37c6@lon-reader.news.telstra.net> <45d83ccf$0$20295$9b4e6d93@newsspool3.arcor-online.net> <45d84628$0$52907$c30e37c6@lon-reader.news.telstra.net> <45dcdb63$0$15952$9b4e6d93@newsspool4.arcor-online.net>
- User-agent: KNode/0.10.4
- Xref: g2news2.google.com comp.sys.apple2:17706
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. =====