From 5a9422dd69e2db817dfe2adbf54a4a4ea05bed07 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 00:53:15 +0100 Subject: [PATCH 1/2] reimplement: SHC_3BB0A8C1_0x0047C860 100.0% Reimplemented ChooseNetworkServiceProvider::MenuModalRenderFunction_ChooseNetworkServiceProvider, moved out of our draft #360 (54856921d6, 65.1%), from Gynt's draft (968b1ee68 at 65.32% on his fork's reimpl/UI-MenuModals-development; his closed #252 had an earlier version). One behaviour fix against his draft, already in #360: the modem tab's second box reaches from y + 265 to y + 345; his draft moved y on to the bottom first and then drew the top at y + 265 from there (y + 610). The original takes the top first (0x0047C9C5), as sourcehold's reimpl/UI-MenuModals has it and as this does. Both frames, the list's (y + 85 to y + 165) and the modem tab's (y + 265 to y + 345), run from x + 40 to x + 460: the outline is one pixel outside that (x + 39 to x + 461), and the dimmed box ends at the scroll bar's column line at x + 440. Each is written in a block with its four edges as int const locals (left = x + 40, top, right = x + 460, bottom) and every coordinate written from them. The original keeps each frame's top in ebx (0x0047C907, 0x0047C9C5). In the list's frame it keeps the left edge less 1 in y's stack slot (0x0047C91C, read back at 0x0047C934, 0x0047C94A and 0x0047C96E) and computes x + 461 again for each line that uses it; in the modem box's it keeps x + 440 in that slot (0x0047C9E3) and x + 461 in esi (0x0047C9F8). In the draft x and y swapped esi and edi, and x + 440 kept ebx, where the original keeps the list's top (quick_diff 0.6780, 177 instructions against 177). With only the list's frame in a block, the modem box's top and left edge swap ebx and ebp (0.9435); with both blocks the listing is the original's (1.0000). Both orders tried for the edges (left, top, right, bottom and right, left, top, bottom) give the same listing, and so does int without const. A comment on each block says why it is one. On main since #387 drawHeaderTextBanner takes an eTextSections: the banner's 76 is TEXT_MULTIPLAYER_CONNECTION. y - 0x3c is written y - 60, and the kick timer's test the other way round (timeGetTime() - kickedAtTime > 5000), with the same listing; an unused include is dropped, and so are the casts on the lines' colour (the same listing). Gynt's newest commit on the file, af1d7904a1 on his reimpl/UI-MenuItems-development (2026-11-02, 45.8% there), writes that test as `DVar2 > 5000 - kickedAtTime`, which is a different test; the original subtracts first (`sub eax`, `cmp eax, 0x1388`, `jbe`), as this does. No line for cmake/compiler-flags-gl.txt: the file reads 100.0% off the /GL list, and 100.0% on it too. reccmp in a build of main's whole /GL list (the 133 files that exist) and this file, off the list, with every resolver of those files on: 144 functions, average 99.56. The function 100.0% raw and normalised, no differing line; the other 143 functions read the same as without the file. That build had the casts, the include and shorter comments; quick_diff gives the same 177 instructions, line for line, for this text. The sources were main's at 3458fea34; main's commits since add cmake files and tools, and two other UI functions' files (#466, #467). Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 Co-Authored-By: Claude Opus 5.5 --- ...rFunction_ChooseNetworkServiceProvider.cpp | 83 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuModals/ChooseNetworkServiceProvider/MenuModalRenderFunction_ChooseNetworkServiceProvider.cpp diff --git a/src/OpenSHC/UI/MenuModals/ChooseNetworkServiceProvider/MenuModalRenderFunction_ChooseNetworkServiceProvider.cpp b/src/OpenSHC/UI/MenuModals/ChooseNetworkServiceProvider/MenuModalRenderFunction_ChooseNetworkServiceProvider.cpp new file mode 100644 index 0000000000..b354d9f3da --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/ChooseNetworkServiceProvider/MenuModalRenderFunction_ChooseNetworkServiceProvider.cpp @@ -0,0 +1,83 @@ +#include "../ChooseNetworkServiceProvider.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/UI/Enums/BuildingsAndStatusMenuTabType.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047C860 + void ChooseNetworkServiceProvider::MenuModalRenderFunction_ChooseNetworkServiceProvider( + int x, int y, int width, int height) + { + // "Service Providers" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, + DAT_PencilRenderCore::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, 6, x, y, width, height); + if (DAT_GameSynchronyState::instance.kickedAtTime != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(x, y - 60, x + width, y - 18, 16); + // "You Were Ejected!" + 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, 92), + width / 2 + x, y - 50, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 16, FALSE, + 0); + if (timeGetTime() - DAT_GameSynchronyState::instance.kickedAtTime > 5000) { + DAT_GameSynchronyState::instance.kickedAtTime = 0; + } + } + // the list: a dimmed box, its outline and the scroll bar's column, every coordinate from the four edges in + // a block of their own: with only the top, the bottom and left - 1 as locals, x and y swap registers + { + int const left = x + 40; + int const top = y + 85; + int const right = x + 460; + int const bottom = y + 165; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + left, top, right - 20, bottom); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top - 1, right + 1, top - 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 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)( + left - 1, top, left - 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)( + right - 20, top, right - 20, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + } + if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM) { + // the modem's box below it, drawn the same way, from its own four edges: with y moved on to the + // bottom and x to the outline's right edge, the box's top and left edge get each other's registers + int const left = x + 40; + int const top = y + 265; + int const right = x + 460; + int const bottom = y + 345; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + left, top, right - 20, bottom); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top - 1, right + 1, top - 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 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)( + left - 1, top, left - 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)( + right - 20, top, right - 20, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + } + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e8a6864d03..37d7e54311 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22253,7 +22253,7 @@ SHC_3BB0A8C1_0x0047C5D0 | 0.0% | Pending SHC_3BB0A8C1_0x0047C670 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0047C860 | 0.0% | Pending +SHC_3BB0A8C1_0x0047C860 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047CA80 | 100.0% | Reimplemented From 11d13f1041f01386d9db3880f471d3c8a8e50713 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 01:22:17 +0100 Subject: [PATCH 2/2] reimplement: SHC_3BB0A8C1_0x0047D190 100.0% Reimplemented FindingNetworkSessions::MenuModalRenderFunction_FindingNetworkSessions, moved out of our draft #360 (e01e70978b, 66.9%), from Gynt's draft (9ae7d0b858 at 66.91% on his fork's reimpl/UI-MenuModals-development, "orig spills one local"; before it 57.97% at e4d0a089b4, 58.30% at 861024c3ac and 39.1% at 4462f5d847 / 70f15af837; his closed #252 had an earlier version). The draft computes what the original computes; no behaviour is changed against it. The session list's frame (a dimmed box, its outline, the scroll bar's column and the column's two squares) is written in a block with its four edges as int const locals, declared left, top, right, bottom (left = x + 40, top = y + 85, right = x + 460, bottom = y + 285), and every coordinate is written from them. That is how the original computes them: x's register becomes the right edge (add ebp, 0x1cc at 0x0047D1C7) and y's the bottom (add edi, 0x11d at 0x0047D1CD), and the left edge less 1 is taken from x's stack slot (0x0047D1EB, 0x0047D1F8) and kept in a slot of its own (0x0047D1FC). In the draft, with the top, the bottom, the right edge and the outline's two edges (right + 1, x + 39) as locals and the box's left edge written out, the right edge did not take x's register, x was not read again, and the function came out four instructions shorter, without the 4-byte frame (quick_diff 0.6691, 134 instructions against 138). Of the 24 declaration orders, the three with left before right, top before bottom and right before bottom give the original's listing (left, top, right, bottom as here; top, left, right, bottom; left, right, top, bottom). The other 21 keep 138 instructions: with the bottom declared before the right edge only the two additions swap (3 orders, quick_diff 0.9855); with right before left or bottom before top the registers differ (18 orders, 0.8478 to 0.9638). A comment on the block says why it is one. On main since #387 drawHeaderTextBanner takes an eTextSections: the banner's 76 is TEXT_MULTIPLAYER_CONNECTION, and eTextSections.hpp is included. No line for cmake/compiler-flags-gl.txt: the file reads 100.0% off the /GL list, and 100.0% on it too. reccmp in a build of main's whole /GL list (the 133 files that exist) and this file, off the list, with every resolver of those files on: 144 functions, average 99.56. The function 100.0% raw and normalised, no differing line; the other 143 functions read the same as without the file. That build had a shorter comment on the block; quick_diff gives the same 138 instructions, line for line, for this text. The sources were main's at 3458fea34; main's commits since add cmake files and tools, and two other UI functions' files (#466, #467). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...lRenderFunction_FindingNetworkSessions.cpp | 66 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuModals/FindingNetworkSessions/MenuModalRenderFunction_FindingNetworkSessions.cpp diff --git a/src/OpenSHC/UI/MenuModals/FindingNetworkSessions/MenuModalRenderFunction_FindingNetworkSessions.cpp b/src/OpenSHC/UI/MenuModals/FindingNetworkSessions/MenuModalRenderFunction_FindingNetworkSessions.cpp new file mode 100644 index 0000000000..6e4afe96f9 --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/FindingNetworkSessions/MenuModalRenderFunction_FindingNetworkSessions.cpp @@ -0,0 +1,66 @@ +#include "../FindingNetworkSessions.func.hpp" + +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_ProtocolDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/UI_NetworkSessionsShadeLogic.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047D190 + void FindingNetworkSessions::MenuModalRenderFunction_FindingNetworkSessions(int x, int y, int width, int height) + { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // "Finding Sessions" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, + DAT_PencilRenderCore::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, 11, x, y, width, height); + // the session list: box, outline, scroll column and squares, all from the four edges in a block. In 21 of + // the other 23 orders, or with top, bottom, right, right + 1 and left - 1 as locals, the listing differs + { + int const left = x + 40; + int const top = y + 85; + int const right = x + 460; + int const bottom = y + 285; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + left, top, right - 20, bottom); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top - 1, right + 1, top - 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 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)( + right - 20, top + 20, right + 1, top + 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top, left - 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)( + right - 20, top, right - 20, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right - 19, bottom - 20, right, bottom - 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + } + // The searching animation, a frame every second call + int const shadeTick = UI_NetworkSessionsShadeLogic::instance + 1; + UI_NetworkSessionsShadeLogic::instance = shadeTick; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_ProtocolDefinedData::instance.field_0x474[shadeTick / 2 % 32] + 398, width / 2 - 14 + x, y + 312); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.scrollBarIndex == -1 + && DAT_GameSynchronyState::instance.DPLAY_SessionsCount != 0) { + DAT_GameSynchronyState::instance.scrollBarIndex = 0; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 37d7e54311..bfd9027781 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22311,7 +22311,7 @@ SHC_3BB0A8C1_0x0047D0E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047D100 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0047D190 | 0.0% | Pending +SHC_3BB0A8C1_0x0047D190 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047D330 | 100.0% | Reimplemented