Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!rphroy!caen!hellgate.utah.edu!csn!ub!dsinc!bagate!cbmvax!jesup From: jesup@cbmvax.commodore.com (Randell Jesup) Newsgroups: comp.sys.amiga.programmer Subject: Re: Direct hardware drive access Message-ID: <20215@cbmvax.commodore.com> Date: 31 Mar 91 08:42:25 GMT References: <2147@pdxgate.UUCP> Reply-To: jesup@cbmvax.commodore.com (Randell Jesup) Organization: Commodore, West Chester, PA Lines: 89 In article mykes@amiga0.SF-Bay.ORG (Mike Schwartz) writes: > bsr StepDelay > rts >You can use > bra StepDelay >Which saves 34 clock cycles and 2 bytes. One of the oldest optimizations known to mankind (and compilers with tail-recursion/etc optimizations will do this too - even a simple peephole optimizer can catch this). >; Turn Amiga drive motor on: >MotorOn clr.l tdError > lea CIAB,a0 > move.b #%11111111,(a0) > move.b #%01111111,(a0) > move.b #%01000111,d0 > or.b tdDriveBits,d0 > move.b d0,(a0) > ; wait for disk to come up to speed > move.l d4,-(sp) > move.w #750/3,d4 >.wait bsr StepDelay > dbra d4,.wait First, the persons code you replied to was far better than this. You're waiting .75 seconds (750 ms) on every motor-on. We spec that floppy drives on the Amiga MUST be up to speed in .5 seconds. Also, the disk hardware as a ready signal, to tell you when it's up to speed. Many drives come up to speed far faster than .5 seconds, or may have just been turned off and are still close to speed, etc, or may have been on already, etc. The person who you responded to looped checking dskrdy. The best way to to wait .5 seconds, checking dskrdy every so often (2.0 trackdisk checks it every .1 seconds). > move.l (sp)+,d4 > move.l tdError,d0 > rts > >; Turn Amiga drive motor off: >MotorOff move.l #CIAB,a0 > move.b #%11111111,(a0) > move.b #%10000111,(a0) > move.b #%11111111,(a0) ^^^^^^^^^^^^^^^^^^^^ not needed, doesn't hurt BTW, you could have coded that routine 2 bytes shorter and 12 cycles shorter, if you care so much about space/speed. > rts ... >; Step toward track 80: >StepRight move.l #CIAB,a0 > move.b #%01000111,d0 ^ Interesting, that's DSKSEL3 Ever test this code with 4 drives? ^ Interesting, that's outwards (toward 0) This stuff of CIAB is not needed. (though a different one is) > or.b tdDriveBits,d0 > move.b d0,(a0) > move.b #%01000100,d0 ^ Interesting, that's DSKSEL3 ^ Interesting, that's inwards (toward 80) The hardware manual says DSKDIREC MUST be set correctly BEFORE step is set to 0. You must be lucky not to have hit a drive that actually requires it yet. > or.b tdDriveBits,d0 > move.b d0,(a0) > move.b #%01000101,d0 ^ Interesting, that's DSKSEL3 > or.b tdDriveBits,d0 > move.b d0,(a0) > move.b #%01000111,d0 ^ Interesting, that's DSKSEL3 ^ Interesting, that's outwards again This stuff of CIAB is not needed. > or.b tdDriveBits,d0 > move.b d0,(a0) > bra StepDelay And where is your settle routine? (I suspect you merely didn't include it - you need 15ms settle after finishing seeking (on top of the step delay!) -- Randell Jesup, Keeper of AmigaDos, Commodore Engineering. {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com BIX: rjesup Thus spake the Master Ninjei: "To program a million-line operating system is easy, to change a man's temperament is more difficult." (From "The Zen of Programming") ;-)