[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: Sun, 18 Feb 2007 23:27:16 +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>
- User-agent: KNode/0.10.4
- Xref: g2news2.google.com comp.sys.apple2:17532
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 :)
Thanks,
Tristan.
--
-----> http://members.dodo.com.au/~izabellion1/tristan/index.html <-----
===== It's not pretty, it's not great, but it is mine. =====