Skip to content

Reimplement 5 more UI::MenuViews functions at 100% - #359

Merged
gynt merged 8 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-MenuViews-2-100
Nov 7, 2026
Merged

gynt merged 8 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-MenuViews-2-100

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Five more UI::MenuViews functions at 100%, each with its status line: the mission finished transition, the scenario editor's every-frame handler, the landscaping editor's setup, the intro logos and the "enter your name" screen.

All five continue gynt's drafts on his fork (each commit body names the branch: the live reimpl/UI-MenuViews-development or archive/UI-MenuViews-merged-full), in the area he agreed on Discord (2026-11-06) we may take, and each credits him as co-author. Every commit body says what changed against the draft and why. No header change is left: gynt's Ghidra sync eef6f66 took both into main, together with the BOOLEnum_00ed279c rename proposed below, and main is merged in; MissionFinishedTransition_Prepare uses the new name (ceae17d).

Other PRs: #353 (the first five MenuViews functions) and draft #356 (four more near 100%); the ready #348, #349, #352, #354, #357 and #358; the drafts #313, #318, #321, #327 and #328.

Built on top of main (1c29459) with the bundled MSVC1400-SP1, natively on Windows, against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a). Each file was measured as it stands: 100.0% raw and 100.0% normalized in a clean alone build, with the struct and function resolvers enabled locally (not committed), using sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie. None of it has been run in game.

It went through the same checks as #353: a fresh-eyes review of every file (behaviour compared with the original's disassembly, all 14 resolution blocks of the landscaping setup included; texts against cr.tex; its points applied and measured), openshc-pr-check with no errors, and status_regression.py, which finds nothing below a known score on main or any fork.

Header changes

Update: both are on main since eef6f66.

  • pendingMenuRedraw is a BOOLEnum (f8e3c78): every store in the exe is 0 or 1, and every read compares it with a zeroed register. Main's two writers (MapEditorLandscaping_Prepare, prepareWindowAndDDrawUnk) store 1 and compile the same.
  • DAT_IntroStep and DAT_IntroBlendStrength are ints (efd3787): IntroLogos_DoEveryFrame compares the step signed (jge after cmp [0x00B9611C], 2 at 0x004247A0). The fade-out stores 32 - elapsed / 20 into the blend strength, which goes negative and isn't reset after the last logo; that negative value is what the jg at 0x00424909 tests (also jl at 0x00424875 and jge at 0x00424968). The other users, main's IntroLogos_General and the pending IntroLogos_Prepare (0x00424720), only compare with == and store constants.

Behaviour fixed compared with the drafts

  • MapEditorLandscaping_DoInitial (0x00430CE0): at 640x480 the draft never set DAT_MenuHandlerState::instance.y, which the original stores (0x00430D0E). The same fix is in draft Reimplement 3 UI::MenuViews functions from gynt's drafts (draft, below 100%) #356 for BuildMenu and BuildingAndStatusMenu.
  • The other four behave as their drafts did. In IntroLogos_DoEveryFrame the draft's goto is gone; the fade-in test still jumps straight to the black box, as in the original.
Class Function Address Raw Draft (gynt's fork)
MissionFinishedTransition MenuView_MissionFinishedTransition_Prepare 0x004E1B30 100.0% reimpl/UI-MenuViews-development, 99.0%
EditScenario MenuView_EditScenario_DoEveryFrame 0x004B8080 100.0% archive/UI-MenuViews-merged-full, 99.2%
MapEditorLandscaping MenuView_MapEditorLandscaping_DoInitial 0x00430CE0 100.0% archive/UI-MenuViews-merged-full, 97.9%; the fix above
IntroLogos MenuView_IntroLogos_DoEveryFrame 0x004247A0 100.0% reimpl/UI-MenuViews-development, 99.3%
GameStartEnterName MenuView_GameStartEnterName_DoEveryFrame 0x00424B10 100.0% archive/UI-MenuViews-merged-full, 96.8%, with the live draft's returnPressed local

Kept as they are, and why

Each was measured; a one-line comment in the code says why.

  • MissionFinishedTransition: four playBINK calls, as the original's compiler merged their tails (one call after picking the file: quick_diff 0.9845 -> 0.8421), as in Reimplement 5 UI::MenuViews functions at 100% #353's GameLost.
  • GameStartEnterName: isNameEntryActive == TRUE, as the original compares with 1, as does every other reader of it (truthiness: quick_diff 0.9375 -> 0.8542). Its second == TRUE test can never be true, since the draw call in between doesn't touch the flag; the branch is dead in the original too, and a comment says so.
  • MapEditorLandscaping: a fixme line: the original loads the left edge picture for both sides, though the right ones exist and other editor views use them.

Proposed, not changed here

  • Done in eef6f66: INT_00ed279c only ever holds 0 and 1, and main has it as BOOLEnum_00ed279c.
  • Names: MapPropertiesState::SEC_Section1089 is the mission's map file name; INT_00ec082c the results screen's page (a copy of activeMenuTab.tabType); DWORD_00ed27b4 the results screen's timestamp (0 = unset; a 5000 ms timeout).
  • playerIsAlive holds 0 and 1 too, but it's a short array, and there's no 16-bit BOOLEnum.

gynt's other commits on these functions

Each commit body names the commits it continues. gynt has more on the same functions on his fork, and they are credited here too: his best-scoring commit on the address and his newest one on the file, where the body doesn't name them. Where one of them is at 100%, his version already matched the original, and a fix this text describes for that function was only against the earlier draft it names.

Function Address His other commits
MenuView_MissionFinishedTransition_Prepare 0x004E1B30 3b83441 (2026-10-27, 99.02%); e9bc49c (2026-11-02, "swap if/else arms across the UI view and modal f")
MenuView_EditScenario_DoEveryFrame 0x004B8080 b5089a4 (2026-10-27, 100%)
MenuView_MapEditorLandscaping_DoInitial 0x00430CE0 24ab62f (2026-10-27, 100%)
MenuView_IntroLogos_DoEveryFrame 0x004247A0 3ebdcac (2026-10-27, 99.27%); 08c492b (2026-11-02, "write x <= 0 where the original tests it, 6 of")
MenuView_GameStartEnterName_DoEveryFrame 0x00424B10 d8708ef (2026-10-25, 96.84%); c73930d (2026-10-27, "87.80% The return-pressed flag is an int read, n")

🤖 Generated with Claude Code

kotijekriv and others added 7 commits November 7, 2026 02:56
From gynt's fork branch reimpl/UI-MenuViews-development (99.0% there), after main's renames (INT_00ec082c,
CHAR_00eb0e44, which also replaces the draft's (*(char*)&INT_00eb0e44::instance) pun) and a style pass; the statements
are his. What changed: the decompiler's two gotos between the skirmish picture and the victory speech become three plain
tests of the game mode in the original's order, and the eight written-out alive-player tests become a loop over
playerIsAlive from player 1, bounded by countof as main writes such loops, testing each entry by truthiness (every store
is 0 or 1); both measure the same as the draft. DVar2 = timeGetTime() is folded into the subtraction; iVar3, cVar4,
pcVar5 and local_104 go or get names (alivePlayers, fileName, scoresFile); pMVar1 is Menu* const menu, and menuY and
menuX are const; the unused xPos and the stray ; go; (BuildingsAndStatusMenuTabType)0 is BASMTT_NONE;
DAT_SomeTextArrayIndex = 9 is TAIT_NINE__FILTER_B, as main writes it; the missions 7 to 11 test is a range; the
lord-type test becomes an else-if; 0x50 and 0x3c are 80 and 60; the (ushort) and (int) casts go; the scores file's
source name is MapPropertiesState's field at offset 0, SEC_Section1089 (the map's file name), where the draft cast the
whole struct to char*; seven using lines and the BOOLEnum.hpp include go; comments say what each part does. The scores
file name is still read into a local before WriteMissionToScoresFile, as the draft had it (the call inside the argument
list: quick_diff 0.9845 -> 0.9741), and the four playBINK calls stay four, as the original's compiler merged their tails
(one call after picking the file: quick_diff 0.9845 -> 0.8421); both kept with a comment. quick_diff 0.9845, the draft's
own number, which leaves only the security cookie and the timeGetTime import call. playBINK and
putFileNameAndAppendFileExtension take a char*, so their strings are cast with (char*), as main's
playBikVideoFromPlayer.cpp does. The strings are the s_ pointers from string-literals.hpp, with their text above them
(SG 19), as in main's sibling PrepareHistoryBook (the original pushes each address; the S_ macros are for inline
copies). This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized in reccmp in a clean
alone build of the branch on main 1c29459.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch archive/UI-MenuViews-merged-full (99.2% there), after a style pass. The map-surface store moves
up, before the list box's corners are worked out: after them, as the draft had it, MSVC spills the left edge one
instruction early (quick_diff 0.9840 -> 0.9920, which leaves only ret / ret 0). What else changed: the banner's text
group 199 is TEXT_SCENARIO (text 2 is "Scenario Editor"; the script's block comment becomes that line); the offsets are
decimal; the colour casts and the stray return go; x1 and x2 are frameLeft and frameRight; the six locals are const; two
unused using lines go; comments say what the background and the box are. This file was measured as it stands, not only
the draft: 100.0% raw and 100.0% normalized in reccmp in a clean alone build of the branch on main 1c29459.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was a dword. Every store in the binary is 0 or 1: the 1s at 0x00430CC4 and 0x00431ADF (immediates), 0x004475E2 (ebp =
1, set at 0x00446C81), 0x00470021 and 0x00472A70 (edi = 1); the 0s at 0x00430DBD, 0x00431C15, 0x0043242F and 0x00439974
(the zero register). Every read compares it with a register holding 0 (0x00430DAA, 0x00431BD3, 0x004323ED, 0x0043993C).
Main's two writers, MenuView_MapEditorLandscaping_Prepare and prepareWindowAndDDrawUnk, store 1 and compile the same
(quick_diff 0.8889 and 0.9773 before and after).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch archive/UI-MenuViews-merged-full (97.9% there). One fix: at 640x480 the draft never set
DAT_MenuHandlerState::instance.y, which the original does in both branches (the store at 0x00430D0E), so at that
resolution the menu handler kept whatever y it had before. With the store back, the two branches have the same shape,
each with its own Menu* const local (the draft's pMVar1) and the border width read once into x, and quick_diff goes
0.9840 -> 0.9975, which leaves only ret / ret 0. Style pass: menuTopY is y and `+ -600` is `- 600`; the offsets and box
corners are decimal; the colour casts and the redundant parentheses go; the pending-redraw test becomes an early return
that keeps the draft's truthiness, if (!pendingMenuRedraw), and the store is FALSE, as the field is a BOOLEnum since the
header commit before this one (both measure the same); three unused using lines go; comments say what the blocks draw,
and a fixme says the original loads the left edge picture for both sides in every resolution, though the right ones
exist and other editor views use them (the code keeps it). The strings are the s_ pointers from string-literals.hpp,
with their text above them (SG 19), as in main's sibling PrepareHistoryBook (the original pushes each address; the S_
macros are for inline copies). This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized
in reccmp in a clean alone build of the branch on main 1c29459.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both were undefined4. MenuView_IntroLogos_DoEveryFrame (0x004247A0) treats them as signed: it tests DAT_IntroStep with
cmp [0x00B9611C], 2 and jge at 0x004247A0, and DAT_IntroBlendStrength holds negative values: the fade-in stores a signed
division by 20 (0x00424870, above 32 for one frame before the clamp) and the fade-out stores 32 - elapsed / 20
(0x00424904), which is 0 or below on the frame the fade ends and is never reset after the last logo; that negative value
is what the jg at 0x00424909 tests, with jl at 0x00424875 and jge at 0x00424968. DAT_IntroStep only holds 0, 1 and 2.
The two other users only compare with == and store constants: MenuItemActionHandler_IntroLogos_General on main
(quick_diff 0.8667 before and after) and MenuView_IntroLogos_Prepare (0x00424720, pending), which tests the step and
stores 0 in the blend. With int, the (int) casts on them go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch reimpl/UI-MenuViews-development (99.3% there), after a style pass; the statements are his (his
archive/UI-MenuViews-merged-full draft of it measures lower, quick_diff 0.8727 against 0.9489). What changed: the goto
that skipped the full-strength test after the fade-in becomes an if around the step-1 stores, which measures the same
and keeps the original's jumps (the fade-in test still jumps straight to the black box); the decompiler's comma test for
step 2 becomes an assignment and an if; the two stores of DAT_IntroStep::instance where it is 0 are written 0;
_currentTime, _yParam, _xPos and _introStepDuration are currentTime, y, x and duration, declared where they are first
used; 0x1e, 0x9c4, 0x14, 0x20 and 0x10 are 30, 2500, 20, 32 and 16; 0xffffff is main's COL_FFFFFF (ColorsEnum.hpp
instead of BGR24.hpp); the (ushort) cast on COL_BLACK, the (int) cast on the blend argument and the stray return go; the
script's block comments become line comments; five using lines and the BOOLEnum.hpp include go. DAT_IntroStep and
DAT_IntroBlendStrength are int since the header commit before this one, so their (int) casts go too; the casts that stay
make the elapsed times signed, as the original has them. The timeGetTime() call whose result the original drops stays,
with a comment. quick_diff 0.9489, the draft's own number, which leaves the colour immediate, the timeGetTime import
calls and ret / ret 0. This file was measured as it stands, not only the draft: 100.0% raw and 100.0% normalized in
reccmp in a clean alone build of the branch on main 1c29459.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch archive/UI-MenuViews-merged-full (96.8% there), with the return-key handling of his live
reimpl/UI-MenuViews-development draft: the original reads returnPressed into a register, clears the field and then tests
the register, which the live draft writes with a local (the merged-full draft tests the field itself: quick_diff 0.9375
-> 0.9053, kept with that comment); the live draft's second returnPressed = 0 in the zero path goes, as the merged-full
draft has it. Both isNameEntryActive tests stay `== TRUE`: the original compares with 1 (cmp ..., 1 at 0x00424B10 and
0x00424B4B), and by truthiness they compare with 0 (quick_diff 0.9375 -> 0.8542; kept with that comment). The second
test can never be true, as the function returned for TRUE at the top and the draw call does not touch the flag; the
original has the dead branch too, so it stays, with a comment. What else changed: the outer if (isNameEntryActive !=
TRUE) becomes an early return (it measures the same); the timeout and right-click tests are one condition before the one
switchToMenuView call (it measures the same as the drafts' two calls); DVar1 is now, declared where it is first used;
0x3e8 is 1000; resetToTextIndex(9) is TAIT_NINE__FILTER_B, as main writes it; the names are written from OpenSHC:: as in
the other four files; the stray return, three using lines and the BOOLEnum.hpp include go; comments say what each branch
does. quick_diff 0.9375, which leaves the timeGetTime import call and ret / ret 0. This file was measured as it stands,
not only the draft: 100.0% raw and 100.0% normalized in reccmp in a clean alone build of the branch on main 1c29459.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sync took in this branch's three header changes (DAT_IntroStep, DAT_IntroBlendStrength,
WindowAndDirectDraw.pendingMenuRedraw) and renamed INT_00ed279c to BOOLEnum_00ed279c, the rename this branch proposed;
MenuView_MissionFinishedTransition_Prepare uses the new name and stores FALSE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gynt
gynt added this pull request to the merge queue Nov 7, 2026
Merged via the queue into sourcehold:main with commit e9c8946 Nov 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants