Alpha One's Track loader

Hits: 1390

Alpha One's loader

More
Tags
Category: TutorialsAmigaCrackingLoaders
Author:
Submitted by: musashi9
Date: 2007-06-22 06:05
No tags
  
init:	move.w	$dff01c,oldintena
	move.w	$dff01e,oldintreq
	bset	#7,oldintena
	bset	#7,oldintreq
	move.w	#$7fff,$dff09a		; interrupts aus.
	move.w	#$7fff,$dff09c		; 

;****************************************************************

	lea	$dff000,a6
	lea	buffer(pc),a0
	lea	mfmbuffer,a2
	move.l	#5*$1600,d0
	move.l	#0,d1
	move.l	#$0,d2
	jsr	trackloader

;****************************************************************

	move.w	oldintena(pc),$dff09a
	move.w	oldintreq(pc),$dff09c
	moveq	#0,d0
	rts

oldintena:	dc.w	0
oldintreq:	dc.w	0
buffer:		blk.b	130000,0
mfmbuffer:	blk.w	6400,0

; ============================================================================

; HARDWARE-DISKLOADER (c) ALPHA ONE 2005.
; ***************************************
; IMPROVED TO READ FROM ODD BYTEPOSITIONS.
; PRO VERSION -> WITH TRACKCOUNTER.
; IN: A6=$DFF000
;     A2=MFMBUFFER.L
;     A0=BUFFER.L
;     D0=LENGTH.L
;     D1=TRACKNR.L
;     D2=BYTEOFFSET.L

TRACKLOADER:
		
		LEA	$BFD100,A4		; DRIVESELECT REGISTER
		LEA	$BFE001,A5		; DRIVESTATUS REGISTER
		LEA	CURRENTTRACK(PC),A3	; HOLDS THE ACTUAL TRACKPOS
		MOVEQ	#0,D7			; D7 = BYTECOUNTER
		ADD.L	D2,D0			; BYTES TO READ + BYTEOFFSET
		MOVE.L	D0,D3			
		DIVS.W	#$1600,D3
		MOVE.B	D3,1(A3)

		MOVE.B	#$7D,(A4)		; SWITCH MOTOR DRIVE 0 ON
		NOP				; =======================
		NOP
		MOVE.B	#$75,(A4)
		BSR.W	DELAY
		BSR.W	DISKREADY

		CMP.B	#$FF,(A3)
		BNE.B	MOVETOCYLINDER
		MOVE.B	#0,(A3)
		BSET	#1,(A4)			; CHOSE DIRECTION TOWARDS 0
MOVETOZERO:	BTST	#4,(A5)			; HEAD ON CYLINDER 0?
		BEQ.B	MOVETOCYLINDER
		BSR.W	MOVEHEAD		; MOVE HEAD + DELAY
		BRA.B	MOVETOZERO	
		
MOVETOCYLINDER:	BSET	#2,(A4)			; CHOOSE HEAD HIGH
		BTST	#0,D1			; EVEN OR ODD TRACK?
		BEQ.B	HEADOK			; TRACK IS EVEN - ALRIGHT!
		BCLR	#2,(A4)			; CHOOSE HEAD LOW
HEADOK:		MOVEQ	#0,D3
		MOVEQ	#0,D5
		MOVE.B	D1,D3			; NEW TRACKNUM -> D3
		MOVE.B	(A3),D5			; CURRENT TRACK -> D5
		MOVE.B	D1,(A3)			; REPLACE CURRENT TRACK
		LSR.W	#1,D3			; GET CYLINDER NUM NEW TRACK
		LSR.W	#1,D5			; GET CYLINDER NUM CUR TRACK
		SUB.W	D3,D5
		BEQ.B	READTRACK
		BMI.B	OTHERDIRECTION
		BSET	#1,(A4)			; CHOOSE DIRECTION TOWARDS 0
		BRA.B	CHOSEN
OTHERDIRECTION:	BCLR	#1,(A4)			; CHOOSE DIRECTION OUTWARDS 0
		NEG.W	D5
CHOSEN:		BSR.W	MOVEHEAD
		SUBQ.B	#1,D5
		BNE.B	CHOSEN

READTRACK:	BSR.W	DISKREADY		; EINEN TRACK LESEN
		MOVE.W	#$8210,$96(A6)		; =================
		MOVE.W	#$7F00,$9E(A6)
		MOVE.W	#$8500,$9E(A6)
		MOVE.W	#$4489,$7E(A6)
		MOVE.W	#$4000,$24(A6)
		MOVE.L	A2,$20(A6)
		MOVE.W	#$9900,$24(A6)
		MOVE.W	#$9900,$24(A6)
		MOVE.W	#$2,$9C(A6)
TRACKREADY:	BTST	#1,$DFF01F
		BEQ.B	TRACKREADY
		MOVE.W	#$4000,$24(A6)

		MOVEQ	#0,D5			; DECODE TRACK
DECODE:		MOVE.L	A2,A1			; ============
		MOVE.L	#$55555555,D4
FINDSYNC:	CMP.W	#$4489,(A1)+
		BNE.B	FINDSYNC
		CMP.W	#$4489,(A1)
		BEQ.B	FINDSYNC
		MOVE.L	(A1),D3
		MOVE.L	4(A1),D1
		AND.L	D4,D3
		AND.L	D4,D1
		ASL.L	#1,D3
		OR.L	D1,D3
		ROR.L	#8,D3
		CMP.B	D5,D3
		BEQ.B	SECTORFOUND
		ADD.L	#1086,A1
		BRA.B	FINDSYNC
SECTORFOUND:	ADD.L	#56,A1
		MOVE.L	#(512/4)-1,D6
DECODESECTOR:	MOVE.L	512(A1),D1
		MOVE.L	(A1)+,D3
		AND.L	D4,D3
		AND.L	D4,D1
		ASL.L	#1,D3
		OR.L	D1,D3
		LEA	STORE(PC),A3
		MOVE.L	D3,(A3)

		MOVEQ	#4-1,D3
LOOP:		CMP.L	D7,D0
		BEQ.B	READREADY
		CMP.L	D7,D2
		BGT.B	BELOW
		MOVE.B	(A3),(A0)+
BELOW:		ADDQ.L	#1,A3
		ADDQ.L	#1,D7
		DBF	D3,LOOP

		DBF	D6,DECODESECTOR
		ADDQ.B	#1,D5
		CMP.B	#11,D5
		BNE.B	DECODE
		
TRACKDONE:	CMP.L	D7,D0			; TRACK DONE, GET ONTO NEXT.
		BEQ.B	READREADY		; ==========================
		BTST	#2,(A4)
		BEQ.B	ONTONEXT
		BCLR	#2,(A4)
		BSR.W	DELAY
		BRA.W	READTRACK
ONTONEXT:	BSET	#2,(A4)
		BSR.W	DELAY
		BCLR	#1,(A4)	
		BSR.W	MOVEHEAD
		BRA.W	READTRACK

READREADY:	MOVE.B	#$FD,(A4)		; SWITCH MOTOR DRIVE 0 OFF
		NOP				; ========================
		NOP
		MOVE.B	#$E7,(A4)
		LEA	CURRENTTRACK(PC),A3
		MOVE.B	1(A3),D0
		ADD.B	D0,(A3)
		RTS

DELAY:		CLR.B	$300(A4)		; DELAY ROUTINE
		MOVE.B	#$19,$400(A4)		; =============
		MOVE.B	#$1,$D00(A4)
WAIT:		BTST	#0,$C00(A4)
		BEQ.B	WAIT
		BCLR	#0,$D00(A4)
		RTS

DISKREADY:	BTST	#5,(A5)			; WAIT FOR DISK-READY
		BNE.B	DISKREADY		; ===================
		RTS

MOVEHEAD:	BCLR	#0,(A4)
		BSR.W	DELAY
		BSET	#0,(A4)	
		BSR.W	DELAY
		RTS		

CURRENTTRACK:	DC.B	$FF,0
STORE:		DC.L	0

TRACKLOADERENDE:

; ============================================================================

FileDownload: Alpha One's Track loader
Filesize: 0KB, downloaded 78 times
Powered by the best online Amiga mod player: FLOD


Some more you may like:
Track Loader ProxHorizon - Master Track ProloaderFile-name Loader

Comments

Leave a Comment!

Name:
: Use this calculator
Your comment will be available for editing for 10 minutes
2010-08-10 17:38
Avatar

1. SIRIaX writes

was? achso!
reply
2010-08-11 11:55

2. aLpHa oNe writes

kaggaichchecknix352352354.s ;-)
reply
2015-07-02 00:44

3. scenex writes

Alpha One, I've extended your trackloader to support multiple drives. Would you mind it being published here on Flashtro? :)
reply
Reply to comment #3
2015-07-02 06:35

4. aLpHa oNe writes

No problem although the original is a bit buggy I suppose. ;-)
reply
Reply to comment #4
2015-07-02 09:34

5. scenex writes

I've used it in 2 cracks and so far it worked :) The only "bug" i could observe is that the drive motors were not turned off after track loading. I changed the program flow a bit, where is waits for 500ms before checking the DSKRDY flag and turns off the motor and quits in case the check failed.
reply
Reply to comment #5
2015-07-02 09:57

6. aLpHa oNe writes

Ok, nice to hear. :p
reply