Repository navigation
One more UI::MenuItems function at 100%: InGameMenu ProcessScribeAnimationChange - #468
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange, rewritten against the original instructions from Gynt's draft (d5895e2 at 29.4%, the file's newest commit on his fork's reimpl/UI-MenuItems; before it 24.6% at 668d05f, 26.74% at cee8a6a and 35.68% at 1831d14; 29.1% at 8725ec5 on his reimpl/UI-MenuItems-development; the 24.6% text, as cf563c2, on 20 of his other branches). The rewrite was first in our draft sourcehold#328 (85.2% at ecef1ca, 93.3% at b730ba6). One thing in the behaviour differs from his newest copies, as the original has it: the frame's copy (scribeAnimationFrameCopy) gets the frame after a step of phase 0 or 2, where his 29% texts (from 65a026c on) compare and store a local that those steps do not update (the original: 0x0043352B and 0x00433545 with the stepped value). The returns he got right himself: his 24.6% text has empty bodies for the three returns (0x00433378, 0x00433381, 0x004333AF), which he restored in cee8a6a (the 60 ms one) and 1831d14 (the game modes); cee8a6a also returned behind every step and at a sequence's end, which he took out in 65a026c ("switch was unreachable"), as the original has it (0x00433485, 0x0043348A, 0x0043352B). Here the returns are the original's. The 93.3% text had the original's 129 instructions with one difference: the zero the compiler keeps in a register was in ebp, where the original has ebx (0x0043338F), and ebx was unused. Here: - the phase is the global itself at each use, not a local that is loaded from it and stored back. A local is one more candidate for a register and took one in front of the zero; with the global the compiler keeps the phase in edi itself (0x004333B5, 0x00433472) and the zero gets ebx; - the frame is written the same way (a local for it gives the same listing); - each entry of a setting's sequence is read into a local and tested (the 93.3% text read the table twice, which this form no longer needs); - the phase switch's cases are in the order 0, 1, 2, as the animation runs (the same listing). No line for cmake/compiler-flags-gl.txt: the file reads 100.0% off the /GL list, and 100.0% on it too. reccmp in a build of main's whole /GL list (the 133 files that exist) and this file, off the list, with every resolver of those files on: 144 functions, average 99.56. The function 100.0% raw and normalised, no differing line, and the same with the file on the list. The other 143 functions of main's list read the same as without the file. 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> Co-Authored-By: Claude Opus 5.5 <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. One behaviour fix against gynt's newest drafts: they leave the frame's copy one step behind after a step of phase 0 or 2 (in the code; the game most likely never enters those phases, below). His older copies return in the wrong places too. He fixed both of those himself, but the oldest copy is still on sourcehold'sreimpl/UI-MenuItemsand on 20 of his fork's branches.InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChangesteps the scribe's animation in the in-game menu. While a tax setting is animated it moves the frame every 60 milliseconds through three phases; otherwise it sets the frame that shows the player's popularity. It is from gynt's draft on his fork'sreimpl/UI-MenuItems, and the commit credits him as co-author.InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange/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.57 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).MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChangereads 100.0 raw and normalised there too, with no diff entry; it has no caller in code. Two functions on main read lower, and it is how reccmp prints a constant, not their code:Menu::handleMenuItems(0x004F6280) reads 97.9 (91.4 normalised) andMenu::Constructor_Menu(0x004F4100) reads 98.4 (95.2), both 100.0 before. Both compare a menu item's type with the constant 0x11000000, and in this build's layout a symbol of our DLL lies at exactly that address, so reccmp prints the constant as that symbol's name on our side; the instructions are the same on both sides, as UI: three more functions at 100%: the building menu's DoInitial, the credits' prepare and activateModalDialog2 #435 and UI: the credits scroll's fade and the win/defeat window at 100% #437 describe. Every other main function reads exactly what it read before (unrounded 99.5746 against 99.5759 raw and 99.5439 against 99.5492 normalised; with those two at 100.0 it would be 99.5761 and 99.5494)./GLlist that exist on main, and this file, off the list: 144 functions, average 99.56. The function reads 100.0% raw and normalised, with no diff entries, and the same with the file on the list. The same build without the file has 143 functions, and each of them reads the same. The builds had this file with one comment worded differently; quick_diff gives the same 129 instructions, line for line, for that text and for this one. The first cut (other comments, the phase cases in the order 2, 1, 0, the parameter namedbutton) read the same in the same two builds. The sources were main's at 3458fea; main's two commits since (02fab42, 812d149) add cmake files only, with the new option off. main has since gained 25d2e9e (feat(import): update requirements and documentation of tools/import #456), which changes onlytools/import.Against the drafts
The function is rewritten against the original instructions; the rewrite was first in our draft #328. Against gynt's newest copies one thing in the behaviour changes, and it is what the original does. His older copies also differ in where they return. He fixed those himself, and the returns here are the original's:
scribeAnimationFrameCopywith the frame and stores the frame there. In his 29% texts (from 65a026c on: 29.41%, 29.4% and 29.1%) the value compared and stored is a local that the two stepping phases do not update: when phase 0 or phase 2 moves the frame one up or down, the copy gets the frame from before the step, socountdownis set one step late. The original has the new frame in the register it compares and stores (0x0043342B to 0x0043343F, 0x0043345C to 0x00433470, then 0x0043352B and 0x00433545). Here the frame is the global itself, so the copy gets the new frame. In the game this most likely never shows. The only code that starts a setting,Helpers::SetTaxesSetting_unknown(0x00433560), starts it in phase 1, and the exe has no other store toscribeAnimationPhasethan this function's= 1(0x00433477). So phases 0 and 2 do not seem to run.The rest is the same: the same tests, the same three phases, the same sequences for the three settings.
What got it to 100%
Our draft's last text read 93.3%: the original's 129 instructions, with one difference. The zero that the compiler keeps in a register was in
ebp, where the original hasebx(0x0043338F), andebxwas not used at all.scribeAnimationPhaseand stored back with it. A local is one more value the compiler wants to give a register: it got one, and the zero got the next. With the global written at each use the compiler keeps the phase inediitself (0x004333B5, 0x00433472), as the original does, and the zero getsebx: 129 instructions against 129, no difference.scribeAnimationFrameat each use. For the frame a local gives the same listing; the global is the plainer text, and it is what makes the copy's fix above plain to see.eaxthere, behind itsmov eax, ecx). In this form the local gives the original's instructions.quick_diff reads 1.0000: 129 instructions against 129.
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 function calls no game function, onlytimeGetTime.Kept as they are
slotis a local: written out at its two uses, the zero is no longer kept in a register of its own and the match is lost (127 instructions).nowis aDWORD, and the 60 millisecond test casts the difference toint: the original compares it signed (jlat 0x004333AF).What some placeholders hold (nothing changed here)
GameCore::taxesSettingUnk: 0 while no setting is animated; 1 to 3 chooseScribeAnimationFrames1to3. It is set byHelpers::SetTaxesSetting_unknown(0x00433560, on main), and only while it is 0. Its callers pass 1, 2 or 3 (the calls at 0x0043AA4F, 0x0043B409, 0x004460DF and 0x004460F1). The same function sets the phase to 1,scribeAnimationFrame2to 0 andtaxestimeUnkto the time. gynt's Wilps branch calls itscribeReactionType.ScribeAnimationFrames1to3: frames 12 to 22, 23 to 33 and 34 to 44, each ended by a 0. The popularity's frames are 1 to 11, hence the> 11in phase 2 (a comment in the code says so).GameCore::scribeAnimationPhase: 0 moves the frame to 6, 1 plays the sequence, 2 moves back to the popularity's frame.GameCore::scribeAnimationFrame2: the place in the sequence.GameCore::taxestimeUnk: the time of the last step (gynt's Wilps branch:scribeAnimLastTickMs).GameCore::countdown: set to 1 when the frame changed ormonthChangedis set.GM_SIEGE_THAT: the game mode 6, as main'sGameMode2.hppnames it.Other PRs
🤖 Generated with Claude Code