From 60e5642ccd027dd780ea2e0d8b6a52a11bf11f71 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 8 Nov 2026 04:18:28 +0100 Subject: [PATCH 1/6] reimplement: SHC_3BB0A8C1_0x00468FE0 100.0% Reimplemented PencilRenderCore::drawHeaderBanner, from gynt's draft (2a0beda24, 40.22%, then 8f3b5dab2, 40.22%, and fc63cfddb, 43.58%, on his fork's reimpl/UI-MenuItems-development; 77191150f, 40.2%, in his closed #255; his style passes 81e1041dd, a389f84e6, dd1433183, 9205629df and cee658d88; at 63cc49fb3 on his fork's reimpl/UI-Rendering-development he moved yPos + 8 into yPos itself and tested the right tile against the banner's width - 8; our 402dc083d, 52.0%, in the draft #360, is that body). The drawing is his: eight rows of 8 by 8 tiles of GID_INTERFACE_ICONS_3 (48, 54 and 60 start the top, middle and bottom rows, + 1 and + 2 for the middle and right tiles, + 3 for each mask), the rows counted in xPos from his first draft on, one tile in from the top and both sides, and the end caps 91 / 92 three pixels in from each end, the right one placed by the cap's width. New here: the banner's width is width itself, reduced in place (width -= 16), as the original keeps it in width's register and puts the row's y in width's stack slot (an innerWidth local: quick_diff 0.6353 -> 1.0000); the rows are counted in a y local, which MSVC also puts in xPos's slot; the pictures are named; the masked row-picture ternary is an if / else if chain and the tile's comma condition a nested if (a flat if / else if chain: quick_diff 1.0000 -> 0.9827); the cap width is read inline between the two cap calls, where the original reads it. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/drawHeaderBanner.cpp | 74 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp new file mode 100644 index 0000000000..12ba34baca --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp @@ -0,0 +1,74 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" + +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // The banner is 8 rows of 8 by 8 pixel tiles. Each y 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 { + BANNER_TILE_SIZE = 8, + BANNER_HEIGHT = 64, + BANNER_TOP_PICTURES = 48, + BANNER_MIDDLE_PICTURES = 54, + BANNER_BOTTOM_PICTURES = 60, + BANNER_CAP_PICTURE = 91, + BANNER_CAP_MASK = 92 + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x00468FE0 + void PencilRenderCore::drawHeaderBanner(int xPos, int yPos, int width, int unusedUnk) + { + // The banner is one tile inside the box at the top and on both sides; width becomes the banner's own. + yPos += BANNER_TILE_SIZE; + int const left = xPos + BANNER_TILE_SIZE; + width -= 2 * BANNER_TILE_SIZE; + for (int y = 0; y < BANNER_HEIGHT; y += BANNER_TILE_SIZE) { + int rowPictures; + if (y == 0) { + rowPictures = BANNER_TOP_PICTURES; + } else if (y == BANNER_HEIGHT - BANNER_TILE_SIZE) { + rowPictures = BANNER_BOTTOM_PICTURES; + } else { + rowPictures = BANNER_MIDDLE_PICTURES; + } + for (int x = 0; x < width; x += BANNER_TILE_SIZE) { + // Nested, not a flat else-if chain (a flat chain: quick_diff 1.0000 -> 0.9827) + int picture = rowPictures; + if (x != 0) { + if (x == width - BANNER_TILE_SIZE) { + picture = rowPictures + 2; + } else { + picture = rowPictures + 1; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture, + x + left, y + yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture + 3, 0); + } + } + // An end cap 3 pixels in from each end of the banner + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE, + left + 3, yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE, + left + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3] + + BANNER_CAP_PICTURE - 1] + .width + + width - 3, + yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4a0c6c0d6a..64bf56caa2 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20111,7 +20111,7 @@ SHC_3BB0A8C1_0x00468F20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468F70 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00468FE0 | 0.0% | Pending +SHC_3BB0A8C1_0x00468FE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004690E0 | 0.0% | Pending From 9661fdba059651e8a7b9f452f720372995fd5ece Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 8 Nov 2026 04:18:28 +0100 Subject: [PATCH 2/6] reimplement: SHC_3BB0A8C1_0x00475CC0 100.0% Reimplemented PencilRenderCore::drawHeaderTextBanner, from gynt's draft (9a1914490, 35.96%, then 6ae321ddb, 35.96%, and e69b74de9, 37.72%, on his fork's reimpl/UI-MenuItems-development; daeda891a, 39.6%, in his closed #255; his style passes 81e1041dd, a389f84e6, b8ab787cc, dd1433183, 9205629df and cee658d88; the same body with his style passes at 63cc49fb3 on his fork's reimpl/UI-Rendering-development; our 9c437b035, 52.4%, in the draft #360). It is drawHeaderBanner's banner with a text centred on it; the banner and the text call (getTextStringInGroupAtOffset nested in renderTextToScreen, centred, COL_C2F0EB, size 15) are his. New here: the banner written as in drawHeaderBanner (yPos += 8 and width -= 16 in place, a y local, the pictures named, the if / else if chain over the rows and the nested tile test: a flat chain, quick_diff 0.9909 -> 0.9774; the cap width inline), so the text sits at width / 2 + left and yPos + 14. The text group keeps its eTextSections cast because the header declares textGroupIndex as int, although every caller passes an eTextSections value; that type is a proposal for the PR text. quick_diff differs only in the colour immediate, which it shows as a data symbol; reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/drawHeaderTextBanner.cpp | 86 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp new file mode 100644 index 0000000000..e53326dd71 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp @@ -0,0 +1,86 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // The banner is 8 rows of 8 by 8 pixel tiles. Each y 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 { + BANNER_TILE_SIZE = 8, + BANNER_HEIGHT = 64, + BANNER_TOP_PICTURES = 48, + BANNER_MIDDLE_PICTURES = 54, + BANNER_BOTTOM_PICTURES = 60, + BANNER_CAP_PICTURE = 91, + BANNER_CAP_MASK = 92, + BANNER_TEXT_FONT_SIZE = 15 + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x00475CC0 + void PencilRenderCore::drawHeaderTextBanner( + int textGroupIndex, int textNumInGroup, int xPos, int yPos, int width, int height) + { + // drawHeaderBanner's banner, with a text centred on it + // The banner is one tile inside the box at the top and on both sides; width becomes the banner's own. + yPos += BANNER_TILE_SIZE; + int const left = xPos + BANNER_TILE_SIZE; + width -= 2 * BANNER_TILE_SIZE; + for (int y = 0; y < BANNER_HEIGHT; y += BANNER_TILE_SIZE) { + int rowPictures; + if (y == 0) { + rowPictures = BANNER_TOP_PICTURES; + } else if (y == BANNER_HEIGHT - BANNER_TILE_SIZE) { + rowPictures = BANNER_BOTTOM_PICTURES; + } else { + rowPictures = BANNER_MIDDLE_PICTURES; + } + for (int x = 0; x < width; x += BANNER_TILE_SIZE) { + // Nested, not a flat else-if chain (a flat chain: quick_diff 0.9909 -> 0.9774) + int picture = rowPictures; + if (x != 0) { + if (x == width - BANNER_TILE_SIZE) { + picture = rowPictures + 2; + } else { + picture = rowPictures + 1; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture, + x + left, y + yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture + 3, 0); + } + } + // An end cap 3 pixels in from each end of the banner + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE, + left + 3, yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE, + left + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3] + + BANNER_CAP_PICTURE - 1] + .width + + width - 3, + yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 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::eTextSections)textGroupIndex, textNumInGroup), + width / 2 + left, yPos + 14, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + BANNER_TEXT_FONT_SIZE, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 64bf56caa2..f88be3ffc9 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -21933,7 +21933,7 @@ SHC_3BB0A8C1_0x00475B90 | 0.0% | Pending SHC_3BB0A8C1_0x00475BE0 | 0.0% | Pending -SHC_3BB0A8C1_0x00475CC0 | 0.0% | Pending +SHC_3BB0A8C1_0x00475CC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00475E00 | 0.0% | Pending From 0f802720902cbd85bc0a9856efe14aa453ab112c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 8 Nov 2026 04:18:28 +0100 Subject: [PATCH 3/6] reimplement: SHC_3BB0A8C1_0x004690E0 100.0% Reimplemented PencilRenderCore::drawScrollbar, from gynt's draft (c80875180, 30.77%, on his fork's reimpl/UI-MenuItems-development; 3d9ca0324, 30.8%, in his closed #255; his style passes 81e1041dd, a389f84e6, dd1433183 and cee658d88; the same body with his style passes at 63cc49fb3 on his fork's reimpl/UI-Rendering-development; 5fa1b203b on his fork's reimpl/UI-MenuItems-development turns the thumb test 10 < thumbHeight - 10 into thumbHeight > 10 - 10, where the binary tests thumbHeight - 10 > 10 (sub ebx, 0xa; cmp ebx, 0xa), as this commit does; our 074c78829, 60.1%, in the draft #360). The pictures and their order are his: the track in 20-pixel pictures (79) and then single rows (95); the thumb small (89, up to 20 high) or as a 10-pixel top (100), single middle rows (101) and a 10-pixel bottom (102); each with its mask (80, 96, 90; 103 to 105). Fixed here: a dragged thumb is drawn once, without masks, and the function returns (ret 0x1c at 0x00469189 and 0x004691EB). In the drafts the dragged branch had no return, so a dragged thumb of up to 20 pixels drew picture 89 and then the large thumb too, and every dragged thumb was then drawn a second time with masks. New here: the draft's hand-made countdown loops and shared final call are plain for loops and one call per branch, which MSVC compiles to the original's countdowns and shared tail; the track walks yPos itself while top keeps its first value (a copy of yPos walking instead: quick_diff 0.8158 -> 0.9474); the thumb loop lowers thumbHeight and advances thumbYPos in place, as the original updates them (0.9474 -> 0.9737 -> 1.0000); the pictures are named; xPos is passed without the (int) casts. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/drawScrollbar.cpp | 100 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/drawScrollbar.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/drawScrollbar.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawScrollbar.cpp new file mode 100644 index 0000000000..397b2c60f7 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/drawScrollbar.cpp @@ -0,0 +1,100 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" + +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // Pictures in GID_INTERFACE_ICONS_3. The track's two and the small thumb are each followed by its alpha mask; + // the thumb's top, middle row and bottom are followed by their three masks. + enum { + SCROLLBAR_TRACK_PICTURE = 79, + SCROLLBAR_TRACK_ROW_PICTURE = 95, + SCROLLBAR_SMALL_THUMB_PICTURE = 89, + SCROLLBAR_THUMB_TOP_PICTURE = 100, + SCROLLBAR_THUMB_ROW_PICTURE = 101, + SCROLLBAR_THUMB_BOTTOM_PICTURE = 102, + SCROLLBAR_TRACK_PICTURE_HEIGHT = 20, + SCROLLBAR_SMALL_THUMB_HEIGHT = 20, + SCROLLBAR_THUMB_END_HEIGHT = 10 + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x004690E0 + void PencilRenderCore::drawScrollbar( + uint xPos, int yPos, int height, int thumbYPos, BOOLEnum isDragged, int thumbHeight, int blendStrength) + { + int const top = yPos; + int const bottom = yPos + height; + // The track in whole pictures, then single rows down to the bottom + for (; yPos <= bottom - SCROLLBAR_TRACK_PICTURE_HEIGHT; yPos += SCROLLBAR_TRACK_PICTURE_HEIGHT) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_TRACK_PICTURE, xPos, yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_TRACK_PICTURE + 1, blendStrength); + } + for (; yPos < bottom; ++yPos) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_TRACK_ROW_PICTURE, xPos, yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_TRACK_ROW_PICTURE + 1, blendStrength); + } + // A dragged thumb is drawn without its masks + if (isDragged) { + if (thumbHeight <= SCROLLBAR_SMALL_THUMB_HEIGHT) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_SMALL_THUMB_PICTURE, xPos, top + thumbYPos); + return; + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_THUMB_TOP_PICTURE, xPos, top + thumbYPos); + // The top and bottom pieces are 10 pixels high, single middle rows fill the rest + thumbYPos += SCROLLBAR_THUMB_END_HEIGHT; + thumbHeight -= SCROLLBAR_THUMB_END_HEIGHT; + for (int row = SCROLLBAR_THUMB_END_HEIGHT; row < thumbHeight; ++row) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_THUMB_ROW_PICTURE, xPos, top + thumbYPos); + ++thumbYPos; + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_THUMB_BOTTOM_PICTURE, xPos, top + thumbYPos); + return; + } + if (thumbHeight <= SCROLLBAR_SMALL_THUMB_HEIGHT) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_SMALL_THUMB_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_SMALL_THUMB_PICTURE + 1, blendStrength); + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_THUMB_TOP_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_THUMB_TOP_PICTURE + 3, blendStrength); + // The top and bottom pieces are 10 pixels high, single middle rows fill the rest + thumbYPos += SCROLLBAR_THUMB_END_HEIGHT; + thumbHeight -= SCROLLBAR_THUMB_END_HEIGHT; + for (int row = SCROLLBAR_THUMB_END_HEIGHT; row < thumbHeight; ++row) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_THUMB_ROW_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_THUMB_ROW_PICTURE + 3, blendStrength); + ++thumbYPos; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_THUMB_BOTTOM_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + SCROLLBAR_THUMB_BOTTOM_PICTURE + 3, blendStrength); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f88be3ffc9..b57b3aeb6d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20113,7 +20113,7 @@ SHC_3BB0A8C1_0x00468F70 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468FE0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004690E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004690E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00469290 | 0.0% | Pending From 220d702ce75434471fd4ac790102c8e540092a05 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 8 Nov 2026 04:18:29 +0100 Subject: [PATCH 4/6] reimplement: SHC_3BB0A8C1_0x00468C80 100.0% Reimplemented PencilRenderCore::setupPencil, from gynt's draft (39577618b, 18.82%, on his fork's reimpl/UI-MenuItems-development; 44a1588bc, 18.8%, in his closed #255; his 3d17527d6 on his fork's reimpl/UI-MenuItems-development puts the map branch first, 19.6%, as this commit does). The clipping is his: left and right clamped to the surface's width (the map surface's 4056 pixels, or resolutionX for the menu surface), top and bottom to the surface's height range, FALSE when the rectangle lies wholly off the surface, then the pencil's size, position, directions and drawing bounds. The note that right and bottom are inclusive is TheRedDaemon's comment in the draft, now one line. Fixed here: the map surface's three width tests are >= 4056, where the draft had 4056 < left and 4056 < right, so 4056 itself was neither clipped nor counted as off the surface: left >= 4056 (cmp edi, 0xfd8; jl at 0x00468CB8), right >= 4056 for the wholly-off test (cmp esi, 0xfd8; jge at 0x00468CC0) and right >= 4056 for the clip (cmp esi, 0xfd8; jl at 0x00468CD5). New here: each branch clips top and bottom against its own height range, read in place, and MSVC merges the identical tails at 0x00468D45 as in the original (the draft's two range locals clip once after the branches); the two sizes, the directions and the drawing bounds are if / else (the sizes as ternaries keep this in ecx: quick_diff 0.5204, if / else 1.0000; the directions and the Y bounds tie either way); 4056 is named MAP_SURFACE_WIDTH. reccmp 100.0%; its callers dimBox and drawColorBox stay at 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../PencilRenderCore/setupPencil.cpp | 134 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/PencilRenderCore/setupPencil.cpp diff --git a/src/OpenSHC/UI/Rendering/PencilRenderCore/setupPencil.cpp b/src/OpenSHC/UI/Rendering/PencilRenderCore/setupPencil.cpp new file mode 100644 index 0000000000..6e1c878cb9 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/PencilRenderCore/setupPencil.cpp @@ -0,0 +1,134 @@ +#include "../PencilRenderCore.func.hpp" + +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // The map surface is 4056 pixels wide. + enum { MAP_SURFACE_WIDTH = 4056 }; + + // FUNCTION: STRONGHOLDCRUSADER 0x00468C80 + BOOLEnum PencilRenderCore::setupPencil(int left, int top, int right, int bottom, ushort color) + { + this->drawColor = color; + // Clips the corners to the surface; right and bottom are inclusive. + if (this->surfaceTarget != OpenSHC::Rendering::Enums::RT_SCREEN_MENU) { + if (left < 0) { + if (right < 0) { + return FALSE; + } + left = 0; + } else if (left >= MAP_SURFACE_WIDTH) { + if (right >= MAP_SURFACE_WIDTH) { + return FALSE; + } + left = MAP_SURFACE_WIDTH - 1; + } + if (right < 0) { + right = 0; + } else if (right >= MAP_SURFACE_WIDTH) { + right = MAP_SURFACE_WIDTH - 1; + } + if (top < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { + if (bottom < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { + return FALSE; + } + top = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; + } + if (top >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + if (bottom >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + return FALSE; + } + top = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - 1; + } + if (bottom < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { + bottom = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; + } + if (bottom >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + bottom = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - 1; + } + } else { + if (left < 0) { + if (right < 0) { + return FALSE; + } + left = 0; + } + if (left >= DAT_WindowAndDirectDraw::instance.resolutionX) { + if (right >= DAT_WindowAndDirectDraw::instance.resolutionX) { + return FALSE; + } + left = DAT_WindowAndDirectDraw::instance.resolutionX - 1; + } + if (right < 0) { + right = 0; + } + if (right >= DAT_WindowAndDirectDraw::instance.resolutionX) { + right = DAT_WindowAndDirectDraw::instance.resolutionX - 1; + } + if (top < DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.start) { + if (bottom < DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.start) { + return FALSE; + } + top = DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.start; + } + if (top >= DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.end) { + if (bottom >= DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.end) { + return FALSE; + } + top = DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.end - 1; + } + if (bottom < DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.start) { + bottom = DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.start; + } + if (bottom >= DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.end) { + bottom = DAT_TextureRenderCoreObject::instance.screenMenuSurfaceHeightRange.end - 1; + } + } + if (top > bottom) { + this->currentHeight_0x2c = top - bottom; + } else { + this->currentHeight_0x2c = bottom - top; + } + if (left > right) { + this->currentWidth_0x28 = left - right; + } else { + this->currentWidth_0x28 = right - left; + } + this->currentX = left; + this->currentY = top; + if (left <= right) { + this->moveDirectionXUnk_0x20 = 1; + } else { + this->moveDirectionXUnk_0x20 = -1; + } + if (top <= bottom) { + this->moveDirectionYUnk_0x24 = 1; + } else { + this->moveDirectionYUnk_0x24 = -1; + } + if (left > right) { + this->drawStartX = right; + this->drawEndX = left; + } else { + this->drawStartX = left; + this->drawEndX = right; + } + if (top > bottom) { + this->drawStartY = bottom; + this->drawEndY = top; + } else { + this->drawEndY = bottom; + this->drawStartY = top; + } + return TRUE; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b57b3aeb6d..43591878b1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20099,7 +20099,7 @@ SHC_3BB0A8C1_0x00468C40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468C50 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00468C80 | 0.0% | Pending +SHC_3BB0A8C1_0x00468C80 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00468DE0 | 100.0% | Reimplemented From 8a3cf407084649447054ffbec68176c09f6193ba Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 8 Nov 2026 04:20:13 +0100 Subject: [PATCH 5/6] reimplement: SHC_3BB0A8C1_0x004B20B0 100.0% Reimplemented RenderNoRushDisplayElementUnk, gynt's function on main (b0a49d06c, 67.57%, and 96008db0d, 82.43%, "shared arm fold direction"; the .cpp and its 82.4% status line came to main in #199 as 648b0c6d2, and the re-measured 83.1% in #269, his 272deccf5, as 4b30c73cc). The function is his: the battle horn and the unlimited display once the no-rush time is over, otherwise the text width, the bar's position by resolution, the blended box, the text, the border and the bar filled by the remaining ticks. New here: the resolutions are tested by separate ifs instead of an else-if chain, in the same order. The original keeps each offset that two resolutions share (-240, -400, -560 and -880) in the first of the two and jumps back to it from the second (je 0x004B212C at 0x004B2144); the else-if chain puts the copy in the second, separate ifs put it in the first, and MSVC still skips the remaining tests once one matches (quick_diff 0.9054 -> 0.9797, the rest being the listing's ret 0 and the colour immediate shown as a data symbol). reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../RenderNoRushDisplayElementUnk.cpp | 40 +++++++++++++------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp b/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp index 8781daff55..057f083502 100644 --- a/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp +++ b/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp @@ -52,33 +52,47 @@ namespace UI { + 50; int x = posX + 800; DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // Separate ifs, not an else-if chain (an else-if chain: quick_diff 0.9797 -> 0.9054) if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) { x += 112; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) { x -= 240; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) { x -= 400; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) { x -= 240; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) { x -= 320; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) { x -= 560; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) { x -= 560; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) { x -= 880; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) { x -= 880; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) { x -= 283; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) { x -= 440; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) { x -= 400; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x600) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x600) { x -= 112; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) { + } + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) { x -= 280; } x += -18 - (barWidth / 2); diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 43591878b1..9e06feb3cf 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26001,7 +26001,7 @@ SHC_3BB0A8C1_0x004B1E60 | 0.0% | Pending SHC_3BB0A8C1_0x004B1EB0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B20B0 | 83.1% | shared arm fold direction +SHC_3BB0A8C1_0x004B20B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B2280 | 100.0% | Reimplemented From f4e1e8c3b47f1d760cc78ba8e8f5b415e26c4cc7 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 8 Nov 2026 04:20:13 +0100 Subject: [PATCH 6/6] style: RenderNoRushDisplayElementUnk without its unused usings and includes The six using declarations and the Helpers and Rendering function headers were unused: the code names everything in full. x += -18 - (barWidth / 2) becomes x -= 18 + barWidth / 2. quick_diff 0.9797 before and after. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../DisplayElements/RenderNoRushDisplayElementUnk.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp b/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp index 057f083502..f47f64828e 100644 --- a/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp +++ b/src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp @@ -2,8 +2,6 @@ #include "OpenSHC/Audio/SFX/SFXState.func.hpp" #include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/Rendering.func.hpp" #include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" @@ -26,13 +24,6 @@ namespace OpenSHC { namespace UI { namespace DisplayElements { - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::Rendering::ScreenResolutionEnum; - using OpenSHC::Rendering::Enums::RenderTarget; - using OpenSHC::Text::TextAlignment; - using OpenSHC::UI::Enums::DisplayElementID; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004B20B0 void RenderNoRushDisplayElementUnk(int posX, int posY, DWORD elementState) { @@ -95,7 +86,7 @@ namespace UI { if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) { x -= 280; } - x += -18 - (barWidth / 2); + x -= 18 + barWidth / 2; int const left = x - (barWidth / 2); MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)(left - 7, posY - 5, (barWidth / 2) + 5 + x, posY + 30, 16);