Skip to content

Commit

Permalink
interp: Implement vsbz and vlgb.
Browse files Browse the repository at this point in the history
Not sure any games actually use them, but good to have the remaining vfpu
ops all implemented.
  • Loading branch information
unknownbrackets committed Feb 23, 2019
1 parent 520f850 commit aff1d8e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
57 changes: 50 additions & 7 deletions Core/MIPS/MIPSIntVFPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1820,11 +1820,33 @@ namespace MIPSInt

void Int_Vlgb(MIPSOpcode op)
{
// S & D valid
Reporting::ReportMessage("vlgb not implemented");
if (!PSP_CoreParameter().headLess) {
_dbg_assert_msg_(CPU,0,"vlgb not implemented");
// Vector log binary (extract exponent)
int vd = _VD;
int vs = _VS;
VectorSize sz = GetVecSize(op);

FloatBits d;
FloatBits s;

ReadVector(s.f, sz, vs);
// TODO: Test swizzle, t?
ApplySwizzleS(s.f, sz);

if (sz != V_Single) {
ERROR_LOG_REPORT(CPU, "vlgb not implemented for size %d", GetNumVectorElements(sz));
}
for (int i = 0; i < GetNumVectorElements(sz); ++i) {
int exp = (s.u[i] & 0x7F800000) >> 23;
if (exp == 0xFF) {
d.f[i] = s.f[i];
} else if (exp == 0) {
d.f[i] = -INFINITY;
} else {
d.f[i] = (float)(exp - 127);
}
}
ApplyPrefixD(d.f, sz);
WriteVector(d.f, sz, vd);
PC += 4;
EatPrefixes();
}
Expand Down Expand Up @@ -1905,10 +1927,31 @@ namespace MIPSInt

void Int_Vsbz(MIPSOpcode op)
{
Reporting::ReportMessage("vsbz not implemented");
if (!PSP_CoreParameter().headLess) {
_dbg_assert_msg_(CPU,0,"vsbz not implemented");
// Vector scale by zero (set exp to 0 to extract mantissa)
int vd = _VD;
int vs = _VS;
VectorSize sz = GetVecSize(op);

FloatBits d;
FloatBits s;

ReadVector(s.f, sz, vs);
// TODO: Test swizzle, t?
ApplySwizzleS(s.f, sz);

if (sz != V_Single) {
ERROR_LOG_REPORT(CPU, "vsbz not implemented for size %d", GetNumVectorElements(sz));
}
for (int i = 0; i < GetNumVectorElements(sz); ++i) {
// NAN and denormals pass through.
if (my_isnan(s.f[i]) || (s.u[i] & 0x7F800000) == 0) {
d.u[i] = s.u[i];
} else {
d.u[i] = (127 << 23) | (s.u[i] & 0x007FFFFF);
}
}
ApplyPrefixD(d.f, sz);
WriteVector(d.f, sz, vd);
PC += 4;
EatPrefixes();
}
Expand Down
1 change: 1 addition & 0 deletions Core/MIPS/MIPSTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ const MIPSInstruction tableVFPU0[8] = // 011000 xxx ....... . ....... . .......
{
INSTR("vadd", JITFUNC(Comp_VecDo3), Dis_VectorSet3, Int_VecDo3, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX),
INSTR("vsub", JITFUNC(Comp_VecDo3), Dis_VectorSet3, Int_VecDo3, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX),
// TODO: Disasm is wrong.
INSTR("vsbn", JITFUNC(Comp_Generic), Dis_VectorSet3, Int_Vsbn, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX),
INVALID, INVALID, INVALID, INVALID,

Expand Down

0 comments on commit aff1d8e

Please sign in to comment.