
	; Xenomorph imager (can easily adapted for Galdregons Domain)

	; Xenomorph is in standard Amiga format, except for tracks 2 and 3
	; which contain the copy protection.

	; The disk is NDOS but contains a custom directory format. The
	; directory is stored at offset $0400 and is built up like this:

	; 16 bytes filename
	; 1 longword filelength
	; 1 word startblock

	; This repeats until an empty filename.


		incdir	Includes:
		include	RawDIC.i

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

		dc.b	"$VER:"
Text:		dc.b	"Xenomorph imager V1.0",10,"by John Selck on 03.03.1999",0
		cnop	0,4

DSK_1:		dc.l	DSK_2		; pointer to next disk structure
		dc.w	1		; disk structure version
		dc.w	0		; flags (look below)
		dc.l	TL_1		; list of tracks which contain data
		dc.l	0		; UNUSED, ALWAYS SET TO 0!
		dc.l	FL_NOFILES	; 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	DC_Xenomorph	; called after a disk has been read

DSK_2:		dc.l	0		; pointer to next disk structure
		dc.w	1		; disk structure version
		dc.w	0		; flags (look below)
		dc.l	TL_1		; list of tracks which contain data
		dc.l	0		; UNUSED, ALWAYS SET TO 0!
		dc.l	FL_NOFILES	; 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	DC_Xenomorph	; called after a disk has been read

TL_1:		TLENTRY	0,1,$1600,SYNC_STD,DMFM_STD
		TLENTRY	2,3,$1600,SYNC_INDEX,DMFM_NULL	; copy protection tracks
		TLENTRY	4,159,$1600,SYNC_STD,DMFM_STD
		TLEND

DC_Xenomorph:
		moveq	#0,d0
		jsr	rawdic_ReadTrack(a5)	; read track containing directory
		add.w	#$0400,a1

.l1		tst.b	(a1)
		beq.b	.out
		move.l	a1,a0
		moveq	#$0f,d1
.l0		move.b	(a0)+,d0
	;cmp.b	#":",d0			; this is not for xenomorph, but
	;blo.b	.s0			; galdr.domain, some filenames
	;cmp.b	#";",d0			; contain ":" and ";". especially
	;bhi.b	.s0			; the ":" causes trouble with dos
	;sub.b	#":"-"A",d0
.s0	;move.b	d0,-1(a0)
		dbeq	d1,.l0
		subq.l	#1,a0
		cmp.l	#".FLR",-(a0)	; for xenomorph: the floor tiles have
		bne.b	.s1		; a ".FLR" extension, but the loader
		clr.l	(a0)		; does not use this extension.
.s1
		move.l	a1,a0
		move.l	$10(a0),d1
		move.w	$14(a0),d0
		mulu.w	#$0200,d0
		jsr	rawdic_SaveDiskFile(a5)
		add.w	#$16,a1
		bra.b	.l1
.out
		moveq	#IERR_OK,d0
		rts


