From 4895ea0f14ac182e792ee14fae5960ffa9bd9303 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 12:36:57 +0100 Subject: [PATCH 01/78] reimplement: SHC_3BB0A8C1_0x0044D3D0 99.50% Asm reads surface via this; 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 --- ...rFunctionResponsibleForManyGameObjects.cpp | 1491 +++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1492 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp new file mode 100644 index 0000000000..d5062e633d --- /dev/null +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp @@ -0,0 +1,1491 @@ +#include "../TextureRenderCore.func.hpp" + +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // Handlers for TGX runs of 1..32 pixels, filled with label addresses of the function below on first use. + // The original keeps them in PTR_ARRAY_00c9a510 / PTR_ARRAY_00d7d250; ours point into our own code. + static void* s_tgxRepeatedPixelHandlers[32]; + static void* s_tgxStreamPixelHandlers[32]; + + // Draws a TGX-compressed RGB565 image onto the current render surface (map surface rows are 4056 pixels). + // The two loops are handwritten assembly in the original, transcribed here from the binary. A TGX token byte + // holds the run type in its top three bits and the run length minus one in the low five: + // 0x00 stream copy the next length pixels from the image, + // 0x20 skip leave length pixels transparent, + // 0x40 repeat fill length pixels with the one colour that follows, + // 0x80 new line advance to the next surface row. + // Stream and repeat runs dispatch through the two handler tables, one handler per length. + // The zoomed-out path (isZoom2) draws the image at half size: every other row and every other column. + // Only the C++ parts are compiled; MSVC does not optimise a function containing __asm, which matches the + // original's unoptimised-looking prologue. + // + // NOTE: the original reads currentRenderSurface through the global instance inside the asm. Inline asm + // cannot name a resolver global, so it goes through this (one extra instruction; a local cost 2.4 points). + + // FUNCTION: STRONGHOLDCRUSADER 0x0044D3D0 + void TextureRenderCore::renderFunctionResponsibleForManyGameObjects( + int drawX, int drawY, int imageWidth, int imageHeight, ushort* imageAddress) + { + // The asm blocks address these by frame slot. MSVC lays out the locals of this unoptimised function by a + // hash of their names first and declaration order second, so both the names and the order below are + // what put every local in the original's slot (measured). + int oddColumn; + int lineStride; + int heightMax; + int heightStart; + int lineTail; + void** streamRunHandlers = s_tgxStreamPixelHandlers; + void** repeatedPixelHandlers = s_tgxRepeatedPixelHandlers; + if (imageHeight <= 0) + return; + + if (DAT_TextureRenderCoreObject::instance.isZoom2 == 0) { + switch (this->drawBufferChoiceValue) { + case OpenSHC::Rendering::Enums::RT_MAP_GAME: + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + lineTail = 4056 * 2 - imageWidth * 2; + lineStride = 4056 * 2; + heightStart = this->mapGameSurfaceHeightRange.start; + heightMax = this->mapGameSurfaceHeightRange.end; + break; + case OpenSHC::Rendering::Enums::RT_BUTTON_AND_ALPHA: + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = AlphaAndButtonSurfaceObj::instance.surfacePtr; + lineTail = AlphaAndButtonSurfaceObj::instance.currentImageWidth * 2 - imageWidth * 2; + lineStride = AlphaAndButtonSurfaceObj::instance.currentImageWidth * 2; + heightStart = 0; + heightMax = imageHeight; + break; + default: + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_screenMenu; + lineTail = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine - imageWidth * 2; + lineStride = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; + heightStart = this->screenMenuSurfaceHeightRange.start; + heightMax = this->screenMenuSurfaceHeightRange.end; + break; + } + if (drawY + imageHeight > heightMax) { + imageHeight = imageHeight - (drawY + imageHeight - heightMax); + if (imageHeight <= 0) + return; + } + // clang-format off + __asm { + mov edi, repeatedPixelHandlers + mov eax, 0 + cmp dword ptr [edi], eax + je L_44e169 + L_44d4f6: + mov esi, imageAddress + mov edi, this + mov edi, dword ptr [edi]TextureRenderCore.currentRenderSurface + mov eax, drawX + cmp eax, 0 + jl L_44e372 + add eax, eax + add edi, eax + mov eax, drawY + mov ebx, heightStart + cmp eax, ebx + jge L_44d55e + sub ebx, eax + mov eax, ebx + cmp imageHeight, eax + jle L_44e372 + sub imageHeight, eax + L_44d529: + mov bl, byte ptr [esi] + movzx ecx, bl + and bl, 0xe0 + and cl, 0x1f + add esi, 1 + cmp bl, 0x20 + je L_44d529 + cmp bl, 0 + je L_44d548 + cmp bl, 0x40 + je L_44d551 + jmp L_44d556 + L_44d548: + add ecx, 1 + add ecx, ecx + add esi, ecx + jmp L_44d529 + L_44d551: + add esi, 2 + jmp L_44d529 + L_44d556: + sub eax, 1 + jg L_44d529 + mov eax, heightStart + L_44d55e: + mov edx, lineStride + mul edx + add edi, eax + mov edx, imageHeight + L_44d568: + mov al, byte ptr [esi] + movzx ecx, al + and al, 0xe0 + and cl, 0x1f + add esi, 1 + cmp al, 0x20 + je L_44d58e + cmp al, 0 + je L_44d5ab + cmp al, 0x40 + je L_44d597 + add edi, lineTail + sub edx, 1 + jg L_44d568 + jmp L_44e372 + L_44d58e: + add ecx, 1 + add ecx, ecx + add edi, ecx + jmp L_44d568 + L_44d597: + movzx eax, word ptr [esi] + mov ebx, eax + shl ebx, 0x10 + add eax, ebx + add esi, 2 + jmp s_tgxRepeatedPixelHandlers[ecx*4] + L_44d5ab: + jmp s_tgxStreamPixelHandlers[ecx*4] + L_44d5b2: + mov ax, word ptr [esi] + mov word ptr [edi], ax + add esi, 2 + add edi, 2 + jmp L_44d568 + L_44d5c0: + mov eax, dword ptr [esi] + mov dword ptr [edi], eax + add esi, 4 + add edi, 4 + jmp L_44d568 + L_44d5cc: + mov eax, dword ptr [esi] + mov bx, word ptr [esi + 4] + mov dword ptr [edi], eax + mov word ptr [edi + 4], bx + add esi, 6 + add edi, 6 + jmp L_44d568 + L_44d5e0: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + add esi, 8 + add edi, 8 + jmp L_44d568 + L_44d5f5: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov cx, word ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov word ptr [edi + 8], cx + add esi, 0xa + add edi, 0xa + jmp L_44d568 + L_44d612: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + add esi, 0xc + add edi, 0xc + jmp L_44d568 + L_44d62d: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov ax, word ptr [esi + 0xc] + mov word ptr [edi + 0xc], ax + add esi, 0xe + add edi, 0xe + jmp L_44d568 + L_44d650: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov dword ptr [edi + 0xc], eax + add esi, 0x10 + add edi, 0x10 + jmp L_44d568 + L_44d671: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov bx, word ptr [esi + 0x10] + mov dword ptr [edi + 0xc], eax + mov word ptr [edi + 0x10], bx + add esi, 0x12 + add edi, 0x12 + jmp L_44d568 + L_44d69a: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + add esi, 0x14 + add edi, 0x14 + jmp L_44d568 + L_44d6c1: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov cx, word ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov word ptr [edi + 0x14], cx + add esi, 0x16 + add edi, 0x16 + jmp L_44d568 + L_44d6f0: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + add esi, 0x18 + add edi, 0x18 + jmp L_44d568 + L_44d71d: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov ax, word ptr [esi + 0x18] + mov word ptr [edi + 0x18], ax + add esi, 0x1a + add edi, 0x1a + jmp L_44d568 + L_44d752: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov dword ptr [edi + 0x18], eax + add esi, 0x1c + add edi, 0x1c + jmp L_44d568 + L_44d785: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov bx, word ptr [esi + 0x1c] + mov dword ptr [edi + 0x18], eax + mov word ptr [edi + 0x1c], bx + add esi, 0x1e + add edi, 0x1e + jmp L_44d568 + L_44d7c0: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + add esi, 0x20 + add edi, 0x20 + jmp L_44d568 + L_44d7f9: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov cx, word ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov word ptr [edi + 0x20], cx + add esi, 0x22 + add edi, 0x22 + jmp L_44d568 + L_44d83a: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + add esi, 0x24 + add edi, 0x24 + jmp L_44d568 + L_44d879: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov ax, word ptr [esi + 0x24] + mov word ptr [edi + 0x24], ax + add esi, 0x26 + add edi, 0x26 + jmp L_44d568 + L_44d8c0: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov dword ptr [edi + 0x24], eax + add esi, 0x28 + add edi, 0x28 + jmp L_44d568 + L_44d905: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov bx, word ptr [esi + 0x28] + mov dword ptr [edi + 0x24], eax + mov word ptr [edi + 0x28], bx + add esi, 0x2a + add edi, 0x2a + jmp L_44d568 + L_44d952: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + add esi, 0x2c + add edi, 0x2c + jmp L_44d568 + L_44d99d: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov cx, word ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov word ptr [edi + 0x2c], cx + add esi, 0x2e + add edi, 0x2e + jmp L_44d568 + L_44d9f0: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + add esi, 0x30 + add edi, 0x30 + jmp L_44d568 + L_44da41: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov ax, word ptr [esi + 0x30] + mov word ptr [edi + 0x30], ax + add esi, 0x32 + add edi, 0x32 + jmp L_44d568 + L_44da9a: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov eax, dword ptr [esi + 0x30] + mov dword ptr [edi + 0x30], eax + add esi, 0x34 + add edi, 0x34 + jmp L_44d568 + L_44daf1: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov eax, dword ptr [esi + 0x30] + mov bx, word ptr [esi + 0x34] + mov dword ptr [edi + 0x30], eax + mov word ptr [edi + 0x34], bx + add esi, 0x36 + add edi, 0x36 + jmp L_44d568 + L_44db50: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], ebx + add esi, 0x38 + add edi, 0x38 + jmp L_44d568 + L_44dbad: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov cx, word ptr [esi + 0x38] + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], ebx + mov word ptr [edi + 0x38], cx + add esi, 0x3a + add edi, 0x3a + jmp L_44d568 + L_44dc12: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], ebx + mov dword ptr [edi + 0x38], ecx + add esi, 0x3c + add edi, 0x3c + jmp L_44d568 + L_44dc75: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], ebx + mov dword ptr [edi + 0x38], ecx + mov ax, word ptr [esi + 0x3c] + mov word ptr [edi + 0x3c], ax + add esi, 0x3e + add edi, 0x3e + jmp L_44d568 + L_44dce0: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 4], ebx + mov dword ptr [edi + 8], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], ebx + mov dword ptr [edi + 0x14], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], ebx + mov dword ptr [edi + 0x20], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], ebx + mov dword ptr [edi + 0x2c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], ebx + mov dword ptr [edi + 0x38], ecx + mov eax, dword ptr [esi + 0x3c] + mov dword ptr [edi + 0x3c], eax + add esi, 0x40 + add edi, 0x40 + jmp L_44d568 + L_44dd49: + mov word ptr [edi], ax + add edi, 2 + jmp L_44d568 + L_44dd54: + mov dword ptr [edi], eax + add edi, 4 + jmp L_44d568 + L_44dd5e: + mov dword ptr [edi], eax + mov word ptr [edi + 4], ax + add edi, 6 + jmp L_44d568 + L_44dd6c: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + add edi, 8 + jmp L_44d568 + L_44dd79: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov word ptr [edi + 8], ax + add edi, 0xa + jmp L_44d568 + L_44dd8a: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + add edi, 0xc + jmp L_44d568 + L_44dd9a: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov word ptr [edi + 0xc], ax + add edi, 0xe + jmp L_44d568 + L_44ddae: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + add edi, 0x10 + jmp L_44d568 + L_44ddc1: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov word ptr [edi + 0x10], ax + add edi, 0x12 + jmp L_44d568 + L_44ddd8: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + add edi, 0x14 + jmp L_44d568 + L_44ddee: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov word ptr [edi + 0x14], ax + add edi, 0x16 + jmp L_44d568 + L_44de08: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + add edi, 0x18 + jmp L_44d568 + L_44de21: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov word ptr [edi + 0x18], ax + add edi, 0x1a + jmp L_44d568 + L_44de3e: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + add edi, 0x1c + jmp L_44d568 + L_44de5a: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov word ptr [edi + 0x1c], ax + add edi, 0x1e + jmp L_44d568 + L_44de7a: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + add edi, 0x20 + jmp L_44d568 + L_44de99: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov word ptr [edi + 0x20], ax + add edi, 0x22 + jmp L_44d568 + L_44debc: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + add edi, 0x24 + jmp L_44d568 + L_44dede: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov word ptr [edi + 0x24], ax + add edi, 0x26 + jmp L_44d568 + L_44df04: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + add edi, 0x28 + jmp L_44d568 + L_44df29: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov word ptr [edi + 0x28], ax + add edi, 0x2a + jmp L_44d568 + L_44df52: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + add edi, 0x2c + jmp L_44d568 + L_44df7a: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov word ptr [edi + 0x2c], ax + add edi, 0x2e + jmp L_44d568 + L_44dfa6: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + add edi, 0x30 + jmp L_44d568 + L_44dfd1: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov word ptr [edi + 0x30], ax + add edi, 0x32 + jmp L_44d568 + L_44e000: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov dword ptr [edi + 0x30], eax + add edi, 0x34 + jmp L_44d568 + L_44e02e: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov dword ptr [edi + 0x30], eax + mov word ptr [edi + 0x34], ax + add edi, 0x36 + jmp L_44d568 + L_44e060: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], eax + add edi, 0x38 + jmp L_44d568 + L_44e091: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], eax + mov word ptr [edi + 0x38], ax + add edi, 0x3a + jmp L_44d568 + L_44e0c6: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], eax + mov dword ptr [edi + 0x38], eax + add edi, 0x3c + jmp L_44d568 + L_44e0fa: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], eax + mov dword ptr [edi + 0x38], eax + mov word ptr [edi + 0x3c], ax + add edi, 0x3e + jmp L_44d568 + L_44e132: + mov dword ptr [edi], eax + mov dword ptr [edi + 4], eax + mov dword ptr [edi + 8], eax + mov dword ptr [edi + 0xc], eax + mov dword ptr [edi + 0x10], eax + mov dword ptr [edi + 0x14], eax + mov dword ptr [edi + 0x18], eax + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x20], eax + mov dword ptr [edi + 0x24], eax + mov dword ptr [edi + 0x28], eax + mov dword ptr [edi + 0x2c], eax + mov dword ptr [edi + 0x30], eax + mov dword ptr [edi + 0x34], eax + mov dword ptr [edi + 0x38], eax + mov dword ptr [edi + 0x3c], eax + add edi, 0x40 + jmp L_44d568 + L_44e169: + mov edi, repeatedPixelHandlers + mov eax, offset L_44dd49 + mov dword ptr [edi], eax + mov eax, offset L_44dd54 + mov dword ptr [edi + 4], eax + mov eax, offset L_44dd5e + mov dword ptr [edi + 8], eax + mov eax, offset L_44dd6c + mov dword ptr [edi + 0xc], eax + mov eax, offset L_44dd79 + mov dword ptr [edi + 0x10], eax + mov eax, offset L_44dd8a + mov dword ptr [edi + 0x14], eax + mov eax, offset L_44dd9a + mov dword ptr [edi + 0x18], eax + mov eax, offset L_44ddae + mov dword ptr [edi + 0x1c], eax + mov eax, offset L_44ddc1 + mov dword ptr [edi + 0x20], eax + mov eax, offset L_44ddd8 + mov dword ptr [edi + 0x24], eax + mov eax, offset L_44ddee + mov dword ptr [edi + 0x28], eax + mov eax, offset L_44de08 + mov dword ptr [edi + 0x2c], eax + mov eax, offset L_44de21 + mov dword ptr [edi + 0x30], eax + mov eax, offset L_44de3e + mov dword ptr [edi + 0x34], eax + mov eax, offset L_44de5a + mov dword ptr [edi + 0x38], eax + mov eax, offset L_44de7a + mov dword ptr [edi + 0x3c], eax + mov eax, offset L_44de99 + mov dword ptr [edi + 0x40], eax + mov eax, offset L_44debc + mov dword ptr [edi + 0x44], eax + mov eax, offset L_44dede + mov dword ptr [edi + 0x48], eax + mov eax, offset L_44df04 + mov dword ptr [edi + 0x4c], eax + mov eax, offset L_44df29 + mov dword ptr [edi + 0x50], eax + mov eax, offset L_44df52 + mov dword ptr [edi + 0x54], eax + mov eax, offset L_44df7a + mov dword ptr [edi + 0x58], eax + mov eax, offset L_44dfa6 + mov dword ptr [edi + 0x5c], eax + mov eax, offset L_44dfd1 + mov dword ptr [edi + 0x60], eax + mov eax, offset L_44e000 + mov dword ptr [edi + 0x64], eax + mov eax, offset L_44e02e + mov dword ptr [edi + 0x68], eax + mov eax, offset L_44e060 + mov dword ptr [edi + 0x6c], eax + mov eax, offset L_44e091 + mov dword ptr [edi + 0x70], eax + mov eax, offset L_44e0c6 + mov dword ptr [edi + 0x74], eax + mov eax, offset L_44e0fa + mov dword ptr [edi + 0x78], eax + mov eax, offset L_44e132 + mov dword ptr [edi + 0x7c], eax + mov edi, streamRunHandlers + mov eax, offset L_44d5b2 + mov dword ptr [edi], eax + mov eax, offset L_44d5c0 + mov dword ptr [edi + 4], eax + mov eax, offset L_44d5cc + mov dword ptr [edi + 8], eax + mov eax, offset L_44d5e0 + mov dword ptr [edi + 0xc], eax + mov eax, offset L_44d5f5 + mov dword ptr [edi + 0x10], eax + mov eax, offset L_44d612 + mov dword ptr [edi + 0x14], eax + mov eax, offset L_44d62d + mov dword ptr [edi + 0x18], eax + mov eax, offset L_44d650 + mov dword ptr [edi + 0x1c], eax + mov eax, offset L_44d671 + mov dword ptr [edi + 0x20], eax + mov eax, offset L_44d69a + mov dword ptr [edi + 0x24], eax + mov eax, offset L_44d6c1 + mov dword ptr [edi + 0x28], eax + mov eax, offset L_44d6f0 + mov dword ptr [edi + 0x2c], eax + mov eax, offset L_44d71d + mov dword ptr [edi + 0x30], eax + mov eax, offset L_44d752 + mov dword ptr [edi + 0x34], eax + mov eax, offset L_44d785 + mov dword ptr [edi + 0x38], eax + mov eax, offset L_44d7c0 + mov dword ptr [edi + 0x3c], eax + mov eax, offset L_44d7f9 + mov dword ptr [edi + 0x40], eax + mov eax, offset L_44d83a + mov dword ptr [edi + 0x44], eax + mov eax, offset L_44d879 + mov dword ptr [edi + 0x48], eax + mov eax, offset L_44d8c0 + mov dword ptr [edi + 0x4c], eax + mov eax, offset L_44d905 + mov dword ptr [edi + 0x50], eax + mov eax, offset L_44d952 + mov dword ptr [edi + 0x54], eax + mov eax, offset L_44d99d + mov dword ptr [edi + 0x58], eax + mov eax, offset L_44d9f0 + mov dword ptr [edi + 0x5c], eax + mov eax, offset L_44da41 + mov dword ptr [edi + 0x60], eax + mov eax, offset L_44da9a + mov dword ptr [edi + 0x64], eax + mov eax, offset L_44daf1 + mov dword ptr [edi + 0x68], eax + mov eax, offset L_44db50 + mov dword ptr [edi + 0x6c], eax + mov eax, offset L_44dbad + mov dword ptr [edi + 0x70], eax + mov eax, offset L_44dc12 + mov dword ptr [edi + 0x74], eax + mov eax, offset L_44dc75 + mov dword ptr [edi + 0x78], eax + mov eax, offset L_44dce0 + mov dword ptr [edi + 0x7c], eax + jmp L_44d4f6 + L_44e372: + } + // clang-format on + } else { + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + lineTail = 4056 * 2; + lineStride = 4056 * 2; + heightStart = this->mapGameSurfaceHeightRange.start; + if (drawY + imageHeight > this->mapGameSurfaceHeightRange.end) { + imageHeight = imageHeight - (drawY + imageHeight - this->mapGameSurfaceHeightRange.end); + if (imageHeight <= 0) + return; + } + // clang-format off + __asm { + mov esi, imageAddress + mov edi, this + mov edi, dword ptr [edi]TextureRenderCore.currentRenderSurface + mov eax, drawX + cmp eax, 0 + jl L_44e4fd + and eax, 0xfffffffe + add edi, eax + mov eax, drawY + mov ebx, heightStart + cmp eax, ebx + jge L_44e430 + sub ebx, eax + mov eax, ebx + cmp imageHeight, eax + jle L_44e4fd + sub imageHeight, eax + L_44e3fb: + mov bl, byte ptr [esi] + movzx ecx, bl + and bl, 0xe0 + and cl, 0x1f + add esi, 1 + cmp bl, 0x20 + je L_44e3fb + cmp bl, 0 + je L_44e41a + cmp bl, 0x40 + je L_44e423 + jmp L_44e428 + L_44e41a: + add ecx, 1 + add ecx, ecx + add esi, ecx + jmp L_44e3fb + L_44e423: + add esi, 2 + jmp L_44e3fb + L_44e428: + sub eax, 1 + jg L_44e3fb + mov eax, heightStart + L_44e430: + mov edx, lineStride + mov ecx, eax + shr eax, 1 + mul edx + add edi, eax + xor eax, eax + xor ebx, ebx + mov oddColumn, ebx + mov edx, imageHeight + L_44e445: + mov al, byte ptr [esi] + movzx ecx, al + and al, 0xe0 + and cl, 0x1f + add esi, 1 + cmp al, 0x20 + je L_44e4a5 + cmp al, 0 + je L_44e4d5 + cmp al, 0x40 + je L_44e4ad + add edi, lineTail + sub edx, 1 + jle L_44e4fd + L_44e46a: + mov bl, byte ptr [esi] + movzx ecx, bl + and bl, 0xe0 + and cl, 0x1f + add esi, 1 + cmp bl, 0x20 + je L_44e46a + cmp bl, 0 + je L_44e489 + cmp bl, 0x40 + je L_44e492 + jmp L_44e497 + L_44e489: + add ecx, 1 + add ecx, ecx + add esi, ecx + jmp L_44e46a + L_44e492: + add esi, 2 + jmp L_44e46a + L_44e497: + xor eax, eax + xor ebx, ebx + mov oddColumn, ebx + sub edx, 1 + jg L_44e445 + jmp L_44e4fd + L_44e4a5: + add ecx, 1 + add oddColumn, ecx + jmp L_44e445 + L_44e4ad: + movzx eax, word ptr [esi] + add esi, 2 + add ecx, 1 + mov ebx, oddColumn + add oddColumn, ecx + L_44e4bc: + test ebx, 1 + jne L_44e4c8 + mov word ptr [edi + ebx], ax + L_44e4c8: + add ebx, 1 + sub ecx, 1 + jne L_44e4bc + jmp L_44e445 + L_44e4d5: + add ecx, 1 + mov ebx, oddColumn + add oddColumn, ecx + L_44e4de: + test ebx, 1 + jne L_44e4ed + mov ax, word ptr [esi] + mov word ptr [edi + ebx], ax + L_44e4ed: + add ebx, 1 + add esi, 2 + sub ecx, 1 + jne L_44e4de + jmp L_44e445 + L_44e4fd: + } + // clang-format on + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 31c1e19ecc..59c64beff8 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16947,7 +16947,7 @@ SHC_3BB0A8C1_0x0044D330 | 0.0% | Pending SHC_3BB0A8C1_0x0044D340 | 0.0% | Pending -SHC_3BB0A8C1_0x0044D3D0 | 0.0% | Pending +SHC_3BB0A8C1_0x0044D3D0 | 99.5% | Asm reads surface via this; own handler tables SHC_3BB0A8C1_0x0044E510 | 0.0% | Pending From 7df0a7ad72cca71be00313319f945ccd570ac404 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 12:36:57 +0100 Subject: [PATCH 02/78] build: drop takeScreenshot.cpp from the /GL file list 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 --- cmake/compiler-flags-gl.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 047fe88235..87a8764d64 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -4,7 +4,6 @@ src/OpenSHC/IO/LowLevelMemory/putFileNameAndAppendFileExtension.cpp src/OpenSHC/IO/DecoderState/encodeData.cpp src/OpenSHC/IO/DecoderState/decodeData.cpp src/OpenSHC/IO/ResourceManager/swapMapDataWithNextMap.cpp -src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp src/OpenSHC/IO/ResourceManager/readFirstPartOfCurrentResourceIntoMemory.cpp src/OpenSHC/IO/ResourceManager/readNextPartOfCurrentResourceIntoMemory.cpp src/OpenSHC/Map/TileMapState/updateMoatCountdownTimers.cpp From cd8f6766f18bc2960a599dc3e5192259597f0ab1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 12:36:57 +0100 Subject: [PATCH 03/78] reimplement: SHC_3BB0A8C1_0x00479540 85.40% Game STL calls; reg rotation 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 --- .../WindowAndDirectDraw/takeScreenshot.cpp | 88 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp new file mode 100644 index 0000000000..29f3f2e7e9 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp @@ -0,0 +1,88 @@ +// disable deprecation warnings for strcpy, strcat and sprintf +#pragma warning(disable : 4996) + +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/string-macros.hpp" + +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" + +#include + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x00479540 + void WindowAndDirectDraw::takeScreenshot(int screenshotNumber) + { + char path[1000]; + // NOTE: Requires direct, non-resolved call due to copy elision. + strcpy(path, DAT_ResourceManager::ptr->paths_getDocumentsFolderString(true).c_str()); + if (screenshotNumber == -1) { + strcat(path, S_SCREEN_CAPTURE_BMP_005A6538); + } else { + char fileName[1000]; + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(fileName, S_SCREEN_CAPTURE__03D_BMP_005A6520, screenshotNumber); + strcat(path, fileName); + } + + // NOTE: the original writes through its own statically linked VC8 std::ofstream. OS::basic_ofstream_write + // (0x004791B0) is that operator<<(ostream&, char), but it is cdecl while OS.hpp declares it __stdcall, + // so this uses the operator<< of our own library on our own stream. + std::ofstream file(path, std::ios::binary); + if (file.fail()) + return; + + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltMapGameSurfaceToScreenMenuSurfaceComplete, this)(); + + BITMAPFILEHEADER fileHeader; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + sizeof(fileHeader), '\0', &fileHeader); + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::copyData, DAT_LowLevelMemory::ptr)( + 2, (void*)DAT_BMP_MAGICVALUE, &fileHeader); + fileHeader.bfSize + = this->numPixel_GameX_x_3_x_GameY_0x4c + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + for (uint i = 0; i < sizeof(fileHeader); i++) { + file << ((char*)&fileHeader)[i]; + } + + BITMAPINFOHEADER infoHeader; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + sizeof(infoHeader), '\0', &infoHeader); + infoHeader.biSize = sizeof(infoHeader); + infoHeader.biPlanes = 1; + infoHeader.biBitCount = 24; + infoHeader.biWidth = this->resolutionX; + infoHeader.biHeight = this->resolutionY; + infoHeader.biCompression = BI_RGB; + infoHeader.biSizeImage = this->numPixel_GameX_x_3_x_GameY_0x4c; + for (uint i = 0; i < sizeof(infoHeader); i++) { + file << ((char*)&infoHeader)[i]; + } + + // RGB565 rows, bottom-up, written as BGR24. The walking pointer and the named char locals are both + // load-bearing: row[x] cost 10 points and passing the expressions directly cost 6 (quick_diff). + for (int y = this->resolutionY - 1; y >= 0; y--) { + ushort* pixelPtr = this->surfacePointer_screenMenu + this->resolutionX * y; + for (int x = 0; x < this->resolutionX; x++) { + int const pixel = *pixelPtr++; + char const blue = (char)pixel << 3; + file << blue; + char const green = (char)(pixel >> 5) * 4; + file << green; + char const red = (char)((short)pixel >> 11) << 3; + file << red; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 59c64beff8..3b13595f98 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22125,7 +22125,7 @@ SHC_3BB0A8C1_0x00479369 | 0.0% | Pending SHC_3BB0A8C1_0x00479400 | 0.0% | Pending -SHC_3BB0A8C1_0x00479540 | 0.0% | Pending +SHC_3BB0A8C1_0x00479540 | 85.4% | Game STL calls; reg rotation SHC_3BB0A8C1_0x00479790 | 0.0% | Pending From f8dd11428907f9e48785911b45b999b99cf7bb61 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 12:36:57 +0100 Subject: [PATCH 04/78] reimplement: SHC_3BB0A8C1_0x00408FC0 84.10% Reg alloc only 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 --- .../copyBinkToVideoBuffer.cpp | 131 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp new file mode 100644 index 0000000000..070368b954 --- /dev/null +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp @@ -0,0 +1,131 @@ +#include "../../../Rendering.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/Rendering/Bink/UnsortedBinkFlag.hpp" +#include "OpenSHC/UI/Menu.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace Rendering { + namespace Bink { + + using OpenSHC::Audio::MSS::enums::SHC_SoundStream; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // The original inlined this per-video body into the loop: its early returns are the jumps to the loop + // increment. Plain `inline` is not expanded by MSVC here, so it has to be __forceinline (same code as a goto, + // no goto needed). + static __forceinline void copyBinkToVideoBuffer_copyFrame( + BinkControlClass* self, int binkObjIndex, dword param_1) + { + if (self->soundStreamIndex[binkObjIndex] != OpenSHC::Audio::MSS::enums::SND_STR_MUSIC) { + if (!MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, + DAT_SoundSystemState::ptr)((SHC_SoundStream)self->soundStreamIndex[binkObjIndex]) + || timeGetTime() - self->startTime[binkObjIndex] > 20000) { + self->soundStreamIndex[binkObjIndex] = OpenSHC::Audio::MSS::enums::SND_STR_MUSIC; + } + } + + if (self->unknownParam07[binkObjIndex] == param_1) { + self->unknown01_zero[binkObjIndex] = 0; + self->unknown02_zero[binkObjIndex] = 0; + } + + if (self->binkObjPtrArray[binkObjIndex] == NULL || self->unknownParam07[binkObjIndex] != param_1) + return; + + if (BinkWait(self->binkObjPtrArray[binkObjIndex]) == 0) { + BinkDoFrame(self->binkObjPtrArray[binkObjIndex]); + + if ((self->binkObjPtrArray[binkObjIndex]->FrameNum == self->binkObjPtrArray[binkObjIndex]->Frames) + && (self->unknownParam03[binkObjIndex] == 0)) { + if (self->soundStreamIndex[binkObjIndex] == OpenSHC::Audio::MSS::enums::SND_STR_MUSIC) { + if (param_1 != 2) { + self->unknown01_zero[binkObjIndex] = 1; + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, self)( + binkObjIndex); + return; + } + self->unknown02_zero[binkObjIndex] = 1; + } else if (param_1 == 2) { + self->unknown02_zero[binkObjIndex] = 1; + } + } else { + BinkNextFrame(self->binkObjPtrArray[binkObjIndex]); + } + + self->frameReadyToDisplay[binkObjIndex] = TRUE; + } + + if (param_1 == 2) { + int const menuBorderHeight = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + int const menuBorderWidth = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth; + OpenSHC::UI::Menu* const menu = DAT_MenuHandlerState::instance.currentMenu; + menu->xPosition = menuBorderWidth; + menu->yPosition = menuBorderHeight; + DAT_MenuHandlerState::instance.y = menuBorderHeight; + DAT_MenuHandlerState::instance.x = menuBorderWidth; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, + DAT_WindowAndDirectDraw::instance.resolutionY, COL_BLACK::instance.shortValue); + } + + if (!self->frameReadyToDisplay[binkObjIndex]) + return; + + IDirectDrawSurface* surface; + if (self->unknownParam04[binkObjIndex] != 0) { + HRESULT result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Lock( + NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame, DDLOCK_WAIT, NULL); + while (result == DDERR_SURFACELOST) { + if (DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Restore() != DD_OK) + return; + result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Lock( + NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame, DDLOCK_WAIT, NULL); + } + BinkCopyToBuffer(self->binkObjPtrArray[binkObjIndex], + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame.lpSurface, + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame.lPitch, + self->binkObjPtrArray[binkObjIndex]->Height, self->xPos[binkObjIndex], self->yPos[binkObjIndex], + self->mapGameSurfaceType | OpenSHC::Rendering::Bink::UBF_BINKCOPYALL); + surface = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame; + } else { + HRESULT result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Lock( + NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104, DDLOCK_WAIT, NULL); + while (result == DDERR_SURFACELOST) { + if (DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Restore() + != DD_OK) + return; + result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Lock(NULL, + &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104, DDLOCK_WAIT, NULL); + } + BinkCopyToBuffer(self->binkObjPtrArray[binkObjIndex], + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104.lpSurface, + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104.lPitch, + self->binkObjPtrArray[binkObjIndex]->Height, self->xPos[binkObjIndex], self->yPos[binkObjIndex], + self->screenMenuSurfaceType_0x5c | OpenSHC::Rendering::Bink::UBF_BINKCOPYALL); + surface = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu; + } + surface->Unlock(NULL); + } + + // FUNCTION: STRONGHOLDCRUSADER 0x00408FC0 + void BinkControlClass::copyBinkToVideoBuffer(dword param_1) + { + for (int binkObjIndex = 0; binkObjIndex < 2; binkObjIndex++) { + copyBinkToVideoBuffer_copyFrame(this, binkObjIndex, param_1); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3b13595f98..e2c0c7e491 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -2579,7 +2579,7 @@ SHC_3BB0A8C1_0x00408EB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00408ED0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00408FC0 | 0.0% | Pending +SHC_3BB0A8C1_0x00408FC0 | 84.1% | Reg alloc only SHC_3BB0A8C1_0x004090E8 | 0.0% | Pending From 9cd2756d43e0eaf6e969edc66886d11adff6aaf9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 12:59:21 +0100 Subject: [PATCH 05/78] headers: basic_ofstream_write (0x004791B0) is __cdecl and takes a char Its body is VC8's operator<<(basic_ostream&, 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 --- src/OpenSHC/OS.func.hpp | 2 +- src/OpenSHC/OS.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/OS.func.hpp b/src/OpenSHC/OS.func.hpp index 4523a08354..793ae204e7 100644 --- a/src/OpenSHC/OS.func.hpp +++ b/src/OpenSHC/OS.func.hpp @@ -24,7 +24,7 @@ namespace OS_Func { using OpenSHC::OS::_atexit_t; using OpenSHC::WindowsHelper::Enums::BOOLEnum; - MACRO_FUNCTION_RESOLVER(int*(__stdcall*)(void* param_1, uint param_2), REIMPLEMENTED_CRT, + MACRO_FUNCTION_RESOLVER(int*(__cdecl*)(void* param_1, char param_2), REIMPLEMENTED_CRT, Address::SHC_3BB0A8C1_0x004791B0, &OpenSHC::OS::basic_ofstream_write) basic_ofstream_write; diff --git a/src/OpenSHC/OS.hpp b/src/OpenSHC/OS.hpp index b0cad4b807..670b72b1e6 100644 --- a/src/OpenSHC/OS.hpp +++ b/src/OpenSHC/OS.hpp @@ -25,7 +25,7 @@ namespace OS { using OpenSHC::OS::_atexit_t; using OpenSHC::WindowsHelper::Enums::BOOLEnum; - int* __stdcall basic_ofstream_write(void* param_1, uint param_2); + int* __cdecl basic_ofstream_write(void* param_1, char param_2); BOOLEnum __cdecl isEqualGUID(GUID* param_1, GUID* param_2); From 207e76f0b9e2817c8a96c12a367d634e86635727 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 12:59:21 +0100 Subject: [PATCH 06/78] reimplement: SHC_3BB0A8C1_0x00479540 87.10% Game STL ctor/dtor; reg rotation 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 --- .../WindowAndDirectDraw/takeScreenshot.cpp | 16 ++++++++-------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp index 29f3f2e7e9..423c216775 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp @@ -31,9 +31,9 @@ namespace UI { strcat(path, fileName); } - // NOTE: the original writes through its own statically linked VC8 std::ofstream. OS::basic_ofstream_write - // (0x004791B0) is that operator<<(ostream&, char), but it is cdecl while OS.hpp declares it __stdcall, - // so this uses the operator<< of our own library on our own stream. + // NOTE: the original writes through its own statically linked VC8 std::ofstream. The bytes go through the + // game's own operator<<(ostream&, char), OS::basic_ofstream_write (0x004791B0); the stream object is our + // library's std::ofstream, which has the same VC8 layout. std::ofstream file(path, std::ios::binary); if (file.fail()) return; @@ -50,7 +50,7 @@ namespace UI { = this->numPixel_GameX_x_3_x_GameY_0x4c + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); for (uint i = 0; i < sizeof(fileHeader); i++) { - file << ((char*)&fileHeader)[i]; + MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, ((char*)&fileHeader)[i]); } BITMAPINFOHEADER infoHeader; @@ -64,7 +64,7 @@ namespace UI { infoHeader.biCompression = BI_RGB; infoHeader.biSizeImage = this->numPixel_GameX_x_3_x_GameY_0x4c; for (uint i = 0; i < sizeof(infoHeader); i++) { - file << ((char*)&infoHeader)[i]; + MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, ((char*)&infoHeader)[i]); } // RGB565 rows, bottom-up, written as BGR24. The walking pointer and the named char locals are both @@ -74,11 +74,11 @@ namespace UI { for (int x = 0; x < this->resolutionX; x++) { int const pixel = *pixelPtr++; char const blue = (char)pixel << 3; - file << blue; + MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, blue); char const green = (char)(pixel >> 5) * 4; - file << green; + MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, green); char const red = (char)((short)pixel >> 11) << 3; - file << red; + MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, red); } } } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e2c0c7e491..72f204c665 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22125,7 +22125,7 @@ SHC_3BB0A8C1_0x00479369 | 0.0% | Pending SHC_3BB0A8C1_0x00479400 | 0.0% | Pending -SHC_3BB0A8C1_0x00479540 | 85.4% | Game STL calls; reg rotation +SHC_3BB0A8C1_0x00479540 | 87.1% | Game STL ctor/dtor; reg rotation SHC_3BB0A8C1_0x00479790 | 0.0% | Pending From 7e409488dc3af335da5b7b23511d3d7ac1247260 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:19:14 +0100 Subject: [PATCH 07/78] reimplement: SHC_3BB0A8C1_0x004729B0 79.10% Callee-saved register swap 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 --- .../prepareWindowAndDDraw_2Unk.cpp | 66 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp new file mode 100644 index 0000000000..ef6d7473d2 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp @@ -0,0 +1,66 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::Rendering::ScreenResolutionEnum; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004729B0 + void WindowAndDirectDraw::prepareWindowAndDDraw_2Unk( + BOOLEnum runAsExclusiveFullscreen, ScreenResolutionEnum resEnum) + { + if (this->drawingReady_0x0 != FALSE) { + dword const pendingBltMode = this->pendingBltMode; + this->pendingBltMode = 0; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + this->byteSizeofScreenResolution, 0, (void*)((int)(this->surfacePointer_screenMenu))); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, this)(1); + this->pendingBltMode = pendingBltMode; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::releaseSurfacesAndDirectDraw, this)( + TRUE); + this->runGameAsExclusiveFullscreen = runAsExclusiveFullscreen; + this->currentGameResolution = resEnum; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::getDeviceCapsAndSetup, this)(); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setupPreferredScreenResolution, this)(); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setWindowStyleRectAndPosition, this)(); + this->drawingReady_0x0 + = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::initializeDirectDraw, this)(); + // If DirectDraw can't start in the chosen resolution, retry once in 800x600, else ask to close. + while (this->drawingReady_0x0 == FALSE) { + if (this->currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + this->postWindowCloseMessage = 1; + break; + } + this->currentGameResolution = OpenSHC::Rendering::SRE_800x600; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::getDeviceCapsAndSetup, this)(); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setupPreferredScreenResolution, this)(); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setWindowStyleRectAndPosition, this)(); + this->drawingReady_0x0 + = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::initializeDirectDraw, this)(); + } + this->unk_resetViewportRelated = 2; + DAT_WindowAndDirectDraw::instance.pendingMenuRedraw = 1; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, DAT_BinkControlState::ptr)(0); + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, DAT_BinkControlState::ptr)(1); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 72f204c665..757642d45d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21413,7 +21413,7 @@ SHC_3BB0A8C1_0x004728F0 | 0.0% | Pending SHC_3BB0A8C1_0x00472950 | 0.0% | Pending -SHC_3BB0A8C1_0x004729B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004729B0 | 79.1% | Callee-saved register swap only SHC_3BB0A8C1_0x00472A90 | 100.0% | Reimplemented From 685b0393447577dcea98d9fe96e7bfea137ed1c3 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:23:37 +0100 Subject: [PATCH 08/78] reimplement: SHC_3BB0A8C1_0x004708F0 80.40% Volatile register rotation 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 --- .../WindowAndDirectDraw/reinitWindow.cpp | 38 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp new file mode 100644 index 0000000000..9660b133fc --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp @@ -0,0 +1,38 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004708F0 + void WindowAndDirectDraw::reinitWindow() + { + HWND const window = this->windowHandle; + if (GetForegroundWindow() != window) { + return; + } + this->isNotProcessingInputEvents = FALSE; + if (DAT_WindowAndDirectDraw::instance.runGameAsExclusiveFullscreen != FALSE) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::prepareWindowAndDDrawUnk, this)(); + SetRect( + &this->clientOnScreenCoords, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + SetFocus(this->windowHandle); + return; + } + GetClientRect(window, &this->clientOnScreenCoords); + ClientToScreen(this->windowHandle, (LPPOINT) & this->clientOnScreenCoords.left); + ClientToScreen(this->windowHandle, (LPPOINT) & this->clientOnScreenCoords.right); + UpdateWindow(this->windowHandle); + SetFocus(this->windowHandle); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 757642d45d..7af315ba97 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21255,7 +21255,7 @@ SHC_3BB0A8C1_0x004706E0 | 0.0% | Pending SHC_3BB0A8C1_0x004707F0 | 0.0% | Pending -SHC_3BB0A8C1_0x004708F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004708F0 | 80.4% | Volatile register rotation only SHC_3BB0A8C1_0x004709B0 | 100.0% | Reimplemented From 303f94b4f8c30fc214520c39eb6977c645607868 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:27:40 +0100 Subject: [PATCH 09/78] reimplement: SHC_3BB0A8C1_0x004706E0 71.50% Scheduling and scratch registers 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 --- .../bltMapGameSurfaceToScreen.cpp | 59 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp new file mode 100644 index 0000000000..17f203663d --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp @@ -0,0 +1,59 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004706E0 + void WindowAndDirectDraw::bltMapGameSurfaceToScreen( + int windowedX, int windowedY, int windowedWidth, int windowedHeigth) + { + if (this->drawingReady_0x0 == FALSE) { + return; + } + if (GetForegroundWindow() != this->windowHandle) { + return; + } + RECT sourceRect; + RECT destinationRect; + int const cameraOffsetX = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; + if (this->NOTSelfBufferOrWindowMode_0xf8 == FALSE) { + sourceRect.left = windowedX - 32; + sourceRect.top = windowedY - 8; + sourceRect.right = windowedWidth + 32; + sourceRect.bottom = windowedHeigth + 8; + destinationRect.top = this->clientOnScreenCoords.top + - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + sourceRect.top; + destinationRect.bottom = this->clientOnScreenCoords.top + - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + sourceRect.bottom; + destinationRect.left = this->clientOnScreenCoords.left - cameraOffsetX + sourceRect.left; + destinationRect.right = this->clientOnScreenCoords.left - cameraOffsetX + sourceRect.right; + } else { + sourceRect.left = 0; + sourceRect.top = 0; + sourceRect.right = this->gameResolutionX; + sourceRect.bottom = this->gameResolutionY; + destinationRect.left = 0; + destinationRect.top = 0; + destinationRect.right = this->gameResolutionX; + destinationRect.bottom = this->gameResolutionY; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + this)(&destinationRect, &sourceRect); + this->directDrawBackbufferSurfacePointer->Blt( + &destinationRect, this->directDrawOffscreenSurfacePointer_mapGame, &sourceRect, DDBLT_WAIT, NULL); + if (this->NOTSelfBufferOrWindowMode_0xf8 == TRUE) { + this->directDrawPrimarySurfacePointer->Flip(NULL, DDFLIP_WAIT); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 7af315ba97..e1e252e568 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21251,7 +21251,7 @@ SHC_3BB0A8C1_0x00470610 | 0.0% | Pending SHC_3BB0A8C1_0x004706A0 | 0.0% | Pending -SHC_3BB0A8C1_0x004706E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004706E0 | 71.5% | Scheduling and scratch registers in the windowed branch SHC_3BB0A8C1_0x004707F0 | 0.0% | Pending From 7dec70333f1519564a13ccc035a03f13d9b0ad87 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:34:33 +0100 Subject: [PATCH 10/78] reimplement: SHC_3BB0A8C1_0x00470040 56.70% Zero not kept in ebp; param_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 --- .../WindowAndDirectDraw/renderBltAndFlip.cpp | 160 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp new file mode 100644 index 0000000000..e0216e3450 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -0,0 +1,160 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // Blits the menu bar (mode 2) or one of two menu panels (modes 3 and 4) from the screen menu surface over the + // map. The original has this code twice, word for word: after the map blit and again after the flip. + static __forceinline void blitMenuOverlayUnk( + WindowAndDirectDraw* window, RECT& sourceRect, RECT& destinationRect) + { + if (window->unk_resetViewportRelated == 2 && DAT_WindowAndDirectDraw::instance.pendingBltMode != 2) { + window->mbr_0xcc += 1; + sourceRect.top = DAT_WindowAndDirectDraw::instance.resolutionY - 128; + sourceRect.bottom = DAT_WindowAndDirectDraw::instance.resolutionY; + destinationRect.left = window->clientOnScreenCoords.left; + destinationRect.bottom + = DAT_WindowAndDirectDraw::instance.resolutionY + window->clientOnScreenCoords.top; + destinationRect.right + = window->clientOnScreenCoords.left + DAT_WindowAndDirectDraw::instance.resolutionX; + sourceRect.right = DAT_WindowAndDirectDraw::instance.resolutionX; + destinationRect.top = destinationRect.bottom - 128; + sourceRect.left = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + window)(&destinationRect, &sourceRect); + window->directDrawBackbufferSurfacePointer->Blt(&destinationRect, + window->directDrawOffscreenSurfacePointer_screenMenu, &sourceRect, DDBLT_WAIT, NULL); + return; + } + if (window->unk_resetViewportRelated == 3) { + sourceRect.left = DAT_MenuHandlerState::instance.x + 571; + sourceRect.top = DAT_MenuHandlerState::instance.y + 465; + sourceRect.right = DAT_MenuHandlerState::instance.x + 697; + sourceRect.bottom = DAT_MenuHandlerState::instance.y + 591; + destinationRect.left = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 571; + destinationRect.top = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 465; + destinationRect.right = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 697; + destinationRect.bottom = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 591; + } else if (window->unk_resetViewportRelated == 4) { + sourceRect.left = DAT_MenuHandlerState::instance.x + 664; + sourceRect.top = DAT_MenuHandlerState::instance.y + 464; + sourceRect.right = DAT_MenuHandlerState::instance.x + 792; + sourceRect.bottom = DAT_MenuHandlerState::instance.y + 592; + destinationRect.left = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 664; + destinationRect.top = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 464; + destinationRect.right = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 792; + destinationRect.bottom = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 592; + } else { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + window)(&destinationRect, &sourceRect); + window->directDrawBackbufferSurfacePointer->Blt( + &destinationRect, window->directDrawOffscreenSurfacePointer_screenMenu, &sourceRect, DDBLT_WAIT, NULL); + } + + // FUNCTION: STRONGHOLDCRUSADER 0x00470040 + void WindowAndDirectDraw::renderBltAndFlip(int param_1) + { + RECT destinationRect; + RECT sourceRect; + char debugText[2000]; + int menuBarHeight = 128; + BOOL mapBltPending = FALSE; + if (param_1 >= 100) { + param_1 -= 100; + } + if (this->pendingBltMode != 0) { + mapBltPending = TRUE; + } + if (param_1 != 0) { + this->windowMoveEventBlitCountdown = 0; + } + if (this->drawingReady_0x0 == FALSE) { + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + return; + } + if (GetForegroundWindow() != this->windowHandle) { + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + return; + } + if (this->windowMoveEventBlitCountdown != 0) { + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + this->windowMoveEventBlitCountdown -= 1; + return; + } + DWORD const now = timeGetTime(); + // This may be an actual max fps: 200fps. But only other certain conditions? -TheRedDaemon + if (this->unk_resetViewportRelated == 1) { + mapBltPending = FALSE; + this->pendingBltMode = 0; + } else if ((int)(now - this->windowRenderTimeUnk_0x1e0) < 5) { + return; + } + this->windowRenderTimeUnk_0x1e0 = now; + if (!mapBltPending) { + sourceRect.left = 0; + sourceRect.top = 0; + sourceRect.right = this->gameResolutionX; + sourceRect.bottom = this->gameResolutionY; + if (param_1 == 1) { + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(debugText, "Vid %d, sys %d", + this->directDrawBackbufferSurfacePointer, this->directDrawOffscreenSurfacePointer_screenMenu); + } + if (this->runGameAsExclusiveFullscreen != FALSE) { + this->directDrawBackbufferSurfacePointer->BltFast(0, 0, + this->directDrawOffscreenSurfacePointer_screenMenu, &this->clientOnScreenCoords, + DDBLTFAST_WAIT); + } else { + destinationRect = this->clientOnScreenCoords; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, this)( + &destinationRect, &sourceRect); + this->directDrawBackbufferSurfacePointer->Blt(&destinationRect, + this->directDrawOffscreenSurfacePointer_screenMenu, &sourceRect, DDBLT_WAIT, NULL); + } + } + if (this->pendingBltMode != 0) { + if (this->pendingBltMode == 2) { + menuBarHeight = 0; + } + sourceRect.left = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; + sourceRect.right = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX + + DAT_WindowAndDirectDraw::instance.resolutionX; + sourceRect.top = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY; + sourceRect.bottom = DAT_WindowAndDirectDraw::instance.resolutionY - menuBarHeight + + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY; + destinationRect.left = this->clientOnScreenCoords.left; + destinationRect.right = this->clientOnScreenCoords.left + DAT_WindowAndDirectDraw::instance.resolutionX; + destinationRect.top = this->clientOnScreenCoords.top; + destinationRect.bottom + = this->clientOnScreenCoords.top - menuBarHeight + DAT_WindowAndDirectDraw::instance.resolutionY; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + this)(&destinationRect, &sourceRect); + this->directDrawBackbufferSurfacePointer->Blt( + &destinationRect, this->directDrawOffscreenSurfacePointer_mapGame, &sourceRect, DDBLT_WAIT, NULL); + blitMenuOverlayUnk(this, sourceRect, destinationRect); + } + if (this->NOTSelfBufferOrWindowMode_0xf8 == TRUE) { + this->directDrawPrimarySurfacePointer->Flip(NULL, DDFLIP_WAIT); + blitMenuOverlayUnk(this, sourceRect, destinationRect); + } + DAT_WindowAndDirectDraw::instance.pendingBltMode = 0; + this->unk_resetViewportRelated = 0; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e1e252e568..28d69b49e5 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21245,7 +21245,7 @@ SHC_3BB0A8C1_0x0046FF50 | 0.0% | Pending SHC_3BB0A8C1_0x0046FFB0 | 0.0% | Pending -SHC_3BB0A8C1_0x00470040 | 0.0% | Pending +SHC_3BB0A8C1_0x00470040 | 56.7% | Zero not kept in ebp; param_1 takes the register instead SHC_3BB0A8C1_0x00470610 | 0.0% | Pending From bde666f89997e260e6637def67c5bd954ff594d2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:37:16 +0100 Subject: [PATCH 11/78] reimplement: SHC_3BB0A8C1_0x004630D0 93.50% Alpha branch's pixel index 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 --- .../isMouseOnButtonImageUnk.cpp | 83 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp new file mode 100644 index 0000000000..860f8e7973 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp @@ -0,0 +1,83 @@ +#include "../AlphaAndButtonSurface.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/COL_MAGENTA.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004630D0 + BOOLEnum AlphaAndButtonSurface::isMouseOnButtonImageUnk() + { + ushort* const surface = this->surfacePtr; + if ((int)DAT_CurrentButtonPictureInGm::instance >= 0) { + int const imageIndex = GMTotalPicturesProcessed::instance[DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0] + + DAT_CurrentButtonPictureInGm::instance - 1; + int const width = DAT_GMImageHeaders::instance.imh[imageIndex].width; + this->currentImageWidth = width; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ShortValue, DAT_LowLevelMemory::ptr)( + DAT_GMImageHeaders::instance.imh[imageIndex].height * width * 2, + (ushort)COL_MAGENTA::instance.shortValue, surface); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_BUTTON_AND_ALPHA; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + DAT_CurrentButtonPictureInGm::instance, 0, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return surface[(DAT_MouseState::instance.screenSpaceY - DAT_ButtonY::instance) * this->currentImageWidth + - DAT_ButtonX::instance + DAT_MouseState::instance.screenSpaceX] + != (ushort)COL_MAGENTA::instance.shortValue; + } + // A negative picture number means the alpha image of the button. + DAT_CurrentButtonPictureInGm::instance = -DAT_CurrentButtonPictureInGm::instance; + int const imageIndex = GMTotalPicturesProcessed::instance[DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .alphaGmIdUnk_0xc] + + DAT_CurrentButtonPictureInGm::instance - 1; + int const width = DAT_GMImageHeaders::instance.imh[imageIndex].width; + this->currentImageWidth = width; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ShortValue, DAT_LowLevelMemory::ptr)( + DAT_GMImageHeaders::instance.imh[imageIndex].height * width * 2, + (ushort)COL_MAGENTA::instance.shortValue, this->surfacePtr); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_BUTTON_AND_ALPHA; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .alphaGmIdUnk_0xc, + DAT_CurrentButtonPictureInGm::instance, 0, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + ushort const pixel + = surface[this->currentImageWidth * (DAT_MouseState::instance.screenSpaceY - DAT_ButtonY::instance) + + (DAT_MouseState::instance.screenSpaceX - DAT_ButtonX::instance)]; + if (pixel != (ushort)COL_MAGENTA::instance.shortValue && (char)(pixel & 0x1f) >= 31) { + return TRUE; + } + return FALSE; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 28d69b49e5..77b111c95d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19155,7 +19155,7 @@ SHC_3BB0A8C1_0x00462FF0 | 0.0% | Pending SHC_3BB0A8C1_0x004630B0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004630D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004630D0 | 93.5% | Alpha branch's pixel index is reassociated SHC_3BB0A8C1_0x00463270 | 0.0% | Pending From 8e65f981987e65a4b0a78c305c657e437fc6a045 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:45:44 +0100 Subject: [PATCH 12/78] reimplement: SHC_3BB0A8C1_0x00463310 72.10% Block placement and jump 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 --- .../openBuildingStatusMenuForBuildingID.cpp | 460 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp new file mode 100644 index 0000000000..e52ff608cb --- /dev/null +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp @@ -0,0 +1,460 @@ +#include "../AlphaAndButtonSurface.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::Game::GameMode2; + using OpenSHC::Map::Buildings::BuildingType; + using OpenSHC::UI::Enums::MenuViewType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00463310 + BOOLEnum AlphaAndButtonSurface::openBuildingStatusMenuForBuildingID(int buildingID) + { + if (buildingID <= 0) { + return FALSE; + } + if (DAT_GameCore::instance.gamePausedLogical != 0) { + return FALSE; + } + short const owner = DAT_BuildingsState::instance.buildings[buildingID].owner; + dword menuTab = 1; + if (owner != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + // Someone else's building: most types are only selected, walls and towers of allies open their menu. + if (owner == 0 + && DAT_BuildingsState::instance.buildings[buildingID].buildingType + == OpenSHC::Map::Buildings::BT_STATUE) { + menuTab = 0x59; + goto openMenu; + } + switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { + case OpenSHC::Map::Buildings::BT_HOVEL: + case OpenSHC::Map::Buildings::BT_HOUSE: + case OpenSHC::Map::Buildings::BT_WOODCUTTERSHUT: + case OpenSHC::Map::Buildings::BT_OXTETHER: + case OpenSHC::Map::Buildings::BT_IRONMINE: + case OpenSHC::Map::Buildings::BT_PITCHRIG: + case OpenSHC::Map::Buildings::BT_HUNTERSHUT: + case OpenSHC::Map::Buildings::BT_MERCENARYPOST: + case OpenSHC::Map::Buildings::BT_BARRACKS: + case OpenSHC::Map::Buildings::BT_STOCKPILE: + case OpenSHC::Map::Buildings::BT_ARMORY: + case OpenSHC::Map::Buildings::BT_FLETCHER: + case OpenSHC::Map::Buildings::BT_BLACKSMITH: + case OpenSHC::Map::Buildings::BT_POLETURNER: + case OpenSHC::Map::Buildings::BT_ARMOURER: + case OpenSHC::Map::Buildings::BT_TANNER: + case OpenSHC::Map::Buildings::BT_BAKERY: + case OpenSHC::Map::Buildings::BT_BREWERY: + case OpenSHC::Map::Buildings::BT_GRANARY: + case OpenSHC::Map::Buildings::BT_QUARRY: + case OpenSHC::Map::Buildings::BT_INN: + case OpenSHC::Map::Buildings::BT_APOTHECARY: + case OpenSHC::Map::Buildings::BT_ENGINEERSGUILD: + case OpenSHC::Map::Buildings::BT_TUNNELERSGUILD: + case OpenSHC::Map::Buildings::BT_MARKETPLACE: + case OpenSHC::Map::Buildings::BT_WELL: + case OpenSHC::Map::Buildings::BT_OILSMELTER: + case OpenSHC::Map::Buildings::BT_SIEGETENT: + case OpenSHC::Map::Buildings::BT_WHEATFARM: + case OpenSHC::Map::Buildings::BT_HOPFARM: + case OpenSHC::Map::Buildings::BT_APPLEFARM: + case OpenSHC::Map::Buildings::BT_DAIRYFARM: + case OpenSHC::Map::Buildings::BT_MILL: + case OpenSHC::Map::Buildings::BT_STABLES: + case OpenSHC::Map::Buildings::BT_CHAPEL: + case OpenSHC::Map::Buildings::BT_CHURCH: + case OpenSHC::Map::Buildings::BT_CATHEDRAL: + case OpenSHC::Map::Buildings::BT_WOODGATE2: + case OpenSHC::Map::Buildings::BT_TUNNEL: + case OpenSHC::Map::Buildings::BT_GALLOWS: + case OpenSHC::Map::Buildings::BT_STOCKS: + case OpenSHC::Map::Buildings::BT_WITCHHOIST: + case OpenSHC::Map::Buildings::BT_MAYPOLE: + case OpenSHC::Map::Buildings::BT_KILLINGPIT: + case OpenSHC::Map::Buildings::BT_SIEGETOWER_PLACED: + case OpenSHC::Map::Buildings::BT_WATERPOT: + case OpenSHC::Map::Buildings::BT_CESSPIT: + case OpenSHC::Map::Buildings::BT_BURNINGSTAKE: + case OpenSHC::Map::Buildings::BT_GIBBET: + case OpenSHC::Map::Buildings::BT_DUNGEON: + case OpenSHC::Map::Buildings::BT_STRETCHINGRACK: + case OpenSHC::Map::Buildings::BT_RACKFLOGGING: + case OpenSHC::Map::Buildings::BT_CHOPPINGBLOCK: + case OpenSHC::Map::Buildings::BT_DUNKINGSTOOL: + case OpenSHC::Map::Buildings::BT_DOGCAGE: + case OpenSHC::Map::Buildings::BT_STATUE: + case OpenSHC::Map::Buildings::BT_SHRINE: + case OpenSHC::Map::Buildings::BT_BEEHIVE: + case OpenSHC::Map::Buildings::BT_DANCINGBEAR: + case OpenSHC::Map::Buildings::BT_BEARCAVE: + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE: + case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: + case OpenSHC::Map::Buildings::BT_WOODGATE1: + case OpenSHC::Map::Buildings::BT_DRAWBRIDGE: + case OpenSHC::Map::Buildings::BT_TOWER1: + case OpenSHC::Map::Buildings::BT_TOWER2: + case OpenSHC::Map::Buildings::BT_TOWER3: + case OpenSHC::Map::Buildings::BT_TOWER4: + case OpenSHC::Map::Buildings::BT_TOWER5: + if (DAT_GameState::instance.mapAndTime.playerTeams[owner] + != DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID]) { + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + } + break; + case OpenSHC::Map::Buildings::BT_OUTPOST_EUROPEAN: + case OpenSHC::Map::Buildings::BT_OUTPOST_ARABIAN: + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + } + break; + default: + return FALSE; + } + } + MACRO_CALL_MEMBER( + OpenSHC::Map::Buildings::BuildingsState_Func::extendResourceCountdownForPlayerBuildingsOfType, + DAT_BuildingsState::ptr)( + (OpenSHC::Map::Buildings::BuildingType)(DAT_BuildingsState::instance.buildings[buildingID] + .buildingType), + 1, DAT_GameSynchronyState::instance.currentPlayerSlotID); + int const currentPlayer = DAT_GameSynchronyState::instance.currentPlayerSlotID; + int setting; + int gatehouse; + switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { + case OpenSHC::Map::Buildings::BT_MERCENARYPOST: + menuTab = 0x2c; + break; + case OpenSHC::Map::Buildings::BT_OUTPOST_EUROPEAN: + case OpenSHC::Map::Buildings::BT_OUTPOST_ARABIAN: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + menuTab = 0x2d; + break; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + case OpenSHC::Map::Buildings::BT_MANORHOUSE: + case OpenSHC::Map::Buildings::BT_STONEKEEP: + case OpenSHC::Map::Buildings::BT_STRONGHOLD: + case OpenSHC::Map::Buildings::BT_KEEPFOUR: + case OpenSHC::Map::Buildings::BT_KEEPFIVE: + case OpenSHC::Map::Buildings::BT_KEEPDOOR_LEFT: + case OpenSHC::Map::Buildings::BT_KEEPDOOR_RIGHT: + case OpenSHC::Map::Buildings::BT_KEEPDOOR: + setting = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .taxesSetting; + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .taxesSetting2 = setting; + menuTab = 2; + DAT_GameState::instance.playerDataArray[currentPlayer].taxesSliderUI = setting; + break; + case OpenSHC::Map::Buildings::BT_INN: + menuTab = 3; + break; + case OpenSHC::Map::Buildings::BT_HOVEL: + case OpenSHC::Map::Buildings::BT_HOUSE: + menuTab = 5; + break; + case OpenSHC::Map::Buildings::BT_WOODCUTTERSHUT: + menuTab = 6; + break; + case OpenSHC::Map::Buildings::BT_OXTETHER: + menuTab = 7; + break; + case OpenSHC::Map::Buildings::BT_IRONMINE: + menuTab = 8; + break; + case OpenSHC::Map::Buildings::BT_PITCHRIG: + menuTab = 9; + break; + case OpenSHC::Map::Buildings::BT_HUNTERSHUT: + menuTab = 10; + break; + case OpenSHC::Map::Buildings::BT_STOCKPILE: + menuTab = 0xb; + break; + case OpenSHC::Map::Buildings::BT_ARMORY: + menuTab = 0xc; + break; + case OpenSHC::Map::Buildings::BT_FLETCHER: + menuTab = 0xd; + break; + case OpenSHC::Map::Buildings::BT_BLACKSMITH: + menuTab = 0xe; + break; + case OpenSHC::Map::Buildings::BT_POLETURNER: + menuTab = 0xf; + break; + case OpenSHC::Map::Buildings::BT_ARMOURER: + menuTab = 0x10; + break; + case OpenSHC::Map::Buildings::BT_TANNER: + menuTab = 0x11; + break; + case OpenSHC::Map::Buildings::BT_BAKERY: + menuTab = 0x12; + break; + case OpenSHC::Map::Buildings::BT_BREWERY: + menuTab = 0x13; + break; + case OpenSHC::Map::Buildings::BT_GRANARY: + setting = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .rationsSetting; + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .rationsSetting2 = setting; + menuTab = 4; + DAT_GameState::instance.playerDataArray[currentPlayer].rationsSetting3 = setting; + break; + case OpenSHC::Map::Buildings::BT_QUARRY: + menuTab = 0x14; + break; + case OpenSHC::Map::Buildings::BT_QUARRYSTOCKPILE: + menuTab = 0x15; + break; + case OpenSHC::Map::Buildings::BT_APOTHECARY: + menuTab = 0x16; + break; + case OpenSHC::Map::Buildings::BT_ENGINEERSGUILD: + menuTab = 0x17; + break; + case OpenSHC::Map::Buildings::BT_TUNNELERSGUILD: + menuTab = 0x18; + break; + case OpenSHC::Map::Buildings::BT_MARKETPLACE: + menuTab = 0x19; + break; + case OpenSHC::Map::Buildings::BT_WELL: + menuTab = 0x1a; + break; + case OpenSHC::Map::Buildings::BT_WATERPOT: + menuTab = 0x28; + break; + case OpenSHC::Map::Buildings::BT_OILSMELTER: + menuTab = 0x1b; + break; + case OpenSHC::Map::Buildings::BT_SIEGETENT: + menuTab = 0x1c; + break; + case OpenSHC::Map::Buildings::BT_WHEATFARM: + menuTab = 0x1d; + break; + case OpenSHC::Map::Buildings::BT_HOPFARM: + menuTab = 0x1e; + break; + case OpenSHC::Map::Buildings::BT_APPLEFARM: + menuTab = 0x1f; + break; + case OpenSHC::Map::Buildings::BT_DAIRYFARM: + menuTab = 0x20; + break; + case OpenSHC::Map::Buildings::BT_MILL: + menuTab = 0x21; + break; + case OpenSHC::Map::Buildings::BT_STABLES: + menuTab = 0x22; + break; + case OpenSHC::Map::Buildings::BT_CHAPEL: + case OpenSHC::Map::Buildings::BT_CHURCH: + menuTab = 0x23; + break; + case OpenSHC::Map::Buildings::BT_CATHEDRAL: + menuTab = 0x60; + break; + case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE: + case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: + case OpenSHC::Map::Buildings::BT_WOODGATE1: + if (DAT_BuildingsState::instance.buildings[buildingID].field203_0x2c6 != 0) { + return FALSE; + } + menuTab = 0x24; + break; + case OpenSHC::Map::Buildings::BT_DRAWBRIDGE: + gatehouse = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, + DAT_BuildingsState::ptr)((int)DAT_BuildingsState::instance.buildings[buildingID].owner, + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].x), + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].y), + (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), + OpenSHC::Map::Buildings::BT_GATEHOUSELARGE, 0); + if (((gatehouse != 0) + || (gatehouse + = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, + DAT_BuildingsState::ptr)((int)DAT_BuildingsState::instance.buildings[buildingID].owner, + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].x), + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].y), + (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), + OpenSHC::Map::Buildings::BT_GATEHOUSESMALL, 0), + gatehouse != 0)) + && DAT_BuildingsState::instance.buildings[gatehouse].field203_0x2c6 != 0) { + return FALSE; + } + menuTab = 0x25; + break; + case OpenSHC::Map::Buildings::BT_WOODGATE2: + menuTab = 0x26; + break; + case OpenSHC::Map::Buildings::BT_TUNNEL: + menuTab = 0x27; + break; + case OpenSHC::Map::Buildings::BT_SIGNPOST: + menuTab = 0x29; + break; + case OpenSHC::Map::Buildings::BT_KILLINGPIT: + menuTab = 0x2a; + break; + case OpenSHC::Map::Buildings::BT_CAMPGROUND: + menuTab = 0x2b; + break; + case OpenSHC::Map::Buildings::BT_TOWER1: + case OpenSHC::Map::Buildings::BT_TOWER2: + case OpenSHC::Map::Buildings::BT_TOWER3: + case OpenSHC::Map::Buildings::BT_TOWER4: + case OpenSHC::Map::Buildings::BT_TOWER5: + menuTab = 0x2e; + break; + case OpenSHC::Map::Buildings::BT_GALLOWS: + menuTab = 0x2f; + break; + case OpenSHC::Map::Buildings::BT_STOCKS: + menuTab = 0x30; + break; + case OpenSHC::Map::Buildings::BT_WITCHHOIST: + menuTab = 0x31; + break; + case OpenSHC::Map::Buildings::BT_MAYPOLE: + menuTab = 0x32; + break; + case OpenSHC::Map::Buildings::BT_GARDEN: + menuTab = 0x33; + break; + case OpenSHC::Map::Buildings::BT_CAMPFIRE: + case OpenSHC::Map::Buildings::BT_PARADEGROUND: + case OpenSHC::Map::Buildings::BT_PARADEGROUND2: + case OpenSHC::Map::Buildings::BT_PARADEGROUND3: + case OpenSHC::Map::Buildings::BT_PARADEGROUND4: + case OpenSHC::Map::Buildings::BT_PARADEGROUND5: + menuTab = 0x34; + break; + case OpenSHC::Map::Buildings::BT_CATAPULT: + menuTab = 0x3a; + break; + case OpenSHC::Map::Buildings::BT_TREBUCHET: + menuTab = 0x3b; + break; + case OpenSHC::Map::Buildings::BT_BATTERINGRAM: + menuTab = 0x3c; + break; + case OpenSHC::Map::Buildings::BT_SIEGETOWER: + menuTab = 0x3d; + break; + case OpenSHC::Map::Buildings::BT_SHIELD: + menuTab = 0x3e; + break; + case OpenSHC::Map::Buildings::BT_FIREBALLISTA: + menuTab = 0x5f; + break; + case OpenSHC::Map::Buildings::BT_CESSPIT: + menuTab = 0x50; + break; + case OpenSHC::Map::Buildings::BT_BURNINGSTAKE: + menuTab = 0x51; + break; + case OpenSHC::Map::Buildings::BT_GIBBET: + menuTab = 0x52; + break; + case OpenSHC::Map::Buildings::BT_DUNGEON: + menuTab = 0x53; + break; + case OpenSHC::Map::Buildings::BT_STRETCHINGRACK: + menuTab = 0x54; + break; + case OpenSHC::Map::Buildings::BT_RACKFLOGGING: + menuTab = 0x55; + break; + case OpenSHC::Map::Buildings::BT_CHOPPINGBLOCK: + menuTab = 0x56; + break; + case OpenSHC::Map::Buildings::BT_DUNKINGSTOOL: + menuTab = 0x57; + break; + case OpenSHC::Map::Buildings::BT_DOGCAGE: + menuTab = 0x58; + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .releaseDogsFlag + = DAT_BuildingsState::instance.buildings[buildingID].flagonsOfAleOrCheeseOrReleaseDogs; + break; + case OpenSHC::Map::Buildings::BT_SHRINE: + menuTab = 0x5a; + break; + case OpenSHC::Map::Buildings::BT_BEEHIVE: + menuTab = 0x5b; + break; + case OpenSHC::Map::Buildings::BT_DANCINGBEAR: + menuTab = 0x5c; + break; + case OpenSHC::Map::Buildings::BT_BEARCAVE: + menuTab = 0x5e; + break; + case OpenSHC::Map::Buildings::BT_BARRACKS: + break; + default: + return FALSE; + case OpenSHC::Map::Buildings::BT_SIEGETOWER_PLACED: + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + case OpenSHC::Map::Buildings::BT_STATUE: + menuTab = 0x59; + break; + } + openMenu: + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = menuTab; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); + DAT_BuildingsState::instance.newSelectedBuildingID = buildingID; + DAT_BuildingsState::instance.newSelectedUnitID = 0; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTutorialBuildingActionState)( + 8, (BuildingType)((int)((short)DAT_BuildingsState::instance.buildings[buildingID].buildingType))); + } + DAT_BuildingsState::instance.selectedBuildingID = 0; + DAT_BuildingsState::instance.selectedBuildingUID = 0; + return TRUE; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 77b111c95d..8fa4f6b1e0 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19159,7 +19159,7 @@ SHC_3BB0A8C1_0x004630D0 | 93.5% | Alpha branch's pixel index is reassociated SHC_3BB0A8C1_0x00463270 | 0.0% | Pending -SHC_3BB0A8C1_0x00463310 | 0.0% | Pending +SHC_3BB0A8C1_0x00463310 | 72.1% | Block placement and jump offsets around the statue case SHC_3BB0A8C1_0x004637E8 | 0.0% | Pending From 9f375ff4bb4ad35537b637f0b5b7fc94ed484c42 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:22:29 +0100 Subject: [PATCH 13/78] reimplement: SHC_3BB0A8C1_0x00433780 95.40% Two locals in swapped stack slots Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Rendering/RenderGoldValue.cpp | 121 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderGoldValue.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp new file mode 100644 index 0000000000..a810ecf518 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp @@ -0,0 +1,121 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" + +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x00433780 + void Rendering::RenderGoldValue() + { + int const playerID = DAT_GameSynchronyState::instance.currentPlayerSlotID; + int const popularity = DAT_GameState::instance.playerDataArray[playerID].popularity / 100; + int const populationCap = DAT_GameState::instance.playerDataArray[playerID].populationCap; + int population = DAT_GameState::instance.playerDataArray[playerID].currentPopulation; + int gold = DAT_GameState::instance.playerDataArray[playerID].currentResources[Game::Resources::RT_GOLD]; + DAT_TextManagerObject::instance.currentXOffset_0x0 + = DAT_GMImageHeaders::instance.imh[GMTotalPicturesProcessed::instance[DE::SHCDE::GM_INTERFACE_ICONS2] + 123] + .width; + + int goldDigitSet = 0; + if (gold > 999) { + goldDigitSet = 2; + } + int goldColor; + if (gold > 0) { + goldColor = 0x7d3e; + } else { + gold = 0; + goldColor = 0xff; + } + goldDigitSet = goldDigitSet + 1; + int goldWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, DAT_TextManagerObject::ptr)( + gold, goldDigitSet); + if (gold >= 100000) { + goldWidth = goldWidth - 2; + } + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, + DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 5, goldColor, + goldDigitSet, FALSE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, + DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 4, goldColor, + goldDigitSet, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, + DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 3, goldColor, + goldDigitSet, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, + DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 2, goldColor, + goldDigitSet, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, + DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 1, goldColor, + goldDigitSet, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, + DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 0, goldColor, + goldDigitSet, TRUE); + + int populationDigitSetUnk = 0; + int populationColor = DAT_GameState::instance.playerDataArray[playerID].crowding <= 100 ? 0x7d3e : 0xff; + if (populationCap == 0) { + populationColor = 0x7d3e; + population = 0; + } else { + if (populationCap >= 100) { + populationDigitSetUnk = 2; + } + if (population < 0) { + population = 0; + } else if (population >= 100) { + populationDigitSetUnk = 2; + } + } + int const populationDigitSet = populationDigitSetUnk + 1; + int const populationWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, + DAT_TextManagerObject::ptr)(population, populationDigitSet); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, + DAT_MenuHandlerState::instance.x - populationWidth + 729, DAT_MenuHandlerState::instance.y + 552, 2, + populationColor, populationDigitSet, FALSE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, + DAT_MenuHandlerState::instance.x - populationWidth + 729, DAT_MenuHandlerState::instance.y + 552, 1, + populationColor, populationDigitSet, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, + DAT_MenuHandlerState::instance.x - populationWidth + 729, DAT_MenuHandlerState::instance.y + 552, 0, + populationColor, populationDigitSet, TRUE); + // the "/" between the population and the cap + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, + DAT_MenuHandlerState::instance.x + 729, DAT_MenuHandlerState::instance.y + 552, -1, populationColor, + populationDigitSet, FALSE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(populationCap, + DAT_MenuHandlerState::instance.x + 727 + populationDigitSetUnk, DAT_MenuHandlerState::instance.y + 552, 2, + populationColor, populationDigitSet, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(populationCap, + DAT_MenuHandlerState::instance.x + 727 + populationDigitSetUnk, DAT_MenuHandlerState::instance.y + 552, 1, + populationColor, populationDigitSet, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(populationCap, + DAT_MenuHandlerState::instance.x + 727 + populationDigitSetUnk, DAT_MenuHandlerState::instance.y + 552, 0, + populationColor, populationDigitSet, TRUE); + + int const popularityColor = popularity < 50 ? 0xff : 0x7d3e; + int const popularityHalfWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, + DAT_TextManagerObject::ptr)(popularity, 0) + / 2; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(popularity, + DAT_MenuHandlerState::instance.x - popularityHalfWidth + 747, DAT_MenuHandlerState::instance.y + 515, 2, + popularityColor, 0, FALSE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(popularity, + DAT_MenuHandlerState::instance.x - popularityHalfWidth + 747, DAT_MenuHandlerState::instance.y + 515, 1, + popularityColor, 0, TRUE); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(popularity, + DAT_MenuHandlerState::instance.x - popularityHalfWidth + 747, DAT_MenuHandlerState::instance.y + 515, 0, + popularityColor, 0, TRUE); + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8fa4f6b1e0..41298b05c7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11105,7 +11105,7 @@ SHC_3BB0A8C1_0x004335A0 | 0.0% | Pending SHC_3BB0A8C1_0x00433630 | 0.0% | Pending -SHC_3BB0A8C1_0x00433780 | 0.0% | Pending +SHC_3BB0A8C1_0x00433780 | 95.4% | Two locals in swapped stack slots SHC_3BB0A8C1_0x00433BC0 | 0.0% | Pending From e4a0f0e71cae3b6ce5f12354a5bf7e560d10c676 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:31:57 +0100 Subject: [PATCH 14/78] reimplement: SHC_3BB0A8C1_0x00493690 85.70% Constant 1 kept in edi 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 --- .../UI/Rendering/RenderLoadAndSaveBar.cpp | 69 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp b/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp new file mode 100644 index 0000000000..536440ff56 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp @@ -0,0 +1,69 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/TIME_LoadSaveBar.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::UI::Enums::BuildingsAndStatusMenuTabType; + using OpenSHC::UI::Enums::MenuViewType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00493690 + void Rendering::RenderLoadAndSaveBar(int progressValueUnk) + { + DWORD const currentTime = timeGetTime(); + if ((int)(currentTime - TIME_LoadSaveBar::instance) <= 30) { + return; + } + TIME_LoadSaveBar::instance = currentTime; + int const barWidth = (progressValueUnk * 300) / 1000; + if (MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)()) { + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)( + DAT_MenuTextInputState::instance.progressBarX, DAT_MenuTextInputState::instance.progressBarY, + DAT_MenuTextInputState::instance.progressBarX + barWidth, + DAT_MenuTextInputState::instance.progressBarY + 15, COL_VERY_SOFT_YELLOW::instance.shortValue); + if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_SIEGETENT_SIEGETOWER + || DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_SIEGETENT_SHIELD) { + DAT_WindowAndDirectDraw::instance.pendingBltMode = 2; + if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU) { + DAT_WindowAndDirectDraw::instance.pendingBltMode = 1; + } + } else { + DAT_WindowAndDirectDraw::instance.pendingBltMode = 1; + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(1); + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)( + DAT_MenuTextInputState::instance.progressBarX, DAT_MenuTextInputState::instance.progressBarY, + DAT_MenuTextInputState::instance.progressBarX + barWidth, + DAT_MenuTextInputState::instance.progressBarY + 15, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltScreenMenuSurfaceToScreen, + DAT_WindowAndDirectDraw::ptr)(DAT_MenuTextInputState::instance.progressBarX, + DAT_MenuTextInputState::instance.progressBarY, DAT_MenuTextInputState::instance.progressBarX + 300, + DAT_MenuTextInputState::instance.progressBarY + 15); + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 41298b05c7..16ab6f4dd1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23625,7 +23625,7 @@ SHC_3BB0A8C1_0x004934F0 | 0.0% | Pending SHC_3BB0A8C1_0x00493560 | 0.0% | Pending -SHC_3BB0A8C1_0x00493690 | 0.0% | Pending +SHC_3BB0A8C1_0x00493690 | 85.7% | Constant 1 kept in edi SHC_3BB0A8C1_0x004937A4 | 0.0% | Pending From ce6bd1e863812f31256798bab5b2f07212e461cb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:37:32 +0100 Subject: [PATCH 15/78] reimplement: SHC_3BB0A8C1_0x004BC790 67.20% Shared blocks and offsets differ Co-Authored-By: Claude Opus 5.5 --- .../RenderAnimatedTutorialFloatOverlay.cpp | 110 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp new file mode 100644 index 0000000000..2a698064eb --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp @@ -0,0 +1,110 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" + +#include "OpenSHC/Globals/DAT_00df5540.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00df563c.hpp" +#include "OpenSHC/Globals/INT_00df5640.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::IO::Graphics::GmID; + using OpenSHC::Rendering::ScreenResolutionEnum; + using OpenSHC::Rendering::Enums::RenderTarget; + + /* + Renders an animated floating arrow/indicator overlay (GID_FLOATS_NEW) at a screen position derived from + param_1/param_2 and the current resolution. Animates through 10 frames at ~60ms per frame using timeGetTime. + Renders twice: once to RT_SCREEN_MENU and once to RT_MAP_GAME with camera offset applied. Skipped if + DAT_00df5540 is non-zero. renamed by: Claude Sonnet 4.6 + */ + // FUNCTION: STRONGHOLDCRUSADER 0x004BC790 + void Rendering::RenderAnimatedTutorialFloatOverlay(int param_1, int param_2) + { + if (DAT_00df5540::instance != 0) { + return; + } + if ((INT_00df5640::instance & 1U) == 0) { + INT_00df5640::instance = INT_00df5640::instance | 1; + INT_00df563c::instance = timeGetTime(); + } + DWORD const now = timeGetTime(); + int frame = (now - INT_00df563c::instance) / 60; + if (frame >= 10) { + frame = 0; + INT_00df563c::instance = now; + } + // The gotos measure 3.5 points better than a plain if/else-if chain: the original keeps the shared + // 168 and 600 blocks at their first occurrence. It also keeps param_1 - 8 and param_2 - 32 apart from the + // later - 28 and - 69 (an inlined helper?), which this source folds. + int iVar4 = 0; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { + LAB_004bc7fc: + iVar4 = 0xa8; + goto LAB_004bc873; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { + iVar4 = 0x1a8; + goto LAB_004bc873; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { + LAB_004bc814: + iVar4 = 600; + } else { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { + iVar4 = 0x78; + goto LAB_004bc873; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1440x900) { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { + iVar4 = 0x1e0; + goto LAB_004bc873; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) + goto LAB_004bc814; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { + iVar4 = 0x348; + goto LAB_004bc873; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { + iVar4 = 1000; + goto LAB_004bc873; + } + if ((DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) + || (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768)) + goto LAB_004bc7fc; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { + iVar4 = 0xfd2; + goto LAB_004bc873; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1600x900) + goto LAB_004bc873; + } + iVar4 = 300; + } + LAB_004bc873: + RenderTargetInt const previousDrawBuffer = DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + param_1 + -0x24, param_2 + -0x65 + iVar4, + OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + param_1 + -0x24, + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + iVar4 + param_2 + -0x65, + OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = previousDrawBuffer; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 16ab6f4dd1..2682582adf 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30097,7 +30097,7 @@ SHC_3BB0A8C1_0x004BC6F0 | 0.0% | Pending SHC_3BB0A8C1_0x004BC770 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BC790 | 0.0% | Pending +SHC_3BB0A8C1_0x004BC790 | 67.2% | Shared blocks and offsets differ SHC_3BB0A8C1_0x004BC910 | 0.0% | Pending From 211e32e651a9fc8df612dda7086418706285cdae Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:43:16 +0100 Subject: [PATCH 16/78] reimplement: SHC_3BB0A8C1_0x004B7C90 74.50% Register allocation differs 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 --- .../Bink/AIMessageQueue/playAiLordMessage.cpp | 140 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp diff --git a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp new file mode 100644 index 0000000000..9d525bb454 --- /dev/null +++ b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp @@ -0,0 +1,140 @@ +#include "../../../Rendering.func.hpp" +#include "../AIMessageQueue.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace Rendering { + namespace Bink { + + using Audio::MSS::enums::SHC_SoundStream; + using DE::SHCDE::eGM; + using UI::Enums::BuildingsAndStatusMenuTabType; + using UI::Enums::DisplayElementID; + using UI::Enums::MenuModalType; + using UI::Enums::MenuViewType; + using WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004B7C90 + void AIMessageQueue::playAiLordMessage(int param_1, int param_2) + { + DWORD const now = timeGetTime(); + int yOffset = 0; + if (!MACRO_CALL_MEMBER(Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)()) { + return; + } + if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_BUILDING_AND_STATUS_MENU) { + if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM) { + yOffset = -40; + } else if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_MERCENARYPOST) { + yOffset = -40; + } else { + yOffset = -20; + } + } + if (MACRO_CALL(UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO)) { + yOffset = yOffset - 40; + } + int textHeight; + int textWidth; + if (!this->currentMessageUnknownValue_0x4) { + textHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineWideTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + (WCHAR*)this->currentMessageText_0x8, 0, 0, 580, 0, 0, 1); + textWidth = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineWideTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + (WCHAR*)this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineWideTextUnk, DAT_TextManagerObject::ptr)( + (WCHAR*)this->currentMessageText_0x8, param_1 - textWidth, yOffset - textHeight + param_2, 580, + 0xccfaff, 0, 18, 0); + } else { + textHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + this->currentMessageText_0x8, 0, 0, 580, 0, 0, 1); + textWidth = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( + this->currentMessageText_0x8, param_1 - textWidth, yOffset - textHeight + param_2, 580, 0xccfaff, 0, + 18, 0); + } + if ((int)this->currentMessageUnknownValue2_0xd4 > 0) { + int const nameHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], 0, 0, 580, + 0, 0, 1); + int const nameWidth = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], 0, 0, 580, + 0, 0, 2); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], + param_1 - nameWidth, yOffset - nameHeight + param_2, 580, 0xccfaff, 0, 18, 0); + int aiCharacter = 0; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[this->currentMessageUnknownValue2_0xd4] + == -1) { + aiCharacter + = DAT_GameSynchronyState::instance.currentAIArray[this->currentMessageUnknownValue2_0xd4]; + } + int const faceX = param_1 - nameWidth - 80; + int const faceY = param_2 - nameHeight - 48; + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + DE::SHCDE::GM_INTERFACE_ICONS2, this->currentMessageUnknownValue2_0xd4 + 546, faceX, faceY); + if (!aiCharacter) { + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(DE::SHCDE::GM_INTERFACE_ICONS2, 539, faceX, faceY); + } else { + MACRO_CALL_MEMBER( + UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + DE::SHCDE::GM_INTERFACE_ICONS2, aiCharacter + 522, faceX, faceY); + } + } + if (!MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, DAT_SoundSystemState::ptr)( + Audio::MSS::enums::SND_STR_SPEECH_1)) { + this->mbr_0x92c = 1; + } + if ((int)(now - this->videoStartTimeUnk_0xd8) <= 10000 && textWidth != 0) { + return; + } + if (this->currentMessageVfxFile_0xc[0] != '\0') { + if (DAT_BinkControlState::instance.binkObjPtrArray[1] != NULL) { + return; + } + } else if (this->currentMessageSfxFile_0x70[0] != '\0' && DAT_SoundSystemState::instance.waveOutOpenUnk_0x8 + && DAT_SoundSystemState::instance.soundActiveUnk_0x0 && !this->mbr_0x92c) { + return; + } + if (DAT_GameCore::instance.gamePausedLogical) { + return; + } + this->mbr_0x928 = 0; + DAT_GameCore::instance.countdown = 2; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition2::ptr)( + UI::Enums::MMT_NONE, FALSE); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2682582adf..8e54d93c4a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27095,7 +27095,7 @@ SHC_3BB0A8C1_0x004B7AB0 | 0.0% | Pending SHC_3BB0A8C1_0x004B7AF0 | 0.0% | Pending -SHC_3BB0A8C1_0x004B7C90 | 0.0% | Pending +SHC_3BB0A8C1_0x004B7C90 | 74.5% | Register allocation differs SHC_3BB0A8C1_0x004B7F60 | 100.0% | Reimplemented From b05f87f9a96573404cb31b2e673ea193f001458b Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:52:33 +0100 Subject: [PATCH 17/78] reimplement: SHC_3BB0A8C1_0x004DAFB0 67.80% Loop registers and RECT spills differ Co-Authored-By: Claude Opus 5.5 --- .../Rendering/RenderTextPageProgressBar.cpp | 51 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp b/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp new file mode 100644 index 0000000000..1c61ec53e7 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp @@ -0,0 +1,51 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/Globals/DAT_00ed2784.hpp" +#include "OpenSHC/Globals/DAT_ARRAY_00ed26d0.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x004DAFB0 + void Rendering::RenderTextPageProgressBar() + { + DWORD elapsed = timeGetTime() - DAT_ARRAY_00ed26d0::instance[0].x; + if (elapsed > 1000000) { + elapsed = 0; + } + DAT_00ed2784::instance = elapsed / 80; + if ((int)DAT_00ed2784::instance > 580) { + DAT_00ed2784::instance = 580; + } + RECT sourceRect; + sourceRect.right = 540; + sourceRect.left = 0; + sourceRect.top = DAT_00ed2784::instance; + sourceRect.bottom = DAT_00ed2784::instance + 220; + int const left = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 20; + int const top = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 20; + RECT destinationRect; + destinationRect.top = top; + destinationRect.left = left; + destinationRect.right = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 560; + destinationRect.bottom = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 240; + MACRO_CALL_MEMBER(UI::Rendering::WindowAndDirectDraw_Func::bltMapGameSurfaceToScreenMenuSurface, + DAT_WindowAndDirectDraw::ptr)(sourceRect, destinationRect); + // fade the top and bottom edges of the page + for (int i = 0; i < 30; ++i) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + left, top + i * 2, left + 539, top + i * 2 + 1, i + 2); + } + for (int i = 0; i < 30; ++i) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + left, top + 220 - i * 2, left + 539, top + 220 - i * 2 + 1, i + 2); + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8e54d93c4a..d4a916b961 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36185,7 +36185,7 @@ SHC_3BB0A8C1_0x004DAE90 | 0.0% | Pending SHC_3BB0A8C1_0x004DAF50 | 0.0% | Pending -SHC_3BB0A8C1_0x004DAFB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004DAFB0 | 67.8% | Loop registers and RECT spills differ SHC_3BB0A8C1_0x004DB0D0 | 0.0% | Pending From eddd914b0ee14f4655b47aeba8ad8a6f64cbe1ef Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 15:53:39 +0100 Subject: [PATCH 18/78] reimplement: SHC_3BB0A8C1_0x004BA910 97.20% One push scheduled later Co-Authored-By: Claude Opus 5.5 --- .../RenderScenarioButtonWithText.cpp | 48 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp new file mode 100644 index 0000000000..86e9a97412 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp @@ -0,0 +1,48 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004BA910 + void Rendering::RenderScenarioButtonWithText(int textNumInGroup) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const x = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const y = DAT_ButtonY::instance + 6; + if (DAT_ButtonCurrentlyInteracting::instance == FALSE) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), + x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), + x, y, OpenSHC::Text::TTA_CENTER, 0xccfaff, 18, FALSE, 0); + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d4a916b961..9f1d0a3d0f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29089,7 +29089,7 @@ SHC_3BB0A8C1_0x004BA7D0 | 0.0% | Pending SHC_3BB0A8C1_0x004BA8B0 | 0.0% | Pending -SHC_3BB0A8C1_0x004BA910 | 0.0% | Pending +SHC_3BB0A8C1_0x004BA910 | 97.2% | One push scheduled later SHC_3BB0A8C1_0x004BA980 | 0.0% | Pending From d924f3e3207cf28eae7705980649b2501711db2d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 16:19:54 +0100 Subject: [PATCH 19/78] reimplement: SHC_3BB0A8C1_0x004D5810 58.70% Frame 8 bytes larger, reg 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 --- .../UI/Rendering/RenderGreatestLordScreen.cpp | 637 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 638 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp new file mode 100644 index 0000000000..2b284eb129 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -0,0 +1,637 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/GreatestLord.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_WHITE.hpp" +#include "OpenSHC/Globals/DAT_00eb9af8.hpp" +#include "OpenSHC/Globals/DAT_00ec082c.hpp" +#include "OpenSHC/Globals/DAT_00ed3118.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00eb0e44.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eGM; + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::IO::Graphics::GmID; + using OpenSHC::Rendering::ScreenResolutionEnum; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // The tables behind the Greatest Lord screen, one entry per player slot (index 0 unused). The original keeps them + // in one block of the stack frame, and its statistic orders are filled by one strided loop, so they are one + // struct here rather than separate arrays. + struct GreatestLordTablesUnk { + int points[9]; + int stars[9]; + int overallOrder[9]; + int kills[9]; + int losses[9]; + // Player order per statistic, best first: 0 kills, 1 buildings burned, 2 food, 3 gold, 4 max population, + // 5 wood, 6 stone, 7 iron, 8 pitch, 9 unused, 10 losses, 11 weapons, 12 buildings lost, 13 troops, + // 14 goods received, 15 goods sent. + int statOrder[16][9]; + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x004D5810 + void Rendering::RenderGreatestLordScreen() + { + int y; + int columnOffset; + int index; + int x; + GreatestLordTablesUnk tables; + char saveText[100]; + char scoreText[100]; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + x = DAT_MenuHandlerState::instance.x + 10; + columnOffset = 58; + } else { + x = DAT_MenuHandlerState::instance.x - 102; + columnOffset = 522; + } + y = DAT_MenuHandlerState::instance.y; + + for (int player = 1; player < 9; ++player) { + tables.points[player] = 0; + } + for (int player = 1; player < 9; ++player) { + int kills = 0; + for (int victim = 1; victim < 9; ++victim) { + if (victim != player) { + kills = kills + DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[player][victim]; + } + } + tables.kills[player] = kills; + int losses = 0; + for (int killer = 0; killer < 9; ++killer) { + if (killer != player) { + losses = losses + DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[killer][player]; + } + } + tables.losses[player] = losses; + } + for (int player = 1; player < 9; ++player) { + tables.stars[player] = 0; + } + for (int player = 1; player < 9; ++player) { + tables.overallOrder[player] = player; + for (int stat = 0; stat < 16; ++stat) { + tables.statOrder[stat][player] = player; + } + } + + // bubble sort every order at once; index is the pass here and the rank further down + for (index = 8; index > 0; --index) { + for (int i = 1; i < index; ++i) { + int const first = tables.overallOrder[i]; + int const firstScore = MACRO_CALL(OpenSHC::UI::GreatestLord_Func::ComputeSkMasterScore)(first); + int const second = tables.overallOrder[i + 1]; + int const secondScore = MACRO_CALL(OpenSHC::UI::GreatestLord_Func::ComputeSkMasterScore)(second); + if (firstScore < secondScore + || firstScore == secondScore + && (DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[first] + < DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[second] + || DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[first] + == DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[second] + && DAT_GameState::instance.mapAndTime.playerIsAlive[first] + < DAT_GameState::instance.mapAndTime.playerIsAlive[second])) { + tables.overallOrder[i] = second; + tables.overallOrder[i + 1] = first; + } + + int current = tables.statOrder[0][i]; + if (tables.kills[current] < tables.kills[tables.statOrder[0][i + 1]]) { + tables.statOrder[0][i] = tables.statOrder[0][i + 1]; + tables.statOrder[0][i + 1] = current; + } + current = tables.statOrder[10][i]; + if (tables.losses[tables.statOrder[10][i + 1]] < tables.losses[current]) { + tables.statOrder[10][i] = tables.statOrder[10][i + 1]; + tables.statOrder[10][i + 1] = current; + } + current = tables.statOrder[1][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[current] + < DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][i + 1]]) { + tables.statOrder[1][i] = tables.statOrder[1][i + 1]; + tables.statOrder[1][i + 1] = current; + } + current = tables.statOrder[2][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][i + 1]]) { + tables.statOrder[2][i] = tables.statOrder[2][i + 1]; + tables.statOrder[2][i + 1] = current; + } + current = tables.statOrder[3][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalGold[current] + < DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][i + 1]]) { + tables.statOrder[3][i] = tables.statOrder[3][i + 1]; + tables.statOrder[3][i + 1] = current; + } + current = tables.statOrder[4][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[current] + < DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][i + 1]]) { + tables.statOrder[4][i] = tables.statOrder[4][i + 1]; + tables.statOrder[4][i + 1] = current; + } + current = tables.statOrder[5][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][i + 1]]) { + tables.statOrder[5][i] = tables.statOrder[5][i + 1]; + tables.statOrder[5][i + 1] = current; + } + current = tables.statOrder[6][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][i + 1]]) { + tables.statOrder[6][i] = tables.statOrder[6][i + 1]; + tables.statOrder[6][i + 1] = current; + } + current = tables.statOrder[7][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalIronProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][i + 1]]) { + tables.statOrder[7][i] = tables.statOrder[7][i + 1]; + tables.statOrder[7][i + 1] = current; + } + current = tables.statOrder[8][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][i + 1]]) { + tables.statOrder[8][i] = tables.statOrder[8][i + 1]; + tables.statOrder[8][i + 1] = current; + } + current = tables.statOrder[11][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][i + 1]]) { + tables.statOrder[11][i] = tables.statOrder[11][i + 1]; + tables.statOrder[11][i + 1] = current; + } + current = tables.statOrder[12][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[tables.statOrder[12][i + 1]] + < DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[current]) { + tables.statOrder[12][i] = tables.statOrder[12][i + 1]; + tables.statOrder[12][i + 1] = current; + } + current = tables.statOrder[13][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[tables.statOrder[13][i + 1]]) { + tables.statOrder[13][i] = tables.statOrder[13][i + 1]; + tables.statOrder[13][i + 1] = current; + } + current = tables.statOrder[14][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[current] + < DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[tables.statOrder[14][i + 1]]) { + tables.statOrder[14][i] = tables.statOrder[14][i + 1]; + tables.statOrder[14][i + 1] = current; + } + current = tables.statOrder[15][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[current] + < DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[tables.statOrder[15][i + 1]]) { + tables.statOrder[15][i] = tables.statOrder[15][i + 1]; + tables.statOrder[15][i + 1] = current; + } + } + } + + // bonus points for the winner and for a clear lead in a statistic + tables.points[tables.overallOrder[1]] = tables.points[tables.overallOrder[1]] + 3; + if (tables.kills[tables.statOrder[0][1]] > 10 + && tables.kills[tables.statOrder[0][1]] > tables.kills[tables.statOrder[0][2]] * 2) { + tables.points[tables.statOrder[0][1]] = tables.points[tables.statOrder[0][1]] + 3; + } + int value = DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][1]]; + if (value > 2 + && value > DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][2]] * 2) { + tables.points[tables.statOrder[1][1]] = tables.points[tables.statOrder[1][1]] + 2; + } + value = DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][1]]; + if (value > 50 + && value > DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][2]] * 2) { + tables.points[tables.statOrder[2][1]] = tables.points[tables.statOrder[2][1]] + 2; + } + value = DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][1]]; + if (value > 100 + && value > DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][2]] * 2) { + tables.points[tables.statOrder[3][1]] = tables.points[tables.statOrder[3][1]] + 3; + } + short const maxPopulation + = DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][1]]; + if (maxPopulation > 24 + && maxPopulation + > DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][2]] * 2) { + // fixme: the original gives the population point to the player with the most kills + tables.points[tables.statOrder[0][1]] = tables.points[tables.statOrder[0][1]] + 1; + } + value = DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][1]]; + if (value > 100 + && value > DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][2]] * 2) { + tables.points[tables.statOrder[5][1]] = tables.points[tables.statOrder[5][1]] + 1; + } + value = DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][1]]; + if (value > 50 + && value > DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][2]] * 2) { + tables.points[tables.statOrder[6][1]] = tables.points[tables.statOrder[6][1]] + 1; + } + value = DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][1]]; + if (value > 10 + && value > DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][2]] * 2) { + tables.points[tables.statOrder[7][1]] = tables.points[tables.statOrder[7][1]] + 1; + } + value = DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][1]]; + if (value > 20 + && value > DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][2]] * 2) { + tables.points[tables.statOrder[8][1]] = tables.points[tables.statOrder[8][1]] + 1; + } + value = DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][1]]; + if (value > 20 + && value + > DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][2]] * 2) { + tables.points[tables.statOrder[11][1]] = tables.points[tables.statOrder[11][1]] + 1; + } + + // three points per star, at most five, and at most four unless player slot 1 took part + int starLimitUnk = 0; + if (DAT_GameSynchronyState::instance.finalResults.active[1]) { + starLimitUnk = 8; + } + for (int player = 1; player < 9; ++player) { + tables.stars[player] = tables.points[player] / 3; + if (tables.points[player] / 3 > 5) { + tables.stars[player] = 5; + } + if (starLimitUnk < 4 && tables.stars[player] == 5) { + tables.stars[player] = 4; + } + } + + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_MenuHandlerState::instance.x, DAT_MenuHandlerState::instance.y, + DAT_MenuHandlerState::instance.x + 800, DAT_MenuHandlerState::instance.y + 600, 16); + // "Greatest Lord" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, + DAT_PencilRenderCore::ptr)(225, 1, DAT_MenuHandlerState::instance.x + 40, y, 720, 720); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_MenuHandlerState::instance.x - 112, + DAT_MenuHandlerState::instance.y - 84, DAT_MenuHandlerState::instance.x + 912, + DAT_MenuHandlerState::instance.y + 684, 16); + // "Greatest Lord" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, + DAT_PencilRenderCore::ptr)(225, 1, DAT_MenuHandlerState::instance.x - 104, y - 30, 1008, 0); + y = y + 20; + } + y = y + 190; + int iconY = y - 18; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + int player; + for (index = 0; index < 8; ++index) { + switch (DAT_FinalResultsOrderByColumn::instance) { + case 0: + player = tables.overallOrder[index + 1]; + break; + case 1: + player = tables.statOrder[0][index + 1]; + break; + case 2: + player = tables.statOrder[1][index + 1]; + break; + case 3: + player = tables.statOrder[10][index + 1]; + break; + case 4: + player = tables.statOrder[3][index + 1]; + break; + case 5: + player = tables.statOrder[2][index + 1]; + break; + case 6: + player = tables.statOrder[5][index + 1]; + break; + case 7: + player = tables.statOrder[6][index + 1]; + break; + case 8: + player = tables.statOrder[7][index + 1]; + break; + case 9: + player = tables.statOrder[8][index + 1]; + break; + case 10: + player = tables.statOrder[4][index + 1]; + break; + case 11: + player = tables.statOrder[11][index + 1]; + break; + case 12: + player = tables.statOrder[12][index + 1]; + break; + case 13: + player = tables.statOrder[13][index + 1]; + break; + case 14: + player = tables.statOrder[14][index + 1]; + break; + case 15: + player = tables.statOrder[15][index + 1]; + break; + } + if (!DAT_GameSynchronyState::instance.finalResults.active[player]) { + continue; + } + char* const name = DAT_GameSynchronyState::instance.finalResults.names[player]; + DAT_TextManagerObject::instance.field12_0x30 = 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( + name, x, y, 260, + DAT_RenderingDefinedData::instance + .ColorArray[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[player]], + 0, 18, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)(name, 18); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + int iconX = x; + if (DAT_GameState::instance.mapAndTime.playerIsAlive[player] != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 139, x, iconY - 2); + iconX = x + 22; + } + for (int star = 0; star < tables.stars[player]; ++star) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 139, iconX, iconY - 2); + iconX = iconX + 22; + } + for (int lord = 0; lord < DAT_GameSynchronyState::instance.finalResults.finalKilledLords[player]; ++lord) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 138, iconX, iconY - 5); + iconX = iconX + 22; + } + if (DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] != 0) { + // "(" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_close_005a2778, iconX + 8, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 665, iconX + 14, iconY - 5); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] % 12), + iconX + 28, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, FALSE, 0); + iconX = iconX + 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] / 12, iconX, iconY, + OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_open_005a2774, iconX, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, TRUE, 0); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_00ec082c::instance == 0 || DAT_00ec082c::instance == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + tables.kills[player], x + 279, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + tables.losses[player], x + 337, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGold[player], x + 395, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[player], x + 453, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[player], x + 511, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[player], x + 569, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalIronProduced[player], x + 627, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[player], x + 685, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[player], x + 743, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + } + if (DAT_00ec082c::instance == 1 || DAT_00ec082c::instance == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[player], columnOffset + 279 + x, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + DAT_GameSynchronyState::instance.finalResults.finalMaxGoodThings[player] * 6 + - DAT_GameSynchronyState::instance.finalResults.finalMaxBadThings[player] + 140, + columnOffset + 330 + x, y, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 176, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[player], columnOffset + 395 + x, + y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[player], + columnOffset + 453 + x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + if (DAT_00ec082c::instance == 1) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], + columnOffset + 511 + x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[player], + columnOffset + 569 + x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[player], columnOffset + 627 + x, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + } + } + if (DAT_00ec082c::instance == 3) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], x + 511, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[player], x + 569, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[player], x + 627, y, + OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + } + y = y + 45; + iconY = iconY + 45; + } + + if ((char)INT_00eb0e44::instance == '\0') { + if (DAT_00eb9af8::instance == 0 && DAT_GameSynchronyState::instance.finalResults.yearStart != 0) { + // fixme: the original writes the date into the (no longer needed) statistic orders + char* const dateText = (char*)tables.statOrder[0]; + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(dateText, s__s__d____s__d_005aaf3c, + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MONTHS, DAT_GameSynchronyState::instance.finalResults.monthStart), + DAT_GameSynchronyState::instance.finalResults.yearStart, + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MONTHS, DAT_GameSynchronyState::instance.finalResults.monthEnd), + DAT_GameSynchronyState::instance.finalResults.yearEnd); + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 545, + OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + dateText, DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 575, + OpenSHC::Text::TTA_CENTER, 0xccfaff, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 602, + OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + dateText, DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 632, + OpenSHC::Text::TTA_CENTER, 0xccfaff, 18, FALSE, 0); + } + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 560, + OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 617, + OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + } + } + DAT_00eb9af8::instance = DAT_FinalResultsOrderByColumn::instance; + if ((char)INT_00eb0e44::instance == '\0') { + return; + } + + // Extreme: show the score and the save file to submit it with + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(scoreText, s____d_005aaf2c, + MACRO_CALL(OpenSHC::UI::GreatestLord_Func::ComputeSkMasterScore)( + DAT_GameSynchronyState::instance.currentPlayerSlotID)); + MACRO_CALL(OpenSHC::OS_Func::_sprintf)( + saveText, s____M_d_d_sav_005aaf18, DAT_GameCore::instance.extremeTrailProgress + 1, DAT_00ed3118::instance); + int boxRight; + int boxLeft; + int boxTop; + int boxBottom; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + // "Extreme Score" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 27), + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + scoreText, DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, + OpenSHC::Text::TTA_LEFT, 0xccfaff, 18, TRUE, 0); + // "Save File" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 28), + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, TRUE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(saveText, + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, TRUE, 0); + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 + 50 + DAT_MenuHandlerState::instance.x; + // "To submit this score, visit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 29), + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 575, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, FALSE, 0); + // "www.fireflyworlds.com" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 30), + DAT_MenuHandlerState::instance.x + 56, DAT_MenuHandlerState::instance.y + 575, OpenSHC::Text::TTA_LEFT, + 0xffffff, 18, TRUE, 0); + if (boxRight < DAT_TextManagerObject::instance.currentXOffset_0x0 + 56 + DAT_MenuHandlerState::instance.x) { + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 + 56 + DAT_MenuHandlerState::instance.x; + } + boxLeft = DAT_MenuHandlerState::instance.x + 30; + boxTop = DAT_MenuHandlerState::instance.y + 546; + boxBottom = DAT_MenuHandlerState::instance.y + 595; + } else { + // "Extreme Score" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 27), + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + scoreText, DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, + OpenSHC::Text::TTA_LEFT, 0xccfaff, 18, TRUE, 0); + // "Save File" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 28), + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, TRUE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(saveText, + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, TRUE, 0); + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 - 42 + DAT_MenuHandlerState::instance.x; + // "To submit this score, visit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 29), + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 632, OpenSHC::Text::TTA_LEFT, + 0xccfaff, 18, FALSE, 0); + // "www.fireflyworlds.com" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 30), + DAT_MenuHandlerState::instance.x - 36, DAT_MenuHandlerState::instance.y + 632, OpenSHC::Text::TTA_LEFT, + 0xffffff, 18, TRUE, 0); + if (boxRight < DAT_TextManagerObject::instance.currentXOffset_0x0 - 36 + DAT_MenuHandlerState::instance.x) { + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 - 36 + DAT_MenuHandlerState::instance.x; + } + boxLeft = DAT_MenuHandlerState::instance.x - 62; + boxTop = DAT_MenuHandlerState::instance.y + 603; + boxBottom = DAT_MenuHandlerState::instance.y + 652; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + boxLeft, boxTop, boxRight + 20, boxBottom, COL_WHITE::instance.shortValue); + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 9f1d0a3d0f..249cae24bb 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35577,7 +35577,7 @@ SHC_3BB0A8C1_0x004D55D0 | 0.0% | Pending SHC_3BB0A8C1_0x004D5780 | 0.0% | Pending -SHC_3BB0A8C1_0x004D5810 | 0.0% | Pending +SHC_3BB0A8C1_0x004D5810 | 58.7% | Frame 8 bytes larger, reg alloc SHC_3BB0A8C1_0x004D5990 | 0.0% | Pending From 505bef45b9fcd7e9f6d5fb70c7a4492a6053750f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 16:28:28 +0100 Subject: [PATCH 20/78] reimplement: SHC_3BB0A8C1_0x004D76A0 58.20% Register assignment differs 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 --- .../Rendering/RenderMissionObjectivesUnk.cpp | 506 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 507 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp new file mode 100644 index 0000000000..2d0b55555b --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -0,0 +1,506 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Global.func.hpp" +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00eb0b24.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00ec02e8.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00eb1238.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed2630.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed2fc8.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed3070.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eGM; + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::Game::GameMode2; + using OpenSHC::IO::Graphics::GmID; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004D76A0 + int Rendering::RenderMissionObjectivesUnk() + { + int y = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 100; + int value = 0; + int boxX = 300; + int eventIndex = -1; + int column = 200; + int const headerX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30; + int const headerY = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 50; + DAT_TextManagerObject::instance.field9_0x24 = 1; + if (DAT_GameCore::instance.section1095 == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 26), + headerX, headerY, OpenSHC::Text::TTA_LEFT, 0xccfaff, 17, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 0), + headerX, headerY, OpenSHC::Text::TTA_LEFT, 0xccfaff, 17, FALSE, 0); + + // first pass: measure the texts for the number column and the tick boxes + for (int objective = 0; objective < 39; ++objective) { + if (INT_ARRAY_00ed2630::instance[objective] == 0) { + continue; + } + if ((objective == 18 || objective == 19) + && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + continue; + } + int textIndex = objective; + if (objective >= 20) { + textIndex = objective + 1; + } + if (textIndex == 17) { + textIndex = 6; + } else if (textIndex == 15) { + textIndex = 8; + } + int const textWidth + = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, textIndex), + 18); + int const textEnd = textWidth + 30; + if (textEnd > boxX - 5) { + boxX = textWidth + 35; + } + int numberWidth; + switch (objective) { + case 1: + case 4: + case 20: + case 21: + case 22: + case 23: + if (textEnd > column - 5) { + column = textWidth + 35; + } + numberWidth = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], 18); + if (DAT_GameCore::instance.gameSuspended == 1) { + numberWidth = numberWidth + + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, + DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); + switch (objective) { + case 1: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentPopulation; + break; + case 4: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[Game::Resources::RT_GOLD]; + break; + case 20: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .previousBlessedPeoplePercentage; + break; + case 21: + value = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::computeAleCoverage, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID); + break; + case 22: + value = -DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + case 23: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + } + numberWidth = numberWidth + + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(value, 18); + } + if (numberWidth + column > boxX - 5) { + boxX = numberWidth + column + 5; + } + break; + case 5: + case 6: + case 7: + case 17: + if (textEnd > column - 5) { + column = textWidth + 35; + } + numberWidth = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], 18); + if (INT_ARRAY_00eb1238::instance[objective] > 0) { + numberWidth = numberWidth + + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GOODS, INT_ARRAY_00eb1238::instance[objective]), + 18) + + 6; + } + if (DAT_GameCore::instance.gameSuspended == 1) { + numberWidth = numberWidth + + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, + DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); + int resource = INT_ARRAY_00eb1238::instance[objective]; + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; + } + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[resource]; + numberWidth = numberWidth + + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(value, 18); + } + if (numberWidth + column > boxX - 5) { + boxX = numberWidth + column + 5; + } + break; + } + } + + // second pass: draw them + for (int objective = 0; objective < 39; ++objective) { + if (INT_ARRAY_00ed2630::instance[objective] == 0) { + continue; + } + if ((objective == 18 || objective == 19) + && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + continue; + } + int textIndex = objective; + if (objective >= 20) { + textIndex = objective + 1; + } + if (textIndex == 17 || textIndex == 5 || textIndex == 6) { + textIndex = 7; + } else if (textIndex == 15) { + textIndex = 8; + } else if (textIndex == 3 && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + if (DAT_GameCore::instance.missionNumber1to20 == 13) { + textIndex = 12; + } else if (DAT_GameCore::instance.missionNumber1to20 == 18) { + textIndex = 13; + } else if (DAT_GameCore::instance.missionNumber1to20 == 21) { + textIndex = 14; + } + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, textIndex), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, + 18, FALSE, 0); + switch (objective) { + case 1: + case 4: + case 20: + case 21: + case 22: + case 23: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, + 0xc2f0eb, 18, FALSE, 0); + if (DAT_GameCore::instance.gameSuspended != 1) { + break; + } + // " (" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s___005aaf74, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, + OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + switch (objective) { + case 1: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentPopulation; + break; + case 4: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[Game::Resources::RT_GOLD]; + break; + case 20: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .previousBlessedPeoplePercentage; + break; + case 21: + value = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::computeAleCoverage, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID); + break; + case 22: + value = -DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + case 23: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(value, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, + 0xc2f0eb, 18, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s_brace_open_005a2774, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, + OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + break; + case 5: + case 6: + case 7: + case 17: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, + 0xc2f0eb, 18, FALSE, 0); + if (INT_ARRAY_00eb1238::instance[objective] > 0) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GOODS, INT_ARRAY_00eb1238::instance[objective]), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, + OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + } + if (DAT_GameCore::instance.gameSuspended != 1) { + break; + } + // " (" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s___005aaf74, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, + OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + { + int resource = INT_ARRAY_00eb1238::instance[objective]; + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; + } + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[resource]; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(value, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, OpenSHC::Text::TTA_LEFT, + 0xc2f0eb, 18, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s_brace_open_005a2774, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, OpenSHC::Text::TTA_LEFT, + 0xc2f0eb, 18, TRUE, 0); + break; + } + // tick box: done or not + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (INT_ARRAY_00ed3070::instance[objective] != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_BUTTONS, 6, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + boxX, y - 25); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_BUTTONS, 5, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + boxX, y); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + y = y + 30; + } + + // objective 39: a progress bar + if (INT_ARRAY_00ed2630::instance[39] != 0 && DAT_MapPropertiesState::instance.SEC_Section1081) { + int const total = DAT_MapPropertiesState::instance.SEC_Section1090; + int done = DAT_MapPropertiesState::instance.SEC_Section1090 + - DAT_MapPropertiesState::instance.SEC_Section1080; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 25), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, + 18, FALSE, 0); + int barX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 301; + if (DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40 + > barX) { + barX = DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 2, barX + 2, y + 1, 24); + if (done > total) { + done = total; + } + if (done != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRect, + DAT_TextureRenderCoreObject::ptr)( + 0, 0, done * 250 / total + barX + 2, DAT_WindowAndDirectDraw::instance.resolutionY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawTgxGmOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 4, barX + 2, y + 1); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRectToGameResolution, + DAT_TextureRenderCoreObject::ptr)(); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 1, barX, y - 1, + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 3, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + y = y + 21; + } + + // time until the next one-off invasion or the deadline of the mission, as a progress bar + int timerText = 15; + if (INT_ARRAY_00ed2630::instance[8] != 0 || INT_ARRAY_00ed2630::instance[15] != 0 + || INT_00ec02e8::instance) { + for (int i = 0; i < DAT_MapPropertiesState::instance.eventsCount; ++i) { + if (DAT_MapPropertiesState::instance.scenarioEvents[i].header.tl_type == 1 + && DAT_MapPropertiesState::instance.scenarioEvents[i].data.invasion.repeatMonths == 0) { + eventIndex = i; + } else if (DAT_MapPropertiesState::instance.scenarioEvents[i].header.tl_type == 3 + && DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.conditions[0].enabled + && (DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.ScenarioEventType == 1 + || DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.ScenarioEventType + == 27)) { + if (eventIndex == -1) { + eventIndex = i; + timerText = 17; + } + break; + } + } + if (eventIndex >= 0) { + int const start = DAT_MapPropertiesState::instance.SEC_StartingMonth + + DAT_MapPropertiesState::instance.SEC_StartingYear * 12; + int const total = DAT_MapPropertiesState::instance.scenarioEvents[eventIndex].header.month + + DAT_MapPropertiesState::instance.scenarioEvents[eventIndex].header.year * 12 - start; + int elapsed = DAT_GameState::instance.mapAndTime.year * 12 - start + + DAT_GameState::instance.mapAndTime.month; + if (!DAT_GameCore::instance.gameSuspended) { + elapsed = 0; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, timerText), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, + 0xc2f0eb, 18, FALSE, 0); + int barX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 301; + if (DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40 + > barX) { + barX = DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 2, barX + 2, y + 1, 24); + if (elapsed > total) { + elapsed = total; + } + if (elapsed != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRect, + DAT_TextureRenderCoreObject::ptr)( + 0, 0, elapsed * 250 / total + barX + 2, DAT_WindowAndDirectDraw::instance.resolutionY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawTgxGmOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 4, barX + 2, y + 1); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRectToGameResolution, + DAT_TextureRenderCoreObject::ptr)(); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 1, barX, + y - 1, OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 3, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + y = y + 21; + } + } + } + + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + return y; + } + // builder mode: the map name and its description, scrolled by pages + int const offset = y - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - 30; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)( + DAT_GameCore::instance.standaloneFilename, &eventIndex), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 400, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 10, OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, + 0); + // the visible height, rounded up to whole lines of 23 pixels + int pageHeight = 377 - offset; + pageHeight = pageHeight + 22 - (pageHeight + 22) % 23; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRange, + DAT_TextureRenderCoreObject::ptr)(DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + offset + 45, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + pageHeight + offset + 45); + if (!DAT_GameCore::instance.descriptionUseStringTable) { + INT_00ed27c4::instance = (MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + DAT_GameCore::instance.temporaryTextBufferOfSize1000, 0, 0, 720, 0, 0, 1) + - 1) + / pageHeight + + 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + DAT_GameCore::instance.temporaryTextBufferOfSize1000, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - DAT_00eb0b24::instance * pageHeight + offset + + 50, + 720, 0xc2f0eb, 18, 0); + } else if (DAT_GameCore::instance.descriptionStringTableIndex) { + INT_00ed27c4::instance + = (MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.descriptionStringTableIndex), + 0, 0, 720, 0, 0, 1) + - 1) + / pageHeight + + 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.descriptionStringTableIndex), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - DAT_00eb0b24::instance * pageHeight + offset + + 50, + 720, 0xc2f0eb, 18, 0); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRangeToResolution, + DAT_TextureRenderCoreObject::ptr)(); + return y; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 249cae24bb..013b4f394f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35841,7 +35841,7 @@ SHC_3BB0A8C1_0x004D6F60 | 0.0% | Pending SHC_3BB0A8C1_0x004D7200 | 0.0% | Pending -SHC_3BB0A8C1_0x004D76A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D76A0 | 58.2% | Register assignment differs SHC_3BB0A8C1_0x004D7730 | 0.0% | Pending From 41a16b637ca72190e1e2225718f10e12eff6aa87 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 16:34:52 +0100 Subject: [PATCH 21/78] reimplement: SHC_3BB0A8C1_0x00453600 89.40% Globals via statics in asm 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 --- src/OpenSHC/Rendering/ApplyBlending.cpp | 378 ++++++++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Rendering/ApplyBlending.cpp diff --git a/src/OpenSHC/Rendering/ApplyBlending.cpp b/src/OpenSHC/Rendering/ApplyBlending.cpp new file mode 100644 index 0000000000..01996dbe0d --- /dev/null +++ b/src/OpenSHC/Rendering/ApplyBlending.cpp @@ -0,0 +1,378 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/Rendering/ColorMode.hpp" + +#include "OpenSHC/Globals/DAT_00ed3154.hpp" +#include "OpenSHC/Globals/DAT_BlendFilterArrays.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" +#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { + +using Rendering::ColorMode; +using UI::Rendering::WindowAndDirectDraw; + +// Blends the tile being drawn into the map surface, pixel by pixel: every colour component of the tile and of the +// surface under it is looked up in DAT_BlendFilterArrays (scaled by (32 - blendLevel) / 32 and blendLevel / 32) and +// the two results are added. The offset tables say where each pixel of the diamond-shaped tile lands on the +// 4056-pixel-wide map surface; zoomed out, every other row and column is used. +// The pixel loops are handwritten assembly in the original, transcribed here from the binary. + +// Inline assembly cannot name a resolver global, so the loops reach the two globals they use through these. +static UI::Rendering::WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; +static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; + +// FUNCTION: STRONGHOLDCRUSADER 0x00453600 +void Rendering::ApplyBlending(int blendLevel) +{ + int* offsets; + short* destinationTable; + short* sourceTable; + ushort* source; + if (!DAT_TextureRenderCoreObject::instance.isZoom2) { + offsets = DAT_BlendingDefinedData::instance.field164_0x27fc; + int const drawY = DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance + DAT_RenderMap_DrawSomeY::instance; + if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start + || drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + return; + } + source = (ushort*)((char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData + + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]); + if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { + MACRO_CALL(UI::Rendering_Func::InitBlendFilterArraysUnk)(); + } + destinationTable = DAT_BlendFilterArrays::instance[blendLevel][0]; + sourceTable = DAT_BlendFilterArrays::instance[32 - blendLevel][0]; + if (DAT_WindowAndDirectDraw::instance.colorBitMode == Rendering::RGB_555) { + // clang-format off + __asm { + mov esi, source + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + add eax, eax + add edi, eax + mov eax, drawY + mov edx, 0x1fb0 + mul edx + add edi, eax + mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi + mov ecx, 0x100 +n555_4536c0: + mov ax, word ptr [esi] + mov edx, dword ptr sourceTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xfc1f + or ax, bx + mov bx, ax + shr bx, 0xa + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x3ff + or ax, bx + push ax + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov ax, word ptr [edi + edx] + mov edx, dword ptr destinationTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xfc1f + or ax, bx + mov bx, ax + shr bx, 0xa + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x83ff + or ax, bx + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov word ptr [edi + edx], ax + pop ax + add word ptr [edi + edx], ax + add esi, 2 + add dword ptr offsets, 4 + sub cx, 1 + jne n555_4536c0 + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, source + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + add eax, eax + add edi, eax + mov eax, drawY + mov edx, 0x1fb0 + mul edx + add edi, eax + mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi + mov ecx, 0x100 +n565_4537ae: + mov ax, word ptr [esi] + mov edx, dword ptr sourceTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x3f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xf81f + or ax, bx + mov bx, ax + shr bx, 0xb + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x7ff + or ax, bx + push ax + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov ax, word ptr [edi + edx] + mov edx, dword ptr destinationTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x3f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xf81f + or ax, bx + mov bx, ax + shr bx, 0xb + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x7ff + or ax, bx + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov word ptr [edi + edx], ax + pop ax + add word ptr [edi + edx], ax + add esi, 2 + add dword ptr offsets, 4 + sub cx, 1 + jne n565_4537ae + } + // clang-format on + return; + } + + offsets = DAT_BlendingDefinedData::instance.field166_0x2dfc; + int* evenRowOffsets = DAT_BlendingDefinedData::instance.field165_0x2bfc; + int const drawY = DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance + DAT_RenderMap_DrawSomeY::instance; + if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start + || drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + return; + } + source = (ushort*)((char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData + + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]); + if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { + MACRO_CALL(UI::Rendering_Func::InitBlendFilterArraysUnk)(); + } + destinationTable = DAT_BlendFilterArrays::instance[blendLevel][0]; + sourceTable = DAT_BlendFilterArrays::instance[32 - blendLevel][0]; + if (DAT_WindowAndDirectDraw::instance.colorBitMode == Rendering::RGB_555) { + // clang-format off + __asm { + mov esi, source + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + and eax, 0xfffffffe + add edi, eax + mov eax, drawY + mov ebx, eax + shr eax, 1 + mov edx, 0x1fb0 + mul edx + add edi, eax + mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi + and ebx, 1 + cmp ebx, 0 + jne z555_45391b + mov eax, dword ptr evenRowOffsets + mov dword ptr offsets, eax +z555_45391b: + mov ecx, 0x40 +z555_453920: + mov edx, dword ptr offsets + add dword ptr offsets, 4 + mov edx, dword ptr [edx] + mov ax, word ptr [esi + edx] + mov edx, dword ptr sourceTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xfc1f + or ax, bx + mov bx, ax + shr bx, 0xa + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x3ff + or ax, bx + push ax + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov ax, word ptr [edi + edx] + mov edx, dword ptr destinationTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xfc1f + or ax, bx + mov bx, ax + shr bx, 0xa + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x83ff + or ax, bx + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov word ptr [edi + edx], ax + pop ax + add word ptr [edi + edx], ax + add dword ptr offsets, 4 + sub cx, 1 + jne z555_453920 + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, source + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + and eax, 0xfffffffe + add edi, eax + mov eax, drawY + mov ebx, eax + shr eax, 1 + mov edx, 0x1fb0 + mul edx + add edi, eax + mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi + and ebx, 1 + cmp ebx, 0 + jne z565_453a23 + mov eax, dword ptr evenRowOffsets + mov dword ptr offsets, eax +z565_453a23: + mov ecx, 0x40 +z565_453a28: + mov edx, dword ptr offsets + add dword ptr offsets, 4 + mov edx, dword ptr [edx] + mov ax, word ptr [esi + edx] + mov edx, dword ptr sourceTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x3f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xf81f + or ax, bx + mov bx, ax + shr bx, 0xb + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x7ff + or ax, bx + push ax + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov ax, word ptr [edi + edx] + mov edx, dword ptr destinationTable + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov bx, word ptr [edx + ebx*8] + and ax, 0xffe0 + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 0x3f + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0xf81f + or ax, bx + mov bx, ax + shr bx, 0xb + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x7ff + or ax, bx + mov edx, dword ptr offsets + mov edx, dword ptr [edx] + mov word ptr [edi + edx], ax + pop ax + add word ptr [edi + edx], ax + add dword ptr offsets, 4 + sub cx, 1 + jne z565_453a28 + } + // clang-format on +} + +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 013b4f394f..77e9bf9022 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16967,7 +16967,7 @@ SHC_3BB0A8C1_0x00451E00 | 0.0% | Pending SHC_3BB0A8C1_0x00452900 | 0.0% | Pending -SHC_3BB0A8C1_0x00453600 | 0.0% | Pending +SHC_3BB0A8C1_0x00453600 | 89.4% | Globals via statics in asm SHC_3BB0A8C1_0x00453B00 | 0.0% | Pending From bb8e7cf3771efa3b23cb06a317d4bb1a0660f008 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 16:39:06 +0100 Subject: [PATCH 22/78] reimplement: SHC_3BB0A8C1_0x00453B00 92.60% Globals via statics in asm 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 --- .../BlitMapImageWithVerticalClip.cpp | 390 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 391 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp new file mode 100644 index 0000000000..1334f46966 --- /dev/null +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp @@ -0,0 +1,390 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Globals/DAT_00ed3154.hpp" +#include "OpenSHC/Globals/DAT_00ed316c.hpp" +#include "OpenSHC/Globals/DAT_00ed3170.hpp" +#include "OpenSHC/Globals/DAT_00ed317c.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" +#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { + +using UI::Rendering::WindowAndDirectDraw; + +// Copies a 30-pixel-wide map image column (tile objects are stored as 15 dwords per row) onto the map surface, +// clipped to the visible rows. An image taller than DAT_00ed3170 rows continues with a second image +// (DAT_00ed316c) once the first one runs out. DAT_00ed317c picks which half of the column is drawn (0 both, +// 1 right, 2 left, 3 only the middle column). Zoomed out, every other row and pixel is used. +// The copy loops are handwritten assembly in the original, transcribed here from the binary. + +// Inline assembly cannot name a resolver global, so the loops reach the globals they use through these. +static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; +static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; +static uint* const s_blitModeUnk = &DAT_00ed317c::instance; +static uint* const s_remainingRowsUnk = &DAT_00ed3170::instance; + +// FUNCTION: STRONGHOLDCRUSADER 0x00453B00 +void Rendering::BlitMapImageWithVerticalClip() +{ + char* image = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; + char* nextImage = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; + int drawY = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance) + 9; + int height = DAT_GMImageHeaders::instance.imh[DAT_GmImageAddressToBeRendered::instance].height - 7; + int skip = 0; + int nextSkip = 0; + if ((int)DAT_00ed3170::instance <= 0) { + return; + } + if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { + int const clippedRows = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - drawY; + nextSkip = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - height - drawY; + drawY = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; + DAT_00ed3170::instance = DAT_00ed3170::instance - clippedRows; + height = height - clippedRows; + skip = clippedRows * 60; + } + if ((int)(DAT_00ed3170::instance + drawY) >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + DAT_00ed3170::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; + // fixme: always adds 0, the original subtracts the already shortened row count + height = height + + (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - DAT_00ed3170::instance - drawY); + } + int firstRows; + if (height <= 0) { + firstRows = 0; + nextSkip = nextSkip * 60; + } else if (height < (int)DAT_00ed3170::instance) { + firstRows = height; + DAT_00ed3170::instance = DAT_00ed3170::instance - height; + nextSkip = 0; + } else { + firstRows = DAT_00ed3170::instance; + DAT_00ed3170::instance = 0; + } + image = image + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; + nextImage = nextImage + DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; + if (!DAT_TextureRenderCoreObject::instance.isZoom2) { + // clang-format off + __asm { + mov esi, image + mov eax, skip + add esi, eax + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + add eax, eax + add edi, eax + mov eax, drawY + mov edx, 0x1fb0 + mul edx + add edi, eax + mov edx, firstRows + cmp edx, 0 + jle nrm_453db7 +nrm_453c34: + mov eax, s_blitModeUnk + mov eax, dword ptr [eax] + cmp eax, 1 + je nrm_453ced + cmp eax, 2 + je nrm_453d45 + cmp eax, 3 + je nrm_453d9b +nrm_453c54: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 0x1fb4], ebx + mov dword ptr [edi + 0x3f68], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0x5f1c], eax + mov dword ptr [edi + 0x7ed0], ebx + mov dword ptr [edi + 0x9e84], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0xbe38], eax + mov dword ptr [edi + 0xddec], ebx + mov dword ptr [edi + 0xbe40], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x9e94], eax + mov dword ptr [edi + 0x7ee8], ebx + mov dword ptr [edi + 0x5f3c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x3f90], eax + mov dword ptr [edi + 0x1fe4], ebx + mov dword ptr [edi + 0x38], ecx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_453db7 + jmp nrm_453c54 +nrm_453ced: + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0xddec], ebx + mov dword ptr [edi + 0xbe40], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x9e94], eax + mov dword ptr [edi + 0x7ee8], ebx + mov dword ptr [edi + 0x5f3c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x3f90], eax + mov dword ptr [edi + 0x1fe4], ebx + mov dword ptr [edi + 0x38], ecx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_453db7 + jmp nrm_453ced +nrm_453d45: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 0x1fb4], ebx + mov dword ptr [edi + 0x3f68], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0x5f1c], eax + mov dword ptr [edi + 0x7ed0], ebx + mov dword ptr [edi + 0x9e84], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0xbe38], eax + mov dword ptr [edi + 0xddec], ebx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_453db7 + jmp nrm_453d45 +nrm_453d9b: + mov ebx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0xddec], ebx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_453db7 + jmp nrm_453d9b +nrm_453db7: + mov eax, s_remainingRowsUnk + cmp dword ptr [eax], 0 + jle nrm_453ddd + mov edx, dword ptr [eax] + mov dword ptr [eax], 0 + mov esi, dword ptr nextImage + mov eax, dword ptr nextSkip + add esi, eax + jmp nrm_453c34 +nrm_453ddd: + pop ebx + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, image + mov eax, skip + add esi, eax + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + and eax, 0xfffffffe + add edi, eax + mov eax, drawY + mov ecx, eax + shr eax, 1 + mov edx, 0x1fb0 + mul edx + add edi, eax + mov edx, firstRows + cmp edx, 0 + jle zm_454049 +zm_453e18: + mov eax, s_blitModeUnk + mov eax, dword ptr [eax] + cmp eax, 1 + je zm_453f0a + cmp eax, 2 + je zm_453f94 + cmp eax, 3 + je zm_454011 +zm_453e38: + mov eax, ecx + and eax, 1 + cmp eax, 0 + jne zm_453ea6 + mov ax, word ptr [esi] + mov bx, word ptr [esi + 8] + mov word ptr [edi], ax + mov word ptr [edi + 0x1fb4], bx + mov ax, word ptr [esi + 0x10] + mov bx, word ptr [esi + 0x18] + mov word ptr [edi + 0x3f68], ax + mov word ptr [edi + 0x5f1c], bx + mov ax, word ptr [esi + 0x20] + mov bx, word ptr [esi + 0x28] + mov word ptr [edi + 0x5f20], ax + mov word ptr [edi + 0x3f74], bx + mov ax, word ptr [esi + 0x30] + mov bx, word ptr [esi + 0x38] + mov word ptr [edi + 0x1fc8], ax + mov word ptr [edi + 0x1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_453e38 +zm_453ea6: + add edi, 0x1fb0 + mov ax, word ptr [esi + 4] + mov bx, word ptr [esi + 0xc] + mov word ptr [edi + 2], ax + mov word ptr [edi + 0x1fb6], bx + mov ax, word ptr [esi + 0x14] + mov bx, word ptr [esi + 0x1c] + mov word ptr [edi + 0x3f6a], ax + mov word ptr [edi + 0x5f1e], bx + mov ax, word ptr [esi + 0x24] + mov bx, word ptr [esi + 0x2c] + mov word ptr [edi + 0x3f72], ax + mov word ptr [edi + 0x1fc6], bx + mov ax, word ptr [esi + 0x34] + mov word ptr [edi + 0x1a], ax + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_453e38 +zm_453f0a: + mov eax, ecx + and eax, 1 + jne zm_453f4e + mov ax, word ptr [esi + 0x20] + mov bx, word ptr [esi + 0x28] + mov word ptr [edi + 0x5f20], ax + mov word ptr [edi + 0x3f74], bx + mov ax, word ptr [esi + 0x30] + mov bx, word ptr [esi + 0x38] + mov word ptr [edi + 0x1fc8], ax + mov word ptr [edi + 0x1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_453f0a +zm_453f4e: + add edi, 0x1fb0 + mov ax, word ptr [esi + 0x1c] + mov bx, word ptr [esi + 0x24] + mov word ptr [edi + 0x5f1e], ax + mov word ptr [edi + 0x3f72], bx + mov ax, word ptr [esi + 0x2c] + mov bx, word ptr [esi + 0x34] + mov word ptr [edi + 0x1fc6], ax + mov word ptr [edi + 0x1a], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_453f0a +zm_453f94: + mov eax, ecx + and eax, 1 + jne zm_453fd2 + mov ax, word ptr [esi] + mov bx, word ptr [esi + 8] + mov word ptr [edi], ax + mov word ptr [edi + 0x1fb4], bx + mov ax, word ptr [esi + 0x10] + mov bx, word ptr [esi + 0x18] + mov word ptr [edi + 0x3f68], ax + mov word ptr [edi + 0x5f1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_453f94 +zm_453fd2: + add edi, 0x1fb0 + mov ax, word ptr [esi + 4] + mov bx, word ptr [esi + 0xc] + mov word ptr [edi + 2], ax + mov word ptr [edi + 0x1fb6], bx + mov ax, word ptr [esi + 0x14] + mov bx, word ptr [esi + 0x1c] + mov word ptr [edi + 0x3f6a], ax + mov word ptr [edi + 0x5f1e], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_453f94 +zm_454011: + mov eax, ecx + and eax, 1 + jne zm_454028 + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_454011 +zm_454028: + add edi, 0x1fb0 + mov ax, word ptr [esi + 0x1c] + mov word ptr [edi + 0x5f1e], ax + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_454049 + jmp zm_454011 +zm_454049: + mov eax, s_remainingRowsUnk + cmp dword ptr [eax], 0 + jle zm_45406f + mov edx, dword ptr [eax] + mov dword ptr [eax], 0 + mov esi, dword ptr nextImage + mov eax, dword ptr nextSkip + add esi, eax + jmp zm_453e18 +zm_45406f: + pop ebx + } + // clang-format on +} + +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 77e9bf9022..35be1b95e3 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16969,7 +16969,7 @@ SHC_3BB0A8C1_0x00452900 | 0.0% | Pending SHC_3BB0A8C1_0x00453600 | 89.4% | Globals via statics in asm -SHC_3BB0A8C1_0x00453B00 | 0.0% | Pending +SHC_3BB0A8C1_0x00453B00 | 92.6% | Globals via statics in asm SHC_3BB0A8C1_0x00454080 | 0.0% | Pending From a47164989af2ad8b0d4afa148fbf89323a42a8c2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 16:41:57 +0100 Subject: [PATCH 23/78] reimplement: SHC_3BB0A8C1_0x00454080 79.70% Prologue registers rotated 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 --- ...BlitMapImageWithVerticalClipAndYOffset.cpp | 392 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 393 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp new file mode 100644 index 0000000000..d1979b7bff --- /dev/null +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp @@ -0,0 +1,392 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Globals/DAT_00ed3154.hpp" +#include "OpenSHC/Globals/DAT_00ed316c.hpp" +#include "OpenSHC/Globals/DAT_00ed3170.hpp" +#include "OpenSHC/Globals/DAT_00ed317c.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" +#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { + +using UI::Rendering::WindowAndDirectDraw; + +// Like BlitMapImageWithVerticalClip, but the second image (DAT_00ed316c) starts 160 - DAT_RenderMap_YOffset rows in. +// The copy loops are handwritten assembly in the original, transcribed here from the binary. + +// Inline assembly cannot name a resolver global, so the loops reach the globals they use through these. +static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; +static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; +static uint* const s_blitModeUnk = &DAT_00ed317c::instance; +static uint* const s_remainingRowsUnk = &DAT_00ed3170::instance; + +// FUNCTION: STRONGHOLDCRUSADER 0x00454080 +void Rendering::BlitMapImageWithVerticalClipAndYOffset() +{ + char* image = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; + char* nextImage = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; + int drawY = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance) + 9; + int height = DAT_GMImageHeaders::instance.imh[DAT_GmImageAddressToBeRendered::instance].height - 7; + int skip = 0; + int nextSkip = 160 - DAT_RenderMap_YOffset::instance; + if ((int)DAT_00ed3170::instance <= 0) { + return; + } + if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { + skip = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - drawY; + DAT_00ed3170::instance = DAT_00ed3170::instance - skip; + drawY = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; + nextSkip = nextSkip + skip; + height = height - skip; + } + if ((int)(DAT_00ed3170::instance + drawY) >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + DAT_00ed3170::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; + // fixme: always adds 0, the original subtracts the already shortened row count + height = height + + (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - DAT_00ed3170::instance - drawY); + } + // rows to bytes: tile objects are 15 dwords per row + skip = skip * 60; + nextSkip = nextSkip * 60; + int firstRows; + if (height <= 0) { + firstRows = 0; + } else if (height < (int)DAT_00ed3170::instance) { + DAT_00ed3170::instance = DAT_00ed3170::instance - height; + firstRows = height; + nextSkip = nextSkip + height * 60; + } else { + firstRows = DAT_00ed3170::instance; + DAT_00ed3170::instance = 0; + skip = nextSkip; + } + if (DAT_00ed317c::instance == 3) { + skip = skip - 480; + } + image = image + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; + nextImage = nextImage + DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; + if (!DAT_TextureRenderCoreObject::instance.isZoom2) { + // clang-format off + __asm { + mov esi, image + mov eax, skip + add esi, eax + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + add eax, eax + add edi, eax + mov eax, drawY + mov edx, 0x1fb0 + mul edx + add edi, eax + mov edx, firstRows + cmp edx, 0 + jle nrm_454359 +nrm_4541d6: + mov eax, s_blitModeUnk + mov eax, dword ptr [eax] + cmp eax, 1 + je nrm_45428f + cmp eax, 2 + je nrm_4542e7 + cmp eax, 3 + je nrm_45433d +nrm_4541f6: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 0x1fb4], ebx + mov dword ptr [edi + 0x3f68], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0x5f1c], eax + mov dword ptr [edi + 0x7ed0], ebx + mov dword ptr [edi + 0x9e84], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0xbe38], eax + mov dword ptr [edi + 0xddec], ebx + mov dword ptr [edi + 0xbe40], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x9e94], eax + mov dword ptr [edi + 0x7ee8], ebx + mov dword ptr [edi + 0x5f3c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x3f90], eax + mov dword ptr [edi + 0x1fe4], ebx + mov dword ptr [edi + 0x38], ecx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_454359 + jmp nrm_4541f6 +nrm_45428f: + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0xddec], ebx + mov dword ptr [edi + 0xbe40], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x9e94], eax + mov dword ptr [edi + 0x7ee8], ebx + mov dword ptr [edi + 0x5f3c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x3f90], eax + mov dword ptr [edi + 0x1fe4], ebx + mov dword ptr [edi + 0x38], ecx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_454359 + jmp nrm_45428f +nrm_4542e7: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 0x1fb4], ebx + mov dword ptr [edi + 0x3f68], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0x5f1c], eax + mov dword ptr [edi + 0x7ed0], ebx + mov dword ptr [edi + 0x9e84], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0xbe38], eax + mov dword ptr [edi + 0xddec], ebx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_454359 + jmp nrm_4542e7 +nrm_45433d: + mov ebx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0xddec], ebx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle nrm_454359 + jmp nrm_45433d +nrm_454359: + mov eax, s_remainingRowsUnk + cmp dword ptr [eax], 0 + jle nrm_45437f + mov edx, dword ptr [eax] + mov dword ptr [eax], 0 + mov esi, dword ptr nextImage + mov eax, dword ptr nextSkip + add esi, eax + jmp nrm_4541d6 +nrm_45437f: + pop ebx + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, image + mov eax, skip + add esi, eax + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + and eax, 0xfffffffe + add edi, eax + mov eax, drawY + mov ecx, eax + shr eax, 1 + mov edx, 0x1fb0 + mul edx + add edi, eax + mov edx, firstRows + cmp edx, 0 + jle zm_4545eb +zm_4543ba: + mov eax, s_blitModeUnk + mov eax, dword ptr [eax] + cmp eax, 1 + je zm_4544ac + cmp eax, 2 + je zm_454536 + cmp eax, 3 + je zm_4545b3 +zm_4543da: + mov eax, ecx + and eax, 1 + cmp eax, 0 + jne zm_454448 + mov ax, word ptr [esi] + mov bx, word ptr [esi + 8] + mov word ptr [edi], ax + mov word ptr [edi + 0x1fb4], bx + mov ax, word ptr [esi + 0x10] + mov bx, word ptr [esi + 0x18] + mov word ptr [edi + 0x3f68], ax + mov word ptr [edi + 0x5f1c], bx + mov ax, word ptr [esi + 0x20] + mov bx, word ptr [esi + 0x28] + mov word ptr [edi + 0x5f20], ax + mov word ptr [edi + 0x3f74], bx + mov ax, word ptr [esi + 0x30] + mov bx, word ptr [esi + 0x38] + mov word ptr [edi + 0x1fc8], ax + mov word ptr [edi + 0x1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_4543da +zm_454448: + add edi, 0x1fb0 + mov ax, word ptr [esi + 4] + mov bx, word ptr [esi + 0xc] + mov word ptr [edi + 2], ax + mov word ptr [edi + 0x1fb6], bx + mov ax, word ptr [esi + 0x14] + mov bx, word ptr [esi + 0x1c] + mov word ptr [edi + 0x3f6a], ax + mov word ptr [edi + 0x5f1e], bx + mov ax, word ptr [esi + 0x24] + mov bx, word ptr [esi + 0x2c] + mov word ptr [edi + 0x3f72], ax + mov word ptr [edi + 0x1fc6], bx + mov ax, word ptr [esi + 0x34] + mov word ptr [edi + 0x1a], ax + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_4543da +zm_4544ac: + mov eax, ecx + and eax, 1 + jne zm_4544f0 + mov ax, word ptr [esi + 0x20] + mov bx, word ptr [esi + 0x28] + mov word ptr [edi + 0x5f20], ax + mov word ptr [edi + 0x3f74], bx + mov ax, word ptr [esi + 0x30] + mov bx, word ptr [esi + 0x38] + mov word ptr [edi + 0x1fc8], ax + mov word ptr [edi + 0x1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_4544ac +zm_4544f0: + add edi, 0x1fb0 + mov ax, word ptr [esi + 0x1c] + mov bx, word ptr [esi + 0x24] + mov word ptr [edi + 0x5f1e], ax + mov word ptr [edi + 0x3f72], bx + mov ax, word ptr [esi + 0x2c] + mov bx, word ptr [esi + 0x34] + mov word ptr [edi + 0x1fc6], ax + mov word ptr [edi + 0x1a], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_4544ac +zm_454536: + mov eax, ecx + and eax, 1 + jne zm_454574 + mov ax, word ptr [esi] + mov bx, word ptr [esi + 8] + mov word ptr [edi], ax + mov word ptr [edi + 0x1fb4], bx + mov ax, word ptr [esi + 0x10] + mov bx, word ptr [esi + 0x18] + mov word ptr [edi + 0x3f68], ax + mov word ptr [edi + 0x5f1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_454536 +zm_454574: + add edi, 0x1fb0 + mov ax, word ptr [esi + 4] + mov bx, word ptr [esi + 0xc] + mov word ptr [edi + 2], ax + mov word ptr [edi + 0x1fb6], bx + mov ax, word ptr [esi + 0x14] + mov bx, word ptr [esi + 0x1c] + mov word ptr [edi + 0x3f6a], ax + mov word ptr [edi + 0x5f1e], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_454536 +zm_4545b3: + mov eax, ecx + and eax, 1 + jne zm_4545ca + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_4545b3 +zm_4545ca: + add edi, 0x1fb0 + mov ax, word ptr [esi + 0x1c] + mov word ptr [edi + 0x5f1e], ax + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zm_4545eb + jmp zm_4545b3 +zm_4545eb: + mov eax, s_remainingRowsUnk + cmp dword ptr [eax], 0 + jle zm_454611 + mov edx, dword ptr [eax] + mov dword ptr [eax], 0 + mov esi, dword ptr nextImage + mov eax, dword ptr nextSkip + add esi, eax + jmp zm_4543ba +zm_454611: + pop ebx + } + // clang-format on +} + +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 35be1b95e3..8012921ec1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16971,7 +16971,7 @@ SHC_3BB0A8C1_0x00453600 | 89.4% | Globals via statics in asm SHC_3BB0A8C1_0x00453B00 | 92.6% | Globals via statics in asm -SHC_3BB0A8C1_0x00454080 | 0.0% | Pending +SHC_3BB0A8C1_0x00454080 | 79.7% | Prologue registers rotated SHC_3BB0A8C1_0x00454620 | 0.0% | Pending From 7934c017a0403da269a4dd6885bfc03e6ff8be5e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 16:43:39 +0100 Subject: [PATCH 24/78] reimplement: SHC_3BB0A8C1_0x00452900 98.10% Globals via statics in asm 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 --- .../RenderTerrainTilesCenterPiece.cpp | 594 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 595 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp b/src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp new file mode 100644 index 0000000000..a38d07a5fd --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp @@ -0,0 +1,594 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Globals/DAT_00ed3154.hpp" +#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" +#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + + using UI::Rendering::WindowAndDirectDraw; + + // Copies the 32x16 centre piece of a terrain tile (stored as 0x200 bytes of RGB words, row by row) onto the map + // surface, or every other pixel of it when zoomed out. The copies are handwritten assembly in the original, + // transcribed here from the binary. + + // Inline assembly cannot name a resolver global, so the copies reach the globals they use through these. + static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; + static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; + + // FUNCTION: STRONGHOLDCRUSADER 0x00452900 + void Rendering::RenderTerrainTilesCenterPiece() + { + int const drawY + = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance); + if (drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end + || drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { + return; + } + char* const source = DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance] + + (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; + if (!DAT_TextureRenderCoreObject::instance.isZoom2) { + // clang-format off + __asm { + mov esi, source + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + add eax, eax + add edi, eax + mov eax, drawY + mov edx, 0x1fb0 + mul edx + add edi, eax + mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov edx, dword ptr [esi + 0xc] + mov dword ptr [edi + 0x1c], eax + mov dword ptr [edi + 0x1fc8], ebx + mov dword ptr [edi + 0x1fcc], ecx + mov dword ptr [edi + 0x1fd0], edx + mov eax, dword ptr [esi + 0x10] + mov ebx, dword ptr [esi + 0x14] + mov ecx, dword ptr [esi + 0x18] + mov edx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0x3f74], eax + mov dword ptr [edi + 0x3f78], ebx + mov dword ptr [edi + 0x3f7c], ecx + mov dword ptr [edi + 0x3f80], edx + mov eax, dword ptr [esi + 0x20] + mov ebx, dword ptr [esi + 0x24] + mov ecx, dword ptr [esi + 0x28] + mov edx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x3f84], eax + mov dword ptr [edi + 0x5f20], ebx + mov dword ptr [edi + 0x5f24], ecx + mov dword ptr [edi + 0x5f28], edx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov edx, dword ptr [esi + 0x3c] + mov dword ptr [edi + 0x5f2c], eax + mov dword ptr [edi + 0x5f30], ebx + mov dword ptr [edi + 0x5f34], ecx + mov dword ptr [edi + 0x5f38], edx + mov eax, dword ptr [esi + 0x40] + mov ebx, dword ptr [esi + 0x44] + mov ecx, dword ptr [esi + 0x48] + mov edx, dword ptr [esi + 0x4c] + mov dword ptr [edi + 0x7ecc], eax + mov dword ptr [edi + 0x7ed0], ebx + mov dword ptr [edi + 0x7ed4], ecx + mov dword ptr [edi + 0x7ed8], edx + mov eax, dword ptr [esi + 0x50] + mov ebx, dword ptr [esi + 0x54] + mov ecx, dword ptr [esi + 0x58] + mov edx, dword ptr [esi + 0x5c] + mov dword ptr [edi + 0x7edc], eax + mov dword ptr [edi + 0x7ee0], ebx + mov dword ptr [edi + 0x7ee4], ecx + mov dword ptr [edi + 0x7ee8], edx + mov eax, dword ptr [esi + 0x60] + mov ebx, dword ptr [esi + 0x64] + mov ecx, dword ptr [esi + 0x68] + mov edx, dword ptr [esi + 0x6c] + mov dword ptr [edi + 0x7eec], eax + mov dword ptr [edi + 0x9e78], ebx + mov dword ptr [edi + 0x9e7c], ecx + mov dword ptr [edi + 0x9e80], edx + mov eax, dword ptr [esi + 0x70] + mov ebx, dword ptr [esi + 0x74] + mov ecx, dword ptr [esi + 0x78] + mov edx, dword ptr [esi + 0x7c] + mov dword ptr [edi + 0x9e84], eax + mov dword ptr [edi + 0x9e88], ebx + mov dword ptr [edi + 0x9e8c], ecx + mov dword ptr [edi + 0x9e90], edx + mov eax, dword ptr [esi + 0x80] + mov ebx, dword ptr [esi + 0x84] + mov ecx, dword ptr [esi + 0x88] + mov edx, dword ptr [esi + 0x8c] + mov dword ptr [edi + 0x9e94], eax + mov dword ptr [edi + 0x9e98], ebx + mov dword ptr [edi + 0x9e9c], ecx + mov dword ptr [edi + 0x9ea0], edx + mov eax, dword ptr [esi + 0x90] + mov ebx, dword ptr [esi + 0x94] + mov ecx, dword ptr [esi + 0x98] + mov edx, dword ptr [esi + 0x9c] + mov dword ptr [edi + 0xbe24], eax + mov dword ptr [edi + 0xbe28], ebx + mov dword ptr [edi + 0xbe2c], ecx + mov dword ptr [edi + 0xbe30], edx + mov eax, dword ptr [esi + 0xa0] + mov ebx, dword ptr [esi + 0xa4] + mov ecx, dword ptr [esi + 0xa8] + mov edx, dword ptr [esi + 0xac] + mov dword ptr [edi + 0xbe34], eax + mov dword ptr [edi + 0xbe38], ebx + mov dword ptr [edi + 0xbe3c], ecx + mov dword ptr [edi + 0xbe40], edx + mov eax, dword ptr [esi + 0xb0] + mov ebx, dword ptr [esi + 0xb4] + mov ecx, dword ptr [esi + 0xb8] + mov edx, dword ptr [esi + 0xbc] + mov dword ptr [edi + 0xbe44], eax + mov dword ptr [edi + 0xbe48], ebx + mov dword ptr [edi + 0xbe4c], ecx + mov dword ptr [edi + 0xbe50], edx + mov eax, dword ptr [esi + 0xc0] + mov ebx, dword ptr [esi + 0xc4] + mov ecx, dword ptr [esi + 0xc8] + mov edx, dword ptr [esi + 0xcc] + mov dword ptr [edi + 0xbe54], eax + mov dword ptr [edi + 0xddd0], ebx + mov dword ptr [edi + 0xddd4], ecx + mov dword ptr [edi + 0xddd8], edx + mov eax, dword ptr [esi + 0xd0] + mov ebx, dword ptr [esi + 0xd4] + mov ecx, dword ptr [esi + 0xd8] + mov edx, dword ptr [esi + 0xdc] + mov dword ptr [edi + 0xdddc], eax + mov dword ptr [edi + 0xdde0], ebx + mov dword ptr [edi + 0xdde4], ecx + mov dword ptr [edi + 0xdde8], edx + mov eax, dword ptr [esi + 0xe0] + mov ebx, dword ptr [esi + 0xe4] + mov ecx, dword ptr [esi + 0xe8] + mov edx, dword ptr [esi + 0xec] + mov dword ptr [edi + 0xddec], eax + mov dword ptr [edi + 0xddf0], ebx + mov dword ptr [edi + 0xddf4], ecx + mov dword ptr [edi + 0xddf8], edx + mov eax, dword ptr [esi + 0xf0] + mov ebx, dword ptr [esi + 0xf4] + mov ecx, dword ptr [esi + 0xf8] + mov edx, dword ptr [esi + 0xfc] + mov dword ptr [edi + 0xddfc], eax + mov dword ptr [edi + 0xde00], ebx + mov dword ptr [edi + 0xde04], ecx + mov dword ptr [edi + 0xde08], edx + mov eax, dword ptr [esi + 0x100] + mov ebx, dword ptr [esi + 0x104] + mov ecx, dword ptr [esi + 0x108] + mov edx, dword ptr [esi + 0x10c] + mov dword ptr [edi + 0xfd80], eax + mov dword ptr [edi + 0xfd84], ebx + mov dword ptr [edi + 0xfd88], ecx + mov dword ptr [edi + 0xfd8c], edx + mov eax, dword ptr [esi + 0x110] + mov ebx, dword ptr [esi + 0x114] + mov ecx, dword ptr [esi + 0x118] + mov edx, dword ptr [esi + 0x11c] + mov dword ptr [edi + 0xfd90], eax + mov dword ptr [edi + 0xfd94], ebx + mov dword ptr [edi + 0xfd98], ecx + mov dword ptr [edi + 0xfd9c], edx + mov eax, dword ptr [esi + 0x120] + mov ebx, dword ptr [esi + 0x124] + mov ecx, dword ptr [esi + 0x128] + mov edx, dword ptr [esi + 0x12c] + mov dword ptr [edi + 0xfda0], eax + mov dword ptr [edi + 0xfda4], ebx + mov dword ptr [edi + 0xfda8], ecx + mov dword ptr [edi + 0xfdac], edx + mov eax, dword ptr [esi + 0x130] + mov ebx, dword ptr [esi + 0x134] + mov ecx, dword ptr [esi + 0x138] + mov edx, dword ptr [esi + 0x13c] + mov dword ptr [edi + 0xfdb0], eax + mov dword ptr [edi + 0xfdb4], ebx + mov dword ptr [edi + 0xfdb8], ecx + mov dword ptr [edi + 0x11d34], edx + mov eax, dword ptr [esi + 0x140] + mov ebx, dword ptr [esi + 0x144] + mov ecx, dword ptr [esi + 0x148] + mov edx, dword ptr [esi + 0x14c] + mov dword ptr [edi + 0x11d38], eax + mov dword ptr [edi + 0x11d3c], ebx + mov dword ptr [edi + 0x11d40], ecx + mov dword ptr [edi + 0x11d44], edx + mov eax, dword ptr [esi + 0x150] + mov ebx, dword ptr [esi + 0x154] + mov ecx, dword ptr [esi + 0x158] + mov edx, dword ptr [esi + 0x15c] + mov dword ptr [edi + 0x11d48], eax + mov dword ptr [edi + 0x11d4c], ebx + mov dword ptr [edi + 0x11d50], ecx + mov dword ptr [edi + 0x11d54], edx + mov eax, dword ptr [esi + 0x160] + mov ebx, dword ptr [esi + 0x164] + mov ecx, dword ptr [esi + 0x168] + mov edx, dword ptr [esi + 0x16c] + mov dword ptr [edi + 0x11d58], eax + mov dword ptr [edi + 0x11d5c], ebx + mov dword ptr [edi + 0x11d60], ecx + mov dword ptr [edi + 0x11d64], edx + mov eax, dword ptr [esi + 0x170] + mov ebx, dword ptr [esi + 0x174] + mov ecx, dword ptr [esi + 0x178] + mov edx, dword ptr [esi + 0x17c] + mov dword ptr [edi + 0x13ce8], eax + mov dword ptr [edi + 0x13cec], ebx + mov dword ptr [edi + 0x13cf0], ecx + mov dword ptr [edi + 0x13cf4], edx + mov eax, dword ptr [esi + 0x180] + mov ebx, dword ptr [esi + 0x184] + mov ecx, dword ptr [esi + 0x188] + mov edx, dword ptr [esi + 0x18c] + mov dword ptr [edi + 0x13cf8], eax + mov dword ptr [edi + 0x13cfc], ebx + mov dword ptr [edi + 0x13d00], ecx + mov dword ptr [edi + 0x13d04], edx + mov eax, dword ptr [esi + 0x190] + mov ebx, dword ptr [esi + 0x194] + mov ecx, dword ptr [esi + 0x198] + mov edx, dword ptr [esi + 0x19c] + mov dword ptr [edi + 0x13d08], eax + mov dword ptr [edi + 0x13d0c], ebx + mov dword ptr [edi + 0x13d10], ecx + mov dword ptr [edi + 0x15c9c], edx + mov eax, dword ptr [esi + 0x1a0] + mov ebx, dword ptr [esi + 0x1a4] + mov ecx, dword ptr [esi + 0x1a8] + mov edx, dword ptr [esi + 0x1ac] + mov dword ptr [edi + 0x15ca0], eax + mov dword ptr [edi + 0x15ca4], ebx + mov dword ptr [edi + 0x15ca8], ecx + mov dword ptr [edi + 0x15cac], edx + mov eax, dword ptr [esi + 0x1b0] + mov ebx, dword ptr [esi + 0x1b4] + mov ecx, dword ptr [esi + 0x1b8] + mov edx, dword ptr [esi + 0x1bc] + mov dword ptr [edi + 0x15cb0], eax + mov dword ptr [edi + 0x15cb4], ebx + mov dword ptr [edi + 0x15cb8], ecx + mov dword ptr [edi + 0x15cbc], edx + mov eax, dword ptr [esi + 0x1c0] + mov ebx, dword ptr [esi + 0x1c4] + mov ecx, dword ptr [esi + 0x1c8] + mov edx, dword ptr [esi + 0x1cc] + mov dword ptr [edi + 0x17c50], eax + mov dword ptr [edi + 0x17c54], ebx + mov dword ptr [edi + 0x17c58], ecx + mov dword ptr [edi + 0x17c5c], edx + mov eax, dword ptr [esi + 0x1d0] + mov ebx, dword ptr [esi + 0x1d4] + mov ecx, dword ptr [esi + 0x1d8] + mov edx, dword ptr [esi + 0x1dc] + mov dword ptr [edi + 0x17c60], eax + mov dword ptr [edi + 0x17c64], ebx + mov dword ptr [edi + 0x17c68], ecx + mov dword ptr [edi + 0x19c04], edx + mov eax, dword ptr [esi + 0x1e0] + mov ebx, dword ptr [esi + 0x1e4] + mov ecx, dword ptr [esi + 0x1e8] + mov edx, dword ptr [esi + 0x1ec] + mov dword ptr [edi + 0x19c08], eax + mov dword ptr [edi + 0x19c0c], ebx + mov dword ptr [edi + 0x19c10], ecx + mov dword ptr [edi + 0x19c14], edx + mov eax, dword ptr [esi + 0x1f0] + mov ebx, dword ptr [esi + 0x1f4] + mov ecx, dword ptr [esi + 0x1f8] + mov edx, dword ptr [esi + 0x1fc] + mov dword ptr [edi + 0x1bbb8], eax + mov dword ptr [edi + 0x1bbbc], ebx + mov dword ptr [edi + 0x1bbc0], ecx + mov dword ptr [edi + 0x1db6c], edx + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, source + mov ecx, s_windowAndDirectDraw + mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame + mov eax, s_drawSomeX + mov eax, dword ptr [eax] + and eax, 0xfffffffe + add edi, eax + mov eax, drawY + mov ebx, eax + shr eax, 1 + mov edx, 0x1fb0 + mul edx + add edi, eax + mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi + and ebx, 1 + cmp ebx, 0 + jne zm_4532a7 + mov ax, word ptr [esi] + mov word ptr [edi + 0xe], ax + mov ax, word ptr [esi + 0x10] + mov bx, word ptr [esi + 0x14] + mov cx, word ptr [esi + 0x18] + mov dx, word ptr [esi + 0x1c] + mov word ptr [edi + 0x1fba], ax + mov word ptr [edi + 0x1fbc], bx + mov word ptr [edi + 0x1fbe], cx + mov word ptr [edi + 0x1fc0], dx + mov ax, word ptr [esi + 0x20] + mov word ptr [edi + 0x1fc2], ax + mov ax, word ptr [esi + 0x40] + mov bx, word ptr [esi + 0x44] + mov cx, word ptr [esi + 0x48] + mov dx, word ptr [esi + 0x4c] + mov word ptr [edi + 0x3f66], ax + mov word ptr [edi + 0x3f68], bx + mov word ptr [edi + 0x3f6a], cx + mov word ptr [edi + 0x3f6c], dx + mov ax, word ptr [esi + 0x50] + mov bx, word ptr [esi + 0x54] + mov cx, word ptr [esi + 0x58] + mov dx, word ptr [esi + 0x5c] + mov word ptr [edi + 0x3f6e], ax + mov word ptr [edi + 0x3f70], bx + mov word ptr [edi + 0x3f72], cx + mov word ptr [edi + 0x3f74], dx + mov ax, word ptr [esi + 0x60] + mov word ptr [edi + 0x3f76], ax + mov ax, word ptr [esi + 0x90] + mov bx, word ptr [esi + 0x94] + mov cx, word ptr [esi + 0x98] + mov dx, word ptr [esi + 0x9c] + mov word ptr [edi + 0x5f12], ax + mov word ptr [edi + 0x5f14], bx + mov word ptr [edi + 0x5f16], cx + mov word ptr [edi + 0x5f18], dx + mov ax, word ptr [esi + 0xa0] + mov bx, word ptr [esi + 0xa4] + mov cx, word ptr [esi + 0xa8] + mov dx, word ptr [esi + 0xac] + mov word ptr [edi + 0x5f1a], ax + mov word ptr [edi + 0x5f1c], bx + mov word ptr [edi + 0x5f1e], cx + mov word ptr [edi + 0x5f20], dx + mov ax, word ptr [esi + 0xb0] + mov bx, word ptr [esi + 0xb4] + mov cx, word ptr [esi + 0xb8] + mov dx, word ptr [esi + 0xbc] + mov word ptr [edi + 0x5f22], ax + mov word ptr [edi + 0x5f24], bx + mov word ptr [edi + 0x5f26], cx + mov word ptr [edi + 0x5f28], dx + mov ax, word ptr [esi + 0xc0] + mov word ptr [edi + 0x5f2a], ax + mov ax, word ptr [esi + 0x100] + mov bx, word ptr [esi + 0x104] + mov cx, word ptr [esi + 0x108] + mov dx, word ptr [esi + 0x10c] + mov word ptr [edi + 0x7ec0], ax + mov word ptr [edi + 0x7ec2], bx + mov word ptr [edi + 0x7ec4], cx + mov word ptr [edi + 0x7ec6], dx + mov ax, word ptr [esi + 0x110] + mov bx, word ptr [esi + 0x114] + mov cx, word ptr [esi + 0x118] + mov dx, word ptr [esi + 0x11c] + mov word ptr [edi + 0x7ec8], ax + mov word ptr [edi + 0x7eca], bx + mov word ptr [edi + 0x7ecc], cx + mov word ptr [edi + 0x7ece], dx + mov ax, word ptr [esi + 0x120] + mov bx, word ptr [esi + 0x124] + mov cx, word ptr [esi + 0x128] + mov dx, word ptr [esi + 0x12c] + mov word ptr [edi + 0x7ed0], ax + mov word ptr [edi + 0x7ed2], bx + mov word ptr [edi + 0x7ed4], cx + mov word ptr [edi + 0x7ed6], dx + mov ax, word ptr [esi + 0x130] + mov bx, word ptr [esi + 0x134] + mov cx, word ptr [esi + 0x138] + mov word ptr [edi + 0x7ed8], ax + mov word ptr [edi + 0x7eda], bx + mov word ptr [edi + 0x7edc], cx + mov ax, word ptr [esi + 0x170] + mov bx, word ptr [esi + 0x174] + mov cx, word ptr [esi + 0x178] + mov dx, word ptr [esi + 0x17c] + mov word ptr [edi + 0x9e74], ax + mov word ptr [edi + 0x9e76], bx + mov word ptr [edi + 0x9e78], cx + mov word ptr [edi + 0x9e7a], dx + mov ax, word ptr [esi + 0x180] + mov bx, word ptr [esi + 0x184] + mov cx, word ptr [esi + 0x188] + mov dx, word ptr [esi + 0x18c] + mov word ptr [edi + 0x9e7c], ax + mov word ptr [edi + 0x9e7e], bx + mov word ptr [edi + 0x9e80], cx + mov word ptr [edi + 0x9e82], dx + mov ax, word ptr [esi + 0x190] + mov bx, word ptr [esi + 0x194] + mov cx, word ptr [esi + 0x198] + mov word ptr [edi + 0x9e84], ax + mov word ptr [edi + 0x9e86], bx + mov word ptr [edi + 0x9e88], cx + mov ax, word ptr [esi + 0x1c0] + mov bx, word ptr [esi + 0x1c4] + mov cx, word ptr [esi + 0x1c8] + mov dx, word ptr [esi + 0x1cc] + mov word ptr [edi + 0xbe28], ax + mov word ptr [edi + 0xbe2a], bx + mov word ptr [edi + 0xbe2c], cx + mov word ptr [edi + 0xbe2e], dx + mov ax, word ptr [esi + 0x1d0] + mov bx, word ptr [esi + 0x1d4] + mov cx, word ptr [esi + 0x1d8] + mov word ptr [edi + 0xbe30], ax + mov word ptr [edi + 0xbe32], bx + mov word ptr [edi + 0xbe34], cx + mov ax, word ptr [esi + 0x1f0] + mov bx, word ptr [esi + 0x1f4] + mov cx, word ptr [esi + 0x1f8] + mov word ptr [edi + 0xdddc], ax + mov word ptr [edi + 0xddde], bx + mov word ptr [edi + 0xdde0], cx + jmp zm_4535f4 +zm_4532a7: + mov bx, word ptr [esi + 4] + mov cx, word ptr [esi + 8] + mov dx, word ptr [esi + 0xc] + mov word ptr [edi + 0x1fbc], bx + mov word ptr [edi + 0x1fbe], cx + mov word ptr [edi + 0x1fc0], dx + mov bx, word ptr [esi + 0x24] + mov cx, word ptr [esi + 0x28] + mov dx, word ptr [esi + 0x2c] + mov word ptr [edi + 0x3f68], bx + mov word ptr [edi + 0x3f6a], cx + mov word ptr [edi + 0x3f6c], dx + mov ax, word ptr [esi + 0x30] + mov bx, word ptr [esi + 0x34] + mov cx, word ptr [esi + 0x38] + mov dx, word ptr [esi + 0x3c] + mov word ptr [edi + 0x3f6e], ax + mov word ptr [edi + 0x3f70], bx + mov word ptr [edi + 0x3f72], cx + mov word ptr [edi + 0x3f74], dx + mov bx, word ptr [esi + 0x64] + mov cx, word ptr [esi + 0x68] + mov dx, word ptr [esi + 0x6c] + mov word ptr [edi + 0x5f14], bx + mov word ptr [edi + 0x5f16], cx + mov word ptr [edi + 0x5f18], dx + mov ax, word ptr [esi + 0x70] + mov bx, word ptr [esi + 0x74] + mov cx, word ptr [esi + 0x78] + mov dx, word ptr [esi + 0x7c] + mov word ptr [edi + 0x5f1a], ax + mov word ptr [edi + 0x5f1c], bx + mov word ptr [edi + 0x5f1e], cx + mov word ptr [edi + 0x5f20], dx + mov ax, word ptr [esi + 0x80] + mov bx, word ptr [esi + 0x84] + mov cx, word ptr [esi + 0x88] + mov dx, word ptr [esi + 0x8c] + mov word ptr [edi + 0x5f22], ax + mov word ptr [edi + 0x5f24], bx + mov word ptr [edi + 0x5f26], cx + mov word ptr [edi + 0x5f28], dx + mov bx, word ptr [esi + 0xc4] + mov cx, word ptr [esi + 0xc8] + mov dx, word ptr [esi + 0xcc] + mov word ptr [edi + 0x7ec0], bx + mov word ptr [edi + 0x7ec2], cx + mov word ptr [edi + 0x7ec4], dx + mov ax, word ptr [esi + 0xd0] + mov bx, word ptr [esi + 0xd4] + mov cx, word ptr [esi + 0xd8] + mov dx, word ptr [esi + 0xdc] + mov word ptr [edi + 0x7ec6], ax + mov word ptr [edi + 0x7ec8], bx + mov word ptr [edi + 0x7eca], cx + mov word ptr [edi + 0x7ecc], dx + mov ax, word ptr [esi + 0xe0] + mov bx, word ptr [esi + 0xe4] + mov cx, word ptr [esi + 0xe8] + mov dx, word ptr [esi + 0xec] + mov word ptr [edi + 0x7ece], ax + mov word ptr [edi + 0x7ed0], bx + mov word ptr [edi + 0x7ed2], cx + mov word ptr [edi + 0x7ed4], dx + mov ax, word ptr [esi + 0xf0] + mov bx, word ptr [esi + 0xf4] + mov cx, word ptr [esi + 0xf8] + mov dx, word ptr [esi + 0xfc] + mov word ptr [edi + 0x7ed6], ax + mov word ptr [edi + 0x7ed8], bx + mov word ptr [edi + 0x7eda], cx + mov word ptr [edi + 0x7edc], dx + mov dx, word ptr [esi + 0x13c] + mov word ptr [edi + 0x9e72], dx + mov ax, word ptr [esi + 0x140] + mov bx, word ptr [esi + 0x144] + mov cx, word ptr [esi + 0x148] + mov dx, word ptr [esi + 0x14c] + mov word ptr [edi + 0x9e74], ax + mov word ptr [edi + 0x9e76], bx + mov word ptr [edi + 0x9e78], cx + mov word ptr [edi + 0x9e7a], dx + mov ax, word ptr [esi + 0x150] + mov bx, word ptr [esi + 0x154] + mov cx, word ptr [esi + 0x158] + mov dx, word ptr [esi + 0x15c] + mov word ptr [edi + 0x9e7c], ax + mov word ptr [edi + 0x9e7e], bx + mov word ptr [edi + 0x9e80], cx + mov word ptr [edi + 0x9e82], dx + mov ax, word ptr [esi + 0x160] + mov bx, word ptr [esi + 0x164] + mov cx, word ptr [esi + 0x168] + mov dx, word ptr [esi + 0x16c] + mov word ptr [edi + 0x9e84], ax + mov word ptr [edi + 0x9e86], bx + mov word ptr [edi + 0x9e88], cx + mov word ptr [edi + 0x9e8a], dx + mov dx, word ptr [esi + 0x19c] + mov word ptr [edi + 0xbe26], dx + mov ax, word ptr [esi + 0x1a0] + mov bx, word ptr [esi + 0x1a4] + mov cx, word ptr [esi + 0x1a8] + mov dx, word ptr [esi + 0x1ac] + mov word ptr [edi + 0xbe28], ax + mov word ptr [edi + 0xbe2a], bx + mov word ptr [edi + 0xbe2c], cx + mov word ptr [edi + 0xbe2e], dx + mov ax, word ptr [esi + 0x1b0] + mov bx, word ptr [esi + 0x1b4] + mov cx, word ptr [esi + 0x1b8] + mov dx, word ptr [esi + 0x1bc] + mov word ptr [edi + 0xbe30], ax + mov word ptr [edi + 0xbe32], bx + mov word ptr [edi + 0xbe34], cx + mov word ptr [edi + 0xbe36], dx + mov dx, word ptr [esi + 0x1dc] + mov word ptr [edi + 0xddda], dx + mov ax, word ptr [esi + 0x1e0] + mov bx, word ptr [esi + 0x1e4] + mov cx, word ptr [esi + 0x1e8] + mov dx, word ptr [esi + 0x1ec] + mov word ptr [edi + 0xdddc], ax + mov word ptr [edi + 0xddde], bx + mov word ptr [edi + 0xdde0], cx + mov word ptr [edi + 0xdde2], dx + mov dx, word ptr [esi + 0x1fc] + mov word ptr [edi + 0xfd8e], dx +zm_4535f4: + } + // clang-format on + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8012921ec1..467794cde8 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16965,7 +16965,7 @@ SHC_3BB0A8C1_0x0044FBF0 | 0.0% | Pending SHC_3BB0A8C1_0x00451E00 | 0.0% | Pending -SHC_3BB0A8C1_0x00452900 | 0.0% | Pending +SHC_3BB0A8C1_0x00452900 | 98.1% | Globals via statics in asm SHC_3BB0A8C1_0x00453600 | 89.4% | Globals via statics in asm From 35818ac7f4d728fd77aa1f1482cde890e3bcc51e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 19:37:16 +0100 Subject: [PATCH 25/78] fix: GMFirstPictureIndex in RenderGoldValue main renamed the global GMTotalPicturesProcessed (same address, int[240]) to GMFirstPictureIndex in 0d1fdb6df, so RenderGoldValue no longer compiled on this branch's base. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Rendering/RenderGoldValue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp index a810ecf518..c5ed2fca53 100644 --- a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp @@ -8,7 +8,7 @@ #include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" #include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" #include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" namespace OpenSHC { namespace UI { @@ -22,7 +22,7 @@ namespace UI { int population = DAT_GameState::instance.playerDataArray[playerID].currentPopulation; int gold = DAT_GameState::instance.playerDataArray[playerID].currentResources[Game::Resources::RT_GOLD]; DAT_TextManagerObject::instance.currentXOffset_0x0 - = DAT_GMImageHeaders::instance.imh[GMTotalPicturesProcessed::instance[DE::SHCDE::GM_INTERFACE_ICONS2] + 123] + = DAT_GMImageHeaders::instance.imh[GMFirstPictureIndex::instance[DE::SHCDE::GM_INTERFACE_ICONS2] + 123] .width; int goldDigitSet = 0; From f9e33bfdf439c4b9c72605ea0c2d48a082040b6f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 19:37:17 +0100 Subject: [PATCH 26/78] style: names, comments and if/else in UI/Rendering 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 --- .../Bink/AIMessageQueue/playAiLordMessage.cpp | 15 ++--- .../RenderAnimatedTutorialFloatOverlay.cpp | 65 +++++++++---------- src/OpenSHC/UI/Rendering/RenderGoldValue.cpp | 14 +++- .../UI/Rendering/RenderGreatestLordScreen.cpp | 3 +- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp index 9d525bb454..f20ab1cb09 100644 --- a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp +++ b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp @@ -37,7 +37,7 @@ namespace Rendering { using WindowsHelper::Enums::BOOLEnum; // FUNCTION: STRONGHOLDCRUSADER 0x004B7C90 - void AIMessageQueue::playAiLordMessage(int param_1, int param_2) + void AIMessageQueue::playAiLordMessage(int x, int y) { DWORD const now = timeGetTime(); int yOffset = 0; @@ -67,8 +67,8 @@ namespace Rendering { &DAT_TextManagerObject::instance.fontSizeClassArray[18])( (WCHAR*)this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineWideTextUnk, DAT_TextManagerObject::ptr)( - (WCHAR*)this->currentMessageText_0x8, param_1 - textWidth, yOffset - textHeight + param_2, 580, - 0xccfaff, 0, 18, 0); + (WCHAR*)this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, 0xccfaff, 0, 18, + 0); } else { textHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, &DAT_TextManagerObject::instance.fontSizeClassArray[18])( @@ -77,8 +77,7 @@ namespace Rendering { &DAT_TextManagerObject::instance.fontSizeClassArray[18])( this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( - this->currentMessageText_0x8, param_1 - textWidth, yOffset - textHeight + param_2, 580, 0xccfaff, 0, - 18, 0); + this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, 0xccfaff, 0, 18, 0); } if ((int)this->currentMessageUnknownValue2_0xd4 > 0) { int const nameHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, @@ -91,15 +90,15 @@ namespace Rendering { 0, 0, 2); MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], - param_1 - nameWidth, yOffset - nameHeight + param_2, 580, 0xccfaff, 0, 18, 0); + x - nameWidth, yOffset - nameHeight + y, 580, 0xccfaff, 0, 18, 0); int aiCharacter = 0; if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[this->currentMessageUnknownValue2_0xd4] == -1) { aiCharacter = DAT_GameSynchronyState::instance.currentAIArray[this->currentMessageUnknownValue2_0xd4]; } - int const faceX = param_1 - nameWidth - 80; - int const faceY = param_2 - nameHeight - 48; + int const faceX = x - nameWidth - 80; + int const faceY = y - nameHeight - 48; MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( DE::SHCDE::GM_INTERFACE_ICONS2, this->currentMessageUnknownValue2_0xd4 + 546, faceX, faceY); if (!aiCharacter) { diff --git a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp index 2a698064eb..75d6ef1411 100644 --- a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp +++ b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp @@ -19,14 +19,11 @@ namespace UI { using OpenSHC::Rendering::ScreenResolutionEnum; using OpenSHC::Rendering::Enums::RenderTarget; - /* - Renders an animated floating arrow/indicator overlay (GID_FLOATS_NEW) at a screen position derived from - param_1/param_2 and the current resolution. Animates through 10 frames at ~60ms per frame using timeGetTime. - Renders twice: once to RT_SCREEN_MENU and once to RT_MAP_GAME with camera offset applied. Skipped if - DAT_00df5540 is non-zero. renamed by: Claude Sonnet 4.6 - */ + // Renders the animated tutorial arrow (GID_FLOATS_NEW) at (x, y), moved down by a per-resolution offset. It + // cycles through 10 frames at about 60 ms each and is drawn twice: to the screen menu surface and, with the + // camera offset, to the map surface. Skipped while DAT_00df5540 is set. // FUNCTION: STRONGHOLDCRUSADER 0x004BC790 - void Rendering::RenderAnimatedTutorialFloatOverlay(int param_1, int param_2) + void Rendering::RenderAnimatedTutorialFloatOverlay(int x, int y) { if (DAT_00df5540::instance != 0) { return; @@ -42,66 +39,66 @@ namespace UI { INT_00df563c::instance = now; } // The gotos measure 3.5 points better than a plain if/else-if chain: the original keeps the shared - // 168 and 600 blocks at their first occurrence. It also keeps param_1 - 8 and param_2 - 32 apart from the + // 168 and 600 blocks at their first occurrence. It also keeps x - 8 and y - 32 apart from the // later - 28 and - 69 (an inlined helper?), which this source folds. - int iVar4 = 0; + int resolutionYOffset = 0; if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { - LAB_004bc7fc: - iVar4 = 0xa8; - goto LAB_004bc873; + yOffset168: + resolutionYOffset = 0xa8; + goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { - iVar4 = 0x1a8; - goto LAB_004bc873; + resolutionYOffset = 0x1a8; + goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { - LAB_004bc814: - iVar4 = 600; + yOffset600: + resolutionYOffset = 600; } else { if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { - iVar4 = 0x78; - goto LAB_004bc873; + resolutionYOffset = 0x78; + goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1440x900) { if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { - iVar4 = 0x1e0; - goto LAB_004bc873; + resolutionYOffset = 0x1e0; + goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) - goto LAB_004bc814; + goto yOffset600; if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { - iVar4 = 0x348; - goto LAB_004bc873; + resolutionYOffset = 0x348; + goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { - iVar4 = 1000; - goto LAB_004bc873; + resolutionYOffset = 1000; + goto draw; } if ((DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) || (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768)) - goto LAB_004bc7fc; + goto yOffset168; if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { - iVar4 = 0xfd2; - goto LAB_004bc873; + resolutionYOffset = 0xfd2; + goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1600x900) - goto LAB_004bc873; + goto draw; } - iVar4 = 300; + resolutionYOffset = 300; } - LAB_004bc873: + draw: RenderTargetInt const previousDrawBuffer = DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + param_1 + -0x24, param_2 + -0x65 + iVar4, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 0x24, y - 0x65 + resolutionYOffset, OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX - + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + param_1 + -0x24, - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + iVar4 + param_2 + -0x65, + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 0x24, + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + resolutionYOffset + y - 0x65, OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = previousDrawBuffer; } diff --git a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp index c5ed2fca53..72a8735549 100644 --- a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp @@ -62,7 +62,12 @@ namespace UI { goldDigitSet, TRUE); int populationDigitSetUnk = 0; - int populationColor = DAT_GameState::instance.playerDataArray[playerID].crowding <= 100 ? 0x7d3e : 0xff; + int populationColor; + if (DAT_GameState::instance.playerDataArray[playerID].crowding <= 100) { + populationColor = 0x7d3e; + } else { + populationColor = 0xff; + } if (populationCap == 0) { populationColor = 0x7d3e; population = 0; @@ -102,7 +107,12 @@ namespace UI { DAT_MenuHandlerState::instance.x + 727 + populationDigitSetUnk, DAT_MenuHandlerState::instance.y + 552, 0, populationColor, populationDigitSet, TRUE); - int const popularityColor = popularity < 50 ? 0xff : 0x7d3e; + int popularityColor; + if (popularity < 50) { + popularityColor = 0xff; + } else { + popularityColor = 0x7d3e; + } int const popularityHalfWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, DAT_TextManagerObject::ptr)(popularity, 0) / 2; diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index 2b284eb129..89b11ef6e6 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -61,7 +61,6 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x004D5810 void Rendering::RenderGreatestLordScreen() { - int y; int columnOffset; int index; int x; @@ -75,7 +74,7 @@ namespace UI { x = DAT_MenuHandlerState::instance.x - 102; columnOffset = 522; } - y = DAT_MenuHandlerState::instance.y; + int y = DAT_MenuHandlerState::instance.y; for (int player = 1; player < 9; ++player) { tables.points[player] = 0; From 33779d7351cb70d188d936013c527e614d6b31f1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:20:21 +0100 Subject: [PATCH 27/78] reimplement: SHC_3BB0A8C1_0x004916C0 90.30% Store scheduling differs 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 --- .../activateModalDialogAndClearText.cpp | 51 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp diff --git a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp new file mode 100644 index 0000000000..5f0ccbdbb3 --- /dev/null +++ b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp @@ -0,0 +1,51 @@ +#include "../MenuTextInputState.func.hpp" + +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::Text::TextArrayIndexType; + using OpenSHC::UI::Enums::MenuModalType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + /* + param_1 is 0xb if Exit Crusader or Restart Game, 0xC if Options decompilerscript: committed: 2025-01-30 + 21:57:43.216000 + */ + // FUNCTION: STRONGHOLDCRUSADER 0x004916C0 + void MenuTextInputState::activateModalDialogAndClearText(MenuModalType dialogID) + { + if (this->currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU) { + DAT_MenuTextInputState::instance.DAT_SomeTextArrayIndex = DAT_UserTextHandlerState::instance.textArrayIndex; + DAT_UserTextHandlerState::instance.allowUserTextInput = 1; + if (DAT_UserTextHandlerState::instance.textArrayIndex != OpenSHC::Text::TAIT_ZERO) { + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::clearTextAndCursor, DAT_UserTextHandlerState::ptr)(); + } + } + if (this->currentModalDialog != dialogID) { + // currentModalDialog and modalDialog_2..6 are a stack of open dialogs; pushing through a pointer + // keeps the original's loads and stores (the plain fields let the compiler reuse currentModalDialog) + MenuModalTypeInt* const dialogs = &this->currentModalDialog; + dialogs[5] = dialogs[4]; + dialogs[4] = dialogs[3]; + dialogs[3] = dialogs[2]; + dialogs[2] = dialogs[1]; + dialogs[1] = dialogs[0]; + dialogs[0] = dialogID; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(dialogID, TRUE); + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 467794cde8..92a76fe5dd 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23405,7 +23405,7 @@ SHC_3BB0A8C1_0x004914D0 | 0.0% | Pending SHC_3BB0A8C1_0x00491680 | 0.0% | Pending -SHC_3BB0A8C1_0x004916C0 | 0.0% | Pending +SHC_3BB0A8C1_0x004916C0 | 90.3% | Store scheduling differs SHC_3BB0A8C1_0x00491730 | 100.0% | Reimplemented From 0ce6fae8b678011f4f3fe6b5d328ebbe0eb34e3d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:20:22 +0100 Subject: [PATCH 28/78] reimplement: SHC_3BB0A8C1_0x00493900 93.90% Store scheduling differs 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 --- .../UI/MenuTextInputState/popModalDialog.cpp | 46 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp diff --git a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp new file mode 100644 index 0000000000..10e87ded5f --- /dev/null +++ b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp @@ -0,0 +1,46 @@ +#include "../MenuTextInputState.func.hpp" + +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::UI::Enums::MenuModalType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00493900 + void MenuTextInputState::popModalDialog() + { + MenuModalTypeInt const previousDialog = this->modalDialog_2; + this->modalDialog_2 = this->modalDialog_3; + this->modalDialog_3 = this->modalDialog_4; + this->modalDialog_4 = this->modalDialog_5; + this->modalDialog_5 = this->modalDialog_6; + this->modalDialog_6 = OpenSHC::UI::Enums::MMT_NO_MENU; + this->currentModalDialog = previousDialog; + if (previousDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + if (previousDialog == OpenSHC::UI::Enums::MMT_SAVE_MAP) { + this->fileListVisibleRowCount = 16; + DAT_UserTextHandlerState::instance.allowUserTextInput = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + 2); + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::moveCursorToEnd, DAT_UserTextHandlerState::ptr)(); + DAT_UserTextHandlerState::instance.allowUserTextInput = 1; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)((OpenSHC::UI::Enums::MenuModalType)previousDialog, TRUE); + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, this)(); + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 92a76fe5dd..1971c5f35c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23645,7 +23645,7 @@ SHC_3BB0A8C1_0x004938F8 | 0.0% | Pending SHC_3BB0A8C1_0x004938FC | 0.0% | Pending -SHC_3BB0A8C1_0x00493900 | 0.0% | Pending +SHC_3BB0A8C1_0x00493900 | 93.9% | Store scheduling differs SHC_3BB0A8C1_0x00493980 | 0.0% | Pending From 300f2370450efe9d3f3b0450563bc1a4f92eb813 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:20:22 +0100 Subject: [PATCH 29/78] reimplement: SHC_3BB0A8C1_0x004B51A0 87.10% Two registers swapped 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 --- .../convertMinimapClickToTileXY.cpp | 42 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp diff --git a/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp b/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp new file mode 100644 index 0000000000..482cf28cfd --- /dev/null +++ b/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp @@ -0,0 +1,42 @@ +#include "../MinimapViewState.func.hpp" + +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B51A0 + void MinimapViewState::convertMinimapClickToTileXY(int* tileX, int* tileY) + { + if (this->minimapClickEnabled != 0) { + int const mouseY = DAT_MouseState::instance.screenSpaceY - this->y; + int orientationOffset = 0; + *tileX = (((DAT_MouseState::instance.screenSpaceX - this->x) * this->oneOrTwo) / this->widthFactor + 6 + + this->tileOffsetX) + * 32; + int const screenY = ((this->oneOrTwo * mouseY) / this->heightFactor + this->tileOffsetY) * 8; + *tileY = screenY; + if (DAT_TileMapState::instance.mapOrientation != 0) { + if (DAT_TileMapState::instance.mapOrientation == 6) { + orientationOffset = 0x13a10; + } else if (DAT_TileMapState::instance.mapOrientation == 4) { + orientationOffset = 0x27420; + } else if (DAT_TileMapState::instance.mapOrientation == 2) { + orientationOffset = 0x3ae30; + } + } + int const tile = DAT_ViewportRenderState::instance + .screenPointToTileNumber[*tileX / 32 + screenY / 16 * 0x191 + orientationOffset - 6]; + int const row = (short)DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent[tile]; + *tileY = row; + *tileX = tile - DAT_ViewportRenderState::instance.translationMatrix[row].addXgetTile; + return; + } + *tileX = -1; + *tileY = -1; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1971c5f35c..0c724208c7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26877,7 +26877,7 @@ SHC_3BB0A8C1_0x004B5100 | 0.0% | Pending SHC_3BB0A8C1_0x004B5110 | 0.0% | Pending -SHC_3BB0A8C1_0x004B51A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B51A0 | 87.1% | Two registers swapped SHC_3BB0A8C1_0x004B5280 | 0.0% | Pending From 34f3fa419aaf09168de6a4116d033f5f82458dbc Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:20:22 +0100 Subject: [PATCH 30/78] reimplement: SHC_3BB0A8C1_0x004B5280 87.50% Globals via statics in asm 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 --- .../MinimapViewState/renderMinimapPreview.cpp | 56 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp new file mode 100644 index 0000000000..a9c77437df --- /dev/null +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp @@ -0,0 +1,56 @@ +#include "../MinimapViewState.func.hpp" + +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::UI::Rendering::PencilRenderCore; + + // Inline assembly cannot name a resolver global, so the copy loop reaches the pencil through this. + static PencilRenderCore* const s_pencilRenderCore = &DAT_PencilRenderCore::instance; + + // FUNCTION: STRONGHOLDCRUSADER 0x004B5280 + void MinimapViewState::renderMinimapPreview(int screenX, int screenY) + { + short* source = this->loadedMiniMap[0]; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencilSurface, DAT_PencilRenderCore::ptr)(); + // Copies the 200x200 minimap to the pencil surface at (screenX, screenY), leaving colour 0 transparent. + // Handwritten assembly in the original, transcribed from the binary. + __asm { + mov ecx, s_pencilRenderCore + mov edi, dword ptr [ecx]PencilRenderCore.surfacePtr + mov eax, screenX + add eax, eax + add edi, eax + mov eax, screenY + mov edx, dword ptr [ecx]PencilRenderCore.horizontalByteSize + mul edx + add edi, eax + mov esi, source + mov edx, 200 + nextRow: + mov ecx, 200 + mov ebx, 0 + nextPixel: + mov ax, word ptr [esi + ebx] + cmp ax, 0 + je transparent + mov word ptr [edi + ebx], ax + transparent: + add ebx, 2 + dec ecx + jne nextPixel + add esi, 400 + mov eax, s_pencilRenderCore + add edi, dword ptr [eax]PencilRenderCore.horizontalByteSize + dec edx + jne nextRow + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 0c724208c7..19e421b211 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26879,7 +26879,7 @@ SHC_3BB0A8C1_0x004B5110 | 0.0% | Pending SHC_3BB0A8C1_0x004B51A0 | 87.1% | Two registers swapped -SHC_3BB0A8C1_0x004B5280 | 0.0% | Pending +SHC_3BB0A8C1_0x004B5280 | 87.5% | Globals via statics in asm SHC_3BB0A8C1_0x004B5300 | 100.0% | Reimplemented From 950e83ebd931128ad061b8feae56226eea980f54 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:20:22 +0100 Subject: [PATCH 31/78] reimplement: SHC_3BB0A8C1_0x004B2820 82.70% Zero kept in esi When an AI lord message is closed and the next stored one starts playing, the original returns, and after the in-game blit it returns too; the draft fell through both and blitted the menu surface as well. Left: the compiler keeps 0 in esi, so esi is pushed for the whole function where the original only saves it around the modal copy. Co-Authored-By: Claude Opus 5.5 --- .../activateModalDialog2.cpp | 110 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp diff --git a/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp b/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp new file mode 100644 index 0000000000..78632fe7bb --- /dev/null +++ b/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp @@ -0,0 +1,110 @@ +#include "../MenuModalComposition.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Rendering/Bink/AIMessageQueue.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/DWORD_00df5534.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::UI::Enums::MenuModalType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004B2820 + void MenuModalComposition::activateModalDialog2(MenuModalType modalDialogID) + { + if (this->slot == 0 && DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + } + if (this->activeModalDialogID == OpenSHC::UI::Enums::MMT_DISPLAY_AI_LORD_MESSAGE) { + this->activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + if (MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::AIMessageQueue_Func::playNextStoredAIMessage, DAT_VideoBikQueue::ptr)() + != FALSE) { + return; + } + } + this->activeModalDialogID = modalDialogID; + if (modalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + // Makes found current. - TheRedDaemon + memcpy(&this->modalMenu, + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::findModalMenu, this)(modalDialogID), + sizeof(MenuModal)); + } + this->modalDragDropUnk = 0; + if ((this->modalMenu.borderStyle & 0x220) != 0) { + // tiled frames come in whole 24x24 tiles + this->modalMenu.width = ((this->modalMenu.width - 1) / 24 + 1) * 24; + this->modalMenu.height = ((this->modalMenu.height - 1) / 24 + 1) * 24; + } + if (MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)() != FALSE) { + if (this->modalMenu.x == -1) { + this->modalMenu.x = DAT_WindowAndDirectDraw::instance.gameResolutionX / 2 - this->modalMenu.width / 2; + } else { + this->modalMenu.x = (DAT_WindowAndDirectDraw::instance.gameResolutionX - 800) / 2 + this->modalMenu.x; + } + if (this->modalMenu.y == -1) { + // centred over the map, above the 128 pixel high menu bar + this->modalMenu.y + = (DAT_WindowAndDirectDraw::instance.gameResolutionY - 128) / 2 - this->modalMenu.height / 2; + } else { + this->modalMenu.y = (DAT_WindowAndDirectDraw::instance.gameResolutionY - 600) / 2 + this->modalMenu.y; + } + } else { + if (this->modalMenu.x == -1) { + this->modalMenu.x = DAT_WindowAndDirectDraw::instance.gameResolutionX / 2 - this->modalMenu.width / 2; + } else { + this->modalMenu.x = (DAT_WindowAndDirectDraw::instance.gameResolutionX - 800) / 2 + this->modalMenu.x; + } + if (this->modalMenu.y == -1) { + this->modalMenu.y = DAT_WindowAndDirectDraw::instance.gameResolutionY / 2 - this->modalMenu.height / 2; + } else { + this->modalMenu.y = (DAT_WindowAndDirectDraw::instance.gameResolutionY - 600) / 2 + this->modalMenu.y; + } + } + this->disappearAfter = 32; + this->mbr_0x6c = 0; + this->timeItIsSet = timeGetTime(); + if ((this->modalMenu.borderStyle & 0x400) != 0) { + this->disappearAfter = 0; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::renderMenuModal, this)(); + if (30 < (int)(this->timeItIsSet - DWORD_00df5534::instance)) { + DWORD_00df5534::instance = this->timeItIsSet; + // show the dialog right away: blit its rectangle to the screen + BOOLEnum const inGame + = MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)(); + int x = this->modalMenu.x; + int y = this->modalMenu.y; + if (inGame != FALSE) { + x = x + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; + y = y + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY; + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltMapGameSurfaceToScreen, + DAT_WindowAndDirectDraw::ptr)(x, y, this->modalMenu.width + x, this->modalMenu.height + y); + this->activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltScreenMenuSurfaceToScreen, + DAT_WindowAndDirectDraw::ptr)(x, y, this->modalMenu.width + x, this->modalMenu.height + y); + } + this->activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 19e421b211..37581c7d3a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26007,7 +26007,7 @@ SHC_3BB0A8C1_0x004B2280 | 0.0% | Pending SHC_3BB0A8C1_0x004B2530 | 0.0% | Pending -SHC_3BB0A8C1_0x004B2820 | 0.0% | Pending +SHC_3BB0A8C1_0x004B2820 | 82.7% | Zero kept in esi SHC_3BB0A8C1_0x004B2A60 | 0.0% | Pending From 3ccb2cf5b9a449f4b01c2098d7b3139712ca546e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:20:23 +0100 Subject: [PATCH 32/78] reimplement: SHC_3BB0A8C1_0x004B5F70 48.20% Frame one slot smaller Rewritten from the asm: the row parity counter starts at firstRow * heightFactor (the draft started it at 0), and rows past 400 end the scan (the draft had an empty if there). Left: the original's frame has one more slot, so the loop's registers and spills differ. Co-Authored-By: Claude Opus 5.5 --- .../locatePlayerKeepPositionsOnMinimap.cpp | 92 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp diff --git a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp new file mode 100644 index 0000000000..e5f4cba9bb --- /dev/null +++ b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp @@ -0,0 +1,92 @@ +#include "../MinimapViewState.func.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B5F70 + void MinimapViewState::locatePlayerKeepPositionsOnMinimap(uint flags, int widthFactor, int heightFactor) + { + int scale = 1; + int firstRow = 0; + int orientationOffset = 8; + int divisor = 2; + for (int player = 0; player < 8; player++) { + this->DAT_MapU4B64.keepPositions[player].x = -1; + this->DAT_MapU4B64.keepPositions[player].y = -1; + } + if ((flags & 4) != 0) { + scale = 2; + } + int const columns = 400 / widthFactor * scale; + int const lastRow = scale * 200; + if (DAT_TileMapState::instance.mapSize <= 200) { + firstRow = 100; + divisor = 1; + } + int const viewportHeight = DAT_ViewportRenderState::instance.viewportState.viewportHeight; + int rowParity = viewportHeight + 1; + if (DAT_TileMapState::instance.mapOrientation != 0) { + if (DAT_TileMapState::instance.mapOrientation == 6) { + orientationOffset = 0x13a18; + } else if (DAT_TileMapState::instance.mapOrientation == 4) { + orientationOffset = 0x27428; + } else if (DAT_TileMapState::instance.mapOrientation == 2) { + orientationOffset = 0x3ae38; + } + } + int const firstColumn = firstRow / 2; + int rowBase = firstColumn * 0x191 + orientationOffset + 1; + for (int row = firstRow; row < lastRow - firstRow; row++) { + // the screen tile rows are staggered: every other row is half a tile in and one tile longer + int rowX; + int rowLength; + if (rowParity == viewportHeight + 1) { + rowParity = viewportHeight; + rowX = widthFactor / 2; + rowLength = 200; + } else { + rowParity = viewportHeight + 1; + rowX = 0; + rowLength = 201; + } + if (0 <= row) { + if (400 <= row) { + return; + } + if (scale != 2 || (row * heightFactor & 1) == 0) { + int const lastColumn = columns / divisor - firstColumn; + for (int column = firstColumn; column < lastColumn; column++) { + int const x = (column - firstColumn) * widthFactor + rowX; + int const buildingID + = DAT_TileMapState::instance.BuildingLayer[DAT_ViewportRenderState::instance + .screenPointToTileNumber[column + rowBase - 8]]; + if (buildingID != 0 + && OpenSHC::Map::Buildings::BT_MANORHOUSE + <= DAT_BuildingsState::instance.buildings[buildingID].buildingType + && DAT_BuildingsState::instance.buildings[buildingID].buildingType + <= OpenSHC::Map::Buildings::BT_KEEPFIVE) { + int const owner = DAT_BuildingsState::instance.buildings[buildingID].owner; + if (this->DAT_MapU4B64.keepPositions[owner - 1].x == -1) { + int const y = (row - firstRow) * heightFactor; + if (scale == 1) { + this->DAT_MapU4B64.keepPositions[owner - 1].x = x; + this->DAT_MapU4B64.keepPositions[owner - 1].y = y; + } else { + this->DAT_MapU4B64.keepPositions[owner - 1].x = x / scale; + this->DAT_MapU4B64.keepPositions[owner - 1].y = y / scale; + } + } + } + } + } + } + rowBase = rowBase + rowLength; + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 37581c7d3a..ada7938eed 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26891,7 +26891,7 @@ SHC_3BB0A8C1_0x004B58D0 | 0.0% | Pending SHC_3BB0A8C1_0x004B5A20 | 0.0% | Pending -SHC_3BB0A8C1_0x004B5F70 | 0.0% | Pending +SHC_3BB0A8C1_0x004B5F70 | 48.2% | Frame one slot smaller SHC_3BB0A8C1_0x004B61F0 | 0.0% | Pending From 553dc4f85e4b3bbef177d01171c5c908d0d93bd6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:20:23 +0100 Subject: [PATCH 33/78] reimplement: SHC_3BB0A8C1_0x004B5330 21.40% Pixel store and registers differ Rewritten from the asm as plain loops (same scan as locatePlayerKeepPositionsOnMinimap). Left: the original's pixel store reloads the colour from its stack slot and multiplies with mul, which suggests a small handwritten store block; register allocation and the frame differ throughout. Co-Authored-By: Claude Opus 5.5 --- ...renderMinimapTileStripWithLuminescence.cpp | 181 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp new file mode 100644 index 0000000000..96c902797e --- /dev/null +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp @@ -0,0 +1,181 @@ +#include "../MinimapViewState.func.hpp" + +#include "OpenSHC/Globals/DAT_MiniMapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + + /* + WARNING: Enum "MappersEnum": Some values do not have unique names + */ + /* + Renders a horizontal strip of minimap pixels for a given map row range. For each tile, determines the base + colour from LogicLayer flags (water, trees, terrain type) and MiniMapDefinedData colour tables, then applies a + luminescence multiplier per channel (RGB555 or RGB565). Writes results into the minimap pixel buffer at + DAT_MinimapViewState, with support for 1x and 2x scale modes. renamed by: Claude Sonnet 4.6 + */ + // FUNCTION: STRONGHOLDCRUSADER 0x004B5330 + void MinimapViewState::renderMinimapTileStripWithLuminescence( + uint flags, int widthFactor, int heightFactor, uint stripStart, int stripLength) + { + // the strip covers rows stripStart% .. stripStart + stripLength% of the 400 screen tile rows + int const firstStripRow = (int)(stripStart * 400) / 100; + int const endStripRow = (stripStart + stripLength) * 400 / 100; + int isRGB565 = 0; + int scale = 1; + int firstRow = 0; + int orientationOffset = 8; + int divisor = 2; + if ((flags & 4) != 0) { + scale = 2; + } + int const columns = 400 / widthFactor * scale; + int const lastRow = scale * 200; + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_565) { + isRGB565 = 1; + } + if (DAT_TileMapState::instance.mapSize <= 200) { + firstRow = 100; + divisor = 1; + } + int const viewportHeight = DAT_ViewportRenderState::instance.viewportState.viewportHeight; + int rowParity = viewportHeight + 1; + if (DAT_TileMapState::instance.mapOrientation != 0) { + if (DAT_TileMapState::instance.mapOrientation == 6) { + orientationOffset = 0x13a18; + } else if (DAT_TileMapState::instance.mapOrientation == 4) { + orientationOffset = 0x27428; + } else if (DAT_TileMapState::instance.mapOrientation == 2) { + orientationOffset = 0x3ae38; + } + } + int const firstColumn = firstRow / 2; + int rowBase = firstColumn * 0x191 + orientationOffset + 1; + for (int row = firstRow; row < lastRow - firstRow; row++) { + // the screen tile rows are staggered: every other row is half a tile in and one tile longer + int rowX; + int rowLength; + if (rowParity == viewportHeight + 1) { + rowParity = viewportHeight; + rowX = widthFactor / 2; + rowLength = 200; + } else { + rowParity = viewportHeight + 1; + rowX = 0; + rowLength = 201; + } + if (firstStripRow <= row) { + if (endStripRow <= row) { + return; + } + if (scale != 2 || (row * heightFactor & 1) == 0) { + int const y = (row - firstRow) * heightFactor; + int const lastColumn = columns / divisor - firstColumn; + for (int column = firstColumn - 2; column < lastColumn; column++) { + int const x = (column - firstColumn) * widthFactor + rowX; + int const tile + = DAT_ViewportRenderState::instance.screenPointToTileNumber[column + rowBase - 8]; + uint const logic = DAT_TileMapState::instance.LogicLayer[tile]; + int const random = DAT_TileMapState::instance.RandomLayer[tile]; + int const luminescence = DAT_TileMapState::instance.LuminesenceLayer[tile]; + uint color = 0; + if ((logic & 0x40000000) != 0) { + color = DAT_MiniMapDefinedData::instance.field6_0x74[isRGB565 + (random & 3) * 2]; + } else if ((logic & 0x3000) != 0) { + color = DAT_MiniMapDefinedData::instance.field16_0x144[isRGB565 + (random & 3) * 2]; + } else if ((logic & 8) != 0) { + if ((DAT_TileMapState::instance.MiscDisplayLayer[tile] & 0x2000) != 0) { + color = DAT_MiniMapDefinedData::instance.field1_0x20[isRGB565]; + } else { + color = 0; + } + } else { + // the colour of the first logic bit that has one + int bit = 0; + while ( + (DAT_MiniMapDefinedData::instance.MinimapColorByLogicBit[bit].integer & logic) == 0) { + if (DAT_MiniMapDefinedData::instance.MinimapColorByLogicBit[bit].integer == 0) { + break; + } + bit = bit + 1; + } + if (DAT_MiniMapDefinedData::instance.MinimapColorByLogicBit[bit].integer != 0) { + color = DAT_MiniMapDefinedData::instance.MinimapColorByLogicBit[bit] + .colorModeSpecificValue[isRGB565]; + } else { + color = 0; + } + } + if (luminescence != 2 && (short)color != 0 && (logic & 2) == 0) { + int const brightness + = DAT_MiniMapDefinedData::instance.LuminescenceBrightnessPercent[luminescence]; + int red; + int green; + if (isRGB565 == 0) { + red = (int)(((ushort)color & 0x7c00) * brightness) / 100; + if (0x7c00 < red) { + red = 0x7c00; + } + green = (int)(((ushort)color & 0x3e0) * brightness) / 100; + red = red & 0x7c00; + if (0x3e0 < green) { + green = 0x3e0; + } + green = green & 0x3e0; + } else { + red = (int)(((ushort)color & 0xf800) * brightness) / 100; + if (0xf800 < red) { + red = 0xf800; + } + green = (int)(((ushort)color & 0x7e0) * brightness) / 100; + red = red & 0xf800; + if (0x7e0 < green) { + green = 0x7e0; + } + green = green & 0x7e0; + } + int blue = (int)(((ushort)color & 0x1f) * brightness) / 100; + if (0x1f < blue) { + blue = 0x1f; + } + color = (ushort)(blue & 0x1f | green | red); + } + if (scale == 1) { + for (int dx = 0; dx < widthFactor; dx++) { + if (0 <= x + dx && x + dx < columns * widthFactor) { + for (int dy = 0; dy < heightFactor; dy++) { + if ((short)color == 0) { + color = this->minimapPixelBuffer[(y + dy) * 400 / 2 + x + dx]; + } + this->field17_0x44[(y + dy) * 200 + x + dx] = (ushort)color; + } + } + } + } else { + // zoomed out: every other pixel, at half the position + for (int dx = x & 1; dx < widthFactor; dx = dx + 2) { + if (0 <= x + dx && x + dx < columns * widthFactor) { + int const pixelX = (x + dx) / scale; + for (int dy = 0; dy < heightFactor; dy++) { + int const pixelY = (y + dy) / scale; + if ((short)color == 0) { + color = this->minimapPixelBuffer[pixelY * 400 / 2 + pixelX]; + } + this->field17_0x44[pixelY * 200 + pixelX] = (ushort)color; + } + } + } + } + } + } + } + rowBase = rowBase + rowLength; + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ada7938eed..340d139497 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26883,7 +26883,7 @@ SHC_3BB0A8C1_0x004B5280 | 87.5% | Globals via statics in asm SHC_3BB0A8C1_0x004B5300 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B5330 | 0.0% | Pending +SHC_3BB0A8C1_0x004B5330 | 21.4% | Pixel store and registers differ SHC_3BB0A8C1_0x004B5480 | 0.0% | Pending From 6b84fcace53e1e2669a0f44ad2ad7891a93c2c4a Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 19:37:21 +0100 Subject: [PATCH 34/78] style: comments in UI-Core activateModalDialogAndClearText's note names dialogID instead of param_1; renderMinimapTileStripWithLuminescence's imported comment (decompiler warning, tool tag) is a short // note. Measured: no function changes. Co-Authored-By: Claude Opus 5.5 --- .../activateModalDialogAndClearText.cpp | 3 +-- .../renderMinimapTileStripWithLuminescence.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp index 5f0ccbdbb3..208ce73a32 100644 --- a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp @@ -18,8 +18,7 @@ namespace UI { using OpenSHC::WindowsHelper::Enums::BOOLEnum; /* - param_1 is 0xb if Exit Crusader or Restart Game, 0xC if Options decompilerscript: committed: 2025-01-30 - 21:57:43.216000 + dialogID is 0xb for Exit Crusader or Restart Game, 0xc for Options */ // FUNCTION: STRONGHOLDCRUSADER 0x004916C0 void MenuTextInputState::activateModalDialogAndClearText(MenuModalType dialogID) diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp index 96c902797e..9face8939a 100644 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp @@ -9,15 +9,9 @@ namespace OpenSHC { namespace UI { - /* - WARNING: Enum "MappersEnum": Some values do not have unique names - */ - /* - Renders a horizontal strip of minimap pixels for a given map row range. For each tile, determines the base - colour from LogicLayer flags (water, trees, terrain type) and MiniMapDefinedData colour tables, then applies a - luminescence multiplier per channel (RGB555 or RGB565). Writes results into the minimap pixel buffer at - DAT_MinimapViewState, with support for 1x and 2x scale modes. renamed by: Claude Sonnet 4.6 - */ + // Draws a strip of minimap rows (stripStart% to stripStart + stripLength% of the screen tile rows) into the minimap + // pixel buffer: each tile's colour comes from its LogicLayer flags and MiniMapDefinedData's tables, scaled by its + // luminescence (RGB555 or RGB565); zoomed out, every other pixel at half the position. // FUNCTION: STRONGHOLDCRUSADER 0x004B5330 void MinimapViewState::renderMinimapTileStripWithLuminescence( uint flags, int widthFactor, int heightFactor, uint stripStart, int stripLength) From 288841e4eda74f288ede13c8b106b7b4d186f6cc Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:40:46 +0100 Subject: [PATCH 35/78] reimplement: SHC_3BB0A8C1_0x0043FAC0 85.30% Loop registers differ An index loop over the four foods: main moved the food types out of RenderingDefinedData, so the draft's loop end (an offset into RenderingDefinedData) no longer bounded the loop. Left: the loop holds the player slot, y and the amount in other registers. Co-Authored-By: Claude Opus 5.5 --- .../UI/StatusMenus/RenderStatusMenu_Food.cpp | 60 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp new file mode 100644 index 0000000000..99df70aa09 --- /dev/null +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp @@ -0,0 +1,60 @@ +#include "../StatusMenus.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_ARRAY_0061818c.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::Game::GameMode; + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x0043FAC0 + void StatusMenus::RenderStatusMenu_Food() + { + int const left = DAT_MenuHandlerState::instance.x + 0xb2; + int const top = DAT_MenuHandlerState::instance.y + 0x200; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // "Food" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 4), + DAT_MenuHandlerState::instance.x + 0x19, DAT_MenuHandlerState::instance.y + 0x1d3, OpenSHC::Text::TTA_LEFT, + 0, 0x11, FALSE, 0); + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + // "Clicking on a food toggles consumption" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x17), + DAT_MenuHandlerState::instance.x + 0x13c, top + 0x46, OpenSHC::Text::TTA_CENTER, 0, 0x12, FALSE, 0); + } + // the stock of the four foods + for (int food = 0; food < 4; food++) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[DAT_ARRAY_0061818c::instance[food]], + left + 12 + food * 80, DAT_MenuHandlerState::instance.y + 0x225, OpenSHC::Text::TTA_LEFT, 0, 0x11, + FALSE, 0); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 340d139497..f4ebc90abe 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13605,7 +13605,7 @@ SHC_3BB0A8C1_0x0043F6A0 | 0.0% | Pending SHC_3BB0A8C1_0x0043F930 | 0.0% | Pending -SHC_3BB0A8C1_0x0043FAC0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043FAC0 | 85.3% | Loop registers differ SHC_3BB0A8C1_0x0043FBB0 | 0.0% | Pending From a2681349de01e4e99b8919ede1339074558a7f2c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:40:46 +0100 Subject: [PATCH 36/78] reimplement: SHC_3BB0A8C1_0x0043F6A0 82.40% Register naming differs Rewritten from the asm: axes, scale label, year labels and one bar per month. Left: the player slot, the highest population and the loop pointer sit in other registers. Co-Authored-By: Claude Opus 5.5 --- .../RenderStatusMenu_Population.cpp | 143 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp new file mode 100644 index 0000000000..f2e7b06e0b --- /dev/null +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp @@ -0,0 +1,143 @@ +#include "../StatusMenus.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x0043F6A0 + void StatusMenus::RenderStatusMenu_Population() + { + int const player = DAT_GameSynchronyState::instance.currentPlayerSlotID; + int const top = DAT_MenuHandlerState::instance.y + 0x1bf; + int const x = DAT_MenuHandlerState::instance.x; + // the graph shows the last 300 months + int months = DAT_GameState::instance.mapAndTime.populationIndex; + if (300 < DAT_GameState::instance.mapAndTime.populationIndex) { + months = 300; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, + DAT_TextureRenderCoreObject::ptr)(1, x + 0xe, DAT_MenuHandlerState::instance.y + 0x1e9); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // "Population" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 3), + DAT_MenuHandlerState::instance.x + 0x19, DAT_MenuHandlerState::instance.y + 0x1d3, OpenSHC::Text::TTA_LEFT, + 0, 0x11, FALSE, 0); + // the axes, three pixels thick + int const bottom = top + 0x7e; + int const right = x + 0x1ed; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0xbc, bottom, right, bottom, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0xbc, top + 0x7f, right, top + 0x7f, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0xbc, top + 0x80, right, top + 0x80, COL_BLACK::instance.shortValue); + int const graphTop = top + 0x32; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0xbe, graphTop, x + 0xbe, bottom, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0xbd, graphTop, x + 0xbd, bottom, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0xbc, graphTop, x + 0xbc, bottom, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0x1eb, graphTop, x + 0x1eb, bottom, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x + 0x1ec, graphTop, x + 0x1ec, bottom, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right, graphTop, right, bottom, COL_BLACK::instance.shortValue); + // "Years" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0xd), + x + 0x154, top + 0x8e, OpenSHC::Text::TTA_CENTER, 0, 0x13, FALSE, 0); + // the vertical scale: 50 people per 75 pixels, doubled until the highest population fits + int highest = 0; + for (int month = 0; month < months; month++) { + if (DAT_GameState::instance.mapAndTime.playerPopulationStatistics[player][month] > highest) { + highest = DAT_GameState::instance.mapAndTime.playerPopulationStatistics[player][month]; + } + } + int scale; + if (highest <= 50) { + scale = 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + 50, x + 0xac, top + 0x2d, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + } else { + if (highest <= 100) { + scale = 2; + } else if (highest <= 200) { + scale = 4; + } else if (highest <= 400) { + scale = 8; + } else if (highest <= 800) { + scale = 16; + } else { + scale = 32; + } + if (scale == 32) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + 1600, x + 0x9c, top + 0x2d, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + scale * 50, x + 0xa4, top + 0x2d, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + } + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + 0, x + 0xb4, top + 0x78, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + // a year label every five years + for (int label = 0; label <= 5; label++) { + int firstYear = (DAT_GameState::instance.mapAndTime.populationIndex - 300) / 12; + if (firstYear < 0) { + firstYear = 0; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + firstYear + label * 5, label * 1475 / 25 + 0xbe + x, top + 0x82, OpenSHC::Text::TTA_LEFT, 0, 0x13, + FALSE, 0); + } + // one bar per month + if (months <= 300) { + for (int month = 0; month < months; month++) { + short const population = DAT_GameState::instance.mapAndTime.playerPopulationStatistics[player][month]; + if (population > 0) { + int const height = population * 75 / (scale * 50); + if (height >= 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRect, + DAT_TextureRenderCoreObject::ptr)( + 0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, bottom); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(0, x + 0xbf + month, top - height + 0x7e); + } + } + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRectToGameResolution, + DAT_TextureRenderCoreObject::ptr)(); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f4ebc90abe..578705e56d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13601,7 +13601,7 @@ SHC_3BB0A8C1_0x0043F2C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0043F2F0 | 0.0% | Pending -SHC_3BB0A8C1_0x0043F6A0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043F6A0 | 82.4% | Register naming differs SHC_3BB0A8C1_0x0043F930 | 0.0% | Pending From a6118a26e33533296d5cf6d808c24f256b3d5730 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:40:46 +0100 Subject: [PATCH 37/78] reimplement: SHC_3BB0A8C1_0x00447FA0 40.20% Register allocation differs The fear-factor bonus is tested > 0, then < 0, then the no-bonus case, as in the original (the draft tested == 0 before < 0), and the frame counter compares signed. Left: register allocation differs across the whole function. Co-Authored-By: Claude Opus 5.5 --- .../UI/StatusMenus/RenderStatusMenu_Army.cpp | 139 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp new file mode 100644 index 0000000000..1a3a28c9be --- /dev/null +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -0,0 +1,139 @@ +#include "../StatusMenus.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/Units/UnitTypeInt.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_00b95b68.hpp" +#include "OpenSHC/Globals/DAT_00b9845c.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UnitTypeGroups.hpp" +#include "OpenSHC/Globals/DAT_UnitTypeRelatedCounter.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eGM; + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::Map::Units::UnitTypeInt; + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00447FA0 + void StatusMenus::RenderStatusMenu_Army() + { + int const x = DAT_MenuHandlerState::instance.x; + int const y = DAT_MenuHandlerState::instance.y; + int const firstGroupIcon = DAT_00b95b68::instance * 9; + int const top = y + 0x1bf; + DAT_00b9845c::instance = DAT_00b9845c::instance + 1; + int nudge = 0; + if (40 < (int)DAT_00b9845c::instance) { + DAT_00b9845c::instance = 0; + MACRO_CALL(OpenSHC::UI::Helpers_Func::CountPlayerUnitsByType)(); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // "Army" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 5), + x + 0x19, y + 0x1d3, OpenSHC::Text::TTA_LEFT, 0, 0x11, FALSE, 0); + int groupSize; + if (DAT_00b95b68::instance == 2) { + groupSize = 8; + nudge = -6; + } else { + groupSize = 9; + } + // an icon and the head count of each unit type in the group + for (int i = 0; i < groupSize; i++) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, + DAT_TextureRenderCoreObject::ptr)(firstGroupIcon + i + 4, x + 0x55 + i * 0x2e, top + 0x28); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_UnitTypeRelatedCounter::instance[DAT_UnitTypeGroups::instance[0][firstGroupIcon + i]], + nudge + i * 0x2e + x + 0x6f, top + 0x7d, OpenSHC::Text::TTA_CENTER, 0, 0x11, FALSE, 0); + if (2 < i) { + nudge = 0; + } + } + if (DAT_00b95b68::instance != 0) { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x10), + x + 0x74, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID].armySize, + x + 0x7a, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, TRUE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + // the fear factor's combat bonus, green when positive and red when negative + int const fearFactor + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + uint color; + int percentX; + if (0 < fearFactor) { + DAT_TextManagerObject::instance.field8_0x20 = 1; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 0xb1, x + 0x74, top + 0x1b); + // "Troop combat bonus:" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x1f), + x + 0x9c, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel + * 5, + x + 0xa2, top + 0x19, OpenSHC::Text::TTA_LEFT, 0xff00, 0, 0x12, TRUE, 0); + color = 0xff00; + percentX = x + 0xa4; + } else if (fearFactor < 0) { + DAT_TextManagerObject::instance.field8_0x20 = 1; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 0xb2, x + 0x74, top + 0x11); + // "Troop combat bonus:" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x1f), + x + 0x92, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel + * 5, + x + 0x98, top + 0x19, OpenSHC::Text::TTA_LEFT, 0xff, 0, 0x12, TRUE, 0); + color = 0xff; + percentX = x + 0x9a; + } else { + // "No 'fear factor' bonus." + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x1e), + x + 0x74, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + "%", percentX, top + 0x19, OpenSHC::Text::TTA_LEFT, color, 0, 0x12, TRUE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + DAT_TextManagerObject::instance.field8_0x20 = 0; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 578705e56d..3200d4748a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16373,7 +16373,7 @@ SHC_3BB0A8C1_0x00447D30 | 0.0% | Pending SHC_3BB0A8C1_0x00447DC0 | 0.0% | Pending -SHC_3BB0A8C1_0x00447FA0 | 0.0% | Pending +SHC_3BB0A8C1_0x00447FA0 | 40.2% | Register allocation differs SHC_3BB0A8C1_0x004482F0 | 0.0% | Pending From 3bf73e876e0733a2199124cf9f52cdccb950786d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 18:52:54 +0100 Subject: [PATCH 38/78] reimplement: SHC_3BB0A8C1_0x0043C1E0 87.60% Register allocation differs When a wedding is on, the original returns after the couple's names; the draft had an empty if there and also drew "No Wedding this month". The draft's RenderingDefinedData.field1120_0x557e0 is INT_0061824c on current main, which split that table out. Left: register allocation (the husband and wife IDs and the counters sit in other registers). Co-Authored-By: Claude Opus 5.5 --- .../RenderBuildingMenu_ChapelAndChurch.cpp | 293 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp diff --git a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp new file mode 100644 index 0000000000..b8c09f7fc7 --- /dev/null +++ b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp @@ -0,0 +1,293 @@ +#include "../BuildingMenus.func.hpp" + +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/Map/Buildings/BuildingTypeShort.hpp" +#include "OpenSHC/Map/Units/UnitType.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_00b98428.hpp" +#include "OpenSHC/Globals/DAT_00b9842c.hpp" +#include "OpenSHC/Globals/DAT_00b98430.hpp" +#include "OpenSHC/Globals/DAT_00b9843c.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_CurrentlyRenderedSpriteID.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_HusbandID.hpp" +#include "OpenSHC/Globals/DAT_HusbandUnitType.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_RenderedUnitOwner.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_WifeID.hpp" +#include "OpenSHC/Globals/DAT_WifeUnitType.hpp" +#include "OpenSHC/Globals/INT_0061824c.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::Map::Buildings::BuildingType; + using OpenSHC::Map::Buildings::BuildingTypeShort; + using OpenSHC::Map::Units::UnitType; + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Rendering::Enums::RenderTarget; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + /* + WARNING: Enum "MappersEnum": Some values do not have unique names + */ + /* + decompilerscript: committed: 2025-01-30 21:57:43.216000 + */ + // FUNCTION: STRONGHOLDCRUSADER 0x0043C1E0 + void BuildingMenus::RenderBuildingMenu_ChapelAndChurch() + { + BuildingTypeShort BVar2; + char* pcVar3; + int iVar4; + int iVar5; + TextAlignment TVar6; + BGR24 BVar7; + uint color; + int iVar8; + BOOLEnum BVar9; + int iVar10; + int blendStrength; + int iVar11; + iVar4 = DAT_BuildingsState::instance.menuSelectedBuildingID; + BVar2 + = DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID].buildingType; + /* + added by script: "Cathedral" + */ + if (BVar2 == OpenSHC::Map::Buildings::BT_CHAPEL) { + iVar11 = DAT_MenuHandlerState::instance.y + 0x1d3; + iVar8 = DAT_MenuHandlerState::instance.x + 0x19; + blendStrength = 0; + BVar9 = FALSE; + iVar10 = 0x10; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 0), + iVar8, iVar11, TVar6, BVar7, iVar10, BVar9, blendStrength); + } else if (BVar2 == OpenSHC::Map::Buildings::BT_CHURCH) { + iVar11 = DAT_MenuHandlerState::instance.y + 0x1d3; + iVar8 = DAT_MenuHandlerState::instance.x + 0x19; + blendStrength = 0; + BVar9 = FALSE; + iVar10 = 0x10; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 3), + iVar8, iVar11, TVar6, BVar7, iVar10, BVar9, blendStrength); + } else if (BVar2 == OpenSHC::Map::Buildings::BT_CATHEDRAL) { + iVar11 = DAT_MenuHandlerState::instance.y + 0x1d3; + iVar8 = DAT_MenuHandlerState::instance.x + 0x19; + blendStrength = 0; + BVar9 = FALSE; + iVar10 = 0x10; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 4), + iVar8, iVar11, TVar6, BVar7, iVar10, BVar9, blendStrength); + } + + if (DAT_BuildingsState::instance.buildings[iVar4].currentEmployeeCount == 0) { + iVar11 = 0; + BVar9 = FALSE; + iVar8 = 0x12; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + iVar4 = DAT_MenuHandlerState::instance.y + 0x205; + iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; + /* + added by script: "No Wedding this month" + */ + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), + iVar5, iVar4, TVar6, BVar7, iVar8, BVar9, iVar11); + return; + } + if (DAT_GameState::instance.mapAndTime.month != INT_0061824c::instance) { + INT_0061824c::instance = DAT_GameState::instance.mapAndTime.month; + DAT_00b9843c::instance = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::chooseHusbandAndWife, + DAT_UnitsState::ptr)((int*)DAT_HusbandID::ptr, (int*)DAT_WifeID::ptr); + if (DAT_00b9843c::instance == 0) { + /* no wedding this month: render the notice and stop */ + iVar11 = 0; + BVar9 = FALSE; + iVar8 = 0x12; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + iVar4 = DAT_MenuHandlerState::instance.y + 0x205; + iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; + /* + added by script: "No Wedding this month" + */ + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), + iVar5, iVar4, TVar6, BVar7, iVar8, BVar9, iVar11); + return; + } + DAT_HusbandUnitType::instance + = (UnitTypeInt)(short)DAT_UnitsState::instance.units[DAT_HusbandID::instance].unitType; + DAT_WifeUnitType::instance + = (UnitTypeInt)(short)DAT_UnitsState::instance.units[DAT_WifeID::instance].unitType; + switch (DAT_WifeUnitType::instance) { + case OpenSHC::Map::Units::UT_BREWER: + DAT_00b98428::instance = DAT_00b98428::instance + 1; + if (9 < (int)DAT_00b98428::instance) { + DAT_00b98428::instance = 0; + } + break; + case OpenSHC::Map::Units::UT_TANNER: + DAT_00b9842c::instance = DAT_00b9842c::instance + 1; + if (9 < (int)DAT_00b9842c::instance) { + DAT_00b9842c::instance = 0; + } + break; + default: + DAT_00b98430::instance = DAT_00b98430::instance + 1; + if (9 < (int)DAT_00b98430::instance) { + DAT_00b98430::instance = 0; + } + } + } + if (DAT_00b9843c::instance != 0) { + if ((int)(short)DAT_UnitsState::instance.units[DAT_HusbandID::instance].unitType + != DAT_HusbandUnitType::instance) { + DAT_00b9843c::instance = 0; + } + if ((int)(short)DAT_UnitsState::instance.units[DAT_WifeID::instance].unitType + != DAT_WifeUnitType::instance) { + DAT_00b9843c::instance = 0; + } + if (DAT_00b9843c::instance != 0) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, DAT_TextureRenderCoreObject::ptr)( + 1, DAT_MenuHandlerState::instance.x + 0x173, DAT_MenuHandlerState::instance.y + 0x1e0); + iVar8 = 0; + iVar5 = 0x12; + color = 0; + iVar4 = 0x15e; + if (DAT_WifeUnitType::instance != OpenSHC::Map::Units::UT_BREWER) { + if (DAT_WifeUnitType::instance == OpenSHC::Map::Units::UT_TANNER) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineTextUnk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b9842c::instance + 0xc, + DAT_MenuHandlerState::instance.x + 0xb4, DAT_MenuHandlerState::instance.y + 0x22f, 0x15e, 0, + 0x12, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineTextUnk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, + DAT_00b98430::instance + 0x17, DAT_MenuHandlerState::instance.x + 0xb4, + DAT_MenuHandlerState::instance.y + 0x22f, 0x15e, 0, 0x12, 0); + } + } else { + iVar11 = DAT_MenuHandlerState::instance.y + 0x22f; + iVar10 = DAT_MenuHandlerState::instance.x + 0xb4; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b98428::instance + 1), + iVar10, iVar11, iVar4, color, iVar5, iVar8); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + DAT_CurrentlyRenderedSpriteID::instance = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getPeasantGmID, DAT_UnitsState::ptr)(DAT_HusbandID::instance); + DAT_RenderedUnitOwner::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_CurrentlyRenderedSpriteID::instance, + 3, DAT_MenuHandlerState::instance.x + 0x82, DAT_MenuHandlerState::instance.y + 0x1c4); + DAT_CurrentlyRenderedSpriteID::instance = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getPeasantGmID, DAT_UnitsState::ptr)(DAT_WifeID::instance); + DAT_RenderedUnitOwner::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_CurrentlyRenderedSpriteID::instance, + 3, DAT_MenuHandlerState::instance.x + 0x91, DAT_MenuHandlerState::instance.y + 0x1dd); + iVar4 = DAT_HusbandID::instance; + byte bVar1 = DAT_UnitsState::instance.units[DAT_HusbandID::instance].firstNameIndex; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if ('\0' < (char)bVar1) { + iVar10 = 0; + BVar9 = FALSE; + iVar11 = 0x12; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + iVar5 = DAT_MenuHandlerState::instance.y + 0x1ec; + iVar8 = DAT_MenuHandlerState::instance.x + 0xd7; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PEASANT_NAMES, (int)((char)bVar1)), + iVar8, iVar5, TVar6, BVar7, iVar11, BVar9, iVar10); + bVar1 = DAT_UnitsState::instance.units[iVar4].rng1_to_70; + if (bVar1 != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_PEASANT_SURNAMES, (int)((char)bVar1), + DAT_MenuHandlerState::instance.x + 0xdc, DAT_MenuHandlerState::instance.y + 0x1ec, + OpenSHC::Text::TTA_LEFT, 0, 0x12, TRUE); + } + } + iVar4 = DAT_WifeID::instance; + bVar1 = DAT_UnitsState::instance.units[DAT_WifeID::instance].firstNameIndex; + if ('\0' < (char)bVar1) { + iVar10 = 0; + BVar9 = FALSE; + iVar11 = 0x12; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + iVar5 = DAT_MenuHandlerState::instance.y + 0x205; + iVar8 = DAT_MenuHandlerState::instance.x + 0xe6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PEASANT_NAMES, (int)((char)bVar1)), + iVar8, iVar5, TVar6, BVar7, iVar11, BVar9, iVar10); + bVar1 = DAT_UnitsState::instance.units[iVar4].rng1_to_70; + if (bVar1 != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_PEASANT_SURNAMES, (int)((char)bVar1), + DAT_MenuHandlerState::instance.x + 0xeb, DAT_MenuHandlerState::instance.y + 0x205, + OpenSHC::Text::TTA_LEFT, 0, 0x12, TRUE); + } + } + // a wedding is on: don't show "No Wedding this month" + if (DAT_00b9843c::instance != 0) { + return; + } + } + } + iVar11 = 0; + BVar9 = FALSE; + iVar8 = 0x12; + BVar7 = 0; + TVar6 = OpenSHC::Text::TTA_LEFT; + iVar4 = DAT_MenuHandlerState::instance.y + 0x205; + iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; + /* + added by script: "No Wedding this month" + */ + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), + iVar5, iVar4, TVar6, BVar7, iVar8, BVar9, iVar11); + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3200d4748a..1de629e60d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13475,7 +13475,7 @@ SHC_3BB0A8C1_0x0043C160 | 0.0% | Pending SHC_3BB0A8C1_0x0043C1A0 | 0.0% | Pending -SHC_3BB0A8C1_0x0043C1E0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043C1E0 | 87.6% | Register allocation differs SHC_3BB0A8C1_0x0043C6A0 | 0.0% | Pending From 87c2eb23202a46d35ebb0e272308daf8c3db65bb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 19:37:26 +0100 Subject: [PATCH 39/78] style: comments and string literal RenderBuildingMenu_ChapelAndChurch: the decompiler warning and the script's comment blocks are one-line // notes. RenderStatusMenu_Army: the "%" sign is s_percentage_005a2770 from string-literals.hpp (rule 12). Measured: no function changes. Co-Authored-By: Claude Opus 5.5 --- .../RenderBuildingMenu_ChapelAndChurch.cpp | 22 ++++--------------- .../UI/StatusMenus/RenderStatusMenu_Army.cpp | 3 ++- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp index b8c09f7fc7..15e3e3fa94 100644 --- a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp +++ b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp @@ -43,12 +43,6 @@ namespace UI { using OpenSHC::Text::TextAlignment; using OpenSHC::WindowsHelper::Enums::BOOLEnum; - /* - WARNING: Enum "MappersEnum": Some values do not have unique names - */ - /* - decompilerscript: committed: 2025-01-30 21:57:43.216000 - */ // FUNCTION: STRONGHOLDCRUSADER 0x0043C1E0 void BuildingMenus::RenderBuildingMenu_ChapelAndChurch() { @@ -67,9 +61,7 @@ namespace UI { iVar4 = DAT_BuildingsState::instance.menuSelectedBuildingID; BVar2 = DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID].buildingType; - /* - added by script: "Cathedral" - */ + // "Cathedral" if (BVar2 == OpenSHC::Map::Buildings::BT_CHAPEL) { iVar11 = DAT_MenuHandlerState::instance.y + 0x1d3; iVar8 = DAT_MenuHandlerState::instance.x + 0x19; @@ -116,9 +108,7 @@ namespace UI { TVar6 = OpenSHC::Text::TTA_LEFT; iVar4 = DAT_MenuHandlerState::instance.y + 0x205; iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; - /* - added by script: "No Wedding this month" - */ + // "No Wedding this month" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), @@ -138,9 +128,7 @@ namespace UI { TVar6 = OpenSHC::Text::TTA_LEFT; iVar4 = DAT_MenuHandlerState::instance.y + 0x205; iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; - /* - added by script: "No Wedding this month" - */ + // "No Wedding this month" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), @@ -280,9 +268,7 @@ namespace UI { TVar6 = OpenSHC::Text::TTA_LEFT; iVar4 = DAT_MenuHandlerState::instance.y + 0x205; iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; - /* - added by script: "No Wedding this month" - */ + // "No Wedding this month" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index 1a3a28c9be..829a065d36 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -10,6 +10,7 @@ #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/DAT_00b95b68.hpp" #include "OpenSHC/Globals/DAT_00b9845c.hpp" @@ -130,7 +131,7 @@ namespace UI { return; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( - "%", percentX, top + 0x19, OpenSHC::Text::TTA_LEFT, color, 0, 0x12, TRUE, 0); + s_percentage_005a2770, percentX, top + 0x19, OpenSHC::Text::TTA_LEFT, color, 0, 0x12, TRUE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; DAT_TextManagerObject::instance.field8_0x20 = 0; } From 435cc46245de587ad04f5b1914001f1dc7a84b16 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 19:53:54 +0100 Subject: [PATCH 40/78] fix: GMFirstPictureIndex in isMouseOnButtonImageUnk main renamed the global GMTotalPicturesProcessed (same address, int[240]) to GMFirstPictureIndex in 0d1fdb6df, so this file no longer compiled on current main. Co-Authored-By: Claude Opus 5.5 --- .../AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp index 860f8e7973..0a69808cd3 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp @@ -15,7 +15,7 @@ #include "OpenSHC/Globals/DAT_MouseState.hpp" #include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" #include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" -#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" namespace OpenSHC { namespace UI { @@ -29,7 +29,7 @@ namespace UI { { ushort* const surface = this->surfacePtr; if ((int)DAT_CurrentButtonPictureInGm::instance >= 0) { - int const imageIndex = GMTotalPicturesProcessed::instance[DAT_UIButtonDefinedData::instance + int const imageIndex = GMFirstPictureIndex::instance[DAT_UIButtonDefinedData::instance .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] .gmId_0x0] + DAT_CurrentButtonPictureInGm::instance - 1; @@ -52,7 +52,7 @@ namespace UI { } // A negative picture number means the alpha image of the button. DAT_CurrentButtonPictureInGm::instance = -DAT_CurrentButtonPictureInGm::instance; - int const imageIndex = GMTotalPicturesProcessed::instance[DAT_UIButtonDefinedData::instance + int const imageIndex = GMFirstPictureIndex::instance[DAT_UIButtonDefinedData::instance .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] .alphaGmIdUnk_0xc] + DAT_CurrentButtonPictureInGm::instance - 1; From 3e056ef021ef7f01e899c37f4db05be1733c7d6f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 19:25:30 +0100 Subject: [PATCH 41/78] reimplement: SHC_3BB0A8C1_0x00486F20 98.90% One lea scheduled earlier GameSynchronyState::initializeFinalResultsForActivePlayers, from gynt's version on his fork's reimpl/GameSynchronyState (89.7%). The two name copies index finalResults.names[i] and DAT_PlayerNames[i] instead of walking pointers, which puts the remaining walkers in the original's stack slots. gynt's piVar4 walker stays, per his note that naming its fields costs a lot. What's left: the original sets up piVar4 one instruction later; the for-init order, setting it before the loop and the increment order don't move it. Needs main's unknownShortArray1/2 names for finalResults (field25/26 on the branch). Co-Authored-By: Claude Opus 5.5 --- ...initializeFinalResultsForActivePlayers.cpp | 69 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp new file mode 100644 index 0000000000..9c04e20733 --- /dev/null +++ b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp @@ -0,0 +1,69 @@ +#include "../../Synchrony.func.hpp" +#include "../GameSynchronyState.func.hpp" + +#include "OpenSHC/Text/UserTextHandler.func.hpp" + +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +#include "string.h" + +namespace OpenSHC { +namespace Synchrony { + + // FUNCTION: STRONGHOLDCRUSADER 0x00486F20 + void GameSynchronyState::initializeFinalResultsForActivePlayers() + { + byte* pbVar1; + int* piVar4; + int iVar6; + int (*paiVar7)[9]; + strcpy(this->DAT_PlayerNames[1], + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); + /* + piVar4 stays a walker. Naming the fields it reaches - finalGold, finalBuildingsBurned and the rest, + all at [iVar6] - is measured at 88.5% -> 38.3%, and the last three alone at 88.5% -> 70.4%, so do + not retry it. + */ + for (iVar6 = 1, piVar4 = this->currentPlayerFullIDArray + 1; iVar6 < 9; + iVar6 = iVar6 + 1, piVar4 = piVar4 + 1) { + if ((*piVar4 == -1) && (piVar4[0x1b] == 0)) { + this->finalResults.active[iVar6] = 0; + } else { + this->finalResults.active[iVar6] = 1; + strcpy(this->finalResults.names[iVar6], this->DAT_PlayerNames[iVar6]); + piVar4[0x42494] = 0; + this->finalResults.finalMaxPopulation[iVar6] = 0; + this->finalResults.finalMaxGoodThings[iVar6] = 0; + this->finalResults.finalMaxBadThings[iVar6] = 0; + piVar4[0x424fe] = 0; + piVar4[0x42542] = 0; + piVar4[0x42507] = 0; + piVar4[0x42539] = 0; + piVar4[0x42510] = 0; + piVar4[0x42519] = 0; + piVar4[0x42522] = 0; + piVar4[0x4252b] = 0; + this->finalResults.finalKilledLords[iVar6] = 0; + piVar4[0x4254b] = 0; + piVar4[0x42554] = 0; + piVar4[0x424a4] = 0; + piVar4[0x4255d] = 0; + piVar4[0x42566] = 0; + piVar4[0x4256f] = 0; + this->finalResults.unknownShortArray1[iVar6] = 0; + this->finalResults.unknownShortArray2[iVar6] = 0; + piVar4[0x42581] = 0; + piVar4[0x4258a] = 0; + piVar4[0x42593] = 0; + piVar4[0x4259c] = 0; + } + } + paiVar7 = this->finalResults.finalKillMatrix; + for (iVar6 = 0x51; iVar6 != 0; iVar6 = iVar6 + -1) { + (*paiVar7)[0] = 0; + paiVar7 = (int (*)[9])(*paiVar7 + 1); + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1de629e60d..1fca2d3cd6 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23047,7 +23047,7 @@ SHC_3BB0A8C1_0x00486C40 | 0.0% | Pending SHC_3BB0A8C1_0x00486C60 | 0.0% | Pending -SHC_3BB0A8C1_0x00486F20 | 0.0% | Pending +SHC_3BB0A8C1_0x00486F20 | 98.9% | One lea scheduled earlier SHC_3BB0A8C1_0x00487080 | 100.0% | Reimplemented From 1c3c6b1fc73898cb7dc1afdc776103fc22e9776b Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 19:41:13 +0100 Subject: [PATCH 42/78] reimplement: SHC_3BB0A8C1_0x00480440 95.70% ebp is saved at entry; the original saves it only for the sort GameSynchronyState::getCommandIDFromCommandSelectionStuff, from gynt's version on his fork's reimpl/GameSynchronyState (72.8%). The command scan is a plain index loop over DAT_GameCommandArray (no stateUnk-relative pointer), and the bubble sort counts its pass at the top of the loop, as the original does; one variable is both the pass counter and the return value, as in gynt's version. What's left: the original pushes ebp only when it enters the sort, ours at function entry. Co-Authored-By: Claude Opus 5.5 --- .../getCommandIDFromCommandSelectionStuff.cpp | 71 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp new file mode 100644 index 0000000000..80477dedd5 --- /dev/null +++ b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp @@ -0,0 +1,71 @@ +#include "../../Synchrony.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Commands/GameCommandState.hpp" +#include "OpenSHC/Commands/GameCommandStateByte.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" + +namespace OpenSHC { +namespace Synchrony { + + using Commands::GameCommandState; + using Commands::GameCommandStateByte; + + // FUNCTION: STRONGHOLDCRUSADER 0x00480440 + int GameSynchronyState::getCommandIDFromCommandSelectionStuff() + { + this->someIndex = 0; + MACRO_CALL_MEMBER(IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + 800, 0, (void*)((int)(this->selectedGameCommands))); + for (int command = this->gameCommandID; command < 200; command++) { + // The command has not been processed yet, should be processed, and its time has come. + if (this->DAT_GameCommandArray[command].stateUnk != (GameCommandState)0 + && (char)this->DAT_GameCommandArray[command].stateUnk < 10 + && (int)this->DAT_GameCommandArray[command].time <= (int)DAT_GameCore::instance.mapTimeInTicks) { + this->protocolInvokerPlayerID + = MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::translateMultiplayerIDsIntoPlayerIDs, this)( + this->DAT_GameCommandArray[command].playerUnk); + this->selectedGameCommands[this->someIndex][0] = command; + this->selectedGameCommands[this->someIndex][1] = this->protocolInvokerPlayerID; + this->someIndex = this->someIndex + 1; + if (this->someIndex >= 100) { + break; + } + } + } + // Sort the selected commands so that lower player IDs are processed first (at most 100 passes). + int pass = 0; + if (0 < this->someIndex) { + int swapped = 1; + for (pass = 0; pass < 100;) { + if (!swapped) { + break; + } + pass++; + swapped = 0; + for (int i = 1; i < this->someIndex; i++) { + int const nextPlayerID = this->selectedGameCommands[i][1]; + int const commandID = this->selectedGameCommands[i - 1][0]; + int const playerID = this->selectedGameCommands[i - 1][1]; + if (!nextPlayerID) { + return 0; + } + if (nextPlayerID < playerID) { + this->selectedGameCommands[i - 1][0] = this->selectedGameCommands[i][0]; + this->selectedGameCommands[i - 1][1] = nextPlayerID; + this->selectedGameCommands[i][0] = commandID; + this->selectedGameCommands[i][1] = playerID; + swapped = 1; + } + } + } + pass = 1; + } + return pass; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1fca2d3cd6..87e7d7d318 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22423,7 +22423,7 @@ SHC_3BB0A8C1_0x004800E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00480210 | 0.0% | Pending -SHC_3BB0A8C1_0x00480440 | 0.0% | Pending +SHC_3BB0A8C1_0x00480440 | 95.7% | ebp is saved at entry; the original saves it only for the sort SHC_3BB0A8C1_0x00480570 | 100.0% | Reimplemented From b83d22f3afb5294e2c39c4b9597877ed06c3d648 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 20:04:30 +0100 Subject: [PATCH 43/78] build: compile determineGameTicksToPerform with /GL Like processSyncPacket and translateMultiplayerIDsIntoPlayerIDs: with /GL the compiler sees that computeLatencyAdjustmentFromMatchTimes keeps ecx, as the original does (64.7% -> 78.2% before any source change). gynt's fork has the same line on reimpl/GameSynchronyState. Co-Authored-By: Claude Opus 5.5 --- cmake/compiler-flags-gl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 87a8764d64..c29b10e1cb 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -88,3 +88,4 @@ src/OpenSHC/Map/Buildings/UpdateGoodBuildingMaypole.cpp src/OpenSHC/Map/Buildings/UpdateBadBuildingDungeon.cpp src/OpenSHC/Map/Buildings/UpdateBadBuildingGallows.cpp src/OpenSHC/Map/Buildings/UpdateBadBuildingBurningStake.cpp +src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp From cb7194614aa77226f41d8eca430e879f9885a804 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 20:04:31 +0100 Subject: [PATCH 44/78] reimplement: SHC_3BB0A8C1_0x00487A30 81.20% Game speed not kept in a register; return-block layout GameSynchronyState::determineGameTicksToPerform, from gynt's version on his fork's reimpl/GameSynchronyState (64.7%). Behaviour fix: when ticksBehindFastestPlayer is negative the original stores it in relativeTickTime; the branch version skipped that case. The two early returns are separate ifs. Needs the previous commit (/GL). What's left: the original keeps the game speed in esi from the start (reading it into a local and writing the 40 default back gets the esi but loses ebp = 0, 62.8%), and the return blocks are laid out differently. Co-Authored-By: Claude Opus 5.5 --- .../determineGameTicksToPerform.cpp | 128 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp new file mode 100644 index 0000000000..9ea8c2bf44 --- /dev/null +++ b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp @@ -0,0 +1,128 @@ +#include "../../Synchrony.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameLoopStopwatch.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MillisecCarry.hpp" + +namespace OpenSHC { +namespace Synchrony { + + using Game::GameMode; + using WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00487A30 + int GameSynchronyState::determineGameTicksToPerform(int currentPlayerSlotID) + { + int _durationOfOneTick; + int _relativeTickTime; + dword _gameSpeedLevel; + if (!DAT_GameCore::instance.gameSpeedLevel) { + DAT_GameCore::instance.gameSpeedLevel = 40; + } + if (DAT_GameCore::instance.currentlyInGameUnk_0xa4 != TRUE) { + return 0; + } + if (this->DAT_GameHalted) { + return 0; + } + if ((this->currentGameMode == Game::GM_SOLITARY) + || (this->currentGameMode == Game::GM_SKIRMISH_SINGLE_PLAYER)) { + this->mapTimeInTicksSinglePlayer = DAT_GameCore::instance.mapTimeInTicks; + _gameSpeedLevel = DAT_GameCore::instance.gameSpeedLevel; + _relativeTickTime = this->relativeTickTime; + } else { + /* + Calculate multiplayer game speed. + */ + DAT_GameCore::instance.gameSpeedMultiplicator = 1; + _gameSpeedLevel = this->skirmishGameSpeedLevel; + DAT_GameSynchronyState::instance.relativeTickTime = 0; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::computeLatencyAdjustmentFromMatchTimes, this)( + currentPlayerSlotID); + if ((int)this->ticksBehindFastestPlayer < 0) { + DAT_GameSynchronyState::instance.relativeTickTime = (int)this->ticksBehindFastestPlayer; + } else { + if (0 < (int)this->ticksAheadOfSlowestPlayer) { + DAT_GameSynchronyState::instance.relativeTickTime = (int)this->ticksAheadOfSlowestPlayer; + if ((int)this->ticksAheadOfSlowestPlayer > (int)this->commandDelay + 0x4b) { + if ((int)this->unknownIncrementBy40_01 < 1) { + this->unknownIncrementBy40_01 = 1; + } + _gameSpeedLevel = this->unknownIncrementBy40_01; + if ((int)this->unknownIncrementBy40_01 > this->skirmishGameSpeedLevel) { + _gameSpeedLevel = this->skirmishGameSpeedLevel; + } + } else if (5 < (int)this->ticksAheadOfSlowestPlayer) { + _gameSpeedLevel + = ((5 - (int)this->ticksAheadOfSlowestPlayer) * 2) / 3 + this->skirmishGameSpeedLevel; + if ((int)_gameSpeedLevel < 15) { + _gameSpeedLevel = 15; + } + } + } + } + _relativeTickTime = DAT_GameSynchronyState::instance.relativeTickTime; + } + DAT_GameSynchronyState::instance.relativeTickTime = _relativeTickTime; + if (DAT_GameCore::instance.gameSpeedMultiplicator < 0) { + _durationOfOneTick = -1000 / (int)_gameSpeedLevel * DAT_GameCore::instance.gameSpeedMultiplicator; + } else { + _durationOfOneTick = 1000 / (int)_gameSpeedLevel; + if (1 < DAT_GameCore::instance.gameSpeedMultiplicator) { + _durationOfOneTick = _durationOfOneTick / DAT_GameCore::instance.gameSpeedMultiplicator; + } + } + _relativeTickTime + = DAT_MillisecCarry::instance + (DAT_GameLoopStopwatch::instance.duration_0x0 - _durationOfOneTick); + DAT_MillisecCarry::instance = _relativeTickTime; + if (_relativeTickTime < 0) { + /* + Wait + */ + if (_relativeTickTime < -_durationOfOneTick) { + DAT_MillisecCarry::instance = _relativeTickTime + _durationOfOneTick; + return 0; + } + } else { + /* + Execute game ticks + */ + if (DAT_GameCore::instance.averageTimePerGameTick > _durationOfOneTick + && _relativeTickTime >= _durationOfOneTick * 2 && _durationOfOneTick == 1000 / (int)_gameSpeedLevel) { + /* + Slow down + */ + DAT_MillisecCarry::instance = 0; + return 2; + } + if (DAT_GameCore::instance.averageTimePerGameTick > (_durationOfOneTick * 7) / 10 + && _relativeTickTime >= _durationOfOneTick * 2 && _durationOfOneTick == 1000 / (int)_gameSpeedLevel) { + /* + Slow down + */ + DAT_MillisecCarry::instance = 0; + return 3; + } + if (_relativeTickTime > _durationOfOneTick * 10) { + /* + Cap game ticks per rendering + */ + DAT_MillisecCarry::instance = 0; + return 11; + } + if (_relativeTickTime > _durationOfOneTick) { + DAT_MillisecCarry::instance + = _relativeTickTime - (_relativeTickTime / _durationOfOneTick) * _durationOfOneTick; + return _relativeTickTime / _durationOfOneTick + 1; + } + } + return 1; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 87e7d7d318..910c219b2f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23071,7 +23071,7 @@ SHC_3BB0A8C1_0x00487770 | 0.0% | Pending SHC_3BB0A8C1_0x00487800 | 0.0% | Pending -SHC_3BB0A8C1_0x00487A30 | 0.0% | Pending +SHC_3BB0A8C1_0x00487A30 | 81.2% | Game speed not kept in a register; return-block layout SHC_3BB0A8C1_0x00487C50 | 0.0% | Pending From 48a2c84c0c990916329e6ad992cf06d62baaa2b2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 20:59:07 +0100 Subject: [PATCH 45/78] status: four lines re-measured in this branch on its own determineGameTicksToPerform 0x00487A30 is 68.3% here (81.2% needs its callee computeLatencyAdjustmentFromMatchTimes reimplemented, which is not in this PR); renderBltAndFlip 57.2%, takeScreenshot 88.2% and RenderGreatestLordScreen 58.8% measure a little higher with reccmp --ignore-security-cookie. Co-Authored-By: Claude Opus 5.5 --- status/addresses-SHC-3BB0A8C1.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 910c219b2f..bd395c687f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21245,7 +21245,7 @@ SHC_3BB0A8C1_0x0046FF50 | 0.0% | Pending SHC_3BB0A8C1_0x0046FFB0 | 0.0% | Pending -SHC_3BB0A8C1_0x00470040 | 56.7% | Zero not kept in ebp; param_1 takes the register instead +SHC_3BB0A8C1_0x00470040 | 57.2% | Zero not kept in ebp; param_1 takes the register instead SHC_3BB0A8C1_0x00470610 | 0.0% | Pending @@ -22125,7 +22125,7 @@ SHC_3BB0A8C1_0x00479369 | 0.0% | Pending SHC_3BB0A8C1_0x00479400 | 0.0% | Pending -SHC_3BB0A8C1_0x00479540 | 87.1% | Game STL ctor/dtor; reg rotation +SHC_3BB0A8C1_0x00479540 | 88.2% | Game STL ctor/dtor; reg rotation SHC_3BB0A8C1_0x00479790 | 0.0% | Pending @@ -23071,7 +23071,7 @@ SHC_3BB0A8C1_0x00487770 | 0.0% | Pending SHC_3BB0A8C1_0x00487800 | 0.0% | Pending -SHC_3BB0A8C1_0x00487A30 | 81.2% | Game speed not kept in a register; return-block layout +SHC_3BB0A8C1_0x00487A30 | 68.3% | this spilled to edi across the proxied computeLatencyAdjustmentFromMatchTimes (81.2% with that callee reimplemented); return-block layout SHC_3BB0A8C1_0x00487C50 | 0.0% | Pending @@ -35577,7 +35577,7 @@ SHC_3BB0A8C1_0x004D55D0 | 0.0% | Pending SHC_3BB0A8C1_0x004D5780 | 0.0% | Pending -SHC_3BB0A8C1_0x004D5810 | 58.7% | Frame 8 bytes larger, reg alloc +SHC_3BB0A8C1_0x004D5810 | 58.8% | Frame 8 bytes larger, reg alloc SHC_3BB0A8C1_0x004D5990 | 0.0% | Pending From dda39f8c60716d9f3594d3f28aad9850fadd3800 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 20:59:46 +0100 Subject: [PATCH 46/78] build: list determineGameTicksToPerform.cpp next to the other GameSynchronyState files Same /GL list; the line moves from the end of compiler-flags-gl.txt to the GameSynchronyState group, so this PR and the rendering one do not both append at the end of the file. Co-Authored-By: Claude Opus 5.5 --- cmake/compiler-flags-gl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index c29b10e1cb..2e77b69bc1 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -59,6 +59,7 @@ src/OpenSHC/Map/Buildings/BuildingsState/processResourceLoss.cpp src/OpenSHC/Map/Buildings/BuildingsState/canUnitReachBuildingPerimeter.cpp src/OpenSHC/Synchrony/GameSynchronyState/processSyncPacket.cpp src/OpenSHC/Synchrony/GameSynchronyState/translateMultiplayerIDsIntoPlayerIDs.cpp +src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp src/OpenSHC/Map/Buildings/UpdateStables.cpp src/OpenSHC/Map/Buildings/UpdateArmorersWorkshop.cpp src/OpenSHC/Map/Buildings/UpdateFletchersWorkshop.cpp @@ -88,4 +89,3 @@ src/OpenSHC/Map/Buildings/UpdateGoodBuildingMaypole.cpp src/OpenSHC/Map/Buildings/UpdateBadBuildingDungeon.cpp src/OpenSHC/Map/Buildings/UpdateBadBuildingGallows.cpp src/OpenSHC/Map/Buildings/UpdateBadBuildingBurningStake.cpp -src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp From ef53d2ef11492e0b31307a0e93d1d5e6f89699eb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 21:57:22 +0100 Subject: [PATCH 47/78] style: renderBltAndFlip takes its format string from string-literals.hpp (review) s_Vid__d__sys__d_005a6208 instead of the literal; compiles to the same code as before. Co-Authored-By: Claude Opus 5.5 --- .../UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp index e0216e3450..e1d5e832b5 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -3,6 +3,7 @@ #include "OpenSHC/OS.func.hpp" #include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" #include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" @@ -110,7 +111,7 @@ namespace UI { sourceRect.right = this->gameResolutionX; sourceRect.bottom = this->gameResolutionY; if (param_1 == 1) { - MACRO_CALL(OpenSHC::OS_Func::_sprintf)(debugText, "Vid %d, sys %d", + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(debugText, s_Vid__d__sys__d_005a6208, this->directDrawBackbufferSurfacePointer, this->directDrawOffscreenSurfacePointer_screenMenu); } if (this->runGameAsExclusiveFullscreen != FALSE) { From 4942821159ec7c7574150f9da04d4b4a61ce2272 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 22:03:54 +0100 Subject: [PATCH 48/78] style: declare at first use, scoped case locals, braces (draft functions) - determineGameTicksToPerform: locals declared where first used, with plain names; the carry after the tick duration is its own const local. - initializeFinalResultsForActivePlayers: unused locals gone; the kill matrix clear is a nested loop. - openBuildingStatusMenuForBuildingID: the taxes, rations and gatehouse locals live in their case blocks; the drawbridge looks up the large gatehouse, then the small one, without the comma expression. The goto to the shared menu tail stays: an if/else without it measured lower. - renderBltAndFlip: the debug text buffer is declared in its if. - copyBinkToVideoBuffer, renderFunctionResponsibleForManyGameObjects, takeScreenshot: braces on single-statement ifs. Measured with reccmp (both resolver sets on, full build): no function lost match. determineGameTicksToPerform goes from 68.3% to 69.4%; its status line is updated. Co-Authored-By: Claude Opus 5.5 --- .../copyBinkToVideoBuffer.cpp | 13 ++- .../determineGameTicksToPerform.cpp | 62 +++++++-------- ...initializeFinalResultsForActivePlayers.cpp | 79 +++++++++---------- .../openBuildingStatusMenuForBuildingID.cpp | 51 ++++++------ ...rFunctionResponsibleForManyGameObjects.cpp | 9 ++- .../WindowAndDirectDraw/renderBltAndFlip.cpp | 2 +- .../WindowAndDirectDraw/takeScreenshot.cpp | 3 +- status/addresses-SHC-3BB0A8C1.txt | 2 +- 8 files changed, 114 insertions(+), 107 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp index 070368b954..4ececabd9a 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp @@ -40,8 +40,9 @@ namespace Rendering { self->unknown02_zero[binkObjIndex] = 0; } - if (self->binkObjPtrArray[binkObjIndex] == NULL || self->unknownParam07[binkObjIndex] != param_1) + if (self->binkObjPtrArray[binkObjIndex] == NULL || self->unknownParam07[binkObjIndex] != param_1) { return; + } if (BinkWait(self->binkObjPtrArray[binkObjIndex]) == 0) { BinkDoFrame(self->binkObjPtrArray[binkObjIndex]); @@ -79,16 +80,19 @@ namespace Rendering { DAT_WindowAndDirectDraw::instance.resolutionY, COL_BLACK::instance.shortValue); } - if (!self->frameReadyToDisplay[binkObjIndex]) + if (!self->frameReadyToDisplay[binkObjIndex]) { return; + } IDirectDrawSurface* surface; if (self->unknownParam04[binkObjIndex] != 0) { HRESULT result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Lock( NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame, DDLOCK_WAIT, NULL); while (result == DDERR_SURFACELOST) { - if (DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Restore() != DD_OK) + if (DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Restore() + != DD_OK) { return; + } result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Lock( NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame, DDLOCK_WAIT, NULL); } @@ -103,8 +107,9 @@ namespace Rendering { NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104, DDLOCK_WAIT, NULL); while (result == DDERR_SURFACELOST) { if (DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Restore() - != DD_OK) + != DD_OK) { return; + } result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Lock(NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104, DDLOCK_WAIT, NULL); } diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp index 9ea8c2bf44..50986b0760 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp @@ -18,9 +18,6 @@ namespace Synchrony { // FUNCTION: STRONGHOLDCRUSADER 0x00487A30 int GameSynchronyState::determineGameTicksToPerform(int currentPlayerSlotID) { - int _durationOfOneTick; - int _relativeTickTime; - dword _gameSpeedLevel; if (!DAT_GameCore::instance.gameSpeedLevel) { DAT_GameCore::instance.gameSpeedLevel = 40; } @@ -30,17 +27,19 @@ namespace Synchrony { if (this->DAT_GameHalted) { return 0; } + dword gameSpeed; + int tickTimeOffset; if ((this->currentGameMode == Game::GM_SOLITARY) || (this->currentGameMode == Game::GM_SKIRMISH_SINGLE_PLAYER)) { this->mapTimeInTicksSinglePlayer = DAT_GameCore::instance.mapTimeInTicks; - _gameSpeedLevel = DAT_GameCore::instance.gameSpeedLevel; - _relativeTickTime = this->relativeTickTime; + gameSpeed = DAT_GameCore::instance.gameSpeedLevel; + tickTimeOffset = this->relativeTickTime; } else { /* Calculate multiplayer game speed. */ DAT_GameCore::instance.gameSpeedMultiplicator = 1; - _gameSpeedLevel = this->skirmishGameSpeedLevel; + gameSpeed = this->skirmishGameSpeedLevel; DAT_GameSynchronyState::instance.relativeTickTime = 0; MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::computeLatencyAdjustmentFromMatchTimes, this)( currentPlayerSlotID); @@ -53,72 +52,71 @@ namespace Synchrony { if ((int)this->unknownIncrementBy40_01 < 1) { this->unknownIncrementBy40_01 = 1; } - _gameSpeedLevel = this->unknownIncrementBy40_01; + gameSpeed = this->unknownIncrementBy40_01; if ((int)this->unknownIncrementBy40_01 > this->skirmishGameSpeedLevel) { - _gameSpeedLevel = this->skirmishGameSpeedLevel; + gameSpeed = this->skirmishGameSpeedLevel; } } else if (5 < (int)this->ticksAheadOfSlowestPlayer) { - _gameSpeedLevel - = ((5 - (int)this->ticksAheadOfSlowestPlayer) * 2) / 3 + this->skirmishGameSpeedLevel; - if ((int)_gameSpeedLevel < 15) { - _gameSpeedLevel = 15; + gameSpeed = ((5 - (int)this->ticksAheadOfSlowestPlayer) * 2) / 3 + this->skirmishGameSpeedLevel; + if ((int)gameSpeed < 15) { + gameSpeed = 15; } } } } - _relativeTickTime = DAT_GameSynchronyState::instance.relativeTickTime; + tickTimeOffset = DAT_GameSynchronyState::instance.relativeTickTime; } - DAT_GameSynchronyState::instance.relativeTickTime = _relativeTickTime; + DAT_GameSynchronyState::instance.relativeTickTime = tickTimeOffset; + int tickDuration; if (DAT_GameCore::instance.gameSpeedMultiplicator < 0) { - _durationOfOneTick = -1000 / (int)_gameSpeedLevel * DAT_GameCore::instance.gameSpeedMultiplicator; + tickDuration = -1000 / (int)gameSpeed * DAT_GameCore::instance.gameSpeedMultiplicator; } else { - _durationOfOneTick = 1000 / (int)_gameSpeedLevel; + tickDuration = 1000 / (int)gameSpeed; if (1 < DAT_GameCore::instance.gameSpeedMultiplicator) { - _durationOfOneTick = _durationOfOneTick / DAT_GameCore::instance.gameSpeedMultiplicator; + tickDuration = tickDuration / DAT_GameCore::instance.gameSpeedMultiplicator; } } - _relativeTickTime - = DAT_MillisecCarry::instance + (DAT_GameLoopStopwatch::instance.duration_0x0 - _durationOfOneTick); - DAT_MillisecCarry::instance = _relativeTickTime; - if (_relativeTickTime < 0) { + int const millisecCarry + = DAT_MillisecCarry::instance + (DAT_GameLoopStopwatch::instance.duration_0x0 - tickDuration); + DAT_MillisecCarry::instance = millisecCarry; + if (millisecCarry < 0) { /* Wait */ - if (_relativeTickTime < -_durationOfOneTick) { - DAT_MillisecCarry::instance = _relativeTickTime + _durationOfOneTick; + if (millisecCarry < -tickDuration) { + DAT_MillisecCarry::instance = millisecCarry + tickDuration; return 0; } } else { /* Execute game ticks */ - if (DAT_GameCore::instance.averageTimePerGameTick > _durationOfOneTick - && _relativeTickTime >= _durationOfOneTick * 2 && _durationOfOneTick == 1000 / (int)_gameSpeedLevel) { + if (DAT_GameCore::instance.averageTimePerGameTick > tickDuration && millisecCarry >= tickDuration * 2 + && tickDuration == 1000 / (int)gameSpeed) { /* Slow down */ DAT_MillisecCarry::instance = 0; return 2; } - if (DAT_GameCore::instance.averageTimePerGameTick > (_durationOfOneTick * 7) / 10 - && _relativeTickTime >= _durationOfOneTick * 2 && _durationOfOneTick == 1000 / (int)_gameSpeedLevel) { + if (DAT_GameCore::instance.averageTimePerGameTick > (tickDuration * 7) / 10 + && millisecCarry >= tickDuration * 2 && tickDuration == 1000 / (int)gameSpeed) { /* Slow down */ DAT_MillisecCarry::instance = 0; return 3; } - if (_relativeTickTime > _durationOfOneTick * 10) { + if (millisecCarry > tickDuration * 10) { /* Cap game ticks per rendering */ DAT_MillisecCarry::instance = 0; return 11; } - if (_relativeTickTime > _durationOfOneTick) { - DAT_MillisecCarry::instance - = _relativeTickTime - (_relativeTickTime / _durationOfOneTick) * _durationOfOneTick; - return _relativeTickTime / _durationOfOneTick + 1; + if (millisecCarry > tickDuration) { + DAT_MillisecCarry::instance = millisecCarry - (millisecCarry / tickDuration) * tickDuration; + return millisecCarry / tickDuration + 1; } } return 1; diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp index 9c04e20733..37dd7902e8 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp @@ -13,55 +13,52 @@ namespace Synchrony { // FUNCTION: STRONGHOLDCRUSADER 0x00486F20 void GameSynchronyState::initializeFinalResultsForActivePlayers() { - byte* pbVar1; - int* piVar4; - int iVar6; - int (*paiVar7)[9]; strcpy(this->DAT_PlayerNames[1], MACRO_CALL_MEMBER(Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); /* - piVar4 stays a walker. Naming the fields it reaches - finalGold, finalBuildingsBurned and the rest, - all at [iVar6] - is measured at 88.5% -> 38.3%, and the last three alone at 88.5% -> 70.4%, so do + perPlayer stays a walker. Naming the fields it reaches - finalGold, finalBuildingsBurned and the rest, + all at [player] - is measured at 88.5% -> 38.3%, and the last three alone at 88.5% -> 70.4%, so do not retry it. */ - for (iVar6 = 1, piVar4 = this->currentPlayerFullIDArray + 1; iVar6 < 9; - iVar6 = iVar6 + 1, piVar4 = piVar4 + 1) { - if ((*piVar4 == -1) && (piVar4[0x1b] == 0)) { - this->finalResults.active[iVar6] = 0; + int* perPlayer = this->currentPlayerFullIDArray + 1; + for (int player = 1; player < 9; player++, perPlayer++) { + // perPlayer[0x1b] is currentAIArray[player]. + if ((*perPlayer == -1) && (perPlayer[0x1b] == 0)) { + this->finalResults.active[player] = 0; } else { - this->finalResults.active[iVar6] = 1; - strcpy(this->finalResults.names[iVar6], this->DAT_PlayerNames[iVar6]); - piVar4[0x42494] = 0; - this->finalResults.finalMaxPopulation[iVar6] = 0; - this->finalResults.finalMaxGoodThings[iVar6] = 0; - this->finalResults.finalMaxBadThings[iVar6] = 0; - piVar4[0x424fe] = 0; - piVar4[0x42542] = 0; - piVar4[0x42507] = 0; - piVar4[0x42539] = 0; - piVar4[0x42510] = 0; - piVar4[0x42519] = 0; - piVar4[0x42522] = 0; - piVar4[0x4252b] = 0; - this->finalResults.finalKilledLords[iVar6] = 0; - piVar4[0x4254b] = 0; - piVar4[0x42554] = 0; - piVar4[0x424a4] = 0; - piVar4[0x4255d] = 0; - piVar4[0x42566] = 0; - piVar4[0x4256f] = 0; - this->finalResults.unknownShortArray1[iVar6] = 0; - this->finalResults.unknownShortArray2[iVar6] = 0; - piVar4[0x42581] = 0; - piVar4[0x4258a] = 0; - piVar4[0x42593] = 0; - piVar4[0x4259c] = 0; + this->finalResults.active[player] = 1; + strcpy(this->finalResults.names[player], this->DAT_PlayerNames[player]); + perPlayer[0x42494] = 0; + this->finalResults.finalMaxPopulation[player] = 0; + this->finalResults.finalMaxGoodThings[player] = 0; + this->finalResults.finalMaxBadThings[player] = 0; + perPlayer[0x424fe] = 0; + perPlayer[0x42542] = 0; + perPlayer[0x42507] = 0; + perPlayer[0x42539] = 0; + perPlayer[0x42510] = 0; + perPlayer[0x42519] = 0; + perPlayer[0x42522] = 0; + perPlayer[0x4252b] = 0; + this->finalResults.finalKilledLords[player] = 0; + perPlayer[0x4254b] = 0; + perPlayer[0x42554] = 0; + perPlayer[0x424a4] = 0; + perPlayer[0x4255d] = 0; + perPlayer[0x42566] = 0; + perPlayer[0x4256f] = 0; + this->finalResults.unknownShortArray1[player] = 0; + this->finalResults.unknownShortArray2[player] = 0; + perPlayer[0x42581] = 0; + perPlayer[0x4258a] = 0; + perPlayer[0x42593] = 0; + perPlayer[0x4259c] = 0; } } - paiVar7 = this->finalResults.finalKillMatrix; - for (iVar6 = 0x51; iVar6 != 0; iVar6 = iVar6 + -1) { - (*paiVar7)[0] = 0; - paiVar7 = (int (*)[9])(*paiVar7 + 1); + for (int row = 0; row < 9; row++) { + for (int column = 0; column < 9; column++) { + this->finalResults.finalKillMatrix[row][column] = 0; + } } } diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp index e52ff608cb..3d710d695f 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp @@ -146,8 +146,6 @@ namespace UI { .buildingType), 1, DAT_GameSynchronyState::instance.currentPlayerSlotID); int const currentPlayer = DAT_GameSynchronyState::instance.currentPlayerSlotID; - int setting; - int gatehouse; switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { case OpenSHC::Map::Buildings::BT_MERCENARYPOST: menuTab = 0x2c; @@ -171,14 +169,16 @@ namespace UI { case OpenSHC::Map::Buildings::BT_KEEPFIVE: case OpenSHC::Map::Buildings::BT_KEEPDOOR_LEFT: case OpenSHC::Map::Buildings::BT_KEEPDOOR_RIGHT: - case OpenSHC::Map::Buildings::BT_KEEPDOOR: - setting = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .taxesSetting; + case OpenSHC::Map::Buildings::BT_KEEPDOOR: { + int const taxes + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .taxesSetting; DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .taxesSetting2 = setting; + .taxesSetting2 = taxes; menuTab = 2; - DAT_GameState::instance.playerDataArray[currentPlayer].taxesSliderUI = setting; + DAT_GameState::instance.playerDataArray[currentPlayer].taxesSliderUI = taxes; break; + } case OpenSHC::Map::Buildings::BT_INN: menuTab = 3; break; @@ -228,14 +228,16 @@ namespace UI { case OpenSHC::Map::Buildings::BT_BREWERY: menuTab = 0x13; break; - case OpenSHC::Map::Buildings::BT_GRANARY: - setting = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .rationsSetting; + case OpenSHC::Map::Buildings::BT_GRANARY: { + int const rations + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .rationsSetting; DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .rationsSetting2 = setting; + .rationsSetting2 = rations; menuTab = 4; - DAT_GameState::instance.playerDataArray[currentPlayer].rationsSetting3 = setting; + DAT_GameState::instance.playerDataArray[currentPlayer].rationsSetting3 = rations; break; + } case OpenSHC::Map::Buildings::BT_QUARRY: menuTab = 0x14; break; @@ -299,27 +301,28 @@ namespace UI { } menuTab = 0x24; break; - case OpenSHC::Map::Buildings::BT_DRAWBRIDGE: - gatehouse = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, + case OpenSHC::Map::Buildings::BT_DRAWBRIDGE: { + // The drawbridge belongs to the large or the small gatehouse next to it. + int gatehouse = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, DAT_BuildingsState::ptr)((int)DAT_BuildingsState::instance.buildings[buildingID].owner, (int)((short)DAT_BuildingsState::instance.buildings[buildingID].x), (int)((short)DAT_BuildingsState::instance.buildings[buildingID].y), (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), OpenSHC::Map::Buildings::BT_GATEHOUSELARGE, 0); - if (((gatehouse != 0) - || (gatehouse - = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, - DAT_BuildingsState::ptr)((int)DAT_BuildingsState::instance.buildings[buildingID].owner, - (int)((short)DAT_BuildingsState::instance.buildings[buildingID].x), - (int)((short)DAT_BuildingsState::instance.buildings[buildingID].y), - (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), - OpenSHC::Map::Buildings::BT_GATEHOUSESMALL, 0), - gatehouse != 0)) - && DAT_BuildingsState::instance.buildings[gatehouse].field203_0x2c6 != 0) { + if (gatehouse == 0) { + gatehouse = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, + DAT_BuildingsState::ptr)((int)DAT_BuildingsState::instance.buildings[buildingID].owner, + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].x), + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].y), + (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), + OpenSHC::Map::Buildings::BT_GATEHOUSESMALL, 0); + } + if (gatehouse != 0 && DAT_BuildingsState::instance.buildings[gatehouse].field203_0x2c6 != 0) { return FALSE; } menuTab = 0x25; break; + } case OpenSHC::Map::Buildings::BT_WOODGATE2: menuTab = 0x26; break; diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp index d5062e633d..6ea3b0ad08 100644 --- a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp @@ -44,8 +44,9 @@ namespace UI { int lineTail; void** streamRunHandlers = s_tgxStreamPixelHandlers; void** repeatedPixelHandlers = s_tgxRepeatedPixelHandlers; - if (imageHeight <= 0) + if (imageHeight <= 0) { return; + } if (DAT_TextureRenderCoreObject::instance.isZoom2 == 0) { switch (this->drawBufferChoiceValue) { @@ -76,8 +77,9 @@ namespace UI { } if (drawY + imageHeight > heightMax) { imageHeight = imageHeight - (drawY + imageHeight - heightMax); - if (imageHeight <= 0) + if (imageHeight <= 0) { return; + } } // clang-format off __asm { @@ -1346,8 +1348,9 @@ namespace UI { heightStart = this->mapGameSurfaceHeightRange.start; if (drawY + imageHeight > this->mapGameSurfaceHeightRange.end) { imageHeight = imageHeight - (drawY + imageHeight - this->mapGameSurfaceHeightRange.end); - if (imageHeight <= 0) + if (imageHeight <= 0) { return; + } } // clang-format off __asm { diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp index e1d5e832b5..b5912fe181 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -71,7 +71,6 @@ namespace UI { { RECT destinationRect; RECT sourceRect; - char debugText[2000]; int menuBarHeight = 128; BOOL mapBltPending = FALSE; if (param_1 >= 100) { @@ -111,6 +110,7 @@ namespace UI { sourceRect.right = this->gameResolutionX; sourceRect.bottom = this->gameResolutionY; if (param_1 == 1) { + char debugText[2000]; MACRO_CALL(OpenSHC::OS_Func::_sprintf)(debugText, s_Vid__d__sys__d_005a6208, this->directDrawBackbufferSurfacePointer, this->directDrawOffscreenSurfacePointer_screenMenu); } diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp index 423c216775..2f76d38fe8 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp @@ -35,8 +35,9 @@ namespace UI { // game's own operator<<(ostream&, char), OS::basic_ofstream_write (0x004791B0); the stream object is our // library's std::ofstream, which has the same VC8 layout. std::ofstream file(path, std::ios::binary); - if (file.fail()) + if (file.fail()) { return; + } MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltMapGameSurfaceToScreenMenuSurfaceComplete, this)(); diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index bd395c687f..df64a66f2c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23071,7 +23071,7 @@ SHC_3BB0A8C1_0x00487770 | 0.0% | Pending SHC_3BB0A8C1_0x00487800 | 0.0% | Pending -SHC_3BB0A8C1_0x00487A30 | 68.3% | this spilled to edi across the proxied computeLatencyAdjustmentFromMatchTimes (81.2% with that callee reimplemented); return-block layout +SHC_3BB0A8C1_0x00487A30 | 69.4% | this spilled to edi across the proxied computeLatencyAdjustmentFromMatchTimes (81.2% with that callee reimplemented); return-block layout SHC_3BB0A8C1_0x00487C50 | 0.0% | Pending From 9d53d546f8852c6683103a9015121647395b2bf9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 3 Nov 2026 22:59:18 +0100 Subject: [PATCH 49/78] style: review fixes (decimal numbers, compound assignments, includes) - Numbers outside bit operations are decimal; colours stay hex. - x = x op y is written x op= y, and x = x + 1 is ++x. - BOOLEnum values are tested by truthiness instead of == FALSE / != FALSE. The == TRUE / != TRUE tests stay: the original compares with 1 (truthiness measured 69.4% -> 43.1% in determineGameTicksToPerform). - The first include is the class's own .func.hpp; no header is included twice; block comments are // lines. - getCommandIDFromCommandSelectionStuff clears selectedGameCommands by sizeof without an address cast; prepareWindowAndDDraw_2Unk passes the surface pointer without one. - copyBinkToVideoBuffer and renderBltAndFlip name their parameters. Measured with reccmp (both resolver sets on, full build): no function lost match. Co-Authored-By: Claude Opus 5.5 --- .../Bink/AIMessageQueue/playAiLordMessage.cpp | 4 +- .../copyBinkToVideoBuffer.cpp | 20 +-- .../BlitMapImageWithVerticalClip.cpp | 12 +- ...BlitMapImageWithVerticalClipAndYOffset.cpp | 20 +-- .../determineGameTicksToPerform.cpp | 32 ++--- .../getCommandIDFromCommandSelectionStuff.cpp | 10 +- ...initializeFinalResultsForActivePlayers.cpp | 51 ++++--- .../RenderBuildingMenu_ChapelAndChurch.cpp | 96 ++++++------- .../activateModalDialog2.cpp | 12 +- .../activateModalDialogAndClearText.cpp | 4 +- .../UI/MenuTextInputState/popModalDialog.cpp | 1 - .../convertMinimapClickToTileXY.cpp | 8 +- .../locatePlayerKeepPositionsOnMinimap.cpp | 10 +- ...renderMinimapTileStripWithLuminescence.cpp | 42 +++--- .../openBuildingStatusMenuForBuildingID.cpp | 128 +++++++++--------- .../RenderAnimatedTutorialFloatOverlay.cpp | 20 +-- src/OpenSHC/UI/Rendering/RenderGoldValue.cpp | 18 +-- .../UI/Rendering/RenderGreatestLordScreen.cpp | 40 +++--- .../Rendering/RenderMissionObjectivesUnk.cpp | 8 +- .../RenderScenarioButtonWithText.cpp | 2 +- ...rFunctionResponsibleForManyGameObjects.cpp | 4 +- .../bltMapGameSurfaceToScreen.cpp | 5 +- .../prepareWindowAndDDraw_2Unk.cpp | 7 +- .../WindowAndDirectDraw/reinitWindow.cpp | 3 +- .../WindowAndDirectDraw/renderBltAndFlip.cpp | 15 +- .../UI/StatusMenus/RenderStatusMenu_Army.cpp | 46 +++---- .../UI/StatusMenus/RenderStatusMenu_Food.cpp | 16 +-- .../RenderStatusMenu_Population.cpp | 48 +++---- 28 files changed, 329 insertions(+), 353 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp index f20ab1cb09..15e10c8e91 100644 --- a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp +++ b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp @@ -1,8 +1,8 @@ -#include "../../../Rendering.func.hpp" #include "../AIMessageQueue.func.hpp" #include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" #include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Rendering.func.hpp" #include "OpenSHC/Text/FontSizeClass.func.hpp" #include "OpenSHC/Text/TextManager.func.hpp" #include "OpenSHC/UI/DisplayElements.func.hpp" @@ -55,7 +55,7 @@ namespace Rendering { } if (MACRO_CALL(UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO)) { - yOffset = yOffset - 40; + yOffset -= 40; } int textHeight; int textWidth; diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp index 4ececabd9a..b9437c2879 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp @@ -1,7 +1,7 @@ -#include "../../../Rendering.func.hpp" +#include "../BinkControlClass.func.hpp" #include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" -#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Rendering.func.hpp" #include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" #include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" #include "OpenSHC/Rendering/Bink/UnsortedBinkFlag.hpp" @@ -25,7 +25,7 @@ namespace Rendering { // increment. Plain `inline` is not expanded by MSVC here, so it has to be __forceinline (same code as a goto, // no goto needed). static __forceinline void copyBinkToVideoBuffer_copyFrame( - BinkControlClass* self, int binkObjIndex, dword param_1) + BinkControlClass* self, int binkObjIndex, dword videoTarget) { if (self->soundStreamIndex[binkObjIndex] != OpenSHC::Audio::MSS::enums::SND_STR_MUSIC) { if (!MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, @@ -35,12 +35,12 @@ namespace Rendering { } } - if (self->unknownParam07[binkObjIndex] == param_1) { + if (self->unknownParam07[binkObjIndex] == videoTarget) { self->unknown01_zero[binkObjIndex] = 0; self->unknown02_zero[binkObjIndex] = 0; } - if (self->binkObjPtrArray[binkObjIndex] == NULL || self->unknownParam07[binkObjIndex] != param_1) { + if (self->binkObjPtrArray[binkObjIndex] == NULL || self->unknownParam07[binkObjIndex] != videoTarget) { return; } @@ -50,14 +50,14 @@ namespace Rendering { if ((self->binkObjPtrArray[binkObjIndex]->FrameNum == self->binkObjPtrArray[binkObjIndex]->Frames) && (self->unknownParam03[binkObjIndex] == 0)) { if (self->soundStreamIndex[binkObjIndex] == OpenSHC::Audio::MSS::enums::SND_STR_MUSIC) { - if (param_1 != 2) { + if (videoTarget != 2) { self->unknown01_zero[binkObjIndex] = 1; MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, self)( binkObjIndex); return; } self->unknown02_zero[binkObjIndex] = 1; - } else if (param_1 == 2) { + } else if (videoTarget == 2) { self->unknown02_zero[binkObjIndex] = 1; } } else { @@ -67,7 +67,7 @@ namespace Rendering { self->frameReadyToDisplay[binkObjIndex] = TRUE; } - if (param_1 == 2) { + if (videoTarget == 2) { int const menuBorderHeight = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; int const menuBorderWidth = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth; OpenSHC::UI::Menu* const menu = DAT_MenuHandlerState::instance.currentMenu; @@ -124,10 +124,10 @@ namespace Rendering { } // FUNCTION: STRONGHOLDCRUSADER 0x00408FC0 - void BinkControlClass::copyBinkToVideoBuffer(dword param_1) + void BinkControlClass::copyBinkToVideoBuffer(dword videoTarget) { for (int binkObjIndex = 0; binkObjIndex < 2; binkObjIndex++) { - copyBinkToVideoBuffer_copyFrame(this, binkObjIndex, param_1); + copyBinkToVideoBuffer_copyFrame(this, binkObjIndex, videoTarget); } } diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp index 1334f46966..f79cab693c 100644 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp @@ -45,8 +45,8 @@ void Rendering::BlitMapImageWithVerticalClip() int const clippedRows = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - drawY; nextSkip = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - height - drawY; drawY = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; - DAT_00ed3170::instance = DAT_00ed3170::instance - clippedRows; - height = height - clippedRows; + DAT_00ed3170::instance -= clippedRows; + height -= clippedRows; skip = clippedRows * 60; } if ((int)(DAT_00ed3170::instance + drawY) >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { @@ -58,17 +58,17 @@ void Rendering::BlitMapImageWithVerticalClip() int firstRows; if (height <= 0) { firstRows = 0; - nextSkip = nextSkip * 60; + nextSkip *= 60; } else if (height < (int)DAT_00ed3170::instance) { firstRows = height; - DAT_00ed3170::instance = DAT_00ed3170::instance - height; + DAT_00ed3170::instance -= height; nextSkip = 0; } else { firstRows = DAT_00ed3170::instance; DAT_00ed3170::instance = 0; } - image = image + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; - nextImage = nextImage + DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; + image += DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; + nextImage += DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; if (!DAT_TextureRenderCoreObject::instance.isZoom2) { // clang-format off __asm { diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp index d1979b7bff..2a6be0c9a6 100644 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp @@ -40,10 +40,10 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() } if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { skip = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - drawY; - DAT_00ed3170::instance = DAT_00ed3170::instance - skip; + DAT_00ed3170::instance -= skip; drawY = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; - nextSkip = nextSkip + skip; - height = height - skip; + nextSkip += skip; + height -= skip; } if ((int)(DAT_00ed3170::instance + drawY) >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { DAT_00ed3170::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; @@ -52,25 +52,25 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() + (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - DAT_00ed3170::instance - drawY); } // rows to bytes: tile objects are 15 dwords per row - skip = skip * 60; - nextSkip = nextSkip * 60; + skip *= 60; + nextSkip *= 60; int firstRows; if (height <= 0) { firstRows = 0; } else if (height < (int)DAT_00ed3170::instance) { - DAT_00ed3170::instance = DAT_00ed3170::instance - height; + DAT_00ed3170::instance -= height; firstRows = height; - nextSkip = nextSkip + height * 60; + nextSkip += height * 60; } else { firstRows = DAT_00ed3170::instance; DAT_00ed3170::instance = 0; skip = nextSkip; } if (DAT_00ed317c::instance == 3) { - skip = skip - 480; + skip -= 480; } - image = image + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; - nextImage = nextImage + DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; + image += DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; + nextImage += DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; if (!DAT_TextureRenderCoreObject::instance.isZoom2) { // clang-format off __asm { diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp index 50986b0760..5ea62e0ea2 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp @@ -1,6 +1,6 @@ -#include "../../Synchrony.func.hpp" +#include "../GameSynchronyState.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" #include "OpenSHC/Game/GameMode.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" @@ -35,9 +35,7 @@ namespace Synchrony { gameSpeed = DAT_GameCore::instance.gameSpeedLevel; tickTimeOffset = this->relativeTickTime; } else { - /* - Calculate multiplayer game speed. - */ + // Calculate multiplayer game speed. DAT_GameCore::instance.gameSpeedMultiplicator = 1; gameSpeed = this->skirmishGameSpeedLevel; DAT_GameSynchronyState::instance.relativeTickTime = 0; @@ -48,7 +46,7 @@ namespace Synchrony { } else { if (0 < (int)this->ticksAheadOfSlowestPlayer) { DAT_GameSynchronyState::instance.relativeTickTime = (int)this->ticksAheadOfSlowestPlayer; - if ((int)this->ticksAheadOfSlowestPlayer > (int)this->commandDelay + 0x4b) { + if ((int)this->ticksAheadOfSlowestPlayer > (int)this->commandDelay + 75) { if ((int)this->unknownIncrementBy40_01 < 1) { this->unknownIncrementBy40_01 = 1; } @@ -73,44 +71,34 @@ namespace Synchrony { } else { tickDuration = 1000 / (int)gameSpeed; if (1 < DAT_GameCore::instance.gameSpeedMultiplicator) { - tickDuration = tickDuration / DAT_GameCore::instance.gameSpeedMultiplicator; + tickDuration /= DAT_GameCore::instance.gameSpeedMultiplicator; } } int const millisecCarry = DAT_MillisecCarry::instance + (DAT_GameLoopStopwatch::instance.duration_0x0 - tickDuration); DAT_MillisecCarry::instance = millisecCarry; if (millisecCarry < 0) { - /* - Wait - */ + // Wait if (millisecCarry < -tickDuration) { DAT_MillisecCarry::instance = millisecCarry + tickDuration; return 0; } } else { - /* - Execute game ticks - */ + // Execute game ticks if (DAT_GameCore::instance.averageTimePerGameTick > tickDuration && millisecCarry >= tickDuration * 2 && tickDuration == 1000 / (int)gameSpeed) { - /* - Slow down - */ + // Slow down DAT_MillisecCarry::instance = 0; return 2; } if (DAT_GameCore::instance.averageTimePerGameTick > (tickDuration * 7) / 10 && millisecCarry >= tickDuration * 2 && tickDuration == 1000 / (int)gameSpeed) { - /* - Slow down - */ + // Slow down DAT_MillisecCarry::instance = 0; return 3; } if (millisecCarry > tickDuration * 10) { - /* - Cap game ticks per rendering - */ + // Cap game ticks per rendering DAT_MillisecCarry::instance = 0; return 11; } diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp index 80477dedd5..312927b647 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp @@ -1,7 +1,7 @@ -#include "../../Synchrony.func.hpp" +#include "../GameSynchronyState.func.hpp" #include "OpenSHC/IO/LowLevelMemory.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" #include "OpenSHC/Commands/GameCommandState.hpp" #include "OpenSHC/Commands/GameCommandStateByte.hpp" @@ -19,10 +19,10 @@ namespace Synchrony { { this->someIndex = 0; MACRO_CALL_MEMBER(IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( - 800, 0, (void*)((int)(this->selectedGameCommands))); + sizeof(this->selectedGameCommands), 0, this->selectedGameCommands); for (int command = this->gameCommandID; command < 200; command++) { // The command has not been processed yet, should be processed, and its time has come. - if (this->DAT_GameCommandArray[command].stateUnk != (GameCommandState)0 + if (this->DAT_GameCommandArray[command].stateUnk != 0 && (char)this->DAT_GameCommandArray[command].stateUnk < 10 && (int)this->DAT_GameCommandArray[command].time <= (int)DAT_GameCore::instance.mapTimeInTicks) { this->protocolInvokerPlayerID @@ -30,7 +30,7 @@ namespace Synchrony { this->DAT_GameCommandArray[command].playerUnk); this->selectedGameCommands[this->someIndex][0] = command; this->selectedGameCommands[this->someIndex][1] = this->protocolInvokerPlayerID; - this->someIndex = this->someIndex + 1; + ++this->someIndex; if (this->someIndex >= 100) { break; } diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp index 37dd7902e8..3596b47d63 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp @@ -1,6 +1,6 @@ -#include "../../Synchrony.func.hpp" #include "../GameSynchronyState.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" #include "OpenSHC/Text/UserTextHandler.func.hpp" #include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" @@ -15,44 +15,41 @@ namespace Synchrony { { strcpy(this->DAT_PlayerNames[1], MACRO_CALL_MEMBER(Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); - /* - perPlayer stays a walker. Naming the fields it reaches - finalGold, finalBuildingsBurned and the rest, - all at [player] - is measured at 88.5% -> 38.3%, and the last three alone at 88.5% -> 70.4%, so do - not retry it. - */ + // perPlayer stays a walker. Naming the fields it reaches - finalGold, finalBuildingsBurned and the rest, all at + // [player] - is measured at 88.5% -> 38.3%, and the last three alone at 88.5% -> 70.4%, so do not retry it. int* perPlayer = this->currentPlayerFullIDArray + 1; for (int player = 1; player < 9; player++, perPlayer++) { - // perPlayer[0x1b] is currentAIArray[player]. - if ((*perPlayer == -1) && (perPlayer[0x1b] == 0)) { + // perPlayer[27] is currentAIArray[player]. + if ((*perPlayer == -1) && (perPlayer[27] == 0)) { this->finalResults.active[player] = 0; } else { this->finalResults.active[player] = 1; strcpy(this->finalResults.names[player], this->DAT_PlayerNames[player]); - perPlayer[0x42494] = 0; + perPlayer[271508] = 0; this->finalResults.finalMaxPopulation[player] = 0; this->finalResults.finalMaxGoodThings[player] = 0; this->finalResults.finalMaxBadThings[player] = 0; - perPlayer[0x424fe] = 0; - perPlayer[0x42542] = 0; - perPlayer[0x42507] = 0; - perPlayer[0x42539] = 0; - perPlayer[0x42510] = 0; - perPlayer[0x42519] = 0; - perPlayer[0x42522] = 0; - perPlayer[0x4252b] = 0; + perPlayer[271614] = 0; + perPlayer[271682] = 0; + perPlayer[271623] = 0; + perPlayer[271673] = 0; + perPlayer[271632] = 0; + perPlayer[271641] = 0; + perPlayer[271650] = 0; + perPlayer[271659] = 0; this->finalResults.finalKilledLords[player] = 0; - perPlayer[0x4254b] = 0; - perPlayer[0x42554] = 0; - perPlayer[0x424a4] = 0; - perPlayer[0x4255d] = 0; - perPlayer[0x42566] = 0; - perPlayer[0x4256f] = 0; + perPlayer[271691] = 0; + perPlayer[271700] = 0; + perPlayer[271524] = 0; + perPlayer[271709] = 0; + perPlayer[271718] = 0; + perPlayer[271727] = 0; this->finalResults.unknownShortArray1[player] = 0; this->finalResults.unknownShortArray2[player] = 0; - perPlayer[0x42581] = 0; - perPlayer[0x4258a] = 0; - perPlayer[0x42593] = 0; - perPlayer[0x4259c] = 0; + perPlayer[271745] = 0; + perPlayer[271754] = 0; + perPlayer[271763] = 0; + perPlayer[271772] = 0; } } for (int row = 0; row < 9; row++) { diff --git a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp index 15e3e3fa94..53dedbe93c 100644 --- a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp +++ b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp @@ -63,11 +63,11 @@ namespace UI { = DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID].buildingType; // "Cathedral" if (BVar2 == OpenSHC::Map::Buildings::BT_CHAPEL) { - iVar11 = DAT_MenuHandlerState::instance.y + 0x1d3; - iVar8 = DAT_MenuHandlerState::instance.x + 0x19; + iVar11 = DAT_MenuHandlerState::instance.y + 467; + iVar8 = DAT_MenuHandlerState::instance.x + 25; blendStrength = 0; BVar9 = FALSE; - iVar10 = 0x10; + iVar10 = 16; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( @@ -75,11 +75,11 @@ namespace UI { DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 0), iVar8, iVar11, TVar6, BVar7, iVar10, BVar9, blendStrength); } else if (BVar2 == OpenSHC::Map::Buildings::BT_CHURCH) { - iVar11 = DAT_MenuHandlerState::instance.y + 0x1d3; - iVar8 = DAT_MenuHandlerState::instance.x + 0x19; + iVar11 = DAT_MenuHandlerState::instance.y + 467; + iVar8 = DAT_MenuHandlerState::instance.x + 25; blendStrength = 0; BVar9 = FALSE; - iVar10 = 0x10; + iVar10 = 16; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( @@ -87,11 +87,11 @@ namespace UI { DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 3), iVar8, iVar11, TVar6, BVar7, iVar10, BVar9, blendStrength); } else if (BVar2 == OpenSHC::Map::Buildings::BT_CATHEDRAL) { - iVar11 = DAT_MenuHandlerState::instance.y + 0x1d3; - iVar8 = DAT_MenuHandlerState::instance.x + 0x19; + iVar11 = DAT_MenuHandlerState::instance.y + 467; + iVar8 = DAT_MenuHandlerState::instance.x + 25; blendStrength = 0; BVar9 = FALSE; - iVar10 = 0x10; + iVar10 = 16; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( @@ -103,15 +103,15 @@ namespace UI { if (DAT_BuildingsState::instance.buildings[iVar4].currentEmployeeCount == 0) { iVar11 = 0; BVar9 = FALSE; - iVar8 = 0x12; + iVar8 = 18; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; - iVar4 = DAT_MenuHandlerState::instance.y + 0x205; - iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; + iVar4 = DAT_MenuHandlerState::instance.y + 517; + iVar5 = DAT_MenuHandlerState::instance.x + 175; // "No Wedding this month" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 34), iVar5, iVar4, TVar6, BVar7, iVar8, BVar9, iVar11); return; } @@ -120,18 +120,18 @@ namespace UI { DAT_00b9843c::instance = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::chooseHusbandAndWife, DAT_UnitsState::ptr)((int*)DAT_HusbandID::ptr, (int*)DAT_WifeID::ptr); if (DAT_00b9843c::instance == 0) { - /* no wedding this month: render the notice and stop */ + // no wedding this month: render the notice and stop iVar11 = 0; BVar9 = FALSE; - iVar8 = 0x12; + iVar8 = 18; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; - iVar4 = DAT_MenuHandlerState::instance.y + 0x205; - iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; + iVar4 = DAT_MenuHandlerState::instance.y + 517; + iVar5 = DAT_MenuHandlerState::instance.x + 175; // "No Wedding this month" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 34), iVar5, iVar4, TVar6, BVar7, iVar8, BVar9, iVar11); return; } @@ -141,19 +141,19 @@ namespace UI { = (UnitTypeInt)(short)DAT_UnitsState::instance.units[DAT_WifeID::instance].unitType; switch (DAT_WifeUnitType::instance) { case OpenSHC::Map::Units::UT_BREWER: - DAT_00b98428::instance = DAT_00b98428::instance + 1; + ++DAT_00b98428::instance; if (9 < (int)DAT_00b98428::instance) { DAT_00b98428::instance = 0; } break; case OpenSHC::Map::Units::UT_TANNER: - DAT_00b9842c::instance = DAT_00b9842c::instance + 1; + ++DAT_00b9842c::instance; if (9 < (int)DAT_00b9842c::instance) { DAT_00b9842c::instance = 0; } break; default: - DAT_00b98430::instance = DAT_00b98430::instance + 1; + ++DAT_00b98430::instance; if (9 < (int)DAT_00b98430::instance) { DAT_00b98430::instance = 0; } @@ -171,26 +171,26 @@ namespace UI { if (DAT_00b9843c::instance != 0) { MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, DAT_TextureRenderCoreObject::ptr)( - 1, DAT_MenuHandlerState::instance.x + 0x173, DAT_MenuHandlerState::instance.y + 0x1e0); + 1, DAT_MenuHandlerState::instance.x + 371, DAT_MenuHandlerState::instance.y + 480); iVar8 = 0; - iVar5 = 0x12; + iVar5 = 18; color = 0; - iVar4 = 0x15e; + iVar4 = 350; if (DAT_WifeUnitType::instance != OpenSHC::Map::Units::UT_BREWER) { if (DAT_WifeUnitType::instance == OpenSHC::Map::Units::UT_TANNER) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineTextUnk, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b9842c::instance + 0xc, - DAT_MenuHandlerState::instance.x + 0xb4, DAT_MenuHandlerState::instance.y + 0x22f, 0x15e, 0, - 0x12, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b9842c::instance + 12, + DAT_MenuHandlerState::instance.x + 180, DAT_MenuHandlerState::instance.y + 559, 350, 0, 18, + 0); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineTextUnk, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, - DAT_00b98430::instance + 0x17, DAT_MenuHandlerState::instance.x + 0xb4, - DAT_MenuHandlerState::instance.y + 0x22f, 0x15e, 0, 0x12, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b98430::instance + 23, + DAT_MenuHandlerState::instance.x + 180, DAT_MenuHandlerState::instance.y + 559, 350, 0, 18, + 0); } } else { - iVar11 = DAT_MenuHandlerState::instance.y + 0x22f; - iVar10 = DAT_MenuHandlerState::instance.x + 0xb4; + iVar11 = DAT_MenuHandlerState::instance.y + 559; + iVar10 = DAT_MenuHandlerState::instance.x + 180; MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, @@ -203,24 +203,24 @@ namespace UI { DAT_RenderedUnitOwner::instance = 0; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_CurrentlyRenderedSpriteID::instance, - 3, DAT_MenuHandlerState::instance.x + 0x82, DAT_MenuHandlerState::instance.y + 0x1c4); + 3, DAT_MenuHandlerState::instance.x + 130, DAT_MenuHandlerState::instance.y + 452); DAT_CurrentlyRenderedSpriteID::instance = MACRO_CALL_MEMBER( OpenSHC::Map::Units::UnitsState_Func::getPeasantGmID, DAT_UnitsState::ptr)(DAT_WifeID::instance); DAT_RenderedUnitOwner::instance = 0; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_CurrentlyRenderedSpriteID::instance, - 3, DAT_MenuHandlerState::instance.x + 0x91, DAT_MenuHandlerState::instance.y + 0x1dd); + 3, DAT_MenuHandlerState::instance.x + 145, DAT_MenuHandlerState::instance.y + 477); iVar4 = DAT_HusbandID::instance; byte bVar1 = DAT_UnitsState::instance.units[DAT_HusbandID::instance].firstNameIndex; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; if ('\0' < (char)bVar1) { iVar10 = 0; BVar9 = FALSE; - iVar11 = 0x12; + iVar11 = 18; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; - iVar5 = DAT_MenuHandlerState::instance.y + 0x1ec; - iVar8 = DAT_MenuHandlerState::instance.x + 0xd7; + iVar5 = DAT_MenuHandlerState::instance.y + 492; + iVar8 = DAT_MenuHandlerState::instance.x + 215; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PEASANT_NAMES, (int)((char)bVar1)), @@ -229,8 +229,8 @@ namespace UI { if (bVar1 != 0) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_PEASANT_SURNAMES, (int)((char)bVar1), - DAT_MenuHandlerState::instance.x + 0xdc, DAT_MenuHandlerState::instance.y + 0x1ec, - OpenSHC::Text::TTA_LEFT, 0, 0x12, TRUE); + DAT_MenuHandlerState::instance.x + 220, DAT_MenuHandlerState::instance.y + 492, + OpenSHC::Text::TTA_LEFT, 0, 18, TRUE); } } iVar4 = DAT_WifeID::instance; @@ -238,11 +238,11 @@ namespace UI { if ('\0' < (char)bVar1) { iVar10 = 0; BVar9 = FALSE; - iVar11 = 0x12; + iVar11 = 18; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; - iVar5 = DAT_MenuHandlerState::instance.y + 0x205; - iVar8 = DAT_MenuHandlerState::instance.x + 0xe6; + iVar5 = DAT_MenuHandlerState::instance.y + 517; + iVar8 = DAT_MenuHandlerState::instance.x + 230; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PEASANT_NAMES, (int)((char)bVar1)), @@ -251,8 +251,8 @@ namespace UI { if (bVar1 != 0) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_PEASANT_SURNAMES, (int)((char)bVar1), - DAT_MenuHandlerState::instance.x + 0xeb, DAT_MenuHandlerState::instance.y + 0x205, - OpenSHC::Text::TTA_LEFT, 0, 0x12, TRUE); + DAT_MenuHandlerState::instance.x + 235, DAT_MenuHandlerState::instance.y + 517, + OpenSHC::Text::TTA_LEFT, 0, 18, TRUE); } } // a wedding is on: don't show "No Wedding this month" @@ -263,15 +263,15 @@ namespace UI { } iVar11 = 0; BVar9 = FALSE; - iVar8 = 0x12; + iVar8 = 18; BVar7 = 0; TVar6 = OpenSHC::Text::TTA_LEFT; - iVar4 = DAT_MenuHandlerState::instance.y + 0x205; - iVar5 = DAT_MenuHandlerState::instance.x + 0xaf; + iVar4 = DAT_MenuHandlerState::instance.y + 517; + iVar5 = DAT_MenuHandlerState::instance.x + 175; // "No Wedding this month" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 0x22), + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 34), iVar5, iVar4, TVar6, BVar7, iVar8, BVar9, iVar11); } diff --git a/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp b/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp index 78632fe7bb..62e656abbc 100644 --- a/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp +++ b/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp @@ -2,7 +2,6 @@ #include "OpenSHC/Game/GameCore.func.hpp" #include "OpenSHC/Rendering/Bink/AIMessageQueue.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" #include "OpenSHC/UI/MenuTextInputState.func.hpp" #include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" @@ -34,8 +33,7 @@ namespace UI { if (this->activeModalDialogID == OpenSHC::UI::Enums::MMT_DISPLAY_AI_LORD_MESSAGE) { this->activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; if (MACRO_CALL_MEMBER( - OpenSHC::Rendering::Bink::AIMessageQueue_Func::playNextStoredAIMessage, DAT_VideoBikQueue::ptr)() - != FALSE) { + OpenSHC::Rendering::Bink::AIMessageQueue_Func::playNextStoredAIMessage, DAT_VideoBikQueue::ptr)()) { return; } } @@ -52,7 +50,7 @@ namespace UI { this->modalMenu.width = ((this->modalMenu.width - 1) / 24 + 1) * 24; this->modalMenu.height = ((this->modalMenu.height - 1) / 24 + 1) * 24; } - if (MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)() != FALSE) { + if (MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)()) { if (this->modalMenu.x == -1) { this->modalMenu.x = DAT_WindowAndDirectDraw::instance.gameResolutionX / 2 - this->modalMenu.width / 2; } else { @@ -91,9 +89,9 @@ namespace UI { = MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)(); int x = this->modalMenu.x; int y = this->modalMenu.y; - if (inGame != FALSE) { - x = x + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; - y = y + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY; + if (inGame) { + x += DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; + y += DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY; DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltMapGameSurfaceToScreen, DAT_WindowAndDirectDraw::ptr)(x, y, this->modalMenu.width + x, this->modalMenu.height + y); diff --git a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp index 208ce73a32..94ca38ab55 100644 --- a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp @@ -17,9 +17,7 @@ namespace UI { using OpenSHC::UI::Enums::MenuModalType; using OpenSHC::WindowsHelper::Enums::BOOLEnum; - /* - dialogID is 0xb for Exit Crusader or Restart Game, 0xc for Options - */ + // dialogID is 11 for Exit Crusader or Restart Game, 12 for Options // FUNCTION: STRONGHOLDCRUSADER 0x004916C0 void MenuTextInputState::activateModalDialogAndClearText(MenuModalType dialogID) { diff --git a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp index 10e87ded5f..99ee938564 100644 --- a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp @@ -2,7 +2,6 @@ #include "OpenSHC/Text/UserTextHandler.func.hpp" #include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/UI/MenuTextInputState.func.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" diff --git a/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp b/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp index 482cf28cfd..53d3db6f8c 100644 --- a/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp +++ b/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp @@ -20,15 +20,15 @@ namespace UI { *tileY = screenY; if (DAT_TileMapState::instance.mapOrientation != 0) { if (DAT_TileMapState::instance.mapOrientation == 6) { - orientationOffset = 0x13a10; + orientationOffset = 80400; } else if (DAT_TileMapState::instance.mapOrientation == 4) { - orientationOffset = 0x27420; + orientationOffset = 160800; } else if (DAT_TileMapState::instance.mapOrientation == 2) { - orientationOffset = 0x3ae30; + orientationOffset = 241200; } } int const tile = DAT_ViewportRenderState::instance - .screenPointToTileNumber[*tileX / 32 + screenY / 16 * 0x191 + orientationOffset - 6]; + .screenPointToTileNumber[*tileX / 32 + screenY / 16 * 401 + orientationOffset - 6]; int const row = (short)DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent[tile]; *tileY = row; *tileX = tile - DAT_ViewportRenderState::instance.translationMatrix[row].addXgetTile; diff --git a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp index e5f4cba9bb..83f20d3737 100644 --- a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp +++ b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp @@ -31,15 +31,15 @@ namespace UI { int rowParity = viewportHeight + 1; if (DAT_TileMapState::instance.mapOrientation != 0) { if (DAT_TileMapState::instance.mapOrientation == 6) { - orientationOffset = 0x13a18; + orientationOffset = 80408; } else if (DAT_TileMapState::instance.mapOrientation == 4) { - orientationOffset = 0x27428; + orientationOffset = 160808; } else if (DAT_TileMapState::instance.mapOrientation == 2) { - orientationOffset = 0x3ae38; + orientationOffset = 241208; } } int const firstColumn = firstRow / 2; - int rowBase = firstColumn * 0x191 + orientationOffset + 1; + int rowBase = firstColumn * 401 + orientationOffset + 1; for (int row = firstRow; row < lastRow - firstRow; row++) { // the screen tile rows are staggered: every other row is half a tile in and one tile longer int rowX; @@ -84,7 +84,7 @@ namespace UI { } } } - rowBase = rowBase + rowLength; + rowBase += rowLength; } } diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp index 9face8939a..06907e04e1 100644 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp @@ -40,15 +40,15 @@ namespace UI { int rowParity = viewportHeight + 1; if (DAT_TileMapState::instance.mapOrientation != 0) { if (DAT_TileMapState::instance.mapOrientation == 6) { - orientationOffset = 0x13a18; + orientationOffset = 80408; } else if (DAT_TileMapState::instance.mapOrientation == 4) { - orientationOffset = 0x27428; + orientationOffset = 160808; } else if (DAT_TileMapState::instance.mapOrientation == 2) { - orientationOffset = 0x3ae38; + orientationOffset = 241208; } } int const firstColumn = firstRow / 2; - int rowBase = firstColumn * 0x191 + orientationOffset + 1; + int rowBase = firstColumn * 401 + orientationOffset + 1; for (int row = firstRow; row < lastRow - firstRow; row++) { // the screen tile rows are staggered: every other row is half a tile in and one tile longer int rowX; @@ -95,7 +95,7 @@ namespace UI { if (DAT_MiniMapDefinedData::instance.MinimapColorByLogicBit[bit].integer == 0) { break; } - bit = bit + 1; + ++bit; } if (DAT_MiniMapDefinedData::instance.MinimapColorByLogicBit[bit].integer != 0) { color = DAT_MiniMapDefinedData::instance.MinimapColorByLogicBit[bit] @@ -111,30 +111,30 @@ namespace UI { int green; if (isRGB565 == 0) { red = (int)(((ushort)color & 0x7c00) * brightness) / 100; - if (0x7c00 < red) { - red = 0x7c00; + if (31744 < red) { + red = 31744; } green = (int)(((ushort)color & 0x3e0) * brightness) / 100; - red = red & 0x7c00; - if (0x3e0 < green) { - green = 0x3e0; + red &= 0x7c00; + if (992 < green) { + green = 992; } - green = green & 0x3e0; + green &= 0x3e0; } else { red = (int)(((ushort)color & 0xf800) * brightness) / 100; - if (0xf800 < red) { - red = 0xf800; + if (63488 < red) { + red = 63488; } green = (int)(((ushort)color & 0x7e0) * brightness) / 100; - red = red & 0xf800; - if (0x7e0 < green) { - green = 0x7e0; + red &= 0xf800; + if (2016 < green) { + green = 2016; } - green = green & 0x7e0; + green &= 0x7e0; } int blue = (int)(((ushort)color & 0x1f) * brightness) / 100; - if (0x1f < blue) { - blue = 0x1f; + if (31 < blue) { + blue = 31; } color = (ushort)(blue & 0x1f | green | red); } @@ -151,7 +151,7 @@ namespace UI { } } else { // zoomed out: every other pixel, at half the position - for (int dx = x & 1; dx < widthFactor; dx = dx + 2) { + for (int dx = x & 1; dx < widthFactor; dx += 2) { if (0 <= x + dx && x + dx < columns * widthFactor) { int const pixelX = (x + dx) / scale; for (int dy = 0; dy < heightFactor; dy++) { @@ -167,7 +167,7 @@ namespace UI { } } } - rowBase = rowBase + rowLength; + rowBase += rowLength; } } diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp index 3d710d695f..bf0d3a51de 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp @@ -40,7 +40,7 @@ namespace UI { if (owner == 0 && DAT_BuildingsState::instance.buildings[buildingID].buildingType == OpenSHC::Map::Buildings::BT_STATUE) { - menuTab = 0x59; + menuTab = 89; goto openMenu; } switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { @@ -148,12 +148,12 @@ namespace UI { int const currentPlayer = DAT_GameSynchronyState::instance.currentPlayerSlotID; switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { case OpenSHC::Map::Buildings::BT_MERCENARYPOST: - menuTab = 0x2c; + menuTab = 44; break; case OpenSHC::Map::Buildings::BT_OUTPOST_EUROPEAN: case OpenSHC::Map::Buildings::BT_OUTPOST_ARABIAN: if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { - menuTab = 0x2d; + menuTab = 45; break; } MACRO_CALL_MEMBER( @@ -202,31 +202,31 @@ namespace UI { menuTab = 10; break; case OpenSHC::Map::Buildings::BT_STOCKPILE: - menuTab = 0xb; + menuTab = 11; break; case OpenSHC::Map::Buildings::BT_ARMORY: - menuTab = 0xc; + menuTab = 12; break; case OpenSHC::Map::Buildings::BT_FLETCHER: - menuTab = 0xd; + menuTab = 13; break; case OpenSHC::Map::Buildings::BT_BLACKSMITH: - menuTab = 0xe; + menuTab = 14; break; case OpenSHC::Map::Buildings::BT_POLETURNER: - menuTab = 0xf; + menuTab = 15; break; case OpenSHC::Map::Buildings::BT_ARMOURER: - menuTab = 0x10; + menuTab = 16; break; case OpenSHC::Map::Buildings::BT_TANNER: - menuTab = 0x11; + menuTab = 17; break; case OpenSHC::Map::Buildings::BT_BAKERY: - menuTab = 0x12; + menuTab = 18; break; case OpenSHC::Map::Buildings::BT_BREWERY: - menuTab = 0x13; + menuTab = 19; break; case OpenSHC::Map::Buildings::BT_GRANARY: { int const rations @@ -239,59 +239,59 @@ namespace UI { break; } case OpenSHC::Map::Buildings::BT_QUARRY: - menuTab = 0x14; + menuTab = 20; break; case OpenSHC::Map::Buildings::BT_QUARRYSTOCKPILE: - menuTab = 0x15; + menuTab = 21; break; case OpenSHC::Map::Buildings::BT_APOTHECARY: - menuTab = 0x16; + menuTab = 22; break; case OpenSHC::Map::Buildings::BT_ENGINEERSGUILD: - menuTab = 0x17; + menuTab = 23; break; case OpenSHC::Map::Buildings::BT_TUNNELERSGUILD: - menuTab = 0x18; + menuTab = 24; break; case OpenSHC::Map::Buildings::BT_MARKETPLACE: - menuTab = 0x19; + menuTab = 25; break; case OpenSHC::Map::Buildings::BT_WELL: - menuTab = 0x1a; + menuTab = 26; break; case OpenSHC::Map::Buildings::BT_WATERPOT: - menuTab = 0x28; + menuTab = 40; break; case OpenSHC::Map::Buildings::BT_OILSMELTER: - menuTab = 0x1b; + menuTab = 27; break; case OpenSHC::Map::Buildings::BT_SIEGETENT: - menuTab = 0x1c; + menuTab = 28; break; case OpenSHC::Map::Buildings::BT_WHEATFARM: - menuTab = 0x1d; + menuTab = 29; break; case OpenSHC::Map::Buildings::BT_HOPFARM: - menuTab = 0x1e; + menuTab = 30; break; case OpenSHC::Map::Buildings::BT_APPLEFARM: - menuTab = 0x1f; + menuTab = 31; break; case OpenSHC::Map::Buildings::BT_DAIRYFARM: - menuTab = 0x20; + menuTab = 32; break; case OpenSHC::Map::Buildings::BT_MILL: - menuTab = 0x21; + menuTab = 33; break; case OpenSHC::Map::Buildings::BT_STABLES: - menuTab = 0x22; + menuTab = 34; break; case OpenSHC::Map::Buildings::BT_CHAPEL: case OpenSHC::Map::Buildings::BT_CHURCH: - menuTab = 0x23; + menuTab = 35; break; case OpenSHC::Map::Buildings::BT_CATHEDRAL: - menuTab = 0x60; + menuTab = 96; break; case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE: case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: @@ -299,7 +299,7 @@ namespace UI { if (DAT_BuildingsState::instance.buildings[buildingID].field203_0x2c6 != 0) { return FALSE; } - menuTab = 0x24; + menuTab = 36; break; case OpenSHC::Map::Buildings::BT_DRAWBRIDGE: { // The drawbridge belongs to the large or the small gatehouse next to it. @@ -320,45 +320,45 @@ namespace UI { if (gatehouse != 0 && DAT_BuildingsState::instance.buildings[gatehouse].field203_0x2c6 != 0) { return FALSE; } - menuTab = 0x25; + menuTab = 37; break; } case OpenSHC::Map::Buildings::BT_WOODGATE2: - menuTab = 0x26; + menuTab = 38; break; case OpenSHC::Map::Buildings::BT_TUNNEL: - menuTab = 0x27; + menuTab = 39; break; case OpenSHC::Map::Buildings::BT_SIGNPOST: - menuTab = 0x29; + menuTab = 41; break; case OpenSHC::Map::Buildings::BT_KILLINGPIT: - menuTab = 0x2a; + menuTab = 42; break; case OpenSHC::Map::Buildings::BT_CAMPGROUND: - menuTab = 0x2b; + menuTab = 43; break; case OpenSHC::Map::Buildings::BT_TOWER1: case OpenSHC::Map::Buildings::BT_TOWER2: case OpenSHC::Map::Buildings::BT_TOWER3: case OpenSHC::Map::Buildings::BT_TOWER4: case OpenSHC::Map::Buildings::BT_TOWER5: - menuTab = 0x2e; + menuTab = 46; break; case OpenSHC::Map::Buildings::BT_GALLOWS: - menuTab = 0x2f; + menuTab = 47; break; case OpenSHC::Map::Buildings::BT_STOCKS: - menuTab = 0x30; + menuTab = 48; break; case OpenSHC::Map::Buildings::BT_WITCHHOIST: - menuTab = 0x31; + menuTab = 49; break; case OpenSHC::Map::Buildings::BT_MAYPOLE: - menuTab = 0x32; + menuTab = 50; break; case OpenSHC::Map::Buildings::BT_GARDEN: - menuTab = 0x33; + menuTab = 51; break; case OpenSHC::Map::Buildings::BT_CAMPFIRE: case OpenSHC::Map::Buildings::BT_PARADEGROUND: @@ -366,67 +366,67 @@ namespace UI { case OpenSHC::Map::Buildings::BT_PARADEGROUND3: case OpenSHC::Map::Buildings::BT_PARADEGROUND4: case OpenSHC::Map::Buildings::BT_PARADEGROUND5: - menuTab = 0x34; + menuTab = 52; break; case OpenSHC::Map::Buildings::BT_CATAPULT: - menuTab = 0x3a; + menuTab = 58; break; case OpenSHC::Map::Buildings::BT_TREBUCHET: - menuTab = 0x3b; + menuTab = 59; break; case OpenSHC::Map::Buildings::BT_BATTERINGRAM: - menuTab = 0x3c; + menuTab = 60; break; case OpenSHC::Map::Buildings::BT_SIEGETOWER: - menuTab = 0x3d; + menuTab = 61; break; case OpenSHC::Map::Buildings::BT_SHIELD: - menuTab = 0x3e; + menuTab = 62; break; case OpenSHC::Map::Buildings::BT_FIREBALLISTA: - menuTab = 0x5f; + menuTab = 95; break; case OpenSHC::Map::Buildings::BT_CESSPIT: - menuTab = 0x50; + menuTab = 80; break; case OpenSHC::Map::Buildings::BT_BURNINGSTAKE: - menuTab = 0x51; + menuTab = 81; break; case OpenSHC::Map::Buildings::BT_GIBBET: - menuTab = 0x52; + menuTab = 82; break; case OpenSHC::Map::Buildings::BT_DUNGEON: - menuTab = 0x53; + menuTab = 83; break; case OpenSHC::Map::Buildings::BT_STRETCHINGRACK: - menuTab = 0x54; + menuTab = 84; break; case OpenSHC::Map::Buildings::BT_RACKFLOGGING: - menuTab = 0x55; + menuTab = 85; break; case OpenSHC::Map::Buildings::BT_CHOPPINGBLOCK: - menuTab = 0x56; + menuTab = 86; break; case OpenSHC::Map::Buildings::BT_DUNKINGSTOOL: - menuTab = 0x57; + menuTab = 87; break; case OpenSHC::Map::Buildings::BT_DOGCAGE: - menuTab = 0x58; + menuTab = 88; DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .releaseDogsFlag = DAT_BuildingsState::instance.buildings[buildingID].flagonsOfAleOrCheeseOrReleaseDogs; break; case OpenSHC::Map::Buildings::BT_SHRINE: - menuTab = 0x5a; + menuTab = 90; break; case OpenSHC::Map::Buildings::BT_BEEHIVE: - menuTab = 0x5b; + menuTab = 91; break; case OpenSHC::Map::Buildings::BT_DANCINGBEAR: - menuTab = 0x5c; + menuTab = 92; break; case OpenSHC::Map::Buildings::BT_BEARCAVE: - menuTab = 0x5e; + menuTab = 94; break; case OpenSHC::Map::Buildings::BT_BARRACKS: break; @@ -438,7 +438,7 @@ namespace UI { = DAT_BuildingsState::instance.buildings[buildingID].uid; return FALSE; case OpenSHC::Map::Buildings::BT_STATUE: - menuTab = 0x59; + menuTab = 89; break; } openMenu: diff --git a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp index 75d6ef1411..1270d722fb 100644 --- a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp +++ b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp @@ -29,7 +29,7 @@ namespace UI { return; } if ((INT_00df5640::instance & 1U) == 0) { - INT_00df5640::instance = INT_00df5640::instance | 1; + INT_00df5640::instance |= 1; INT_00df563c::instance = timeGetTime(); } DWORD const now = timeGetTime(); @@ -44,11 +44,11 @@ namespace UI { int resolutionYOffset = 0; if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { yOffset168: - resolutionYOffset = 0xa8; + resolutionYOffset = 168; goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { - resolutionYOffset = 0x1a8; + resolutionYOffset = 424; goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { @@ -56,18 +56,18 @@ namespace UI { resolutionYOffset = 600; } else { if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { - resolutionYOffset = 0x78; + resolutionYOffset = 120; goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1440x900) { if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { - resolutionYOffset = 0x1e0; + resolutionYOffset = 480; goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) goto yOffset600; if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { - resolutionYOffset = 0x348; + resolutionYOffset = 840; goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { @@ -78,7 +78,7 @@ namespace UI { || (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768)) goto yOffset168; if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { - resolutionYOffset = 0xfd2; + resolutionYOffset = 4050; goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1600x900) @@ -91,14 +91,14 @@ namespace UI { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 0x24, y - 0x65 + resolutionYOffset, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 36, y - 101 + resolutionYOffset, OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX - + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 0x24, - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + resolutionYOffset + y - 0x65, + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 36, + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + resolutionYOffset + y - 101, OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = previousDrawBuffer; } diff --git a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp index 72a8735549..030a9a3bac 100644 --- a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp @@ -31,16 +31,16 @@ namespace UI { } int goldColor; if (gold > 0) { - goldColor = 0x7d3e; + goldColor = 32062; } else { gold = 0; - goldColor = 0xff; + goldColor = 255; } - goldDigitSet = goldDigitSet + 1; + ++goldDigitSet; int goldWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, DAT_TextManagerObject::ptr)( gold, goldDigitSet); if (gold >= 100000) { - goldWidth = goldWidth - 2; + goldWidth -= 2; } MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 5, goldColor, @@ -64,12 +64,12 @@ namespace UI { int populationDigitSetUnk = 0; int populationColor; if (DAT_GameState::instance.playerDataArray[playerID].crowding <= 100) { - populationColor = 0x7d3e; + populationColor = 32062; } else { - populationColor = 0xff; + populationColor = 255; } if (populationCap == 0) { - populationColor = 0x7d3e; + populationColor = 32062; population = 0; } else { if (populationCap >= 100) { @@ -109,9 +109,9 @@ namespace UI { int popularityColor; if (popularity < 50) { - popularityColor = 0xff; + popularityColor = 255; } else { - popularityColor = 0x7d3e; + popularityColor = 32062; } int const popularityHalfWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, DAT_TextManagerObject::ptr)(popularity, 0) diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index 89b11ef6e6..a60c7ec1ac 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -83,14 +83,14 @@ namespace UI { int kills = 0; for (int victim = 1; victim < 9; ++victim) { if (victim != player) { - kills = kills + DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[player][victim]; + kills += DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[player][victim]; } } tables.kills[player] = kills; int losses = 0; for (int killer = 0; killer < 9; ++killer) { if (killer != player) { - losses = losses + DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[killer][player]; + losses += DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[killer][player]; } } tables.losses[player] = losses; @@ -216,25 +216,25 @@ namespace UI { } // bonus points for the winner and for a clear lead in a statistic - tables.points[tables.overallOrder[1]] = tables.points[tables.overallOrder[1]] + 3; + tables.points[tables.overallOrder[1]] += 3; if (tables.kills[tables.statOrder[0][1]] > 10 && tables.kills[tables.statOrder[0][1]] > tables.kills[tables.statOrder[0][2]] * 2) { - tables.points[tables.statOrder[0][1]] = tables.points[tables.statOrder[0][1]] + 3; + tables.points[tables.statOrder[0][1]] += 3; } int value = DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][1]]; if (value > 2 && value > DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][2]] * 2) { - tables.points[tables.statOrder[1][1]] = tables.points[tables.statOrder[1][1]] + 2; + tables.points[tables.statOrder[1][1]] += 2; } value = DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][1]]; if (value > 50 && value > DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][2]] * 2) { - tables.points[tables.statOrder[2][1]] = tables.points[tables.statOrder[2][1]] + 2; + tables.points[tables.statOrder[2][1]] += 2; } value = DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][1]]; if (value > 100 && value > DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][2]] * 2) { - tables.points[tables.statOrder[3][1]] = tables.points[tables.statOrder[3][1]] + 3; + tables.points[tables.statOrder[3][1]] += 3; } short const maxPopulation = DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][1]]; @@ -242,33 +242,33 @@ namespace UI { && maxPopulation > DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][2]] * 2) { // fixme: the original gives the population point to the player with the most kills - tables.points[tables.statOrder[0][1]] = tables.points[tables.statOrder[0][1]] + 1; + ++tables.points[tables.statOrder[0][1]]; } value = DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][1]]; if (value > 100 && value > DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][2]] * 2) { - tables.points[tables.statOrder[5][1]] = tables.points[tables.statOrder[5][1]] + 1; + ++tables.points[tables.statOrder[5][1]]; } value = DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][1]]; if (value > 50 && value > DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][2]] * 2) { - tables.points[tables.statOrder[6][1]] = tables.points[tables.statOrder[6][1]] + 1; + ++tables.points[tables.statOrder[6][1]]; } value = DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][1]]; if (value > 10 && value > DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][2]] * 2) { - tables.points[tables.statOrder[7][1]] = tables.points[tables.statOrder[7][1]] + 1; + ++tables.points[tables.statOrder[7][1]]; } value = DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][1]]; if (value > 20 && value > DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][2]] * 2) { - tables.points[tables.statOrder[8][1]] = tables.points[tables.statOrder[8][1]] + 1; + ++tables.points[tables.statOrder[8][1]]; } value = DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][1]]; if (value > 20 && value > DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][2]] * 2) { - tables.points[tables.statOrder[11][1]] = tables.points[tables.statOrder[11][1]] + 1; + ++tables.points[tables.statOrder[11][1]]; } // three points per star, at most five, and at most four unless player slot 1 took part @@ -302,9 +302,9 @@ namespace UI { // "Greatest Lord" MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, DAT_PencilRenderCore::ptr)(225, 1, DAT_MenuHandlerState::instance.x - 104, y - 30, 1008, 0); - y = y + 20; + y += 20; } - y = y + 190; + y += 190; int iconY = y - 18; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; int player; @@ -380,12 +380,12 @@ namespace UI { for (int star = 0; star < tables.stars[player]; ++star) { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 139, iconX, iconY - 2); - iconX = iconX + 22; + iconX += 22; } for (int lord = 0; lord < DAT_GameSynchronyState::instance.finalResults.finalKilledLords[player]; ++lord) { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 138, iconX, iconY - 5); - iconX = iconX + 22; + iconX += 22; } if (DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] != 0) { // "(" @@ -399,7 +399,7 @@ namespace UI { DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] % 12), iconX + 28, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, FALSE, 0); - iconX = iconX + 32; + iconX += 32; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] / 12, iconX, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, TRUE, 0); @@ -478,8 +478,8 @@ namespace UI { DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[player], x + 627, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); } - y = y + 45; - iconY = iconY + 45; + y += 45; + iconY += 45; } if ((char)INT_00eb0e44::instance == '\0') { diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index 2d0b55555b..75760bcd52 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -332,7 +332,7 @@ namespace UI { DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + boxX, y); } DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - y = y + 30; + y += 30; } // objective 39: a progress bar @@ -373,7 +373,7 @@ namespace UI { DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 1, barX, y - 1, OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 3, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - y = y + 21; + y += 21; } // time until the next one-off invasion or the deadline of the mission, as a progress bar @@ -442,7 +442,7 @@ namespace UI { y - 1, OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 3, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - y = y + 21; + y += 21; } } } @@ -460,7 +460,7 @@ namespace UI { 0); // the visible height, rounded up to whole lines of 23 pixels int pageHeight = 377 - offset; - pageHeight = pageHeight + 22 - (pageHeight + 22) % 23; + pageHeight += 22 - (pageHeight + 22) % 23; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRange, DAT_TextureRenderCoreObject::ptr)(DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + offset + 45, DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + pageHeight + offset + 45); diff --git a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp index 86e9a97412..8aeb308585 100644 --- a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp +++ b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp @@ -31,7 +31,7 @@ namespace UI { AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); int const x = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; int const y = DAT_ButtonY::instance + 6; - if (DAT_ButtonCurrentlyInteracting::instance == FALSE) { + if (!DAT_ButtonCurrentlyInteracting::instance) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp index 6ea3b0ad08..660551bdab 100644 --- a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp @@ -76,7 +76,7 @@ namespace UI { break; } if (drawY + imageHeight > heightMax) { - imageHeight = imageHeight - (drawY + imageHeight - heightMax); + imageHeight -= (drawY + imageHeight - heightMax); if (imageHeight <= 0) { return; } @@ -1347,7 +1347,7 @@ namespace UI { lineStride = 4056 * 2; heightStart = this->mapGameSurfaceHeightRange.start; if (drawY + imageHeight > this->mapGameSurfaceHeightRange.end) { - imageHeight = imageHeight - (drawY + imageHeight - this->mapGameSurfaceHeightRange.end); + imageHeight -= (drawY + imageHeight - this->mapGameSurfaceHeightRange.end); if (imageHeight <= 0) { return; } diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp index 17f203663d..3bbcdc66a9 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp @@ -1,6 +1,5 @@ #include "../WindowAndDirectDraw.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" @@ -15,7 +14,7 @@ namespace UI { void WindowAndDirectDraw::bltMapGameSurfaceToScreen( int windowedX, int windowedY, int windowedWidth, int windowedHeigth) { - if (this->drawingReady_0x0 == FALSE) { + if (!this->drawingReady_0x0) { return; } if (GetForegroundWindow() != this->windowHandle) { @@ -24,7 +23,7 @@ namespace UI { RECT sourceRect; RECT destinationRect; int const cameraOffsetX = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; - if (this->NOTSelfBufferOrWindowMode_0xf8 == FALSE) { + if (!this->NOTSelfBufferOrWindowMode_0xf8) { sourceRect.left = windowedX - 32; sourceRect.top = windowedY - 8; sourceRect.right = windowedWidth + 32; diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp index ef6d7473d2..7da33efa08 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp @@ -2,7 +2,6 @@ #include "OpenSHC/IO/LowLevelMemory.func.hpp" #include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" #include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" @@ -21,11 +20,11 @@ namespace UI { void WindowAndDirectDraw::prepareWindowAndDDraw_2Unk( BOOLEnum runAsExclusiveFullscreen, ScreenResolutionEnum resEnum) { - if (this->drawingReady_0x0 != FALSE) { + if (this->drawingReady_0x0) { dword const pendingBltMode = this->pendingBltMode; this->pendingBltMode = 0; MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( - this->byteSizeofScreenResolution, 0, (void*)((int)(this->surfacePointer_screenMenu))); + this->byteSizeofScreenResolution, 0, this->surfacePointer_screenMenu); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, this)(1); this->pendingBltMode = pendingBltMode; } @@ -39,7 +38,7 @@ namespace UI { this->drawingReady_0x0 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::initializeDirectDraw, this)(); // If DirectDraw can't start in the chosen resolution, retry once in 800x600, else ask to close. - while (this->drawingReady_0x0 == FALSE) { + while (!this->drawingReady_0x0) { if (this->currentGameResolution == OpenSHC::Rendering::SRE_800x600) { this->postWindowCloseMessage = 1; break; diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp index 9660b133fc..79cc8cbd09 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp @@ -1,6 +1,5 @@ #include "../WindowAndDirectDraw.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" @@ -19,7 +18,7 @@ namespace UI { return; } this->isNotProcessingInputEvents = FALSE; - if (DAT_WindowAndDirectDraw::instance.runGameAsExclusiveFullscreen != FALSE) { + if (DAT_WindowAndDirectDraw::instance.runGameAsExclusiveFullscreen) { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::prepareWindowAndDDrawUnk, this)(); SetRect( &this->clientOnScreenCoords, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp index b5912fe181..aa4685f786 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -1,7 +1,6 @@ #include "../WindowAndDirectDraw.func.hpp" #include "OpenSHC/OS.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/string-literals.hpp" @@ -67,22 +66,22 @@ namespace UI { } // FUNCTION: STRONGHOLDCRUSADER 0x00470040 - void WindowAndDirectDraw::renderBltAndFlip(int param_1) + void WindowAndDirectDraw::renderBltAndFlip(int request) { RECT destinationRect; RECT sourceRect; int menuBarHeight = 128; BOOL mapBltPending = FALSE; - if (param_1 >= 100) { - param_1 -= 100; + if (request >= 100) { + request -= 100; } if (this->pendingBltMode != 0) { mapBltPending = TRUE; } - if (param_1 != 0) { + if (request != 0) { this->windowMoveEventBlitCountdown = 0; } - if (this->drawingReady_0x0 == FALSE) { + if (!this->drawingReady_0x0) { DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; return; } @@ -109,12 +108,12 @@ namespace UI { sourceRect.top = 0; sourceRect.right = this->gameResolutionX; sourceRect.bottom = this->gameResolutionY; - if (param_1 == 1) { + if (request == 1) { char debugText[2000]; MACRO_CALL(OpenSHC::OS_Func::_sprintf)(debugText, s_Vid__d__sys__d_005a6208, this->directDrawBackbufferSurfacePointer, this->directDrawOffscreenSurfacePointer_screenMenu); } - if (this->runGameAsExclusiveFullscreen != FALSE) { + if (this->runGameAsExclusiveFullscreen) { this->directDrawBackbufferSurfacePointer->BltFast(0, 0, this->directDrawOffscreenSurfacePointer_screenMenu, &this->clientOnScreenCoords, DDBLTFAST_WAIT); diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index 829a065d36..c6654ff50c 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -40,8 +40,8 @@ namespace UI { int const x = DAT_MenuHandlerState::instance.x; int const y = DAT_MenuHandlerState::instance.y; int const firstGroupIcon = DAT_00b95b68::instance * 9; - int const top = y + 0x1bf; - DAT_00b9845c::instance = DAT_00b9845c::instance + 1; + int const top = y + 447; + ++DAT_00b9845c::instance; int nudge = 0; if (40 < (int)DAT_00b9845c::instance) { DAT_00b9845c::instance = 0; @@ -52,7 +52,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 5), - x + 0x19, y + 0x1d3, OpenSHC::Text::TTA_LEFT, 0, 0x11, FALSE, 0); + x + 25, y + 467, OpenSHC::Text::TTA_LEFT, 0, 17, FALSE, 0); int groupSize; if (DAT_00b95b68::instance == 2) { groupSize = 8; @@ -63,10 +63,10 @@ namespace UI { // an icon and the head count of each unit type in the group for (int i = 0; i < groupSize; i++) { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, - DAT_TextureRenderCoreObject::ptr)(firstGroupIcon + i + 4, x + 0x55 + i * 0x2e, top + 0x28); + DAT_TextureRenderCoreObject::ptr)(firstGroupIcon + i + 4, x + 85 + i * 46, top + 40); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_UnitTypeRelatedCounter::instance[DAT_UnitTypeGroups::instance[0][firstGroupIcon + i]], - nudge + i * 0x2e + x + 0x6f, top + 0x7d, OpenSHC::Text::TTA_CENTER, 0, 0x11, FALSE, 0); + nudge + i * 46 + x + 111, top + 125, OpenSHC::Text::TTA_CENTER, 0, 17, FALSE, 0); if (2 < i) { nudge = 0; } @@ -75,11 +75,11 @@ namespace UI { // "Total Troops" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x10), - x + 0x74, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16), + x + 116, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID].armySize, - x + 0x7a, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, TRUE, 0); + x + 122, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, TRUE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; return; } @@ -92,46 +92,46 @@ namespace UI { if (0 < fearFactor) { DAT_TextManagerObject::instance.field8_0x20 = 1; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 0xb1, x + 0x74, top + 0x1b); + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 177, x + 116, top + 27); // "Troop combat bonus:" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x1f), - x + 0x9c, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 31), + x + 156, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel * 5, - x + 0xa2, top + 0x19, OpenSHC::Text::TTA_LEFT, 0xff00, 0, 0x12, TRUE, 0); - color = 0xff00; - percentX = x + 0xa4; + x + 162, top + 25, OpenSHC::Text::TTA_LEFT, 65280, 0, 18, TRUE, 0); + color = 65280; + percentX = x + 164; } else if (fearFactor < 0) { DAT_TextManagerObject::instance.field8_0x20 = 1; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 0xb2, x + 0x74, top + 0x11); + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 178, x + 116, top + 17); // "Troop combat bonus:" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x1f), - x + 0x92, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 31), + x + 146, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel * 5, - x + 0x98, top + 0x19, OpenSHC::Text::TTA_LEFT, 0xff, 0, 0x12, TRUE, 0); - color = 0xff; - percentX = x + 0x9a; + x + 152, top + 25, OpenSHC::Text::TTA_LEFT, 255, 0, 18, TRUE, 0); + color = 255; + percentX = x + 154; } else { // "No 'fear factor' bonus." MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x1e), - x + 0x74, top + 0x19, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 30), + x + 116, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; return; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( - s_percentage_005a2770, percentX, top + 0x19, OpenSHC::Text::TTA_LEFT, color, 0, 0x12, TRUE, 0); + s_percentage_005a2770, percentX, top + 25, OpenSHC::Text::TTA_LEFT, color, 0, 18, TRUE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; DAT_TextManagerObject::instance.field8_0x20 = 0; } diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp index 99df70aa09..f243fb1c11 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp @@ -29,29 +29,29 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x0043FAC0 void StatusMenus::RenderStatusMenu_Food() { - int const left = DAT_MenuHandlerState::instance.x + 0xb2; - int const top = DAT_MenuHandlerState::instance.y + 0x200; + int const left = DAT_MenuHandlerState::instance.x + 178; + int const top = DAT_MenuHandlerState::instance.y + 512; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; // "Food" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 4), - DAT_MenuHandlerState::instance.x + 0x19, DAT_MenuHandlerState::instance.y + 0x1d3, OpenSHC::Text::TTA_LEFT, - 0, 0x11, FALSE, 0); + DAT_MenuHandlerState::instance.x + 25, DAT_MenuHandlerState::instance.y + 467, OpenSHC::Text::TTA_LEFT, 0, + 17, FALSE, 0); if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { // "Clicking on a food toggles consumption" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0x17), - DAT_MenuHandlerState::instance.x + 0x13c, top + 0x46, OpenSHC::Text::TTA_CENTER, 0, 0x12, FALSE, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 23), + DAT_MenuHandlerState::instance.x + 316, top + 70, OpenSHC::Text::TTA_CENTER, 0, 18, FALSE, 0); } // the stock of the four foods for (int food = 0; food < 4; food++) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[DAT_ARRAY_0061818c::instance[food]], - left + 12 + food * 80, DAT_MenuHandlerState::instance.y + 0x225, OpenSHC::Text::TTA_LEFT, 0, 0x11, - FALSE, 0); + left + 12 + food * 80, DAT_MenuHandlerState::instance.y + 549, OpenSHC::Text::TTA_LEFT, 0, 17, FALSE, + 0); } DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; } diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp index f2e7b06e0b..07a5e97922 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp @@ -31,7 +31,7 @@ namespace UI { void StatusMenus::RenderStatusMenu_Population() { int const player = DAT_GameSynchronyState::instance.currentPlayerSlotID; - int const top = DAT_MenuHandlerState::instance.y + 0x1bf; + int const top = DAT_MenuHandlerState::instance.y + 447; int const x = DAT_MenuHandlerState::instance.x; // the graph shows the last 300 months int months = DAT_GameState::instance.mapAndTime.populationIndex; @@ -39,41 +39,41 @@ namespace UI { months = 300; } MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, - DAT_TextureRenderCoreObject::ptr)(1, x + 0xe, DAT_MenuHandlerState::instance.y + 0x1e9); + DAT_TextureRenderCoreObject::ptr)(1, x + 14, DAT_MenuHandlerState::instance.y + 489); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; // "Population" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 3), - DAT_MenuHandlerState::instance.x + 0x19, DAT_MenuHandlerState::instance.y + 0x1d3, OpenSHC::Text::TTA_LEFT, - 0, 0x11, FALSE, 0); + DAT_MenuHandlerState::instance.x + 25, DAT_MenuHandlerState::instance.y + 467, OpenSHC::Text::TTA_LEFT, 0, + 17, FALSE, 0); // the axes, three pixels thick - int const bottom = top + 0x7e; - int const right = x + 0x1ed; + int const bottom = top + 126; + int const right = x + 493; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0xbc, bottom, right, bottom, COL_BLACK::instance.shortValue); + x + 188, bottom, right, bottom, COL_BLACK::instance.shortValue); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0xbc, top + 0x7f, right, top + 0x7f, COL_BLACK::instance.shortValue); + x + 188, top + 127, right, top + 127, COL_BLACK::instance.shortValue); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0xbc, top + 0x80, right, top + 0x80, COL_BLACK::instance.shortValue); - int const graphTop = top + 0x32; + x + 188, top + 128, right, top + 128, COL_BLACK::instance.shortValue); + int const graphTop = top + 50; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0xbe, graphTop, x + 0xbe, bottom, COL_BLACK::instance.shortValue); + x + 190, graphTop, x + 190, bottom, COL_BLACK::instance.shortValue); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0xbd, graphTop, x + 0xbd, bottom, COL_BLACK::instance.shortValue); + x + 189, graphTop, x + 189, bottom, COL_BLACK::instance.shortValue); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0xbc, graphTop, x + 0xbc, bottom, COL_BLACK::instance.shortValue); + x + 188, graphTop, x + 188, bottom, COL_BLACK::instance.shortValue); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0x1eb, graphTop, x + 0x1eb, bottom, COL_BLACK::instance.shortValue); + x + 491, graphTop, x + 491, bottom, COL_BLACK::instance.shortValue); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - x + 0x1ec, graphTop, x + 0x1ec, bottom, COL_BLACK::instance.shortValue); + x + 492, graphTop, x + 492, bottom, COL_BLACK::instance.shortValue); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( right, graphTop, right, bottom, COL_BLACK::instance.shortValue); // "Years" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 0xd), - x + 0x154, top + 0x8e, OpenSHC::Text::TTA_CENTER, 0, 0x13, FALSE, 0); + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 13), + x + 340, top + 142, OpenSHC::Text::TTA_CENTER, 0, 19, FALSE, 0); // the vertical scale: 50 people per 75 pixels, doubled until the highest population fits int highest = 0; for (int month = 0; month < months; month++) { @@ -85,7 +85,7 @@ namespace UI { if (highest <= 50) { scale = 1; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - 50, x + 0xac, top + 0x2d, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + 50, x + 172, top + 45, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); } else { if (highest <= 100) { scale = 2; @@ -100,14 +100,14 @@ namespace UI { } if (scale == 32) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - 1600, x + 0x9c, top + 0x2d, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + 1600, x + 156, top + 45, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - scale * 50, x + 0xa4, top + 0x2d, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + scale * 50, x + 164, top + 45, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); } } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - 0, x + 0xb4, top + 0x78, OpenSHC::Text::TTA_LEFT, 0, 0x13, FALSE, 0); + 0, x + 180, top + 120, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); // a year label every five years for (int label = 0; label <= 5; label++) { int firstYear = (DAT_GameState::instance.mapAndTime.populationIndex - 300) / 12; @@ -115,8 +115,8 @@ namespace UI { firstYear = 0; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - firstYear + label * 5, label * 1475 / 25 + 0xbe + x, top + 0x82, OpenSHC::Text::TTA_LEFT, 0, 0x13, - FALSE, 0); + firstYear + label * 5, label * 1475 / 25 + 190 + x, top + 130, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, + 0); } // one bar per month if (months <= 300) { @@ -129,7 +129,7 @@ namespace UI { DAT_TextureRenderCoreObject::ptr)( 0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, bottom); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, - DAT_TextureRenderCoreObject::ptr)(0, x + 0xbf + month, top - height + 0x7e); + DAT_TextureRenderCoreObject::ptr)(0, x + 191 + month, top - height + 126); } } } From f84d13435ae01a35d2e77d829bf4085409dacb03 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 00:19:11 +0100 Subject: [PATCH 50/78] style: drop unused using declarations, compound assignments (draft functions) Applied with openshc-pr-fix.py; every changed file compiles to the same code as before (quick_diff identical for all 22). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Rendering/ApplyBlending.cpp | 1 - .../Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp | 8 -------- .../Bink/BinkControlClass/copyBinkToVideoBuffer.cpp | 1 - .../GameSynchronyState/determineGameTicksToPerform.cpp | 3 --- .../getCommandIDFromCommandSelectionStuff.cpp | 3 --- .../BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp | 4 ---- .../UI/MenuModalComposition/activateModalDialog2.cpp | 9 ++++----- .../activateModalDialogAndClearText.cpp | 2 -- src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp | 1 - .../AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp | 1 - .../openBuildingStatusMenuForBuildingID.cpp | 2 -- .../UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp | 4 ---- src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp | 6 ------ src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp | 5 ----- src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp | 8 -------- .../UI/Rendering/RenderScenarioButtonWithText.cpp | 6 ------ .../WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp | 2 -- .../UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp | 2 -- .../Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp | 2 -- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp | 8 -------- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp | 7 ------- .../UI/StatusMenus/RenderStatusMenu_Population.cpp | 6 ------ 22 files changed, 4 insertions(+), 87 deletions(-) diff --git a/src/OpenSHC/Rendering/ApplyBlending.cpp b/src/OpenSHC/Rendering/ApplyBlending.cpp index 01996dbe0d..428474e0d0 100644 --- a/src/OpenSHC/Rendering/ApplyBlending.cpp +++ b/src/OpenSHC/Rendering/ApplyBlending.cpp @@ -16,7 +16,6 @@ namespace OpenSHC { -using Rendering::ColorMode; using UI::Rendering::WindowAndDirectDraw; // Blends the tile being drawn into the map surface, pixel by pixel: every colour component of the tile and of the diff --git a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp index 15e10c8e91..407b7b7a7b 100644 --- a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp +++ b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp @@ -28,14 +28,6 @@ namespace OpenSHC { namespace Rendering { namespace Bink { - using Audio::MSS::enums::SHC_SoundStream; - using DE::SHCDE::eGM; - using UI::Enums::BuildingsAndStatusMenuTabType; - using UI::Enums::DisplayElementID; - using UI::Enums::MenuModalType; - using UI::Enums::MenuViewType; - using WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004B7C90 void AIMessageQueue::playAiLordMessage(int x, int y) { diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp index b9437c2879..fee8c2e691 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp @@ -19,7 +19,6 @@ namespace Rendering { namespace Bink { using OpenSHC::Audio::MSS::enums::SHC_SoundStream; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; // The original inlined this per-video body into the loop: its early returns are the jumps to the loop // increment. Plain `inline` is not expanded by MSVC here, so it has to be __forceinline (same code as a goto, diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp index 5ea62e0ea2..68e937a456 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp @@ -12,9 +12,6 @@ namespace OpenSHC { namespace Synchrony { - using Game::GameMode; - using WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x00487A30 int GameSynchronyState::determineGameTicksToPerform(int currentPlayerSlotID) { diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp index 312927b647..0f45f6b383 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp @@ -11,9 +11,6 @@ namespace OpenSHC { namespace Synchrony { - using Commands::GameCommandState; - using Commands::GameCommandStateByte; - // FUNCTION: STRONGHOLDCRUSADER 0x00480440 int GameSynchronyState::getCommandIDFromCommandSelectionStuff() { diff --git a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp index 53dedbe93c..6086c6cdd6 100644 --- a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp +++ b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp @@ -34,12 +34,8 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Map::Buildings::BuildingType; using OpenSHC::Map::Buildings::BuildingTypeShort; - using OpenSHC::Map::Units::UnitType; using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Rendering::Enums::RenderTarget; using OpenSHC::Text::TextAlignment; using OpenSHC::WindowsHelper::Enums::BOOLEnum; diff --git a/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp b/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp index 62e656abbc..a3fec7e1a9 100644 --- a/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp +++ b/src/OpenSHC/UI/MenuModalComposition/activateModalDialog2.cpp @@ -19,7 +19,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::Rendering::Enums::RenderTarget; using OpenSHC::UI::Enums::MenuModalType; using OpenSHC::WindowsHelper::Enums::BOOLEnum; @@ -54,25 +53,25 @@ namespace UI { if (this->modalMenu.x == -1) { this->modalMenu.x = DAT_WindowAndDirectDraw::instance.gameResolutionX / 2 - this->modalMenu.width / 2; } else { - this->modalMenu.x = (DAT_WindowAndDirectDraw::instance.gameResolutionX - 800) / 2 + this->modalMenu.x; + this->modalMenu.x += (DAT_WindowAndDirectDraw::instance.gameResolutionX - 800) / 2; } if (this->modalMenu.y == -1) { // centred over the map, above the 128 pixel high menu bar this->modalMenu.y = (DAT_WindowAndDirectDraw::instance.gameResolutionY - 128) / 2 - this->modalMenu.height / 2; } else { - this->modalMenu.y = (DAT_WindowAndDirectDraw::instance.gameResolutionY - 600) / 2 + this->modalMenu.y; + this->modalMenu.y += (DAT_WindowAndDirectDraw::instance.gameResolutionY - 600) / 2; } } else { if (this->modalMenu.x == -1) { this->modalMenu.x = DAT_WindowAndDirectDraw::instance.gameResolutionX / 2 - this->modalMenu.width / 2; } else { - this->modalMenu.x = (DAT_WindowAndDirectDraw::instance.gameResolutionX - 800) / 2 + this->modalMenu.x; + this->modalMenu.x += (DAT_WindowAndDirectDraw::instance.gameResolutionX - 800) / 2; } if (this->modalMenu.y == -1) { this->modalMenu.y = DAT_WindowAndDirectDraw::instance.gameResolutionY / 2 - this->modalMenu.height / 2; } else { - this->modalMenu.y = (DAT_WindowAndDirectDraw::instance.gameResolutionY - 600) / 2 + this->modalMenu.y; + this->modalMenu.y += (DAT_WindowAndDirectDraw::instance.gameResolutionY - 600) / 2; } } this->disappearAfter = 32; diff --git a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp index 94ca38ab55..2963ec4062 100644 --- a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp @@ -13,9 +13,7 @@ namespace OpenSHC { namespace UI { - using OpenSHC::Text::TextArrayIndexType; using OpenSHC::UI::Enums::MenuModalType; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; // dialogID is 11 for Exit Crusader or Restart Game, 12 for Options // FUNCTION: STRONGHOLDCRUSADER 0x004916C0 diff --git a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp index 99ee938564..724327e324 100644 --- a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp @@ -12,7 +12,6 @@ namespace OpenSHC { namespace UI { using OpenSHC::UI::Enums::MenuModalType; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; // FUNCTION: STRONGHOLDCRUSADER 0x00493900 void MenuTextInputState::popModalDialog() diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp index 0a69808cd3..5a98f5f008 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp @@ -21,7 +21,6 @@ namespace OpenSHC { namespace UI { namespace Rendering { - using OpenSHC::Rendering::Enums::RenderTarget; using OpenSHC::WindowsHelper::Enums::BOOLEnum; // FUNCTION: STRONGHOLDCRUSADER 0x004630D0 diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp index bf0d3a51de..2ad6025274 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp @@ -19,9 +19,7 @@ namespace OpenSHC { namespace UI { namespace Rendering { - using OpenSHC::Game::GameMode2; using OpenSHC::Map::Buildings::BuildingType; - using OpenSHC::UI::Enums::MenuViewType; using OpenSHC::WindowsHelper::Enums::BOOLEnum; // FUNCTION: STRONGHOLDCRUSADER 0x00463310 diff --git a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp index 1270d722fb..0c4aa6524c 100644 --- a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp +++ b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp @@ -15,10 +15,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::IO::Graphics::GmID; - using OpenSHC::Rendering::ScreenResolutionEnum; - using OpenSHC::Rendering::Enums::RenderTarget; - // Renders the animated tutorial arrow (GID_FLOATS_NEW) at (x, y), moved down by a per-resolution offset. It // cycles through 10 frames at about 60 ms each and is drawn twice: to the screen menu surface and, with the // camera offset, to the map surface. Skipped while DAT_00df5540 is set. diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index a60c7ec1ac..500b0b5022 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -35,13 +35,7 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eGM; using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::IO::Graphics::GmID; - using OpenSHC::Rendering::ScreenResolutionEnum; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; // The tables behind the Greatest Lord screen, one entry per player slot (index 0 unused). The original keeps them // in one block of the stack frame, and its statistic orders are filled by one strided loop, so they are one diff --git a/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp b/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp index 536440ff56..8b80557926 100644 --- a/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp +++ b/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp @@ -19,11 +19,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::UI::Enums::BuildingsAndStatusMenuTabType; - using OpenSHC::UI::Enums::MenuViewType; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x00493690 void Rendering::RenderLoadAndSaveBar(int progressValueUnk) { diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index 75760bcd52..bf86977207 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -33,14 +33,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eGM; - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Game::GameMode2; - using OpenSHC::IO::Graphics::GmID; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004D76A0 int Rendering::RenderMissionObjectivesUnk() { diff --git a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp index 8aeb308585..42cc6fa74f 100644 --- a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp +++ b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp @@ -18,12 +18,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004BA910 void Rendering::RenderScenarioButtonWithText(int textNumInGroup) { diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp index 3bbcdc66a9..68e9046da1 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp @@ -8,8 +8,6 @@ namespace OpenSHC { namespace UI { namespace Rendering { - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004706E0 void WindowAndDirectDraw::bltMapGameSurfaceToScreen( int windowedX, int windowedY, int windowedWidth, int windowedHeigth) diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp index 79cc8cbd09..79a2402f76 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp @@ -8,8 +8,6 @@ namespace OpenSHC { namespace UI { namespace Rendering { - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004708F0 void WindowAndDirectDraw::reinitWindow() { diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp index aa4685f786..91da5878ba 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -13,8 +13,6 @@ namespace OpenSHC { namespace UI { namespace Rendering { - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // Blits the menu bar (mode 2) or one of two menu panels (modes 3 and 4) from the screen menu surface over the // map. The original has this code twice, word for word: after the map blit and again after the flip. static __forceinline void blitMenuOverlayUnk( diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index c6654ff50c..95d6db76fb 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -26,14 +26,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eGM; - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Map::Units::UnitTypeInt; - using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x00447FA0 void StatusMenus::RenderStatusMenu_Army() { diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp index f243fb1c11..a6a9313f2c 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp @@ -19,13 +19,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Game::GameMode; - using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x0043FAC0 void StatusMenus::RenderStatusMenu_Food() { diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp index 07a5e97922..8bf1de96f5 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp @@ -21,12 +21,6 @@ namespace OpenSHC { namespace UI { - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x0043F6A0 void StatusMenus::RenderStatusMenu_Population() { From d3e6fa8b322af9646e6bc8564580883bb3176a55 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 00:20:12 +0100 Subject: [PATCH 51/78] style: initializeFinalResultsForActivePlayers disables the strcpy deprecation warning, as the cheat sheet asks Co-Authored-By: Claude Opus 5.5 --- .../initializeFinalResultsForActivePlayers.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp index 3596b47d63..bb78ee004e 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp @@ -1,3 +1,6 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + #include "../GameSynchronyState.func.hpp" #include "OpenSHC/Synchrony.func.hpp" From 116dd55bffe914a87ee02067f2a1ab07a667c9a6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 02:26:17 +0100 Subject: [PATCH 52/78] style: DAT_ButtonW is an int now, so the cast goes (RenderScenarioButtonWithText) quick_diff output is identical. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp index 42cc6fa74f..3a18472acb 100644 --- a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp +++ b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp @@ -23,7 +23,7 @@ namespace UI { { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const x = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const x = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; int const y = DAT_ButtonY::instance + 6; if (!DAT_ButtonCurrentlyInteracting::instance) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( From b882d22e1970efbff778503b6840d3fdf1815f9e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 02:29:34 +0100 Subject: [PATCH 53/78] reimplement: SHC_3BB0A8C1_0x00479540 86.40% calls into the C++ library (ofstream constructor, destructor, operator<<) that reccmp cannot map; register rotation WindowAndDirectDraw::takeScreenshot writes every byte with the C++ library's operator<<(ostream&, char) on the std::ofstream instead of calling the game's statically linked copy (OS::basic_ofstream_write, 0x004791B0), as gynt asked on #313: library code is used, not reimplemented. The stream object was already std::ofstream. reccmp goes from 88.2% to 86.4% raw (89.9% to 91.4% normalized): the original's calls to its own copies of the ofstream constructor, destructor and operator<< (and _free for the path string) have no symbol, so every library call now counts as a different target, while before the operator<< calls went to the game's copy through the resolver. The rest is the same register rotation as before and the addresses of the inline-copied file name strings. ostream::put measured 81.3% (the original's call takes two arguments, so it is the non-member operator<<). Co-Authored-By: Claude Opus 5.5 --- .../WindowAndDirectDraw/takeScreenshot.cpp | 15 +++++++-------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp index 2f76d38fe8..07ad88e093 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp @@ -31,9 +31,8 @@ namespace UI { strcat(path, fileName); } - // NOTE: the original writes through its own statically linked VC8 std::ofstream. The bytes go through the - // game's own operator<<(ostream&, char), OS::basic_ofstream_write (0x004791B0); the stream object is our - // library's std::ofstream, which has the same VC8 layout. + // The game links its own copy of the VC8 library; this is the same std::ofstream from the compiler's + // headers. std::ofstream file(path, std::ios::binary); if (file.fail()) { return; @@ -51,7 +50,7 @@ namespace UI { = this->numPixel_GameX_x_3_x_GameY_0x4c + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); for (uint i = 0; i < sizeof(fileHeader); i++) { - MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, ((char*)&fileHeader)[i]); + file << ((char*)&fileHeader)[i]; } BITMAPINFOHEADER infoHeader; @@ -65,7 +64,7 @@ namespace UI { infoHeader.biCompression = BI_RGB; infoHeader.biSizeImage = this->numPixel_GameX_x_3_x_GameY_0x4c; for (uint i = 0; i < sizeof(infoHeader); i++) { - MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, ((char*)&infoHeader)[i]); + file << ((char*)&infoHeader)[i]; } // RGB565 rows, bottom-up, written as BGR24. The walking pointer and the named char locals are both @@ -75,11 +74,11 @@ namespace UI { for (int x = 0; x < this->resolutionX; x++) { int const pixel = *pixelPtr++; char const blue = (char)pixel << 3; - MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, blue); + file << blue; char const green = (char)(pixel >> 5) * 4; - MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, green); + file << green; char const red = (char)((short)pixel >> 11) << 3; - MACRO_CALL(OpenSHC::OS_Func::basic_ofstream_write)(&file, red); + file << red; } } } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 79756e452d..e02e52d67a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22125,7 +22125,7 @@ SHC_3BB0A8C1_0x00479369 | 0.0% | Pending SHC_3BB0A8C1_0x00479400 | 0.0% | Pending -SHC_3BB0A8C1_0x00479540 | 88.2% | Game STL ctor/dtor; reg rotation +SHC_3BB0A8C1_0x00479540 | 86.4% | calls into the C++ library (ofstream constructor, destructor, operator<<) that reccmp cannot map; register rotation SHC_3BB0A8C1_0x00479790 | 0.0% | Pending From 536abcc369f3ac20a45a1ec1245dc16b6524b75e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 02:35:18 +0100 Subject: [PATCH 54/78] style: for loops step with ++i / --i (gynt's review of #311) 23 steps in 9 files. quick_diff output is identical for all 9. Co-Authored-By: Claude Opus 5.5 --- .../Bink/BinkControlClass/copyBinkToVideoBuffer.cpp | 2 +- .../getCommandIDFromCommandSelectionStuff.cpp | 4 ++-- .../initializeFinalResultsForActivePlayers.cpp | 6 +++--- .../locatePlayerKeepPositionsOnMinimap.cpp | 6 +++--- .../renderMinimapTileStripWithLuminescence.cpp | 10 +++++----- .../Rendering/WindowAndDirectDraw/takeScreenshot.cpp | 8 ++++---- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp | 2 +- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp | 2 +- .../UI/StatusMenus/RenderStatusMenu_Population.cpp | 6 +++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp index fee8c2e691..8dc7617c15 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp @@ -125,7 +125,7 @@ namespace Rendering { // FUNCTION: STRONGHOLDCRUSADER 0x00408FC0 void BinkControlClass::copyBinkToVideoBuffer(dword videoTarget) { - for (int binkObjIndex = 0; binkObjIndex < 2; binkObjIndex++) { + for (int binkObjIndex = 0; binkObjIndex < 2; ++binkObjIndex) { copyBinkToVideoBuffer_copyFrame(this, binkObjIndex, videoTarget); } } diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp index 0f45f6b383..130d7a21fc 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp @@ -17,7 +17,7 @@ namespace Synchrony { this->someIndex = 0; MACRO_CALL_MEMBER(IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( sizeof(this->selectedGameCommands), 0, this->selectedGameCommands); - for (int command = this->gameCommandID; command < 200; command++) { + for (int command = this->gameCommandID; command < 200; ++command) { // The command has not been processed yet, should be processed, and its time has come. if (this->DAT_GameCommandArray[command].stateUnk != 0 && (char)this->DAT_GameCommandArray[command].stateUnk < 10 @@ -43,7 +43,7 @@ namespace Synchrony { } pass++; swapped = 0; - for (int i = 1; i < this->someIndex; i++) { + for (int i = 1; i < this->someIndex; ++i) { int const nextPlayerID = this->selectedGameCommands[i][1]; int const commandID = this->selectedGameCommands[i - 1][0]; int const playerID = this->selectedGameCommands[i - 1][1]; diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp index bb78ee004e..b21f65692f 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp @@ -21,7 +21,7 @@ namespace Synchrony { // perPlayer stays a walker. Naming the fields it reaches - finalGold, finalBuildingsBurned and the rest, all at // [player] - is measured at 88.5% -> 38.3%, and the last three alone at 88.5% -> 70.4%, so do not retry it. int* perPlayer = this->currentPlayerFullIDArray + 1; - for (int player = 1; player < 9; player++, perPlayer++) { + for (int player = 1; player < 9; ++player, ++perPlayer) { // perPlayer[27] is currentAIArray[player]. if ((*perPlayer == -1) && (perPlayer[27] == 0)) { this->finalResults.active[player] = 0; @@ -55,8 +55,8 @@ namespace Synchrony { perPlayer[271772] = 0; } } - for (int row = 0; row < 9; row++) { - for (int column = 0; column < 9; column++) { + for (int row = 0; row < 9; ++row) { + for (int column = 0; column < 9; ++column) { this->finalResults.finalKillMatrix[row][column] = 0; } } diff --git a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp index 83f20d3737..ef90c6cca7 100644 --- a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp +++ b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp @@ -14,7 +14,7 @@ namespace UI { int firstRow = 0; int orientationOffset = 8; int divisor = 2; - for (int player = 0; player < 8; player++) { + for (int player = 0; player < 8; ++player) { this->DAT_MapU4B64.keepPositions[player].x = -1; this->DAT_MapU4B64.keepPositions[player].y = -1; } @@ -40,7 +40,7 @@ namespace UI { } int const firstColumn = firstRow / 2; int rowBase = firstColumn * 401 + orientationOffset + 1; - for (int row = firstRow; row < lastRow - firstRow; row++) { + for (int row = firstRow; row < lastRow - firstRow; ++row) { // the screen tile rows are staggered: every other row is half a tile in and one tile longer int rowX; int rowLength; @@ -59,7 +59,7 @@ namespace UI { } if (scale != 2 || (row * heightFactor & 1) == 0) { int const lastColumn = columns / divisor - firstColumn; - for (int column = firstColumn; column < lastColumn; column++) { + for (int column = firstColumn; column < lastColumn; ++column) { int const x = (column - firstColumn) * widthFactor + rowX; int const buildingID = DAT_TileMapState::instance.BuildingLayer[DAT_ViewportRenderState::instance diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp index 06907e04e1..0867edd847 100644 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp @@ -49,7 +49,7 @@ namespace UI { } int const firstColumn = firstRow / 2; int rowBase = firstColumn * 401 + orientationOffset + 1; - for (int row = firstRow; row < lastRow - firstRow; row++) { + for (int row = firstRow; row < lastRow - firstRow; ++row) { // the screen tile rows are staggered: every other row is half a tile in and one tile longer int rowX; int rowLength; @@ -69,7 +69,7 @@ namespace UI { if (scale != 2 || (row * heightFactor & 1) == 0) { int const y = (row - firstRow) * heightFactor; int const lastColumn = columns / divisor - firstColumn; - for (int column = firstColumn - 2; column < lastColumn; column++) { + for (int column = firstColumn - 2; column < lastColumn; ++column) { int const x = (column - firstColumn) * widthFactor + rowX; int const tile = DAT_ViewportRenderState::instance.screenPointToTileNumber[column + rowBase - 8]; @@ -139,9 +139,9 @@ namespace UI { color = (ushort)(blue & 0x1f | green | red); } if (scale == 1) { - for (int dx = 0; dx < widthFactor; dx++) { + for (int dx = 0; dx < widthFactor; ++dx) { if (0 <= x + dx && x + dx < columns * widthFactor) { - for (int dy = 0; dy < heightFactor; dy++) { + for (int dy = 0; dy < heightFactor; ++dy) { if ((short)color == 0) { color = this->minimapPixelBuffer[(y + dy) * 400 / 2 + x + dx]; } @@ -154,7 +154,7 @@ namespace UI { for (int dx = x & 1; dx < widthFactor; dx += 2) { if (0 <= x + dx && x + dx < columns * widthFactor) { int const pixelX = (x + dx) / scale; - for (int dy = 0; dy < heightFactor; dy++) { + for (int dy = 0; dy < heightFactor; ++dy) { int const pixelY = (y + dy) / scale; if ((short)color == 0) { color = this->minimapPixelBuffer[pixelY * 400 / 2 + pixelX]; diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp index 07ad88e093..be135863ea 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp @@ -49,7 +49,7 @@ namespace UI { fileHeader.bfSize = this->numPixel_GameX_x_3_x_GameY_0x4c + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); - for (uint i = 0; i < sizeof(fileHeader); i++) { + for (uint i = 0; i < sizeof(fileHeader); ++i) { file << ((char*)&fileHeader)[i]; } @@ -63,15 +63,15 @@ namespace UI { infoHeader.biHeight = this->resolutionY; infoHeader.biCompression = BI_RGB; infoHeader.biSizeImage = this->numPixel_GameX_x_3_x_GameY_0x4c; - for (uint i = 0; i < sizeof(infoHeader); i++) { + for (uint i = 0; i < sizeof(infoHeader); ++i) { file << ((char*)&infoHeader)[i]; } // RGB565 rows, bottom-up, written as BGR24. The walking pointer and the named char locals are both // load-bearing: row[x] cost 10 points and passing the expressions directly cost 6 (quick_diff). - for (int y = this->resolutionY - 1; y >= 0; y--) { + for (int y = this->resolutionY - 1; y >= 0; --y) { ushort* pixelPtr = this->surfacePointer_screenMenu + this->resolutionX * y; - for (int x = 0; x < this->resolutionX; x++) { + for (int x = 0; x < this->resolutionX; ++x) { int const pixel = *pixelPtr++; char const blue = (char)pixel << 3; file << blue; diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index 95d6db76fb..328656677b 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -53,7 +53,7 @@ namespace UI { groupSize = 9; } // an icon and the head count of each unit type in the group - for (int i = 0; i < groupSize; i++) { + for (int i = 0; i < groupSize; ++i) { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, DAT_TextureRenderCoreObject::ptr)(firstGroupIcon + i + 4, x + 85 + i * 46, top + 40); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp index a6a9313f2c..88f84feb6f 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp @@ -39,7 +39,7 @@ namespace UI { DAT_MenuHandlerState::instance.x + 316, top + 70, OpenSHC::Text::TTA_CENTER, 0, 18, FALSE, 0); } // the stock of the four foods - for (int food = 0; food < 4; food++) { + for (int food = 0; food < 4; ++food) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[DAT_ARRAY_0061818c::instance[food]], diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp index 8bf1de96f5..d48b77cb6c 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp @@ -70,7 +70,7 @@ namespace UI { x + 340, top + 142, OpenSHC::Text::TTA_CENTER, 0, 19, FALSE, 0); // the vertical scale: 50 people per 75 pixels, doubled until the highest population fits int highest = 0; - for (int month = 0; month < months; month++) { + for (int month = 0; month < months; ++month) { if (DAT_GameState::instance.mapAndTime.playerPopulationStatistics[player][month] > highest) { highest = DAT_GameState::instance.mapAndTime.playerPopulationStatistics[player][month]; } @@ -103,7 +103,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( 0, x + 180, top + 120, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); // a year label every five years - for (int label = 0; label <= 5; label++) { + for (int label = 0; label <= 5; ++label) { int firstYear = (DAT_GameState::instance.mapAndTime.populationIndex - 300) / 12; if (firstYear < 0) { firstYear = 0; @@ -114,7 +114,7 @@ namespace UI { } // one bar per month if (months <= 300) { - for (int month = 0; month < months; month++) { + for (int month = 0; month < months; ++month) { short const population = DAT_GameState::instance.mapAndTime.playerPopulationStatistics[player][month]; if (population > 0) { int const height = population * 75 / (scale * 50); From 74dbb76dbdccdcb511b1a122984c5cb7f9dda560 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 02:35:19 +0100 Subject: [PATCH 55/78] header: drop this PR's basic_ofstream_write change, nothing here calls it any more takeScreenshot now writes with the compiler's own std::ofstream (gynt on #313), so the game's statically linked operator<<(ostream&, char) at 0x004791B0 is no longer called, and OS.hpp and OS.func.hpp are main's again. For the record: that function takes a char, not a uint. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/OS.func.hpp | 2 +- src/OpenSHC/OS.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/OS.func.hpp b/src/OpenSHC/OS.func.hpp index 793ae204e7..efbddd61a4 100644 --- a/src/OpenSHC/OS.func.hpp +++ b/src/OpenSHC/OS.func.hpp @@ -24,7 +24,7 @@ namespace OS_Func { using OpenSHC::OS::_atexit_t; using OpenSHC::WindowsHelper::Enums::BOOLEnum; - MACRO_FUNCTION_RESOLVER(int*(__cdecl*)(void* param_1, char param_2), REIMPLEMENTED_CRT, + MACRO_FUNCTION_RESOLVER(int*(__cdecl*)(void* param_1, uint param_2), REIMPLEMENTED_CRT, Address::SHC_3BB0A8C1_0x004791B0, &OpenSHC::OS::basic_ofstream_write) basic_ofstream_write; diff --git a/src/OpenSHC/OS.hpp b/src/OpenSHC/OS.hpp index 670b72b1e6..b419e05e28 100644 --- a/src/OpenSHC/OS.hpp +++ b/src/OpenSHC/OS.hpp @@ -25,7 +25,7 @@ namespace OS { using OpenSHC::OS::_atexit_t; using OpenSHC::WindowsHelper::Enums::BOOLEnum; - int* __cdecl basic_ofstream_write(void* param_1, char param_2); + int* __cdecl basic_ofstream_write(void* param_1, uint param_2); BOOLEnum __cdecl isEqualGUID(GUID* param_1, GUID* param_2); From d372ee003d96201b0ccee7cac718b20f6dfff5ff Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 03:13:17 +0100 Subject: [PATCH 56/78] header: seven globals the code compares as signed are int DAT_00ed3170 (the vertical clip offset in the two BlitMapImageWithVerticalClip functions), DAT_00b98428/2c/30 (counters compared with 9 in the chapel and church menu), DAT_00b9845c (a 0..40 counter, like DAT_00b98448), DAT_00ed2784 (a progress bar width compared with 580) and DAT_CurrentButtonPictureInGm (tested >= 0). Nothing on main uses them. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00b98428.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00b9842c.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00b98430.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00b9845c.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00ed2784.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00ed3170.hpp | 4 ++-- src/OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00b98428.hpp b/src/OpenSHC/Globals/DAT_00b98428.hpp index 90615620b3..1f196e123f 100644 --- a/src/OpenSHC/Globals/DAT_00b98428.hpp +++ b/src/OpenSHC/Globals/DAT_00b98428.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B98428 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B98428) DAT_00b98428; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B98428) DAT_00b98428; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B98428); diff --git a/src/OpenSHC/Globals/DAT_00b9842c.hpp b/src/OpenSHC/Globals/DAT_00b9842c.hpp index 4e3f052dea..55403e516f 100644 --- a/src/OpenSHC/Globals/DAT_00b9842c.hpp +++ b/src/OpenSHC/Globals/DAT_00b9842c.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B9842C -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B9842C) DAT_00b9842c; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B9842C) DAT_00b9842c; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B9842C); diff --git a/src/OpenSHC/Globals/DAT_00b98430.hpp b/src/OpenSHC/Globals/DAT_00b98430.hpp index f075de4df7..51f4eeab36 100644 --- a/src/OpenSHC/Globals/DAT_00b98430.hpp +++ b/src/OpenSHC/Globals/DAT_00b98430.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B98430 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B98430) DAT_00b98430; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B98430) DAT_00b98430; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B98430); diff --git a/src/OpenSHC/Globals/DAT_00b9845c.hpp b/src/OpenSHC/Globals/DAT_00b9845c.hpp index 9be0bf3794..aade7806f4 100644 --- a/src/OpenSHC/Globals/DAT_00b9845c.hpp +++ b/src/OpenSHC/Globals/DAT_00b9845c.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B9845C -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B9845C) DAT_00b9845c; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B9845C) DAT_00b9845c; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B9845C); diff --git a/src/OpenSHC/Globals/DAT_00ed2784.hpp b/src/OpenSHC/Globals/DAT_00ed2784.hpp index 41361ad099..0c660b232d 100644 --- a/src/OpenSHC/Globals/DAT_00ed2784.hpp +++ b/src/OpenSHC/Globals/DAT_00ed2784.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00ED2784 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00ED2784) DAT_00ed2784; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00ED2784) DAT_00ed2784; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00ED2784); diff --git a/src/OpenSHC/Globals/DAT_00ed3170.hpp b/src/OpenSHC/Globals/DAT_00ed3170.hpp index 74c06ea9a1..f12c3edcb4 100644 --- a/src/OpenSHC/Globals/DAT_00ed3170.hpp +++ b/src/OpenSHC/Globals/DAT_00ed3170.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00ED3170 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00ED3170) DAT_00ed3170; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00ED3170) DAT_00ed3170; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00ED3170); diff --git a/src/OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp b/src/OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp index d538a235ed..a7abcb3295 100644 --- a/src/OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp +++ b/src/OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00ED31C0 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00ED31C0) DAT_CurrentButtonPictureInGm; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00ED31C0) DAT_CurrentButtonPictureInGm; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00ED31C0); From fb337c10287ace71e5d739a193d8a567173d3874 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 03:13:53 +0100 Subject: [PATCH 57/78] style: drop the (int) casts on the globals that are int now The two BlitMapImageWithVerticalClip functions keep their static pointer to DAT_00ed3170 as int*. quick_diff output is identical for every file that uses these globals. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp | 8 ++++---- .../Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp | 8 ++++---- .../BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp | 6 +++--- .../AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp | 2 +- src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp | 2 +- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp index f79cab693c..0b6fa6ec1c 100644 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp @@ -27,7 +27,7 @@ using UI::Rendering::WindowAndDirectDraw; static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; static uint* const s_blitModeUnk = &DAT_00ed317c::instance; -static uint* const s_remainingRowsUnk = &DAT_00ed3170::instance; +static int* const s_remainingRowsUnk = &DAT_00ed3170::instance; // FUNCTION: STRONGHOLDCRUSADER 0x00453B00 void Rendering::BlitMapImageWithVerticalClip() @@ -38,7 +38,7 @@ void Rendering::BlitMapImageWithVerticalClip() int height = DAT_GMImageHeaders::instance.imh[DAT_GmImageAddressToBeRendered::instance].height - 7; int skip = 0; int nextSkip = 0; - if ((int)DAT_00ed3170::instance <= 0) { + if (DAT_00ed3170::instance <= 0) { return; } if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { @@ -49,7 +49,7 @@ void Rendering::BlitMapImageWithVerticalClip() height -= clippedRows; skip = clippedRows * 60; } - if ((int)(DAT_00ed3170::instance + drawY) >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + if (DAT_00ed3170::instance + drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { DAT_00ed3170::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; // fixme: always adds 0, the original subtracts the already shortened row count height = height @@ -59,7 +59,7 @@ void Rendering::BlitMapImageWithVerticalClip() if (height <= 0) { firstRows = 0; nextSkip *= 60; - } else if (height < (int)DAT_00ed3170::instance) { + } else if (height < DAT_00ed3170::instance) { firstRows = height; DAT_00ed3170::instance -= height; nextSkip = 0; diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp index 2a6be0c9a6..a2e8537765 100644 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp @@ -24,7 +24,7 @@ using UI::Rendering::WindowAndDirectDraw; static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; static uint* const s_blitModeUnk = &DAT_00ed317c::instance; -static uint* const s_remainingRowsUnk = &DAT_00ed3170::instance; +static int* const s_remainingRowsUnk = &DAT_00ed3170::instance; // FUNCTION: STRONGHOLDCRUSADER 0x00454080 void Rendering::BlitMapImageWithVerticalClipAndYOffset() @@ -35,7 +35,7 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() int height = DAT_GMImageHeaders::instance.imh[DAT_GmImageAddressToBeRendered::instance].height - 7; int skip = 0; int nextSkip = 160 - DAT_RenderMap_YOffset::instance; - if ((int)DAT_00ed3170::instance <= 0) { + if (DAT_00ed3170::instance <= 0) { return; } if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { @@ -45,7 +45,7 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() nextSkip += skip; height -= skip; } - if ((int)(DAT_00ed3170::instance + drawY) >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + if (DAT_00ed3170::instance + drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { DAT_00ed3170::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; // fixme: always adds 0, the original subtracts the already shortened row count height = height @@ -57,7 +57,7 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() int firstRows; if (height <= 0) { firstRows = 0; - } else if (height < (int)DAT_00ed3170::instance) { + } else if (height < DAT_00ed3170::instance) { DAT_00ed3170::instance -= height; firstRows = height; nextSkip += height * 60; diff --git a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp index 6086c6cdd6..bd2ace2508 100644 --- a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp +++ b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp @@ -138,19 +138,19 @@ namespace UI { switch (DAT_WifeUnitType::instance) { case OpenSHC::Map::Units::UT_BREWER: ++DAT_00b98428::instance; - if (9 < (int)DAT_00b98428::instance) { + if (9 < DAT_00b98428::instance) { DAT_00b98428::instance = 0; } break; case OpenSHC::Map::Units::UT_TANNER: ++DAT_00b9842c::instance; - if (9 < (int)DAT_00b9842c::instance) { + if (9 < DAT_00b9842c::instance) { DAT_00b9842c::instance = 0; } break; default: ++DAT_00b98430::instance; - if (9 < (int)DAT_00b98430::instance) { + if (9 < DAT_00b98430::instance) { DAT_00b98430::instance = 0; } } diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp index 5a98f5f008..d2c3f764ae 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp @@ -27,7 +27,7 @@ namespace UI { BOOLEnum AlphaAndButtonSurface::isMouseOnButtonImageUnk() { ushort* const surface = this->surfacePtr; - if ((int)DAT_CurrentButtonPictureInGm::instance >= 0) { + if (DAT_CurrentButtonPictureInGm::instance >= 0) { int const imageIndex = GMFirstPictureIndex::instance[DAT_UIButtonDefinedData::instance .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] .gmId_0x0] diff --git a/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp b/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp index 1c61ec53e7..ca78f674aa 100644 --- a/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp +++ b/src/OpenSHC/UI/Rendering/RenderTextPageProgressBar.cpp @@ -19,7 +19,7 @@ namespace UI { elapsed = 0; } DAT_00ed2784::instance = elapsed / 80; - if ((int)DAT_00ed2784::instance > 580) { + if (DAT_00ed2784::instance > 580) { DAT_00ed2784::instance = 580; } RECT sourceRect; diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index 328656677b..e9f44473df 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -35,7 +35,7 @@ namespace UI { int const top = y + 447; ++DAT_00b9845c::instance; int nudge = 0; - if (40 < (int)DAT_00b9845c::instance) { + if (40 < DAT_00b9845c::instance) { DAT_00b9845c::instance = 0; MACRO_CALL(OpenSHC::UI::Helpers_Func::CountPlayerUnitsByType)(); } From 1ac567010bccc7512ca828d00fd4862e48119093 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 05:14:13 +0100 Subject: [PATCH 58/78] style: drop BOOLEnum.hpp and BGR24.hpp where the type is never named 19 includes in 15 files (TRUE and FALSE are the Windows macros). quick_diff output is identical. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp | 1 - .../Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp | 1 - .../GameSynchronyState/determineGameTicksToPerform.cpp | 1 - .../UI/MenuTextInputState/activateModalDialogAndClearText.cpp | 1 - src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp | 1 - src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp | 1 - src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp | 1 - src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp | 1 - src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp | 2 -- .../Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp | 1 - src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp | 1 - .../UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp | 1 - src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp | 2 -- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp | 2 -- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp | 2 -- 15 files changed, 19 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp index 407b7b7a7b..d84c562885 100644 --- a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp +++ b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp @@ -14,7 +14,6 @@ #include "OpenSHC/UI/Enums/DisplayElementID.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" #include "OpenSHC/UI/Enums/MenuViewType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_BinkControlState.hpp" #include "OpenSHC/Globals/DAT_GameCore.hpp" diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp index 8dc7617c15..d765ad72cd 100644 --- a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp @@ -6,7 +6,6 @@ #include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" #include "OpenSHC/Rendering/Bink/UnsortedBinkFlag.hpp" #include "OpenSHC/UI/Menu.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/COL_BLACK.hpp" #include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp index 68e937a456..6265d20a07 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp @@ -2,7 +2,6 @@ #include "OpenSHC/Synchrony.func.hpp" #include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_GameCore.hpp" #include "OpenSHC/Globals/DAT_GameLoopStopwatch.hpp" diff --git a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp index 2963ec4062..26a51ae170 100644 --- a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp @@ -4,7 +4,6 @@ #include "OpenSHC/UI/MenuModalComposition.func.hpp" #include "OpenSHC/Text/TextArrayIndexType.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" #include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" diff --git a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp index 724327e324..28c2ce0ba5 100644 --- a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp @@ -3,7 +3,6 @@ #include "OpenSHC/Text/UserTextHandler.func.hpp" #include "OpenSHC/UI/MenuModalComposition.func.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" #include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index 500b0b5022..15e981458d 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -11,7 +11,6 @@ #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/COL_WHITE.hpp" diff --git a/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp b/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp index 8b80557926..a032f5a5e3 100644 --- a/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp +++ b/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp @@ -6,7 +6,6 @@ #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" #include "OpenSHC/UI/Enums/MenuViewType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" #include "OpenSHC/Globals/DAT_GameCore.hpp" diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index bf86977207..d4215aabfc 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -12,7 +12,6 @@ #include "OpenSHC/IO/Graphics/GmID.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/DAT_00eb0b24.hpp" diff --git a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp index 3a18472acb..2f8b5a98df 100644 --- a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp +++ b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp @@ -3,10 +3,8 @@ #include "OpenSHC/Text/TextManager.func.hpp" #include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/BGR24.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" #include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp index 68e9046da1..73d1ca0716 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp @@ -1,6 +1,5 @@ #include "../WindowAndDirectDraw.func.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp index 79a2402f76..53703550a4 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp @@ -1,6 +1,5 @@ #include "../WindowAndDirectDraw.func.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp index 91da5878ba..ad0d155f11 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -1,7 +1,6 @@ #include "../WindowAndDirectDraw.func.hpp" #include "OpenSHC/OS.func.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index e9f44473df..1d909b36ac 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -6,10 +6,8 @@ #include "OpenSHC/DE/SHCDE/eGM.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/Map/Units/UnitTypeInt.hpp" -#include "OpenSHC/Rendering/Colors/BGR24.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/DAT_00b95b68.hpp" diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp index 88f84feb6f..8984253767 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp @@ -3,10 +3,8 @@ #include "OpenSHC/Text/TextManager.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/Rendering/Colors/BGR24.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_ARRAY_0061818c.hpp" #include "OpenSHC/Globals/DAT_GameState.hpp" diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp index d48b77cb6c..7bf7b6f3c4 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp @@ -4,10 +4,8 @@ #include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/BGR24.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/COL_BLACK.hpp" #include "OpenSHC/Globals/DAT_GameState.hpp" From bd6a7137e744e6ddab647561e711b35ac0e63be5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 05:15:07 +0100 Subject: [PATCH 59/78] style: clang-format after the include clean-up Co-Authored-By: Claude Opus 5.5 --- .../Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp | 1 - src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp index 73d1ca0716..79d9e802ca 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp @@ -1,6 +1,5 @@ #include "../WindowAndDirectDraw.func.hpp" - #include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" namespace OpenSHC { diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp index 53703550a4..fcab4577bd 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp @@ -1,6 +1,5 @@ #include "../WindowAndDirectDraw.func.hpp" - #include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" namespace OpenSHC { From e4c935e920e88d4e3abed6a5708a3a416d3e748d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:20:24 +0100 Subject: [PATCH 60/78] fix: follow bc45882f8's field names in openBuildingStatusMenuForBuildingID Building's field203_0x2c6 is field202_0x2c6 after the sync. quick_diff output is identical. Co-Authored-By: Claude Opus 5.5 --- .../openBuildingStatusMenuForBuildingID.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp index 2ad6025274..ee993dce58 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp @@ -294,7 +294,7 @@ namespace UI { case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE: case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: case OpenSHC::Map::Buildings::BT_WOODGATE1: - if (DAT_BuildingsState::instance.buildings[buildingID].field203_0x2c6 != 0) { + if (DAT_BuildingsState::instance.buildings[buildingID].field202_0x2c6 != 0) { return FALSE; } menuTab = 36; @@ -315,7 +315,7 @@ namespace UI { (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), OpenSHC::Map::Buildings::BT_GATEHOUSESMALL, 0); } - if (gatehouse != 0 && DAT_BuildingsState::instance.buildings[gatehouse].field203_0x2c6 != 0) { + if (gatehouse != 0 && DAT_BuildingsState::instance.buildings[gatehouse].field202_0x2c6 != 0) { return FALSE; } menuTab = 37; From 881c4579613dc09cd1559d5a468476710e0ee7e1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 15:17:56 +0100 Subject: [PATCH 61/78] Name the text colours with main's ColorsEnum The style guide's rule 18 asks for a name over a number; main's ColorsEnum (a521bf7bd) has COL_CCFAFF and COL_00FF00 for the colours these functions pass to the text renderers. quick_diff output is identical for all 35 files (in renderFunctionResponsibleForManyGameObjects only MSVC's label numbering moves, from the header sync). Co-Authored-By: Claude Opus 5.5 --- .../Bink/AIMessageQueue/playAiLordMessage.cpp | 10 +++--- .../UI/Rendering/RenderGreatestLordScreen.cpp | 33 ++++++++++--------- .../Rendering/RenderMissionObjectivesUnk.cpp | 9 ++--- .../RenderScenarioButtonWithText.cpp | 3 +- .../UI/StatusMenus/RenderStatusMenu_Army.cpp | 5 +-- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp index d84c562885..97461b47fc 100644 --- a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp +++ b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp @@ -10,6 +10,7 @@ #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" #include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" #include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" #include "OpenSHC/UI/Enums/DisplayElementID.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" @@ -58,8 +59,8 @@ namespace Rendering { &DAT_TextManagerObject::instance.fontSizeClassArray[18])( (WCHAR*)this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineWideTextUnk, DAT_TextManagerObject::ptr)( - (WCHAR*)this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, 0xccfaff, 0, 18, - 0); + (WCHAR*)this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, 0); } else { textHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, &DAT_TextManagerObject::instance.fontSizeClassArray[18])( @@ -68,7 +69,8 @@ namespace Rendering { &DAT_TextManagerObject::instance.fontSizeClassArray[18])( this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( - this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, 0xccfaff, 0, 18, 0); + this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, 0); } if ((int)this->currentMessageUnknownValue2_0xd4 > 0) { int const nameHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, @@ -81,7 +83,7 @@ namespace Rendering { 0, 0, 2); MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], - x - nameWidth, yOffset - nameHeight + y, 580, 0xccfaff, 0, 18, 0); + x - nameWidth, yOffset - nameHeight + y, 580, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, 0); int aiCharacter = 0; if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[this->currentMessageUnknownValue2_0xd4] == -1) { diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index 15e981458d..aadd909ad5 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -8,6 +8,7 @@ #include "OpenSHC/DE/SHCDE/eGM.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" #include "OpenSHC/Text/TextAlignment.hpp" @@ -495,10 +496,10 @@ namespace UI { .GreatestLordTextEntries[DAT_00eb9af8::instance][0], DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 545, - OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( dateText, DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 575, - OpenSHC::Text::TTA_CENTER, 0xccfaff, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, @@ -506,10 +507,10 @@ namespace UI { .GreatestLordTextEntries[DAT_00eb9af8::instance][0], DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 602, - OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( dateText, DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 632, - OpenSHC::Text::TTA_CENTER, 0xccfaff, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); } } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( @@ -518,7 +519,7 @@ namespace UI { .GreatestLordTextEntries[DAT_00eb9af8::instance][0], DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 560, - OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, @@ -526,7 +527,7 @@ namespace UI { .GreatestLordTextEntries[DAT_00eb9af8::instance][0], DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 617, - OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); } } DAT_00eb9af8::instance = DAT_FinalResultsOrderByColumn::instance; @@ -550,26 +551,26 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 27), DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, FALSE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( scoreText, DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, - OpenSHC::Text::TTA_LEFT, 0xccfaff, 18, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); // "Save File" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 28), DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(saveText, DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 + 50 + DAT_MenuHandlerState::instance.x; // "To submit this score, visit" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 29), DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 575, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, FALSE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); // "www.fireflyworlds.com" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, @@ -588,26 +589,26 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 27), DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, FALSE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( scoreText, DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, - OpenSHC::Text::TTA_LEFT, 0xccfaff, 18, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); // "Save File" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 28), DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(saveText, DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 - 42 + DAT_MenuHandlerState::instance.x; // "To submit this score, visit" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 29), DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 632, OpenSHC::Text::TTA_LEFT, - 0xccfaff, 18, FALSE, 0); + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); // "www.fireflyworlds.com" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index d4215aabfc..34acb004d4 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -10,6 +10,7 @@ #include "OpenSHC/Game/GameMode2.hpp" #include "OpenSHC/Game/Resources/ResourceType.hpp" #include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/string-literals.hpp" @@ -47,12 +48,12 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 26), - headerX, headerY, OpenSHC::Text::TTA_LEFT, 0xccfaff, 17, FALSE, 0); + headerX, headerY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 0), - headerX, headerY, OpenSHC::Text::TTA_LEFT, 0xccfaff, 17, FALSE, 0); + headerX, headerY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); // first pass: measure the texts for the number column and the tick boxes for (int objective = 0; objective < 39; ++objective) { @@ -447,8 +448,8 @@ namespace UI { MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)( DAT_GameCore::instance.standaloneFilename, &eventIndex), DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 400, - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 10, OpenSHC::Text::TTA_CENTER, 0xccfaff, 17, FALSE, - 0); + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 10, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); // the visible height, rounded up to whole lines of 23 pixels int pageHeight = 377 - offset; pageHeight += 22 - (pageHeight + 22) % 23; diff --git a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp index 2f8b5a98df..4da783f852 100644 --- a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp +++ b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp @@ -3,6 +3,7 @@ #include "OpenSHC/Text/TextManager.func.hpp" #include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" @@ -32,7 +33,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), - x, y, OpenSHC::Text::TTA_CENTER, 0xccfaff, 18, FALSE, 0); + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); } } diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index 1d909b36ac..207424cb3c 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -6,6 +6,7 @@ #include "OpenSHC/DE/SHCDE/eGM.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/Map/Units/UnitTypeInt.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/string-literals.hpp" @@ -92,8 +93,8 @@ namespace UI { DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel * 5, - x + 162, top + 25, OpenSHC::Text::TTA_LEFT, 65280, 0, 18, TRUE, 0); - color = 65280; + x + 162, top + 25, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_00FF00, 0, 18, TRUE, 0); + color = OpenSHC::Rendering::Colors::COL_00FF00; percentX = x + 164; } else if (fearFactor < 0) { DAT_TextManagerObject::instance.field8_0x20 = 1; From bff2b9015db9694974174a82af7867847267db36 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 22:06:15 +0100 Subject: [PATCH 62/78] reimplement: SHC_3BB0A8C1_0x00454080 86.3% the C++ part before the asm keeps its values in other registers; the asm matches Rendering::BlitMapImageWithVerticalClipAndYOffset: fix a stack bug in the transcribed asm. Both asm blocks ended with pop ebx, copied from the binary, with no push to match. In the original that pop belongs to the compiler's epilogue, which pairs it with a push ebx made after the early return. In our build MSVC saves ebx in the prologue itself, because the asm uses ebx, and pops it again in its own epilogue. The extra pop in the asm therefore took the saved edi slot, and the function returned with the caller's esi, edi and ebx wrong. The two pops are removed. The asm now also names its globals directly (DAT_WindowAndDirectDraw, DAT_RenderMap_DrawSomeX, DAT_00ed317c, DAT_00ed3170) instead of going through static pointers. Inline asm can name a resolver global once C++ code has instantiated it; a sizeof does that for the ones the C++ part doesn't use, without generating code. The same fix took BlitMapImageWithVerticalClip (0x00453B00) to 100%. Measured with both resolver sets on (--resolve-wrapped-calls --ignore-security-cookie): 79.7% -> 86.3% raw (normalized 61.2% -> 48.0%). Every remaining difference is in the C++ part before the first asm block, which keeps its values (the Y offset, the image header, the remaining row count) in other registers than the original. Four arrangements of its declarations didn't fix that. Co-Authored-By: Claude Opus 5.5 --- ...BlitMapImageWithVerticalClipAndYOffset.cpp | 47 +++++++------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp index a2e8537765..c74f0e591b 100644 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp @@ -15,20 +15,17 @@ namespace OpenSHC { -using UI::Rendering::WindowAndDirectDraw; - // Like BlitMapImageWithVerticalClip, but the second image (DAT_00ed316c) starts 160 - DAT_RenderMap_YOffset rows in. // The copy loops are handwritten assembly in the original, transcribed here from the binary. -// Inline assembly cannot name a resolver global, so the loops reach the globals they use through these. -static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; -static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; -static uint* const s_blitModeUnk = &DAT_00ed317c::instance; -static int* const s_remainingRowsUnk = &DAT_00ed3170::instance; - // FUNCTION: STRONGHOLDCRUSADER 0x00454080 void Rendering::BlitMapImageWithVerticalClipAndYOffset() { + // The asm below names these globals, which inline asm can only do once C++ code has instantiated them; + // sizeof does that without generating any code. + (void)sizeof(DAT_WindowAndDirectDraw::instance); + (void)sizeof(DAT_RenderMap_DrawSomeX::instance); + (void)sizeof(DAT_00ed317c::instance); char* image = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; char* nextImage = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; int drawY = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance) + 9; @@ -77,10 +74,8 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() mov esi, image mov eax, skip add esi, eax - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] + mov edi, DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame + mov eax, DAT_RenderMap_DrawSomeX::instance add eax, eax add edi, eax mov eax, drawY @@ -91,8 +86,7 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() cmp edx, 0 jle nrm_454359 nrm_4541d6: - mov eax, s_blitModeUnk - mov eax, dword ptr [eax] + mov eax, DAT_00ed317c::instance cmp eax, 1 je nrm_45428f cmp eax, 2 @@ -192,17 +186,15 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() jle nrm_454359 jmp nrm_45433d nrm_454359: - mov eax, s_remainingRowsUnk - cmp dword ptr [eax], 0 + cmp DAT_00ed3170::instance, 0 jle nrm_45437f - mov edx, dword ptr [eax] - mov dword ptr [eax], 0 + mov edx, DAT_00ed3170::instance + mov DAT_00ed3170::instance, 0 mov esi, dword ptr nextImage mov eax, dword ptr nextSkip add esi, eax jmp nrm_4541d6 nrm_45437f: - pop ebx } // clang-format on return; @@ -212,10 +204,8 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() mov esi, image mov eax, skip add esi, eax - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] + mov edi, DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame + mov eax, DAT_RenderMap_DrawSomeX::instance and eax, 0xfffffffe add edi, eax mov eax, drawY @@ -228,8 +218,7 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() cmp edx, 0 jle zm_4545eb zm_4543ba: - mov eax, s_blitModeUnk - mov eax, dword ptr [eax] + mov eax, DAT_00ed317c::instance cmp eax, 1 je zm_4544ac cmp eax, 2 @@ -374,17 +363,15 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() jle zm_4545eb jmp zm_4545b3 zm_4545eb: - mov eax, s_remainingRowsUnk - cmp dword ptr [eax], 0 + cmp DAT_00ed3170::instance, 0 jle zm_454611 - mov edx, dword ptr [eax] - mov dword ptr [eax], 0 + mov edx, DAT_00ed3170::instance + mov DAT_00ed3170::instance, 0 mov esi, dword ptr nextImage mov eax, dword ptr nextSkip add esi, eax jmp zm_4543ba zm_454611: - pop ebx } // clang-format on } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f10d0dcc96..73c58d5da3 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16971,7 +16971,7 @@ SHC_3BB0A8C1_0x00453600 | 89.4% | Globals via statics in asm SHC_3BB0A8C1_0x00453B00 | 92.6% | Globals via statics in asm -SHC_3BB0A8C1_0x00454080 | 79.7% | Prologue registers rotated +SHC_3BB0A8C1_0x00454080 | 86.3% | the C++ part before the asm keeps its values in other registers; the asm matches SHC_3BB0A8C1_0x00454620 | 0.0% | Pending From 955b59e47c4b82cf22e274dbae90f5c8e692ce9d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 22:07:26 +0100 Subject: [PATCH 63/78] Take the nine functions that reached 100% out of this draft renderFunctionResponsibleForManyGameObjects, initializeFinalResultsForActivePlayers, RenderTerrainTilesCenterPiece, RenderScenarioButtonWithText, getCommandIDFromCommandSelectionStuff, RenderGoldValue, ApplyBlending, BlitMapImageWithVerticalClip and renderMinimapPreview now measure 100% and are in a ready PR of their own, so this draft no longer carries them: their files and status lines are back to main's. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Rendering/ApplyBlending.cpp | 377 ----- .../BlitMapImageWithVerticalClip.cpp | 390 ----- .../getCommandIDFromCommandSelectionStuff.cpp | 68 - ...initializeFinalResultsForActivePlayers.cpp | 66 - .../MinimapViewState/renderMinimapPreview.cpp | 56 - src/OpenSHC/UI/Rendering/RenderGoldValue.cpp | 131 -- .../RenderScenarioButtonWithText.cpp | 41 - .../RenderTerrainTilesCenterPiece.cpp | 594 ------- ...rFunctionResponsibleForManyGameObjects.cpp | 1494 ----------------- status/addresses-SHC-3BB0A8C1.txt | 18 +- 10 files changed, 9 insertions(+), 3226 deletions(-) delete mode 100644 src/OpenSHC/Rendering/ApplyBlending.cpp delete mode 100644 src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp delete mode 100644 src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp delete mode 100644 src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp delete mode 100644 src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp delete mode 100644 src/OpenSHC/UI/Rendering/RenderGoldValue.cpp delete mode 100644 src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp delete mode 100644 src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp delete mode 100644 src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp diff --git a/src/OpenSHC/Rendering/ApplyBlending.cpp b/src/OpenSHC/Rendering/ApplyBlending.cpp deleted file mode 100644 index 428474e0d0..0000000000 --- a/src/OpenSHC/Rendering/ApplyBlending.cpp +++ /dev/null @@ -1,377 +0,0 @@ -#include "../Rendering.func.hpp" - -#include "OpenSHC/UI/Rendering.func.hpp" -#include "OpenSHC/Rendering/ColorMode.hpp" - -#include "OpenSHC/Globals/DAT_00ed3154.hpp" -#include "OpenSHC/Globals/DAT_BlendFilterArrays.hpp" -#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" -#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" -#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" - -namespace OpenSHC { - -using UI::Rendering::WindowAndDirectDraw; - -// Blends the tile being drawn into the map surface, pixel by pixel: every colour component of the tile and of the -// surface under it is looked up in DAT_BlendFilterArrays (scaled by (32 - blendLevel) / 32 and blendLevel / 32) and -// the two results are added. The offset tables say where each pixel of the diamond-shaped tile lands on the -// 4056-pixel-wide map surface; zoomed out, every other row and column is used. -// The pixel loops are handwritten assembly in the original, transcribed here from the binary. - -// Inline assembly cannot name a resolver global, so the loops reach the two globals they use through these. -static UI::Rendering::WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; -static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; - -// FUNCTION: STRONGHOLDCRUSADER 0x00453600 -void Rendering::ApplyBlending(int blendLevel) -{ - int* offsets; - short* destinationTable; - short* sourceTable; - ushort* source; - if (!DAT_TextureRenderCoreObject::instance.isZoom2) { - offsets = DAT_BlendingDefinedData::instance.field164_0x27fc; - int const drawY = DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance + DAT_RenderMap_DrawSomeY::instance; - if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - || drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { - return; - } - source = (ushort*)((char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData - + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]); - if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { - MACRO_CALL(UI::Rendering_Func::InitBlendFilterArraysUnk)(); - } - destinationTable = DAT_BlendFilterArrays::instance[blendLevel][0]; - sourceTable = DAT_BlendFilterArrays::instance[32 - blendLevel][0]; - if (DAT_WindowAndDirectDraw::instance.colorBitMode == Rendering::RGB_555) { - // clang-format off - __asm { - mov esi, source - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - add eax, eax - add edi, eax - mov eax, drawY - mov edx, 0x1fb0 - mul edx - add edi, eax - mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi - mov ecx, 0x100 -n555_4536c0: - mov ax, word ptr [esi] - mov edx, dword ptr sourceTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xfc1f - or ax, bx - mov bx, ax - shr bx, 0xa - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x3ff - or ax, bx - push ax - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov ax, word ptr [edi + edx] - mov edx, dword ptr destinationTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xfc1f - or ax, bx - mov bx, ax - shr bx, 0xa - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x83ff - or ax, bx - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov word ptr [edi + edx], ax - pop ax - add word ptr [edi + edx], ax - add esi, 2 - add dword ptr offsets, 4 - sub cx, 1 - jne n555_4536c0 - } - // clang-format on - return; - } - // clang-format off - __asm { - mov esi, source - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - add eax, eax - add edi, eax - mov eax, drawY - mov edx, 0x1fb0 - mul edx - add edi, eax - mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi - mov ecx, 0x100 -n565_4537ae: - mov ax, word ptr [esi] - mov edx, dword ptr sourceTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x3f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xf81f - or ax, bx - mov bx, ax - shr bx, 0xb - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x7ff - or ax, bx - push ax - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov ax, word ptr [edi + edx] - mov edx, dword ptr destinationTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x3f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xf81f - or ax, bx - mov bx, ax - shr bx, 0xb - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x7ff - or ax, bx - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov word ptr [edi + edx], ax - pop ax - add word ptr [edi + edx], ax - add esi, 2 - add dword ptr offsets, 4 - sub cx, 1 - jne n565_4537ae - } - // clang-format on - return; - } - - offsets = DAT_BlendingDefinedData::instance.field166_0x2dfc; - int* evenRowOffsets = DAT_BlendingDefinedData::instance.field165_0x2bfc; - int const drawY = DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance + DAT_RenderMap_DrawSomeY::instance; - if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - || drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { - return; - } - source = (ushort*)((char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData - + DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]); - if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { - MACRO_CALL(UI::Rendering_Func::InitBlendFilterArraysUnk)(); - } - destinationTable = DAT_BlendFilterArrays::instance[blendLevel][0]; - sourceTable = DAT_BlendFilterArrays::instance[32 - blendLevel][0]; - if (DAT_WindowAndDirectDraw::instance.colorBitMode == Rendering::RGB_555) { - // clang-format off - __asm { - mov esi, source - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - and eax, 0xfffffffe - add edi, eax - mov eax, drawY - mov ebx, eax - shr eax, 1 - mov edx, 0x1fb0 - mul edx - add edi, eax - mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi - and ebx, 1 - cmp ebx, 0 - jne z555_45391b - mov eax, dword ptr evenRowOffsets - mov dword ptr offsets, eax -z555_45391b: - mov ecx, 0x40 -z555_453920: - mov edx, dword ptr offsets - add dword ptr offsets, 4 - mov edx, dword ptr [edx] - mov ax, word ptr [esi + edx] - mov edx, dword ptr sourceTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xfc1f - or ax, bx - mov bx, ax - shr bx, 0xa - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x3ff - or ax, bx - push ax - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov ax, word ptr [edi + edx] - mov edx, dword ptr destinationTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xfc1f - or ax, bx - mov bx, ax - shr bx, 0xa - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x83ff - or ax, bx - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov word ptr [edi + edx], ax - pop ax - add word ptr [edi + edx], ax - add dword ptr offsets, 4 - sub cx, 1 - jne z555_453920 - } - // clang-format on - return; - } - // clang-format off - __asm { - mov esi, source - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - and eax, 0xfffffffe - add edi, eax - mov eax, drawY - mov ebx, eax - shr eax, 1 - mov edx, 0x1fb0 - mul edx - add edi, eax - mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi - and ebx, 1 - cmp ebx, 0 - jne z565_453a23 - mov eax, dword ptr evenRowOffsets - mov dword ptr offsets, eax -z565_453a23: - mov ecx, 0x40 -z565_453a28: - mov edx, dword ptr offsets - add dword ptr offsets, 4 - mov edx, dword ptr [edx] - mov ax, word ptr [esi + edx] - mov edx, dword ptr sourceTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x3f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xf81f - or ax, bx - mov bx, ax - shr bx, 0xb - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x7ff - or ax, bx - push ax - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov ax, word ptr [edi + edx] - mov edx, dword ptr destinationTable - mov ebx, 0 - mov bx, ax - and bx, 0x1f - mov bx, word ptr [edx + ebx*8] - and ax, 0xffe0 - or ax, bx - mov bx, ax - shr bx, 5 - and bx, 0x3f - mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0xf81f - or ax, bx - mov bx, ax - shr bx, 0xb - and bx, 0x1f - mov bx, word ptr [edx + ebx*8 + 4] - and ax, 0x7ff - or ax, bx - mov edx, dword ptr offsets - mov edx, dword ptr [edx] - mov word ptr [edi + edx], ax - pop ax - add word ptr [edi + edx], ax - add dword ptr offsets, 4 - sub cx, 1 - jne z565_453a28 - } - // clang-format on -} - -} diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp deleted file mode 100644 index 0b6fa6ec1c..0000000000 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClip.cpp +++ /dev/null @@ -1,390 +0,0 @@ -#include "../Rendering.func.hpp" - -#include "OpenSHC/Globals/DAT_00ed3154.hpp" -#include "OpenSHC/Globals/DAT_00ed316c.hpp" -#include "OpenSHC/Globals/DAT_00ed3170.hpp" -#include "OpenSHC/Globals/DAT_00ed317c.hpp" -#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" -#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" -#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" - -namespace OpenSHC { - -using UI::Rendering::WindowAndDirectDraw; - -// Copies a 30-pixel-wide map image column (tile objects are stored as 15 dwords per row) onto the map surface, -// clipped to the visible rows. An image taller than DAT_00ed3170 rows continues with a second image -// (DAT_00ed316c) once the first one runs out. DAT_00ed317c picks which half of the column is drawn (0 both, -// 1 right, 2 left, 3 only the middle column). Zoomed out, every other row and pixel is used. -// The copy loops are handwritten assembly in the original, transcribed here from the binary. - -// Inline assembly cannot name a resolver global, so the loops reach the globals they use through these. -static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; -static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; -static uint* const s_blitModeUnk = &DAT_00ed317c::instance; -static int* const s_remainingRowsUnk = &DAT_00ed3170::instance; - -// FUNCTION: STRONGHOLDCRUSADER 0x00453B00 -void Rendering::BlitMapImageWithVerticalClip() -{ - char* image = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; - char* nextImage = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; - int drawY = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance) + 9; - int height = DAT_GMImageHeaders::instance.imh[DAT_GmImageAddressToBeRendered::instance].height - 7; - int skip = 0; - int nextSkip = 0; - if (DAT_00ed3170::instance <= 0) { - return; - } - if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { - int const clippedRows = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - drawY; - nextSkip = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - height - drawY; - drawY = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; - DAT_00ed3170::instance -= clippedRows; - height -= clippedRows; - skip = clippedRows * 60; - } - if (DAT_00ed3170::instance + drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { - DAT_00ed3170::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; - // fixme: always adds 0, the original subtracts the already shortened row count - height = height - + (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - DAT_00ed3170::instance - drawY); - } - int firstRows; - if (height <= 0) { - firstRows = 0; - nextSkip *= 60; - } else if (height < DAT_00ed3170::instance) { - firstRows = height; - DAT_00ed3170::instance -= height; - nextSkip = 0; - } else { - firstRows = DAT_00ed3170::instance; - DAT_00ed3170::instance = 0; - } - image += DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; - nextImage += DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; - if (!DAT_TextureRenderCoreObject::instance.isZoom2) { - // clang-format off - __asm { - mov esi, image - mov eax, skip - add esi, eax - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - add eax, eax - add edi, eax - mov eax, drawY - mov edx, 0x1fb0 - mul edx - add edi, eax - mov edx, firstRows - cmp edx, 0 - jle nrm_453db7 -nrm_453c34: - mov eax, s_blitModeUnk - mov eax, dword ptr [eax] - cmp eax, 1 - je nrm_453ced - cmp eax, 2 - je nrm_453d45 - cmp eax, 3 - je nrm_453d9b -nrm_453c54: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 0x1fb4], ebx - mov dword ptr [edi + 0x3f68], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0x5f1c], eax - mov dword ptr [edi + 0x7ed0], ebx - mov dword ptr [edi + 0x9e84], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0xbe38], eax - mov dword ptr [edi + 0xddec], ebx - mov dword ptr [edi + 0xbe40], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x9e94], eax - mov dword ptr [edi + 0x7ee8], ebx - mov dword ptr [edi + 0x5f3c], ecx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov ecx, dword ptr [esi + 0x38] - mov dword ptr [edi + 0x3f90], eax - mov dword ptr [edi + 0x1fe4], ebx - mov dword ptr [edi + 0x38], ecx - add esi, 0x3c - add edi, 0x1fb0 - sub edx, 1 - cmp edx, 0 - jle nrm_453db7 - jmp nrm_453c54 -nrm_453ced: - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0xddec], ebx - mov dword ptr [edi + 0xbe40], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x9e94], eax - mov dword ptr [edi + 0x7ee8], ebx - mov dword ptr [edi + 0x5f3c], ecx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov ecx, dword ptr [esi + 0x38] - mov dword ptr [edi + 0x3f90], eax - mov dword ptr [edi + 0x1fe4], ebx - mov dword ptr [edi + 0x38], ecx - add esi, 0x3c - add edi, 0x1fb0 - sub edx, 1 - cmp edx, 0 - jle nrm_453db7 - jmp nrm_453ced -nrm_453d45: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 0x1fb4], ebx - mov dword ptr [edi + 0x3f68], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0x5f1c], eax - mov dword ptr [edi + 0x7ed0], ebx - mov dword ptr [edi + 0x9e84], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov dword ptr [edi + 0xbe38], eax - mov dword ptr [edi + 0xddec], ebx - add esi, 0x3c - add edi, 0x1fb0 - sub edx, 1 - cmp edx, 0 - jle nrm_453db7 - jmp nrm_453d45 -nrm_453d9b: - mov ebx, dword ptr [esi + 0x1c] - mov dword ptr [edi + 0xddec], ebx - add esi, 0x3c - add edi, 0x1fb0 - sub edx, 1 - cmp edx, 0 - jle nrm_453db7 - jmp nrm_453d9b -nrm_453db7: - mov eax, s_remainingRowsUnk - cmp dword ptr [eax], 0 - jle nrm_453ddd - mov edx, dword ptr [eax] - mov dword ptr [eax], 0 - mov esi, dword ptr nextImage - mov eax, dword ptr nextSkip - add esi, eax - jmp nrm_453c34 -nrm_453ddd: - pop ebx - } - // clang-format on - return; - } - // clang-format off - __asm { - mov esi, image - mov eax, skip - add esi, eax - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - and eax, 0xfffffffe - add edi, eax - mov eax, drawY - mov ecx, eax - shr eax, 1 - mov edx, 0x1fb0 - mul edx - add edi, eax - mov edx, firstRows - cmp edx, 0 - jle zm_454049 -zm_453e18: - mov eax, s_blitModeUnk - mov eax, dword ptr [eax] - cmp eax, 1 - je zm_453f0a - cmp eax, 2 - je zm_453f94 - cmp eax, 3 - je zm_454011 -zm_453e38: - mov eax, ecx - and eax, 1 - cmp eax, 0 - jne zm_453ea6 - mov ax, word ptr [esi] - mov bx, word ptr [esi + 8] - mov word ptr [edi], ax - mov word ptr [edi + 0x1fb4], bx - mov ax, word ptr [esi + 0x10] - mov bx, word ptr [esi + 0x18] - mov word ptr [edi + 0x3f68], ax - mov word ptr [edi + 0x5f1c], bx - mov ax, word ptr [esi + 0x20] - mov bx, word ptr [esi + 0x28] - mov word ptr [edi + 0x5f20], ax - mov word ptr [edi + 0x3f74], bx - mov ax, word ptr [esi + 0x30] - mov bx, word ptr [esi + 0x38] - mov word ptr [edi + 0x1fc8], ax - mov word ptr [edi + 0x1c], bx - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_453e38 -zm_453ea6: - add edi, 0x1fb0 - mov ax, word ptr [esi + 4] - mov bx, word ptr [esi + 0xc] - mov word ptr [edi + 2], ax - mov word ptr [edi + 0x1fb6], bx - mov ax, word ptr [esi + 0x14] - mov bx, word ptr [esi + 0x1c] - mov word ptr [edi + 0x3f6a], ax - mov word ptr [edi + 0x5f1e], bx - mov ax, word ptr [esi + 0x24] - mov bx, word ptr [esi + 0x2c] - mov word ptr [edi + 0x3f72], ax - mov word ptr [edi + 0x1fc6], bx - mov ax, word ptr [esi + 0x34] - mov word ptr [edi + 0x1a], ax - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_453e38 -zm_453f0a: - mov eax, ecx - and eax, 1 - jne zm_453f4e - mov ax, word ptr [esi + 0x20] - mov bx, word ptr [esi + 0x28] - mov word ptr [edi + 0x5f20], ax - mov word ptr [edi + 0x3f74], bx - mov ax, word ptr [esi + 0x30] - mov bx, word ptr [esi + 0x38] - mov word ptr [edi + 0x1fc8], ax - mov word ptr [edi + 0x1c], bx - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_453f0a -zm_453f4e: - add edi, 0x1fb0 - mov ax, word ptr [esi + 0x1c] - mov bx, word ptr [esi + 0x24] - mov word ptr [edi + 0x5f1e], ax - mov word ptr [edi + 0x3f72], bx - mov ax, word ptr [esi + 0x2c] - mov bx, word ptr [esi + 0x34] - mov word ptr [edi + 0x1fc6], ax - mov word ptr [edi + 0x1a], bx - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_453f0a -zm_453f94: - mov eax, ecx - and eax, 1 - jne zm_453fd2 - mov ax, word ptr [esi] - mov bx, word ptr [esi + 8] - mov word ptr [edi], ax - mov word ptr [edi + 0x1fb4], bx - mov ax, word ptr [esi + 0x10] - mov bx, word ptr [esi + 0x18] - mov word ptr [edi + 0x3f68], ax - mov word ptr [edi + 0x5f1c], bx - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_453f94 -zm_453fd2: - add edi, 0x1fb0 - mov ax, word ptr [esi + 4] - mov bx, word ptr [esi + 0xc] - mov word ptr [edi + 2], ax - mov word ptr [edi + 0x1fb6], bx - mov ax, word ptr [esi + 0x14] - mov bx, word ptr [esi + 0x1c] - mov word ptr [edi + 0x3f6a], ax - mov word ptr [edi + 0x5f1e], bx - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_453f94 -zm_454011: - mov eax, ecx - and eax, 1 - jne zm_454028 - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_454011 -zm_454028: - add edi, 0x1fb0 - mov ax, word ptr [esi + 0x1c] - mov word ptr [edi + 0x5f1e], ax - add esi, 0x3c - add ecx, 1 - sub edx, 1 - cmp edx, 0 - jle zm_454049 - jmp zm_454011 -zm_454049: - mov eax, s_remainingRowsUnk - cmp dword ptr [eax], 0 - jle zm_45406f - mov edx, dword ptr [eax] - mov dword ptr [eax], 0 - mov esi, dword ptr nextImage - mov eax, dword ptr nextSkip - add esi, eax - jmp zm_453e18 -zm_45406f: - pop ebx - } - // clang-format on -} - -} diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp deleted file mode 100644 index 130d7a21fc..0000000000 --- a/src/OpenSHC/Synchrony/GameSynchronyState/getCommandIDFromCommandSelectionStuff.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "../GameSynchronyState.func.hpp" - -#include "OpenSHC/IO/LowLevelMemory.func.hpp" -#include "OpenSHC/Synchrony.func.hpp" -#include "OpenSHC/Commands/GameCommandState.hpp" -#include "OpenSHC/Commands/GameCommandStateByte.hpp" - -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" - -namespace OpenSHC { -namespace Synchrony { - - // FUNCTION: STRONGHOLDCRUSADER 0x00480440 - int GameSynchronyState::getCommandIDFromCommandSelectionStuff() - { - this->someIndex = 0; - MACRO_CALL_MEMBER(IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( - sizeof(this->selectedGameCommands), 0, this->selectedGameCommands); - for (int command = this->gameCommandID; command < 200; ++command) { - // The command has not been processed yet, should be processed, and its time has come. - if (this->DAT_GameCommandArray[command].stateUnk != 0 - && (char)this->DAT_GameCommandArray[command].stateUnk < 10 - && (int)this->DAT_GameCommandArray[command].time <= (int)DAT_GameCore::instance.mapTimeInTicks) { - this->protocolInvokerPlayerID - = MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::translateMultiplayerIDsIntoPlayerIDs, this)( - this->DAT_GameCommandArray[command].playerUnk); - this->selectedGameCommands[this->someIndex][0] = command; - this->selectedGameCommands[this->someIndex][1] = this->protocolInvokerPlayerID; - ++this->someIndex; - if (this->someIndex >= 100) { - break; - } - } - } - // Sort the selected commands so that lower player IDs are processed first (at most 100 passes). - int pass = 0; - if (0 < this->someIndex) { - int swapped = 1; - for (pass = 0; pass < 100;) { - if (!swapped) { - break; - } - pass++; - swapped = 0; - for (int i = 1; i < this->someIndex; ++i) { - int const nextPlayerID = this->selectedGameCommands[i][1]; - int const commandID = this->selectedGameCommands[i - 1][0]; - int const playerID = this->selectedGameCommands[i - 1][1]; - if (!nextPlayerID) { - return 0; - } - if (nextPlayerID < playerID) { - this->selectedGameCommands[i - 1][0] = this->selectedGameCommands[i][0]; - this->selectedGameCommands[i - 1][1] = nextPlayerID; - this->selectedGameCommands[i][0] = commandID; - this->selectedGameCommands[i][1] = playerID; - swapped = 1; - } - } - } - pass = 1; - } - return pass; - } - -} -} diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp deleted file mode 100644 index b21f65692f..0000000000 --- a/src/OpenSHC/Synchrony/GameSynchronyState/initializeFinalResultsForActivePlayers.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// disable deprecation warnings for strcpy -#pragma warning(disable : 4996) - -#include "../GameSynchronyState.func.hpp" - -#include "OpenSHC/Synchrony.func.hpp" -#include "OpenSHC/Text/UserTextHandler.func.hpp" - -#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" - -#include "string.h" - -namespace OpenSHC { -namespace Synchrony { - - // FUNCTION: STRONGHOLDCRUSADER 0x00486F20 - void GameSynchronyState::initializeFinalResultsForActivePlayers() - { - strcpy(this->DAT_PlayerNames[1], - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); - // perPlayer stays a walker. Naming the fields it reaches - finalGold, finalBuildingsBurned and the rest, all at - // [player] - is measured at 88.5% -> 38.3%, and the last three alone at 88.5% -> 70.4%, so do not retry it. - int* perPlayer = this->currentPlayerFullIDArray + 1; - for (int player = 1; player < 9; ++player, ++perPlayer) { - // perPlayer[27] is currentAIArray[player]. - if ((*perPlayer == -1) && (perPlayer[27] == 0)) { - this->finalResults.active[player] = 0; - } else { - this->finalResults.active[player] = 1; - strcpy(this->finalResults.names[player], this->DAT_PlayerNames[player]); - perPlayer[271508] = 0; - this->finalResults.finalMaxPopulation[player] = 0; - this->finalResults.finalMaxGoodThings[player] = 0; - this->finalResults.finalMaxBadThings[player] = 0; - perPlayer[271614] = 0; - perPlayer[271682] = 0; - perPlayer[271623] = 0; - perPlayer[271673] = 0; - perPlayer[271632] = 0; - perPlayer[271641] = 0; - perPlayer[271650] = 0; - perPlayer[271659] = 0; - this->finalResults.finalKilledLords[player] = 0; - perPlayer[271691] = 0; - perPlayer[271700] = 0; - perPlayer[271524] = 0; - perPlayer[271709] = 0; - perPlayer[271718] = 0; - perPlayer[271727] = 0; - this->finalResults.unknownShortArray1[player] = 0; - this->finalResults.unknownShortArray2[player] = 0; - perPlayer[271745] = 0; - perPlayer[271754] = 0; - perPlayer[271763] = 0; - perPlayer[271772] = 0; - } - } - for (int row = 0; row < 9; ++row) { - for (int column = 0; column < 9; ++column) { - this->finalResults.finalKillMatrix[row][column] = 0; - } - } - } - -} -} diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp deleted file mode 100644 index a9c77437df..0000000000 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapPreview.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "../MinimapViewState.func.hpp" - -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" - -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" - -namespace OpenSHC { -namespace UI { - - using OpenSHC::UI::Rendering::PencilRenderCore; - - // Inline assembly cannot name a resolver global, so the copy loop reaches the pencil through this. - static PencilRenderCore* const s_pencilRenderCore = &DAT_PencilRenderCore::instance; - - // FUNCTION: STRONGHOLDCRUSADER 0x004B5280 - void MinimapViewState::renderMinimapPreview(int screenX, int screenY) - { - short* source = this->loadedMiniMap[0]; - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencilSurface, DAT_PencilRenderCore::ptr)(); - // Copies the 200x200 minimap to the pencil surface at (screenX, screenY), leaving colour 0 transparent. - // Handwritten assembly in the original, transcribed from the binary. - __asm { - mov ecx, s_pencilRenderCore - mov edi, dword ptr [ecx]PencilRenderCore.surfacePtr - mov eax, screenX - add eax, eax - add edi, eax - mov eax, screenY - mov edx, dword ptr [ecx]PencilRenderCore.horizontalByteSize - mul edx - add edi, eax - mov esi, source - mov edx, 200 - nextRow: - mov ecx, 200 - mov ebx, 0 - nextPixel: - mov ax, word ptr [esi + ebx] - cmp ax, 0 - je transparent - mov word ptr [edi + ebx], ax - transparent: - add ebx, 2 - dec ecx - jne nextPixel - add esi, 400 - mov eax, s_pencilRenderCore - add edi, dword ptr [eax]PencilRenderCore.horizontalByteSize - dec edx - jne nextRow - } - } - -} -} diff --git a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp b/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp deleted file mode 100644 index 030a9a3bac..0000000000 --- a/src/OpenSHC/UI/Rendering/RenderGoldValue.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "../Rendering.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/DE/SHCDE/eGM.hpp" - -#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" - -namespace OpenSHC { -namespace UI { - - // FUNCTION: STRONGHOLDCRUSADER 0x00433780 - void Rendering::RenderGoldValue() - { - int const playerID = DAT_GameSynchronyState::instance.currentPlayerSlotID; - int const popularity = DAT_GameState::instance.playerDataArray[playerID].popularity / 100; - int const populationCap = DAT_GameState::instance.playerDataArray[playerID].populationCap; - int population = DAT_GameState::instance.playerDataArray[playerID].currentPopulation; - int gold = DAT_GameState::instance.playerDataArray[playerID].currentResources[Game::Resources::RT_GOLD]; - DAT_TextManagerObject::instance.currentXOffset_0x0 - = DAT_GMImageHeaders::instance.imh[GMFirstPictureIndex::instance[DE::SHCDE::GM_INTERFACE_ICONS2] + 123] - .width; - - int goldDigitSet = 0; - if (gold > 999) { - goldDigitSet = 2; - } - int goldColor; - if (gold > 0) { - goldColor = 32062; - } else { - gold = 0; - goldColor = 255; - } - ++goldDigitSet; - int goldWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, DAT_TextManagerObject::ptr)( - gold, goldDigitSet); - if (gold >= 100000) { - goldWidth -= 2; - } - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, - DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 5, goldColor, - goldDigitSet, FALSE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, - DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 4, goldColor, - goldDigitSet, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, - DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 3, goldColor, - goldDigitSet, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, - DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 2, goldColor, - goldDigitSet, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, - DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 1, goldColor, - goldDigitSet, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(gold, - DAT_MenuHandlerState::instance.x - goldWidth + 743, DAT_MenuHandlerState::instance.y + 537, 0, goldColor, - goldDigitSet, TRUE); - - int populationDigitSetUnk = 0; - int populationColor; - if (DAT_GameState::instance.playerDataArray[playerID].crowding <= 100) { - populationColor = 32062; - } else { - populationColor = 255; - } - if (populationCap == 0) { - populationColor = 32062; - population = 0; - } else { - if (populationCap >= 100) { - populationDigitSetUnk = 2; - } - if (population < 0) { - population = 0; - } else if (population >= 100) { - populationDigitSetUnk = 2; - } - } - int const populationDigitSet = populationDigitSetUnk + 1; - int const populationWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, - DAT_TextManagerObject::ptr)(population, populationDigitSet); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, - DAT_MenuHandlerState::instance.x - populationWidth + 729, DAT_MenuHandlerState::instance.y + 552, 2, - populationColor, populationDigitSet, FALSE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, - DAT_MenuHandlerState::instance.x - populationWidth + 729, DAT_MenuHandlerState::instance.y + 552, 1, - populationColor, populationDigitSet, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, - DAT_MenuHandlerState::instance.x - populationWidth + 729, DAT_MenuHandlerState::instance.y + 552, 0, - populationColor, populationDigitSet, TRUE); - // the "/" between the population and the cap - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(population, - DAT_MenuHandlerState::instance.x + 729, DAT_MenuHandlerState::instance.y + 552, -1, populationColor, - populationDigitSet, FALSE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(populationCap, - DAT_MenuHandlerState::instance.x + 727 + populationDigitSetUnk, DAT_MenuHandlerState::instance.y + 552, 2, - populationColor, populationDigitSet, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(populationCap, - DAT_MenuHandlerState::instance.x + 727 + populationDigitSetUnk, DAT_MenuHandlerState::instance.y + 552, 1, - populationColor, populationDigitSet, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(populationCap, - DAT_MenuHandlerState::instance.x + 727 + populationDigitSetUnk, DAT_MenuHandlerState::instance.y + 552, 0, - populationColor, populationDigitSet, TRUE); - - int popularityColor; - if (popularity < 50) { - popularityColor = 255; - } else { - popularityColor = 32062; - } - int const popularityHalfWidth = MACRO_CALL_MEMBER(Text::TextManager_Func::calcRenderedNumberWidth, - DAT_TextManagerObject::ptr)(popularity, 0) - / 2; - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(popularity, - DAT_MenuHandlerState::instance.x - popularityHalfWidth + 747, DAT_MenuHandlerState::instance.y + 515, 2, - popularityColor, 0, FALSE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(popularity, - DAT_MenuHandlerState::instance.x - popularityHalfWidth + 747, DAT_MenuHandlerState::instance.y + 515, 1, - popularityColor, 0, TRUE); - MACRO_CALL_MEMBER(Text::TextManager_Func::renderPartOfNumberUnk, DAT_TextManagerObject::ptr)(popularity, - DAT_MenuHandlerState::instance.x - popularityHalfWidth + 747, DAT_MenuHandlerState::instance.y + 515, 0, - popularityColor, 0, TRUE); - } - -} -} diff --git a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp b/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp deleted file mode 100644 index 4da783f852..0000000000 --- a/src/OpenSHC/UI/Rendering/RenderScenarioButtonWithText.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "../Rendering.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" - -#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BA910 - void Rendering::RenderScenarioButtonWithText(int textNumInGroup) - { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const x = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - int const y = DAT_ButtonY::instance + 6; - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), - x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup), - x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - } - -} -} diff --git a/src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp b/src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp deleted file mode 100644 index a38d07a5fd..0000000000 --- a/src/OpenSHC/UI/Rendering/RenderTerrainTilesCenterPiece.cpp +++ /dev/null @@ -1,594 +0,0 @@ -#include "../Rendering.func.hpp" - -#include "OpenSHC/Globals/DAT_00ed3154.hpp" -#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" -#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" -#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" - -namespace OpenSHC { -namespace UI { - - using UI::Rendering::WindowAndDirectDraw; - - // Copies the 32x16 centre piece of a terrain tile (stored as 0x200 bytes of RGB words, row by row) onto the map - // surface, or every other pixel of it when zoomed out. The copies are handwritten assembly in the original, - // transcribed here from the binary. - - // Inline assembly cannot name a resolver global, so the copies reach the globals they use through these. - static WindowAndDirectDraw* const s_windowAndDirectDraw = &DAT_WindowAndDirectDraw::instance; - static uint* const s_drawSomeX = &DAT_RenderMap_DrawSomeX::instance; - - // FUNCTION: STRONGHOLDCRUSADER 0x00452900 - void Rendering::RenderTerrainTilesCenterPiece() - { - int const drawY - = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance); - if (drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - || drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { - return; - } - char* const source = DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance] - + (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; - if (!DAT_TextureRenderCoreObject::instance.isZoom2) { - // clang-format off - __asm { - mov esi, source - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - add eax, eax - add edi, eax - mov eax, drawY - mov edx, 0x1fb0 - mul edx - add edi, eax - mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov edx, dword ptr [esi + 0xc] - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x1fc8], ebx - mov dword ptr [edi + 0x1fcc], ecx - mov dword ptr [edi + 0x1fd0], edx - mov eax, dword ptr [esi + 0x10] - mov ebx, dword ptr [esi + 0x14] - mov ecx, dword ptr [esi + 0x18] - mov edx, dword ptr [esi + 0x1c] - mov dword ptr [edi + 0x3f74], eax - mov dword ptr [edi + 0x3f78], ebx - mov dword ptr [edi + 0x3f7c], ecx - mov dword ptr [edi + 0x3f80], edx - mov eax, dword ptr [esi + 0x20] - mov ebx, dword ptr [esi + 0x24] - mov ecx, dword ptr [esi + 0x28] - mov edx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x3f84], eax - mov dword ptr [edi + 0x5f20], ebx - mov dword ptr [edi + 0x5f24], ecx - mov dword ptr [edi + 0x5f28], edx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov ecx, dword ptr [esi + 0x38] - mov edx, dword ptr [esi + 0x3c] - mov dword ptr [edi + 0x5f2c], eax - mov dword ptr [edi + 0x5f30], ebx - mov dword ptr [edi + 0x5f34], ecx - mov dword ptr [edi + 0x5f38], edx - mov eax, dword ptr [esi + 0x40] - mov ebx, dword ptr [esi + 0x44] - mov ecx, dword ptr [esi + 0x48] - mov edx, dword ptr [esi + 0x4c] - mov dword ptr [edi + 0x7ecc], eax - mov dword ptr [edi + 0x7ed0], ebx - mov dword ptr [edi + 0x7ed4], ecx - mov dword ptr [edi + 0x7ed8], edx - mov eax, dword ptr [esi + 0x50] - mov ebx, dword ptr [esi + 0x54] - mov ecx, dword ptr [esi + 0x58] - mov edx, dword ptr [esi + 0x5c] - mov dword ptr [edi + 0x7edc], eax - mov dword ptr [edi + 0x7ee0], ebx - mov dword ptr [edi + 0x7ee4], ecx - mov dword ptr [edi + 0x7ee8], edx - mov eax, dword ptr [esi + 0x60] - mov ebx, dword ptr [esi + 0x64] - mov ecx, dword ptr [esi + 0x68] - mov edx, dword ptr [esi + 0x6c] - mov dword ptr [edi + 0x7eec], eax - mov dword ptr [edi + 0x9e78], ebx - mov dword ptr [edi + 0x9e7c], ecx - mov dword ptr [edi + 0x9e80], edx - mov eax, dword ptr [esi + 0x70] - mov ebx, dword ptr [esi + 0x74] - mov ecx, dword ptr [esi + 0x78] - mov edx, dword ptr [esi + 0x7c] - mov dword ptr [edi + 0x9e84], eax - mov dword ptr [edi + 0x9e88], ebx - mov dword ptr [edi + 0x9e8c], ecx - mov dword ptr [edi + 0x9e90], edx - mov eax, dword ptr [esi + 0x80] - mov ebx, dword ptr [esi + 0x84] - mov ecx, dword ptr [esi + 0x88] - mov edx, dword ptr [esi + 0x8c] - mov dword ptr [edi + 0x9e94], eax - mov dword ptr [edi + 0x9e98], ebx - mov dword ptr [edi + 0x9e9c], ecx - mov dword ptr [edi + 0x9ea0], edx - mov eax, dword ptr [esi + 0x90] - mov ebx, dword ptr [esi + 0x94] - mov ecx, dword ptr [esi + 0x98] - mov edx, dword ptr [esi + 0x9c] - mov dword ptr [edi + 0xbe24], eax - mov dword ptr [edi + 0xbe28], ebx - mov dword ptr [edi + 0xbe2c], ecx - mov dword ptr [edi + 0xbe30], edx - mov eax, dword ptr [esi + 0xa0] - mov ebx, dword ptr [esi + 0xa4] - mov ecx, dword ptr [esi + 0xa8] - mov edx, dword ptr [esi + 0xac] - mov dword ptr [edi + 0xbe34], eax - mov dword ptr [edi + 0xbe38], ebx - mov dword ptr [edi + 0xbe3c], ecx - mov dword ptr [edi + 0xbe40], edx - mov eax, dword ptr [esi + 0xb0] - mov ebx, dword ptr [esi + 0xb4] - mov ecx, dword ptr [esi + 0xb8] - mov edx, dword ptr [esi + 0xbc] - mov dword ptr [edi + 0xbe44], eax - mov dword ptr [edi + 0xbe48], ebx - mov dword ptr [edi + 0xbe4c], ecx - mov dword ptr [edi + 0xbe50], edx - mov eax, dword ptr [esi + 0xc0] - mov ebx, dword ptr [esi + 0xc4] - mov ecx, dword ptr [esi + 0xc8] - mov edx, dword ptr [esi + 0xcc] - mov dword ptr [edi + 0xbe54], eax - mov dword ptr [edi + 0xddd0], ebx - mov dword ptr [edi + 0xddd4], ecx - mov dword ptr [edi + 0xddd8], edx - mov eax, dword ptr [esi + 0xd0] - mov ebx, dword ptr [esi + 0xd4] - mov ecx, dword ptr [esi + 0xd8] - mov edx, dword ptr [esi + 0xdc] - mov dword ptr [edi + 0xdddc], eax - mov dword ptr [edi + 0xdde0], ebx - mov dword ptr [edi + 0xdde4], ecx - mov dword ptr [edi + 0xdde8], edx - mov eax, dword ptr [esi + 0xe0] - mov ebx, dword ptr [esi + 0xe4] - mov ecx, dword ptr [esi + 0xe8] - mov edx, dword ptr [esi + 0xec] - mov dword ptr [edi + 0xddec], eax - mov dword ptr [edi + 0xddf0], ebx - mov dword ptr [edi + 0xddf4], ecx - mov dword ptr [edi + 0xddf8], edx - mov eax, dword ptr [esi + 0xf0] - mov ebx, dword ptr [esi + 0xf4] - mov ecx, dword ptr [esi + 0xf8] - mov edx, dword ptr [esi + 0xfc] - mov dword ptr [edi + 0xddfc], eax - mov dword ptr [edi + 0xde00], ebx - mov dword ptr [edi + 0xde04], ecx - mov dword ptr [edi + 0xde08], edx - mov eax, dword ptr [esi + 0x100] - mov ebx, dword ptr [esi + 0x104] - mov ecx, dword ptr [esi + 0x108] - mov edx, dword ptr [esi + 0x10c] - mov dword ptr [edi + 0xfd80], eax - mov dword ptr [edi + 0xfd84], ebx - mov dword ptr [edi + 0xfd88], ecx - mov dword ptr [edi + 0xfd8c], edx - mov eax, dword ptr [esi + 0x110] - mov ebx, dword ptr [esi + 0x114] - mov ecx, dword ptr [esi + 0x118] - mov edx, dword ptr [esi + 0x11c] - mov dword ptr [edi + 0xfd90], eax - mov dword ptr [edi + 0xfd94], ebx - mov dword ptr [edi + 0xfd98], ecx - mov dword ptr [edi + 0xfd9c], edx - mov eax, dword ptr [esi + 0x120] - mov ebx, dword ptr [esi + 0x124] - mov ecx, dword ptr [esi + 0x128] - mov edx, dword ptr [esi + 0x12c] - mov dword ptr [edi + 0xfda0], eax - mov dword ptr [edi + 0xfda4], ebx - mov dword ptr [edi + 0xfda8], ecx - mov dword ptr [edi + 0xfdac], edx - mov eax, dword ptr [esi + 0x130] - mov ebx, dword ptr [esi + 0x134] - mov ecx, dword ptr [esi + 0x138] - mov edx, dword ptr [esi + 0x13c] - mov dword ptr [edi + 0xfdb0], eax - mov dword ptr [edi + 0xfdb4], ebx - mov dword ptr [edi + 0xfdb8], ecx - mov dword ptr [edi + 0x11d34], edx - mov eax, dword ptr [esi + 0x140] - mov ebx, dword ptr [esi + 0x144] - mov ecx, dword ptr [esi + 0x148] - mov edx, dword ptr [esi + 0x14c] - mov dword ptr [edi + 0x11d38], eax - mov dword ptr [edi + 0x11d3c], ebx - mov dword ptr [edi + 0x11d40], ecx - mov dword ptr [edi + 0x11d44], edx - mov eax, dword ptr [esi + 0x150] - mov ebx, dword ptr [esi + 0x154] - mov ecx, dword ptr [esi + 0x158] - mov edx, dword ptr [esi + 0x15c] - mov dword ptr [edi + 0x11d48], eax - mov dword ptr [edi + 0x11d4c], ebx - mov dword ptr [edi + 0x11d50], ecx - mov dword ptr [edi + 0x11d54], edx - mov eax, dword ptr [esi + 0x160] - mov ebx, dword ptr [esi + 0x164] - mov ecx, dword ptr [esi + 0x168] - mov edx, dword ptr [esi + 0x16c] - mov dword ptr [edi + 0x11d58], eax - mov dword ptr [edi + 0x11d5c], ebx - mov dword ptr [edi + 0x11d60], ecx - mov dword ptr [edi + 0x11d64], edx - mov eax, dword ptr [esi + 0x170] - mov ebx, dword ptr [esi + 0x174] - mov ecx, dword ptr [esi + 0x178] - mov edx, dword ptr [esi + 0x17c] - mov dword ptr [edi + 0x13ce8], eax - mov dword ptr [edi + 0x13cec], ebx - mov dword ptr [edi + 0x13cf0], ecx - mov dword ptr [edi + 0x13cf4], edx - mov eax, dword ptr [esi + 0x180] - mov ebx, dword ptr [esi + 0x184] - mov ecx, dword ptr [esi + 0x188] - mov edx, dword ptr [esi + 0x18c] - mov dword ptr [edi + 0x13cf8], eax - mov dword ptr [edi + 0x13cfc], ebx - mov dword ptr [edi + 0x13d00], ecx - mov dword ptr [edi + 0x13d04], edx - mov eax, dword ptr [esi + 0x190] - mov ebx, dword ptr [esi + 0x194] - mov ecx, dword ptr [esi + 0x198] - mov edx, dword ptr [esi + 0x19c] - mov dword ptr [edi + 0x13d08], eax - mov dword ptr [edi + 0x13d0c], ebx - mov dword ptr [edi + 0x13d10], ecx - mov dword ptr [edi + 0x15c9c], edx - mov eax, dword ptr [esi + 0x1a0] - mov ebx, dword ptr [esi + 0x1a4] - mov ecx, dword ptr [esi + 0x1a8] - mov edx, dword ptr [esi + 0x1ac] - mov dword ptr [edi + 0x15ca0], eax - mov dword ptr [edi + 0x15ca4], ebx - mov dword ptr [edi + 0x15ca8], ecx - mov dword ptr [edi + 0x15cac], edx - mov eax, dword ptr [esi + 0x1b0] - mov ebx, dword ptr [esi + 0x1b4] - mov ecx, dword ptr [esi + 0x1b8] - mov edx, dword ptr [esi + 0x1bc] - mov dword ptr [edi + 0x15cb0], eax - mov dword ptr [edi + 0x15cb4], ebx - mov dword ptr [edi + 0x15cb8], ecx - mov dword ptr [edi + 0x15cbc], edx - mov eax, dword ptr [esi + 0x1c0] - mov ebx, dword ptr [esi + 0x1c4] - mov ecx, dword ptr [esi + 0x1c8] - mov edx, dword ptr [esi + 0x1cc] - mov dword ptr [edi + 0x17c50], eax - mov dword ptr [edi + 0x17c54], ebx - mov dword ptr [edi + 0x17c58], ecx - mov dword ptr [edi + 0x17c5c], edx - mov eax, dword ptr [esi + 0x1d0] - mov ebx, dword ptr [esi + 0x1d4] - mov ecx, dword ptr [esi + 0x1d8] - mov edx, dword ptr [esi + 0x1dc] - mov dword ptr [edi + 0x17c60], eax - mov dword ptr [edi + 0x17c64], ebx - mov dword ptr [edi + 0x17c68], ecx - mov dword ptr [edi + 0x19c04], edx - mov eax, dword ptr [esi + 0x1e0] - mov ebx, dword ptr [esi + 0x1e4] - mov ecx, dword ptr [esi + 0x1e8] - mov edx, dword ptr [esi + 0x1ec] - mov dword ptr [edi + 0x19c08], eax - mov dword ptr [edi + 0x19c0c], ebx - mov dword ptr [edi + 0x19c10], ecx - mov dword ptr [edi + 0x19c14], edx - mov eax, dword ptr [esi + 0x1f0] - mov ebx, dword ptr [esi + 0x1f4] - mov ecx, dword ptr [esi + 0x1f8] - mov edx, dword ptr [esi + 0x1fc] - mov dword ptr [edi + 0x1bbb8], eax - mov dword ptr [edi + 0x1bbbc], ebx - mov dword ptr [edi + 0x1bbc0], ecx - mov dword ptr [edi + 0x1db6c], edx - } - // clang-format on - return; - } - // clang-format off - __asm { - mov esi, source - mov ecx, s_windowAndDirectDraw - mov edi, dword ptr [ecx]WindowAndDirectDraw.surfacePointer_mapGame - mov eax, s_drawSomeX - mov eax, dword ptr [eax] - and eax, 0xfffffffe - add edi, eax - mov eax, drawY - mov ebx, eax - shr eax, 1 - mov edx, 0x1fb0 - mul edx - add edi, eax - mov dword ptr [ecx]WindowAndDirectDraw.unknownSpecificPointer, edi - and ebx, 1 - cmp ebx, 0 - jne zm_4532a7 - mov ax, word ptr [esi] - mov word ptr [edi + 0xe], ax - mov ax, word ptr [esi + 0x10] - mov bx, word ptr [esi + 0x14] - mov cx, word ptr [esi + 0x18] - mov dx, word ptr [esi + 0x1c] - mov word ptr [edi + 0x1fba], ax - mov word ptr [edi + 0x1fbc], bx - mov word ptr [edi + 0x1fbe], cx - mov word ptr [edi + 0x1fc0], dx - mov ax, word ptr [esi + 0x20] - mov word ptr [edi + 0x1fc2], ax - mov ax, word ptr [esi + 0x40] - mov bx, word ptr [esi + 0x44] - mov cx, word ptr [esi + 0x48] - mov dx, word ptr [esi + 0x4c] - mov word ptr [edi + 0x3f66], ax - mov word ptr [edi + 0x3f68], bx - mov word ptr [edi + 0x3f6a], cx - mov word ptr [edi + 0x3f6c], dx - mov ax, word ptr [esi + 0x50] - mov bx, word ptr [esi + 0x54] - mov cx, word ptr [esi + 0x58] - mov dx, word ptr [esi + 0x5c] - mov word ptr [edi + 0x3f6e], ax - mov word ptr [edi + 0x3f70], bx - mov word ptr [edi + 0x3f72], cx - mov word ptr [edi + 0x3f74], dx - mov ax, word ptr [esi + 0x60] - mov word ptr [edi + 0x3f76], ax - mov ax, word ptr [esi + 0x90] - mov bx, word ptr [esi + 0x94] - mov cx, word ptr [esi + 0x98] - mov dx, word ptr [esi + 0x9c] - mov word ptr [edi + 0x5f12], ax - mov word ptr [edi + 0x5f14], bx - mov word ptr [edi + 0x5f16], cx - mov word ptr [edi + 0x5f18], dx - mov ax, word ptr [esi + 0xa0] - mov bx, word ptr [esi + 0xa4] - mov cx, word ptr [esi + 0xa8] - mov dx, word ptr [esi + 0xac] - mov word ptr [edi + 0x5f1a], ax - mov word ptr [edi + 0x5f1c], bx - mov word ptr [edi + 0x5f1e], cx - mov word ptr [edi + 0x5f20], dx - mov ax, word ptr [esi + 0xb0] - mov bx, word ptr [esi + 0xb4] - mov cx, word ptr [esi + 0xb8] - mov dx, word ptr [esi + 0xbc] - mov word ptr [edi + 0x5f22], ax - mov word ptr [edi + 0x5f24], bx - mov word ptr [edi + 0x5f26], cx - mov word ptr [edi + 0x5f28], dx - mov ax, word ptr [esi + 0xc0] - mov word ptr [edi + 0x5f2a], ax - mov ax, word ptr [esi + 0x100] - mov bx, word ptr [esi + 0x104] - mov cx, word ptr [esi + 0x108] - mov dx, word ptr [esi + 0x10c] - mov word ptr [edi + 0x7ec0], ax - mov word ptr [edi + 0x7ec2], bx - mov word ptr [edi + 0x7ec4], cx - mov word ptr [edi + 0x7ec6], dx - mov ax, word ptr [esi + 0x110] - mov bx, word ptr [esi + 0x114] - mov cx, word ptr [esi + 0x118] - mov dx, word ptr [esi + 0x11c] - mov word ptr [edi + 0x7ec8], ax - mov word ptr [edi + 0x7eca], bx - mov word ptr [edi + 0x7ecc], cx - mov word ptr [edi + 0x7ece], dx - mov ax, word ptr [esi + 0x120] - mov bx, word ptr [esi + 0x124] - mov cx, word ptr [esi + 0x128] - mov dx, word ptr [esi + 0x12c] - mov word ptr [edi + 0x7ed0], ax - mov word ptr [edi + 0x7ed2], bx - mov word ptr [edi + 0x7ed4], cx - mov word ptr [edi + 0x7ed6], dx - mov ax, word ptr [esi + 0x130] - mov bx, word ptr [esi + 0x134] - mov cx, word ptr [esi + 0x138] - mov word ptr [edi + 0x7ed8], ax - mov word ptr [edi + 0x7eda], bx - mov word ptr [edi + 0x7edc], cx - mov ax, word ptr [esi + 0x170] - mov bx, word ptr [esi + 0x174] - mov cx, word ptr [esi + 0x178] - mov dx, word ptr [esi + 0x17c] - mov word ptr [edi + 0x9e74], ax - mov word ptr [edi + 0x9e76], bx - mov word ptr [edi + 0x9e78], cx - mov word ptr [edi + 0x9e7a], dx - mov ax, word ptr [esi + 0x180] - mov bx, word ptr [esi + 0x184] - mov cx, word ptr [esi + 0x188] - mov dx, word ptr [esi + 0x18c] - mov word ptr [edi + 0x9e7c], ax - mov word ptr [edi + 0x9e7e], bx - mov word ptr [edi + 0x9e80], cx - mov word ptr [edi + 0x9e82], dx - mov ax, word ptr [esi + 0x190] - mov bx, word ptr [esi + 0x194] - mov cx, word ptr [esi + 0x198] - mov word ptr [edi + 0x9e84], ax - mov word ptr [edi + 0x9e86], bx - mov word ptr [edi + 0x9e88], cx - mov ax, word ptr [esi + 0x1c0] - mov bx, word ptr [esi + 0x1c4] - mov cx, word ptr [esi + 0x1c8] - mov dx, word ptr [esi + 0x1cc] - mov word ptr [edi + 0xbe28], ax - mov word ptr [edi + 0xbe2a], bx - mov word ptr [edi + 0xbe2c], cx - mov word ptr [edi + 0xbe2e], dx - mov ax, word ptr [esi + 0x1d0] - mov bx, word ptr [esi + 0x1d4] - mov cx, word ptr [esi + 0x1d8] - mov word ptr [edi + 0xbe30], ax - mov word ptr [edi + 0xbe32], bx - mov word ptr [edi + 0xbe34], cx - mov ax, word ptr [esi + 0x1f0] - mov bx, word ptr [esi + 0x1f4] - mov cx, word ptr [esi + 0x1f8] - mov word ptr [edi + 0xdddc], ax - mov word ptr [edi + 0xddde], bx - mov word ptr [edi + 0xdde0], cx - jmp zm_4535f4 -zm_4532a7: - mov bx, word ptr [esi + 4] - mov cx, word ptr [esi + 8] - mov dx, word ptr [esi + 0xc] - mov word ptr [edi + 0x1fbc], bx - mov word ptr [edi + 0x1fbe], cx - mov word ptr [edi + 0x1fc0], dx - mov bx, word ptr [esi + 0x24] - mov cx, word ptr [esi + 0x28] - mov dx, word ptr [esi + 0x2c] - mov word ptr [edi + 0x3f68], bx - mov word ptr [edi + 0x3f6a], cx - mov word ptr [edi + 0x3f6c], dx - mov ax, word ptr [esi + 0x30] - mov bx, word ptr [esi + 0x34] - mov cx, word ptr [esi + 0x38] - mov dx, word ptr [esi + 0x3c] - mov word ptr [edi + 0x3f6e], ax - mov word ptr [edi + 0x3f70], bx - mov word ptr [edi + 0x3f72], cx - mov word ptr [edi + 0x3f74], dx - mov bx, word ptr [esi + 0x64] - mov cx, word ptr [esi + 0x68] - mov dx, word ptr [esi + 0x6c] - mov word ptr [edi + 0x5f14], bx - mov word ptr [edi + 0x5f16], cx - mov word ptr [edi + 0x5f18], dx - mov ax, word ptr [esi + 0x70] - mov bx, word ptr [esi + 0x74] - mov cx, word ptr [esi + 0x78] - mov dx, word ptr [esi + 0x7c] - mov word ptr [edi + 0x5f1a], ax - mov word ptr [edi + 0x5f1c], bx - mov word ptr [edi + 0x5f1e], cx - mov word ptr [edi + 0x5f20], dx - mov ax, word ptr [esi + 0x80] - mov bx, word ptr [esi + 0x84] - mov cx, word ptr [esi + 0x88] - mov dx, word ptr [esi + 0x8c] - mov word ptr [edi + 0x5f22], ax - mov word ptr [edi + 0x5f24], bx - mov word ptr [edi + 0x5f26], cx - mov word ptr [edi + 0x5f28], dx - mov bx, word ptr [esi + 0xc4] - mov cx, word ptr [esi + 0xc8] - mov dx, word ptr [esi + 0xcc] - mov word ptr [edi + 0x7ec0], bx - mov word ptr [edi + 0x7ec2], cx - mov word ptr [edi + 0x7ec4], dx - mov ax, word ptr [esi + 0xd0] - mov bx, word ptr [esi + 0xd4] - mov cx, word ptr [esi + 0xd8] - mov dx, word ptr [esi + 0xdc] - mov word ptr [edi + 0x7ec6], ax - mov word ptr [edi + 0x7ec8], bx - mov word ptr [edi + 0x7eca], cx - mov word ptr [edi + 0x7ecc], dx - mov ax, word ptr [esi + 0xe0] - mov bx, word ptr [esi + 0xe4] - mov cx, word ptr [esi + 0xe8] - mov dx, word ptr [esi + 0xec] - mov word ptr [edi + 0x7ece], ax - mov word ptr [edi + 0x7ed0], bx - mov word ptr [edi + 0x7ed2], cx - mov word ptr [edi + 0x7ed4], dx - mov ax, word ptr [esi + 0xf0] - mov bx, word ptr [esi + 0xf4] - mov cx, word ptr [esi + 0xf8] - mov dx, word ptr [esi + 0xfc] - mov word ptr [edi + 0x7ed6], ax - mov word ptr [edi + 0x7ed8], bx - mov word ptr [edi + 0x7eda], cx - mov word ptr [edi + 0x7edc], dx - mov dx, word ptr [esi + 0x13c] - mov word ptr [edi + 0x9e72], dx - mov ax, word ptr [esi + 0x140] - mov bx, word ptr [esi + 0x144] - mov cx, word ptr [esi + 0x148] - mov dx, word ptr [esi + 0x14c] - mov word ptr [edi + 0x9e74], ax - mov word ptr [edi + 0x9e76], bx - mov word ptr [edi + 0x9e78], cx - mov word ptr [edi + 0x9e7a], dx - mov ax, word ptr [esi + 0x150] - mov bx, word ptr [esi + 0x154] - mov cx, word ptr [esi + 0x158] - mov dx, word ptr [esi + 0x15c] - mov word ptr [edi + 0x9e7c], ax - mov word ptr [edi + 0x9e7e], bx - mov word ptr [edi + 0x9e80], cx - mov word ptr [edi + 0x9e82], dx - mov ax, word ptr [esi + 0x160] - mov bx, word ptr [esi + 0x164] - mov cx, word ptr [esi + 0x168] - mov dx, word ptr [esi + 0x16c] - mov word ptr [edi + 0x9e84], ax - mov word ptr [edi + 0x9e86], bx - mov word ptr [edi + 0x9e88], cx - mov word ptr [edi + 0x9e8a], dx - mov dx, word ptr [esi + 0x19c] - mov word ptr [edi + 0xbe26], dx - mov ax, word ptr [esi + 0x1a0] - mov bx, word ptr [esi + 0x1a4] - mov cx, word ptr [esi + 0x1a8] - mov dx, word ptr [esi + 0x1ac] - mov word ptr [edi + 0xbe28], ax - mov word ptr [edi + 0xbe2a], bx - mov word ptr [edi + 0xbe2c], cx - mov word ptr [edi + 0xbe2e], dx - mov ax, word ptr [esi + 0x1b0] - mov bx, word ptr [esi + 0x1b4] - mov cx, word ptr [esi + 0x1b8] - mov dx, word ptr [esi + 0x1bc] - mov word ptr [edi + 0xbe30], ax - mov word ptr [edi + 0xbe32], bx - mov word ptr [edi + 0xbe34], cx - mov word ptr [edi + 0xbe36], dx - mov dx, word ptr [esi + 0x1dc] - mov word ptr [edi + 0xddda], dx - mov ax, word ptr [esi + 0x1e0] - mov bx, word ptr [esi + 0x1e4] - mov cx, word ptr [esi + 0x1e8] - mov dx, word ptr [esi + 0x1ec] - mov word ptr [edi + 0xdddc], ax - mov word ptr [edi + 0xddde], bx - mov word ptr [edi + 0xdde0], cx - mov word ptr [edi + 0xdde2], dx - mov dx, word ptr [esi + 0x1fc] - mov word ptr [edi + 0xfd8e], dx -zm_4535f4: - } - // clang-format on - } - -} -} diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp deleted file mode 100644 index 660551bdab..0000000000 --- a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderFunctionResponsibleForManyGameObjects.cpp +++ /dev/null @@ -1,1494 +0,0 @@ -#include "../TextureRenderCore.func.hpp" - -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" - -#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" - -namespace OpenSHC { -namespace UI { - namespace Rendering { - - // Handlers for TGX runs of 1..32 pixels, filled with label addresses of the function below on first use. - // The original keeps them in PTR_ARRAY_00c9a510 / PTR_ARRAY_00d7d250; ours point into our own code. - static void* s_tgxRepeatedPixelHandlers[32]; - static void* s_tgxStreamPixelHandlers[32]; - - // Draws a TGX-compressed RGB565 image onto the current render surface (map surface rows are 4056 pixels). - // The two loops are handwritten assembly in the original, transcribed here from the binary. A TGX token byte - // holds the run type in its top three bits and the run length minus one in the low five: - // 0x00 stream copy the next length pixels from the image, - // 0x20 skip leave length pixels transparent, - // 0x40 repeat fill length pixels with the one colour that follows, - // 0x80 new line advance to the next surface row. - // Stream and repeat runs dispatch through the two handler tables, one handler per length. - // The zoomed-out path (isZoom2) draws the image at half size: every other row and every other column. - // Only the C++ parts are compiled; MSVC does not optimise a function containing __asm, which matches the - // original's unoptimised-looking prologue. - // - // NOTE: the original reads currentRenderSurface through the global instance inside the asm. Inline asm - // cannot name a resolver global, so it goes through this (one extra instruction; a local cost 2.4 points). - - // FUNCTION: STRONGHOLDCRUSADER 0x0044D3D0 - void TextureRenderCore::renderFunctionResponsibleForManyGameObjects( - int drawX, int drawY, int imageWidth, int imageHeight, ushort* imageAddress) - { - // The asm blocks address these by frame slot. MSVC lays out the locals of this unoptimised function by a - // hash of their names first and declaration order second, so both the names and the order below are - // what put every local in the original's slot (measured). - int oddColumn; - int lineStride; - int heightMax; - int heightStart; - int lineTail; - void** streamRunHandlers = s_tgxStreamPixelHandlers; - void** repeatedPixelHandlers = s_tgxRepeatedPixelHandlers; - if (imageHeight <= 0) { - return; - } - - if (DAT_TextureRenderCoreObject::instance.isZoom2 == 0) { - switch (this->drawBufferChoiceValue) { - case OpenSHC::Rendering::Enums::RT_MAP_GAME: - DAT_TextureRenderCoreObject::instance.currentRenderSurface - = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; - lineTail = 4056 * 2 - imageWidth * 2; - lineStride = 4056 * 2; - heightStart = this->mapGameSurfaceHeightRange.start; - heightMax = this->mapGameSurfaceHeightRange.end; - break; - case OpenSHC::Rendering::Enums::RT_BUTTON_AND_ALPHA: - DAT_TextureRenderCoreObject::instance.currentRenderSurface - = AlphaAndButtonSurfaceObj::instance.surfacePtr; - lineTail = AlphaAndButtonSurfaceObj::instance.currentImageWidth * 2 - imageWidth * 2; - lineStride = AlphaAndButtonSurfaceObj::instance.currentImageWidth * 2; - heightStart = 0; - heightMax = imageHeight; - break; - default: - DAT_TextureRenderCoreObject::instance.currentRenderSurface - = DAT_WindowAndDirectDraw::instance.surfacePointer_screenMenu; - lineTail = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine - imageWidth * 2; - lineStride = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; - heightStart = this->screenMenuSurfaceHeightRange.start; - heightMax = this->screenMenuSurfaceHeightRange.end; - break; - } - if (drawY + imageHeight > heightMax) { - imageHeight -= (drawY + imageHeight - heightMax); - if (imageHeight <= 0) { - return; - } - } - // clang-format off - __asm { - mov edi, repeatedPixelHandlers - mov eax, 0 - cmp dword ptr [edi], eax - je L_44e169 - L_44d4f6: - mov esi, imageAddress - mov edi, this - mov edi, dword ptr [edi]TextureRenderCore.currentRenderSurface - mov eax, drawX - cmp eax, 0 - jl L_44e372 - add eax, eax - add edi, eax - mov eax, drawY - mov ebx, heightStart - cmp eax, ebx - jge L_44d55e - sub ebx, eax - mov eax, ebx - cmp imageHeight, eax - jle L_44e372 - sub imageHeight, eax - L_44d529: - mov bl, byte ptr [esi] - movzx ecx, bl - and bl, 0xe0 - and cl, 0x1f - add esi, 1 - cmp bl, 0x20 - je L_44d529 - cmp bl, 0 - je L_44d548 - cmp bl, 0x40 - je L_44d551 - jmp L_44d556 - L_44d548: - add ecx, 1 - add ecx, ecx - add esi, ecx - jmp L_44d529 - L_44d551: - add esi, 2 - jmp L_44d529 - L_44d556: - sub eax, 1 - jg L_44d529 - mov eax, heightStart - L_44d55e: - mov edx, lineStride - mul edx - add edi, eax - mov edx, imageHeight - L_44d568: - mov al, byte ptr [esi] - movzx ecx, al - and al, 0xe0 - and cl, 0x1f - add esi, 1 - cmp al, 0x20 - je L_44d58e - cmp al, 0 - je L_44d5ab - cmp al, 0x40 - je L_44d597 - add edi, lineTail - sub edx, 1 - jg L_44d568 - jmp L_44e372 - L_44d58e: - add ecx, 1 - add ecx, ecx - add edi, ecx - jmp L_44d568 - L_44d597: - movzx eax, word ptr [esi] - mov ebx, eax - shl ebx, 0x10 - add eax, ebx - add esi, 2 - jmp s_tgxRepeatedPixelHandlers[ecx*4] - L_44d5ab: - jmp s_tgxStreamPixelHandlers[ecx*4] - L_44d5b2: - mov ax, word ptr [esi] - mov word ptr [edi], ax - add esi, 2 - add edi, 2 - jmp L_44d568 - L_44d5c0: - mov eax, dword ptr [esi] - mov dword ptr [edi], eax - add esi, 4 - add edi, 4 - jmp L_44d568 - L_44d5cc: - mov eax, dword ptr [esi] - mov bx, word ptr [esi + 4] - mov dword ptr [edi], eax - mov word ptr [edi + 4], bx - add esi, 6 - add edi, 6 - jmp L_44d568 - L_44d5e0: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - add esi, 8 - add edi, 8 - jmp L_44d568 - L_44d5f5: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov cx, word ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov word ptr [edi + 8], cx - add esi, 0xa - add edi, 0xa - jmp L_44d568 - L_44d612: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - add esi, 0xc - add edi, 0xc - jmp L_44d568 - L_44d62d: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov ax, word ptr [esi + 0xc] - mov word ptr [edi + 0xc], ax - add esi, 0xe - add edi, 0xe - jmp L_44d568 - L_44d650: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov dword ptr [edi + 0xc], eax - add esi, 0x10 - add edi, 0x10 - jmp L_44d568 - L_44d671: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov bx, word ptr [esi + 0x10] - mov dword ptr [edi + 0xc], eax - mov word ptr [edi + 0x10], bx - add esi, 0x12 - add edi, 0x12 - jmp L_44d568 - L_44d69a: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - add esi, 0x14 - add edi, 0x14 - jmp L_44d568 - L_44d6c1: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov cx, word ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov word ptr [edi + 0x14], cx - add esi, 0x16 - add edi, 0x16 - jmp L_44d568 - L_44d6f0: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - add esi, 0x18 - add edi, 0x18 - jmp L_44d568 - L_44d71d: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov ax, word ptr [esi + 0x18] - mov word ptr [edi + 0x18], ax - add esi, 0x1a - add edi, 0x1a - jmp L_44d568 - L_44d752: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov dword ptr [edi + 0x18], eax - add esi, 0x1c - add edi, 0x1c - jmp L_44d568 - L_44d785: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov bx, word ptr [esi + 0x1c] - mov dword ptr [edi + 0x18], eax - mov word ptr [edi + 0x1c], bx - add esi, 0x1e - add edi, 0x1e - jmp L_44d568 - L_44d7c0: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - add esi, 0x20 - add edi, 0x20 - jmp L_44d568 - L_44d7f9: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov cx, word ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov word ptr [edi + 0x20], cx - add esi, 0x22 - add edi, 0x22 - jmp L_44d568 - L_44d83a: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - add esi, 0x24 - add edi, 0x24 - jmp L_44d568 - L_44d879: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov ax, word ptr [esi + 0x24] - mov word ptr [edi + 0x24], ax - add esi, 0x26 - add edi, 0x26 - jmp L_44d568 - L_44d8c0: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov dword ptr [edi + 0x24], eax - add esi, 0x28 - add edi, 0x28 - jmp L_44d568 - L_44d905: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov bx, word ptr [esi + 0x28] - mov dword ptr [edi + 0x24], eax - mov word ptr [edi + 0x28], bx - add esi, 0x2a - add edi, 0x2a - jmp L_44d568 - L_44d952: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - add esi, 0x2c - add edi, 0x2c - jmp L_44d568 - L_44d99d: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov cx, word ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov word ptr [edi + 0x2c], cx - add esi, 0x2e - add edi, 0x2e - jmp L_44d568 - L_44d9f0: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - add esi, 0x30 - add edi, 0x30 - jmp L_44d568 - L_44da41: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov ax, word ptr [esi + 0x30] - mov word ptr [edi + 0x30], ax - add esi, 0x32 - add edi, 0x32 - jmp L_44d568 - L_44da9a: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov eax, dword ptr [esi + 0x30] - mov dword ptr [edi + 0x30], eax - add esi, 0x34 - add edi, 0x34 - jmp L_44d568 - L_44daf1: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov eax, dword ptr [esi + 0x30] - mov bx, word ptr [esi + 0x34] - mov dword ptr [edi + 0x30], eax - mov word ptr [edi + 0x34], bx - add esi, 0x36 - add edi, 0x36 - jmp L_44d568 - L_44db50: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], ebx - add esi, 0x38 - add edi, 0x38 - jmp L_44d568 - L_44dbad: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov cx, word ptr [esi + 0x38] - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], ebx - mov word ptr [edi + 0x38], cx - add esi, 0x3a - add edi, 0x3a - jmp L_44d568 - L_44dc12: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov ecx, dword ptr [esi + 0x38] - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], ebx - mov dword ptr [edi + 0x38], ecx - add esi, 0x3c - add edi, 0x3c - jmp L_44d568 - L_44dc75: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov ecx, dword ptr [esi + 0x38] - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], ebx - mov dword ptr [edi + 0x38], ecx - mov ax, word ptr [esi + 0x3c] - mov word ptr [edi + 0x3c], ax - add esi, 0x3e - add edi, 0x3e - jmp L_44d568 - L_44dce0: - mov eax, dword ptr [esi] - mov ebx, dword ptr [esi + 4] - mov ecx, dword ptr [esi + 8] - mov dword ptr [edi], eax - mov dword ptr [edi + 4], ebx - mov dword ptr [edi + 8], ecx - mov eax, dword ptr [esi + 0xc] - mov ebx, dword ptr [esi + 0x10] - mov ecx, dword ptr [esi + 0x14] - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], ebx - mov dword ptr [edi + 0x14], ecx - mov eax, dword ptr [esi + 0x18] - mov ebx, dword ptr [esi + 0x1c] - mov ecx, dword ptr [esi + 0x20] - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], ebx - mov dword ptr [edi + 0x20], ecx - mov eax, dword ptr [esi + 0x24] - mov ebx, dword ptr [esi + 0x28] - mov ecx, dword ptr [esi + 0x2c] - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], ebx - mov dword ptr [edi + 0x2c], ecx - mov eax, dword ptr [esi + 0x30] - mov ebx, dword ptr [esi + 0x34] - mov ecx, dword ptr [esi + 0x38] - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], ebx - mov dword ptr [edi + 0x38], ecx - mov eax, dword ptr [esi + 0x3c] - mov dword ptr [edi + 0x3c], eax - add esi, 0x40 - add edi, 0x40 - jmp L_44d568 - L_44dd49: - mov word ptr [edi], ax - add edi, 2 - jmp L_44d568 - L_44dd54: - mov dword ptr [edi], eax - add edi, 4 - jmp L_44d568 - L_44dd5e: - mov dword ptr [edi], eax - mov word ptr [edi + 4], ax - add edi, 6 - jmp L_44d568 - L_44dd6c: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - add edi, 8 - jmp L_44d568 - L_44dd79: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov word ptr [edi + 8], ax - add edi, 0xa - jmp L_44d568 - L_44dd8a: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - add edi, 0xc - jmp L_44d568 - L_44dd9a: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov word ptr [edi + 0xc], ax - add edi, 0xe - jmp L_44d568 - L_44ddae: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - add edi, 0x10 - jmp L_44d568 - L_44ddc1: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov word ptr [edi + 0x10], ax - add edi, 0x12 - jmp L_44d568 - L_44ddd8: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - add edi, 0x14 - jmp L_44d568 - L_44ddee: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov word ptr [edi + 0x14], ax - add edi, 0x16 - jmp L_44d568 - L_44de08: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - add edi, 0x18 - jmp L_44d568 - L_44de21: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov word ptr [edi + 0x18], ax - add edi, 0x1a - jmp L_44d568 - L_44de3e: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - add edi, 0x1c - jmp L_44d568 - L_44de5a: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov word ptr [edi + 0x1c], ax - add edi, 0x1e - jmp L_44d568 - L_44de7a: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - add edi, 0x20 - jmp L_44d568 - L_44de99: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov word ptr [edi + 0x20], ax - add edi, 0x22 - jmp L_44d568 - L_44debc: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - add edi, 0x24 - jmp L_44d568 - L_44dede: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov word ptr [edi + 0x24], ax - add edi, 0x26 - jmp L_44d568 - L_44df04: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - add edi, 0x28 - jmp L_44d568 - L_44df29: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov word ptr [edi + 0x28], ax - add edi, 0x2a - jmp L_44d568 - L_44df52: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - add edi, 0x2c - jmp L_44d568 - L_44df7a: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov word ptr [edi + 0x2c], ax - add edi, 0x2e - jmp L_44d568 - L_44dfa6: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - add edi, 0x30 - jmp L_44d568 - L_44dfd1: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov word ptr [edi + 0x30], ax - add edi, 0x32 - jmp L_44d568 - L_44e000: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov dword ptr [edi + 0x30], eax - add edi, 0x34 - jmp L_44d568 - L_44e02e: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov dword ptr [edi + 0x30], eax - mov word ptr [edi + 0x34], ax - add edi, 0x36 - jmp L_44d568 - L_44e060: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], eax - add edi, 0x38 - jmp L_44d568 - L_44e091: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], eax - mov word ptr [edi + 0x38], ax - add edi, 0x3a - jmp L_44d568 - L_44e0c6: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], eax - mov dword ptr [edi + 0x38], eax - add edi, 0x3c - jmp L_44d568 - L_44e0fa: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], eax - mov dword ptr [edi + 0x38], eax - mov word ptr [edi + 0x3c], ax - add edi, 0x3e - jmp L_44d568 - L_44e132: - mov dword ptr [edi], eax - mov dword ptr [edi + 4], eax - mov dword ptr [edi + 8], eax - mov dword ptr [edi + 0xc], eax - mov dword ptr [edi + 0x10], eax - mov dword ptr [edi + 0x14], eax - mov dword ptr [edi + 0x18], eax - mov dword ptr [edi + 0x1c], eax - mov dword ptr [edi + 0x20], eax - mov dword ptr [edi + 0x24], eax - mov dword ptr [edi + 0x28], eax - mov dword ptr [edi + 0x2c], eax - mov dword ptr [edi + 0x30], eax - mov dword ptr [edi + 0x34], eax - mov dword ptr [edi + 0x38], eax - mov dword ptr [edi + 0x3c], eax - add edi, 0x40 - jmp L_44d568 - L_44e169: - mov edi, repeatedPixelHandlers - mov eax, offset L_44dd49 - mov dword ptr [edi], eax - mov eax, offset L_44dd54 - mov dword ptr [edi + 4], eax - mov eax, offset L_44dd5e - mov dword ptr [edi + 8], eax - mov eax, offset L_44dd6c - mov dword ptr [edi + 0xc], eax - mov eax, offset L_44dd79 - mov dword ptr [edi + 0x10], eax - mov eax, offset L_44dd8a - mov dword ptr [edi + 0x14], eax - mov eax, offset L_44dd9a - mov dword ptr [edi + 0x18], eax - mov eax, offset L_44ddae - mov dword ptr [edi + 0x1c], eax - mov eax, offset L_44ddc1 - mov dword ptr [edi + 0x20], eax - mov eax, offset L_44ddd8 - mov dword ptr [edi + 0x24], eax - mov eax, offset L_44ddee - mov dword ptr [edi + 0x28], eax - mov eax, offset L_44de08 - mov dword ptr [edi + 0x2c], eax - mov eax, offset L_44de21 - mov dword ptr [edi + 0x30], eax - mov eax, offset L_44de3e - mov dword ptr [edi + 0x34], eax - mov eax, offset L_44de5a - mov dword ptr [edi + 0x38], eax - mov eax, offset L_44de7a - mov dword ptr [edi + 0x3c], eax - mov eax, offset L_44de99 - mov dword ptr [edi + 0x40], eax - mov eax, offset L_44debc - mov dword ptr [edi + 0x44], eax - mov eax, offset L_44dede - mov dword ptr [edi + 0x48], eax - mov eax, offset L_44df04 - mov dword ptr [edi + 0x4c], eax - mov eax, offset L_44df29 - mov dword ptr [edi + 0x50], eax - mov eax, offset L_44df52 - mov dword ptr [edi + 0x54], eax - mov eax, offset L_44df7a - mov dword ptr [edi + 0x58], eax - mov eax, offset L_44dfa6 - mov dword ptr [edi + 0x5c], eax - mov eax, offset L_44dfd1 - mov dword ptr [edi + 0x60], eax - mov eax, offset L_44e000 - mov dword ptr [edi + 0x64], eax - mov eax, offset L_44e02e - mov dword ptr [edi + 0x68], eax - mov eax, offset L_44e060 - mov dword ptr [edi + 0x6c], eax - mov eax, offset L_44e091 - mov dword ptr [edi + 0x70], eax - mov eax, offset L_44e0c6 - mov dword ptr [edi + 0x74], eax - mov eax, offset L_44e0fa - mov dword ptr [edi + 0x78], eax - mov eax, offset L_44e132 - mov dword ptr [edi + 0x7c], eax - mov edi, streamRunHandlers - mov eax, offset L_44d5b2 - mov dword ptr [edi], eax - mov eax, offset L_44d5c0 - mov dword ptr [edi + 4], eax - mov eax, offset L_44d5cc - mov dword ptr [edi + 8], eax - mov eax, offset L_44d5e0 - mov dword ptr [edi + 0xc], eax - mov eax, offset L_44d5f5 - mov dword ptr [edi + 0x10], eax - mov eax, offset L_44d612 - mov dword ptr [edi + 0x14], eax - mov eax, offset L_44d62d - mov dword ptr [edi + 0x18], eax - mov eax, offset L_44d650 - mov dword ptr [edi + 0x1c], eax - mov eax, offset L_44d671 - mov dword ptr [edi + 0x20], eax - mov eax, offset L_44d69a - mov dword ptr [edi + 0x24], eax - mov eax, offset L_44d6c1 - mov dword ptr [edi + 0x28], eax - mov eax, offset L_44d6f0 - mov dword ptr [edi + 0x2c], eax - mov eax, offset L_44d71d - mov dword ptr [edi + 0x30], eax - mov eax, offset L_44d752 - mov dword ptr [edi + 0x34], eax - mov eax, offset L_44d785 - mov dword ptr [edi + 0x38], eax - mov eax, offset L_44d7c0 - mov dword ptr [edi + 0x3c], eax - mov eax, offset L_44d7f9 - mov dword ptr [edi + 0x40], eax - mov eax, offset L_44d83a - mov dword ptr [edi + 0x44], eax - mov eax, offset L_44d879 - mov dword ptr [edi + 0x48], eax - mov eax, offset L_44d8c0 - mov dword ptr [edi + 0x4c], eax - mov eax, offset L_44d905 - mov dword ptr [edi + 0x50], eax - mov eax, offset L_44d952 - mov dword ptr [edi + 0x54], eax - mov eax, offset L_44d99d - mov dword ptr [edi + 0x58], eax - mov eax, offset L_44d9f0 - mov dword ptr [edi + 0x5c], eax - mov eax, offset L_44da41 - mov dword ptr [edi + 0x60], eax - mov eax, offset L_44da9a - mov dword ptr [edi + 0x64], eax - mov eax, offset L_44daf1 - mov dword ptr [edi + 0x68], eax - mov eax, offset L_44db50 - mov dword ptr [edi + 0x6c], eax - mov eax, offset L_44dbad - mov dword ptr [edi + 0x70], eax - mov eax, offset L_44dc12 - mov dword ptr [edi + 0x74], eax - mov eax, offset L_44dc75 - mov dword ptr [edi + 0x78], eax - mov eax, offset L_44dce0 - mov dword ptr [edi + 0x7c], eax - jmp L_44d4f6 - L_44e372: - } - // clang-format on - } else { - DAT_TextureRenderCoreObject::instance.currentRenderSurface - = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; - lineTail = 4056 * 2; - lineStride = 4056 * 2; - heightStart = this->mapGameSurfaceHeightRange.start; - if (drawY + imageHeight > this->mapGameSurfaceHeightRange.end) { - imageHeight -= (drawY + imageHeight - this->mapGameSurfaceHeightRange.end); - if (imageHeight <= 0) { - return; - } - } - // clang-format off - __asm { - mov esi, imageAddress - mov edi, this - mov edi, dword ptr [edi]TextureRenderCore.currentRenderSurface - mov eax, drawX - cmp eax, 0 - jl L_44e4fd - and eax, 0xfffffffe - add edi, eax - mov eax, drawY - mov ebx, heightStart - cmp eax, ebx - jge L_44e430 - sub ebx, eax - mov eax, ebx - cmp imageHeight, eax - jle L_44e4fd - sub imageHeight, eax - L_44e3fb: - mov bl, byte ptr [esi] - movzx ecx, bl - and bl, 0xe0 - and cl, 0x1f - add esi, 1 - cmp bl, 0x20 - je L_44e3fb - cmp bl, 0 - je L_44e41a - cmp bl, 0x40 - je L_44e423 - jmp L_44e428 - L_44e41a: - add ecx, 1 - add ecx, ecx - add esi, ecx - jmp L_44e3fb - L_44e423: - add esi, 2 - jmp L_44e3fb - L_44e428: - sub eax, 1 - jg L_44e3fb - mov eax, heightStart - L_44e430: - mov edx, lineStride - mov ecx, eax - shr eax, 1 - mul edx - add edi, eax - xor eax, eax - xor ebx, ebx - mov oddColumn, ebx - mov edx, imageHeight - L_44e445: - mov al, byte ptr [esi] - movzx ecx, al - and al, 0xe0 - and cl, 0x1f - add esi, 1 - cmp al, 0x20 - je L_44e4a5 - cmp al, 0 - je L_44e4d5 - cmp al, 0x40 - je L_44e4ad - add edi, lineTail - sub edx, 1 - jle L_44e4fd - L_44e46a: - mov bl, byte ptr [esi] - movzx ecx, bl - and bl, 0xe0 - and cl, 0x1f - add esi, 1 - cmp bl, 0x20 - je L_44e46a - cmp bl, 0 - je L_44e489 - cmp bl, 0x40 - je L_44e492 - jmp L_44e497 - L_44e489: - add ecx, 1 - add ecx, ecx - add esi, ecx - jmp L_44e46a - L_44e492: - add esi, 2 - jmp L_44e46a - L_44e497: - xor eax, eax - xor ebx, ebx - mov oddColumn, ebx - sub edx, 1 - jg L_44e445 - jmp L_44e4fd - L_44e4a5: - add ecx, 1 - add oddColumn, ecx - jmp L_44e445 - L_44e4ad: - movzx eax, word ptr [esi] - add esi, 2 - add ecx, 1 - mov ebx, oddColumn - add oddColumn, ecx - L_44e4bc: - test ebx, 1 - jne L_44e4c8 - mov word ptr [edi + ebx], ax - L_44e4c8: - add ebx, 1 - sub ecx, 1 - jne L_44e4bc - jmp L_44e445 - L_44e4d5: - add ecx, 1 - mov ebx, oddColumn - add oddColumn, ecx - L_44e4de: - test ebx, 1 - jne L_44e4ed - mov ax, word ptr [esi] - mov word ptr [edi + ebx], ax - L_44e4ed: - add ebx, 1 - add esi, 2 - sub ecx, 1 - jne L_44e4de - jmp L_44e445 - L_44e4fd: - } - // clang-format on - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 73c58d5da3..708174f3cc 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11105,7 +11105,7 @@ SHC_3BB0A8C1_0x004335A0 | 0.0% | Pending SHC_3BB0A8C1_0x00433630 | 0.0% | Pending -SHC_3BB0A8C1_0x00433780 | 95.4% | Two locals in swapped stack slots +SHC_3BB0A8C1_0x00433780 | 0.0% | Pending SHC_3BB0A8C1_0x00433BC0 | 0.0% | Pending @@ -16947,7 +16947,7 @@ SHC_3BB0A8C1_0x0044D330 | 0.0% | Pending SHC_3BB0A8C1_0x0044D340 | 0.0% | Pending -SHC_3BB0A8C1_0x0044D3D0 | 99.5% | Asm reads surface via this; own handler tables +SHC_3BB0A8C1_0x0044D3D0 | 0.0% | Pending SHC_3BB0A8C1_0x0044E510 | 100.0% | Reimplemented @@ -16965,11 +16965,11 @@ SHC_3BB0A8C1_0x0044FBF0 | 0.0% | Pending SHC_3BB0A8C1_0x00451E00 | 0.0% | Pending -SHC_3BB0A8C1_0x00452900 | 98.1% | Globals via statics in asm +SHC_3BB0A8C1_0x00452900 | 0.0% | Pending -SHC_3BB0A8C1_0x00453600 | 89.4% | Globals via statics in asm +SHC_3BB0A8C1_0x00453600 | 0.0% | Pending -SHC_3BB0A8C1_0x00453B00 | 92.6% | Globals via statics in asm +SHC_3BB0A8C1_0x00453B00 | 0.0% | Pending SHC_3BB0A8C1_0x00454080 | 86.3% | the C++ part before the asm keeps its values in other registers; the asm matches @@ -22423,7 +22423,7 @@ SHC_3BB0A8C1_0x004800E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00480210 | 0.0% | Pending -SHC_3BB0A8C1_0x00480440 | 95.7% | ebp is saved at entry; the original saves it only for the sort +SHC_3BB0A8C1_0x00480440 | 0.0% | Pending SHC_3BB0A8C1_0x00480570 | 100.0% | Reimplemented @@ -23047,7 +23047,7 @@ SHC_3BB0A8C1_0x00486C40 | 0.0% | Pending SHC_3BB0A8C1_0x00486C60 | 0.0% | Pending -SHC_3BB0A8C1_0x00486F20 | 98.9% | One lea scheduled earlier +SHC_3BB0A8C1_0x00486F20 | 0.0% | Pending SHC_3BB0A8C1_0x00487080 | 100.0% | Reimplemented @@ -26879,7 +26879,7 @@ SHC_3BB0A8C1_0x004B5110 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B51A0 | 87.1% | Two registers swapped -SHC_3BB0A8C1_0x004B5280 | 87.5% | Globals via statics in asm +SHC_3BB0A8C1_0x004B5280 | 0.0% | Pending SHC_3BB0A8C1_0x004B5300 | 100.0% | Reimplemented @@ -29089,7 +29089,7 @@ SHC_3BB0A8C1_0x004BA7D0 | 0.0% | Pending SHC_3BB0A8C1_0x004BA8B0 | 0.0% | Pending -SHC_3BB0A8C1_0x004BA910 | 97.2% | One push scheduled later +SHC_3BB0A8C1_0x004BA910 | 0.0% | Pending SHC_3BB0A8C1_0x004BA980 | 0.0% | Pending From 34815126e4e08bb6505f9cdb2589bf2bda7aebeb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 23:15:00 +0100 Subject: [PATCH 64/78] Follow 7c6bb9e26's field renames Generated field names in five files follow main's header sync (fieldN_0xOFF -> field_0xOFF): renderMinimapTileStripWithLuminescence, openBuildingStatusMenuForBuildingID, RenderGreatestLordScreen, RenderMissionObjectivesUnk and RenderStatusMenu_Army. Every function of the branch compiles to the same code as before the merge. Co-Authored-By: Claude Opus 5.5 --- .../renderMinimapTileStripWithLuminescence.cpp | 10 +++++----- .../openBuildingStatusMenuForBuildingID.cpp | 4 ++-- src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp | 2 +- .../UI/Rendering/RenderMissionObjectivesUnk.cpp | 2 +- src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp index 0867edd847..7a242ee05e 100644 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp @@ -78,12 +78,12 @@ namespace UI { int const luminescence = DAT_TileMapState::instance.LuminesenceLayer[tile]; uint color = 0; if ((logic & 0x40000000) != 0) { - color = DAT_MiniMapDefinedData::instance.field6_0x74[isRGB565 + (random & 3) * 2]; + color = DAT_MiniMapDefinedData::instance.field_0x74[isRGB565 + (random & 3) * 2]; } else if ((logic & 0x3000) != 0) { - color = DAT_MiniMapDefinedData::instance.field16_0x144[isRGB565 + (random & 3) * 2]; + color = DAT_MiniMapDefinedData::instance.field_0x144[isRGB565 + (random & 3) * 2]; } else if ((logic & 8) != 0) { if ((DAT_TileMapState::instance.MiscDisplayLayer[tile] & 0x2000) != 0) { - color = DAT_MiniMapDefinedData::instance.field1_0x20[isRGB565]; + color = DAT_MiniMapDefinedData::instance.field_0x20[isRGB565]; } else { color = 0; } @@ -145,7 +145,7 @@ namespace UI { if ((short)color == 0) { color = this->minimapPixelBuffer[(y + dy) * 400 / 2 + x + dx]; } - this->field17_0x44[(y + dy) * 200 + x + dx] = (ushort)color; + this->field_0x44[(y + dy) * 200 + x + dx] = (ushort)color; } } } @@ -159,7 +159,7 @@ namespace UI { if ((short)color == 0) { color = this->minimapPixelBuffer[pixelY * 400 / 2 + pixelX]; } - this->field17_0x44[pixelY * 200 + pixelX] = (ushort)color; + this->field_0x44[pixelY * 200 + pixelX] = (ushort)color; } } } diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp index ee993dce58..2d1a9ae73d 100644 --- a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp @@ -294,7 +294,7 @@ namespace UI { case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE: case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: case OpenSHC::Map::Buildings::BT_WOODGATE1: - if (DAT_BuildingsState::instance.buildings[buildingID].field202_0x2c6 != 0) { + if (DAT_BuildingsState::instance.buildings[buildingID].field_0x2c6 != 0) { return FALSE; } menuTab = 36; @@ -315,7 +315,7 @@ namespace UI { (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), OpenSHC::Map::Buildings::BT_GATEHOUSESMALL, 0); } - if (gatehouse != 0 && DAT_BuildingsState::instance.buildings[gatehouse].field202_0x2c6 != 0) { + if (gatehouse != 0 && DAT_BuildingsState::instance.buildings[gatehouse].field_0x2c6 != 0) { return FALSE; } menuTab = 37; diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index aadd909ad5..eeae3a0bbd 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -357,7 +357,7 @@ namespace UI { continue; } char* const name = DAT_GameSynchronyState::instance.finalResults.names[player]; - DAT_TextManagerObject::instance.field12_0x30 = 1; + DAT_TextManagerObject::instance.field_0x30 = 1; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( name, x, y, 260, DAT_RenderingDefinedData::instance diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index 34acb004d4..29781eec41 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -43,7 +43,7 @@ namespace UI { int column = 200; int const headerX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30; int const headerY = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 50; - DAT_TextManagerObject::instance.field9_0x24 = 1; + DAT_TextManagerObject::instance.field_0x24 = 1; if (DAT_GameCore::instance.section1095 == 2) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index 207424cb3c..d184e8356b 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -81,7 +81,7 @@ namespace UI { uint color; int percentX; if (0 < fearFactor) { - DAT_TextManagerObject::instance.field8_0x20 = 1; + DAT_TextManagerObject::instance.field_0x20 = 1; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 177, x + 116, top + 27); // "Troop combat bonus:" @@ -97,7 +97,7 @@ namespace UI { color = OpenSHC::Rendering::Colors::COL_00FF00; percentX = x + 164; } else if (fearFactor < 0) { - DAT_TextManagerObject::instance.field8_0x20 = 1; + DAT_TextManagerObject::instance.field_0x20 = 1; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 178, x + 116, top + 17); // "Troop combat bonus:" @@ -124,7 +124,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( s_percentage_005a2770, percentX, top + 25, OpenSHC::Text::TTA_LEFT, color, 0, 18, TRUE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - DAT_TextManagerObject::instance.field8_0x20 = 0; + DAT_TextManagerObject::instance.field_0x20 = 0; } } From e09ec7804d2eeb0d6d0b0ef0b7cdb15ee64d232f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 13:35:00 +0100 Subject: [PATCH 65/78] headers: ColorsEnum gets the colours our menus and displays use COL_007D3E, COL_00A2FF, COL_7CAAAF, COL_7F7F7F, COL_B8E6F5 and COL_C2F0EB, in the generated style and value order. They were written as numbers in our reimplementations; gynt's review of #323 asked for them in the Colors enum. The same commit is in each of our PRs that uses one of them. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Rendering/Colors/ColorsEnum.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp b/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp index e31edf4234..6fec3f33ab 100644 --- a/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp +++ b/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp @@ -14,9 +14,15 @@ namespace Rendering { typedef enum ColorsEnum { COL_0000FF = 255, // 0x000000FF + COL_007D3E = 32062, // 0x00007D3E COL_0080FF = 33023, // 0x000080FF + COL_00A2FF = 41727, // 0x0000A2FF COL_00FF00 = 65280, // 0x0000FF00 + COL_7CAAAF = 8170159, // 0x007CAAAF + COL_7F7F7F = 8355711, // 0x007F7F7F + COL_B8E6F5 = 12117749, // 0x00B8E6F5 COL_B8EEFB = 12119803, // 0x00B8EEFB + COL_C2F0EB = 12775659, // 0x00C2F0EB COL_CCFAFF = 13433599, // 0x00CCFAFF COL_FFFFFF = 16777215 // 0x00FFFFFF From 73c5cfcca83886c6dcf882113d02bd8ef071c666 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 13:46:45 +0100 Subject: [PATCH 66/78] Colours by their ColorsEnum names RenderGreatestLordScreen, RenderMissionObjectivesUnk and RenderStatusMenu_Army wrote their text colours as numbers (0xC2F0EB 36 times, 0xFFFFFF twice, 255 twice); they are COL_C2F0EB (from the shared colours commit), COL_FFFFFF and COL_0000FF now. Same code for all three (quick_diff output identical). Co-Authored-By: Claude Opus 5.5 --- .../UI/Rendering/RenderGreatestLordScreen.cpp | 55 +++++++++++-------- .../Rendering/RenderMissionObjectivesUnk.cpp | 32 +++++------ .../UI/StatusMenus/RenderStatusMenu_Army.cpp | 4 +- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index eeae3a0bbd..aa8c53342c 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -384,7 +384,8 @@ namespace UI { if (DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] != 0) { // "(" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - s_brace_close_005a2778, iconX + 8, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, FALSE, 0); + s_brace_close_005a2778, iconX + 8, iconY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 665, iconX + 14, iconY - 5); @@ -392,47 +393,50 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] % 12), - iconX + 28, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, FALSE, 0); + iconX + 28, iconY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); iconX += 32; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] / 12, iconX, iconY, - OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, TRUE, 0); // ")" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - s_brace_open_005a2774, iconX, iconY, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 19, TRUE, 0); + s_brace_open_005a2774, iconX, iconY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, TRUE, 0); } DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; if (DAT_00ec082c::instance == 0 || DAT_00ec082c::instance == 2) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - tables.kills[player], x + 279, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + tables.kills[player], x + 279, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - tables.losses[player], x + 337, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + tables.losses[player], x + 337, y, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalGold[player], x + 395, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[player], x + 453, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[player], x + 511, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[player], x + 569, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalIronProduced[player], x + 627, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[player], x + 685, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[player], x + 743, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } if (DAT_00ec082c::instance == 1 || DAT_00ec082c::instance == 2) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[player], columnOffset + 279 + x, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, @@ -442,35 +446,38 @@ namespace UI { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[player], columnOffset + 395 + x, - y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[player], - columnOffset + 453 + x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + columnOffset + 453 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE, 0); if (DAT_00ec082c::instance == 1) { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], - columnOffset + 511 + x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + columnOffset + 511 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE, 0); MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[player], - columnOffset + 569 + x, y, OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + columnOffset + 569 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE, 0); MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[player], columnOffset + 627 + x, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } } if (DAT_00ec082c::instance == 3) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], x + 511, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[player], x + 569, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[player], x + 627, y, - OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } y += 45; iconY += 45; @@ -576,7 +583,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 30), DAT_MenuHandlerState::instance.x + 56, DAT_MenuHandlerState::instance.y + 575, OpenSHC::Text::TTA_LEFT, - 0xffffff, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_FFFFFF, 18, TRUE, 0); if (boxRight < DAT_TextManagerObject::instance.currentXOffset_0x0 + 56 + DAT_MenuHandlerState::instance.x) { boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 + 56 + DAT_MenuHandlerState::instance.x; } @@ -614,7 +621,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 30), DAT_MenuHandlerState::instance.x - 36, DAT_MenuHandlerState::instance.y + 632, OpenSHC::Text::TTA_LEFT, - 0xffffff, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_FFFFFF, 18, TRUE, 0); if (boxRight < DAT_TextManagerObject::instance.currentXOffset_0x0 - 36 + DAT_MenuHandlerState::instance.x) { boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 - 36 + DAT_MenuHandlerState::instance.x; } diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index 29781eec41..c2d2b3fd7c 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -208,8 +208,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, textIndex), - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, - 18, FALSE, 0); + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); switch (objective) { case 1: case 4: @@ -220,14 +220,14 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, - 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); if (DAT_GameCore::instance.gameSuspended != 1) { break; } // " (" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( (char*)s___005aaf74, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, - OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); switch (objective) { case 1: value = DAT_GameState::instance @@ -262,11 +262,11 @@ namespace UI { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(value, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, - 0xc2f0eb, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); // ")" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( (char*)s_brace_open_005a2774, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, - OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); break; case 5: case 6: @@ -275,7 +275,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, - 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); if (INT_ARRAY_00eb1238::instance[objective] > 0) { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( @@ -283,7 +283,7 @@ namespace UI { DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_GOODS, INT_ARRAY_00eb1238::instance[objective]), DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, - OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); } if (DAT_GameCore::instance.gameSuspended != 1) { break; @@ -291,7 +291,7 @@ namespace UI { // " (" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( (char*)s___005aaf74, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, - OpenSHC::Text::TTA_LEFT, 0xc2f0eb, 18, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); { int resource = INT_ARRAY_00eb1238::instance[objective]; if (resource == Game::Resources::RT_PARTIALPITCH) { @@ -304,12 +304,12 @@ namespace UI { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(value, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, OpenSHC::Text::TTA_LEFT, - 0xc2f0eb, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); // ")" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( (char*)s_brace_open_005a2774, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, OpenSHC::Text::TTA_LEFT, - 0xc2f0eb, 18, TRUE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); break; } // tick box: done or not @@ -335,8 +335,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 25), - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, 0xc2f0eb, - 18, FALSE, 0); + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); int barX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 301; if (DAT_TextManagerObject::instance.currentXOffset_0x0 + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40 @@ -402,7 +402,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, timerText), DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, - 0xc2f0eb, 18, FALSE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); int barX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 301; if (DAT_TextManagerObject::instance.currentXOffset_0x0 + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40 @@ -468,7 +468,7 @@ namespace UI { DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - DAT_00eb0b24::instance * pageHeight + offset + 50, - 720, 0xc2f0eb, 18, 0); + 720, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, 0); } else if (DAT_GameCore::instance.descriptionStringTableIndex) { INT_00ed27c4::instance = (MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, @@ -487,7 +487,7 @@ namespace UI { DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - DAT_00eb0b24::instance * pageHeight + offset + 50, - 720, 0xc2f0eb, 18, 0); + 720, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, 0); } MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRangeToResolution, DAT_TextureRenderCoreObject::ptr)(); diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp index d184e8356b..a5ab2fe1a2 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -109,8 +109,8 @@ namespace UI { DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel * 5, - x + 152, top + 25, OpenSHC::Text::TTA_LEFT, 255, 0, 18, TRUE, 0); - color = 255; + x + 152, top + 25, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_0000FF, 0, 18, TRUE, 0); + color = OpenSHC::Rendering::Colors::COL_0000FF; percentX = x + 154; } else { // "No 'fear factor' bonus." From 764858fcddc2b959351c114e3db29153c14ea63a Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 17:29:47 +0100 Subject: [PATCH 67/78] Loop bounds by countof(), as main's 948dce845 locatePlayerKeepPositionsOnMinimap's keepPositions loop and RenderGreatestLordScreen's three finalKillMatrix loops now take their bound from the array with the int-returning countof(); the bounds are the same numbers. Co-Authored-By: Claude Opus 5.5 --- .../locatePlayerKeepPositionsOnMinimap.cpp | 2 +- src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp index ef90c6cca7..1b33cb277a 100644 --- a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp +++ b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp @@ -14,7 +14,7 @@ namespace UI { int firstRow = 0; int orientationOffset = 8; int divisor = 2; - for (int player = 0; player < 8; ++player) { + for (int player = 0; player < countof(this->DAT_MapU4B64.keepPositions); ++player) { this->DAT_MapU4B64.keepPositions[player].x = -1; this->DAT_MapU4B64.keepPositions[player].y = -1; } diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index aa8c53342c..d47bcb5abd 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -73,16 +73,19 @@ namespace UI { for (int player = 1; player < 9; ++player) { tables.points[player] = 0; } - for (int player = 1; player < 9; ++player) { + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.finalResults.finalKillMatrix); + ++player) { int kills = 0; - for (int victim = 1; victim < 9; ++victim) { + for (int victim = 1; victim < countof(DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[0]); + ++victim) { if (victim != player) { kills += DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[player][victim]; } } tables.kills[player] = kills; int losses = 0; - for (int killer = 0; killer < 9; ++killer) { + for (int killer = 0; killer < countof(DAT_GameSynchronyState::instance.finalResults.finalKillMatrix); + ++killer) { if (killer != player) { losses += DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[killer][player]; } From 296da0b1c660b5c870063b89b609694b7f14c606 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 00:21:35 +0100 Subject: [PATCH 68/78] Use main's names from the ghidra sync a9401a727 renamed DAT_00ed3170, DAT_00ed316c and DAT_00ed317c to DAT_RenderMap_RowsLeft, DAT_RenderMap_SecondBlitImageIndex and DAT_RenderMap_WhatToDraw, DAT_00ec082c to INT_00ec082c, and INT_00eb0e44 to CHAR_00eb0e44, now a char, so its (char) casts go. Every function measures as before. Co-Authored-By: Claude Opus 5.5 --- ...BlitMapImageWithVerticalClipAndYOffset.cpp | 51 ++++++++++--------- .../UI/Rendering/RenderGreatestLordScreen.cpp | 16 +++--- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp index c74f0e591b..e1ccb9f876 100644 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp @@ -1,21 +1,22 @@ #include "../Rendering.func.hpp" #include "OpenSHC/Globals/DAT_00ed3154.hpp" -#include "OpenSHC/Globals/DAT_00ed316c.hpp" -#include "OpenSHC/Globals/DAT_00ed3170.hpp" -#include "OpenSHC/Globals/DAT_00ed317c.hpp" #include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" #include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" #include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" #include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" #include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_RowsLeft.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_SecondBlitImageIndex.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_WhatToDraw.hpp" #include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" #include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" #include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" namespace OpenSHC { -// Like BlitMapImageWithVerticalClip, but the second image (DAT_00ed316c) starts 160 - DAT_RenderMap_YOffset rows in. +// Like BlitMapImageWithVerticalClip, but the second image (DAT_RenderMap_SecondBlitImageIndex) starts +// 160 - DAT_RenderMap_YOffset rows in. // The copy loops are handwritten assembly in the original, transcribed here from the binary. // FUNCTION: STRONGHOLDCRUSADER 0x00454080 @@ -25,28 +26,30 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() // sizeof does that without generating any code. (void)sizeof(DAT_WindowAndDirectDraw::instance); (void)sizeof(DAT_RenderMap_DrawSomeX::instance); - (void)sizeof(DAT_00ed317c::instance); + (void)sizeof(DAT_RenderMap_WhatToDraw::instance); char* image = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; char* nextImage = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; int drawY = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance) + 9; int height = DAT_GMImageHeaders::instance.imh[DAT_GmImageAddressToBeRendered::instance].height - 7; int skip = 0; int nextSkip = 160 - DAT_RenderMap_YOffset::instance; - if (DAT_00ed3170::instance <= 0) { + if (DAT_RenderMap_RowsLeft::instance <= 0) { return; } if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { skip = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - drawY; - DAT_00ed3170::instance -= skip; + DAT_RenderMap_RowsLeft::instance -= skip; drawY = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; nextSkip += skip; height -= skip; } - if (DAT_00ed3170::instance + drawY >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { - DAT_00ed3170::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; + if (DAT_RenderMap_RowsLeft::instance + drawY + >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + DAT_RenderMap_RowsLeft::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; // fixme: always adds 0, the original subtracts the already shortened row count height = height - + (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - DAT_00ed3170::instance - drawY); + + (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - DAT_RenderMap_RowsLeft::instance + - drawY); } // rows to bytes: tile objects are 15 dwords per row skip *= 60; @@ -54,20 +57,20 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() int firstRows; if (height <= 0) { firstRows = 0; - } else if (height < DAT_00ed3170::instance) { - DAT_00ed3170::instance -= height; + } else if (height < DAT_RenderMap_RowsLeft::instance) { + DAT_RenderMap_RowsLeft::instance -= height; firstRows = height; nextSkip += height * 60; } else { - firstRows = DAT_00ed3170::instance; - DAT_00ed3170::instance = 0; + firstRows = DAT_RenderMap_RowsLeft::instance; + DAT_RenderMap_RowsLeft::instance = 0; skip = nextSkip; } - if (DAT_00ed317c::instance == 3) { + if (DAT_RenderMap_WhatToDraw::instance == 3) { skip -= 480; } image += DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; - nextImage += DAT_GMImageOffsets::instance[DAT_00ed316c::instance]; + nextImage += DAT_GMImageOffsets::instance[DAT_RenderMap_SecondBlitImageIndex::instance]; if (!DAT_TextureRenderCoreObject::instance.isZoom2) { // clang-format off __asm { @@ -86,7 +89,7 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() cmp edx, 0 jle nrm_454359 nrm_4541d6: - mov eax, DAT_00ed317c::instance + mov eax, DAT_RenderMap_WhatToDraw::instance cmp eax, 1 je nrm_45428f cmp eax, 2 @@ -186,10 +189,10 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() jle nrm_454359 jmp nrm_45433d nrm_454359: - cmp DAT_00ed3170::instance, 0 + cmp DAT_RenderMap_RowsLeft::instance, 0 jle nrm_45437f - mov edx, DAT_00ed3170::instance - mov DAT_00ed3170::instance, 0 + mov edx, DAT_RenderMap_RowsLeft::instance + mov DAT_RenderMap_RowsLeft::instance, 0 mov esi, dword ptr nextImage mov eax, dword ptr nextSkip add esi, eax @@ -218,7 +221,7 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() cmp edx, 0 jle zm_4545eb zm_4543ba: - mov eax, DAT_00ed317c::instance + mov eax, DAT_RenderMap_WhatToDraw::instance cmp eax, 1 je zm_4544ac cmp eax, 2 @@ -363,10 +366,10 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() jle zm_4545eb jmp zm_4545b3 zm_4545eb: - cmp DAT_00ed3170::instance, 0 + cmp DAT_RenderMap_RowsLeft::instance, 0 jle zm_454611 - mov edx, DAT_00ed3170::instance - mov DAT_00ed3170::instance, 0 + mov edx, DAT_RenderMap_RowsLeft::instance + mov DAT_RenderMap_RowsLeft::instance, 0 mov esi, dword ptr nextImage mov eax, dword ptr nextSkip add esi, eax diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index d47bcb5abd..e1a1c4808a 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -14,9 +14,9 @@ #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/string-literals.hpp" +#include "OpenSHC/Globals/CHAR_00eb0e44.hpp" #include "OpenSHC/Globals/COL_WHITE.hpp" #include "OpenSHC/Globals/DAT_00eb9af8.hpp" -#include "OpenSHC/Globals/DAT_00ec082c.hpp" #include "OpenSHC/Globals/DAT_00ed3118.hpp" #include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" #include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" @@ -30,7 +30,7 @@ #include "OpenSHC/Globals/DAT_TextManagerObject.hpp" #include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" #include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/INT_00eb0e44.hpp" +#include "OpenSHC/Globals/INT_00ec082c.hpp" namespace OpenSHC { namespace UI { @@ -407,7 +407,7 @@ namespace UI { OpenSHC::Rendering::Colors::COL_C2F0EB, 19, TRUE, 0); } DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - if (DAT_00ec082c::instance == 0 || DAT_00ec082c::instance == 2) { + if (INT_00ec082c::instance == 0 || INT_00ec082c::instance == 2) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( tables.kills[player], x + 279, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); @@ -436,7 +436,7 @@ namespace UI { DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[player], x + 743, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } - if (DAT_00ec082c::instance == 1 || DAT_00ec082c::instance == 2) { + if (INT_00ec082c::instance == 1 || INT_00ec082c::instance == 2) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[player], columnOffset + 279 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); @@ -454,7 +454,7 @@ namespace UI { DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[player], columnOffset + 453 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - if (DAT_00ec082c::instance == 1) { + if (INT_00ec082c::instance == 1) { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], @@ -471,7 +471,7 @@ namespace UI { OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } } - if (DAT_00ec082c::instance == 3) { + if (INT_00ec082c::instance == 3) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], x + 511, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); @@ -486,7 +486,7 @@ namespace UI { iconY += 45; } - if ((char)INT_00eb0e44::instance == '\0') { + if (CHAR_00eb0e44::instance == '\0') { if (DAT_00eb9af8::instance == 0 && DAT_GameSynchronyState::instance.finalResults.yearStart != 0) { // fixme: the original writes the date into the (no longer needed) statistic orders char* const dateText = (char*)tables.statOrder[0]; @@ -541,7 +541,7 @@ namespace UI { } } DAT_00eb9af8::instance = DAT_FinalResultsOrderByColumn::instance; - if ((char)INT_00eb0e44::instance == '\0') { + if (CHAR_00eb0e44::instance == '\0') { return; } From 3448886d5ad4640993c5acb7857ceb4000a7fa88 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 16:02:16 +0100 Subject: [PATCH 69/78] Move four functions to the ready PR popModalDialog (0x00493900), activateModalDialogAndClearText (0x004916C0), convertMinimapClickToTileXY (0x004B51A0) and RenderLoadAndSaveBar (0x00493690) reach 100.0 on main's headers, the first two with MenuTextInputState's modalDialog_2..6 as one array, so they go to reimpl/batch15-100. Their .cpp files leave this draft and their status lines are main's again. Co-Authored-By: Claude Opus 5.5 --- .../activateModalDialogAndClearText.cpp | 45 ------------- .../UI/MenuTextInputState/popModalDialog.cpp | 43 ------------- .../convertMinimapClickToTileXY.cpp | 42 ------------- .../UI/Rendering/RenderLoadAndSaveBar.cpp | 63 ------------------- status/addresses-SHC-3BB0A8C1.txt | 8 +-- 5 files changed, 4 insertions(+), 197 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp delete mode 100644 src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp delete mode 100644 src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp delete mode 100644 src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp diff --git a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp b/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp deleted file mode 100644 index 26a51ae170..0000000000 --- a/src/OpenSHC/UI/MenuTextInputState/activateModalDialogAndClearText.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "../MenuTextInputState.func.hpp" - -#include "OpenSHC/Text/UserTextHandler.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/Text/TextArrayIndexType.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" - -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" - -namespace OpenSHC { -namespace UI { - - using OpenSHC::UI::Enums::MenuModalType; - - // dialogID is 11 for Exit Crusader or Restart Game, 12 for Options - // FUNCTION: STRONGHOLDCRUSADER 0x004916C0 - void MenuTextInputState::activateModalDialogAndClearText(MenuModalType dialogID) - { - if (this->currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU) { - DAT_MenuTextInputState::instance.DAT_SomeTextArrayIndex = DAT_UserTextHandlerState::instance.textArrayIndex; - DAT_UserTextHandlerState::instance.allowUserTextInput = 1; - if (DAT_UserTextHandlerState::instance.textArrayIndex != OpenSHC::Text::TAIT_ZERO) { - MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::clearTextAndCursor, DAT_UserTextHandlerState::ptr)(); - } - } - if (this->currentModalDialog != dialogID) { - // currentModalDialog and modalDialog_2..6 are a stack of open dialogs; pushing through a pointer - // keeps the original's loads and stores (the plain fields let the compiler reuse currentModalDialog) - MenuModalTypeInt* const dialogs = &this->currentModalDialog; - dialogs[5] = dialogs[4]; - dialogs[4] = dialogs[3]; - dialogs[3] = dialogs[2]; - dialogs[2] = dialogs[1]; - dialogs[1] = dialogs[0]; - dialogs[0] = dialogID; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(dialogID, TRUE); - } - } - -} -} diff --git a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp b/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp deleted file mode 100644 index 28c2ce0ba5..0000000000 --- a/src/OpenSHC/UI/MenuTextInputState/popModalDialog.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "../MenuTextInputState.func.hpp" - -#include "OpenSHC/Text/UserTextHandler.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" - -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" - -namespace OpenSHC { -namespace UI { - - using OpenSHC::UI::Enums::MenuModalType; - - // FUNCTION: STRONGHOLDCRUSADER 0x00493900 - void MenuTextInputState::popModalDialog() - { - MenuModalTypeInt const previousDialog = this->modalDialog_2; - this->modalDialog_2 = this->modalDialog_3; - this->modalDialog_3 = this->modalDialog_4; - this->modalDialog_4 = this->modalDialog_5; - this->modalDialog_5 = this->modalDialog_6; - this->modalDialog_6 = OpenSHC::UI::Enums::MMT_NO_MENU; - this->currentModalDialog = previousDialog; - if (previousDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { - if (previousDialog == OpenSHC::UI::Enums::MMT_SAVE_MAP) { - this->fileListVisibleRowCount = 16; - DAT_UserTextHandlerState::instance.allowUserTextInput = 0; - MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( - 2); - MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::moveCursorToEnd, DAT_UserTextHandlerState::ptr)(); - DAT_UserTextHandlerState::instance.allowUserTextInput = 1; - } - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)((OpenSHC::UI::Enums::MenuModalType)previousDialog, TRUE); - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, this)(); - } - -} -} diff --git a/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp b/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp deleted file mode 100644 index 53d3db6f8c..0000000000 --- a/src/OpenSHC/UI/MinimapViewState/convertMinimapClickToTileXY.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "../MinimapViewState.func.hpp" - -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_TileMapState.hpp" -#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" - -namespace OpenSHC { -namespace UI { - - // FUNCTION: STRONGHOLDCRUSADER 0x004B51A0 - void MinimapViewState::convertMinimapClickToTileXY(int* tileX, int* tileY) - { - if (this->minimapClickEnabled != 0) { - int const mouseY = DAT_MouseState::instance.screenSpaceY - this->y; - int orientationOffset = 0; - *tileX = (((DAT_MouseState::instance.screenSpaceX - this->x) * this->oneOrTwo) / this->widthFactor + 6 - + this->tileOffsetX) - * 32; - int const screenY = ((this->oneOrTwo * mouseY) / this->heightFactor + this->tileOffsetY) * 8; - *tileY = screenY; - if (DAT_TileMapState::instance.mapOrientation != 0) { - if (DAT_TileMapState::instance.mapOrientation == 6) { - orientationOffset = 80400; - } else if (DAT_TileMapState::instance.mapOrientation == 4) { - orientationOffset = 160800; - } else if (DAT_TileMapState::instance.mapOrientation == 2) { - orientationOffset = 241200; - } - } - int const tile = DAT_ViewportRenderState::instance - .screenPointToTileNumber[*tileX / 32 + screenY / 16 * 401 + orientationOffset - 6]; - int const row = (short)DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent[tile]; - *tileY = row; - *tileX = tile - DAT_ViewportRenderState::instance.translationMatrix[row].addXgetTile; - return; - } - *tileX = -1; - *tileY = -1; - } - -} -} diff --git a/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp b/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp deleted file mode 100644 index a032f5a5e3..0000000000 --- a/src/OpenSHC/UI/Rendering/RenderLoadAndSaveBar.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "../Rendering.func.hpp" - -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" - -#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/TIME_LoadSaveBar.hpp" - -namespace OpenSHC { -namespace UI { - - // FUNCTION: STRONGHOLDCRUSADER 0x00493690 - void Rendering::RenderLoadAndSaveBar(int progressValueUnk) - { - DWORD const currentTime = timeGetTime(); - if ((int)(currentTime - TIME_LoadSaveBar::instance) <= 30) { - return; - } - TIME_LoadSaveBar::instance = currentTime; - int const barWidth = (progressValueUnk * 300) / 1000; - if (MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)()) { - DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; - DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)( - DAT_MenuTextInputState::instance.progressBarX, DAT_MenuTextInputState::instance.progressBarY, - DAT_MenuTextInputState::instance.progressBarX + barWidth, - DAT_MenuTextInputState::instance.progressBarY + 15, COL_VERY_SOFT_YELLOW::instance.shortValue); - if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_SIEGETENT_SIEGETOWER - || DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_SIEGETENT_SHIELD) { - DAT_WindowAndDirectDraw::instance.pendingBltMode = 2; - if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU) { - DAT_WindowAndDirectDraw::instance.pendingBltMode = 1; - } - } else { - DAT_WindowAndDirectDraw::instance.pendingBltMode = 1; - } - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(1); - DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)( - DAT_MenuTextInputState::instance.progressBarX, DAT_MenuTextInputState::instance.progressBarY, - DAT_MenuTextInputState::instance.progressBarX + barWidth, - DAT_MenuTextInputState::instance.progressBarY + 15, COL_VERY_SOFT_YELLOW::instance.shortValue); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltScreenMenuSurfaceToScreen, - DAT_WindowAndDirectDraw::ptr)(DAT_MenuTextInputState::instance.progressBarX, - DAT_MenuTextInputState::instance.progressBarY, DAT_MenuTextInputState::instance.progressBarX + 300, - DAT_MenuTextInputState::instance.progressBarY + 15); - } - } - -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index aebd3194b1..ca272d1eb2 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23405,7 +23405,7 @@ SHC_3BB0A8C1_0x004914D0 | 0.0% | Pending SHC_3BB0A8C1_0x00491680 | 0.0% | Pending -SHC_3BB0A8C1_0x004916C0 | 90.3% | Store scheduling differs +SHC_3BB0A8C1_0x004916C0 | 0.0% | Pending SHC_3BB0A8C1_0x00491730 | 100.0% | Reimplemented @@ -23625,7 +23625,7 @@ SHC_3BB0A8C1_0x004934F0 | 0.0% | Pending SHC_3BB0A8C1_0x00493560 | 0.0% | Pending -SHC_3BB0A8C1_0x00493690 | 85.7% | Constant 1 kept in edi +SHC_3BB0A8C1_0x00493690 | 0.0% | Pending SHC_3BB0A8C1_0x004937A4 | 0.0% | Pending @@ -23645,7 +23645,7 @@ SHC_3BB0A8C1_0x004938F8 | 0.0% | Pending SHC_3BB0A8C1_0x004938FC | 0.0% | Pending -SHC_3BB0A8C1_0x00493900 | 93.9% | Store scheduling differs +SHC_3BB0A8C1_0x00493900 | 0.0% | Pending SHC_3BB0A8C1_0x00493980 | 100.0% | Reimplemented @@ -26877,7 +26877,7 @@ SHC_3BB0A8C1_0x004B5100 | 0.0% | Pending SHC_3BB0A8C1_0x004B5110 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B51A0 | 87.1% | Two registers swapped +SHC_3BB0A8C1_0x004B51A0 | 0.0% | Pending SHC_3BB0A8C1_0x004B5280 | 0.0% | Pending From 6a2b835096a86e97e5e5011254c11ab62ebce980 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:01:34 +0100 Subject: [PATCH 70/78] RenderStatusMenu_Population: 82.4% -> 93.8% The opening locals are read top first, then the player and x (player first: quick_diff 0.9638 -> 0.8913); the "Population" title takes its position as locals, y then x (in the call: 0.8693; x first: 0.9512); the first year of the labels is max(0, ...), which repeats the division as the original does (an if: 0.9384). Left: the bar loop's three scratch registers rotate (screen width in ecx, not eax) and the year sum is an lea. reccmp 93.8%. Co-Authored-By: Claude Opus 5.5 --- .../RenderStatusMenu_Population.cpp | 18 +++++++++--------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp index 7bf7b6f3c4..e859791a20 100644 --- a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Population.cpp @@ -22,8 +22,9 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x0043F6A0 void StatusMenus::RenderStatusMenu_Population() { - int const player = DAT_GameSynchronyState::instance.currentPlayerSlotID; + // top first, then the player and x (player first: quick_diff 0.9638 -> 0.8913) int const top = DAT_MenuHandlerState::instance.y + 447; + int const player = DAT_GameSynchronyState::instance.currentPlayerSlotID; int const x = DAT_MenuHandlerState::instance.x; // the graph shows the last 300 months int months = DAT_GameState::instance.mapAndTime.populationIndex; @@ -33,12 +34,14 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, DAT_TextureRenderCoreObject::ptr)(1, x + 14, DAT_MenuHandlerState::instance.y + 489); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // y then x for the title (in the call: quick_diff 0.9638 -> 0.8693; x first: 0.9512) + int const titleY = DAT_MenuHandlerState::instance.y + 467; + int const titleX = DAT_MenuHandlerState::instance.x + 25; // "Population" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 3), - DAT_MenuHandlerState::instance.x + 25, DAT_MenuHandlerState::instance.y + 467, OpenSHC::Text::TTA_LEFT, 0, - 17, FALSE, 0); + titleX, titleY, OpenSHC::Text::TTA_LEFT, 0, 17, FALSE, 0); // the axes, three pixels thick int const bottom = top + 126; int const right = x + 493; @@ -102,13 +105,10 @@ namespace UI { 0, x + 180, top + 120, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); // a year label every five years for (int label = 0; label <= 5; ++label) { - int firstYear = (DAT_GameState::instance.mapAndTime.populationIndex - 300) / 12; - if (firstYear < 0) { - firstYear = 0; - } + // the first year shown, at least 0, through max() (an if: quick_diff 0.9638 -> 0.9384) MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - firstYear + label * 5, label * 1475 / 25 + 190 + x, top + 130, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, - 0); + max(0, (DAT_GameState::instance.mapAndTime.populationIndex - 300) / 12) + label * 5, + label * 1475 / 25 + 190 + x, top + 130, OpenSHC::Text::TTA_LEFT, 0, 19, FALSE, 0); } // one bar per month if (months <= 300) { diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ca272d1eb2..e5ade943ab 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13601,7 +13601,7 @@ SHC_3BB0A8C1_0x0043F2C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0043F2F0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0043F6A0 | 82.4% | Register naming differs +SHC_3BB0A8C1_0x0043F6A0 | 93.8% | Bar loop: three scratch registers rotate; the year sum is an lea SHC_3BB0A8C1_0x0043F930 | 0.0% | Pending From c03aad61038662ca70ebe7d831c79bf337985e17 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 18:17:57 +0100 Subject: [PATCH 71/78] RenderMissionObjectivesUnk: use main's INT_00eb0b24 main's header sync 8125c61c2 renamed DAT_00eb0b24 to INT_00eb0b24 and typed it int (it was undefined4); the merge of main left this draft on the old name, which no longer exists. reccmp 58.2%, as recorded. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index c2d2b3fd7c..d5f5e3422c 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -15,7 +15,6 @@ #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/string-literals.hpp" -#include "OpenSHC/Globals/DAT_00eb0b24.hpp" #include "OpenSHC/Globals/DAT_GameCore.hpp" #include "OpenSHC/Globals/DAT_GameState.hpp" #include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" @@ -23,6 +22,7 @@ #include "OpenSHC/Globals/DAT_TextManagerObject.hpp" #include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" #include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00eb0b24.hpp" #include "OpenSHC/Globals/INT_00ec02e8.hpp" #include "OpenSHC/Globals/INT_00ed27c4.hpp" #include "OpenSHC/Globals/INT_ARRAY_00eb1238.hpp" @@ -466,7 +466,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( DAT_GameCore::instance.temporaryTextBufferOfSize1000, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - DAT_00eb0b24::instance * pageHeight + offset + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - INT_00eb0b24::instance * pageHeight + offset + 50, 720, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, 0); } else if (DAT_GameCore::instance.descriptionStringTableIndex) { @@ -485,7 +485,7 @@ namespace UI { OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.descriptionStringTableIndex), DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - DAT_00eb0b24::instance * pageHeight + offset + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - INT_00eb0b24::instance * pageHeight + offset + 50, 720, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, 0); } From 65f0307680ca3079acce56e63bc84764c0444f08 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 23:43:22 +0100 Subject: [PATCH 72/78] RenderMissionObjectivesUnk: the objectives are ScenarioEventConditionIndex values As gynt asked on #354, cases over a value that has an enum use its names. The objective loops run over the scenario conditions 0 to 38 and draw the win timer (39) apart: conditions 18 and 19 (4 cattle farms, 2 inns) are skipped in the builder mode, 17 shares 6's text and 15 shares 8's, and the cases with a number column are population, gold and the percent / maximum conditions 20 to 23. So the 32 case labels, the loop bounds, the comparisons and the indexes into INT_ARRAY_00ed2630 and conditions[] now use the SECI_ names (main's ScenarioEventConditionIndex, e32319b21). Codegen unchanged: quick_diff 0.5846 before and after. Co-Authored-By: Claude Opus 5.5 --- .../Rendering/RenderMissionObjectivesUnk.cpp | 92 ++++++++++--------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index d5f5e3422c..c41160e4c1 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -9,6 +9,7 @@ #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/Game/GameMode2.hpp" #include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventConditionIndex.hpp" #include "OpenSHC/IO/Graphics/GmID.hpp" #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" @@ -56,16 +57,17 @@ namespace UI { headerX, headerY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); // first pass: measure the texts for the number column and the tick boxes - for (int objective = 0; objective < 39; ++objective) { + for (int objective = 0; objective < OpenSHC::Game::ScenarioEvents::Enums::SECI_WIN_TIMER; ++objective) { if (INT_ARRAY_00ed2630::instance[objective] == 0) { continue; } - if ((objective == 18 || objective == 19) + if ((objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_4_CATTLE_FARMS + || objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_2_INNS) && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { continue; } int textIndex = objective; - if (objective >= 20) { + if (objective >= OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED) { textIndex = objective + 1; } if (textIndex == 17) { @@ -84,12 +86,12 @@ namespace UI { } int numberWidth; switch (objective) { - case 1: - case 4: - case 20: - case 21: - case 22: - case 23: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: if (textEnd > column - 5) { column = textWidth + 35; } @@ -100,31 +102,31 @@ namespace UI { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); switch (objective) { - case 1: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentPopulation; break; - case 4: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[Game::Resources::RT_GOLD]; break; - case 20: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .previousBlessedPeoplePercentage; break; - case 21: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: value = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::computeAleCoverage, DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID); break; - case 22: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: value = -DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel; break; - case 23: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel; @@ -138,10 +140,10 @@ namespace UI { boxX = numberWidth + column + 5; } break; - case 5: - case 6: - case 7: - case 17: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_FOOD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOODS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED_17: if (textEnd > column - 5) { column = textWidth + 35; } @@ -180,16 +182,17 @@ namespace UI { } // second pass: draw them - for (int objective = 0; objective < 39; ++objective) { + for (int objective = 0; objective < OpenSHC::Game::ScenarioEvents::Enums::SECI_WIN_TIMER; ++objective) { if (INT_ARRAY_00ed2630::instance[objective] == 0) { continue; } - if ((objective == 18 || objective == 19) + if ((objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_4_CATTLE_FARMS + || objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_2_INNS) && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { continue; } int textIndex = objective; - if (objective >= 20) { + if (objective >= OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED) { textIndex = objective + 1; } if (textIndex == 17 || textIndex == 5 || textIndex == 6) { @@ -211,12 +214,12 @@ namespace UI { DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); switch (objective) { - case 1: - case 4: - case 20: - case 21: - case 22: - case 23: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, @@ -229,31 +232,31 @@ namespace UI { (char*)s___005aaf74, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); switch (objective) { - case 1: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentPopulation; break; - case 4: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[Game::Resources::RT_GOLD]; break; - case 20: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .previousBlessedPeoplePercentage; break; - case 21: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: value = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::computeAleCoverage, DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID); break; - case 22: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: value = -DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel; break; - case 23: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .fearFactorLevel; @@ -268,10 +271,10 @@ namespace UI { (char*)s_brace_open_005a2774, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); break; - case 5: - case 6: - case 7: - case 17: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_FOOD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOODS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED_17: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, @@ -327,8 +330,9 @@ namespace UI { y += 30; } - // objective 39: a progress bar - if (INT_ARRAY_00ed2630::instance[39] != 0 && DAT_MapPropertiesState::instance.SEC_Section1081) { + // The win timer: a progress bar + if (INT_ARRAY_00ed2630::instance[OpenSHC::Game::ScenarioEvents::Enums::SECI_WIN_TIMER] != 0 + && DAT_MapPropertiesState::instance.SEC_Section1081) { int const total = DAT_MapPropertiesState::instance.SEC_Section1090; int done = DAT_MapPropertiesState::instance.SEC_Section1090 - DAT_MapPropertiesState::instance.SEC_Section1080; @@ -370,14 +374,18 @@ namespace UI { // time until the next one-off invasion or the deadline of the mission, as a progress bar int timerText = 15; - if (INT_ARRAY_00ed2630::instance[8] != 0 || INT_ARRAY_00ed2630::instance[15] != 0 + if (INT_ARRAY_00ed2630::instance[OpenSHC::Game::ScenarioEvents::Enums::SECI_NO_ENEMY_AND_INVASIONS_LEFT] + != 0 + || INT_ARRAY_00ed2630::instance[OpenSHC::Game::ScenarioEvents::Enums::SECI_NO_ENEMY_ON_MAP] != 0 || INT_00ec02e8::instance) { for (int i = 0; i < DAT_MapPropertiesState::instance.eventsCount; ++i) { if (DAT_MapPropertiesState::instance.scenarioEvents[i].header.tl_type == 1 && DAT_MapPropertiesState::instance.scenarioEvents[i].data.invasion.repeatMonths == 0) { eventIndex = i; } else if (DAT_MapPropertiesState::instance.scenarioEvents[i].header.tl_type == 3 - && DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.conditions[0].enabled + && DAT_MapPropertiesState::instance.scenarioEvents[i] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_AUTO_STOP] + .enabled && (DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.ScenarioEventType == 1 || DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.ScenarioEventType == 27)) { From 742c910ddb9d3c50e8e248825e7baf15d5bc2d02 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 10 Nov 2026 09:40:17 +0100 Subject: [PATCH 73/78] fix(minimap): index screenPointToTileNumber from its new base gynt's Ghidra sync 2bd620bf2 moved ViewportRenderState::screenPointToTileNumber 8 ints earlier (0x4E600 -> 0x4E5E0), and main's 39ed8174d 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 --- .../UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp | 2 +- .../MinimapViewState/renderMinimapTileStripWithLuminescence.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp index 1b33cb277a..42dce2b0a3 100644 --- a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp +++ b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp @@ -63,7 +63,7 @@ namespace UI { int const x = (column - firstColumn) * widthFactor + rowX; int const buildingID = DAT_TileMapState::instance.BuildingLayer[DAT_ViewportRenderState::instance - .screenPointToTileNumber[column + rowBase - 8]]; + .screenPointToTileNumber[column + rowBase]]; if (buildingID != 0 && OpenSHC::Map::Buildings::BT_MANORHOUSE <= DAT_BuildingsState::instance.buildings[buildingID].buildingType diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp index 7a242ee05e..b360cd3519 100644 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp @@ -72,7 +72,7 @@ namespace UI { for (int column = firstColumn - 2; column < lastColumn; ++column) { int const x = (column - firstColumn) * widthFactor + rowX; int const tile - = DAT_ViewportRenderState::instance.screenPointToTileNumber[column + rowBase - 8]; + = DAT_ViewportRenderState::instance.screenPointToTileNumber[column + rowBase]; uint const logic = DAT_TileMapState::instance.LogicLayer[tile]; int const random = DAT_TileMapState::instance.RandomLayer[tile]; int const luminescence = DAT_TileMapState::instance.LuminesenceLayer[tile]; From 4d3c4e762af203f4c84e2b21993510d58d03fcf8 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 11 Nov 2026 11:36:00 +0100 Subject: [PATCH 74/78] style: self-operations in renderBltAndFlip (style guide rule 29) 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 --- .../UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp index ad0d155f11..dc5ecaf1c5 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -18,7 +18,7 @@ namespace UI { WindowAndDirectDraw* window, RECT& sourceRect, RECT& destinationRect) { if (window->unk_resetViewportRelated == 2 && DAT_WindowAndDirectDraw::instance.pendingBltMode != 2) { - window->mbr_0xcc += 1; + window->mbr_0xcc++; sourceRect.top = DAT_WindowAndDirectDraw::instance.resolutionY - 128; sourceRect.bottom = DAT_WindowAndDirectDraw::instance.resolutionY; destinationRect.left = window->clientOnScreenCoords.left; @@ -88,7 +88,7 @@ namespace UI { } if (this->windowMoveEventBlitCountdown != 0) { DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - this->windowMoveEventBlitCountdown -= 1; + this->windowMoveEventBlitCountdown--; return; } DWORD const now = timeGetTime(); From 0287fe51b988f7767619c54c3e7f26c0a5e1fed7 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 00:10:35 +0100 Subject: [PATCH 75/78] reimplement: SHC_3BB0A8C1_0x004BC790 100.0% Reimplemented 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: 5236e9845 (60.79%), e8e27aad0 (60.8%) and 63cc49fb3; ce6bd1e86 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 Co-Authored-By: Claude Opus 5.5 --- .../RenderAnimatedTutorialFloatOverlay.cpp | 77 +++++++++---------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 37 insertions(+), 42 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp index 0c4aa6524c..9ab7427249 100644 --- a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp +++ b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp @@ -34,67 +34,62 @@ namespace UI { frame = 0; INT_00df563c::instance = now; } - // The gotos measure 3.5 points better than a plain if/else-if chain: the original keeps the shared - // 168 and 600 blocks at their first occurrence. It also keeps x - 8 and y - 32 apart from the - // later - 28 and - 69 (an inlined helper?), which this source folds. + x -= 8; + y -= 32; int resolutionYOffset = 0; if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { - yOffset168: resolutionYOffset = 168; - goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { resolutionYOffset = 424; - goto draw; } if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { - yOffset600: resolutionYOffset = 600; - } else { - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { - resolutionYOffset = 120; - goto draw; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1440x900) { - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { - resolutionYOffset = 480; - goto draw; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) - goto yOffset600; - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { - resolutionYOffset = 840; - goto draw; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { - resolutionYOffset = 1000; - goto draw; - } - if ((DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) - || (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768)) - goto yOffset168; - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { - resolutionYOffset = 4050; - goto draw; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution != OpenSHC::Rendering::SRE_1600x900) - goto draw; - } + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { + resolutionYOffset = 120; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) { + resolutionYOffset = 300; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { + resolutionYOffset = 480; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) { + resolutionYOffset = 600; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { + resolutionYOffset = 840; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { + resolutionYOffset = 1000; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) { + resolutionYOffset = 168; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) { + resolutionYOffset = 168; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { + resolutionYOffset = 4050; + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) { resolutionYOffset = 300; } - draw: RenderTargetInt const previousDrawBuffer = DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue; + x -= 28; + y -= 69; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 36, y - 101 + resolutionYOffset, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x, y + resolutionYOffset, OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX - + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x - 36, - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + resolutionYOffset + y - 101, + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x, + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + resolutionYOffset + y, OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = previousDrawBuffer; } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 55a1de6b09..bd2b292927 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30097,7 +30097,7 @@ SHC_3BB0A8C1_0x004BC6F0 | 0.0% | Pending SHC_3BB0A8C1_0x004BC770 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BC790 | 67.2% | Shared blocks and offsets differ +SHC_3BB0A8C1_0x004BC790 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BC910 | 100.0% | Reimplemented From 21b73bcfdcc356db9f3314cffdda96e6563511c9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 03:49:39 +0100 Subject: [PATCH 76/78] drafts: move 0x004BC790 RenderAnimatedTutorialFloatOverlay to the units 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 0287fe51b, so it moves to the units round 2 PR (reimpl/units-A-round2-100, 558163d18). 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 --- .../RenderAnimatedTutorialFloatOverlay.cpp | 98 ------------------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 99 deletions(-) delete mode 100644 src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp diff --git a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp b/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp deleted file mode 100644 index 9ab7427249..0000000000 --- a/src/OpenSHC/UI/Rendering/RenderAnimatedTutorialFloatOverlay.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "../Rendering.func.hpp" - -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/IO/Graphics/GmID.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" - -#include "OpenSHC/Globals/DAT_00df5540.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/INT_00df563c.hpp" -#include "OpenSHC/Globals/INT_00df5640.hpp" - -namespace OpenSHC { -namespace UI { - - // Renders the animated tutorial arrow (GID_FLOATS_NEW) at (x, y), moved down by a per-resolution offset. It - // cycles through 10 frames at about 60 ms each and is drawn twice: to the screen menu surface and, with the - // camera offset, to the map surface. Skipped while DAT_00df5540 is set. - // FUNCTION: STRONGHOLDCRUSADER 0x004BC790 - void Rendering::RenderAnimatedTutorialFloatOverlay(int x, int y) - { - if (DAT_00df5540::instance != 0) { - return; - } - if ((INT_00df5640::instance & 1U) == 0) { - INT_00df5640::instance |= 1; - INT_00df563c::instance = timeGetTime(); - } - DWORD const now = timeGetTime(); - int frame = (now - INT_00df563c::instance) / 60; - if (frame >= 10) { - frame = 0; - INT_00df563c::instance = now; - } - x -= 8; - y -= 32; - int resolutionYOffset = 0; - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { - resolutionYOffset = 168; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { - resolutionYOffset = 424; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { - resolutionYOffset = 600; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { - resolutionYOffset = 120; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) { - resolutionYOffset = 300; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { - resolutionYOffset = 480; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) { - resolutionYOffset = 600; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { - resolutionYOffset = 840; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { - resolutionYOffset = 1000; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) { - resolutionYOffset = 168; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) { - resolutionYOffset = 168; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { - resolutionYOffset = 4050; - } - if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) { - resolutionYOffset = 300; - } - RenderTargetInt const previousDrawBuffer = DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue; - x -= 28; - y -= 69; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x, y + resolutionYOffset, - OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 261, - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX - + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + x, - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + resolutionYOffset + y, - OpenSHC::IO::Graphics::GID_FLOATS_NEW, frame + 271, 0); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = previousDrawBuffer; - } - -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index bd2b292927..5eda229083 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30097,7 +30097,7 @@ SHC_3BB0A8C1_0x004BC6F0 | 0.0% | Pending SHC_3BB0A8C1_0x004BC770 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BC790 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x004BC790 | 0.0% | Pending SHC_3BB0A8C1_0x004BC910 | 100.0% | Reimplemented From 64d6ed0c5725d19eb33fd6189d3f1d2df60b0072 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 05:19:11 +0100 Subject: [PATCH 77/78] style: checker fixes in four drafts - 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 --- ...BlitMapImageWithVerticalClipAndYOffset.cpp | 121 +++++++++--------- ...renderMinimapTileStripWithLuminescence.cpp | 3 +- .../Rendering/RenderMissionObjectivesUnk.cpp | 20 ++- .../WindowAndDirectDraw/takeScreenshot.cpp | 4 +- 4 files changed, 71 insertions(+), 77 deletions(-) diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp index e1ccb9f876..0f872621d0 100644 --- a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp @@ -47,9 +47,8 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { DAT_RenderMap_RowsLeft::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; // fixme: always adds 0, the original subtracts the already shortened row count - height = height - + (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - DAT_RenderMap_RowsLeft::instance - - drawY); + height += (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end + - DAT_RenderMap_RowsLeft::instance - drawY); } // rows to bytes: tile objects are 15 dwords per row skip *= 60; @@ -87,16 +86,16 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add edi, eax mov edx, firstRows cmp edx, 0 - jle nrm_454359 -nrm_4541d6: + jle next_image +row_start: mov eax, DAT_RenderMap_WhatToDraw::instance cmp eax, 1 - je nrm_45428f + je copy_right_half cmp eax, 2 - je nrm_4542e7 + je copy_left_half cmp eax, 3 - je nrm_45433d -nrm_4541f6: + je copy_middle +copy_whole_row: mov eax, dword ptr [esi] mov ebx, dword ptr [esi + 4] mov ecx, dword ptr [esi + 8] @@ -131,9 +130,9 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add edi, 0x1fb0 sub edx, 1 cmp edx, 0 - jle nrm_454359 - jmp nrm_4541f6 -nrm_45428f: + jle next_image + jmp copy_whole_row +copy_right_half: mov ebx, dword ptr [esi + 0x1c] mov ecx, dword ptr [esi + 0x20] mov dword ptr [edi + 0xddec], ebx @@ -154,9 +153,9 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add edi, 0x1fb0 sub edx, 1 cmp edx, 0 - jle nrm_454359 - jmp nrm_45428f -nrm_4542e7: + jle next_image + jmp copy_right_half +copy_left_half: mov eax, dword ptr [esi] mov ebx, dword ptr [esi + 4] mov ecx, dword ptr [esi + 8] @@ -177,27 +176,27 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add edi, 0x1fb0 sub edx, 1 cmp edx, 0 - jle nrm_454359 - jmp nrm_4542e7 -nrm_45433d: + jle next_image + jmp copy_left_half +copy_middle: mov ebx, dword ptr [esi + 0x1c] mov dword ptr [edi + 0xddec], ebx add esi, 0x3c add edi, 0x1fb0 sub edx, 1 cmp edx, 0 - jle nrm_454359 - jmp nrm_45433d -nrm_454359: + jle next_image + jmp copy_middle +next_image: cmp DAT_RenderMap_RowsLeft::instance, 0 - jle nrm_45437f + jle done mov edx, DAT_RenderMap_RowsLeft::instance mov DAT_RenderMap_RowsLeft::instance, 0 mov esi, dword ptr nextImage mov eax, dword ptr nextSkip add esi, eax - jmp nrm_4541d6 -nrm_45437f: + jmp row_start +done: } // clang-format on return; @@ -219,20 +218,20 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add edi, eax mov edx, firstRows cmp edx, 0 - jle zm_4545eb -zm_4543ba: + jle zoom_next_image +zoom_row_start: mov eax, DAT_RenderMap_WhatToDraw::instance cmp eax, 1 - je zm_4544ac + je zoom_right_half cmp eax, 2 - je zm_454536 + je zoom_left_half cmp eax, 3 - je zm_4545b3 -zm_4543da: + je zoom_middle +zoom_whole_row: mov eax, ecx and eax, 1 cmp eax, 0 - jne zm_454448 + jne zoom_whole_row_odd mov ax, word ptr [esi] mov bx, word ptr [esi + 8] mov word ptr [edi], ax @@ -253,9 +252,9 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_4543da -zm_454448: + jle zoom_next_image + jmp zoom_whole_row +zoom_whole_row_odd: add edi, 0x1fb0 mov ax, word ptr [esi + 4] mov bx, word ptr [esi + 0xc] @@ -275,12 +274,12 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_4543da -zm_4544ac: + jle zoom_next_image + jmp zoom_whole_row +zoom_right_half: mov eax, ecx and eax, 1 - jne zm_4544f0 + jne zoom_right_half_odd mov ax, word ptr [esi + 0x20] mov bx, word ptr [esi + 0x28] mov word ptr [edi + 0x5f20], ax @@ -293,9 +292,9 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_4544ac -zm_4544f0: + jle zoom_next_image + jmp zoom_right_half +zoom_right_half_odd: add edi, 0x1fb0 mov ax, word ptr [esi + 0x1c] mov bx, word ptr [esi + 0x24] @@ -309,12 +308,12 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_4544ac -zm_454536: + jle zoom_next_image + jmp zoom_right_half +zoom_left_half: mov eax, ecx and eax, 1 - jne zm_454574 + jne zoom_left_half_odd mov ax, word ptr [esi] mov bx, word ptr [esi + 8] mov word ptr [edi], ax @@ -327,9 +326,9 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_454536 -zm_454574: + jle zoom_next_image + jmp zoom_left_half +zoom_left_half_odd: add edi, 0x1fb0 mov ax, word ptr [esi + 4] mov bx, word ptr [esi + 0xc] @@ -343,19 +342,19 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_454536 -zm_4545b3: + jle zoom_next_image + jmp zoom_left_half +zoom_middle: mov eax, ecx and eax, 1 - jne zm_4545ca + jne zoom_middle_odd add esi, 0x3c add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_4545b3 -zm_4545ca: + jle zoom_next_image + jmp zoom_middle +zoom_middle_odd: add edi, 0x1fb0 mov ax, word ptr [esi + 0x1c] mov word ptr [edi + 0x5f1e], ax @@ -363,18 +362,18 @@ void Rendering::BlitMapImageWithVerticalClipAndYOffset() add ecx, 1 sub edx, 1 cmp edx, 0 - jle zm_4545eb - jmp zm_4545b3 -zm_4545eb: + jle zoom_next_image + jmp zoom_middle +zoom_next_image: cmp DAT_RenderMap_RowsLeft::instance, 0 - jle zm_454611 + jle zoom_done mov edx, DAT_RenderMap_RowsLeft::instance mov DAT_RenderMap_RowsLeft::instance, 0 mov esi, dword ptr nextImage mov eax, dword ptr nextSkip add esi, eax - jmp zm_4543ba -zm_454611: + jmp zoom_row_start +zoom_done: } // clang-format on } diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp index b360cd3519..8517a2952e 100644 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileStripWithLuminescence.cpp @@ -71,8 +71,7 @@ namespace UI { int const lastColumn = columns / divisor - firstColumn; for (int column = firstColumn - 2; column < lastColumn; ++column) { int const x = (column - firstColumn) * widthFactor + rowX; - int const tile - = DAT_ViewportRenderState::instance.screenPointToTileNumber[column + rowBase]; + int const tile = DAT_ViewportRenderState::instance.screenPointToTileNumber[column + rowBase]; uint const logic = DAT_TileMapState::instance.LogicLayer[tile]; int const random = DAT_TileMapState::instance.RandomLayer[tile]; int const luminescence = DAT_TileMapState::instance.LuminesenceLayer[tile]; diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp index c41160e4c1..dbf243e10c 100644 --- a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -98,9 +98,8 @@ namespace UI { numberWidth = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], 18); if (DAT_GameCore::instance.gameSuspended == 1) { - numberWidth = numberWidth - + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, - DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, + DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); switch (objective) { case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: value = DAT_GameState::instance @@ -132,9 +131,8 @@ namespace UI { .fearFactorLevel; break; } - numberWidth = numberWidth - + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, - DAT_TextManagerObject::ptr)(value, 18); + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(value, 18); } if (numberWidth + column > boxX - 5) { boxX = numberWidth + column + 5; @@ -160,9 +158,8 @@ namespace UI { + 6; } if (DAT_GameCore::instance.gameSuspended == 1) { - numberWidth = numberWidth - + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, - DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, + DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); int resource = INT_ARRAY_00eb1238::instance[objective]; if (resource == Game::Resources::RT_PARTIALPITCH) { resource = Game::Resources::RT_PITCH; @@ -170,9 +167,8 @@ namespace UI { value = DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[resource]; - numberWidth = numberWidth - + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, - DAT_TextManagerObject::ptr)(value, 18); + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(value, 18); } if (numberWidth + column > boxX - 5) { boxX = numberWidth + column + 5; diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp index be135863ea..6123591cb7 100644 --- a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp @@ -6,7 +6,7 @@ #include "OpenSHC/IO/LowLevelMemory.func.hpp" #include "OpenSHC/IO/ResourceManager.func.hpp" #include "OpenSHC/OS.func.hpp" -#include "OpenSHC/string-macros.hpp" +#include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" #include "OpenSHC/Globals/DAT_ResourceManager.hpp" @@ -27,7 +27,7 @@ namespace UI { strcat(path, S_SCREEN_CAPTURE_BMP_005A6538); } else { char fileName[1000]; - MACRO_CALL(OpenSHC::OS_Func::_sprintf)(fileName, S_SCREEN_CAPTURE__03D_BMP_005A6520, screenshotNumber); + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(fileName, s_screen_capture__03d_bmp_005a6520, screenshotNumber); strcat(path, fileName); } From e9ccae5860d31c5dbd1dec30e7bcc8bc75485960 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 05:31:37 +0100 Subject: [PATCH 78/78] fix: RenderGreatestLordScreen builds against main's headers 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 e086ba7c3, where the draft did not compile before. Co-Authored-By: Claude Opus 5.5 --- .../UI/Rendering/RenderGreatestLordScreen.cpp | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp index e1a1c4808a..de203babd4 100644 --- a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -289,16 +289,18 @@ namespace UI { DAT_PencilRenderCore::ptr)(DAT_MenuHandlerState::instance.x, DAT_MenuHandlerState::instance.y, DAT_MenuHandlerState::instance.x + 800, DAT_MenuHandlerState::instance.y + 600, 16); // "Greatest Lord" - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, - DAT_PencilRenderCore::ptr)(225, 1, DAT_MenuHandlerState::instance.x + 40, y, 720, 720); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, DAT_PencilRenderCore::ptr)( + OpenSHC::DE::SHCDE::TEXT_MP_RANK, 1, DAT_MenuHandlerState::instance.x + 40, y, 720, 720); } else { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)(DAT_MenuHandlerState::instance.x - 112, DAT_MenuHandlerState::instance.y - 84, DAT_MenuHandlerState::instance.x + 912, DAT_MenuHandlerState::instance.y + 684, 16); // "Greatest Lord" - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, - DAT_PencilRenderCore::ptr)(225, 1, DAT_MenuHandlerState::instance.x - 104, y - 30, 1008, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, DAT_PencilRenderCore::ptr)( + OpenSHC::DE::SHCDE::TEXT_MP_RANK, 1, DAT_MenuHandlerState::instance.x - 104, y - 30, 1008, 0); y += 20; } y += 190; @@ -487,18 +489,19 @@ namespace UI { } if (CHAR_00eb0e44::instance == '\0') { - if (DAT_00eb9af8::instance == 0 && DAT_GameSynchronyState::instance.finalResults.yearStart != 0) { + if (DAT_00eb9af8::instance == 0 + && DAT_GameSynchronyState::instance.finalResults.tail.tail1.yearStart != 0) { // fixme: the original writes the date into the (no longer needed) statistic orders char* const dateText = (char*)tables.statOrder[0]; MACRO_CALL(OpenSHC::OS_Func::_sprintf)(dateText, s__s__d____s__d_005aaf3c, - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MONTHS, DAT_GameSynchronyState::instance.finalResults.monthStart), - DAT_GameSynchronyState::instance.finalResults.yearStart, - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MONTHS, DAT_GameSynchronyState::instance.finalResults.monthEnd), - DAT_GameSynchronyState::instance.finalResults.yearEnd); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_GameSynchronyState::instance.finalResults.tail.tail1.monthStart), + DAT_GameSynchronyState::instance.finalResults.tail.tail1.yearStart, + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_GameSynchronyState::instance.finalResults.tail.tail1.monthEnd), + DAT_GameSynchronyState::instance.finalResults.tail.tail1.yearEnd); if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset,