From: ptitSeb Date: Thu, 16 Jan 2014 22:04:14 +0000 (+0100) Subject: GLES2N64: Added WIP fix for CBFD from mupen64plus-ae X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f4ee9e9e363445037c2ecfd59875222017c58ab;p=mupen64plus-pandora.git GLES2N64: Added WIP fix for CBFD from mupen64plus-ae --- diff --git a/source/gles2n64/Makefile b/source/gles2n64/Makefile index ebf5d98..3048cfa 100755 --- a/source/gles2n64/Makefile +++ b/source/gles2n64/Makefile @@ -87,9 +87,9 @@ CXX = $(CROSS_COMPILE)g++ RM ?= rm -f INSTALL ?= install MKDIR ?= mkdir -p -COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -gdwarf-2 -flto -fuse-linker-plugin -c -COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -gdwarf-2 -flto -fuse-linker-plugin -c -LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH) -gdwarf-2 -flto -fuse-linker-plugin +COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -gdwarf-2 -c +COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -gdwarf-2 -c +LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH) -gdwarf-2 # set installation options ifeq ($(PREFIX),) diff --git a/source/gles2n64/src/F3DCBFD.cpp b/source/gles2n64/src/F3DCBFD.cpp old mode 100644 new mode 100755 index d96449b..71087d4 --- a/source/gles2n64/src/F3DCBFD.cpp +++ b/source/gles2n64/src/F3DCBFD.cpp @@ -22,7 +22,6 @@ u32 normal_address = 0; void F3DCBFD_Vtx(u32 w0, u32 w1) { - s32 v0, n; u32 address; n = (w0 >> 12)&0xFF; @@ -37,14 +36,14 @@ void F3DCBFD_Vtx(u32 w0, u32 w1) gSPFlushTriangles(); Vertex* vertex = (Vertex*)&RDRAM[address]; - + u32 v; + for (s32 i=0; i < n; i++) { - u32 v; #ifdef __TRIBUFFER_OPT - v = __indexmap_getnew(i, 1); + v = __indexmap_getnew(v0 + i, 1); #else - v = i; + v = v0 + i; #endif OGL.triangles.vertices[v].x = vertex->x; @@ -57,19 +56,23 @@ void F3DCBFD_Vtx(u32 w0, u32 w1) if (config.enableLighting && gSP.geometryMode & G_LIGHTING) { - OGL.triangles.vertices[v].nx = ((s8*)RDRAM)[(normal_address + (i<<2) + (v0<<1) + 0)^3]; - OGL.triangles.vertices[v].ny = ((s8*)RDRAM)[(normal_address + (i<<2) + (v0<<1) + 1)^3]; + OGL.triangles.vertices[v].nx = ((s8*)RDRAM)[(normal_address + (i<<1) + (v0<<1) + 0)^3]; + OGL.triangles.vertices[v].ny = ((s8*)RDRAM)[(normal_address + (i<<1) + (v0<<1) + 1)^3]; OGL.triangles.vertices[v].nz = (s8)(vertex->flag&0xff); } gSPProcessVertex(v); - if (config.enableLighting && gSP.geometryMode & G_LIGHTING) + u32 nonblack = 0; + nonblack += OGL.triangles.vertices[v].r; + nonblack += OGL.triangles.vertices[v].g; + nonblack += OGL.triangles.vertices[v].b; + if (config.enableLighting && (gSP.geometryMode & G_LIGHTING) && (nonblack != 0)) { OGL.triangles.vertices[v].r = OGL.triangles.vertices[v].r * vertex->color.r * 0.0039215689f; OGL.triangles.vertices[v].g = OGL.triangles.vertices[v].g * vertex->color.g * 0.0039215689f; OGL.triangles.vertices[v].b = OGL.triangles.vertices[v].b * vertex->color.b * 0.0039215689f; - OGL.triangles.vertices[v].a = OGL.triangles.vertices[v].a * vertex->color.a * 0.0039215689f; + OGL.triangles.vertices[v].a = vertex->color.a * 0.0039215689f; } else { @@ -90,7 +93,7 @@ void F3DCBFD_MoveWord(u32 w0, u32 w1) switch (index) { case G_MW_NUMLIGHT: - gSPNumLights(w1 / 48); + gSPNumLights(w1 / 48); break; case G_MW_CLIP: @@ -101,7 +104,7 @@ void F3DCBFD_MoveWord(u32 w0, u32 w1) break; case G_MW_SEGMENT: - gSPSegment(_SHIFTR(offset, 2, 4), w1); + gSPSegment(_SHIFTR(offset, 2, 4), w1 & 0x00FFFFFF); break; case G_MW_FOG: @@ -133,11 +136,14 @@ void F3DCBFD_MoveMem(u32 w0, u32 w1) case F3DCBFD_MV_LIGHT: { - u32 offset = _SHIFTR( w0, 8, 8 ) << 3; - if (offset >= 48) - { - gSPLight( w1, (offset - 24) / 24); - } + u32 offset = (w0 >> 5) & 0x3FFF; + u32 n = offset / 48; + if (n < 2) { + //LookAt + return; + } + n--; + gSPLight(w1, n); break; } @@ -151,7 +157,7 @@ void F3DCBFD_MoveMem(u32 w0, u32 w1) void F3DCBFD_Tri4(u32 w0, u32 w1) { gSP4Triangles( _SHIFTR(w0, 23, 5), _SHIFTR(w0, 18, 5), (_SHIFTR(w0, 15, 3 ) << 2) | _SHIFTR(w1, 30, 2), - _SHIFTR(w0, 10, 5), _SHIFTR(w0, 5, 5), _SHIFTR(w1, 0, 5), + _SHIFTR(w0, 10, 5), _SHIFTR(w0, 5, 5), _SHIFTR(w0, 0, 5), _SHIFTR(w1, 25, 5), _SHIFTR(w1, 20, 5), _SHIFTR(w1, 15, 5), _SHIFTR(w1, 10, 5), _SHIFTR(w1, 5, 5), _SHIFTR(w1, 0, 5)); } diff --git a/source/gles2n64/src/GBI.cpp b/source/gles2n64/src/GBI.cpp old mode 100644 new mode 100755 index daa6de7..d24f54a --- a/source/gles2n64/src/GBI.cpp +++ b/source/gles2n64/src/GBI.cpp @@ -42,7 +42,7 @@ SpecialMicrocodeInfo specialMicrocodes[] = {F3DPD, FALSE, 0x1c4f7869, "Perfect Dark"}, {F3DEX, FALSE, 0x0ace4c3f, "Mario Kart"}, //{F3DEX, FALSE, 0xda51ccdb, "Rogue Squadron"}, - //{F3DCBFD, FALSE, 0x1b4ace88, "RSP Gfx ucode F3DEXBG.NoN fifo 2.08 Yoshitaka Yasumoto 1999 Nintendo."}, + {F3DCBFD, FALSE, 0x1b4ace88, "RSP Gfx ucode F3DEXBG.NoN fifo 2.08 Yoshitaka Yasumoto 1999 Nintendo."}, }; u32 G_RDPHALF_1, G_RDPHALF_2, G_RDPHALF_CONT;