SBSPSS/source/level/layerback.cpp

144 lines
4.2 KiB
C++
Raw Normal View History

2001-02-22 15:55:13 +01:00
/*************************/
/*** Shade Layer Class ***/
/*************************/
2001-01-13 18:04:56 +01:00
2001-06-21 21:19:15 +02:00
#include "system\vid.h"
2001-01-13 18:04:56 +01:00
#include "system\global.h"
#include <DStructs.h>
#include "utils\utils.h"
#include "gfx\prim.h"
2001-03-09 22:17:14 +01:00
#include "gfx\sprbank.h"
2001-01-13 18:04:56 +01:00
#include "LayerTile.h"
2001-01-15 16:22:33 +01:00
#include "LayerBack.h"
2001-01-13 18:04:56 +01:00
2001-04-04 02:16:26 +02:00
#include "Game\game.h"
2001-03-09 22:17:14 +01:00
2001-01-13 18:04:56 +01:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-04-19 17:12:21 +02:00
CLayerBack::CLayerBack(sLevelHdr *LevelHdr,sLayerHdr *Hdr) : CLayerTile(LevelHdr,Hdr)
2001-01-13 18:04:56 +01:00
{
2001-02-20 20:17:03 +01:00
Data=(sLayerShadeHdr*)MakePtr(Hdr,sizeof(sLayerHdr));
2001-02-20 16:56:16 +01:00
2001-05-03 22:50:32 +02:00
Data->GfxList=(sLayerShadeBackGfx*)MakePtr(Hdr,(int)Data->GfxList);
Data->TypeList=(sLayerShadeBackGfxType*)MakePtr(Hdr,(int)Data->TypeList);
2001-04-30 23:49:54 +02:00
ASSERT(Data->BandCount<=LAYER_SHADE_RGB_MAX);
BandCount=Data->BandCount-1;
2001-01-13 18:04:56 +01:00
}
/*****************************************************************************/
2001-01-15 16:22:33 +01:00
CLayerBack::~CLayerBack()
2001-01-13 18:04:56 +01:00
{
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-02-22 15:55:13 +01:00
void CLayerBack::init(DVECTOR &MapPos,int Shift)
2001-01-13 18:04:56 +01:00
{
2001-02-20 20:17:03 +01:00
MapXYShift=Shift;
2001-02-22 15:55:13 +01:00
BandHeight=(MapHeight*16)/(BandCount);
if (BandHeight>=512) BandHeight=511;
2001-02-20 20:17:03 +01:00
for (int i=0; i<BandCount; i++)
{
SetPolyG4(&Band[i]);
2001-04-30 23:49:54 +02:00
setRGB0(&Band[i],Data->RGB[i+0][0],Data->RGB[i+0][1],Data->RGB[i+0][2]);
setRGB1(&Band[i],Data->RGB[i+0][0],Data->RGB[i+0][1],Data->RGB[i+0][2]);
setRGB2(&Band[i],Data->RGB[i+1][0],Data->RGB[i+1][1],Data->RGB[i+1][2]);
setRGB3(&Band[i],Data->RGB[i+1][0],Data->RGB[i+1][1],Data->RGB[i+1][2]);
2001-02-20 20:17:03 +01:00
}
2001-03-09 22:17:14 +01:00
2001-05-04 20:47:12 +02:00
2001-03-09 23:10:53 +01:00
XOfs=MapPos.vy;
YOfs=MapPos.vy;
}
2001-01-13 18:04:56 +01:00
/*****************************************************************************/
2001-01-15 16:22:33 +01:00
void CLayerBack::shutdown()
2001-01-13 18:04:56 +01:00
{
}
2001-03-09 22:17:14 +01:00
/*****************************************************************************/
2001-01-15 16:22:33 +01:00
void CLayerBack::think(DVECTOR &MapPos)
2001-02-20 16:56:16 +01:00
{
2001-05-04 20:47:12 +02:00
XOfs=MapPos.vx>>MapXYShift;
YOfs=MapPos.vy>>MapXYShift;
2001-03-09 22:17:14 +01:00
2001-05-02 01:27:30 +02:00
if (YOfs<1) YOfs=1;
2001-01-13 18:04:56 +01:00
}
/*****************************************************************************/
2001-05-04 20:47:12 +02:00
const int BM=16;
const int BB=16;
2001-08-17 19:06:29 +02:00
2001-01-15 16:22:33 +01:00
void CLayerBack::render()
2001-01-13 18:04:56 +01:00
{
2001-05-03 22:50:32 +02:00
sOT *ThisOT=OtPtr+(MAX_OT-1);
int i,ThisY=-YOfs;
2001-03-09 22:17:14 +01:00
// Render Back Sprites
2001-05-03 22:50:32 +02:00
sLayerShadeBackGfx *GfxList=Data->GfxList;
2001-03-09 22:17:14 +01:00
2001-05-03 22:50:32 +02:00
for (i=0; i<Data->GfxCount; i++)
2001-03-09 22:17:14 +01:00
{
2001-05-04 20:47:12 +02:00
int PosX=(GfxList->PosX*BB)-XOfs;
int PosY=(GfxList->PosY*BB)-YOfs;
2001-06-21 21:19:15 +02:00
if (PosX>0-64 && PosX<INGAME_SCREENW+64)
if (PosY>0-64 && PosY<INGAME_SCREENH+64)
2001-05-29 17:43:22 +02:00
{
POLY_GT4 *sGt4,*Gt4=GetPrimGT4();
sLayerShadeBackGfxType &ThisType=Data->TypeList[GfxList->Type];
Gt4->x0=PosX+(GfxList->Ofs[0][0])*BM; Gt4->y0=PosY+(GfxList->Ofs[0][1])*BM;
Gt4->x1=PosX+(GfxList->Ofs[1][0])*BM; Gt4->y1=PosY+(GfxList->Ofs[1][1])*BM;
Gt4->x2=PosX+(GfxList->Ofs[2][0])*BM; Gt4->y2=PosY+(GfxList->Ofs[2][1])*BM;
Gt4->x3=PosX+(GfxList->Ofs[3][0])*BM; Gt4->y3=PosY+(GfxList->Ofs[3][1])*BM;
setRGB0(Gt4,GfxList->RGB[0][0]>>1,GfxList->RGB[0][1]>>1,GfxList->RGB[0][2]>>1);
setRGB1(Gt4,GfxList->RGB[1][0]>>1,GfxList->RGB[1][1]>>1,GfxList->RGB[1][2]>>1);
setRGB2(Gt4,GfxList->RGB[2][0]>>1,GfxList->RGB[2][1]>>1,GfxList->RGB[2][2]>>1);
setRGB3(Gt4,GfxList->RGB[3][0]>>1,GfxList->RGB[3][1]>>1,GfxList->RGB[3][2]>>1);
setUVWH(Gt4,ThisType.U,ThisType.V,ThisType.W,ThisType.H);
Gt4->u1--; Gt4->u3--;
Gt4->v2--; Gt4->v3--;
Gt4->clut=ThisType.Clut;
setSemiTrans(Gt4,1);
Gt4->tpage=ThisType.TPage;// | GfxList->Trans<<5;
AddPrim(ThisOT,Gt4);
}
2001-05-04 20:47:12 +02:00
/*
// Bodge it cos artist made the fuckers too big
sGt4=GetPrimGT4(); *sGt4=*Gt4;
Gt4->x0--; Gt4->y0--; Gt4->x1++; Gt4->y1--; Gt4->x2--; Gt4->y2++; Gt4->x3++; Gt4->y3++;
AddPrim(ThisOT,sGt4);
*/
2001-05-03 22:50:32 +02:00
GfxList++;
2001-03-09 22:17:14 +01:00
}
// Render Back Shade
2001-05-02 01:27:30 +02:00
2001-05-03 22:50:32 +02:00
2001-05-05 21:42:49 +02:00
if (BandHeight>256) BandHeight=256;
// if (ThisY<0) BandHeight=256;
2001-03-09 22:17:14 +01:00
for (i=0; i<BandCount; i++)
2001-02-20 20:17:03 +01:00
{
2001-06-21 21:19:15 +02:00
setXYWH(&Band[i],0,ThisY,INGAME_SCREENW,BandHeight);
2001-02-20 20:17:03 +01:00
addPrim(ThisOT,&Band[i]);
ThisY+=BandHeight;
}
2001-04-28 01:05:14 +02:00
if (Band[BandCount-1].y1<0)
{
Band[BandCount-1].y0=0;
Band[BandCount-1].y1=0;
Band[BandCount-1].y2=256;
Band[BandCount-1].y3=256;
}
2001-01-13 18:04:56 +01:00
}