; dthook.asm
; Datatype hook function for the Be DataType descriptor.
; Written by Edmund Vermeulen <edmundv@grafix.xs4all.nl>.
;
; Load it in DTDesc through the 'Load Function...' menu to create the
; Be DataType descriptor.

	include	"libraries/dos.i"
	include	"datatypes/datatypes.i"

	section code
; a0 comes initialised with a pointer to a DTHookContext struct
	cmpi.l	#20,dthc_BufferLength(a0)	; at least 20 bytes in buffer?
	blt.s	false
	move.l	dthc_Buffer(a0),a0	; pointer to buffer in a0

	moveq	#4,d0			; repeat 5 times
loop	tst.b	(a0)
	bne.s	false
	tst.b	1(a0)
	bne.s	false
	addq.l	#4,a0
	dbra	d0,loop

	tst.b	-2(a0)
	bne.s	false
	cmpi.b	#4,-1(a0)		; B_COLOR_8_BIT
	beq.s	true
	cmpi.b	#8,-1(a0)		; B_RGB_32_BIT
	beq.s	true

false	moveq	#0,d0			; FALSE
	rts				; short way out of here

true	moveq	#1,d0			; TRUE
	rts

verstr	dc.b	'$VER: BE 43.0 (30.10.96)',0
	end
