#define INTUI_V36_NAMES_ONLY
#include "iffp/ilbmapp.h"

/* ProtoTypes Follow */

void cleanup(void);

#include "ilbmload_rev.h"

struct Library *IntuitionBase  = NULL;
struct Library *GfxBase        = NULL;
struct Library *IFFParseBase   = NULL;

/* Note - these fields are also available in the ILBMInfo structure */

struct  ILBMInfo  *ilbm;		      /* Our ILBM Structure! */


LONG	ilbmprops[] = 
                {
		ID_ILBM, ID_BMHD,
		ID_ILBM, ID_CMAP,
		ID_ILBM, ID_CAMG,
		ID_ILBM, ID_CCRT,
		ID_ILBM, ID_AUTH,
		ID_ILBM, ID_Copyright,
		TAG_DONE
		};

LONG	ilbmcollects[] = 
                {
		ID_ILBM, ID_CRNG,
		TAG_DONE
		};

LONG	ilbmstops[] = 
                {
		ID_ILBM, ID_BODY,
		TAG_DONE
		};

/* 
 * MAIN 
 */

void main( void )
   {

   UBYTE *ilbmname=NULL;

   ilbmname = "work:graphics/digitized/triton.iff.16c\0";

   /* Open Libraries */

   if(!(IntuitionBase = OpenLibrary("intuition.library", 0)))
      bye("Can't open intuition library.\n",RETURN_WARN);
      
   if(!(GfxBase = OpenLibrary("graphics.library",0)))
      bye("Can't open graphics library.\n",RETURN_WARN);

   if(!(IFFParseBase = OpenLibrary("iffparse.library",0)))
      bye("Can't open iffparse library.\n",RETURN_WARN);

ilbm = (struct ILBMInfo *)AllocMem(sizeof(struct ILBMInfo),MEMF_PUBLIC|MEMF_CLEAR)

    ilbm->ParseInfo.propchks	= ilbmprops;	 //Stick In The THings
    ilbm->ParseInfo.collectchks	= ilbmcollects; //To Our ILBM 
    ilbm->ParseInfo.stopchks	= ilbmstops;   //Structure!
    ilbm->windef	= &BackgroundWnd;	//Put In Our Window Here!!

        ilbm->ParseInfo.iff = AllocIFF() 
        queryilbm(ilbm,ilbmname)))

	ilbm->scr	= &Scr
	ilbm->win	= &BackgroundWnd
	ilbm->wrp	= &BackgroundWnd->RPort
	ilbm->srp	= &Scr->RastPort
	ilbm->vp	= &Scr->ViewPort

	        loadilbm(ilbm, ilbmname)
		closeifile(ilbm);
		unloadilbm(ilbm);	
 	    }

void cleanup()
   {
   if(ilbm)
	{
	if(ilbm->ParseInfo.iff)
           {
 	     FreeIFF(ilbm->ParseInfo.iff);
           }
	FreeMem(ilbm,sizeof(struct ILBMInfo));
	}

   if(GfxBase) 	     	CloseLibrary(GfxBase);
   if(IntuitionBase) 	CloseLibrary(IntuitionBase);
   if(IFFParseBase)  	CloseLibrary(IFFParseBase);
   }
