/*******************************************************************************
 *
 * (c) Copyright 1993 Commodore-Amiga, Inc.  All rights reserved.
 *
 * This software is provided as-is and is subject to change; no warranties
 * are made.  All use is at your own risk.  No liability or responsibility
 * is assumed.
 *
 * playanim.h - header file for the anim code. 
 *
 ******************************************************************************/

struct BitMapHeader 
{
	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;
	UBYTE	XAspect, YAspect;
	WORD	PageWidth, PageHeight;
};

struct ANHD
{
	UBYTE operation;
	UBYTE mask;
	UWORD w, h;
	WORD x, y;
	ULONG abstime;
	ULONG reltime;
	UBYTE ileave;
	UBYTE pad0;
	ULONG bits;
	UBYTE pad1[16];
};

struct VHDR
{
	ULONG OneShotHiSamples;
	ULONG RepeatHiSamples;
	ULONG SamplesPerHiCycle;
	UWORD SamplesPerSec;
	UBYTE CtOctave;
	UBYTE SCompression;
	LONG  Volume;
};

#define FIRSTCOLOUR_RED 0x0
#define FIRSTCOLOUR_GREEN 0x44444444
#define FIRSTCOLOUR_BLUE 0x88888888
#define LASTCOLOUR_RED 0x0
#define LASTCOLOUR_GREEN 0xffffffff
#define LASTCOLOUR_BLUE 0xffffffff

#define COPLISTTYPES 1
#define COLOURRANGE 50
#define COPINSCNT COLOURRANGE

#define SECTORSIZE 2048
#define DATASIZE ((sizeof(struct Frame1Head)) + (ncolours * 3))
#define BYTES_TO_SECTORS(x) (((x) + DATASIZE + sizeof(struct VistaScript) + (SECTORSIZE - 1)) / SECTORSIZE)
#define BYTES_TO_WHOLE_SECTORS(x) (BYTES_TO_SECTORS(x) * SECTORSIZE)
#define WHOLE_SECTORS(x) (((x) + (SECTORSIZE - 1)) / SECTORSIZE)

/* Frame1 is the format of the 1st frame of the sequence.
 * This cannot be defined in C, because the structure is of a variable length.
 *
 *
 * struct Frame1Head
 * {
 *	ULONG f1_MaxSectorSize;	 max number of sectors in a frame
 * 	ULONG f1_ByteSize;	 number of bytes in this block
 *	ULONG f1_Sectors;	 number of sectors in this block
 *	UWORD f1_ImageWidth;	 number of pixels accross the image
 *	UWORD f1_ImageHeight;	 number of rows in the image
 *	UWORD f1_ImageDepth;	 depth of the image
 *	UWORD f1_ScreenWidth;	 number of pixels accross the screen
 *	UWORD f1_ScreenHeight;
 *	UWORD f1_ScreenDepth;
 *	ULONG f1_ScreenModeID;
 *	UWORD f1_Colours;	 number of colours in the CMAP
 *	UBYTE f1_CMAP[];	 full CMAP structure.
 *	UBYTE f1_ILBM;		 ILBM of frame 1
 *	ULONG f1_NextByteSize;	 number of bytes in the next frame
 *	ULONG f1_NextSectors;	 number of sectors in the next frame
 *      VistaScript Data
 *	UBYTE f1_pads[];	 pad to the next whole sector
 *	AudioData
 * };
 */

/* Frame is the format of the other frames in the sequence.
 *
 * struct Frame
 * {
 *	UBYTE f1_DLTA[];	 DLTA of this frame
 *	ULONG f1_NextByteSize;	 number of bytes in the next frame
 *	ULONG f1_NextSectors;	 number of sectors in the next frame
 *      VistaScript Data
 * };
 */


struct Frame1Head
{
    ULONG f1_MaxSectorSize;
    ULONG f1_ByteSize;
    ULONG f1_Sectors;
    UWORD f1_ImageWidth;	/* number of pixels across the image */
    UWORD f1_ImageHeight;	/* number of rows in the image */
    UWORD f1_ImageDepth;	/* depth of the image */
    UWORD f1_ScreenWidth;	/* number of pixels across the screen */
    UWORD f1_ScreenHeight;
    UWORD f1_ScreenDepth;
    ULONG f1_ScreenModeID;
    UWORD f1_Colours;
};

struct VistaScript
{
    WORD vs_CamX;
    WORD vs_CamY;
    WORD vs_CamZ;
    WORD vs_Bank;
    WORD vs_Heading;
    WORD vs_Pitch;
    WORD vs_Focal;
};

struct Missile
{
    struct ExtSprite *mis_Sprite;
    WORD mis_Active;
    WORD mis_StartX;
    WORD mis_StartY;
    WORD mis_StartZ;
    WORD mis_StartPitch;
    WORD mis_Distance;
};

/* The Audio data in Frame1 has the following format:
 * ULONG SizeOfSample;
 * ULONG SamplesPerSecond;
 * LONG  Volume;
 * UBYTE Sample[];
 * Pads to whole sector size.
 *
 * (Next sample).
 *
 * The first sample is of the gunshot (or missile launch, or whatever).
 * The second is the thrusters.
 */

#define PERIOD(p) ((ULONG)(SysBase->ex_EClockFrequency * 5) / (ULONG)(p))
#define VOLUME(v) (((v) * 64) >> 16)

struct RawAudio
{
    ULONG ra_SizeOfSample;
    ULONG ra_SamplesPerSecond;
    ULONG ra_SamplesPerCycle;
    LONG  ra_Volume;
    /* UBYTE ra_Sample; starts here */
};
