diff --git a/src/gSP.cpp b/src/gSP.cpp index b22c49577..d6662d95f 100644 --- a/src/gSP.cpp +++ b/src/gSP.cpp @@ -248,6 +248,8 @@ void gSPDMAMatrix( u32 matrix, u8 index, u8 multiply ) mtx[3][0], mtx[3][1], mtx[3][2], mtx[3][3] ); } +#define G_F3DEX3_NEW_MAXZ 0x7FFF + void gSPViewport( u32 v ) { u32 address = RSP_SegmentToPhysical( v ); @@ -267,8 +269,15 @@ void gSPViewport( u32 v ) gSP.viewport.vtrans[2] = _FIXED2FLOAT( *(s16*)&RDRAM[address + 14], 10 );// * 0.00097847357f; gSP.viewport.vtrans[3] = *(s16*)&RDRAM[address + 12]; - if (gSP.viewport.vscale[1] < 0.0f && !GBI.isNegativeY()) - gSP.viewport.vscale[1] = -gSP.viewport.vscale[1]; + if (gSP.viewport.vscale[1] < 0.0f) { + if (!GBI.isNegativeY()) { + gSP.viewport.vscale[1] = -gSP.viewport.vscale[1]; + if (F3DEX3 == GBI.getMicrocodeType()) { + gSP.viewport.vscale[2] /= (G_F3DEX3_NEW_MAXZ / 2) / 511.f; + gSP.viewport.vtrans[2] /= (G_F3DEX3_NEW_MAXZ / 2) / 511.f; + } + } + } gSP.viewport.x = gSP.viewport.vtrans[0] - gSP.viewport.vscale[0]; gSP.viewport.y = gSP.viewport.vtrans[1] - gSP.viewport.vscale[1]; @@ -314,7 +323,7 @@ void gSPLight( u32 l, s32 n ) Light *light = (Light*)&RDRAM[addrByte]; - if (n < 9) { + if (n < 10) { gSP.lights.rgb[n][R] = _FIXED2FLOATCOLOR(light->r,8); gSP.lights.rgb[n][G] = _FIXED2FLOATCOLOR(light->g,8); gSP.lights.rgb[n][B] = _FIXED2FLOATCOLOR(light->b,8); diff --git a/src/uCodes/F3DEX3.cpp b/src/uCodes/F3DEX3.cpp index 056c23f17..e1fc9d51b 100644 --- a/src/uCodes/F3DEX3.cpp +++ b/src/uCodes/F3DEX3.cpp @@ -35,21 +35,7 @@ #define F3DEX3_G_MAX_LIGHTS 9 -struct F3DEX3_Ambient -{ - u8 pad0, b, g, r; - u8 pad1, b2, g2, r2; -}; - -struct F3DEX3_Light -{ - u8 pad0, b, g, r; - u8 pad1, b2, g2, r2; - s8 pad2, z, y, x; - u8 size, pad3[3]; -}; - -// Notice how it looks like F3DEX3_Light but the ending so there are 8 bytes of difference +// Notice how it looks like Light but the ending so there are 8 bytes of difference struct F3DEX3_LookAt { s8 pad, z, y, x; @@ -83,7 +69,7 @@ static void writeLight(int off, u32 w) gSPLookAt(w - (sizeof(F3DEX3_LookAtOld) - sizeof(F3DEX3_LookAt)) + sizeof(F3DEX3_LookAt), 1); } - for (u32 i = 1; i <= gSP.numLights; i++) + for (u32 i = 1; i <= gSP.numLights + 1; i++) { if (_LIGHT_TO_OFFSET(i) == off) { @@ -91,10 +77,6 @@ static void writeLight(int off, u32 w) } } - if (_LIGHT_TO_OFFSET(gSP.numLights + 1) == off) - { - // TODO: Write ambient lights - } if ((F3DEX3_G_MAX_LIGHTS * 0x10) + 0x18 == off) { // TODO: OcclusionPlane not supported