void DecodedMux::Decode(uint32_t dwMux0, uint32_t dwMux1) { m_dwMux0 = dwMux0; m_dwMux1 = dwMux1; aRGB0 = uint8_t((dwMux0>>20)&0x0F); // c1 c1 // a0 bRGB0 = uint8_t((dwMux1>>28)&0x0F); // c1 c2 // b0 cRGB0 = uint8_t((dwMux0>>15)&0x1F); // c1 c3 // c0 dRGB0 = uint8_t((dwMux1>>15)&0x07); // c1 c4 // d0 aA0 = uint8_t((dwMux0>>12)&0x07); // c1 a1 // Aa0 bA0 = uint8_t((dwMux1>>12)&0x07); // c1 a2 // Ab0 cA0 = uint8_t((dwMux0>>9 )&0x07); // c1 a3 // Ac0 dA0 = uint8_t((dwMux1>>9 )&0x07); // c1 a4 // Ad0 aRGB1 = uint8_t((dwMux0>>5 )&0x0F); // c2 c1 // a1 bRGB1 = uint8_t((dwMux1>>24)&0x0F); // c2 c2 // b1 cRGB1 = uint8_t((dwMux0 )&0x1F); // c2 c3 // c1 dRGB1 = uint8_t((dwMux1>>6 )&0x07); // c2 c4 // d1 aA1 = uint8_t((dwMux1>>21)&0x07); // c2 a1 // Aa1 bA1 = uint8_t((dwMux1>>3 )&0x07); // c2 a2 // Ab1 cA1 = uint8_t((dwMux1>>18)&0x07); // c2 a3 // Ac1 dA1 = uint8_t((dwMux1 )&0x07); // c2 a4 // Ad1 //This function will translate the decode mux info further, so we can use //the decode data better. //Will translate A,B,C,D to unified presentation aRGB0 = sc_Mux16[aRGB0]; bRGB0 = sc_Mux16[bRGB0]; cRGB0 = sc_Mux32[cRGB0]; dRGB0 = sc_Mux8[dRGB0]; aA0 = sc_Mux8[aA0]; bA0 = sc_Mux8[bA0]; cA0 = sc_Mux8[cA0]; dA0 = sc_Mux8[dA0]; aRGB1 = sc_Mux16[aRGB1]; bRGB1 = sc_Mux16[bRGB1]; cRGB1 = sc_Mux32[cRGB1]; dRGB1 = sc_Mux8[dRGB1]; aA1 = sc_Mux8[aA1]; bA1 = sc_Mux8[bA1]; cA1 = sc_Mux8[cA1]; dA1 = sc_Mux8[dA1]; m_bShadeIsUsed[1] = IsUsedInAlphaChannel(MUX_SHADE, MUX_MASK); m_bShadeIsUsed[0] = IsUsedInColorChannel(MUX_SHADE, MUX_MASK); m_bTexel0IsUsed = IsUsed(MUX_TEXEL0, MUX_MASK); m_bTexel1IsUsed = IsUsed(MUX_TEXEL1, MUX_MASK); m_dwShadeColorChannelFlag = 0; m_dwShadeAlphaChannelFlag = 0; m_ColorTextureFlag[0] = 0; m_ColorTextureFlag[1] = 0; }
int DecodedMux::HowManyTextures() { int n = 0; if (IsUsed(MUX_TEXEL0, MUX_MASK)) n++; if (IsUsed(MUX_TEXEL1, MUX_MASK)) n++; return n; }
void DecodedMux::Simplify(void) { CheckCombineInCycle1(); if (gRDP.otherMode.text_lod) ConvertLODFracTo0(); if (g_curRomInfo.bTexture1Hack) { ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 2, MUX_MASK); ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 3, MUX_MASK); } Reformat(true); UseShadeForConstant(); Reformat(true); if (m_dwShadeColorChannelFlag == MUX_0) { MergeShadeWithConstants(); Reformat(true); } #ifdef ALLOW_USE_TEXTURE_FOR_CONSTANTS UseTextureForConstant(); for (int i=0; i<2; i++) { if (m_ColorTextureFlag[i] != 0) { if (m_dwShadeColorChannelFlag == m_ColorTextureFlag[i]) { ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle0RGB, MUX_MASK); ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle1RGB, MUX_MASK); m_dwShadeColorChannelFlag = 0; } if (m_dwShadeAlphaChannelFlag == m_ColorTextureFlag[i]) { ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle0Alpha, MUX_MASK); ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle1Alpha, MUX_MASK); ReplaceVal(MUX_SHADE|MUX_ALPHAREPLICATE, (MUX_TEXEL0+i)|MUX_ALPHAREPLICATE, N64Cycle0RGB, MUX_MASK_WITH_ALPHA); ReplaceVal(MUX_SHADE|MUX_ALPHAREPLICATE, (MUX_TEXEL0+i)|MUX_ALPHAREPLICATE, N64Cycle1RGB, MUX_MASK_WITH_ALPHA); m_dwShadeAlphaChannelFlag = 0; } } } Reformat(true); #endif m_bTexel0IsUsed = IsUsed(MUX_TEXEL0, MUX_MASK); m_bTexel1IsUsed = IsUsed(MUX_TEXEL1, MUX_MASK); }
void DecodedMux::UseTextureForConstant(void) { int numofconst = HowManyConstFactors(); int numOftex = HowManyTextures(); if (numofconst > m_maxConstants && numOftex < m_maxTextures) { // We can use a texture for a constant for (int i=0; i<2 && numofconst > m_maxConstants ; i++) { if (IsUsed(MUX_TEXEL0+i, MUX_MASK)) { continue; // can not use this texture } if (IsUsed(MUX_PRIM, MUX_MASK)) { ReplaceVal(MUX_PRIM, MUX_TEXEL0+i, -1, MUX_MASK); m_ColorTextureFlag[i] = MUX_PRIM; numofconst--; continue; } if (IsUsed(MUX_ENV, MUX_MASK)) { ReplaceVal(MUX_ENV, MUX_TEXEL0+i, -1, MUX_MASK); m_ColorTextureFlag[i] = MUX_ENV; numofconst--; continue; } if (IsUsed(MUX_LODFRAC, MUX_MASK)) { ReplaceVal(MUX_LODFRAC, MUX_TEXEL0+i, -1, MUX_MASK); m_ColorTextureFlag[i] = MUX_LODFRAC; numofconst--; continue; } if (IsUsed(MUX_PRIMLODFRAC, MUX_MASK)) { ReplaceVal(MUX_PRIMLODFRAC, MUX_TEXEL0+i, -1, MUX_MASK); m_ColorTextureFlag[i] = MUX_PRIMLODFRAC; numofconst--; continue; } } } }
void DecodedMuxForOGL14V2::UseTextureForConstant(void) { bool envused = IsUsed(MUX_ENV, MUX_MASK); bool lodused = IsUsed(MUX_LODFRAC, MUX_MASK); int numofconst = 0; if (envused) numofconst++; if (lodused) numofconst++; int numOftex = HowManyTextures(); if (numofconst > 0 && numOftex < 2) { // We can use a texture for a constant for (int i=0; i<2 && numofconst > 0 ; i++) { if (IsUsed(MUX_TEXEL0+i, MUX_MASK)) { continue; // can not use this texture } if (envused) { ReplaceVal(MUX_ENV, MUX_TEXEL0+i, -1, MUX_MASK); m_ColorTextureFlag[i] = MUX_ENV; numofconst--; envused = false; continue; } if (IsUsed(MUX_LODFRAC, MUX_MASK)) { ReplaceVal(MUX_LODFRAC, MUX_TEXEL0+i, -1, MUX_MASK); m_ColorTextureFlag[i] = MUX_LODFRAC; numofconst--; continue; } if (IsUsed(MUX_PRIMLODFRAC, MUX_MASK)) { ReplaceVal(MUX_PRIMLODFRAC, MUX_TEXEL0+i, -1, MUX_MASK); m_ColorTextureFlag[i] = MUX_PRIMLODFRAC; numofconst--; continue; } } } }
uintptr_t ForEachSetMember( GENERICSET *pSet, int unitsize, int max, FESMCallback f, uintptr_t psv ) { //Log2( WIDE("Doing all in set - size: %d setsize: %d"), unitsize, max ); if( f ) { int total = 0; int ofs, n; ofs = ( ( max + 31) / 32 ) * 4; while( pSet ) { int nFound = 0; for( n = 0; nFound < (int)pSet->nUsed && n < max; n++ ) if( IsUsed( pSet, n ) ) { uintptr_t psvReturn; nFound++; psvReturn = f( total+n, psv ); if( psvReturn ) { //Log( WIDE("Return short? ")); return psvReturn; } } total += n; pSet = pSet->next; } } return 0; }
void PortSpace::Release(const Value_t port) { if(port < min_ || port > max_ || IsUsed(port) == false) return; setPort(port, false); }
void DeleteSetMemberEx( GENERICSET *pSet, INDEX iMember, uintptr_t unitsize, INDEX max ) { //Log2( WIDE("Deleting from %08x of %08x "), pSet, iMember ); while( pSet ) { if( iMember >= max ) { iMember -= max; pSet = pSet->next; continue; } break; } if( pSet ) { if( !IsUsed( pSet, iMember ) ) { DebugBreak(); lprintf( WIDE("Deleting set member which is already released? not decrementing used counter") ); } else { ClearUsed( pSet, iMember ); //pSet->nUsed--; // one not used - quick reference counter } } else Log( WIDE("Failed to find node in set!") ); }
int NFCRecord::FindVector3(const int nCol, const NFVector3& value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_VECTOR3 != mVarRecordType->Type(nCol)) { return -1; } { for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetVector3(i, nCol) == value) { varResult << (int64_t)i; } } return varResult.GetCount(); } return -1; }
uintptr_t _ForAllInSet( GENERICSET *pSet, int unitsize, int max, FAISCallback f, uintptr_t psv ) { //Log2( WIDE("Doing all in set - size: %d setsize: %d"), unitsize, max ); if( f ) { int ofs, n; ofs = ( ( max + 31) / 32 ) * 4; while( pSet ) { for( n = 0; n < max; n++ ) if( IsUsed( pSet, n ) ) { uintptr_t psvReturn; psvReturn = f( (void*)( ((uintptr_t)(pSet->bUsed)) + ofs + n * unitsize ), psv ); if( psvReturn ) { //Log( WIDE("Return short? ")); return psvReturn; } } pSet = pSet->next; } } return 0; }
int NFCRecord::FindFloat(const int nCol, const double value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_FLOAT != mVarRecordType->Type(nCol)) { return -1; } for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetFloat(i, nCol) == value) { varResult << i; } } return varResult.GetCount(); }
void PortSpace::Use(const Value_t port) { if(IsUsed(port)) throw UnavailablePortError(port, *this); setPort(port, true); }
int NFCRecord::FindString(const int nCol, const std::string& value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_STRING != mVarRecordType->Type(nCol)) { return -1; } { for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } const std::string& strData = GetString(i, nCol); if (0 == strcmp(strData.c_str(), value.c_str())) { varResult << (int64_t)i; } } return varResult.GetCount(); } return -1; }
void DecodedMuxForOGL14V2::Simplify(void) { CheckCombineInCycle1(); if (g_curRomInfo.bTexture1Hack) { ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 2, MUX_MASK); ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 3, MUX_MASK); } Reformat(true); UseTextureForConstant(); Reformat(true); m_bTexel0IsUsed = IsUsed(MUX_TEXEL0, MUX_MASK); m_bTexel1IsUsed = IsUsed(MUX_TEXEL1, MUX_MASK); }
bool NFCRecord::SwapRowInfo(const int nOriginRow, const int nTargetRow) { if (!IsUsed(nOriginRow)) { return false; } if (ValidRow(nOriginRow) && ValidRow(nTargetRow)) { for (int i = 0; i < GetCols(); ++i) { NF_SHARE_PTR<NFData> pOrigin = mtRecordVec.at(GetPos(nOriginRow, i)); mtRecordVec[GetPos(nOriginRow, i)] = mtRecordVec.at(GetPos(nTargetRow, i)); mtRecordVec[GetPos(nTargetRow, i)] = pOrigin; } int nOriginUse = mVecUsedState[nOriginRow]; mVecUsedState[nOriginRow] = mVecUsedState[nTargetRow]; mVecUsedState[nTargetRow] = nOriginUse; RECORD_EVENT_DATA xEventData; xEventData.nOpType = RECORD_EVENT_DATA::Swap; xEventData.nRow = nOriginRow; xEventData.nCol = nTargetRow; xEventData.strRecordName = mstrRecordName; NFData xData; OnEventHandler(mSelf, xEventData, xData, xData); return true; } return false; }
int NFCRecord::FindObject(const int nCol, const NFGUID& value, NFIDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_OBJECT != mVarRecordType->Type(nCol)) { return -1; } { for (int64_t i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetObject(i, nCol) == value) { varResult << i; } } return varResult.GetCount(); } return -1; }
ERMsg COGRBaseOption::ProcessOption(int& i, int argc, char* argv[]) { ERMsg msg; string error; if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "--utility_version")) { m_bVersion = true; } else if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "-co") && i < argc - 1) { m_createOptions.push_back(argv[++i]); } else if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "-of") && i < argc - 1) { m_format = argv[++i]; } else if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "-wo") && i < argc - 1)//working option { //UNIFIED_SRC_NODATA m_workOptions.push_back(argv[++i]); } else if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "-multi")) { m_bMulti = true; } else if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "-f") && i < argc - 1) { m_format = argv[i + 1]; } else if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "-overwrite")) { m_bOverwrite = true; } else if (IsUsed(BASE_OPTIONS) && IsEqual(argv[i], "-q")) { m_bQuiet = true; } else if (IsEqual(argv[i], "-?") || IsEqual(argv[i], "-help")) { m_bNeedHelp = true; } else if (argv[i][0] == '-') { error = string("ERROR: Invalid option: ") + argv[i] + ", use - ? for more help.\n"; msg.ajoute(error); //return false; } else { m_filesPath.push_back(argv[i]); } return msg; }
inline Slot GetUsedSlots() const noexcept { Slot n = 0; for (Slot s = 0; s < Slots; ++s) if (IsUsed(s)) ++n; return n; }
int DecodedMux::HowManyConstFactors() { int n = 0; if (IsUsed(MUX_PRIM, MUX_MASK)) n++; if (IsUsed(MUX_ENV, MUX_MASK)) n++; if (IsUsed(MUX_LODFRAC, MUX_MASK)) n++; if (IsUsed(MUX_PRIMLODFRAC, MUX_MASK)) n++; return n; }
const PortSpace::Value_t PortSpace::GetAvailable() const { for(Value_t port = min_; port <= max_; port++) { if(!IsUsed(port)) return port; } return empty; }
void DecodedMuxForPixelShader::Simplify(void) { CheckCombineInCycle1(); //Reformat(true); if( g_curRomInfo.bTexture1Hack ) { ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 2, MUX_MASK); ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 3, MUX_MASK); } splitType[0] = CM_FMT_TYPE_NOT_USED; splitType[1] = CM_FMT_TYPE_NOT_USED; splitType[2] = CM_FMT_TYPE_NOT_USED; splitType[3] = CM_FMT_TYPE_NOT_USED; mType = CM_FMT_TYPE_NOT_USED; m_bTexel0IsUsed = IsUsed(MUX_TEXEL0, MUX_MASK); m_bTexel1IsUsed = IsUsed(MUX_TEXEL1, MUX_MASK); }
bool NFCRecord::SetVector3(const int nRow, const int nCol, const NFVector3& value) { if (!ValidPos(nRow, nCol)) { return false; } if (TDATA_VECTOR3 != GetColType(nCol)) { return false; } if (!IsUsed(nRow)) { return false; } NFData var; var.SetVector3(value); NF_SHARE_PTR<NFData>& pVar = mtRecordVec.at(GetPos(nRow, nCol)); //must have memory if (nullptr == pVar) { return false; } if (var == *pVar) { return false; } if (mtRecordCallback.size() == 0) { pVar->SetVector3(value); } else { NFData oldValue; oldValue.SetVector3(pVar->GetVector3()); pVar->SetVector3(value); RECORD_EVENT_DATA xEventData; xEventData.nOpType = RECORD_EVENT_DATA::Update; xEventData.nRow = nRow; xEventData.nCol = nCol; xEventData.strRecordName = mstrRecordName; OnEventHandler(mSelf, xEventData, oldValue, *pVar); } return true; }
string COGRBaseOption::GetUsage()const { string usage = "Usage: \n"; if (IsUsed(BASE_OPTIONS)) { usage += " [--help-general] [--formats]\n" " [-of format] [-ot Byte/Int16/...] [-co \"NAME=VALUE\"]*\n" " [-srcnodata value] [-dstnodata value] [-wo \"NAME=VALUE\"]*\n" " [-q] [-multi] [-overwrite]\n"; } if (IsUsed(OP_SEPARATE)) usage += " [-separate]\n"; if (IsUsed(OP_EXTENTS)) { usage += " [-te xmin ymin xmax ymax] -tap\n"; } if (IsUsed(OP_SIZE)) { usage += " [-ts xres yres] [-ts width height]\n"; } if (IsUsed(OP_BANDS)) { usage += " [-b band]\n"; } //usage += " srcfile*\n"; return usage; }
int CountUsedInSetEx( GENERICSET *pSet, int max ) { int cnt = 0, n; while( pSet ) { for( n = 0; n < max; n++ ) if( IsUsed( pSet, n ) ) cnt++; pSet = pSet->next; } return cnt; }
// 获得数据 bool NFCRecord::QueryRow(const int nRow, NFIDataList& varList) { if (!ValidRow(nRow)) { return false; } if (!IsUsed(nRow)) { return false; } varList.Clear(); for (int i = 0; i < GetCols(); ++i) { NF_SHARE_PTR<NFIDataList::TData> pVar = mtRecordVec.at(GetPos(nRow, i)); if (pVar.get()) { varList.Append(*pVar); } else { switch (GetColType(i)) { case TDATA_INT: varList.Add(NFINT64(0)); break; case TDATA_FLOAT: varList.Add(0.0f); break; case TDATA_STRING: varList.Add(NULL_STR.c_str()); break; case TDATA_OBJECT: varList.Add(NFGUID()); break; default: return false; break; } } } if (varList.GetCount() != GetCols()) { return false; } return true; }
// interface int asCModule::AddScriptSection(const char *name, const char *code, size_t codeLength, int lineOffset) { if( IsUsed() ) return asMODULE_IS_IN_USE; if( !builder ) builder = asNEW(asCBuilder)(engine, this); builder->AddCode(name, code, (int)codeLength, lineOffset, (int)builder->scripts.GetLength(), engine->ep.copyScriptSections); return asSUCCESS; }
CRect cdxCDynamicControlsManager::ControlData::GetCurrentPosition() const { if(!IsUsed()) { ASSERT(false); // all sub-controls have been deleted return CRect(0,0,0,0); } WINDOWPLACEMENT wpl; VERIFY( m_pCtrl->GetCWnd().GetWindowPlacement(&wpl) ); return CRect(wpl.rcNormalPosition); }
const PortSpace::Value_t PortSpace::GetNextDefault() { default_count_++; if(default_count_ > max_) return empty; // out of values :( if(IsUsed(default_count_)) return GetNextDefault(); // this isn't available, try again else return default_count_; //^ Recursion may be a bad idea here }
bool UserDefinedEncodings::Get(uint16 unicode, uint8 &encoding, uint8 &index) { bool missing = !IsUsed(unicode); if (missing) { SetUsed(unicode); fEncoding[unicode] = fCurrentEncoding; fIndex[unicode] = fCurrentIndex; if (fCurrentIndex == 255) { fCurrentIndex = 0; fCurrentEncoding ++; } else { fCurrentIndex ++; } } encoding = fEncoding[unicode]; index = fIndex[unicode]; return missing; }
void DecodedMuxForSemiPixelShader::Reset(void) { Decode(m_dwMux0, m_dwMux1); splitType[0] = CM_FMT_TYPE_NOT_CHECKED; splitType[1] = CM_FMT_TYPE_NOT_CHECKED; splitType[2] = CM_FMT_TYPE_NOT_CHECKED; splitType[3] = CM_FMT_TYPE_NOT_CHECKED; Hack(); gRSP.bProcessDiffuseColor = false; gRSP.bProcessSpecularColor = false; CheckCombineInCycle1(); if( g_curRomInfo.bTexture1Hack ) { ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 2, MUX_MASK); ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 3, MUX_MASK); } m_bTexel0IsUsed = IsUsed(MUX_TEXEL0, MUX_MASK); m_bTexel1IsUsed = IsUsed(MUX_TEXEL1, MUX_MASK); }