From d6f40edd6552bdec2fa051ea10f870c53c11a393 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:04 +0100 Subject: [PATCH 01/11] headers: TextInputDefinedData::field_0x0 is two tables, of 5 and 6 rows field_0x0[11] at 0x00B37CBC holds 5, 3, 2, 1, 1 and then 6, 4, 3, 2, 1, 1: two tables of row indents for rounded box corners, each starting with its row count (a corner's outermost row is indented by its radius), as field_0x2c[22] at 0x00B37CE8 (22, 19, 16, ..., 1, 1) is the RBERL_STRONG table. The exe uses only the first five: drawBoxWithRoundedEdgesAndColor and drawBoxWithRoundedEdges load 0x00B37CBC for RBERL_SLIGHT (5) (mov ebx, 0xb37cbc at 0x00470EFE and 0x004710BE) and read rows 0 to roundingLevel - 1 of it. Nothing refers to the 6-row table at 0x00B37CD0: no instruction in .text has an immediate or a displacement from 0x00B37CBC up to below 0x00B37D40, where UserTextHandler_CharacterFilter_B_1_8_9 starts (0x00469984 and 0x00474146 read that address itself), other than those two loads and mov ebx, 0xb37ce8 (0x00470EF7, 0x004710B7), and no dword in any section points into that range. So field_0x0 becomes int[5] and the 6-row table field_0x14 int[6], named in Ghidra's style. The struct's size is unchanged and no user's code changes: the two rounded-box functions in this branch take field_0x0 as an int*, and main's other users of the struct (the three file filters and four FontSizeClass functions) read other fields. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/TextInputDefinedData.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/TextInputDefinedData.hpp b/src/OpenSHC/UI/TextInputDefinedData.hpp index 1455565a25..6e2cc6766a 100644 --- a/src/OpenSHC/UI/TextInputDefinedData.hpp +++ b/src/OpenSHC/UI/TextInputDefinedData.hpp @@ -19,7 +19,8 @@ namespace UI { // SIZE: 0x00000734 typedef struct TextInputDefinedData { - int field_0x0[11]; // 0x00000000 length: 44 + int field_0x0[5]; // 0x00000000 length: 20 + int field_0x14[6]; // 0x00000014 length: 24 int field_0x2c[22]; // 0x0000002C length: 88 byte UserTextHandler_CharacterFilter_B_1_8_9[256]; // 0x00000084 length: 256 byte UserTextHandler_CharacterFilter_A_2_3[256]; // 0x00000184 length: 256 From 69a17d14235aa5cce2e6db3ced8cab1db7075a3d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:04 +0100 Subject: [PATCH 02/11] reimplement: SHC_3BB0A8C1_0x00468DE0 100.0% Reimplemented PencilRenderCore::drawHorizontalLine, from gynt's draft (f98d57abe, 21.05%, "orig keeps this in ecx at /Od"; b8ff55d3c, 21.1%, in his closed #255; the same body at 63cc49fb3 on his fork's reimpl/UI-Rendering-development). His plate comment already found what the function does: it copies drawStartX, drawStartY, drawEndX and drawColor into locals and writes the row through the global pencil's surface and stride (0x0191D724 / 0x0191D728), not through this. New here: the loop is handwritten assembly in the original (mov edx, 2 as the step, the row offset through mul), so it is transcribed into an __asm block, as main's renderMinimapPreview does; the four copies are int const locals the asm reads from their frame slots; the asm block is what gives the frame pointer and the saved ebx / edi, so his #pragma optimize("gy", off) goes; and a sizeof line instantiates DAT_PencilRenderCore before the asm names it, as main's ApplyBlending does. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/drawHorizontalLine.cpp | 47 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawHorizontalLine.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHorizontalLine.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHorizontalLine.cpp new file mode 100644 index 0000000000..06e6fd79c1 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHorizontalLine.cpp @@ -0,0 +1,47 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x00468DE0 + void PencilRenderCore::drawHorizontalLine() + { + // The asm below names DAT_PencilRenderCore, which inline asm can only do once C++ code has instantiated + // it; sizeof does that without generating any code. + (void)sizeof(DAT_PencilRenderCore::instance); + int const startX = this->drawStartX; + int const startY = this->drawStartY; + int const endX = this->drawEndX; + int const color = this->drawColor; + // Fills row startY from startX to endX with the colour, on the global pencil's surface, not on this one's. + // Handwritten assembly in the original, transcribed from the binary. + __asm { + mov edi, DAT_PencilRenderCore::instance.surfacePtr + mov eax, startX + add eax, eax + add edi, eax + mov eax, startY + mov edx, DAT_PencilRenderCore::instance.horizontalByteSize + mul edx + add edi, eax + mov eax, startX + mov ebx, endX + mov cx, word ptr color + mov edx, 2 + next_pixel: + cmp eax, ebx + jg done + mov word ptr [edi], cx + add edi, edx + add eax, 1 + jmp next_pixel + done: + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6e036f9340..a9e5f75bec 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20101,7 +20101,7 @@ SHC_3BB0A8C1_0x00468C50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468C80 | 0.0% | Pending -SHC_3BB0A8C1_0x00468DE0 | 0.0% | Pending +SHC_3BB0A8C1_0x00468DE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468E40 | 0.0% | Pending From b3b6e3af2406ca3c1203ddfe836cb9a644402e28 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:04 +0100 Subject: [PATCH 03/11] reimplement: SHC_3BB0A8C1_0x00468E40 100.0% Reimplemented PencilRenderCore::drawVerticalLine, from gynt's draft (e24b66b50, 21.05%, "orig keeps this in ecx at /Od"; 88f785c69, 21.1%, in his closed #255; the same body at 63cc49fb3 on his fork's reimpl/UI-Rendering-development). His draft already had the shape: four local copies, the global pencil's surface, and a step of the global's horizontalByteSize per row. New here, as in drawHorizontalLine: the loop transcribed from the binary into an __asm block (it reads the stride into edx again for the step), the copies as int const locals, the pragma gone and the sizeof line. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/drawVerticalLine.cpp | 47 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawVerticalLine.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawVerticalLine.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawVerticalLine.cpp new file mode 100644 index 0000000000..c7b69597d4 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawVerticalLine.cpp @@ -0,0 +1,47 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x00468E40 + void PencilRenderCore::drawVerticalLine() + { + // The asm below names DAT_PencilRenderCore, which inline asm can only do once C++ code has instantiated + // it; sizeof does that without generating any code. + (void)sizeof(DAT_PencilRenderCore::instance); + int const startX = this->drawStartX; + int const startY = this->drawStartY; + int const endY = this->drawEndY; + int const color = this->drawColor; + // Fills column startX from startY to endY with the colour, on the global pencil's surface, not on this + // one's. Handwritten assembly in the original, transcribed from the binary. + __asm { + mov edi, DAT_PencilRenderCore::instance.surfacePtr + mov eax, startX + add eax, eax + add edi, eax + mov eax, startY + mov edx, DAT_PencilRenderCore::instance.horizontalByteSize + mul edx + add edi, eax + mov eax, startY + mov ebx, endY + mov cx, word ptr color + mov edx, DAT_PencilRenderCore::instance.horizontalByteSize + next_pixel: + cmp eax, ebx + jg done + mov word ptr [edi], cx + add edi, edx + add eax, 1 + jmp next_pixel + done: + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a9e5f75bec..75d8f03503 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20103,7 +20103,7 @@ SHC_3BB0A8C1_0x00468C80 | 0.0% | Pending SHC_3BB0A8C1_0x00468DE0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00468E40 | 0.0% | Pending +SHC_3BB0A8C1_0x00468E40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468EA0 | 0.0% | Pending From fda2911d35b9873f25eac7f564ed182ec9683718 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:05 +0100 Subject: [PATCH 04/11] reimplement: SHC_3BB0A8C1_0x00468EA0 100.0% Reimplemented PencilRenderCore::dimHorizontalLine, from gynt's draft (82f902f5a, 15.56%, "orig keeps this in ecx at /Od"; 18ad79e3b, 15.6%, in his closed #255; the same body at 63cc49fb3 on his fork's reimpl/UI-Rendering-development). The mask choice by the colour mode and its explanation are his: the mask clears the lowest bit of every colour channel before the shift, 0xf7de for RGB565 and 0x7bde for RGB555, so that halving a pixel moves no bit into the channel below. New here: the loop transcribed from the binary into an __asm block like drawHorizontalLine; the masks named and written as every bit but the lowest of each channel (no hex left for the style-lint bot); the test written colorBitMode == RGB_555 first, as main's ApplyBlending does, which compiles to the original's neg / sbb / and 0x7c00 / add 0x7bde as the other order does; int const copies; the pragma gone and the sizeof line. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/dimHorizontalLine.cpp | 64 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/dimHorizontalLine.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/dimHorizontalLine.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/dimHorizontalLine.cpp new file mode 100644 index 0000000000..09a24e4f27 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/dimHorizontalLine.cpp @@ -0,0 +1,64 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Rendering/ColorMode.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // Every bit but the lowest of each colour channel, so that halving a pixel shifts no bit into the channel + // below: red starts at bit 11 in RGB565 and at bit 10 in RGB555. + enum { + HALVING_MASK_RGB565 = 65535 & ~((1 << 11) | (1 << 5) | 1), + HALVING_MASK_RGB555 = 32767 & ~((1 << 10) | (1 << 5) | 1) + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x00468EA0 + void PencilRenderCore::dimHorizontalLine() + { + // The asm below names DAT_PencilRenderCore, which inline asm can only do once C++ code has instantiated + // it; sizeof does that without generating any code. + (void)sizeof(DAT_PencilRenderCore::instance); + int const startX = this->drawStartX; + int const startY = this->drawStartY; + int const endX = this->drawEndX; + int halvingMask; + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + halvingMask = HALVING_MASK_RGB555; + } else { + halvingMask = HALVING_MASK_RGB565; + } + // Halves the brightness of row startY from startX to endX, on the global pencil's surface, not on this + // one's. Handwritten assembly in the original, transcribed from the binary. + __asm { + mov edi, DAT_PencilRenderCore::instance.surfacePtr + mov eax, startX + add eax, eax + add edi, eax + mov eax, startY + mov edx, DAT_PencilRenderCore::instance.horizontalByteSize + mul edx + add edi, eax + mov eax, startX + mov ebx, endX + mov dx, word ptr halvingMask + next_pixel: + cmp eax, ebx + jg done + mov cx, word ptr [edi] + and cx, dx + shr cx, 1 + mov word ptr [edi], cx + add edi, 2 + add eax, 1 + jmp next_pixel + done: + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 75d8f03503..4f495f7cd7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20105,7 +20105,7 @@ SHC_3BB0A8C1_0x00468DE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468E40 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00468EA0 | 0.0% | Pending +SHC_3BB0A8C1_0x00468EA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468F20 | 0.0% | Pending From 7f73057227cbc445692927b7e6d1ecbfbd023edb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:05 +0100 Subject: [PATCH 05/11] reimplement: SHC_3BB0A8C1_0x00470EE0 100.0% Reimplemented PencilRenderCore::drawBoxWithRoundedEdgesAndColor, from gynt's draft (4ac54a923, 29.47%; b77851e64, 29.5%, in his closed #255; at 63cc49fb3 on his fork's reimpl/UI-Rendering-development it no longer compiles on today's headers, TextInputDefinedData::field0_0x0). The table choice by rounding level (0x00B37CBC for RBERL_SLIGHT, 0x00B37CE8 for RBERL_STRONG) and the three-loop shape (the first rows indented by the table from the top edge, the middle rows full width, the last rows by the table backwards) are his. New here, fixed against the binary: any other rounding level returns without drawing (jne 0x00470FEF), where the draft went on with the strong table; the tables are the fields field_0x0 and field_0x2c of DAT_TextInputDefinedData (split by the header commit before) rather than a cast address; a switch gives the original's cmp 5 / je, cmp 0x16 / jne order; drawStartX / drawEndX are restored once after the first loop, where the draft reset them on every pass; and the middle loop decrements the height before it moves drawStartY, both in the for's step. quick_diff leaves only an alignment jmp; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../drawBoxWithRoundedEdgesAndColor.cpp | 59 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdgesAndColor.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdgesAndColor.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdgesAndColor.cpp new file mode 100644 index 0000000000..a95b2204fc --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdgesAndColor.cpp @@ -0,0 +1,59 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Globals/DAT_TextInputDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x00470EE0 + void PencilRenderCore::drawBoxWithRoundedEdgesAndColor( + int left, int top, int right, int bottom, ushort color, RoundedBoxEdgeRoundingLevel roundingLevel) + { + // How far each of the first roundingLevel rows is indented at both ends, outermost row first. + int* rowIndents; + switch (roundingLevel) { + case OpenSHC::UI::Enums::RBERL_SLIGHT: + rowIndents = DAT_TextInputDefinedData::instance.field_0x0; + break; + case OpenSHC::UI::Enums::RBERL_STRONG: + rowIndents = DAT_TextInputDefinedData::instance.field_0x2c; + break; + default: + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencilSurface, this)(); + if (!MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencil, this)( + left, top, right, bottom, color)) { + return; + } + // Too low for both rounded ends + if (this->drawEndY - this->drawStartY < roundingLevel * 2) { + return; + } + int const startX = this->drawStartX; + int const endX = this->drawEndX; + for (int row = 0; row < roundingLevel && this->currentHeight_0x2c >= 0; ++row) { + this->drawStartX = rowIndents[row] + startX; + this->drawEndX = endX - rowIndents[row]; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHorizontalLine, this)(); + --this->currentHeight_0x2c; + ++this->drawStartY; + } + this->drawStartX = startX; + this->drawEndX = endX; + for (; this->currentHeight_0x2c >= roundingLevel; --this->currentHeight_0x2c, ++this->drawStartY) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHorizontalLine, this)(); + } + for (int row = roundingLevel - 1; row >= 0 && this->currentHeight_0x2c >= 0; --row) { + this->drawStartX = rowIndents[row] + startX; + this->drawEndX = endX - rowIndents[row]; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHorizontalLine, this)(); + --this->currentHeight_0x2c; + ++this->drawStartY; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4f495f7cd7..9ecaa59eb4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21267,7 +21267,7 @@ SHC_3BB0A8C1_0x00470BC0 | 100.0% | Reimplemented, requires SHC_3BB0A8C1_0x0046CC SHC_3BB0A8C1_0x00470E90 | 0.0% | Pending -SHC_3BB0A8C1_0x00470EE0 | 0.0% | Pending +SHC_3BB0A8C1_0x00470EE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00470FC0 | 0.0% | Pending From 308b0249ae8a266017ec5412fbc57c046efc247c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:05 +0100 Subject: [PATCH 06/11] reimplement: SHC_3BB0A8C1_0x00471440 100.0% Reimplemented PencilRenderCore::drawBorderedBoxWithCustomBlendedBackground, from gynt's draft (16efb3fad, 36.87%; 08d397014, 36.9%, in his closed #255; 7cca78d4b, 40.93%, and the same body with his style passes at 63cc49fb3, both on his fork's reimpl/UI-Rendering-development). The drawing is his: the box rounded up to whole 24-pixel tiles, the pictures of GID_INTERFACE_ICONS_3 by row (1, 7 and 13 start the top, middle and bottom rows, + 1 and + 2 for the middle and right tiles, + 3 for each mask), the inside tiles skipped, the renderGMWithAlphaMask call per tile and the background's (blendStrength - 32) * 16 / 32 + 32. New here: drawBlendedBlackBox on the global pencil (mov ecx, 0x0191D720), where the draft passed this; width and height rounded up in place, as the original stores the rounded width in width's own stack slot, which puts xPos + width in the original's lea order (quick_diff 0.9720 -> 0.9813, where only the imul constant's display differs); the pictures named; and the row's first picture by an if / else if chain instead of the masked ternary. The tile's picture keeps the original's nested shape (a flat else-if chain: quick_diff 0.8000). reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...BorderedBoxWithCustomBlendedBackground.cpp | 67 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithCustomBlendedBackground.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithCustomBlendedBackground.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithCustomBlendedBackground.cpp new file mode 100644 index 0000000000..0632fcdaa5 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithCustomBlendedBackground.cpp @@ -0,0 +1,67 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // The border is drawn in tiles of 24 by 24 pixels. Each row of tiles has a left, a middle and a right picture + // in GID_INTERFACE_ICONS_3, followed by their three alpha masks; these are the rows' first pictures. + enum { + BORDER_TILE_SIZE = 24, + BORDER_TOP_PICTURES = 1, + BORDER_MIDDLE_PICTURES = 7, + BORDER_BOTTOM_PICTURES = 13 + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x00471440 + void PencilRenderCore::drawBorderedBoxWithCustomBlendedBackground( + int xPos, int yPos, int width, int height, int blendStrength) + { + // Rounded up to whole tiles + width = ((width - 1) / BORDER_TILE_SIZE + 1) * BORDER_TILE_SIZE; + height = ((height - 1) / BORDER_TILE_SIZE + 1) * BORDER_TILE_SIZE; + for (int y = 0; y < height; y += BORDER_TILE_SIZE) { + int rowPictures; + if (y == 0) { + rowPictures = BORDER_TOP_PICTURES; + } else if (y == height - BORDER_TILE_SIZE) { + rowPictures = BORDER_BOTTOM_PICTURES; + } else { + rowPictures = BORDER_MIDDLE_PICTURES; + } + for (int x = 0; x < width; x += BORDER_TILE_SIZE) { + // The left picture first, replaced further in: a flat else-if chain doesn't match + int picture = rowPictures; + if (x != 0) { + if (x == width - BORDER_TILE_SIZE) { + picture = rowPictures + 2; + } else { + // The inside of the box is left to the blended background + if (rowPictures == BORDER_MIDDLE_PICTURES) { + continue; + } + picture = rowPictures + 1; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture, + x + xPos, y + yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture + 3, blendStrength); + } + } + // The background always goes on the global pencil, not on this one. + // Half-way to full strength (32); * 16 / 32 gives the original's shl / sar, where / 2 doesn't. + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(xPos + BORDER_TILE_SIZE, yPos + BORDER_TILE_SIZE, + xPos + width - BORDER_TILE_SIZE - 1, yPos + height - BORDER_TILE_SIZE - 1, + (blendStrength - 32) * 16 / 32 + 32); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 9ecaa59eb4..90ebbca887 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21287,7 +21287,7 @@ SHC_3BB0A8C1_0x004712E0 | 0.0% | Pending SHC_3BB0A8C1_0x00471340 | 0.0% | Pending -SHC_3BB0A8C1_0x00471440 | 0.0% | Pending +SHC_3BB0A8C1_0x00471440 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00471570 | 0.0% | Pending From 7a8638a27747fd513c3a94ed14429792f99b7742 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:05 +0100 Subject: [PATCH 07/11] reimplement: SHC_3BB0A8C1_0x00468F20 100.0% Reimplemented PencilRenderCore::drawCurrentPixel, from gynt's drafts. 9f37b5275 (0.00%, "orig is /Od, frame 0xc") and cc7f83ff0 (0.0%, in his closed #255) write the pixel through this, with no locals, no global and no pragma. At 63cc49fb3 on his fork's reimpl/UI-Rendering-development he copied currentX, currentY and drawColor into locals, wrote the pixel through the global pencil's surface and stride, and added #pragma optimize("g", off); our 3e7ec7ef8 (4.5%, in the draft #360) is that body. New here: the store is handwritten assembly in the original, transcribed from the binary like drawHorizontalLine, with the copies as int const locals and the sizeof line. The original is not /Od: it has no frame pointer (sub esp, 0xc; locals at esp), which is what MSVC builds for this function, so the pragma goes. quick_diff leaves only ret / ret 0; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/drawCurrentPixel.cpp | 36 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawCurrentPixel.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawCurrentPixel.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawCurrentPixel.cpp new file mode 100644 index 0000000000..83de94d993 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawCurrentPixel.cpp @@ -0,0 +1,36 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x00468F20 + void PencilRenderCore::drawCurrentPixel() + { + // The asm below names DAT_PencilRenderCore, which inline asm can only do once C++ code has instantiated + // it; sizeof does that without generating any code. + (void)sizeof(DAT_PencilRenderCore::instance); + int const x = this->currentX; + int const y = this->currentY; + int const color = this->drawColor; + // Sets the pixel at (currentX, currentY) to the colour, on the global pencil's surface, not on this one's. + // Handwritten assembly in the original, transcribed from the binary. + __asm { + mov edi, DAT_PencilRenderCore::instance.surfacePtr + mov eax, x + add eax, eax + add edi, eax + mov eax, y + mov edx, DAT_PencilRenderCore::instance.horizontalByteSize + mul edx + add edi, eax + mov cx, word ptr color + mov word ptr [edi], cx + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 90ebbca887..09374ce610 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20107,7 +20107,7 @@ SHC_3BB0A8C1_0x00468E40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468EA0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00468F20 | 0.0% | Pending +SHC_3BB0A8C1_0x00468F20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468F70 | 0.0% | Pending From c260e3866c25758686981571df20b4e4248fbbe1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:06 +0100 Subject: [PATCH 08/11] reimplement: SHC_3BB0A8C1_0x00468F70 100.0% Reimplemented PencilRenderCore::drawPixelPattern4x4, from gynt's drafts (f19bf37ca, 0.00%; ec6bf49db, 0.0%; c5cc82ee3, 4.8%, "Running row offset and global instance"; at 63cc49fb3 on his fork's reimpl/UI-Rendering-development the same rows, with the row pixels and the right pair in two locals, the right pair kept across three rows as the original keeps it in ebx; our 2c99182cf, 9.3%, in the draft #360, is that body). The pattern is his: the four rows of two dword stores through the global pencil's surface, with the original's pixel pairs and a running row offset. New here: the whole body is handwritten assembly in the original (mov ecx, 0 and mov eax, 0 materialise zero), so it is one __asm block transcribed from the binary; the colours are named by their RGB565 channels (PATTERN_GREY 0x7bcf, PATTERN_WHITE 0xffff, PATTERN_DARK_GREY 0x39c7) and each pixel pair is built from them in the asm operand, which assembles to the original's immediates (0xffff7bcf, 0x39c70000, 0x7bcf7bcf, 0x39c739c7). No frame pointer, as in the original. quick_diff differs only in how it displays the constants; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/drawPixelPattern4x4.cpp | 56 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawPixelPattern4x4.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawPixelPattern4x4.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawPixelPattern4x4.cpp new file mode 100644 index 0000000000..53514dc68b --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawPixelPattern4x4.cpp @@ -0,0 +1,56 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // The pattern's colours in RGB565 (red << 11 | green << 5 | blue); black is 0. + enum { + PATTERN_GREY = (15 << 11) | (30 << 5) | 15, + PATTERN_WHITE = (31 << 11) | (63 << 5) | 31, + PATTERN_DARK_GREY = (7 << 11) | (14 << 5) | 7 + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x00468F70 + void PencilRenderCore::drawPixelPattern4x4(int drawX, int drawY) + { + // The asm below names DAT_PencilRenderCore, which inline asm can only do once C++ code has instantiated + // it; sizeof does that without generating any code. + (void)sizeof(DAT_PencilRenderCore::instance); + // A 4x4 pattern at (drawX, drawY), on the global pencil's surface, not on this one's, two pixels per store, + // the left one in the low word. Handwritten assembly in the original, transcribed from the binary. + __asm { + mov edi, DAT_PencilRenderCore::instance.surfacePtr + mov eax, drawX + add eax, eax + add edi, eax + mov eax, drawY + mov edx, DAT_PencilRenderCore::instance.horizontalByteSize + mul edx + add edi, eax + mov ecx, 0 + mov edx, DAT_PencilRenderCore::instance.horizontalByteSize + mov eax, PATTERN_GREY + PATTERN_WHITE * 65536 + mov ebx, PATTERN_DARK_GREY * 65536 + mov dword ptr [edi + ecx], eax + mov dword ptr [edi + ecx + 4], ebx + add ecx, edx + mov eax, PATTERN_GREY + PATTERN_GREY * 65536 + mov dword ptr [edi + ecx], eax + mov dword ptr [edi + ecx + 4], ebx + add ecx, edx + mov eax, PATTERN_DARK_GREY + PATTERN_DARK_GREY * 65536 + mov dword ptr [edi + ecx], eax + mov dword ptr [edi + ecx + 4], ebx + add ecx, edx + mov eax, 0 + mov dword ptr [edi + ecx], eax + mov dword ptr [edi + ecx + 4], eax + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 09374ce610..15fa7c7a6d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20109,7 +20109,7 @@ SHC_3BB0A8C1_0x00468EA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468F20 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00468F70 | 0.0% | Pending +SHC_3BB0A8C1_0x00468F70 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468FE0 | 0.0% | Pending From c7cdcf6eab4f3ac6b9486fcb56f54a73d4be46b3 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:06 +0100 Subject: [PATCH 09/11] reimplement: SHC_3BB0A8C1_0x004710A0 100.0% Reimplemented PencilRenderCore::drawBoxWithRoundedEdges, from gynt's draft (8fcbd14ae, 32.43%; c890ad077, 32.4%, in his closed #255; the same body with his style passes at 63cc49fb3 on his fork's reimpl/UI-Rendering-development; our ea42833c1, 38.9%, in the draft #360). It is drawBoxWithRoundedEdgesAndColor with colour 0 for setupPencil and dimHorizontalLine for drawHorizontalLine, so it darkens a rounded box instead of filling it; that, the table choice and the three-loop shape are his, as in that function. New here: the same fixes as in drawBoxWithRoundedEdgesAndColor (other rounding levels return, the tables as fields, the switch, drawStartX / drawEndX restored once after the first loop, the middle loop's decrement order). The exe's two functions differ in push 0 at 0x004710D4, where the other loads the colour (and the stack offsets and registers that follow from one argument less), and in the three calls to 0x00468EA0. quick_diff 1.0000; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../drawBoxWithRoundedEdges.cpp | 60 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp new file mode 100644 index 0000000000..21062c42db --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBoxWithRoundedEdges.cpp @@ -0,0 +1,60 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Globals/DAT_TextInputDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x004710A0 + void PencilRenderCore::drawBoxWithRoundedEdges( + int left, int top, int right, int bottom, RoundedBoxEdgeRoundingLevel roundingLevel) + { + // How far each of the first roundingLevel rows is indented at both ends, outermost row first. + int* rowIndents; + switch (roundingLevel) { + case OpenSHC::UI::Enums::RBERL_SLIGHT: + rowIndents = DAT_TextInputDefinedData::instance.field_0x0; + break; + case OpenSHC::UI::Enums::RBERL_STRONG: + rowIndents = DAT_TextInputDefinedData::instance.field_0x2c; + break; + default: + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencilSurface, this)(); + // Darkens the box instead of filling it: setupPencil's colour is not used. + if (!MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencil, this)( + left, top, right, bottom, 0)) { + return; + } + // Too low for both rounded ends + if (this->drawEndY - this->drawStartY < roundingLevel * 2) { + return; + } + int const startX = this->drawStartX; + int const endX = this->drawEndX; + for (int row = 0; row < roundingLevel && this->currentHeight_0x2c >= 0; ++row) { + this->drawStartX = rowIndents[row] + startX; + this->drawEndX = endX - rowIndents[row]; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimHorizontalLine, this)(); + --this->currentHeight_0x2c; + ++this->drawStartY; + } + this->drawStartX = startX; + this->drawEndX = endX; + for (; this->currentHeight_0x2c >= roundingLevel; --this->currentHeight_0x2c, ++this->drawStartY) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimHorizontalLine, this)(); + } + for (int row = roundingLevel - 1; row >= 0 && this->currentHeight_0x2c >= 0; --row) { + this->drawStartX = rowIndents[row] + startX; + this->drawEndX = endX - rowIndents[row]; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimHorizontalLine, this)(); + --this->currentHeight_0x2c; + ++this->drawStartY; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 15fa7c7a6d..2a50041d6d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21275,7 +21275,7 @@ SHC_3BB0A8C1_0x00471000 | 0.0% | Pending SHC_3BB0A8C1_0x00471050 | 0.0% | Pending -SHC_3BB0A8C1_0x004710A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004710A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004711B0 | 0.0% | Pending From e556e6808a46855a583f0b52633535c5586b420c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:06 +0100 Subject: [PATCH 10/11] reimplement: SHC_3BB0A8C1_0x00471340 100.0% Reimplemented PencilRenderCore::drawBorderedBoxWithBlendedBackground, from gynt's draft (8e9176448, 31.79%; c6809d45f, 31.8%, in his closed #255; the same body with his style passes at 63cc49fb3 on his fork's reimpl/UI-Rendering-development; our 8543e6b97, 32.8%, in the draft #360). It is drawBorderedBoxWithCustomBlendedBackground with fixed blends, 0 for the border tiles and 16 for the background; the drawing and both blend values are his, as in that function. New here: the same changes as in drawBorderedBoxWithCustomBlendedBackground (drawBlendedBlackBox on the global pencil, mov ecx, 0x0191D720, where the draft passed this; the in-place rounding; the names; the if / else if chain for the row; the tile's nested shape, which a flat chain loses, quick_diff 0.9637). quick_diff 0.9792, where only the imul constant's display differs; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../drawBorderedBoxWithBlendedBackground.cpp | 65 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp new file mode 100644 index 0000000000..fca487fc6d --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawBorderedBoxWithBlendedBackground.cpp @@ -0,0 +1,65 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // The border is drawn in tiles of 24 by 24 pixels. Each row of tiles has a left, a middle and a right picture + // in GID_INTERFACE_ICONS_3, followed by their three alpha masks; these are the rows' first pictures. + enum { + BORDER_TILE_SIZE = 24, + BORDER_TOP_PICTURES = 1, + BORDER_MIDDLE_PICTURES = 7, + BORDER_BOTTOM_PICTURES = 13 + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x00471340 + void PencilRenderCore::drawBorderedBoxWithBlendedBackground(int xPos, int yPos, int width, int height) + { + // Rounded up to whole tiles + width = ((width - 1) / BORDER_TILE_SIZE + 1) * BORDER_TILE_SIZE; + height = ((height - 1) / BORDER_TILE_SIZE + 1) * BORDER_TILE_SIZE; + // The custom version's blends for blendStrength 0: 0 on the tiles, 16 (half-way to 32) on the background + for (int y = 0; y < height; y += BORDER_TILE_SIZE) { + int rowPictures; + if (y == 0) { + rowPictures = BORDER_TOP_PICTURES; + } else if (y == height - BORDER_TILE_SIZE) { + rowPictures = BORDER_BOTTOM_PICTURES; + } else { + rowPictures = BORDER_MIDDLE_PICTURES; + } + for (int x = 0; x < width; x += BORDER_TILE_SIZE) { + // The left picture first, replaced further in: a flat else-if chain doesn't match + int picture = rowPictures; + if (x != 0) { + if (x == width - BORDER_TILE_SIZE) { + picture = rowPictures + 2; + } else { + // The inside of the box is left to the blended background + if (rowPictures == BORDER_MIDDLE_PICTURES) { + continue; + } + picture = rowPictures + 1; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture, + x + xPos, y + yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture + 3, 0); + } + } + // The background always goes on the global pencil, not on this one. + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(xPos + BORDER_TILE_SIZE, yPos + BORDER_TILE_SIZE, + xPos + width - BORDER_TILE_SIZE - 1, yPos + height - BORDER_TILE_SIZE - 1, 16); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2a50041d6d..3d5f674936 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21285,7 +21285,7 @@ SHC_3BB0A8C1_0x00471280 | 0.0% | Pending SHC_3BB0A8C1_0x004712E0 | 0.0% | Pending -SHC_3BB0A8C1_0x00471340 | 0.0% | Pending +SHC_3BB0A8C1_0x00471340 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00471440 | 100.0% | Reimplemented From d77f441b82a9d79eb1e02104d8affb297fe664a3 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 22:06:06 +0100 Subject: [PATCH 11/11] reimplement: SHC_3BB0A8C1_0x00472B20 100.0% Reimplemented PencilRenderCore::drawLine, from gynt's draft (8a949924d, 47.89%; dbccd6707, 47.9%, in his closed #255; the same body with his style passes at 63cc49fb3 on his fork's reimpl/UI-Rendering-development; our cfbab8e4b, 56.3%, in the draft #360). The four calls and their conditions are his. New here: a return after each call (ret at 0x00472B5B, 0x00472B6D, 0x00472B7C). The draft had none, so every line also went through drawDiagonalWiderThanHighUnk, a vertical one through drawDiagonalHeigherThanWideUnk too, and a single point through drawVerticalLine, drawHorizontalLine and drawDiagonalWiderThanHighUnk. quick_diff 1.0000; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../Rendering/PencilRenderCore/drawLine.cpp | 33 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawLine.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawLine.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawLine.cpp new file mode 100644 index 0000000000..57cb89cf9a --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawLine.cpp @@ -0,0 +1,33 @@ +#include "../PencilRenderCore.func.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x00472B20 + void PencilRenderCore::drawLine(int x1, int y1, int x2, int y2, ushort color) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencilSurface, this)(); + if (!MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::setupPencil, this)( + x1, y1, x2, y2, color)) { + return; + } + if (this->currentWidth_0x28 == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawVerticalLine, this)(); + return; + } + if (this->currentHeight_0x2c == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHorizontalLine, this)(); + return; + } + if (this->currentHeight_0x2c > this->currentWidth_0x28) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawDiagonalHeigherThanWideUnk, this)(); + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawDiagonalWiderThanHighUnk, this)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3d5f674936..b65c1771da 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21417,7 +21417,7 @@ SHC_3BB0A8C1_0x004729B0 | 0.0% | Pending SHC_3BB0A8C1_0x00472A90 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00472B20 | 0.0% | Pending +SHC_3BB0A8C1_0x00472B20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00472B90 | 0.0% | Pending