This commit is contained in:
parent
d0780ad261
commit
6d989f8c1f
@ -1,6 +1,6 @@
|
|||||||
/******************************/
|
/*************************/
|
||||||
/*** Solid Tile Layer Class ***/
|
/*** Shade Layer Class ***/
|
||||||
/******************************/
|
/*************************/
|
||||||
|
|
||||||
#include "system\global.h"
|
#include "system\global.h"
|
||||||
#include <DStructs.h>
|
#include <DStructs.h>
|
||||||
@ -20,7 +20,6 @@ CLayerBack::CLayerBack(sLayerHdr *Hdr,sTile *TileList,sTri *TriList,sQuad *QuadL
|
|||||||
Data=(sLayerShadeHdr*)MakePtr(Hdr,sizeof(sLayerHdr));
|
Data=(sLayerShadeHdr*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||||
|
|
||||||
ASSERT(Data->Count<=LAYER_SHADE_RGB_MAX);
|
ASSERT(Data->Count<=LAYER_SHADE_RGB_MAX);
|
||||||
printf("%i Back Shades",Data->Count);
|
|
||||||
BandCount=Data->Count-1;
|
BandCount=Data->Count-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,11 +32,12 @@ CLayerBack::~CLayerBack()
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerBack::init(DVECTOR &MapPos,int Shift,int Width,int Height)
|
void CLayerBack::init(DVECTOR &MapPos,int Shift)
|
||||||
{
|
{
|
||||||
MapXYShift=Shift;
|
MapXYShift=Shift;
|
||||||
|
|
||||||
BandHeight=(Height*16)/(BandCount);
|
BandHeight=(MapHeight*16)/(BandCount);
|
||||||
|
if (BandHeight>=512) BandHeight=511;
|
||||||
|
|
||||||
for (int i=0; i<BandCount; i++)
|
for (int i=0; i<BandCount; i++)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,6 @@ void CLayerBack::init(DVECTOR &MapPos,int Shift,int Width,int Height)
|
|||||||
setRGB2(&Band[i],Data->Data[i+1].RGB[0],Data->Data[i+1].RGB[1],Data->Data[i+1].RGB[2]);
|
setRGB2(&Band[i],Data->Data[i+1].RGB[0],Data->Data[i+1].RGB[1],Data->Data[i+1].RGB[2]);
|
||||||
setRGB3(&Band[i],Data->Data[i+1].RGB[0],Data->Data[i+1].RGB[1],Data->Data[i+1].RGB[2]);
|
setRGB3(&Band[i],Data->Data[i+1].RGB[0],Data->Data[i+1].RGB[1],Data->Data[i+1].RGB[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -56,9 +55,11 @@ void CLayerBack::shutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
extern DVECTOR TileMapOfs;
|
||||||
void CLayerBack::think(DVECTOR &MapPos)
|
void CLayerBack::think(DVECTOR &MapPos)
|
||||||
{
|
{
|
||||||
YOfs=MapPos.vy>>MapXYShift;
|
YOfs=MapPos.vy>>MapXYShift;
|
||||||
|
YOfs+=TileMapOfs.vy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -13,7 +13,7 @@ public:
|
|||||||
CLayerBack(sLayerHdr *Hdr,sTile *TileList,sTri *TriList,sQuad *QuadList,sVtx *VtxList);
|
CLayerBack(sLayerHdr *Hdr,sTile *TileList,sTri *TriList,sQuad *QuadList,sVtx *VtxList);
|
||||||
~CLayerBack();
|
~CLayerBack();
|
||||||
|
|
||||||
void init(DVECTOR &MapPos,int Shift,int Width,int Height);
|
void init(DVECTOR &MapPos,int Shift);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void think(DVECTOR &MapPos);
|
void think(DVECTOR &MapPos);
|
||||||
void render();
|
void render();
|
||||||
|
@ -15,6 +15,9 @@ const u32 YInc=16<<16;
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Uses single buffer. Hopefully this will be adequate
|
// Uses single buffer. Hopefully this will be adequate
|
||||||
|
// Changed from strip scroll to whole map update (cos of camera)
|
||||||
|
|
||||||
|
DVECTOR TileMapOfs={0,4}; // To line layers up :oP
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -25,12 +28,12 @@ CLayerTile::CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_Qu
|
|||||||
MapWidth=LayerHdr->Width;
|
MapWidth=LayerHdr->Width;
|
||||||
MapHeight=LayerHdr->Height;
|
MapHeight=LayerHdr->Height;
|
||||||
|
|
||||||
|
printf("%i %i\n",MapWidth,MapHeight);
|
||||||
TileList=_TileList;
|
TileList=_TileList;
|
||||||
TriList=_TriList;
|
TriList=_TriList;
|
||||||
QuadList=_QuadList;
|
QuadList=_QuadList;
|
||||||
VtxList=_VtxList;
|
VtxList=_VtxList;
|
||||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||||
PrimGrid=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -41,80 +44,15 @@ CLayerTile::~CLayerTile()
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::init(DVECTOR &MapPos,int Shift,int Width,int Height)
|
void CLayerTile::init(DVECTOR &MapPos,int Shift)
|
||||||
{
|
{
|
||||||
int Size=Width*Height;
|
|
||||||
|
|
||||||
ASSERT(Width>=SCREEN_TILE_WIDTH);
|
|
||||||
ASSERT(Height>=SCREEN_TILE_HEIGHT);
|
|
||||||
|
|
||||||
MapXYShift=Shift;
|
MapXYShift=Shift;
|
||||||
PrimGridWidth=Width;
|
MapXY=MapPos;
|
||||||
PrimGridHeight=Height;
|
|
||||||
|
|
||||||
PrimGrid=(sPrimGridElem*) MemAlloc(Size*sizeof(sPrimGridElem),"2d PrimGrid");
|
|
||||||
ASSERT(PrimGrid);
|
|
||||||
MapX=0;
|
|
||||||
MapY=0;
|
|
||||||
for (int Y=0; Y<PrimGridHeight; Y++)
|
|
||||||
{
|
|
||||||
for (int X=0; X<PrimGridWidth; X++)
|
|
||||||
{
|
|
||||||
sPrimGridElem *ThisElem=GetGridPos(X,Y);
|
|
||||||
// Tile prim
|
|
||||||
setTSprt16(&ThisElem->Prim);
|
|
||||||
setTSetShadeTex(&ThisElem->Prim,1);
|
|
||||||
// Grid
|
|
||||||
ThisElem->Right=GetGridPos(X+1,Y);
|
|
||||||
ThisElem->Down=GetGridPos(X,Y+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UpdateWholeMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
// AS not time critical, use row update routine for whole map
|
|
||||||
void CLayerTile::UpdateWholeMap()
|
|
||||||
{
|
|
||||||
for (int Y=0; Y<PrimGridHeight; Y++)
|
|
||||||
{
|
|
||||||
UpdateRow(MapX,MapY+Y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::shutdown()
|
void CLayerTile::shutdown()
|
||||||
{
|
{
|
||||||
if (PrimGrid) MemFree(PrimGrid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
// 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(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(ThisMap+Pos);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -122,86 +60,28 @@ int Pos;
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::think(DVECTOR &MapPos)
|
void CLayerTile::think(DVECTOR &MapPos)
|
||||||
{
|
{
|
||||||
// Update rows and Columns :o)
|
|
||||||
// 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 NewX=XPos>>4;
|
|
||||||
int NewY=YPos>>4;
|
MapXY.vx=XPos>>4;
|
||||||
|
MapXY.vy=YPos>>4;
|
||||||
|
|
||||||
|
/**/ MapXY.vx+=TileMapOfs.vx;
|
||||||
|
/**/ MapXY.vy+=TileMapOfs.vy;
|
||||||
|
|
||||||
ShiftX=XPos & 15;
|
ShiftX=XPos & 15;
|
||||||
ShiftY=YPos & 15;
|
ShiftY=YPos & 15;
|
||||||
|
|
||||||
//!!#ifdef __USER_paul__
|
if (MapXY.vx+SCREEN_TILE_WIDTH<=MapWidth)
|
||||||
MapX=NewX;
|
RenderW=SCREEN_TILE_WIDTH;
|
||||||
MapY=NewY;
|
|
||||||
UpdateWholeMap();
|
|
||||||
/*
|
|
||||||
#else
|
|
||||||
if (NewX>MapX)
|
|
||||||
{ // update right column
|
|
||||||
UpdateColumn(NewX+SCREEN_TILE_WIDTH-1,MapY);
|
|
||||||
MapX=NewX;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
if (NewX<MapX)
|
RenderW=MapWidth-MapXY.vx;
|
||||||
{ // update left column
|
|
||||||
UpdateColumn(NewX,MapY);
|
|
||||||
MapX=NewX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NewY>MapY)
|
if (MapXY.vy+SCREEN_TILE_HEIGHT<=MapHeight)
|
||||||
{ // update bottom row
|
RenderH=SCREEN_TILE_HEIGHT;
|
||||||
UpdateRow(MapX,NewY+SCREEN_TILE_HEIGHT-1);
|
|
||||||
MapY=NewY;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
if (NewY<MapY)
|
RenderH=MapHeight-MapXY.vy;
|
||||||
{ // update top row
|
|
||||||
UpdateRow(MapX,NewY);
|
|
||||||
MapY=NewY;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerTile::UpdateRow(int X,int 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=&Grid->Prim;
|
|
||||||
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
|
||||||
/**/ setTSprtTPage(Prim,Tile->TPage);
|
|
||||||
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
|
||||||
// Next Elem
|
|
||||||
MapPtr++;
|
|
||||||
Grid=Grid->Right;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerTile::UpdateColumn(int X,int 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=&Grid->Prim;
|
|
||||||
/**/ sTile *Tile=&TileList[MapPtr->Tile];
|
|
||||||
/**/ setTSprtTPage(Prim,Tile->TPage);
|
|
||||||
*(u32*)&Prim->u0=*(u32*)&Tile->u0; // copy uv AND clut
|
|
||||||
// Next Elem
|
|
||||||
MapPtr+=MapWidth;
|
|
||||||
Grid=Grid->Down;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -209,32 +89,43 @@ sTileMapElem *MapPtr=GetMapPos(X,Y);
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::render()
|
void CLayerTile::render()
|
||||||
{
|
{
|
||||||
sPrimGridElem *Grid=GetGridPos(MapX,MapY);
|
sTileMapElem *MapPtr=GetMapPos();
|
||||||
|
u8 *PrimPtr=GetPrimPtr();
|
||||||
s16 TileX,TileY;
|
s16 TileX,TileY;
|
||||||
sOT *ThisOT=OtPtr+LayerOT;
|
sOT *ThisOT=OtPtr+LayerOT;
|
||||||
|
|
||||||
// Setup shift bits of pos
|
// Setup shift bits of pos
|
||||||
TileY=-ShiftY;
|
TileY=-ShiftY;
|
||||||
|
|
||||||
// Render it!!
|
// Render it!!
|
||||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
for (int Y=0; Y<RenderH; Y++)
|
||||||
{
|
{
|
||||||
sPrimGridElem *GridDown=Grid->Down;
|
sTileMapElem *MapRow=MapPtr;
|
||||||
TileX=-ShiftX;
|
TileX=-ShiftX;
|
||||||
|
|
||||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
for (int X=0; X<RenderW; X++)
|
||||||
{
|
{
|
||||||
TSPRT_16 *Prim=&Grid->Prim;
|
/**/ sTile *Tile=&TileList[MapRow->Tile];
|
||||||
if (Prim->clut)
|
|
||||||
|
if (Tile->Clut)
|
||||||
{
|
{
|
||||||
/**/ Prim->x0=TileX;
|
TSPRT_16 *SprPtr=(TSPRT_16*)PrimPtr;
|
||||||
/**/ Prim->y0=TileY;
|
setTSprt16(SprPtr);
|
||||||
addPrimNoCheck(ThisOT,Prim);
|
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);
|
||||||
}
|
}
|
||||||
Grid=Grid->Right;
|
MapRow++;
|
||||||
TileX+=TILE_WIDTH;
|
TileX+=TILE_WIDTH;
|
||||||
}
|
}
|
||||||
Grid=GridDown;
|
MapPtr+=MapWidth;
|
||||||
TileY+=TILE_HEIGHT;
|
TileY+=TILE_HEIGHT;
|
||||||
}
|
}
|
||||||
|
SetPrimPtr(PrimPtr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,20 +9,6 @@
|
|||||||
#include "gfx\prim.h"
|
#include "gfx\prim.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
struct sPrimGridElem
|
|
||||||
{
|
|
||||||
TSPRT_16 Prim;
|
|
||||||
sPrimGridElem *Right;
|
|
||||||
sPrimGridElem *Down;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sPrimGridElem3d : public sPrimGridElem
|
|
||||||
{
|
|
||||||
u16 Tile;
|
|
||||||
u16 Flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
const s32 LayerOT=MAX_OT-1;
|
const s32 LayerOT=MAX_OT-1;
|
||||||
|
|
||||||
@ -43,26 +29,23 @@ public:
|
|||||||
{
|
{
|
||||||
TILE_WIDTH=16,
|
TILE_WIDTH=16,
|
||||||
TILE_HEIGHT=16,
|
TILE_HEIGHT=16,
|
||||||
SCREEN_TILE_WIDTH=32,
|
SCREEN_TILE_WIDTH=34,
|
||||||
SCREEN_TILE_HEIGHT=16,
|
SCREEN_TILE_HEIGHT=18,
|
||||||
SCREEN_TILE_SIZE=SCREEN_TILE_WIDTH*SCREEN_TILE_HEIGHT
|
SCREEN_TILE_SIZE=SCREEN_TILE_WIDTH*SCREEN_TILE_HEIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
CLayerTile(sLayerHdr *Hdr,sTile *TileList,sTri *TriList,sQuad *QuadList,sVtx *VtxList);
|
CLayerTile(sLayerHdr *Hdr,sTile *TileList,sTri *TriList,sQuad *QuadList,sVtx *VtxList);
|
||||||
virtual ~CLayerTile();
|
virtual ~CLayerTile();
|
||||||
|
|
||||||
virtual void init(DVECTOR &MapPos,int Shift,int Width=SCREEN_TILE_WIDTH,int Height=SCREEN_TILE_HEIGHT);
|
virtual void init(DVECTOR &MapPos,int Shift);
|
||||||
virtual void shutdown();
|
virtual void shutdown();
|
||||||
virtual void think(DVECTOR &MapPos);
|
virtual void think(DVECTOR &MapPos);
|
||||||
virtual void render();
|
virtual void render();
|
||||||
|
|
||||||
|
int GetMapOfs() {return(MapXY.vx+(MapXY.vy*MapWidth));}
|
||||||
|
virtual sTileMapElem *GetMapPos() {return(Map+GetMapOfs());}
|
||||||
protected:
|
protected:
|
||||||
virtual void UpdateWholeMap();
|
|
||||||
virtual void UpdateRow(int MapX,int MapY);
|
|
||||||
virtual void UpdateColumn(int MapX,int MapY);
|
|
||||||
|
|
||||||
sPrimGridElem *GetGridPos(int X,int Y);
|
|
||||||
sTileMapElem *GetMapPos(int X,int Y);
|
|
||||||
|
|
||||||
sLayerHdr *LayerHdr;
|
sLayerHdr *LayerHdr;
|
||||||
sTile *TileList;
|
sTile *TileList;
|
||||||
@ -71,14 +54,12 @@ virtual void UpdateColumn(int MapX,int MapY);
|
|||||||
sVtx *VtxList;
|
sVtx *VtxList;
|
||||||
|
|
||||||
int MapWidth,MapHeight,MapXYShift;
|
int MapWidth,MapHeight,MapXYShift;
|
||||||
int PrimGridWidth,PrimGridHeight;
|
int RenderW,RenderH;
|
||||||
|
|
||||||
int MapX,MapY;
|
DVECTOR MapXY;
|
||||||
u16 ShiftX,ShiftY;
|
u16 ShiftX,ShiftY;
|
||||||
|
|
||||||
sTileMapElem *Map;
|
sTileMapElem *Map;
|
||||||
sPrimGridElem *PrimGrid;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,44 +28,17 @@ CLayerTile3d::~CLayerTile3d()
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile3d::init(DVECTOR &MapPos,int Shift,int Width,int Height)
|
|
||||||
|
void CLayerTile3d::init(DVECTOR &MapPos,int Shift)
|
||||||
{
|
{
|
||||||
int Size=Width*Height;
|
CLayerTile::init(MapPos,Shift);
|
||||||
|
|
||||||
ASSERT(Width>=SCREEN_TILE_WIDTH);
|
|
||||||
ASSERT(Height>=SCREEN_TILE_HEIGHT);
|
|
||||||
|
|
||||||
MapXYShift=Shift;
|
|
||||||
PrimGridWidth=Width;
|
|
||||||
PrimGridHeight=Height;
|
|
||||||
|
|
||||||
PrimGrid=(sPrimGridElem3d*) MemAlloc(Size*sizeof(sPrimGridElem3d),"3d PrimGrid");
|
|
||||||
ASSERT(PrimGrid);
|
|
||||||
MapX=0;
|
|
||||||
MapY=0;
|
|
||||||
for (int Y=0; Y<PrimGridHeight; Y++)
|
|
||||||
{
|
|
||||||
for (int X=0; X<PrimGridWidth; X++)
|
|
||||||
{
|
|
||||||
sPrimGridElem3d *ThisElem=GetGridPos3d(X,Y);
|
|
||||||
// Tile prim
|
|
||||||
setTSprt16(&ThisElem->Prim);
|
|
||||||
setTSetShadeTex(&ThisElem->Prim,1);
|
|
||||||
// Table
|
|
||||||
ThisElem->Right=GetGridPos3d(X+1,Y);
|
|
||||||
ThisElem->Down=GetGridPos3d(X,Y+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UpdateWholeMap();
|
|
||||||
CreateRenderFlagTable();
|
CreateRenderFlagTable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile3d::shutdown()
|
void CLayerTile3d::shutdown()
|
||||||
{
|
{
|
||||||
MemFree(RenderFlagTable);
|
MemFree(RenderFlagTable);
|
||||||
MemFree(PrimGrid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -103,83 +76,6 @@ s16 *Ptr;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
// Get (wrapped) PrimGrid pos
|
|
||||||
sPrimGridElem3d *CLayerTile3d::GetGridPos3d(int X,int Y)
|
|
||||||
{
|
|
||||||
sPrimGridElem3d *ThisGrid=(sPrimGridElem3d*)PrimGrid;
|
|
||||||
int Pos;
|
|
||||||
|
|
||||||
/**/ X%=PrimGridWidth;
|
|
||||||
/**/ Y%=PrimGridHeight;
|
|
||||||
/**/ Pos=(X+(Y*PrimGridWidth));
|
|
||||||
|
|
||||||
/**/ return(ThisGrid+Pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
// Get (wrapped) Map pos
|
|
||||||
sTileMapElem3d *CLayerTile3d::GetMapPos3d(int X,int Y)
|
|
||||||
{
|
|
||||||
sTileMapElem3d *ThisMap=(sTileMapElem3d*)Map;
|
|
||||||
int Pos;
|
|
||||||
|
|
||||||
/**/ X%=MapWidth;
|
|
||||||
/**/ Y%=MapHeight;
|
|
||||||
/**/ Pos=(X+(Y*MapWidth));
|
|
||||||
|
|
||||||
/**/ return(ThisMap+Pos);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerTile3d::UpdateRow(int X,int Y)
|
|
||||||
{
|
|
||||||
sPrimGridElem3d *Grid=GetGridPos3d(X,Y);
|
|
||||||
sTileMapElem3d *MapPtr=GetMapPos3d(X,Y);
|
|
||||||
|
|
||||||
for (int i=0; i<SCREEN_TILE_WIDTH; i++)
|
|
||||||
{
|
|
||||||
// Tile 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
|
|
||||||
/**/ Grid->Tile=MapPtr->Tile;
|
|
||||||
/**/ Grid->Flags=MapPtr->Flags;
|
|
||||||
// Next Elem
|
|
||||||
MapPtr++;
|
|
||||||
Grid=(sPrimGridElem3d *)Grid->Right;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerTile3d::UpdateColumn(int X,int Y)
|
|
||||||
{
|
|
||||||
sPrimGridElem3d *Grid=GetGridPos3d(X,Y);
|
|
||||||
sTileMapElem3d *MapPtr=GetMapPos3d(X,Y);
|
|
||||||
|
|
||||||
for (int i=0; i<SCREEN_TILE_HEIGHT; i++)
|
|
||||||
{
|
|
||||||
// Tile 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
|
|
||||||
/**/ Grid->Tile=MapPtr->Tile;
|
|
||||||
/**/ Grid->Flags=MapPtr->Flags;
|
|
||||||
// Next Elem
|
|
||||||
MapPtr+=MapWidth;
|
|
||||||
Grid=(sPrimGridElem3d *)Grid->Down;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -187,52 +83,58 @@ sTileMapElem3d *MapPtr=GetMapPos3d(X,Y);
|
|||||||
|
|
||||||
void CLayerTile3d::render()
|
void CLayerTile3d::render()
|
||||||
{
|
{
|
||||||
sPrimGridElem3d *Grid=GetGridPos3d(MapX,MapY);
|
sTileMapElem3d *MapPtr=GetMapPos3d();
|
||||||
|
u8 *PrimPtr=GetPrimPtr();
|
||||||
s16 TileX,TileY;
|
s16 TileX,TileY;
|
||||||
VECTOR BlkPos;
|
VECTOR BlkPos;
|
||||||
s32 BlkXStore;
|
s32 BlkXStore;
|
||||||
sOT *ThisOT=OtPtr+LayerOT;
|
sOT *ThisOT=OtPtr+LayerOT;
|
||||||
s16 *RenderFlags=RenderFlagTable;
|
s16 *RenderFlags=RenderFlagTable;
|
||||||
|
|
||||||
|
|
||||||
// Setup shift bits of pos
|
// Setup shift bits of pos
|
||||||
TileY=-ShiftY;
|
TileY=-ShiftY;
|
||||||
BlkPos.vx=((-15*TILE_WIDTH)-ShiftX)*BLOCK_MULT;
|
BlkPos.vx=((-15*TILE_WIDTH)-ShiftX)*BLOCK_MULT;
|
||||||
// BlkPos.vy=((-8*TILE_HEIGHT)-ShiftY)*BLOCK_MULT;
|
|
||||||
BlkPos.vy=((-7*TILE_HEIGHT)-ShiftY)*BLOCK_MULT;
|
BlkPos.vy=((-7*TILE_HEIGHT)-ShiftY)*BLOCK_MULT;
|
||||||
BlkXStore=BlkPos.vx;
|
BlkXStore=BlkPos.vx;
|
||||||
|
|
||||||
// Render it!!
|
// Render it!!
|
||||||
for (int Y=0; Y<SCREEN_TILE_HEIGHT; Y++)
|
for (int Y=0; Y<RenderH; Y++)
|
||||||
{
|
{
|
||||||
sPrimGridElem *GridDown=(sPrimGridElem3d *)Grid->Down;
|
sTileMapElem3d *MapRow=MapPtr;
|
||||||
TileX=-ShiftX;
|
TileX=-ShiftX;
|
||||||
|
|
||||||
for (int X=0; X<SCREEN_TILE_WIDTH; X++)
|
for (int X=0; X<RenderW; X++)
|
||||||
{
|
{
|
||||||
TSPRT_16 *Prim=&Grid->Prim;
|
/**/ sTile *Tile=&TileList[MapRow->Tile];
|
||||||
if (Prim->clut)
|
|
||||||
{ // Has 2d Data
|
if (Tile->Clut)
|
||||||
/**/ Prim->x0=TileX;
|
{
|
||||||
/**/ Prim->y0=TileY;
|
TSPRT_16 *SprPtr=(TSPRT_16*)PrimPtr;
|
||||||
addPrimNoCheck(ThisOT,Prim);
|
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);
|
||||||
}
|
}
|
||||||
if (Grid->Flags)
|
if (MapRow->Flags)
|
||||||
{ // Has 3d Data
|
{ // Has 3d Data
|
||||||
/**/ CMX_SetTransMtxXY(&BlkPos);
|
CMX_SetTransMtxXY(&BlkPos);
|
||||||
/**/ RenderBlock(Grid,*RenderFlags);
|
PrimPtr=RenderBlock(Tile,MapRow->Flags & *RenderFlags,PrimPtr);
|
||||||
}
|
}
|
||||||
Grid=(sPrimGridElem3d *)Grid->Right;
|
MapRow++;
|
||||||
TileX+=TILE_WIDTH;
|
TileX+=TILE_WIDTH;
|
||||||
BlkPos.vx+=TILE_WIDTH*BLOCK_MULT;
|
BlkPos.vx+=TILE_WIDTH*BLOCK_MULT;
|
||||||
RenderFlags++;
|
RenderFlags++;
|
||||||
}
|
}
|
||||||
Grid=(sPrimGridElem3d *)GridDown;
|
MapPtr+=MapWidth;
|
||||||
TileY+=TILE_HEIGHT;
|
TileY+=TILE_HEIGHT;
|
||||||
BlkPos.vx=BlkXStore;
|
BlkPos.vx=BlkXStore;
|
||||||
BlkPos.vy+=TILE_HEIGHT*BLOCK_MULT;
|
BlkPos.vy+=TILE_HEIGHT*BLOCK_MULT;
|
||||||
}
|
}
|
||||||
|
SetPrimPtr(PrimPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -240,27 +142,22 @@ s16 *RenderFlags=RenderFlagTable;
|
|||||||
// NOTE: Tiles are split into facing strips, to reduce overdraw :o)
|
// NOTE: Tiles are split into facing strips, to reduce overdraw :o)
|
||||||
// NOTE: Matrix already setup for block
|
// NOTE: Matrix already setup for block
|
||||||
|
|
||||||
void CLayerTile3d::RenderBlock(sPrimGridElem3d *Elem,s16 RenderFlags)
|
u8 *CLayerTile3d::RenderBlock(sTile *Tile,s16 RenderFlags,u8 *PrimPtr)
|
||||||
{
|
{
|
||||||
sTile *Tile=&TileList[Elem->Tile];
|
|
||||||
u32 Flags=Elem->Flags & RenderFlags;
|
|
||||||
sVtx *P0,*P1,*P2;
|
sVtx *P0,*P1,*P2;
|
||||||
POLY_FT3 *TPrimPtr=(POLY_FT3*)GetPrimPtr();
|
POLY_FT3 *TPrimPtr=(POLY_FT3*)PrimPtr;
|
||||||
u16 *TileTable=Tile->TileTable;
|
u16 *TileTable=Tile->TileTable;
|
||||||
u32 T0,T1,T2;
|
u32 T0,T1,T2;
|
||||||
sTri *TList=TriList+Tile->TriStart;
|
sTri *TList=TriList+Tile->TriStart;
|
||||||
sOT *ThisOT=OtPtr+LayerOT;
|
sOT *ThisOT=OtPtr+LayerOT;
|
||||||
|
|
||||||
Flags=0xff & RenderFlags;
|
|
||||||
// Flags=0xff;// & RenderFlags;
|
|
||||||
|
|
||||||
//--- Tris ---------------------------------------------------------------------------
|
//--- Tris ---------------------------------------------------------------------------
|
||||||
|
|
||||||
for (int i=0; i<TILE3D_FLAGS_MAX; i++)
|
for (int i=0; i<TILE3D_FLAGS_MAX; i++)
|
||||||
{
|
{
|
||||||
int TriCount=*TileTable++; // Get Tri Count
|
int TriCount=*TileTable++; // Get Tri Count
|
||||||
sTri *NextList=TList+TriCount;
|
sTri *NextList=TList+TriCount;
|
||||||
// if (Flags & 1)
|
// if (RenderFlags & 1)
|
||||||
{
|
{
|
||||||
while (TriCount--)
|
while (TriCount--)
|
||||||
{
|
{
|
||||||
@ -285,8 +182,8 @@ sOT *ThisOT=OtPtr+LayerOT;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TList=NextList;
|
TList=NextList;
|
||||||
Flags>>=1;
|
RenderFlags>>=1;
|
||||||
}
|
}
|
||||||
SetPrimPtr((u8*)TPrimPtr);
|
return((u8*)TPrimPtr);
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -13,19 +13,15 @@ public:
|
|||||||
CLayerTile3d(sLayerHdr *Hdr,sTile *TileList,sTri *TriList,sQuad *QuadList,sVtx *VtxList);
|
CLayerTile3d(sLayerHdr *Hdr,sTile *TileList,sTri *TriList,sQuad *QuadList,sVtx *VtxList);
|
||||||
~CLayerTile3d();
|
~CLayerTile3d();
|
||||||
|
|
||||||
void init(DVECTOR &MapPos,int Shift,int Width,int Height);
|
void init(DVECTOR &MapPos,int Shift);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
sTileMapElem3d *GetMapPos3d() {return(((sTileMapElem3d*)Map)+GetMapOfs());}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreateRenderFlagTable();
|
void CreateRenderFlagTable();
|
||||||
void UpdateRow(int MapX,int MapY);
|
u8 *RenderBlock(sTile *Tile,s16 RenderFlags,u8 *PrimPtr);
|
||||||
void UpdateColumn(int MapX,int MapY);
|
|
||||||
|
|
||||||
sPrimGridElem3d *GetGridPos3d(int X,int Y);
|
|
||||||
sTileMapElem3d *GetMapPos3d(int X,int Y);
|
|
||||||
|
|
||||||
void RenderBlock(sPrimGridElem3d *Elem,s16 RenderFlags);
|
|
||||||
|
|
||||||
s16 *RenderFlagTable;
|
s16 *RenderFlagTable;
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "level\level.h"
|
#include "level\level.h"
|
||||||
#include "level\layertile.h"
|
#include "level\layertile.h"
|
||||||
#include "level\layerback.h"
|
#include "level\layerback.h"
|
||||||
#include "level\layertilesolid.h"
|
|
||||||
#include "level\layertile3d.h"
|
#include "level\layertile3d.h"
|
||||||
#include "level\layercollision.h"
|
#include "level\layercollision.h"
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ int MAP3D_CENTRE_Y=500;
|
|||||||
int MAP3D_BLOCKSTEPSIZE=315;
|
int MAP3D_BLOCKSTEPSIZE=315;
|
||||||
|
|
||||||
int MAP2D_CENTRE_X=-256;
|
int MAP2D_CENTRE_X=-256;
|
||||||
int MAP2D_CENTRE_Y=-136;
|
int MAP2D_CENTRE_Y=-136-(4*16);
|
||||||
int MAP2D_BLOCKSTEPSIZE=16;
|
int MAP2D_BLOCKSTEPSIZE=16;
|
||||||
|
|
||||||
int CAMERA_SCROLLLIMIT=8; // SB is this many tiles off centre at most
|
int CAMERA_SCROLLLIMIT=8; // SB is this many tiles off centre at most
|
||||||
|
Loading…
Reference in New Issue
Block a user