This commit is contained in:
Daveo 2001-05-05 18:38:24 +00:00
parent 9bd6bfaa2c
commit c1cb9f37dc
2 changed files with 46 additions and 6 deletions

View File

@ -54,6 +54,43 @@ int CActorCache::GetSizeType(int Size)
return(-1); return(-1);
} }
/*****************************************************************************/
int CActorCache::ReAllocSlot(int W,int H)
{
int i;
int Slot=-1;
int SlotW=+32000,SlotH=+32000;
// Find best slot which fits in
// ASSERT(!"ReAlloc");
for (i=0;i<SlotCount; i++)
{
int ThisW=(SlotList[i].Width-W);
int ThisH=(SlotList[i].Height-H);
if (ThisW<SlotW || ThisH<SlotH)
{
Slot=i;
SlotW=ThisW;
SlotH=ThisH;
}
}
if (SlotList[Slot].Width<W)
{
// printf("Adjusted Slot Width from %i to %i\n",SlotList[Slot].Width,W);
SlotList[Slot].Width=W;
}
if (SlotList[Slot].Height<H)
{
// printf("Adjusted Slot Height from %i to %i\n",SlotList[Slot].Height,H);
SlotList[Slot].Height=H;
}
return(Slot);
}
/*****************************************************************************/ /*****************************************************************************/
int CActorCache::GetSlot(int W,int H) int CActorCache::GetSlot(int W,int H)
{ {
@ -70,15 +107,17 @@ int Slot=0;
if (!Slot) if (!Slot)
{ // Use New Slot { // Use New Slot
ASSERT(SlotCount!=CACHE_TYPE_MAX); if (SlotCount>=CACHE_TYPE_MAX)
{ // No free slots, grab an existing one, and alter size to fit
Slot=ReAllocSlot(W,H);
}
else
{
Slot=SlotCount; Slot=SlotCount;
SlotList[Slot].Width=W; SlotList[Slot].Width=W;
SlotList[Slot].Height=H; SlotList[Slot].Height=H;
printf("Get Slot %i Slots\n",SlotCount);
/*bodge*/ //if (SlotCount<CACHE_W-1)
SlotCount++; SlotCount++;
}
} }
SlotList[Slot].RefCount++; SlotList[Slot].RefCount++;
@ -179,7 +218,7 @@ int MaxH=0;
/* if (TPW<1) */TPW=1; /* if (TPW<1) */TPW=1;
ASSERT(SlotCount<CACHE_W); ASSERT(SlotCount<=CACHE_W);
for (int i=0; i<SlotCount; i++) for (int i=0; i<SlotCount; i++)
{ {

View File

@ -95,6 +95,7 @@ static void AddNodeList(sNodeList *Src,sNodeList *Dst);
static u8 *UnpackBuffer; static u8 *UnpackBuffer;
protected: protected:
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);