diff --git a/Source/ee/Vif.cpp b/Source/ee/Vif.cpp index 61a2367ea3..af15881c8c 100644 --- a/Source/ee/Vif.cpp +++ b/Source/ee/Vif.cpp @@ -711,12 +711,10 @@ void CVif::Cmd_UNPACK(StreamType& stream, CODE nCommand, uint32 nDstAddr) ((*this).*(unpackFct))(stream, nCommand, nDstAddr); } -uint32 CVif::GetMaskOp(unsigned int row, unsigned int col) const +uint32 CVif::GetColMaskOp(unsigned int col) const { - if(col > 3) col = 3; - assert(row < 4); - unsigned int index = (col * 4) + row; - return (m_MASK >> (index * 2)) & 0x03; + assert(col < 4); + return (m_MASK >> (col * 8)) & 0xFF; } void CVif::PrepareMicroProgram() diff --git a/Source/ee/Vif.h b/Source/ee/Vif.h index 0fb8ba110b..36f29021c5 100644 --- a/Source/ee/Vif.h +++ b/Source/ee/Vif.h @@ -317,7 +317,7 @@ class CVif void Cmd_STCOL(StreamType&, CODE); void Cmd_STMASK(StreamType&, CODE); - inline uint32 GetMaskOp(unsigned int, unsigned int) const; + inline uint32 GetColMaskOp(unsigned int) const; inline bool Unpack_S32(StreamType& stream, uint128& result) { @@ -577,41 +577,49 @@ class CVif if(mustWrite) { auto dst = reinterpret_cast(vuMem + nDstAddr); + uint32 col = (m_writeTick > 3) ? 3 : m_writeTick; + uint32 colMask = useMask ? GetColMaskOp(col) : 0; - for(unsigned int i = 0; i < 4; i++) + if((colMask == 0) && (mode == 0)) { - uint32 maskOp = useMask ? GetMaskOp(i, m_writeTick) : MASK_DATA; - - if(maskOp == MASK_DATA) + (*dst) = writeValue; + } + else + { + for(unsigned int i = 0; i < 4; i++) { - if(mode == MODE_OFFSET) + uint32 maskOp = useMask ? (colMask >> (i * 2)) & 0x3 : MASK_DATA; + + if(maskOp == MASK_DATA) { - writeValue.nV[i] += m_R[i]; + if(mode == MODE_OFFSET) + { + writeValue.nV[i] += m_R[i]; + } + else if(mode == MODE_DIFFERENCE) + { + writeValue.nV[i] += m_R[i]; + m_R[i] = writeValue.nV[i]; + } + + dst->nV[i] = writeValue.nV[i]; } - else if(mode == MODE_DIFFERENCE) + else if(maskOp == MASK_ROW) { - writeValue.nV[i] += m_R[i]; - m_R[i] = writeValue.nV[i]; + dst->nV[i] = m_R[i]; + } + else if(maskOp == MASK_COL) + { + dst->nV[i] = m_C[col]; + } + else if(maskOp == MASK_MASK) + { + //Don't write anything + } + else + { + assert(0); } - - dst->nV[i] = writeValue.nV[i]; - } - else if(maskOp == MASK_ROW) - { - dst->nV[i] = m_R[i]; - } - else if(maskOp == MASK_COL) - { - int index = (m_writeTick > 3) ? 3 : m_writeTick; - dst->nV[i] = m_C[index]; - } - else if(maskOp == MASK_MASK) - { - //Don't write anything - } - else - { - assert(0); } }