This commit is contained in:
parent
7b8e1fe8c4
commit
3aeddaf979
9 changed files with 111 additions and 235 deletions
|
@ -9,7 +9,7 @@
|
|||
#include "system\vid.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
sOT *OtList[2],*BaseOtPtr,*GUIOtPtr,*OtPtr;
|
||||
sOT *OtList[2],*BaseOtPtr,*OtPtr;
|
||||
u32 DmaStart[2];
|
||||
u8 *PrimBuffer[2],*PrimListStart,*PrimListEnd;
|
||||
u8 *CurrPrim,*EndPrim;
|
||||
|
@ -26,8 +26,7 @@ void PrimInit()
|
|||
|
||||
PrimFlipFlag=0;
|
||||
BaseOtPtr=(sOT*)OtList[PrimFlipFlag];
|
||||
GUIOtPtr=BaseOtPtr;
|
||||
OtPtr=GUIOtPtr+MAX_OT_GUI;
|
||||
OtPtr=BaseOtPtr;
|
||||
CurrPrim=(u8*)PrimBuffer[PrimFlipFlag];
|
||||
EndPrim=CurrPrim+PRIMPOOL_SIZE;
|
||||
|
||||
|
@ -60,8 +59,7 @@ void PrimDisplay()
|
|||
|
||||
PrimFlipFlag^=1;
|
||||
BaseOtPtr=(sOT*)OtList[PrimFlipFlag];
|
||||
GUIOtPtr=BaseOtPtr;
|
||||
OtPtr=GUIOtPtr+MAX_OT_GUI;
|
||||
OtPtr=BaseOtPtr;
|
||||
CurrPrim=(u8*)PrimBuffer[PrimFlipFlag];
|
||||
EndPrim=CurrPrim+(PRIMPOOL_SIZE);
|
||||
ResetOTagR(BaseOtPtr,MAX_OT_ALL);
|
||||
|
@ -71,8 +69,7 @@ void PrimDisplay()
|
|||
void FlushPrimPool()
|
||||
{
|
||||
BaseOtPtr=(sOT*)OtList[PrimFlipFlag];
|
||||
GUIOtPtr=BaseOtPtr;
|
||||
OtPtr=GUIOtPtr+MAX_OT_GUI;
|
||||
OtPtr=BaseOtPtr;
|
||||
CurrPrim=(u8*)PrimBuffer[PrimFlipFlag];
|
||||
EndPrim=CurrPrim+(PRIMPOOL_SIZE);
|
||||
ResetOTagR(BaseOtPtr,MAX_OT_ALL);
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
#include "gfx\primplus.h"
|
||||
#endif
|
||||
|
||||
#define MAX_OT_GUI (0)
|
||||
//#define MAX_OT_GUI (0)
|
||||
#define MAX_OT (16)
|
||||
#define MAX_OT_ALL (MAX_OT+MAX_OT_GUI)
|
||||
#define MAX_PRIMS ((1024*2)+512) // Put back after overrender bug found (BAD DAVE!) ( put back in by evilpaul ;)
|
||||
// bumped down a lil, cos we need memory hope this value works ok. Be ok once quadding is in
|
||||
#define MAX_OT_ALL (MAX_OT)
|
||||
#define MAX_PRIMS ((1024*2)) // Took off 512 as mid layer now pre-stored as TSPRTs
|
||||
|
||||
//#define USE_NTAGS 1
|
||||
|
||||
|
@ -308,7 +307,7 @@ typedef u32 sOT;
|
|||
#define OTLIST_SIZE (MAX_OT_ALL*sizeof(sOT))
|
||||
|
||||
/********************************************************************************************************/
|
||||
extern sOT *BaseOtPtr,*GUIOtPtr,*OtPtr;
|
||||
extern sOT *BaseOtPtr,*OtPtr;
|
||||
extern u8 *CurrPrim,*EndPrim;
|
||||
extern u8 *PrimListStart,*PrimListEnd;
|
||||
//extern int PrimFlipFlag;
|
||||
|
@ -330,12 +329,13 @@ LINE_G2 *DrawGLine(int _x0,int _y0,int _x1,int _y1,int _r1,int _g1,int _b1,int
|
|||
/********************************************************************************************************/
|
||||
/*** Inlines ********************************************************************************************/
|
||||
/********************************************************************************************************/
|
||||
/*
|
||||
inline void AddGUIPrimToList(void *Prim,u32 Depth)
|
||||
{
|
||||
ASSERT(Depth<MAX_OT_GUI);
|
||||
addPrim(GUIOtPtr+Depth,(u32*)Prim);
|
||||
}
|
||||
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------------------------*/
|
||||
inline void AddPrimToList(void *Prim,u32 Depth)
|
||||
{
|
||||
|
|
|
@ -14,25 +14,44 @@ const u32 XInc=16<<0;
|
|||
const u32 YInc=16<<16;
|
||||
|
||||
/*****************************************************************************/
|
||||
//DVECTOR TileMapOfs={0,4}; // To line layers up :oP
|
||||
static const int TILE2D_WIDTH=16;
|
||||
static const int TILE2D_HEIGHT=12;
|
||||
static const int SCREEN_TILE2D_WIDTH=((512/TILE2D_WIDTH)+1);
|
||||
static const int SCREEN_TILE2D_HEIGHT=((256/TILE2D_HEIGHT)+1);
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
CLayerTile::CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr)
|
||||
{
|
||||
int Count=SCREEN_TILE2D_WIDTH*SCREEN_TILE2D_HEIGHT;
|
||||
int MemSize=Count*sizeof(TSPRT);
|
||||
|
||||
LayerHdr=Hdr;
|
||||
MapWidth=LayerHdr->Width;
|
||||
MapHeight=LayerHdr->Height;
|
||||
|
||||
// printf("%i %i\n",MapWidth,MapHeight);
|
||||
ElemBank2d=LevelHdr->ElemBank2d;
|
||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||
|
||||
PrimBank=(TSPRT*)MemAlloc(MemSize,"Mid Polyz");
|
||||
|
||||
TSPRT *PrimPtr=PrimBank;
|
||||
for (int i=0; i<Count; i++)
|
||||
{
|
||||
setTSprt(PrimPtr);
|
||||
setTSetShadeTex(PrimPtr,1);
|
||||
PrimPtr->w=TILE2D_WIDTH;
|
||||
PrimPtr->h=TILE2D_HEIGHT;
|
||||
PrimPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
CLayerTile::~CLayerTile()
|
||||
{
|
||||
MemFree(PrimBank);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -58,16 +77,10 @@ int XPos=MapPos.vx>>MapXYShift;
|
|||
int YPos=MapPos.vy>>MapXYShift;
|
||||
|
||||
MapXY.vx=XPos>>4;
|
||||
MapXY.vy=YPos/12;
|
||||
MapXY.vy=YPos/TILE2D_HEIGHT;
|
||||
|
||||
/* if (LayerHdr->SubType==1) // BODGE AND A HALF
|
||||
{
|
||||
MapXY.vx+=TileMapOfs.vx; MapXY.vy+=TileMapOfs.vy;
|
||||
}
|
||||
*/
|
||||
ShiftX=XPos & 15;
|
||||
// ShiftY=YPos & 15;
|
||||
ShiftY=YPos%12;
|
||||
ShiftY=YPos%TILE2D_HEIGHT;
|
||||
|
||||
if (MapXY.vx+SCREEN_TILE2D_WIDTH<=MapWidth)
|
||||
RenderW=SCREEN_TILE2D_WIDTH;
|
||||
|
@ -84,19 +97,18 @@ int YPos=MapPos.vy>>MapXYShift;
|
|||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
#if 1 // FT4 version
|
||||
void CLayerTile::render()
|
||||
{
|
||||
|
||||
sTileMapElem *MapPtr=GetMapPos();
|
||||
u8 *PrimPtr=GetPrimPtr();
|
||||
s16 TileX,TileY;
|
||||
sOT *ThisOT=OtPtr+LayerOT;
|
||||
TSPRT *PrimPtr=PrimBank;
|
||||
|
||||
// Setup shift bits of pos
|
||||
TileY=-ShiftY;
|
||||
|
||||
// Render it!!
|
||||
|
||||
for (int Y=0; Y<RenderH; Y++)
|
||||
{
|
||||
sTileMapElem *MapRow=MapPtr;
|
||||
|
@ -109,68 +121,17 @@ sOT *ThisOT=OtPtr+LayerOT;
|
|||
if (ThisTile)
|
||||
{
|
||||
sElem2d *Tile=&ElemBank2d[ThisTile];
|
||||
POLY_FT4 *Ft4=(POLY_FT4*)PrimPtr;
|
||||
setPolyFT4(Ft4);
|
||||
setShadeTex(Ft4,1);
|
||||
setXYWH(Ft4,TileX,TileY,16,12);
|
||||
setUVWH(Ft4,Tile->u0,Tile->v0,15,15);
|
||||
Ft4->tpage=Tile->TPage;
|
||||
Ft4->clut=Tile->Clut;
|
||||
// addPrimNoCheck(ThisOT,Ft4);
|
||||
addPrim(ThisOT,Ft4);
|
||||
PrimPtr+=sizeof(POLY_FT4);
|
||||
PrimPtr->x0=TileX;
|
||||
PrimPtr->y0=TileY;
|
||||
setTSprtTPage(PrimPtr,Tile->TPage);
|
||||
*(u32*)&PrimPtr->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
||||
addPrim(ThisOT,PrimPtr);
|
||||
PrimPtr++;
|
||||
}
|
||||
TileX+=TILE2D_WIDTH;
|
||||
}
|
||||
MapPtr+=MapWidth;
|
||||
TileY+=TILE2D_HEIGHT;
|
||||
}
|
||||
SetPrimPtr(PrimPtr);
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
void CLayerTile::render()
|
||||
{
|
||||
sTileMapElem *MapPtr=GetMapPos();
|
||||
u8 *PrimPtr=GetPrimPtr();
|
||||
s16 TileX,TileY;
|
||||
sOT *ThisOT=OtPtr+LayerOT;
|
||||
|
||||
// Setup shift bits of pos
|
||||
TileY=-ShiftY;
|
||||
|
||||
// Render it!!
|
||||
for (int Y=0; Y<RenderH; Y++)
|
||||
{
|
||||
sTileMapElem *MapRow=MapPtr;
|
||||
TileX=-ShiftX;
|
||||
|
||||
for (int X=0; X<RenderW; X++)
|
||||
{
|
||||
int ThisTile=*MapRow++;
|
||||
if (ThisTile)
|
||||
{
|
||||
/**/ sElem2d *Tile=&ElemBank2d[ThisTile];
|
||||
TSPRT_16 *SprPtr=(TSPRT_16*)PrimPtr;
|
||||
setTSprt16(SprPtr);
|
||||
setTSetShadeTex(SprPtr,1);
|
||||
/**/ SprPtr->x0=TileX;
|
||||
/**/ SprPtr->y0=TileY;
|
||||
/**/ setTSprtTPage(SprPtr,Tile->TPage);
|
||||
*(u32*)&SprPtr->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
||||
addPrimNoCheck(ThisOT,SprPtr);
|
||||
PrimPtr+=sizeof(TSPRT_16);
|
||||
}
|
||||
// MapRow++;
|
||||
TileX+=TILE2D_WIDTH;
|
||||
}
|
||||
MapPtr+=MapWidth;
|
||||
TileY+=TILE2D_HEIGHT;
|
||||
}
|
||||
SetPrimPtr(PrimPtr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -18,22 +18,12 @@ class CLayerTile
|
|||
public:
|
||||
enum LAYER_TILE_TYPE
|
||||
{ // Stored reverse for rendering :o)
|
||||
LAYER_TILE_TYPE_FORE,
|
||||
LAYER_TILE_TYPE_ACTION,
|
||||
LAYER_TILE_TYPE_MID,
|
||||
LAYER_TILE_TYPE_BACK,
|
||||
LAYER_TILE_TYPE_MAX
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TILE2D_WIDTH=16,
|
||||
TILE2D_HEIGHT=12,
|
||||
SCREEN_TILE2D_WIDTH=(32+2),
|
||||
SCREEN_TILE2D_HEIGHT=(22+2),
|
||||
SCREEN_TILE_SIZE=SCREEN_TILE2D_WIDTH*SCREEN_TILE2D_HEIGHT,
|
||||
};
|
||||
|
||||
CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr);
|
||||
virtual ~CLayerTile();
|
||||
|
||||
|
@ -58,6 +48,7 @@ protected:
|
|||
u16 ShiftX,ShiftY;
|
||||
|
||||
sTileMapElem *Map;
|
||||
TSPRT *PrimBank;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue