Fix primitive 2D, and on screen 3D items.

This commit is contained in:
Skyth 2025-01-18 21:24:46 +03:00
parent d8b6befec0
commit 8fa2344f25

View file

@ -779,9 +779,9 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str
scaleX *= g_aspectRatioGameplayScale; scaleX *= g_aspectRatioGameplayScale;
if ((modifier.flags & ALIGN_RIGHT) != 0) if ((modifier.flags & ALIGN_RIGHT) != 0)
offsetX += Video::s_viewportWidth * (1.0f - g_aspectRatioGameplayScale); offsetX += 1280.0f * (1.0f - g_aspectRatioGameplayScale) * g_aspectRatioScale;
else if ((modifier.flags & ALIGN_LEFT) == 0) else if ((modifier.flags & ALIGN_LEFT) == 0)
offsetX += Video::s_viewportWidth * (1.0f - g_aspectRatioGameplayScale) * 0.5f; offsetX += 640.0f * (1.0f - g_aspectRatioGameplayScale) * g_aspectRatioScale;
} }
if ((modifier.flags & WORLD_MAP) != 0) if ((modifier.flags & WORLD_MAP) != 0)
@ -809,9 +809,9 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str
scaleY *= g_aspectRatioGameplayScale; scaleY *= g_aspectRatioGameplayScale;
if ((modifier.flags & ALIGN_BOTTOM) != 0) if ((modifier.flags & ALIGN_BOTTOM) != 0)
offsetY += Video::s_viewportHeight * (1.0f - g_aspectRatioGameplayScale); offsetY += 720.0f * (1.0f - g_aspectRatioGameplayScale) * g_aspectRatioScale;
else if ((modifier.flags & ALIGN_TOP) == 0) else if ((modifier.flags & ALIGN_TOP) == 0)
offsetY += Video::s_viewportHeight * (1.0f - g_aspectRatioGameplayScale) * 0.5f; offsetY += 360.0f * (1.0f - g_aspectRatioGameplayScale) * g_aspectRatioScale;
} }
} }
@ -896,10 +896,10 @@ PPC_FUNC(sub_82E16C70)
{ {
auto scissorRect = reinterpret_cast<GuestRect*>(base + ctx.r4.u32); auto scissorRect = reinterpret_cast<GuestRect*>(base + ctx.r4.u32);
scissorRect->left = scissorRect->left + g_aspectRatioOffsetX; scissorRect->left = scissorRect->left * g_aspectRatioScale + g_aspectRatioOffsetX;
scissorRect->top = scissorRect->top + g_aspectRatioOffsetY; scissorRect->top = scissorRect->top * g_aspectRatioScale + g_aspectRatioOffsetY;
scissorRect->right = scissorRect->right + g_aspectRatioOffsetX; scissorRect->right = scissorRect->right * g_aspectRatioScale + g_aspectRatioOffsetX;
scissorRect->bottom = scissorRect->bottom + g_aspectRatioOffsetY; scissorRect->bottom = scissorRect->bottom * g_aspectRatioScale + g_aspectRatioOffsetY;
__imp__sub_82E16C70(ctx, base); __imp__sub_82E16C70(ctx, base);
} }
@ -937,8 +937,6 @@ PPC_FUNC(sub_830D1EF0)
__imp__sub_830D1EF0(ctx, base); __imp__sub_830D1EF0(ctx, base);
if (!PPC_LOAD_U8(r3.u32 + PRIMITIVE_2D_PADDING_OFFSET))
{
struct Vertex struct Vertex
{ {
be<float> x; be<float> x;
@ -957,8 +955,18 @@ PPC_FUNC(sub_830D1EF0)
float x = vertex[i].x * 640.0f + 640.0f; float x = vertex[i].x * 640.0f + 640.0f;
float y = vertex[i].y * -360.0f + 360.0f; float y = vertex[i].y * -360.0f + 360.0f;
if (PPC_LOAD_U8(r3.u32 + PRIMITIVE_2D_PADDING_OFFSET))
{
// Stretch
x = ((x + 0.5f) / 1280.0f) * Video::s_viewportWidth;
y = ((y + 0.5f) / 720.0f) * Video::s_viewportHeight;
}
else
{
// Center
x = g_aspectRatioOffsetX + (x + 0.5f) * g_aspectRatioScale; x = g_aspectRatioOffsetX + (x + 0.5f) * g_aspectRatioScale;
y = g_aspectRatioOffsetY + (y + 0.5f) * g_aspectRatioScale; y = g_aspectRatioOffsetY + (y + 0.5f) * g_aspectRatioScale;
}
vertex[i].x = ((x - 0.5f) / Video::s_viewportWidth) * 2.0f - 1.0f; vertex[i].x = ((x - 0.5f) / Video::s_viewportWidth) * 2.0f - 1.0f;
vertex[i].y = ((y - 0.5f) / Video::s_viewportHeight) * -2.0f + 1.0f; vertex[i].y = ((y - 0.5f) / Video::s_viewportHeight) * -2.0f + 1.0f;
@ -1001,7 +1009,6 @@ PPC_FUNC(sub_830D1EF0)
vertex[3].y = -1.0f + halfPixelY; vertex[3].y = -1.0f + halfPixelY;
} }
} }
}
} }
// Objects are pushed forward by 1m, so the coordinates need to compensate for it. // Objects are pushed forward by 1m, so the coordinates need to compensate for it.
@ -1033,8 +1040,9 @@ static double ComputeObjGetItemX(uint32_t type)
x = 1058.0; x = 1058.0;
x *= g_aspectRatioScale; x *= g_aspectRatioScale;
x *= g_aspectRatioGameplayScale;
double scaleOffset = (1280.0 * (1.0 - g_aspectRatioScale)); double scaleOffset = (1280.0 * (1.0 - g_aspectRatioGameplayScale)) * g_aspectRatioScale;
if (Config::UIScaleMode == EUIScaleMode::Edge) if (Config::UIScaleMode == EUIScaleMode::Edge)
{ {
@ -1080,7 +1088,8 @@ static double ComputeObjGetItemY(uint32_t type)
y = 582.0; y = 582.0;
y *= g_aspectRatioScale; y *= g_aspectRatioScale;
y += g_aspectRatioOffsetY * 2.0 + 720.0 * (1.0 - g_aspectRatioScale); y *= g_aspectRatioGameplayScale;
y += g_aspectRatioOffsetY * 2.0 + 720.0 * (1.0 - g_aspectRatioGameplayScale) * g_aspectRatioScale;
return ((0.5 * Video::s_viewportHeight) - y) / (0.5 * Video::s_viewportHeight) * OBJ_GET_ITEM_TANGENT; return ((0.5 * Video::s_viewportHeight) - y) / (0.5 * Video::s_viewportHeight) * OBJ_GET_ITEM_TANGENT;
} }