#ifndef READ_ILBM_H
#define READ_ILBM_H

/*************************************************************************
 ***                  ILBM READER HEADER FILE                          ***
 *************************************************************************/

/******************** INCLUDES *******************************************/
/* Other includes are in the readILBM.c file, to avoid conflict in client
 * modules that include this one. */

/******************** DEFINES ********************************************/
#ifndef NULL
#define NULL 0L
#endif

/* Error numbers */
#define ILBM_NOFILE         1       /* File not found */
#define ILBM_NOTFORM        2       /* Not a form file */
#define ILBM_NOTILBMFORM    3       /* A form file, but not an ILBM FORM */
#define ILBM_NOBMHD         4       /* No BMHD chunk */
#define ILBM_BADIMAGE       5       /* Image file and BitMap do not match */
#define ILBM_MASKSET        6       /* Mask parameter wierd */
#define ILBM_COMPUNKNOWN    7       /* Compression method unkown */
#define ILBM_SPRITE         8       /* File contains a SPRT chunk->a sprite */
#define ILBM_NOBODY         9       /* No BODY chunk found */
#define ILBM_NOCOLORS       10      /* No CMAP chunk found */
#define ILBM_FILE_ERROR     11      /* File system error */
#define ILBM_BADBMHD        12      /* BMHD chunk not correct length */
#define BODY_BADLENGTH      13      /* BODY chunk incorrect length */
#define BODY_BADLINE        14      /* BODY has a line of peculiar length */
#define BODY_BADUNIT        15      /* BODY unit beyond [-127,128] */
#define ILBM_TOODEEP        16      /* File depth too great for BitMap */

/* Stuff from the IFF section of the AMIGA RKM: Exec */
#define MakeID(a,b,c,d) ((LONG)(a)<<24L | (LONG)(b)<<16L | (c)<<8 | (d))
#define mskNone                 0
#define mskHasMask              1
#define mskHasTransparentColor  2
#define mskLasso                3

#define cmpNone         0
#define cmpByteRun1     1

/* chunk types */
#define TYPE_FORM   MakeID('F','O','R','M')
#define TYPE_ILBM   MakeID('I','L','B','M')
#define TYPE_BMHD   MakeID('B','M','H','D')
#define TYPE_CMAP   MakeID('C','M','A','P')
#define TYPE_GRAB   MakeID('G','R','A','B')
#define TYPE_DEST   MakeID('D','E','S','T')
#define TYPE_SPRT   MakeID('S','P','R','T')
#define TYPE_CAMG   MakeID('C','A','M','G')
#define TYPE_CRNG   MakeID('C','R','N','G')
#define TYPE_CCRT   MakeID('C','C','R','T')
#define TYPE_BODY   MakeID('B','O','D','Y')

typedef UBYTE   Masking;
typedef UBYTE   Compression;

typedef struct {                            /* BitMapHeader (BMHD) */
    UWORD   w,h;
    WORD    x,y;
    UBYTE   nPlanes;
    Masking masking;
    Compression compression;
    UBYTE   pad1;
    UWORD   transparentColor;
    UBYTE   xAspect,yAspect;
    WORD    pageWidth,pageHeight;} BitMapHeader;

typedef struct {                               /* Array of these == CMAP */
    UBYTE red,green,blue;} ColorRegister;

typedef struct {                                           /* GRAB chunk */
    WORD    x,y;} Point2D;

typedef struct {                                           /* DEST chunk */
    UBYTE   depth;
    UBYTE   pad1;
    UWORD   planePick;
    UWORD   planeOnOff;
    UWORD   planeMask;} DestMerge;

typedef UWORD   SpritePrecedence;                          /* SPRT chunk */

typedef LONG    ILBMViewMode;                              /* CAMG chunk */

typedef struct {                                           /* CRNG chunk */
    WORD    pad1;
    WORD    rate;
    WORD    active;
    UBYTE   low,high;} CRange;

typedef struct {                                           /* CCRT chunk */
    WORD    direction;
    UBYTE   start,end;
    LONG    seconds;
    LONG    microseconds;
    WORD    pad;} CycleInfo;

#ifndef   ILBM_PARENT
extern char *ILBMerror(int);                             /* Error number */
extern int  readILBM(struct BitMap *,UWORD *,char *);  /* bmap,cmap,file */
extern BitMapHeader *getBMHD(char *);                            /* file */
#endif

#endif
