Repository navigation
Reimplement 7 UI functions from gynt's drafts, and DAT_ButtonBlendStrength as an int (100%) - #400
Merged
Merged
Conversation
Main's Ghidra sync c67521e changed changeMapOrientation's parameter from int to MapOrientation. processMapOrientationChange passes DAT_FutureMapOrientation, which is still undefined4, so the file stopped compiling (C2664). The cast restores it; quick_diff is 1.0000 before the sync and after the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…first Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The button's blend strength at 0x00ED31C4 was undefined4. MenuItemRenderFunction_TacticalPowerBar_Main (0x004D9EC0) dims its icons during a multiplayer game's no-rush time by 32 - (32 - strength) / 2, and the original divides that signed (mov eax, 0x20; sub eax, [0xed31c4]; cdq; sub eax, edx; sar eax, 1), where the unsigned field gives shr. Every reader passes it on as a renderGMWithBlending blend strength, which is an int. The four files on main that read it (MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface, MenuItemRenderFunction_MapEditorLandscaping_GeneralButtons, RenderButtonImageWithBlending, RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk) give the same quick_diff output with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
data.asm names the instance at 0x00ED31C4 with the int type (H instead of I), as it does for main's other int globals, to go with the header commit before it. With the old name the original's references to the address show the unsigned instance in reccmp, and MenuItemRenderFunction_TacticalPowerBar_Main reads 96.4% raw where it is 100.0% normalized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets handles the right mouse button in game: with no right click started, or a siege tent's battering ram or shield tab open in the build menu, a right drag moves the camera; otherwise, with no mapper command active, it stores the mouse position and turns the preview on. Written from the original's instructions, with gynt's draft (b05c784 on his fork's reimpl/UI-MenuItems, 49.12% there, and his batch pass 8725ec5; earlier 357b379 at 35.7%) for the reads. Behaviour fix: the original tail-calls updateRightDragCameraControl and returns, where the draft went on to clear previewEnabled after it. Also: an early return for a viewport that is not active, main's names (field_0x0, editorPlacementPlayerID), truth tests on the two BOOL fields, no decompiler comments. The handler's int parameter is unused and keeps the header's name. quick_diff leaves only ret / ret 0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_AlliesOrder_Main sends the order of one of the allies dialog's buttons to the ally shown: buttons 1 to 6 ask for the goods of the enemy listed there, and only exist up to the number of enemies. Button -2 opens the allies dialog again; 10 opens it again after its order, the others close it. From gynt's draft (36d9d19 on his fork's reimpl/UI-MenuItems-development, 80.00% there; earlier 92e7815 at 66.67%) with our earlier behaviour fixes: the dialog opens again only for -2 and 10. The shape the original needs: -2 opens the dialog and returns at the top, and 10 has its own activateModalDialog call in an if / else with the close-dialog store (one shared call: quick_diff 0.8750, the store before it). quick_diff leaves only ret / ret 0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_General_EventSlider draws a scenario event's slider: its thumb, in dark lime while it is dragged and greyish yellow otherwise, and the value beside it, or "-" for slider -2 at 10. Sliders -2 and -1 only show for the events that last a while (the travelling fair, the plagues and pests, bandits to archers, theft and fire), the others only for the event one below their number. Written from the original's instructions, with gynt's draft (a35032b on his fork's reimpl/UI-MenuItems, 74.47% there, and his batch pass 8725ec5; earlier 48ef385 at 60.4%) for the reads. Behaviour fix: in the draft the -2 and -1 cases fell from the inner switch into the next case's event test, which -2 and -1 never pass, so those sliders were never drawn; the original goes straight to drawing. The two thumb colours are two drawColorBox calls, as in the original, which shares their tail. Also: the parameters named slider and value (the outer switch's cases are slider numbers, which have no enum), the inner switch's cases by their ScenarioEventType names, s___005a2280 for "-", COL_CCFAFF, decimals. quick_diff leaves the jump tables' labels, the colour immediate and ret / ret 0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_OverlaySlider_Slider draws a modal dialog's slider: a dark box, the slider's title from the dialog's text group and index, and the thumb in dark lime while it is dragged and greyish yellow otherwise. A thumb as wide as the slider covers the title, so the title is drawn again over it. Written from the original's instructions, with gynt's draft (71f7285 on his fork's reimpl/UI-MenuItems-development, 53.63% there; earlier 3144747 at 40.70%) for the reads. Two forms are kept for the register allocation: the title's position in two locals, y first, in both title blocks (inline: quick_diff 0.6816, and MSVC then merges the thumb's two drawColorBox calls; one block only: 0.8696), and the thumb's two colours as two calls. Also: the parameters named slider and value as in the event slider (both unused here), COL_C2F0EB and COL_CCFAFF, decimals, no decompiler locals. quick_diff leaves the colour immediates and ret / ret 0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_TacticalPowerBar_Main draws one slot of the tactical powers bar: a short line, and the power's icon, bright once the bar's level has filled the slot (636 points a slot) with a highlight while the mouse is over it, dimmed otherwise. The first time a power is ready the help text is shown. During the no-rush time of a multiplayer game the icons are dimmed further and never bright. Written from the original's instructions, with gynt's draft (643ea42 on his fork's reimpl/UI-MenuItems, 36.70% there, and his batch pass 8725ec5; earlier 477e2bb at 30.8%) for the reads. Behaviour fix: once the slot is full the original draws the bright icon and returns; the draft went on to draw the dimmed icon over it. Needs the header commit before it: the no-rush blend strength is a signed division. The forms the original needs: the button's y and x read into locals, y first, before the level (inline: quick_diff 0.7919), level >= ... rather than ... <= level, and the dimmed icon as one call in each branch, which MSVC merges at the tail (one call with a blend local: 0.9137). Also: the parameter named slot; the slot to icon switch (slot numbers, no enum) with the 4 / 8 / 9 case last as in the original, decimals, no decompiler comments. quick_diff leaves the jump table's label and ret / ret 0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_MissionEndscreen_Main draws the buttons of a skirmish or multiplayer game's end screen: the two tabs -100 and -101, drawn pressed when they are the one INT_00ec082c selects (0 or 2 for the first, 1 or 3 for the second); the results table's column headers 0 to 15, the one the table is sorted by drawn pressed, and the column under the mouse stored in DAT_00eb9af8; and everything else as a normal button. Written from the original's instructions, with gynt's draft (aa394fe on his fork's reimpl/UI-MenuItems, 43.10% there, and his batch pass 8725ec5; earlier 20d79c5 at 27.27% and 77ed5e0 at 19.9%) for the reads. Behaviour fixes: the draft drew the normal button twice for button -1, and returned after storing the column under the mouse where the original goes on to draw that column's header. The forms the original needs: the two tab tests in one condition, so their pressed drawing is one block that MSVC shares with the column header's (separate blocks: 15 instructions more); the -10 and -1 stores as a switch (an if / else-if lays them out the other way round). Also: the parameter named buttonID as in the sibling handler, CHAR_00eb0e44 and INT_00ec082c by main's names, TRUE / FALSE for the BOOL stores, no decompiler locals or gotos. quick_diff leaves only ret / ret 0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_TextEditor_Scrollbar handles the help text's scroll bar: its range is how far the text reaches past the view (never below 0), its arrows move a twentieth of that, at least one, and the value is the text's scroll offset. Written from the original's instructions, with gynt's draft (77036d2 on his fork's reimpl/UI-MenuItems-development, 43.44% there, and his style pass dd1a7c4; earlier c1f0ea6 at 41.63% and 8d5d290 at 22.67%) for the reads. The draft's mask expressions ((x <= 0) - 1 & x) are max(x, 0): the original computes it again at each use and from the step's division twice, which is how Windows' max macro, already used on main, expands. The forms the original needs: both arrows as an if / else on an offset local with one store pair after it, which MSVC copies into each arm (the stores in the arms: quick_diff 0.8702). Also: the parameter named action, decimals. quick_diff leaves the jump table's label and ret / ret 0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the fresh-eyes review. quick_diff is unchanged for all six files (1.0000, and the RightClick handler's 0.9655 both before and after, where it prints one global's address operand differently; reccmp reads it 100.0). - RightClickMenuAndMaybeResets: viewportState.field_0x0 and previewEnabled tested by truth, as main's other readers test them; the unused int parameter named unused. - TextEditor_Scrollbar: the parameters named unused and scrollbarEvent, as main's sibling Scrollbar handlers have them. - Why-comments on the three forms kept for the match, measured again on main c67521e: the scrollbar's second clamp after max (without it: 0.7126; the original tests again, test eax, eax; jge at 0x0045EE81), TacticalPowerBar's x and y read into locals while the icon calls re-read the globals (inline: 0.8776), and OverlaySlider's title position in locals, y first (inline: 0.7039). - MissionEndscreen's tab comment on one line; EventSlider's "-" comment moved off the macro's argument list, to the line above the call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four comments carried quick_diff numbers; the numbers belong in the PR text, so the comments keep only the reason: the OverlaySlider render's title positions (two), the TacticalPowerBar render's icon positions and the TextEditor scrollbar handler's second clamp. Comments only, no code change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in sourcehold#397 (merged as 5ec4011), so this PR no longer shows its commits, plus sourcehold#290, sourcehold#402 and sourcehold#405. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
added a commit
that referenced
this pull request
Nov 13, 2026
Main's Ghidra sync 1d819b7 has the DAT_ButtonBlendStrength header change from this PR, so the PR no longer changes a header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 14, 2026
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seven more UI functions at 100%. Six were written from the original's instructions, with gynt's draft (below 100%) used for the reads. The AlliesOrder handler starts from his draft directly. Each commit cites the drafts it builds on and credits him as co-author. All seven are part of the rest of UI that gynt OK'd on 2026-11-09.
InGameMenu::MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResetsAlliesOrder::MenuItemActionHandler_AlliesOrder_MainGeneral::MenuItemRenderFunction_General_EventSliderOverlaySlider::MenuItemRenderFunction_OverlaySlider_SliderTacticalPowerBar::MenuItemRenderFunction_TacticalPowerBar_MainMissionEndscreen::MenuItemRenderFunction_MissionEndscreen_MainTextEditor::MenuItemActionHandler_TextEditor_ScrollbarMeasured on main c67521e, with #397's two commits on top (see below).
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.== 0/!= 0tests that are now truth tests. quick_diff reads the same before and after for all six files it touches: 1.0000 for five of them. The RightClick handler reads 0.9655 both times, because quick_diff prints one global's address operand differently; reccmp reads it 100.0%.openshc-pr-checkgives no errors, andstatus_regression.pyfinds no score below a known one.Behaviour fixed compared with the drafts
updateRightDragCameraControland returns (jmp 0x00470BC0at 0x00438BC7). The draft went on to clearpreviewEnabledafter it.Header change (in a commit of its own)
DAT_ButtonBlendStrengthis anint(0cab9d6). 90af173 renames itsdata.asmsymbol to the int type to go with it, as dbb3e8c did forDAT_00b9840cin #385.32 - (32 - strength) / 2. The original divides that signed:mov eax, 0x20; sub eax, [0xed31c4]; cdq; sub eax, edx; sar eax, 1at 0x004D9F5A-0x004D9F68. Withundefined4, MSVC emits ashrinstead.renderGMWithBlending's blend strength, which is anint.MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface,MenuItemRenderFunction_MapEditorLandscaping_GeneralButtons,RenderButtonImageWithBlending,RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk) give identical quick_diff output with it. Its writer,prepareAndRenderMenuItems, stays at 100.0% in a full build.The declaration check will fail and label this PR until main has the line. Then I'll merge main in.
Built on #397
Main c67521e doesn't compile
processMapOrientationChange.cppafter the Ghidra sync, so this branch sits on #397's two commits: e32e2b8 (theMapOrientationcast) and 4cf6926 (the file's own include first). That is the one Map file in this diff. Once #397 is merged, I'll merge main in here and the file drops out of this PR.Kept as they are, measured with quick_diff
maxtest eax, eax; jgeat 0x0045EE81-0x0045EE85)max(range, 0)written out at each use, no localoffsetlocal, with one store pair after itactivateModalDialogcall, in an if/else with the close-dialog storedrawColorBoxcallsThe kept forms that a reader might tidy away (the second clamp, and the position locals in TacticalPowerBar and OverlaySlider) each have a one-line comment.
Numbers left as numbers:
None of these has an enum on main. The event slider's inner switch uses the
ScenarioEventTypenames.What some placeholders hold
INT_00ec082c: the end screen's selected tab. The GameLost and MissionFinishedTransition prepares set it to 0 or 2. The first tab is drawn pressed for 0 or 2, the second for 1 or 3.DAT_00eb9af8: the end screen's button under the mouse: the column 0 to 15, 16 for button -1, 17 for -10. The same prepares reset it to 0.CHAR_00eb0e44: hides the two tabs while it is set (main's MissionEndscreen action handler tests it the same way).ViewportState::field_0x0: main's name. The right-click handler returns while it is 0, and main's other readers test it by truth too.Proposed, not changed here
MenuModalComposition::textGroupis anint, cast toeTextSectionsfor both of OverlaySlider's title calls. It holds -1 for no title (the>= 0tests), so I left the type alone.MouseState::previewEnabledis anint. The code here stores only 0 and 1, and main tests it by truth, so it could be aBOOLEnum. Not every writer is reimplemented yet, so this isn't proven.thumbYPosandthumbHeight(the header's names for the slider renders' parameters) are the thumb's x offset and width in these two horizontal sliders: they are added toDAT_ButtonXand compared withDAT_ButtonW.Other PRs
🤖 Generated with Claude Code