
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>

struct	Window	    *getNewWind();

struct	IntuitionBase	*IntuitionBase;
struct	GfxBase 	*GfxBase;

#define debug(x)

#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))

/* for my window structure */

extern ULONG flg;
extern ULONG iflg;

/*------------------------------------------------------------------------*/
			    /* IFF header stuff */
/*------------------------------------------------------------------------*/

/* This was all lifted from an example by Leo Schwab */

/* turn 4 letters into a longword value */
#define MAKE_ID(a,b,c,d) (((long)(a)<<24)+((long)(b)<<16)+((long)(c)<<8)+(long)(d))

/* chunk types; not all are relevant to the program */

#define FORM	MAKE_ID('F', 'O', 'R', 'M')
#define ILBM	MAKE_ID('I', 'L', 'B', 'M')
#define BMHD	MAKE_ID('B', 'M', 'H', 'D')
#define CMAP	MAKE_ID('C', 'M', 'A', 'P')
#define BODY	MAKE_ID('B', 'O', 'D', 'Y')
#define GRAB	MAKE_ID('G', 'R', 'A', 'B')
#define DEST	MAKE_ID('D', 'E', 'S', 'T')
#define SPRT	MAKE_ID('S', 'P', 'R', 'T')
#define CAMG	MAKE_ID('C', 'A', 'M', 'G')
#define CRNG	MAKE_ID('C', 'R', 'N', 'G')
#define CCRT	MAKE_ID('C', 'C', 'R', 'T')
#define DPPV	MAKE_ID('D', 'P', 'P', 'V')

#define CHUNKHEADERSIZE 	sizeof (struct ChunkHeader)

/*  Compression techniques  */
#define cmpNone 		0
#define cmpByteRun1		1

/*  Bitmap header (BMHD) structure  */
struct bmhd {
	UWORD	w, h;		/*  Width, height in pixels */
	WORD	x, y;		/*  x, y position for this bitmap  */
	UBYTE	nplanes;	/*  # of planes  */
	UBYTE	Masking;
	UBYTE	Compression;
	UBYTE	pad1;
	UWORD	TransparentColor;
	UWORD	XAspect, YAspect;
	WORD	PageWidth, PageHeight;
};

/* NB: IFF colours aren't quite the same as you normally think */
struct ColorRegister {
	UBYTE red, green, blue;
};

/* since we can think of 'FORM' and the like as strings or longwords */
union yachunk {
	char name[4];
	long type;
};

struct ChunkHeader {
	union yachunk chunktype;
	long chunksize;
};

#define TYPE		chunktype.type
#define STRTYPE 	chunktype.name

/*------------------------------------------------------------------------*/

/* Some IFF functions; sketchy, but I hope they're illustrative and adaptable */

BOOL get_body();
long get_chunk();
BOOL good_pict();

