[rsx/wip] Take the branching code on BRB when bit 25 of d3 is set

This commit is contained in:
kd-11
2017-01-08 16:02:57 +03:00
committed by Zangetsu38
parent 91b73dafd5
commit 335fb6456e
3 changed files with 23 additions and 25 deletions
@@ -216,22 +216,12 @@ std::string VertexProgramDecompiler::Format(const std::string& code)
return "if(" + cond + ") "; return "if(" + cond + ") ";
} }
}, },
{ "$cond", std::bind(std::mem_fn(&VertexProgramDecompiler::GetCond), this) }, { "$cond", std::bind(std::mem_fn(&VertexProgramDecompiler::GetCond), this) }
{ "$bconst", std::bind(std::mem_fn(&VertexProgramDecompiler::GetBooleanConstantCond), this) }
}; };
return fmt::replace_all(code, repl_list); 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() std::string VertexProgramDecompiler::GetCond()
{ {
enum enum
@@ -671,24 +661,30 @@ std::string VertexProgramDecompiler::Decompile()
case RSX_SCA_OPCODE_BRB: case RSX_SCA_OPCODE_BRB:
// works differently (BRB o[1].x !b0, L0;) // 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); 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);
u32 jump_position = find_jump_lvl(GetAddr());
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(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("{"); if (d3.brb_cond_true)
m_cur_instr->open_scopes++; {
u32 jump_position = find_jump_lvl(GetAddr());
AddCode(fmt::format("jump_position = %u;", jump_position)); AddCode(fmt::format("jump_position = %u;", jump_position));
AddCode("continue;"); AddCode("continue;");
m_cur_instr->close_scopes++; AddCode("");
AddCode("}"); }
break; break;
} }
case RSX_SCA_OPCODE_CLB: break; case RSX_SCA_OPCODE_CLB: break;
// works same as BRB // works same as BRB
LOG_ERROR(RSX, "Unimplemented sca_opcode 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("if (!$bconst) $f(); //CLB"); AddCode("//CLB");
if (d3.brb_cond_true)
{
AddCode("$f(); //CLB");
AddCode("");
}
break; break;
case RSX_SCA_OPCODE_PSH: break; case RSX_SCA_OPCODE_PSH: break;
// works differently (PSH o[1].x A0;) // works differently (PSH o[1].x A0;)
@@ -69,7 +69,6 @@ struct VertexProgramDecompiler
std::string GetFunc(); std::string GetFunc();
std::string GetTex(); std::string GetTex();
std::string GetCond(); std::string GetCond();
std::string GetBooleanConstantCond();
std::string AddAddrMask(); std::string AddAddrMask();
std::string AddAddrReg(); std::string AddAddrReg();
std::string AddAddrRegWithoutMask(); std::string AddAddrRegWithoutMask();
+4 -1
View File
@@ -146,9 +146,12 @@ union D3
u32 sca_writemask_x : 1; u32 sca_writemask_x : 1;
u32 src2l : 11; u32 src2l : 11;
}; };
struct struct
{ {
u32 : 29; u32 : 25;
u32 brb_cond_true : 1;
u32 : 3;
u32 iaddrl : 3; u32 iaddrl : 3;
}; };
}; };