Repository navigation
Reimplement 2 UI::Rendering TextureRenderCore asm functions from gynt's drafts (100%) - #389
Merged
Merged
Conversation
…ngOccupationArea and InitBlendFilterArraysUnk Both functions (0x0044F170, 0x0044E630) load height into edi once and still use it after the InitBlendFilterArraysUnk call (lea edx, [ecx + edi] at 0x0044F205; lea ecx, [eax + edi] at 0x0044E6CC), so the original compiler knew that call leaves height alone. Here height is named in the functions' asm blocks, so without that knowledge MSVC reads it from memory again after the call; by quick_diff that is the only difference in the C++ part. With InitBlendFilterArraysUnk's definition compiled into the same file (a local test that includes it) both match instruction for instruction; /GL on all three files gives the compiler that view across files, as for the other caller and callee pairs in this list. The lines sit next to the other UI/Rendering entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
renderGmWithPreparedAlphaMask draws a TGX image through the alpha surface prepared earlier: per pixel, the mask's blue channel less blendStrength leaves the destination alone at or below zero, copies the source at 31 and blends the two through DAT_BlendFilterArrays in between, in one handwritten asm loop per colour mode. From gynt's draft (3ea4438 on reimpl/TextureRenderCore, 93.2% there; his later 3d17527 on this file is an arm swap on the earlier decompiled version, not on this one). Needs the cmake commit that puts this file and InitBlendFilterArraysUnk.cpp under /GL: the original keeps height in edi across that call, which MSVC only does when it can see the callee. Also: the asm reads the render surface from the global, main's parameter names, lineJump / lineBytes / heightStart / heightEnd as in renderTgxWithColorUnk, 4056 for the map surface's width, maskPtr as the alpha surface's own ushort*, the token compares with the TgxToken names and descriptive labels as in the other TGX asm blocks on main. With InitBlendFilterArraysUnk compiled into the same file and the ebp-frame slots resolved, quick_diff is 1.0000 (442 instructions each side). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
renderInterfaceOrBuildingOccupationArea blends a TGX image over the destination through the pair of DAT_BlendFilterArrays rows that blendStrengthUnk picks, in four handwritten asm loops (RGB555 and RGB565, each for the normal and the zoomed-out surface, which keeps only every second row and column). From gynt's draft (ac42b30 on reimpl/TextureRenderCore, 92.8% there, "two stack slots swapped"; his newer 3d17527 on this file is an arm swap on the earlier decompiled version, not on this one). Needs the cmake commit that puts this file and InitBlendFilterArraysUnk.cpp under /GL: the original keeps height in edi across that call. Also: the asm reads the render surface from the global, the destination filter row computed before the source row (the other order swaps ecx and edx), main's parameter names, lineJump / lineBytes / heightStart / heightEnd as in renderTgxWithColorUnk (gynt's draft kept the line jump and the line bytes in width and blendStrengthUnk; as locals MSVC gives them those parameters' slots, so the code is the same), the token compares with the TgxToken names and descriptive labels as in the other TGX asm blocks on main. The two swapped slots: columnOffset is used only by the zoomed-out loops and is declared in that branch, now an else; declared at function scope it takes [ebp - 4] and pushes heightStart to [ebp - 8], the other way round from the original (declaration order, names and extra references did not move them). With InitBlendFilterArraysUnk compiled into the same file and the ebp-frame slots resolved, quick_diff goes 0.9702 -> 1.0000 (805 instructions each side). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment above each InitBlendFilterArraysUnk call in renderGmWithPreparedAlphaMask and renderInterfaceOrBuildingOccupationArea also said that the original keeps height in edi across the call, which needs /GL on these files and the callee. That is a finding about the build, not about the code, so it moves to the PR description; the line on why the call is there stays. quick_diff output is identical for both files, plain and with the callee in the same TU (1.0000 there). The full /GL build of the commit before reads both at 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ked for The asm writes masks as lowercase 0x numbers, and shift counts and plain values (32, 31) in decimal, as main's TGX asm blocks do; none of them uses the MASM h suffix. Each body gets a one-line summary, and the shapes the review asked about get main's measured comment: - the map arm first (with the arms swapped: 0.8258 -> 0.8077 and 0.8270 -> 0.8228); - maskPtr read before the height test (after it: 0.8235); - two filter pointers in renderGmWithPreparedAlphaMask (one for both: 0.8231). The zoomed-out arm says why its lineJump is a whole row, and columnOffset says that only the asm writes it. quick_diff output is identical for both files, with -s. 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) 50 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 11 — No magic addresses
Rule 18 — Use the name, not the number
|
This was referenced Nov 10, 2026
gynt
approved these changes
Nov 10, 2026
gynt
approved these changes
Nov 10, 2026
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.
Two more TextureRenderCore functions at 100%, the last two of the round whose other five are in #386. Both were written from gynt's drafts (92.8% and 93.2% on his reimpl/TextureRenderCore). Each commit cites the draft it builds on and credits him as co-author. Part of the rest of UI that gynt OK'd on 2026-11-09.
TextureRenderCore::renderGmWithPreparedAlphaMaskTextureRenderCore::renderInterfaceOrBuildingOccupationAreaMeasured on main d5d965d. The branch is rebased onto 847c77b, which leaves the two functions' files and
InitBlendFilterArraysUnk.cppas they were.Stronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.ApplyBlendingandrenderBlendedBlackBox, stay at 100.0%.openshc-pr-checkgives no errors, andstatus_regression.pyfinds no score below a known one.Why
/GL(cmake commit 0c8b764)Both functions load the height into
edionce and still use it after theInitBlendFilterArraysUnkcall:lea edx, [ecx + edi]at 0x0044F205,lea ecx, [eax + edi]at 0x0044E6CC. So the original compiler knew that call leavesedialone./GL, MSVC reads the height from memory again after the call. By quick_diff, that is the only difference in the C++ part./GLon both files and onInitBlendFilterArraysUnk.cpp, the compiler sees the callee across files, as for the other caller and callee pairs incmake/compiler-flags-gl.txt. The three lines sit next to the other UI/Rendering entries.InitBlendFilterArraysUnkreads 97.9% raw in every full build, with/GLor without. Its instructions match. The only difference is how reccmp prints two loop-end compares against an address just past the end of the blend filter array, which our DLL lays out differently. Reimplement 32 rendering and UI rendering functions at 100% #311 records that, and main keeps it at 100%./GLdoesn't change it.How much is assembly
The drawing loops are handwritten assembly in the original, and they stay as inline asm here, transcribed from the binary:
Everything around them is C++: the zoom test, the blend filter rows (
short* const, declared at first use), theInitBlendFilterArraysUnkcall, and the pointers and counts the loops start from.TgxTokennames, asrenderTgxWithColorUnkand main's other TGX asm blocks do.0xffe0,0x3ff, …), shift counts and plain values in decimal (shr bx, 10,mov eax, 32,cmp edx, 31).The style-lint bot will flag the 50 masks above
0xff(126 hex masks in all). Every one is a mask in anand, written as main's TGX asm writes them; gynt's rule on #311 allows hex there.lineJump,lineBytes,heightStartandheightEndare declared without a value before the zoom and surface tests, because every arm assigns them, as inrenderTgxWithColorUnk.Kept as it is, measured with quick_diff
columnOffsetdeclared in the zoomed-out branch only!= RT_SCREEN_MENU)==with the arms swapped: 0.8258 → 0.8077 and 0.8270 → 0.8228maskPtrread before the height testThe plain quick_diff figures are below 1.0000 because, without
/GL, the height is read again after the callee (see above). Each comment gives its number in main's one-line form.Other PRs
InitTutorialState's declaration.🤖 Generated with Claude Code