SBSPSS/source/gfx/actor.h

132 lines
2.6 KiB
C
Raw Normal View History

2001-04-01 22:22:49 +02:00
/*******************/
/*** Actor Stuff ***/
/*******************/
2001-04-01 09:22:30 +02:00
#ifndef __ACTOR_HEADER__
#define __ACTOR_HEADER__
#include "system\global.h"
#include <dstructs.h>
#ifndef __BigLump_H__
#include <biglump.h>
#endif
2001-04-09 23:27:21 +02:00
struct sSlot
{
u16 W,H;
};
2001-04-01 09:22:30 +02:00
/*****************************************************************************/
2001-04-09 23:27:21 +02:00
struct sActorPool
{
FileEquate Filename;
sSpriteAnimBank *SpriteBank;
u16 RefCount;
u16 Clut;
};
/*****************************************************************************/
class CSlotCache
2001-04-01 09:22:30 +02:00
{
public:
2001-04-09 23:27:21 +02:00
enum
{
DYN_W =64,
DYN_H =64,
DYN_TPAGEW =4*256,
DYN_TPAGEH =1*256,
DYN_SLOTW =(DYN_TPAGEW/DYN_W),
DYN_SLOTH =(DYN_TPAGEH/DYN_H),
DYN_SLOTX =512+256,
DYN_SLOTY =256,
};
CSlotCache(){};
~CSlotCache(){};
2001-04-01 09:22:30 +02:00
2001-04-09 23:27:21 +02:00
void Init();
bool FindSlot(int SprW,int SprH,u16 &TexX,u16 &TexY,u8 &u,u8 &v);
protected:
bool TakeSlot(int SX,int SY,int SW,int SH);
2001-04-02 22:24:58 +02:00
2001-04-09 23:27:21 +02:00
sSlot Cache[DYN_SLOTW][DYN_SLOTH];
2001-04-01 23:38:59 +02:00
2001-04-01 09:22:30 +02:00
};
/*****************************************************************************/
2001-04-09 23:27:21 +02:00
class CActorGfx;
2001-04-01 22:22:49 +02:00
class CActorPool
2001-04-01 09:22:30 +02:00
{
public:
enum
{
2001-04-10 01:29:26 +02:00
MAX_ACTORS =64,
2001-04-09 23:27:21 +02:00
MAX_ACTOR_SIZE= 128*128,
2001-04-01 09:22:30 +02:00
};
2001-04-04 18:51:04 +02:00
enum ACTOR_TYPE
{
ACTOR_PLAYER = 0,
ACTOR_FRIEND_NPC = 1,
ACTOR_ENEMY_NPC,
2001-04-19 01:12:24 +02:00
ACTOR_ENEMY_GENERATOR_NPC,
2001-04-04 18:51:04 +02:00
ACTOR_UNKNOWN,
};
2001-04-01 09:22:30 +02:00
static void Init();
2001-04-19 18:18:26 +02:00
static void AddActor(FileEquate Filename) {GetActor(Filename);}
2001-04-09 23:27:21 +02:00
static CActorGfx *GetActor(FileEquate Filename);
static void DumpActors();
2001-04-01 09:22:30 +02:00
2001-04-02 20:25:09 +02:00
2001-04-04 18:51:04 +02:00
static ACTOR_TYPE getActorType( int actorNum ) {return actorType[actorNum];}
2001-04-09 23:27:21 +02:00
protected:
static int FindActorInPool(FileEquate Filename);
static int FindFreeActor();
static int LoadActor(FileEquate Filename);
static u16 LoadPalette(sActorPool &ThisActor,int Idx);
static sActorPool ActorPool[];
static ACTOR_TYPE actorType[];
};
/*****************************************************************************/
class CActorGfx
{
public:
CActorGfx();
virtual ~CActorGfx();
void SetData(FileEquate Filename,sSpriteAnimBank *_SpriteBank,u16 _Clut);
static void ResetCache();
POLY_FT4 *Render(DVECTOR &Pos,int Anim,int Frame,bool FlipX=false,bool FlipY=false,bool Shadow=false);
int getFrameCount(int Anim) {return(SpriteBank->AnimList[Anim].FrameCount);}
protected:
void SetUpFT4(POLY_FT4 *Ft4,sSpriteFrame *ThisFrame,int X,int Y,bool XFlip,bool YFlip);
sSpriteFrame *GetFrame(int Anim,int Frame);
sSpriteAnimBank *SpriteBank;
// RECT DrawRect;
u16 Clut;
u16 TPage,TexX,TexY;
u8 U,V;
2001-04-01 09:22:30 +02:00
2001-04-09 23:27:21 +02:00
static CSlotCache SlotCache;
static u8 UnpackBuffer[CActorPool::MAX_ACTOR_SIZE];
2001-04-01 09:22:30 +02:00
2001-04-04 18:51:04 +02:00
2001-04-01 09:22:30 +02:00
};
/*****************************************************************************/
#endif