This commit is contained in:
Daveo 2001-05-14 19:40:30 +00:00
parent 8bbc516b36
commit 488c311c93
5 changed files with 87 additions and 104 deletions

View File

@ -6,19 +6,21 @@
#include "mem\memory.h"
#include "fileio\fileio.h"
#include "utils\utils.h"
#include "utils\pak.h"
//#include "utils\pak.h"
#include "gfx\prim.h"
#include "gfx\actor.h"
#include "gfx\otpos.h"
#include "gfx\animtex.h"
#include <dstructs.h>
/*****************************************************************************/
const int BBOX_ADJ=4;
/*****************************************************************************/
CActorCache CActorPool::Cache;
sActorPool *CActorPool::ActorList,*CActorPool::LastActor;
u8 *CActorCache::UnpackBuffer;
/*****************************************************************************/
/*** Cache *******************************************************************/
/*****************************************************************************/
@ -28,8 +30,6 @@ CActorCache::CActorCache()
{
SlotList[i].ListMem=0;
}
UnpackBuffer=0;
}
/*****************************************************************************/
@ -37,23 +37,6 @@ CActorCache::~CActorCache()
{
}
/*****************************************************************************/
int CActorCache::GetSizeType(int Size)
{
// if (Size<= 16) return(16);
// if (Size<= 32) return(32);
// if (Size<= 64) return(64);
// if (Size<=128) return(128);
// if (Size<=256) return(256);
return((Size+15)&-16);
// Size>>=4;
// Size<<=4;
// return(Size);
ASSERT(!"SPRITE SIZE NOT SUPPORTED");
return(-1);
}
/*****************************************************************************/
int CActorCache::ReAllocSlot(int W,int H)
{
@ -248,7 +231,7 @@ int MaxH=0;
if (MaxH<SlotList[i].Height) MaxH=SlotList[i].Height;
InitCache(i,TPW);
}
UnpackBuffer=(u8*)MemAlloc(MaxW*MaxH,"UnpackBuffer");
CPakTex::Init(MaxW*MaxH);
}
/*****************************************************************************/
@ -277,9 +260,9 @@ sPoolNode *List;
int TexX=CACHE_X+CurrentTPX+(U>>2);
int TexY=CACHE_Y+V;
List->Actor=(FileEquate)0;
List->TexX=TexX;
List->TexY=TexY;
List->Frame=0;
List->DstRect.x=TexX;
List->DstRect.y=TexY;
List->U=U&255;
List->V=V&255;
List->TPage=getTPage(0,0,TexX,TexY);
@ -306,8 +289,7 @@ void CActorCache::Reset()
SlotList[i].Width=0;
SlotList[i].Height=0;
}
if (UnpackBuffer) MemFree(UnpackBuffer);
UnpackBuffer=0;
CPakTex::Shutdown();
CurrentTPX=0;
CurrentPalette=0;
@ -513,13 +495,13 @@ sActorPool *Actor=ActorList;
while (Actor)
{
// Actor->LastCache.Head=0;//Actor->LocalCache.Head;
// Actor->LastCache.Tail=0;//Actor->LocalCache.Tail;
Actor->LastCache.Head=Actor->LocalCache.Head;
Actor->LastCache.Tail=Actor->LocalCache.Tail;
CActorCache::AddNodeList(&Actor->LocalCache ,Actor->GlobalCache);
Actor->LocalCache.Head=0;
Actor->LocalCache.Tail=0;
// ASSERT(Actor->GlobalCache->Head);
// ASSERT(Actor->GlobalCache->Tail);
ASSERT(Actor->GlobalCache->Head);
ASSERT(Actor->GlobalCache->Tail);
Actor=Actor->Next;
}
/*
@ -567,7 +549,6 @@ u16 ThisFrame=ThisAnim->Anim[Frame];
}
/*****************************************************************************/
const int BBOX_ADJ=4;
POLY_FT4 *CActorGfx::Render(DVECTOR &Pos,int Anim,int Frame,bool XFlip,bool YFlip)
{
sPoolNode *ThisNode,*FindNode;
@ -580,7 +561,7 @@ POLY_FT4 *Ft4;
FindNode=PoolEntry->LocalCache.Head;
while (FindNode)
{ // Try local Cache (From Head forward)
if (FindNode->Actor==PoolEntry->Filename && FindNode->Anim==Anim && FindNode->Frame==Frame)
if (FindNode->Frame==CurrentFrame)
{
ThisNode=FindNode;
break;
@ -594,7 +575,7 @@ POLY_FT4 *Ft4;
FindNode=PoolEntry->LastCache.Head;
while (FindNode)
{
if (FindNode->Actor==PoolEntry->Filename && FindNode->Anim==Anim && FindNode->Frame==Frame)
if (FindNode->Frame==CurrentFrame)
{
ThisNode=FindNode;
CActorCache::RemoveNode(ThisNode,PoolEntry->GlobalCache);
@ -613,7 +594,7 @@ POLY_FT4 *Ft4;
FindNode=PoolEntry->GlobalCache->Tail;
while (FindNode)
{
if (FindNode->Actor==PoolEntry->Filename && FindNode->Anim==Anim && FindNode->Frame==Frame)
if (FindNode->Frame==CurrentFrame)
{
ThisNode=FindNode;
CActorCache::RemoveNode(ThisNode,PoolEntry->GlobalCache);
@ -630,18 +611,12 @@ POLY_FT4 *Ft4;
ThisNode=CActorCache::RemoveHeadNode(PoolEntry->GlobalCache);
ASSERT(ThisNode);
CActorCache::AddNode(ThisNode,&PoolEntry->LocalCache);
RECT R;
ThisNode->Actor=PoolEntry->Filename;
ThisNode->Anim=Anim;
ThisNode->Frame=Frame;
ThisNode->Frame=CurrentFrame;
PAK_doUnpak(CActorCache::UnpackBuffer,CurrentFrame->PAKSpr);
R.x=ThisNode->TexX;
R.y=ThisNode->TexY;
R.w=CurrentFrame->W>>2; // div 4 cos 16 color
R.h=CurrentFrame->H;
LoadImage( &R, (u32*)CActorCache::UnpackBuffer);
ThisNode->DstRect.w=CurrentFrame->W>>2; // div 4 cos 16 color
ThisNode->DstRect.h=CurrentFrame->H;
CPakTex::Add(CurrentFrame->PAKSpr,&ThisNode->DstRect);
}
Ft4=GetPrimFT4();

View File

@ -13,14 +13,11 @@
#endif
/*****************************************************************************/
// Pack together Actor anim & frame for quicker check later
struct sPoolNode
{
FileEquate Actor;
u16 Anim;
u16 Frame;
sSpriteFrame *Frame;
RECT DstRect;
u16 TPage;
u16 TexX,TexY;
u8 U,V;
sPoolNode *Prev,*Next;
};
@ -66,19 +63,14 @@ public:
CACHE_Y =256,
CACHE_W =8,
CACHE_H =1,
/*
CACHE_X =512+256,
CACHE_Y =256,
CACHE_W =4,
CACHE_H =1,
*/
CACHE_PALX =CACHE_X,
CACHE_PALY =510,
CACHE_PALW =64,
CACHE_PALH =1,
CACHE_TYPE_MAX =8,
};
CActorCache();
@ -96,20 +88,18 @@ static sPoolNode *RemoveHeadNode(sNodeList *Root);
static void RemoveNode(sPoolNode *Node,sNodeList *Root);
static void AddNode(sPoolNode *Node,sNodeList *Root);
static void AddNodeList(sNodeList *Src,sNodeList *Dst);
static u8 *UnpackBuffer;
protected:
int ReAllocSlot(int W,int H);
int GetSlot(int W,int H);
void InitCache(int Type,int Count);
int GetSizeType(int Size);
int GetSizeType(int Size) {return((Size+15)&-16);}
sPoolSlot SlotList[CACHE_TYPE_MAX];
int CurrentTPX;
int CurrentPalette;
int SlotCount;
};
/*****************************************************************************/
@ -133,6 +123,7 @@ static void AddActor(sActorPool *ThisActor);
static CActorCache Cache;
static sActorPool *ActorList,*LastActor;
};
/*****************************************************************************/

View File

@ -9,13 +9,16 @@
#include "gfx\animtex.h"
#include "gfx\tpage.h"
#include "utils\utils.h"
#include "utils\pak.h"
#ifndef __SYSTEM_GSTATE_H__
#include "system\gstate.h"
#endif
CAnimTex *AnimTexList=0;
CMoveTex CMoveTex::MoveTexList[CMoveTex::MOVETEX_MAX];
CPakTex CPakTex::PakTexList[CPakTex::PAKTEX_MAX];
int CPakTex::PakTexCount;
u8 *CPakTex::UnpackBuffer;
/*****************************************************************************/
CAnimTex::CAnimTex()
@ -144,43 +147,54 @@ int Time = GameState::getFramesSinceLast();
ThisTex->Count%=(ThisTex->Rect.h<<2);
ThisTex=ThisTex->NextTex;
}
CMoveTex::MoveTex();
}
/*****************************************************************************/
/*****************************************************************************/
/*** Pak Tex Stuff ***********************************************************/
/*****************************************************************************/
/*
void CMoveTex::Add(sTexInfo &SrcFrame,sTexInfo &DstFrame)
/*****************************************************************************/
CPakTex::CPakTex()
{
int Idx;
for (Idx=0; Idx<MOVETEX_MAX && MoveTexList[Idx].Src; Idx++);
ASSERT(Idx<MOVETEX_MAX);
CMoveTex &ThisTex=MoveTexList[Idx];
ThisTex.Src=&SrcFrame;
ThisTex.Dst=&DstFrame;
PakTexCount=0;
UnpackBuffer=0;
}
*/
/*****************************************************************************/
void CMoveTex::MoveTex()
{
/*
CMoveTex *ThisTex=MoveTexList,*NextTex;
for (int Idx=0; Idx<MOVETEX_MAX; Idx++)
/*****************************************************************************/
void CPakTex::Init(int MaxSize)
{
ASSERT(UnpackBuffer==0);
UnpackBuffer=(u8*)MemAlloc(MaxSize,"CPakTex::UnpackBuffer");
PakTexCount=0;
}
/*****************************************************************************/
void CPakTex::Shutdown()
{
if (UnpackBuffer) MemFree(UnpackBuffer);
UnpackBuffer=0;
}
/*****************************************************************************/
void CPakTex::Add(u8 *PakSpr,RECT *DstRect)
{
ASSERT(PakTexCount<PAKTEX_MAX);
PakTexList[PakTexCount].PakSpr=PakSpr;
PakTexList[PakTexCount].DstRect=DstRect;
PakTexCount++;
}
/*****************************************************************************/
void CPakTex::DMAPakTex()
{
for (int i=0; i<PakTexCount; i++)
{
CMoveTex &ThisTex=MoveTexList[Idx];
if (!ThisTex.Src) return;
MoveImage((RECT*)ThisTex.Src,ThisTex.Dst->x,ThisTex.Dst->y);
ThisTex.Src=0;
ASSERT(UnpackBuffer);
PAK_doUnpak(UnpackBuffer,PakTexList[i].PakSpr);
LoadImage( PakTexList[i].DstRect, (u32*)UnpackBuffer);
}
*/
PakTexCount=0;
}
/*****************************************************************************/

View File

@ -32,26 +32,28 @@ private:
};
/*****************************************************************************/
class CMoveTex
class CPakTex
{
public:
enum
{
MOVETEX_MAX=16,
PAKTEX_MAX=16,
};
CMoveTex()
{
// Src=0;
}
//static void Add(sTexInfo &SrcFrame,sTexInfo &DstFrame);
static void MoveTex();
CPakTex();
static void Init(int MaxSize);
static void Shutdown();
static void Add(u8 *PakSpr,RECT *DstRect);
static void DMAPakTex();
protected:
u8 *PakSpr;
RECT *DstRect;
private:
// sTexInfo *Src,*Dst;
static CMoveTex MoveTexList[];
static CPakTex PakTexList[];
static int PakTexCount;
static u8 *UnpackBuffer;
};
/*****************************************************************************/

View File

@ -44,6 +44,7 @@ void PrimInit()
void PrimDisplay()
{
CAnimTex::AnimateTex();
CPakTex::DMAPakTex();
UnlinkOTagR(BaseOtPtr, MAX_OT_ALL, &DmaStart[PrimFlipFlag]);
#ifdef USE_NTAGS