From bfac9fd22334ae320f6f53a23f0468a249c301f4 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 22 Nov 2026 14:36:08 +0100 Subject: [PATCH] reimplement: SHC_3BB0A8C1_0x00493560 100.0% Reimplemented ProgressBarBox::MenuModalRenderFunction_ProgressBarBox, moved out of our draft #360 (f860f20f38, Gynt's code with the fixer's rewrites), from Gynt's draft (217700a5ed at 96.33% on his fork's reimpl/UI-MenuModals-development, "spill slot differs"). That draft computes what the original computes; no behaviour is changed against it. His earlier copies (45.2% at 266d7a5542, in his closed #252; 48.6% at 6987e8c181) have no else on the second test and dim the filled box; he put the else in in 85a110f622 (85.97%), as the original has it (it returns at 0x00493642), and it is here. His draft has the original's 109 instructions; four of them use another stack slot. The original keeps the bar's x in the second parameter's slot: computed at 0x0049360F, stored there in front of the draw (0x00493620) and read back for progressBarX (0x0049362F; 0x0049364E, 0x0049365E and 0x0049366D in the other arm). The draft assigns the value to height, the unused fourth parameter, and gets the fourth slot. Here: - the bar's x is assigned to y. On its own that keeps the value in y's register (105 instructions), an own local gets a new stack slot (112 instructions), and so does the expression written out at both uses (112); - so y is read through a local, top, that is assigned from y in each arm of the language test, where the original loads the second parameter (0x00493572, 0x004935A2). Then top gets y's register (edi), y is not kept in a register, and its new value lives in its own slot: 109 instructions against 109. Declared with y as its value (int top = y; or int const top = y;), top is loaded at the function's start and the match is lost (107 instructions); the unused height as the copy gives the same listing as top; - the bar's bottom is written out in the two calls (as a local, the same listing), and the casts on the text's number and on the box's colour are dropped (the same listing). 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, and the same with the file on the list. The other 143 functions of main's list read the same as without the file. Both builds had an earlier text of this file (one unused include more, and the bar's bottom in a local); quick_diff gives the same 109 instructions, line for line, for that text and for this one. The sources are main's at 3458fea34; main's two commits since (02fab423c, 812d149696) add cmake files only, with the new option off. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 Co-Authored-By: Claude Opus 5.5 --- ...MenuModalRenderFunction_ProgressBarBox.cpp | 73 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuModals/ProgressBarBox/MenuModalRenderFunction_ProgressBarBox.cpp diff --git a/src/OpenSHC/UI/MenuModals/ProgressBarBox/MenuModalRenderFunction_ProgressBarBox.cpp b/src/OpenSHC/UI/MenuModals/ProgressBarBox/MenuModalRenderFunction_ProgressBarBox.cpp new file mode 100644 index 0000000000..fef37518f0 --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/ProgressBarBox/MenuModalRenderFunction_ProgressBarBox.cpp @@ -0,0 +1,73 @@ +#include "../ProgressBarBox.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/GameLanguage.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x00493560 + void ProgressBarBox::MenuModalRenderFunction_ProgressBarBox(int x, int y, int width, int height) + { + // y is copied in each arm of the language test, where the original loads it: y itself holds the bar's x + // further down. Declared with y as its value, top has y loaded at the function's start: the match is lost. + int top; + // the title, in a smaller font for English and American + if (DAT_TextManagerObject::instance.gameLanguage == OpenSHC::Text::GL_ENGLISH + || DAT_TextManagerObject::instance.gameLanguage == OpenSHC::Text::GL_AMERICAN) { + top = y; + 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, + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter), + width / 2 + x, top + 25, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 16, + FALSE, 0); + } else { + top = y; + 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, + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter), + width / 2 + x, top + 25, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE, 0); + } + // the bar's box: filled in a game that is neither solitary nor a single player skirmish while saveRelated + // is set, dimmed otherwise. RenderLoadAndSaveBar draws the progress at the place kept here. + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_GameSynchronyState::instance.saveRelated != 0) { + int barInset = (width - 300) / 2; + int barY = top + 65; + // the bar's x: the original keeps it in y's place on the stack, so it is assigned to y + y = barInset + x; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)( + y, barY, x - barInset + width, top + 80, COL_VERY_SOFT_YELLOW::instance.shortValue); + DAT_MenuTextInputState::instance.progressBarY = barY; + DAT_MenuTextInputState::instance.progressBarX = y; + } else { + int barInset = (width - 300) / 2; + int barY = top + 65; + // the bar's x: the original keeps it in y's place on the stack, so it is assigned to y + y = barInset + x; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + y, barY, x - barInset + width, top + 80); + DAT_MenuTextInputState::instance.progressBarY = barY; + DAT_MenuTextInputState::instance.progressBarX = y; + } + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..39ecce8cfe 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23623,7 +23623,7 @@ SHC_3BB0A8C1_0x004934E5 | 0.0% | Pending SHC_3BB0A8C1_0x004934F0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00493560 | 0.0% | Pending +SHC_3BB0A8C1_0x00493560 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00493690 | 100.0% | Reimplemented