/*
** AGA Fade Demo
** -------------
**
** Fades in a 32 colour AGA picture (24 bit colour).  Then up to a specified
** colour (greenish yellow), and then out to black.
*/

#include <proto/games.h>
#include <proto/exec.h>
#include <exec/memory.h>

struct GMSBase *GMSBase;
extern struct ExecBase *SysBase;

#define AMT_PLANES 5

ULONG Palette[] =
{
     0x000000,0x080808,0x101010,0x191919,0x212121,0x292929,0x313131,
     0x3A3A3A,0x424242,0x4A4A4A,0x525252,0x5A5A5A,0x636363,0x6B6B6B,
     0x737373,0x7B7B7B,0x848484,0x8C8C8C,0x949494,0x9C9C9C,0xA5A5A5,
     0xADADAD,0xB5B5B5,0xBDBDBD,0xC5C5C5,0xCECECE,0xD6D6D6,0x7F7F7F,
     0x9B9B9B,0x707070,0x444444,0x1E1E1E
};

struct GameScreen GameScreen =
{
     GSV1,               /* Structure version */
     0,0,0,              /* Screen Mem 1,2,3 */
     0,                  /* ScreenLink */
     0,                  /* Adress of palette */
     0,                  /* Address of rasterlist */
     32,                 /* Amount of colours */
     320,256,            /* Screen Width and Height */
     320/8,256,          /* Picture Width/8 and Height */
     AMT_PLANES,         /* Amount of bitplanes */
     0,0,                /* X/Y screen offset */
     0,0,                /* X/Y picture offset */
     0,                  /* Special attributes */
     LORES|COL24BIT,     /* Screen mode */
     INTERLEAVED,        /* Screen type */
     0                   /* Reserved */
};

struct Picture GamePic =
{
     PCV1,               /* Version header */
     0,                  /* Destination */
     320/8,256,          /* Width, Height */
     AMT_PLANES,         /* Amount of Planes */
     32,                 /* Amount of colours */
     Palette,            /* Palette */
     LORES|COL24BIT,     /* Screen mode */
     INTERLEAVED,        /* Destination */
     0,                  /* Parameters */
     "GAMESLIB:data/IFF.Loading"
};

/*=========================================================================*/

void main(void)
{
   int FState=0;

   GMSBase = (struct GMSBase *) OpenLibrary("games.library", 0);
   SetUserPrefs(0);
   if (Add_Screen(&GameScreen) == NULL) {
      GamePic.Data = GameScreen.MemPtr1;
      if (LoadPic(&GamePic) == NULL) {
         Show_Screen(&GameScreen);

         do
         {
           Wait_OSVBL();
           FState = ColourToPalette(&GameScreen,FState,2,0,32,&Palette,0x000000);
         } while (FState != NULL);

         do
         {
           Wait_OSVBL();
           FState = PaletteToColour(&GameScreen,FState,2,0,32,&Palette,0xa5f343);
         } while (FState != NULL);

         do
         {
           Wait_OSVBL();
           FState = ColourMorph(&GameScreen,FState,2,0,32,0xa5f343,0x000000);
         } while (FState != NULL);

      }
      Delete_Screen(&GameScreen);
   }
   CloseLibrary((struct Library *)GMSBase);
}

