void RegisteredUsersDialog::FilterRegs() { int iTextLength = ::GetWindowTextLength(m_hWndWindowItems[EDT_FILTER]); if(iTextLength == 0) { m_sFilterString.clear(); AddAllRegs(); } else { m_iFilterColumn = (int)::SendMessage(m_hWndWindowItems[CB_FILTER], CB_GETCURSEL, 0, 0); char buf[65]; int iLen = ::GetWindowText(m_hWndWindowItems[EDT_FILTER], buf, 65); for(int i = 0; i < iLen; i++) { buf[i] = (char)tolower(buf[i]); } m_sFilterString = buf; ::SendMessage(m_hWndWindowItems[LV_REGS], WM_SETREDRAW, (WPARAM)FALSE, 0); ::SendMessage(m_hWndWindowItems[LV_REGS], LVM_DELETEALLITEMS, 0, 0); RegUser * curReg = nullptr, * nextReg = RegManager::m_Ptr->m_pRegListS; while(nextReg != nullptr) { curReg = nextReg; nextReg = curReg->m_pNext; switch(m_iFilterColumn) { case 0: if(stristr2(curReg->m_sNick, m_sFilterString.c_str()) == nullptr) { continue; } break; case 1: if(stristr2(curReg->m_sPass, m_sFilterString.c_str()) == nullptr) { continue; } break; case 2: if(stristr2(ProfileManager::m_Ptr->m_ppProfilesTable[curReg->m_ui16Profile]->m_sName, m_sFilterString.c_str()) == nullptr) { continue; } break; } AddReg(curReg); } ListViewSelectFirstItem(m_hWndWindowItems[LV_REGS]); ::SendMessage(m_hWndWindowItems[LV_REGS], WM_SETREDRAW, (WPARAM)TRUE, 0); } }
void CRegression::AddList(CRegression* reglist) { CRegression* p = reglist->Next; while(NULL!=p) { AddReg(p->Weight,p->Vars); p = p->Next; } //Delete(); return; }
void FragmentProgramDecompiler::SetDst(std::string code, bool append_mask) { if (!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) return; switch (src1.scale) { case 0: break; case 1: code = "(" + code + " * 2.0)"; break; case 2: code = "(" + code + " * 4.0)"; break; case 3: code = "(" + code + " * 8.0)"; break; case 5: code = "(" + code + " / 2.0)"; break; case 6: code = "(" + code + " / 4.0)"; break; case 7: code = "(" + code + " / 8.0)"; break; default: LOG_ERROR(RSX, "Bad scale: %d", u32{ src1.scale }); Emu.Pause(); break; } if (dst.saturate) { code = saturate(code); } code += (append_mask ? "$m" : ""); if (dst.no_dest) { if (dst.set_cond) { AddCode("$ifcond " + m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(src0.cond_mod_reg_index)) + "$m = " + code + ";"); } else { AddCode("$ifcond " + code + ";"); } return; } std::string dest = AddReg(dst.dest_reg, dst.fp16) + "$m"; AddCodeCond(Format(dest), code); //AddCode("$ifcond " + dest + code + (append_mask ? "$m;" : ";")); if (dst.set_cond) { AddCode(m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(src0.cond_mod_reg_index)) + "$m = " + dest + ";"); } }
void RegisteredUsersDialog::AddAllRegs() { ::SendMessage(m_hWndWindowItems[LV_REGS], WM_SETREDRAW, (WPARAM)FALSE, 0); ::SendMessage(m_hWndWindowItems[LV_REGS], LVM_DELETEALLITEMS, 0, 0); RegUser * curReg = nullptr, * nextReg = RegManager::m_Ptr->m_pRegListS; while(nextReg != nullptr) { curReg = nextReg; nextReg = curReg->m_pNext; AddReg(curReg); } ListViewSelectFirstItem(m_hWndWindowItems[LV_REGS]); ::SendMessage(m_hWndWindowItems[LV_REGS], WM_SETREDRAW, (WPARAM)TRUE, 0); }
void GLFragmentDecompilerThread::SetDst(std::string code, bool append_mask) { if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) return; switch(src1.scale) { case 0: break; case 1: code = "(" + code + " * 2.0)"; break; case 2: code = "(" + code + " * 4.0)"; break; case 3: code = "(" + code + " * 8.0)"; break; case 5: code = "(" + code + " / 2.0)"; break; case 6: code = "(" + code + " / 4.0)"; break; case 7: code = "(" + code + " / 8.0)"; break; default: ConLog.Error("Bad scale: %d", fmt::by_value(src1.scale)); Emu.Pause(); break; } if(dst.saturate) { code = "clamp(" + code + ", 0.0, 1.0)"; } std::string dest; if (dst.set_cond) { dest += m_parr.AddParam(PARAM_NONE, "vec4", "cc" + std::to_string(src0.cond_mod_reg_index)) + "$m = "; } if (!dst.no_dest) { dest += AddReg(dst.dest_reg, dst.fp16) + "$m = "; } AddCode("$ifcond " + dest + code + (append_mask ? "$m;" : ";")); }
int DecVRT(struct fp_img_dev *dev) { return AddReg(dev, 0xE1, -1, "VRT", 0, 0x3F); }
int IncVRB(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0xE2, 1, "VRB", 0, 0x3A); }
template<typename T> std::string GLFragmentDecompilerThread::GetSRC(T src) { std::string ret; switch(src.reg_type) { case 0: //tmp ret += AddReg(src.tmp_reg_index, src.fp16); break; case 1: //input { static const std::string reg_table[] = { "gl_Position", "diff_color", "spec_color", "fogc", "tc0", "tc1", "tc2", "tc3", "tc4", "tc5", "tc6", "tc7", "tc8", "tc9", "ssa" }; switch(dst.src_attr_reg_num) { case 0x00: ret += reg_table[0]; break; default: if(dst.src_attr_reg_num < sizeof(reg_table)/sizeof(reg_table[0])) { ret += m_parr.AddParam(PARAM_IN, "vec4", reg_table[dst.src_attr_reg_num]); } else { ConLog.Error("Bad src reg num: %d", fmt::by_value(dst.src_attr_reg_num)); ret += m_parr.AddParam(PARAM_IN, "vec4", "unk"); Emu.Pause(); } break; } } break; case 2: //const ret += AddConst(); break; default: ConLog.Error("Bad src type %d", fmt::by_value(src.reg_type)); Emu.Pause(); break; } static const char f[4] = {'x', 'y', 'z', 'w'}; std::string swizzle = ""; swizzle += f[src.swizzle_x]; swizzle += f[src.swizzle_y]; swizzle += f[src.swizzle_z]; swizzle += f[src.swizzle_w]; if(strncmp(swizzle.c_str(), f, 4) != 0) ret += "." + swizzle; if(src.abs) ret = "abs(" + ret + ")"; if(src.neg) ret = "-" + ret; return ret; }
int DecReg04(struct fp_img_dev *dev) { return AddReg(dev, 0x04, -1, "REG_04", 0, 0x35); }
int DecVCO_C(struct fp_img_dev *dev) { return AddReg(dev, 0xE5, -1, "VCO_C", 0, 0x20); }
void GLFragmentDecompilerThread::AddCode(std::string code, bool append_mask) { if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) return; const std::string mask = GetMask().c_str(); std::string cond = ""; if(!src0.exec_if_gr || !src0.exec_if_lt || !src0.exec_if_eq) { static const char f[4] = {'x', 'y', 'z', 'w'}; std::string swizzle = ""; swizzle += f[src0.cond_swizzle_x]; swizzle += f[src0.cond_swizzle_y]; swizzle += f[src0.cond_swizzle_z]; swizzle += f[src0.cond_swizzle_w]; if(src0.exec_if_gr && src0.exec_if_eq) { cond = "greaterThanEqual"; } else if(src0.exec_if_lt && src0.exec_if_eq) { cond = "lessThanEqual"; } else if(src0.exec_if_gr && src0.exec_if_lt) { cond = "notEqual"; } else if(src0.exec_if_gr) { cond = "greaterThan"; } else if(src0.exec_if_lt) { cond = "lessThan"; } else //if(src0.exec_if_eq) { cond = "equal"; } cond = std::string("if(all(" + cond + "(" + AddCond(dst.no_dest) + "." + swizzle +", vec4(0, 0, 0, 0)))) "); //ConLog.Error("cond! [eq: %d gr: %d lt: %d] (%s)", src0.exec_if_eq, src0.exec_if_gr, src0.exec_if_lt, cond); //Emu.Pause(); //return; } if(src1.scale) { switch(src1.scale) { case 1: code = "(" + code + " * 2)"; break; case 2: code = "(" + code + " * 4)"; break; case 3: code = "(" + code + " * 8)"; break; case 5: code = "(" + code + " / 2)"; break; case 6: code = "(" + code + " / 4)"; break; case 7: code = "(" + code + " / 8)"; break; default: ConLog.Error("Bad scale: %d", src1.scale); Emu.Pause(); break; } } if(dst.saturate) { code = "clamp(" + code + ", 0.0, 1.0)"; } code = cond + (dst.set_cond ? m_parr.AddParam(PARAM_NONE , "vec4", std::string(dst.fp16 ? "hc" : "rc") + std::to_string(src0.cond_reg_index)) : AddReg(dst.dest_reg, dst.fp16)) + mask + " = " + code + (append_mask ? mask : ""); main += "\t" + code + ";\n"; }
int DecReg93(struct fp_img_dev *dev) { return AddReg(dev, 0x93, -1, "REG_93", 0, 0x50); }
int DecDTVRT(struct fp_img_dev *dev) { return AddReg(dev, 0xE3, -1, "DTVRT", 0, 0x20); }
int DecReg1A(struct fp_img_dev *dev) { return AddReg(dev, 0x1A, -1, "REG_1A", 0, 0x35); }
int IncReg93(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0x93, 1, "REG_93", 0, 0x50); }
int IncReg1A(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0x1A, 1, "REG_1A", 0, 0x35); }
int DecReg10(struct fp_img_dev *dev) { return AddReg(dev, 0x10, -1, "REG_10", 0, 0x99); }
int IncReg10(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0x10, 1, "REG_10", 0, 0x99); }
int DecVRB(struct fp_img_dev *dev) { return AddReg(dev, 0xE2, -1, "VRB", 0, 0x3A); }
int IncReg94(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0x94, 1, "REG_94", 0, 0x35); }
int IncDTVRT(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0xE3, 1, "DTVRT", 0, 0x20); }
int DecReg94(struct fp_img_dev *dev) { return AddReg(dev, 0x94, -1, "REG_94", 0, 0x35); }
int IncVCO_C(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0xE5, 1, "VCO_C", 0, 0x20); }
template<typename T> std::string FragmentProgramDecompiler::GetSRC(T src) { std::string ret; switch (src.reg_type) { case 0: //tmp ret += AddReg(src.tmp_reg_index, src.fp16); break; case 1: //input { static const std::string reg_table[] = { "gl_Position", "diff_color", "spec_color", "fogc", "tc0", "tc1", "tc2", "tc3", "tc4", "tc5", "tc6", "tc7", "tc8", "tc9", "ssa" }; switch (dst.src_attr_reg_num) { case 0x00: ret += reg_table[0]; break; default: if (dst.src_attr_reg_num < sizeof(reg_table) / sizeof(reg_table[0])) { ret += m_parr.AddParam(PF_PARAM_IN, getFloatTypeName(4), reg_table[dst.src_attr_reg_num]); } else { LOG_ERROR(RSX, "Bad src reg num: %d", u32{ dst.src_attr_reg_num }); ret += m_parr.AddParam(PF_PARAM_IN, getFloatTypeName(4), "unk"); Emu.Pause(); } break; } } break; case 2: //const ret += AddConst(); break; case 3: // ??? Used by a few games, what is it? LOG_ERROR(RSX, "Src type 3 used, please report this to a developer."); break; default: LOG_ERROR(RSX, "Bad src type %d", u32{ src.reg_type }); Emu.Pause(); break; } static const char f[4] = { 'x', 'y', 'z', 'w' }; std::string swizzle = ""; swizzle += f[src.swizzle_x]; swizzle += f[src.swizzle_y]; swizzle += f[src.swizzle_z]; swizzle += f[src.swizzle_w]; if (strncmp(swizzle.c_str(), f, 4) != 0) ret += "." + swizzle; if (src.abs) ret = "abs(" + ret + ")"; if (src.neg) ret = "-" + ret; return ret; }
int DecDCOffset(struct fp_img_dev *dev) { return AddReg(dev, 0xE6, -1, "DCOFFSET", 0, 0x35); }
int DecGain(struct fp_img_dev *dev) { return AddReg(dev, 0xE0, -1, "GAIN", 0, 0x35); }
void GLFragmentDecompilerThread::AddCode(std::string code, bool append_mask) { if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) return; const std::string mask = GetMask(); std::string cond; if(!src0.exec_if_gr || !src0.exec_if_lt || !src0.exec_if_eq) { static const char f[4] = {'x', 'y', 'z', 'w'}; std::string swizzle; swizzle += f[src0.cond_swizzle_x]; swizzle += f[src0.cond_swizzle_y]; swizzle += f[src0.cond_swizzle_z]; swizzle += f[src0.cond_swizzle_w]; swizzle = swizzle == "xyzw" ? "" : "." + swizzle; if(src0.exec_if_gr && src0.exec_if_eq) { cond = "greaterThanEqual"; } else if(src0.exec_if_lt && src0.exec_if_eq) { cond = "lessThanEqual"; } else if(src0.exec_if_gr && src0.exec_if_lt) { cond = "notEqual"; } else if(src0.exec_if_gr) { cond = "greaterThan"; } else if(src0.exec_if_lt) { cond = "lessThan"; } else //if(src0.exec_if_eq) { cond = "equal"; } cond = "if(all(" + cond + "(" + AddCond(dst.no_dest) + swizzle + ", vec4(0.0)))) "; } if(src1.scale) { switch(src1.scale) { case 1: code = "(" + code + " * 2)"; break; case 2: code = "(" + code + " * 4)"; break; case 3: code = "(" + code + " * 8)"; break; case 5: code = "(" + code + " / 2)"; break; case 6: code = "(" + code + " / 4)"; break; case 7: code = "(" + code + " / 8)"; break; default: ConLog.Error("Bad scale: %d", fmt::by_value(src1.scale)); Emu.Pause(); break; } } if(dst.saturate) { code = "clamp(" + code + ", 0.0, 1.0)"; } std::string dest; if(dst.no_dest) { if(dst.set_cond) { dest = m_parr.AddParam(PARAM_NONE , "vec4", std::string(dst.fp16 ? "hc" : "rc") + std::to_string(src0.cond_reg_index)); } } else { dest = AddReg(dst.dest_reg, dst.fp16); } code = cond + (dest.length() ? dest + mask + " = " : "") + code + (append_mask ? mask : ""); main += "\t" + code + ";\n"; }
int IncVRT(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0xE1, 1, "VRT", 0, 0x3F); }
int IncGain(struct fp_img_dev *dev) { /* TODO unknown min max */ return AddReg(dev, 0xE0, 1, "GAIN", 0, 0x35); }
int DecReg03(struct fp_img_dev *dev) { return AddReg(dev, 0x03, -1, "REG_03", 0, 0x35); }