Skip to content

Reimplement 5 UI::MenuItems scrollbar, crusade intro and options functions at 100% - #342

Merged
gynt merged 7 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-MenuItems-7-100
Nov 6, 2026
Merged

gynt merged 7 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-MenuItems-7-100

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Five UI::MenuItems functions at 100%, each with its status line: the scrollbars of two lists (network sessions and ranking games), the crusade mission intro's handler and render, and the text button of the game options menus.

All five continue gynt's drafts on his fork (reimpl/UI-MenuItems and -development, at 60.9-94.4% there). Every commit body says what changed against the draft and why. No header change left: main's Ghidra sync 7621d4f took ours in (below), and main is merged in.

Other PRs: the ready #348 and #349, and the drafts #313, #318, #321, #327 and #328.

Built on top of main (d972299, and it merges cleanly into 57d3334) with the bundled MSVC1400-SP1, natively on Windows, against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a). The branch was built and measured on its own, 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 #331 and #340: the points from the reviews of #311, #312 and #323, a fresh-eyes review of every file (the behaviour fixes checked against the original's disassembly, every text comment against the code that reads it; its points applied and measured), openshc-pr-check with no errors, main's style_lint.py with nothing to report, and status_regression.py, which finds nothing below a known score on main or any fork.

Header change (now on main)

DAT_00ed3120 and DAT_00eb9b60 are ints on main since its sync 7621d4f, renamed INT_00ed3120 and INT_00eb9b60; this branch now uses those names. The evidence was: the ranking games scrollbar compares the offset against the count less 8 with jge at 0x004D9BDD, which shows both are signed, and it tests the offset with jle at 0x004D9BBC and the count less 8 with jns at 0x004D9B92.

Behaviour fixed compared with the draft

Read from the original's asm; the commit body gives the details.

  • FindingNetworkSessions_Scrollbar, event 6 (scroll down): the original also writes the new offset to *currentValue, through the mov [edx], eax at 0x0047D3C5 that scrolling up uses too. The draft returned right after the increment, so *currentValue was never written after a scroll down.
  • RankingGames_Scrollbar, event 7 (a click on the track, off the thumb): the original sets *currentValue to 6 and returns (mov dword ptr [edx], 6; ret at 0x004D9BAA, with its own jump-table entry). The draft had no break, so it fell into event 5, scrolled up one and overwrote the 6. The menu then pages the list by 6 of its 8 games.
Class Function Address Raw Notes
FindingNetworkSessions MenuItemActionHandler_FindingNetworkSessions_Scrollbar 0x0047D330 100.0% Finished from gynt's draft on reimpl/UI-MenuItems (79.2%); the event 6 fix above. Ten sessions fit in the list.
RankingGames MenuItemActionHandler_RankingGames_Scrollbar 0x004D9B30 100.0% Finished from gynt's draft on reimpl/UI-MenuItems (75.4%); the event 7 fix above. Eight games fit in the list (RankingGames_Main tests row < 8).
CrusadeMissionIntro MenuItemActionHandler_CrusadeMissionIntro_Main 0x004D8C10 100.0% Finished from gynt's draft on reimpl/UI-MenuItems-development (78.7%). Button 10 starts the next mission of the trail (20, 30 and 50 missions long), or resumes when the game is suspended; button 11 goes back to the crusade map, or asks "Quit Mission" when suspended.
General MenuItemRenderFunction_General_GameOptionsTextButton 0x004934F0 100.0% Finished from gynt's draft on reimpl/UI-MenuItems (94.4%).
CrusadeMissionIntro MenuItemRenderFunction_CrusadeMissionIntro_Main 0x004D8BB0 100.0% Finished from gynt's draft on reimpl/UI-MenuItems (60.9%). The flag is a BOOLEnum: the original zeroes it with xor and tests it with cmp.

Kept as they are, and why

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

  • GameOptionsTextButton: each path makes its own renderTextToScreen call and computes its own position, which MSVC merges into the original's one call at 0x00493556 (one call with a colour local: 100.0% -> 62.5%; the position declared once above the if: 97.2%).
  • CrusadeMissionIntro_Main handler: one SetupSkirmishMode call per trail, which MSVC merges (one call with mission and length locals: quick_diff 0.9545 -> 0.8764, reccmp 100.0% -> 80.9%).
  • RankingGames_Scrollbar: the count read once into a local (reading it again for the test: quick_diff 0.8679 -> 0.7593), and the compare before each store, as the original does (a plain store: 0.8679 -> 0.7308 for events 2 and 3, 0.6538 for event 4).
  • gameSuspended == 1: the original compares with 1, as main's ResetEventStatusUnk does.

Proposed, not changed here

  • DAT_00eb9b60 is the number of leaderboard entries left after the filter: written by Skirmish_PrepareLeaderboardView (0x004D9400), read by Skirmish_SortAIOpponentOrder and RankingGames_Main (0x004D9730).
  • DAT_00ed3120 is the ranking list's scroll offset.
  • DAT_ButtonUnknownZero looks like a "button disabled" flag: the intro render sets it for button 10 once the trail is complete.

🤖 Generated with Claude Code

kotijekriv and others added 6 commits November 6, 2026 08:00
Finished from gynt's draft on his fork (reimpl/UI-MenuItems, 79.2%, "Style pass, asm differs"). Behaviour fix: after
scrolling down (event 6) the original also writes the new offset to *currentValue, as it does after scrolling up; the
draft returned without it. Both scroll events now step the offset and store it in one tail, which the compiler shares
the way the original does. quick_diff 0.8182 (43 instructions against 45) -> 45/45 with only the jump-table spelling
and ret / ret 0 left (0.8667), same global order. Style pass: named parameters (scrollbarEvent, as main's map select
scrollbar calls it), - 10 for + -10, ++ / --, no plate comment, and the namespace block its siblings on main use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ranking games scrollbar (0x004D9B30) compares the offset against the count less 8 with jge at 0x004D9BDD, which
shows both are signed. It also tests the offset with jle at 0x004D9BBC and the count less 8 with jns at 0x004D9B92.
DAT_00eb9b60 has no user on main; DAT_00ed3120's one user there, SetActiveCreditsSequenceIndex, only stores 0 in it,
which compiles the same either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finished from gynt's draft on his fork (reimpl/UI-MenuItems, 75.4%, "Style pass, asm differs"); it needs the header
commit before this one. Behaviour fix: event 7 (a click on the track, off the thumb) sets *currentValue to 6 and
returns, where the draft fell on into event 5 and scrolled up as well. For that event the menu passes its page step in
that pointer, then moves the offset by it and sends event 2 (handleMenuElementsCallbacks), so the list pages by 6 of
its 8 games. Events 5 and 6 step the offset and store it in one tail each, as the FindingNetworkSessions scrollbar
does; the cases stay in the original's order (1, 2/3, 4, 7, 5, 6). Comments give what the other forms measured: the
count read once into a local (reading it again for the test: quick_diff 0.8679 -> 0.7593), and the compare before each
store (a plain store: quick_diff 0.8679 -> 0.7308 and reccmp 100.0% -> 78.3% for events 2 and 3, 0.6538 and 69.4% for
event 4). quick_diff 0.7810 (52 instructions against 53) -> 53/53 with only the jump-table spelling and ret / ret 0
left (0.8679), same global order. The event parameter is scrollbarEvent, as main's map select scrollbar calls it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finished from gynt's draft on his fork (reimpl/UI-MenuItems-development, 78.7%, "Reimplemented, asm differs"). Each
trail tests its own progress against its own length (20, 30 and 50 missions) inside its arm and starts the mission
there; the compiler merges the three calls into the original's one. The draft's form, one call with mission and length
locals, needs one more instruction (quick_diff 0.9545 -> 0.8764, reccmp 100.0% -> 80.9%); a comment says so. Question
7 of the yes/no dialog is "Quit Mission" (drawHeaderTextBanner(TEXT_GAME_OPTIONS, 7)). No casts (the progress fields
are ints on main). quick_diff 0.8764 (45 instructions against 44) -> 44/44 with only ret / ret 0 left (0.9545), same
global order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finished from gynt's draft on his fork (reimpl/UI-MenuItems, 94.4%, "Style pass, asm differs"). Each path makes its own
renderTextToScreen call, which the compiler merges into the original's one call site (0x00493556); one call with a
colour local measures 100.0% -> 62.5%. Each path also computes the text position itself: the compiler hoists the
identical computations above the branch the way the original does, while the position declared once above the `if`
(as main's OptionsMenu_SubOptionsButtons has it) schedules one `push 0` later, 100.0% -> 97.2%. A comment gives both.
quick_diff 0.8889 -> 0.9167 at 36/36 instructions; the three lines it still marks are its own artefacts: the two colour
immediates, which fall in the exe's address range so it prints them as globals on the original's side, and ret / ret 0.
Names as on main: textIndex, as in its other TEXT_GAME_OPTIONS lookups, textX and textY, and the namespace block the
other General files use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finished from gynt's draft on his fork (reimpl/UI-MenuItems, 60.9%, "rebuilt control flow from asm"). Each trail sets
the flag with an `if` inside its own arm, so the compiler shares one `jl` and `mov eax, 1` between the three arms, as
the original does. The flag is a BOOLEnum: the original zeroes it with xor and tests it with cmp, so it is an int and
not a bool. No casts (the progress fields are ints on main). quick_diff 24/24, only the tail jump's target differs
(0.9583).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's sync took in this branch's header change: DAT_00ed3120 and DAT_00eb9b60 are now INT_00ed3120 and
INT_00eb9b60, declared int. Main's two headers are taken as they are, so the branch's header commit leaves no diff,
and RankingGames_Scrollbar follows the rename (11 and 3 uses, and its two includes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gynt
gynt added this pull request to the merge queue Nov 6, 2026
Merged via the queue into sourcehold:main with commit 787a1bc Nov 6, 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