Repository navigation
Reimplement 22 rendering, UI and GameSynchronyState functions (not yet 100%) - #313
Draft
kotijekriv wants to merge 92 commits into
Draft
kotijekriv wants to merge 92 commits into
kotijekriv wants to merge 92 commits into
Conversation
…s; own handler tables The TGX blitter: C++ around the two handwritten __asm blocks transcribed from the binary. All seven locals sit in the original's frame slots (names and declaration order both matter in this unoptimised function). Left: the asm reads currentRenderSurface through `this` (inline asm cannot name a resolver global), and the handler tables are our own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was listed before the file existed. With resolvers on, takeScreenshot measures 37.1% with /GL and 85.4% without: LTCG gives our STL instantiations custom calling conventions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plain std::ofstream lines up with the game's statically linked VC8 STL; the call and vtable targets differ. Also left: volatile register choice in the byte-writing loops, and one ecx reload before copyData that only goes away with fillMemory.cpp in the same translation unit. Needs src/OpenSHC/IO/ResourceManager/paths.cpp in the build list (direct call). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same instructions as the original; only the callee-saved registers holding 0, 1 and `this` rotate. Their use counts already match the original's (25, 10, 7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its body is VC8's operator<<(basic_ostream<char>&, char): the callers clean the stack (add esp, 8), and the second argument is the character. Declared __stdcall with a uint, every call through the resolver would have leaked 8 bytes of stack. No other file calls it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…otation The bytes now go through the game's own operator<< (OS::basic_ofstream_write) via its resolver, as in the original: 85.4 -> 87.1% (data resolvers on); the five calls match. The stream object is still our library's std::ofstream (same VC8 layout). Left: the inlined parts of the game's ofstream constructor/destructor (vtables, _Stinit, close), volatile register choice in the byte loops, one ecx reload before copyData. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p only WindowAndDirectDraw::prepareWindowAndDDraw_2Unk, from gynt's version on his fork's reimpl/UI-Rendering-development (66.7%). The retry is a plain while loop that falls back to 800x600 once and otherwise posts the close message, the saved blit mode is scoped to the first if, and pendingMenuRedraw is written through the global instance as in the original. The instructions now match; only edi and ebx (the constant 1 and the saved blit mode) are swapped. Loading the saved mode before the if gives the original's registers but moves the load (74.6%). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n only WindowAndDirectDraw::reinitWindow, from gynt's version on his fork's reimpl/UI-Rendering-development (58.6%). The fullscreen check reads the global instance as the original does, and the fullscreen branch returns after SetFocus instead of falling through to the client-rect code. What's left is only which of eax/ecx/edx each windowHandle reload uses; if/else, nested and early-return shapes all tie. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gisters in the windowed branch WindowAndDirectDraw::bltMapGameSurfaceToScreen, from gynt's version on his fork's reimpl/UI-Rendering-development (55.6%). Early returns, a cameraOffsetX local (the original keeps it in ebp, loaded before the windowed/fullscreen branch, with zero in edi), and the destination rect written as the source rect shifted by the client origin minus the camera. What's left is the order of the windowed branch's arithmetic and which scratch registers it uses: the original computes right and bottom into eax/ecx so both branches share the last two stores. Without the local those stores merge but zero moves to ebp (56.8%). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…am_1 takes the register instead WindowAndDirectDraw::renderBltAndFlip, rewritten from gynt's version on his fork's reimpl/UI-Rendering-development (46.5%). The menu overlay block (modes 2, 3 and 4) appears twice in the original, word for word, after the map blit and after the flip, so it's a static __forceinline helper here. The overlay test, the resolution and the final pendingBltMode reset go through the global instance, as in the original; the fullscreen path BltFasts to &clientOnScreenCoords, and the flag is a BOOL (a dword 0/1 in the original). What's left is register allocation: the original keeps zero in ebp and leaves param_1 in its stack slot, ours gives param_1 ebp and uses immediate zeros, which shifts much of the function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…x is reassociated AlphaAndButtonSurface::isMouseOnButtonImageUnk, from gynt's version on his fork's reimpl/UI-BuildingMenus-100 (65.4%). The picture number is compared signed, the image index is computed once for the width and height reads, and the magenta tests are 16-bit (ushort) compares as in the original. In the alpha branch the original computes mouseX - ButtonX on its own and adds it to width * y; ours folds it into width * y - ButtonX + mouseX. Locals, int casts, a row pointer and computing it before the global store all compile the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…offsets around the statue case AlphaAndButtonSurface::openBuildingStatusMenuForBuildingID, restructured from gynt's version on his fork's reimpl/UI-Rendering-development (55.0%). The original tests someone else's building first (statue, then a switch that only selects most types and lets allied walls and towers and editor outposts through), falls into the owner path, and lays out the owner switch's cases in its own order (roughly by menu tab), which is reproduced here; the two early returns are separate ifs. The building field is field203_0x2c6 on main (field241_0x2c6 on the branch). What's left: the original keeps the 0x59 statue block in the visitor branch and the owner STATUE case jumps back to it; ours keeps it in the owner switch, which shifts the jump offsets after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ck slots Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second bar and the blit only run outside an in-game menu (if/else in the original). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… differ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The message only closes once its video or speech has finished: the draft had empty ifs where the original returns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pills differ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… alloc Rewritten from the asm: the decompiler had split the ranking tables into ~20 overlapping arrays and the draft's init loop wrote past the end of one of them. Left: the frame is 8 bytes larger (iconY and the player index are spilled where the original keeps them in ebx/esi), which shifts every stack offset. Separate arrays (points, stars, overallOrder + one block for kills, losses and the 16 orders) put every array in the original's slot and raise the normalized match, but measured 1.5 points lower raw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from the asm with both passes, the two progress bars and the builder-mode description as the original has them. Left: register assignment (loop index, y and the number width sit in different callee-saved registers), which renames most of the function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The four pixel loops (555/565, normal/zoomed out) are handwritten assembly in the original and are transcribed from the binary; the setup stays C++ and the locals are declared so they land in the original's frame slots. Left: the setup loads the row and the image pointer into other registers, and the asm reaches surfacePointer_mapGame, DrawSomeX and unknownSpecificPointer through two static pointers (inline asm cannot name a resolver global), two extra instructions per loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two copy loops (normal and zoomed out) are handwritten assembly in the original and are transcribed from the binary; the clipping stays C++, with the locals in the original's frame slots. The draft fell through an empty if where the original returns when there are no rows. Left: ebx is pushed in the prologue where the original pushes it after the early return, and the asm reaches four globals through static pointers (inline asm cannot name a resolver global). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two copy loops are handwritten assembly in the original and are transcribed from the binary; the clipping stays C++, with the locals in the original's frame slots. The draft fell through an empty if where the original returns when there are no rows. Left: the clipping prologue holds the row count, skip and next skip in other registers (esi/ecx/edx rotated), and the asm reaches four globals through static pointers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The copies are handwritten assembly in the original and are transcribed from the binary; the range check stays C++, with drawY and source in the original's frame slots. Left: the asm reaches surfacePointer_mapGame, DrawSomeX and unknownSpecificPointer through two static pointers (inline asm cannot name a resolver global), two extra instructions per path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main renamed the global GMTotalPicturesProcessed (same address, int[240]) to GMFirstPictureIndex in 0d1fdb6, so RenderGoldValue no longer compiled on this branch's base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
playAiLordMessage's param_1/param_2 are x/y; RenderAnimatedTutorialFloatOverlay's are x/y too, its offset local and goto labels are named and '+ -N' is '- N' (rule 15); its imported comment is a short // note. RenderGoldValue's two colour ternaries are if/else (rule 23). RenderGreatestLordScreen declares one more variable at first use (rule 24). Measured: no function changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DAT_SomeTextArrayIndex is written through the global instance, as the original does. Left: two stores of the dialog stack push are scheduled after the activateModalDialog arguments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original only clears the other dialogs when there is no previous dialog to return to; the draft called clearAnyOtherModalDialogs every time. Left: one store of the dialog stack shift is scheduled after the compare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original returns after converting the click; the draft fell through and always wrote -1 to both outputs. The row is read with a short cast (movsx). Left: the tileX pointer and the orientation offset sit in swapped callee-saved registers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The copy loop is handwritten assembly in the original (mov reg, 0 and mul), transcribed into __asm. Left: inline asm cannot name a resolver global, so the pencil surface is reached through a static pointer (two extra instructions). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Nov 8, 2026
…00% (sourcehold#348) * reimplement: SHC_3BB0A8C1_0x00426D30 100.0% Reimplemented MenuItemRenderFunction_UnusedEconomicMissionSelect_MissionSelect, from gynt's draft on his fork's branch reimpl/UI-MenuItems (43.5% there). A mission not reached yet is an empty cell; the selected one shows its number and name; the others the same in two colours, one call per colour, as in the original (one renderText2 with a colour local, gynt's draft: quick_diff 0.9302 -> 0.6615). DAT_ButtonUnknownZero is set to TRUE/FALSE. Shape: the selected mission's name position as locals, y then x (in the call: quick_diff 0.9302 -> 0.7608; x first: 0.8992); the other missions' number position and value worked out in each branch (once, before the hover test: 0.9302 -> 0.8760; any order of the three ties inside the branches). A comment says what the button holds: minus the mission number, shown as mission - 32 and named by entry mission - 11 of TEXT_MISSION_NAMES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuTextInputState's modalDialog_2..6 are one array The five fields after currentModalDialog (+0x60..+0x70) are the stack of dialogs below the current one, and the original moves them as an array: popModalDialog shifts them down one and activateModalDialogAndClearText pushes the current dialog on top, each a loop the compiler unrolled (0x00493900, 0x004916C0). Written as five named fields neither function matches (quick_diff 0.8788 and 0.7742). Now previousModalDialogs[5], most recent first. main's clearModalDialog2to6 is the only .cpp on main that names the fields; the next commit moves it over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: clearModalDialog2to6 clears previousModalDialogs main's MenuTextInputState::clearModalDialog2to6 (0x00491730) named the five fields the previous commit makes one array. It now clears previousModalDialogs in one loop (countof, to MMT_NO_MENU, which is 0) and compiles to the same code (reccmp 100.0%). Its first include is now the class's .func.hpp, as its siblings have it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00493900 100.0% Reimplemented MenuTextInputState::popModalDialog, from our draft on kotijekriv's fork branch reimpl/UI-Core-development (93.9% there, also in sourcehold#313). The previous dialog comes off the stack, the rest move down one (a loop over previousModalDialogs; written out per element: quick_diff 0.9394 -> 0.8788), and it becomes the current dialog. The save-map dialog gets its file list and text input back; an empty stack clears every other dialog. Guarded, not an early return (an early return for the empty stack: 0.9394 -> 0.8788). resetToTextIndex takes TAIT_TWO__FILTER_A; the last index is countof(previousModalDialogs) - 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004916C0 100.0% Reimplemented MenuTextInputState::activateModalDialogAndClearText, from our draft on kotijekriv's fork branch reimpl/UI-Core-development (90.3% there, also in sourcehold#313). With no dialog open it saves the text array index and clears the text; a dialog that isn't already current is pushed onto the stack, counting down over previousModalDialogs from countof(previousModalDialogs) - 1 (written out per element: quick_diff 1.0000 -> 0.7742; i != 0 as the bound: 0.5312), and activated. The draft's pointer over ¤tModalDialog is gone, and so is the imported plate comment. The text array index is saved through the global, as the original does (this->: quick_diff 1.0000 -> 0.9355). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004B51A0 100.0% Reimplemented MinimapViewState::convertMinimapClickToTileXY, from our draft on kotijekriv's fork branch reimpl/UI-Core-development (87.1% there, also in sourcehold#313). The mouse position on the minimap becomes a screen point, looked up in the current orientation's screenPointToTileNumber table (80400 entries apart, as main's ViewportBasedTileNumber writes them), and the tile is split into x and y; with clicks disabled both are -1. Orientation 0 sets the offset again, as main's renderPreviewAtMouseLocation does (without that arm: quick_diff 1.0000 -> 0.8714; it was the draft's register swap). Guarded, not an early return (an early return when disabled: 1.0000 -> 0.9000). Computing the offset from the orientation instead: 0.5507. The redundant (short) cast on the short table is gone; 0x191 is 401. The flag is a truthiness test. The Y term and the offset stay up front (Y inline: 1.0000 -> 0.7770; the offset declared at first use: 0.6714); comments say why the +6 / -6 both stay and that the out parameters hold the screen point until the tile is known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00493690 100.0% Reimplemented Rendering::RenderLoadAndSaveBar, from our draft on kotijekriv's fork branch reimpl/UI-Rendering-development (85.7% there, also in sourcehold#313). At most every 30 ms it draws the progress bar, in game on the map surface and flipped, in the menus on the menu surface and blitted. The blit mode is 2 on the siege tent's tower and shield tabs unless the building and status menu is open, else 1: one store of 1 for both paths, as in main's WinMain (there a comma expression, here a siegeTowerOrShieldTab local; an if/else with a store each: quick_diff 0.9459 -> 0.8742, and MSVC then keeps 1 in edi, the draft's blocker). The 30 ms, the per-mille progress (300 pixels wide when full) and the 15-pixel height have a comment each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: GameCore::unlockAllHistoricalCampaigns is a BOOLEnum Its only stores in the exe are 1 at 0x004B49C8 (ebp, set to 1 at 0x004B4813) and 0 in GameCore's initialiser (mov [eax + 0x58], ecx at 0x0046B21D, ecx zeroed at 0x0046B1F2); its readers compare it with a zero register (0x004269FC, 0x00426D4C). BOOLEnum is a typedef of int, so the size and every access stay the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MinimapViewState::minimapClickEnabled is a BOOLEnum Its only stores in the exe are 1 at 0x00434328 (eax, set to 1 at 0x00434319 on both paths) and 0 at 0x0043432E; no MinimapViewState method writes it through this. BOOLEnum is a typedef of int, so the size and every access stay the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: clang-format MinimapViewState.hpp cpp-linter checks whole changed files: the BOOLEnum include added in 65c0847 sorts with the project includes. Whitespace and include order only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MinimapViewState as on main again The merge of eef6f66 left the BOOLEnum using-declaration twice: the sync added its own when it took minimapClickEnabled's BOOLEnum from this PR. The header is now the same as main's, so the PR no longer changes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt's Ghidra sync 2bd620b moved ViewportRenderState::screenPointToTileNumber 8 ints earlier (0x4E600 -> 0x4E5E0), and main's 39ed817 dropped the -8 its two readers needed. locatePlayerKeepPositionsOnMinimap and renderMinimapTileStripWithLuminescence read the same table the same way, so they drop their -8 too. quick_diff output is the same; only the compiler's temporary label names differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
window->mbr_0xcc += 1 and windowMoveEventBlitCountdown -= 1 become ++ and --, as rule 29 of main's style guide asks. quick_diff output is the same before and after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 11, 2026
UI::Rendering::RenderAnimatedTutorialFloatOverlay in the form TheRedDaemon worked out in his review: x and y step down by 8 and 32 before the per-resolution offset, and by 28 and 69 after the draw buffer is saved, and the offset comes from a chain of plain ifs, so the gotos are gone. The original pushes the trailing 0 before it computes the other arguments, and this form gives that order. reccmp 67.2 -> 100%. The function is Gynt's, from his fork's reimpl/UI-Rendering-development: 5236e98 (60.79%), e8e27aa (60.8%) and 63cc49f; ce6bd1e took it to 67.2%. This changes the order of the x and y steps and the offset chain. Co-authored-by: TheRedDaemon <66257843+TheRedDaemon@users.noreply.github.com> Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
Merged
…ts round 2 PR TheRedDaemon's form from his review here (x and y stepped down by 8 and 32 before the per-resolution offset and by 28 and 69 after the draw buffer is saved, the offset as a chain of plain ifs) took the function from 67.2% to 100.0% in 0287fe5, so it moves to the units round 2 PR (reimpl/units-A-round2-100, 558163d). This draft drops its .cpp file, and its status line goes back to main's. Main has no file for it, and this draft changes no header, so nothing else goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- BlitMapImageWithVerticalClipAndYOffset (0x00454080): the asm labels get the names BlitMapImageWithVerticalClip uses on main for the same blocks (row_start, copy_whole_row, copy_right_half, copy_left_half, copy_middle, next_image, done, and their zoom_ forms with _odd), instead of addresses; height is adjusted with +=. - RenderMissionObjectivesUnk: the four numberWidth sums are written with +=. - takeScreenshot: the sprintf format is the s_ pointer from string-literals.hpp. - renderMinimapTileStripWithLuminescence: clang-format. quick_diff gives the same instructions as before for the first three; takeScreenshot reads the same 0.8571, with only the compiler's temporary names changed by the larger include. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's Ghidra syncs moved SkirmishStatistics' start and end dates into tail.tail1 (yearStart, monthStart, yearEnd, monthEnd) and made drawHeaderTextBanner's first parameter an eTextSections; the "Greatest Lord" banner is TEXT_MP_RANK (225). quick_diff 0.5519 on main e086ba7, where the draft did not compile before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Twenty-two functions I couldn't get to 100%, opened as a draft so others can continue from here. Each comes with its status line saying what's left. Thirteen more started here and are at 100% now, so they left this PR in the same push: nine in #323 and four in #348.
This is one of three PRs for one batch, each kept under 50 files as discussed on Discord:
Built on top of
mainwith the bundled MSVC1400-SP1, natively on Windows, against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a). This branch was built and measured on its own (every reimplemented.cppit contains), with the struct resolvers and the 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.No header change left: main's Ghidra sync a9401a7 took in the six colours of our shared commit (gynt's colour point on #323). This draft uses
COL_C2F0EB, and namesCOL_FFFFFFandCOL_0000FFtoo, where it wrote them as numbers (same code). Main 72b2732 is merged in, with the sync's new names used (DAT_RenderMap_*,INT_00ec082c,CHAR_00eb0e44, which also drops a(char)cast); every function measures what its status line records. The seven globals it retyped toint(DAT_00ed3170,DAT_00b98428,DAT_00b9842c,DAT_00b98430,DAT_00b9845c,DAT_00ed2784,DAT_CurrentButtonPictureInGm) are on main since 12854bc, and every file here that uses them compiles to the same code without its(int)casts (fb337c1).The earlier
OS.hppchange is gone: main took the calling convention in a521bf7, and after gynt's question takeScreenshot writes with the compiler's ownstd::ofstream, so nothing here callsbasic_ofstream_writeany more (74dbb76). For the record: it is VC8'soperator<<(basic_ostream<char>&, char), so its second parameter is achar, not auint.Other changes:
cmake/compiler-flags-gl.txt:takeScreenshot.cppremoved (with/GLit measured 37.1% against 85.4% without, which fits tools: the /GL conundrum solved - tu_merge, tu_layout, rich_header, diagnose, tuple_dump #306's finding that the original wasn't built with/GL);determineGameTicksToPerform.cppadded.fix:commits:isMouseOnButtonImageUnkandRenderGoldValueincludeGMFirstPictureIndex.hpp, after main's rename.playAiLordMessageisMouseOnButtonImageUnkopenBuildingStatusMenuForBuildingIDcopyBinkToVideoBufferRenderBuildingMenu_ChapelAndChurchdetermineGameTicksToPerformactivateModalDialog2locatePlayerKeepPositionsOnMinimaprenderMinimapTileStripWithLuminescenceBlitMapImageWithVerticalClipAndYOffsetRenderAnimatedTutorialFloatOverlayRenderGreatestLordScreenRenderMissionObjectivesUnkRenderTextPageProgressBarRenderStatusMenu_ArmyRenderStatusMenu_FoodRenderStatusMenu_Populationleawhere the original addsbltMapGameSurfaceToScreenprepareWindowAndDDraw_2UnkreinitWindowrenderBltAndFliptakeScreenshotdetermineGameTicksToPerformmeasures 69.4%: the original keepsthisinecxacross the call tocomputeLatencyAdjustmentFromMatchTimes(0x0047E5B0), and ours spills it toedi. An earlier figure of 81.2% with that callee reimplemented didn't reproduce: with gynt's 96.4% draft of the callee switched on it still reads 69.4%.Review round (2026-11-04)
The points from the review of #311 are applied here too, in every file: no findings in code comments, string pointers from
string-literals.hpp, decimal numbers (hex only for bit operations), theColorsEnumnames for the text colours, compound assignments and prefix++/--, truthiness tests, first includes../<Folder>.func.hpp, no unusedusings, declarations at first use, the strcpy deprecation pragma. Also:prepareWindowAndDDraw_2Unklost a(void*)((int)...)cast, andcopyBinkToVideoBufferandrenderBltAndFliphave named parameters. Every change compiles to the same code as before, exceptdetermineGameTicksToPerform, which went from 68.3% to 69.4%.Kept on purpose:
determineGameTicksToPerform,bltMapGameSurfaceToScreenandrenderBltAndFlipcomparecurrentlyInGameUnk_0xa4andNOTSelfBufferOrWindowMode_0xf8withTRUE, because the original compares with 1. A truthiness test measures 69.4% -> 43.1% and 71.5% -> 69.1%.RenderBuildingMenu_ChapelAndChurchstill has the decompiler's local names; it's left for whoever continues it.Open for others to continue
__asmblitters (renderFunctionResponsibleForManyGameObjects,RenderTerrainTilesCenterPiece,ApplyBlending,BlitMapImageWithVerticalClip,renderMinimapPreview) are at 100% in Reimplement 13 functions from our drafts at 100% #323: inline asm can name a resolver global after all, once the C++ has used it (Reimplement 13 functions from our drafts at 100% #323 explains how).BlitMapImageWithVerticalClipAndYOffset(86.3%) stays here. Its asm ended with apop ebxthat has no push in our build (in the original the pop is the compiler's own epilogue), so it popped ebx twice and returned with the caller's esi, edi and ebx wrong. That is fixed (79.7% to 86.3%; BlitMapImageWithVerticalClip had the same bug). The asm matches now; the C++ part before it keeps its values in other registers.takeScreenshot(86.4%): it uses the compiler's ownstd::ofstreamthroughout now, as gynt asked: the file object and every byte write (file << c). reccmp can't map the calls into our copy of the library to the game's statically linked copy (constructor, destructor,operator<<, and_freefor the path string), so raw drops from 88.2% to 86.4% while normalized rises from 89.9% to 91.4%. The rest is a register rotation and the addresses of the inline-copied file name strings.copyBinkToVideoBuffer(84.1%): the instructions match; only the callee-saved registers holding 0, 1 andthisrotate. It's the first.cppto call DirectDraw throughddraw.h's C++ interface (surface->Lock(...)); happy to change that if you prefer another form.RenderStatusMenu_Army(40.2%) andrenderMinimapTileStripWithLuminescence(21.4%) are the furthest off.Not included, because my versions didn't beat gynt's drafts:
Overview85.0,Popularity65.0,Chimp56.7;Marketplace_Trade99.0,Armory80.6,Keep66.7;generateMinimapImage74.7,convertLoadedMinimapColors63.6,drawMinimap32.8;🤖 Generated with Claude Code