SLOW.ASM 4.09 KB
Newer Older
ASCP's avatar
ASCP committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170

DSKPTR: EQU     $DFF020
DSKLEN: EQU     $DFF024
FLAG:   EQU     $BFDD00
CIAA:   EQU     $BFE001
CIAB:   EQU     $BFD100
INTENAR: EQU    $DFF01C
INTENA: EQU     $DFF09A
INTREQ: EQU     $DFF09C
INTREQR: EQU    $DFF01E
BUFSIZ: EQU     16000
ADKCON: EQU     $DFF09E
ADKCONR: EQU    $DFF010

DISABLE MACRO
        MOVE.W  #$4000,$DFF09A
        ENDM

ENABLE  MACRO
        MOVE.W  #$C000,$DFF09A
        ENDM

GO:     MOVE.B  #$7F,FLAG               ;TURN OFF ICR ENABLE MASK
        MOVE.W  #$2002,INTENA           ;TURN OFF DISK INTERRUPTS, IF ON
        MOVE.W  #$2002,INTREQ

* SELECT DF2 AND TURN ON ITS MOTOR

	DISABLE
        MOVE.B  #-1,CIAB
        MOVE.B  #-1,CIAB
        MOVE.B  #-9,CIAB
        MOVE.B  #-1,CIAB
        MOVE.B  #-$11,CIAB
        MOVE.B  #-1,CIAB
        MOVE.B  #-$21,CIAB
        MOVE.B  #-1,CIAB
        MOVE.B  #-$41,CIAB

        MOVE.B  #-1,CIAB                ;START WITH ALL RESET
        MOVE.B  #$7F,CIAB               ;TURN ON MOTOR
        MOVE.B  #-$21,CIAB              ;SELECT DF2
        MOVE.L  #500000,D1              ;WAIT FOR MOTOR TO COME ON
        JSR     DELAY                   ;WAIT FOR A WHILE

* SET GCR, ETC.

        MOVE.W  #$600,ADKCON
        MOVE.W  #$1100,ADKCON
	MOVE.W	#$2002,INTREQ

* SEEK DESIRED TRACK

        MOVE.B  #$5F,D0                 ;DF2 WITH MOTOR ON
        BSET    #2,D0                   ;SIDE 0
        BCLR    #1,D0                   ;TOWARD SPINDLE
        MOVE.B  D0,CIAB
        MOVE.B  D0,SAVE_D0              ;SAVE VALUE
        MOVEQ   #40,D2                  ;MAX OF 40 TRIES
1$:     BTST    #4,CIAA                 ;ON TRACK 0?
        BNE.S   2$                      ;NO...NO NEED TO GO FURTHER
        JSR     STEP                    ;ELSE MOVE AWAY FROM TRACK 0
        DBF     D2,1$                   ;LOOP FOR A WHILE
2$:     BSET    #1,SAVE_D0              ;NOW MOVE TOWARD EDGE
        MOVE.W  #100,D2                 ;MAX OF 100 STEPS
        BRA.S   3$
4$:     JSR     STEP                    ;STEP THE HEADS
3$:     BTST    #4,CIAA                 ;BACK TO TRACK 0?
        DBEQ    D2,4$                   ;NO...STEP AGAIN
	MOVE.B	#$5F,D0			;DF2
	BSET	#2,D0			;SIDE 0
	BCLR	#1,D0			;TOWARD SPINDLE
	MOVE.B	D0,SAVE_D0
	MOVEQ	#5,D2			;GET TO TRACK 7
5$:	JSR	STEP
	DBF	D2,5$

	JSR	SLOW			;TRY TO SLOW DRIVE MOTOR

        LEA     DSKBUF,A0               ;DISK BUFFER
        MOVE.L  A0,DSKPTR               ;SET UP DMA ADDRESS
        MOVE.W  #6250,D1                ;NUMBER OF WORDS PER TRACK?
        OR.W    #$8000,D1               ;THIS IS THE START BIT
        MOVE.W  D1,DSKLEN               ;THATS ONCE
        MOVE.W  D1,DSKLEN               ;AND THAT SHOULD START IT

	JSR	SLOW

* LOOP TILL DSKBLK SHOWS END OF DMA TRANSFER
INDEX:
        MOVEQ   #0,D0
3$:     ADD.L   #1,D0
        MOVE.W  INTREQR,D1              ;DISK DONE YET?
        BTST    #1,D1
        BEQ     3$                      ;NO

* NOW SHUT DOWN THE DISK

        MOVE.W  #0,DSKLEN               ;TURN OFF THE DMA ENABLE BIT
        MOVE.W  #2,INTREQ               ;AND KILL THE DISK DONT INT REQ
        MOVE.B  #-1,CIAB                ;TURN OFF THE DRIVE
        MOVE.B  #-1,CIAB
        MOVE.B  #-$21,CIAB

* TRY TO DECODE THE TRACK DATA

FIND_TRACK_START:
	ENABLE
        RTS                             ;BACK TO AMIGADOS

* STEP THE HEADS

STEP:
        MOVE.B  SAVE_D0,D0              ;SAVED DISK SELECT, SIDE, DIRECTION
        LEA     CIAB,A1
        MOVE.B  D0,D1
        BCLR    #0,D0                   ;STEP BIT
        MOVE.B  D0,(A1)
        NOP
        NOP
        MOVE.B  D1,(A1)
        MOVE.L  #$2000,D1
        JSR     DELAY                   ;WAIT
        RTS

DELAY:
        DBF     D1,DELAY
        SUB.L   #$10000,D1
        BPL.S   DELAY
        RTS

SLOW:	MOVE.L	#1000,D6
1$:	JSR	DUTY
	DBF	D6,1$
	RTS

DUTY:	MOVE.B	#-1,CIAB
	MOVE.B	#$DF,CIAB
	MOVEQ	#18,D1
	JSR	SDELAY
	MOVE.B	#$7F,CIAB
	MOVE.B	#$5F,CIAB
	MOVEQ	#80,D1
	JSR	SDELAY
	RTS

SDELAY:
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	DBF	D1,SDELAY
	RTS

SAVE_D0: DC.B 0

        CNOP    0,4
  
DSKBUF: DCB.B  BUFSIZ,0                 ;RESERVE DISK DATA BUFFER


TEXTBUF: DCB.B  BUFSIZ,0                ;CONVERTED DATA BUFFER
        END