[rsx/wip] Branch to absolute address for BRB instead of Address Register redirection
This commit is contained in:
@@ -493,6 +493,7 @@ std::string VertexProgramDecompiler::Decompile()
|
|||||||
i += 4;
|
i += 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RSX_SCA_OPCODE_BRB:
|
||||||
case RSX_SCA_OPCODE_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];
|
||||||
@@ -535,6 +536,21 @@ std::string VertexProgramDecompiler::Decompile()
|
|||||||
m_cur_instr->open_scopes++;
|
m_cur_instr->open_scopes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto find_jump_lvl = [this](u32 address)
|
||||||
|
{
|
||||||
|
u32 jump = 0;
|
||||||
|
|
||||||
|
for (auto pos : m_jump_lvls)
|
||||||
|
{
|
||||||
|
if (address == pos)
|
||||||
|
break;
|
||||||
|
|
||||||
|
++jump;
|
||||||
|
}
|
||||||
|
|
||||||
|
return jump;
|
||||||
|
};
|
||||||
|
|
||||||
for (u32 i = 0; i < m_instr_count; ++i)
|
for (u32 i = 0; i < m_instr_count; ++i)
|
||||||
{
|
{
|
||||||
m_cur_instr = &m_instructions[i];
|
m_cur_instr = &m_instructions[i];
|
||||||
@@ -614,7 +630,7 @@ std::string VertexProgramDecompiler::Decompile()
|
|||||||
case RSX_SCA_OPCODE_LIT: SetDSTSca("lit_legacy($s)"); break;
|
case RSX_SCA_OPCODE_LIT: SetDSTSca("lit_legacy($s)"); break;
|
||||||
case RSX_SCA_OPCODE_BRA:
|
case RSX_SCA_OPCODE_BRA:
|
||||||
{
|
{
|
||||||
AddCode("$if ($cond)");
|
AddCode("$if ($cond) //BRA");
|
||||||
AddCode("{");
|
AddCode("{");
|
||||||
m_cur_instr->open_scopes++;
|
m_cur_instr->open_scopes++;
|
||||||
AddCode("jump_position = $a$am;");
|
AddCode("jump_position = $a$am;");
|
||||||
@@ -625,24 +641,7 @@ std::string VertexProgramDecompiler::Decompile()
|
|||||||
break;
|
break;
|
||||||
case RSX_SCA_OPCODE_BRI: // works differently (BRI o[1].x(TR) L0;)
|
case RSX_SCA_OPCODE_BRI: // works differently (BRI o[1].x(TR) L0;)
|
||||||
{
|
{
|
||||||
u32 jump_position = 1;
|
u32 jump_position = find_jump_lvl(GetAddr());
|
||||||
|
|
||||||
if (is_has_BRA)
|
|
||||||
{
|
|
||||||
jump_position = GetAddr();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u32 addr = GetAddr();
|
|
||||||
|
|
||||||
for (auto pos : m_jump_lvls)
|
|
||||||
{
|
|
||||||
if (addr == pos)
|
|
||||||
break;
|
|
||||||
|
|
||||||
++jump_position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AddCode("$ifcond //BRI");
|
AddCode("$ifcond //BRI");
|
||||||
AddCode("{");
|
AddCode("{");
|
||||||
@@ -673,10 +672,12 @@ std::string VertexProgramDecompiler::Decompile()
|
|||||||
// 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_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());
|
||||||
|
|
||||||
AddCode("$if (!$bconst) //BRB"); //If only the cond flags are set, we can just use $ifcond
|
AddCode("$if (!$bconst) //BRB"); //If only the cond flags are set, we can just use $ifcond
|
||||||
AddCode("{");
|
AddCode("{");
|
||||||
m_cur_instr->open_scopes++;
|
m_cur_instr->open_scopes++;
|
||||||
AddCode("jump_position = $a$am;");
|
AddCode(fmt::format("jump_position = %u;", jump_position));
|
||||||
AddCode("continue;");
|
AddCode("continue;");
|
||||||
m_cur_instr->close_scopes++;
|
m_cur_instr->close_scopes++;
|
||||||
AddCode("}");
|
AddCode("}");
|
||||||
|
|||||||
Reference in New Issue
Block a user