void VertexDecompilerThread::AddScaCode(wxString code, bool src_mask) { if(d0.cond == 0) return; if(d0.cond != 7) { ConLog.Error("Bad cond! %d", d0.cond); Emu.Pause(); return; } code = GetDST(true) + GetScaMask() + " = " + (src_mask ? code + GetScaMask() : code); main += "\t" + code + ";\n"; }
void GLVertexDecompilerThread::SetDST(bool is_sca, std::string value) { if(d0.cond == 0) return; enum { lt = 0x1, eq = 0x2, gt = 0x4, }; std::string mask = GetMask(is_sca); value += mask; if(is_sca && d0.vec_result) { value = "vec4(" + value + ")" + mask; } if(d0.staturate) { value = "clamp(" + value + ", 0.0, 1.0)"; } std::string dest; if (d0.cond_update_enable_0 && d0.cond_update_enable_1) { dest += m_parr.AddParam(PARAM_NONE, "vec4", "cc" + std::to_string(d0.cond_reg_sel_1), "vec4(0.0)") + mask + " = "; } if (d3.dst != 0x1f || (is_sca ? d3.sca_dst_tmp != 0x3f : d0.dst_tmp != 0x3f)) { dest += GetDST(is_sca) + mask + " = "; } std::string code; if (d0.cond_test_enable) code += "$ifcond "; code += dest + value; AddCode(code + ";"); }
void VertexProgramDecompiler::SetDST(bool is_sca, std::string value) { if (d0.cond == 0) return; enum { lt = 0x1, eq = 0x2, gt = 0x4, }; std::string mask = GetMask(is_sca); if (is_sca) { value = getFloatTypeName(4) + "(" + value + ")"; } value += mask; if (d0.staturate) { value = "clamp(" + value + ", 0.0, 1.0)"; } std::string dest; if (d0.cond_update_enable_0 && d0.cond_update_enable_1) { dest = m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(d0.cond_reg_sel_1), getFloatTypeName(4) + "(0., 0., 0., 0.)") + mask; } else if (d3.dst != 0x1f || (is_sca ? d3.sca_dst_tmp != 0x3f : d0.dst_tmp != 0x3f)) { dest = GetDST(is_sca) + mask; } //std::string code; //if (d0.cond_test_enable) // code += "$ifcond "; //code += dest + value; //AddCode(code + ";"); AddCodeCond(Format(dest), value); }
void GLVertexDecompilerThread::AddCode(bool is_sca, const std::string& pCode, bool src_mask, bool set_dst, bool set_cond) { std::string code = pCode; if(d0.cond == 0) return; enum { lt = 0x1, eq = 0x2, gt = 0x4, }; static const char* cond_string_table[(lt | gt | eq) + 1] = { "error", "lessThan", "equal", "lessThanEqual", "greaterThan", "notEqual", "greaterThanEqual", "error" }; std::string cond; if((set_cond || d0.cond_test_enable) && d0.cond != (lt | gt | eq)) { static const char f[4] = {'x', 'y', 'z', 'w'}; std::string swizzle; swizzle += f[d0.mask_x]; swizzle += f[d0.mask_y]; swizzle += f[d0.mask_z]; swizzle += f[d0.mask_w]; swizzle = swizzle == "xyzw" ? "" : "." + swizzle; cond = fmt::Format("if(all(%s(rc%s, vec4(0.0)%s))) ", cond_string_table[d0.cond], swizzle.c_str(), swizzle.c_str()); } std::string mask = GetMask(is_sca); std::string value = src_mask ? code + mask : code; if(is_sca && d0.vec_result) { value = "vec4(" + value + ")" + mask; } if(d0.staturate) { value = "clamp(" + value + ", 0.0, 1.0)"; } if(set_dst) { std::string dest; if(d0.cond_update_enable_0) { dest = m_parr.AddParam(PARAM_NONE, "vec4", "rc", "vec4(0.0)") + mask; } else if(d3.dst == 5 || d3.dst == 6) { if(d3.vec_writemask_x) { dest = m_parr.AddParam(PARAM_OUT, "vec4", "fogc") + mask; } else { int num = d3.dst == 5 ? 0 : 3; //if(d3.vec_writemask_y) num += 0; if(d3.vec_writemask_z) num += 1; else if(d3.vec_writemask_w) num += 2; dest = fmt::Format(GetDST(is_sca) + "/*" + mask + "*/", num); } } else { dest = GetDST(is_sca) + mask; } code = cond + dest + " = " + value; } else { code = cond + value; } m_body.push_back(code + ";"); }
void VertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask) { if(d0.cond == 0) return; enum { lt = 0x1, eq = 0x2, gt = 0x4, }; wxString cond; if(d0.cond != (lt | gt | eq)) { if((d0.cond & (lt | gt)) == (lt | gt)) { cond = "!="; } else { if(d0.cond & lt) cond = "<"; else if(d0.cond & gt) cond = ">"; else if(d0.cond & eq) cond = "="; if(d0.cond & eq) cond += "="; } //ConLog.Error("cond! %d (%d %s %d %d)", d0.cond, d0.dst_tmp, cond, d1.input_src, d1.const_src); cond = wxString::Format("if(tmp%d.x %s 0) ", d0.dst_tmp, cond); } wxString value = src_mask ? code + GetMask(is_sca) : code; if(d0.staturate) { value = "clamp(" + value + ", 0.0, 1.0)"; } wxString dest; if(d3.dst == 5 || d3.dst == 6) { int num = d3.dst == 5 ? 0 : 3; if(d3.vec_writemask_x) { ConLog.Error("Bad clip mask."); } //if(d3.vec_writemask_y) num += 0; if(d3.vec_writemask_z) num += 1; else if(d3.vec_writemask_w) num += 2; dest = wxString::Format(GetDST(is_sca), num); } else { dest = GetDST(is_sca) + GetMask(is_sca); } code = cond + dest + " = " + value; main += "\t" + code + ";\n"; }
void GLVertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask, bool set_dst) { if(d0.cond == 0) return; enum { lt = 0x1, eq = 0x2, gt = 0x4, }; wxString cond; if(d0.cond != (lt | gt | eq)) { if((d0.cond & (lt | gt)) == (lt | gt)) { cond = "!="; } else { if(d0.cond & lt) cond = "<"; else if(d0.cond & gt) cond = ">"; else if(d0.cond & eq) cond = "="; if(d0.cond & eq) cond += "="; } //ConLog.Error("cond! %d (%d %s %d %d)", d0.cond, d0.dst_tmp, cond, d1.input_src, d1.const_src); cond = wxString::Format("if(rc %s 0) ", cond.mb_str()); } wxString value = src_mask ? code + GetMask(is_sca) : code; if(d0.staturate) { value = "clamp(" + value + ", 0.0, 1.0)"; } if(set_dst) { wxString dest; if(d0.cond_update_enable_0) { dest = m_parr.AddParam(PARAM_NONE, "float", "rc"); } else if(d3.dst == 5 || d3.dst == 6) { int num = d3.dst == 5 ? 0 : 3; if(d3.vec_writemask_x) { ConLog.Error("Bad clip mask."); } //if(d3.vec_writemask_y) num += 0; if(d3.vec_writemask_z) num += 1; else if(d3.vec_writemask_w) num += 2; dest = wxString::Format(GetDST(is_sca), num); } else { dest = GetDST(is_sca) + GetMask(is_sca); } code = cond + dest + " = " + value; } else { code = cond + value; } m_body.Add(code + wxString::Format(";//%d %d %d %d", d0.cond_reg_sel_1, d0.cond_test_enable, d0.cond_update_enable_0, d0.cond_update_enable_1)); }