This commit is contained in:
parent
000a914914
commit
4cbe1ef5dd
3 changed files with 31 additions and 32 deletions
|
@ -16,7 +16,7 @@
|
|||
CActorCache CActorPool::Cache;
|
||||
sActorPool *CActorPool::ActorList,*CActorPool::LastActor;
|
||||
|
||||
u8 CActorGfx::UnpackBuffer[CActorCache::MAX_ACTOR_SIZE];
|
||||
u8 *CActorCache::UnpackBuffer;
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Cache *******************************************************************/
|
||||
|
@ -25,8 +25,10 @@ CActorCache::CActorCache()
|
|||
{
|
||||
for (int i=0;i<CACHE_TYPE_MAX; i++)
|
||||
{
|
||||
SlotList[i].NodeList.List=0;
|
||||
SlotList[i].ListMem=0;
|
||||
}
|
||||
UnpackBuffer=0;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -135,12 +137,16 @@ int Slot=GetSlot(W,H);
|
|||
void CActorCache::AllocCache()
|
||||
{
|
||||
int TPW=CACHE_W/SlotCount;
|
||||
int MaxW=0;
|
||||
int MaxH=0;
|
||||
|
||||
for (int i=0; i<SlotCount; i++)
|
||||
{
|
||||
// printf("Slot %i: (%i) %i %i=%i\n",i,SlotList[i].RefCount,SlotList[i].Width,SlotList[i].Height,SlotList[i].FrameCount);
|
||||
if (MaxW<SlotList[i].Width) MaxW=SlotList[i].Width;
|
||||
if (MaxH<SlotList[i].Height) MaxH=SlotList[i].Height;
|
||||
InitCache(i,TPW);
|
||||
}
|
||||
UnpackBuffer=(u8*)MemAlloc(MaxW*MaxH,"UnpackBuffer");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -155,7 +161,8 @@ sPoolNode *List;
|
|||
|
||||
// Init List
|
||||
|
||||
List=(sPoolNode*)MemAlloc(Total*sizeof(sPoolNode),"CacheNodeList");
|
||||
ThisSlot->ListMem=(u8*)MemAlloc(Total*sizeof(sPoolNode),"CacheNodeList");
|
||||
List=(sPoolNode*)ThisSlot->ListMem;
|
||||
|
||||
// Create List Entries
|
||||
for (int Y=0; Y<H; Y++)
|
||||
|
@ -187,7 +194,8 @@ void CActorCache::Reset()
|
|||
// Free and init lists
|
||||
for (int i=0;i<CACHE_TYPE_MAX; i++)
|
||||
{
|
||||
if (SlotList[i].NodeList.List) MemFree(SlotList[i].NodeList.List);
|
||||
if (SlotList[i].ListMem) MemFree(SlotList[i].ListMem);
|
||||
SlotList[i].ListMem=0;
|
||||
SlotList[i].NodeList.List=0;
|
||||
SlotList[i].NodeList.LastNode=0;
|
||||
SlotList[i].RefCount=0;
|
||||
|
@ -195,15 +203,8 @@ void CActorCache::Reset()
|
|||
SlotList[i].Width=0;
|
||||
SlotList[i].Height=0;
|
||||
}
|
||||
|
||||
// Init VRam Table
|
||||
for (int Y=0; Y<CACHE_TABLE_H; Y++)
|
||||
{
|
||||
for (int X=0; X<CACHE_TABLE_W; X++)
|
||||
{
|
||||
SlotTable[X][Y]=0;
|
||||
}
|
||||
}
|
||||
if (UnpackBuffer) MemFree(UnpackBuffer);
|
||||
UnpackBuffer=0;
|
||||
|
||||
CurrentTPX=0;
|
||||
CurrentPalette=0;
|
||||
|
@ -335,7 +336,7 @@ sActorPool *CActorPool::LoadActor(FileEquate Filename)
|
|||
int i;
|
||||
int TotalFrames=0;
|
||||
|
||||
sSpriteAnimBank *Spr=(sSpriteAnimBank*)CFileIO::loadFile(Filename);
|
||||
sSpriteAnimBank *Spr=(sSpriteAnimBank*)CFileIO::loadFile(Filename,"ActorGfx");
|
||||
|
||||
// printf("Add Actor %i\n",(int)Filename);
|
||||
Spr->AnimList=(sSpriteAnim*) MakePtr(Spr,(int)Spr->AnimList);
|
||||
|
@ -436,8 +437,6 @@ sPoolNode *ThisNode;;
|
|||
POLY_FT4 *Ft4;
|
||||
|
||||
// Is cached?
|
||||
// if(this->PoolEntry->Filename==ACTORS_SPONGEBOB_SBK) return(0);
|
||||
|
||||
ThisNode=PoolEntry->ThisCache.List;
|
||||
while (ThisNode)
|
||||
{
|
||||
|
@ -454,12 +453,12 @@ POLY_FT4 *Ft4;
|
|||
ThisNode->Anim=Anim;
|
||||
ThisNode->Frame=Frame;
|
||||
|
||||
PAK_doUnpak(UnpackBuffer,FrameGfx->PAKSpr);
|
||||
PAK_doUnpak(CActorCache::UnpackBuffer,FrameGfx->PAKSpr);
|
||||
R.x=ThisNode->TexX;
|
||||
R.y=ThisNode->TexY;
|
||||
R.w=FrameGfx->W>>2; // div 4 cos 16 color
|
||||
R.h=FrameGfx->H;
|
||||
LoadImage( &R, (u32*)UnpackBuffer);
|
||||
LoadImage( &R, (u32*)CActorCache::UnpackBuffer);
|
||||
}
|
||||
|
||||
Ft4=GetPrimFT4();
|
||||
|
@ -481,6 +480,14 @@ POLY_FT4 *Ft4;
|
|||
setRGB0(sFt4,0,0,0);
|
||||
AddPrimToList(sFt4,ActorOT);
|
||||
}
|
||||
// Set BBox
|
||||
int HalfW=FrameGfx->W>>1;
|
||||
int HalfH=FrameGfx->H>>1;
|
||||
|
||||
BBox.XMin=-HalfW;
|
||||
BBox.XMax=+HalfW;
|
||||
BBox.YMin=-HalfH;
|
||||
BBox.YMax=+HalfH;
|
||||
|
||||
return(Ft4);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ struct sPoolSlot
|
|||
u16 RefCount;
|
||||
u16 FrameCount;
|
||||
sNodeList NodeList;
|
||||
u8 *ListMem;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -69,14 +70,7 @@ public:
|
|||
CACHE_PALW =64,
|
||||
CACHE_PALH =1,
|
||||
|
||||
CACHE_TABLE_W =(TPAGE_W*CACHE_W)/32,
|
||||
CACHE_TABLE_H =(TPAGE_H*CACHE_H)/32,
|
||||
|
||||
CACHE_TYPE_MAX =8,
|
||||
|
||||
MAX_ACTOR_W =128,
|
||||
MAX_ACTOR_H =128,
|
||||
MAX_ACTOR_SIZE =MAX_ACTOR_W*MAX_ACTOR_H,
|
||||
};
|
||||
|
||||
CActorCache();
|
||||
|
@ -91,19 +85,19 @@ public:
|
|||
static sPoolNode *RemoveHeadNode(sNodeList *Root);
|
||||
static void RemoveNode(sPoolNode *Node,sNodeList *Root);
|
||||
static void AddNode(sPoolNode *Node,sNodeList *Root);
|
||||
static u8 *UnpackBuffer;
|
||||
|
||||
protected:
|
||||
int GetSlot(int W,int H);
|
||||
void InitCache(int Type,int Count);
|
||||
int GetSizeType(int Size);
|
||||
|
||||
|
||||
u8 SlotTable[CACHE_TABLE_W][CACHE_TABLE_H];
|
||||
sPoolSlot SlotList[CACHE_TYPE_MAX];
|
||||
|
||||
int CurrentTPX;
|
||||
int CurrentPalette;
|
||||
int SlotCount;
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -136,7 +130,6 @@ public:
|
|||
{
|
||||
ShadowXOfs =32,
|
||||
ShadowYOfs =32,
|
||||
|
||||
};
|
||||
|
||||
CActorGfx(sActorPool *ThisActor);
|
||||
|
@ -152,8 +145,7 @@ protected:
|
|||
sSpriteFrame *GetFrame(int Anim,int Frame);
|
||||
|
||||
sActorPool *PoolEntry;
|
||||
|
||||
static u8 UnpackBuffer[CActorCache::MAX_ACTOR_SIZE];
|
||||
sBBox BBox;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#endif
|
||||
|
||||
#define MAX_OT (16)
|
||||
#define MAX_PRIMS (1024*4)
|
||||
#define MAX_PRIMS (1024*2)
|
||||
|
||||
//#define USE_NTAGS 1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue