[rsx/wip] Implement BRB opcode (test 1)

This commit is contained in:
kd-11
2017-01-08 10:34:10 +03:00
committed by Zangetsu38
parent c2806c8d11
commit e630c828c3
2 changed files with 27 additions and 6 deletions
@@ -216,12 +216,22 @@ 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
@@ -476,15 +486,15 @@ std::string VertexProgramDecompiler::Decompile()
switch (d1.sca_opcode) switch (d1.sca_opcode)
{ {
case 0x08: //BRA case RSX_SCA_OPCODE_BRA:
LOG_ERROR(RSX, "BRA found. Please report to RPCS3 team."); case RSX_SCA_OPCODE_BRB:
is_has_BRA = true; is_has_BRA = true;
m_jump_lvls.clear(); m_jump_lvls.clear();
d3.HEX = m_data[++i]; d3.HEX = m_data[++i];
i += 4; i += 4;
break; break;
case 0x09: //BRI case RSX_SCA_OPCODE_BRI:
d2.HEX = m_data[i++]; d2.HEX = m_data[i++];
d3.HEX = m_data[i]; d3.HEX = m_data[i];
i += 2; i += 2;
@@ -635,7 +645,7 @@ std::string VertexProgramDecompiler::Decompile()
} }
} }
AddCode("$ifcond "); AddCode("$ifcond //BRI");
AddCode("{"); AddCode("{");
m_cur_instr->open_scopes++; m_cur_instr->open_scopes++;
AddCode(fmt::format("jump_position = %u;", jump_position)); AddCode(fmt::format("jump_position = %u;", jump_position));
@@ -662,11 +672,21 @@ std::string VertexProgramDecompiler::Decompile()
case RSX_SCA_OPCODE_COS: SetDSTSca("cos($s)"); break; case RSX_SCA_OPCODE_COS: SetDSTSca("cos($s)"); break;
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"); LOG_ERROR(RSX, "Unimplemented sca_opcode BRB d0=0x%X, d1=0x%X, d2=0x%X, d3=0x%X");
AddCode("$if (!$bconst) //BRB"); //If only the cond flags are set, we can just use $ifcond
AddCode("{");
m_cur_instr->open_scopes++;
AddCode("jump_position = $a$am;");
AddCode("continue;");
m_cur_instr->close_scopes++;
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_ERROR(RSX, "Unimplemented sca_opcode CLB");
AddCode("$if (!$bconst) $f(); //CLB");
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,6 +69,7 @@ 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();