Repository navigation
One more UI::MenuItems function at 100%: LobbyMenu NonBoxedButtons - #459
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
LobbyMenu::MenuItemRenderFunction_LobbyMenu_NonBoxedButtons, from Gynt's draft on his fork's reimpl/UI-MenuItems-development (a87bbb9 at 53.37%, a349a0e at 53.81%, eb99046 at 59.30%, 2dedc17 at 76.48%, dd1a7c4 style). The draft has the buttons' conditions, the calls and their arguments. Behaviour fixes against dd1a7c4, whose 2dedc17 had restored most returns: Load (1) is not drawn for a guest, Ready (-20) is not drawn in a single-player skirmish, Send Map (105) is not drawn unless it can be used, and Skirmish Masters (413) is not drawn outside a single-player skirmish. Each marks the button and returns, as the original does. The keep under the mouse is the first match (-200). There are no draw-buffer or mark stores behind the switch, which the original does not have. Rewritten against the original instructions is the control flow: one switch with the cases in the order of the original's code, the scroll cases aside (its jump table covers -200 to 4; 105 and 413 are tested in front of it, as the compiler lowers such a switch). The forms that matter: - the flag for every human player being ready is declared in front of the switch, not in its two cases: the original keeps its 1 in edi through the whole switch and pushes it for TTA_CENTER and for the down buttons; - the six scroll buttons are six cases with a call each, in the order -10, -1, -11, -2, -100, -101. The compiler gives the calls' one temporary eax, ecx and edx in turn and then joins the cases whose code came out the same: -100 into -1's call and -11 with -101. That is the original: its jump table sends -100 into the middle of -1's block (0x0042AF64), and its four blocks read the blend into ecx, edx, ecx and eax (0x0042AF41 to 0x0042AF9D). Written as the four blocks the original ends with, the turns are off by one from the third block on; -11 and -101 may swap (the same code), and no other order of the six was compiled; - the texts of the buttons 3 and 105 are two calls each, one per colour. One call with the colour chosen in it compiles without a branch (neg / sbb). With the scroll cases as above the two calls of button 3 get the original's registers (y in edx and in eax, 0x0042B0B4 and 0x0042B0E4) and share only the pushes before and after the colour. The buttons' names in the comments are from the lobby's text group and from the click handler (0x00442640). No line for cmake/compiler-flags-gl.txt: the file reads 100.0% off the /GL list, and 100.0% on it too. quick_diff gives the same instructions with and without its callees' bodies in the unit. reccmp in a build of main's whole /GL list (the 133 files that exist) and the file, off the list, with every resolver of those files on: 144 functions, average 99.56. NonBoxedButtons 100.0% raw and normalised, no differing line, the jump table and its index bytes included. The same build without the file has 143 functions, and each of them reads the same. Both builds (off and on the list) had this file before its comments, clang-format and the flag's BOOLEnum type. quick_diff gives the same 383 instructions, line for line, for that text and for this one. The sources are main's at 3458fea; main's two commits since (02fab42, 812d149) add cmake files only, with the new option off. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
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.
One more function at 100%, with no header changes and no line for
cmake/compiler-flags-gl.txt. Six behaviour fixes against gynt's best draft (below).LobbyMenu::MenuItemRenderFunction_LobbyMenu_NonBoxedButtonsdraws the lobby's buttons that have no box: the scroll buttons of the chat, the map list and the map description, the host's Load and Launch Game buttons, Main Menu, Ready (a picture button, and a Ready text button), the host's Send Map, Skirmish Masters and the keeps on the map preview. It is from gynt's draft on his fork'sreimpl/UI-MenuItems-development, and the commit credits him as co-author.LobbyMenu::MenuItemRenderFunction_LobbyMenu_NonBoxedButtons/GLlist and on itMeasured.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie./GLlist and with 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) left out and its resolver off, as in main's baseline: 0 failed of 2,424 compile steps, 99.58 over 2,440 functions, against 99.58 over 2,439 for main alone (built at f489b72; 3458fea only adds files undertools/, and cmake: optional wrapper units built from function-visibility.txt #399 and cmake: function-visibility.txt, which callers must see which callees' bodies #398 add the optional function-visibility units, off by default).MenuItemRenderFunction_LobbyMenu_NonBoxedButtonsreads 100.0 raw and normalised there too, with no diff entry. Every main function reads exactly what it read before (unrounded 99.5761 against 99.5759 raw, 99.5494 against 99.5492 normalised; 2,323 against 2,322 functions at 100.0 raw)./GLlist that exist on main, and the file, off the list: 144 functions, average 99.56. The function reads 100.0% raw and normalised, with no diff entries; the switch's jump table and its index bytes are part of that. The same build without the file has 143 functions, and each of them reads the same. That build, and the one with the file on the list (below), had the file before its comments, clang-format and the flag'sBOOLEnumtype. quick_diff gives the same 383 instructions, line for line, for that text and for this one. The sources were main's at 3458fea; main's two commits since (02fab42, 812d149) add cmake files only, with the new option off.nopat 0x0042B15F andmov edi, ediat 0x0042B362), in its order; reccmp's diff for the function is empty. The case labels pair with the original's jump table (12 entries) and index table (205 bytes), case for case.The behaviour fixes
gynt's 2dedc17 ("control flow from the asm") already restores the returns of the modal-dialog block, of button 1's two draws and of the buttons 3, 4 and 105. These are the ones left, each against dd1a7c4:
DAT_ButtonUnknownZero) and returns (cmp [isHost], ebp; jeat 0x0042AFBF). The draft set the mark and went on. It drew the host's Load button for guests too: dimmed, and lit once everyone was ready. On the dimmed path it also cleared the mark again behind the switch.drawBufferChoiceValuetoRT_SCREEN_MENUand cleared the mark there. After button 1's dimmed draw and after 413's draw, that undid theRT_MAP_GAMEwhichRenderCurrentButtonToScreenMenuWithBlendingUnkleaves behind.Not a fix: the draft's
- 1in the map index of the buttons 4 and 105. main's header has since movedDAT_ArrayOfMapIndicesfrom 0x884 to 0x880 (it is now 501 entries long), so the same address is now written[offset + selection].Read case by case against the jump table, the draft's values are the original's: the conditions, the call arguments, the colours and the keep boxes (572 / 595, 3 / 35).
What got it to 100%
The draft has the buttons' conditions, the calls and their arguments, and most of the original's returns (see above). The control flow is rewritten against the original instructions, in two steps on our dev branch (not public): 91.2%, then 100.0%.
edithrough the whole switch and pushes it forTTA_CENTERand for the down buttons.eax,ecx,edxin turn, block after block, as far as we can tell. After that it joins the cases whose code came out the same: -100 into the call of -1, and -11 with -101. That is what the original shows: its jump table sends -100 into the middle of the block of -1, behind that block's mode check (0x0042AF64), and its four remaining blocks read the blend intoecx,edx,ecxandeax(0x0042AF41, 0x0042AF64, 0x0042AF87, 0x0042AF9D). Only this order, or the same with -11 and -101 swapped (the same code), gives those four registers; written as the original's four blocks, the turns are off by one from the third block on, and with them every temporary in the cases behind it.neg/sbb); the original branches. Once the scroll cases are as above, button 3's two calls get the original's registers by themselves (y inedxand ineax, 0x0042B0B4 and 0x0042B0E4), and the compiler shares only the pushes before and after the colour (alpha, FALSE and 18 in front, and the tail from x on, 0x0042B0C4), as the original does.quick_diff reads 1.0000: 383 instructions against 383.
No line for
cmake/compiler-flags-gl.txt/GLlist, and 100.0% on it too (the same build with the line added). So it needs no line.cmake/function-visibility.txt(cmake: function-visibility.txt, which callers must see which callees' bodies #398) either: the manifest listsRenderCurrentButtonToScreenMenuWithBlendingUnkonly as the caller ofgetPictureNumberInGm.Kept as they are
mov [0x00ED31CC], ebpat 0x0042B109 and 0x0042B32D). A comment says so.buttonIDis the menu item's plain number, and no enum on main names these buttons. Each case has a comment that says what the button is, from the texts of the lobby's group (1 "Load", 2 "Main Menu", 3 "Ready", 4 "Launch Game", 105 "Send Map", 413 "Skirmish Masters") and from the click handler of our UI: three more functions at 100%: the lobby's start button, the save list's header and the mission rows #423 (0x00442640).INT_00b95950(one CHECK): a placeholder name; what it holds is below.What some placeholders hold
INT_00b95950: the keep under the mouse on the map preview, set by button -200. The minimap (General_MenuMiniMap, on main) draws that keep highlighted and sets it back to -1 after each draw. gynt's reimpl/Wilps-2026-10-18 has it asDAT_LobbyMinimapHoveredKeepIndex, a name for Ghidra's side.DAT_ButtonUnknownZero: a mark set for a button that is not drawn or not live in the current state; cleared in front of the switch.GameSynchronyState::DAT_PlayerSlotArraySomeValue: zero for a player who is not ready (buttons 1, 4 and -20 read it so).GameSynchronyState::unknownMapRelatedReceivedDataArray: indexed by the selected map; button 4 is dimmed while the entry is zero or less, and button 105 is only drawn while it is zero. The Launch Game handler (0x00442640, UI: three more functions at 100%: the lobby's start button, the save list's header and the mission rows #423) starts the game only when the entry is above zero.Other PRs
🤖 Generated with Claude Code