GPU: Truncate sprite/rectangle positions to 12 bits before rendering

Fixes disappearing objects in Skullmonkeys.
This commit is contained in:
Connor McLaughlin
2020-04-27 12:51:17 +10:00
parent 63692a012f
commit 304391bd00
3 changed files with 16 additions and 14 deletions

View File

@ -166,7 +166,7 @@ public:
bool ConvertScreenCoordinatesToBeamTicksAndLines(s32 window_x, s32 window_y, u32* out_tick, u32* out_line) const;
protected:
static TickCount GPUTicksToSystemTicks(TickCount gpu_ticks)
static constexpr TickCount GPUTicksToSystemTicks(TickCount gpu_ticks)
{
// convert to master clock, rounding up as we want to overshoot not undershoot
return static_cast<TickCount>((static_cast<u32>(gpu_ticks) * 7u + 10u) / 11u);
@ -254,7 +254,6 @@ protected:
}
};
// TODO: Use BitField to do sign extending instead
union VertexPosition
{
u32 bits;
@ -263,6 +262,9 @@ protected:
BitField<u32, s32, 16, 12> y;
};
// Sprites/rectangles should be clipped to 12 bits before drawing.
static constexpr s32 TruncateVertexPosition(s32 x) { return SignExtendN<11, s32>(x); }
union VRAMPixel
{
u16 bits;