Skip to content

Reimplement 3 UI::MenuViews functions from gynt's drafts (draft, below 100%) - #356

Draft
kotijekriv wants to merge 14 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-MenuViews-development
Draft

kotijekriv wants to merge 14 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-MenuViews-development

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Three UI::MenuViews functions from gynt's drafts that come close to 100% but don't reach it, so others can continue from them (the rule: ready functions in their own PR, the rest in a draft). Two of them fix behaviour bugs in the drafts. Each status line says what is left, and each commit body says what changed against the draft and what was tried.

MenuView_BuildMenu_DoInitial was the fourth: it is at 100% now in #384, so its draft here is dropped (2680bda) and the two PRs merge cleanly.

Other PRs: the ready #379, #380, #381, #382, #383 and #384, and the drafts #313, #318, #321, #327, #328, #360 and #363.

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 of this branch. None of it has been run in game. openshc-pr-check gives no errors, and status_regression.py finds nothing below a known score.

Class Function Address Raw / normalized Draft (gynt's fork) Left
BuildingAndStatusMenu MenuView_BuildingAndStatusMenu_DoInitial 0x004398B0 96.3% / 90.7% reimpl/UI-MenuViews-development, 96.2% MSVC keeps the constant 99 in ecx from one resolution block to the next; the original only in the first.
UnusedDemoBuyItScreen MenuView_UnusedDemoBuyItScreen_DoInitial 0x00426600 97.7% / 94.4% archive/UI-MenuViews-merged-full, 83.7% x now has a local of its own, which puts the border height and width in the original's registers (was 83.7% / 66.7%). Left: our menu y store comes before the resolution test, the original's after it.
GameStartEnterName MenuView_GameStartEnterName_Prepare 0x00440560 98.2% / 94.1% reimpl/UI-MenuViews-development, 82.5% The name buffer and the security cookie sit 4 bytes off in the frame (gynt's draft has the same).

Behaviour fixed compared with the drafts

  • BuildingAndStatusMenu_DoInitial: at 640x480 the draft never set DAT_MenuHandlerState::instance.y, which the original stores for both branches (the shared tail store at 0x004398F5). Reimplement 14 UI functions from gynt's drafts, and drawHeaderTextBanner's text group as eTextSections (100%) #384's BuildMenu_DoInitial has the same fix.
  • GameStartEnterName_Prepare: when a name was entered before, the original returns right after clearing the two trigger flags (stores at 0x00440648 and 0x0044064E, return at 0x00440669). The draft went on to load frontend_combat3.tgx, reset the text and open the name dialog.

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

🤖 Generated with Claude Code

kotijekriv and others added 4 commits November 7, 2026 02:50
…ed, s_ pointers, style pass

From gynt's fork branch reimpl/UI-MenuViews-development (99.8% there). One fix: at 640x480 the draft never set
DAT_MenuHandlerState::instance.y, which the original stores for both branches (the shared tail store at 0x00431BA3).
Style pass: the decimal offsets and box corners, s_ pointers for the 98 edge pictures with their names above them, the
casts and `+ -1` gone, tab 62 named in a comment (BuildMenuTabType has no name for it), comments on what the blocks
draw. Left: the original zeroes esi before it adds -600 to the screen height, ours the other way round (quick_diff
0.9984); fifteen shapes of the menu-position code (y forms, x locals, a switch, store orders, branch-local y) all tie or
lose. Measured in a clean alone build of this branch on main 8125c61: 99.9% raw, 92.9% normalized.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed, s_ pointers, style pass

From gynt's fork branch reimpl/UI-MenuViews-development (96.2% there). One fix: at 640x480 the draft never set
DAT_MenuHandlerState::instance.y, which the original stores for both branches (the shared tail store at 0x004398F5);
with it the prologue's push ebx lands where the original has it. Style pass: decimal offsets, s_ pointers for the edge
pictures ((char*), loadGfxAtBufferEnd takes a char*), the redundant parentheses, casts and `+ -1` gone, iVar5 is
leftGfx, the pending-redraw test an early return. Left: MSVC keeps the constant 99 in ecx from one resolution block to
the next (a `mov ecx, 99` at each block's end), where the original keeps it only inside the first block and stores an
immediate everywhere else (quick_diff 0.9791). Moving the 99 stores of the first two blocks out of their tab branches
fixes every later block (0.9920) but breaks those two; inverting the tab tests, swapping the stores and other literal
types (99L, 99u, 'c', short) all tie. Measured in a clean alone build of this branch on main 8125c61: 96.3% raw, 90.7%
normalized.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch archive/UI-MenuViews-merged-full (83.7% there). The menu handler's x is stored before its y
(quick_diff 0.8372 -> 0.8605, though reccmp still gives the draft's 83.7%). Style pass: iVar2 is offset, borderWidth and
borderHeight are locals at first use (borderHeight const), pMVar1 is Menu* const menu, 0x18 is 24, the casts, the unused
using and bVar3 go, a comment says what the 24 pixels are. Left: the original holds the border height in eax and the
width in ecx, ours the other way round; declaration orders, an inline height, an if / else for the x store and reusing
the offset local for the width all tie or lose. Measured in a clean alone build of this branch on main 8125c61: 83.7%
raw, 66.7% normalized.

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

From gynt's fork branch reimpl/UI-MenuViews-development (82.5% there). One fix: when a name was entered before, the
original returns right after clearing the two trigger flags (the stores at 0x00440648 and 0x0044064E, the return at
0x00440669); the draft went on to load frontend_combat3.tgx, reset the text and open the name dialog. Style pass: the
copy is strcpy with main's 4996 pragma, the lord-name search an index loop over LordNameToCall with a found flag, the
length test a for (;;) loop (strlen makes the frame four bytes larger: quick_diff 0.9577 -> 0.9296), TAIT_ZERO, the s_
pointer, the plate comment, casts and unused usings gone. quick_diff 0.9577 is artefacts only, but quick_diff collapses
stack slots: reccmp shows the name buffer at [esp + 0xc] where the original has [esp + 0x10] and the cookie 4 bytes off,
also in gynt's draft. Buffer sizes 248 to 260, declaration orders and the goto all tie. Measured in a clean alone build
of this branch on main 8125c61: 98.2% raw, 94.1% normalized.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 2 commits November 7, 2026 21:03
…ith gynt's draft

Draft. MenuView_SingleplayerMapChoice_DoEveryFrame fades the map table's background, rebuilds the table's list of maps
of the chosen mission type when asked to (selecting and scrolling to the map named in standaloneFilename), and draws the
table's box and frame. Written from the original's instructions, with gynt's draft (6abf598 on his fork's
reimpl/UI-MenuViews-development, 83.33% there) for the reads. Fixed: with main's header the draft's
DAT_ArrayOfMapIndices[count - 1] and DAT_ArrayOfMapIndices[count + 499] land 4 bytes below the original's stores; the
original stores to [count * 4 + 0x01126E28] and [count * 4 + 0x011275F8], which in main's header are
DAT_ArrayOfMapIndices[count] and DAT_ArrayOfMapIndices2[count - 1] (as main's SaveLoadMap indexes it). Changed: the
stricmp nested around the name lookup, which pushes standaloneFilename first as the original does; strlen for the inline
loop; the copy of the name into a 1008-byte buffer with strcpy and strcat (main's 4996 pragma, S__MAP_005A2294); a for
loop with continue; the scroll counter a local (in the globals: quick_diff 0.8440 -> 0.7794). Left: the original keeps
the scroll counter in edx and stores it and the selection only after the scroll loop, and allocates the box's
coordinates to other registers; the loop and coordinate forms tried tie or lose. This file was measured as it stands in
a clean alone build of the branch on main eef6f66: 84.2% raw, 75.1% normalized.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Draft. MenuView_Credits_Prepare loads the credits pictures (or the end credit after the campaign), opens credits.hlp in
the scroll dialog, stores the credits' start times and clears the screen. From gynt's draft (458bcd5 on his fork's
reimpl/UI-MenuViews-development, 80.00% there): main's namespace form, the s_ pointers for the six strings, the section
lookup nested in the call, -600 for 0xfffffda8, the casts go. Left: the original keeps 0 in edi for its six zero stores
and pushes; ours uses immediates. Typing the three undefined4 globals int, a zero local, !x and the store order do not
change that. This file was measured as it stands in a clean alone build of the branch on main eef6f66: 82.1% raw,
82.1% normalized.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al's arm order

Draft. MenuView_BuildingAndStatusMenu_DoEveryFrame draws the building and status menu's panel for the open tab and
resolution, then the open building's menu (one switch arm per building, 88 of them) and, unless a video plays or at
640x480, the minimap. From gynt's 7be5530 on his fork's reimpl/UI-MenuViews-development (44.69% in its status line,
earlier 1f2ec77 and 3207aef at 39.2%): the whole function is his. Changed here: the 88 arms in the original's order,
read off the addresses of the jump table's targets (1, 44, 2, 3, 4, 45, 5 .. 24, 96, 25, 53, 57, ..., 79, 78), which is
the order MSVC lays the arms out in; quick_diff, which reduces every call to one token, cannot see this (it gives his
order 0.9852) but reccmp does: 45.0% raw and 86.7% normalized in his order. Also: main's namespace form; decimals for
the panel offsets (0x195, 0x196, 0x1b9, 0x1d7, 0x1d8, 0x1e9, 0xe); the casts on the colour and five unused using lines
go; truth tests on the two BOOLEnum video flags; needsRedraw = TRUE; one comment. Left: the original has a separate arm
for the mercenary post that calls 0x0043A8D0 like the barracks' arm (two arms, at 0x00449624 and 0x0044962E); ours calls
the same resolver from both cases and MSVC merges the two arms into one. Two different functions folded into one address
by the linker would explain the original's two arms; the header has one name for that address. With the arm missing,
every jmp to the shared exit after it is 15 bytes off, which is all reccmp still shows. The tail call is the resolver's.
This file was measured as it stands in a clean alone build of the branch on main eef6f66: 72.9% raw, 58.9% normalized.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 3 commits November 7, 2026 23:39
…ith gynt's draft

Draft. MenuView_UnusedCreateSiege_DoEveryFrame draws the unused "'Siege That' Builder" screen: the title, " - " and the
map's name, the description (TEXT_MAPEDIT 37) unless the bottom-left text box shows one, and the same minimap preview
with its size label as NewMapMapsize's DoEveryFrame (0x0042F3F0, here at y + 240); then it clears
MenuTextInputState.field_0xa4 and stores whether the current player has a keep. Written from the original's
instructions, with gynt's draft (266501c on his fork's reimpl/UI-MenuViews-development, 73.70% there; earlier
0df26b8, c218ebd, 94b5738 and 660d9d6) for the reads; the preview is the code of the twins in
sourcehold#369, which the original's instructions repeat. Changed: main's names after the sync (field_0x24,
field_0xa4, buildingEntryInfos[0] for keep); the description's position as two locals, y first (inline: quick_diff
0.8802 -> 0.5928); s___005a2304 for " - "; COL_C2F0EB and COL_000000; decimals; main's namespace form; no decompiler
locals. Left: the original keeps 1 in ebx and saves all four callee-saved registers up front, and in the name's else
branch computes the position into esi and edi before it calls getTextArrayPointer; ours keeps 1 in edi and saves ebx and
esi only around the preview. The forms tried for the name (its position as locals before the branch or in it, the call
as a statement of its own, the title's position as locals) all lose. This file was measured as it stands in a clean
alone build of the branch on main eef6f66: 91.4% raw, 76.4% normalized.

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

The sync renamed DAT_00b95954 to INT_00b95954, typed int; MenuView_Credits_Prepare uses the new name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As in sourcehold#369's twins: 160, 200, 300 and the default 400 are MC_MAP_SIZE_160, _200, _300 and _400; 100 has no name
and stays a number. quick_diff 0.8802 as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Draft. MenuView_UnusedDemoBuyItScreen_DoInitial (0d11bd2, gynt's draft in main's style) now gives x a local of its
own, x = borderWidth with + 24 at 800x600, instead of adding to borderWidth in place. That puts the height in eax and
the width in ecx, as in the original (with one local for both, ours held them the other way round); the y store into
MenuHandlerState now comes before the x store, also as in the original (quick_diff 0.8605 -> 0.9535; one local for
both: 0.8605). Left: our menu y store is placed before the resolution test, the original's after it; writing the store
into both arms of the test, or the test before the store, loses. Measured in a build of the changed draft files alone
on the branch (main e32319b): 97.7% raw, 94.4% normalized (was 83.7% and 66.7%).

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>
…100 has at 100%

MenuView_BuildMenu_DoInitial (0x00431B60) is at 100% on reimpl/UI-A-round37-100. Its draft here (99.9%, from
3717c67) goes, and its status line returns to main's, so the two PRs merge cleanly in either order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kotijekriv kotijekriv changed the title Reimplement 4 UI::MenuViews functions from gynt's drafts (draft, below 100%) Reimplement 3 UI::MenuViews functions from gynt's drafts (draft, below 100%) Nov 9, 2026
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>

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