From 3ea73978bea4bcd7eae6690cbf1064e1caca30ef Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Fri, 3 Jan 2025 16:18:24 +0300 Subject: [PATCH] Add extend flag, fix cast lookups. --- UnleashedRecomp/patches/video_patches.cpp | 63 +++++++++++++++++------ 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/UnleashedRecomp/patches/video_patches.cpp b/UnleashedRecomp/patches/video_patches.cpp index e88c5e5e..439b1fb2 100644 --- a/UnleashedRecomp/patches/video_patches.cpp +++ b/UnleashedRecomp/patches/video_patches.cpp @@ -84,7 +84,7 @@ namespace Chao::CSD struct CastNode { be CastCount; - xpointer pCasts; + xpointer> pCasts; be RootCastIndex; xpointer pCastLinks; }; @@ -166,7 +166,7 @@ static void TraverseCast(Chao::CSD::Scene* scene, uint32_t castNodeIndex, Chao:: } } - EmplacePath(&castNode->pCasts[castIndex], path); + EmplacePath(castNode->pCasts[castIndex].get(), path); if (castNode->RootCastIndex == castIndex) EmplacePath(castNode, path); @@ -232,6 +232,8 @@ enum STRETCH_VERTICAL = 1 << 5, STRETCH = STRETCH_HORIZONTAL | STRETCH_VERTICAL, + + EXTEND_LEFT = 1 << 6, }; static const ankerl::unordered_dense::map g_flags = @@ -249,6 +251,18 @@ static const ankerl::unordered_dense::map g_flags = { HashStr("ui_playscreen/add/u_info"), ALIGN_BOTTOM_RIGHT }, { HashStr("ui_playscreen/add/medal_get_s"), ALIGN_BOTTOM_RIGHT }, { HashStr("ui_playscreen/add/medal_get_m"), ALIGN_BOTTOM_RIGHT }, + + // ui_pause + { HashStr("ui_pause/header/status_title/title_bg/center"), EXTEND_LEFT }, + { HashStr("ui_pause/header/status_title/title_bg/center/h_light"), EXTEND_LEFT }, + + // ui_status + { HashStr("ui_status/header/status_title/title_bg/center"), EXTEND_LEFT }, + { HashStr("ui_status/header/status_title/title_bg/center/h_light"), EXTEND_LEFT }, + { HashStr("ui_status/main/tag/bg/tag_bg_1/total_1_bg/center"), EXTEND_LEFT }, + { HashStr("ui_status/main/tag/bg/tag_bg_1/total_1_bg/center/h_light"), EXTEND_LEFT }, + { HashStr("ui_status/main/tag/bg/tag_bg_1/total_1_bg/center/left"), STRETCH }, + { HashStr("ui_status/main/tag/bg/tag_bg_1/total_1_bg/center/left/h_light"), STRETCH }, }; static std::optional FindFlags(uint32_t data) @@ -294,6 +308,23 @@ void RenderCsdCastMidAsmHook(PPCRegister& r4) static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t stride) { + float minX = 1280.0f; + float minY = 720.0f; + float maxX = 0.0f; + float maxY = 0.0f; + + for (size_t i = 0; i < ctx.r5.u32; i++) + { + auto position = reinterpret_cast*>(base + ctx.r4.u32 + i * stride); + minX = std::min(position[0], minX); + minY = std::min(position[1], minY); + maxX = std::max(position[0], maxX); + maxY = std::max(position[1], maxY); + } + + float centerX = (minX + maxX) / 2.0f; + float centerY = (minY + maxY) / 2.0f; + uint32_t flags = 0; if (g_castFlags.has_value()) @@ -310,20 +341,6 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str } else { - float minX = 1280.0f; - float minY = 720.0f; - float maxX = 0.0f; - float maxY = 0.0f; - - for (size_t i = 0; i < ctx.r5.u32; i++) - { - auto position = reinterpret_cast*>(base + ctx.r4.u32 + i * stride); - minX = std::min(position[0], minX); - minY = std::min(position[1], minY); - maxX = std::max(position[0], maxX); - maxY = std::max(position[1], maxY); - } - if (minX < 0.001f && maxX > 1279.999f) flags |= STRETCH_HORIZONTAL; @@ -376,9 +393,21 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str auto position = reinterpret_cast*>(stack + i * stride); if (aspectRatio > ORIGINAL_ASPECT_RATIO) - position[0] = position[0] * scaleX + offsetX; + { + if ((flags & EXTEND_LEFT) != 0 && (position[0] <= 0.0f) && (position[0] <= centerX)) + { + position[0] = 0.0f; + } + else + { + position[0] = position[0] * scaleX + offsetX; + } + + } else + { position[1] = position[1] * scaleY + offsetY; + } } ctx.r4.u32 = ctx.r1.u32;