[comp.os.cpm] Faster floppy drives

DBRAATAN@NORUNIT.BITNET (05/23/88)

Higher floppy step rates.

Many modern floppy drives work at higher step rates than the
Western Digital (or compatible) Floppy Disc Controllers (FDCs)
may be programmed for. The highest step rate (FDC at 1 MHz)
is 6 ms per step. It is a pity that the controller cannot achive
the maximum drive performance. I think I have a solution to
the problem. It works for the WD 2797 controller and 3 1/2 inch
drive in my Bondwell-2 computer. I guess it will work for other
software compatible controllers also (1771, 1773, 2793, etc).

It IS possible to step the drive faster than the data sheet for
the controller says. Just use this Z80 program:


;-----------------------------------------------------------
;On entry:
;   C: Destination track number
;   B: Current track number
;
        LD      A,B
        OUT     (FTRK),A      ;Update track register in FDC
        LD      A,C
        SUB     B             ;Calculate distance from current to new track
        JR      Z,NOJOB       ;We are at the right track, exit
        LD      C,58h         ;FDC command: Step in
        JR      NC,INWARD     ;Step inwards
        NEG                   ;Get positive number of steps
        LD      C,78h         ;FDC command: Step out
INWARD: LD      B,A           ;Use B as step counter (counts down)
NXTSTP: LD      A,C
        OUT     (FCOMM),A     ;Issue step command to FDC
        LD      HL,TIME       ;Time between steps
        CALL    LPAUSE        ;Wait until the floppy is ready for next step
        CALL    IMMINT        ;Interrupt FDC
        DJNZ    NXTSTP        ;Do next step
NOJOB:                        ;Continue processing...


;       **** SUBROUTINES: ****
;----------------------------------------------
; Subroutine IMMINT
;   Issues immediate interrupt command to
;   Floppy Disc Controller.
;
IMMINT: LD      A,0D8h        ;FDC command: Immediate interrupt
        OUT     (FCOMM),A
        CALL    SDELAY        ;Short delay
        LD      A,0D0h        ;FDC command: Reset interrupt
        OUT     (FCOMM),A
WREADY: IN      A,(FCOMM)     ;Wait until the FDC is ready for next command...
        BIT     0,A
        JR      NZ,WREADY
        RET

;----------------------------------------------
; Subroutine SDELAY
;   This short delay is needed because the FDC registers
;   do not update instantly. The CALL - RET sequence is
;   a part of the delay. The delay is calculated for a
;   4 Mhz Z80 CPU.
SDELAY: PUSH    IX
        POP     IX
        PUSH    IX
        POP     IX
        RET

;----------------------------------------------
; Subroutine LPAUSE
;   General delay routine. Use your own or...
LPAUSE: DEC     HL
        INC     IX
        DEC     IX
        LD      A,H
        OR      L
        JR      NZ,LPAUSE
        RET

;------------------------------------------------

Final notes:
    My Bondwell uses a TIME = 216 constant. The fastest stepping
    rate you normally get with the FDC is something like TIME = 900.

    FCOMM is the I/O address to the FDC command/status register.
    FTRK is the I/O address to the FDC track register.

    This program must, of course, be inserted into your BIOS.

    I hope this may be of some use to some of you. The algorithm
    may be used on 8080 computers also, of course. Maybe the
    IBM PC also can do this. I dont know that. Please try it
    out.

    There may be errors in this note.

    Write EMAIL to me if you have questions or remarks.

          Dag Henrik Braatane
          DBRAATAN@NORUNIT.BITNET