Repository navigation
Reimplement UI::Rendering TextureRenderCore's renderUnitAnimationWithBlendingUnk from gynt's asm draft (draft, below 100%) - #363
Closed
kotijekriv wants to merge 10 commits into
Conversation
… path's surface pointer fixed Draft. renderUnitAnimationWithBlendingUnk blends a unit animation's TGX picture into the surface with the player's colour palette; four asm loops (RGB555 and RGB565, zoomed and not). From gynt's renderUnitAnimationWithBlendingUnk.cpp in 3c9bcdb (origin/reimpl/TextureRenderCore, 2026-10-04, 91.5% there, "Four asm loops recovered, stack slot allocation differs"). Fixed: his two zoomed-path asm blocks load the surface pointer from width, which that path never sets (only the unzoomed path assigns width = the surface pointer), so they draw through the picture width as a pointer; all four blocks now read DAT_TextureRenderCoreObject::instance.currentRenderSurface, as the original does, and the two width assignments are gone. Also: main's colorPaletteOverride for his mbr_0x70; 32, 32 * 512, 512 and 4056 * 2 for 0x20, 0x4000, 0x200 and 0x1fb0; the two unused usings dropped. Left: the stack slots. The asm-only _columnOffset always gets -4 in our listing where the original has it at -16, between colorPalette and dstFilter, which moves the C locals by one slot each; its declaration position, a block scope and a (void) reference do not move it. The C part also keeps height in another register (the original holds it in edi from the first test on). Measured in a clean alone build of the branch on main 1c29459: 92.5% raw, 84.8% normalized. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… extra locals Draft. moveOverlappingMenuPartsToMapSurface copies the parts of the open menu tab that reach over the map from the menu surface onto the map surface, all but the magenta pixels; the copy loop is handwritten assembly in the original. From gynt's asm version in c2e5474 (origin/reimpl/TextureRenderCore, 2026-10-04, 68.0% there). Changed: the colour key read from COL_MAGENTA in the asm and the record index inline, which drops his two extra stack slots (the original has ten); the tab in a local, read once as in the original; the line jumps computed before the width is read again, which gives the original's store order before the asm; main's field_0x3014 rows ([55][8], so (tab - 1) * 5) for his field166_0x2dfc; 4056 for 0xfd8. Left: the original computes the record offset, lea [eax + eax*4 - 5] and shl 5, twice and keeps the - 5 in the lea; ours computes it once and folds - 160 into the addresses. Index spellings, the pointers computed before the -1 test and a [11][40] table shape do not change that. Measured in a clean alone build of the branch on main 1c29459: 84.8% raw, 67.4% normalized. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 2 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 2 of the 2 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 9 — Prefer
Rule 24 — Declare variables upon first use
|
…Core-development Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the original's shared blocks Draft. loadGMFile reads a .gm1 file, its header, the offsets, sizes and headers of its pictures and their data, and copies each picture's data behind the ones processed so far, or points it at the previous picture's or another one's data. Written from the original's instructions, with gynt's draft (63cc49f on his fork's reimpl/UI-Rendering-development, 84.5% there) for the reads. The two-way sharing test is one condition, which gives the original's one copy block and one sharing block (the draft's gotos measure lower: quick_diff 0.9326 -> 0.9091; nested if / else without them writes both blocks twice: 0.7759). DAT_GMImageSizes[picture + 115999] in the draft is DAT_GMImageOffsets[picture - 1], the previous picture's offset (the original reads [picture * 4 + 0x00D0BA0C]). Left: the original walks the picture headers with a pointer to alternativeImageIndexUnk and does not re-test (animatedColor & 4) after animatedColor == 0; ours points at animatedColor and re-tests. This file was measured as it stands in a clean alone build of the branch on main eef6f66: 93.1% raw, 79.7% normalized. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
…Core-development Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
Draft. moveOverlappingMenuPartsToMapSurface (adec92b, gynt's asm without his two extra locals) now takes the tab's record index, (tab - 1) * 5, into a local of its own for the four pointers. The original computes that index a second time after the -1 test (lea and shl again) instead of reusing the test's, and keeps the - 5 in the index rather than folding it into the addresses; with the index inline MSVC shares one computation, 98 instructions to the original's 100. The pointers are set up in the original's order (width, x, height, y). PR sourcehold#276's structural_diff.py now reads kind 1.000 with no instruction-mix delta (was 0.980, delta 2), and slot_map.py shows every stack slot at the original's offset. Left: the -1 test's own index still has its - 5 folded into the address (as a local, cast to a row pointer, as tab * 5 - 5, or as a second local, it folds the same). Measured in a build of the changed draft files alone on the branch (main e32319b): 96.5% raw, 88.1% normalized (was 84.8% and 67.4%). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
TextureRenderCore::moveOverlappingMenuPartsToMapSurface (0x00454F00) reaches reccmp 100.0 (normalized 100.0) on main 0e4a83b and goes out with the ready branch reimpl/UI-B-round50-100 (8a7edac). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TextureRenderCore::renderUnitAnimationWithBlendingUnk (0x00451E00) reaches reccmp 100.0 (normalized 100.0) on main 0e4a83b and goes out with the ready branch reimpl/UI-C-round17-100 (c41d2a3). Its file leaves this draft and its status line goes back to main's. It was the last function here, so the branch now matches main. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
gynt
added a commit
to kotijekriv/OpenSHC
that referenced
this pull request
Nov 24, 2026
* reimplement: SHC_3BB0A8C1_0x004559B0 100.0% Reimplemented TextureRenderCore::loadGMFile. gynt's drafts: 071726e at 77.8% on sourcehold's reimpl/UI-Rendering, and 84.5% in the status line of his fork's reimpl/UI-Rendering-development (63cc49f); the newest commit on the file, 15e5712, is on his fork's reimpl/UI-MenuItems-development. Our draft d29d51d (93.1%, in the draft PR sourcehold#363) was written from the original's instructions with his draft for the reads. What was left was the loop's test whether a picture shares another one's data. The original tests the flag first (0x00455B70). With the flag set it reads the colour byte once, into cl, and tests it twice: zero copies the picture, bit 2 (value 4) takes the previous picture's offset, anything else the alternative picture's (0x00455B82 to 0x00455B9A). Without the flag it tests bit 2 in memory and runs on into the same blocks (0x00455B9C). The draft had one condition, (flag && colour != 0) || (colour & 4): with it the compiler tested bit 2 again behind the zero test and based the header pointer on the colour byte. Written as the listing has it: - The flag's two arms, each with its own sharing and its own copying. The compiler merges the two copies of the copying and lets the second arm run into the first arm's stores, as the original does. With the copying written once the match is lost: behind the draft's one test quick_diff reads 0.9326, behind a flag variable or a continue 0.70 to 0.77. - The colour byte in a local in the flag's arm. Without it the rest is the same, but the copying adds its source address the other way round (0.9610 against 0.9714). Measured: quick_diff 0.9714 with 192 instructions against 193, also with the stack slots kept. What still differs there is not in the code: four calls through the import table, the jmp over the padding in front of the loop (0x00455B66), and the previous offset's address, which the original's listing shows folded (0x00D0BA0C). reccmp 100.0% (normalized 100.0%) alone, data resolvers and its own resolver on. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00440A50 100.0% Reimplemented LobbyMenu::MenuItemActionHandler_LobbyMenu_MapSelectHeader, rewritten from the original's listing. gynt's drafts: 7a1fcbd at 32.66% on his fork's reimpl/UI-MenuItems, and d0d28fd at 45.93% ("comparison operand order") on his fork's reimpl/UI-MenuItems-development, whose status line records 45.9%; the newest commit on the file, dd1a7c4, is on that branch too. Our draft c792435 (46.3%, in the draft PR sourcehold#328) was his code with a mechanical pass. The function sorts the lobby's map list by name, by players or by balance: on a click on a column or, with a negative argument, by a stored order again. The drafts had the decompiler's text, with seven iVar and two uVar locals. Written out with names, six things decide the match: - The non-negative arm stands first. The original falls through into the modal checks and jumps away for a negative argument (jl at 0x00440A64). - A stored order is compared after it is negated (neg eax at 0x00440B29, then cmp eax, 1 and so on). In each arm the source sets the column in front of the order. The listing loads the order's value first, then the column, and stores the order last (mov ecx, 4; mov eax, 2; mov [order], ecx, from 0x00440B5E); with the order set first in the source the match is lost. - In every bubble pass the second index is taken in front of the first, as the name sort's listing has it (0x00440D10). With the first one first the match is lost. - The players' sort reads the list's length in its loop condition each time (0x00440C8F); the other two sorts take it once. - The players' sort counts its seven tries in the parameter's own slot (mov dword ptr [esp + 0x18], 7 at 0x00440C29), which is why the argument is copied at the top (0x00440A57). A local for the tries loses the match. - The search for the chosen map is a plain for loop over the list that handles the hit inside (0x00440DC0 to 0x00440DFD). The drafts' while loop with a second test of the length has four instructions more. The sorts' repeat-until-nothing-swapped loops are for loops (for (int swaps = 1; swaps != 0;)), which compile to the same code as do-while loops. Measured: quick_diff 0.9766 with 253 instructions against 259. The six lines are the original's jmp over the padding in front of its loops, which our listing shows as padding; the rest is how the two listings print two constants and the tail call. reccmp 100.0% (normalized 100.0%) alone, data resolvers and its own resolver on. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
kotijekriv
added a commit
to kotijekriv/OpenSHC
that referenced
this pull request
Nov 24, 2026
…#480) TextureRenderCore::renderUnitAnimationWithBlendingUnk: blends a unit animation's TGX picture into the map or menu surface through the player's colour palette and a pair of rows of the blend filter arrays, picked by the blend strength. The four drawing loops (RGB555 and RGB565, zoomed out and not) are the original's handwritten assembly, as inline asm. From gynt's asm draft: his 91.5% 3c9bcdb ("Four asm loops recovered, stack slot allocation differs") on sourcehold's reimpl/TextureRenderCore, through our draft in sourcehold#363 (92.5%, 29ca840), which fixed his two zoomed-path blocks drawing through the picture width as the surface pointer. His newest version, 3d17527 (2026-11-02, with d90dce4's style pass on top) on his fork's reimpl/UI-MenuItems-development, is the decompiler's C form (6.0%, no asm); not used. What the match needed: - The zoomed path in an else block, with the column offset declared in it. The stack slots of the asm-referenced locals follow their reference weights, and every asm block adds to the weight of each local that any asm block writes, if that local is declared in a block that contains it (wherever in that block). At the top the column offset weighs more than the line width, the start height and the palette and takes their slots; in the zoomed block it falls behind them, as in the original (at the top: reccmp 95.8). - /GL with InitBlendFilterArraysUnk (100% on main): with its body visible the compiler keeps height in edi across the call, as the original does, and keeps the two surface arms' stores apart. - The map arm's stores with the heights last (with them first: 99.9), and the zoomed path's column parity first (after the heights: 98.8). Also: the header's parameter names, isZoom2 tested by truthiness, the TGX token constants and C hex in the asm, labels by what they do, no leading underscores, the filter rows as array indexing, declarations at their first assignment where both paths don't share them. Same code. Measured in a narrow build of this file with InitBlendFilterArraysUnk on main 0e4a83b, both resolver sets on: 100.0% raw and normalised. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 UI::Rendering
TextureRenderCorefunction from gynt's asm drafts onorigin/reimpl/TextureRenderCorethat comes close but doesn't reach 100%, so others can continue from it (the rule: ready functions in their own PR, the rest in a draft). It fixes a bug in his draft. Its status line says what is left; each commit body says what changed against his commit and credits him as co-author.Other PRs: the ready #348, #349, #352, #353, #354, #357, #358 and #359, and the drafts #313, #318, #321, #327, #328, #356 and #360. The ready TextureRenderCore PR (18 functions) follows shortly.
Built on top of
main(03827fa, merged in) with the bundled MSVC1400-SP1 against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie; the numbers are from a clean alone build. None of it has been run in game.openshc-pr-checkgives no errors, andstatus_regression.pyfinds nothing below a known score.renderUnitAnimationWithBlendingUnk_columnOffsetat -16, ours at -4).loadGMFile (0x004559B0) was on this branch at 93.1% since d29d51d, without a row in this text. It is at 100% now and goes out in #439 (01f351c): its file leaves this draft and its status line goes back to main's.
moveOverlappingMenuPartsToMapSurface (0x00454F00) was on this branch at 96.5% since 3171551. It is at 100% now and goes out in #476 (4187d7f): its file leaves this draft and its status line goes back to main's. The last difference was the -1 test's index: written as
(tab - 1) * 5, its -5 was folded into the address, and withtab - 1as a value of its own the original'slea ecx, [eax + eax*4 - 5]comes back.Behaviour fixed compared with the draft
renderUnitAnimationWithBlendingUnk: the two zoomed-path asm blocks in gynt's draft load the surface pointer from
width, which that path never sets (only the unzoomed path assigns the surface pointer to it), so they would draw through the picture width as a pointer. All four blocks now read the global surface pointer, as the original does.renderTextChar (0x00455540) isn't here: our version reaches 28.0%, below gynt's 39.6% on his branch, although his doesn't compile against today's headers.
🤖 Generated with Claude Code