/* xflick.h
   Modified by Rob Poole
*/

#include <string.h>
#include <fcntl.h>

#define FHD_EXPAND_SIZE 102
#undef USE_MEMSET

struct fli_header
{
    unsigned long fhd_size;    /* Length of whole file */
    int fhd_magic;  /* 0xaf11 */
    int fhd_frames;
    int fhd_width; 
    int fhd_height;
    int fhd_gap;
    int fhd_flags;
    int fhd_speed;  /* # of ticks between frames */
    unsigned long fhd_next;
    unsigned long fhd_frit;
    char fhd_expand[FHD_EXPAND_SIZE];
};

#define FR_EXPAND_SIZE 8
struct frame_header 
{
    unsigned long fr_size;       /* Frame size in bytes */
    int fr_magic;     /* 0xf1fa */
    int fr_chunks;    /* Number of chunks */
    char fr_expand[FR_EXPAND_SIZE];
};

struct chunk_header
{
    unsigned long ch_bytes;    /* # of bytes in this chunk */
    int ch_type;    /* Type of chunk */
};

#define FLI_256_COLOR 4    /* Compressed color map (8 bit)*/
#define FLI_DELTA 7     /* Wordwise run-lenght compressed frame */
#define FLI_COLOR 11    /* Compressed color map (6 bit)*/
#define FLI_LC    12    /* Line, compressed */
#define FLI_BLACK 13    /* Set whole screen black */
#define FLI_BRUN  15    /* Bytewise run-length compression-1st frame only */
#define FLI_COPY  16    /* Uncompressed 64k to follow */

#define FLI_SYNC  255   /* Sent between each frame (NOT in .fli file) */

#define FLI_MAGIC 0xaf11
#define FLC_MAGIC 0xaf12		/* flc magic */

#define MAXCOL 256

#define SIZE_HEADER 128
#define SIZE_FHEADER 16
#define SIZE_CHEADER 6

#define grab_short(p,l,h)\
    (((((unsigned char *)(p))[l] & 0x000000ff) + ((((unsigned char *)p)[h] & 0x000000ff) <<8)))
#define get_long(p) ((grab_short(p,2,3)<<16) + grab_short(p,0,1))
#define get_short(p) (grab_short(p,0,1)) & 0x0000ffff

#define SHORTSIZE 2
#define LONGSIZE 4

#ifdef USE_MEMSET
#define bcopy(a,b,n) memcpy(b,a,n)
#define bzero(a,n) memset(a,0,n)
#endif

/* for AmigaDOS compatibility */
#define xferror(str) fprintf(stderr, str)
