From 3fbaf5cb5829652a8863952ccf6d3ab6d1e8d096 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 12:40:14 +0100 Subject: [PATCH 1/6] reimplement: SHC_3BB0A8C1_0x00426750 100.0% Reimplemented Finished from gynt's draft on his fork (reimpl/UI-MenuItems, 84.8%), which no longer compiled on main: the GameCore field at 0x118 is isNameEntryActive there now. The original stores DAT_ButtonUnknownZero = 1 before it tests anything, returns on the hidden button (8, "OK", while a title is set, and 25, "Change Your Title, Lord?", while one is typed in; isNameEntryActive is 1 when a title is already set, so its name reads the other way round) and stores 0 otherwise, so the source does the same, without the decompiler's goto. Each path makes its own call and computes the text position itself: the compiler merges the two calls into the original's one (a ternary colour compiles branch-free instead: quick_diff 0.6966) and hoists the identical position above the branch the way the original does, which puts the first push 0 where the original has it. The position computed once above the `if` measured 97.7%, as it did in GameOptionsTextButton (0x004934F0); a comment says so. quick_diff 0.8478 (the renamed draft, 48 instructions against 44) -> 44/44 with only quick_diff's own artefacts left: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. `== TRUE` stays: the original tests for 1 and then for 0 (a truthiness test: 100.0% -> 85.4%), and every other reader of the field compares it with 1; a comment says so. DAT_ButtonUnknownZero takes TRUE and FALSE (a BOOLEnum on main). The parameter is button, as the menu's handler calls it. Co-Authored-By: Claude Opus 5.5 --- ...enderFunction_UnusedSetName_ButtonsUnk.cpp | 56 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedSetName_ButtonsUnk.cpp diff --git a/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedSetName_ButtonsUnk.cpp b/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedSetName_ButtonsUnk.cpp new file mode 100644 index 0000000000..42163bea97 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedSetName_ButtonsUnk.cpp @@ -0,0 +1,56 @@ +#include "../Unused.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00426750 + void Unused::MenuItemRenderFunction_UnusedSetName_ButtonsUnk(int button, ...) + { + DAT_ButtonUnknownZero::instance = TRUE; + // == TRUE: the original tests for 1 and then for 0 (a truthiness test: 100.0% -> 85.4%) + // "OK" is hidden while a title is set, "Change Your Title, Lord?" while one is typed in + if ((DAT_GameCore::instance.isNameEntryActive == TRUE && button == 8) + || (!DAT_GameCore::instance.isNameEntryActive && button == 25)) { + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // one call and position per path, which MSVC merges (position above the if: 100.0% -> 97.7%) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + return; + } + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e90b860d04..960c080943 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6773,7 +6773,7 @@ SHC_3BB0A8C1_0x004266A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004266E0 | 0.0% | Pending -SHC_3BB0A8C1_0x00426750 | 0.0% | Pending +SHC_3BB0A8C1_0x00426750 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004267F0 | 100.0% | Reimplemented From e3adbdd776a483bdcf1c015ed656be89f5f22967 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 12:40:15 +0100 Subject: [PATCH 2/6] reimplement: SHC_3BB0A8C1_0x004BB570 100.0% Reimplemented Rewritten from gynt's draft (98.4%, the same code). The draft read SEC_MercRecruitable[troopIndex - 7], a negative index; the address is barracksRecruitability.array.barracksRecruitability[troopIndex], as the handler for the same screen reads it. Early returns, `troopIndex >= 0 && troopIndex <= 7` instead of the unsigned cast, COL_CCFAFF, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 98.4%; a comment says so. Moved here from the draft #327 (reimpl/UI-MenuItems-3-development, 8f88cf174). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is troopIndex, as the handler for the same screen calls it. A comment says index 2 is the spearmen, whose button is drawn 8 pixels further left. The flag is tested for truthiness (it is only ever 0 or 1; the same code). Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_DisableEuroTroops_Main.cpp | 76 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp new file mode 100644 index 0000000000..d43c1eb7ac --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp @@ -0,0 +1,76 @@ +#include "../DisableEuroTroops.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BB570 + void DisableEuroTroops::MenuItemRenderFunction_DisableEuroTroops_Main(int troopIndex, ...) + { + if (troopIndex >= 0 && troopIndex <= 7) { + // the spearmen's button is drawn 8 pixels further left + if (troopIndex == 2) { + DAT_ButtonX::instance -= 8; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + if (DAT_MapPropertiesState::instance.barracksRecruitability.array.barracksRecruitability[troopIndex]) { + return; + } + if (troopIndex == 2) { + DAT_ButtonX::instance += 8; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45, + DAT_ButtonX::instance + 9, DAT_ButtonY::instance + 3, 12); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (troopIndex != -3) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the position in each path, which MSVC hoists the way the original does (above the if: 100.0% -> 98.4%) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + // "Exit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + return; + } + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + // "Exit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 960c080943..45164ac632 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29289,7 +29289,7 @@ SHC_3BB0A8C1_0x004BB530 | 0.0% | Pending SHC_3BB0A8C1_0x004BB540 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BB570 | 0.0% | Pending +SHC_3BB0A8C1_0x004BB570 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BB650 | 100.0% | Reimplemented From d085da4078f24a4bf42280ce88117b3601fad0a3 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 12:40:15 +0100 Subject: [PATCH 3/6] reimplement: SHC_3BB0A8C1_0x004BB680 100.0% Reimplemented Rewritten from gynt's draft (98.2%, the same code), the same way as the euro troops render: early returns, both bounds spelled out, COL_CCFAFF, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 98.2%; a comment says so. Moved here from the draft #327 (reimpl/UI-MenuItems-3-development, 45815854a). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is troopIndex, as the handler for the same screen calls it. The flag is tested for truthiness (it is only ever 0 or 1; the same code). Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_DisableArabTroops_Main.cpp | 69 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp new file mode 100644 index 0000000000..40393c06e1 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp @@ -0,0 +1,69 @@ +#include "../DisableArabTroops.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BB680 + void DisableArabTroops::MenuItemRenderFunction_DisableArabTroops_Main(int troopIndex, ...) + { + if (troopIndex >= 0 && troopIndex <= 7) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + if (DAT_MapPropertiesState::instance.SEC_MercRecruitable[troopIndex]) { + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45, + DAT_ButtonX::instance + 9, DAT_ButtonY::instance + 3, 12); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (troopIndex != -3) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the position in each path, which MSVC hoists the way the original does (above the if: 100.0% -> 98.2%) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + // "Exit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + return; + } + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + // "Exit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 45164ac632..74b3a93a27 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29293,7 +29293,7 @@ SHC_3BB0A8C1_0x004BB570 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BB650 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BB680 | 0.0% | Pending +SHC_3BB0A8C1_0x004BB680 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BB740 | 0.0% | Pending From be14b4eaa0ea176ac505208fbbc783a86d17d101 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 12:40:15 +0100 Subject: [PATCH 4/6] reimplement: SHC_3BB0A8C1_0x004BD0F0 100.0% Reimplemented Rewritten from gynt's draft (97.9%, the same code): early returns, the button texts from cr.tex ("Continue", "Exit", "Skip"), no casts (the counters it compares, DAT_00df5558 and DAT_00df555c, are ints on main), COL_CCFAFF. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 97.9%; a comment says so. Moved here from the draft #327 (reimpl/UI-MenuItems-3-development, 36d0a96ca). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is button, as the handler for the same box calls it. `>> 1` stays: the original halves without the sign fix-up (`/ 2`: 100.0% -> 93.9%), as its comment says. DAT_00df5560 is tested for truthiness, as main's handler for the same box does. Co-Authored-By: Claude Opus 5.5 --- ...enuItemRenderFunction_TutorialBox_Main.cpp | 71 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp new file mode 100644 index 0000000000..ca14132072 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp @@ -0,0 +1,71 @@ +#include "../TutorialBox.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_00df5540.hpp" +#include "OpenSHC/Globals/DAT_00df5558.hpp" +#include "OpenSHC/Globals/DAT_00df555c.hpp" +#include "OpenSHC/Globals/DAT_00df5560.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BD0F0 + void TutorialBox::MenuItemRenderFunction_TutorialBox_Main(int button, ...) + { + // "Continue" + int buttonText = 1; + if (DAT_00df5540::instance != 0) { + return; + } + if (button == 2) { + // "Exit" + buttonText = 2; + } else { + if (!DAT_00df5560::instance) { + return; + } + if (DAT_00df5558::instance < DAT_00df555c::instance - 1 + && DAT_SoundSystemState::instance.waveOutOpenUnk_0x8 + && DAT_SoundSystemState::instance.soundActiveUnk_0x0) { + // "Skip" + buttonText = 5; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the position in each path, which MSVC hoists the way the original does (above the if: 100.0% -> 97.9%) + if (DAT_ButtonCurrentlyInteracting::instance) { + // >> 1: the original halves without the sign fix-up (/ 2: 100.0% -> 93.9%) + int const textX = (DAT_ButtonW::instance >> 1) + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 8; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL_BUTTONS, buttonText), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + int const textX = (DAT_ButtonW::instance >> 1) + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 8; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL_BUTTONS, buttonText), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 74b3a93a27..ae5d972448 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30173,7 +30173,7 @@ SHC_3BB0A8C1_0x004BCBA0 | 0.0% | Pending SHC_3BB0A8C1_0x004BCEC0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BD0F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BD0F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BD1B0 | 100.0% | Reimplemented From 6da73bd07bdddd5cfdc5e8e5e3d6e37d4facc471 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 11:08:38 +0100 Subject: [PATCH 5/6] reimplement: SHC_3BB0A8C1_0x00491C50 100.0% Reimplemented Rewritten from gynt's draft (97.7%, the same code): no TextAlignment local, an early return, COL_CCFAFF, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 97.7%; a comment says so. Moved here from the draft #327 (reimpl/UI-MenuItems-3-development, 8d25a1fa5). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is textIndex: it is only the text's index. Co-Authored-By: Claude Opus 5.5 --- ...rFunction_EnterTitleOnGameStart_Button.cpp | 46 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp diff --git a/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp b/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp new file mode 100644 index 0000000000..45c16d990e --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp @@ -0,0 +1,46 @@ +#include "../EnterTitleOnGameStart.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00491C50 + void EnterTitleOnGameStart::MenuItemRenderFunction_EnterTitleOnGameStart_Button(int textIndex, ...) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the position in each path, which MSVC hoists the way the original does (above the if: 100.0% -> 97.7%) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + return; + } + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ae5d972448..822ebd2ead 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23425,7 +23425,7 @@ SHC_3BB0A8C1_0x00491BF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00491C20 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00491C50 | 0.0% | Pending +SHC_3BB0A8C1_0x00491C50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00491CE0 | 0.0% | Pending From a66bc01fe1f6e2d938f2cbdcdef402526509d625 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 12:40:16 +0100 Subject: [PATCH 6/6] reimplement: SHC_3BB0A8C1_0x004AC440 100.0% Reimplemented Rewritten from gynt's draft (97.3%, the same code): early returns, COL_CCFAFF, decimal numbers, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 97.3%; a comment says so. Moved here from the draft #327 (reimpl/UI-MenuItems-3-development, 197b9d49c). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is buttonID: the button's ID, which is also its text's index. A comment says what 68 is: "Send", hidden while a map is being transferred. Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_SendReceiveMap_Main.cpp | 51 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp b/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp new file mode 100644 index 0000000000..853a821d75 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp @@ -0,0 +1,51 @@ +#include "../SendReceiveMap.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AC440 + void SendReceiveMap::MenuItemRenderFunction_SendReceiveMap_Main(int buttonID, ...) + { + // "Send" is hidden while a map is being transferred + if (DAT_GameSynchronyState::instance.DAT_MapFileReceivingState != 0 && buttonID == 68) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the position in each path, which MSVC hoists the way the original does (above the if: 100.0% -> 97.3%) + if (DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, buttonID), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, buttonID), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 822ebd2ead..e99388bbb4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25785,7 +25785,7 @@ SHC_3BB0A8C1_0x004AC280 | 0.0% | Pending SHC_3BB0A8C1_0x004AC310 | 0.0% | Pending -SHC_3BB0A8C1_0x004AC440 | 0.0% | Pending +SHC_3BB0A8C1_0x004AC440 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AC4C0 | 0.0% | Pending