From 7289c460fb3d36e64d3c38e3b9b5b43e23763e29 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 19 Nov 2026 21:50:15 +0100 Subject: [PATCH 1/2] reimplement: SHC_3BB0A8C1_0x004DAFB0 100.0% Reimplemented Rendering::RenderTextPageProgressBar, from gynt's draft (4778264429, 45.28%) by way of my draft in the open draft PR (fb337c1028, 67.80%, "Loop registers and RECT spills differ"). reccmp 100.0 (normalized 100.0) on main 3458fea34 with the data on. Three changes took it from 67.8 to 100: - The fade loops read destinationRect.left and destinationRect.top instead of separate left/top locals. The original keeps destinationRect.top in the RECT's own stack slot and reloads it for the second loop (`mov ebx, [esp + 0x14]`), with left in esi and the right edge in ebp for both loops; the locals put top in ebp and recomputed the right edge. - The second loop's row is a local, `y = destinationRect.top + 220 - i * 2`, passed as y and y + 1. Written out twice, `... + 1` became a second induction variable; the original has one (`lea edx, [ebx + 1]`). - sourceRect is filled left, right, top, bottom, which gives the original's zero register for `left` (ecx) and edi for 540. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../Rendering/RenderTextPageProgressBar.cpp | 51 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp b/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp new file mode 100644 index 0000000000..5da0348dc0 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp @@ -0,0 +1,51 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/Globals/DAT_00ed2784.hpp" +#include "OpenSHC/Globals/DAT_ARRAY_00ed26d0.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x004DAFB0 + void Rendering::RenderTextPageProgressBar() + { + DWORD elapsed = timeGetTime() - DAT_ARRAY_00ed26d0::instance[0].x; + if (elapsed > 1000000) { + elapsed = 0; + } + DAT_00ed2784::instance = elapsed / 80; + if (DAT_00ed2784::instance > 580) { + DAT_00ed2784::instance = 580; + } + RECT sourceRect; + sourceRect.left = 0; + sourceRect.right = 540; + sourceRect.top = DAT_00ed2784::instance; + sourceRect.bottom = DAT_00ed2784::instance + 220; + RECT destinationRect; + destinationRect.left = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 20; + destinationRect.top = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 20; + destinationRect.right = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 560; + destinationRect.bottom = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 240; + MACRO_CALL_MEMBER(UI::Rendering::WindowAndDirectDraw_Func::bltMapGameSurfaceToScreenMenuSurface, + DAT_WindowAndDirectDraw::ptr)(sourceRect, destinationRect); + // fade the top and bottom edges of the page + for (int i = 0; i < 30; ++i) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + destinationRect.left, destinationRect.top + i * 2, destinationRect.left + 539, + destinationRect.top + i * 2 + 1, i + 2); + } + for (int i = 0; i < 30; ++i) { + int const y = destinationRect.top + 220 - i * 2; + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + destinationRect.left, y, destinationRect.left + 539, y + 1, i + 2); + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..618237eaab 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36185,7 +36185,7 @@ SHC_3BB0A8C1_0x004DAE90 | 0.0% | Pending SHC_3BB0A8C1_0x004DAF50 | 100.0% | Reimplemented, only the loop's end address resolves to the next symbol -SHC_3BB0A8C1_0x004DAFB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004DAFB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DB0D0 | 100.0% | Reimplemented From 9d405f21c2987b56bcb51c12ebd04da6b4cec57c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 19 Nov 2026 21:56:47 +0100 Subject: [PATCH 2/2] reimplement: SHC_3BB0A8C1_0x004B1AC0 100.0% Reimplemented Roundtable::MenuModalRenderFunction_Roundtable, from gynt's drafts (dd3b7dc011, 32.54%; his newest scored draft f5c054926, 70.24% on his reimpl/UI-MenuModals-development, "y kept in reg by orig") by way of my draft in the open draft PR (8f2719d986, 76.1%, built on f5c054926). reccmp 100.0 (normalized 100.0) on main 3458fea34 with the data on. Behaviour fix against my draft and f5c054926: each shield's x is the seat's x plus the x parameter. Both added the group counter there (mine as `group`, f5c054926 as the reused `width` parameter), which draws the shields at the wrong place; the original reads x from its stack home for that argument (`add ecx, dword ptr [esp + 0x58]` with one push pending). gynt's first draft, dd3b7dc011, has x, and so does the Roundtable from Wilps' work on gynt's fork (8ca78619c on reimpl/Wilps-2026-10-18, later the same day as f5c054926), which is at 0.0% Pending there. From f5c054926: the seat table as constants, the two blend calls and the button rectangle. f5c054926 kept the counter in the width parameter; here it is its own local, which MSVC places in y's home as the original does. With x back the register assignment matched at once. The rest is order: tint and group are declared before the seat table (the original clears group in the middle of the table's stores), and DAT_ButtonY is set after DAT_ButtonX. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuModalRenderFunction_Roundtable.cpp | 82 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuModals/Roundtable/MenuModalRenderFunction_Roundtable.cpp diff --git a/src/OpenSHC/UI/MenuModals/Roundtable/MenuModalRenderFunction_Roundtable.cpp b/src/OpenSHC/UI/MenuModals/Roundtable/MenuModalRenderFunction_Roundtable.cpp new file mode 100644 index 0000000000..4872d04fa0 --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/Roundtable/MenuModalRenderFunction_Roundtable.cpp @@ -0,0 +1,82 @@ +#include "../Roundtable.func.hpp" + +#include "OpenSHC/UI/BottomLeftTextDisplayState.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_00df4288.hpp" +#include "OpenSHC/Globals/DAT_BottomLeftTextDisplayState.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B1AC0 + void Roundtable::MenuModalRenderFunction_Roundtable(int x, int y, int width, int height) + { + if (DAT_MouseState::instance.rightClickStart) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, + DAT_TextureRenderCoreObject::ptr)(2, x + 8, y + 8); + // Players sit in their groups' order; each new group switches between the plain and the tinted shields + int tint = 1; + int group = 0; + // Each seat's shield position at the table, clockwise from the top left + int seatPositions[8][2] = { + { 12, 12 }, + { 216, 12 }, + { 398, 12 }, + { 397, 103 }, + { 398, 193 }, + { 216, 192 }, + { 12, 193 }, + { 12, 103 }, + }; + for (int seat = 1; seat < countof(DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray); ++seat) { + int const player = DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[seat]; + if (player < 1 || DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[player] < 1) { + break; + } + if (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[player] > group) { + ++group; + ++tint; + if (tint > 1) { + tint = 0; + } + } + if (tint == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGfxTgxWithBlending, + DAT_TextureRenderCoreObject::ptr)( + seat + 2, seatPositions[seat - 1][0] + x, seatPositions[seat - 1][1] + y, 16); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGfxTgxWithBlending, + DAT_TextureRenderCoreObject::ptr)( + seat + 2 + tint * 8, seatPositions[seat - 1][0] + x, seatPositions[seat - 1][1] + y, 20); + } + } + DAT_ButtonX::instance = x + 24; + DAT_ButtonY::instance = y + 380; + DAT_ButtonW::instance = 380; + DAT_ButtonH::instance = 40; + if (DAT_00df4288::instance != 0) { + MACRO_CALL_MEMBER( + OpenSHC::UI::BottomLeftTextDisplayState_Func::renderCurrentlyDisplayedTextConstructionCost, + DAT_BottomLeftTextDisplayState::ptr)(0); + DAT_00df4288::instance = 0; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 618237eaab..fd9a3880a7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25989,7 +25989,7 @@ SHC_3BB0A8C1_0x004B1990 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B19E0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B1AC0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B1AC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B1C30 | 100.0% | Reimplemented