diff --git a/Utils/Libs/DaveLib/facestore.cpp b/Utils/Libs/DaveLib/facestore.cpp index 4810c88f8..e210e4d8f 100644 --- a/Utils/Libs/DaveLib/facestore.cpp +++ b/Utils/Libs/DaveLib/facestore.cpp @@ -256,7 +256,8 @@ int V=ThisTex.v+H; Out.TPage=ThisTex.Tpage; Out.Clut=ThisTex.Clut; - Out.PolyCode=GPU_PolyFT3Code; +// Out.PolyCode=GPU_PolyFT3Code; + Out.PolyCode=GPU_PolyGT3Code; if (In.TPageFlag) { @@ -319,7 +320,8 @@ int V=ThisTex.v+H; Out.TPage=ThisTex.Tpage; Out.Clut=ThisTex.Clut; - Out.PolyCode=GPU_PolyFT4Code; +// Out.PolyCode=GPU_PolyFT4Code; + Out.PolyCode=GPU_PolyGT4Code; if (In.TPageFlag) { @@ -393,9 +395,29 @@ int ListSize=OutTriList.size(); ParseVtx4BBox(OutVtxList[OutFace.P0]); ParseVtx4BBox(OutVtxList[OutFace.P1]); ParseVtx4BBox(OutVtxList[OutFace.P2]); + // Materials and other shit SetupUV(InFace,OutFace); OutFace.OTOfs=InFace.OtOfs; + +// RGB Shite +int ZOfs=+4*Scale; + int Z[3]; + + Z[0]=(OutVtxList[OutFace.P0].vz+ZOfs)/8; + Z[1]=(OutVtxList[OutFace.P1].vz+ZOfs)/8; + Z[2]=(OutVtxList[OutFace.P2].vz+ZOfs)/8; + + for (int p=0; p<3; p++) + { + if (Z[p]<0 ) Z[p]=0; + if (Z[p]>15) Z[p]=15; + + } + + OutFace.C0=Z[0]*4; + OutFace.C1=Z[1]*4; + OutFace.C2=Z[2]*4; } } @@ -425,6 +447,26 @@ int ListSize=OutQuadList.size(); // Materials and other shit SetupUV(InFace,OutFace); OutFace.OTOfs=InFace.OtOfs; +// RGB Shite +int ZOfs=+4*Scale; + int Z[4]; + + Z[0]=(OutVtxList[OutFace.P0].vz+ZOfs)/8; + Z[1]=(OutVtxList[OutFace.P1].vz+ZOfs)/8; + Z[2]=(OutVtxList[OutFace.P2].vz+ZOfs)/8; + Z[3]=(OutVtxList[OutFace.P3].vz+ZOfs)/8; + + for (int p=0; p<4; p++) + { + if (Z[p]<0 ) Z[p]=0; + if (Z[p]>15) Z[p]=15; + + } + + OutFace.C0=Z[0]*4; + OutFace.C1=Z[1]*4; + OutFace.C2=Z[2]*4; + OutFace.C3=Z[3]*4; } } diff --git a/Utils/MkLevel/MkLevel.cpp b/Utils/MkLevel/MkLevel.cpp index 6eaac6458..b52b60827 100644 --- a/Utils/MkLevel/MkLevel.cpp +++ b/Utils/MkLevel/MkLevel.cpp @@ -1050,8 +1050,8 @@ int i,ListSize; //*************************************************************************** int CMkLevel::WriteTriList() { -int ThisPos=ftell(File); -int i,ListSize=OutTriList.size(); +int ThisPos=ftell(File); +int i,ListSize=OutTriList.size(); for (i=0;iAnimList+Anim; Ft4->tpage=ThisNode->TPage; Ft4->clut=PoolEntry->ActorGfx->Clut; setShadeTex(Ft4,1); + setRGB0(Ft4,127,127,127); addPrim(OtPtr+OtPos,Ft4); // Set BBox // Sizes now depend on aspect corrected sizes, so get sizes back from poly @@ -921,7 +922,7 @@ u32 const *XYList=(u32*)SCRATCH_RAM; sTri *TList=&TriList[ThisElem->TriStart]; while (TriCount--) { - POLY_FT3 *ThisPrim=(POLY_FT3*)PrimPtr; + POLY_GT3 *ThisPrim=(POLY_GT3*)PrimPtr; P0=XYList[TList->P0]; P1=XYList[TList->P1]; @@ -930,7 +931,7 @@ u32 const *XYList=(u32*)SCRATCH_RAM; gte_ldsxy1(P1); gte_ldsxy2(P2); - setlen(ThisPrim, GPU_PolyFT3Tag); + setlen(ThisPrim, GPU_PolyGT3Tag); ThisPrim->code=TList->PolyCode; gte_nclip_b(); // 8 cycles @@ -953,7 +954,7 @@ u32 const *XYList=(u32*)SCRATCH_RAM; *(u32*)&ThisPrim->x1=P1; // Set XY1 *(u32*)&ThisPrim->x2=P2; // Set XY2 addPrim(ThisOT,ThisPrim); - PrimPtr+=sizeof(POLY_FT3); + PrimPtr+=sizeof(POLY_GT3); } } @@ -962,7 +963,7 @@ u32 const *XYList=(u32*)SCRATCH_RAM; sQuad *QList=&QuadList[ThisElem->QuadStart]; while (QuadCount--) { - POLY_FT4 *ThisPrim=(POLY_FT4*)PrimPtr; + POLY_GT4 *ThisPrim=(POLY_GT4*)PrimPtr; P0=XYList[QList->P0]; P1=XYList[QList->P1]; @@ -972,7 +973,7 @@ u32 const *XYList=(u32*)SCRATCH_RAM; gte_ldsxy1(P1); gte_ldsxy2(P2); - setlen(ThisPrim, GPU_PolyFT4Tag); + setlen(ThisPrim, GPU_PolyGT4Tag); ThisPrim->code=QList->PolyCode; gte_nclip_b(); // 8 cycles @@ -997,7 +998,7 @@ u32 const *XYList=(u32*)SCRATCH_RAM; *(u32*)&ThisPrim->x2=P2; // Set XY2 *(u32*)&ThisPrim->x3=P3; // Set XY3 addPrim(ThisOT,ThisPrim); - PrimPtr+=sizeof(POLY_FT4); + PrimPtr+=sizeof(POLY_GT4); } } diff --git a/source/level/layertile3d.cpp b/source/level/layertile3d.cpp index 4dab60156..2f41b3f41 100644 --- a/source/level/layertile3d.cpp +++ b/source/level/layertile3d.cpp @@ -87,6 +87,16 @@ sFlipTable FlipTable[4]= },0<<31} }; +u8 RGBTable[16*4]; +int RS=128; +int Ri=-6; +int GS=128; +int Gi=-6; +int BS=128; +int Bi=-6; +int AS=128; +int Ai=-6; + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ @@ -98,12 +108,29 @@ CLayerTile3d::CLayerTile3d(sLevelHdr *LevelHdr,sLayerHdr *Hdr) : CLayerTile(Leve VtxList=LevelHdr->VtxList; VtxIdxList=LevelHdr->VtxIdxList; + #if defined(_SHOW_POLYZ_) Font=new ("PrimFont") FontBank; Font->initialise( &standardFont ); Font->setOt( 0 ); Font->setTrans(1); #endif + for (int i=0; i<16; i++) + { + int R,G,B; + R=RS-(i*Ri); + G=GS-(i*Gi); + B=BS-(i*Bi); + if (R<0) R=0; else if (R>255) R=255; + if (G<0) G=0; else if (G>255) G=255; + if (B<0) B=0; else if (B>255) B=255; + + RGBTable[(i*4)+0]=R; + RGBTable[(i*4)+1]=G; + RGBTable[(i*4)+2]=B; + RGBTable[(i*4)+3]=0; + } + } /*****************************************************************************/ @@ -236,6 +263,33 @@ void CLayerTile3d::think(DVECTOR &MapPos) RenderH=SCREEN_TILE3D_HEIGHT; else RenderH=MapHeight-MapXY.vy; + +#if defined(__USER_daveo__) + if (AS!=-1) + { + RS=GS=BS=AS; + } + if (Ai!=-1) + { + Ri=Gi=Bi=Ai; + } + + for (int i=0; i<16; i++) + { + int R,G,B; + R=RS-(i*Ri); + G=GS-(i*Gi); + B=BS-(i*Bi); + if (R<0) R=0; else if (R>255) R=255; + if (G<0) G=0; else if (G>255) G=255; + if (B<0) B=0; else if (B>255) B=255; + + RGBTable[(i*4)+0]=R; + RGBTable[(i*4)+1]=G; + RGBTable[(i*4)+2]=B; + RGBTable[(i*4)+3]=0; + } +#endif } /*****************************************************************************/ @@ -386,7 +440,7 @@ s16 TCount=0,QCount=0; // --- Render Tri's ------------- while (TriCount--) { - POLY_FT3 *ThisPrim=(POLY_FT3*)PrimPtr; + POLY_GT3 *ThisPrim=(POLY_GT3*)PrimPtr; P0=XYList[TList->P0]; P1=XYList[TList->P1]; @@ -395,13 +449,14 @@ s16 TCount=0,QCount=0; gte_ldsxy1(P1); gte_ldsxy2(P2); - setlen(ThisPrim, GPU_PolyFT3Tag); + setlen(ThisPrim, GPU_PolyGT3Tag); ThisPrim->code=TList->PolyCode; gte_nclip_b(); // 8 cycles setShadeTex(ThisPrim,1); + #if defined(_SHOW_POLYZ_) - if (ShowPolyz) {setShadeTex(ThisPrim,0);setRGB0(ThisPrim,127,0,0);} + if (ShowPolyz) {setShadeTex(ThisPrim,0);setRGB0(ThisPrim,127,0,0); setRGB1(ThisPrim,255,0,0); setRGB2(ThisPrim,255,0,0);} #endif T0=*(u32*)&TList->uv0; // Get UV0 & TPage @@ -413,25 +468,35 @@ s16 TCount=0,QCount=0; gte_stopz(&ClipZ); ThisOT=OtPtr+TList->OTOfs; ClipZ^=FTab->ClipCode; - TList++; if (ClipZ<0) { *(u32*)&ThisPrim->x0=P0; // Set XY0 *(u32*)&ThisPrim->x1=P1; // Set XY1 *(u32*)&ThisPrim->x2=P2; // Set XY2 addPrim(ThisOT,ThisPrim); - PrimPtr+=sizeof(POLY_FT3); + // lighting + setShadeTex(ThisPrim,0); + T0=*(u32*)&RGBTable[TList->C0]; + T1=*(u32*)&RGBTable[TList->C1]; + T2=*(u32*)&RGBTable[TList->C2]; + *(u32*)&ThisPrim->r0=T0; + *(u32*)&ThisPrim->r1=T1; + *(u32*)&ThisPrim->r2=T2; + ThisPrim->code=TList->PolyCode; + + PrimPtr+=sizeof(POLY_GT3); #if defined(_SHOW_POLYZ_) TCount++; #endif } + TList++; } // --- Render Quads ----------- while (QuadCount--) { - POLY_FT4 *ThisPrim=(POLY_FT4*)PrimPtr; + POLY_GT4 *ThisPrim=(POLY_GT4*)PrimPtr; P0=XYList[QList->P0]; P1=XYList[QList->P1]; @@ -441,13 +506,13 @@ s16 TCount=0,QCount=0; gte_ldsxy1(P1); gte_ldsxy2(P2); - setlen(ThisPrim, GPU_PolyFT4Tag); + setlen(ThisPrim, GPU_PolyGT4Tag); ThisPrim->code=QList->PolyCode; gte_nclip_b(); // 8 cycles setShadeTex(ThisPrim,1); #if defined(_SHOW_POLYZ_) - if (ShowPolyz) {setShadeTex(ThisPrim,0);setRGB0(ThisPrim,0,127,0);} + if (ShowPolyz) {setShadeTex(ThisPrim,0);setRGB0(ThisPrim,0,127,0);setRGB1(ThisPrim,0,255,0); setRGB2(ThisPrim,0,255,0); setRGB3(ThisPrim,0,255,0);} #endif T0=*(u32*)&QList->uv0; // Get UV0 & TPage @@ -461,20 +526,31 @@ s16 TCount=0,QCount=0; gte_stopz(&ClipZ); ThisOT=OtPtr+QList->OTOfs; ClipZ^=FTab->ClipCode; - QList++; if (ClipZ<0) { *(u32*)&ThisPrim->x0=P0; // Set XY0 *(u32*)&ThisPrim->x1=P1; // Set XY1 *(u32*)&ThisPrim->x2=P2; // Set XY2 *(u32*)&ThisPrim->x3=P3; // Set XY3 + // Lighting + setShadeTex(ThisPrim,0); + T0=*(u32*)&RGBTable[QList->C0]; + T1=*(u32*)&RGBTable[QList->C1]; + T2=*(u32*)&RGBTable[QList->C2]; + T3=*(u32*)&RGBTable[QList->C3]; + *(u32*)&ThisPrim->r0=T0; + *(u32*)&ThisPrim->r1=T1; + *(u32*)&ThisPrim->r2=T2; + *(u32*)&ThisPrim->r3=T3; + ThisPrim->code=QList->PolyCode; + addPrim(ThisOT,ThisPrim); - PrimPtr+=sizeof(POLY_FT4); + PrimPtr+=sizeof(POLY_GT4); #if defined(_SHOW_POLYZ_) QCount++; #endif - } + QList++; } } diff --git a/tools/Data/bin/MkLevel.exe b/tools/Data/bin/MkLevel.exe index c3696d836..b28add9a8 100644 Binary files a/tools/Data/bin/MkLevel.exe and b/tools/Data/bin/MkLevel.exe differ diff --git a/tools/Data/include/dstructs.h b/tools/Data/include/dstructs.h index 6b9ddfd67..5a1edb64f 100644 --- a/tools/Data/include/dstructs.h +++ b/tools/Data/include/dstructs.h @@ -63,7 +63,7 @@ struct sShortXYZ //*************************************************************************** struct sVtx { - s16 vx, vy, vz, pad; + s16 vx, vy, vz, rgb; #ifdef WIN32 bool operator==(sVtx const &v1) {return((vx==v1.vx) && (vy==v1.vy) && (vz==v1.vz));} @@ -108,7 +108,9 @@ struct sTri s16 OTOfs; // 2 u8 PolyCode; // 1 u8 Pad; // 1 -}; // 20 + u8 C0,C1,C2; + u8 Pad2; +}; // 24 //--------------------------------------------------------------------------- struct sQuad @@ -126,7 +128,8 @@ struct sQuad s16 OTOfs; // 2 u8 PolyCode; // 1 u8 Pad; // 1 -}; // 24 + u8 C0,C1,C2,C3; +}; // 28 struct sPoly