From d0882a9b464ce415c5d850c9e61b0c8038439513 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:14:17 +0100 Subject: [PATCH 1/7] build: compile RenderStatusMenu_Overview and SomeFearFactorComputation with /GL RenderStatusMenu_Overview only matches when SomeFearFactorComputation is compiled with it under /GL: the original's caller knows the callee clobbers only ecx. Entries taken from draft #529. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- cmake/compiler-flags-gl.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 5430b694de..6de0f645bc 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -449,5 +449,7 @@ src/OpenSHC/Map/Units/UpdateHunter.cpp src/OpenSHC/Map/Units/UpdateAppleFarmer.cpp src/OpenSHC/Map/Units/UpdateJester.cpp src/OpenSHC/Map/Units/UpdateSlave.cpp +src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp +src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp src/OpenSHC/Map/Units/UpdateHealer.cpp src/OpenSHC/Map/Units/UpdateSpearman.cpp From 86ae99edaa947c5fd8a8dfcfa574552ddfed456a Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:14:18 +0100 Subject: [PATCH 2/7] reimplement: SHC_3BB0A8C1_0x0043E5A0 100% SomeFearFactorComputation Taken from draft #529. Measured on main 40cbb1cb7 with the three files of this PR in .local, both resolver sets enabled and the /GL entries: reccmp 100.0 / normalized 100.0. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../UI/Helpers/SomeFearFactorComputation.cpp | 40 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp diff --git a/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp new file mode 100644 index 0000000000..7cf0338192 --- /dev/null +++ b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp @@ -0,0 +1,40 @@ +#include "../Helpers.func.hpp" + +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x0043E5A0 + undefined4 Helpers::SomeFearFactorComputation() + { + // Picks a message number from the player's fear factor level (-5 .. 5). + int const fearFactor + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + if (fearFactor <= -5) { + return 14; + } + if (fearFactor <= -3) { + return 15; + } + if (fearFactor <= -1) { + return 16; + } + if (fearFactor >= 5) { + return 19; + } + if (fearFactor >= 3) { + return 18; + } + // 0 .. 2. The test is always true here, but it is what keeps MSVC from folding the + // 17/18 pair above into a setge (the original loads 18 before the jge). + if (fearFactor >= 0) { + return 17; + } + return 17; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 766545d302..34d0a86c78 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13589,7 +13589,7 @@ SHC_3BB0A8C1_0x0043E4E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0043E540 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0043E5A0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043E5A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0043E5F0 | 100.0% | Reimplemented From 5bbadec4eae775cc77b9c081efd0d016975ad70e Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:14:18 +0100 Subject: [PATCH 3/7] reimplement: SHC_3BB0A8C1_0x00447DC0 100% RenderStatusMenu_Overview Taken from draft #529. Measured on main 40cbb1cb7 with the three files of this PR in .local, both resolver sets enabled and the /GL entries: reccmp 100.0 / normalized 100.0. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../StatusMenus/RenderStatusMenu_Overview.cpp | 98 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp new file mode 100644 index 0000000000..1ce317df1e --- /dev/null +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp @@ -0,0 +1,98 @@ +#include "../StatusMenus.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/INT_00b96120.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00447DC0 + void StatusMenus::RenderStatusMenu_Overview() + { + INT_00b96120::instance = 0x47; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, DAT_TextureRenderCoreObject::ptr)( + 0, DAT_MenuHandlerState::instance.x + 0x12, DAT_MenuHandlerState::instance.y + 0x1c7); + int const nameY = DAT_MenuHandlerState::instance.y + 0x1cf; + int const nameX = DAT_MenuHandlerState::instance.x + 0x8d; + char* const name = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + name, nameX, nameY, OpenSHC::Text::TTA_CENTER, 0, 0x13, FALSE, 0); + // the description, "and" and the popularity text are centred as one line + int width = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, + (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel + != 0 + ? MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeFearFactorComputation)() + : MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeGoldRelatedComputation)())), + 0x13); + width = width + + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, 0x28), + 0x13); + int const widthPopularity = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomePopularityRelatedComputation)(); + width = width + 0xc + + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, widthPopularity), + 0x13); + int const x = DAT_MenuHandlerState::instance.x - width / 2 + 0x8d; + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel + != 0) { + int const descY = DAT_MenuHandlerState::instance.y + 0x242; + int const description = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeFearFactorComputation)(); + 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_PLAYER_DESC, description), + x, descY, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + } else { + int const descY = DAT_MenuHandlerState::instance.y + 0x242; + int const description = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeGoldRelatedComputation)(); + 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_PLAYER_DESC, description), + x, descY, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + } + // "and" + int const andY = DAT_MenuHandlerState::instance.y + 0x242; + 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_PLAYER_DESC, 0x28), + x + 6, andY, OpenSHC::Text::TTA_LEFT, 0, 0x13, TRUE, 0); + int const popY = DAT_MenuHandlerState::instance.y + 0x242; + int const popularity = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomePopularityRelatedComputation)(); + 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_PLAYER_DESC, popularity), + x + 0xc, popY, OpenSHC::Text::TTA_LEFT, 0, 0x13, TRUE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 34d0a86c78..f02c44c897 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16371,7 +16371,7 @@ SHC_3BB0A8C1_0x00447CF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00447D30 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00447DC0 | 0.0% | Pending +SHC_3BB0A8C1_0x00447DC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00447FA0 | 0.0% | Pending From 831514360488d3fd0497f9cd71c748591b0cafb8 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:14:18 +0100 Subject: [PATCH 4/7] reimplement: SHC_3BB0A8C1_0x004DB8B0 100% MenuView_HistoricMissionIntro_DoEveryFrame Taken from draft #529. Measured on main 40cbb1cb7 with the three files of this PR in .local, both resolver sets enabled and the /GL entries: reccmp 96.2 / normalized 96.0, the only differences being float constant names and _ftol2_sse, so counted as 100% per main's convention. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- ...View_HistoricMissionIntro_DoEveryFrame.cpp | 123 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp new file mode 100644 index 0000000000..42d819ceb0 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp @@ -0,0 +1,123 @@ +#include "../HistoricMissionIntro.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Credits.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/Audio/SFX/AmbientSFXType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_00eb0b20.hpp" +#include "OpenSHC/Globals/DAT_00eb9b28.hpp" +#include "OpenSHC/Globals/DAT_00eb9b2c.hpp" +#include "OpenSHC/Globals/DAT_00eb9b30.hpp" +#include "OpenSHC/Globals/DAT_00eb9b34.hpp" +#include "OpenSHC/Globals/DAT_00eb9b38.hpp" +#include "OpenSHC/Globals/DAT_00eb9b3c.hpp" +#include "OpenSHC/Globals/DAT_00eb9b40.hpp" +#include "OpenSHC/Globals/DAT_00ed2780.hpp" +#include "OpenSHC/Globals/DAT_ArrayOfStoredMenuStrings.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/FLOAT_00ec0834.hpp" +#include "OpenSHC/Globals/FLOAT_Between1And5.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + using Audio::MSS::enums::SHC_SoundStream; + using Audio::SFX::AmbientSFXType; + using UI::Enums::MenuViewType; + using WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004DB8B0 + void HistoricMissionIntro::MenuView_HistoricMissionIntro_DoEveryFrame() + { + BOOLEnum BVar1; + int iVar2; + BVar1 = MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, DAT_SoundSystemState::ptr)( + Audio::MSS::enums::SND_STR_SFX_1Unk); + if (!BVar1) { + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playAmbientSoundStreamUnk, DAT_SFXState::ptr)( + Audio::SFX::ASFXT_WIND_0); + } + if (DAT_MouseState::instance.leftClickStart) { + if (!DAT_00eb9b28::instance) { + DAT_00eb9b28::instance = 1; + } else if (!DAT_00ed2780::instance) { + FLOAT_00ec0834::instance = 0.0; + DAT_00ed2780::instance = 2; + } else if (DAT_00ed2780::instance == 1) { + FLOAT_00ec0834::instance = 31.0 - FLOAT_00ec0834::instance; + DAT_00ed2780::instance = 2; + } + } + iVar2 = MACRO_CALL(UI::Helpers_Func::TicksSinceCounterStart)(); + if (!iVar2) { + return; + } + MACRO_CALL(UI::Rendering_Func::RenderGfxHelperUnk)(0, 0, 0); + MACRO_CALL(UI::Rendering_Func::RenderHistoryBookEdgeUnk)(); + iVar2 = 0; + if (DAT_00ed2780::instance == 1) { + iVar2 = 0x1f - (long)((double)FLOAT_00ec0834::instance); + } else if (DAT_00ed2780::instance == 2) { + iVar2 = (long)((double)FLOAT_00ec0834::instance); + } else if (!DAT_00ed2780::instance) { + MACRO_CALL(UI::Rendering_Func::RenderGfxHelperUnk)(DAT_00eb0b20::instance, 0x24, 0x56); + } + if (DAT_00ed2780::instance) { + MACRO_CALL(UI::Rendering_Func::RenderMenuGfxHelper)(DAT_00eb0b20::instance, 0x24, 0x56, iVar2); + } + if (DAT_00ed2780::instance == 2) { + int const textY = DAT_00eb9b34::instance; + int const textX = DAT_00eb9b30::instance; + int const borderW = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth; + int const borderH = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + DAT_ArrayOfStoredMenuStrings::instance[DAT_00eb9b2c::instance], textX + borderW, textY + borderH, + DAT_00eb9b38::instance, DAT_00eb9b3c::instance, DAT_00eb9b40::instance, iVar2); + } else if (!DAT_00ed2780::instance) { + MACRO_CALL(UI::Credits_Func::RenderScrollingCreditsTextFrame)(30.0); + } + MACRO_CALL(UI::Rendering_Func::DrawLoadedMenuStringHelperWithBlending)( + 0, 0x15e, 0xaa, 400, 0, 0x11, FALSE, iVar2); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + DAT_ArrayOfStoredMenuStrings::instance[1], + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 0x15e, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 0xd2, 400, 0, 0x11, iVar2); + if ((DAT_00ed2780::instance) + && (FLOAT_00ec0834::instance = FLOAT_Between1And5::instance + FLOAT_00ec0834::instance, + FLOAT_00ec0834::instance >= 32.0f)) { + if (DAT_00ed2780::instance == 2) { + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); + FLOAT_00ec0834::instance = 31.0; + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + Audio::MSS::enums::SND_STR_SFX_1Unk); + return; + } + DAT_00ed2780::instance = 0; + int const missionIndex = DAT_GameCore::instance.missionNumber1to20 - 1; + if (missionIndex < 20) { + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::playSoundOnStream3Unk, DAT_SoundSystemState::ptr)( + DAT_MissionDefinedData::instance.HistoricMissionIntroSoundNames[missionIndex], 1); + } + } + return; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f02c44c897..8b2fe71a06 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36207,7 +36207,7 @@ SHC_3BB0A8C1_0x004DB600 | 100.0% | Reimplemented (counted: only float constant n SHC_3BB0A8C1_0x004DB7B0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004DB8B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004DB8B0 | 100.0% | Reimplemented (counted: only float constant names and _ftol2_sse differ) SHC_3BB0A8C1_0x004DBAF0 | 100.0% | Reimplemented From 7da446172b6cb4afe7709ab0829bd63f7460eae2 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:33:16 +0100 Subject: [PATCH 5/7] style: the three #529 functions per REIMPLEMENTATION_STYLE_GUIDE MenuView_HistoricMissionIntro_DoEveryFrame: - named locals (windPlaying, ticks, blendStrength) instead of BVar1/iVar2, declared at first use - early return instead of the comma operator in the fade condition, += for the fade step - decimal coordinates, 0.0f/30.0f/31.0f float literals, no redundant (double) casts, countof for the mission sound table - the 31.0 in the fade reversal stays a double with a comment: the original subtracts in double precision (fsubr qword) - dropped the trailing return and the unused usings RenderStatusMenu_Overview: - decimal coordinates, font size and text index, += for the width sum, comments for the three description parts - dropped the unused usings and the unused BGR24 include SomeFearFactorComputation: namespace closing comments. Re-measured on main 40cbb1cb7 with a full build and reccmp: unchanged, SomeFearFactorComputation and RenderStatusMenu_Overview at 100.0 / 100.0, HistoricMissionIntro at 96.2 / 96.0 with only float constant names and _ftol2_sse differing. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../UI/Helpers/SomeFearFactorComputation.cpp | 4 +- ...View_HistoricMissionIntro_DoEveryFrame.cpp | 58 +++++++++--------- .../StatusMenus/RenderStatusMenu_Overview.cpp | 60 +++++++++---------- 3 files changed, 57 insertions(+), 65 deletions(-) diff --git a/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp index 7cf0338192..1deb552e2a 100644 --- a/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp +++ b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp @@ -36,5 +36,5 @@ namespace UI { return 17; } -} -} +} // namespace UI +} // namespace OpenSHC diff --git a/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp index 42d819ceb0..1f3f1e5255 100644 --- a/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp +++ b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp @@ -36,19 +36,14 @@ namespace OpenSHC { namespace UI { namespace MenuViews { - using Audio::MSS::enums::SHC_SoundStream; - using Audio::SFX::AmbientSFXType; - using UI::Enums::MenuViewType; using WindowsHelper::Enums::BOOLEnum; // FUNCTION: STRONGHOLDCRUSADER 0x004DB8B0 void HistoricMissionIntro::MenuView_HistoricMissionIntro_DoEveryFrame() { - BOOLEnum BVar1; - int iVar2; - BVar1 = MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, DAT_SoundSystemState::ptr)( - Audio::MSS::enums::SND_STR_SFX_1Unk); - if (!BVar1) { + BOOLEnum const windPlaying = MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, + DAT_SoundSystemState::ptr)(Audio::MSS::enums::SND_STR_SFX_1Unk); + if (!windPlaying) { MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playAmbientSoundStreamUnk, DAT_SFXState::ptr)( Audio::SFX::ASFXT_WIND_0); } @@ -56,29 +51,30 @@ namespace UI { if (!DAT_00eb9b28::instance) { DAT_00eb9b28::instance = 1; } else if (!DAT_00ed2780::instance) { - FLOAT_00ec0834::instance = 0.0; + FLOAT_00ec0834::instance = 0.0f; DAT_00ed2780::instance = 2; } else if (DAT_00ed2780::instance == 1) { + // 31.0 stays a double: the original subtracts in double precision (fsubr qword) FLOAT_00ec0834::instance = 31.0 - FLOAT_00ec0834::instance; DAT_00ed2780::instance = 2; } } - iVar2 = MACRO_CALL(UI::Helpers_Func::TicksSinceCounterStart)(); - if (!iVar2) { + int const ticks = MACRO_CALL(UI::Helpers_Func::TicksSinceCounterStart)(); + if (!ticks) { return; } MACRO_CALL(UI::Rendering_Func::RenderGfxHelperUnk)(0, 0, 0); MACRO_CALL(UI::Rendering_Func::RenderHistoryBookEdgeUnk)(); - iVar2 = 0; + int blendStrength = 0; if (DAT_00ed2780::instance == 1) { - iVar2 = 0x1f - (long)((double)FLOAT_00ec0834::instance); + blendStrength = 31 - (long)FLOAT_00ec0834::instance; } else if (DAT_00ed2780::instance == 2) { - iVar2 = (long)((double)FLOAT_00ec0834::instance); + blendStrength = (long)FLOAT_00ec0834::instance; } else if (!DAT_00ed2780::instance) { - MACRO_CALL(UI::Rendering_Func::RenderGfxHelperUnk)(DAT_00eb0b20::instance, 0x24, 0x56); + MACRO_CALL(UI::Rendering_Func::RenderGfxHelperUnk)(DAT_00eb0b20::instance, 36, 86); } if (DAT_00ed2780::instance) { - MACRO_CALL(UI::Rendering_Func::RenderMenuGfxHelper)(DAT_00eb0b20::instance, 0x24, 0x56, iVar2); + MACRO_CALL(UI::Rendering_Func::RenderMenuGfxHelper)(DAT_00eb0b20::instance, 36, 86, blendStrength); } if (DAT_00ed2780::instance == 2) { int const textY = DAT_00eb9b34::instance; @@ -87,37 +83,37 @@ namespace UI { int const borderH = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( DAT_ArrayOfStoredMenuStrings::instance[DAT_00eb9b2c::instance], textX + borderW, textY + borderH, - DAT_00eb9b38::instance, DAT_00eb9b3c::instance, DAT_00eb9b40::instance, iVar2); + DAT_00eb9b38::instance, DAT_00eb9b3c::instance, DAT_00eb9b40::instance, blendStrength); } else if (!DAT_00ed2780::instance) { - MACRO_CALL(UI::Credits_Func::RenderScrollingCreditsTextFrame)(30.0); + MACRO_CALL(UI::Credits_Func::RenderScrollingCreditsTextFrame)(30.0f); } MACRO_CALL(UI::Rendering_Func::DrawLoadedMenuStringHelperWithBlending)( - 0, 0x15e, 0xaa, 400, 0, 0x11, FALSE, iVar2); + 0, 350, 170, 400, 0, 17, FALSE, blendStrength); MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( - DAT_ArrayOfStoredMenuStrings::instance[1], - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 0x15e, - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 0xd2, 400, 0, 0x11, iVar2); - if ((DAT_00ed2780::instance) - && (FLOAT_00ec0834::instance = FLOAT_Between1And5::instance + FLOAT_00ec0834::instance, - FLOAT_00ec0834::instance >= 32.0f)) { + DAT_ArrayOfStoredMenuStrings::instance[1], DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 210, 400, 0, 17, blendStrength); + if (!DAT_00ed2780::instance) { + return; + } + FLOAT_00ec0834::instance += FLOAT_Between1And5::instance; + if (FLOAT_00ec0834::instance >= 32.0f) { if (DAT_00ed2780::instance == 2) { MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); - FLOAT_00ec0834::instance = 31.0; + FLOAT_00ec0834::instance = 31.0f; MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( Audio::MSS::enums::SND_STR_SFX_1Unk); return; } DAT_00ed2780::instance = 0; int const missionIndex = DAT_GameCore::instance.missionNumber1to20 - 1; - if (missionIndex < 20) { + if (missionIndex < countof(DAT_MissionDefinedData::instance.HistoricMissionIntroSoundNames)) { MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::playSoundOnStream3Unk, DAT_SoundSystemState::ptr)( DAT_MissionDefinedData::instance.HistoricMissionIntroSoundNames[missionIndex], 1); } } - return; } - } -} -} + } // namespace MenuViews +} // namespace UI +} // namespace OpenSHC diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp index 1ce317df1e..4d800775df 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp @@ -5,7 +5,6 @@ #include "OpenSHC/UI/Helpers.func.hpp" #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/BGR24.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" @@ -21,27 +20,22 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x00447DC0 void StatusMenus::RenderStatusMenu_Overview() { - INT_00b96120::instance = 0x47; + INT_00b96120::instance = 71; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, DAT_TextureRenderCoreObject::ptr)( - 0, DAT_MenuHandlerState::instance.x + 0x12, DAT_MenuHandlerState::instance.y + 0x1c7); - int const nameY = DAT_MenuHandlerState::instance.y + 0x1cf; - int const nameX = DAT_MenuHandlerState::instance.x + 0x8d; + 0, DAT_MenuHandlerState::instance.x + 18, DAT_MenuHandlerState::instance.y + 455); + int const nameY = DAT_MenuHandlerState::instance.y + 463; + int const nameX = DAT_MenuHandlerState::instance.x + 141; char* const name = MACRO_CALL_MEMBER( OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - name, nameX, nameY, OpenSHC::Text::TTA_CENTER, 0, 0x13, FALSE, 0); + name, nameX, nameY, OpenSHC::Text::TTA_CENTER, 0, 19, FALSE, 0); // the description, "and" and the popularity text are centred as one line + // the fear factor or gold description of the player int width = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, @@ -50,49 +44,51 @@ namespace UI { != 0 ? MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeFearFactorComputation)() : MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeGoldRelatedComputation)())), - 0x13); - width = width - + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, 0x28), - 0x13); + 19); + // "and" + width += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, 40), + 19); int const widthPopularity = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomePopularityRelatedComputation)(); - width = width + 0xc + // the popularity description, after a 12 pixel gap + width += 12 + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, widthPopularity), - 0x13); - int const x = DAT_MenuHandlerState::instance.x - width / 2 + 0x8d; + 19); + int const x = DAT_MenuHandlerState::instance.x - width / 2 + 141; if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel != 0) { - int const descY = DAT_MenuHandlerState::instance.y + 0x242; + int const descY = DAT_MenuHandlerState::instance.y + 578; int const description = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeFearFactorComputation)(); 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_PLAYER_DESC, description), - x, descY, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + x, descY, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); } else { - int const descY = DAT_MenuHandlerState::instance.y + 0x242; + int const descY = DAT_MenuHandlerState::instance.y + 578; int const description = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeGoldRelatedComputation)(); 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_PLAYER_DESC, description), - x, descY, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + x, descY, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); } // "and" - int const andY = DAT_MenuHandlerState::instance.y + 0x242; + int const andY = DAT_MenuHandlerState::instance.y + 578; 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_PLAYER_DESC, 0x28), - x + 6, andY, OpenSHC::Text::TTA_LEFT, 0, 0x13, TRUE, 0); - int const popY = DAT_MenuHandlerState::instance.y + 0x242; + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC, 40), + x + 6, andY, OpenSHC::Text::TTA_LEFT, 0, 19, TRUE, 0); + int const popY = DAT_MenuHandlerState::instance.y + 578; int const popularity = MACRO_CALL(OpenSHC::UI::Helpers_Func::SomePopularityRelatedComputation)(); 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_PLAYER_DESC, popularity), - x + 0xc, popY, OpenSHC::Text::TTA_LEFT, 0, 0x13, TRUE, 0); + x + 12, popY, OpenSHC::Text::TTA_LEFT, 0, 19, TRUE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; } -} -} + +} // namespace UI +} // namespace OpenSHC From ce743ef29333946ef23a22928501081d2fabdd53 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 16:07:59 +0100 Subject: [PATCH 6/7] reimplement: SHC_3BB0A8C1_0x004DD100 96.3% MenuView_ScenarioDescription_Prepare, register allocation differs Taken from draft #529, with the style pass applied (imported string literals with their text as comments, the comma-operator condition written out as nested ifs, named locals for the event-condition clear, no unused usings or trailing return). memset was measured for the clear and costs the match (it is called, not inlined), so the pointer walk stays with a comment. Measured on main 592a17d94 with a full build and reccmp: 96.3 / 88.2. The only remaining differences are allocation ones: - the two stores after the rep stosd use the zero in esi instead of the eax that rep stosd leaves at zero; - the mov ecx, 0x1f40 count load sits before instead of after xor eax, eax; - one branch offset moves by 2 bytes because the esi stores encode longer. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../MenuView_ScenarioDescription_Prepare.cpp | 138 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp diff --git a/src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp b/src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp new file mode 100644 index 0000000000..d57c66683f --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp @@ -0,0 +1,138 @@ +#include "../ScenarioDescription.func.hpp" + +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Rendering.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/ScenarioEvents/InGameEventExtra.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00ed2794.hpp" +#include "OpenSHC/Globals/DAT_00ed2798.hpp" +#include "OpenSHC/Globals/DAT_ARRAY_00ed26d0.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MenuView_TriggerPrepare.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/INT_00eb0b24.hpp" +#include "OpenSHC/Globals/INT_00ed27bc.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + // FUNCTION: STRONGHOLDCRUSADER 0x004DD100 + void ScenarioDescription::MenuView_ScenarioDescription_Prepare() + { + DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; + DAT_TextureRenderCoreObject::instance.totalLoadedGfx = 0; + // "briefing_screen_background.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_screen_background_tgx_005ab5b4); + // "briefing_back0.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back0_tgx_005ab5a0); + // "briefing_back1.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back1_tgx_005ab58c); + // "briefing_back2.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back2_tgx_005ab578); + // "briefing_back3.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back3_tgx_005ab564); + // "briefing_back4.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back4_tgx_005ab550); + // "briefing_back5.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back5_tgx_005ab53c); + // "briefing_back6.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back6_tgx_005ab528); + // "briefing_back7.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back7_tgx_005ab514); + // "briefing_back8.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back8_tgx_005ab500); + // "briefing_back9.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back9_tgx_005ab4ec); + // "briefing_back10.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back10_tgx_005ab4d8); + // "briefing_back11.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back11_tgx_005ab4c4); + // "briefing_back12.tgx" + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::loadGfxFile, DAT_TextureRenderCoreObject::ptr)( + s_briefing_back12_tgx_005ab4b0); + if (DAT_MenuView_TriggerPrepare::instance != 2) { + if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION) { + DAT_00ed2798::instance = 0; + } else { + DAT_00ed2798::instance = 1; + if (DAT_GameCore::instance.gameMode_2 == Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_00ed2798::instance = 0; + } + } + } + if (DAT_MenuModalComposition2::instance.activeModalDialogID == UI::Enums::MMT_DISPLAY_AI_LORD_MESSAGE) { + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition2::ptr)( + UI::Enums::MMT_NONE, FALSE); + } + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL(Rendering_Func::TicksStartCounter)(); + if (DAT_GameCore::instance.missionNumber1to20 <= 0) { + DAT_GameCore::instance.missionNumber1to20 = 1; + } + if (!DAT_GameCore::instance.gameSuspended) { + if (DAT_GameCore::instance.gameMode_2 != Game::GM_BUILDERUnk) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMapSiegeHeaderForMissionIndex, + DAT_MapPropertiesState::ptr)((char*)DAT_GameCore::instance.missionNumber1to20); + } + // Clears every event's conditions with a pointer walk: memset is called here instead of + // inlined to the original's rep stosd, which costs the match. + int* condition = DAT_MapPropertiesState::instance.SEC_EventsExtra[0].conditionIsTrue; + for (int remaining = sizeof(DAT_MapPropertiesState::instance.SEC_EventsExtra) / sizeof(int); + remaining != 0; remaining--) { + *condition = 0; + condition++; + } + DAT_GameState::instance.mapAndTime.field43_0xf0 = 0; + DAT_GameState::instance.mapAndTime.field44_0xf4 = 0; + } + if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION + && !DAT_GameCore::instance.gameSuspended) { + if (DAT_GameCore::instance.missionNumber1to20 < 4) { + DAT_GameState::instance.mapAndTime.difficulty = 1; + } else { + DAT_GameState::instance.mapAndTime.difficulty = DAT_GameCore::instance.missionDifficulty; + } + } + DAT_MouseState::instance.waitCursorToggle = 0; + MACRO_CALL(UI::Helpers_Func::ResetEventStatusUnk)(); + INT_00eb0b24::instance = 0; + INT_00ed27c4::instance = 1; + DAT_ARRAY_00ed26d0::instance[0].y = 0; + INT_00ed27bc::instance = 0; + DAT_00ed2794::instance = 0; + if (DAT_MenuView_TriggerPrepare::instance != 2 && !DAT_GameCore::instance.gameSuspended) { + DAT_00ed2794::instance = timeGetTime(); + } + MACRO_CALL(UI::Helpers_Func::LoadTGX_shc_back)(); + } + + } // namespace MenuViews +} // namespace UI +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a2f56932f0..bd53f20bce 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36263,7 +36263,7 @@ SHC_3BB0A8C1_0x004DCC90 | 0.0% | Pending SHC_3BB0A8C1_0x004DD0C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004DD100 | 0.0% | Pending +SHC_3BB0A8C1_0x004DD100 | 96.3% | Register allocation differs SHC_3BB0A8C1_0x004DD300 | 100.0% | Reimplemented From 61bee571089a7669c7a64e91bd3234c2af537887 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 16:50:12 +0100 Subject: [PATCH 7/7] review: pre-review pass on the #529 functions - SomeFearFactorComputation, HistoricMissionIntro: the comments that only explained match-driven forms move to the PR thread. - HistoricMissionIntro: the wind-sound check and the tick count feed the ifs directly instead of going through one-use locals. - ScenarioDescription_Prepare: the event-condition clear is a countof loop over SEC_EventsExtra[event].conditionIsTrue instead of a pointer walk; MSVC still turns it into the original's rep stosd. - RenderStatusMenu_Overview: the two description comments are one. Re-measured on main 592a17d94 with a full build and reccmp, unchanged: 100.0 / 100.0 / 96.2 (counted) / 96.3 (register allocation differs). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../UI/Helpers/SomeFearFactorComputation.cpp | 2 -- .../MenuView_HistoricMissionIntro_DoEveryFrame.cpp | 9 +++------ .../MenuView_ScenarioDescription_Prepare.cpp | 13 ++++++------- .../UI/StatusMenus/RenderStatusMenu_Overview.cpp | 3 +-- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp index 1deb552e2a..d664dd0871 100644 --- a/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp +++ b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp @@ -28,8 +28,6 @@ namespace UI { if (fearFactor >= 3) { return 18; } - // 0 .. 2. The test is always true here, but it is what keeps MSVC from folding the - // 17/18 pair above into a setge (the original loads 18 before the jge). if (fearFactor >= 0) { return 17; } diff --git a/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp index 1f3f1e5255..e1e42e3c3c 100644 --- a/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp +++ b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp @@ -41,9 +41,8 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x004DB8B0 void HistoricMissionIntro::MenuView_HistoricMissionIntro_DoEveryFrame() { - BOOLEnum const windPlaying = MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, - DAT_SoundSystemState::ptr)(Audio::MSS::enums::SND_STR_SFX_1Unk); - if (!windPlaying) { + if (!MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, DAT_SoundSystemState::ptr)( + Audio::MSS::enums::SND_STR_SFX_1Unk)) { MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playAmbientSoundStreamUnk, DAT_SFXState::ptr)( Audio::SFX::ASFXT_WIND_0); } @@ -54,13 +53,11 @@ namespace UI { FLOAT_00ec0834::instance = 0.0f; DAT_00ed2780::instance = 2; } else if (DAT_00ed2780::instance == 1) { - // 31.0 stays a double: the original subtracts in double precision (fsubr qword) FLOAT_00ec0834::instance = 31.0 - FLOAT_00ec0834::instance; DAT_00ed2780::instance = 2; } } - int const ticks = MACRO_CALL(UI::Helpers_Func::TicksSinceCounterStart)(); - if (!ticks) { + if (!MACRO_CALL(UI::Helpers_Func::TicksSinceCounterStart)()) { return; } MACRO_CALL(UI::Rendering_Func::RenderGfxHelperUnk)(0, 0, 0); diff --git a/src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp b/src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp index d57c66683f..183830c12f 100644 --- a/src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp +++ b/src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp @@ -101,13 +101,12 @@ namespace UI { MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMapSiegeHeaderForMissionIndex, DAT_MapPropertiesState::ptr)((char*)DAT_GameCore::instance.missionNumber1to20); } - // Clears every event's conditions with a pointer walk: memset is called here instead of - // inlined to the original's rep stosd, which costs the match. - int* condition = DAT_MapPropertiesState::instance.SEC_EventsExtra[0].conditionIsTrue; - for (int remaining = sizeof(DAT_MapPropertiesState::instance.SEC_EventsExtra) / sizeof(int); - remaining != 0; remaining--) { - *condition = 0; - condition++; + for (int event = 0; event < countof(DAT_MapPropertiesState::instance.SEC_EventsExtra); event++) { + for (int condition = 0; + condition < countof(DAT_MapPropertiesState::instance.SEC_EventsExtra[event].conditionIsTrue); + condition++) { + DAT_MapPropertiesState::instance.SEC_EventsExtra[event].conditionIsTrue[condition] = 0; + } } DAT_GameState::instance.mapAndTime.field43_0xf0 = 0; DAT_GameState::instance.mapAndTime.field44_0xf4 = 0; diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp index 4d800775df..21755a5455 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp @@ -34,8 +34,7 @@ namespace UI { OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( name, nameX, nameY, OpenSHC::Text::TTA_CENTER, 0, 19, FALSE, 0); - // the description, "and" and the popularity text are centred as one line - // the fear factor or gold description of the player + // the fear factor or gold description, "and" and the popularity description are centred as one line int width = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PLAYER_DESC,