1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Fix flat shading.

Fixed 2D tokens in Tetrispere.
This commit is contained in:
Sergey Lipskiy 2016-02-28 23:47:26 +06:00
parent bcdc6bc6a5
commit 5e5c3faed4
3 changed files with 18 additions and 15 deletions

View File

@ -316,13 +316,14 @@ void OGLVideo::readScreen2(void * _dest, int * _width, int * _height, int _front
void OGLRender::addTriangle(int _v0, int _v1, int _v2)
{
const u32 firstIndex = triangles.num;
triangles.elements[triangles.num++] = _v0;
triangles.elements[triangles.num++] = _v1;
triangles.elements[triangles.num++] = _v2;
if ((gSP.geometryMode & G_SHADE) == 0) {
// Prim shading
for (u32 i = triangles.num - 3; i < triangles.num; ++i) {
for (u32 i = firstIndex; i < triangles.num; ++i) {
SPVertex & vtx = triangles.vertices[triangles.elements[i]];
vtx.flat_r = gDP.primColor.r;
vtx.flat_g = gDP.primColor.g;
@ -331,18 +332,19 @@ void OGLRender::addTriangle(int _v0, int _v1, int _v2)
}
} else if ((gSP.geometryMode & G_SHADING_SMOOTH) == 0) {
// Flat shading
SPVertex & vtx0 = triangles.vertices[_v0];
for (u32 i = triangles.num - 3; i < triangles.num; ++i) {
SPVertex & vtx0 = triangles.vertices[firstIndex + ((RSP.w1 >> 24) & 3)];
for (u32 i = firstIndex; i < triangles.num; ++i) {
SPVertex & vtx = triangles.vertices[triangles.elements[i]];
vtx.flat_r = vtx0.r;
vtx.flat_g = vtx0.g;
vtx.flat_b = vtx0.b;
vtx.flat_a = vtx0.a;
vtx.r = vtx.flat_r = vtx0.r;
vtx.g = vtx.flat_g = vtx0.g;
vtx.b = vtx.flat_b = vtx0.b;
vtx.a = vtx.flat_a = vtx0.a;
vtx.a = vtx0.a;
}
}
if (gDP.otherMode.depthSource == G_ZS_PRIM) {
for (u32 i = triangles.num - 3; i < triangles.num; ++i) {
for (u32 i = firstIndex; i < triangles.num; ++i) {
SPVertex & vtx = triangles.vertices[triangles.elements[i]];
vtx.z = gDP.primDepth.z * vtx.w;
}
@ -350,7 +352,7 @@ void OGLRender::addTriangle(int _v0, int _v1, int _v2)
#ifdef GLESX
if (GBI.isNoN() && gDP.otherMode.depthCompare == 0 && gDP.otherMode.depthUpdate == 0) {
for (u32 i = triangles.num - 3; i < triangles.num; ++i) {
for (u32 i = firstIndex; i < triangles.num; ++i) {
SPVertex & vtx = triangles.vertices[triangles.elements[i]];
vtx.z = 0.0f;
}

View File

@ -193,19 +193,19 @@ void RSP_ProcessDList()
break;
}
u32 w0 = *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
u32 w1 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.cmd = _SHIFTR(w0, 24, 8);
RSP.w0 = *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
RSP.w1 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.cmd = _SHIFTR(RSP.w0, 24, 8);
#ifdef DEBUG
DebugRSPState( RSP.PCi, RSP.PC[RSP.PCi], _SHIFTR( w0, 24, 8 ), w0, w1 );
DebugMsg( DEBUG_LOW | DEBUG_HANDLED, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR( w0, 24, 8 ), w0, w1 );
DebugRSPState( RSP.PCi, RSP.PC[RSP.PCi], _SHIFTR( RSP.w0, 24, 8 ), RSP.w0, RSP.w1 );
DebugMsg( DEBUG_LOW | DEBUG_HANDLED, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR( RSP.w0, 24, 8 ), RSP.w0, RSP.w1 );
#endif
RSP.PC[RSP.PCi] += 8;
RSP.nextCmd = _SHIFTR(*(u32*)&RDRAM[RSP.PC[RSP.PCi]], 24, 8);
GBI.cmd[RSP.cmd](w0, w1);
GBI.cmd[RSP.cmd](RSP.w0, RSP.w1);
RSP_CheckDLCounter();
}
}

View File

@ -7,6 +7,7 @@
typedef struct
{
u32 PC[18], PCi, busy, halt, close, uc_start, uc_dstart, cmd, nextCmd;
u32 w0, w1;
s32 count;
bool bLLE;
char romname[21];