Repository navigation
Reimplement 5 UI::Rendering PencilRenderCore functions at 100% - #358
Merged
gynt merged 10 commits intoNov 7, 2026
Merged
Conversation
setupPencil (0x00468C80) stores the clipped left and top into them (mov [ebp + 0x10], edi and mov [ebp + 0x14], edx at 0x00468D8A / 0x00468D8D) after signed clamps (test edi, edi; jge at 0x00468C9F; cmp edi, 0xFD8; jl at 0x00468CB8). drawPixelPattern4x4OverWholeScreen (0x004712E0) steps both over the screen and compares them signed with the resolution (jl at 0x0047132B for currentX, at 0x00471339 for currentY), and passes them to drawPixelPattern4x4(int drawX, int drawY). With dword the loops need (int) casts to keep the jl. No function on main uses either field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nk_0x24 are int setupPencil (0x00468C80) sets both to +1 or -1: xor ecx, ecx; cmp edi, esi; setle cl; lea ecx, [ecx + ecx - 1]; mov [ebp + 0x20], ecx at 0x00468D83-0x00468D94, and the same from the top / bottom compare into +0x24 at 0x00468D97-0x00468DA4. The two Bresenham functions add them to currentX / currentY, which are int. No function on main uses either field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setupPencil (0x00468C80) clamps left, top, right and bottom with signed compares (test edi, edi; jge at 0x00468C9F; cmp edi, 0xFD8; jl at 0x00468CB8, and the same for the others), then stores the smaller of left / right into drawStartX and the larger into drawEndX after a signed jle (0x00468D9E-0x00468DB4), and the same for top / bottom into drawStartY / drawEndY (0x00468DB7-0x00468DD2). No function on main uses these fields; gynt's open sourcehold#294 casts them to (int), and those casts become no-ops with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PencilRenderCore::drawColorBox, gynt's draft from his fork's reimpl/UI-Rendering-development (63cc49f; 96.3% "asm differs" there; his closed sourcehold#255 had an older form). The box is set up with setupPencil and then filled with drawHorizontalLine row by row from the top. The original decrements the remaining height before it moves drawStartY down; the draft's for loop (height in the increment, drawStartY in the body) did it the other way round, which was the whole gap. Now both go in the for's step, --currentHeight_0x2c, ++drawStartY, in the original's order. Also: an early return when setupPencil reports nothing to draw, in place of the BOOLEnum local and the != FALSE test, and the unused includes and using dropped. quick_diff 1.0000; reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PencilRenderCore::dimBox, gynt's draft from his fork's reimpl/UI-Rendering-development (63cc49f; 96.3% "asm differs" there; his closed sourcehold#255 had an older form). The box is set up with setupPencil and then darkened with dimHorizontalLine row by row from the top. The original decrements the remaining height before it moves drawStartY down; the draft's for loop (height in the increment, drawStartY in the body) did it the other way round, which was the whole gap. Now both go in the for's step, --currentHeight_0x2c, ++drawStartY, in the original's order. Also: an early return when setupPencil reports nothing to draw, in place of the BOOLEnum local and the != FALSE test, and the unused includes and using dropped. quick_diff 1.0000; reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PencilRenderCore::drawPixelPattern4x4OverWholeScreen, gynt's draft from his fork's reimpl/UI-Rendering-development (63cc49f; 93.1% "asm differs" there; his closed sourcehold#255 had an older form). It tiles the 4x4 pixel pattern over the whole screen, keeping the position in currentX / currentY. The draft's do-while loops behind if guards become two for loops over the fields, which put the inner compare's load in the original's register (quick_diff 0.7857 -> 0.9643; the rest is ret / ret 0). With currentX and currentY int (the header commit before this one) the (int) casts go. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PencilRenderCore::drawDiagonalWiderThanHighUnk, gynt's draft from his fork's reimpl/UI-Rendering-development (63cc49f; 44.8% "asm differs" there; his closed sourcehold#255 had an older form), rewritten from the binary. A Bresenham line for the mostly horizontal case: one pixel per step along x (currentWidth_0x28 counts down), with a step along y as well while the error term is positive. The error term starts at 2 * height - width and grows by 2 * height on a straight step and by 2 * (height - width) on a diagonal one (straightStep and diagonalStep), as the original keeps them (ebx, ebp, edi). The draft did the same, but moved x once after the if, where the original moves it in each arm (once after the if: quick_diff 0.9722 -> 0.8286), and kept its iVar locals. quick_diff leaves only ret / ret 0; reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PencilRenderCore::drawDiagonalHeigherThanWideUnk, gynt's draft from his fork's reimpl/UI-Rendering-development (63cc49f; 38.8% "asm differs" there; his closed sourcehold#255 had an older form), rewritten from the binary. The same Bresenham line as drawDiagonalWiderThanHighUnk for the mostly vertical case: one pixel per step along y (currentHeight_0x2c counts down), with a step along x as well while the error term is positive; the error term starts at 2 * width - height and grows by 2 * width (straightStep) or by 2 * (width - height) (diagonalStep). The draft did the same, but moved y once after the if, where the original moves it in each arm (once after the if: quick_diff 0.9722 -> 0.8857), and kept its iVar locals. quick_diff leaves only ret / ret 0; reccmp 100.0%. 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
…ore-1-100 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rement drawDiagonalHeigherThanWideUnk (0x00471220) and drawDiagonalWiderThanHighUnk (0x00471280) had the measurement in their comment (moving the major axis once after the if: quick_diff 0.9722 -> 0.8857 and 0.9722 -> 0.8286). The numbers go to the PR text; the comment keeps one line on why the major axis moves in each arm. Comments only, no code change. 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
gynt
approved these changes
Nov 7, 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.
Five UI::Rendering
PencilRenderCorefunctions at 100%, each with its status line: a filled box, a dimmed box, a 4x4 pixel pattern over the whole screen, and the two diagonal line routines.All five continue gynt's drafts from his fork's
reimpl/UI-Rendering-development(63cc49f), in an area he agreed on Discord (2026-11-06) we may take; none is in his open #294, which has three other PencilRenderCore functions. The two diagonals were rewritten from the binary as Bresenham lines (his drafts read 44.8% and 38.8%). Every commit body says what changed against the draft and why, and each credits him as co-author. No header change is left: gynt's Ghidra sync eef6f66 took all three into main, and main is merged in (9abcf90).Other PRs: the ready #348, #349, #352, #353 and #354, the ready #357 (MenuModals and DisplayElements), and the drafts #313, #318, #321, #327, #328 and #356.
Built on top of
main(1c29459) with the bundled MSVC1400-SP1, natively on Windows, against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a), with the struct and function resolvers enabled locally (not committed), using sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. None of it has been run in game.It went through the same checks as #354: a fresh-eyes review of every file (each step compared with the original's disassembly, the Bresenham error terms, their signs and the end conditions included; its points applied and measured),
openshc-pr-checkwith no errors, andstatus_regression.py, which finds nothing below a known score on main or any fork.Header changes
Update: all three are on main since eef6f66.
All three in
PencilRenderCore; no function on main uses any of these fields.currentXandcurrentYareints: setupPencil (0x00468C80) stores the clipped left and top into them after signed clamps (jgeat 0x00468C9F,jlat 0x00468CB8), and drawPixelPattern4x4OverWholeScreen compares them signed with the resolution (jlat 0x0047132B and 0x00471339). Withdword, its loops needed(int)casts.moveDirectionXUnk_0x20andmoveDirectionYUnk_0x24areints: setupPencil sets each to +1 or -1 (setleandlea [ecx + ecx - 1], 0x00468D83-0x00468DA4).drawStartX/YanddrawEndX/Yareints: setupPencil clamps the edges with signed compares and stores the smaller as the start and the larger as the end (0x00468C9F-0x00468DD2). gynt's open Reimplement 18 UI rendering, minimap and credits functions #294 casts them to(int); those casts become no-ops.drawColorBoxfor (; currentHeight_0x2c >= 0; --currentHeight_0x2c, ++drawStartY)(the draft had the two the other way round).dimBoxdrawPixelPattern4x4OverWholeScreenforloops over the fields instead of guarded do-whiles (quick_diff 0.7857 -> 0.9643; the rest isret/ret 0).drawDiagonalWiderThanHighUnkdrawDiagonalHeigherThanWideUnkNone of the five changes behaviour against its draft: the drafts drew the same pixels in the same order. The changes are shape, names and types.
Kept as they are, and why
currentWidth_0x28/currentHeight_0x2c) rather than a counter of their own, because the original decrements the field itself and leaves it at -1.Proposed, not changed here
Names only, for the Ghidra side:
drawDiagonalHeigherThanWideUnk->drawLineBresenhamSteepanddrawDiagonalWiderThanHighUnk->drawLineBresenhamShallow, the names gynt's open refactor: Wilps contribution 2026-07-09 #155 already gives them (drawLine, 0x00472B20, sendsheight > widthto the first). If refactor: Wilps contribution 2026-07-09 #155 lands first, our two.cppfiles take the new names; the other way round, refactor: Wilps contribution 2026-07-09 #155 does.moveDirectionXUnk_0x20/moveDirectionYUnk_0x24->stepX/stepY;currentWidth_0x28/currentHeight_0x2chold |right - left| and |bottom - top|, sospanX/spanY.gynt's other commits on these functions
Each commit body names the commits it continues. gynt has more on the same functions on his fork, and they are credited here too: his best-scoring commit on the address and his newest one on the file, where the body doesn't name them. Where one of them is at 100%, his version already matched the original, and a fix this text describes for that function was only against the earlier draft it names.
drawColorBoxdimBoxdrawPixelPattern4x4OverWholeScreendrawDiagonalWiderThanHighUnkdrawDiagonalHeigherThanWideUnk🤖 Generated with Claude Code