Skip to content

Reimplement 4 PencilRenderCore functions and the no-rush countdown at 100% - #376

Merged
gynt merged 6 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-PencilRenderCore-3-100
Nov 8, 2026
Merged

gynt merged 6 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-PencilRenderCore-3-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

Five more UI functions at 100%, each with its status line: four from UI::Rendering PencilRenderCore (the header banner, the header banner with its text, the scrollbar, and setupPencil, the clipping every pencil routine starts with) and UI::DisplayElements' no-rush countdown, which gynt left on main at 83.1%.

All five continue gynt's work, in areas he agreed on Discord (2026-11-06) we may take: his drafts on his fork's reimpl/UI-MenuItems-development and reimpl/UI-Rendering-development (63cc49f), his closed #255, and for the countdown his own function on main. None is in his open #294. Three of them were in our draft #360, which drops them in the same push. Every commit body cites his commits by hash, says what was already his and what is new, and credits him as co-author. No header change.

Other PRs: the ready #354, #374 (a fix for main) and #375 (a tools fix); the drafts #313, #318, #321, #327, #328, #356, #360 and #363.

Built on top of main (3a1c7f7) with the bundled MSVC1400-SP1, natively on Windows, against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a). All five read 100.0% raw and normalized in an alone build of this tree, and setupPencil's callers dimBox and drawColorBox stay at 100.0%, 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 a fresh-eyes review (each function compared with the original's disassembly, every attribution checked against the whole history; its points applied and measured), openshc-pr-check with no errors, and status_regression.py, which finds nothing below a known score on main or any fork.

Behaviour fixed compared with the drafts

  • setupPencil (0x00468C80): the map surface's three width tests are >= 4056, where the drafts had 4056 < left and 4056 < right, so x = 4056, one pixel past the 4056-wide map row, was neither clipped nor counted as off the surface: cmp edi, 0xfd8; jl at 0x00468CB8, cmp esi, 0xfd8; jge at 0x00468CC0, cmp esi, 0xfd8; jl at 0x00468CD5. Its callers dimBox and drawColorBox stay at 100%.
  • drawScrollbar (0x004690E0): 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.

The other three behave as before. RenderNoRushDisplayElementUnk's only change is its resolution tests written as separate ifs instead of an else-if chain, in the same order: one resolution matches, and every arm jumps on to 0x004B21AB, so at most one offset applies, as before.

Function Address gynt's commits
drawHeaderBanner 0x00468FE0 2a0beda, 8f3b5da, fc63cfd, 7719115, 63cc49f
drawHeaderTextBanner 0x00475CC0 9a19144, 6ae321d, e69b74d, daeda89, 63cc49f
drawScrollbar 0x004690E0 c808751, 3d9ca03, 63cc49f, 5fa1b20
setupPencil 0x00468C80 3957761, 44a1588, 3d17527
RenderNoRushDisplayElementUnk 0x004B20B0 b0a49d0, 96008db (#199, 648b0c6), 272decc (#269, 4b30c73)

Each body also names his style passes on the file (81e1041, a389f84, dd14331, 9205629, cee658d, b8ab787). A last commit only removes RenderNoRush's six unused using-declarations and two unused includes and writes x -= 18 + barWidth / 2 (quick_diff the same).

Kept as they are, and why

Each was measured; a one-line comment in the code says why where the shape isn't plain.

  • The banners: width is reduced in place (width -= 16), as the original keeps it in width's register (an innerWidth local: quick_diff 0.6353 -> 1.0000 the other way). The tile test stays nested (a flat else-if chain: quick_diff 1.0000 -> 0.9827 and 0.9909 -> 0.9774). rowPictures is declared before the if / else-if chain over the rows that sets it, as in Reimplement 10 UI::Rendering PencilRenderCore functions at 100% #370's bordered boxes. drawHeaderTextBanner repeats drawHeaderBanner's body rather than calling it, as the original has it inline at 0x00475CC0 and never calls 0x00468FE0; the picture enum is repeated per file, like Reimplement 10 UI::Rendering PencilRenderCore functions at 100% #370's BORDER_*.
  • drawScrollbar: its two loops walk yPos itself, as the original does (a walking copy: quick_diff 0.8158 -> 0.9474).
  • RenderNoRushDisplayElementUnk: separate ifs keep each offset that two resolutions share (-240, -400, -560, -880) in the first of the two, as the original does (je 0x004B212C at 0x004B2144) (an else-if chain: quick_diff 0.9797 -> 0.9054). Pairs can't be joined with ||, as the original tests them apart.

Proposed, not changed here

  • PencilRenderCore::drawHeaderTextBanner's textGroupIndex is an eTextSections at every caller on main (TEXT_MAINOPTIONS, TEXT_GAME_OPTIONS, TEXT_XPLAY_WAITING_ROOM, TEXT_SCENARIO); retyping it would touch 17 caller files, so it's left for a PR of its own or the Ghidra sync.
  • drawScrollbar's uint xPos is only passed on to the int drawX and never compared, so nothing in this function settles its sign.
  • gynt's branch reimpl/Wilps-2026-10-18 names 0x27F0 / 0x27F4 skirmishNoRushTicksLeft / skirmishNoRushTicksTotal and this function RenderNoRushCountdownDisplayElement; when those names land, the bar's divisor reads ...Total.

🤖 Generated with Claude Code

kotijekriv and others added 6 commits November 8, 2026 04:18
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>
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>
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>
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>
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>
…cludes

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>
@gynt
gynt added this pull request to the merge queue Nov 8, 2026
Merged via the queue into sourcehold:main with commit ab083cf Nov 8, 2026
5 checks passed
gynt added a commit to gynt/OpenSHC that referenced this pull request Nov 10, 2026
…ner's text group as eTextSections (100%) (sourcehold#384)

* reimplement: SHC_3BB0A8C1_0x00431B60 100.0% Reimplemented

BuildMenu::MenuView_BuildMenu_DoInitial, from gynt's draft (0b3b5bf, 27.26%, and abf493f, 27.3%, in his closed
sourcehold#253; on his fork's reimpl/UI-MenuViews-development 2a65f06, 41.59%, 722a4a2, 44.58%, 22964ce, 74.03%,
1f5a1aa, 98.90%, the dropped guard restored, and fa2be92, 99.84%, the two hidden-tab guards as early returns;
his style passes up to e9bc49c on his fork's reimpl/UI-MenuItems-development) and our 3717c67, 99.9%, in the
draft sourcehold#356. The function is his: the menu's position by resolution, then per build menu tab its menu picture, its
edge pictures and the redraw. 3717c67 added the 640x480 y store (the draft never set DAT_MenuHandlerState::
instance.y there; the original stores it for both branches at 0x00431BA3) and the style pass (decimal offsets, s_
pointers for the 98 edge pictures with their names above them, comments on what the blocks draw).

New here: y is assigned in each branch instead of once before the resolution test, which puts the original's
xor esi, esi before its add eax, -600 (one y before the test: quick_diff 0.9992 -> 0.9984; the rest is the listing's
ret 0); the BOOLEnum pendingMenuRedraw is tested by truthiness and cleared with FALSE (neutral). reccmp 100.0%.

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

* drawHeaderTextBanner's callers name their text group

Fifteen of its eighteen callers passed the text group as a number: 199 is TEXT_SCENARIO, 0x4a TEXT_GAME_OPTIONS, 5
TEXT_MAINOPTIONS and 0x4f TEXT_XPLAY_WAITING_ROOM (eTextSections.hpp). Each now names it, as NewEvent, NewEventAction
and EditScenario already did, and includes eTextSections.hpp. The enum converts to the int parameter, so the code is
the same: all fifteen stay at reccmp 100.0. On the lines this touches, the text number is decimal and each file's
first include is its own "../X.func.hpp" (style guide 18 and 14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* header: drawHeaderTextBanner's textGroupIndex is an eTextSections

As sourcehold#376's description proposed. The function hands it straight to getTextStringInGroupAtOffset, whose first
parameter is an eTextSections (the definition cast it), and every caller passes an eTextSections value:
TEXT_SCENARIO, TEXT_GAME_OPTIONS, TEXT_MAINOPTIONS or TEXT_XPLAY_WAITING_ROOM. PencilRenderCore.hpp includes
eTextSections.hpp and declares the parameter with it; the resolver in PencilRenderCore.func.hpp takes the same
signature. PencilRenderCore.func.hpp includes eTextSections.hpp and has its using, as TextManager.func.hpp does.
The definition follows in the next commit, so this commit alone doesn't build (C2511: the class declares
eTextSections while the definition still takes int); the two stay apart because a header change goes in a commit of
its own. Measured with the next commit: drawHeaderTextBanner and its 18 callers stay at reccmp 100.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* drawHeaderTextBanner takes the eTextSections its header declares

The definition's textGroupIndex becomes eTextSections, and the cast before getTextStringInGroupAtOffset goes. reccmp
100.0 before and after; its 18 callers stay at 100.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* reimplement: SHC_3BB0A8C1_0x004F4EF0 100.0% Reimplemented

BottomLeftTextDisplayState::hasPassedCountdownOrDuration, from gynt's draft (d92c05c, 72.22%, in his closed sourcehold#256;
truth tests in dd14331 on his fork's archive/UI-MenuViews-development-second-pass, locals at first use in
10280b1 on his fork's reimpl/UI-Core-development), restructured from the binary: one if/else chain in place of
the goto (a duration of -1 expires the text, as in his draft), and the previous time is tested after the global is
overwritten instead of through a bool copy, which added a setne. 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_0x004D5780 100.0% Reimplemented

GreatestLord::ComputeSkMasterScore, from gynt's draft (73e93f1, 33.33%, in his closed sourcehold#256; 36.8% in 10280b1 on
his fork's reimpl/UI-Core-development). His finalResults.yearEnd, yearStart, monthStart and monthEnd are
finalResults.tail.tail1's fields on main now, which is what kept the draft from compiling; the killed-lords bonus
is added with +=, and the draft's (char) on finalKilledLords, already a char, goes. The arithmetic is his. 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_0x005119C0 100.0% Reimplemented

HoveredState::Constructor_HoveredState, gynt's draft (bcc9597, 20.00%, in his closed sourcehold#256; 40.0% in 10280b1 on
his fork's reimpl/UI-Core-development) unchanged apart from a duplicate include. The original keeps this in edx
across the call to clearHoveredState, which needs link-time code generation to know that clearHoveredState leaves
edx alone, so both files go into cmake/compiler-flags-gl.txt (without it: push esi / mov esi, ecx).
clearHoveredState stays at reccmp 100.0%. 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_0x00501110 100.0% Reimplemented

HoveredState::createHoverStateElement, from gynt's draft (fee5db4, 50.00%, and 5976ab1, 75.0%, the full-array
return, in his closed sourcehold#256; locals at first use in cf563c2 and the flag comparison in f507976 on his fork's
archive/UI-MenuViews-development-second-pass; restyled in 10280b1 on reimpl/UI-Core-development), rewritten from
the binary: an early return for GM_SOLITARY, and the search for a free element is one for-loop with the element's
fields filled in and returned from inside it, so a full list falls off the end as in the original (the draft's
while loop had an empty bound check). The expiry time adds mapTimeInTicks first, which loads it into ecx as the
original does (commandDelay first: reccmp 93.8%). 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_0x004F4C80 100.0% Reimplemented

MenuHandlerState::startBuildMenuTransition, from gynt's draft (453d527, 82.35%, and 1b5e0a3, 82.4%, in his
closed sourcehold#256; 88.2% in 10280b1 on his fork's reimpl/UI-Core-development). The direction flip is an if/else: his
(uint)(direction < 0) * 2 + -1 put the result in edx where the original reuses ecx (quick_diff 0.7647 -> 0.8824,
the rest being the listing's import call and tail jump). The sound is (SoundEffectID)103, which SoundEffectID
doesn't name yet (a later header commit adds SEID_UNKNOWN_0x67 for it); the draft wrote it as
SEID_BURNING_MAN_SCREAM2 | SEID_WOOD_SAW. 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_0x004F6A80 100.0% Reimplemented

MenuHandlerState::setupMenuForRendering, from gynt's draft (0dfa41d, 40.68%, and cc5c6ea, 45.9%, the not-found
return, in his closed sourcehold#256; 44.1% in 10280b1 on his fork's reimpl/UI-Core-development), rewritten from the binary
as one loop over the menu pairs with the setup inside it. loadMenuElements is called on this->currentMenu, which is
what the original reads ([edi + 4]), not on DAT_MenuHandlerState's. 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_0x004AA480 100.0% Reimplemented

MenuModalComposition::setSliderParameters, from gynt's draft (9f04be9, 78.05%, in his closed sourcehold#256; 93.7% with the
arms swapped in e9bc49c on his fork's reimpl/UI-MenuItems-development), now in the form of its sibling
setSliderParameters2 (0x004AA540, at 100% on main): the offset is stored first and overwritten, as the original
does, and the parameters match the header (NoArgCallback*). It differs from the sibling only in which destination
it sets. Its bound is range > 200, as in the binary and in setSliderParameters2; e9bc49c tested >= 200. 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_0x00491680 100.0% Reimplemented

MenuTextInputState::Constructor_MenuTextInputState, from gynt's draft (d64401f, 95.00%, in his closed sourcehold#256; field
names in 0caea1f on his fork's archive/UI-MenuViews-development-second-pass, restyled in 10280b1 on
reimpl/UI-Core-development). Main has since merged his modalDialog_2 to modalDialog_6 into previousModalDialogs[5],
so those five stores are a for-loop over the array; the rest is his. 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_0x004B6320 100.0% Reimplemented

MinimapViewState::convertLoadedMinimapColors, from gynt's draft (6cbe8e7, 52.48%, in his closed sourcehold#256; 63.6% in
10280b1 on his fork's reimpl/UI-Core-development), rewritten with loops. The palette copy is a memcpy, which MSVC
inlines as the original's rep movsd; the RGB565 conversion reads each colour once, which keeps MSVC from unrolling
that loop as the original doesn't; and the loop over the 200 x 200 tiles is a plain for-loop that MSVC unrolls by
five, as in the original (the draft wrote the five stores out). The 0xffe0 mask is written ~0x1f: the same code,
and main's style_lint accepts it. The draft's #pragma optimize("y", off) isn't needed. reccmp 100.0% (with
--ignore-security-cookie).

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

* reimplement: SHC_3BB0A8C1_0x004B61F0 100.0% Reimplemented

MinimapViewState::generateMinimapImage, from gynt's draft (c00d3e9 and 76f32df, 70.33%, a2075f1, 70.3%, in
his closed sourcehold#256; 74.7% in 10280b1 on his fork's reimpl/UI-Core-development), rewritten from the binary as the
counterpart of convertLoadedMinimapColors (0x004B6320, earlier in this branch): it packs the minimap into a palette
of up to 256 colours and one index per tile. The colour mask is a ushort set in an if/else (an int mask stays in a
register where the original reloads it from the stack: quick_diff 0.6404 -> 0.8315), the palette search leaves with
a goto (measured against a break and an index test in its comment), the colour is compared first, and the RGB555
conversion shifts an int and masks with 0x7fe0 (measured in its comment). The two colour masks (0xf79e and 0xfbde)
are written as the bits they clear. reccmp 100.0% (with --ignore-security-cookie).

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

* reimplement: SHC_3BB0A8C1_0x004B7300 100.0% Reimplemented

MinimapViewState::renderMinimapMain, from gynt's draft (2e5a61f and 270c7e2, 45.5%, af82e41, 65.40%, in his
closed sourcehold#256; field names in 2113d0b and 314b50c on his fork's archive/UI-MenuViews-development-second-pass;
10280b1 on reimpl/UI-Core-development). The code is mostly his. Changed from the draft, to match the binary: the
large-map test is mapSize > 200 (the draft's < 200 swapped the two draws at exactly 200), with the two drawMinimap
calls written out per branch; the y offset adds viewportY / 8 first (the other order: quick_diff 0.9911 -> 0.9464);
the counter wraps with % 4; the click test is one condition; the cursor picture is GM_MINI_CURSORS (the draft's
(eGM)153); and field_0xc and someMiniMapCounterTill4 are main's names now. 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_0x00464300 100.0% Reimplemented

Rendering::RenderCurrentButtonOnScreenMenu, from gynt's draft (6e94dc7, 47.27%, and ea80e97, 47.3%, in his
closed sourcehold#255). The picture number is an argument of drawTgxGmOnFlaggedSurface rather than a local (the original
pushes y and x before it calls getPictureNumberInGm), and the file goes into cmake/compiler-flags-gl.txt next to
getPictureNumberInGm and RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk: the original keeps
buttonGmData in ecx across that call, which needs link-time code generation. 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_0x00464370 100.0% Reimplemented

Rendering::RenderCurrentButtonToScreenMenuWithBlendingUnk, from gynt's draft (5fc0022, 40.00%, and 34ea366,
40.0%, in his closed sourcehold#255), in the form of RenderCurrentButtonOnScreenMenu (0x00464300, previous commit): a blend
strength of 32 returns early, the picture number is an argument of renderGMWithBlending, and the file goes into
cmake/compiler-flags-gl.txt so that buttonGmData stays in ecx across getPictureNumberInGm. reccmp 100.0%.

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

* header: BuildMenuTabType gets BMTT_UNKNOWN_62

MenuView_BuildMenu_DoInitial (0x00431B60) returns early when activeMenuTab.buildMenuTab is 62, a tab the enum has no
name for. Main's hideOrUnhideUI (0x00471AA0) switches the build menu from BMTT_SOLDIERS to 62 when it hides the menu
and from 62 back to BMTT_SOLDIERS when it shows it again, so 62 is the hidden soldiers tab. Named the way the enum
already names 49 (BMTT_UNKNOWN_49) until Ghidra has a name for it. Used in a later commit; code generation is the
same.

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

* header: SoundEffectID gets SEID_UNKNOWN_0x67

MenuHandlerState::startBuildMenuTransition (0x004F4C80) plays sound effect 103 (push 0x67 before setUpSFXToPlayUnk),
which the enum leaves out between SEID_BURNING_MAN_SCREAM2 (100) and SEID_CATAPULT_SHOOT (106); gynt's draft wrote
it SEID_BURNING_MAN_SCREAM2 | SEID_WOOD_SAW. Named in the enum's SEID_UNKNOWN_0x.. form. Used in a later commit;
code generation is the same.

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

* UI: banner texts, BMTT_UNKNOWN_62 and SEID_UNKNOWN_0x67 in use, unused includes

- MenuView_BuildMenu_DoInitial compares with BMTT_UNKNOWN_62 (header commit) in one early return with the hidden
  menu, the comments keep only their reasons, and a fixme says that from 1280x1024 on editor and siege games reset
  the gfx list before the second load, so slot 1 is drawn without being loaded (the original's bug; it matches).
- startBuildMenuTransition plays SEID_UNKNOWN_0x67 (header commit) in place of (SoundEffectID)103.
- The fifteen drawHeaderTextBanner callers have their banner text above the call, from cr.tex, as main's three
  named callers do.
- setupMenuForRendering says why currentMenu is read again for the last two calls; renderMinimapMain writes
  needsRedraw = FALSE, compares DAT_SelectionIconType with 0 and the map size with MC_MAP_SIZE_200;
  convertLoadedMinimapColors says why one copy is inlined and the other calls _memcpy, and loses its history line;
  generateMinimapImage writes its mask as 31 << 10 | 31 << 5 like its colorMask lines, its comment on one line;
  hasPassedCountdownOrDuration uses --unknownCountdown01 and countdown -= now - previousTime.
- Unused includes and usings go (MappersEnum, MenuModalType, MenuViewType, SoundEffectID's using).
Kept, measured: setupMenuForRendering's pointer over the pairs (indexed: quick_diff 1.0000 -> 0.3636), with a
line in the code. Everything else is quick_diff-identical, and all functions the branch touches are reccmp 100.0
in a full build.

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

* MenuView_BuildMenu_DoInitial: the fixme only where the list is reset twice

Only the soldiers tab resets totalLoadedGfx a second time, in editor and siege games, before loading slot 1; the
other tabs reset it once per resolution and load both slots. The two copies of the fixme on those tabs go, and the
true one fits on one line. Comments only.

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>
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.

2 participants