This commit is contained in:
parent
8bbc516b36
commit
488c311c93
5 changed files with 87 additions and 104 deletions
|
@ -6,19 +6,21 @@
|
||||||
#include "mem\memory.h"
|
#include "mem\memory.h"
|
||||||
#include "fileio\fileio.h"
|
#include "fileio\fileio.h"
|
||||||
#include "utils\utils.h"
|
#include "utils\utils.h"
|
||||||
#include "utils\pak.h"
|
//#include "utils\pak.h"
|
||||||
#include "gfx\prim.h"
|
#include "gfx\prim.h"
|
||||||
#include "gfx\actor.h"
|
#include "gfx\actor.h"
|
||||||
#include "gfx\otpos.h"
|
#include "gfx\otpos.h"
|
||||||
|
#include "gfx\animtex.h"
|
||||||
|
|
||||||
#include <dstructs.h>
|
#include <dstructs.h>
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
const int BBOX_ADJ=4;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CActorCache CActorPool::Cache;
|
CActorCache CActorPool::Cache;
|
||||||
sActorPool *CActorPool::ActorList,*CActorPool::LastActor;
|
sActorPool *CActorPool::ActorList,*CActorPool::LastActor;
|
||||||
|
|
||||||
u8 *CActorCache::UnpackBuffer;
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Cache *******************************************************************/
|
/*** Cache *******************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -28,8 +30,6 @@ CActorCache::CActorCache()
|
||||||
{
|
{
|
||||||
SlotList[i].ListMem=0;
|
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)
|
int CActorCache::ReAllocSlot(int W,int H)
|
||||||
{
|
{
|
||||||
|
@ -248,7 +231,7 @@ int MaxH=0;
|
||||||
if (MaxH<SlotList[i].Height) MaxH=SlotList[i].Height;
|
if (MaxH<SlotList[i].Height) MaxH=SlotList[i].Height;
|
||||||
InitCache(i,TPW);
|
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 TexX=CACHE_X+CurrentTPX+(U>>2);
|
||||||
int TexY=CACHE_Y+V;
|
int TexY=CACHE_Y+V;
|
||||||
|
|
||||||
List->Actor=(FileEquate)0;
|
List->Frame=0;
|
||||||
List->TexX=TexX;
|
List->DstRect.x=TexX;
|
||||||
List->TexY=TexY;
|
List->DstRect.y=TexY;
|
||||||
List->U=U&255;
|
List->U=U&255;
|
||||||
List->V=V&255;
|
List->V=V&255;
|
||||||
List->TPage=getTPage(0,0,TexX,TexY);
|
List->TPage=getTPage(0,0,TexX,TexY);
|
||||||
|
@ -306,8 +289,7 @@ void CActorCache::Reset()
|
||||||
SlotList[i].Width=0;
|
SlotList[i].Width=0;
|
||||||
SlotList[i].Height=0;
|
SlotList[i].Height=0;
|
||||||
}
|
}
|
||||||
if (UnpackBuffer) MemFree(UnpackBuffer);
|
CPakTex::Shutdown();
|
||||||
UnpackBuffer=0;
|
|
||||||
|
|
||||||
CurrentTPX=0;
|
CurrentTPX=0;
|
||||||
CurrentPalette=0;
|
CurrentPalette=0;
|
||||||
|
@ -513,13 +495,13 @@ sActorPool *Actor=ActorList;
|
||||||
|
|
||||||
while (Actor)
|
while (Actor)
|
||||||
{
|
{
|
||||||
// Actor->LastCache.Head=0;//Actor->LocalCache.Head;
|
Actor->LastCache.Head=Actor->LocalCache.Head;
|
||||||
// Actor->LastCache.Tail=0;//Actor->LocalCache.Tail;
|
Actor->LastCache.Tail=Actor->LocalCache.Tail;
|
||||||
CActorCache::AddNodeList(&Actor->LocalCache ,Actor->GlobalCache);
|
CActorCache::AddNodeList(&Actor->LocalCache ,Actor->GlobalCache);
|
||||||
Actor->LocalCache.Head=0;
|
Actor->LocalCache.Head=0;
|
||||||
Actor->LocalCache.Tail=0;
|
Actor->LocalCache.Tail=0;
|
||||||
// ASSERT(Actor->GlobalCache->Head);
|
ASSERT(Actor->GlobalCache->Head);
|
||||||
// ASSERT(Actor->GlobalCache->Tail);
|
ASSERT(Actor->GlobalCache->Tail);
|
||||||
Actor=Actor->Next;
|
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)
|
POLY_FT4 *CActorGfx::Render(DVECTOR &Pos,int Anim,int Frame,bool XFlip,bool YFlip)
|
||||||
{
|
{
|
||||||
sPoolNode *ThisNode,*FindNode;
|
sPoolNode *ThisNode,*FindNode;
|
||||||
|
@ -580,7 +561,7 @@ POLY_FT4 *Ft4;
|
||||||
FindNode=PoolEntry->LocalCache.Head;
|
FindNode=PoolEntry->LocalCache.Head;
|
||||||
while (FindNode)
|
while (FindNode)
|
||||||
{ // Try local Cache (From Head forward)
|
{ // Try local Cache (From Head forward)
|
||||||
if (FindNode->Actor==PoolEntry->Filename && FindNode->Anim==Anim && FindNode->Frame==Frame)
|
if (FindNode->Frame==CurrentFrame)
|
||||||
{
|
{
|
||||||
ThisNode=FindNode;
|
ThisNode=FindNode;
|
||||||
break;
|
break;
|
||||||
|
@ -594,7 +575,7 @@ POLY_FT4 *Ft4;
|
||||||
FindNode=PoolEntry->LastCache.Head;
|
FindNode=PoolEntry->LastCache.Head;
|
||||||
while (FindNode)
|
while (FindNode)
|
||||||
{
|
{
|
||||||
if (FindNode->Actor==PoolEntry->Filename && FindNode->Anim==Anim && FindNode->Frame==Frame)
|
if (FindNode->Frame==CurrentFrame)
|
||||||
{
|
{
|
||||||
ThisNode=FindNode;
|
ThisNode=FindNode;
|
||||||
CActorCache::RemoveNode(ThisNode,PoolEntry->GlobalCache);
|
CActorCache::RemoveNode(ThisNode,PoolEntry->GlobalCache);
|
||||||
|
@ -613,7 +594,7 @@ POLY_FT4 *Ft4;
|
||||||
FindNode=PoolEntry->GlobalCache->Tail;
|
FindNode=PoolEntry->GlobalCache->Tail;
|
||||||
while (FindNode)
|
while (FindNode)
|
||||||
{
|
{
|
||||||
if (FindNode->Actor==PoolEntry->Filename && FindNode->Anim==Anim && FindNode->Frame==Frame)
|
if (FindNode->Frame==CurrentFrame)
|
||||||
{
|
{
|
||||||
ThisNode=FindNode;
|
ThisNode=FindNode;
|
||||||
CActorCache::RemoveNode(ThisNode,PoolEntry->GlobalCache);
|
CActorCache::RemoveNode(ThisNode,PoolEntry->GlobalCache);
|
||||||
|
@ -630,18 +611,12 @@ POLY_FT4 *Ft4;
|
||||||
ThisNode=CActorCache::RemoveHeadNode(PoolEntry->GlobalCache);
|
ThisNode=CActorCache::RemoveHeadNode(PoolEntry->GlobalCache);
|
||||||
ASSERT(ThisNode);
|
ASSERT(ThisNode);
|
||||||
CActorCache::AddNode(ThisNode,&PoolEntry->LocalCache);
|
CActorCache::AddNode(ThisNode,&PoolEntry->LocalCache);
|
||||||
RECT R;
|
|
||||||
|
|
||||||
ThisNode->Actor=PoolEntry->Filename;
|
ThisNode->Frame=CurrentFrame;
|
||||||
ThisNode->Anim=Anim;
|
|
||||||
ThisNode->Frame=Frame;
|
ThisNode->DstRect.w=CurrentFrame->W>>2; // div 4 cos 16 color
|
||||||
|
ThisNode->DstRect.h=CurrentFrame->H;
|
||||||
PAK_doUnpak(CActorCache::UnpackBuffer,CurrentFrame->PAKSpr);
|
CPakTex::Add(CurrentFrame->PAKSpr,&ThisNode->DstRect);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ft4=GetPrimFT4();
|
Ft4=GetPrimFT4();
|
||||||
|
|
|
@ -13,16 +13,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Pack together Actor anim & frame for quicker check later
|
|
||||||
struct sPoolNode
|
struct sPoolNode
|
||||||
{
|
{
|
||||||
FileEquate Actor;
|
sSpriteFrame *Frame;
|
||||||
u16 Anim;
|
RECT DstRect;
|
||||||
u16 Frame;
|
u16 TPage;
|
||||||
u16 TPage;
|
u8 U,V;
|
||||||
u16 TexX,TexY;
|
sPoolNode *Prev,*Next;
|
||||||
u8 U,V;
|
|
||||||
sPoolNode *Prev,*Next;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sNodeList
|
struct sNodeList
|
||||||
|
@ -66,19 +63,14 @@ public:
|
||||||
CACHE_Y =256,
|
CACHE_Y =256,
|
||||||
CACHE_W =8,
|
CACHE_W =8,
|
||||||
CACHE_H =1,
|
CACHE_H =1,
|
||||||
/*
|
|
||||||
CACHE_X =512+256,
|
|
||||||
CACHE_Y =256,
|
|
||||||
CACHE_W =4,
|
|
||||||
CACHE_H =1,
|
|
||||||
|
|
||||||
*/
|
|
||||||
CACHE_PALX =CACHE_X,
|
CACHE_PALX =CACHE_X,
|
||||||
CACHE_PALY =510,
|
CACHE_PALY =510,
|
||||||
CACHE_PALW =64,
|
CACHE_PALW =64,
|
||||||
CACHE_PALH =1,
|
CACHE_PALH =1,
|
||||||
|
|
||||||
CACHE_TYPE_MAX =8,
|
CACHE_TYPE_MAX =8,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CActorCache();
|
CActorCache();
|
||||||
|
@ -96,20 +88,18 @@ static sPoolNode *RemoveHeadNode(sNodeList *Root);
|
||||||
static void RemoveNode(sPoolNode *Node,sNodeList *Root);
|
static void RemoveNode(sPoolNode *Node,sNodeList *Root);
|
||||||
static void AddNode(sPoolNode *Node,sNodeList *Root);
|
static void AddNode(sPoolNode *Node,sNodeList *Root);
|
||||||
static void AddNodeList(sNodeList *Src,sNodeList *Dst);
|
static void AddNodeList(sNodeList *Src,sNodeList *Dst);
|
||||||
static u8 *UnpackBuffer;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int ReAllocSlot(int W,int H);
|
int ReAllocSlot(int W,int H);
|
||||||
int GetSlot(int W,int H);
|
int GetSlot(int W,int H);
|
||||||
void InitCache(int Type,int Count);
|
void InitCache(int Type,int Count);
|
||||||
int GetSizeType(int Size);
|
int GetSizeType(int Size) {return((Size+15)&-16);}
|
||||||
|
|
||||||
sPoolSlot SlotList[CACHE_TYPE_MAX];
|
sPoolSlot SlotList[CACHE_TYPE_MAX];
|
||||||
|
|
||||||
int CurrentTPX;
|
int CurrentTPX;
|
||||||
int CurrentPalette;
|
int CurrentPalette;
|
||||||
int SlotCount;
|
int SlotCount;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -133,6 +123,7 @@ static void AddActor(sActorPool *ThisActor);
|
||||||
|
|
||||||
static CActorCache Cache;
|
static CActorCache Cache;
|
||||||
static sActorPool *ActorList,*LastActor;
|
static sActorPool *ActorList,*LastActor;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -9,13 +9,16 @@
|
||||||
#include "gfx\animtex.h"
|
#include "gfx\animtex.h"
|
||||||
#include "gfx\tpage.h"
|
#include "gfx\tpage.h"
|
||||||
#include "utils\utils.h"
|
#include "utils\utils.h"
|
||||||
|
#include "utils\pak.h"
|
||||||
|
|
||||||
#ifndef __SYSTEM_GSTATE_H__
|
#ifndef __SYSTEM_GSTATE_H__
|
||||||
#include "system\gstate.h"
|
#include "system\gstate.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CAnimTex *AnimTexList=0;
|
CAnimTex *AnimTexList=0;
|
||||||
CMoveTex CMoveTex::MoveTexList[CMoveTex::MOVETEX_MAX];
|
CPakTex CPakTex::PakTexList[CPakTex::PAKTEX_MAX];
|
||||||
|
int CPakTex::PakTexCount;
|
||||||
|
u8 *CPakTex::UnpackBuffer;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CAnimTex::CAnimTex()
|
CAnimTex::CAnimTex()
|
||||||
|
@ -144,43 +147,54 @@ int Time = GameState::getFramesSinceLast();
|
||||||
ThisTex->Count%=(ThisTex->Rect.h<<2);
|
ThisTex->Count%=(ThisTex->Rect.h<<2);
|
||||||
ThisTex=ThisTex->NextTex;
|
ThisTex=ThisTex->NextTex;
|
||||||
}
|
}
|
||||||
CMoveTex::MoveTex();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
/*** Pak Tex Stuff ***********************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*
|
/*****************************************************************************/
|
||||||
void CMoveTex::Add(sTexInfo &SrcFrame,sTexInfo &DstFrame)
|
CPakTex::CPakTex()
|
||||||
{
|
{
|
||||||
int Idx;
|
PakTexCount=0;
|
||||||
|
UnpackBuffer=0;
|
||||||
for (Idx=0; Idx<MOVETEX_MAX && MoveTexList[Idx].Src; Idx++);
|
|
||||||
|
|
||||||
ASSERT(Idx<MOVETEX_MAX);
|
|
||||||
|
|
||||||
CMoveTex &ThisTex=MoveTexList[Idx];
|
|
||||||
|
|
||||||
ThisTex.Src=&SrcFrame;
|
|
||||||
ThisTex.Dst=&DstFrame;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*****************************************************************************/
|
|
||||||
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];
|
ASSERT(UnpackBuffer);
|
||||||
if (!ThisTex.Src) return;
|
PAK_doUnpak(UnpackBuffer,PakTexList[i].PakSpr);
|
||||||
|
LoadImage( PakTexList[i].DstRect, (u32*)UnpackBuffer);
|
||||||
MoveImage((RECT*)ThisTex.Src,ThisTex.Dst->x,ThisTex.Dst->y);
|
|
||||||
ThisTex.Src=0;
|
|
||||||
}
|
}
|
||||||
*/
|
PakTexCount=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -32,26 +32,28 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CMoveTex
|
|
||||||
|
class CPakTex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MOVETEX_MAX=16,
|
PAKTEX_MAX=16,
|
||||||
};
|
};
|
||||||
|
|
||||||
CMoveTex()
|
CPakTex();
|
||||||
{
|
|
||||||
// Src=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//static void Add(sTexInfo &SrcFrame,sTexInfo &DstFrame);
|
|
||||||
static void MoveTex();
|
|
||||||
|
|
||||||
|
static void Init(int MaxSize);
|
||||||
|
static void Shutdown();
|
||||||
|
static void Add(u8 *PakSpr,RECT *DstRect);
|
||||||
|
static void DMAPakTex();
|
||||||
|
protected:
|
||||||
|
u8 *PakSpr;
|
||||||
|
RECT *DstRect;
|
||||||
private:
|
private:
|
||||||
// sTexInfo *Src,*Dst;
|
static CPakTex PakTexList[];
|
||||||
|
static int PakTexCount;
|
||||||
static CMoveTex MoveTexList[];
|
static u8 *UnpackBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -44,6 +44,7 @@ void PrimInit()
|
||||||
void PrimDisplay()
|
void PrimDisplay()
|
||||||
{
|
{
|
||||||
CAnimTex::AnimateTex();
|
CAnimTex::AnimateTex();
|
||||||
|
CPakTex::DMAPakTex();
|
||||||
UnlinkOTagR(BaseOtPtr, MAX_OT_ALL, &DmaStart[PrimFlipFlag]);
|
UnlinkOTagR(BaseOtPtr, MAX_OT_ALL, &DmaStart[PrimFlipFlag]);
|
||||||
|
|
||||||
#ifdef USE_NTAGS
|
#ifdef USE_NTAGS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue