This commit is contained in:
parent
5c55823d63
commit
e2956c44ee
12 changed files with 277 additions and 203 deletions
|
@ -64,7 +64,7 @@ int Size=Width*Height;
|
|||
// Tile prim
|
||||
setTSprt16(&ThisElem->Prim);
|
||||
setTSetShadeTex(&ThisElem->Prim,1);
|
||||
// Table
|
||||
// Grid
|
||||
ThisElem->Right=GetGridPos(X+1,Y);
|
||||
ThisElem->Down=GetGridPos(X,Y+1);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ int Size=Width*Height;
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
// AS not critical, us row update routine for whole map
|
||||
// AS not time critical, use row update routine for whole map
|
||||
void CLayerTile::UpdateWholeMap()
|
||||
{
|
||||
for (int Y=0; Y<PrimGridHeight; Y++)
|
||||
|
@ -92,26 +92,28 @@ void CLayerTile::shutdown()
|
|||
// Get (wrapped) PrimGrid pos
|
||||
sPrimGridElem *CLayerTile::GetGridPos(int X,int Y)
|
||||
{
|
||||
sPrimGridElem *ThisGrid=(sPrimGridElem *)PrimGrid;
|
||||
int Pos;
|
||||
|
||||
/**/ X%=PrimGridWidth;
|
||||
/**/ Y%=PrimGridHeight;
|
||||
/**/ Pos=(X+(Y*PrimGridWidth));
|
||||
|
||||
/**/ return(PrimGrid+Pos);
|
||||
/**/ return(ThisGrid+Pos);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
// Get (wrapped) Map pos
|
||||
sTileMapElem *CLayerTile::GetMapPos(int X,int Y)
|
||||
{
|
||||
sTileMapElem *ThisMap=(sTileMapElem *)Map;
|
||||
int Pos;
|
||||
|
||||
/**/ X%=MapWidth;
|
||||
/**/ Y%=MapHeight;
|
||||
/**/ Pos=(X+(Y*MapWidth));
|
||||
|
||||
/**/ return(Map+Pos);
|
||||
/**/ return(ThisMap+Pos);
|
||||
|
||||
}
|
||||
|
||||
|
@ -158,21 +160,19 @@ int NewY=YPos>>4;
|
|||
/*****************************************************************************/
|
||||
void CLayerTile::UpdateRow(int X,int Y)
|
||||
{
|
||||
sPrimGridElem *Table=GetGridPos(X,Y);
|
||||
sPrimGridElem *Grid=GetGridPos(X,Y);
|
||||
sTileMapElem *MapPtr=GetMapPos(X,Y);
|
||||
|
||||
for (int i=0; i<SCREEN_TILE_WIDTH; i++)
|
||||
{
|
||||
// Tile prim
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
TSPRT_16 *Prim=&Grid->Prim;
|
||||
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
||||
/**/ setTSprtTPage(Prim,Tile->TPage);
|
||||
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
||||
/**/ Table->Tile=MapPtr->Tile;
|
||||
/**/ Table->Flags=MapPtr->Flags;
|
||||
// Next Elem
|
||||
MapPtr++;
|
||||
Table=Table->Right;
|
||||
Grid=Grid->Right;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -180,21 +180,19 @@ sTileMapElem *MapPtr=GetMapPos(X,Y);
|
|||
/*****************************************************************************/
|
||||
void CLayerTile::UpdateColumn(int X,int Y)
|
||||
{
|
||||
sPrimGridElem *Table=GetGridPos(X,Y);
|
||||
sPrimGridElem *Grid=GetGridPos(X,Y);
|
||||
sTileMapElem *MapPtr=GetMapPos(X,Y);
|
||||
|
||||
for (int i=0; i<SCREEN_TILE_HEIGHT; i++)
|
||||
{
|
||||
// Tile prim
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
TSPRT_16 *Prim=&Grid->Prim;
|
||||
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
||||
/**/ setTSprtTPage(Prim,Tile->TPage);
|
||||
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
||||
/**/ Table->Tile=MapPtr->Tile;
|
||||
/**/ Table->Flags=MapPtr->Flags;
|
||||
// Next Elem
|
||||
MapPtr+=MapWidth;
|
||||
Table=Table->Down;
|
||||
Grid=Grid->Down;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +201,7 @@ sTileMapElem *MapPtr=GetMapPos(X,Y);
|
|||
/*****************************************************************************/
|
||||
void CLayerTile::render()
|
||||
{
|
||||
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||
sPrimGridElem *Grid=GetGridPos(MapX,MapY);
|
||||
s16 TileX,TileY;
|
||||
|
||||
// Setup shift bits of pos
|
||||
|
@ -212,147 +210,23 @@ s16 TileX,TileY;
|
|||
// Render it!!
|
||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||
{
|
||||
sPrimGridElem *TableDown=Table->Down;
|
||||
sPrimGridElem *GridDown=Grid->Down;
|
||||
TileX=-ShiftX;
|
||||
|
||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||
{
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
TSPRT_16 *Prim=&Grid->Prim;
|
||||
if (Prim->clut)
|
||||
{
|
||||
/**/ Prim->x0=TileX;
|
||||
/**/ Prim->y0=TileY;
|
||||
/**/ AddPrim(OtPtr,Prim);
|
||||
}
|
||||
Table=Table->Right;
|
||||
Grid=Grid->Right;
|
||||
TileX+=TILE_WIDTH;
|
||||
}
|
||||
Table=TableDown;
|
||||
Grid=GridDown;
|
||||
TileY+=TILE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::renderSolid()
|
||||
{
|
||||
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||
s16 TileX,TileY;
|
||||
|
||||
// Setup shift bits of pos
|
||||
TileY=-ShiftY;
|
||||
|
||||
// Render it!!
|
||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||
{
|
||||
sPrimGridElem *TableDown=Table->Down;
|
||||
TileX=-ShiftX;
|
||||
|
||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||
{
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
/**/ Prim->x0=TileX;
|
||||
/**/ Prim->y0=TileY;
|
||||
/**/ AddPrim(OtPtr,Prim);
|
||||
Table=Table->Right;
|
||||
TileX+=TILE_WIDTH;
|
||||
}
|
||||
Table=TableDown;
|
||||
TileY+=TILE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
#define BLOCK_MULT 16
|
||||
void CLayerTile::render3d()
|
||||
{
|
||||
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||
s16 TileX,TileY;
|
||||
VECTOR BlkPos;
|
||||
s32 BlkXStore;
|
||||
|
||||
// Setup shift bits of pos
|
||||
TileY=-ShiftY;
|
||||
BlkPos.vx=((-15*TILE_WIDTH)-ShiftX)*BLOCK_MULT;
|
||||
BlkPos.vy=((-8*TILE_HEIGHT)-ShiftY)*BLOCK_MULT;
|
||||
BlkXStore=BlkPos.vx;
|
||||
|
||||
// Render it!!
|
||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||
{
|
||||
sPrimGridElem *TableDown=Table->Down;
|
||||
TileX=-ShiftX;
|
||||
|
||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||
{
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
if (Prim->clut)
|
||||
{ // Has 2d Data
|
||||
/**/ Prim->x0=TileX;
|
||||
/**/ Prim->y0=TileY;
|
||||
/**/ AddPrim(OtPtr,Prim);
|
||||
}
|
||||
if (Table->Flags)
|
||||
{ // Has 3d Data
|
||||
/**/ CMX_SetTransMtxXY(&BlkPos);
|
||||
/**/ RenderBlock(Table);
|
||||
}
|
||||
Table=Table->Right;
|
||||
TileX+=TILE_WIDTH;
|
||||
BlkPos.vx+=TILE_WIDTH*BLOCK_MULT;
|
||||
}
|
||||
Table=TableDown;
|
||||
TileY+=TILE_HEIGHT;
|
||||
BlkPos.vx=BlkXStore;
|
||||
BlkPos.vy+=TILE_HEIGHT*BLOCK_MULT;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
// NOTE: Tiles will be sorted by z order (cos they 'should' be simple objects
|
||||
// NOTE: Tiles are split into facing strips, to reduce overdraw :o)
|
||||
// NOTE: Matrix already setup for block
|
||||
|
||||
void CLayerTile::RenderBlock(sPrimGridElem *Elem)
|
||||
{
|
||||
sTile *Tile=&TileList[Elem->Tile];
|
||||
u32 Flags=Elem->Flags;
|
||||
sVtx *P0,*P1,*P2;
|
||||
POLY_FT3 *TPrimPtr=(POLY_FT3*)GetPrimPtr();
|
||||
sTileTable *TileTable=Tile->TileTable;
|
||||
u32 T0,T1,T2;
|
||||
|
||||
//--- Tris ---------------------------------------------------------------------------
|
||||
|
||||
for (int i=0; i<TILE3D_FLAGS_MAX; i++)
|
||||
{
|
||||
int TriCount=TileTable->TriCount;
|
||||
sTri *TList=TriList+TileTable->TriList;
|
||||
if (Flags & 1)
|
||||
{
|
||||
while (TriCount--)
|
||||
{
|
||||
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2];
|
||||
gte_ldv3(P0,P1,P2);
|
||||
/**/ setPolyFT3(TPrimPtr);
|
||||
/**/ setShadeTex(TPrimPtr,1);
|
||||
/**/ setlen(TPrimPtr, GPU_PolyFT3Tag);
|
||||
gte_rtpt_b();
|
||||
|
||||
T0=*(u32*)&TList->uv0; // Get UV0 & TPage
|
||||
T1=*(u32*)&TList->uv1; // Get UV1 & Clut
|
||||
T2=*(u16*)&TList->uv2; // Get UV2
|
||||
*(u32*)&TPrimPtr->u0=T0; // Set UV0
|
||||
*(u32*)&TPrimPtr->u1=T1; // Set UV1
|
||||
*(u16*)&TPrimPtr->u2=T2; // Set UV2
|
||||
|
||||
TList++;
|
||||
addPrim(OtPtr,TPrimPtr);
|
||||
gte_stsxy3_ft3(TPrimPtr);
|
||||
TPrimPtr++;
|
||||
}
|
||||
}
|
||||
TileTable++;
|
||||
Flags>>=1;
|
||||
}
|
||||
SetPrimPtr((u8*)TPrimPtr);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue