mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
CPU/PGXP: Inline valid flag updates
This commit is contained in:
parent
2011f66f06
commit
6104821a08
|
@ -58,14 +58,8 @@ struct PGXPValue
|
||||||
u32 value;
|
u32 value;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
||||||
ALWAYS_INLINE void SetValid(u32 comp, bool valid = true)
|
|
||||||
{
|
|
||||||
const u32 mask = (1u << comp);
|
|
||||||
flags = valid ? (flags | mask) : (flags & ~mask);
|
|
||||||
}
|
|
||||||
ALWAYS_INLINE void Validate(u32 psxval) { flags = (value == psxval) ? flags : 0; }
|
ALWAYS_INLINE void Validate(u32 psxval) { flags = (value == psxval) ? flags : 0; }
|
||||||
|
|
||||||
ALWAYS_INLINE bool HasValid(u32 comp) const { return ConvertToBoolUnchecked((flags >> comp) & 1); }
|
|
||||||
ALWAYS_INLINE float GetValidX(u32 psxval) const
|
ALWAYS_INLINE float GetValidX(u32 psxval) const
|
||||||
{
|
{
|
||||||
return (flags & 1) ? x : static_cast<float>(static_cast<s16>(psxval));
|
return (flags & 1) ? x : static_cast<float>(static_cast<s16>(psxval));
|
||||||
|
|
|
@ -37,13 +37,6 @@ enum : u32
|
||||||
PGXP_MEM_SCRATCH_OFFSET = Bus::RAM_8MB_SIZE / 4,
|
PGXP_MEM_SCRATCH_OFFSET = Bus::RAM_8MB_SIZE / 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum : u32
|
|
||||||
{
|
|
||||||
COMP_X,
|
|
||||||
COMP_Y,
|
|
||||||
COMP_Z,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum : u32
|
enum : u32
|
||||||
{
|
{
|
||||||
VALID_X = (1u << 0),
|
VALID_X = (1u << 0),
|
||||||
|
@ -317,19 +310,19 @@ ALWAYS_INLINE_RELEASE void CPU::PGXP::ValidateAndLoadMem16(PGXPValue& dest, u32
|
||||||
if (hiword)
|
if (hiword)
|
||||||
{
|
{
|
||||||
dest.x = dest.y;
|
dest.x = dest.y;
|
||||||
dest.SetValid(COMP_X, dest.HasValid(COMP_Y));
|
dest.flags = (dest.flags & ~VALID_X) | ((dest.flags & VALID_Y) >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only set y as valid if x is also valid.. don't want to make fake values
|
// only set y as valid if x is also valid.. don't want to make fake values
|
||||||
if (dest.HasValid(COMP_X))
|
if (dest.flags & VALID_X)
|
||||||
{
|
{
|
||||||
dest.y = (dest.x < 0) ? -1.0f * sign : 0.0f;
|
dest.y = (dest.x < 0) ? -1.0f * sign : 0.0f;
|
||||||
dest.SetValid(COMP_Y);
|
dest.flags |= VALID_Y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest.y = 0.0f;
|
dest.y = 0.0f;
|
||||||
dest.SetValid(COMP_Y, false);
|
dest.flags &= ~VALID_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.value = value;
|
dest.value = value;
|
||||||
|
@ -356,23 +349,22 @@ ALWAYS_INLINE_RELEASE void CPU::PGXP::WriteMem16(u32 addr, const PGXPValue& valu
|
||||||
if (hiword)
|
if (hiword)
|
||||||
{
|
{
|
||||||
dest->y = value.x;
|
dest->y = value.x;
|
||||||
dest->SetValid(COMP_Y, value.HasValid(COMP_X));
|
dest->flags = (dest->flags & ~VALID_Y) | ((value.flags & VALID_X) << 1);
|
||||||
dest->value = (dest->value & UINT32_C(0x0000FFFF)) | (value.value << 16);
|
dest->value = (dest->value & UINT32_C(0x0000FFFF)) | (value.value << 16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest->x = value.x;
|
dest->x = value.x;
|
||||||
dest->SetValid(COMP_X, value.HasValid(COMP_X));
|
dest->flags = (dest->flags & ~VALID_X) | (value.flags & VALID_X);
|
||||||
dest->value = (dest->value & UINT32_C(0xFFFF0000)) | (value.value & UINT32_C(0x0000FFFF));
|
dest->value = (dest->value & UINT32_C(0xFFFF0000)) | (value.value & UINT32_C(0x0000FFFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
// overwrite z/w if valid
|
// overwrite z/w if valid
|
||||||
// TODO: Check modified
|
// TODO: Check modified
|
||||||
if (value.HasValid(COMP_Z))
|
if (value.flags & VALID_Z)
|
||||||
{
|
{
|
||||||
dest->z = value.z;
|
dest->z = value.z;
|
||||||
dest->SetValid(COMP_Z);
|
dest->flags |= VALID_Z | (hiword ? VALID_HIGHZ : VALID_LOWZ);
|
||||||
dest->flags |= hiword ? VALID_HIGHZ : VALID_LOWZ;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -384,7 +376,7 @@ ALWAYS_INLINE_RELEASE void CPU::PGXP::WriteMem16(u32 addr, const PGXPValue& valu
|
||||||
|
|
||||||
ALWAYS_INLINE_RELEASE void CPU::PGXP::CopyZIfMissing(PGXPValue& dst, const PGXPValue& src)
|
ALWAYS_INLINE_RELEASE void CPU::PGXP::CopyZIfMissing(PGXPValue& dst, const PGXPValue& src)
|
||||||
{
|
{
|
||||||
dst.z = dst.HasValid(COMP_Z) ? dst.z : src.z;
|
dst.z = (dst.flags & VALID_Z) ? dst.z : src.z;
|
||||||
dst.flags |= (src.flags & VALID_Z);
|
dst.flags |= (src.flags & VALID_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +775,7 @@ void CPU::PGXP::CPU_ANDI(Instruction instr, u32 rsVal)
|
||||||
{
|
{
|
||||||
// if 0 then x == 0
|
// if 0 then x == 0
|
||||||
prtVal.x = 0.0f;
|
prtVal.x = 0.0f;
|
||||||
prtVal.SetValid(COMP_X);
|
prtVal.flags |= VALID_X;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -798,7 +790,7 @@ void CPU::PGXP::CPU_ANDI(Instruction instr, u32 rsVal)
|
||||||
{
|
{
|
||||||
// otherwise x is low precision value
|
// otherwise x is low precision value
|
||||||
prtVal.x = static_cast<float>(LOWORD_S16(rtVal));
|
prtVal.x = static_cast<float>(LOWORD_S16(rtVal));
|
||||||
prtVal.SetValid(COMP_X);
|
prtVal.flags |= VALID_X;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue