RSP: Clean up VCL

This commit is contained in:
zilmar 2023-08-24 10:07:05 +09:30
parent 9dab3481ae
commit 7db5876927
5 changed files with 26 additions and 71 deletions

View File

@ -1515,87 +1515,38 @@ void RSP_Vector_VGE(void)
void RSP_Vector_VCL(void)
{
uint8_t el, del;
RSPVector Result;
for (el = 0; el < 8; el++)
for (uint8_t el = 0; el < 8; el++)
{
del = EleSpec[RSPOpC.e].B[el];
if ((RSP_Flags[0].UW & (1 << (7 - el))) != 0)
if (VCOL.Get(el))
{
if ((RSP_Flags[0].UW & (1 << (15 - el))) != 0)
if (VCOH.Get(el))
{
if ((RSP_Flags[1].UW & (1 << (7 - el))) != 0)
{
RSP_ACCUM[el].HW[1] = -RSP_Vect[RSPOpC.vt].u16(del);
}
else
{
RSP_ACCUM[el].HW[1] = RSP_Vect[RSPOpC.vs].s16(el);
}
RSP_ACCUM[el].HW[1] = VCCL.Get(el) ? -RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) : RSP_Vect[RSPOpC.vs].s16(el);
}
else
{
if ((RSP_Flags[2].UW & (1 << (7 - el))))
{
if (RSP_Vect[RSPOpC.vs].u16(el) + RSP_Vect[RSPOpC.vt].u16(del) > 0x10000)
{
RSP_ACCUM[el].HW[1] = RSP_Vect[RSPOpC.vs].s16(el);
RSP_Flags[1].UW &= ~(1 << (7 - el));
}
else
{
RSP_ACCUM[el].HW[1] = -RSP_Vect[RSPOpC.vt].u16(del);
RSP_Flags[1].UW |= (1 << (7 - el));
}
}
else
{
if (RSP_Vect[RSPOpC.vt].u16(del) + RSP_Vect[RSPOpC.vs].u16(el) != 0)
{
RSP_ACCUM[el].HW[1] = RSP_Vect[RSPOpC.vs].s16(el);
RSP_Flags[1].UW &= ~(1 << (7 - el));
}
else
{
RSP_ACCUM[el].HW[1] = -RSP_Vect[RSPOpC.vt].u16(del);
RSP_Flags[1].UW |= (1 << (7 - el));
}
}
bool Set = VCE.Get(el) ? (RSP_Vect[RSPOpC.vs].u16(el) + RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) <= 0x10000) : (RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) + RSP_Vect[RSPOpC.vs].u16(el) == 0);
RSP_ACCUM[el].HW[1] = Set ? -RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) : RSP_Vect[RSPOpC.vs].s16(el);
VCCL.Set(el, Set);
}
}
else
{
if ((RSP_Flags[0].UW & (1 << (15 - el))) != 0)
if (VCOH.Get(el))
{
if ((RSP_Flags[1].UW & (1 << (15 - el))) != 0)
{
RSP_ACCUM[el].HW[1] = RSP_Vect[RSPOpC.vt].s16(del);
}
else
{
RSP_ACCUM[el].HW[1] = RSP_Vect[RSPOpC.vs].s16(el);
}
RSP_ACCUM[el].UHW[1] = VCCH.Get(el) ? RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) : RSP_Vect[RSPOpC.vs].s16(el);
}
else
{
if (RSP_Vect[RSPOpC.vs].u16(el) - RSP_Vect[RSPOpC.vt].u16(del) >= 0)
{
RSP_ACCUM[el].HW[1] = RSP_Vect[RSPOpC.vt].u16(del);
RSP_Flags[1].UW |= (1 << (15 - el));
}
else
{
RSP_ACCUM[el].HW[1] = RSP_Vect[RSPOpC.vs].s16(el);
RSP_Flags[1].UW &= ~(1 << (15 - el));
}
RSP_ACCUM[el].HW[1] = VCCH.Set(el, RSP_Vect[RSPOpC.vs].u16(el) - RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) >= 0) ? RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) : RSP_Vect[RSPOpC.vs].s16(el);
}
}
Result.s16(el) = RSP_ACCUM[el].HW[1];
}
RSP_Flags[0].UW = 0;
RSP_Flags[2].UW = 0;
VCOL.Clear();
VCOH.Clear();
VCE.Clear();
RSP_Vect[RSPOpC.vd] = Result;
}

View File

@ -5,7 +5,9 @@ UWORD32 RSP_GPR[32], RSP_Flags[4];
UDWORD RSP_ACCUM[8];
RSPVector RSP_Vect[32];
RSPFlag VCOL(RSP_Flags[0].UHW[0]), VCOH(RSP_Flags[0].UHW[1]);
RSPFlag VCOL(RSP_Flags[0].UB[0]), VCOH(RSP_Flags[0].UB[1]);
RSPFlag VCCL(RSP_Flags[1].UB[0]), VCCH(RSP_Flags[1].UB[1]);
RSPFlag VCE(RSP_Flags[2].UB[0]);
char * GPR_Strings[32] = {
"R0",

View File

@ -104,4 +104,6 @@ extern UWORD32 RSP_GPR[32], RSP_Flags[4];
extern UDWORD RSP_ACCUM[8];
extern RSPVector RSP_Vect[32];
extern RSPFlag VCOL, VCOH;
extern RSPFlag VCOL, VCOH;
extern RSPFlag VCCL, VCCH;
extern RSPFlag VCE;

View File

@ -51,7 +51,7 @@ uint64_t & RSPVector::u64(uint8_t Index)
return m_Reg[Index];
}
RSPFlag::RSPFlag(uint16_t & Flag) :
RSPFlag::RSPFlag(uint8_t & Flag) :
m_Flag(Flag)
{
}
@ -61,7 +61,7 @@ void RSPFlag::Clear(void)
m_Flag = 0;
}
void RSPFlag::Set(uint8_t Index, bool Value)
bool RSPFlag::Set(uint8_t Index, bool Value)
{
if (Value)
{
@ -71,10 +71,10 @@ void RSPFlag::Set(uint8_t Index, bool Value)
{
m_Flag &= ~(1 << (7 - Index));
}
return Value;
}
bool RSPFlag::Get(uint8_t Index) const
{
return (m_Flag & (1 << (7 - Index))) != 0;
}

View File

@ -39,17 +39,17 @@ public:
int32_t & s32(uint8_t Index);
uint64_t & u64(uint8_t Index);
private:
private:
uint64_t m_Reg[2] alignas(16);
};
class RSPFlag
{
public:
RSPFlag(uint16_t & Flag);
RSPFlag(uint8_t & Flag);
void Clear(void);
void Set(uint8_t Index, bool Value);
bool Set(uint8_t Index, bool Value);
bool Get(uint8_t Index) const;
private:
@ -57,5 +57,5 @@ private:
RSPFlag(const RSPFlag &);
RSPFlag & operator=(const RSPFlag &);
uint16_t & m_Flag;
uint8_t & m_Flag;
};