RSP: Add class to wrap around RSP flag

This commit is contained in:
zilmar 2023-08-24 08:00:29 +09:30
parent 0cb43e0c33
commit 9dab3481ae
5 changed files with 56 additions and 15 deletions

View File

@ -1304,22 +1304,14 @@ void RSP_Vector_VABS(void)
void RSP_Vector_VADDC(void)
{
uint8_t el, del;
UWORD32 temp;
RSPVector Result;
RSP_Flags[0].UW = 0;
for (el = 0; el < 8; el++)
VCOH.Clear();
for (uint8_t el = 0; el < 8; el++)
{
del = EleSpec[RSPOpC.e].B[el];
temp.UW = (int)RSP_Vect[RSPOpC.vs].u16(el) + (int)RSP_Vect[RSPOpC.vt].u16(del);
RSP_ACCUM[el].HW[1] = temp.HW[0];
Result.u16(el) = temp.UHW[0];
if (temp.UW & 0xffff0000)
{
RSP_Flags[0].UW |= (1 << (7 - el));
}
int32_t Temp = (int32_t)RSP_Vect[RSPOpC.vs].u16(el) + (int32_t)RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e);
RSP_ACCUM[el].HW[1] = (int16_t)Temp;
Result.u16(el) = RSP_ACCUM[el].HW[1];
VCOL.Set(el, (Temp >> 16) != 0);
}
RSP_Vect[RSPOpC.vd] = Result;
}

View File

@ -5,6 +5,8 @@ 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]);
char * GPR_Strings[32] = {
"R0",
"AT",

View File

@ -103,3 +103,5 @@ void UpdateRSPRegistersScreen(void);
extern UWORD32 RSP_GPR[32], RSP_Flags[4];
extern UDWORD RSP_ACCUM[8];
extern RSPVector RSP_Vect[32];
extern RSPFlag VCOL, VCOH;

View File

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

View File

@ -39,6 +39,23 @@ 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);
void Clear(void);
void Set(uint8_t Index, bool Value);
bool Get(uint8_t Index) const;
private:
RSPFlag();
RSPFlag(const RSPFlag &);
RSPFlag & operator=(const RSPFlag &);
uint16_t & m_Flag;
};