Skip to content

Reimplement 3 UI::DisplayElements and PencilRenderCore functions (draft, below 100%) - #360

Draft
kotijekriv wants to merge 30 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-A-areas-development
Draft

kotijekriv wants to merge 30 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-A-areas-development

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Three functions in UI::DisplayElements and UI::Rendering's PencilRenderCore that don't reach 100% yet, so others can continue from them (the rule: ready functions in their own PR, the rest in a draft). These are the areas gynt agreed on Discord (2026-11-06) we may continue from his drafts; none of the three is in an open PR of anyone else. Each status line gives the reccmp % as measured and what is left; each commit body says where the code came from and what was tried.

Fourteen functions that started here have left:

Built on top of main (eef6f66, merged in d00cf56) 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. None of it has been run in game. The fixer and the checker's mechanical items were applied (colours by name, line comments, decimal and signed constants, duplicate includes, countof, clang-format); the decompiler's local names (iVar1) are left as they are, as in other drafts.

Area Function Address Raw Left
DisplayElements DebugNumbers 0x004AF860 78.7% durationSum stays in a register where the original keeps elementState. The original has both sums in registers only inside the loop and in stack slots behind it; see the note below
DisplayElements PlayerInfoOnHover 0x004B0390 62.0% Asm differs
PencilRenderCore drawTableCellBackground 0x004692E0 95.2% (91.5% normalised; 68b56e4, a narrow build of the file on main 3458fea) One instruction: the original reads the stripe index as a sign-extended byte (movsx edi, byte ptr [esp + 0x10]), ours as a dword. It is a byte longer, so reccmp also counts the four jumps across the loop's padding and the padding itself (a jmp plus a lea in ours where the original has one lea: 137 instructions against 136); see the note below

DebugNumbers, for whoever continues it. The original keeps both sums (ecx, edx) in registers only inside the summing loop and in two stack slots behind it ([esp + 0x10], [esp + 0x14], an 8-byte frame), and that is what frees edi for the last loop duration and, later, for elementState. In ours the duration sum gets a callee-saved register for the whole function. Written as a plain for loop over both buffers, the compiler unrolls the loop into the original's five-wide form by itself, so the hand-unrolled loops of the draft are not needed. With both sums declared and zeroed first, the tick count lands in esi as in the original. Marking the sums volatile as an experiment made everything behind the loop match (the registers of x, y, the average and elementState), which shows the sums in memory are the whole difference; it is not the answer, because the loop then adds in memory too. A union, pointers and references to the sums compile to the same code as two plain locals; an array or a struct is taken apart into two registers as well, and its loop then adds one element at a time.

drawTableCellBackground, for whoever continues it. The second arm's registers match since 68b56e4: the right piece is written inside the first arm, followed by a return, and once more behind the second arm. The compiler still emits it once, and the two arms get the original's two different orders of the three scratch registers (the lever: a block that follows an if / else join, written out inside one arm, changes that arm's registers). What is left is the byte read of the stripe index. With the parameter as a char (header and resolver changed locally, not committed) every spelling of the picture's expression we tried reads movzx into eax and copies it to edi later, which also turns the arms' registers back: a plain expression, an int local set from the parameter, step-by-step assignments, casts to int, uint and short, a shift, a conditional expression and an inline helper that takes an int. The char parameter updated in place does byte arithmetic in al, and a cast on the int parameter reads movzx as well. With % 2 in place of & 1 the char parameter is read with movsx, but into eax, and the remainder's code is longer.

Every commit built on gynt's draft credits him as co-author.

🤖 Generated with Claude Code

kotijekriv and others added 18 commits November 7, 2026 02:23
MenuModalRenderFunction_ChooseNetworkServiceProvider, from gynt's reimpl/UI-MenuModals-development (PR sourcehold#252,
closed unmerged) (65.3% there). His draft as it is. The fixer's mechanical rewrites (decimal constants, compound
assignments, - N for + -N, truth tests, unused using-declarations dropped) are applied; nothing else is restyled
yet. reccmp reads 65.3%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_CreditsScroll, from gynt's reimpl/UI-MenuModals-development (PR sourcehold#252, closed unmerged)
(40.8% there). His draft as it is. The fixer's mechanical rewrites (decimal constants, compound assignments, - N
for + -N, truth tests, unused using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads
41.0%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_FindingNetworkSessions, from gynt's reimpl/UI-MenuModals-development (PR sourcehold#252, closed
unmerged) (66.9% there). Restyled, with main's rename field135_0x474 -> field_0x474: the list's frame as named
positions. The fixer's mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth tests,
unused using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads 66.9%: register
mismatch: the original keeps the right column in ebp and reloads x.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_ProgressBarBox, from gynt's reimpl/UI-MenuModals-development (PR sourcehold#252, closed unmerged)
(96.3% there). His draft as it is. The fixer's mechanical rewrites (decimal constants, compound assignments, - N
for + -N, truth tests, unused using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads
96.3%: only the spill slot of the bar's x differs (the original uses y's home).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_Roundtable, from gynt's reimpl/UI-MenuModals-development (PR sourcehold#252, closed unmerged) (70.2%
there). Rewritten from the binary: the seat positions as an initialised array, the seat loop and the group tint as
named locals. The fixer's mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth tests,
unused using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads 76.1%: register
mismatch: the original keeps y in ebp and the group counter in y's home.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderDebugNumbersDisplayElement, from gynt's reimpl/UI-DisplayElements-pr-development (PR sourcehold#249, closed unmerged)
(78.7% there). His draft as it is (every loop form tried compiles the same). The fixer's mechanical rewrites
(decimal constants, compound assignments, - N for + -N, truth tests, unused using-declarations dropped) are
applied; nothing else is restyled yet. reccmp reads 78.7%: register mismatch: durationSum stays in a register
where the original keeps elementState.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderInGameWinDefeatWindowDisplayElement, from gynt's reimpl/UI-DisplayElements-pr-development (PR sourcehold#249, closed
unmerged) (81.0% there). His draft, with the alive-flag pointers short* for today's short playerIsAlive. The
fixer's mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth tests, unused
using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads 82.0%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderPlayerInfoOnHoverDisplayElement, from gynt's reimpl/UI-DisplayElements-pr-development (PR sourcehold#249, closed
unmerged) (62.0% there). His draft, with main's rename viewportState.field0_0x0 -> field_0x0. The fixer's
mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth tests, unused using-declarations
dropped) are applied; nothing else is restyled yet. reccmp reads 62.0%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawBorderedBoxWithBlendedBackground, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged)
(32.8% there). His draft as it is. The fixer's mechanical rewrites (decimal constants, compound assignments, - N
for + -N, truth tests, unused using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads
32.8%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawBoxWithRoundedEdges, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (38.9% there). His
draft, with main's rename TextInputDefinedData::field0_0x0 -> field_0x0. The fixer's mechanical rewrites (decimal
constants, compound assignments, - N for + -N, truth tests, unused using-declarations dropped) are applied;
nothing else is restyled yet. reccmp reads 38.9%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawCurrentPixel, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (4.5% there). His draft,
with the optimize pragma moved above the FUNCTION line so the function is found. The fixer's mechanical rewrites
(decimal constants, compound assignments, - N for + -N, truth tests, unused using-declarations dropped) are
applied; nothing else is restyled yet. reccmp reads 4.5%: heavy structural mismatch.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawHeaderBanner, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (52.0% there). His draft,
with main's rename GMTotalPicturesProcessed -> GMFirstPictureIndex. The fixer's mechanical rewrites (decimal
constants, compound assignments, - N for + -N, truth tests, unused using-declarations dropped) are applied;
nothing else is restyled yet. reccmp reads 52.0%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawHeaderTextBanner, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (51.6% there). His
draft, with main's rename GMTotalPicturesProcessed -> GMFirstPictureIndex. The fixer's mechanical rewrites
(decimal constants, compound assignments, - N for + -N, truth tests, unused using-declarations dropped) are
applied; nothing else is restyled yet. reccmp reads 52.4%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawLine, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (56.3% there). His draft as it
is. The fixer's mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth tests, unused
using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads 56.3%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawPixelPattern4x4, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (9.3% there). His
draft as it is. The fixer's mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth
tests, unused using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads 9.3%: heavy
structural mismatch.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawScrollbar, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (60.1% there). His draft as
it is. The fixer's mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth tests, unused
using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads 60.1%: asm differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawTableCellBackground, from gynt's reimpl/UI-Rendering-development (PR sourcehold#255, closed unmerged) (75.5% there). His
draft as it is. Three differences are known: the stripe row loads with movzx where the original sign-extends (a
char parameter does not change it), the width test is the other way round, and the first cap is drawn at the
global x instead of the local copy; fixing the last two alone measured worse (65.2%) with the registers that
follow. The fixer's mechanical rewrites (decimal constants, compound assignments, - N for + -N, truth tests,
unused using-declarations dropped) are applied; nothing else is restyled yet. reccmp reads 78.4%: asm differs:
stripe row zero-extended, width test inverted.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Below 100% main's commit_progress_batch.py writes the blocker as the remark ("Style pass, asm differs"), not
"Reimplemented". This draft's seventeen status lines keep their percentages and blocker remarks.

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)

82 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 10 of the 17 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 17
16 Give variables a name that says what they hold 45
18 Use the name, not the number 9
20 Keep nesting low; no goto 2
24 Declare variables upon first use 9
Where

Rule 9 — Prefer for over while/do

  • src/OpenSHC/UI/DisplayElements/RenderDebugNumbersDisplayElement.cpp:40 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/DisplayElements/RenderDebugNumbersDisplayElement.cpp:59 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/DisplayElements/RenderInGameWinDefeatWindowDisplayElement.cpp:99 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:46 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:135 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp:20 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp:28 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp:39 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp:22 — do-loop; the guide asks for a for
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp:30 — do-loop; the guide asks for a for
  • ... and 7 more

Rule 16 — Give variables a name that says what they hold

  • src/OpenSHC/UI/DisplayElements/RenderInGameWinDefeatWindowDisplayElement.cpp:29 — decompiler name iVar4
  • src/OpenSHC/UI/DisplayElements/RenderInGameWinDefeatWindowDisplayElement.cpp:30 — decompiler name piVar5
  • src/OpenSHC/UI/DisplayElements/RenderInGameWinDefeatWindowDisplayElement.cpp:31 — decompiler name local_8
  • src/OpenSHC/UI/DisplayElements/RenderInGameWinDefeatWindowDisplayElement.cpp:76 — decompiler name iVar3
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:17 — decompiler name iVar1
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:23 — decompiler name local_58
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:25 — decompiler name local_10
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:26 — decompiler name local_14
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:27 — decompiler name local_18
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:28 — decompiler name local_1c
  • ... and 35 more

Rule 18 — Use the name, not the number

  • src/OpenSHC/UI/DisplayElements/RenderInGameWinDefeatWindowDisplayElement.cpp:132 — hex constant 0x53E9A; use a name, or decimal
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:28 — hex constant 0x1FE; use a name, or decimal
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:29 — hex constant 0x1E0; use a name, or decimal
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:117 — hex constant 0x1FE; use a name, or decimal
  • src/OpenSHC/UI/MenuModals/CreditsScroll/MenuModalRenderFunction_CreditsScroll.cpp:118 — hex constant 0x1E0; use a name, or decimal
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp:24 — hex constant 0xFFFFFFFA; use a name, or decimal
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp:27 — hex constant 0xB37CE8; use a name, or decimal
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp:26 — hex constant 0xFFFFFFFA; use a name, or decimal
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp:36 — hex constant 0xFFFFFFFA; use a name, or decimal

Rule 20 — Keep nesting low; no goto

  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp:39 — goto; check how many predecessors the target has first
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp:43 — goto; check how many predecessors the target has first

Rule 24 — Declare variables upon first use

  • src/OpenSHC/UI/DisplayElements/RenderInGameWinDefeatWindowDisplayElement.cpp:29 — declare iVar4 where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp:20 — declare _drawReady where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp:22 — declare iVar4 where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp:23 — declare _textY where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp:24 — declare _width where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp:25 — declare iVar2 where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp:26 — declare iVar3 where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp:28 — declare _textX where it is first assigned
  • src/OpenSHC/UI/Rendering/PencilRenderCore/drawLine.cpp:14 — declare _drawReady where it is first assigned

kotijekriv and others added 2 commits November 7, 2026 18:11
…opment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Core-2-100 has at 100%

drawCurrentPixel (0x00468F20), drawPixelPattern4x4 (0x00468F70), drawBoxWithRoundedEdges (0x004710A0),
drawBorderedBoxWithBlendedBackground (0x00471340) and drawLine (0x00472B20) are reimplemented at reccmp 100.0% on
reimpl/UI-PencilRenderCore-2-100, rewritten from the binary. Their drafts here (3e7ec7e, 2c99182, ea42833,
8543e6b and cfbab8e, from gynt's drafts) go, with their status lines back to main's, so that the two branches
merge cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 2 commits November 8, 2026 00:44
…rCore-3-100 has at 100%

drawHeaderBanner (0x00468FE0), drawHeaderTextBanner (0x00475CC0) and drawScrollbar (0x004690E0) are at 100% on
reimpl/UI-PencilRenderCore-3-100. Their drafts here (402dc08, 9c437b0, 074c788) go, and their status lines
return to main's, so the two branches merge cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PencilRenderCore::drawTableCellBackground, from gynt's draft (b184193, 26.83%; 7c68476, 26.8%, in his closed
sourcehold#255; the same body with his style passes at 63cc49f on his fork's reimpl/UI-Rendering-development; our
4d8dc93, 78.4%, before this). The two highlighted branches (selected, or the button being interacted with), their
left end, middle pieces and right end with the middle's mask, the run of stripes otherwise, and the button width
raised to 21 when it is narrower are his.

New here: the width tests as > 20 and > 21, the binary's jle 0x14 / jle 0x15 with the draw first; x passed for the
left end too; the pictures named; the stripe picture without the (char) cast, which made MSVC load the byte
zero-extended and in eax before the pushes (quick_diff 0.8339 -> 0.9481, reccmp 78.4% -> 89.7%). Left: the original
reads the index as a sign-extended byte (movsx edi, byte ptr [esp + 0x10]), which no form tried reproduces (a char
parameter, a char local, casts, ternary and if forms all give movzx), and its second branch keeps ButtonY and the
loop bound in other registers than its identical first branch.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6and8 pushed a commit to 6and8/OpenSHC that referenced this pull request Nov 8, 2026
… 100% (sourcehold#376)

* reimplement: SHC_3BB0A8C1_0x00468FE0 100.0% Reimplemented

PencilRenderCore::drawHeaderBanner, from gynt's draft (2a0beda, 40.22%, then 8f3b5da, 40.22%, and fc63cfd,
43.58%, on his fork's reimpl/UI-MenuItems-development; 7719115, 40.2%, in his closed sourcehold#255; his style passes
81e1041, a389f84, dd14331, 9205629 and cee658d; at 63cc49f on his fork's reimpl/UI-Rendering-development
he moved yPos + 8 into yPos itself and tested the right tile against the banner's width - 8; our 402dc08, 52.0%,
in the draft sourcehold#360, is that body). The drawing is his: eight rows of 8 by 8 tiles of GID_INTERFACE_ICONS_3 (48, 54
and 60 start the top, middle and bottom rows, + 1 and + 2 for the middle and right tiles, + 3 for each mask), the
rows counted in xPos from his first draft on, one tile in from the top and both sides, and the end caps 91 / 92
three pixels in from each end, the right one placed by the cap's width.

New here: the banner's width is width itself, reduced in place (width -= 16), as the original keeps it in width's
register and puts the row's y in width's stack slot (an innerWidth local: quick_diff 0.6353 -> 1.0000); the rows
are counted in a y local, which MSVC also puts in xPos's slot; the pictures are named; the masked row-picture
ternary is an if / else if chain and the tile's comma condition a nested if (a flat if / else if chain: quick_diff
1.0000 -> 0.9827); the cap width is read inline between the two cap calls, where the original reads it. reccmp
100.0%.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x00475CC0 100.0% Reimplemented

PencilRenderCore::drawHeaderTextBanner, from gynt's draft (9a19144, 35.96%, then 6ae321d, 35.96%, and
e69b74d, 37.72%, on his fork's reimpl/UI-MenuItems-development; daeda89, 39.6%, in his closed sourcehold#255; his style
passes 81e1041, a389f84, b8ab787, dd14331, 9205629 and cee658d; the same body with his style passes at
63cc49f on his fork's reimpl/UI-Rendering-development; our 9c437b0, 52.4%, in the draft sourcehold#360). It is
drawHeaderBanner's banner with a text centred on it; the banner and the text call (getTextStringInGroupAtOffset
nested in renderTextToScreen, centred, COL_C2F0EB, size 15) are his.

New here: the banner written as in drawHeaderBanner (yPos += 8 and width -= 16 in place, a y local, the pictures
named, the if / else if chain over the rows and the nested tile test: a flat chain, quick_diff 0.9909 -> 0.9774;
the cap width inline), so the text sits at width / 2 + left and yPos + 14. The text group keeps its eTextSections
cast because the header declares textGroupIndex as int, although every caller passes an eTextSections value; that
type is a proposal for the PR text. quick_diff differs only in the colour immediate, which it shows as a data
symbol; reccmp 100.0%.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x004690E0 100.0% Reimplemented

PencilRenderCore::drawScrollbar, from gynt's draft (c808751, 30.77%, on his fork's reimpl/UI-MenuItems-development;
3d9ca03, 30.8%, in his closed sourcehold#255; his style passes 81e1041, a389f84, dd14331 and cee658d; the same body
with his style passes at 63cc49f on his fork's reimpl/UI-Rendering-development; 5fa1b20 on his fork's
reimpl/UI-MenuItems-development turns the thumb test 10 < thumbHeight - 10 into thumbHeight > 10 - 10, where the
binary tests thumbHeight - 10 > 10 (sub ebx, 0xa; cmp ebx, 0xa), as this commit does; our 074c788, 60.1%, in the
draft sourcehold#360). The pictures and their order are his: the track in 20-pixel pictures (79) and then single rows (95);
the thumb small (89, up to 20 high) or as a 10-pixel top (100), single middle rows (101) and a 10-pixel bottom
(102); each with its mask (80, 96, 90; 103 to 105).

Fixed here: a dragged thumb is drawn once, without masks, and the function returns (ret 0x1c at 0x00469189 and
0x004691EB). In the drafts the dragged branch had no return, so a dragged thumb of up to 20 pixels drew picture 89
and then the large thumb too, and every dragged thumb was then drawn a second time with masks.

New here: the draft's hand-made countdown loops and shared final call are plain for loops and one call per branch,
which MSVC compiles to the original's countdowns and shared tail; the track walks yPos itself while top keeps its
first value (a copy of yPos walking instead: quick_diff 0.8158 -> 0.9474); the thumb loop lowers thumbHeight and
advances thumbYPos in place, as the original updates them (0.9474 -> 0.9737 -> 1.0000); the pictures are named;
xPos is passed without the (int) casts. reccmp 100.0%.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x00468C80 100.0% Reimplemented

PencilRenderCore::setupPencil, from gynt's draft (3957761, 18.82%, on his fork's reimpl/UI-MenuItems-development;
44a1588, 18.8%, in his closed sourcehold#255; his 3d17527 on his fork's reimpl/UI-MenuItems-development puts the map
branch first, 19.6%, as this commit does). The clipping is his: left and right clamped to the surface's width (the
map surface's 4056 pixels, or resolutionX for the menu surface), top and bottom to the surface's height range, FALSE
when the rectangle lies wholly off the surface, then the pencil's size, position, directions and drawing bounds. The
note that right and bottom are inclusive is TheRedDaemon's comment in the draft, now one line.

Fixed here: the map surface's three width tests are >= 4056, where the draft had 4056 < left and 4056 < right, so
4056 itself was neither clipped nor counted as off the surface: left >= 4056 (cmp edi, 0xfd8; jl at 0x00468CB8),
right >= 4056 for the wholly-off test (cmp esi, 0xfd8; jge at 0x00468CC0) and right >= 4056 for the clip (cmp esi,
0xfd8; jl at 0x00468CD5).

New here: each branch clips top and bottom against its own height range, read in place, and MSVC merges the
identical tails at 0x00468D45 as in the original (the draft's two range locals clip once after the branches); the
two sizes, the directions and the drawing bounds are if / else (the sizes as ternaries keep this in ecx: quick_diff
0.5204, if / else 1.0000; the directions and the Y bounds tie either way); 4056 is named MAP_SURFACE_WIDTH. reccmp
100.0%; its callers dimBox and drawColorBox stay at 100.0%.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x004B20B0 100.0% Reimplemented

RenderNoRushDisplayElementUnk, gynt's function on main (b0a49d0, 67.57%, and 96008db, 82.43%, "shared arm fold
direction"; the .cpp and its 82.4% status line came to main in sourcehold#199 as 648b0c6, and the re-measured 83.1% in
sourcehold#269, his 272decc, as 4b30c73). The function is his: the battle horn and the unlimited display once the no-rush
time is over, otherwise the text width, the bar's position by resolution, the blended box, the text, the border and
the bar filled by the remaining ticks.

New here: the resolutions are tested by separate ifs instead of an else-if chain, in the same order. The original
keeps each offset that two resolutions share (-240, -400, -560 and -880) in the first of the two and jumps back to
it from the second (je 0x004B212C at 0x004B2144); the else-if chain puts the copy in the second, separate ifs put it
in the first, and MSVC still skips the remaining tests once one matches (quick_diff 0.9054 -> 0.9797, the rest being
the listing's ret 0 and the colour immediate shown as a data symbol). reccmp 100.0%.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style: RenderNoRushDisplayElementUnk without its unused usings and includes

The six using declarations and the Helpers and Rendering function headers were unused: the code names everything in
full. x += -18 - (barWidth / 2) becomes x -= 18 + barWidth / 2. quick_diff 0.9797 before and after.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Roundtable::MenuModalRenderFunction_Roundtable (0x004B1AC0) reaches reccmp 100.0 (normalized 100.0) on main
3458fea and goes out with the ready branch reimpl/UI-B-round22-100 (9d405f2), with a behaviour fix: this draft
added the group counter to each shield's x where the original adds the x parameter. Its file leaves this draft and
its status line goes back to main's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kotijekriv kotijekriv changed the title Reimplement 17 UI::MenuModals, DisplayElements and PencilRenderCore functions (draft, below 100%) Reimplement 8 UI::MenuModals, DisplayElements and PencilRenderCore functions (draft, below 100%) Nov 19, 2026
kotijekriv and others added 3 commits November 20, 2026 15:01
CreditsScroll::MenuModalRenderFunction_CreditsScroll (0x004AAB50) reaches reccmp 100.0 (normalized 100.0) on main
3458fea and goes out with the ready branch reimpl/UI-B-round26-100 (015b79f). Its file leaves this draft and its
status line goes back to main's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
DisplayElements::RenderInGameWinDefeatWindowDisplayElement (0x004AFB30) reaches reccmp 100.0 (normalized 100.0) on
main 3458fea and goes out with the ready branch reimpl/UI-B-round26-100 (015b79f). Its file leaves this draft and
its status line goes back to main's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…5 too low

ChooseNetworkServiceProvider::MenuModalRenderFunction_ChooseNetworkServiceProvider: a behaviour fix in the draft.

The second box, drawn on the modem tab, reaches from y + 265 to y + 345. The original takes the top first
(lea ebx, [edi + 0x109] at 0x0047C9C5) and then moves y on to the bottom (add edi, 0x159). The draft moved y first
and then wrote the top as y + 265, which made it y + 610, 345 pixels below where it belongs (265 below the box's
bottom), and the frame's lines with it. The top is a local again, set in front of `y += 345`.

Where it came from: gynt's 968b1ee ("65.32% esi/edi split, orig lea x3", on his fork's
reimpl/UI-MenuModals-development) replaced the local of his 8f37773 (65.13%) by `(y + 0x109)` behind the move, and
our c8ff9d9 took that file over as it was. So the 0.2 points between the two were a changed value, not a better
match. sourcehold's reimpl/UI-MenuModals has the top right, and so has the newest commit on the file, af1d790 on his
fork's reimpl/UI-MenuItems-development (the older text, 35.3% there).

Measured: reccmp 65.1% (normalized 65.1%) in a narrow build of the file on main 3458fea, with
TEXT_MULTIPLAYER_CONNECTION in place of 76 so that it compiles there, data resolvers and its own resolver on; 65.3%
with the wrong top. Not run in game.

What is left: x and y swap esi and edi, and x + 440 keeps a register where the original keeps y + 85 and works
x + 440 out again at each use. Tried without a gain: both boxes written from x and y alone, with and without locals
for their sides (0.56 to 0.61 in quick_diff against this form's 0.68), and the second box as `y += 180` in front of
the first box's text.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kotijekriv kotijekriv changed the title Reimplement 8 UI::MenuModals, DisplayElements and PencilRenderCore functions (draft, below 100%) Reimplement 6 UI::MenuModals, DisplayElements and PencilRenderCore functions (draft, below 100%) Nov 20, 2026
kotijekriv and others added 2 commits November 20, 2026 21:27
…st arm; one byte read left

PencilRenderCore::drawTableCellBackground, 89.7% to 95.2% (91.5% normalized), on top of be147ca (our rewrite with
gynt's draft). gynt's commits on it: 7c68476 at 26.8% on sourcehold's reimpl/UI-Rendering, b184193 at 26.83%
and 63cc49f, the newest, on his fork's reimpl/UI-Rendering-development, whose status line records 75.5%.

The second arm's registers match now. The selected cell and the cell under the mouse draw the same pieces, and the
original gives the second arm's three scratch registers in another order than the first's (the row's y in ecx at
0x004693AB against eax at 0x00469310, and so on round). Our two arms had the first arm's order twice. Written with
the right piece inside the first arm, followed by a return, and once more behind the second arm, both arms come out
as the original's; the compiler still emits the right piece once (0x00469426). The lever: a block that follows an
if / else join, written out inside one arm, changes that arm's registers.

Left is one instruction: the original reads the stripe index as a sign-extended byte (movsx edi, byte ptr
[esp + 0x10] at 0x004692E8), ours as a dword. It is one byte longer, so reccmp also counts the four jumps across the
loop's padding (jge 0x0046934E, jmp 0x0046938B, je 0x00469397 and jge 0x004693EA) and the padding itself, which is a
jmp plus a lea in ours where the original has one lea (137 instructions against 136, 130 of them the same:
2 x 130 / 273 = 95.2). quick_diff shows only the byte read (0.9926, 135 instructions on both sides).

Tried for the byte read, all without it: the parameter as a char (header and resolver changed locally, not
committed) with the picture's expression in nine spellings, among them an int local set from it, step by step
assignments, casts to int, uint and short, a shift, a conditional expression and an inline helper that takes an
int: every one reads movzx into eax and copies it to edi later, which also turns the arms' registers back. The
char parameter updated in place does byte arithmetic in al. A cast on the int parameter reads movzx as well. With %
2 in place of & 1 the char parameter is read with movsx, but into eax, and the remainder's code is longer.

Measured in a narrow build of the file on main 3458fea, 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>
ProgressBarBox::MenuModalRenderFunction_ProgressBarBox (0x00493560) reaches reccmp 100.0 (normalized 100.0) on main
3458fea, off the /GL list and on it, and goes out with the ready branch reimpl/UI-A-progressbarbox-100
(bfac9fd). Its file leaves this draft and its status line goes back to main's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kotijekriv kotijekriv changed the title Reimplement 6 UI::MenuModals, DisplayElements and PencilRenderCore functions (draft, below 100%) Reimplement 5 UI::MenuModals, DisplayElements and PencilRenderCore functions (draft, below 100%) Nov 22, 2026
kotijekriv and others added 2 commits November 23, 2026 00:53
ChooseNetworkServiceProvider::MenuModalRenderFunction_ChooseNetworkServiceProvider (0x0047C860) reaches reccmp
100.0 (normalized 100.0), off the /GL list and on it, and goes out with the ready branch reimpl/UI-A-netmodals-100
(5a9422d, on main 0e4a83b). Its file leaves this draft and its status line goes back to main's.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FindingNetworkSessions::MenuModalRenderFunction_FindingNetworkSessions (0x0047D190) reaches reccmp 100.0
(normalized 100.0), off the /GL list and on it, and goes out with the same ready branch, reimpl/UI-A-netmodals-100
(11d13f1, on main 0e4a83b). Its file leaves this draft and its status line goes back to main's.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kotijekriv kotijekriv changed the title Reimplement 5 UI::MenuModals, DisplayElements and PencilRenderCore functions (draft, below 100%) Reimplement 3 UI::DisplayElements and PencilRenderCore functions (draft, below 100%) Nov 23, 2026

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