From 1c0923795b3804b807c762d4b0e99221cd64fcaa Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:37 +0100 Subject: [PATCH 01/11] GameCommandType: add GCT_UNKNOWN_99 RenderSomeMultiplayerInfoUnkDisplayElement28 (0x004B2530) queues command 99: push 0x63 before GameSynchronyState::queueCommand at 0x004B2587 (which the lag notice 0x43 path joins from 0x004B26B0) and at 0x004B2781. These are the exe's only queueCommand calls with 99 (2 of the 11 push 0x63 in .text go to 0x00489100). Ghidra rendered it as GCT_SEND_RESYNC_TILEMAPDATA2 | GCT_CHANGE_RATIONS (64 | 35). The command handler table at 0x00B38E10 holds, at [99], 0x00485650: it sends the 2-byte lagNotificationCode, and on the other machines stores the code and sets DAT_SomeTime = timeGetTime(); [98] is 0x004855C0, which sets laggingPlayerIDUnk and shows display element 28. The enum has no value 99 yet; named like its neighbour GCT_UNKNOWN_98. The values are explicit, so nothing renumbers. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Commands/GameCommandType.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/Commands/GameCommandType.hpp b/src/OpenSHC/Commands/GameCommandType.hpp index d7de0cfac4..d5f01b51d2 100644 --- a/src/OpenSHC/Commands/GameCommandType.hpp +++ b/src/OpenSHC/Commands/GameCommandType.hpp @@ -90,6 +90,7 @@ namespace Commands { GCT_CLOSE_MODAL_DIALOG_FOR_ALL = 94, // 0x0000005E GCT_LEAVE_GAME = 95, // 0x0000005F GCT_UNKNOWN_98 = 98, // 0x00000062 + GCT_UNKNOWN_99 = 99, // 0x00000063 GCT_SHARE_GAME_STATE_PARTIAL_HASHES = 100, // 0x00000064 GCT_SHARE_SYNC_STATUS = 101, // 0x00000065 GCT_UNKNOWN_103 = 103, // 0x00000067 From 610627ecd6d4d3ae687aca406fc874b4a2138ef0 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:37 +0100 Subject: [PATCH 02/11] DAT_00df5644: int instead of undefined4 The tutorial's button-hint speech toggle. Its six accesses are the exe's only ones, all in MenuModalRenderFunction_TutorialBox: reads at 0x004BCD05, 0x004BCD41, 0x004BCE14 and 0x004BCE42, writes at 0x004BCD10 and 0x004BCD17. The compare after the increment is signed (cmp eax, 1; jle at 0x004BCD0D / 0x004BCD15), and the value is used as an index (* 96, + 3). TutorialBox is its only user on main, on this branch and in the exe, and it drops its (int) cast with this. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00df5644.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00df5644.hpp b/src/OpenSHC/Globals/DAT_00df5644.hpp index 0d47e12c86..e36546902f 100644 --- a/src/OpenSHC/Globals/DAT_00df5644.hpp +++ b/src/OpenSHC/Globals/DAT_00df5644.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00DF5644 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF5644) DAT_00df5644; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00DF5644) DAT_00df5644; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF5644); From 826ddaf97d6a8b75bf2661d076c70876507403ce Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:38 +0100 Subject: [PATCH 03/11] MapPropertiesState: SEC_Section1090 and SEC_Section1080 int instead of undefined4 The Win Timer's total and remaining ticks. Every access in the exe is signed: 0x004C3EAE / 0x004C3EB4 (in 0x004C35B0) set both to conditions[39].value * 800 (condition 39 is "Win Timer", text 209), right after showing DEID_TIME_UNTIL_VICTORY at 0x004C3E87; processSingleplayerEvents (0x004C31A0) counts 1080 down at 0x004C343E-4B behind a signed jle; loadMap (0x004C62C0) clears it at 0x004C65D0; the objectives panel's "Time Until Victory" bar (0x004D7990) reads 1090 - 1080 at 0x004D7D1F / 0x004D7D2C with a signed jle and imul 250; cdq; idiv 1090; and RenderTimeUntilVictoryDisplayElement (0x004B1EB0) divides by 1090 with cdq; idiv at 0x004B2060 / 0x004B2066. No function on main uses either field; the victory timer drops its two (int) casts with this. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/MapPropertiesState.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Map/MapPropertiesState.hpp b/src/OpenSHC/Map/MapPropertiesState.hpp index 5aead0c5ec..816bfa225a 100644 --- a/src/OpenSHC/Map/MapPropertiesState.hpp +++ b/src/OpenSHC/Map/MapPropertiesState.hpp @@ -65,8 +65,8 @@ namespace Map { int scenarionMissionType; // 0x00013534 length: 4 MapType2Int SEC_U3_MapType2_1; // 0x00013538 length: 4 MapType2Int scenarioMissionSiegeOrInvasion; // 0x0001353C length: 4 - undefined4 SEC_Section1090; // 0x00013540 length: 4 - undefined4 SEC_Section1080; // 0x00013544 length: 4 + int SEC_Section1090; // 0x00013540 length: 4 + int SEC_Section1080; // 0x00013544 length: 4 undefined4 SEC_Section1081; // 0x00013548 length: 4 undefined1 padding_0x1354c[4]; // 0x0001354C length: 4 int visibleRowCount; // 0x00013550 length: 4 From f6e4e443e63e6119200fb8ef446ef50952c4e793 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:51:33 +0100 Subject: [PATCH 04/11] headers: DAT_00df5564 is a BOOLEnum The tutorial's button-hint flag only ever holds 0 or 1. Its three writers in the exe: 0x004BC728 (= 0, ecx zeroed at 0x004BC6FF), SetTutorialHintActiveWithTimestamp 0x004BC770 (= 1) and UpdateTutorialStepAndProgress 0x004BD2DD (= 0); its readers test it against 0, and INT_00df5648 only ever takes its value (0x004BCDA4). BOOLEnum is a typedef of int, so the size and every access stay the same. Main's two users, SetTutorialHintActiveWithTimestamp and UpdateTutorialStepAndProgress, compile to the same code (measured). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00df5564.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00df5564.hpp b/src/OpenSHC/Globals/DAT_00df5564.hpp index f667751e7a..f1985503ba 100644 --- a/src/OpenSHC/Globals/DAT_00df5564.hpp +++ b/src/OpenSHC/Globals/DAT_00df5564.hpp @@ -8,12 +8,16 @@ #pragma once +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + // GLOBAL: STRONGHOLDCRUSADER 0x00DF5564 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF5564) DAT_00df5564; +using OpenSHC::WindowsHelper::Enums::BOOLEnum; + +MACRO_STRUCT_RESOLVER(BOOLEnum, false, Address::SHC_3BB0A8C1_0x00DF5564) DAT_00df5564; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF5564); From 5a6f1d08e0cba8464e3e44ee6415ba05dfef36e0 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:51:33 +0100 Subject: [PATCH 05/11] MapPropertiesState: SEC_Section1081 is a BOOLEnum The Win Timer's on switch (+0x13548). Every store in the exe is 0 or 1: 1 at 0x004C3EC1 and 0 at 0x004C3EF6 (both in 0x004C35B0, which also sets the timer's ticks), and 0 in loadMap at 0x004C65D6 (ebx, zeroed at 0x004C63D7 and kept across the calls in between). Its readers compare it with 0 (0x004C3436 in processSingleplayerEvents, 0x004C3E93, 0x004C3EE1, 0x004D7D12). No function on main uses the field. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/MapPropertiesState.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/Map/MapPropertiesState.hpp b/src/OpenSHC/Map/MapPropertiesState.hpp index 816bfa225a..2db2c0792e 100644 --- a/src/OpenSHC/Map/MapPropertiesState.hpp +++ b/src/OpenSHC/Map/MapPropertiesState.hpp @@ -67,7 +67,7 @@ namespace Map { MapType2Int scenarioMissionSiegeOrInvasion; // 0x0001353C length: 4 int SEC_Section1090; // 0x00013540 length: 4 int SEC_Section1080; // 0x00013544 length: 4 - undefined4 SEC_Section1081; // 0x00013548 length: 4 + BOOLEnum SEC_Section1081; // 0x00013548 length: 4 undefined1 padding_0x1354c[4]; // 0x0001354C length: 4 int visibleRowCount; // 0x00013550 length: 4 undefined1 padding_0x13554[8]; // 0x00013554 length: 8 From 0c572ca71c2fa26fb46dd78d2e5757e0a54813d3 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:38 +0100 Subject: [PATCH 06/11] reimplement: SHC_3BB0A8C1_0x004AB790 100.0% Reimplemented MenuModalRenderFunction_NewEvent, from gynt's reimpl/UI-MenuModals-development (86.7% there, after main's rename field92_0x170 -> field_0x170). Rewritten on the struct fields: each condition is scenarioEvents[currentEventID].data.scenario.conditions[i] (enabled, subType, value) instead of the draft's *(char*)((int)&...data + (event * 0x39 + i) * 4 + 0xf) casts; his do-while becomes a for with continue; his reused eventIndex local is split into conditionText and eventText, and the end's x = x + 0x9e / eventIndex = y + 0x17c parameter reuse is passed straight into the call; the banner's group is TEXT_SCENARIO; the brackets are the s_brace_close_005a2778 "(" and s_brace_open_005a2774 ")" pointers (the generated names have the two the wrong way round). Comments name the text ranges (conditions 106-125 then 190 on, the four "... Acquired" conditions shown as 113, event actions 128-155 then 177 on) and the condition kinds (1 a resource, 2 a lord). Kept forms: the option's text offset is read into a local after the "(" is drawn (in the call: quick_diff 0.9476 -> 0.8429), and the loop counter (bound countof(...conditions)) is declared before the loop, between rowsDrawn and rowY (declared in the for: 0.9476 -> 0.9372; the original zeroes the counter first, at 0x004AB7BD). quick_diff leaves only ret / ret 0 and the colour constant; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuModalRenderFunction_NewEvent.cpp | 123 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuModals/NewEvent/MenuModalRenderFunction_NewEvent.cpp diff --git a/src/OpenSHC/UI/MenuModals/NewEvent/MenuModalRenderFunction_NewEvent.cpp b/src/OpenSHC/UI/MenuModals/NewEvent/MenuModalRenderFunction_NewEvent.cpp new file mode 100644 index 0000000000..d00f2fc6f5 --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/NewEvent/MenuModalRenderFunction_NewEvent.cpp @@ -0,0 +1,123 @@ +#include "../NewEvent.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AB790 + void NewEvent::MenuModalRenderFunction_NewEvent(int x, int y, int width, int height) + { + // "Event" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, + DAT_PencilRenderCore::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 48, x, y, width, height); + // Lists the event's first seven enabled conditions, each with its parameter and value + int rowsDrawn = 0; + // Declared here, between the other two (declared in the for: quick_diff 0.9476 -> 0.9372) + int conditionIndex = 0; + int rowY = y + 165; + for (; + conditionIndex < countof(DAT_MapPropertiesState::instance.scenarioEvents[0].data.scenario.conditions); + ++conditionIndex) { + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[conditionIndex] + .enabled + == 0) { + continue; + } + // Condition names are texts 106-125, then 190 on; the four "... Acquired" ones all read "Goods + // Acquired" + int conditionText = conditionIndex + 106; + if (conditionText > 125) { + conditionText += 64; + } + if (conditionText == 111 || conditionText == 112 || conditionText == 113 || conditionText == 123) { + conditionText = 113; + } + 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, conditionText), + x + 150, rowY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + // Kind 1: the condition's resource + if (DAT_MissionAestheticsDefinedData::instance.EventConditionParamKind[conditionIndex] == 1) { + int const optionX = x + 158; + // "(" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_close_005a2778, optionX, rowY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + // The option's text offset is read after the "(" (in the call: quick_diff 0.9476 -> 0.8429) + int const optionText = DAT_MissionAestheticsDefinedData::instance + .EventConditionOptionTextOffsets[DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[conditionIndex] + .subType]; + 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, optionText), + optionX, rowY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_open_005a2774, optionX, rowY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + } + // Kind 2: the condition's lord + if (DAT_MissionAestheticsDefinedData::instance.EventConditionParamKind[conditionIndex] == 2) { + int const optionX = x + 158; + // "(" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_close_005a2778, optionX, rowY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + int const optionText + = DAT_MissionAestheticsDefinedData::instance.field_0x170[DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[conditionIndex] + .subType]; + 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, optionText), + optionX, rowY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_open_005a2774, optionX, rowY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[conditionIndex] + .value + * DAT_MissionAestheticsDefinedData::instance.EventConditionValueScale[conditionIndex], + x + 450, rowY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + ++rowsDrawn; + rowY += 24; + if (rowsDrawn >= 7) { + break; + } + } + // Event action names are texts 128-155, then 177 on + int eventText + = DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + + 128; + if (eventText > 155) { + eventText += 21; + } + 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, eventText), + x + 158, y + 380, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6e036f9340..26ca554333 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25555,7 +25555,7 @@ SHC_3BB0A8C1_0x004AB570 | 0.0% | Pending SHC_3BB0A8C1_0x004AB680 | 0.0% | Pending -SHC_3BB0A8C1_0x004AB790 | 0.0% | Pending +SHC_3BB0A8C1_0x004AB790 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004ABA20 | 0.0% | Pending From 998defc99ddcdfea83d897bcdfb540d5b8e087cf Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:39 +0100 Subject: [PATCH 07/11] reimplement: SHC_3BB0A8C1_0x004BCBA0 100.0% Reimplemented MenuModalRenderFunction_TutorialBox, from gynt's reimpl/UI-MenuModals-development (91.6% there, after main's renames field1248_0x41e4 -> field_0x41e4 and field1_0x4 -> field_0x4). What was left were register choices in the text under the frame. The body text's offset is worked out into a local before its call (in the call: quick_diff 0.9764 -> 0.9291), and the button hint's text offset is read into a local for measuring and again in each arm, as the original reloads it from memory there (in the calls: 0.9764 -> 0.9333). The hint is a second test of DAT_00df5564, not an else (else: 0.9764 -> 0.9261); nothing in between writes it (its writers are 0x004BC728, 0x004BC770 and 0x004BD2DD). The centre is width >> 1 + x, as the original has no rounding fix (/ 2: 0.9764 -> 0.8745). quick_diff's 0.9764 is ret / ret 0, the colour constants and the cookie's slot, which reccmp ignores. Restyled: decimal constants, no (int) cast on DAT_00df5644 (int since its header commit), truth tests for the sound checks and for DAT_00df5564 / INT_00df5648 (0/1 only), blendStrength for the draft's keepOffsetX (it goes to the blendStrength parameters; in the one-line hint the original passes it as renderTextToScreen's keepOffsetX and 0 as the blend, push 0 / push ebx at 0x004BCE75 / 0x004BCE77: a fixme line says so), the s__s_s_005aa800 and s_fx_speech__005a64cc pointers for the speech file name, COL_CCFAFF / COL_C2F0EB / COL_0000FF, the plain inner tile's own call explained, the hint's two texts and its 35-pixel height test in a comment. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuModalRenderFunction_TutorialBox.cpp | 150 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp diff --git a/src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp b/src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp new file mode 100644 index 0000000000..673f3de8e2 --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp @@ -0,0 +1,150 @@ +#include "../TutorialBox.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.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/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00df5540.hpp" +#include "OpenSHC/Globals/DAT_00df5544.hpp" +#include "OpenSHC/Globals/DAT_00df5558.hpp" +#include "OpenSHC/Globals/DAT_00df5564.hpp" +#include "OpenSHC/Globals/DAT_00df5644.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_TutorialCurrentStep.hpp" +#include "OpenSHC/Globals/INT_00df5648.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00df5598.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BCBA0 + void TutorialBox::MenuModalRenderFunction_TutorialBox(int x, int y, int width, int height) + { + if (DAT_TutorialCurrentStep::instance >= 32) { + return; + } + int const textX = x + 16; + int const textWidth = width - 32; + int const tutorialTextOffset = INT_ARRAY_00df5598::instance[DAT_TutorialCurrentStep::instance]; + int blendStrength = 0; + if (DAT_00df5540::instance != 0) { + blendStrength = DAT_00df5544::instance; + } + // The frame is drawn in 24 pixel tiles, rounded up to whole tiles + int const boxWidth = ((width - 1) / 24 + 1) * 24; + int const boxHeight = ((height - 1) / 24 + 1) * 24; + for (int offsetY = 0; offsetY < boxHeight; offsetY += 24) { + // Icons 1-3 are the top row's left, inner and right tiles, 7-9 a middle row's and 13-15 the bottom's + int rowBaseIcon; + if (offsetY == 0) { + rowBaseIcon = 1; + } else if (offsetY == boxHeight - 24) { + rowBaseIcon = 13; + } else { + rowBaseIcon = 7; + } + for (int offsetX = 0; offsetX < boxWidth; offsetX += 24) { + int iconIndex = rowBaseIcon; + if (offsetX != 0) { + if (offsetX == boxWidth - 24) { + iconIndex = rowBaseIcon + 2; + } else if (rowBaseIcon == 7) { + // The plain inner tile has its own call (the original pushes 8 and 11 as constants) + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 8, + offsetX + x, offsetY + y, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 11, + blendStrength); + continue; + } else { + iconIndex = rowBaseIcon + 1; + } + } + // Each tile's alpha mask is three icons on + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iconIndex, + offsetX + x, offsetY + y, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iconIndex + 3, + blendStrength); + } + } + // Speaks the button hint once when it comes up, the two recordings taking turns + if (DAT_00df5564::instance && !INT_00df5648::instance) { + ++DAT_00df5644::instance; + if (DAT_00df5644::instance > 1) { + DAT_00df5644::instance = 0; + } + if (!MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, + DAT_SoundSystemState::ptr)(OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1) + && !MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, + DAT_SoundSystemState::ptr)(OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2)) { + char speechFileName[32]; + // "%s%s", "fx\\speech\\" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(speechFileName, s__s_s_005aa800, s_fx_speech__005a64cc, + DAT_MissionAestheticsDefinedData::instance.field_0x41e4[DAT_00df5644::instance + 34][0]); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::playAmbientStreamWithLoop, + DAT_SoundSystemState::ptr)(speechFileName); + } + } + INT_00df5648::instance = DAT_00df5564::instance; + // >> 1 for the centre, as the original has no rounding fix (/ 2: quick_diff 0.9764 -> 0.8745) + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL, tutorialTextOffset), + (width >> 1) + x, y + 15, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, + blendStrength); + int bodyY = y + 38; + if (!DAT_00df5564::instance) { + // The text's offset is worked out before the call (in the call: quick_diff 0.9764 -> 0.9291) + int const bodyTextOffset = DAT_00df5558::instance + 1 + tutorialTextOffset; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL, bodyTextOffset), + textX, bodyY, textWidth, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, blendStrength); + bodyY += DAT_TextManagerObject::instance.field_0x4; + } + // A second test, not an else (else: quick_diff 0.9764 -> 0.9261) + if (DAT_00df5564::instance) { + // Read for measuring and again in each arm (in the calls: quick_diff 0.9764 -> 0.9333) + int const measuredText = DAT_00df5644::instance + 3; + // "That's not a valid option at this time." or "You can't do that at this point in the tutorial.": + // wrapped when taller than 35 pixels (more than one line), centred on one line otherwise + if (MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL_BUTTONS, measuredText), + 0, 0, textWidth, 0, 0, 1) + > 35) { + int const hintText = DAT_00df5644::instance + 3; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL_BUTTONS, hintText), + textX, bodyY, textWidth, OpenSHC::Rendering::Colors::COL_0000FF, 18, blendStrength); + } else { + int const hintText = DAT_00df5644::instance + 3; + // fixme: the original passes the blend as keepOffsetX here, and 0 as the blend + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL_BUTTONS, hintText), + (width >> 1) + x, bodyY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_0000FF, 18, + blendStrength, 0); + } + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderTutorialFloatForUIElement)(DAT_TutorialCurrentStep::instance); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 26ca554333..bce69bbd09 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30169,7 +30169,7 @@ SHC_3BB0A8C1_0x004BCB9D | 0.0% | Pending SHC_3BB0A8C1_0x004BCB9E | 0.0% | Pending -SHC_3BB0A8C1_0x004BCBA0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BCBA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BCEC0 | 100.0% | Reimplemented From 8c45223c7c3ad08dc9fc4ef15f63eb7d5299e3af Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:39 +0100 Subject: [PATCH 08/11] reimplement: SHC_3BB0A8C1_0x004B2530 100.0% Reimplemented RenderSomeMultiplayerInfoUnkDisplayElement28, gynt's code from gynt's reimpl/UI-DisplayElements-pr-development (his work after the closed #249) (99.5% there). It measures reccmp 100.0% unchanged with both resolver sets on, and this commit only restyles it: main's DisplayElements form (a namespace, not a class), the duplicate UI/DisplayElements.func.hpp include dropped, decimal constants, COL_C2F0EB / COL_CCFAFF / COL_7F7F7F, GCT_UNKNOWN_99 (added in its own commit) for the GCT_SEND_RESYNC_TILEMAPDATA2 | GCT_CHANGE_RATIONS that Ghidra made of 99, DWORD const currentTime for _currentTime, own names for the two locals the draft reused (textY/textX for the name, secondsLeft and buttonTextY for the eject button), BVar7 inlined into its if, truth tests for the BOOLEnum results, line comments (the three lag notice texts "Timed Out", "Back in the Game!" and "Ejected"; the countdown is the 60 s drop limit). gynt's nesting stays: early returns for the DAT_SomeTime != 0 and !isHost cases measured quick_diff 0.9395 -> 0.6573 (reccmp 100.0% -> 67.3%). quick_diff is unchanged at 0.9395 (only ret / ret 0, colours and the tail-call jumps); reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...SomeMultiplayerInfoUnkDisplayElement28.cpp | 158 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/DisplayElements/RenderSomeMultiplayerInfoUnkDisplayElement28.cpp diff --git a/src/OpenSHC/UI/DisplayElements/RenderSomeMultiplayerInfoUnkDisplayElement28.cpp b/src/OpenSHC/UI/DisplayElements/RenderSomeMultiplayerInfoUnkDisplayElement28.cpp new file mode 100644 index 0000000000..49ce4b0d79 --- /dev/null +++ b/src/OpenSHC/UI/DisplayElements/RenderSomeMultiplayerInfoUnkDisplayElement28.cpp @@ -0,0 +1,158 @@ +#include "../DisplayElements.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Commands/GameCommandType.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/UI/Enums/DisplayElementID.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace DisplayElements { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B2530 + void RenderSomeMultiplayerInfoUnkDisplayElement28(int posX, int posY, DWORD elementState) + { + DWORD const currentTime = timeGetTime(); + if (DAT_GameCore::instance.mapU4Int0 != 0) { + posY += 65; + } + // Nested, not early returns (early returns: quick_diff 0.9395 -> 0.6573) + if (DAT_GameSynchronyState::instance.DAT_SomeTime == 0) { + if (DAT_GameSynchronyState::instance.isHost) { + if (DAT_GameSynchronyState::instance + .currentPlayerFullIDArray[DAT_GameSynchronyState::instance.laggingPlayerIDUnk] + == -1) { + DAT_GameSynchronyState::instance.DAT_SomeTime = currentTime; + // "Timed Out" + DAT_GameSynchronyState::instance.lagNotificationCode = 65; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_99); + } else if (currentTime + - DAT_GameSynchronyState::instance + .connectionLagInfoArray[DAT_GameSynchronyState::instance.laggingPlayerIDUnk] + .time + <= 10000) { + DAT_GameSynchronyState::instance.DAT_SomeTime = currentTime; + // "Back in the Game!" + DAT_GameSynchronyState::instance.lagNotificationCode = 67; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_99); + } + } + } else if (currentTime - DAT_GameSynchronyState::instance.DAT_SomeTime > 2000) { + DAT_GameSynchronyState::instance.DAT_SomeTime = 0; + DAT_GameSynchronyState::instance.laggingPlayerIDUnk = 0; + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_SOME_MULTIPLAYER_INFO_Unk_28, 0); + return; + } + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderedBoxWithBlendedBackground, + DAT_PencilRenderCore::ptr)(posX - 204, posY, 408, 96); + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + int const textY = posY + 20; + int const textX = posX - 190; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults + .names[DAT_GameSynchronyState::instance.laggingPlayerIDUnk], + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + // ": Not Responding", after the name + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, 64), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + if (DAT_GameSynchronyState::instance.DAT_SomeTime == 0) { + DAT_ButtonX::instance = posX; + DAT_ButtonY::instance = posY + 52; + DAT_ButtonW::instance = 180; + DAT_ButtonH::instance = 28; + if (DAT_GameSynchronyState::instance.isHost) { + // Seconds until the player is dropped (60 s after their last message), shown as 50 at most + int secondsLeft = 60 + - (currentTime + - DAT_GameSynchronyState::instance + .connectionLagInfoArray[DAT_GameSynchronyState::instance.laggingPlayerIDUnk] + .time) + / 1000; + if (secondsLeft > 50) { + secondsLeft = 50; + } else if (secondsLeft < 0) { + secondsLeft = 0; + } + int const buttonTextY = posY + 58; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(secondsLeft, posX - 102, buttonTextY, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + if (MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::isMouseInsideBox, DAT_MouseState::ptr)( + posX - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX, + posY - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + 52, 180, + 28)) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // "Eject", highlighted + 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_XPLAY_WAITING_ROOM, 91), + posX + 90, buttonTextY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE, 0); + if (!DAT_MouseState::instance.leftClickStart) { + return; + } + DAT_GameSynchronyState::instance.DAT_SomeTime = timeGetTime(); + // "Ejected" + DAT_GameSynchronyState::instance.lagNotificationCode = 66; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_99); + return; + } + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // "Eject" + 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_XPLAY_WAITING_ROOM, 91), + posX + 90, buttonTextY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE, 0); + return; + } + // "Eject", greyed out: only the host can eject + 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_XPLAY_WAITING_ROOM, 91), + posX + 90, posY + 58, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_7F7F7F, 18, FALSE, + 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, + DAT_GameSynchronyState::instance.lagNotificationCode), + posX, posY + 58, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index bce69bbd09..58bebc8fc1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26005,7 +26005,7 @@ SHC_3BB0A8C1_0x004B20B0 | 83.1% | shared arm fold direction SHC_3BB0A8C1_0x004B2280 | 0.0% | Pending -SHC_3BB0A8C1_0x004B2530 | 0.0% | Pending +SHC_3BB0A8C1_0x004B2530 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B2820 | 0.0% | Pending From 6c00ef2229c27686a5acd575852e402b46d878a4 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:40 +0100 Subject: [PATCH 09/11] reimplement: SHC_3BB0A8C1_0x004B1EB0 100.0% Reimplemented RenderTimeUntilVictoryDisplayElement, from gynt's reimpl/UI-DisplayElements-pr-development (his work after the closed #249) (98.1% there). The only difference was the operand order of three lea instructions: with a centre local of its own (gynt's iVar1) MSVC writes [half + posX] where the original has [posX + half]. posX itself becomes the bar's centre (a centre local: quick_diff 0.9810 -> 0.9620; the rest is ret / ret 0 and the colour constant). The bar's left edge is written out at each use, as in the defeat timer (a tie with a local). Restyled to main's DisplayElements form (a namespace, not a class) like RenderNoRushDisplayElementUnk: decimal constants and posX -= N (the 14 offsets are (screen width - 800) / 2), barWidth and halfWidth for iVar4 and iVar3, the xParam/yParam copies, the colour casts and the (int) casts dropped (SEC_Section1090/1080 are int since their header commit), posX += 10 + halfWidth, COL_C2F0EB. DAT_00df4290 is this bar's width + 16, which RenderTimeUntilDefeatDisplayElement adds to its own position. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../RenderTimeUntilVictoryDisplayElement.cpp | 99 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/DisplayElements/RenderTimeUntilVictoryDisplayElement.cpp diff --git a/src/OpenSHC/UI/DisplayElements/RenderTimeUntilVictoryDisplayElement.cpp b/src/OpenSHC/UI/DisplayElements/RenderTimeUntilVictoryDisplayElement.cpp new file mode 100644 index 0000000000..51ec553e90 --- /dev/null +++ b/src/OpenSHC/UI/DisplayElements/RenderTimeUntilVictoryDisplayElement.cpp @@ -0,0 +1,99 @@ +#include "../DisplayElements.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.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/DisplayElementID.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_00df4290.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace DisplayElements { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B1EB0 + void RenderTimeUntilVictoryDisplayElement(int posX, int posY, DWORD elementState) + { + if (DAT_GameCore::instance.section1095 == 2) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_TIME_UNTIL_VICTORY, 0); + return; + } + // "Time Until Victory" + int const barWidth + = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 25), + 18); + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // Centred for an 800-pixel-wide layout: shifted left by (width - 800) / 2 + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { + posX -= 112; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { + posX -= 240; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { + posX -= 400; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { + posX -= 240; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) { + posX -= 320; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { + posX -= 560; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) { + posX -= 560; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { + posX -= 880; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { + posX -= 880; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) { + posX -= 283; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { + posX -= 440; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) { + posX -= 400; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x600) { + posX -= 112; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) { + posX -= 280; + } + int const halfWidth = barWidth / 2; + // Read by RenderTimeUntilDefeatDisplayElement, which draws its bar to the right of this one + DAT_00df4290::instance = barWidth + 16; + // posX becomes the bar's centre (a centre local: quick_diff 0.9810 -> 0.9620) + posX += 10 + halfWidth; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(posX - halfWidth - 7, posY - 5, halfWidth + 5 + posX, posY + 30, 16); + // "Time Until Victory" + 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_OBJECTIVES, 25), + posX, posY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + posX - halfWidth - 1, posY + 18, halfWidth + 1 + posX, posY + 24, COL_BLACK::instance.shortValue); + if (DAT_MapPropertiesState::instance.SEC_Section1080 != DAT_MapPropertiesState::instance.SEC_Section1090) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(posX - halfWidth, posY + 19, + ((DAT_MapPropertiesState::instance.SEC_Section1090 + - DAT_MapPropertiesState::instance.SEC_Section1080) + * barWidth) + / DAT_MapPropertiesState::instance.SEC_Section1090 + - halfWidth + posX, + posY + 23, COL_DARK_LIME::instance.shortValue); + } + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 58bebc8fc1..151154a3ac 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25999,7 +25999,7 @@ SHC_3BB0A8C1_0x004B1D90 | 0.0% | Pending SHC_3BB0A8C1_0x004B1E60 | 0.0% | Pending -SHC_3BB0A8C1_0x004B1EB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B1EB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B20B0 | 83.1% | shared arm fold direction From a6e13e2a6779e0a0399dceb71a9b52b0c16b1975 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 02:28:41 +0100 Subject: [PATCH 10/11] reimplement: SHC_3BB0A8C1_0x004B2280 100.0% Reimplemented RenderTimeUntilDefeatDisplayElement, from gynt's reimpl/UI-DisplayElements-pr-development (his work after the closed #249) (70.9% there). The original keeps the half width (edx) live across the first GetIfDisplayElementStateNotZero call and the month ticks (edx) across the second, which needs LTCG: this file, GetIfDisplayElementStateNotZero.cpp and its callee FindDisplayElementWithID.cpp go into cmake/compiler-flags-gl.txt. With the caller alone, or the caller and GetIfDisplayElementStateNotZero, it stays at 79.6%; all three give 91.1%, and both callees stay at 100.0%. The rest was a register rotation from a left local; the bar's left edge is written out as posX - halfWidth at each use (a left local: reccmp 100.0% -> 91.1%). posX becomes the bar's centre (posX += 10 + halfWidth), as in RenderTimeUntilVictoryDisplayElement (a centre local: reccmp 100.0% -> 98.5%), and the file is restyled like that one, with deadlineTicks, elapsedMonthTicks and ticksLeft for iVar4, iVar5 and local_c. None of the other callers of the two callees (switchToMenuView, updateDateAndTime, MainButtons and four DisplayElements) is in /GL, so their own code does not change: switchToMenuView reads 98.7% and MainButtons 99.8% raw here (100.0% normalized, call targets only), and main's status lines have both at 100.0%. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- cmake/compiler-flags-gl.txt | 3 + .../RenderTimeUntilDefeatDisplayElement.cpp | 127 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/DisplayElements/RenderTimeUntilDefeatDisplayElement.cpp diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 7a4a662301..2110779750 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -115,3 +115,6 @@ src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAn src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_GatehouseOpenClose.cpp src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_WorkshopWeaponSelection.cpp src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface.cpp +src/OpenSHC/UI/DisplayElements/RenderTimeUntilDefeatDisplayElement.cpp +src/OpenSHC/UI/DisplayElements/GetIfDisplayElementStateNotZero.cpp +src/OpenSHC/UI/DisplayElements/FindDisplayElementWithID.cpp diff --git a/src/OpenSHC/UI/DisplayElements/RenderTimeUntilDefeatDisplayElement.cpp b/src/OpenSHC/UI/DisplayElements/RenderTimeUntilDefeatDisplayElement.cpp new file mode 100644 index 0000000000..ed263da13d --- /dev/null +++ b/src/OpenSHC/UI/DisplayElements/RenderTimeUntilDefeatDisplayElement.cpp @@ -0,0 +1,127 @@ +#include "../DisplayElements.func.hpp" + +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.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/DisplayElementID.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_00df4290.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace DisplayElements { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B2280 + void RenderTimeUntilDefeatDisplayElement(int posX, int posY, DWORD elementState) + { + if (DAT_GameCore::instance.section1095 == 2) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_TIME_UNTIL_DEFEAT, 0); + return; + } + // "Time Until Defeat" + int const barWidth + = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 17), + 18); + // Centred for an 800-pixel-wide layout: shifted left by (width - 800) / 2 + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { + posX -= 112; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { + posX -= 240; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { + posX -= 400; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { + posX -= 240; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) { + posX -= 320; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { + posX -= 560; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) { + posX -= 560; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { + posX -= 880; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { + posX -= 880; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) { + posX -= 283; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { + posX -= 440; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) { + posX -= 400; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x600) { + posX -= 112; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) { + posX -= 280; + } + int const halfWidth = barWidth / 2; + // posX becomes the bar's centre (a centre local: reccmp 100.0% -> 98.5%) + posX += 10 + halfWidth; + // Drawn right of the victory timer's bar when both are shown + if (MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + OpenSHC::UI::Enums::DEID_TIME_UNTIL_VICTORY)) { + posX += DAT_00df4290::instance; + } + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // The bar's left edge is written out at each use (a left local: reccmp 100.0% -> 91.1%) + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(posX - halfWidth - 7, posY - 5, halfWidth + 5 + posX, posY + 30, 16); + // "Time Until Defeat" + 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_OBJECTIVES, 17), + posX, posY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 18, FALSE, 0); + int const eventID + = MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::getEventIDForTimeUntilDefeatEventType, + DAT_MapPropertiesState::ptr)(); + int const startMonths = DAT_MapPropertiesState::instance.SEC_StartingMonth + + DAT_MapPropertiesState::instance.SEC_StartingYear * 12; + // A month is 800 ticks (4 weeks of 200) + int const deadlineTicks + = (DAT_MapPropertiesState::instance.scenarioEvents[eventID].header.month + + DAT_MapPropertiesState::instance.scenarioEvents[eventID].header.year * 12 - startMonths) + * 800; + int const elapsedMonthTicks = (DAT_GameState::instance.mapAndTime.year * 12 - startMonths + + DAT_GameState::instance.mapAndTime.month) + * 800; + // While time is halted, or the keep placement hint is up, only whole months count + int ticksLeft; + if (!DAT_GameCore::instance.isTimeHalted + && !MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO)) { + ticksLeft = deadlineTicks - DAT_GameState::instance.mapAndTime.week * 200 + - DAT_GameState::instance.gameTicksLoadBalancer - elapsedMonthTicks; + } else { + ticksLeft = deadlineTicks - elapsedMonthTicks; + } + if (ticksLeft < 0) { + ticksLeft = 0; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + posX - halfWidth - 1, posY + 18, halfWidth + 1 + posX, posY + 24, COL_BLACK::instance.shortValue); + if (ticksLeft != deadlineTicks) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(posX - halfWidth, posY + 19, + ((deadlineTicks - ticksLeft) * barWidth) / deadlineTicks - halfWidth + posX, posY + 23, + COL_DARK_LIME::instance.shortValue); + } + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 151154a3ac..98e48917aa 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26003,7 +26003,7 @@ SHC_3BB0A8C1_0x004B1EB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B20B0 | 83.1% | shared arm fold direction -SHC_3BB0A8C1_0x004B2280 | 0.0% | Pending +SHC_3BB0A8C1_0x004B2280 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B2530 | 100.0% | Reimplemented From 8b02cf21f4571fb9622da4758db722dedfb8204c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 17:45:43 +0100 Subject: [PATCH 11/11] MenuModalRenderFunction_TutorialBox: use main's INT_00df5564 and INT_00df5644 gynt's header sync (eef6f667a) renamed DAT_00df5564 to INT_00df5564 and DAT_00df5644 to INT_00df5644, both int; this branch had typed the first a BOOLEnum (f6e4e443e), and the merge before takes main's. The function only tests INT_00df5564 for truth and copies it into INT_00df5648, so the new names are all it needs. reccmp 100.0%. Co-Authored-By: Claude Opus 5.5 --- .../MenuModalRenderFunction_TutorialBox.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp b/src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp index 673f3de8e2..23239f73cc 100644 --- a/src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp +++ b/src/OpenSHC/UI/MenuModals/TutorialBox/MenuModalRenderFunction_TutorialBox.cpp @@ -16,13 +16,13 @@ #include "OpenSHC/Globals/DAT_00df5540.hpp" #include "OpenSHC/Globals/DAT_00df5544.hpp" #include "OpenSHC/Globals/DAT_00df5558.hpp" -#include "OpenSHC/Globals/DAT_00df5564.hpp" -#include "OpenSHC/Globals/DAT_00df5644.hpp" #include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" #include "OpenSHC/Globals/DAT_SoundSystemState.hpp" #include "OpenSHC/Globals/DAT_TextManagerObject.hpp" #include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" #include "OpenSHC/Globals/DAT_TutorialCurrentStep.hpp" +#include "OpenSHC/Globals/INT_00df5564.hpp" +#include "OpenSHC/Globals/INT_00df5644.hpp" #include "OpenSHC/Globals/INT_00df5648.hpp" #include "OpenSHC/Globals/INT_ARRAY_00df5598.hpp" @@ -80,10 +80,10 @@ namespace UI { } } // Speaks the button hint once when it comes up, the two recordings taking turns - if (DAT_00df5564::instance && !INT_00df5648::instance) { - ++DAT_00df5644::instance; - if (DAT_00df5644::instance > 1) { - DAT_00df5644::instance = 0; + if (INT_00df5564::instance && !INT_00df5648::instance) { + ++INT_00df5644::instance; + if (INT_00df5644::instance > 1) { + INT_00df5644::instance = 0; } if (!MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, DAT_SoundSystemState::ptr)(OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1) @@ -92,12 +92,12 @@ namespace UI { char speechFileName[32]; // "%s%s", "fx\\speech\\" MACRO_CALL(OpenSHC::OS_Func::_sprintf)(speechFileName, s__s_s_005aa800, s_fx_speech__005a64cc, - DAT_MissionAestheticsDefinedData::instance.field_0x41e4[DAT_00df5644::instance + 34][0]); + DAT_MissionAestheticsDefinedData::instance.field_0x41e4[INT_00df5644::instance + 34][0]); MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::playAmbientStreamWithLoop, DAT_SoundSystemState::ptr)(speechFileName); } } - INT_00df5648::instance = DAT_00df5564::instance; + INT_00df5648::instance = INT_00df5564::instance; // >> 1 for the centre, as the original has no rounding fix (/ 2: quick_diff 0.9764 -> 0.8745) MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, @@ -105,7 +105,7 @@ namespace UI { (width >> 1) + x, y + 15, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, blendStrength); int bodyY = y + 38; - if (!DAT_00df5564::instance) { + if (!INT_00df5564::instance) { // The text's offset is worked out before the call (in the call: quick_diff 0.9764 -> 0.9291) int const bodyTextOffset = DAT_00df5558::instance + 1 + tutorialTextOffset; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( @@ -115,9 +115,9 @@ namespace UI { bodyY += DAT_TextManagerObject::instance.field_0x4; } // A second test, not an else (else: quick_diff 0.9764 -> 0.9261) - if (DAT_00df5564::instance) { + if (INT_00df5564::instance) { // Read for measuring and again in each arm (in the calls: quick_diff 0.9764 -> 0.9333) - int const measuredText = DAT_00df5644::instance + 3; + int const measuredText = INT_00df5644::instance + 3; // "That's not a valid option at this time." or "You can't do that at this point in the tutorial.": // wrapped when taller than 35 pixels (more than one line), centred on one line otherwise if (MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, @@ -126,14 +126,14 @@ namespace UI { DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL_BUTTONS, measuredText), 0, 0, textWidth, 0, 0, 1) > 35) { - int const hintText = DAT_00df5644::instance + 3; + int const hintText = INT_00df5644::instance + 3; MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_TUTORIAL_BUTTONS, hintText), textX, bodyY, textWidth, OpenSHC::Rendering::Colors::COL_0000FF, 18, blendStrength); } else { - int const hintText = DAT_00df5644::instance + 3; + int const hintText = INT_00df5644::instance + 3; // fixme: the original passes the blend as keepOffsetX here, and 0 as the blend MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset,