//---------------------------------------------------------------------------
// Character class
//---------------------------------------------------------------------------

#ifndef __shootpoint
   #define __shootpoint
   typedef struct
   {
      int x;
      int y;
      int GunType;
      int Counter;
   } shootpnt;
#endif

#define MAXACTION       20

#ifndef __player
   #define __player
   typedef struct
   {
      int Score;
      int BulletType;
      int Bullets;
      int Lifepnt;
      int Counter;
      short GunX;
      short GunY;
      short ShotX;
      short ShotY;
      char Grade;
      short Shots;
      short Hits;
      short VictimsMiss;
      char PlayerNbr;
   } PLAYER;
#endif

#ifndef __point
   #define __point
   typedef struct
   {
      int x;
      int y;
   } point;
#endif

//-------------------------------------
// Class definition
//-------------------------------------
class Character
{
   typedef struct
   {
      u_char  ActionType;
      u_char  NumFrame;
      signed  char *OffsetX;
      signed  char *OffsetY;
      u_char  *Animation;
      u_char  *Wait;
      u_char  GunType;
      u_short GunOfsX;
      u_short GunOfsY;
      u_char  DieLink;
      u_char  ShotLink;
      u_char  EndLink;
   } ACTION;

   private:
   u_short *DestClut;
   u_short *ActualClut;
   u_short *OriginalClut;
   short   ClutY;
   u_short NumSprite;
   short   x, y;
   short   scale;
   u_short Lifepnt;
   char    Death;                // Is the character dead (still displayed) ?
   char    Flic;                 // Nbr of flics remained if the char's dead
   u_short SprTPX;
   u_short SprTPY;
   char    SprU;
   char    SprV;
   u_short *SprW;
   u_short *SprH;
   char    *SprCX;
   char    *SprCY;
   int     *SprAddress;
   short   *SprHandle;
   u_short *SprMapSize;
   char    *SprHitW;
   char    *SprHitH;
   int     *SprHitMapAdr;
   char    compressed;
   int     CurrentFrame;
   int     CurrentAction;
   ACTION  *Action;
   u_short NbrAnimation;
   u_short NbrAction;
   char    NewAction;
   short   PrevSprite;
   point   VramMemSpace;
   short   VramMemHandle;
   u_char  ActionBefore;
   u_char  WaitCnt;                     // before changing sprite...
   u_char  Inverse;                     // Normal direction (0) or inverse (1)
   char    depth;
   short   CarLoopX;
   short   CarLoopY;
   short   CarShake;
   char    SfxStart[MAXACTION];
   char    SfxEnd[MAXACTION];
   char    VabStart[MAXACTION];
   char    VabEnd[MAXACTION];
   char    filnam[60];
   char    Blink;                       // To make the character turn white
   char    Blinkable;                   //
   short   GunDeltaX, GunDeltaY;        // If the object is a gun, needs
   u_char  GunMove;                     //  coordinate to make it move down
   short   GunColorChange;              //
   char    BWChangeComplete;            //
   u_short Chrctristic;                 //
   char    ShotToDeath;                 //
   char    Origina;                     //
   char    Projectile;                  //
   char    ActualProjectile;            //
   Character *ProjChar[7];              //
   int     Reappear;                    //
   int     CharNbr;                     //
   int     BossAngle;                   //
   int     BossAngle2;                  //
   int     Bossu;                       //
   int     CarState;                    //
   int     ScaleDest;                   //
   int     ScaleSource;                 //
   int     ScaleActualStep;             //
   int     ScaleTotalStep;              //
   int     MoveDestX, MoveDestY;        //
   int     MoveXSource, MoveYSource;    //
   int     MoveTotalStep;               //
   int     MoveActualStep;              //
   short   SpecificDeath;               //

   public:
   shootpnt ShootPoint;
   RECT     Collisio;
   Character ();
   int  Load (char Filename[], u_long *memptr);
   shootpnt *DrawNextFrame (int bkdx, int bkdy, DoubleBuffer *db, int *sfx, int *vab, int *posi);
   void DrawFrame (int bkdx, int bkdy, DoubleBuffer *db);
   void Set_Frame (int frame);
   void Clear (void);
   void StopAction (void);
   void Set_Location (int coorx, int coory);
   void Scale (int scaling);
   void SetDepth (int dpth);
   int  GetDepth (void);
   void Die (void);
   int  GetHit (int coorx, int coory, PLAYER *plr, int shotforce, Background *bkd, DoubleBuffer *db);
   void SetCenter (int coorx, int coory, int sprnum);
   void DrawSpr (int sprnum, point p, DoubleBuffer *db);
   int  StartAction (int actionnum, int inverse);
   Character *Clone_Character (int pal, u_long *memptr);
   void ReInit (void);
   void Init_Spr_Array (int numsprite, char compress, u_short characte,
                        u_short *sprw, u_short *sprh, char *sprcx, char *sprcy,
                        int *spraddress, short *sprhandle,  u_short *sprmapsize,
                        char *sprhitw, char *sprhith, int *sprhitmapadr);
   void Init_Anim_Array (int nbraction, int nbranimation,
                         ACTION *action, int cluty, u_short *actualclut,
                         u_short *destclut, char sfxstart[], char sfxend[],
                         char vabstart[], char vabend[], int origina);
   int  ChangeClut (int black);
   void LifePoint (int life);
   int  GetLifePoint (void);
   void DumpData (void);
   int  LoadSLK (char filename[], u_long *memptr);
   void Move (int dx, int dy);
   point Coordinate (void);
   void Pop (int actio);
   void TurnWhite (void);
   void MakeBlinkable (void);
   void MakeTranslucent (void);
   void FlushSprFile (int sprnbr);
   void SetCharacteristics (u_short thing);
   int  Characteristic (void);
   int  Collision (RECT *hitbox, int dpth);
   RECT *GetHitBox (void);
   void Reverse (int inv);
   int  HasBeenShot (void);
   int  Dead (void);
   int  Displayed (void);
   void AssignProj (Character *proj);
   void SetCharNbr (char num);
   void BuildDestClut (int typeclut);
   int  GetCharNbr (void);
   void ShakeCar (void);
   void LoadCompressedImage(RECT *rect, int i);
   void ScaleTo (int scaledest, int scalestep);
   void MoveTo (int destx, int desty, int movestep);
   void Relive (void);
   int  GetScale (void);
   void SetDeathAnim (int anim);
};

u_long SprCacheInit(u_long heap);
void SprCacheSetFirst(void);
void SprCacheReset(void);
void SprCacheFlush(void);
short SprCacheHandle(void);
u_long *SprCacheDecompress(short handle, u_char *compressed, int width, int height);
