Skip to content

Reimplement 2 UI::Rendering TextureRenderCore functions from gynt's asm drafts (draft, below 100%) - #363

Draft
kotijekriv wants to merge 7 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-TextureRenderCore-development
Draft

kotijekriv wants to merge 7 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-TextureRenderCore-development

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Two UI::Rendering TextureRenderCore functions from gynt's asm drafts on origin/reimpl/TextureRenderCore that come close but don't reach 100%, so others can continue from them (the rule: ready functions in their own PR, the rest in a draft). One fixes a bug in his draft. Each 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 Steam Stronghold 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-check gives no errors, and status_regression.py finds nothing below a known score.

Function Address Raw / normalized gynt's commit Left
renderUnitAnimationWithBlendingUnk 0x00451E00 92.5% / 84.8% 3c9bcdb, 91.5% The stack slots of the asm-only column offset and the C locals (the original keeps _columnOffset at -16, ours at -4).
moveOverlappingMenuPartsToMapSurface 0x00454F00 96.5% / 88.1% c2e5474, 68.0% The tab's record index is now a local of its own, as the original computes it a second time; the instruction mix and every stack slot match (was 84.8% / 67.4%). Left: the -1 test's own index still has its -5 folded into the addresses.

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

kotijekriv and others added 2 commits November 7, 2026 08:57
… 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>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Style guide reading (advisory, posted once)

2 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 2 of the 2 reimplemented .cpp file(s) in this PR.

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.

rule what it asks hits
9 Prefer for over while/do 1
24 Declare variables upon first use 1
Where

Rule 9 — Prefer for over while/do

  • src/OpenSHC/UI/Rendering/TextureRenderCore/moveOverlappingMenuPartsToMapSurface.cpp:36 — do-loop; the guide asks for a for

Rule 24 — Declare variables upon first use

  • src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp:44 — declare _startColumnParity where it is first assigned

…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>
…Core-development

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 2 commits November 9, 2026 00:41
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 branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant