

		section "Recognizer",code

	incdir "includes:"
	include	"asm:datamaster.library/datamaster.i"
	include	"asm:datamaster.library/datamaster_lib.i"

	incdir "includes:"

;EXEC
	include "exec/exec_lib.i"
	include	"exec/exec.i"

	include "misc/deliplayer.i"

CALLBASE:	MACRO
	jsr	_LVO\1(a6)
		ENDM

JMPBASE:	MACRO
	jmp	_LVO\1(a6)
		ENDM


;DEBUGGING=1

	IFD DEBUGGING

	lea	dmname,a1
	moveq	#2,d0
	move.l	$4.w,a6
	CALLBASE OpenLibrary
	move.l	d0,a5
	move.l	a5,a6
	lea	data,a0
	move.l	#data2-data,d0
	move.l	a0,a2
	move.l	d0,d2

	jsr	Custom_Check

	move.l	a6,a1
	move.l	$4.w,a6
	CALLBASE CloseLibrary
	rts

dmname:	dc.b	"datamaster.library",0
data:	
	incbin "Mods-4:Modules/Synth/Custom/CUST.Imploder-4"
data2:
	even
	ENDC




		RECOHEADER reco
reco:	dc.l	DMR_Flags,RECOF_CheckData+RECOF_CheckPatt+RECOF_SubType
	dc.l	DMR_DMVersion,2
	dc.l	DMR_Version,1<<16+4
	dc.l	DMR_Class,DMCLASSF_MUSIC
	dc.l	DMR_SubTypesTable,CheckTable
	dc.l	DMR_CheckRoutineHook,checkroutine
	dc.l	DMR_Name,.name
	dc.l	DMR_Descr,.descr
	dc.l	DMR_HookName,execname
	dc.l	TAG_END
	
.name:	dc.b	"MUSIC-Synth",0

.descr:	dc.b	"CUSTOM music-formats",0
	even


;had to include this personal checkroutine to modify the results
;of the XXXX_Check routines...(as they return good=NULL and datamaster
;needs to get d0=subtype string if good, else NULL) (!)

;get d0= output of the current sub-check & a0=pointer on current
;entry in the array
checkroutine:
	tst.l	d0
	beq.s	.good
.bad:	moveq	#0,d0
	rts
.good:	move.l	8(a0),d0	;get current subtype string
	rts




*---------------------------------------------------------------------------*
RonKlaren_Check:cmp.l	#$70ff4e75,$20(a0)		;moveq #-1,d0/rts
		bne.s	.Return
		lea	$28(a0),a0
		lea	.RK_ChkData(pc),a1
.NextB:		move.b	(a1)+,d0
		beq.s	.Ok
		cmp.b	(a0)+,d0
		beq.s	.NextB
		bra.s	.Return
.Ok:		moveq	#0,d0				;kennung No Found
.Return:	rts
.RK_ChkData:	dc.b	"RON_KLAREN_SOUNDMODULE!",0
		even


*---------------------------------------------------------------------------*
Custom_Check:	lea	.deliheader,a1
		move.l	#1024,d0
		CALLBASE dmFindTextC
		tst.l	d0
		beq.s	.ok
		rts
.ok:		move.l	(a1),d0
		cmp.l	#1024,d0	;check if data is relocated or not
		bhi.s	.relocated	;(add a2=relocate)
		lea	-12(a1),a1
		add.l	a1,d0
.relocated:	cmp.l	a2,d0
		bhi.s	.sure
		move.l	a2,d0
.sure:		move.l	d0,a4


;now we're going to check some "basic" tags....
		
		move.l	#DTP_CustomPlayer,d0
		bsr.s	find
		beq.s	.error

.good:		moveq	#0,d0
		rts
.error:		moveq	#1,d0
		rts

		even
.deliheader:	dc.b	$70,$ff
		dc.b	$4e,$75
		dc.b	"DELIRIUM",0
		even

find:				;cherche le tag d0=>valeur RELOGEE en d0
	move.l	a4,a0		;0 si pas trouvé
.cont:	move.l	(a0),d1
	bne.s	.notzero
	moveq	#0,d0
	rts
.notzero:
	cmp.l	d0,d1
	bne.s	.pasbon		;bon tag?
	moveq	#1,d0
	move.l	4(a0),d0	;ti_data
	rts
.pasbon:lea	8(a0),a0
	bra.s	.cont
	even


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

;				CheckING TABLE

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


CheckTable:
			dc.l	Custom_Check,Custom_Patt,Custom_Name
			dc.l	RonKlaren_Check,RonKlaren_Patt,RonKlaren_Name
			dc.l	0,0,0




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

;				SubTypes strings

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

RonKlaren_Name:		dc.b	"Ron Klaren",0
Custom_Name:		dc.b	"CUSTOM module",0


RonKlaren_Patt:
	dc.b	"RK.*",0		;="Eagleplayers/RonKlaren"
	dc.b	"RonKlaren.*",0
	dc.b	"*.RK",0
	dc.b	$ff
	
Custom_Patt:
	dc.b	"CU.*",0		;customs
	dc.b	"cust.*",0
	dc.b	"*.CUST",0
	dc.b	$ff

execname:
	dc.b	"executable",0
	

