From d08b3380919136c4f245e12063e374bff9b51052 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 00:18:38 +0100 Subject: [PATCH 01/13] reimplement: SHC_3BB0A8C1_0x004DBE30 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuViews-development (97.9% there), after a style pass; the statements are his. What changed: the four picture names "c1pic.tgx" to "c4pic.tgx" are s_ pointers, with each name's comment above its statement; (int)(historicCampaignNumber * 6 + -2) and + -1 are written * 6 - 2 and - 1; the unused using of eTextSections goes; two comments say what the switch and the two texts are (cr.tex group 179 has six texts per campaign, and the last two are "Aftermath" and the closing text). quick_diff 0.9762, which leaves only the original's jump-table spelling and ret / ret 0. The strings are the s_ pointers from string-literals.hpp, with their text above them (SG 19), as in main's sibling PrepareHistoryBook (the original pushes each address; the S_ macros are for inline copies); the pointer swap measures the same as the S_ macros did. This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized in reccmp in a clean alone build of the branch on main da1fef58e. Co-Authored-By: Claude Opus 5.5 --- ...MenuView_HistoricCampaignOutro_Prepare.cpp | 65 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/HistoricCampaignOutro/MenuView_HistoricCampaignOutro_Prepare.cpp diff --git a/src/OpenSHC/UI/MenuViews/HistoricCampaignOutro/MenuView_HistoricCampaignOutro_Prepare.cpp b/src/OpenSHC/UI/MenuViews/HistoricCampaignOutro/MenuView_HistoricCampaignOutro_Prepare.cpp new file mode 100644 index 0000000000..02722830d5 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/HistoricCampaignOutro/MenuView_HistoricCampaignOutro_Prepare.cpp @@ -0,0 +1,65 @@ +#include "../HistoricCampaignOutro.func.hpp" + +#include "OpenSHC/Rendering.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00eb0b20.hpp" +#include "OpenSHC/Globals/DAT_00ed2780.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_NumberOfStoredMenuStrings.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/FLOAT_00ec0834.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + // FUNCTION: STRONGHOLDCRUSADER 0x004DBE30 + void HistoricCampaignOutro::MenuView_HistoricCampaignOutro_Prepare() + { + MACRO_CALL(OpenSHC::UI::Helpers_Func::PrepareHistoryBook)(); + // the campaign's picture + switch (DAT_GameCore::instance.historicCampaignNumber) { + case 1: + // "c1pic.tgx" + DAT_00eb0b20::instance = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_c1pic_tgx_005ab0ec); + break; + case 2: + // "c2pic.tgx" + DAT_00eb0b20::instance = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_c2pic_tgx_005ab0e0); + break; + case 3: + // "c3pic.tgx" + DAT_00eb0b20::instance = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_c3pic_tgx_005ab0d4); + break; + case 4: + // "c4pic.tgx" + DAT_00eb0b20::instance = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_c4pic_tgx_005ab0c8); + break; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::LoadTGX_shc_back)(); + // "Aftermath" and the campaign's closing text, the last two of its six in TEXT_CAMPAIGN_INFO + DAT_NumberOfStoredMenuStrings::instance = 0; + MACRO_CALL(OpenSHC::UI::Helpers_Func::StoreStringInMenuStringArray)(MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_CAMPAIGN_INFO, DAT_GameCore::instance.historicCampaignNumber * 6 - 2)); + MACRO_CALL(OpenSHC::UI::Helpers_Func::StoreStringInMenuStringArray)(MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_CAMPAIGN_INFO, DAT_GameCore::instance.historicCampaignNumber * 6 - 1)); + FLOAT_00ec0834::instance = 0.0; + DAT_00ed2780::instance = 1; + MACRO_CALL(OpenSHC::Rendering_Func::TicksStartCounter)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d195ecb365..c59a7ead77 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36229,7 +36229,7 @@ SHC_3BB0A8C1_0x004DBE28 | 0.0% | Pending SHC_3BB0A8C1_0x004DBE2C | 0.0% | Pending -SHC_3BB0A8C1_0x004DBE30 | 0.0% | Pending +SHC_3BB0A8C1_0x004DBE30 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DBEE4 | 0.0% | Pending From 7478b71dc878b9d3c9dc7c697885843c25848c70 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 00:18:38 +0100 Subject: [PATCH 02/13] reimplement: SHC_3BB0A8C1_0x00424DA0 100.0% Reimplemented From gynt's fork branch archive/UI-MenuViews-merged-full (97.2% there), after a style pass. His live reimpl/UI-MenuViews-development has another draft of it, also 97.2%, with two gotos; the merged-full one already writes the video and view-switch test as an if, so it was the shorter way to a goto-free function. What changed: the decompiler's hand-written security cookie and its MSVC_SecurityCookie.hpp include go (MSVC emits the cookie for the buffer itself); the buffer is char version[100], declared where it is first used; the goto that skipped the idle video becomes if (!flag), which measures the same (quick_diff 0.9725 both); (HBINK)0x0 is NULL; the (int) casts on currentNumber1 and y + 588 go; 0 < flag is flag > 0; 0x1fc, 0x16 and 0x13 are 508, 22 and 19; the colour 0x7caaaf is main's COL_7CAAAF; the stray ; and return go, and so do three using lines and the BOOLEnum.hpp include. The comment on the roll is a fixme: SEC_RNG's table comes from rand(), so currentNumber1 % 3 is 0 to 2 and every roll leaves the flag 0, and the sword swing never starts from here (only from MainMenu_DoInitial 0x00424CD0), as in the original. quick_diff 0.9725, which leaves the security cookie, the colour immediate and ret / ret 0. The strings are the s_ pointers from string-literals.hpp, with their text above them (SG 19), as in main's sibling PrepareHistoryBook (the original pushes each address; the S_ macros are for inline copies); the pointer swap measures the same as the S_ macros did. playBINK takes a char*, so its strings are cast with (char*), as main's playBikVideoFromPlayer.cpp does. This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized in reccmp in a clean alone build of the branch on main da1fef58e. Co-Authored-By: Claude Opus 5.5 --- .../MenuView_MainMenu_DoEveryFrame.cpp | 88 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp new file mode 100644 index 0000000000..180a10a6b1 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp @@ -0,0 +1,88 @@ +#include "../MainMenu.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MainMenuSwingSwordBool.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UnknownGFXIndex.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + // FUNCTION: STRONGHOLDCRUSADER 0x00424DA0 + void MainMenu::MenuView_MainMenu_DoEveryFrame() + { + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { + DAT_UnknownGFXIndex::instance = 0; + // fixme: a positive remainder is cleared too, so the sword swing below never starts from here + if (DAT_BinkControlState::instance.binkObjPtrArray[0] == NULL + && DAT_GameCore::instance.menuViewToSwitchTo == DAT_GameCore::instance.currentMenuViewType) { + if (DAT_MainMenuSwingSwordBool::instance) { + DAT_MainMenuSwingSwordBool::instance = 0; + } else { + DAT_MainMenuSwingSwordBool::instance = SEC_RNG::instance.currentNumber1 % 3; + if (DAT_MainMenuSwingSwordBool::instance > 0) { + DAT_MainMenuSwingSwordBool::instance = 0; + } + MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::nextRandomNumber1, SEC_RNG::ptr)(); + } + // the idle video + if (!DAT_MainMenuSwingSwordBool::instance) { + // "richard_ambient.bik" + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, + DAT_BinkControlState::ptr)(0, (char*)s_richard_ambient_bik_005a1fe4, 0, 0, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 508, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 22, 0); + } + if (DAT_MainMenuSwingSwordBool::instance == 1) { + // "richard_swordswing.bik" + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, + DAT_BinkControlState::ptr)(0, (char*)s_richard_swordswing_bik_005a1fc4, 0, 0, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 508, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 22, 0); + } + } + } else { + DAT_UnknownGFXIndex::instance = 1; + if (DAT_BinkControlState::instance.binkObjPtrArray[0] != NULL) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, + DAT_BinkControlState::ptr)(0); + } + } + // the background, centred + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(DAT_UnknownGFXIndex::instance, + (DAT_WindowAndDirectDraw::instance.resolutionX + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[DAT_UnknownGFXIndex::instance].width) + / 2, + (DAT_WindowAndDirectDraw::instance.resolutionY + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[DAT_UnknownGFXIndex::instance].height) + / 2); + // the version, "V1.41", in the bottom left corner + char version[100]; + // "V1.%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(version, s_V1_d_005a1fdc, 41); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(version, + DAT_MenuHandlerState::instance.x + 2, DAT_MenuHandlerState::instance.y + 588, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c59a7ead77..b400356d32 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6683,7 +6683,7 @@ SHC_3BB0A8C1_0x00424C40 | 0.0% | Pending SHC_3BB0A8C1_0x00424CD0 | 0.0% | Pending -SHC_3BB0A8C1_0x00424DA0 | 0.0% | Pending +SHC_3BB0A8C1_0x00424DA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00424F50 | 0.0% | Pending From b06a49ad472352b9d32276950c8cc813837db523 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 00:18:38 +0100 Subject: [PATCH 03/13] reimplement: SHC_3BB0A8C1_0x004DB7B0 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuViews-development (96.8% there), after a style pass. What changed: pcVar1 goes and the three text calls feed StoreStringInMenuStringArray directly; _tgxFileName is fileName, declared after PrepareHistoryBook where it is first used; the text group missionNumber1to20 * 4 + 95 is written (missionNumber1to20 - 1) * 4 + TEXT_MISSION1_STORY, the mission's story group ("Mission N", the title and the story; it measures the same as the draft's + 95); the casts in the eTextSections and TrimStoredMenuString arguments and a stray ; go; comments say what the picture, the texts and the trim are. The three calls stay three (a loop over the text number: quick_diff 0.9677 -> 0.6903). quick_diff 0.9677, which leaves the security cookie and ret / ret 0. The strings are the s_ pointers from string-literals.hpp, with their text above them (SG 19), as in main's sibling PrepareHistoryBook (the original pushes each address; the S_ macros are for inline copies); the pointer swap measures the same as the S_ macros did. This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized in reccmp in a clean alone build of the branch on main da1fef58e. Co-Authored-By: Claude Opus 5.5 --- .../MenuView_HistoricMissionIntro_Prepare.cpp | 64 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_Prepare.cpp diff --git a/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_Prepare.cpp b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_Prepare.cpp new file mode 100644 index 0000000000..f8e1fa6dd1 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_Prepare.cpp @@ -0,0 +1,64 @@ +#include "../HistoricMissionIntro.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Rendering.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00eb0b20.hpp" +#include "OpenSHC/Globals/DAT_00ed2780.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_NumberOfStoredMenuStrings.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/FLOAT_00ec0834.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + using OpenSHC::DE::SHCDE::eTextSections; + + // FUNCTION: STRONGHOLDCRUSADER 0x004DB7B0 + void HistoricMissionIntro::MenuView_HistoricMissionIntro_Prepare() + { + MACRO_CALL(OpenSHC::UI::Helpers_Func::PrepareHistoryBook)(); + // the mission's map + char fileName[16]; + // "m%dmap.tgx" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)( + fileName, s_m_dmap_tgx_005ab0b8, DAT_GameCore::instance.missionNumber1to20); + DAT_00eb0b20::instance = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(fileName); + // the mission's story group: "Mission N", its title and the story + DAT_NumberOfStoredMenuStrings::instance = 0; + // three calls (a loop over the text number: quick_diff 0.9677 -> 0.6903) + MACRO_CALL(OpenSHC::UI::Helpers_Func::StoreStringInMenuStringArray)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)((DAT_GameCore::instance.missionNumber1to20 - 1) * 4 + + OpenSHC::DE::SHCDE::TEXT_MISSION1_STORY), + 0)); + MACRO_CALL(OpenSHC::UI::Helpers_Func::StoreStringInMenuStringArray)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)((DAT_GameCore::instance.missionNumber1to20 - 1) * 4 + + OpenSHC::DE::SHCDE::TEXT_MISSION1_STORY), + 1)); + MACRO_CALL(OpenSHC::UI::Helpers_Func::StoreStringInMenuStringArray)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)((DAT_GameCore::instance.missionNumber1to20 - 1) * 4 + + OpenSHC::DE::SHCDE::TEXT_MISSION1_STORY), + 2)); + FLOAT_00ec0834::instance = 0.0; + DAT_00ed2780::instance = 1; + // the story (stored text 2), 740 wide in font size 17 + MACRO_CALL(OpenSHC::UI::Helpers_Func::TrimStoredMenuString)(2, 30, 380, 740, 0, 17); + MACRO_CALL(OpenSHC::Rendering_Func::TicksStartCounter)(); + MACRO_CALL(OpenSHC::UI::Helpers_Func::LoadTGX_shc_back)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b400356d32..d5f120124a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36205,7 +36205,7 @@ SHC_3BB0A8C1_0x004DB5C0 | 0.0% | Pending SHC_3BB0A8C1_0x004DB600 | 0.0% | Pending -SHC_3BB0A8C1_0x004DB7B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004DB7B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DB8B0 | 0.0% | Pending From 85b148f770c3041017e495c48285a1cb6a0431b5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 00:18:38 +0100 Subject: [PATCH 04/13] reimplement: SHC_3BB0A8C1_0x004DB4F0 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuViews-development (96.2% there), after a style pass. What changed: pcVar1 goes and the two text calls are inline; local_14 is fileName, in the same place; + -1 is - 1; the text group is (missionNumber1to20 - 1) * 4 + TEXT_MISSION1_STORY ("Mission N" and the title; it measures the same as the draft's + 95); a stray ; goes; comments say which picture (the campaign's: five missions each) and which texts. quick_diff 0.9623, which leaves the security cookie and ret / ret 0. The strings are the s_ pointers from string-literals.hpp, with their text above them (SG 19), as in main's sibling PrepareHistoryBook (the original pushes each address; the S_ macros are for inline copies); the pointer swap measures the same as the S_ macros did. This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized in reccmp in a clean alone build of the branch on main da1fef58e. Co-Authored-By: Claude Opus 5.5 --- ...enuView_HistoricMissionPicture_Prepare.cpp | 56 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/HistoricMissionPicture/MenuView_HistoricMissionPicture_Prepare.cpp diff --git a/src/OpenSHC/UI/MenuViews/HistoricMissionPicture/MenuView_HistoricMissionPicture_Prepare.cpp b/src/OpenSHC/UI/MenuViews/HistoricMissionPicture/MenuView_HistoricMissionPicture_Prepare.cpp new file mode 100644 index 0000000000..8cf6086172 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/HistoricMissionPicture/MenuView_HistoricMissionPicture_Prepare.cpp @@ -0,0 +1,56 @@ +#include "../HistoricMissionPicture.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Rendering.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00eb0b20.hpp" +#include "OpenSHC/Globals/DAT_00ed2780.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_NumberOfStoredMenuStrings.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/FLOAT_00ec0834.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + using OpenSHC::DE::SHCDE::eTextSections; + + // FUNCTION: STRONGHOLDCRUSADER 0x004DB4F0 + void HistoricMissionPicture::MenuView_HistoricMissionPicture_Prepare() + { + // the picture of the mission's campaign, five missions each: missions 1 to 5 show m1pic.tgx + char fileName[16]; + // "m%dpic.tgx" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)( + fileName, s_m_dpic_tgx_005ab0a0, (DAT_GameCore::instance.missionNumber1to20 - 1) / 5 + 1); + MACRO_CALL(OpenSHC::UI::Helpers_Func::PrepareHistoryBook)(); + DAT_00eb0b20::instance = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(fileName); + // the mission's story group: "Mission N" and its title + DAT_NumberOfStoredMenuStrings::instance = 0; + MACRO_CALL(OpenSHC::UI::Helpers_Func::StoreStringInMenuStringArray)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)((DAT_GameCore::instance.missionNumber1to20 - 1) * 4 + + OpenSHC::DE::SHCDE::TEXT_MISSION1_STORY), + 0)); + MACRO_CALL(OpenSHC::UI::Helpers_Func::StoreStringInMenuStringArray)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)((DAT_GameCore::instance.missionNumber1to20 - 1) * 4 + + OpenSHC::DE::SHCDE::TEXT_MISSION1_STORY), + 1)); + FLOAT_00ec0834::instance = 0.0; + DAT_00ed2780::instance = 1; + MACRO_CALL(OpenSHC::Rendering_Func::TicksStartCounter)(); + MACRO_CALL(OpenSHC::UI::Helpers_Func::LoadTGX_shc_back)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d5f120124a..e694668d3e 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36199,7 +36199,7 @@ SHC_3BB0A8C1_0x004DB390 | 0.0% | Pending SHC_3BB0A8C1_0x004DB490 | 100.0% | Reimplemented, mismatches in float constants and functions -SHC_3BB0A8C1_0x004DB4F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004DB4F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DB5C0 | 0.0% | Pending From dc7b91aca7ed01a47e0fa2216ab04ad541172516 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 00:18:38 +0100 Subject: [PATCH 05/13] reimplement: SHC_3BB0A8C1_0x004D55D0 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuViews-development (99.1% there), after main's renames (INT_00ec082c, CHAR_00eb0e44) and a style pass. What changed: DVar2 = timeGetTime() is folded into the subtraction; the two tab stores are activeMenuTab.tabType = BASMTT_NONE and BASMTT_KEEP_OR_MPMENU_IPX, as main's MissionEndscreen_Main pairs them with INT_00ec082c 0 and 2 (the draft had (BuildMenuTabType)0 and 2 in buildMenuTab, the same int at the same offset); DAT_SomeTextArrayIndex = 9 is TAIT_NINE__FILTER_B, as main writes it; the (ushort) cast on COL_BLACK goes; menuY and menuX are const and pMVar1 is Menu* const menu; the missions 6 to 10 test is a range; 0x50 and 0x3c are 80 and 60; six using lines and the BOOLEnum.hpp include go. currentMenu is still read once into the local, as the draft had it (read twice: quick_diff 0.9909 -> 0.9774). The four playBINK calls stay four, as the original's compiler merged their tails (one call after picking the file: quick_diff 0.9909 -> 0.7282). quick_diff 0.9909, which leaves only the timeGetTime import call. The strings are the s_ pointers from string-literals.hpp, with their text above them (SG 19), as in main's sibling PrepareHistoryBook (the original pushes each address; the S_ macros are for inline copies); the pointer swap measures the same as the S_ macros did. playBINK takes a char*, so its strings are cast with (char*), as main's playBikVideoFromPlayer.cpp does. This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized in reccmp in a clean alone build of the branch on main da1fef58e. Co-Authored-By: Claude Opus 5.5 --- .../GameLost/MenuView_GameLost_Prepare.cpp | 118 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp diff --git a/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp new file mode 100644 index 0000000000..70a1df7d41 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp @@ -0,0 +1,118 @@ +#include "../GameLost.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/Skirmish.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/CHAR_00eb0e44.hpp" +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_00eb9af8.hpp" +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/DWORD_00ed27b4.hpp" +#include "OpenSHC/Globals/INT_00ec082c.hpp" +#include "OpenSHC/Globals/INT_00ed279c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D55D0 + void GameLost::MenuView_GameLost_Prepare() + { + DAT_GameCore::instance.gameDuration = timeGetTime() - DAT_GameCore::instance.timeSum_2; + INT_00ed279c::instance = 0; + DAT_FinalResultsOrderByColumn::instance = 0; + DAT_00eb9af8::instance = 0; + CHAR_00eb0e44::instance = 0; + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_NONE; + INT_00ec082c::instance = 0; + } else { + DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_KEEP_OR_MPMENU_IPX; + INT_00ec082c::instance = 2; + } + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreLocalTime)(); + DWORD_00ed27b4::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::setupLossMusic, DAT_SoundSystemState::ptr)(); + int const menuY = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + int const menuX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth; + // currentMenu read once (read twice: quick_diff 0.9909 -> 0.9774) + Menu* const menu = DAT_MenuHandlerState::instance.currentMenu; + menu->xPosition = menuX; + menu->yPosition = menuY; + DAT_MenuHandlerState::instance.y = menuY; + DAT_MenuHandlerState::instance.x = menuX; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)(0, + 0, DAT_WindowAndDirectDraw::instance.resolutionX, DAT_WindowAndDirectDraw::instance.resolutionY, + COL_BLACK::instance.shortValue); + // the defeat video, outside skirmish: Arabian for campaign missions 6 to 10 or an Arabian lord + // four calls (one call after picking the file: quick_diff 0.9909 -> 0.7282) + if (DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + if (DAT_GameCore::instance.missionNumber1to20 >= 6 + && DAT_GameCore::instance.missionNumber1to20 <= 10) { + // "arabian_lose.bik" + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, + DAT_BinkControlState::ptr)(0, (char*)s_arabian_lose_bik_005aaf04, 0, 0, + DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); + } else { + // "crusader_lose.bik" + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, + DAT_BinkControlState::ptr)(0, (char*)s_crusader_lose_bik_005aaef0, 0, 0, + DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); + } + } else if (MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::getLordTypeForPlayer, + DAT_GameSynchronyState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID) + == 1) { + // "arabian_lose.bik" + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, + DAT_BinkControlState::ptr)(0, (char*)s_arabian_lose_bik_005aaf04, 0, 0, + DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); + } else { + // "crusader_lose.bik" + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, + DAT_BinkControlState::ptr)(0, (char*)s_crusader_lose_bik_005aaef0, 0, 0, + DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); + } + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::LoadTGX_shc_back)(); + DAT_MenuTextInputState::instance.DAT_SomeTextArrayIndex = OpenSHC::Text::TAIT_NINE__FILTER_B; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e694668d3e..ceeabeb398 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35573,7 +35573,7 @@ SHC_3BB0A8C1_0x004D53A0 | 0.0% | Pending SHC_3BB0A8C1_0x004D53E0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D55D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D55D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D5780 | 0.0% | Pending From 78a1f04dc63cf8738b9dd667fcab45493f2a026c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:57:04 +0100 Subject: [PATCH 06/13] GameLost_Prepare: the defeat video is skipped only at the skirmish end screen The comment said "outside skirmish", but the video is skipped only in GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER (666); a skirmish game (GM_SKIRMISH_SINGLE_PLAYER, 99) gets it. Comment only: quick_diff 0.9909 before and after. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp index 70a1df7d41..3c972cb6a7 100644 --- a/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp +++ b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp @@ -76,7 +76,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, DAT_WindowAndDirectDraw::instance.resolutionY, COL_BLACK::instance.shortValue); - // the defeat video, outside skirmish: Arabian for campaign missions 6 to 10 or an Arabian lord + // the defeat video unless at the skirmish end screen: Arabian for missions 6 to 10 or an Arabian lord // four calls (one call after picking the file: quick_diff 0.9909 -> 0.7282) if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER) { From b953b94c4f26307bb092c6f49f61072c38c386a4 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:28:49 +0100 Subject: [PATCH 07/13] headers: INT_00ed279c is a BOOLEnum It was an int. Every store is 0 or 1: 0 at 0x004D55EC (this PR's MenuView_GameLost_Prepare) and 0x004E1B5F (MenuView_MissionFinishedTransition_Prepare), both from a zeroed ebx, and 1 at 0x004D6C23 (MenuItemActionHandler_MissionEndscreen_Main, on main); the two reads, at 0x004DC5B5 and 0x004DCA5C, compare it with a register and with 0. The name stays INT_00ed279c, a proposal for Ghidra's side ("end screen continue pressed"). BOOLEnum is BOOL, an int, so main's MissionEndscreen_Main compiles the same. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/INT_00ed279c.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/Globals/INT_00ed279c.hpp b/src/OpenSHC/Globals/INT_00ed279c.hpp index 4f79633004..8307f891e8 100644 --- a/src/OpenSHC/Globals/INT_00ed279c.hpp +++ b/src/OpenSHC/Globals/INT_00ed279c.hpp @@ -8,12 +8,16 @@ #pragma once +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + // GLOBAL: STRONGHOLDCRUSADER 0x00ED279C // StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00ED279C) INT_00ed279c; +using OpenSHC::WindowsHelper::Enums::BOOLEnum; + +MACRO_STRUCT_RESOLVER(BOOLEnum, false, Address::SHC_3BB0A8C1_0x00ED279C) INT_00ed279c; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00ED279C); From 6445c6e5e32d25f2f7cf034878224fbcd3fc5abc Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:28:50 +0100 Subject: [PATCH 08/13] headers: getSoundVolumeForFilename takes a char const* The file name is only read: the function compares it with each loaded sound's name through __stricmp, which takes char const* (main's getSoundVolumeForFilename.cpp, 0x0044A240). Every caller passes a char* and compiles the same; the change lets playBINK pass its own file name on as const. The definition follows in the next commit. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SFXState.func.hpp | 2 +- src/OpenSHC/Audio/SFX/SFXState.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Audio/SFX/SFXState.func.hpp b/src/OpenSHC/Audio/SFX/SFXState.func.hpp index 142f4cbe44..54937eb5cd 100644 --- a/src/OpenSHC/Audio/SFX/SFXState.func.hpp +++ b/src/OpenSHC/Audio/SFX/SFXState.func.hpp @@ -74,7 +74,7 @@ namespace Audio { playAmbientSoundStream2Unk; MACRO_FUNCTION_RESOLVER( - int (SFXState::*)(char*), false, Address::SHC_3BB0A8C1_0x0044A240, &SFXState::getSoundVolumeForFilename) + int (SFXState::*)(char const*), false, Address::SHC_3BB0A8C1_0x0044A240, &SFXState::getSoundVolumeForFilename) getSoundVolumeForFilename; MACRO_FUNCTION_RESOLVER( diff --git a/src/OpenSHC/Audio/SFX/SFXState.hpp b/src/OpenSHC/Audio/SFX/SFXState.hpp index 8a3a94cec9..cba97835f5 100644 --- a/src/OpenSHC/Audio/SFX/SFXState.hpp +++ b/src/OpenSHC/Audio/SFX/SFXState.hpp @@ -78,7 +78,7 @@ namespace Audio { void playAmbientSoundStream2Unk(int ambientSoundIndexUnk); - int getSoundVolumeForFilename(char* soundFileName); + int getSoundVolumeForFilename(char const* soundFileName); void playUnitSpeechEffect(uint speechEffectID); From 3cf47bd487504feb34705802d460683095c4f687 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:28:50 +0100 Subject: [PATCH 09/13] getSoundVolumeForFilename: the definition takes the char const* it is declared with Follows the header commit before this one. Same code. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SFXState/getSoundVolumeForFilename.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/Audio/SFX/SFXState/getSoundVolumeForFilename.cpp b/src/OpenSHC/Audio/SFX/SFXState/getSoundVolumeForFilename.cpp index b199481dd3..ced596d8c7 100644 --- a/src/OpenSHC/Audio/SFX/SFXState/getSoundVolumeForFilename.cpp +++ b/src/OpenSHC/Audio/SFX/SFXState/getSoundVolumeForFilename.cpp @@ -7,7 +7,7 @@ namespace Audio { namespace SFX { // FUNCTION: STRONGHOLDCRUSADER 0x0044A240 - int SFXState::getSoundVolumeForFilename(char* soundFileName) + int SFXState::getSoundVolumeForFilename(char const* soundFileName) { for (int _runCounter = 0; _runCounter < this->DAT_SoundTotalCount; ++_runCounter) { if (!MACRO_CALL(OpenSHC::OS_Func::__stricmp)( From 8a97d31d25f2b8ba7ebff8902fc501abccd86e61 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:28:50 +0100 Subject: [PATCH 10/13] headers: playBINK takes its file name as char const* binkFileName is only read: main's playBINK.cpp (0x00408ED0) passes it to resolveResourceFileName, which takes char const*, and to getSoundVolumeForFilename, which does since the header commit before. Callers that pass a char* compile the same; the s_ pointers from string-literals.hpp no longer need a (char*) cast. The definition follows in the next commit. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Rendering/Bink/BinkControlClass.func.hpp | 2 +- src/OpenSHC/Rendering/Bink/BinkControlClass.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass.func.hpp b/src/OpenSHC/Rendering/Bink/BinkControlClass.func.hpp index 999749e0a7..638b15234a 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass.func.hpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass.func.hpp @@ -30,7 +30,7 @@ namespace Rendering { &BinkControlClass::stopAllBinkPlayback) stopAllBinkPlayback; - MACRO_FUNCTION_RESOLVER(void (BinkControlClass::*)(int, char*, DWORD, DWORD, int, int, DWORD), false, + MACRO_FUNCTION_RESOLVER(void (BinkControlClass::*)(int, char const*, DWORD, DWORD, int, int, DWORD), false, Address::SHC_3BB0A8C1_0x00408ED0, &BinkControlClass::playBINK) playBINK; diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp b/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp index 3b3d9dbec7..ad57def57e 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp @@ -62,7 +62,7 @@ namespace Rendering { void stopAllBinkPlayback(); void playBINK( - int binkObjIndex, char* binkFileName, DWORD param_3, DWORD param_4, int xPos, int yPos, DWORD param_7); + int binkObjIndex, char const* binkFileName, DWORD param_3, DWORD param_4, int xPos, int yPos, DWORD param_7); void copyBinkToVideoBuffer(dword param_1); From 9dc005d6ca097f85bd92a0293bc7a405734cf28c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:28:51 +0100 Subject: [PATCH 11/13] playBINK: the definition takes the char const* it is declared with Follows the header commit before this one. Touching the file brings it under the checker, so it also gets the first include of its class (../BinkControlClass.func.hpp, SG 14; Rendering.func.hpp moves into the include list) and declares the sound volume where it is assigned (SG 24). Same code. Co-Authored-By: Claude Opus 5.5 --- .../Rendering/Bink/BinkControlClass/playBINK.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/playBINK.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/playBINK.cpp index 0165c26776..85027ee803 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass/playBINK.cpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/playBINK.cpp @@ -1,8 +1,8 @@ -#include "../../../Rendering.func.hpp" +#include "../BinkControlClass.func.hpp" #include "OpenSHC/Audio/SFX/SFXState.func.hpp" #include "OpenSHC/IO/ResourceManager.func.hpp" -#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Rendering.func.hpp" #include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" #include "OpenSHC/IO/FileResourceType.hpp" #include "OpenSHC/Rendering/Bink/UnsortedBinkFlag.hpp" @@ -23,11 +23,10 @@ namespace Rendering { // FUNCTION: STRONGHOLDCRUSADER 0x00408ED0 void BinkControlClass::playBINK( - int binkObjIndex, char* binkFileName, DWORD param_3, DWORD param_4, int xPos, int yPos, DWORD param_7) + int binkObjIndex, char const* binkFileName, DWORD param_3, DWORD param_4, int xPos, int yPos, DWORD param_7) { char* _videoFileName; HBINK _binkObjPtr; - int _fileSoundVolumne; MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( OpenSHC::IO::FRT_BINKS, (char const*)((int)(binkFileName))); if (this->binkObjPtrArray[binkObjIndex] != (HBINK)0x0) { @@ -49,9 +48,9 @@ namespace Rendering { } if ((DAT_SoundSystemState::instance.waveOutOpenUnk_0x8 != FALSE) && (DAT_SoundSystemState::instance.soundActiveUnk_0x0 != 0)) { - _fileSoundVolumne = MACRO_CALL_MEMBER( + int const fileSoundVolume = MACRO_CALL_MEMBER( OpenSHC::Audio::SFX::SFXState_Func::getSoundVolumeForFilename, DAT_SFXState::ptr)(binkFileName); - BinkSetVolume(this->binkObjPtrArray[binkObjIndex], 0, (long)((int)(_fileSoundVolumne * 250))); + BinkSetVolume(this->binkObjPtrArray[binkObjIndex], 0, (long)((int)(fileSoundVolume * 250))); } this->xPos[binkObjIndex] = xPos; this->yPos[binkObjIndex] = yPos; From ad1bb394f18b35603408b13674c68fc2f188831b Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:28:51 +0100 Subject: [PATCH 12/13] GameLost_Prepare and MainMenu_DoEveryFrame: drop the (char*) casts playBINK no longer needs playBINK takes its file name as char const* since the header commit before this one, so the s_ pointers go in uncast; GameLost_Prepare also stores FALSE in INT_00ed279c, a BOOLEnum now. Same code (quick_diff unchanged). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuViews/GameLost/MenuView_GameLost_Prepare.cpp | 10 +++++----- .../MainMenu/MenuView_MainMenu_DoEveryFrame.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp index 3c972cb6a7..507bbc3df3 100644 --- a/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp +++ b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_Prepare.cpp @@ -44,7 +44,7 @@ namespace UI { void GameLost::MenuView_GameLost_Prepare() { DAT_GameCore::instance.gameDuration = timeGetTime() - DAT_GameCore::instance.timeSum_2; - INT_00ed279c::instance = 0; + INT_00ed279c::instance = FALSE; DAT_FinalResultsOrderByColumn::instance = 0; DAT_00eb9af8::instance = 0; CHAR_00eb0e44::instance = 0; @@ -85,12 +85,12 @@ namespace UI { && DAT_GameCore::instance.missionNumber1to20 <= 10) { // "arabian_lose.bik" MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, - DAT_BinkControlState::ptr)(0, (char*)s_arabian_lose_bik_005aaf04, 0, 0, + DAT_BinkControlState::ptr)(0, s_arabian_lose_bik_005aaf04, 0, 0, DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); } else { // "crusader_lose.bik" MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, - DAT_BinkControlState::ptr)(0, (char*)s_crusader_lose_bik_005aaef0, 0, 0, + DAT_BinkControlState::ptr)(0, s_crusader_lose_bik_005aaef0, 0, 0, DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); } } else if (MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::getLordTypeForPlayer, @@ -98,12 +98,12 @@ namespace UI { == 1) { // "arabian_lose.bik" MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, - DAT_BinkControlState::ptr)(0, (char*)s_arabian_lose_bik_005aaf04, 0, 0, + DAT_BinkControlState::ptr)(0, s_arabian_lose_bik_005aaf04, 0, 0, DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); } else { // "crusader_lose.bik" MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, - DAT_BinkControlState::ptr)(0, (char*)s_crusader_lose_bik_005aaef0, 0, 0, + DAT_BinkControlState::ptr)(0, s_crusader_lose_bik_005aaef0, 0, 0, DAT_MenuHandlerState::instance.x + 80, DAT_MenuHandlerState::instance.y + 60, 2); } } diff --git a/src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp index 180a10a6b1..9393d9e2be 100644 --- a/src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp +++ b/src/OpenSHC/UI/MenuViews/MainMenu/MenuView_MainMenu_DoEveryFrame.cpp @@ -46,14 +46,14 @@ namespace UI { if (!DAT_MainMenuSwingSwordBool::instance) { // "richard_ambient.bik" MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, - DAT_BinkControlState::ptr)(0, (char*)s_richard_ambient_bik_005a1fe4, 0, 0, + DAT_BinkControlState::ptr)(0, s_richard_ambient_bik_005a1fe4, 0, 0, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 508, DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 22, 0); } if (DAT_MainMenuSwingSwordBool::instance == 1) { // "richard_swordswing.bik" MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::playBINK, - DAT_BinkControlState::ptr)(0, (char*)s_richard_swordswing_bik_005a1fc4, 0, 0, + DAT_BinkControlState::ptr)(0, s_richard_swordswing_bik_005a1fc4, 0, 0, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 508, DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 22, 0); } From 5524fc8b368604c3c74b0dd3adf2feb9848de0fb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 04:35:27 +0100 Subject: [PATCH 13/13] headers: clang-format SFXState.func.hpp and BinkControlClass.hpp cpp-linter checks whole changed files: the two declarations changed to char const* are wrapped the way clang-format wraps them. Whitespace only. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SFXState.func.hpp | 4 ++-- src/OpenSHC/Rendering/Bink/BinkControlClass.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/Audio/SFX/SFXState.func.hpp b/src/OpenSHC/Audio/SFX/SFXState.func.hpp index 54937eb5cd..4caa2a18ae 100644 --- a/src/OpenSHC/Audio/SFX/SFXState.func.hpp +++ b/src/OpenSHC/Audio/SFX/SFXState.func.hpp @@ -73,8 +73,8 @@ namespace Audio { void (SFXState::*)(int), false, Address::SHC_3BB0A8C1_0x0044A1B0, &SFXState::playAmbientSoundStream2Unk) playAmbientSoundStream2Unk; - MACRO_FUNCTION_RESOLVER( - int (SFXState::*)(char const*), false, Address::SHC_3BB0A8C1_0x0044A240, &SFXState::getSoundVolumeForFilename) + MACRO_FUNCTION_RESOLVER(int (SFXState::*)(char const*), false, Address::SHC_3BB0A8C1_0x0044A240, + &SFXState::getSoundVolumeForFilename) getSoundVolumeForFilename; MACRO_FUNCTION_RESOLVER( diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp b/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp index ad57def57e..7bc4128775 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass.hpp @@ -61,8 +61,8 @@ namespace Rendering { void stopAllBinkPlayback(); - void playBINK( - int binkObjIndex, char const* binkFileName, DWORD param_3, DWORD param_4, int xPos, int yPos, DWORD param_7); + void playBINK(int binkObjIndex, char const* binkFileName, DWORD param_3, DWORD param_4, int xPos, int yPos, + DWORD param_7); void copyBinkToVideoBuffer(dword param_1);