From ff29b3e7863597bc0db2f94e1baf2af5dfd936b3 Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Tue, 28 Jan 2025 01:45:04 +0300 Subject: [PATCH] Repeat world map info grid on center UI scale mode. (#222) --- .../patches/aspect_ratio_patches.cpp | 62 +++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/UnleashedRecomp/patches/aspect_ratio_patches.cpp b/UnleashedRecomp/patches/aspect_ratio_patches.cpp index db3c7d2..7c381a7 100644 --- a/UnleashedRecomp/patches/aspect_ratio_patches.cpp +++ b/UnleashedRecomp/patches/aspect_ratio_patches.cpp @@ -335,6 +335,8 @@ enum OFFSET_SCALE_LEFT = 1 << 13, OFFSET_SCALE_RIGHT = 1 << 14, + + REPEAT_LEFT = 1 << 15 }; struct CsdModifier @@ -637,6 +639,22 @@ static const ankerl::unordered_dense::map g_modifiers { HashStr("ui_worldmap/contents/choices/cts_choices_bg"), { STRETCH } }, { HashStr("ui_worldmap/contents/info/bg/cts_info_bg"), { ALIGN_TOP_LEFT | WORLD_MAP } }, { HashStr("ui_worldmap/contents/info/bg/info_bg_1"), { ALIGN_TOP_LEFT | WORLD_MAP } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_01/row_01/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_01/row_02/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_01/row_03/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_01/row_04/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_02/row_01/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_02/row_02/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_02/row_03/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_02/row_04/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_03/row_01/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_03/row_02/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_03/row_03/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_03/row_04/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_04/row_01/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_04/row_02/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_04/row_03/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, + { HashStr("ui_worldmap/contents/info/bg/info_bg_1/position_04/row_04/img_12"), { ALIGN_TOP_LEFT | WORLD_MAP | REPEAT_LEFT } }, { HashStr("ui_worldmap/contents/info/img/info_img_1"), { ALIGN_TOP_LEFT | WORLD_MAP } }, { HashStr("ui_worldmap/contents/info/img/info_img_2"), { ALIGN_TOP_LEFT | WORLD_MAP } }, { HashStr("ui_worldmap/contents/info/img/info_img_3"), { ALIGN_TOP_LEFT | WORLD_MAP } }, @@ -803,6 +821,11 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str uint8_t* stack = base + ctx.r1.u32; memcpy(stack, base + ctx.r4.u32, size); + auto getPosition = [&](size_t index) + { + return reinterpret_cast*>(stack + index * stride); + }; + float offsetX = 0.0f; float offsetY = 0.0f; float pivotX = 0.0f; @@ -880,7 +903,7 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str offsetScaleModifier = g_castModifier.value(); uint32_t vertexIndex = ((offsetScaleModifier.flags & STORE_LEFT_CORNER) != 0) ? 0 : 3; - corner = *reinterpret_cast*>(base + ctx.r4.u32 + vertexIndex * stride); + corner = *getPosition(vertexIndex); } if (offsetScaleModifier.cornerMax == 0.0f && g_castNodeModifier.has_value()) @@ -908,7 +931,7 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str for (size_t i = 0; i < ctx.r5.u32; i++) { - auto position = reinterpret_cast*>(stack + i * stride); + auto position = getPosition(i); float x = offsetX + (position[0] - pivotX) * scaleX; float y = offsetY + (position[1] - pivotY) * scaleY; @@ -926,9 +949,38 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str position[1] = round(y); } - ctx.r4.u32 = ctx.r1.u32; - original(ctx, base); - ctx.r1.u32 += size; + if ((modifier.flags & REPEAT_LEFT) != 0) + { + float width = *getPosition(2) - *getPosition(0); + + auto r3 = ctx.r3; + auto r5 = ctx.r5; + auto r6 = ctx.r6; + auto r7 = ctx.r7; + auto r8 = ctx.r8; + + while (*getPosition(2) > 0.0f) + { + ctx.r3 = r3; + ctx.r4 = ctx.r1; + ctx.r5 = r5; + ctx.r6 = r6; + ctx.r7 = r7; + ctx.r8 = r8; + original(ctx, base); + + for (size_t i = 0; i < ctx.r5.u32; i++) + *getPosition(i) = *getPosition(i) - width; + } + + ctx.r1.u32 += size; + } + else + { + ctx.r4.u32 = ctx.r1.u32; + original(ctx, base); + ctx.r1.u32 += size; + } } // SWA::CCsdPlatformMirage::Draw