From ebf1965fabad64fe62f9df0ac80ba8a3d291e0a8 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:34:56 +0300 Subject: [PATCH] Snap to pixel on the CPU. --- UnleashedRecomp/patches/csd_patches.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/UnleashedRecomp/patches/csd_patches.cpp b/UnleashedRecomp/patches/csd_patches.cpp index f0503bb9..9d4c9a96 100644 --- a/UnleashedRecomp/patches/csd_patches.cpp +++ b/UnleashedRecomp/patches/csd_patches.cpp @@ -585,25 +585,31 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str { auto position = reinterpret_cast*>(stack + i * stride); + float x = position[0]; + float y = position[1]; + if (aspectRatio >= ORIGINAL_ASPECT_RATIO) { - if ((flags & EXTEND_LEFT) != 0 && (position[0] <= centerX)) + if ((flags & EXTEND_LEFT) != 0 && (x <= centerX)) { - position[0] = 0.0f; + x = 0.0f; } - else if ((flags & EXTEND_RIGHT) != 0 && (position[0] >= centerX)) + else if ((flags & EXTEND_RIGHT) != 0 && (x >= centerX)) { - position[0] = 1280.0f; + x = 1280.0f; } else { - position[0] = (position[0] - pivotX) * scaleX + offsetX; + x = (x - pivotX) * scaleX + offsetX; } } else { - position[1] = (position[1] - pivotY) * scaleY + offsetY; + y = (y - pivotY) * scaleY + offsetY; } + + position[0] = round(x / 1280.0f * GameWindow::s_width) / GameWindow::s_width * 1280.0f; + position[1] = round(y / 720.0f * GameWindow::s_height) / GameWindow::s_height * 720.0f; } ctx.r4.u32 = ctx.r1.u32;