

	; OutRun imager


	; 1987 OutRun disk format:

	; The disk is in a standard Amiga 11-sector format where all
	; sectors (except for the ones on track 0) have changed blockheaders
	; so Amiga DOS cannot read these.

	; The track layout is different to other formats:

	; The disk is double sided, but track 0 to 79 are on cylinder
	; 0 to 79 on side 0, track 80 to 159 are on cylinder 0 to 79 on
	; side 1.

	; Tracks 43 to 45 are not formatted.


	; 1988 OutRun disk format:

	; Tracks 0 to 1 and 76 to 89 are in Amiga format, the disk
	; contains a standard bootblock and two files on disk:

	; S/STARTUP-SEQUENCE	(only contains "BOOT" as string)
	; BOOT			(contains the bootloader with loaderscreen)

	; All other tracks are in "Hackmatt" format.

	; Explanation of a "Hackmatt"-track:

	; Sync ($4489)
	; $55555555,$AAAAAAAA
	; 1 longword checksum
	; $5DC longwords data ($1770 bytes)

	; The MFM decoding is very simple, just a standard DECODE_L
	; for every longword.


		incdir	Includes:
		include	RawDIC.i

		SLAVE_HEADER
		dc.b	1	; Slave version
		dc.b	0	; Slave flags
		dc.l	DSK_1a	; Pointer to the first disk structure
		dc.l	Text	; Pointer to the text displayed in the imager window

		dc.b	"$VER:"
Text:		dc.b	"Outrun imager V1.1",10,"by John Selck on 21.03.1999",0
		cnop	0,4

DSK_1a:		dc.l	0		; pointer to next disk structure
		dc.w	1		; disk structure version
		dc.w	DFLG_SWAPSIDES	; flags (look below)
		dc.l	TL_1a		; list of tracks which contain data
		dc.l	0		; UNUSED, ALWAYS SET TO 0!
		dc.l	FL_DISKIMAGE	; list of files to be saved
		dc.l	CRC_1		; table of certain tracks with CRC values
		dc.l	DSK_1b		; alternative disk structure, if CRC failed
		dc.l	0		; called before a disk is read
		dc.l	0		; called after a disk has been read


DSK_1b:		dc.l	0		; pointer to next disk structure
		dc.w	1		; disk structure version
		dc.w	DFLG_RAWREADONLY|DFLG_DOUBLEINC	; flags (look below)
		dc.l	TL_1b		; list of tracks which contain data
		dc.l	0		; UNUSED, ALWAYS SET TO 0!
		dc.l	FL_DISKIMAGE	; list of files to be saved
		dc.l	0		; table of certain tracks with CRC values
		dc.l	0		; alternative disk structure, if CRC failed
		dc.l	0		; called before a disk is read
		dc.l	0		; called after a disk has been read

CRC_1:		CRCENTRY 1,$62b9
		CRCEND

TL_1a:		TLENTRY	1,1,$1600,SYNC_STD,DMFM_STD
		TLENTRY	2,75,$1770,SYNC_STD,DMFM_OutRun
		TLENTRY	90,126,$1770,SYNC_STD,DMFM_OutRun	; this is the main exe of outrun, length: $33780
		TLEND

TL_1b:		TLENTRY	0,84,$1600,SYNC_STD,DMFM_STD
		TLENTRY	86,118,$1600,SYNC_INDEX,DMFM_NULL	; Errors on tracks 86,88,90. Tracks 92-118 are empty.
		TLENTRY	120,158,$1600,SYNC_STD,DMFM_STD
		TLENTRY	1,159,$1600,SYNC_STD,DMFM_STD
		TLEND

DMFM_OutRun:
		addq.l	#8,a0		; $55555555,$aaaaaaaa

		move.l	#$55555555,d1
		DECODE_L (a0)+,d1,d4

		move.w	#$1770/4-1,d2
		moveq	#0,d3
.l0		DECODE_L (a0)+,d1,d0
		move.l	d0,(a1)+
		sub.l	d0,d3
		dbra	d2,.l0

		cmp.l	d3,d4
		bne.b	.csum

		moveq	#IERR_OK,d0
		rts
.csum		moveq	#IERR_CHECKSUM,d0
		rts
