From 56222fc18db39293bbc3dd621159dc9b56dcc279 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 16:37:05 +0100 Subject: [PATCH 1/8] headers: MC_MAP_SIZE_100 for the 100x100 map size MapConstants names the map sizes 160, 200, 300 and 400 but not 100, which the editor also offers: the map-size switch in MenuView_MapEditorProperties_DoEveryFrame (0x0042E0D0) has cases for 100, 160, 200 and 300, with 400 as its default, and now uses MC_MAP_SIZE_100 there. A new enum value changes no code; the functions that read the map constants measure the same before and after (reccmp, one build with every user on the build list). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/MapConstants.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/Map/MapConstants.hpp b/src/OpenSHC/Map/MapConstants.hpp index 0dfae3f5dc..c893f7867b 100644 --- a/src/OpenSHC/Map/MapConstants.hpp +++ b/src/OpenSHC/Map/MapConstants.hpp @@ -16,6 +16,7 @@ namespace Map { MC_MAP_EAST = 2, // 0x00000002 MC_MAP_SOUTH = 4, // 0x00000004 MC_MAP_WEST = 6, // 0x00000006 + MC_MAP_SIZE_100 = 100, // 0x00000064 MC_MAP_SIZE_160 = 160, // 0x000000A0 MC_MAP_SIZE_200 = 200, // 0x000000C8 MC_MAP_SIZE_300 = 300, // 0x0000012C From 555f12c8c6d787ec43d91b23ce0fe57f3b13034a Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 16:37:05 +0100 Subject: [PATCH 2/8] headers: MenuTextInputState's cursor type, resolution and scroll speed are typed Three undefined4 fields of MenuTextInputState hold values whose type main already has. OptionsMenu's SubOptionsButtons handler (0x00493BD0) fills each of them when it opens the video options, and the VideoOptions render (0x00492170) tests them against that type's values: - menuCursorType (0x50) is a CursorTypeInt: copied from MouseState's cursorType, and compared with CT_ANI_CURSOR and CT_WINDOWS_LIKE_CURSOR to pick each cursor button's highlighted icon. - menuCurrentlySelectedResolution (0x28) is a ScreenResolutionEnumInt: copied from WindowAndDirectDraw's currentGameResolution (a ScreenResolutionEnumInt on main), and switched on with the SRE_ values to pick the resolution text. - menuScrollSpeedSetting (0x34) is a ScrollSpeedInt: copied from ScrollingHandler's scrollSpeedSetting_0x38 (a ScrollSpeedInt on main), and switched on with SS_SLOW, SS_FAST and SS_NORMAL to pick the scroll-speed text. These two are the only reimplemented functions that use the three fields, and both measure the same before and after (reccmp 100.0). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/MenuTextInputState.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/OpenSHC/UI/MenuTextInputState.hpp b/src/OpenSHC/UI/MenuTextInputState.hpp index 3959d4f988..7ec4b5b4fb 100644 --- a/src/OpenSHC/UI/MenuTextInputState.hpp +++ b/src/OpenSHC/UI/MenuTextInputState.hpp @@ -8,12 +8,18 @@ #pragma once +#include "OpenSHC/Rendering/ScreenResolutionEnumInt.hpp" +#include "OpenSHC/UI/Enums/CursorTypeInt.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" #include "OpenSHC/UI/Enums/MenuModalTypeInt.hpp" +#include "OpenSHC/UI/ScrollSpeedInt.hpp" namespace OpenSHC { namespace UI { + using OpenSHC::Rendering::ScreenResolutionEnumInt; + using OpenSHC::UI::ScrollSpeedInt; + using OpenSHC::UI::Enums::CursorTypeInt; using OpenSHC::UI::Enums::MenuModalType; using OpenSHC::UI::Enums::MenuModalTypeInt; @@ -32,10 +38,10 @@ namespace UI { undefined4 savedListOffset3; // 0x0000001C length: 4 undefined4 savedListSelection3; // 0x00000020 length: 4 undefined4 savedListSortOrder3; // 0x00000024 length: 4 - undefined4 menuCurrentlySelectedResolution; // 0x00000028 length: 4 + ScreenResolutionEnumInt menuCurrentlySelectedResolution; // 0x00000028 length: 4 undefined4 unknownZoomRelatedFlag01; // 0x0000002C length: 4 undefined4 pendingGameSpeedLevel; // 0x00000030 length: 4 - undefined4 menuScrollSpeedSetting; // 0x00000034 length: 4 + ScrollSpeedInt menuScrollSpeedSetting; // 0x00000034 length: 4 undefined4 pendingSettingBubbleHelp; // 0x00000038 length: 4 undefined1 pendingUnusedOption1; // 0x0000003C length: 1 undefined1 padding_0x3d[3]; // 0x0000003D length: 3 @@ -43,7 +49,7 @@ namespace UI { undefined4 pendingStreamVolume0; // 0x00000044 length: 4 undefined4 pendingStreamVolume1; // 0x00000048 length: 4 undefined4 pendingStreamVolume3; // 0x0000004C length: 4 - undefined4 menuCursorType; // 0x00000050 length: 4 + CursorTypeInt menuCursorType; // 0x00000050 length: 4 undefined4 DAT_GenieVoiceActiveMenuVar; // 0x00000054 length: 4 undefined4 DAT_MenuOptionsActionParameter; // 0x00000058 length: 4 MenuModalTypeInt currentModalDialog; // 0x0000005C length: 4 From e2ede57b9eb28f0117f0d922a319da72bb4fc650 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 16:37:05 +0100 Subject: [PATCH 3/8] headers: GameCore's trail start dates and historicCampaignNumber are ints skirmishTrailStartDateMonths, warchestTrailStartDateMonths, extremeTrailStartDateMonths and historicCampaignNumber were dword. The original compares them signed: MissionFinishedTransition's DoEveryFrame (0x004DC500) tests `months - StartDateMonths < monthsTaken` with jl (0x004DC6E9, 0x004DC70E, 0x004DC732) and `missionNumber1to20 > historicCampaignNumber * 5` with jle (0x004DC918), which an unsigned field could only give through (int) casts. Every other user on main measures the same after the change (reccmp, one build): playUnitSpeechEffect, incrementMissionProgress, switchToMenuView (98.7 before and after, its call target), readMapOrSavFile, HistoricCampaignSelect's handler, and HistoricCampaignIntro's and HistoricCampaignOutro's Prepare. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Game/GameCore.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/Game/GameCore.hpp b/src/OpenSHC/Game/GameCore.hpp index 85c2d2884c..5e06f1bb4e 100644 --- a/src/OpenSHC/Game/GameCore.hpp +++ b/src/OpenSHC/Game/GameCore.hpp @@ -59,7 +59,7 @@ namespace Game { dword field_0x30; // 0x00000030 length: 4 ActiveMenuTab secondaryActiveMenuTabToSwitchTo; // 0x00000034 length: 4 BuildMenuTabTypeInt tabTypeSiegeSubset; // 0x00000038 length: 4 - dword historicCampaignNumber; // 0x0000003C length: 4 + int historicCampaignNumber; // 0x0000003C length: 4 int missionNumber1to20; // 0x00000040 length: 4 ScenarioProgress scenarioProgress; // 0x00000044 length: 16 int furthestMission; // 0x00000054 length: 4 @@ -172,7 +172,7 @@ namespace Game { int skirmishTrailMonthsTakenOrChicken[50]; // 0x00001DFC length: 200 int skirmishTrailStartDateInMonths[50]; // 0x00001EC4 length: 200 dword skirmishTrailYearReached; // 0x00001F8C length: 4 - dword skirmishTrailStartDateMonths; // 0x00001F90 length: 4 + int skirmishTrailStartDateMonths; // 0x00001F90 length: 4 BOOLEnum isSkirmishTrail; // 0x00001F94 length: 4 int skirmishTrailProgress; // 0x00001F98 length: 4 TrailTypeInt currentTrailType; // 0x00001F9C length: 4 @@ -180,14 +180,14 @@ namespace Game { int warchestTrailMonthsTakenOrChicken[50]; // 0x00001FA4 length: 200 int warchestTrailStartDatesInMonths[50]; // 0x0000206C length: 200 dword warchestTrailYearReached; // 0x00002134 length: 4 - dword warchestTrailStartDateMonths; // 0x00002138 length: 4 + int warchestTrailStartDateMonths; // 0x00002138 length: 4 dword field_0x213c; // 0x0000213C length: 4 int warchestTrailProgress; // 0x00002140 length: 4 int furthestExtremeTrailMission; // 0x00002144 length: 4 int extremeTrailMonthsTakenOrChicken[50]; // 0x00002148 length: 200 int extremeTrailStartDatesInMonths[50]; // 0x00002210 length: 200 dword extremeTrailYearReached; // 0x000022D8 length: 4 - dword extremeTrailStartDateMonths; // 0x000022DC length: 4 + int extremeTrailStartDateMonths; // 0x000022DC length: 4 dword field_0x22e0; // 0x000022E0 length: 4 int extremeTrailProgress; // 0x000022E4 length: 4 int lordIconUnk; // 0x000022E8 length: 4 From c9d90d673aa188676ce645ae80a364703f8ebe7e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 12:36:44 +0100 Subject: [PATCH 4/8] reimplement: SHC_3BB0A8C1_0x0042E0D0 100.0% Reimplemented Rewritten from gynt's draft 86f6e30ef (76.56%, "Map-size dispatch is a switch"), without its gotos and decompiler locals; the behaviour is the same. The forms the original was compiled from, each measured (quick_diff 0.9964, against 0.6978 for the draft built on main; reccmp 100.0): - the header texts' position is read into locals before the single/multiplayer branch, y first, and so are the map name's position in each of its two branches and the clicked-button texts' (inline: 0.7363, 0.8768, 0.8659, 0.9746); - the separators and map-type names write x + 140 / y + 35 at each call: reading the textX / textY locals there measured 0.7615, so a comment says the original reads the position again; - the minimap starts at the centre and each size steps back to its corner (left -= 50, top -= 50), with the centre copied after the map-size default (copied straight after top: 0.9909); - the size label's dimmed box takes the text width as a nested call, so its other arguments are pushed first. The 100 map size is MC_MAP_SIZE_100 (the MapConstants header commit). COL_BLACK's short value is passed uncast, needsRedraw takes TRUE, and the string comments stand above their calls, the TEXT_MAPEDIT entries included ("Multi-Player", "Untitled", "Flag this map as Balanced" / "Un-Balanced", "Invasion", "Economic"). The draft's field44_0xa4 is main's field_0xa4. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...uView_MapEditorProperties_DoEveryFrame.cpp | 317 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_DoEveryFrame.cpp new file mode 100644 index 0000000000..5b95ed19c1 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_DoEveryFrame.cpp @@ -0,0 +1,317 @@ +#include "../MapEditorProperties.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.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/Map/MapConstants.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MapEditorProperties_ClickedButton.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.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_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b95f68.hpp" +#include "OpenSHC/Globals/INT_00b960e4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042E0D0 + void MapEditorProperties::MenuView_MapEditorProperties_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 + 48, DAT_MenuHandlerState::instance.y + 6, 704, 50); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameCore::instance.mapLoadedForEditor) { + // the position in locals, y first, as the original reads it + int const textY = DAT_MenuHandlerState::instance.y + 35; + int const textX = DAT_MenuHandlerState::instance.x + 140; + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { + // "Single-Player" + 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, 12), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + // the separators and map types read the position again, as the original does + switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { + case OpenSHC::Map::MT_SIEGE: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + // "Siege" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 28, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + break; + case OpenSHC::Map::MT_INVASION: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + if (DAT_GameCore::instance.mapU3EndInt == 0) { + // "Invasion" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 29, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + } else { + // "Economic" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 30, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + } + break; + case OpenSHC::Map::MT_ECONOMIC: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + // "Economic" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 30, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + break; + case OpenSHC::Map::MT_JUST_BUILD: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + // "Landscape" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 33, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + break; + } + } else { + // "Multi-Player" + 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, 13), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + } + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s___005a2304, DAT_MenuHandlerState::instance.x + 140, DAT_MenuHandlerState::instance.y + 35, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + if (INT_00b960e4::instance == 0) { + // y and x into locals before the call, as the original reads them + int const nameY = DAT_MenuHandlerState::instance.y + 35; + int const nameX = DAT_MenuHandlerState::instance.x + 140; + // "Untitled" + 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, 24), + nameX, nameY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + } else { + // the position before the name lookup, as the original reads it + int const nameY = DAT_MenuHandlerState::instance.y + 35; + int const nameX = DAT_MenuHandlerState::instance.x + 140; + char* const name = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(2); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + name, nameX, nameY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, + 0); + } + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { + int left = DAT_MenuHandlerState::instance.x; + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { + left += 400; + } else { + left += 600; + } + int top = DAT_MenuHandlerState::instance.y + 240; + int mapSize = DAT_TileMapState::instance.mapSize; + if (mapSize == 0) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; + } + // the centre is copied once the size is settled, as the original does + int const centerX = left; + int const centerY = top; + DAT_MinimapViewState::instance.needsRedraw = TRUE; + char sizeText[20]; + // "%dx%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(sizeText, s__dx_d_005a22fc, mapSize, mapSize); + int width; + switch (mapSize) { + case OpenSHC::Map::MC_MAP_SIZE_100: + left -= 50; + top -= 50; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, mapSize, mapSize); + width = 100; + break; + case OpenSHC::Map::MC_MAP_SIZE_160: + left -= 80; + top -= 80; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, mapSize, mapSize); + width = 160; + break; + case OpenSHC::Map::MC_MAP_SIZE_200: + left -= 100; + top -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, mapSize, mapSize); + width = 200; + break; + case OpenSHC::Map::MC_MAP_SIZE_300: + left -= 75; + top -= 75; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, 150, 150); + width = 150; + break; + default: // 400 (no map size yet) and any other size + left -= 100; + top -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, 200, 200); + width = 200; + break; + } + switch (mapSize) { + 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); + 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 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); + 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 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); + 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; + 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; + } + int const right = width + left; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + right + - MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)(sizeText, 19) + - 15, + top - 15, right, top); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(sizeText, right - 5, top - 11, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); + // each text's position in locals, y first, as the original reads it + if (DAT_MapEditorProperties_ClickedButton::instance == -3) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Flag this map as Balanced" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 45), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + if (DAT_MapEditorProperties_ClickedButton::instance == -4) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Flag this map as Un-Balanced" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 46), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + if (DAT_MapEditorProperties_ClickedButton::instance == -5) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Invasion" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 29), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + if (DAT_MapEditorProperties_ClickedButton::instance == -6) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Economic" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 30), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + } + if (DAT_GameCore::instance.isTimeHalted2 != 0) { + // "Game Paused" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(s_Game_Paused_005a22f0, 798, 576, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_00A2FF, OpenSHC::Rendering::Colors::COL_003E66, 17, FALSE, 0); + } + DAT_MapEditorProperties_ClickedButton::instance = 0; + if (DAT_MenuTextInputState::instance.field_0xa4 != 0) { + INT_00b95f68::instance = 0; + DAT_MenuTextInputState::instance.field_0xa4 = 0; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 507eed8917..573310afae 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8267,7 +8267,7 @@ SHC_3BB0A8C1_0x0042DF40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042DFD0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0042E0D0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042E0D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042E808 | 0.0% | Pending From 198aac9239b3c40a9ff48593ffda3e7caa5d87df Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 12:52:53 +0100 Subject: [PATCH 5/8] reimplement: SHC_3BB0A8C1_0x0042EBC0 100.0% Reimplemented Rewritten from gynt's draft (ea6f9bb59 at 47.9%; his last reimplement commit on the file is 8725ec523 and his last style pass dd1a7c48c; 0.5519 in quick_diff for the draft built on main), with early returns. reccmp 99.4, normalised 100.0: the only difference is the first tail call's target, which goes through the resolver for setScreenMenuSurfaceHeightRangeToResolution (0x0044CD30), not reimplemented yet. Behaviour fix: when the description is not from the string table, the original draws it, resets the surface height range and returns; the draft went on to draw the string-table text as well and reset twice. Forms the original was compiled from, measured (quick_diff 0.9882): the button position is read only after the three conditions; top is computed before right (right first: 0.9704); the lines work from top rather than a local for the button's y (a y local: 0.8798); x - 1 is written at each use (in a local: 0.9436). The first dimmed box and right take the x local (the same code). The parameter is never read, so it is named unused; the colour's short value is passed uncast. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ..._MapEditorProperties_MapDescriptionBox.cpp | 94 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox.cpp diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox.cpp new file mode 100644 index 0000000000..323559ae82 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox.cpp @@ -0,0 +1,94 @@ +#include "../MapEditorProperties.func.hpp" + +#include "OpenSHC/Text/TextManager.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/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042EBC0 + void MapEditorProperties::MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox(int unused, ...) + { + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0 + || DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU + || DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + int const x = DAT_ButtonX::instance; + // top before right, as the original computes them + int const top = DAT_ButtonY::instance + 4; + int const right = DAT_ButtonW::instance + 24 + x; + int const bottom = DAT_ButtonH::instance - 6 + DAT_ButtonY::instance; + int const divider = right - 20; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + x, top, divider, bottom); + int const sideTop = bottom - 35; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + right - 19, sideTop, right, bottom); + // the lines work from top, as the original does, not from the button's y + int const lineTop = top - 1; + // x - 1 at each use, as the original computes it each time + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x - 1, lineTop, right + 1, lineTop, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x - 1, bottom + 1, right + 1, bottom + 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x - 1, top, x - 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right + 1, top, right + 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, top, divider, sideTop, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, top + 20, right, top + 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, bottom - 55, right, bottom - 55, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, sideTop, right, sideTop, COL_VERY_SOFT_YELLOW::instance.shortValue); + if (!DAT_GameCore::instance.mapLoadedForEditor) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRange, + DAT_TextureRenderCoreObject::ptr)( + DAT_ButtonY::instance + 7, DAT_ButtonH::instance - 42 + DAT_ButtonY::instance); + if (!DAT_GameCore::instance.descriptionUseStringTable) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + DAT_GameCore::instance.temporaryTextBufferOfSize1000, DAT_ButtonX::instance + 5, + DAT_ButtonY::instance - DAT_00b960f4::instance + 11, 360, OpenSHC::Rendering::Colors::COL_C2F0EB, + 19, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRangeToResolution, + DAT_TextureRenderCoreObject::ptr)(); + return; + } + if (DAT_GameCore::instance.descriptionStringTableIndex != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText2Unk, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.descriptionStringTableIndex, + DAT_ButtonX::instance + 5, DAT_ButtonY::instance - DAT_00b960f4::instance + 11, 360, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19); + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRangeToResolution, + DAT_TextureRenderCoreObject::ptr)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 573310afae..4af7554964 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8697,7 +8697,7 @@ SHC_3BB0A8C1_0x0042E96A | 0.0% | Pending SHC_3BB0A8C1_0x0042EA59 | 0.0% | Pending -SHC_3BB0A8C1_0x0042EBC0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042EBC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042EDF0 | 100.0% | Reimplemented From e9371a311e4337e8b3fe35f9732890acbd1a1ea6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 13:29:52 +0100 Subject: [PATCH 6/8] reimplement: SHC_3BB0A8C1_0x004DC500 100.0% Reimplemented Rewritten without gotos from gynt's draft (638ed4e59 at 56.76%; 0.6469 in quick_diff for the draft built on main). reccmp 100.0. The decompiler's gotos are MSVC's jump threading over plain if/else chains, so the source is written as those: the wait before leaving uses a flag that MSVC threads away; every exit after it shares the final skipStoreSKMasters = 0 (the early return does not reach it, as in the original); the record-time update and the progress step are two separate dispatches on the trail type; and each trail's step is nested, the progress incremented in both branches (as three separate ifs: quick_diff 0.6224; alive read into a local: 0.8892). The builder branch is a switch on the map type (an if/else: 0.9905). The progress steps are ++; the loop-flag stores before the two endSoundStream calls are indexed by SND_STR_SPEECH_2 and SND_STR_SPEECH_1, being endSpeechStreamsAndResetLoopFlags (0x00424700) written out inline; the trail start dates and historicCampaignNumber need no casts after the GameCore header commit; the Bink handle is compared with NULL and the wait flag is a BOOLEnum. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...MissionFinishedTransition_DoEveryFrame.cpp | 314 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 315 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/MissionFinishedTransition/MenuView_MissionFinishedTransition_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/MissionFinishedTransition/MenuView_MissionFinishedTransition_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/MissionFinishedTransition/MenuView_MissionFinishedTransition_DoEveryFrame.cpp new file mode 100644 index 0000000000..23cf78f4e4 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/MissionFinishedTransition/MenuView_MissionFinishedTransition_DoEveryFrame.cpp @@ -0,0 +1,314 @@ +#include "../MissionFinishedTransition.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/UI/Rendering/TextureRenderCore.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_GameState.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/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/DWORD_00ed27b4.hpp" +#include "OpenSHC/Globals/SEC_SkirmishLobbySetupStructure.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004DC500 + void MissionFinishedTransition::MenuView_MissionFinishedTransition_DoEveryFrame() + { + 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 { + if (DAT_GameSynchronyState::instance.currentGameMode + == OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER) { + 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); + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderGreatestLordScreen)(); + } + // a flag, not a goto: the timed-out path skips the return below + BOOLEnum waitedLongEnough = 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) { + waitedLongEnough = TRUE; + } + } + if (!waitedLongEnough + && (!DAT_MouseState::instance.draggingStopped + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) + && !BOOLEnum_00ed279c::instance) { + return; + } + // endSpeechStreamsAndResetLoopFlags, written out inline + 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)(); + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + 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 TRUE, as the original does + if (DAT_GameCore::instance.isSkirmishTrail == TRUE) { + if (!DAT_GameCore::instance.skipStoreSKMasters) { + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.extremeTrailProgress + 81); + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.warchestTrailProgress + 51); + } else { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.skirmishTrailProgress + 1); + } + } + int progressBefore = DAT_GameCore::instance.skirmishTrailProgress; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + progressBefore = DAT_GameCore::instance.extremeTrailProgress; + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + progressBefore = DAT_GameCore::instance.warchestTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0) { + int const months = DAT_GameState::instance.mapAndTime.month + + DAT_GameState::instance.mapAndTime.year * 12; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + if (months - DAT_GameCore::instance.extremeTrailStartDateMonths + < DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[DAT_GameCore::instance + .extremeTrailProgress] + || DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[DAT_GameCore::instance + .extremeTrailProgress] + < 0) { + DAT_GameCore::instance + .extremeTrailMonthsTakenOrChicken[DAT_GameCore::instance.extremeTrailProgress] + = months - DAT_GameCore::instance.extremeTrailStartDateMonths; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)( + 3); + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + if (months - DAT_GameCore::instance.warchestTrailStartDateMonths + < DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken + [DAT_GameCore::instance.warchestTrailProgress] + || DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[DAT_GameCore::instance + .warchestTrailProgress] + < 0) { + DAT_GameCore::instance + .warchestTrailMonthsTakenOrChicken[DAT_GameCore::instance.warchestTrailProgress] + = months - DAT_GameCore::instance.warchestTrailStartDateMonths; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)( + 2); + } + } else { + if (months - DAT_GameCore::instance.skirmishTrailStartDateMonths + < DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken + [DAT_GameCore::instance.skirmishTrailProgress] + || DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[DAT_GameCore::instance + .skirmishTrailProgress] + < 0) { + DAT_GameCore::instance + .skirmishTrailMonthsTakenOrChicken[DAT_GameCore::instance.skirmishTrailProgress] + = months - DAT_GameCore::instance.skirmishTrailStartDateMonths; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)( + 1); + } + } + } + // each trail's step nested like this, as the original lays out the three trails + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.extremeTrailProgress + >= DAT_GameCore::instance.furthestExtremeTrailMission) { + DAT_GameCore::instance.furthestExtremeTrailMission + = DAT_GameCore::instance.extremeTrailProgress + 1; + if (DAT_GameCore::instance.extremeTrailProgress < 19) { + ++DAT_GameCore::instance.extremeTrailProgress; + } + } else if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.extremeTrailProgress < 19) { + ++DAT_GameCore::instance.extremeTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.extremeTrailProgress == 19 + && progressBefore == DAT_GameCore::instance.extremeTrailProgress) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_ENDSCREEN, 0); + } else { + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(4); + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.warchestTrailProgress + >= DAT_GameCore::instance.furthestWarchestTrailMission) { + DAT_GameCore::instance.furthestWarchestTrailMission + = DAT_GameCore::instance.warchestTrailProgress + 1; + if (DAT_GameCore::instance.warchestTrailProgress < 29) { + ++DAT_GameCore::instance.warchestTrailProgress; + } + } else if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.warchestTrailProgress < 29) { + ++DAT_GameCore::instance.warchestTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.warchestTrailProgress == 29 + && progressBefore == DAT_GameCore::instance.warchestTrailProgress) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_ENDSCREEN, 0); + } else { + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(3); + } + } else { + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.skirmishTrailProgress + >= DAT_GameCore::instance.furthestSkirmishTrailMission) { + DAT_GameCore::instance.furthestSkirmishTrailMission + = DAT_GameCore::instance.skirmishTrailProgress + 1; + if (DAT_GameCore::instance.skirmishTrailProgress < 49) { + ++DAT_GameCore::instance.skirmishTrailProgress; + } + } else if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.skirmishTrailProgress < 49) { + ++DAT_GameCore::instance.skirmishTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.skirmishTrailProgress == 49 + && progressBefore == DAT_GameCore::instance.skirmishTrailProgress) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_ENDSCREEN, 0); + } else { + 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 { + 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) { + DAT_GameCore::instance.gameSuspended = 0; + if (DAT_GameCore::instance.missionNumber1to20 > DAT_GameCore::instance.historicCampaignNumber * 5) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_CAMPAIGN_OUTRO, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_MISSION_PICTURE, 0); + } + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_GameCore::instance.gameSuspended = 0; + if (DAT_GameCore::instance.missionNumber1to20 > 37) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); + } + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + // a switch on the map type, as the original dispatches it + 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 4af7554964..a57cb2e03f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36253,7 +36253,7 @@ SHC_3BB0A8C1_0x004DC140 | 100.0% | Reimplemented, only the loop's end address re SHC_3BB0A8C1_0x004DC1C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004DC500 | 0.0% | Pending +SHC_3BB0A8C1_0x004DC500 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DC9E0 | 100.0% | Reimplemented From 69a3ba260288eda5919150e281f23bbc4690f1f0 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 14:54:33 +0100 Subject: [PATCH 7/8] reimplement: SHC_3BB0A8C1_0x004BBA60 100.0% Reimplemented MenuItemRenderFunction_General_CreateEventCallbackFunction, from the draft #327 (reimpl/UI-MenuItems-3-development, 4967da730, 96.8%; the file's newest commit on the draft is 446f9fa17), itself rewritten from gynt's 4e09857f1 (95.35%). The bandits text now reads its position into `int const textY` then `textX` inside each of the two colour paths: MSVC still merges the two calls into the original's one, and the first push 0 and the " - " text's registers now land where the original has them. With the position written inside the calls it measured 96.8%. reccmp 100.0, normalised 100.0, quick_diff 157/157 at 1.0000. The parameter is textNumInGroup, as main names it in RenderScenarioButtonWithText, which gets the same value. Case 93 sets option = 2 rather than the draft's iconOffset, which holds 2 there (the same code), and a comment marks case 148's fall-through into 146. Behaviour fix kept from #327: a crusader or arabian button that is not the current choice falls back to the default button render; gynt's draft fell through into the bandits case. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...on_General_CreateEventCallbackFunction.cpp | 138 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp new file mode 100644 index 0000000000..6befcb639d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp @@ -0,0 +1,138 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.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/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BBA60 + void General::MenuItemRenderFunction_General_CreateEventCallbackFunction(int textNumInGroup, ...) + { + int option = -1; + int iconOffset = 2; + switch (textNumInGroup) { + case 91: + case 221: + option = 0; + break; + case 92: + case 222: + option = 1; + break; + case 93: + option = 2; + break; + case 94: + option = 3; + break; + case 95: + option = 4; + break; + case 96: + option = 5; + break; + case 97: + option = 6; + break; + case 98: + option = 7; + break; + case 99: + option = 8; + break; + case 157: + option = 9; + break; + case 158: + option = 10; + break; + case 159: + option = 11; + break; + case 160: + option = 12; + break; + case 161: + option = 13; + break; + case 162: + option = 14; + break; + } + switch (textNumInGroup) { + case 221: + case 222: + if (DAT_MapPropertiesState::instance.invasionEventContent.crusaderArabian == option) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + return; + } + break; + case 148: + // drawn as the bandits button with the other icon + textNumInGroup = 146; + iconOffset = 0; + // fall through + case 146: { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // "Bandits"; each path reads its own text position, y first, for the original's merged call + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + int const nameWidth = DAT_TextManagerObject::instance.currentXOffset_0x0; + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s___005a2304, nameWidth / 2 - 15 + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iconOffset + 128, + DAT_ButtonW::instance / 2 - 9 + (DAT_TextManagerObject::instance.currentXOffset_0x0 + nameWidth) / 2 + + DAT_ButtonX::instance, + DAT_ButtonY::instance + 3); + return; + } + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(textNumInGroup); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a57cb2e03f..55e28df73f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29321,7 +29321,7 @@ SHC_3BB0A8C1_0x004BBA20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BBA30 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBA60 | 0.0% | Pending +SHC_3BB0A8C1_0x004BBA60 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BBC64 | 0.0% | Pending From 028d7610eb6f6ae7b442dd0ef0f38369c33c4a84 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 15:38:04 +0100 Subject: [PATCH 8/8] reimplement: SHC_3BB0A8C1_0x00492170 100.0% Reimplemented MenuItemRenderFunction_VideoOptions_Main, from the draft #328 (reimpl/UI-MenuItems-3-development-2, 6325fb75f, 80.4%; the file's newest commit on the draft is a552e96a3), itself gynt's draft (newest gynt reimplement commit on the function: a45757507). Three changes: - The button rows (not pressed, pressed) each make their own text call with their own position, y then x, and the zoom and scroll-speed rows share one call after their switches. MSVC merges the button calls into the original's and puts the push 0s where the original has them; the draft's single shared call with an iVar1/yParam/color set on every path measured 0.9845 in quick_diff. - The resolution cases are written in the original's block order (800x600, 1024x600, 1024x768, 1280x1024, 1600x1200, ...): their blocks differ only in the string, so quick_diff read 1.0000 while reccmp read 81.9 until the order matched. - The first test is `button <= -10`, as the original's `cmp -10; jg`. Behaviour fix: with an unknown resolution, button -1 returns, as the original's jump-table default does (the same `return` as a button that is not -1, 0x0049261E); the draft fell into the zoom switch and drew the zoom text. reccmp 100.0, normalised 100.0, quick_diff 388/388 at 1.0000. The cursor tests use CT_WINDOWS_LIKE_CURSOR and CT_ANI_CURSOR and the scroll-speed cases SS_SLOW, SS_FAST and SS_NORMAL (the fields are typed in the MenuTextInputState header commit). `int icon = 182; if (..) icon += 2;` measured 0.9871, so the icon still starts at 0 and a comment says so. The resolution strings are string-literals.hpp pointers with their comments above the calls, the no-op (int) casts on the int button globals are gone, the parameter is button and the icon and text indices have names. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nuItemRenderFunction_VideoOptions_Main.cpp | 235 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp new file mode 100644 index 0000000000..ab469c4a9d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp @@ -0,0 +1,235 @@ +#include "../VideoOptions.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/CursorType.hpp" +#include "OpenSHC/UI/ScrollSpeed.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00492170 + void VideoOptions::MenuItemRenderFunction_VideoOptions_Main(int button, ...) + { + if (button <= -10) { + // 0 or 2 first, then the base added, as the original computes the icon + int icon = 0; + if (button == -10) { + if (DAT_MenuTextInputState::instance.menuCursorType == OpenSHC::UI::Enums::CT_WINDOWS_LIKE_CURSOR) { + icon = 2; + } + icon += 182; + } else { + if (button != -20) { + return; + } + if (DAT_MenuTextInputState::instance.menuCursorType == OpenSHC::UI::Enums::CT_ANI_CURSOR) { + icon = 2; + } + icon += 183; + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, icon, DAT_ButtonX::instance, DAT_ButtonY::instance); + return; + } + if (button >= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // each path reads its own text position, y first, for the original's merged call + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + 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_GAME_OPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + return; + } + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + 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_GAME_OPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + int textID; + // the negated tests keep the -3 and -2 bodies last, as the original lays them out + if (button != -3) { + if (button != -2) { + if (button != -1) { + return; + } + // the cases in the original's block order + switch (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution) { + case OpenSHC::Rendering::SRE_800x600: + // "800x600" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_800x600_005a7598, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1024x600: + // "1024x600" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1024x600_005a758c, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1024x768: + // "1024x768" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1024x768_005a7580, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1280x1024: + // "1280x1024" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1280x1024_005a7574, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1600x1200: + // "1600x1200" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1600x1200_005a7568, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1280x720: + // "1280x720" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1280x720_005a755c, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1440x900: + // "1440x900" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1440x900_005a7550, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1920x1080: + // "1920x1080" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1920x1080_005a7544, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1920x1200: + // "1920x1200" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1920x1200_005a7538, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_2560x1440: + // "2560x1440" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_2560x1440_005a752c, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_2560x1600: + // "2560x1600" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_2560x1600_005a7520, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1366x768: + // "1366x768" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1366x768_005a7514, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1360x768: + // "1360x768" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1360x768_005a7508, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1680x1050: + // "1680x1050" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1680x1050_005a74fc, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1600x900: + // "1600x900" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1600x900_005a74f0, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + default: + return; + } + } + // the zoom flag's cases, 1 first, as the original tests them + switch (DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01) { + case 1: + // "On" + textID = 13; + break; + case 0: + // "Off" + textID = 14; + break; + default: + return; + } + } else { + // the scroll speed's cases in the reverse of the original's test order + switch (DAT_MenuTextInputState::instance.menuScrollSpeedSetting) { + case OpenSHC::UI::SS_SLOW: + // "Slow" + textID = 19; + break; + case OpenSHC::UI::SS_FAST: + // "Fast" + textID = 21; + break; + case OpenSHC::UI::SS_NORMAL: + // "Normal" + textID = 20; + break; + default: + return; + } + } + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + 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_GAME_OPTIONS, textID), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 55e28df73f..38b5e2f5f4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23453,7 +23453,7 @@ SHC_3BB0A8C1_0x00492080 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492120 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00492170 | 0.0% | Pending +SHC_3BB0A8C1_0x00492170 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492620 | 0.0% | Pending