This commit is contained in:
parent
ff9329d718
commit
389110e981
5 changed files with 64 additions and 65 deletions
|
@ -81,7 +81,8 @@ int CLayerCollision::getHeightFromGround(int _x,int _y,int _maxHeight)
|
||||||
int maxHeightToCheck;
|
int maxHeightToCheck;
|
||||||
|
|
||||||
mapX=_x>>4;
|
mapX=_x>>4;
|
||||||
mapY=(_y>>4)*MapWidth;
|
// mapY=(_y>>4)*MapWidth;
|
||||||
|
mapY=GetYPos(_y>>4);
|
||||||
xFraction=_x&0x0f;
|
xFraction=_x&0x0f;
|
||||||
yFraction=16-(_y&0x0f);
|
yFraction=16-(_y&0x0f);
|
||||||
distanceFromGround=0;
|
distanceFromGround=0;
|
||||||
|
@ -135,7 +136,8 @@ int CLayerCollision::getHeightFromGroundExcluding(int _x,int _y,int _exclusion
|
||||||
int maxHeightToCheck;
|
int maxHeightToCheck;
|
||||||
|
|
||||||
mapX=_x>>4;
|
mapX=_x>>4;
|
||||||
mapY=(_y>>4)*MapWidth;
|
// mapY=(_y>>4)*MapWidth;
|
||||||
|
mapY=GetYPos(_y>>4);
|
||||||
xFraction=_x&0x0f;
|
xFraction=_x&0x0f;
|
||||||
yFraction=16-(_y&0x0f);
|
yFraction=16-(_y&0x0f);
|
||||||
distanceFromGround=0;
|
distanceFromGround=0;
|
||||||
|
@ -201,7 +203,8 @@ int CLayerCollision::getHeightFromGroundCart(int _x,int _y,int _maxHeight)
|
||||||
int maxHeightToCheck;
|
int maxHeightToCheck;
|
||||||
|
|
||||||
mapX=_x>>4;
|
mapX=_x>>4;
|
||||||
mapY=(_y>>4)*MapWidth;
|
// mapY=(_y>>4)*MapWidth;
|
||||||
|
mapY=GetYPos(_y>>4);
|
||||||
xFraction=_x&0x0f;
|
xFraction=_x&0x0f;
|
||||||
yFraction=16-(_y&0x0f);
|
yFraction=16-(_y&0x0f);
|
||||||
distanceFromGround=0;
|
distanceFromGround=0;
|
||||||
|
@ -315,7 +318,8 @@ void CLayerCollision::render(DVECTOR &MapPos)
|
||||||
mapy=MapPos.vy/16;
|
mapy=MapPos.vy/16;
|
||||||
for(y=-yoff;y<(20*16)-yoff;y+=16)
|
for(y=-yoff;y<(20*16)-yoff;y+=16)
|
||||||
{
|
{
|
||||||
coll=&Map[mapx+(mapy*MapWidth)];
|
// coll=&Map[mapx+(mapy*MapWidth)];
|
||||||
|
coll=&Map[mapx+(GetYPos(mapy))];
|
||||||
for(x=-xoff;x<(33*16)-xoff;x+=16)
|
for(x=-xoff;x<(33*16)-xoff;x+=16)
|
||||||
{
|
{
|
||||||
colour=&s_typeColours[((*coll)&COLLISION_TYPE_MASK)>>COLLISION_TYPE_FLAG_SHIFT];
|
colour=&s_typeColours[((*coll)&COLLISION_TYPE_MASK)>>COLLISION_TYPE_FLAG_SHIFT];
|
||||||
|
|
|
@ -18,6 +18,8 @@ static const int TILE2D_WIDTH=16;
|
||||||
static const int TILE2D_HEIGHT=12;
|
static const int TILE2D_HEIGHT=12;
|
||||||
static const int SCREEN_TILE2D_WIDTH=((512/TILE2D_WIDTH)+1);
|
static const int SCREEN_TILE2D_WIDTH=((512/TILE2D_WIDTH)+1);
|
||||||
static const int SCREEN_TILE2D_HEIGHT=((256/TILE2D_HEIGHT)+1);
|
static const int SCREEN_TILE2D_HEIGHT=((256/TILE2D_HEIGHT)+1);
|
||||||
|
static const int PrimCount=SCREEN_TILE2D_WIDTH*SCREEN_TILE2D_HEIGHT;
|
||||||
|
static const int PrimMemSize=PrimCount*sizeof(TSPRT);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -25,9 +27,6 @@ static const int SCREEN_TILE2D_HEIGHT=((256/TILE2D_HEIGHT)+1);
|
||||||
|
|
||||||
CLayerTile::CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr)
|
CLayerTile::CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr)
|
||||||
{
|
{
|
||||||
int Count=SCREEN_TILE2D_WIDTH*SCREEN_TILE2D_HEIGHT;
|
|
||||||
int MemSize=Count*sizeof(TSPRT);
|
|
||||||
|
|
||||||
LayerHdr=Hdr;
|
LayerHdr=Hdr;
|
||||||
MapWidth=LayerHdr->Width;
|
MapWidth=LayerHdr->Width;
|
||||||
MapHeight=LayerHdr->Height;
|
MapHeight=LayerHdr->Height;
|
||||||
|
@ -35,23 +34,31 @@ int MemSize=Count*sizeof(TSPRT);
|
||||||
ElemBank2d=LevelHdr->ElemBank2d;
|
ElemBank2d=LevelHdr->ElemBank2d;
|
||||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||||
|
|
||||||
PrimBank=(TSPRT*)MemAlloc(MemSize,"Mid Polyz");
|
PrimBankID=0;
|
||||||
|
|
||||||
TSPRT *PrimPtr=PrimBank;
|
for (int b=0; b<2; b++)
|
||||||
for (int i=0; i<Count; i++)
|
|
||||||
{
|
{
|
||||||
setTSprt(PrimPtr);
|
PrimBank[b]=(TSPRT*)MemAlloc(PrimMemSize,"Mid Polyz");
|
||||||
setTSetShadeTex(PrimPtr,1);
|
TSPRT *PrimPtr=PrimBank[b];
|
||||||
PrimPtr->w=TILE2D_WIDTH;
|
for (int i=0; i<PrimCount; i++)
|
||||||
PrimPtr->h=TILE2D_HEIGHT;
|
{
|
||||||
PrimPtr++;
|
setTSprt(PrimPtr);
|
||||||
|
setTSetShadeTex(PrimPtr,1);
|
||||||
|
PrimPtr->w=TILE2D_WIDTH;
|
||||||
|
PrimPtr->h=TILE2D_HEIGHT;
|
||||||
|
PrimPtr++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerTile::~CLayerTile()
|
CLayerTile::~CLayerTile()
|
||||||
{
|
{
|
||||||
MemFree(PrimBank);
|
for (int b=0; b<2; b++)
|
||||||
|
{
|
||||||
|
MemFree(PrimBank[b]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -113,7 +120,9 @@ void CLayerTile::render()
|
||||||
sTileMapElem *MapPtr=Map+GetMapOfs();
|
sTileMapElem *MapPtr=Map+GetMapOfs();
|
||||||
s16 TileX,TileY;
|
s16 TileX,TileY;
|
||||||
sOT *ThisOT=OtPtr+LayerOT;
|
sOT *ThisOT=OtPtr+LayerOT;
|
||||||
TSPRT *PrimPtr=PrimBank;
|
TSPRT *PrimPtr=PrimBank[PrimBankID];
|
||||||
|
|
||||||
|
PrimBankID^=1;
|
||||||
|
|
||||||
// Setup shift bits of pos
|
// Setup shift bits of pos
|
||||||
TileY=-ShiftY;
|
TileY=-ShiftY;
|
||||||
|
@ -128,7 +137,6 @@ TSPRT *PrimPtr=PrimBank;
|
||||||
for (int X=0; X<RenderW; X++)
|
for (int X=0; X<RenderW; X++)
|
||||||
{
|
{
|
||||||
int ThisTile=MapRow->Tile;
|
int ThisTile=MapRow->Tile;
|
||||||
MapRow++;
|
|
||||||
if (ThisTile)
|
if (ThisTile)
|
||||||
{
|
{
|
||||||
sElem2d *Tile=&ElemBank2d[ThisTile];
|
sElem2d *Tile=&ElemBank2d[ThisTile];
|
||||||
|
@ -139,6 +147,7 @@ TSPRT *PrimPtr=PrimBank;
|
||||||
addPrim(ThisOT,PrimPtr);
|
addPrim(ThisOT,PrimPtr);
|
||||||
PrimPtr++;
|
PrimPtr++;
|
||||||
}
|
}
|
||||||
|
MapRow++;
|
||||||
TileX+=TILE2D_WIDTH;
|
TileX+=TILE2D_WIDTH;
|
||||||
}
|
}
|
||||||
MapPtr+=MapWidth;
|
MapPtr+=MapWidth;
|
||||||
|
|
|
@ -48,7 +48,8 @@ protected:
|
||||||
u16 ShiftX,ShiftY;
|
u16 ShiftX,ShiftY;
|
||||||
|
|
||||||
sTileMapElem *Map;
|
sTileMapElem *Map;
|
||||||
TSPRT *PrimBank;
|
TSPRT *PrimBank[2];
|
||||||
|
int PrimBankID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
#if defined(__USER_sbart__) || defined(__USER_daveo__)
|
#if defined(__USER_sbart__) // || defined(__USER_daveo__)
|
||||||
#define _SHOW_POLYZ_ 1
|
#define _SHOW_POLYZ_ 1
|
||||||
#include "gfx\font.h"
|
#include "gfx\font.h"
|
||||||
static FontBank *Font;
|
static FontBank *Font;
|
||||||
|
@ -405,10 +405,6 @@ s16 TCount=0,QCount=0;
|
||||||
setlen(ThisPrim, GPU_PolyGT3Tag);
|
setlen(ThisPrim, GPU_PolyGT3Tag);
|
||||||
gte_nclip_b(); // 8 cycles
|
gte_nclip_b(); // 8 cycles
|
||||||
|
|
||||||
#if defined(_SHOW_POLYZ_)
|
|
||||||
if (ShowPolyz) {setRGB0(ThisPrim,127,0,0); setRGB1(ThisPrim,255,0,0); setRGB2(ThisPrim,255,0,0);}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*(u32*)&ThisPrim->x0=T0; // Set XY0
|
*(u32*)&ThisPrim->x0=T0; // Set XY0
|
||||||
*(u32*)&ThisPrim->x1=T1; // Set XY1
|
*(u32*)&ThisPrim->x1=T1; // Set XY1
|
||||||
*(u32*)&ThisPrim->x2=T2; // Set XY2
|
*(u32*)&ThisPrim->x2=T2; // Set XY2
|
||||||
|
@ -424,25 +420,20 @@ s16 TCount=0,QCount=0;
|
||||||
*(u32*)&ThisPrim->u1=T1; // Set UV1
|
*(u32*)&ThisPrim->u1=T1; // Set UV1
|
||||||
*(u32*)&ThisPrim->u2=T2; // Set UV2
|
*(u32*)&ThisPrim->u2=T2; // Set UV2
|
||||||
addPrim(ThisOT,ThisPrim);
|
addPrim(ThisOT,ThisPrim);
|
||||||
|
{ // lighting
|
||||||
|
T0=*(u32*)&RGB[TList->C0];
|
||||||
|
T1=*(u32*)&RGB[TList->C1];
|
||||||
|
T2=*(u32*)&RGB[TList->C2];
|
||||||
|
*(u32*)&ThisPrim->r0=T0;
|
||||||
|
*(u32*)&ThisPrim->r1=T1;
|
||||||
|
*(u32*)&ThisPrim->r2=T2;
|
||||||
|
}
|
||||||
#if defined(_SHOW_POLYZ_)
|
#if defined(_SHOW_POLYZ_)
|
||||||
if (!ShowPolyz)
|
if (ShowPolyz) {setRGB0(ThisPrim,127,0,0); setRGB1(ThisPrim,255,0,0); setRGB2(ThisPrim,255,0,0); TCount++;}
|
||||||
#endif
|
#endif
|
||||||
{ // lighting
|
|
||||||
T0=*(u32*)&RGB[TList->C0];
|
|
||||||
T1=*(u32*)&RGB[TList->C1];
|
|
||||||
T2=*(u32*)&RGB[TList->C2];
|
|
||||||
*(u32*)&ThisPrim->r0=T0;
|
|
||||||
*(u32*)&ThisPrim->r1=T1;
|
|
||||||
*(u32*)&ThisPrim->r2=T2;
|
|
||||||
}
|
|
||||||
ThisPrim->code=TList->PolyCode;
|
ThisPrim->code=TList->PolyCode;
|
||||||
|
|
||||||
PrimPtr+=sizeof(POLY_GT3);
|
PrimPtr+=sizeof(POLY_GT3);
|
||||||
#if defined(_SHOW_POLYZ_)
|
|
||||||
TCount++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
TList++;
|
TList++;
|
||||||
}
|
}
|
||||||
|
@ -452,10 +443,10 @@ s16 TCount=0,QCount=0;
|
||||||
{
|
{
|
||||||
POLY_GT4 *ThisPrim=(POLY_GT4*)PrimPtr;
|
POLY_GT4 *ThisPrim=(POLY_GT4*)PrimPtr;
|
||||||
|
|
||||||
T0=*(u32*)(XYList+(QList->P0/*4*/));
|
T0=*(u32*)(XYList+QList->P0);
|
||||||
T1=*(u32*)(XYList+(QList->P1/*4*/));
|
T1=*(u32*)(XYList+QList->P1);
|
||||||
T2=*(u32*)(XYList+(QList->P2/*4*/));
|
T2=*(u32*)(XYList+QList->P2);
|
||||||
T3=*(u32*)(XYList+(QList->P3/*4*/));
|
T3=*(u32*)(XYList+QList->P3);
|
||||||
gte_ldsxy0(T0);
|
gte_ldsxy0(T0);
|
||||||
gte_ldsxy1(T1);
|
gte_ldsxy1(T1);
|
||||||
gte_ldsxy2(T2);
|
gte_ldsxy2(T2);
|
||||||
|
@ -463,10 +454,6 @@ s16 TCount=0,QCount=0;
|
||||||
setlen(ThisPrim, GPU_PolyGT4Tag);
|
setlen(ThisPrim, GPU_PolyGT4Tag);
|
||||||
gte_nclip_b(); // 8 cycles
|
gte_nclip_b(); // 8 cycles
|
||||||
|
|
||||||
#if defined(_SHOW_POLYZ_)
|
|
||||||
if (ShowPolyz) {setRGB0(ThisPrim,0,127,0);setRGB1(ThisPrim,0,255,0); setRGB2(ThisPrim,0,255,0); setRGB3(ThisPrim,0,255,0);}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*(u32*)&ThisPrim->x0=T0; // Set XY0
|
*(u32*)&ThisPrim->x0=T0; // Set XY0
|
||||||
*(u32*)&ThisPrim->x1=T1; // Set XY1
|
*(u32*)&ThisPrim->x1=T1; // Set XY1
|
||||||
*(u32*)&ThisPrim->x2=T2; // Set XY2
|
*(u32*)&ThisPrim->x2=T2; // Set XY2
|
||||||
|
@ -484,26 +471,23 @@ s16 TCount=0,QCount=0;
|
||||||
*(u32*)&ThisPrim->u1=T1; // Set UV1
|
*(u32*)&ThisPrim->u1=T1; // Set UV1
|
||||||
*(u32*)&ThisPrim->u2=T2; // Set UV2
|
*(u32*)&ThisPrim->u2=T2; // Set UV2
|
||||||
*(u32*)&ThisPrim->u3=T3; // Set UV2
|
*(u32*)&ThisPrim->u3=T3; // Set UV2
|
||||||
|
{ // Lighting
|
||||||
|
T0=*(u32*)&RGB[QList->C0];
|
||||||
|
T1=*(u32*)&RGB[QList->C1];
|
||||||
|
T2=*(u32*)&RGB[QList->C2];
|
||||||
|
T3=*(u32*)&RGB[QList->C3];
|
||||||
|
*(u32*)&ThisPrim->r0=T0;
|
||||||
|
*(u32*)&ThisPrim->r1=T1;
|
||||||
|
*(u32*)&ThisPrim->r2=T2;
|
||||||
|
*(u32*)&ThisPrim->r3=T3;
|
||||||
|
}
|
||||||
#if defined(_SHOW_POLYZ_)
|
#if defined(_SHOW_POLYZ_)
|
||||||
if (!ShowPolyz)
|
if (ShowPolyz) {setRGB0(ThisPrim,0,127,0);setRGB1(ThisPrim,0,255,0); setRGB2(ThisPrim,0,255,0); setRGB3(ThisPrim,0,255,0); QCount++;}
|
||||||
#endif
|
#endif
|
||||||
{ // Lighting
|
|
||||||
T0=*(u32*)&RGB[QList->C0];
|
|
||||||
T1=*(u32*)&RGB[QList->C1];
|
|
||||||
T2=*(u32*)&RGB[QList->C2];
|
|
||||||
T3=*(u32*)&RGB[QList->C3];
|
|
||||||
*(u32*)&ThisPrim->r0=T0;
|
|
||||||
*(u32*)&ThisPrim->r1=T1;
|
|
||||||
*(u32*)&ThisPrim->r2=T2;
|
|
||||||
*(u32*)&ThisPrim->r3=T3;
|
|
||||||
}
|
|
||||||
ThisPrim->code=QList->PolyCode;
|
ThisPrim->code=QList->PolyCode;
|
||||||
|
|
||||||
addPrim(ThisOT,ThisPrim);
|
addPrim(ThisOT,ThisPrim);
|
||||||
PrimPtr+=sizeof(POLY_GT4);
|
PrimPtr+=sizeof(POLY_GT4);
|
||||||
#if defined(_SHOW_POLYZ_)
|
|
||||||
QCount++;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
QList++;
|
QList++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
|
|
||||||
struct sFlipTable
|
struct sFlipTable
|
||||||
{
|
{
|
||||||
s16 Mtx[4];
|
s16 Mtx[4]; // 8
|
||||||
DVECTOR *DeltaTab[8];
|
DVECTOR *DeltaTab[8]; // 32
|
||||||
s32 ClipCode;
|
s32 ClipCode; // 4
|
||||||
|
s8 Pad[20];
|
||||||
};
|
};
|
||||||
extern sFlipTable FlipTable[];
|
extern sFlipTable FlipTable[];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue