This commit is contained in:
parent
7cceaaac22
commit
c9050e5b51
4 changed files with 206 additions and 231 deletions
|
@ -13,6 +13,9 @@
|
||||||
const u32 XInc=16<<0;
|
const u32 XInc=16<<0;
|
||||||
const u32 YInc=16<<16;
|
const u32 YInc=16<<16;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// Uses single buffer. Hopefully this will be adequate
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -32,14 +35,7 @@ CLayerTile::CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_Qu
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerTile::~CLayerTile()
|
CLayerTile::~CLayerTile()
|
||||||
{
|
{
|
||||||
if (TileTable[0].Table) MemFree(TileTable[0].Table);
|
MemFree(PrimGrid);
|
||||||
if (TileTable[1].Table) MemFree(TileTable[1].Table);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
sTileTable &CLayerTile::GetTileTable()
|
|
||||||
{
|
|
||||||
return(TileTable[FrameFlipFlag]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -53,68 +49,37 @@ int Size=Width*Height;
|
||||||
ASSERT(Height>=SCREEN_TILE_HEIGHT);
|
ASSERT(Height>=SCREEN_TILE_HEIGHT);
|
||||||
|
|
||||||
MapXYShift=Shift;
|
MapXYShift=Shift;
|
||||||
TileTableWidth=Width;
|
PrimGridWidth=Width;
|
||||||
TileTableHeight=Height;
|
PrimGridHeight=Height;
|
||||||
|
|
||||||
for (int Buffer=0; Buffer<2; Buffer++)
|
PrimGrid=(sPrimGridElem*) MemAlloc(Size*sizeof(sPrimGridElem),"2d PrimGrid");
|
||||||
|
ASSERT(PrimGrid);
|
||||||
|
MapX=0;
|
||||||
|
MapY=0;
|
||||||
|
for (int Y=0; Y<PrimGridHeight; Y++)
|
||||||
{
|
{
|
||||||
sTileTableElem *Table=(sTileTableElem*) MemAlloc(Size*sizeof(sTileTableElem),"2d TileTable");
|
for (int X=0; X<PrimGridWidth; X++)
|
||||||
TileTable[Buffer].Table=Table;
|
|
||||||
TileTable[Buffer].MapX=0;
|
|
||||||
TileTable[Buffer].MapY=0;
|
|
||||||
|
|
||||||
for (int Y=0; Y<Height; Y++)
|
|
||||||
{
|
{
|
||||||
|
sPrimGridElem *ThisElem=GetGridPos(X,Y);
|
||||||
for (int X=0; X<Width; X++)
|
|
||||||
{
|
|
||||||
sTileTableElem *ThisElem=&Table[X+(Y*Width)];
|
|
||||||
// Tile prim
|
// Tile prim
|
||||||
TSPRT_16 *Prim=&ThisElem->Prim;
|
setTSprt16(&ThisElem->Prim);
|
||||||
setTSprt16(Prim);
|
setTSetShadeTex(&ThisElem->Prim,1);
|
||||||
setTSetShadeTex(Prim,1);
|
|
||||||
// Table
|
// Table
|
||||||
int TableR=(X+1) % Width;
|
ThisElem->Right=GetGridPos(X+1,Y);
|
||||||
int TableD=(Y+1) % Height;
|
ThisElem->Down=GetGridPos(X,Y+1);
|
||||||
ThisElem->Right=&Table[TableR+(Y*Width)];
|
|
||||||
ThisElem->Down=&Table[X+(TableD*Width)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
UpdateWholeMap(TileTable[Buffer]);
|
|
||||||
}
|
}
|
||||||
|
UpdateWholeMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::UpdateWholeMap(sTileTable &ThisTable)
|
// AS not critical, us row update routine for whole map
|
||||||
|
void CLayerTile::UpdateWholeMap()
|
||||||
{
|
{
|
||||||
sTileTableElem *Table=ThisTable.Table;
|
for (int Y=0; Y<PrimGridHeight; Y++)
|
||||||
sTileMapElem *MapPtr=Map;
|
|
||||||
|
|
||||||
// Calc (wrapped) Map/Table pos
|
|
||||||
Table+=CalcTableOfs(ThisTable.MapX,ThisTable.MapY);
|
|
||||||
MapPtr+=CalcMapOfs(ThisTable.MapX,ThisTable.MapY);
|
|
||||||
|
|
||||||
for (int Y=0; Y<TileTableHeight; Y++)
|
|
||||||
{
|
{
|
||||||
sTileTableElem *TableDown=Table->Down;
|
UpdateRow(MapX,MapY+Y);
|
||||||
sTileMapElem *MapDown=MapPtr+MapWidth;
|
|
||||||
|
|
||||||
for (int X=0; X<TileTableWidth; X++)
|
|
||||||
{
|
|
||||||
TSPRT_16 *Prim=&Table->Prim;
|
|
||||||
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
|
||||||
setTSprtTPage(Prim,Tile->TPage);
|
|
||||||
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
|
||||||
Table->Tile=Tile;
|
|
||||||
Table->TileFlags=Tile->TriCount;
|
|
||||||
Table++;
|
|
||||||
MapPtr++;
|
|
||||||
}
|
}
|
||||||
Table=TableDown;
|
|
||||||
MapPtr=MapDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -124,22 +89,29 @@ void CLayerTile::shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CLayerTile::CalcTableOfs(int X,int Y)
|
// Get (wrapped) PrimGrid pos
|
||||||
|
sPrimGridElem *CLayerTile::GetGridPos(int X,int Y)
|
||||||
{
|
{
|
||||||
/**/ X%=TileTableWidth;
|
int Pos;
|
||||||
/**/ Y%=TileTableHeight;
|
|
||||||
|
|
||||||
/**/ return(X+(Y*TileTableWidth));
|
/**/ X%=PrimGridWidth;
|
||||||
|
/**/ Y%=PrimGridHeight;
|
||||||
|
/**/ Pos=(X+(Y*PrimGridWidth));
|
||||||
|
|
||||||
|
/**/ return(PrimGrid+Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CLayerTile::CalcMapOfs(int X,int Y)
|
// Get (wrapped) Map pos
|
||||||
|
sTileMapElem *CLayerTile::GetMapPos(int X,int Y)
|
||||||
{
|
{
|
||||||
|
int Pos;
|
||||||
|
|
||||||
/**/ X%=MapWidth;
|
/**/ X%=MapWidth;
|
||||||
/**/ Y%=MapHeight;
|
/**/ Y%=MapHeight;
|
||||||
|
/**/ Pos=(X+(Y*MapWidth));
|
||||||
|
|
||||||
/**/ return(X+(Y*MapWidth));
|
/**/ return(Map+Pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,56 +121,45 @@ int CLayerTile::CalcMapOfs(int X,int Y)
|
||||||
void CLayerTile::think(VECTOR &MapPos)
|
void CLayerTile::think(VECTOR &MapPos)
|
||||||
{
|
{
|
||||||
// Update rows and Columns :o)
|
// Update rows and Columns :o)
|
||||||
sTileTable &ThisTable=TileTable[FrameFlipFlag];
|
// As these are on the borders, they 'shouldnt' alter any being rendered
|
||||||
int XPos=MapPos.vx>>MapXYShift;
|
int XPos=MapPos.vx>>MapXYShift;
|
||||||
int YPos=MapPos.vy>>MapXYShift;
|
int YPos=MapPos.vy>>MapXYShift;
|
||||||
int ShiftX=15-(XPos&15);
|
|
||||||
int ShiftY=15-(YPos&15);
|
|
||||||
|
|
||||||
ThisTable.ShiftXY=ShiftY<<16 | ShiftX<<0;
|
|
||||||
|
|
||||||
int NewX=XPos>>4;
|
int NewX=XPos>>4;
|
||||||
int NewY=YPos>>4;
|
int NewY=YPos>>4;
|
||||||
int OldX=ThisTable.MapX;
|
|
||||||
int OldY=ThisTable.MapY;
|
|
||||||
|
|
||||||
if (NewX>OldX)
|
ShiftX=XPos & 15;
|
||||||
|
ShiftY=YPos & 15;
|
||||||
|
|
||||||
|
if (NewX>MapX)
|
||||||
{ // update right column
|
{ // update right column
|
||||||
UpdateColumn(NewX+SCREEN_TILE_WIDTH-1,NewY,ThisTable);
|
UpdateColumn(NewX+SCREEN_TILE_WIDTH-1,MapY);
|
||||||
|
MapX=NewX;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (NewX<OldX)
|
if (NewX<MapX)
|
||||||
{ // update left column
|
{ // update left column
|
||||||
UpdateColumn(NewX,NewY,ThisTable);
|
UpdateColumn(NewX,MapY);
|
||||||
|
MapX=NewX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewY>OldY)
|
if (NewY>MapY)
|
||||||
{ // update bottom row
|
{ // update bottom row
|
||||||
UpdateRow(NewX,NewY+SCREEN_TILE_HEIGHT-2,ThisTable);
|
UpdateRow(MapX,NewY+SCREEN_TILE_HEIGHT-1);
|
||||||
|
MapY=NewY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (NewY<OldY)
|
if (NewY<MapY)
|
||||||
{ // update top row
|
{ // update top row
|
||||||
UpdateRow(NewX,NewY,ThisTable);
|
UpdateRow(MapX,NewY);
|
||||||
|
MapY=NewY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThisTable.MapX=NewX;
|
|
||||||
ThisTable.MapY=NewY;
|
|
||||||
|
|
||||||
ThisTable.MapX=NewX;
|
|
||||||
ThisTable.MapY=NewY;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::UpdateRow(int MapX,int MapY,sTileTable &ThisTable)
|
void CLayerTile::UpdateRow(int X,int Y)
|
||||||
{
|
{
|
||||||
sTileTableElem *Table=ThisTable.Table;
|
sPrimGridElem *Table=GetGridPos(X,Y);
|
||||||
sTileMapElem *MapPtr=Map;
|
sTileMapElem *MapPtr=GetMapPos(X,Y);
|
||||||
|
|
||||||
// Calc (wrapped) Map/Table pos
|
|
||||||
Table+=CalcTableOfs(MapX,MapY);
|
|
||||||
MapPtr+=CalcMapOfs(MapX,MapY);
|
|
||||||
|
|
||||||
for (int i=0; i<SCREEN_TILE_WIDTH; i++)
|
for (int i=0; i<SCREEN_TILE_WIDTH; i++)
|
||||||
{
|
{
|
||||||
|
@ -207,23 +168,20 @@ sTileMapElem *MapPtr=Map;
|
||||||
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
||||||
/**/ setTSprtTPage(Prim,Tile->TPage);
|
/**/ setTSprtTPage(Prim,Tile->TPage);
|
||||||
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
||||||
Table->Tile=Tile;
|
/**/ Table->Tile=MapPtr->Tile;
|
||||||
Table->TileFlags=Tile->TriCount;
|
/**/ Table->Flags=MapPtr->Flags;
|
||||||
MapPtr+=1;
|
// Next Elem
|
||||||
|
MapPtr++;
|
||||||
Table=Table->Right;
|
Table=Table->Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::UpdateColumn(int MapX,int MapY,sTileTable &ThisTable)
|
void CLayerTile::UpdateColumn(int X,int Y)
|
||||||
{
|
{
|
||||||
sTileTableElem *Table=ThisTable.Table;
|
sPrimGridElem *Table=GetGridPos(X,Y);
|
||||||
sTileMapElem *MapPtr=Map;
|
sTileMapElem *MapPtr=GetMapPos(X,Y);
|
||||||
|
|
||||||
// Calc (wrapped) Map/Table pos
|
|
||||||
Table+=CalcTableOfs(MapX,MapY);
|
|
||||||
MapPtr+=CalcMapOfs(MapX,MapY);
|
|
||||||
|
|
||||||
for (int i=0; i<SCREEN_TILE_HEIGHT; i++)
|
for (int i=0; i<SCREEN_TILE_HEIGHT; i++)
|
||||||
{
|
{
|
||||||
|
@ -232,10 +190,9 @@ sTileMapElem *MapPtr=Map;
|
||||||
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
||||||
/**/ setTSprtTPage(Prim,Tile->TPage);
|
/**/ setTSprtTPage(Prim,Tile->TPage);
|
||||||
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
||||||
Table->Tile=Tile;
|
/**/ Table->Tile=MapPtr->Tile;
|
||||||
Table->TileFlags=Tile->TriCount;
|
/**/ Table->Flags=MapPtr->Flags;
|
||||||
|
// Next Elem
|
||||||
|
|
||||||
MapPtr+=MapWidth;
|
MapPtr+=MapWidth;
|
||||||
Table=Table->Down;
|
Table=Table->Down;
|
||||||
}
|
}
|
||||||
|
@ -246,141 +203,139 @@ sTileMapElem *MapPtr=Map;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::render()
|
void CLayerTile::render()
|
||||||
{
|
{
|
||||||
sTileTable &ThisTable=TileTable[FrameFlipFlag];
|
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||||
sTileTableElem *Table=ThisTable.Table;
|
s16 TileX,TileY;
|
||||||
u32 XYPos;
|
|
||||||
|
|
||||||
// Setup shift bits of pos
|
// Setup shift bits of pos
|
||||||
XYPos=ThisTable.ShiftXY;
|
TileY=-ShiftY;
|
||||||
|
|
||||||
// Calc (wrapped) Start pos
|
|
||||||
Table+=CalcTableOfs(ThisTable.MapX,ThisTable.MapY);
|
|
||||||
|
|
||||||
// Render it!!
|
// Render it!!
|
||||||
for (int TileY=0; TileY<SCREEN_TILE_HEIGHT; TileY++)
|
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||||
{
|
{
|
||||||
sTileTableElem *TableDown=Table->Down;
|
sPrimGridElem *TableDown=Table->Down;
|
||||||
u32 XYPosDown=XYPos+YInc;
|
TileX=-ShiftX;
|
||||||
for (int TileX=0; TileX<SCREEN_TILE_WIDTH; TileX++)
|
|
||||||
|
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||||
{
|
{
|
||||||
TSPRT_16 *Prim=&Table->Prim;
|
TSPRT_16 *Prim=&Table->Prim;
|
||||||
if (Prim->clut)
|
if (Prim->clut)
|
||||||
{
|
{
|
||||||
*(u32*)&Prim->x0=XYPos;
|
/**/ Prim->x0=TileX;
|
||||||
|
/**/ Prim->y0=TileY;
|
||||||
/**/ AddPrim(OtPtr,Prim);
|
/**/ AddPrim(OtPtr,Prim);
|
||||||
}
|
}
|
||||||
Table=Table->Right;
|
Table=Table->Right;
|
||||||
XYPos+=XInc;
|
TileX+=TILE_WIDTH;
|
||||||
}
|
}
|
||||||
Table=TableDown;
|
Table=TableDown;
|
||||||
XYPos=XYPosDown;
|
TileY+=TILE_HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::renderSolid()
|
void CLayerTile::renderSolid()
|
||||||
{
|
{
|
||||||
sTileTable &ThisTable=TileTable[FrameFlipFlag];
|
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||||
sTileTableElem *Table=ThisTable.Table;
|
s16 TileX,TileY;
|
||||||
u32 XYPos;
|
|
||||||
|
|
||||||
// Setup shift bits of pos
|
// Setup shift bits of pos
|
||||||
XYPos=ThisTable.ShiftXY;
|
TileY=-ShiftY;
|
||||||
|
|
||||||
// Calc (wrapped) Start pos
|
|
||||||
Table+=CalcTableOfs(ThisTable.MapX,ThisTable.MapY);
|
|
||||||
|
|
||||||
// Render it!!
|
// Render it!!
|
||||||
for (int TileY=0; TileY<SCREEN_TILE_HEIGHT; TileY++)
|
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||||
{
|
{
|
||||||
sTileTableElem *TableDown=Table->Down;
|
sPrimGridElem *TableDown=Table->Down;
|
||||||
u32 XYPosDown=XYPos+YInc;
|
TileX=-ShiftX;
|
||||||
for (int TileX=0; TileX<SCREEN_TILE_WIDTH; TileX++)
|
|
||||||
|
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||||
{
|
{
|
||||||
TSPRT_16 *Prim=&Table->Prim;
|
TSPRT_16 *Prim=&Table->Prim;
|
||||||
*(u32*)&Prim->x0=XYPos;
|
/**/ Prim->x0=TileX;
|
||||||
|
/**/ Prim->y0=TileY;
|
||||||
/**/ AddPrim(OtPtr,Prim);
|
/**/ AddPrim(OtPtr,Prim);
|
||||||
Table=Table->Right;
|
Table=Table->Right;
|
||||||
XYPos+=XInc;
|
TileX+=TILE_WIDTH;
|
||||||
}
|
}
|
||||||
Table=TableDown;
|
Table=TableDown;
|
||||||
XYPos=XYPosDown;
|
TileY+=TILE_HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
VECTOR asd={0,0,512};
|
#define BLOCK_MULT 16
|
||||||
|
|
||||||
void CLayerTile::render3d()
|
void CLayerTile::render3d()
|
||||||
{
|
{
|
||||||
sTileTable &ThisTable=TileTable[FrameFlipFlag];
|
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||||
sTileTableElem *Table=ThisTable.Table;
|
s16 TileX,TileY;
|
||||||
u32 XYPos,XYPos3d;
|
VECTOR BlkPos;
|
||||||
MATRIX _Mtx,*Mtx=&_Mtx;
|
s32 BlkXStore;
|
||||||
|
|
||||||
SetIdent(Mtx);
|
|
||||||
Mtx->t[2]=asd.vz;
|
|
||||||
gte_SetRotMatrix(Mtx);
|
|
||||||
|
|
||||||
// Setup shift bits of pos
|
// Setup shift bits of pos
|
||||||
XYPos=ThisTable.ShiftXY;
|
TileY=-ShiftY;
|
||||||
|
BlkPos.vx=((-15*TILE_WIDTH)-ShiftX)*BLOCK_MULT;
|
||||||
// Calc (wrapped) Start pos
|
BlkPos.vy=((-8*TILE_HEIGHT)-ShiftY)*BLOCK_MULT;
|
||||||
Table+=CalcTableOfs(ThisTable.MapX,ThisTable.MapY);
|
BlkXStore=BlkPos.vx;
|
||||||
|
|
||||||
// Render it!!
|
// Render it!!
|
||||||
for (int TileY=0; TileY<SCREEN_TILE_HEIGHT; TileY++)
|
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||||
{
|
{
|
||||||
sTileTableElem *TableDown=Table->Down;
|
sPrimGridElem *TableDown=Table->Down;
|
||||||
u32 XYPosDown=XYPos+YInc;
|
TileX=-ShiftX;
|
||||||
for (int TileX=0; TileX<SCREEN_TILE_WIDTH; TileX++)
|
|
||||||
|
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||||
{
|
{
|
||||||
TSPRT_16 *Prim=&Table->Prim;
|
TSPRT_16 *Prim=&Table->Prim;
|
||||||
if (Prim->clut)
|
if (Prim->clut)
|
||||||
{ // 2d tile
|
{ // Has 2d Data
|
||||||
*(u32*)&Prim->x0=XYPos;
|
/**/ Prim->x0=TileX;
|
||||||
|
/**/ Prim->y0=TileY;
|
||||||
/**/ AddPrim(OtPtr,Prim);
|
/**/ AddPrim(OtPtr,Prim);
|
||||||
}
|
}
|
||||||
if (Table->TileFlags)
|
if (Table->Flags)
|
||||||
{ // 3d tile
|
{ // Has 3d Data
|
||||||
u32 SX=(ThisTable.ShiftXY &15);
|
/**/ CMX_SetTransMtxXY(&BlkPos);
|
||||||
u32 SY=(ThisTable.ShiftXY>>16);
|
/**/ RenderBlock(Table);
|
||||||
Mtx->t[0]=((TileX-15)*16)+SX;
|
|
||||||
Mtx->t[1]=((TileY-10)*16)+SY;
|
|
||||||
gte_SetTransMatrix(Mtx);
|
|
||||||
RenderBlock(Table->Tile,Table->TileFlags);
|
|
||||||
}
|
}
|
||||||
Table=Table->Right;
|
Table=Table->Right;
|
||||||
XYPos+=XInc;
|
TileX+=TILE_WIDTH;
|
||||||
|
BlkPos.vx+=TILE_WIDTH*BLOCK_MULT;
|
||||||
}
|
}
|
||||||
Table=TableDown;
|
Table=TableDown;
|
||||||
XYPos=XYPosDown;
|
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 will be sorted by z order (cos they 'should' be simple objects
|
||||||
// NOTE: Tiles will be split into facing strips, to reduce overdraw :o)
|
// NOTE: Tiles are split into facing strips, to reduce overdraw :o)
|
||||||
// NOTE: Matrix already setup for tile
|
// NOTE: Matrix already setup for block
|
||||||
void CLayerTile::RenderBlock(sTile *Tile,u32 Flags)
|
|
||||||
|
void CLayerTile::RenderBlock(sPrimGridElem *Elem)
|
||||||
{
|
{
|
||||||
|
sTile *Tile=&TileList[Elem->Tile];
|
||||||
|
u32 Flags=Elem->Flags;
|
||||||
sVtx *P0,*P1,*P2;
|
sVtx *P0,*P1,*P2;
|
||||||
s32 ClipZ=0;
|
|
||||||
POLY_FT3 *TPrimPtr=(POLY_FT3*)GetPrimPtr();
|
POLY_FT3 *TPrimPtr=(POLY_FT3*)GetPrimPtr();
|
||||||
int TriCount=Tile->TriCount;
|
sTileTable *TileTable=Tile->TileTable;
|
||||||
sTri *TList=TriList+Tile->TriList;
|
|
||||||
u32 T0,T1,T2;
|
u32 T0,T1,T2;
|
||||||
|
|
||||||
//--- Tris ---------------------------------------------------------------------------
|
//--- Tris ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
for (int i=0; i<TILE3D_FLAGS_MAX; i++)
|
||||||
|
{
|
||||||
|
int TriCount=TileTable->TriCount;
|
||||||
|
sTri *TList=TriList+TileTable->TriList;
|
||||||
|
if (Flags & 1)
|
||||||
|
{
|
||||||
while (TriCount--)
|
while (TriCount--)
|
||||||
{
|
{
|
||||||
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2];
|
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2];
|
||||||
gte_ldv3(P0,P1,P2);
|
gte_ldv3(P0,P1,P2);
|
||||||
setPolyFT3(TPrimPtr);
|
/**/ setPolyFT3(TPrimPtr);
|
||||||
setShadeTex(TPrimPtr,1);
|
/**/ setShadeTex(TPrimPtr,1);
|
||||||
setlen( TPrimPtr, GPU_PolyFT3Tag);
|
/**/ setlen(TPrimPtr, GPU_PolyFT3Tag);
|
||||||
gte_rtpt_b();
|
gte_rtpt_b();
|
||||||
|
|
||||||
T0=*(u32*)&TList->uv0; // Get UV0 & TPage
|
T0=*(u32*)&TList->uv0; // Get UV0 & TPage
|
||||||
|
@ -395,6 +350,9 @@ u32 T0,T1,T2;
|
||||||
gte_stsxy3_ft3(TPrimPtr);
|
gte_stsxy3_ft3(TPrimPtr);
|
||||||
TPrimPtr++;
|
TPrimPtr++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
TileTable++;
|
||||||
|
Flags>>=1;
|
||||||
|
}
|
||||||
SetPrimPtr((u8*)TPrimPtr);
|
SetPrimPtr((u8*)TPrimPtr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,13 @@
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
struct sTileTableElem
|
struct sPrimGridElem
|
||||||
{
|
{
|
||||||
TSPRT_16 Prim;
|
TSPRT_16 Prim;
|
||||||
sTile *Tile;
|
u16 Tile;
|
||||||
u32 TileFlags;
|
u16 Flags;
|
||||||
sTileTableElem *Right;
|
sPrimGridElem *Right;
|
||||||
sTileTableElem *Down;
|
sPrimGridElem *Down;
|
||||||
};
|
|
||||||
|
|
||||||
struct sTileTable
|
|
||||||
{
|
|
||||||
int MapX,MapY;
|
|
||||||
u32 ShiftXY;
|
|
||||||
sTileTableElem *Table;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -56,16 +49,15 @@ virtual void render();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void UpdateWholeMap(sTileTable &ThisMap);
|
void UpdateWholeMap();
|
||||||
sTileTable &GetTileTable();
|
sPrimGridElem *GetGridPos(int X,int Y);
|
||||||
int CalcTableOfs(int X,int Y);
|
sTileMapElem *GetMapPos(int X,int Y);
|
||||||
int CalcMapOfs(int X,int Y);
|
void UpdateRow(int MapX,int MapY);
|
||||||
void UpdateRow(int MapX,int MapY,sTileTable &ThisMap);
|
void UpdateColumn(int MapX,int MapY);
|
||||||
void UpdateColumn(int MapX,int MapY,sTileTable &ThisMap);
|
|
||||||
|
|
||||||
void renderSolid();
|
void renderSolid();
|
||||||
void render3d();
|
void render3d();
|
||||||
void RenderBlock(sTile *Tile,u32 Flags);
|
void RenderBlock(sPrimGridElem *Elem);
|
||||||
|
|
||||||
sLayerHdr *LayerHdr;
|
sLayerHdr *LayerHdr;
|
||||||
sTile *TileList;
|
sTile *TileList;
|
||||||
|
@ -75,8 +67,12 @@ protected:
|
||||||
sTileMapElem *Map;
|
sTileMapElem *Map;
|
||||||
|
|
||||||
int MapWidth,MapHeight,MapXYShift;
|
int MapWidth,MapHeight,MapXYShift;
|
||||||
int TileTableWidth,TileTableHeight;
|
int PrimGridWidth,PrimGridHeight;
|
||||||
sTileTable TileTable[2]; // Double Buffered
|
|
||||||
|
int MapX,MapY;
|
||||||
|
u16 ShiftX,ShiftY;
|
||||||
|
sPrimGridElem *PrimGrid;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,22 @@ CLevel::~CLevel()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
int ZPos=6500;
|
||||||
|
|
||||||
void CLevel::init()
|
void CLevel::init()
|
||||||
{
|
{
|
||||||
LevelHdr=(sLvlHdr *)CFileIO::loadFile(LEVEL04_LEVEL04_LVL,"Level Data");
|
LevelHdr=(sLvlHdr *)CFileIO::loadFile(LEVEL04_LEVEL04_LVL,"Level Data");
|
||||||
TPLoadTex(LEVEL04_LEVEL04_TEX);
|
TPLoadTex(LEVEL04_LEVEL04_TEX);
|
||||||
|
|
||||||
initLayers();
|
initLayers();
|
||||||
|
|
||||||
|
// Setup Constand Rot Matrix
|
||||||
|
MATRIX Mtx;
|
||||||
|
|
||||||
|
SetIdent(&Mtx);
|
||||||
|
Mtx.t[2]=ZPos;
|
||||||
|
SetRotMatrix(&Mtx);
|
||||||
|
SetTransMatrix(&Mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -47,6 +47,17 @@
|
||||||
: \
|
: \
|
||||||
: "r"( r0 ),"r"( r1 ))
|
: "r"( r0 ),"r"( r1 ))
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define CMX_SetTransMtxXY(r0) __asm__ ( \
|
||||||
|
"lw $12, 0( %0 );" \
|
||||||
|
"lw $13, 4( %0 );" \
|
||||||
|
"ctc2 $12, $5;" \
|
||||||
|
"ctc2 $13, $6;" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ) \
|
||||||
|
: "$12", "$13" )
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Smaller Translation Macros (no return flags) ****************************/
|
/*** Smaller Translation Macros (no return flags) ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
Loading…
Add table
Reference in a new issue