/*
**      $VER: rgfx 1.2 (7.12.97)
**
**      Specs and structure definitions for the IFF-RGFX file format -
**
**      (C) Copyright 1997 Andreas R. Kleinert
**      Freeware. All Rights Reserved.
*/

#ifndef RGFX_H
#define RGFX_H

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif /* EXEC_TYPES_H */

#ifndef LIBARIES_IFFPARSE_H
#include <libraries/iffparse.h>
#endif /* LIBARIES_IFFPARSE_H */


/* *************************************************** */
/* *                                                 * */
/* * IFF/RGFX specific definitions and declarations  * */
/* *                                                 * */
/* *************************************************** */

#define ID_FORM  MAKE_ID('F','O','R','M')  /* if not already defined */
#define ID_RGFX  MAKE_ID('R','G','F','X')  /* IFF-RGFX               */

/* A typical structure of a RGFX file (recommended) :

     FORM-RGFX

       RGHD
       RSCM
       RCOL
       RBOD
*/


/*******************************************************
   RGHD - RawGfx Bitmap Header

   ** This one replaces BMHD

*/

#define ID_RGHD  MAKE_ID('R','G','H','D')

struct RGHD
{
 ULONG rgfx_LeftEdge;     /* (see BMHD)                               */
 ULONG rgfx_TopEdge;      /* (see BMHD)                               */
 ULONG rgfx_Width;        /* (see BMHD)                               */
 ULONG rgfx_Height;       /* (see BMHD)                               */
 ULONG rgfx_PageWidth;    /* (see BMHD)                               */
 ULONG rgfx_PageHeight;   /* (see BMHD)                               */

 ULONG rgfx_Depth;        /* 1-8         for RMBT_BYTEPLANAR8,
                             1-8         for RMBT_BYTECHUNKY8,
                              24         for RMBT_3BYTERGB24          */
 ULONG rgfx_PixelBits;    /* 1-8         for RMBT_BYTEPLANAR8,
                               8         for RMBT_BYTECHUNKY8,
                              24         for RMBT_3BYTERGB24          */
 ULONG rgfx_BytesPerLine; /* (width+7)/8 for RMBT_BYTEPLANAR8,
                              width      for RMBT_BYTECHUNKY8,
                              width*3    for RMBT_3BYTERGB24          */

 ULONG rgfx_Compression;  /* RCMP_ type flag                          */
 ULONG rgfx_XAspect;      /* (see BMHD)                               */
 ULONG rgfx_YAspect;      /* (see BMHD)                               */
 ULONG rgfx_BitMapType;   /* RBMT_ type flag                          */
};

 /* if you encounter unknown depth/pixelbits/bytesperline combinations,
    then do reject these (future expansions). But so far, only use
    the legally defined ones yourself ! Don't define own formats,
    e.g. for 16 Bit or for BGR !
  */

#define RCMT_NOCOMPRESSION  (0L)
#define RCMT_XPK            (1L)

#define RMBT_BYTEPLANAR8    (0L)   /* unaligned planar 8 bit bitmap */
#define RMBT_BYTECHUNKY8    (1L)   /* unaligned chunky 8 bit bitmap */
#define RMBT_3BYTERGB24     (2L)   /* 3-byte 24 bit RGB triples     */
/* ***************************************************** */


/*******************************************************
   RSCM - RawGfx ScreenMode

   ** This one replaces CAMG.

   The default setting is:

   rscm_AGA:  default screenmode
   rscm_CGfx: INVALID_ID
   rscm_P96:  INVALID_ID

   if ModeNotAvailable( rscm_P96 ) does return an error,
   then try ModeNotAvailable( rscm_CGfx ) - on error,
   then try ModeNotAvailable( rscm_AGA ).

   Use the first ID, which is available, otherwise compute
   one yourself by using BestModeID()


   Note: Since HAM modes only can be identified by their
         ID, you should make sure, tht CGfx/P96 are set
         to INVALID_ID and that AGA is OR'ed with HAM_KEY
         for these modes.
         For EHB, you should make sure, that the AGA viewmode
         field is OR'ed with EXTRAHALFBRITE_KEY - if you want
         to keep that feature with the graphics. Please also
         see colormap notes for EHB.
         (see <graphics/modeid.h>)

*/

#define ID_RSCM  MAKE_ID('R','S','C','M')

struct RSCM
{
 ULONG rscm_AGA;  /* 32 Bit AGA  Viewmode ID */
 ULONG rscm_CGfx; /* 32 Bit CGfx Viewmode ID */
 ULONG rscm_P96;  /* 32 Bit P96  Viewmode ID */
};
/* ***************************************************** */


/*******************************************************
   RCOL - RawGfx Colormap

   ** This one replaces CMAP,

      Required with RMBT_BYTEPLANAR8 and RMBT_BYTECHUNKY8,
      and optionally allowed with RMBT_3BYTERGB24 for use
      as a dithering destination colormap.

      Stored are 256 byte triples in RGB format. Note, that
      full-range values (0..255) have to be stored.

      Sample:   rcol_Colors[0][0]   = 0..255 red   value, color #0 (1st)
                rcol_Colors[0][1]   = 0..255 green value, color #0
                rcol_Colors[0][2]   = 0..255 blue  value, color #0
                ...
                rcol_Colors[255][0] = 0..255 red   value, color #255 (256th)
                rcol_Colors[255][1] = 0..255 green value, color #255
                rcol_Colors[255][2] = 0..255 blue  value, color #255


      Unused entries should be filled with zeroes.


   Allowed boolean values:  TRUE (1L) and FALSE (0L)

   Note: With EHB mode, which e.g. uses 64 colors with only a 32 color
         palette, you always should store the full color range within
         the RCOL structure: if someone is going to display EHB pictures
         on an RTG screen, he won't have to calculate the 'missing'
         colors by himself.

*/

#define ID_RCOL  MAKE_ID('R','C','O','L')

struct RCOL
{
 ULONG rcol_TransColor;      /* boolean: is there a transparent color ?  */
 ULONG rcol_TransColorNum;   /* yes, it's number ... from the ones below */
 UBYTE rcol_Colors[256][3];
};
/* ***************************************************** */


/*******************************************************
   RBOD - RawGfx Bitmap Body

   ** This one replaces BODY
*/

#define ID_RBOD  MAKE_ID('R','B','O','D')

/* May look like:

struct RBOD
{
 UBYTE rbod_XPK[3];     ** containing 'XPK'
 UBYTE rbod_BitMap[];
};

   Or simply:

struct RBOD
{
 UBYTE rbod_BitMap[];
};

 This has not been defined as a union structure here, since some
 compilers might add unwished pad bytes to the structure.

 You should reference this chunk as an UBYTE array, only.

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


/*******************************************************
   RGFX - Other chunks

   - NAME, AUTH, ANNO and (C) chunks are allowed
   -
******************************************************** */

#endif /* RGFX_H */
