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

Re: Apple floppy adaptor. I'm stuck!



Tristan Mumford wrote:
Linards Ticmanis wrote:


Tristan Mumford wrote:


Judging by the function of the stepping routines and the breakdown of the
method of stepping in UTA2, I would say I am properly decoding all normal
states of the step phase lines. However if there is other software that
forces it to activate other combinations it will just consider that an
illegal combination, do nothing and happily aid in destroying the
contents of the disk :)

Hmmm... maybe this stepping code from YAE could help with the odd stuff?
Note that the numbers given in the table and held in physical_track_no
are *quarter* tracks.

static int    stepper_movement_table[16][NO_OF_PHASES] = {
{  0,  0,  0,  0,  0,  0,  0,  0 },   /* all electromagnets off */
{  0, -1, -2, -3,  0,  3,  2,  1 },   /* EM 1 on */
{  2,  1,  0, -1, -2, -3,  0,  3 },   /* EM 2 on */
{  1,  0, -1, -2, -3,  0,  3,  2 },   /* EMs 1 & 2 on */
{  0,  3,  2,  1,  0, -1, -2, -3 },   /* EM 3 on */
{  0, -1,  0,  1,  0, -1,  0,  1 },   /* EMs 1 & 3 on */
{  3,  2,  1,  0, -1, -2, -3,  0 },   /* EMs 2 & 3 on */
{  2,  1,  0, -1, -2, -3,  0,  3 },   /* EMs 1, 2 & 3 on */
{ -2, -3,  0,  3,  2,  1,  0, -1 },   /* EM 4 on */
{ -1, -2, -3,  0,  3,  2,  1,  0 },   /* EMs 1 & 4 on */
{  0,  1,  0, -1,  0,  1,  0, -1 },   /* EMs 2 & 4 */
{  0, -1, -2, -3,  0,  3,  2,  1 },   /* EMs 1, 2 & 4 on */
{ -3,  0,  3,  2,  1,  0, -1, -2 },   /* EMs 3 & 4 on */
{ -2, -3,  0,  3,  2,  1,  0, -1 },   /* EMs 1, 3 & 4 on */
{  0,  3,  2,  1,  0, -1, -2, -3 },   /* EMs 2, 3 & 4 on */
{  0,  0,  0,  0,  0,  0,  0,  0 } }; /* all electromagnets on */
static void toggleStepper( ADDR address )
{
int   magnet, on, old_track_no, new_status,phase;

if ( track_buffer_valid )
save_track_buffer();
magnet = (address & 0x0E) >> 1;
on = address & 0x01;
old_track_no = physical_track_no[current_slot][current_drive];
if ( on )
stepper_status |= (1<<magnet);
else
stepper_status &= ~(1<<magnet);
if ( motor_on ) {
new_status = stepper_status;
phase = physical_track_no[current_slot][current_drive] & 0x07;
physical_track_no[current_slot][current_drive] +=
stepper_movement_table[new_status][phase];
if ( physical_track_no[current_slot][current_drive] < 0 ) {
#ifdef DEBUG
fprintf( stderr, "Grrrr....\n" );
#endif
physical_track_no[current_slot][current_drive] = 0;
}
else if ( physical_track_no[current_slot][current_drive] >=
MAX_PHYSICAL_TRACK_NO )
physical_track_no[current_slot][current_drive] =
MAX_PHYSICAL_TRACK_NO-1;
track_buffer_valid = 0;
}

}



-snipped for sanity-

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. Most notably that there are states used which I have been ignoring.
My original code which is thankfully just commented out uses a really scary
pair of lookup tables that have all the states that seemed to be valid.
Still I don't think I'll use the old code. It was a little too efficient.
Basically I think it could get the current phase, decode it and figure out
which direction it needed to go in a few cycles. Doing that though it was
kind of painful to look at.
Given the massive disparity in step times between a2 and pc it would almost
be possible to have the drive play a stepper tune with extra seeks while
waiting. Hmm. Sounds fun.

The current code only deals with one phase on at a time. Partially because
it looked like that was all the standard routines dealt with, and partially
because it seems logical that no matter what a stepping routine would
probably have each single phase on exclusively at some point of rotation.

That code does seem similar in spirit to mine. Just that looks better
thought out :)

The normal seek behavior of RWTS and the Disk ][ Driver is to "idle"
with all phases off (though the boot ROM leaves phase 0 on after the
recalibration seek).

To move, the driver turns on the "current" phase (the one last
energized), then turns on the adjacent phase (in the desired direction),
then turns off the original phase and waits for the stepper to
stabilize.  It repeats this cycle twice for each track moved.

-michael

NadaNet networking for Apple II computers!
Home page:  http://members.aol.com/MJMahon/

"The wastebasket is our most important design
tool--and it's seriously underused."