
/******************************************************************************
 *
 * Flowerpower's AOM_Raw Datatype
 *
 * Written by Christian Buchner and David N. Junod
 *
 ******************************************************************************
 * check.c
 *
 */

#include <exec/types.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <datatypes/datatypes.h>
#include <graphics/gfx.h>

#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/utility_protos.h>

#include <pragmas/exec_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/utility_pragmas.h>

/*****************************************************************************/

#define SysBase          dthc->dthc_SysBase
#define DOSBase          dthc->dthc_DOSBase
#define UtilityBase      dthc->dthc_UtilityBase

/*****************************************************************************/

struct RawHeader
{
	ULONG width;
	ULONG height;
	ULONG depth;
};

/*****************************************************************************/

BOOL __asm DTHook (register __a0 struct DTHookContext * dthc)
{
	BOOL retval = FALSE;
	struct RawHeader *rh;
	ULONG filesize;
	
	/* Make sure we have a FileInfoBlock */
	if (dthc->dthc_FIB)
	{
		/* Make sure we have a buffer */
		if (dthc->dthc_Buffer && dthc->dthc_BufferLength>=sizeof(struct RawHeader))
		{
			/* The buffer is the RawHeader */
			rh=(struct RawHeader*)dthc->dthc_Buffer;
			
			/* Only allow depths of 5 and 6 */
			if (rh->depth==5 || rh->depth==6)
			{
				filesize=rh->depth*RASSIZE(rh->width,rh->height)+sizeof(struct RawHeader)+32*sizeof(UWORD);
				
				if (dthc->dthc_FIB->fib_Size == filesize)
				{
					retval=TRUE;
				}
			}
		}
	}
	return(retval);
}
