From a911c8588112b5fe9dba755b68e14244298ab7e3 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sat, 20 Dec 2014 23:13:26 +0600 Subject: [PATCH] Disable BranchLessZ logic for Zelda MM ucode since it uses unknown format of test Z value. --- GBI.cpp | 3 +++ GBI.h | 2 ++ gSP.cpp | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/GBI.cpp b/GBI.cpp index e732f501..46c00b3c 100644 --- a/GBI.cpp +++ b/GBI.cpp @@ -208,6 +208,7 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize) current.dataSize = uc_dsize; current.NoN = false; current.textureGen = true; + current.branchLessZ = true; current.type = NONE; // See if we can identify it by CRC @@ -252,6 +253,8 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize) type = F3DEX2; if (strncmp(&uc_str[14], "F3DF", 4) == 0) current.textureGen = false; + else if (strncmp(&uc_str[14], "F3DZ", 4) == 0) + current.branchLessZ = false; } else if (strncmp( &uc_str[14], "L3D", 3 ) == 0) { u32 t = 22; diff --git a/GBI.h b/GBI.h index bba398be..f4791285 100644 --- a/GBI.h +++ b/GBI.h @@ -679,6 +679,7 @@ struct MicrocodeInfo u32 crc; bool NoN; bool textureGen; + bool branchLessZ; }; struct GBIInfo @@ -694,6 +695,7 @@ struct GBIInfo bool isHWLSupported() const; bool isNoN() const { return m_pCurrent != NULL ? m_pCurrent->NoN : false; } bool isTextureGen() const { return m_pCurrent != NULL ? m_pCurrent->textureGen: true; } + bool isBranchLessZ() const { return m_pCurrent != NULL ? m_pCurrent->branchLessZ : true; } private: void _makeCurrent(MicrocodeInfo * _pCurrent); diff --git a/gSP.cpp b/gSP.cpp index a36b635a..1fe986b0 100644 --- a/gSP.cpp +++ b/gSP.cpp @@ -1266,7 +1266,7 @@ void gSPBranchLessZ( u32 branchdl, u32 vtx, f32 zval ) SPVertex & v = video().getRender().getVertex(vtx); const float zTest = v.z / v.w; - if (zTest > 1.0f || zTest <= zval) + if (zTest > 1.0f || zTest <= zval || !GBI.isBranchLessZ()) RSP.PC[RSP.PCi] = address; #ifdef DEBUG