Skip to content

Reimplement 5 UI::MenuViews functions at 100% - #353

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

gynt merged 15 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-MenuViews-1-100

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Five UI::MenuViews functions at 100%, each with its status line: the historic campaign outro, the main menu's every-frame handler, the historic mission intro and picture, and the "game lost" screen.

This is our first PR in UI::MenuViews, which gynt agreed on Discord (2026-11-06) we may continue from his drafts, only the ones not in one of his open PRs. All five are his drafts from his fork, statement for statement, after a style pass; each commit body names the draft's branch and lists every change against it. Gynt's drafts were already near 100% on today's main: most of their gap was the security cookie, which reccmp now ignores. No header change is left: gynt's Ghidra sync eef6f66 took all three into main (INT_00ed279c as BOOLEnum_00ed279c), main is merged in, and GameLost uses the new name (fbec174).

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

Built on top of main (da1fef5; it merges cleanly with today's main) 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 #351: a fresh-eyes review of every file (behaviour checked against the original's disassembly, 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. Nothing else touches these files: no branch of ours and no open PR (gynt's #253 had them and was closed unmerged on 2026-10-03). 6and8 has his own rewrites of eight other MenuViews functions on his fork, and we left those alone.

Class Function Address Raw Draft (gynt's fork) Notes
HistoricCampaignOutro MenuView_HistoricCampaignOutro_Prepare 0x004DBE30 100.0% reimpl/UI-MenuViews-development, 97.9% cr.tex group 179: six texts per campaign, the last two "Aftermath" and the closing text.
MainMenu MenuView_MainMenu_DoEveryFrame 0x00424DA0 100.0% archive/UI-MenuViews-merged-full, 97.2% The live development branch's draft is also 97.2% but has two gotos; this one already wrote the video test as an if. The decompiler's hand-written security cookie goes; the colour is COL_7CAAAF.
HistoricMissionIntro MenuView_HistoricMissionIntro_Prepare 0x004DB7B0 100.0% reimpl/UI-MenuViews-development, 96.8%
HistoricMissionPicture MenuView_HistoricMissionPicture_Prepare 0x004DB4F0 100.0% reimpl/UI-MenuViews-development, 96.2%
GameLost MenuView_GameLost_Prepare 0x004D55D0 100.0% reimpl/UI-MenuViews-development, 99.1% The tab stores are tabType = BASMTT_NONE / BASMTT_KEEP_OR_MPMENU_IPX and the text index TAIT_NINE__FILTER_B, as main writes them.

The file names are the s_ pointers from string-literals.hpp, each with its text above it, as in main's sibling PrepareHistoryBook (the original pushes each address); playBINK takes a char*, so its names are cast with (char*), as main's playBikVideoFromPlayer does. The mission text group is written (missionNumber1to20 - 1) * 4 + TEXT_MISSION1_STORY: the mission's story group, whose texts 0, 1 and 2 are "Mission N", the mission's title and the story (the drafts' * 4 + 95 measures the same).

Header changes

Update: all three are on main since eef6f66. Main's own playBINK.cpp and getSoundVolumeForFilename.cpp don't compile there until this PR lands, because it carries their definitions (3cf47bd, 9dc005d below); the other files the sync broke are in #368.

  • INT_00ed279c is a BOOLEnum (b953b94; the type only, the name kept): it stores 0 at 0x004D55EC / 0x004E1B5F and 1 at 0x004D6C23, and is tested at 0x004DC5B5 / 0x004DCA5C. GameLost stores FALSE.
  • getSoundVolumeForFilename takes a char const* (6445c6e, and 3cf47bd for its definition on main): it only passes the name to __stricmp.
  • playBINK takes a char const* (8a97d31, and 9dc005d for its definition on main): it only passes the name on to resolveResourceFileName (char const*) and getSoundVolumeForFilename. GameLost and MainMenu drop their (char*) casts (ad1bb39).

Main's playBINK.cpp and getSoundVolumeForFilename.cpp compile the same (quick_diff 0.9315 and 1.0000 before and after), and so do GameLost (0.9909) and MainMenu (0.9725). The definition commits follow the header commits because each header change stays in a commit of its own; touching playBINK.cpp also fixed its first include and one local, which our checker flags.

Behaviour

None of the five differs from the original. One thing worth knowing about MainMenu_DoEveryFrame, kept as the original has it and marked with a fixme line: its sword-swing branch can never run. SEC_RNG's table comes from rand() (0 to 32767), so currentNumber1 % 3 is 0 to 2 and every roll leaves the flag at 0; the sword swing only plays from MainMenu_DoInitial (0x00424CD0).

Kept as they are, and why

Each was measured; for the first two, a one-line comment in the code says why. quick_diff's baselines below 1.0 here are the security cookie, a colour immediate, an import call and ret / ret 0.

  • GameLost: currentMenu read once into a Menu* const local, as the draft had it (read twice: quick_diff 0.9909 -> 0.9774); the four playBINK calls stay four, as the original's compiler merged their tails (one call after picking the file: 0.7282).
  • HistoricMissionIntro: three StoreStringInMenuStringArray calls (a loop over the text number: quick_diff 0.9677 -> 0.6903).
  • MainMenu: gynt's goto past the idle video is now if (!flag), which measures the same (0.9725 both).

Proposed, not changed here

  • DAT_00eb0b20: the history book picture's gfx index (loadGfxFile's result after PrepareHistoryBook's nine files; the DoEveryFrame functions draw it at 43,63).
  • DAT_00ed2780: the history book's page-turn state (Prepare sets 1; DoEveryFrame tests 0, 1 and 2 and sets 2), and FLOAT_00ec0834 its progress, 0 to 31.
  • INT_00ed279c: "end screen continue pressed" (MissionEndscreen_Main's button -1 sets it, this clears it, the GameLost and MissionFinishedTransition DoEveryFrame functions test it); its BOOLEnum type is in this PR now.
  • INT_00ec082c: the end screen's page, 0 to 3 (MissionEndscreen_Main's -100 / -101 step it; activeMenuTab.tabType mirrors it). DWORD_00ed27b4: the timeGetTime() stamp for the end screen's 5000 ms wait.
  • DAT_00eb9af8: the row index into MissionDefinedData.GreatestLordTextEntries (MissionEndscreen's render sets 16 and 17).

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_HistoricCampaignOutro_Prepare 0x004DBE30 81a291a (2026-10-27, 100%)
MenuView_MainMenu_DoEveryFrame 0x00424DA0 13b3601 (2026-10-25, 97.25%); d7c632c (2026-10-27, "97.17% Branch polarity corrected")
MenuView_HistoricMissionIntro_Prepare 0x004DB7B0 7b11acb (2026-10-01, 77.42%); 239133c (2026-10-25, "UI-MenuViews average 64.84% -> 74.64%, 12 of 79")
MenuView_HistoricMissionPicture_Prepare 0x004DB4F0 a3310f6 (2026-09-30, 79.25%); 239133c (2026-10-25, "UI-MenuViews average 64.84% -> 74.64%, 12 of 79")
MenuView_GameLost_Prepare 0x004D55D0 a80e67d (2026-10-27, 99.13%)

🤖 Generated with Claude Code

kotijekriv and others added 5 commits November 7, 2026 00:18
From gynt's fork branch reimpl/UI-MenuViews-development (97.9% there), after a style pass; the statements are his. What
changed: the four picture names "c1pic.tgx" to "c4pic.tgx" are s_ pointers, with each name's comment above its
statement; (int)(historicCampaignNumber * 6 + -2) and + -1 are written * 6 - 2 and - 1; the unused using of
eTextSections goes; two comments say what the switch and the two texts are (cr.tex group 179 has six texts per campaign,
and the last two are "Aftermath" and the closing text). quick_diff 0.9762, which leaves only the original's jump-table
spelling and ret / ret 0. 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); the
pointer swap measures the same as the S_ macros did. 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 da1fef5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch archive/UI-MenuViews-merged-full (97.2% there), after a style pass. His live
reimpl/UI-MenuViews-development has another draft of it, also 97.2%, with two gotos; the merged-full one already writes
the video and view-switch test as an if, so it was the shorter way to a goto-free function. What changed: the
decompiler's hand-written security cookie and its MSVC_SecurityCookie.hpp include go (MSVC emits the cookie for the
buffer itself); the buffer is char version[100], declared where it is first used; the goto that skipped the idle video
becomes if (!flag), which measures the same (quick_diff 0.9725 both); (HBINK)0x0 is NULL; the (int) casts on
currentNumber1 and y + 588 go; 0 < flag is flag > 0; 0x1fc, 0x16 and 0x13 are 508, 22 and 19; the colour 0x7caaaf is
main's COL_7CAAAF; the stray ; and return go, and so do three using lines and the BOOLEnum.hpp include. The comment on
the roll is a fixme: SEC_RNG's table comes from rand(), so currentNumber1 % 3 is 0 to 2 and every roll leaves the flag
0, and the sword swing never starts from here (only from MainMenu_DoInitial 0x00424CD0), as in the original. quick_diff
0.9725, which leaves the security cookie, the colour immediate and ret / ret 0. 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); the pointer swap measures the same as the S_ macros did. playBINK
takes a char*, so its strings are cast with (char*), as main's playBikVideoFromPlayer.cpp does. 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 da1fef5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch reimpl/UI-MenuViews-development (96.8% there), after a style pass. What changed: pcVar1 goes and
the three text calls feed StoreStringInMenuStringArray directly; _tgxFileName is fileName, declared after
PrepareHistoryBook where it is first used; the text group missionNumber1to20 * 4 + 95 is written (missionNumber1to20 -
1) * 4 + TEXT_MISSION1_STORY, the mission's story group ("Mission N", the title and the story; it measures the same as
the draft's + 95); the casts in the eTextSections and TrimStoredMenuString arguments and a stray ; go; comments say what
the picture, the texts and the trim are. The three calls stay three (a loop over the text number: quick_diff 0.9677 ->
0.6903). quick_diff 0.9677, which leaves the security cookie and ret / ret 0. 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); the pointer swap measures the same as the S_ macros did. 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 da1fef5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch reimpl/UI-MenuViews-development (96.2% there), after a style pass. What changed: pcVar1 goes and
the two text calls are inline; local_14 is fileName, in the same place; + -1 is - 1; the text group is
(missionNumber1to20 - 1) * 4 + TEXT_MISSION1_STORY ("Mission N" and the title; it measures the same as the draft's +
95); a stray ; goes; comments say which picture (the campaign's: five missions each) and which texts. quick_diff 0.9623,
which leaves the security cookie and ret / ret 0. 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); the pointer swap measures the same as the S_ macros did. 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 da1fef5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch reimpl/UI-MenuViews-development (99.1% there), after main's renames (INT_00ec082c,
CHAR_00eb0e44) and a style pass. What changed: DVar2 = timeGetTime() is folded into the subtraction; the two tab stores
are activeMenuTab.tabType = BASMTT_NONE and BASMTT_KEEP_OR_MPMENU_IPX, as main's MissionEndscreen_Main pairs them with
INT_00ec082c 0 and 2 (the draft had (BuildMenuTabType)0 and 2 in buildMenuTab, the same int at the same offset);
DAT_SomeTextArrayIndex = 9 is TAIT_NINE__FILTER_B, as main writes it; the (ushort) cast on COL_BLACK goes; menuY and
menuX are const and pMVar1 is Menu* const menu; the missions 6 to 10 test is a range; 0x50 and 0x3c are 80 and 60; six
using lines and the BOOLEnum.hpp include go. currentMenu is still read once into the local, as the draft had it (read
twice: quick_diff 0.9909 -> 0.9774). The four playBINK calls stay four, as the original's compiler merged their tails
(one call after picking the file: quick_diff 0.9909 -> 0.7282). quick_diff 0.9909, which leaves only the timeGetTime
import call. 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); the pointer swap
measures the same as the S_ macros did. playBINK takes a char*, so its strings are cast with (char*), as main's
playBikVideoFromPlayer.cpp does. 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 da1fef5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d screen

The comment said "outside skirmish", but the video is skipped only in GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER (666); a
skirmish game (GM_SKIRMISH_SINGLE_PLAYER, 99) gets it. Comment only: quick_diff 0.9909 before and after.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 7 commits November 7, 2026 03:27
It was an int. Every store is 0 or 1: 0 at 0x004D55EC (this PR's MenuView_GameLost_Prepare) and 0x004E1B5F
(MenuView_MissionFinishedTransition_Prepare), both from a zeroed ebx, and 1 at 0x004D6C23
(MenuItemActionHandler_MissionEndscreen_Main, on main); the two reads, at 0x004DC5B5 and 0x004DCA5C, compare it with a
register and with 0. The name stays INT_00ed279c, a proposal for Ghidra's side ("end screen continue pressed"). BOOLEnum
is BOOL, an int, so main's MissionEndscreen_Main compiles the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file name is only read: the function compares it with each loaded sound's name through __stricmp, which takes char
const* (main's getSoundVolumeForFilename.cpp, 0x0044A240). Every caller passes a char* and compiles the same; the change
lets playBINK pass its own file name on as const. The definition follows in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… declared with

Follows the header commit before this one. Same code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
binkFileName is only read: main's playBINK.cpp (0x00408ED0) passes it to resolveResourceFileName, which takes char
const*, and to getSoundVolumeForFilename, which does since the header commit before. Callers that pass a char* compile
the same; the s_ pointers from string-literals.hpp no longer need a (char*) cast. The definition follows in the next
commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follows the header commit before this one. Touching the file brings it under the checker, so it also gets the first
include of its class (../BinkControlClass.func.hpp, SG 14; Rendering.func.hpp moves into the include list) and declares
the sound volume where it is assigned (SG 24). Same code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ayBINK no longer needs

playBINK takes its file name as char const* since the header commit before this one, so the s_ pointers go in uncast;
GameLost_Prepare also stores FALSE in INT_00ed279c, a BOOLEnum now. Same code (quick_diff unchanged).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 7, 2026
cpp-linter checks whole changed files: the two declarations changed to char const* are wrapped the way
clang-format wraps them. Whitespace only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sync renamed INT_00ed279c to BOOLEnum_00ed279c with the BOOLEnum type this branch gave it, so main's header is
taken and MenuView_GameLost_Prepare uses the new name.

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 a266a86 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