diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp index 032ca53476..b036127047 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp @@ -216,22 +216,12 @@ std::string VertexProgramDecompiler::Format(const std::string& code) return "if(" + cond + ") "; } }, - { "$cond", std::bind(std::mem_fn(&VertexProgramDecompiler::GetCond), this) }, - { "$bconst", std::bind(std::mem_fn(&VertexProgramDecompiler::GetBooleanConstantCond), this) } + { "$cond", std::bind(std::mem_fn(&VertexProgramDecompiler::GetCond), this) } }; return fmt::replace_all(code, repl_list); } -std::string VertexProgramDecompiler::GetBooleanConstantCond() -{ - if (d0.cond == 0) return "false"; - if (d0.cond == 7) return "true"; - - LOG_ERROR(RSX, "Boolean constant condition not found; returning false"); - return "false"; -} - std::string VertexProgramDecompiler::GetCond() { enum @@ -671,24 +661,30 @@ std::string VertexProgramDecompiler::Decompile() case RSX_SCA_OPCODE_BRB: // works differently (BRB o[1].x !b0, L0;) { - LOG_ERROR(RSX, "Unimplemented sca_opcode BRB d0=0x%X, d1=0x%X, d2=0x%X, d3=0x%X", d0.HEX, d1.HEX, d2.HEX, d3.HEX); - u32 jump_position = find_jump_lvl(GetAddr()); - + LOG_WARNING(RSX, "sca_opcode BRB, d0=0x%X, d1=0x%X, d2=0x%X, d3=0x%X", d0.HEX, d1.HEX, d2.HEX, d3.HEX); AddCode(fmt::format("//BRB opcode, d0=0x%X, d1=0x%X, d2=0x%X, d3=0x%X", d0.HEX, d1.HEX, d2.HEX, d3.HEX)); - AddCode("if (!$bconst) //BRB"); //If only the cond flags are set, we can just use $ifcond - AddCode("{"); - m_cur_instr->open_scopes++; - AddCode(fmt::format("jump_position = %u;", jump_position)); - AddCode("continue;"); - m_cur_instr->close_scopes++; - AddCode("}"); + + if (d3.brb_cond_true) + { + u32 jump_position = find_jump_lvl(GetAddr()); + AddCode(fmt::format("jump_position = %u;", jump_position)); + AddCode("continue;"); + AddCode(""); + } break; } case RSX_SCA_OPCODE_CLB: break; // works same as BRB - LOG_ERROR(RSX, "Unimplemented sca_opcode CLB"); - AddCode("if (!$bconst) $f(); //CLB"); + LOG_WARNING(RSX, "sca_opcode CLB, d0=0x%X, d1=0x%X, d2=0x%X, d3=0x%X", d0.HEX, d1.HEX, d2.HEX, d3.HEX); + AddCode("//CLB"); + + if (d3.brb_cond_true) + { + AddCode("$f(); //CLB"); + AddCode(""); + } + break; case RSX_SCA_OPCODE_PSH: break; // works differently (PSH o[1].x A0;) diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h index 0cb1a3f350..d0d99c72fb 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h @@ -69,7 +69,6 @@ struct VertexProgramDecompiler std::string GetFunc(); std::string GetTex(); std::string GetCond(); - std::string GetBooleanConstantCond(); std::string AddAddrMask(); std::string AddAddrReg(); std::string AddAddrRegWithoutMask(); diff --git a/rpcs3/Emu/RSX/RSXVertexProgram.h b/rpcs3/Emu/RSX/RSXVertexProgram.h index 9b74ccf687..1374e96982 100644 --- a/rpcs3/Emu/RSX/RSXVertexProgram.h +++ b/rpcs3/Emu/RSX/RSXVertexProgram.h @@ -146,9 +146,12 @@ union D3 u32 sca_writemask_x : 1; u32 src2l : 11; }; + struct { - u32 : 29; + u32 : 25; + u32 brb_cond_true : 1; + u32 : 3; u32 iaddrl : 3; }; };