This commit is contained in:
parent
7cceaaac22
commit
c9050e5b51
4 changed files with 206 additions and 231 deletions
|
@ -10,36 +10,32 @@
|
|||
|
||||
#include "LayerTile.h"
|
||||
|
||||
const u32 XInc=16<<0;
|
||||
const u32 YInc=16<<16;
|
||||
const u32 XInc=16<<0;
|
||||
const u32 YInc=16<<16;
|
||||
|
||||
/*****************************************************************************/
|
||||
// Uses single buffer. Hopefully this will be adequate
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
CLayerTile::CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_QuadList,sVtx *_VtxList)
|
||||
{
|
||||
LayerHdr=Hdr;
|
||||
TileList=_TileList;
|
||||
TriList=_TriList;
|
||||
QuadList=_QuadList;
|
||||
VtxList=_VtxList;
|
||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||
MapWidth=LayerHdr->Width;
|
||||
MapHeight=LayerHdr->Height;
|
||||
LayerHdr=Hdr;
|
||||
TileList=_TileList;
|
||||
TriList=_TriList;
|
||||
QuadList=_QuadList;
|
||||
VtxList=_VtxList;
|
||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||
MapWidth=LayerHdr->Width;
|
||||
MapHeight=LayerHdr->Height;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
CLayerTile::~CLayerTile()
|
||||
{
|
||||
if (TileTable[0].Table) MemFree(TileTable[0].Table);
|
||||
if (TileTable[1].Table) MemFree(TileTable[1].Table);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
sTileTable &CLayerTile::GetTileTable()
|
||||
{
|
||||
return(TileTable[FrameFlipFlag]);
|
||||
MemFree(PrimGrid);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -47,74 +43,43 @@ sTileTable &CLayerTile::GetTileTable()
|
|||
/*****************************************************************************/
|
||||
void CLayerTile::init(VECTOR &MapPos,int Shift,int Width,int Height)
|
||||
{
|
||||
int Size=Width*Height;
|
||||
int Size=Width*Height;
|
||||
|
||||
ASSERT(Width>=SCREEN_TILE_WIDTH);
|
||||
ASSERT(Height>=SCREEN_TILE_HEIGHT);
|
||||
|
||||
MapXYShift=Shift;
|
||||
TileTableWidth=Width;
|
||||
TileTableHeight=Height;
|
||||
PrimGridWidth=Width;
|
||||
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");
|
||||
TileTable[Buffer].Table=Table;
|
||||
TileTable[Buffer].MapX=0;
|
||||
TileTable[Buffer].MapY=0;
|
||||
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
for (int X=0; X<PrimGridWidth; X++)
|
||||
{
|
||||
|
||||
for (int X=0; X<Width; X++)
|
||||
{
|
||||
sTileTableElem *ThisElem=&Table[X+(Y*Width)];
|
||||
sPrimGridElem *ThisElem=GetGridPos(X,Y);
|
||||
// Tile prim
|
||||
TSPRT_16 *Prim=&ThisElem->Prim;
|
||||
setTSprt16(Prim);
|
||||
setTSetShadeTex(Prim,1);
|
||||
setTSprt16(&ThisElem->Prim);
|
||||
setTSetShadeTex(&ThisElem->Prim,1);
|
||||
// Table
|
||||
int TableR=(X+1) % Width;
|
||||
int TableD=(Y+1) % Height;
|
||||
ThisElem->Right=&Table[TableR+(Y*Width)];
|
||||
ThisElem->Down=&Table[X+(TableD*Width)];
|
||||
}
|
||||
|
||||
ThisElem->Right=GetGridPos(X+1,Y);
|
||||
ThisElem->Down=GetGridPos(X,Y+1);
|
||||
}
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
for (int Y=0; Y<PrimGridHeight; Y++)
|
||||
{
|
||||
UpdateRow(MapX,MapY+Y);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -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;
|
||||
/**/ Y%=TileTableHeight;
|
||||
int Pos;
|
||||
|
||||
/**/ 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;
|
||||
/**/ Y%=MapHeight;
|
||||
|
||||
/**/ return(X+(Y*MapWidth));
|
||||
/**/ Pos=(X+(Y*MapWidth));
|
||||
|
||||
/**/ return(Map+Pos);
|
||||
|
||||
}
|
||||
|
||||
|
@ -149,56 +121,45 @@ int CLayerTile::CalcMapOfs(int X,int Y)
|
|||
void CLayerTile::think(VECTOR &MapPos)
|
||||
{
|
||||
// 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 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 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
|
||||
UpdateColumn(NewX+SCREEN_TILE_WIDTH-1,NewY,ThisTable);
|
||||
UpdateColumn(NewX+SCREEN_TILE_WIDTH-1,MapY);
|
||||
MapX=NewX;
|
||||
}
|
||||
else
|
||||
if (NewX<OldX)
|
||||
if (NewX<MapX)
|
||||
{ // update left column
|
||||
UpdateColumn(NewX,NewY,ThisTable);
|
||||
UpdateColumn(NewX,MapY);
|
||||
MapX=NewX;
|
||||
}
|
||||
|
||||
if (NewY>OldY)
|
||||
if (NewY>MapY)
|
||||
{ // update bottom row
|
||||
UpdateRow(NewX,NewY+SCREEN_TILE_HEIGHT-2,ThisTable);
|
||||
UpdateRow(MapX,NewY+SCREEN_TILE_HEIGHT-1);
|
||||
MapY=NewY;
|
||||
}
|
||||
else
|
||||
if (NewY<OldY)
|
||||
if (NewY<MapY)
|
||||
{ // 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;
|
||||
sTileMapElem *MapPtr=Map;
|
||||
|
||||
// Calc (wrapped) Map/Table pos
|
||||
Table+=CalcTableOfs(MapX,MapY);
|
||||
MapPtr+=CalcMapOfs(MapX,MapY);
|
||||
sPrimGridElem *Table=GetGridPos(X,Y);
|
||||
sTileMapElem *MapPtr=GetMapPos(X,Y);
|
||||
|
||||
for (int i=0; i<SCREEN_TILE_WIDTH; i++)
|
||||
{
|
||||
|
@ -207,23 +168,20 @@ sTileMapElem *MapPtr=Map;
|
|||
/**/ 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;
|
||||
MapPtr+=1;
|
||||
/**/ Table->Tile=MapPtr->Tile;
|
||||
/**/ Table->Flags=MapPtr->Flags;
|
||||
// Next Elem
|
||||
MapPtr++;
|
||||
Table=Table->Right;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::UpdateColumn(int MapX,int MapY,sTileTable &ThisTable)
|
||||
void CLayerTile::UpdateColumn(int X,int Y)
|
||||
{
|
||||
sTileTableElem *Table=ThisTable.Table;
|
||||
sTileMapElem *MapPtr=Map;
|
||||
|
||||
// Calc (wrapped) Map/Table pos
|
||||
Table+=CalcTableOfs(MapX,MapY);
|
||||
MapPtr+=CalcMapOfs(MapX,MapY);
|
||||
sPrimGridElem *Table=GetGridPos(X,Y);
|
||||
sTileMapElem *MapPtr=GetMapPos(X,Y);
|
||||
|
||||
for (int i=0; i<SCREEN_TILE_HEIGHT; i++)
|
||||
{
|
||||
|
@ -232,10 +190,9 @@ sTileMapElem *MapPtr=Map;
|
|||
/**/ 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->Tile=MapPtr->Tile;
|
||||
/**/ Table->Flags=MapPtr->Flags;
|
||||
// Next Elem
|
||||
MapPtr+=MapWidth;
|
||||
Table=Table->Down;
|
||||
}
|
||||
|
@ -246,155 +203,156 @@ sTileMapElem *MapPtr=Map;
|
|||
/*****************************************************************************/
|
||||
void CLayerTile::render()
|
||||
{
|
||||
sTileTable &ThisTable=TileTable[FrameFlipFlag];
|
||||
sTileTableElem *Table=ThisTable.Table;
|
||||
u32 XYPos;
|
||||
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||
s16 TileX,TileY;
|
||||
|
||||
// Setup shift bits of pos
|
||||
XYPos=ThisTable.ShiftXY;
|
||||
TileY=-ShiftY;
|
||||
|
||||
// Calc (wrapped) Start pos
|
||||
Table+=CalcTableOfs(ThisTable.MapX,ThisTable.MapY);
|
||||
|
||||
// Render it!!
|
||||
for (int TileY=0; TileY<SCREEN_TILE_HEIGHT; TileY++)
|
||||
// Render it!!
|
||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||
{
|
||||
sTileTableElem *TableDown=Table->Down;
|
||||
u32 XYPosDown=XYPos+YInc;
|
||||
for (int TileX=0; TileX<SCREEN_TILE_WIDTH; TileX++)
|
||||
sPrimGridElem *TableDown=Table->Down;
|
||||
TileX=-ShiftX;
|
||||
|
||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||
{
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
if (Prim->clut)
|
||||
{
|
||||
*(u32*)&Prim->x0=XYPos;
|
||||
/**/ Prim->x0=TileX;
|
||||
/**/ Prim->y0=TileY;
|
||||
/**/ AddPrim(OtPtr,Prim);
|
||||
}
|
||||
Table=Table->Right;
|
||||
XYPos+=XInc;
|
||||
TileX+=TILE_WIDTH;
|
||||
}
|
||||
Table=TableDown;
|
||||
XYPos=XYPosDown;
|
||||
TileY+=TILE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::renderSolid()
|
||||
{
|
||||
sTileTable &ThisTable=TileTable[FrameFlipFlag];
|
||||
sTileTableElem *Table=ThisTable.Table;
|
||||
u32 XYPos;
|
||||
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||
s16 TileX,TileY;
|
||||
|
||||
// Setup shift bits of pos
|
||||
XYPos=ThisTable.ShiftXY;
|
||||
TileY=-ShiftY;
|
||||
|
||||
// Calc (wrapped) Start pos
|
||||
Table+=CalcTableOfs(ThisTable.MapX,ThisTable.MapY);
|
||||
|
||||
// Render it!!
|
||||
for (int TileY=0; TileY<SCREEN_TILE_HEIGHT; TileY++)
|
||||
// Render it!!
|
||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||
{
|
||||
sTileTableElem *TableDown=Table->Down;
|
||||
u32 XYPosDown=XYPos+YInc;
|
||||
for (int TileX=0; TileX<SCREEN_TILE_WIDTH; TileX++)
|
||||
sPrimGridElem *TableDown=Table->Down;
|
||||
TileX=-ShiftX;
|
||||
|
||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||
{
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
*(u32*)&Prim->x0=XYPos;
|
||||
/**/ Prim->x0=TileX;
|
||||
/**/ Prim->y0=TileY;
|
||||
/**/ AddPrim(OtPtr,Prim);
|
||||
Table=Table->Right;
|
||||
XYPos+=XInc;
|
||||
TileX+=TILE_WIDTH;
|
||||
}
|
||||
Table=TableDown;
|
||||
XYPos=XYPosDown;
|
||||
TileY+=TILE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
VECTOR asd={0,0,512};
|
||||
|
||||
#define BLOCK_MULT 16
|
||||
void CLayerTile::render3d()
|
||||
{
|
||||
sTileTable &ThisTable=TileTable[FrameFlipFlag];
|
||||
sTileTableElem *Table=ThisTable.Table;
|
||||
u32 XYPos,XYPos3d;
|
||||
MATRIX _Mtx,*Mtx=&_Mtx;
|
||||
|
||||
SetIdent(Mtx);
|
||||
Mtx->t[2]=asd.vz;
|
||||
gte_SetRotMatrix(Mtx);
|
||||
sPrimGridElem *Table=GetGridPos(MapX,MapY);
|
||||
s16 TileX,TileY;
|
||||
VECTOR BlkPos;
|
||||
s32 BlkXStore;
|
||||
|
||||
// Setup shift bits of pos
|
||||
XYPos=ThisTable.ShiftXY;
|
||||
TileY=-ShiftY;
|
||||
BlkPos.vx=((-15*TILE_WIDTH)-ShiftX)*BLOCK_MULT;
|
||||
BlkPos.vy=((-8*TILE_HEIGHT)-ShiftY)*BLOCK_MULT;
|
||||
BlkXStore=BlkPos.vx;
|
||||
|
||||
// Calc (wrapped) Start pos
|
||||
Table+=CalcTableOfs(ThisTable.MapX,ThisTable.MapY);
|
||||
|
||||
// Render it!!
|
||||
for (int TileY=0; TileY<SCREEN_TILE_HEIGHT; TileY++)
|
||||
// Render it!!
|
||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
||||
{
|
||||
sTileTableElem *TableDown=Table->Down;
|
||||
u32 XYPosDown=XYPos+YInc;
|
||||
for (int TileX=0; TileX<SCREEN_TILE_WIDTH; TileX++)
|
||||
sPrimGridElem *TableDown=Table->Down;
|
||||
TileX=-ShiftX;
|
||||
|
||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
||||
{
|
||||
TSPRT_16 *Prim=&Table->Prim;
|
||||
if (Prim->clut)
|
||||
{ // 2d tile
|
||||
*(u32*)&Prim->x0=XYPos;
|
||||
{ // Has 2d Data
|
||||
/**/ Prim->x0=TileX;
|
||||
/**/ Prim->y0=TileY;
|
||||
/**/ AddPrim(OtPtr,Prim);
|
||||
}
|
||||
if (Table->TileFlags)
|
||||
{ // 3d tile
|
||||
u32 SX=(ThisTable.ShiftXY &15);
|
||||
u32 SY=(ThisTable.ShiftXY>>16);
|
||||
Mtx->t[0]=((TileX-15)*16)+SX;
|
||||
Mtx->t[1]=((TileY-10)*16)+SY;
|
||||
gte_SetTransMatrix(Mtx);
|
||||
RenderBlock(Table->Tile,Table->TileFlags);
|
||||
if (Table->Flags)
|
||||
{ // Has 3d Data
|
||||
/**/ CMX_SetTransMtxXY(&BlkPos);
|
||||
/**/ RenderBlock(Table);
|
||||
}
|
||||
Table=Table->Right;
|
||||
XYPos+=XInc;
|
||||
TileX+=TILE_WIDTH;
|
||||
BlkPos.vx+=TILE_WIDTH*BLOCK_MULT;
|
||||
}
|
||||
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 split into facing strips, to reduce overdraw :o)
|
||||
// NOTE: Matrix already setup for tile
|
||||
void CLayerTile::RenderBlock(sTile *Tile,u32 Flags)
|
||||
// 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;
|
||||
s32 ClipZ=0;
|
||||
POLY_FT3 *TPrimPtr=(POLY_FT3*)GetPrimPtr();
|
||||
int TriCount=Tile->TriCount;
|
||||
sTri *TList=TriList+Tile->TriList;
|
||||
sTileTable *TileTable=Tile->TileTable;
|
||||
u32 T0,T1,T2;
|
||||
|
||||
//--- Tris ---------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
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();
|
||||
|
||||
TList++;
|
||||
addPrim(OtPtr,TPrimPtr);
|
||||
gte_stsxy3_ft3(TPrimPtr);
|
||||
TPrimPtr++;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -7,20 +7,13 @@
|
|||
|
||||
|
||||
/*****************************************************************************/
|
||||
struct sTileTableElem
|
||||
struct sPrimGridElem
|
||||
{
|
||||
TSPRT_16 Prim;
|
||||
sTile *Tile;
|
||||
u32 TileFlags;
|
||||
sTileTableElem *Right;
|
||||
sTileTableElem *Down;
|
||||
};
|
||||
|
||||
struct sTileTable
|
||||
{
|
||||
int MapX,MapY;
|
||||
u32 ShiftXY;
|
||||
sTileTableElem *Table;
|
||||
u16 Tile;
|
||||
u16 Flags;
|
||||
sPrimGridElem *Right;
|
||||
sPrimGridElem *Down;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -56,16 +49,15 @@ virtual void render();
|
|||
|
||||
|
||||
protected:
|
||||
void UpdateWholeMap(sTileTable &ThisMap);
|
||||
sTileTable &GetTileTable();
|
||||
int CalcTableOfs(int X,int Y);
|
||||
int CalcMapOfs(int X,int Y);
|
||||
void UpdateRow(int MapX,int MapY,sTileTable &ThisMap);
|
||||
void UpdateColumn(int MapX,int MapY,sTileTable &ThisMap);
|
||||
void UpdateWholeMap();
|
||||
sPrimGridElem *GetGridPos(int X,int Y);
|
||||
sTileMapElem *GetMapPos(int X,int Y);
|
||||
void UpdateRow(int MapX,int MapY);
|
||||
void UpdateColumn(int MapX,int MapY);
|
||||
|
||||
void renderSolid();
|
||||
void render3d();
|
||||
void RenderBlock(sTile *Tile,u32 Flags);
|
||||
void RenderBlock(sPrimGridElem *Elem);
|
||||
|
||||
sLayerHdr *LayerHdr;
|
||||
sTile *TileList;
|
||||
|
@ -75,8 +67,12 @@ protected:
|
|||
sTileMapElem *Map;
|
||||
|
||||
int MapWidth,MapHeight,MapXYShift;
|
||||
int TileTableWidth,TileTableHeight;
|
||||
sTileTable TileTable[2]; // Double Buffered
|
||||
int PrimGridWidth,PrimGridHeight;
|
||||
|
||||
int MapX,MapY;
|
||||
u16 ShiftX,ShiftY;
|
||||
sPrimGridElem *PrimGrid;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ CLevel::CLevel()
|
|||
}
|
||||
|
||||
MapPos.vx=0;
|
||||
MapPos.vy=0;
|
||||
MapPos.vy=0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -38,12 +38,22 @@ CLevel::~CLevel()
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int ZPos=6500;
|
||||
|
||||
void CLevel::init()
|
||||
{
|
||||
LevelHdr=(sLvlHdr *)CFileIO::loadFile(LEVEL04_LEVEL04_LVL,"Level Data");
|
||||
TPLoadTex(LEVEL04_LEVEL04_TEX);
|
||||
|
||||
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 ))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
#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) ****************************/
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Add table
Reference in a new issue