Software backend: make TEV rounding match hardware.

Formulas stolen from gxtest.  (Not sure how "==" got turned into "!=", but
I'm pretty confident the patched version is correct.)
This commit is contained in:
magumagu 2014-04-15 14:01:22 -07:00
parent 12d7ffac13
commit 5e1c6aba33

View File

@ -185,8 +185,9 @@ void Tev::DrawColorRegular(TevStageCombiner::ColorCombiner &cc, const InputRegTy
s32 temp = InputReg.a * (256 - c) + (InputReg.b * c);
temp <<= m_ScaleLShiftLUT[cc.shift];
temp += (cc.shift != 3) ? 0 : (cc.op == 1) ? 127 : 128;
temp = cc.op ? (-temp >> 8) : (temp >> 8);
temp += (cc.shift == 3) ? 0 : (cc.op == 1) ? 127 : 128;
temp >>= 8;
temp = cc.op ? -temp : temp;
s32 result = ((InputReg.d + m_BiasLUT[cc.bias]) << m_ScaleLShiftLUT[cc.shift]) + temp;
result = result >> m_ScaleRShiftLUT[cc.shift];