From 0c8b764ac588a73a560b29602857735cf62e5917 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 10 Nov 2026 06:24:02 +0100 Subject: [PATCH 1/5] cmake: /GL for renderGmWithPreparedAlphaMask, renderInterfaceOrBuildingOccupationArea and InitBlendFilterArraysUnk Both functions (0x0044F170, 0x0044E630) load height into edi once and still use it after the InitBlendFilterArraysUnk call (lea edx, [ecx + edi] at 0x0044F205; lea ecx, [eax + edi] at 0x0044E6CC), so the original compiler knew that call leaves height alone. Here height is named in the functions' asm blocks, so without that knowledge MSVC reads it from memory again after the call; by quick_diff that is the only difference in the C++ part. With InitBlendFilterArraysUnk's definition compiled into the same file (a local test that includes it) both match instruction for instruction; /GL on all three files gives the compiler that view across files, as for the other caller and callee pairs in this list. The lines sit next to the other UI/Rendering entries. Co-Authored-By: Claude Opus 5.5 --- cmake/compiler-flags-gl.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 89537a3a92..650a761a7a 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -113,6 +113,9 @@ src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemActionHandler_BuildMenu_UnitActionBut src/OpenSHC/UI/Rendering/RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk.cpp 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/InitBlendFilterArraysUnk.cpp src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_DrawbridgeOpenClose.cpp src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_GatehouseOpenClose.cpp src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_WorkshopWeaponSelection.cpp From 70fd7411bbd3d5c12c2eefa3255e82158eed6240 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 10 Nov 2026 06:24:23 +0100 Subject: [PATCH 2/5] reimplement: SHC_3BB0A8C1_0x0044F170 100.0% Reimplemented renderGmWithPreparedAlphaMask draws a TGX image through the alpha surface prepared earlier: per pixel, the mask's blue channel less blendStrength leaves the destination alone at or below zero, copies the source at 31 and blends the two through DAT_BlendFilterArrays in between, in one handwritten asm loop per colour mode. From gynt's draft (3ea443811 on reimpl/TextureRenderCore, 93.2% there; his later 3d17527d6 on this file is an arm swap on the earlier decompiled version, not on this one). Needs the cmake commit that puts this file and InitBlendFilterArraysUnk.cpp under /GL: the original keeps height in edi across that call, which MSVC only does when it can see the callee. Also: the asm reads the render surface from the global, main's parameter names, lineJump / lineBytes / heightStart / heightEnd as in renderTgxWithColorUnk, 4056 for the map surface's width, maskPtr as the alpha surface's own ushort*, the token compares with the TgxToken names and descriptive labels as in the other TGX asm blocks on main. With InitBlendFilterArraysUnk compiled into the same file and the ebp-frame slots resolved, quick_diff is 1.0000 (442 instructions each side). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../renderGmWithPreparedAlphaMask.cpp | 493 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 494 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp new file mode 100644 index 0000000000..9053a7a64c --- /dev/null +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp @@ -0,0 +1,493 @@ +#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/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_BlendFilterArrays.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 two drawing loops are handwritten assembly in the original, transcribed here from the binary. + + // FUNCTION: STRONGHOLDCRUSADER 0x0044F170 + void TextureRenderCore::renderGmWithPreparedAlphaMask( + int x, int y, int width, int height, ushort* imageDataPtr, int blendStrength) + { + // Declared before the if because both arms assign them; lineJump is from one row's end to the next + int lineJump; + int lineBytes; + int heightStart; + int heightEnd; + // The alpha surface prepared earlier, walked in step with the destination + ushort* maskPtr = AlphaAndButtonSurfaceObj::instance.surfacePtr; + if (height <= 0) { + return; + } + // The last filter entry is still zero until the filter arrays are built. The original keeps height in edi + // across this call, which takes /GL on this file and InitBlendFilterArraysUnk.cpp + if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::InitBlendFilterArraysUnk)(); + } + // Both start at the table's base: the asm adds the row for the alpha value to each + short* const dstFilter = DAT_BlendFilterArrays::instance[0][0]; + short* const srcFilter = DAT_BlendFilterArrays::instance[0][0]; + 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 + lineJump = (4056 - width) * 2; + heightStart = this->mapGameSurfaceHeightRange.start; + heightEnd = this->mapGameSurfaceHeightRange.end; + lineBytes = 4056 * 2; + } else { + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_screenMenu; + lineJump = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine - width * 2; + lineBytes = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; + heightStart = this->screenMenuSurfaceHeightRange.start; + heightEnd = this->screenMenuSurfaceHeightRange.end; + } + if (height + y > heightEnd) { + height = heightEnd - y; + if (height <= 0) { + return; + } + } + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + // clang-format off + __asm { + mov esi, imageDataPtr + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, x + cmp eax, 0 + jl done_555 + add eax, eax + add edi, eax + mov eax, y + 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 bl, byte ptr [esi] + movzx ecx, bl + 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 ecx, ecx + add esi, ecx + jmp skip_token_555 + skip_repeating_555: + add esi, 2 + jmp skip_token_555 + skip_newline_555: + mov ebx, width + add maskPtr, ebx + add maskPtr, ebx + sub eax, 1 + jg skip_token_555 + mov eax, heightStart + add_y_offset_555: + mov edx, lineBytes + mul edx + add edi, eax + mov edx, height + draw_token_555: + mov al, byte ptr [esi] + movzx ecx, al + 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 + add edi, lineJump + sub edx, 1 + jg draw_token_555 + jmp done_555 + draw_transparent_555: + add ecx, 1 + add ecx, ecx + add edi, ecx + add maskPtr, ecx + jmp draw_token_555 + draw_repeating_555: + xor eax, eax + add ecx, 1 + push edx + repeating_pixel_555: + xor edx, edx + mov eax, maskPtr + add maskPtr, 2 + mov dx, word ptr [eax] + and edx, 1Fh + sub edx, blendStrength + jle repeating_next_555 + cmp edx, 1Fh + jne repeating_blend_555 + mov ax, word ptr [esi] + mov word ptr [edi], ax + jmp repeating_next_555 + repeating_blend_555: + push edx + shl edx, 9 + add edx, srcFilter + mov ax, word ptr [esi] + movzx ebx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0FC1Fh + or ax, bx + mov bx, ax + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 3FFh + or ax, bx + pop edx + push ax + mov eax, 20h + sub eax, edx + shl eax, 9 + add eax, dstFilter + mov dx, word ptr [edi] + movzx ebx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0FC1Fh + or dx, bx + mov bx, dx + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 83FFh + or dx, bx + pop ax + add dx, ax + mov word ptr [edi], dx + repeating_next_555: + add edi, 2 + sub ecx, 1 + jne repeating_pixel_555 + pop edx + add esi, 2 + jmp draw_token_555 + draw_stream_555: + add ecx, 1 + push edx + xor ebx, ebx + stream_pixel_555: + xor edx, edx + mov eax, maskPtr + add maskPtr, 2 + mov dx, word ptr [eax] + and edx, 1Fh + sub edx, blendStrength + jle stream_next_555 + cmp edx, 1Fh + jne stream_blend_555 + mov ax, word ptr [esi] + mov word ptr [edi], ax + jmp stream_next_555 + stream_blend_555: + push edx + shl edx, 9 + add edx, srcFilter + mov ax, word ptr [esi] + mov bx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0FC1Fh + or ax, bx + mov bx, ax + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 3FFh + or ax, bx + mov bx, word ptr [edi] + mov word ptr [edi], ax + pop edx + mov eax, 20h + sub eax, edx + shl eax, 9 + add eax, dstFilter + mov dx, bx + movzx ebx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0FC1Fh + or dx, bx + mov bx, dx + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 83FFh + or dx, bx + add word ptr [edi], dx + stream_next_555: + add esi, 2 + add edi, 2 + sub ecx, 1 + jne stream_pixel_555 + pop edx + jmp draw_token_555 + done_555: + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, imageDataPtr + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, x + cmp eax, 0 + jl done_565 + add eax, eax + add edi, eax + mov eax, y + 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 bl, byte ptr [esi] + movzx ecx, bl + 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 ecx, ecx + add esi, ecx + jmp skip_token_565 + skip_repeating_565: + add esi, 2 + jmp skip_token_565 + skip_newline_565: + mov ebx, width + add maskPtr, ebx + add maskPtr, ebx + sub eax, 1 + jg skip_token_565 + mov eax, heightStart + add_y_offset_565: + mov edx, lineBytes + mul edx + add edi, eax + mov edx, height + draw_token_565: + mov al, byte ptr [esi] + movzx ecx, al + 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 + add edi, lineJump + sub edx, 1 + jg draw_token_565 + jmp done_565 + draw_transparent_565: + add ecx, 1 + add ecx, ecx + add edi, ecx + add maskPtr, ecx + jmp draw_token_565 + draw_repeating_565: + xor eax, eax + add ecx, 1 + push edx + repeating_pixel_565: + xor edx, edx + mov eax, maskPtr + add maskPtr, 2 + mov dx, word ptr [eax] + and edx, 1Fh + sub edx, blendStrength + jle repeating_next_565 + cmp edx, 1Fh + jne repeating_blend_565 + mov ax, word ptr [esi] + mov word ptr [edi], ax + jmp repeating_next_565 + repeating_blend_565: + push cx + push edx + shl edx, 9 + add edx, srcFilter + mov ax, word ptr [esi] + movzx ebx, ax + and bx, 1Fh + mov cx, word ptr [edx + ebx*8] + mov bx, ax + shr bx, 5 + and bx, 3Fh + or cx, word ptr [edx + ebx*8 + 2] + mov bx, ax + shr bx, 0Bh + and bx, 1Fh + or cx, word ptr [edx + ebx*8 + 4] + pop edx + mov eax, 20h + sub eax, edx + shl eax, 9 + add eax, dstFilter + mov dx, word ptr [edi] + movzx ebx, dx + and bx, 1Fh + add cx, word ptr [eax + ebx*8] + mov bx, dx + shr bx, 5 + and bx, 3Fh + add cx, word ptr [eax + ebx*8 + 2] + mov bx, dx + shr bx, 0Bh + and bx, 1Fh + add cx, word ptr [eax + ebx*8 + 4] + mov word ptr [edi], cx + pop cx + repeating_next_565: + add edi, 2 + sub ecx, 1 + jne repeating_pixel_565 + pop edx + add esi, 2 + jmp draw_token_565 + draw_stream_565: + add ecx, 1 + push edx + xor ebx, ebx + stream_pixel_565: + xor edx, edx + mov eax, maskPtr + add maskPtr, 2 + mov dx, word ptr [eax] + and edx, 1Fh + sub edx, blendStrength + jle stream_next_565 + cmp edx, 1Fh + jne stream_blend_565 + mov ax, word ptr [esi] + mov word ptr [edi], ax + jmp stream_next_565 + stream_blend_565: + push cx + push edx + shl edx, 9 + add edx, srcFilter + mov ax, word ptr [esi] + mov bx, ax + and bx, 1Fh + mov cx, word ptr [edx + ebx*8] + mov bx, ax + shr bx, 5 + and bx, 3Fh + or cx, word ptr [edx + ebx*8 + 2] + mov bx, ax + shr bx, 0Bh + and bx, 1Fh + or cx, word ptr [edx + ebx*8 + 4] + movzx bx, word ptr [edi] + pop edx + mov eax, 20h + sub eax, edx + shl eax, 9 + add eax, dstFilter + mov dx, bx + and bx, 1Fh + add cx, word ptr [eax + ebx*8] + mov bx, dx + shr bx, 5 + and bx, 3Fh + add cx, word ptr [eax + ebx*8 + 2] + mov bx, dx + shr bx, 0Bh + and bx, 1Fh + add cx, word ptr [eax + ebx*8 + 4] + mov word ptr [edi], cx + pop cx + stream_next_565: + add esi, 2 + add edi, 2 + sub ecx, 1 + jne stream_pixel_565 + pop edx + jmp draw_token_565 + done_565: + } + // clang-format on + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ae4d052731..93dd9dea0c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16955,7 +16955,7 @@ SHC_3BB0A8C1_0x0044E630 | 0.0% | Pending SHC_3BB0A8C1_0x0044F020 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0044F170 | 0.0% | Pending +SHC_3BB0A8C1_0x0044F170 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0044F6F0 | 100.0% | Reimplemented From 485df4aae4b891cac191de408dcc196a66d6ad07 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 10 Nov 2026 06:24:35 +0100 Subject: [PATCH 3/5] reimplement: SHC_3BB0A8C1_0x0044E630 100.0% Reimplemented renderInterfaceOrBuildingOccupationArea blends a TGX image over the destination through the pair of DAT_BlendFilterArrays rows that blendStrengthUnk picks, in four handwritten asm loops (RGB555 and RGB565, each for the normal and the zoomed-out surface, which keeps only every second row and column). From gynt's draft (ac42b3069 on reimpl/TextureRenderCore, 92.8% there, "two stack slots swapped"; his newer 3d17527d6 on this file is an arm swap on the earlier decompiled version, not on this one). Needs the cmake commit that puts this file and InitBlendFilterArraysUnk.cpp under /GL: the original keeps height in edi across that call. Also: the asm reads the render surface from the global, the destination filter row computed before the source row (the other order swaps ecx and edx), main's parameter names, lineJump / lineBytes / heightStart / heightEnd as in renderTgxWithColorUnk (gynt's draft kept the line jump and the line bytes in width and blendStrengthUnk; as locals MSVC gives them those parameters' slots, so the code is the same), the token compares with the TgxToken names and descriptive labels as in the other TGX asm blocks on main. The two swapped slots: columnOffset is used only by the zoomed-out loops and is declared in that branch, now an else; declared at function scope it takes [ebp - 4] and pushes heightStart to [ebp - 8], the other way round from the original (declaration order, names and extra references did not move them). With InitBlendFilterArraysUnk compiled into the same file and the ebp-frame slots resolved, quick_diff goes 0.9702 -> 1.0000 (805 instructions each side). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...enderInterfaceOrBuildingOccupationArea.cpp | 876 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 877 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp new file mode 100644 index 0000000000..9fd3bbe87c --- /dev/null +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp @@ -0,0 +1,876 @@ +#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_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 0x0044E630 + void TextureRenderCore::renderInterfaceOrBuildingOccupationArea( + int x, int y, int width, int height, ushort* imageDataPtr, int blendStrengthUnk) + { + // Declared before the if because all three arms assign them; lineJump is from one row's end to the next + int lineJump; + int lineBytes; + int heightStart; + int heightEnd; + if (height <= 0) { + return; + } + // The last filter entry is still zero until the filter arrays are built. The original keeps height in edi + // across this call, which takes /GL on this file and InitBlendFilterArraysUnk.cpp + if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::InitBlendFilterArraysUnk)(); + } + short* const dstFilter = DAT_BlendFilterArrays::instance[blendStrengthUnk][0]; + short* const srcFilter = DAT_BlendFilterArrays::instance[32 - blendStrengthUnk][0]; + 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 + lineJump = (4056 - width) * 2; + heightStart = this->mapGameSurfaceHeightRange.start; + heightEnd = this->mapGameSurfaceHeightRange.end; + lineBytes = 4056 * 2; + } else { + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_screenMenu; + lineJump = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine - width * 2; + heightStart = this->screenMenuSurfaceHeightRange.start; + heightEnd = this->screenMenuSurfaceHeightRange.end; + lineBytes = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; + } + if (height + y > heightEnd) { + height = heightEnd - y; + if (height <= 0) { + return; + } + } + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + // clang-format off + __asm { + mov esi, imageDataPtr + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, x + cmp eax, 0 + jl done_555 + add eax, eax + add edi, eax + mov eax, y + 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 bl, byte ptr [esi] + movzx ecx, 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 ecx, ecx + add esi, ecx + jmp skip_token_555 + skip_repeating_555: + add esi, 2 + 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, height + 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 + add edi, lineJump + sub edx, 1 + cmp edx, 0 + jg draw_token_555 + jmp done_555 + draw_transparent_555: + add ecx, 1 + add ecx, ecx + add edi, ecx + jmp draw_token_555 + draw_repeating_555: + mov eax, 0 + mov ax, word ptr [esi] + add esi, 2 + add ecx, 1 + push edx + mov edx, srcFilter + mov ebx, 0 + mov bx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0FC1Fh + or ax, bx + mov bx, ax + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 3FFh + or ax, bx + repeating_pixel_555: + mov dx, word ptr [edi] + push ax + mov eax, dstFilter + mov ebx, 0 + mov bx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0FC1Fh + or dx, bx + mov bx, dx + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 83FFh + 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: + add ecx, 1 + push edx + mov ebx, 0 + stream_pixel_555: + mov ax, word ptr [esi] + mov edx, srcFilter + mov bx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0FC1Fh + or ax, bx + mov bx, ax + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 3FFh + or ax, bx + mov dx, word ptr [edi] + mov word ptr [edi], ax + mov eax, dstFilter + mov ebx, 0 + mov bx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0FC1Fh + or dx, bx + mov bx, dx + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 83FFh + or dx, bx + add word ptr [edi], dx + add esi, 2 + add edi, 2 + sub ecx, 1 + jne stream_pixel_555 + pop edx + jmp draw_token_555 + done_555: + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, imageDataPtr + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, x + cmp eax, 0 + jl done_565 + add eax, eax + add edi, eax + mov eax, y + 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 bl, byte ptr [esi] + movzx ecx, bl + 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 ecx, ecx + add esi, ecx + jmp skip_token_565 + skip_repeating_565: + add esi, 2 + jmp skip_token_565 + skip_newline_565: + sub eax, 1 + jg skip_token_565 + mov eax, heightStart + add_y_offset_565: + mov edx, lineBytes + mul edx + add edi, eax + mov edx, height + draw_token_565: + mov al, byte ptr [esi] + movzx ecx, al + 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 + add edi, lineJump + sub edx, 1 + jg draw_token_565 + jmp done_565 + draw_transparent_565: + add ecx, 1 + add ecx, ecx + add edi, ecx + jmp draw_token_565 + draw_repeating_565: + movzx eax, word ptr [esi] + add esi, 2 + push esi + add ecx, 1 + push edx + mov esi, srcFilter + movzx ebx, ax + and bx, 1Fh + mov dx, word ptr [esi + ebx*8] + mov bx, ax + shr bx, 5 + and bx, 3Fh + or dx, word ptr [esi + ebx*8 + 2] + mov bx, ax + shr bx, 0Bh + and bx, 1Fh + or dx, word ptr [esi + ebx*8 + 4] + mov ax, dx + mov esi, dstFilter + repeating_pixel_565: + mov dx, word ptr [edi] + push ax + movzx ebx, dx + and bx, 1Fh + mov ax, word ptr [esi + ebx*8] + mov bx, dx + shr bx, 5 + and bx, 3Fh + or ax, word ptr [esi + ebx*8 + 2] + mov bx, dx + shr bx, 0Bh + and bx, 1Fh + 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 + push edx + xor ebx, ebx + stream_pixel_565: + mov ax, word ptr [esi] + mov edx, srcFilter + push cx + mov bx, ax + and bx, 1Fh + mov cx, word ptr [edx + ebx*8] + mov bx, ax + shr bx, 5 + and bx, 3Fh + or cx, word ptr [edx + ebx*8 + 2] + mov bx, ax + shr bx, 0Bh + and bx, 1Fh + or cx, word ptr [edx + ebx*8 + 4] + mov dx, word ptr [edi] + mov eax, dstFilter + movzx ebx, dx + and bx, 1Fh + add cx, word ptr [eax + ebx*8] + mov bx, dx + shr bx, 5 + and bx, 3Fh + add cx, word ptr [eax + ebx*8 + 2] + mov bx, dx + shr bx, 0Bh + and bx, 1Fh + add cx, word ptr [eax + ebx*8 + 4] + mov word ptr [edi], cx + add esi, 2 + add edi, 2 + pop cx + sub ecx, 1 + jne stream_pixel_565 + pop edx + jmp draw_token_565 + done_565: + } + // clang-format on + } else { + // Declared in this branch (at function scope: quick_diff 1.0000 -> 0.9702) + int columnOffset; + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + lineJump = 4056 * 2; + lineBytes = 4056 * 2; + heightStart = this->mapGameSurfaceHeightRange.start; + heightEnd = this->mapGameSurfaceHeightRange.end; + if (height + y > heightEnd) { + height = heightEnd - y; + if (height <= 0) { + return; + } + } + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + // clang-format off + __asm { + mov esi, imageDataPtr + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, x + cmp eax, 0 + jl zoom_done_555 + and eax, 0FFFFFFFEh + add edi, eax + mov eax, y + mov ebx, heightStart + cmp eax, ebx + jge zoom_add_y_offset_555 + sub ebx, eax + mov eax, ebx + cmp height, eax + jle zoom_done_555 + sub height, eax + zoom_skip_token_555: + mov bl, byte ptr [esi] + movzx ecx, bl + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je zoom_skip_token_555 + cmp bl, TT_STREAM_OF_PIXELS + je zoom_skip_stream_555 + cmp bl, TT_REPEATING_PIXELS + je zoom_skip_repeating_555 + jmp zoom_skip_newline_555 + zoom_skip_stream_555: + add ecx, 1 + add ecx, ecx + add esi, ecx + jmp zoom_skip_token_555 + zoom_skip_repeating_555: + add esi, 2 + jmp zoom_skip_token_555 + zoom_skip_newline_555: + sub eax, 1 + jg zoom_skip_token_555 + mov eax, heightStart + zoom_add_y_offset_555: + mov edx, lineBytes + mov ecx, eax + shr eax, 1 + mul edx + add edi, eax + xor eax, eax + xor ebx, ebx + mov columnOffset, ebx + mov edx, height + zoom_draw_token_555: + mov al, byte ptr [esi] + movzx ecx, al + and al, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp al, TT_TRANSPARENT_PIXELS + je zoom_draw_transparent_555 + cmp al, TT_STREAM_OF_PIXELS + je zoom_draw_stream_555 + cmp al, TT_REPEATING_PIXELS + je zoom_draw_repeating_555 + add edi, lineJump + sub edx, 1 + jle zoom_done_555 + zoom_skip_row_token_555: + mov bl, byte ptr [esi] + movzx ecx, bl + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je zoom_skip_row_token_555 + cmp bl, TT_STREAM_OF_PIXELS + je zoom_skip_row_stream_555 + cmp bl, TT_REPEATING_PIXELS + je zoom_skip_row_repeating_555 + jmp zoom_row_skipped_555 + zoom_skip_row_stream_555: + add ecx, 1 + add ecx, ecx + add esi, ecx + jmp zoom_skip_row_token_555 + zoom_skip_row_repeating_555: + add esi, 2 + jmp zoom_skip_row_token_555 + zoom_row_skipped_555: + xor eax, eax + xor ebx, ebx + mov columnOffset, ebx + sub edx, 1 + jg zoom_draw_token_555 + jmp zoom_done_555 + zoom_draw_transparent_555: + add ecx, 1 + add columnOffset, ecx + jmp zoom_draw_token_555 + zoom_draw_repeating_555: + movzx eax, word ptr [esi] + add esi, 2 + push edx + mov edx, srcFilter + movzx ebx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0FC1Fh + or ax, bx + mov bx, ax + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 3FFh + or ax, bx + pop edx + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + zoom_repeating_pixel_555: + test ebx, 1 + jne zoom_repeating_next_555 + push edx + push ebx + mov dx, word ptr [edi + ebx] + push ax + mov eax, dstFilter + movzx ebx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0FC1Fh + or dx, bx + mov bx, dx + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 83FFh + or dx, bx + pop ax + add dx, ax + pop ebx + mov word ptr [edi + ebx], dx + pop edx + zoom_repeating_next_555: + add ebx, 1 + sub ecx, 1 + jne zoom_repeating_pixel_555 + jmp zoom_draw_token_555 + zoom_draw_stream_555: + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + zoom_stream_pixel_555: + test ebx, 1 + jne zoom_stream_next_555 + push edx + push ebx + mov ax, word ptr [esi] + mov edx, srcFilter + mov bx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0FC1Fh + or ax, bx + mov bx, ax + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 3FFh + or ax, bx + pop ebx + mov dx, word ptr [edi + ebx] + mov word ptr [edi + ebx], ax + push ebx + mov eax, dstFilter + movzx ebx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0FC1Fh + or dx, bx + mov bx, dx + shr bx, 0Ah + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 83FFh + or dx, bx + pop ebx + add word ptr [edi + ebx], dx + pop edx + zoom_stream_next_555: + add ebx, 1 + add esi, 2 + sub ecx, 1 + jne zoom_stream_pixel_555 + jmp zoom_draw_token_555 + zoom_done_555: + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, imageDataPtr + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, x + cmp eax, 0 + jl zoom_done_565 + and eax, 0FFFFFFFEh + add edi, eax + mov eax, y + mov ebx, heightStart + cmp eax, ebx + jge zoom_add_y_offset_565 + sub ebx, eax + mov eax, ebx + cmp height, eax + jle zoom_done_565 + sub height, eax + zoom_skip_token_565: + mov bl, byte ptr [esi] + movzx ecx, bl + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je zoom_skip_token_565 + cmp bl, TT_STREAM_OF_PIXELS + je zoom_skip_stream_565 + cmp bl, TT_REPEATING_PIXELS + je zoom_skip_repeating_565 + jmp zoom_skip_newline_565 + zoom_skip_stream_565: + add ecx, 1 + add ecx, ecx + add esi, ecx + jmp zoom_skip_token_565 + zoom_skip_repeating_565: + add esi, 2 + jmp zoom_skip_token_565 + zoom_skip_newline_565: + sub eax, 1 + jg zoom_skip_token_565 + mov eax, heightStart + zoom_add_y_offset_565: + mov edx, lineBytes + mov ecx, eax + shr eax, 1 + mul edx + add edi, eax + xor eax, eax + xor ebx, ebx + mov columnOffset, ebx + mov edx, height + zoom_draw_token_565: + mov al, byte ptr [esi] + movzx ecx, al + and al, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp al, TT_TRANSPARENT_PIXELS + je zoom_draw_transparent_565 + cmp al, TT_STREAM_OF_PIXELS + je zoom_draw_stream_565 + cmp al, TT_REPEATING_PIXELS + je zoom_draw_repeating_565 + add edi, lineJump + sub edx, 1 + jle zoom_done_565 + zoom_skip_row_token_565: + mov bl, byte ptr [esi] + movzx ecx, bl + and bl, TT_TGX_PIXEL_HEADER + and cl, TT_TGX_PIXEL_LENGTH + add esi, 1 + cmp bl, TT_TRANSPARENT_PIXELS + je zoom_skip_row_token_565 + cmp bl, TT_STREAM_OF_PIXELS + je zoom_skip_row_stream_565 + cmp bl, TT_REPEATING_PIXELS + je zoom_skip_row_repeating_565 + jmp zoom_row_skipped_565 + zoom_skip_row_stream_565: + add ecx, 1 + add ecx, ecx + add esi, ecx + jmp zoom_skip_row_token_565 + zoom_skip_row_repeating_565: + add esi, 2 + jmp zoom_skip_row_token_565 + zoom_row_skipped_565: + xor eax, eax + xor ebx, ebx + mov columnOffset, ebx + sub edx, 1 + jg zoom_draw_token_565 + jmp zoom_done_565 + zoom_draw_transparent_565: + add ecx, 1 + add columnOffset, ecx + jmp zoom_draw_token_565 + zoom_draw_repeating_565: + movzx eax, word ptr [esi] + add esi, 2 + push edx + mov edx, srcFilter + movzx ebx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 3Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0F81Fh + or ax, bx + mov bx, ax + shr bx, 0Bh + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 7FFh + or ax, bx + pop edx + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + zoom_repeating_pixel_565: + test ebx, 1 + jne zoom_repeating_next_565 + push edx + push ebx + mov dx, word ptr [edi + ebx] + push ax + mov eax, dstFilter + movzx ebx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 3Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0F81Fh + or dx, bx + mov bx, dx + shr bx, 0Bh + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 7FFh + or dx, bx + pop ax + add dx, ax + pop ebx + mov word ptr [edi + ebx], dx + pop edx + zoom_repeating_next_565: + add ebx, 1 + sub ecx, 1 + jne zoom_repeating_pixel_565 + jmp zoom_draw_token_565 + zoom_draw_stream_565: + add ecx, 1 + mov ebx, columnOffset + add columnOffset, ecx + zoom_stream_pixel_565: + test ebx, 1 + jne zoom_stream_next_565 + push edx + push ebx + mov ax, word ptr [esi] + mov edx, srcFilter + mov bx, ax + and bx, 1Fh + mov bx, word ptr [edx + ebx*8] + and ax, 0FFE0h + or ax, bx + mov bx, ax + shr bx, 5 + and bx, 3Fh + mov bx, word ptr [edx + ebx*8 + 2] + and ax, 0F81Fh + or ax, bx + mov bx, ax + shr bx, 0Bh + and bx, 1Fh + mov bx, word ptr [edx + ebx*8 + 4] + and ax, 7FFh + or ax, bx + pop ebx + mov dx, word ptr [edi + ebx] + mov word ptr [edi + ebx], ax + push ebx + mov eax, dstFilter + movzx ebx, dx + and bx, 1Fh + mov bx, word ptr [eax + ebx*8] + and dx, 0FFE0h + or dx, bx + mov bx, dx + shr bx, 5 + and bx, 3Fh + mov bx, word ptr [eax + ebx*8 + 2] + and dx, 0F81Fh + or dx, bx + mov bx, dx + shr bx, 0Bh + and bx, 1Fh + mov bx, word ptr [eax + ebx*8 + 4] + and dx, 7FFh + or dx, bx + pop ebx + add word ptr [edi + ebx], dx + pop edx + zoom_stream_next_565: + add ebx, 1 + add esi, 2 + sub ecx, 1 + jne zoom_stream_pixel_565 + jmp zoom_draw_token_565 + zoom_done_565: + } + // clang-format on + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 93dd9dea0c..a1c219ccf9 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16951,7 +16951,7 @@ SHC_3BB0A8C1_0x0044D3D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0044E510 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0044E630 | 0.0% | Pending +SHC_3BB0A8C1_0x0044E630 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0044F020 | 100.0% | Reimplemented From 49802328c1325fb95b794ba96664e570dc0dd063 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 10 Nov 2026 07:15:03 +0100 Subject: [PATCH 4/5] style: drop the register note at the InitBlendFilterArraysUnk calls The comment above each InitBlendFilterArraysUnk call in renderGmWithPreparedAlphaMask and renderInterfaceOrBuildingOccupationArea also said that the original keeps height in edi across the call, which needs /GL on these files and the callee. That is a finding about the build, not about the code, so it moves to the PR description; the line on why the call is there stays. quick_diff output is identical for both files, plain and with the callee in the same TU (1.0000 there). The full /GL build of the commit before reads both at 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../TextureRenderCore/renderGmWithPreparedAlphaMask.cpp | 3 +-- .../renderInterfaceOrBuildingOccupationArea.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp index 9053a7a64c..c463a2251a 100644 --- a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp @@ -36,8 +36,7 @@ namespace UI { if (height <= 0) { return; } - // The last filter entry is still zero until the filter arrays are built. The original keeps height in edi - // across this call, which takes /GL on this file and InitBlendFilterArraysUnk.cpp + // 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)(); } diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp index 9fd3bbe87c..aadfcb6c12 100644 --- a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp @@ -33,8 +33,7 @@ namespace UI { if (height <= 0) { return; } - // The last filter entry is still zero until the filter arrays are built. The original keeps height in edi - // across this call, which takes /GL on this file and InitBlendFilterArraysUnk.cpp + // 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)(); } From ef8deed6b38bf5a179e59927d4eef60972fd774a Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 10 Nov 2026 07:48:57 +0100 Subject: [PATCH 5/5] style: main's number style in the asm, and the comments the review asked for The asm writes masks as lowercase 0x numbers, and shift counts and plain values (32, 31) in decimal, as main's TGX asm blocks do; none of them uses the MASM h suffix. Each body gets a one-line summary, and the shapes the review asked about get main's measured comment: - the map arm first (with the arms swapped: 0.8258 -> 0.8077 and 0.8270 -> 0.8228); - maskPtr read before the height test (after it: 0.8235); - two filter pointers in renderGmWithPreparedAlphaMask (one for both: 0.8231). The zoomed-out arm says why its lineJump is a whole row, and columnOffset says that only the asm writes it. quick_diff output is identical for both files, with -s. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../renderGmWithPreparedAlphaMask.cpp | 118 +++++----- ...enderInterfaceOrBuildingOccupationArea.cpp | 209 +++++++++--------- 2 files changed, 166 insertions(+), 161 deletions(-) diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp index c463a2251a..8f54785cc3 100644 --- a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderGmWithPreparedAlphaMask.cpp @@ -26,12 +26,13 @@ namespace UI { void TextureRenderCore::renderGmWithPreparedAlphaMask( int x, int y, int width, int height, ushort* imageDataPtr, int blendStrength) { + // Draws the TGX image through the alpha mask: its blue channel less blendStrength sets each pixel's blend // Declared before the if because both arms assign them; lineJump is from one row's end to the next int lineJump; int lineBytes; int heightStart; int heightEnd; - // The alpha surface prepared earlier, walked in step with the destination + // The alpha mask, walked with the destination (read after the test: quick_diff 0.8258 -> 0.8235) ushort* maskPtr = AlphaAndButtonSurfaceObj::instance.surfacePtr; if (height <= 0) { return; @@ -40,9 +41,10 @@ namespace UI { if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { MACRO_CALL(OpenSHC::UI::Rendering_Func::InitBlendFilterArraysUnk)(); } - // Both start at the table's base: the asm adds the row for the alpha value to each + // Both at the table's base; the asm adds each one's row (one pointer: quick_diff 0.8258 -> 0.8231) short* const dstFilter = DAT_BlendFilterArrays::instance[0][0]; short* const srcFilter = DAT_BlendFilterArrays::instance[0][0]; + // Map arm first (== with the arms swapped: quick_diff 0.8258 -> 0.8077) if (this->drawBufferChoiceValue != OpenSHC::Rendering::Enums::RT_SCREEN_MENU) { DAT_TextureRenderCoreObject::instance.currentRenderSurface = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; @@ -148,10 +150,10 @@ namespace UI { mov eax, maskPtr add maskPtr, 2 mov dx, word ptr [eax] - and edx, 1Fh + and edx, 0x1f sub edx, blendStrength jle repeating_next_555 - cmp edx, 1Fh + cmp edx, 31 jne repeating_blend_555 mov ax, word ptr [esi] mov word ptr [edi], ax @@ -162,45 +164,45 @@ namespace UI { add edx, srcFilter mov ax, word ptr [esi] movzx ebx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0FC1Fh + and ax, 0xfc1f or ax, bx mov bx, ax - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 3FFh + and ax, 0x3ff or ax, bx pop edx push ax - mov eax, 20h + mov eax, 32 sub eax, edx shl eax, 9 add eax, dstFilter mov dx, word ptr [edi] movzx ebx, dx - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0FC1Fh + and dx, 0xfc1f or dx, bx mov bx, dx - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 83FFh + and dx, 0x83ff or dx, bx pop ax add dx, ax @@ -221,10 +223,10 @@ namespace UI { mov eax, maskPtr add maskPtr, 2 mov dx, word ptr [eax] - and edx, 1Fh + and edx, 0x1f sub edx, blendStrength jle stream_next_555 - cmp edx, 1Fh + cmp edx, 31 jne stream_blend_555 mov ax, word ptr [esi] mov word ptr [edi], ax @@ -235,46 +237,46 @@ namespace UI { add edx, srcFilter mov ax, word ptr [esi] mov bx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0FC1Fh + and ax, 0xfc1f or ax, bx mov bx, ax - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 3FFh + and ax, 0x3ff or ax, bx mov bx, word ptr [edi] mov word ptr [edi], ax pop edx - mov eax, 20h + mov eax, 32 sub eax, edx shl eax, 9 add eax, dstFilter mov dx, bx movzx ebx, dx - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0FC1Fh + and dx, 0xfc1f or dx, bx mov bx, dx - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 83FFh + and dx, 0x83ff or dx, bx add word ptr [edi], dx stream_next_555: @@ -371,10 +373,10 @@ namespace UI { mov eax, maskPtr add maskPtr, 2 mov dx, word ptr [eax] - and edx, 1Fh + and edx, 0x1f sub edx, blendStrength jle repeating_next_565 - cmp edx, 1Fh + cmp edx, 31 jne repeating_blend_565 mov ax, word ptr [esi] mov word ptr [edi], ax @@ -386,32 +388,32 @@ namespace UI { add edx, srcFilter mov ax, word ptr [esi] movzx ebx, ax - and bx, 1Fh + and bx, 0x1f mov cx, word ptr [edx + ebx*8] mov bx, ax shr bx, 5 - and bx, 3Fh + and bx, 0x3f or cx, word ptr [edx + ebx*8 + 2] mov bx, ax - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f or cx, word ptr [edx + ebx*8 + 4] pop edx - mov eax, 20h + mov eax, 32 sub eax, edx shl eax, 9 add eax, dstFilter mov dx, word ptr [edi] movzx ebx, dx - and bx, 1Fh + and bx, 0x1f add cx, word ptr [eax + ebx*8] mov bx, dx shr bx, 5 - and bx, 3Fh + and bx, 0x3f add cx, word ptr [eax + ebx*8 + 2] mov bx, dx - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f add cx, word ptr [eax + ebx*8 + 4] mov word ptr [edi], cx pop cx @@ -431,10 +433,10 @@ namespace UI { mov eax, maskPtr add maskPtr, 2 mov dx, word ptr [eax] - and edx, 1Fh + and edx, 0x1f sub edx, blendStrength jle stream_next_565 - cmp edx, 1Fh + cmp edx, 31 jne stream_blend_565 mov ax, word ptr [esi] mov word ptr [edi], ax @@ -446,32 +448,32 @@ namespace UI { add edx, srcFilter mov ax, word ptr [esi] mov bx, ax - and bx, 1Fh + and bx, 0x1f mov cx, word ptr [edx + ebx*8] mov bx, ax shr bx, 5 - and bx, 3Fh + and bx, 0x3f or cx, word ptr [edx + ebx*8 + 2] mov bx, ax - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f or cx, word ptr [edx + ebx*8 + 4] movzx bx, word ptr [edi] pop edx - mov eax, 20h + mov eax, 32 sub eax, edx shl eax, 9 add eax, dstFilter mov dx, bx - and bx, 1Fh + and bx, 0x1f add cx, word ptr [eax + ebx*8] mov bx, dx shr bx, 5 - and bx, 3Fh + and bx, 0x3f add cx, word ptr [eax + ebx*8 + 2] mov bx, dx - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f add cx, word ptr [eax + ebx*8 + 4] mov word ptr [edi], cx pop cx diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp index aadfcb6c12..1b97a8f8eb 100644 --- a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderInterfaceOrBuildingOccupationArea.cpp @@ -25,6 +25,7 @@ namespace UI { void TextureRenderCore::renderInterfaceOrBuildingOccupationArea( int x, int y, int width, int height, ushort* imageDataPtr, int blendStrengthUnk) { + // Blends the TGX image over the destination through the two filter rows blendStrengthUnk picks // Declared before the if because all three arms assign them; lineJump is from one row's end to the next int lineJump; int lineBytes; @@ -40,6 +41,7 @@ namespace UI { short* const dstFilter = DAT_BlendFilterArrays::instance[blendStrengthUnk][0]; short* const srcFilter = DAT_BlendFilterArrays::instance[32 - blendStrengthUnk][0]; if (!DAT_TextureRenderCoreObject::instance.isZoom2) { + // Map arm first (== with the arms swapped: quick_diff 0.8270 -> 0.8228) if (this->drawBufferChoiceValue != OpenSHC::Rendering::Enums::RT_SCREEN_MENU) { DAT_TextureRenderCoreObject::instance.currentRenderSurface = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; @@ -144,21 +146,21 @@ namespace UI { mov edx, srcFilter mov ebx, 0 mov bx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0FC1Fh + and ax, 0xfc1f or ax, bx mov bx, ax - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 3FFh + and ax, 0x3ff or ax, bx repeating_pixel_555: mov dx, word ptr [edi] @@ -166,21 +168,21 @@ namespace UI { mov eax, dstFilter mov ebx, 0 mov bx, dx - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0FC1Fh + and dx, 0xfc1f or dx, bx mov bx, dx - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 83FFh + and dx, 0x83ff or dx, bx pop ax add dx, ax @@ -198,42 +200,42 @@ namespace UI { mov ax, word ptr [esi] mov edx, srcFilter mov bx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0FC1Fh + and ax, 0xfc1f or ax, bx mov bx, ax - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 3FFh + 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, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0FC1Fh + and dx, 0xfc1f or dx, bx mov bx, dx - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 83FFh + and dx, 0x83ff or dx, bx add word ptr [edi], dx add esi, 2 @@ -324,15 +326,15 @@ namespace UI { push edx mov esi, srcFilter movzx ebx, ax - and bx, 1Fh + and bx, 0x1f mov dx, word ptr [esi + ebx*8] mov bx, ax shr bx, 5 - and bx, 3Fh + and bx, 0x3f or dx, word ptr [esi + ebx*8 + 2] mov bx, ax - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f or dx, word ptr [esi + ebx*8 + 4] mov ax, dx mov esi, dstFilter @@ -340,15 +342,15 @@ namespace UI { mov dx, word ptr [edi] push ax movzx ebx, dx - and bx, 1Fh + and bx, 0x1f mov ax, word ptr [esi + ebx*8] mov bx, dx shr bx, 5 - and bx, 3Fh + and bx, 0x3f or ax, word ptr [esi + ebx*8 + 2] mov bx, dx - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f or ax, word ptr [esi + ebx*8 + 4] mov dx, ax pop ax @@ -369,28 +371,28 @@ namespace UI { mov edx, srcFilter push cx mov bx, ax - and bx, 1Fh + and bx, 0x1f mov cx, word ptr [edx + ebx*8] mov bx, ax shr bx, 5 - and bx, 3Fh + and bx, 0x3f or cx, word ptr [edx + ebx*8 + 2] mov bx, ax - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f or cx, word ptr [edx + ebx*8 + 4] mov dx, word ptr [edi] mov eax, dstFilter movzx ebx, dx - and bx, 1Fh + and bx, 0x1f add cx, word ptr [eax + ebx*8] mov bx, dx shr bx, 5 - and bx, 3Fh + and bx, 0x3f add cx, word ptr [eax + ebx*8 + 2] mov bx, dx - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f add cx, word ptr [eax + ebx*8 + 4] mov word ptr [edi], cx add esi, 2 @@ -404,10 +406,11 @@ namespace UI { } // clang-format on } else { - // Declared in this branch (at function scope: quick_diff 1.0000 -> 0.9702) + // Written by the asm only; declared in this branch (at function scope: quick_diff 1.0000 -> 0.9702) int columnOffset; DAT_TextureRenderCoreObject::instance.currentRenderSurface = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + // A whole row here: the zoomed-out loops keep edi at the row's start and add columnOffset lineJump = 4056 * 2; lineBytes = 4056 * 2; heightStart = this->mapGameSurfaceHeightRange.start; @@ -426,7 +429,7 @@ namespace UI { mov eax, x cmp eax, 0 jl zoom_done_555 - and eax, 0FFFFFFFEh + and eax, 0xfffffffe add edi, eax mov eax, y mov ebx, heightStart @@ -525,21 +528,21 @@ namespace UI { push edx mov edx, srcFilter movzx ebx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0FC1Fh + and ax, 0xfc1f or ax, bx mov bx, ax - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 3FFh + and ax, 0x3ff or ax, bx pop edx add ecx, 1 @@ -554,21 +557,21 @@ namespace UI { push ax mov eax, dstFilter movzx ebx, dx - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0FC1Fh + and dx, 0xfc1f or dx, bx mov bx, dx - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 83FFh + and dx, 0x83ff or dx, bx pop ax add dx, ax @@ -592,21 +595,21 @@ namespace UI { mov ax, word ptr [esi] mov edx, srcFilter mov bx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0FC1Fh + and ax, 0xfc1f or ax, bx mov bx, ax - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 3FFh + and ax, 0x3ff or ax, bx pop ebx mov dx, word ptr [edi + ebx] @@ -614,21 +617,21 @@ namespace UI { push ebx mov eax, dstFilter movzx ebx, dx - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0FC1Fh + and dx, 0xfc1f or dx, bx mov bx, dx - shr bx, 0Ah - and bx, 1Fh + shr bx, 10 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 83FFh + and dx, 0x83ff or dx, bx pop ebx add word ptr [edi + ebx], dx @@ -651,7 +654,7 @@ namespace UI { mov eax, x cmp eax, 0 jl zoom_done_565 - and eax, 0FFFFFFFEh + and eax, 0xfffffffe add edi, eax mov eax, y mov ebx, heightStart @@ -750,21 +753,21 @@ namespace UI { push edx mov edx, srcFilter movzx ebx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 3Fh + and bx, 0x3f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0F81Fh + and ax, 0xf81f or ax, bx mov bx, ax - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 7FFh + and ax, 0x7ff or ax, bx pop edx add ecx, 1 @@ -779,21 +782,21 @@ namespace UI { push ax mov eax, dstFilter movzx ebx, dx - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 3Fh + and bx, 0x3f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0F81Fh + and dx, 0xf81f or dx, bx mov bx, dx - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 7FFh + and dx, 0x7ff or dx, bx pop ax add dx, ax @@ -817,21 +820,21 @@ namespace UI { mov ax, word ptr [esi] mov edx, srcFilter mov bx, ax - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [edx + ebx*8] - and ax, 0FFE0h + and ax, 0xffe0 or ax, bx mov bx, ax shr bx, 5 - and bx, 3Fh + and bx, 0x3f mov bx, word ptr [edx + ebx*8 + 2] - and ax, 0F81Fh + and ax, 0xf81f or ax, bx mov bx, ax - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f mov bx, word ptr [edx + ebx*8 + 4] - and ax, 7FFh + and ax, 0x7ff or ax, bx pop ebx mov dx, word ptr [edi + ebx] @@ -839,21 +842,21 @@ namespace UI { push ebx mov eax, dstFilter movzx ebx, dx - and bx, 1Fh + and bx, 0x1f mov bx, word ptr [eax + ebx*8] - and dx, 0FFE0h + and dx, 0xffe0 or dx, bx mov bx, dx shr bx, 5 - and bx, 3Fh + and bx, 0x3f mov bx, word ptr [eax + ebx*8 + 2] - and dx, 0F81Fh + and dx, 0xf81f or dx, bx mov bx, dx - shr bx, 0Bh - and bx, 1Fh + shr bx, 11 + and bx, 0x1f mov bx, word ptr [eax + ebx*8 + 4] - and dx, 7FFh + and dx, 0x7ff or dx, bx pop ebx add word ptr [edi + ebx], dx