From 4cc9d5e9885692050f59500c5b4f09bffb1558de Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:27 +0100 Subject: [PATCH 01/10] headers: DAT_00b95954 is a BOOLEnum Every store is 0 or 1: 0x004254C0 stores ebx, zeroed at 0x004254B6, and 0x004E1F08 stores ecx, set to 1 in Unknown26_CampaignRelatedUnk_DoEveryFrame. Every read compares it with 0 or 1: cmp .., 0 three times, cmp .., 1 twice (at 0x0046B806 among them) and 0x004261E4 against a zeroed edi. The type changes from undefined4 to BOOLEnum, with the include and using as in main's BOOLEnum_00ed279c. Ghidra would name it BOOLEnum_00b95954; the name stays, so that the sync can rename it together with its users. Its users compile to the same code before and after: main's playDarMehqOrGlory and switchToMenuView are 100.0% raw and normalized in clean alone builds of this branch without and with this commit, which compare equal over all 1827 functions; this branch's Unknown26_CampaignRelatedUnk_DoEveryFrame and Credits_Prepare in the MenuViews draft measure the same in quick_diff. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00b95954.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00b95954.hpp b/src/OpenSHC/Globals/DAT_00b95954.hpp index ffec5716b2..4bdff0a983 100644 --- a/src/OpenSHC/Globals/DAT_00b95954.hpp +++ b/src/OpenSHC/Globals/DAT_00b95954.hpp @@ -8,12 +8,16 @@ #pragma once +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + // GLOBAL: STRONGHOLDCRUSADER 0x00B95954 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B95954) DAT_00b95954; +using OpenSHC::WindowsHelper::Enums::BOOLEnum; + +MACRO_STRUCT_RESOLVER(BOOLEnum, false, Address::SHC_3BB0A8C1_0x00B95954) DAT_00b95954; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B95954); From 56d6a82801f87ffaae7ae374ea9630c1f6af84e5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:27 +0100 Subject: [PATCH 02/10] headers: GameCore.descriptionUseStringTable and mapLoadedForEditor are BOOLEnums descriptionUseStringTable (0x01FE8678) is stored 0 at 0x0042EE75 and 0x0042FA76, 1 at 0x00474EE6, and from registers holding 0 or 1 at 0x0042F0C1 (ebx, zeroed at 0x0042F012), 0x00474ECA (ebx, zeroed at 0x00474E62) and 0x00448922 (ebp, set to 1 at 0x004485F0); readMapOrSavFile also reads it from the map file. mapLoadedForEditor (0x01FE9AA8) is stored 1 at 0x004300C9, 0x00430614 and 0x00494610, and from esi (zeroed at 0x00425EA1) at 0x00425F1D and edi (set to 1 at 0x0042F989) at 0x0042FA96. Every read of either compares it with 0 or with a register, and the registers checked hold 0 (ecx at 0x0042E940, and esi at 0x0042E05B and 0x0042E06F, where this branch's MapEditorProperties_Prepare matches with truth tests). Both change from dword to BOOLEnum. All their users compile to the same code before and after (quick_diff, same ratio and length each): main's switchToMenuView, readMapOrSavFile, writeMapOrSaveFile, InitializeBasicMap, MenuItemRenderFunction_MapEditorProperties_MainButtons, MenuItemActionHandler_SaveLoadMap_Buttons, MenuItemActionHandler_UnusedChooseAvailableKeeps_Main and _UnusedChooseGameType_Main, and this branch's MapEditorProperties_Prepare and Unknown26_CampaignRelatedUnk_DoEveryFrame. The names stay. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Game/GameCore.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Game/GameCore.hpp b/src/OpenSHC/Game/GameCore.hpp index 919ae027e2..a98d1edfc6 100644 --- a/src/OpenSHC/Game/GameCore.hpp +++ b/src/OpenSHC/Game/GameCore.hpp @@ -137,7 +137,7 @@ namespace Game { byte unused_0x178[2024]; // 0x00000178 length: 2024 BOOLEnum cheatModeFlag; // 0x00000960 length: 4 BOOLEnum solitaryAltUDungeon; // 0x00000964 length: 4 - dword descriptionUseStringTable; // 0x00000968 length: 4 + BOOLEnum descriptionUseStringTable; // 0x00000968 length: 4 dword descriptionStringTableIndex; // 0x0000096C length: 4 char temporaryTextBufferOfSize1000[1000]; // 0x00000970 length: 1000 char standaloneFilename[1001]; // 0x00000D58 length: 1001 @@ -159,7 +159,7 @@ namespace Game { int savedMapBalance; // 0x00001D8C length: 4 MapLockStateInt U3_mapLockedState; // 0x00001D90 length: 4 MapLockStateInt savedMapLocked; // 0x00001D94 length: 4 - dword mapLoadedForEditor; // 0x00001D98 length: 4 + BOOLEnum mapLoadedForEditor; // 0x00001D98 length: 4 int mapU3EndInt; // 0x00001D9C length: 4 int savedMapEndInt2; // 0x00001DA0 length: 4 int canBeginMainLoop; // 0x00001DA4 length: 4 From f648ad15f1a5d2204cdbb91e0e0728511f48735d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:27 +0100 Subject: [PATCH 03/10] reimplement: SHC_3BB0A8C1_0x0042DFD0 100.0% Reimplemented MenuView_MapEditorProperties_Prepare opens the map editor's properties view: it closes the third modal, resets the text input, loads frontend_builder2.tgx, in a multiplayer map counts the players with a first building and clears every player's and the map's start goods, and measures the height of the map's description. From gynt's 46f3f3826 on his fork's reimpl/UI-MenuViews-development (85.71% there, "Shared call duplicated"), first written in 24305ee23 and 8f42b3d97 (59.5%): the function's reads and stores, the per-arm renderMultilineTextUnk calls and the positive descriptionStringTableIndex test are his. Changed here: the two pointer loops become index loops over players 1 to 8 and the 25 start goods (with the draft's walking pointers MSVC addresses the start resources from an offset register: quick_diff 1.0000 -> 0.9429); the building test reads playerDataArray[player].buildingEntryInfos[0].id, the field the draft reached through a cast 0x3D8 bytes before startResources; main's INT_00b95b74 for DAT_00b95b74 and TAIT_NINE__FILTER_B for 9; COL_000000 for the black colour; truth tests on mapLoadedForEditor and descriptionUseStringTable, BOOLEnums since the header commit before this one; 0x13 and 0x168 are 19 and 360; the (int) cast on descriptionStringTableIndex, piVar2 to piVar4, five using lines and three unused includes go; main's namespace form; the file name's s_ pointer with its text above it; comments say what the loops and the height are. This file was measured as it stands in a clean alone build of the branch on main eef6f667a: 100.0% raw, 100.0% normalized. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuView_MapEditorProperties_Prepare.cpp | 82 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_Prepare.cpp diff --git a/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_Prepare.cpp b/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_Prepare.cpp new file mode 100644 index 0000000000..9a4a1bd77d --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_Prepare.cpp @@ -0,0 +1,82 @@ +#include "../MapEditorProperties.func.hpp" + +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapEditorProperties_ClickedButton.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + namespace MapEditorProperties { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042DFD0 + void MenuView_MapEditorProperties_Prepare() + { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_NINE__FILTER_B); + DAT_MapEditorProperties_ClickedButton::instance = 0; + DAT_TextureRenderCoreObject::instance.totalLoadedGfx = 0; + // "frontend_builder2.tgx" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_frontend_builder2_tgx_005a206c); + if (DAT_GameCore::instance.U2_mapType_singleOrMulti != 0) { + // count the players with a first building and clear every player's start goods and the map's + DAT_GameCore::instance.mapU2PlayersCount = 0; + for (int player = 1; player < countof(DAT_GameState::instance.playerDataArray); ++player) { + if (DAT_GameState::instance.playerDataArray[player].buildingEntryInfos[0].id != 0) { + ++DAT_GameCore::instance.mapU2PlayersCount; + } + for (int good = 0; good < countof(DAT_GameState::instance.mapAndTime.startGoods); ++good) { + DAT_GameState::instance.playerDataArray[player].startResources[good] = 0; + DAT_GameState::instance.mapAndTime.startGoods[good] = 0; + } + } + } + INT_00b95b74::instance = 0; + DAT_00b960f4::instance = 0; + // the height of the map's description in pixels (mode 1 only measures) + if (DAT_GameCore::instance.mapLoadedForEditor) { + if (!DAT_GameCore::instance.descriptionUseStringTable) { + INT_00b95b74::instance + = MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[19])( + DAT_GameCore::instance.temporaryTextBufferOfSize1000, 0, 0, 360, + OpenSHC::Rendering::Colors::COL_000000, 0, 1); + } else if (DAT_GameCore::instance.descriptionStringTableIndex != 0) { + INT_00b95b74::instance + = MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[19])( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, + DAT_GameCore::instance.descriptionStringTableIndex), + 0, 0, 360, OpenSHC::Rendering::Colors::COL_000000, 0, 1); + } + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::LoadTGX_shc_back)(); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6e036f9340..1b320adb91 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8265,7 +8265,7 @@ SHC_3BB0A8C1_0x0042DEB0 | 0.0% | Pending SHC_3BB0A8C1_0x0042DF40 | 0.0% | Pending -SHC_3BB0A8C1_0x0042DFD0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042DFD0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042E0D0 | 0.0% | Pending From 0e63713725dca481fc8e1a67d8a1bfd7ef942487 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:27 +0100 Subject: [PATCH 04/10] reimplement: SHC_3BB0A8C1_0x0042F3F0 100.0% Reimplemented MenuView_NewMapMapsize_DoEveryFrame draws the screen's title, "Select New Map Size" (TEXT_MAPEDIT 20), and a minimap preview of the map at its size, framed twice in black, with the size as text above its top right corner. Written from the original's instructions, with gynt's draft (3a10a4484 on his fork's reimpl/UI-MenuViews-development, 83.46% there; earlier 35d66b707 at 64.5% and 4cfdc4287 at 62.32%) for the reads: the two switches, the first the original's jump table and the second its sub / je chain with default first, are his. His goto from default into case 200 goes, as both arms written out are merged by MSVC as in the original. Two forms are kept for the register allocation, each with a one-line comment: the title's position in two locals, y first (inline: quick_diff 0.9760 -> 0.7200, x first: 0.9600), and the label's x in its own local (x += previewSize: 0.8617). Also: main's namespace form, as in the sibling Prepare; s__dx_d_005a22fc for "%dx%d" with its text above it; COL_C2F0EB, COL_000000 and TTA_RIGHT for 0xc2f0eb, 0 and -1; needsRedraw = TRUE; decimals for 0x1e, 0x32, 0x3b, 0x122 and the frame offsets; the casts on the frame colour go; the draft's eleven decompiler locals become x, y, centerX, centerY, mapSize, previewSize, sizeText, titleX, titleY and labelX; comments say what is drawn, that x and y become the preview's top left corner and that a 100 map gets the default 200 frame. quick_diff 0.9760 leaves the security cookie, the colour immediate, the jump table's labels and ret / ret 0. This file was measured as it stands in a clean alone build of the branch on main eef6f667a: 100.0% raw, 100.0% normalized. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuView_NewMapMapsize_DoEveryFrame.cpp | 160 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp new file mode 100644 index 0000000000..558918f4c5 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp @@ -0,0 +1,160 @@ +#include "../NewMapMapsize.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + namespace NewMapMapsize { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042F3F0 + void MenuView_NewMapMapsize_DoEveryFrame() + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(0, + (DAT_WindowAndDirectDraw::instance.resolutionX + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].width) + / 2, + (DAT_WindowAndDirectDraw::instance.resolutionY + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].height) + / 2); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderBanner, DAT_PencilRenderCore::ptr)( + DAT_MenuHandlerState::instance.x + 100, DAT_MenuHandlerState::instance.y + 30, 600, 50); + // "Select New Map Size"; its position named, y first (inline: quick_diff 0.9760 -> 0.7200) + int const titleY = DAT_MenuHandlerState::instance.y + 59; + int const titleX = DAT_MenuHandlerState::instance.x + 400; + 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_MAPEDIT, 20), + titleX, titleY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 16, FALSE, 0); + + // the minimap preview, centred on (x, y) + int x = DAT_MenuHandlerState::instance.x + 600; + int y = DAT_MenuHandlerState::instance.y + 290; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + int mapSize = DAT_TileMapState::instance.mapSize; + if (mapSize == 0) { + mapSize = 400; + } + int const centerX = x; + int const centerY = y; + DAT_MinimapViewState::instance.needsRedraw = TRUE; + char sizeText[20]; + // "%dx%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(sizeText, s__dx_d_005a22fc, mapSize, mapSize); + // x and y move to the preview's top left corner + int previewSize; + switch (mapSize) { + case 100: + x -= 50; + y -= 50; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 100; + break; + case 160: + x -= 80; + y -= 80; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 160; + break; + case 200: + x -= 100; + y -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 200; + break; + case 300: + // drawn at half size + x -= 75; + y -= 75; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, 150, 150); + previewSize = 150; + break; + default: + // 400 is drawn at half size + x -= 100; + y -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, 200, 200); + previewSize = 200; + break; + } + + // a two-pixel black frame around the preview + // default first, as the original lays the arms out; a 100 map gets the default 200 frame + switch (mapSize) { + default: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 100, centerY - 100, centerX + 99, centerY + 100, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 101, centerY - 101, centerX + 100, centerY + 101, COL_BLACK::instance.shortValue); + break; + case 300: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 75, centerY - 75, centerX + 73, centerY + 74, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 76, centerY - 76, centerX + 74, centerY + 75, COL_BLACK::instance.shortValue); + break; + case 200: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 98, centerY - 99, centerX + 99, centerY + 99, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 99, centerY - 100, centerX + 100, centerY + 100, COL_BLACK::instance.shortValue); + break; + case 160: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 78, centerY - 79, centerX + 78, centerY + 77, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 79, centerY - 80, centerX + 79, centerY + 78, COL_BLACK::instance.shortValue); + break; + } + + // the size label at the top right (x += previewSize: quick_diff 0.9760 -> 0.8617) + int const labelX = x + previewSize; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + labelX + - MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)(sizeText, 19) + - 15, + y - 15, labelX, y); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(sizeText, labelX - 5, y - 11, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, OpenSHC::Rendering::Colors::COL_000000, 19, FALSE, 0); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1b320adb91..67687216bc 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8743,7 +8743,7 @@ SHC_3BB0A8C1_0x0042F3C0 | 0.0% | Pending SHC_3BB0A8C1_0x0042F3D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0042F3F0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042F3F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042F708 | 0.0% | Pending From d687f007da836eb70f870c3adb19a26ddc0e12f6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:28 +0100 Subject: [PATCH 05/10] reimplement: SHC_3BB0A8C1_0x0042FAC0 100.0% Reimplemented MenuView_UnusedChooseAvailableKeeps_DoEveryFrame draws the screen's title, "Select Keep Types" (TEXT_MAPEDIT 21), and a minimap preview of the map at its size, framed twice in black, with the size as text above its top right corner. The body is the one of NewMapMapsize's 0x0042F3F0 with its own title, and the original's instructions are the same but for that text index. Written from the original's instructions, with gynt's draft (96f71d992 on his fork's reimpl/UI-MenuViews-development, 83.46% there; earlier 69751c0ed at 64.5% and cef13edff at 62.32%) for the reads: the two switches, the first the original's jump table and the second its sub / je chain with default first, are his. His goto from default into case 200 goes, as both arms written out are merged by MSVC as in the original. Two forms are kept for the register allocation, each with a one-line comment: the title's position in two locals, y first (inline: quick_diff 0.9760 -> 0.7200, x first: 0.9600), and the label's x in its own local (x += previewSize: 0.8617). Also: main's namespace form, as in the sibling Prepare; s__dx_d_005a22fc for "%dx%d" with its text above it; COL_C2F0EB, COL_000000 and TTA_RIGHT for 0xc2f0eb, 0 and -1; needsRedraw = TRUE; decimals for 0x1e, 0x32, 0x3b, 0x122 and the frame offsets; the casts on the frame colour go; the draft's eleven decompiler locals become x, y, centerX, centerY, mapSize, previewSize, sizeText, titleX, titleY and labelX; comments say what is drawn, that x and y become the preview's top left corner and that a 100 map gets the default 200 frame. quick_diff 0.9760 leaves the security cookie, the colour immediate, the jump table's labels and ret / ret 0. This file was measured as it stands in a clean alone build of the branch on main eef6f667a: 100.0% raw, 100.0% normalized. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nusedChooseAvailableKeeps_DoEveryFrame.cpp | 160 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp new file mode 100644 index 0000000000..22b4be3ee5 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp @@ -0,0 +1,160 @@ +#include "../UnusedChooseAvailableKeeps.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + namespace UnusedChooseAvailableKeeps { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042FAC0 + void MenuView_UnusedChooseAvailableKeeps_DoEveryFrame() + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(0, + (DAT_WindowAndDirectDraw::instance.resolutionX + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].width) + / 2, + (DAT_WindowAndDirectDraw::instance.resolutionY + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].height) + / 2); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderBanner, DAT_PencilRenderCore::ptr)( + DAT_MenuHandlerState::instance.x + 100, DAT_MenuHandlerState::instance.y + 30, 600, 50); + // "Select Keep Types"; its position named, y first (inline: quick_diff 0.9760 -> 0.7200) + int const titleY = DAT_MenuHandlerState::instance.y + 59; + int const titleX = DAT_MenuHandlerState::instance.x + 400; + 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_MAPEDIT, 21), + titleX, titleY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 16, FALSE, 0); + + // the minimap preview, centred on (x, y) + int x = DAT_MenuHandlerState::instance.x + 600; + int y = DAT_MenuHandlerState::instance.y + 290; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + int mapSize = DAT_TileMapState::instance.mapSize; + if (mapSize == 0) { + mapSize = 400; + } + int const centerX = x; + int const centerY = y; + DAT_MinimapViewState::instance.needsRedraw = TRUE; + char sizeText[20]; + // "%dx%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(sizeText, s__dx_d_005a22fc, mapSize, mapSize); + // x and y move to the preview's top left corner + int previewSize; + switch (mapSize) { + case 100: + x -= 50; + y -= 50; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 100; + break; + case 160: + x -= 80; + y -= 80; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 160; + break; + case 200: + x -= 100; + y -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 200; + break; + case 300: + // drawn at half size + x -= 75; + y -= 75; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, 150, 150); + previewSize = 150; + break; + default: + // 400 is drawn at half size + x -= 100; + y -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, 200, 200); + previewSize = 200; + break; + } + + // a two-pixel black frame around the preview + // default first, as the original lays the arms out; a 100 map gets the default 200 frame + switch (mapSize) { + default: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 100, centerY - 100, centerX + 99, centerY + 100, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 101, centerY - 101, centerX + 100, centerY + 101, COL_BLACK::instance.shortValue); + break; + case 300: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 75, centerY - 75, centerX + 73, centerY + 74, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 76, centerY - 76, centerX + 74, centerY + 75, COL_BLACK::instance.shortValue); + break; + case 200: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 98, centerY - 99, centerX + 99, centerY + 99, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 99, centerY - 100, centerX + 100, centerY + 100, COL_BLACK::instance.shortValue); + break; + case 160: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 78, centerY - 79, centerX + 78, centerY + 77, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 79, centerY - 80, centerX + 79, centerY + 78, COL_BLACK::instance.shortValue); + break; + } + + // the size label at the top right (x += previewSize: quick_diff 0.9760 -> 0.8617) + int const labelX = x + previewSize; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + labelX + - MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)(sizeText, 19) + - 15, + y - 15, labelX, y); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(sizeText, labelX - 5, y - 11, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, OpenSHC::Rendering::Colors::COL_000000, 19, FALSE, 0); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 67687216bc..6da41c36e4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -9165,7 +9165,7 @@ SHC_3BB0A8C1_0x0042FA10 | 0.0% | Pending SHC_3BB0A8C1_0x0042FAA0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0042FAC0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042FAC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042FDD8 | 0.0% | Pending From 13b8a5969dc742fe48d711b4cba1f3d12944dc53 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:28 +0100 Subject: [PATCH 06/10] reimplement: SHC_3BB0A8C1_0x00430150 100.0% Reimplemented MenuView_UnusedChooseGameType_DoEveryFrame draws the screen's title, "Select Game Type" (TEXT_MAPEDIT 27), and a minimap preview of the map at its size, framed twice in black, with the size as text above its top right corner. The body is the one of NewMapMapsize's 0x0042F3F0 with its own title, and the original's instructions are the same but for that text index. Written from the original's instructions, with gynt's draft (7425729fd on his fork's reimpl/UI-MenuViews-development, 83.46% there; earlier 431d154b8 at 64.5% and 27bdc1588 at 63.19%) for the reads: the two switches, the first the original's jump table and the second its sub / je chain with default first, are his. His goto from default into case 200 goes, as both arms written out are merged by MSVC as in the original. Two forms are kept for the register allocation, each with a one-line comment: the title's position in two locals, y first (inline: quick_diff 0.9760 -> 0.7200, x first: 0.9600), and the label's x in its own local (x += previewSize: 0.8617). Also: main's namespace form, as in the sibling Prepare; s__dx_d_005a22fc for "%dx%d" with its text above it; COL_C2F0EB, COL_000000 and TTA_RIGHT for 0xc2f0eb, 0 and -1; needsRedraw = TRUE; decimals for 0x1e, 0x32, 0x3b, 0x122 and the frame offsets; the casts on the frame colour go; the draft's eleven decompiler locals become x, y, centerX, centerY, mapSize, previewSize, sizeText, titleX, titleY and labelX; comments say what is drawn, that x and y become the preview's top left corner and that a 100 map gets the default 200 frame. quick_diff 0.9760 leaves the security cookie, the colour immediate, the jump table's labels and ret / ret 0. This file was measured as it stands in a clean alone build of the branch on main eef6f667a: 100.0% raw, 100.0% normalized. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...View_UnusedChooseGameType_DoEveryFrame.cpp | 160 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp new file mode 100644 index 0000000000..c7ce069880 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp @@ -0,0 +1,160 @@ +#include "../UnusedChooseGameType.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + namespace UnusedChooseGameType { + + // FUNCTION: STRONGHOLDCRUSADER 0x00430150 + void MenuView_UnusedChooseGameType_DoEveryFrame() + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(0, + (DAT_WindowAndDirectDraw::instance.resolutionX + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].width) + / 2, + (DAT_WindowAndDirectDraw::instance.resolutionY + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].height) + / 2); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderBanner, DAT_PencilRenderCore::ptr)( + DAT_MenuHandlerState::instance.x + 100, DAT_MenuHandlerState::instance.y + 30, 600, 50); + // "Select Game Type"; its position named, y first (inline: quick_diff 0.9760 -> 0.7200) + int const titleY = DAT_MenuHandlerState::instance.y + 59; + int const titleX = DAT_MenuHandlerState::instance.x + 400; + 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_MAPEDIT, 27), + titleX, titleY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 16, FALSE, 0); + + // the minimap preview, centred on (x, y) + int x = DAT_MenuHandlerState::instance.x + 600; + int y = DAT_MenuHandlerState::instance.y + 290; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + int mapSize = DAT_TileMapState::instance.mapSize; + if (mapSize == 0) { + mapSize = 400; + } + int const centerX = x; + int const centerY = y; + DAT_MinimapViewState::instance.needsRedraw = TRUE; + char sizeText[20]; + // "%dx%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(sizeText, s__dx_d_005a22fc, mapSize, mapSize); + // x and y move to the preview's top left corner + int previewSize; + switch (mapSize) { + case 100: + x -= 50; + y -= 50; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 100; + break; + case 160: + x -= 80; + y -= 80; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 160; + break; + case 200: + x -= 100; + y -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); + previewSize = 200; + break; + case 300: + // drawn at half size + x -= 75; + y -= 75; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, 150, 150); + previewSize = 150; + break; + default: + // 400 is drawn at half size + x -= 100; + y -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(x, y, 200, 200); + previewSize = 200; + break; + } + + // a two-pixel black frame around the preview + // default first, as the original lays the arms out; a 100 map gets the default 200 frame + switch (mapSize) { + default: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 100, centerY - 100, centerX + 99, centerY + 100, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 101, centerY - 101, centerX + 100, centerY + 101, COL_BLACK::instance.shortValue); + break; + case 300: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 75, centerY - 75, centerX + 73, centerY + 74, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 76, centerY - 76, centerX + 74, centerY + 75, COL_BLACK::instance.shortValue); + break; + case 200: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 98, centerY - 99, centerX + 99, centerY + 99, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 99, centerY - 100, centerX + 100, centerY + 100, COL_BLACK::instance.shortValue); + break; + case 160: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 78, centerY - 79, centerX + 78, centerY + 77, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 79, centerY - 80, centerX + 79, centerY + 78, COL_BLACK::instance.shortValue); + break; + } + + // the size label at the top right (x += previewSize: quick_diff 0.9760 -> 0.8617) + int const labelX = x + previewSize; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + labelX + - MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)(sizeText, 19) + - 15, + y - 15, labelX, y); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(sizeText, labelX - 5, y - 11, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, OpenSHC::Rendering::Colors::COL_000000, 19, FALSE, 0); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6da41c36e4..4f373e2556 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -9627,7 +9627,7 @@ SHC_3BB0A8C1_0x004300F4 | 0.0% | Pending SHC_3BB0A8C1_0x00430100 | 0.0% | Pending -SHC_3BB0A8C1_0x00430150 | 0.0% | Pending +SHC_3BB0A8C1_0x00430150 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00430468 | 0.0% | Pending From 07a8a750decfc03250108655e676452719ba67e1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:28 +0100 Subject: [PATCH 07/10] reimplement: SHC_3BB0A8C1_0x004D8CB0 100.0% Reimplemented MenuView_CrusadeMap_Prepare loads the trail's map picture, keeps each trail's progress within its missions, and counts into DAT_SkirmishTrailRelated1 three less one for each of the current trail's missions so far that was skipped with the chicken, not below 0. From gynt's ba3438802 on his fork's reimpl/UI-MenuViews-development (82.46% there, "Dropped goto restored in trail-type chain"), first written in 75c2542a0 and 387ad8875 (65.9%): the function's reads and stores, the three chicken counts and the trail-type chain are his. Changed here: each count becomes a for loop up to the trail's furthest mission, read once into a const local, behind a test of it, with the counter set before the test and the clamp to 0 inside it: the draft's guard `< 1` compiled to cmp 1 / jl where the original tests the zero register with jle (written `> 0` now), and the original skips the clamp when nothing was counted (quick_diff 0.8686 -> 0.9708). Two shapes stay, each with a one-line comment: the counter outside the for (declared in it, each loop gets a second guard, 91 instructions against the original's 86: quick_diff 0.9379) and a totalLoadedGfx store in each arm (one store after picking the file name, as the original's one store at 0x004D8CE1: 0.9123). Also: 0x31, 0x1d, 0x13 and -0x4b0 are 49, 29, 19 and -1200; the (int) casts on the progress fields and on DAT_SkirmishTrailRelated1, which are int, go; INT_00ed2bdc = FALSE, as main's CrusadeMapAndEndscreen writes it; `+ -1` is a decrement; iVar1 is mission and the furthest mission furthestMission; main's namespace form; the unused using goes; a fixme says the original clamps the warchest progress when the extreme one passes 19 (the store at 0x004D8D22), which the code keeps; the s_ pointers with their text above them. quick_diff 0.9708 leaves the timeGetTime import call, ret / ret 0 and the alignment jump the original has before its third loop. This file was measured as it stands in a clean alone build of the branch on main eef6f667a: 100.0% raw, 100.0% normalized. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuView_CrusadeMap_Prepare.cpp | 105 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/CrusadeMap/MenuView_CrusadeMap_Prepare.cpp diff --git a/src/OpenSHC/UI/MenuViews/CrusadeMap/MenuView_CrusadeMap_Prepare.cpp b/src/OpenSHC/UI/MenuViews/CrusadeMap/MenuView_CrusadeMap_Prepare.cpp new file mode 100644 index 0000000000..059669669e --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/CrusadeMap/MenuView_CrusadeMap_Prepare.cpp @@ -0,0 +1,105 @@ +#include "../CrusadeMap.func.hpp" + +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DWORD_00ed27a8.hpp" +#include "OpenSHC/Globals/DWORD_00ed311c.hpp" +#include "OpenSHC/Globals/INT_00eb9b48.hpp" +#include "OpenSHC/Globals/INT_00ed2bdc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + namespace CrusadeMap { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8CB0 + void MenuView_CrusadeMap_Prepare() + { + DWORD_00ed311c::instance = 0; + // the trail's map (one totalLoadedGfx store after picking the name: quick_diff 0.9708 -> 0.9123) + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + DAT_TextureRenderCoreObject::instance.totalLoadedGfx = 0; + // "shcx_map.tgx" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_shcx_map_tgx_005aafcc); + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + DAT_TextureRenderCoreObject::instance.totalLoadedGfx = 0; + // "skirmish_trail2.tgx" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_skirmish_trail2_tgx_005aafb8); + } else { + DAT_TextureRenderCoreObject::instance.totalLoadedGfx = 0; + // "skirmish_trail.tgx" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_skirmish_trail_tgx_005aafa4); + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::LoadTGX_shc_back)(); + // each trail's progress stays within its 50, 30 and 20 missions + if (DAT_GameCore::instance.skirmishTrailProgress > 49) { + DAT_GameCore::instance.skirmishTrailProgress = 49; + } + if (DAT_GameCore::instance.warchestTrailProgress > 29) { + DAT_GameCore::instance.warchestTrailProgress = 29; + } + // fixme: the original clamps the warchest progress here, not the extreme one + if (DAT_GameCore::instance.extremeTrailProgress > 19) { + DAT_GameCore::instance.warchestTrailProgress = 19; + } + INT_00eb9b48::instance = 1; + DWORD_00ed27a8::instance = timeGetTime(); + // three, less one for each mission of the trail skipped with the chicken (-1200), but not below 0 + DAT_SkirmishTrailRelated1::instance = 3; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { + int const furthestMission = DAT_GameCore::instance.furthestSkirmishTrailMission; + // the counter outside the for (in it: quick_diff 0.9708 -> 0.9379) + int mission = 0; + if (furthestMission > 0) { + for (; mission < furthestMission; ++mission) { + if (DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[mission] == -1200) { + --DAT_SkirmishTrailRelated1::instance; + } + } + if (DAT_SkirmishTrailRelated1::instance < 0) { + DAT_SkirmishTrailRelated1::instance = 0; + } + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + int const furthestMission = DAT_GameCore::instance.furthestWarchestTrailMission; + int mission = 0; + if (furthestMission > 0) { + for (; mission < furthestMission; ++mission) { + if (DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[mission] == -1200) { + --DAT_SkirmishTrailRelated1::instance; + } + } + if (DAT_SkirmishTrailRelated1::instance < 0) { + DAT_SkirmishTrailRelated1::instance = 0; + } + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + int const furthestMission = DAT_GameCore::instance.furthestExtremeTrailMission; + int mission = 0; + if (furthestMission > 0) { + for (; mission < furthestMission; ++mission) { + if (DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[mission] == -1200) { + --DAT_SkirmishTrailRelated1::instance; + } + } + if (DAT_SkirmishTrailRelated1::instance < 0) { + DAT_SkirmishTrailRelated1::instance = 0; + } + } + } + INT_00ed2bdc::instance = FALSE; + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4f373e2556..33088ad467 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36007,7 +36007,7 @@ SHC_3BB0A8C1_0x004D8BB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D8C10 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D8CB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8CB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D8DC0 | 0.0% | Pending From 3b4ae3e511faa3213577da8ff3c8746d6b15a369 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:28 +0100 Subject: [PATCH 08/10] reimplement: SHC_3BB0A8C1_0x004DC9E0 100.0% Reimplemented MenuView_GameLost_DoEveryFrame keeps the game-lost screen up until it may leave: in skirmish and multiplayer, behind the greatest-lord screen, only once BOOLEnum_00ed279c is set (0x004DCA4A to 0x004DCA63); otherwise also once draggingStopped is set, which it sets itself when no video plays, or in a campaign mission 5 seconds after the first frame that gets there. Then it ends both speech streams (SoundSystem::endSpeechStreamsAndResetLoopFlags, 0x00424700, inlined), stops the videos and goes back to the menu the game came from. Written from the original's instructions, with gynt's draft (9df20a956 on his fork's reimpl/UI-MenuViews-development, 65.81% there; earlier 29597e4a6 and 5ddb42266 at 33.9%) for the reads: its returning arms, the extreme / warchest / skirmish order and the inverted MT_ECONOMIC test are his. Changed: one skipStoreSKMasters = 0 at the end in place of a store and a return in each arm, which MSVC copies into the arms itself; with a store in each arm it keeps 0 in ebx all through the function (quick_diff 0.9221 -> 0.6937); the video test before the greatest-lord screen, as the original's jumps run (the other way round: 0.9026); the goto past the leave test is a timedOut flag (the goto measures the same); the builder's map type a switch, as the original's sub / je (if / else: 0.9121); truth tests on the BOOLEnums and on skipStoreSKMasters, except isSkirmishTrail == TRUE, which the original compares with 1. Also: main's namespace form; main's BOOLEnum_00ed279c for INT_00ed279c; the speech streams' flags indexed by SND_STR_SPEECH_1 and _2; NULL for (HBINK)0x0; 0x51, 0x33 and 0x16 are 81, 51 and 22; comments for the SKMasters slots, SelectCrusade_Main's argument, the "Quit Mission" action and the inlined call. quick_diff 0.9221 leaves the timeGetTime import calls and ret / ret 0. This file was measured as it stands in a clean alone build of the branch on main eef6f667a: 100.0% raw, 100.0% normalized. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuView_GameLost_DoEveryFrame.cpp | 169 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_DoEveryFrame.cpp new file mode 100644 index 0000000000..7d41dc1637 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/GameLost/MenuView_GameLost_DoEveryFrame.cpp @@ -0,0 +1,169 @@ +#include "../GameLost.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/Skirmish.func.hpp" +#include "OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/MenuItems/CustomScenarios.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuItems/MainMenu.func.hpp" +#include "OpenSHC/UI/MenuItems/SelectCrusade.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/BOOLEnum_00ed279c.hpp" +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DWORD_00ed27b4.hpp" +#include "OpenSHC/Globals/SEC_SkirmishLobbySetupStructure.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + namespace GameLost { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004DC9E0 + void MenuView_GameLost_DoEveryFrame() + { + // the bink test first (the greatest-lord screen first: quick_diff 0.9221 -> 0.9026) + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + if (DAT_BinkControlState::instance.binkObjPtrArray[0] == NULL) { + DAT_MouseState::instance.draggingStopped = TRUE; + } + } else { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderGreatestLordScreen)(); + } + // in a campaign mission, leave 5 seconds after the first frame that gets here + BOOLEnum timedOut = FALSE; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + && DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER + && DAT_BinkControlState::instance.unknown02_zero[0] != 0) { + if (DWORD_00ed27b4::instance == 0) { + DWORD_00ed27b4::instance = timeGetTime(); + } else if (timeGetTime() - DWORD_00ed27b4::instance > 5000) { + timedOut = TRUE; + } + } + if (!timedOut + && (!DAT_MouseState::instance.draggingStopped + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) + && !BOOLEnum_00ed279c::instance) { + return; + } + + // SoundSystem::endSpeechStreamsAndResetLoopFlags (0x00424700), inlined + DAT_SoundSystemState::instance + .streamFlagsUnkAndLoopCount_0x34[OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2] = 0; + DAT_SoundSystemState::instance + .streamFlagsUnkAndLoopCount_0x34[OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1] = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2); + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopAllBinkPlayback, DAT_BinkControlState::ptr)(); + + // one shared store at the end, as MSVC copies it into each arm (per arm: quick_diff 0.9221 -> 0.6937) + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + // SKMasters slots: 0 custom skirmish, 1-50 skirmish trail, 51-80 warchest, 81-100 extreme + // SelectCrusade_Main: 1 skirmish trail, 2 custom skirmish, 3 warchest, 4 extreme + if (!DAT_GameCore::instance.isSkirmishTrail) { + if (!DAT_GameCore::instance.skipStoreSKMasters) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)(0); + } + MACRO_CALL( + OpenSHC::UI::MenuItems::SelectCrusade_Func::MenuItemActionHandler_SelectCrusade_Main)( + 2); + MACRO_CALL_MEMBER( + OpenSHC::Game::Skirmish::SkirmishLobbySetupStructure_Func::restoreSkirmishLobbySetup, + SEC_SkirmishLobbySetupStructure::ptr)(); + } + // compared with 1, as the original does + if (DAT_GameCore::instance.isSkirmishTrail == TRUE) { + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + if (!DAT_GameCore::instance.skipStoreSKMasters) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.extremeTrailProgress + 81); + } + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(4); + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + if (!DAT_GameCore::instance.skipStoreSKMasters) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.warchestTrailProgress + 51); + } + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(3); + } else { + if (!DAT_GameCore::instance.skipStoreSKMasters) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.skirmishTrailProgress + 1); + } + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(1); + } + } + } else if (DAT_GameSynchronyState::instance.currentGameMode + == OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER) { + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); + } else { + // 7 is the "Quit Mission" action + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)(22); + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER( + OpenSHC::Game::Skirmish::SkirmishLobbySetupStructure_Func::restoreSkirmishLobbySetup, + SEC_SkirmishLobbySetupStructure::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_SHARE_LOBBY_STATE); + } + } + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + MACRO_CALL_MEMBER( + OpenSHC::Game::GameCore_Func::switchToScenarioDescriptionMenuView, DAT_GameCore::ptr)(); + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::exitToScenarioDescriptionMenu, DAT_GameCore::ptr)(); + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + // a switch, as the original's sub / je (if / else: quick_diff 0.9221 -> 0.9121) + switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { + case OpenSHC::Map::MT_ECONOMIC: + MACRO_CALL(OpenSHC::UI::MenuItems::MainMenu_Func::MenuItemActionHandler_MainMenu_Main)(3); + break; + default: + MACRO_CALL( + OpenSHC::UI::MenuItems::CustomScenarios_Func::MenuItemActionHandler_CustomScenarios_Main)( + 4); + break; + } + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + } + DAT_GameCore::instance.skipStoreSKMasters = 0; + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 33088ad467..c3c810f941 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36255,7 +36255,7 @@ SHC_3BB0A8C1_0x004DC1C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DC500 | 0.0% | Pending -SHC_3BB0A8C1_0x004DC9E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004DC9E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DCC70 | 100.0% | Reimplemented From 5ff60ef7a0fe5b29fc3ebd9e52ed96c8c1dc6b69 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 21:09:28 +0100 Subject: [PATCH 09/10] reimplement: SHC_3BB0A8C1_0x004E1E70 100.0% Reimplemented MenuView_Unknown26_CampaignRelatedUnk_DoEveryFrame plays the sequence its Prepare built with BuildIntroLogoSequence (credits-script elements and videos) frame by frame and, once it is over, switches to the next view. From gynt's f4756df68 on his fork's reimpl/UI-MenuViews-development (titled 100.00%): returning after every switchToMenuView and testing missions past 21 first are his; his d40842f2e on top of it only added (int) casts, and only his earlier 288b1cd7d, 0ef5f8b94, faaf06cad and 43d1ef1db went on after the switch. Changed here: early returns in place of his nesting, no iVar1, no casts (the bink counters are int), 21 for 0x15, ++ for the + 1, TRUE for DAT_00b95954 (a BOOLEnum since this branch's first header commit), main's namespace form, and comments: mission 1000 is the intro sequence, and DAT_00b95954 makes switchToMenuView play the end credits' music. quick_diff 0.9057 leaves ret / ret 0. This file was measured as it stands in a clean alone build of the branch on main eef6f667a: 100.0% raw, 100.0% normalized. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nown26_CampaignRelatedUnk_DoEveryFrame.cpp | 81 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/Unknown26/MenuView_Unknown26_CampaignRelatedUnk_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/Unknown26/MenuView_Unknown26_CampaignRelatedUnk_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/Unknown26/MenuView_Unknown26_CampaignRelatedUnk_DoEveryFrame.cpp new file mode 100644 index 0000000000..bfdf068133 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/Unknown26/MenuView_Unknown26_CampaignRelatedUnk_DoEveryFrame.cpp @@ -0,0 +1,81 @@ +#include "../Unknown26.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Rendering.func.hpp" +#include "OpenSHC/UI/Credits.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_00b95954.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_UnknownBinkCount.hpp" +#include "OpenSHC/Globals/DAT_UnknownBinkIndex.hpp" +#include "OpenSHC/Globals/INT_00ed3114.hpp" +#include "OpenSHC/Globals/INT_00ed3144.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + namespace Unknown26 { + + // FUNCTION: STRONGHOLDCRUSADER 0x004E1E70 + void MenuView_Unknown26_CampaignRelatedUnk_DoEveryFrame() + { + if (!MACRO_CALL(OpenSHC::UI::Helpers_Func::TicksSinceCounterStart)()) { + return; + } + if (DAT_MouseState::instance.rightClickStop) { + MACRO_CALL(OpenSHC::UI::Credits_Func::StopCreditsPlaybackAndSounds)(); + } + if (DAT_MouseState::instance.leftClickStart) { + MACRO_CALL(OpenSHC::UI::Credits_Func::EndCreditsSegmentAndAdvanceToNext)(); + } + MACRO_CALL(OpenSHC::Rendering_Func::ProcessCreditsScriptCommands)(); + if (DAT_UnknownBinkIndex::instance < DAT_UnknownBinkCount::instance) { + MACRO_CALL(OpenSHC::Rendering_Func::RenderActiveCreditsElements)(); + } + ++INT_00ed3144::instance; + if (DAT_UnknownBinkIndex::instance < DAT_UnknownBinkCount::instance) { + return; + } + + // the sequence is over: on to the next view + // mission 1000: the intro sequence + if (DAT_GameCore::instance.missionNumber1to20 == 1000) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_INTRO_VIDEO, 0); + return; + } + if (DAT_GameCore::instance.section1066 == 2) { + // past mission 21 first (<= 21 first: quick_diff 0.9057 -> 0.8113) + if (DAT_GameCore::instance.missionNumber1to20 > 21) { + if (INT_00ed3114::instance != 0) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNKNOWN_27_CAMPAIGNUnk, 0); + return; + } + // the end credits (switchToMenuView then plays music 38 instead of 15) + DAT_00b95954::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CREDITS, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNKNOWN_27_CAMPAIGNUnk, 0); + DAT_GameCore::instance.section1066 = 0; + return; + } + if (DAT_GameCore::instance.missionNumber1to20 == 1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNKNOWN_27_CAMPAIGNUnk, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c3c810f941..e9bf73a111 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36385,7 +36385,7 @@ SHC_3BB0A8C1_0x004E1B30 | 0.0% | Pending SHC_3BB0A8C1_0x004E1E30 | 0.0% | Pending -SHC_3BB0A8C1_0x004E1E70 | 0.0% | Pending +SHC_3BB0A8C1_0x004E1E70 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004E1F50 | 0.0% | Pending From a968ec456eb8f05645924dd7f570c5437156de17 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 23:40:54 +0100 Subject: [PATCH 10/10] style: the twins' map sizes by their MapConstants names gynt on #354 asked why a switch used numbers where an enum has names. The NewMapMapsize, UnusedChooseAvailableKeeps and UnusedChooseGameType DoEveryFrame switches now name 160, 200 and 300 as MC_MAP_SIZE_160, _200 and _300, and the default size 400 as MC_MAP_SIZE_400, as main's checkKeepEnclosed does. 100 has no name in MapConstants and stays a number. quick_diff gives all three the same 0.9760 as before (only the cookie, the colour immediate, the jump table's labels and ret / ret 0 differ). No other numeric case or comparison in this branch has an enum: missionNumber1to20 (1000, 1) and section1066 (2) are plain ints. Co-Authored-By: Claude Opus 5.5 --- .../MenuView_NewMapMapsize_DoEveryFrame.cpp | 15 ++++++++------- ...ew_UnusedChooseAvailableKeeps_DoEveryFrame.cpp | 15 ++++++++------- ...MenuView_UnusedChooseGameType_DoEveryFrame.cpp | 15 ++++++++------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp index 558918f4c5..3c03c1c97f 100644 --- a/src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp +++ b/src/OpenSHC/UI/MenuViews/NewMapMapsize/MenuView_NewMapMapsize_DoEveryFrame.cpp @@ -6,6 +6,7 @@ #include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/MapConstants.hpp" #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" @@ -54,7 +55,7 @@ namespace UI { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; int mapSize = DAT_TileMapState::instance.mapSize; if (mapSize == 0) { - mapSize = 400; + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; } int const centerX = x; int const centerY = y; @@ -72,21 +73,21 @@ namespace UI { DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 100; break; - case 160: + case OpenSHC::Map::MC_MAP_SIZE_160: x -= 80; y -= 80; MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 160; break; - case 200: + case OpenSHC::Map::MC_MAP_SIZE_200: x -= 100; y -= 100; MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 200; break; - case 300: + case OpenSHC::Map::MC_MAP_SIZE_300: // drawn at half size x -= 75; y -= 75; @@ -115,7 +116,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 101, centerY - 101, centerX + 100, centerY + 101, COL_BLACK::instance.shortValue); break; - case 300: + case OpenSHC::Map::MC_MAP_SIZE_300: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 75, centerY - 75, centerX + 73, centerY + 74, COL_BLACK::instance.shortValue); @@ -123,7 +124,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 76, centerY - 76, centerX + 74, centerY + 75, COL_BLACK::instance.shortValue); break; - case 200: + case OpenSHC::Map::MC_MAP_SIZE_200: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 98, centerY - 99, centerX + 99, centerY + 99, COL_BLACK::instance.shortValue); @@ -131,7 +132,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 99, centerY - 100, centerX + 100, centerY + 100, COL_BLACK::instance.shortValue); break; - case 160: + case OpenSHC::Map::MC_MAP_SIZE_160: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 78, centerY - 79, centerX + 78, centerY + 77, COL_BLACK::instance.shortValue); diff --git a/src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp index 22b4be3ee5..72e348659c 100644 --- a/src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp +++ b/src/OpenSHC/UI/MenuViews/UnusedChooseAvailableKeeps/MenuView_UnusedChooseAvailableKeeps_DoEveryFrame.cpp @@ -6,6 +6,7 @@ #include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/MapConstants.hpp" #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" @@ -54,7 +55,7 @@ namespace UI { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; int mapSize = DAT_TileMapState::instance.mapSize; if (mapSize == 0) { - mapSize = 400; + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; } int const centerX = x; int const centerY = y; @@ -72,21 +73,21 @@ namespace UI { DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 100; break; - case 160: + case OpenSHC::Map::MC_MAP_SIZE_160: x -= 80; y -= 80; MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 160; break; - case 200: + case OpenSHC::Map::MC_MAP_SIZE_200: x -= 100; y -= 100; MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 200; break; - case 300: + case OpenSHC::Map::MC_MAP_SIZE_300: // drawn at half size x -= 75; y -= 75; @@ -115,7 +116,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 101, centerY - 101, centerX + 100, centerY + 101, COL_BLACK::instance.shortValue); break; - case 300: + case OpenSHC::Map::MC_MAP_SIZE_300: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 75, centerY - 75, centerX + 73, centerY + 74, COL_BLACK::instance.shortValue); @@ -123,7 +124,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 76, centerY - 76, centerX + 74, centerY + 75, COL_BLACK::instance.shortValue); break; - case 200: + case OpenSHC::Map::MC_MAP_SIZE_200: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 98, centerY - 99, centerX + 99, centerY + 99, COL_BLACK::instance.shortValue); @@ -131,7 +132,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 99, centerY - 100, centerX + 100, centerY + 100, COL_BLACK::instance.shortValue); break; - case 160: + case OpenSHC::Map::MC_MAP_SIZE_160: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 78, centerY - 79, centerX + 78, centerY + 77, COL_BLACK::instance.shortValue); diff --git a/src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp index c7ce069880..ba10435f94 100644 --- a/src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp +++ b/src/OpenSHC/UI/MenuViews/UnusedChooseGameType/MenuView_UnusedChooseGameType_DoEveryFrame.cpp @@ -6,6 +6,7 @@ #include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/MapConstants.hpp" #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" @@ -54,7 +55,7 @@ namespace UI { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; int mapSize = DAT_TileMapState::instance.mapSize; if (mapSize == 0) { - mapSize = 400; + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; } int const centerX = x; int const centerY = y; @@ -72,21 +73,21 @@ namespace UI { DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 100; break; - case 160: + case OpenSHC::Map::MC_MAP_SIZE_160: x -= 80; y -= 80; MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 160; break; - case 200: + case OpenSHC::Map::MC_MAP_SIZE_200: x -= 100; y -= 100; MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, DAT_MinimapViewState::ptr)(x, y, mapSize, mapSize); previewSize = 200; break; - case 300: + case OpenSHC::Map::MC_MAP_SIZE_300: // drawn at half size x -= 75; y -= 75; @@ -115,7 +116,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 101, centerY - 101, centerX + 100, centerY + 101, COL_BLACK::instance.shortValue); break; - case 300: + case OpenSHC::Map::MC_MAP_SIZE_300: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 75, centerY - 75, centerX + 73, centerY + 74, COL_BLACK::instance.shortValue); @@ -123,7 +124,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 76, centerY - 76, centerX + 74, centerY + 75, COL_BLACK::instance.shortValue); break; - case 200: + case OpenSHC::Map::MC_MAP_SIZE_200: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 98, centerY - 99, centerX + 99, centerY + 99, COL_BLACK::instance.shortValue); @@ -131,7 +132,7 @@ namespace UI { OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 99, centerY - 100, centerX + 100, centerY + 100, COL_BLACK::instance.shortValue); break; - case 160: + case OpenSHC::Map::MC_MAP_SIZE_160: MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( centerX - 78, centerY - 79, centerX + 78, centerY + 77, COL_BLACK::instance.shortValue);