From c41d2a3444296ce5093bf8ca028a8ff638423333 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 07:56:58 +0100 Subject: [PATCH] reimplement: SHC_3BB0A8C1_0x00451E00 100.0% Reimplemented TextureRenderCore::renderUnitAnimationWithBlendingUnk: blends a unit animation's TGX picture into the map or menu surface through the player's colour palette and a pair of rows of the blend filter arrays, picked by the blend strength. The four drawing loops (RGB555 and RGB565, zoomed out and not) are the original's handwritten assembly, as inline asm. From gynt's asm draft: his 91.5% 3c9bcdb72 ("Four asm loops recovered, stack slot allocation differs") on sourcehold's reimpl/TextureRenderCore, through our draft in #363 (92.5%, 29ca84055), which fixed his two zoomed-path blocks drawing through the picture width as the surface pointer. His newest version, 3d17527d65 (2026-11-02, with d90dce4e29's style pass on top) on his fork's reimpl/UI-MenuItems-development, is the decompiler's C form (6.0%, no asm); not used. What the match needed: - The zoomed path in an else block, with the column offset declared in it. The stack slots of the asm-referenced locals follow their reference weights, and every asm block adds to the weight of each local that any asm block writes, if that local is declared in a block that contains it (wherever in that block). At the top the column offset weighs more than the line width, the start height and the palette and takes their slots; in the zoomed block it falls behind them, as in the original (at the top: reccmp 95.8). - /GL with InitBlendFilterArraysUnk (100% on main): with its body visible the compiler keeps height in edi across the call, as the original does, and keeps the two surface arms' stores apart. - The map arm's stores with the heights last (with them first: 99.9), and the zoomed path's column parity first (after the heights: 98.8). Also: the header's parameter names, isZoom2 tested by truthiness, the TGX token constants and C hex in the asm, labels by what they do, no leading underscores, the filter rows as array indexing, declarations at their first assignment where both paths don't share them. Same code. Measured in a narrow build of this file with InitBlendFilterArraysUnk on main 0e4a83b5d, both resolver sets on: 100.0% raw and normalised. Not run in game. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5 Co-Authored-By: Claude Opus 5.5 --- cmake/compiler-flags-gl.txt | 1 + cmake/function-visibility.txt | 2 + .../renderUnitAnimationWithBlendingUnk.cpp | 936 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 4 files changed, 940 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 18dce0ff70..418d4f5592 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -113,6 +113,7 @@ src/OpenSHC/UI/Rendering/TextureRenderCore/transformTilesetToRGB565.cpp src/OpenSHC/UI/Rendering/TextureRenderCore/transformTileObjectToRGB565.cpp src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp +src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp src/OpenSHC/UI/Rendering/InitBlendFilterArraysUnk.cpp src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_DrawbridgeOpenClose.cpp src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_GatehouseOpenClose.cpp diff --git a/cmake/function-visibility.txt b/cmake/function-visibility.txt index 003232c0b0..1679fd55e7 100644 --- a/cmake/function-visibility.txt +++ b/cmake/function-visibility.txt @@ -55,6 +55,8 @@ OpenSHC::UI::Rendering::TextureRenderCore::renderInterfaceOrBuildingOccupationAr OpenSHC::UI::Rendering::InitBlendFilterArraysUnk OpenSHC::UI::Rendering::TextureRenderCore::renderGmWithPreparedAlphaMask OpenSHC::UI::Rendering::InitBlendFilterArraysUnk +OpenSHC::UI::Rendering::TextureRenderCore::renderUnitAnimationWithBlendingUnk + OpenSHC::UI::Rendering::InitBlendFilterArraysUnk OpenSHC::UI::Rendering::TextureRenderCore::transformTilesetToRGB565 OpenSHC::UI::Rendering::TextureRenderCore::transformTileObjectToRGB565 OpenSHC::Game::GameStateStructures::clearEnemyRelatedStructures diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp new file mode 100644 index 0000000000..500a6dd7d5 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp @@ -0,0 +1,936 @@ +#include "../TextureRenderCore.func.hpp" + +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/IO/Graphics/TgxToken.hpp" +#include "OpenSHC/Rendering/ColorMode.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/DAT_BlendFilterArrays.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_CurrentlyRenderedSpriteID.hpp" +#include "OpenSHC/Globals/DAT_RenderedUnitOwner.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::IO::Graphics::TT_REPEATING_PIXELS; + using OpenSHC::IO::Graphics::TT_STREAM_OF_PIXELS; + using OpenSHC::IO::Graphics::TT_TGX_PIXEL_HEADER; + using OpenSHC::IO::Graphics::TT_TGX_PIXEL_LENGTH; + using OpenSHC::IO::Graphics::TT_TRANSPARENT_PIXELS; + + // The four drawing loops are handwritten assembly in the original, transcribed here from the binary. + + // FUNCTION: STRONGHOLDCRUSADER 0x00451E00 + void TextureRenderCore::renderUnitAnimationWithBlendingUnk( + int xPosition, int yPosition, int width, int height, byte* imageAddress, int blendStrengthUnk) + { + // Both paths and both surface arms assign these; the asm reads the first two + int lineBytes; + int heightStart; + int heightEnd; + if (DAT_RenderedUnitOwner::instance == 1) { + DAT_RenderedUnitOwner::instance = 4; + } else if (DAT_RenderedUnitOwner::instance == 4) { + DAT_RenderedUnitOwner::instance = 1; + } + short* colorPalette = this->gmFileHeaderColorpaletteArray[DAT_CurrentlyRenderedSpriteID::instance] + .colorPalette[DAT_BlendingDefinedData::instance + .PlayerSlotUnitColor[DAT_RenderedUnitOwner::instance]]; + if (height <= 0) { + return; + } + if (this->colorPaletteOverride != 0) { + colorPalette = (short*)this->colorPaletteOverride; + } + if (blendStrengthUnk >= 32) { + return; + } + // The last filter entry is still zero until the filter arrays are built + if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::InitBlendFilterArraysUnk)(); + } + // The asm weighs the destination with one row and the drawn colour with the other + short* const dstFilter = DAT_BlendFilterArrays::instance[blendStrengthUnk][0]; + short* const srcFilter = DAT_BlendFilterArrays::instance[32 - blendStrengthUnk][0]; + // From here blendStrengthUnk holds the line step the asm adds per row, in its own slot as in the original + if (!DAT_TextureRenderCoreObject::instance.isZoom2) { + if (this->drawBufferChoiceValue != OpenSHC::Rendering::Enums::RT_SCREEN_MENU) { + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + // The map surface is 4056 pixels wide; the heights after the steps (before them loses the match) + blendStrengthUnk = 4056 * 2; + lineBytes = 4056 * 2; + heightStart = this->mapGameSurfaceHeightRange.start; + heightEnd = this->mapGameSurfaceHeightRange.end; + } else { + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_screenMenu; + blendStrengthUnk = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; + lineBytes = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; + heightStart = this->screenMenuSurfaceHeightRange.start; + heightEnd = this->screenMenuSurfaceHeightRange.end; + } + if (height + yPosition > heightEnd) { + height = heightEnd - yPosition; + if (height <= 0) { + return; + } + } + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + // clang-format off + __asm { + mov esi, imageAddress + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPosition + cmp eax, 0 + jl done_555 + add eax, eax + add edi, eax + mov eax, yPosition + mov ebx, heightStart + cmp eax, ebx + jge add_y_offset_555 + sub ebx, eax + mov eax, ebx + cmp height, eax + jle done_555 + sub height, eax + skip_token_555: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je skip_token_555 + cmp bl, TT_STREAM_OF_PIXELS + je skip_stream_555 + cmp bl, TT_REPEATING_PIXELS + je skip_repeating_555 + jmp skip_newline_555 + skip_stream_555: + add ecx, 1 + add esi, ecx + jmp skip_token_555 + skip_repeating_555: + add esi, 1 + jmp skip_token_555 + skip_newline_555: + sub eax, 1 + cmp eax, 0 + jg skip_token_555 + mov eax, heightStart + add_y_offset_555: + mov edx, lineBytes + mul edx + add edi, eax + mov edx, colorPalette + draw_row_555: + push edi + draw_token_555: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp al, TT_TRANSPARENT_PIXELS + je draw_transparent_555 + cmp al, TT_STREAM_OF_PIXELS + je draw_stream_555 + cmp al, TT_REPEATING_PIXELS + je draw_repeating_555 + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jg draw_row_555 + jmp done_555 + draw_transparent_555: + add ecx, 1 + add ecx, ecx + add edi, ecx + jmp draw_token_555 + draw_repeating_555: + mov ebx, 0 + mov eax, 0 + mov bl, byte ptr [esi] + mov ax, word ptr [edx + ebx*2] + add esi, 1 + add ecx, 1 + push edx + mov edx, srcFilter + 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, 10 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x3ff + or ax, bx + repeating_pixel_555: + mov dx, word ptr [edi] + push ax + mov eax, dstFilter + mov ebx, 0 + mov bx, dx + and bx, 0x1f + mov bx, word ptr [eax + ebx*8] + and dx, 0xffe0 + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0xfc1f + or dx, bx + mov bx, dx + shr bx, 10 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 0x83ff + or dx, bx + pop ax + add dx, ax + mov word ptr [edi], dx + add edi, 2 + sub ecx, 1 + jne repeating_pixel_555 + pop edx + jmp draw_token_555 + draw_stream_555: + mov ebx, 0 + add ecx, 1 + stream_pixel_555: + mov eax, 0 + mov al, byte ptr [esi] + mov ax, word ptr [edx + eax*2] + push edx + mov edx, srcFilter + 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, 10 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x3ff + or ax, bx + mov dx, word ptr [edi] + mov word ptr [edi], ax + mov eax, dstFilter + mov ebx, 0 + mov bx, dx + and bx, 0x1f + mov bx, word ptr [eax + ebx*8] + and dx, 0xffe0 + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0xfc1f + or dx, bx + mov bx, dx + shr bx, 10 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 0x83ff + or dx, bx + add word ptr [edi], dx + pop edx + add esi, 1 + add edi, 2 + sub ecx, 1 + jne stream_pixel_555 + jmp draw_token_555 + done_555: + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, imageAddress + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPosition + cmp eax, 0 + jl done_565 + add eax, eax + add edi, eax + mov eax, yPosition + mov ebx, heightStart + cmp eax, ebx + jge add_y_offset_565 + sub ebx, eax + mov eax, ebx + cmp height, eax + jle done_565 + sub height, eax + skip_token_565: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je skip_token_565 + cmp bl, TT_STREAM_OF_PIXELS + je skip_stream_565 + cmp bl, TT_REPEATING_PIXELS + je skip_repeating_565 + jmp skip_newline_565 + skip_stream_565: + add ecx, 1 + add esi, ecx + jmp skip_token_565 + skip_repeating_565: + add esi, 1 + jmp skip_token_565 + skip_newline_565: + sub eax, 1 + cmp eax, 0 + jg skip_token_565 + mov eax, heightStart + add_y_offset_565: + mov edx, lineBytes + mul edx + add edi, eax + mov edx, colorPalette + draw_row_565: + push edi + draw_token_565: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp al, TT_TRANSPARENT_PIXELS + je draw_transparent_565 + cmp al, TT_STREAM_OF_PIXELS + je draw_stream_565 + cmp al, TT_REPEATING_PIXELS + je draw_repeating_565 + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jg draw_row_565 + jmp done_565 + draw_transparent_565: + add ecx, 1 + add ecx, ecx + add edi, ecx + jmp draw_token_565 + draw_repeating_565: + mov ebx, 0 + mov eax, 0 + mov bl, byte ptr [esi] + mov ax, word ptr [edx + ebx*2] + add esi, 1 + push esi + add ecx, 1 + push edx + mov esi, srcFilter + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov dx, word ptr [esi + ebx*8] + mov bx, ax + shr bx, 5 + and bx, 0x3f + or dx, word ptr [esi + ebx*8 + 2] + mov bx, ax + shr bx, 11 + and bx, 0x1f + or dx, word ptr [esi + ebx*8 + 4] + mov ax, dx + mov esi, dstFilter + repeating_pixel_565: + mov dx, word ptr [edi] + push ax + mov ebx, 0 + mov bx, dx + and bx, 0x1f + mov ax, word ptr [esi + ebx*8] + mov bx, dx + shr bx, 5 + and bx, 0x3f + or ax, word ptr [esi + ebx*8 + 2] + mov bx, dx + shr bx, 11 + and bx, 0x1f + or ax, word ptr [esi + ebx*8 + 4] + mov dx, ax + pop ax + add dx, ax + mov word ptr [edi], dx + add edi, 2 + sub ecx, 1 + jne repeating_pixel_565 + pop edx + pop esi + jmp draw_token_565 + draw_stream_565: + add ecx, 1 + stream_pixel_565: + mov eax, 0 + mov al, byte ptr [esi] + mov ax, word ptr [edx + eax*2] + push ecx + push edx + mov edx, srcFilter + mov ebx, 0 + mov bx, ax + and bx, 0x1f + mov cx, word ptr [edx + ebx*8] + mov bx, ax + shr bx, 5 + and bx, 0x3f + or cx, word ptr [edx + ebx*8 + 2] + mov bx, ax + shr bx, 11 + and bx, 0x1f + or cx, word ptr [edx + ebx*8 + 4] + mov dx, word ptr [edi] + mov eax, dstFilter + mov ebx, 0 + mov bx, dx + and bx, 0x1f + add cx, word ptr [eax + ebx*8] + mov bx, dx + shr bx, 5 + and bx, 0x3f + add cx, word ptr [eax + ebx*8 + 2] + mov bx, dx + shr bx, 11 + and bx, 0x1f + add cx, word ptr [eax + ebx*8 + 4] + mov word ptr [edi], cx + pop edx + pop ecx + add esi, 1 + add edi, 2 + sub ecx, 1 + jne stream_pixel_565 + jmp draw_token_565 + done_565: + } + // clang-format on + } else { + // Only the zoomed asm uses it (declared at the top it takes the line width's slot and loses the match) + int columnOffset; + // The zoomed-out loops skip odd columns: the parity first (after the heights loses the match) + int const startColumnParity = xPosition & 1; + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + blendStrengthUnk = 4056 * 2; + lineBytes = 4056 * 2; + heightStart = this->mapGameSurfaceHeightRange.start; + heightEnd = this->mapGameSurfaceHeightRange.end; + if (height + yPosition > heightEnd) { + height = heightEnd - yPosition; + if (height <= 0) { + return; + } + } + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + // clang-format off + __asm { + mov esi, imageAddress + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPosition + cmp eax, 0 + jl done_zoomed_555 + and eax, 0xfffffffe + add edi, eax + mov eax, yPosition + mov ebx, heightStart + cmp eax, ebx + jge add_y_offset_zoomed_555 + sub ebx, eax + mov eax, ebx + cmp height, eax + jle done_zoomed_555 + sub height, eax + skip_token_zoomed_555: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je skip_token_zoomed_555 + cmp bl, TT_STREAM_OF_PIXELS + je skip_stream_zoomed_555 + cmp bl, TT_REPEATING_PIXELS + je skip_repeating_zoomed_555 + jmp skip_newline_zoomed_555 + skip_stream_zoomed_555: + add ecx, 1 + add esi, ecx + jmp skip_token_zoomed_555 + skip_repeating_zoomed_555: + add esi, 1 + jmp skip_token_zoomed_555 + skip_newline_zoomed_555: + sub eax, 1 + cmp eax, 0 + jg skip_token_zoomed_555 + mov eax, heightStart + add_y_offset_zoomed_555: + mov edx, lineBytes + mov ecx, eax + shr eax, 1 + mul edx + add edi, eax + mov edx, colorPalette + draw_row_zoomed_555: + mov ebx, startColumnParity + mov columnOffset, ebx + push edi + draw_token_zoomed_555: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp al, TT_TRANSPARENT_PIXELS + je draw_transparent_zoomed_555 + cmp al, TT_STREAM_OF_PIXELS + je draw_stream_zoomed_555 + cmp al, TT_REPEATING_PIXELS + je draw_repeating_zoomed_555 + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jle done_zoomed_555 + skip_row_token_zoomed_555: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je skip_row_token_zoomed_555 + cmp bl, TT_STREAM_OF_PIXELS + je skip_row_stream_zoomed_555 + cmp bl, TT_REPEATING_PIXELS + je skip_row_repeating_zoomed_555 + jmp skip_row_done_zoomed_555 + skip_row_stream_zoomed_555: + add ecx, 1 + add esi, ecx + jmp skip_row_token_zoomed_555 + skip_row_repeating_zoomed_555: + add esi, 1 + jmp skip_row_token_zoomed_555 + skip_row_done_zoomed_555: + sub height, 1 + cmp height, 0 + jg draw_row_zoomed_555 + jmp done_zoomed_555 + draw_transparent_zoomed_555: + add ecx, 1 + add columnOffset, ecx + jmp draw_token_zoomed_555 + draw_repeating_zoomed_555: + mov ebx, 0 + mov eax, 0 + mov bl, byte ptr [esi] + mov ax, word ptr [edx + ebx*2] + add esi, 1 + push edx + mov edx, srcFilter + 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, 10 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x3ff + or ax, bx + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + repeating_pixel_zoomed_555: + test ebx, 1 + jne repeating_next_zoomed_555 + mov dx, word ptr [edi + ebx] + push ax + push ebx + mov eax, dstFilter + mov ebx, 0 + mov bx, dx + and bx, 0x1f + mov bx, word ptr [eax + ebx*8] + and dx, 0xffe0 + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0xfc1f + or dx, bx + mov bx, dx + shr bx, 10 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 0x83ff + or dx, bx + pop ebx + pop ax + add dx, ax + mov word ptr [edi + ebx], dx + repeating_next_zoomed_555: + add ebx, 1 + sub ecx, 1 + jne repeating_pixel_zoomed_555 + pop edx + jmp draw_token_zoomed_555 + draw_stream_zoomed_555: + mov eax, 0 + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + stream_pixel_zoomed_555: + test ebx, 1 + jne stream_next_zoomed_555 + push edx + push ebx + mov eax, 0 + mov al, byte ptr [esi] + mov ax, word ptr [edx + eax*2] + mov edx, srcFilter + 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, 10 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x3ff + or ax, bx + pop ebx + mov dx, word ptr [edi + ebx] + mov word ptr [edi + ebx], ax + mov eax, dstFilter + push ebx + mov ebx, 0 + mov bx, dx + and bx, 0x1f + mov bx, word ptr [eax + ebx*8] + and dx, 0xffe0 + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0xfc1f + or dx, bx + mov bx, dx + shr bx, 10 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 0x83ff + or dx, bx + pop ebx + add word ptr [edi + ebx], dx + pop edx + stream_next_zoomed_555: + add esi, 1 + add ebx, 1 + sub ecx, 1 + jne stream_pixel_zoomed_555 + jmp draw_token_zoomed_555 + done_zoomed_555: + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, imageAddress + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPosition + cmp eax, 0 + jl done_zoomed_565 + and eax, 0xfffffffe + add edi, eax + mov eax, yPosition + mov ebx, heightStart + cmp eax, ebx + jge add_y_offset_zoomed_565 + sub ebx, eax + mov eax, ebx + cmp height, eax + jle done_zoomed_565 + sub height, eax + skip_token_zoomed_565: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je skip_token_zoomed_565 + cmp bl, TT_STREAM_OF_PIXELS + je skip_stream_zoomed_565 + cmp bl, TT_REPEATING_PIXELS + je skip_repeating_zoomed_565 + jmp skip_newline_zoomed_565 + skip_stream_zoomed_565: + add ecx, 1 + add esi, ecx + jmp skip_token_zoomed_565 + skip_repeating_zoomed_565: + add esi, 1 + jmp skip_token_zoomed_565 + skip_newline_zoomed_565: + sub eax, 1 + cmp eax, 0 + jg skip_token_zoomed_565 + mov eax, heightStart + add_y_offset_zoomed_565: + mov edx, lineBytes + mov ecx, eax + shr eax, 1 + mul edx + add edi, eax + mov edx, colorPalette + draw_row_zoomed_565: + mov ebx, startColumnParity + mov columnOffset, ebx + push edi + draw_token_zoomed_565: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp al, TT_TRANSPARENT_PIXELS + je draw_transparent_zoomed_565 + cmp al, TT_STREAM_OF_PIXELS + je draw_stream_zoomed_565 + cmp al, TT_REPEATING_PIXELS + je draw_repeating_zoomed_565 + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jle done_zoomed_565 + skip_row_token_zoomed_565: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je skip_row_token_zoomed_565 + cmp bl, TT_STREAM_OF_PIXELS + je skip_row_stream_zoomed_565 + cmp bl, TT_REPEATING_PIXELS + je skip_row_repeating_zoomed_565 + jmp skip_row_done_zoomed_565 + skip_row_stream_zoomed_565: + add ecx, 1 + add esi, ecx + jmp skip_row_token_zoomed_565 + skip_row_repeating_zoomed_565: + add esi, 1 + jmp skip_row_token_zoomed_565 + skip_row_done_zoomed_565: + sub height, 1 + cmp height, 0 + jg draw_row_zoomed_565 + jmp done_zoomed_565 + draw_transparent_zoomed_565: + add ecx, 1 + add columnOffset, ecx + jmp draw_token_zoomed_565 + draw_repeating_zoomed_565: + mov ebx, 0 + mov eax, 0 + mov bl, byte ptr [esi] + mov ax, word ptr [edx + ebx*2] + add esi, 1 + push edx + mov edx, srcFilter + 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, 11 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x7ff + or ax, bx + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + repeating_pixel_zoomed_565: + test ebx, 1 + jne repeating_next_zoomed_565 + mov dx, word ptr [edi + ebx] + push ax + push ebx + mov eax, dstFilter + mov ebx, 0 + mov bx, dx + and bx, 0x1f + mov bx, word ptr [eax + ebx*8] + and dx, 0xffe0 + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 0x3f + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0xf81f + or dx, bx + mov bx, dx + shr bx, 11 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 0x7ff + or dx, bx + pop ebx + pop ax + add dx, ax + mov word ptr [edi + ebx], dx + repeating_next_zoomed_565: + add ebx, 1 + sub ecx, 1 + jne repeating_pixel_zoomed_565 + pop edx + jmp draw_token_zoomed_565 + draw_stream_zoomed_565: + mov eax, 0 + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + stream_pixel_zoomed_565: + test ebx, 1 + jne stream_next_zoomed_565 + push edx + push ebx + mov eax, 0 + mov al, byte ptr [esi] + mov ax, word ptr [edx + eax*2] + mov edx, srcFilter + 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, 11 + and bx, 0x1f + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 0x7ff + or ax, bx + pop ebx + mov dx, word ptr [edi + ebx] + mov word ptr [edi + ebx], ax + mov eax, dstFilter + push ebx + mov ebx, 0 + mov bx, dx + and bx, 0x1f + mov bx, word ptr [eax + ebx*8] + and dx, 0xffe0 + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 0x3f + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0xf81f + or dx, bx + mov bx, dx + shr bx, 11 + and bx, 0x1f + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 0x7ff + or dx, bx + pop ebx + add word ptr [edi + ebx], dx + pop edx + stream_next_zoomed_565: + add esi, 1 + add ebx, 1 + sub ecx, 1 + jne stream_pixel_zoomed_565 + jmp draw_token_zoomed_565 + done_zoomed_565: + } + // clang-format on + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e8a6864d03..562f4f05ba 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16963,7 +16963,7 @@ SHC_3BB0A8C1_0x0044F850 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0044FBF0 | 0.0% | Pending -SHC_3BB0A8C1_0x00451E00 | 0.0% | Pending +SHC_3BB0A8C1_0x00451E00 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00452900 | 100.0% | Reimplemented