Skip to content

UI menu views and modals: 9 functions, none at 100% yet - #529

Draft
gynt wants to merge 31 commits into
mainfrom
reimpl/ui-menuviews-modals-development
Draft

gynt wants to merge 31 commits into
mainfrom
reimpl/ui-menuviews-modals-development

Conversation

@gynt

@gynt gynt commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

8 menu-view functions plus their callee SomeFearFactorComputation, rewritten from the original control flow. The functions were ported from gynt's catch-all branches: this branch is origin/main plus the copied files, compile fixes, matching work and status.

Measured with reccmp, with both the struct and the function resolvers enabled and main's /GL callees on.

0 of 9 functions at 100%. The others hit a wall: the blocker named for each was measured, and the source forms tried against it tied or scored worse.

Hit a wall

Function Address Match Ported at Why it stops there
ScenarioDescription::MenuView_ScenarioDescription_Prepare 0x004DD100 96.3% 88.2% The stores after rep stosd reuse the zeroed eax in the original.
HistoricMissionIntro::MenuView_HistoricMissionIntro_DoEveryFrame 0x004DB8B0 96.2% 75.4% The float constants come from a global table in the original; only data addresses differ.
StatusMenus::RenderStatusMenu_Overview 0x00447DC0 94.3% 85.0% Under /GL the callee SomeFearFactorComputation clobbers ecx with its setge, so this caller reloads where the original does not. Follows the callee's wall.
ScenarioDescription::MenuView_ScenarioDescription_DoEveryFrame 0x004DD350 87.2% 53.2% Temporary register rotation; the frame-reset copy is constant-folded and the import is called through edi.
Helpers::SomeFearFactorComputation 0x0043E5A0 85.1% new Our final 17/18 choice if-converts to setge on ecx; the original branches. int result = 18; if (x < 3) result = 17; reproduces the original tail exactly but moves fearFactor to ecx (worse); ternary, if/else and early-return forms tie.
CampaignUnk::MenuView_CampaignUnk_Prepare 0x004DCC90 79.7% 57.5% The count lands in ecx instead of eax, and the 20-field row copy alternates ecx/edx in the original.
RankingGames::MenuView_RankingGames_DoEveryFrame 0x004DFB90 79.6% 63.0% Register and stack-slot allocation in the row loop.
CrusadeMap::MenuView_CrusadeMap_DoEveryFrame 0x004DE300 72.6% 54.4% The original tests the furthest trail mission in memory against the zeroed loop register; ours loads it into a register once, which renames everything after the first loop. Merging the cap into the loop condition gives identical code.
DisplayElements::RenderPlayerInfoOnHoverDisplayElement 0x004B0390 68.2% 62.0% The original shares its zero register with aiIndex (ebx); ours zeroes edi and needs an extra stack slot. Reusing posX for iconX, per-arm textWidth / 2 and four aiIndex placements are all worse or tie.

Behaviour fixes

These were wrong in the decompiler output and are fixed against the binary:

  • MenuView_CrusadeMap_DoEveryFrame rendered the extreme trail's mission number as progress + 0x51 (the text-lookup offset); the original adds 1, like the other two trails.
  • types commit: the SkMasters2 version, count and entries are one SkMasters2Data global (same change as on mission-skirmish-flow).

Type and header changes are in their own types: commits. Resolver flags are not committed.


🤖 Generated with Claude Code

https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ

gynt and others added 19 commits November 28, 2026 13:56
…s-modals-development

Their best match lives only on gynt's catch-all branches, which are ~2080 cpp
files ahead of their merge base and 412 commits behind main. The cpp files are
copied unchanged, without the headers of those branches:
- gynt/archive/UI-MenuViews-merged-full@2755710f9 (4)
- gynt/reimpl/UI-DisplayElements-pr-development@fbc092e15 (1)
- gynt/reimpl/UI-MenuViews-development@71e725a06 (2)
- gynt/reimpl/UI-StatusMenus-development@67318e112 (1)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
Renamed fields, globals and resolvers by address, enum-typed arguments,
array fields indexed directly, clang-format.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
SHC_3BB0A8C1_0x00447DC0 85.0% RenderStatusMenu_Overview
SHC_3BB0A8C1_0x004B0390 62.0% RenderPlayerInfoOnHoverDisplayElement
SHC_3BB0A8C1_0x004DB8B0 75.4% MenuView_HistoricMissionIntro_DoEveryFrame
SHC_3BB0A8C1_0x004DCC90 57.5% MenuView_CampaignUnk_Prepare
SHC_3BB0A8C1_0x004DD100 88.2% MenuView_ScenarioDescription_Prepare
SHC_3BB0A8C1_0x004DD350 53.2% MenuView_ScenarioDescription_DoEveryFrame
SHC_3BB0A8C1_0x004DE300 54.4% MenuView_CrusadeMap_DoEveryFrame
SHC_3BB0A8C1_0x004DFB90 63.0% MenuView_RankingGames_DoEveryFrame

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
- HistoricMissionIntro_DoEveryFrame 75.4 -> 93.7: the state-0 render joins the
  else-if chain and the menu render is a separate `state != 0` test (the
  original re-reads the state), the fade end compares against a float
  constant, the intro sound index is one local, and the click handling has no
  goto. Left: register naming in the multiline-text argument sums.
- ScenarioDescription_Prepare 88.2 -> 96.3: no copy of the mission number; the
  difficulty test reads the field. Left: the two field stores after the
  rep stosd use the zeroed eax in the original.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
- CampaignUnk_Prepare 57.5 -> 70.7: MissionDefinedData.field_0x28 is the first
  of one 88-byte row per mission; the changed-objective scan is a plain loop
  comparing row m-1 against row m-2 through one row pointer (MSVC unrolls it
  5x like the original). Left: the count lands in ecx instead of eax, which
  also costs the paired loads in the 20-field copy.
- ScenarioDescription_DoEveryFrame 53.2 -> 84.9: rebuilt from the original
  without gotos - one stack local for the text offset, the animation frame is
  an unsigned divide compared signed, the hint block keeps a running y, the
  two "Hints" headers are separate calls, and the hint flags are the bytes at
  mapAndTime.field43_0xf0 (cleared by ScenarioDescription_Prepare).
  Left: the frame reset copy is constant-folded, import call through edi.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
85.1. Maps the current player's fear factor level to the status-menu
message number 14..19, like SomePopularityRelatedComputation does for
popularity.

Left: MSVC if-converts the final `>= 3 ? 18 : 17` into setge/add on ecx
in every form tried (early returns, ternary, preset result, one result
variable through an else-if chain), where the original branches with
eax alone. Because ours clobbers ecx, building it with
RenderStatusMenu_Overview under /GL cannot remove the ecx reload that
caller's original omits, so it is not added to compiler-flags-gl.txt.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
70.7 -> 79.7. The original keeps INT_00ed27b0 in eax as the counter: it
stores that same register as the initial zero and writes it back after
the copy. Counting in a separate local gave an extra register.

The 20-field copy alternates ecx/edx in the original. A struct
assignment, memcpy and an element loop all give rep movsd or the same
single-register copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
93.7 -> 96.2. The original loads the offset globals before the border
width and height.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
84.9 -> 87.2. Wrapping the frame counter resets it and renders frame 0
through the same `frame < 26` call; the original has no second copy.
The economic-mission hint count reads field_0xae4 (one entry per
mission 33..37) instead of an offset into the speech file names, and
the text section is computed before the count, which is the order the
original loads them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
…order

85.0 -> 94.3. The decompiler output is replaced by named locals in the
order the original reads them:
- The width sum runs left to right.
- The popularity index is computed before its width.
- Each description arm reads the y position before calling its message
  helper.
- The test is `fearFactorLevel != 0` with the fear arm first.

The original keeps the fear arm's y in ecx across the call to
SomeFearFactorComputation, so both functions go on the /GL list. Our
SomeFearFactorComputation still clobbers ecx (setge, see its status), so
our arm uses edx; that is the remaining gap.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
54.4 -> 72.5. This replaces the decompiler output, which had a goto, a
pointer walk and a dozen reused temporaries, with three trail arms of the
same shape:
- The divisions are unsigned, because now is a DWORD.
- The lord animation frame stays uninitialised when INT_00eb9b48 is
  negative, as in the original.
- The icon shift is zeroed before the trail-type test.
- The extreme trail adds the map offset before the render-data x.

The remaining gap starts at the first loop: the original tests
`furthest...TrailMission` in memory against the zeroed loop register,
while ours loads it into edx once and keeps it for the post-loop test,
which renames the registers from there on. Merging the cap into the loop
condition gives identical code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
Row offsets are separate induction variables, the entry is addressed by
reference, the hover arms render with literal icon ids, and the team
loops and filter blocks are goto-free. 63.0% -> 68.9%.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
The original derives each row offset from y with lea and keeps the row
x running in one register. 68.9% -> 71.7%.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
The original keeps the unblended branch's aiIndex in the shared zero
register and zeroes a fresh one for the blended branch. 62.0% -> 68.2%.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
…obal

Same change as on reimpl/mission-skirmish-flow: 0x00DF6248..0x00EB0AB0 is
one block in the original (float version, entry count, 250 entries),
which the original compiles as one object. The three resolvers become
DAT_SkMasters2Data and every user moves to its fields, so the branches
agree on the header once merged. Nothing on this branch changes its
match; readSkMasters2, WriteSkMasters2, Skirmish_SortAIOpponentOrder and
MenuItemActionHandler_RankingGames_Main still differ only in labels.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
… test

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
… test

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
The original repeats the eight row-position increments on the path for a
row without an entry and jumps straight to the loop test, so the empty-row
case is an early continue rather than an if around the row body. The hover
test reads the unadvanced x; each arm advances it before drawing the icon.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
The number in front of the extreme trail's name was rendered as
extremeTrailProgress + 0x51, the offset that only the trail-name text
lookup uses; the original adds 1, as the other two trails do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 30, 2026
@github-actions

Copy link
Copy Markdown

Style guide reading (advisory, posted once)

176 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 10 of the 13 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
1 Drop the decompiler trailing return; 3
13 One function per file, named after it 1
15 Write - 1, not + -1 9
16 Give variables a name that says what they hold 2
18 Use the name, not the number 156
23 Prefer if-else over ternary 1
24 Declare variables upon first use 4
Where

Rule 1 — Drop the decompiler trailing return;

  • src/OpenSHC/UI/MenuViews/CampaignUnk/MenuView_CampaignUnk_Prepare.cpp:149 — trailing return; in a void function
  • src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp:116 — trailing return; in a void function
  • src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp:119 — trailing return; in a void function

Rule 13 — One function per file, named after it

  • src/OpenSHC/IO/readSkMasters2.cpp:16 — none of ReadSkMasters2 matches the file name readSkMasters2

Rule 15 — Write - 1, not + -1

  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:59 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:61 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:63 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:124 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:141 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:156 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:178 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:197 — writes + -N; the readable form is - N
  • src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp:93 — writes + -N; the readable form is - N

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

  • src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp:48 — decompiler name iVar2
  • src/OpenSHC/UI/MenuViews/ScenarioDescription/MenuView_ScenarioDescription_Prepare.cpp:40 — decompiler name iVar1

Rule 18 — Use the name, not the number

  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:110 — hex constant 0x2D0; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:125 — hex constant 0xC2F0EB; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:136 — hex constant 0xC2F0EB; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:144 — hex constant 0x222; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:148 — hex constant 0x21B; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:151 — hex constant 0x21C; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:154 — hex constant 0x21D; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:161 — hex constant 0x20A; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:168 — hex constant 0x1ED; use a name, or decimal
  • src/OpenSHC/UI/DisplayElements/RenderPlayerInfoOnHoverDisplayElement.cpp:172 — hex constant 0xC2F0EB; use a name, or decimal
  • ... and 146 more

Rule 23 — Prefer if-else over ternary

  • src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp:51 — ternary; the guide prefers extending the if-else chain

Rule 24 — Declare variables upon first use

  • src/OpenSHC/Game/Skirmish/Skirmish_SortAIOpponentOrder.cpp:21 — declare maxValue where it is first assigned
  • src/OpenSHC/UI/MenuViews/HistoricMissionIntro/MenuView_HistoricMissionIntro_DoEveryFrame.cpp:47 — declare BVar1 where it is first assigned
  • src/OpenSHC/UI/MenuViews/RankingGames/MenuView_RankingGames_DoEveryFrame.cpp:204 — declare i where it is first assigned
  • src/OpenSHC/UI/MenuViews/RankingGames/MenuView_RankingGames_DoEveryFrame.cpp:244 — declare j where it is first assigned

- SkMasters2Data.hpp (add/add): take main's header.
- compiler-flags-gl.txt: main's list plus this branch's
  RenderStatusMenu_Overview and SomeFearFactorComputation lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot removed the declaration/type change This requires changes to the generated/exported types or definitions. label Dec 2, 2026
gynt added a commit that referenced this pull request Dec 3, 2026
…eb9c9 header syncs (#546)

* Fix eight files that stopped compiling after the efea7fc header sync

The Ghidra sync efea7fc renamed PlayerData::aiControlStatusRelated to aiHoldBackTicks (the same int at
0x2274). migrateGameStateForMapVersion, setAIControlStatusTo100000 and six Update* unit functions still used
the old name; they move to main's name. No header or status line changes.

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

* Fix eight more files that stopped compiling after the Ghidra syncs

The syncs 6823e33 and 1feb9c9 renamed or merged four more things that eight files still used:

- Entity's short at 0xB0: unkMinusOne -> blendStrength (setEntityParameters, tickEntityDecayCounter).
- The global at 0x00ED3154: DAT_00ed3154 (undefined4) -> INT_00ed3154 (int), with its header
  (ApplyBlending, BlitMapImageWithVerticalClip, RenderTerrainTilesCenterPiece).
- MenuTextInputState's method at 0x004917C0: meth_0x4917c0 -> closeAllModalDialogs
  (MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk).
- The three SkMasters2 globals (version, count, entries) are now one struct, DAT_SkMasters2Data at 0x00DF6248
  (ReadSkMasters2, WriteSkMasters2).

No header or status line changes.

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

* Fix five more files after the syncs, with lines from gynt's open PRs

The syncs typed three things these files pass or compare as plain numbers, and merged the SkMasters2 globals:

- SetStorageMarketFailState takes a StorageMarketFailStateEnum: the SMFS_ names for the numbers it is
  given and the states compared after it (MenuItemActionHandler_AlliesSendAndRequestGoods_Main,
  MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands), as in gynt's #295.
- The plateau call's fourth parameter is a Logic2: a cast on DAT_GameCommandParam3 (ClickCreatePlateau),
  as in gynt's #396.
- DAT_SkMasters2DataArray is DAT_SkMasters2Data's entries (Skirmish_SortAIOpponentOrder,
  MenuItemActionHandler_RankingGames_Main), as in gynt's #525 and #529.

The hunks are gynt's, unchanged, so those PRs merge with this one.

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>
Co-authored-by: Gynt <gynt@users.noreply.github.com>
gynt and others added 2 commits December 3, 2026 23:14
cmake/compiler-flags-gl.txt: both sides appended entries; kept both.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The two border additions in the renderMultilineText5Unk call now come out
with their operands the other way round. Restoring the pre-merge
TextManager.hpp/.func.hpp alone brings the quick diff back from 0.9686 to
0.9937, although this function calls none of the changed declarations, and
no spelling of the sums in the .cpp (operand order, locals, casts, ptr
access, include order) changes the emitted code. Measured with a full build
and reccmp, both resolver sets enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
gynt and others added 7 commits December 4, 2026 10:00
The original ends in `cmp eax, 3; mov eax, 18; jge; mov eax, 17`, which
no two-way spelling produces: `>= 3 ? 18 : 17`, `17 + (ff >= 3)`, the
if/return pair either way round and an else-if chain all fold into
`xor ecx, ecx; setge cl; add ecx, 17` (85.7%), and a result local
initialised to 18 moves the fear factor into ecx (75.0%). A third,
always-true `>= 0` exit before the final `return 17` keeps the branch.
Behaviour is unchanged. No longer writing ecx also lets
RenderStatusMenu_Overview, compiled with it under /GL, keep a value in
ecx across the call, as the original does. Measured with a full /GL
build and reccmp, both resolver sets enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Add the popularity text width straight onto `width + 0xc` instead of
through a local (gives the original's `lea eax, [esi + eax + 0xc]`
operand order), and load the "and" line's y into a local before the call
so it is computed into eax ahead of `x + 6`. Together with
SomeFearFactorComputation no longer clobbering ecx, this is 96.5% ->
100%. Build mode: /GL (both files stay in compiler-flags-gl.txt); the
ecx reuse across the SomeFearFactorComputation call only happens when
the callee's register use is visible.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Read the text position and the menu border into locals, in the order
y, x, border, before the renderMultilineText5Unk call. Which operand of
each `+` becomes the add's destination and which is loaded first is a
tie MSVC breaks by symbol order, and the order the globals are first
referenced in the function decides it: of the six orders, only
DAT_00eb9b34, DAT_00eb9b30, DAT_WindowAndDirectDraw gives the
original's `mov edx, [b34]; mov eax, [borderH]; add eax, edx` and
`mov edx, [borderW]; mov ecx, [b30]; add edx, ecx` (the others 91.8 -
93.7%). reccmp 92.5% -> 96.2%.

The remaining reccmp lines are labels only: the original's 30.0f,
31.0f, 32.0f and 31.0 constants (0x5ab0c4, 0x5ab03c, 0x5ab0ac,
0x5ab0b0, values checked in the exe) are unnamed data, and _ftol2_sse
is an unnamed call target. The instruction stream is identical.
Measured with a full build and reccmp, both resolver sets enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…ryFrame

Name the RenderMissionObjectivesUnk result before subtracting the border
height and the 0x1e margin. The single-expression form gives the
original's `mov ecx, -0x1e; sub ecx, [borderH]; add eax, ecx` but takes
edx instead of ecx for it, and every scratch register after that point
comes out one step along the eax/ecx/edx cycle from the original's (26
operands). With the local, MSVC reassociates the sum into
`sub eax, [borderH]; sub eax, 0x1e` and the cycle downstream lines up
again. reccmp 87.2% -> 90.7%.

Remaining: those two instructions, plus two more scratch-register
picks in the hint loop. In one, the original takes ecx for `i + 2` where
ours reuses the just-pushed eax. That also lets MSVC hoist the loop's
`mov ecx, TextManager` above the je. Measured with a full build and
reccmp, both resolver sets enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Three local-shape fixes in the row loop, reccmp 79.6% -> 80.4%:
- The hover test reuses `x + 0x18` for the right edge
  (`lea eax, [esi + 0x18]; ...; add eax, 0x2da`), so name it `left`
  and compare against `left + 0x2da`.
- The row counter's zero store comes first among the second group of
  stores to the frame (after the dateY lea batch), so declare it
  between dateY and nameY.
- `drawn = 1` is stored before lordTeam, so declare it first.

What remains is mostly eax/ecx/edx picks for short-lived values that
come out one step along the cycle from the original's. Where that
happens inside if/else arms, the arms stop being identical, so MSVC can
neither hoist their common head (the 0x1f "Turn off" block) nor merge
their tails as the original does. Measured with a full build and
reccmp, both resolver sets enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…oop reads

The test after the first-edition trail loop compares skirmishTrailProgress
with furthestSkirmishTrailMission. MSVC reused the loop condition's load of
furthestSkirmishTrailMission for it, so it kept that value in edx through the
loop guard, the loop bottom and the test. The original reads it from memory
each time (`cmp ebp, [furthest]`). Reading both operands of the test through
volatile stops the reuse, and the loop now matches the original
instruction for instruction. Semantics are unchanged.

reccmp 72.6% -> 75.3% (full build, both resolver sets enabled).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…mission index

The diff loop now names both rows from the mission index, with the next
row written as [1] of the current one, instead of going through `rows`.
Two effects:
- `rows` is no longer read in the loop, so the strength-reduced loop
  pointer outranks it. The pointer takes edx and `rows` takes esi, as in
  the original, which also gives the 20-field copy its ecx/edx
  alternation back.
- The loop pointer is based on the current row, so the loads are
  `[edx + 0x58]` against `[edx]` as in the original.

What remains: the original computes the row address once, as
`lea esi, [esi + G]`, and copies it with `mov edx, esi`. Ours computes it
twice (`add esi, G`, then an `imul`/`lea` for the loop).

reccmp 79.7% -> 98.2% (full build, both resolver sets enabled).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
gynt added a commit to gynt/OpenSHC that referenced this pull request Dec 4, 2026
…GUIDE

MenuView_HistoricMissionIntro_DoEveryFrame:
- named locals (windPlaying, ticks, blendStrength) instead of BVar1/iVar2,
  declared at first use
- early return instead of the comma operator in the fade condition,
  += for the fade step
- decimal coordinates, 0.0f/30.0f/31.0f float literals, no redundant
  (double) casts, countof for the mission sound table
- the 31.0 in the fade reversal stays a double with a comment: the
  original subtracts in double precision (fsubr qword)
- dropped the trailing return and the unused usings

RenderStatusMenu_Overview:
- decimal coordinates, font size and text index, += for the width sum,
  comments for the three description parts
- dropped the unused usings and the unused BGR24 include

SomeFearFactorComputation: namespace closing comments.

Re-measured on main 40cbb1c with a full build and reccmp: unchanged,
SomeFearFactorComputation and RenderStatusMenu_Overview at 100.0 / 100.0,
HistoricMissionIntro at 96.2 / 96.0 with only float constant names and
_ftol2_sse differing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
gynt added a commit to gynt/OpenSHC that referenced this pull request Dec 4, 2026
…on_Prepare, register allocation differs

Taken from draft sourcehold#529, with the style pass applied (imported string
literals with their text as comments, the comma-operator condition written
out as nested ifs, named locals for the event-condition clear, no
unused usings or trailing return). memset was measured for the clear and
costs the match (it is called, not inlined), so the pointer walk stays
with a comment.

Measured on main 592a17d with a full build and reccmp: 96.3 / 88.2.
The only remaining differences are allocation ones:
- the two stores after the rep stosd use the zero in esi instead of the
  eax that rep stosd leaves at zero;
- the mov ecx, 0x1f40 count load sits before instead of after xor eax, eax;
- one branch offset moves by 2 bytes because the esi stores encode longer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
gynt added a commit to gynt/OpenSHC that referenced this pull request Dec 4, 2026
- SomeFearFactorComputation, HistoricMissionIntro: the comments that only
  explained match-driven forms move to the PR thread.
- HistoricMissionIntro: the wind-sound check and the tick count feed the
  ifs directly instead of going through one-use locals.
- ScenarioDescription_Prepare: the event-condition clear is a countof loop
  over SEC_EventsExtra[event].conditionIsTrue instead of a pointer walk;
  MSVC still turns it into the original's rep stosd.
- RenderStatusMenu_Overview: the two description comments are one.

Re-measured on main 592a17d with a full build and reccmp, unchanged:
100.0 / 100.0 / 96.2 (counted) / 96.3 (register allocation differs).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
gynt and others added 2 commits December 5, 2026 05:48
Scores re-measured with both resolver sets on after merging main
(ScenarioDescription_DoEveryFrame 87.2 -> 90.7, RankingGames_DoEveryFrame
79.6 -> 80.4 from main's changes alone) and the blockers recorded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp

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