Repository navigation
Reimplement 3 UI::MenuItems functions from gynt's drafts (not yet 100%) - #328
Draft
kotijekriv wants to merge 92 commits into
Draft
kotijekriv wants to merge 92 commits into
kotijekriv wants to merge 92 commits into
Conversation
Used by the drafts in the companion development PRs: LobbyscreenStartButtonClick and CrusadeMap_Main play sound 253 when they switch to the rankings screen. The LobbyscreenStartButtonClick draft wrote it as SEID_UNIT_DAMAGE3 | SEID_ARROW_SHOOT (248 | 5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lobby's keep-position drag keeps the dragged player's position in DAT_00b95960 (-1 for none, compared signed: cmp/jl at 0x00442A29) and its slot index in DAT_00b95f64 (an array index). DAT_00b95b74 is the map description's height, used signed in the scroll limit. General_MenuMiniMap reads DAT_00b95960 here; the other users are drafts in the companion PRs (LobbyscreenStartButtonClick, MapEditorProperties_MainButtons, SingleplayerMapChoice_ButtonsAndHands). On main, DisplayMapDescriptionAndAllocatePlayersToSlots stores to DAT_00b95b74 and compiles to the same instructions with the int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; register allocation and structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; register allocation and structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al pass; structure gynt's draft. Compiles at a521bf7 again (GameModeInt include). The map-name extension is a strcat with the string-macros.hpp literal (the draft's hand-made scan and strcpy into the end), and auto_backup_map.map is STR_AutoBackupMap; quick_diff 0.6907 -> 0.7065. The rest is the mechanical pass. Both PlayerSlotUnitColor copies are for loops (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again: the menu tabs to switch to are ActiveMenuTab structs now (.tabType). auto_backup_map.map is STR_AutoBackupMap; the rest is the mechanical pass (identical code). The player IDs are set by a for loop (identical code). Re-measured on main 06d4938, where sourcehold#319 and sourcehold#322 reimplement callees of this function: 50.6% -> 53.2% (same code as before). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again: the byte the draft wrote through units[0x9bb].field_0x3e3 (a field the header no longer has) is addressed from that unit's start + 0x3e3, the same address; the target is not really in a unit, see the PR text. The rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BuildMenu_UnitActionButtons' render function tests the selected unit's type against -1 (no unit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InGameMenu_PeasantBuildAndRightClickMenuSelection compares the active build-menu tab with 49. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It copies the text it is given into the active text slot and does not write to it (0x00472C30), so its parameter is const. EditScenario_BaseMenuButtons passes the string pointer for "", which is const; readUserConfig on main passes a char* and compiles to the same code (quick_diff identical). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again: getResourceSpace takes a ResourceType now (the draft passed (int*)(int)x). Gold is RT_GOLD; the rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass; the no-unit test uses UT_NONE (header commit). quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again (InGameEventUnionVersion using). The %d and empty strings are their string-literals.hpp pointers (copyIntoTextArray takes a char const* now, header commit), the starting resources are indexed by RT_GOLD / RT_PARTIALPITCH; the rest is the mechanical pass. The new event's condition stores name their fields (conditions[k].subType and .enabled) instead of byte offsets, identical code; conditions 5-7 stay written out, since a for loop loses the match (quick_diff 0.6452 -> 0.5879). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again (AlphaAndButtonSurface's processBuildingClickBonus and selectUnitAndOpenStatusMenu were renamed). Tab 49 is BMTT_UNKNOWN_49 (header commit); the rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. The group maximum and the group count are for loops and the copy of the saved groups is a memcpy (67.4% -> 71.2% in the combined build). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass; no pending token is HTT_NONE (header commit), and the character tests compare with 32 without a HelpTextToken cast. quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SelectCrusade_Main clears the menu tab to switch to with 0 (no tab), and MissionEndscreen_Main stores 0 into the active tab. The ChooseNetworkServiceProvider_Buttons draft in the companion development PR uses it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. The PlayerSlotUnitColor copy is a for loop (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. The cost tests are for loops (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… are ints The map editor compares the active brush and the affect type signed (jle at 0x00431563 and 0x004315E3, jge at 0x004317D3) and halves the brush with sar. switchToMenuView on main and InGameMenu_MainButtons here compile to the same code (quick_diff identical); the other users are drafts in the companion development PRs (MapEditorLandscaping_GeneralButtons, MapEditorLandscaping_QueueCommandCallback). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e ready PR BuildMenu::MenuItemRenderFunction_BuildMenu_UnitActionButtons (0x00438BE0) reaches reccmp 100.0 (normalized 100.0) on main 3458fea and goes out with the ready branch reimpl/UI-B-round29-100 (ea07ba3). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…; two behaviour fixes; two /GL lines TextEditor::MenuItemActionHandler_TextEditor_TextInputRelatedUnk, 40.9% to 90.2% (71.2% normalized), written from the original's listing. gynt's drafts: a3e51bf at 39.44% ("Style pass, asm differs") on his fork's reimpl/UI-MenuItems, whose status line records 39.4%, and ccd2b04 at 40.92% ("comparison operand order") on his fork's reimpl/UI-MenuItems-development, whose status line records 40.9%; the newest commit on the file there is dd1a7c4. Our draft (61df885, then 084c469) was his code with a mechanical pass. The function handles one key of the help window's text. With the alternate tab off it only scrolls the text (keys 244 to 251, through the jump table at 0x00461984). Otherwise it edits the custom text (keys 240 to 249, jump table at 0x004619A4): a typed character is inserted, 240 and 241 insert a tab or a new paragraph token outside custom text mode, 242 / 243 move the cursor, 244 / 245 change the line, 246 / 247 go to the start or the end, 248 / 249 remove what stands in front of or at the cursor. Two behaviour fixes. Keys 248 and 249 move the rest of the text down in a loop, and the original runs that loop when index < length + advance (cmp ecx, edx; jge at 0x0046189E, and cmp ecx, edi; jge at 0x0046190D). The draft ran it when length > index + advance, taken over from ccd2b04; gynt's reimpl/UI-MenuItems has the original's test. With the draft's test a removal at the text's end did not copy the terminator down. It needs /GL. Behind three calls of helpToken_getHelpTokenAdvanceLength (0x0045F080) the original still has the cursor in edx (0x004617CE, 0x00461815, 0x00461894), so the caller must see that the callee leaves edx alone. This commit adds this file and helpToken.cpp to cmake/compiler-flags-gl.txt. With the two lines: 90.2%; without them: 69.0% (62.4% normalized). helpToken.cpp's two functions (0x0045F080, 0x0045F0D0) read 100.0% with the lines. What the match needed: - First half: 244, 247 and 250 assign one offset variable and leave by break to one store behind the switch; 245, 246 and 251 store themselves. With 244 and 250 storing themselves the shared zero block sits behind 244 instead of 250 (85.0%); with 245 and 251 breaking too 72.9%; with 246 breaking 64.3%. 247 reads the same either way and breaks. The first half matches completely. - Second half: the cursor index is read from the state each time in 242, 243, 248 and 249. In a local: 76.8%. - The insert is one block, entered from 240 and 241 by goto, because the original has one copy of it with the character in a register (mov esi, 9 at 0x00461728, mov esi, 6 at 0x0046173B, both jumping to 0x004616F7). Behind a flag: 75.5%. Written out three times the compiler pushes the constants and nothing merges: 67.7%. - The length test is one || test whose body is the insert block. Left, with 285 instructions on both sides (up to the last ret, alignment fill included): the character sits in edx in ours and in esi in the original, so the inlined wcslen's temporary (0x004616D6), the shift loop's temporary and one pair of loads use other registers; and the insert's entry test (0x004616F7) stands where the typed-character path falls into it in the original, behind 241 in ours. Tried for both without gain: the insert behind a flag (the entry test lands right, the loop goes behind the switch), the label in four places, for / do-while / while, the text pointer in a local (the character gets esi, the pointer takes edx), an unsigned character, the length test nested or with locals, locals for the pending token, the converted character and the loop's moved character, the pending step as an inline helper. A lead for the register: with one more call on the typed-character path that the compiler cannot see into, the character goes to esi and every register behind it is the original's, but the text pointer's early load (0x00461699) is lost. So in the original something on that path costs edx without touching memory; the call of helpToken_getHelpTokenAdvanceLength there does neither in ours. Measured in a narrow build of this file as committed and helpToken.cpp, on main 3458fea, struct resolvers and the three functions' resolvers on, both files in the /GL list. No all-on build was run with the two new /GL lines. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… the ready PR MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MainButtons (0x00443070) reaches reccmp 100.0 (normalized 100.0) on main 3458fea and goes out with the ready branch reimpl/UI-B-round31-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…eUnk to the ready PR General::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk (0x00494950) reaches reccmp 100.0 (normalized 100.0) on main 3458fea and goes out with the ready branch reimpl/UI-B-round32-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…y PR NewEventCondition::MenuItemActionHandler_NewEventCondition_Main (0x004B9620) is rewritten on main 3458fea and goes out with the ready branch reimpl/UI-B-round33-100: its code is the original's, recorded as 100% (reccmp shows 99.8, one resolved address is named differently on the two sides). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…; six behaviour fixes; four instructions left MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback, 23.3% to 94.7% (66.1% normalized), written from the original's listing. gynt's draft: 0938952 at 23.29% ("Style pass, asm differs") on his fork's reimpl/UI-MenuItems, whose status line records 23.3%; his reimpl/UI-MenuItems-development records 23.3% too ("Reimplemented, asm differs"; the newest commit on the file there is 8725ec5). Our draft (3f2ac05, then 5fca8b9) was his code with a mechanical pass. The function is the landscaping view's callback in the map editor. It handles the mouse's event (lowered view, map rotation, zoom, flat view), switches the "people left to place" element, previews the mapper under the mouse while no button is down, and on a left click queues the mapper's command: one switch over currentMapperCommand, 33 blocks through the byte table at 0x0044432C and the jump table at 0x004442A4 and two (340, 341) through compares. Every block fills the command's params (x, y, the brush size or a constant, two more) and calls queueCommand. Six behaviour fixes, each visible in the draft's own listing: - Event 5 (the flat view) returned right after toggleFlatView. The original goes on: it sets the handled flag and runs the rest (0x00443AE8 falls into 0x00443AED). - The "people left to place" element was switched with `2300 < unitCount`. The original has `>= 2300` (cmp with 0x8fc, jl at 0x00443AFD). - No return after HandleWallTerrainMouseDrag: the original leaves through it (a tail jump at 0x00443B1C). - No return after storeXYAndResetMouseState: the same (0x00443B31). - No return after renderWallPlacementPreview: the original returns (0x00443BF2); the draft ran on into the click part. - The river, foam and ripple case had no return after its first queueCommand: for the river and the ripple it queued their GCT_SET_TERRAIN and then a second one with param 4 = 16, the foam's. The original queues once on each path: the foam's call at 0x00443F7D with a ret at 0x00443F85, the other two's at 0x00443FA9 with a ret at 0x00443FB1. What the match needed. The counts are differing lines out of the original's 508 instructions in our own exact listing compare (operands, jump landings and the jump table included), not reccmp numbers: - The two 0 / 1 arguments are an if / else with a call in each arm (resetupViewport(0) / (1), and the element's call with 1 / 0). The compiler shares the call and pushes the constant in each arm, and with that it keeps 0, 1 and 2 in ebx, esi and edi for the function's first half, as the original does. As conditional expressions it emits sete / setge and the constant registers are gone: 678 against 43. - Two pairs of tile variables: a const pair for the click's start and copies for the snapped tile. With one pair x and y stay in edi and esi and the compiler merges every case into one tail (393 instructions, 386 lines). - The click part's locals are read in the order snap, orientation, tile y, tile x: 43 to 39. - The switch is on the field, and the cases read the field again. With a local the command sits in edx instead of esi through all the cases: 39 to 8. - Every case is written out in full, params in the order 0 to 4, then the call and a return. The shapes of the original's cases come from that by themselves: the scratch register for the brush size rotates from case to case (eax, ecx, edx); with eax the x store comes first, with ecx the y store; and the compiler shares the cases' tails with the last case's code (0x00444266 to 0x00444298), which 16 jumps enter at four places. Cases with a constant in place of the brush size do not advance the rotation. Left: four instructions in two places of the click part, 8 lines of that compare. - The second leftClickStart test (0x00443C1C) compares with ebx, the zero register, in the original and with an immediate 0 in ours. In ours the load of the orientation into ebx counts as coming first. - The logic layer's index goes through eax in the original and through edx in ours: three instructions (0x00443C5B, 0x00443C62 and 0x00443C6E). Tried for the first: the test as a truth test, through a local copy (BOOLEnum, bool, int), the four locals in every order and with other types, and the locals assigned in both arms of the test, all four or any subset. Only the last form gives the compare with ebx, and then the orientation's load comes after the tile's two (in all 24 orders). Tried for the second, without any change: the index in a local, through a helper, with the operands the other way round, in the variable that later holds x, the valid test in a local or as one condition with the logic test, and xyAreValid called without the macro. A /GL build with the nine finished callees reads 54.7%, and xyAreValid's body visible as an inline copy changes nothing, so neither is the cause. The reccmp diff has 82 lines: these four instructions, and every jump over them and every jump table entry after them, which the one byte of the longer compare shifts. Measured in a narrow build on main 3458fea of this file as committed and the nine finished functions it calls, struct resolvers and their resolvers on: xyAreValid, setupMouseTileXY, queueCommand, HandleWallTerrainMouseDrag, storeXYAndResetMouseState, CheckDisplayElementByIDAndSetForUnlimitedDisplay, resetupViewport, toggleFlatView and setMapRotation. Seven of them read 100.0; queueCommand (99.1) and resetupViewport (43.8) read what they read in main's own all-on build. No all-on build was run for this commit. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… to the ready PR LobbyMenu::MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons (0x00427810) reaches reccmp 100.0 (normalized 100.0) on main 3458fea and goes out with the ready branch reimpl/UI-B-round35-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Allies::MenuItemRenderFunction_Allies_Main (0x004AC7A0) reaches reccmp 100.0 (normalized 100.0) on main 3458fea and goes out with the ready branch reimpl/UI-B-round36-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e ready PR General::MenuItemRenderFunction_General_AdvancedGameOptions (0x00428AC0) reaches reccmp 100.0 (normalized 100.0) on main 3458fea and goes out with the ready branch reimpl/UI-B-round37-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… both arms of the click test MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback, on top of 356f824 (our rewrite from the listing with gynt's draft; his draft: 0938952 at 23.29% on his fork's reimpl/UI-MenuItems, and the newest commit on the file on his reimpl/UI-MenuItems-development is 8725ec5): the orientation is no longer read in front of the second leftClickStart test but in each arm of it. Read in front of the test, it took ebx, so the test compared with an immediate 0; read in the arms, the test compares with ebx, the zero register, as the original's does (0x00443C1C). The code does the same: in both arms the field is read before anything there can change it. 94.7% to 99.5% (66.1% to 89.2% normalized). Our exact listing compare (operands, jump landings and the jump table) still counts 8 differing lines, but other ones: the compare is the original's length again, so every jump over it and every jump table entry after it lands where the original's does, and reccmp's diff goes from 82 lines to 8. Left, the 8 lines of that compare: - The compiler loads the orientation into ebx after the tile's y and x (0x00443C3A); the original loads it second, after the snap mode (0x00443C28). The load waits for the compare that reads ebx and then goes behind every load that was ready before it. Not moved by: the reads in the arms in all six orders, other orders of the reads in front of the test, the tile's y and x or the snap mode read in the arms too, different orders in the two arms, or the test negated with its arms swapped. - The logic layer's index goes through edx where the original has eax (0x00443C5B, 0x00443C62 and 0x00443C6E), as before. Not moved by: the index or the logic value in a local, the valid test's result in a local, or x and y given their values elsewhere. Measured in a narrow build on main 3458fea of this file as committed and the nine finished functions it calls, struct resolvers and their resolvers on, as for 356f824. No all-on build was run for this commit. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange (0x00433370) reaches reccmp 100.0 (normalized 100.0) on main 3458fea, off the /GL list and on it, and goes out with the ready branch reimpl/UI-A-scribe-100 (f9fabb0). The last difference, the zero in ebp, went away with the animation phase written as the global itself at each use instead of a local copied from it and stored back. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 22, 2026
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.
Three of gynt's UI::MenuItems drafts from his fork (
reimpl/UI-MenuItemsand-development), brought ontomainso others can continue from them. No header changes. Two lines are added tocmake/compiler-flags-gl.txt(see TextInputRelatedUnk below the table).Two more are at 100% now and left this draft for #434 (106a282, c5e065d): PeasantBuildAndRightClickMenuSelection (0x00434350) and ScenarioDescription's render function (0x004D8250), both rewritten from the binary here first. A third followed in #439 (8f1e257): LobbyMenu's MapSelectHeader (0x00440A50), rewritten from the original's listing. A fourth followed in #440 (d7cff49): BuildMenu's UnitActionButtons render function (0x00438BE0), rewritten from the original's listing. A fifth followed in #441 (1319211): MapEditorProperties' MainButtons handler (0x00443070), rewritten from the original's listing; that PR also gives the description box's handler its parameter list in the header. A sixth followed in #442 (76eb7a7): General's LaunchOrQuitMultiplayerGameUnk (0x00494950), rewritten from the original's listing, with one behaviour fix (the draft never reached its case for the question -7). A seventh followed in #443 (3919ea8): NewEventCondition's Main handler (0x004B9620), rewritten from the original's listing; that PR also gives the event conditions' option table its
int[32][25]type in the header. An eighth followed in #446 (dd901ee): LobbyMenu's PlayerListAndNpcButtons render function (0x00427810), rewritten from the original's listing, with seven behaviour fixes (its ranges of item numbers were not chained). A ninth followed in #447 (98ffddb): Allies' Main render function (0x004AC7A0), rewritten from the original's listing, with behaviour fixes (most of the draft's ranges of item numbers had no return). A tenth followed in #448 (b250213): General's AdvancedGameOptions render function (0x00428AC0), rewritten from the original's listing, with behaviour fixes (most of its items had no return, and one never returned). An eleventh followed in #468 (86e650b): InGameMenu's ProcessScribeAnimationChange handler (0x00433370), rewritten from the original's listing here first (b730ba6, 93.3%); its last difference, the zero's register, went away with the animation phase read and written as the global itself.Rewritten from the binary (3):
/GLlines; see below the table.No mechanical draft is left. Every commit body says what changed.
Functions
Every number in the "Measured raw" and "Normalised" columns is from a narrow build on main 3458fea; the all-on build described below (ecef1ca) has none of the three as they are now. The head is 86e650b now: on top of ecef1ca two move-out commits, then b730ba6, which changes ProcessScribeAnimationChange, then a third move-out, 8f1e257, then 077d2c3, which rewrites AlliesSendAndRequestGoods_Main, then a fourth move-out, d7cff49, then 48fac64, which rewrites TextEditor_TextInputRelatedUnk, then a fifth, a sixth and a seventh move-out, 1319211, 76eb7a7 and 3919ea8, then 356f824, which rewrites QueueCommandCallback, then an eighth, a ninth and a tenth move-out, dd901ee, 98ffddb and b250213, then cc33a2b, which changes QueueCommandCallback, then an eleventh move-out, 86e650b. None of the eleven move-outs changes a source file that is left. QueueCommandCallback's numbers are from cc33a2b, in a narrow build on main 3458fea of that file as committed together with the nine finished functions it calls, with the struct resolvers and those functions' resolvers on. AlliesSendAndRequestGoods_Main's numbers are from 077d2c3, in a narrow build of that file as committed, alone, on main 3458fea. TextEditor_TextInputRelatedUnk's numbers are from 48fac64, in a narrow build on main 3458fea of that file as committed together with helpToken.cpp, both in the
/GLlist, with the struct resolvers and the three functions' resolvers on. "Best before" is the best score on gynt's and 6and8's branches, as recorded in the earlier version of this text.MenuItemRenderFunction_AlliesSendAndRequestGoods_MainMenuItemActionHandler_MapEditorLandscaping_QueueCommandCallbackMenuItemActionHandler_TextEditor_TextInputRelatedUnk/GLbuild on main 3458fea)AlliesSendAndRequestGoods_Main: two behaviour fixes, and what is left. The draft, like gynt's text on both of his branches, tested
actionParam < 20for the resource buttons where the original takes the numbers up to and including 20 (cmp esi, 0x14; jgat 0x004AD925), so button 20 was not drawn. And in the panel's frame it returned where the original goes on to the next column (cmp esi, 7; jeto the loop's step at 0x004ADAF6), which ended the whole function at a middle row's second column: no further rows, no box and no text. Both are fixed in 077d2c3, which writes the function from the listing. Both sides have 359 instructions now. What is left is three scratch registers from the amount test on: the original has the amount ineax, the y inecxand x + 36 inedx; ours has x + 36 ineaxand the amount inedx. The three text calls behind them are rotated by one: TEXT_ALLIES 14 at 0x004ADB79, TEXT_ALLIES 13 (the goods <= 0 case) at 0x004ADBA1 and TEXT_GOODS at 0x004ADC2C. The compiler ranks the two coordinates above the amount (keys 64 and 54) and serves it last; in the original it is served first. The commit body lists what was tried.TextEditor_TextInputRelatedUnk: two behaviour fixes, two
/GLlines, and what is left. The function handles one key of the help window's text: with the alternate tab off it scrolls, otherwise it edits the custom text.index < length + advance(cmp ecx, edx; jgeat 0x0046189E, andcmp ecx, edi; jgeat 0x0046190D). The draft ran it whenlength > index + advance, taken over from ccd2b04 on gynt's reimpl/UI-MenuItems-development; his reimpl/UI-MenuItems has the original's test. With the draft's test a removal at the text's end did not copy the terminator down./GLlines. Behind three calls ofhelpToken_getHelpTokenAdvanceLength(0x0045F080) the original still has the cursor inedx(0x004617CE, 0x00461815, 0x00461894), so the caller has to see that the callee leavesedxalone. 48fac64 addssrc/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cppandsrc/OpenSHC/Text/TextEditorState/helpToken.cpptocmake/compiler-flags-gl.txt. With the two lines the function reads 90.2%, without them 69.0% (62.4% normalised). helpToken.cpp's two functions (0x0045F080 and 0x0045F0D0) read 100.0% with the lines, in the same narrow build.ret, alignment fill included, and the scrolling half matches completely. In the editing half the typed character sits inedxin ours and inesiin the original, so the inlinedwcslen's temporary (0x004616D6), the shift loop's temporary and one pair of loads use other registers. And the insert's entry test (0x004616F7) stands where the typed-character path falls into it in the original, behind key 241's code in ours.esiand every register behind it is the original's, but the text pointer's early load (0x00461699) is lost. So in the original something on that path costsedxwithout touching memory.mov esi, 9at 0x00461728,mov esi, 6at 0x0046173B, both jumping to 0x004616F7). The draft had three gotos; the rewrite has two, both to that block. With the insert behind a flag the function reads 75.5%, with the insert written out three times 67.7%.QueueCommandCallback: six behaviour fixes, and what is left. The function is the landscaping view's callback in the map editor: it handles the mouse's event, previews the mapper under the mouse, and on a left click queues the mapper's command through one
switchwith 35 blocks.toggleFlatView. The original goes on and runs the rest (0x00443AE8 falls into 0x00443AED).2300 < unitCount. The original has>= 2300(cmpwith 0x8fc,jlat 0x00443AFD).HandleWallTerrainMouseDragand afterstoreXYAndResetMouseState(the original leaves through each with a tail jump, 0x00443B1C and 0x00443B31), and afterrenderWallPlacementPreview(0x00443BF2). The draft ran on into the code after them.queueCommand: the river and the ripple queued theirGCT_SET_TERRAINand then a second one with the foam's param (16). The original queues once on each path (0x00443F7D with aretat 0x00443F85, 0x00443FA9 with aretat 0x00443FB1).if/elsewith a call in each arm. With that the compiler keeps 0, 1 and 2 inebx,esiandedi, as the original does; as conditional expressions it emitssete/setge.switchis on the field, with no local for the command.leftClickStarttest (cc33a2b). Read in front of the test, it tookebx, and the test compared with an immediate 0. Read in the arms, the test compares withebx, the zero register, as the original's does (0x00443C1C). The compare is the original's length again, so every jump over it and every jump table entry after it lands where the original's does: reccmp's diff went from 82 lines to 8, and the function from 94.7% to 99.5%.eaxin the original and throughedxin ours: three instructions (0x00443C5B, 0x00443C62, 0x00443C6E)./GLbuild with the nine finished callees reads 54.7%, so/GLis not it. The two commit bodies list what else was tried.Moved out of this draft since the last version of this text
MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChangeMenuItemRenderFunction_General_AdvancedGameOptionsMenuItemRenderFunction_Allies_MainMenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtonsMenuItemActionHandler_NewEventCondition_MainMenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnkMenuItemActionHandler_MapEditorProperties_MainButtonsMenuItemRenderFunction_BuildMenu_UnitActionButtonsMenuItemActionHandler_LobbyMenu_MapSelectHeaderMenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelectionMenuItemRenderFunction_ScenarioDescription_MainMenuItemRenderFunction_VideoOptions_MainMenuItemActionHandler_ChooseNetworkServiceProvider_ButtonsMenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHandsMenuItemActionHandler_CrusadeMap_MainMenuItemRenderFunction_InGameMenu_MainButtonsMenuItemActionHandler_Roundtable_MainMenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHandsMenuItemActionHandler_AlliesSendAndRequestGoods_MainMenuItemRenderFunction_SiegeAttackingForceAndStartGoods_MainMenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHandsMenuItemActionHandler_VideoOptions_MainMeasured
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cppand helpToken.cpp, both compiled with/GL, with the struct resolvers and the three functions' resolvers on. The all-on builds above have it as it was at ecef1ca, at 40.9%, and without the two/GLlines. No all-on build was run with the two new/GLlines, so their effect on the other/GLfunctions is not measured.Two readings that are lower than on current main
Both functions read 100.0 raw and normalised in an all-on build of main f489b72 (3458fea only adds files under
tools/). They read lower in all three builds above: e086ba7, a8b3225 and ecef1ca.UpdateFireBallistaBuildingmov edxfrom an int global sits at a different placeMenuItemActionHandler_InGameMenu_MainButtonsjmpdistance, -0x8a6 against -0xa8aWhat we know: the base commit alone shows both readings, so neither comes from this draft's functions. The source files of these two functions are the same on e086ba7, on this branch and on main.
What we don't know: why the same source reads 100 on current main and lower on e086ba7.
UpdateFireBallistaBuildingis compiled with/GL, and we are still testing whether the symbol-count effect from #366 explains its move. We have not rebuilt this branch on top of current main.🤖 Generated with Claude Code