diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/loadGMFile.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/loadGMFile.cpp new file mode 100644 index 0000000000..c476ec7767 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/loadGMFile.cpp @@ -0,0 +1,100 @@ +#include "../TextureRenderCore.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/IO/Graphics/GmImageType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" +#include "OpenSHC/Globals/DAT_GMImageSizes.hpp" +#include "OpenSHC/Globals/DAT_LoadingBarProgress.hpp" +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_PictureNumToGmIDArray_UNUSED.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x004559B0 + void TextureRenderCore::loadGMFile(GmID gmID, char* gmFileName) + { + // keep the window responsive while the files load + MSG message; + if (PeekMessageA(&message, NULL, 0, 0, 0) && GetMessageA(&message, NULL, 0, 0)) { + TranslateMessage(&message); + DispatchMessageA(&message); + } + BOOLEnum const flag = this->unknownSfxAndGmRelatedFlag; + int totalSize = 0; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + sizeof(this->gmFileHeaderColorpaletteArray[gmID]), 0, &this->gmFileHeaderColorpaletteArray[gmID]); + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + 1000, 0, this->gmFileNameArray_UNUSEDUnk_0x13179c[gmID]); + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::copyData, DAT_LowLevelMemory::ptr)( + strlen(gmFileName), gmFileName, this->gmFileNameArray_UNUSEDUnk_0x13179c[gmID]); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + OpenSHC::IO::FRT_GM, this->gmFileNameArray_UNUSEDUnk_0x13179c[gmID]); + + // the header, the offsets, sizes and headers of its pictures, then their data + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::readFirstPartOfCurrentResourceIntoMemory, + DAT_ResourceManager::ptr)(&this->gmFileHeaderColorpaletteArray[gmID], + sizeof(this->gmFileHeaderColorpaletteArray[gmID]), (char*)s_gm1_005a5068); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::readNextPartOfCurrentResourceIntoMemory, + DAT_ResourceManager::ptr)(&DAT_GMImageOffsets::instance[this->gmNumberOfProcessedPictures], + this->gmFileHeaderColorpaletteArray[gmID].numberOfPicturesInFile * 4, (char*)s_gm1_005a5068); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::readNextPartOfCurrentResourceIntoMemory, + DAT_ResourceManager::ptr)(&DAT_GMImageSizes::instance[this->gmNumberOfProcessedPictures], + this->gmFileHeaderColorpaletteArray[gmID].numberOfPicturesInFile * 4, (char*)s_gm1_005a5068); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::readNextPartOfCurrentResourceIntoMemory, + DAT_ResourceManager::ptr)(&DAT_GMImageHeaders::instance.imh[this->gmNumberOfProcessedPictures], + this->gmFileHeaderColorpaletteArray[gmID].numberOfPicturesInFile * 16, (char*)s_gm1_005a5068); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::readNextPartOfCurrentResourceIntoMemory, + DAT_ResourceManager::ptr)(this->gmAndGfxImageDataBuffer, + this->gmFileHeaderColorpaletteArray[gmID].dataSize, (char*)s_gm1_005a5068); + if (this->gmFileHeaderColorpaletteArray[gmID].ImageType == OpenSHC::IO::Graphics::GIT_Animation) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::transformGmColorTableFromRGB555To565IfRequired, + this)(gmID); + } + + // copy each picture's data behind the ones processed so far; a picture that shares another one's data + // points at it instead + int offset = DAT_GMImageOffsets::instance[this->gmNumberOfProcessedPictures]; + for (int picture = this->gmNumberOfProcessedPictures; picture + < this->gmFileHeaderColorpaletteArray[gmID].numberOfPicturesInFile + this->gmNumberOfProcessedPictures; + ++picture) { + DAT_PictureNumToGmIDArray_UNUSED::instance[picture] = gmID; + if ((flag && DAT_GMImageHeaders::instance.imh[picture].animatedColor != 0) + || (DAT_GMImageHeaders::instance.imh[picture].animatedColor & 4) != 0) { + if ((DAT_GMImageHeaders::instance.imh[picture].animatedColor & 4) != 0) { + DAT_GMImageOffsets::instance[picture] = DAT_GMImageOffsets::instance[picture - 1]; + } else { + DAT_GMImageOffsets::instance[picture] = DAT_GMImageOffsets::instance + [DAT_GMImageHeaders::instance.imh[picture].alternativeImageIndexUnk + picture]; + } + DAT_GMImageSizes::instance[picture] + = DAT_GMImageSizes::instance[DAT_GMImageHeaders::instance.imh[picture].alternativeImageIndexUnk + + picture]; + } else { + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::copyData, DAT_LowLevelMemory::ptr)( + DAT_GMImageSizes::instance[picture], + this->gmAndGfxImageDataBuffer + DAT_GMImageOffsets::instance[picture], + this->gmProcessedImageData + this->gmSizeOfProcessedPictures_0x44 + offset); + DAT_GMImageOffsets::instance[picture] = this->gmSizeOfProcessedPictures_0x44 + offset; + totalSize += DAT_GMImageSizes::instance[picture]; + offset += DAT_GMImageSizes::instance[picture]; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::adaptGmColorsToRGB565IfRequired, + this)(gmID, picture); + } + } + this->gmSizeOfProcessedPictures_0x44 += totalSize; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawLoadingBarUnk, this)( + gmID, DAT_LoadingBarProgress::instance + 180); + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/moveOverlappingMenuPartsToMapSurface.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/moveOverlappingMenuPartsToMapSurface.cpp new file mode 100644 index 0000000000..9b223576c0 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/moveOverlappingMenuPartsToMapSurface.cpp @@ -0,0 +1,96 @@ +#include "../TextureRenderCore.func.hpp" + +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" + +#include "OpenSHC/Globals/COL_MAGENTA.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // The copy loop is handwritten assembly in the original, transcribed here from the binary. + + // FUNCTION: STRONGHOLDCRUSADER 0x00454F00 + void TextureRenderCore::moveOverlappingMenuPartsToMapSurface() + { + // copies the parts of the open menu tab that reach over the map from the menu surface onto the map + // surface, all but the magenta pixels; the tab's records hold x, y, width and height, -1 ends them and + // -2 marks the ones that only apply above 800x600 + int const tab = this->activeMenuTabIndex; + if (tab == 0) { + return; + } + if (DAT_BlendingDefinedData::instance.field_0x3014[(tab - 1) * 5][0] == -1) { + return; + } + // the asm below names COL_MAGENTA, which inline asm can only do once C++ code has instantiated it + (void)sizeof(COL_MAGENTA::instance); + // the index in a local: the original computes it again here (inline: 98 instructions to its 100) + int const record = (tab - 1) * 5; + int* width = &DAT_BlendingDefinedData::instance.field_0x3014[record][2]; + int* x = &DAT_BlendingDefinedData::instance.field_0x3014[record][0]; + int* height = &DAT_BlendingDefinedData::instance.field_0x3014[record][3]; + int* y = &DAT_BlendingDefinedData::instance.field_0x3014[record][1]; + do { + if (*x == -2) { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + return; + } + y += 4; + height += 4; + width += 4; + x += 4; + } + ushort* const screen = (ushort*)((byte*)DAT_WindowAndDirectDraw::instance.surfacePointer_screenMenu + + (*y + DAT_MenuHandlerState::instance.y) + * DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine + + (DAT_MenuHandlerState::instance.x + *x) * 2); + // the map surface is 4056 pixels wide + ushort* const map = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame + + (*y + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + + DAT_MenuHandlerState::instance.y) + * 4056 + + *x + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX + + DAT_MenuHandlerState::instance.x; + int const mapLineJump = (4056 - *width) * 2; + int const screenLineJump = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine - *width * 2; + int const partHeight = *height; + int const partWidth = *width; + // clang-format off + __asm { + mov esi, screen + mov edi, map + mov ecx, partHeight + mov bx, COL_MAGENTA::instance.shortValue + rowLoop: + mov edx, partWidth + pixelLoop: + mov ax, word ptr [esi] + cmp ax, bx + je skipPixel + mov word ptr [edi], ax + skipPixel: + add esi, 2 + add edi, 2 + sub edx, 1 + jne pixelLoop + add esi, screenLineJump + add edi, mapLineJump + sub ecx, 1 + jne rowLoop + } + // clang-format on + y += 4; + height += 4; + width += 4; + x += 4; + } while (*x != -1); + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp new file mode 100644 index 0000000000..a958b97596 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/TextureRenderCore/renderUnitAnimationWithBlendingUnk.cpp @@ -0,0 +1,932 @@ +#include "../TextureRenderCore.func.hpp" + +#include "OpenSHC/UI/Rendering.func.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 { + + // NOTE: The four drawing loops are hand-written assembly in the original: they materialise + // zero with mov reg,0, compare with cmp reg,0 rather than test, load the same token byte + // twice into two registers, and use mul for the row offset. Only the owner swap, the + // palette and blend filter setup, the surface selection and the height clamp are + // ordinary C++. + // + // Each loop walks TGX tokens whose pixels are byte indices into the sprite's player + // colour palette, and blends the looked-up colour over the destination through a pair of + // 512-byte filter rows of DAT_BlendFilterArrays picked by blendStrengthUnk: row + // [blendStrengthUnk] weights the destination and row [0x20 - blendStrengthUnk] the + // source. The row start is kept on the stack with push edi so a newline token can + // restore it and step one whole line. There are four loops because the component masks + // differ between RGB555 and RGB565, and because the zoomed-out surface stores only every + // second column, so those two loops track a running column offset seeded from xPos & 1 + // and skip odd columns with test ebx,1. + + // FUNCTION: STRONGHOLDCRUSADER 0x00451E00 + void TextureRenderCore::renderUnitAnimationWithBlendingUnk( + int xPos, int yPos, int width, int height, byte* imageSource, int blendStrengthUnk) + { + int _lineByteWidth; + int _heightStart; + short* _colorPalette; + int _columnOffset; + short* _dstFilter; + short* _srcFilter; + int _startColumnParity; + int _heightEnd; + if (DAT_RenderedUnitOwner::instance == 1) { + DAT_RenderedUnitOwner::instance = 4; + } else if (DAT_RenderedUnitOwner::instance == 4) { + DAT_RenderedUnitOwner::instance = 1; + } + _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; + } + if (DAT_BlendFilterArrays::instance[32][31][0] == 0) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::InitBlendFilterArraysUnk)(); + } + _dstFilter = (short*)((char*)DAT_BlendFilterArrays::instance + blendStrengthUnk * 512); + _srcFilter = (short*)((char*)DAT_BlendFilterArrays::instance + (32 * 512 - blendStrengthUnk * 512)); + if (DAT_TextureRenderCoreObject::instance.isZoom2 == 0) { + if (this->drawBufferChoiceValue != OpenSHC::Rendering::Enums::RT_SCREEN_MENU) { + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + _heightStart = this->mapGameSurfaceHeightRange.start; + _heightEnd = this->mapGameSurfaceHeightRange.end; + blendStrengthUnk = 4056 * 2; + _lineByteWidth = 4056 * 2; + } else { + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_screenMenu; + blendStrengthUnk = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; + _lineByteWidth = DAT_WindowAndDirectDraw::instance.byteSizeOfOneHorizontalLine; + _heightStart = this->screenMenuSurfaceHeightRange.start; + _heightEnd = this->screenMenuSurfaceHeightRange.end; + } + if (height + yPos > _heightEnd) { + height = _heightEnd - yPos; + if (height <= 0) { + return; + } + } + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + __asm { + mov esi, imageSource + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPos + cmp eax, 0 + jl a5done + add eax, eax + add edi, eax + mov eax, yPos + mov ebx, _heightStart + cmp eax, ebx + jge a5addRowOffset + sub ebx, eax + mov eax, ebx + cmp height, eax + jle a5done + sub height, eax + a5skip: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, 0E0h + and cl, 1Fh + add esi, 1 + cmp bl, 20h + je a5skip + cmp bl, 0 + je a5skipStream + cmp bl, 40h + je a5skipRepeat + jmp a5skipNewline + a5skipStream: + add ecx, 1 + add esi, ecx + jmp a5skip + a5skipRepeat: + add esi, 1 + jmp a5skip + a5skipNewline: + sub eax, 1 + cmp eax, 0 + jg a5skip + mov eax, _heightStart + a5addRowOffset: + mov edx, _lineByteWidth + mul edx + add edi, eax + mov edx, _colorPalette + a5row: + push edi + a5token: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, 0E0h + and cl, 1Fh + add esi, 1 + cmp al, 20h + je a5transparent + cmp al, 0 + je a5stream + cmp al, 40h + je a5repeat + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jg a5row + jmp a5done + a5transparent: + add ecx, 1 + add ecx, ecx + add edi, ecx + jmp a5token + a5repeat: + 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, 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 + a5repeatLoop: + 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 a5repeatLoop + pop edx + jmp a5token + a5stream: + mov ebx, 0 + add ecx, 1 + a5streamLoop: + 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, 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 + pop edx + add esi, 1 + add edi, 2 + sub ecx, 1 + jne a5streamLoop + jmp a5token + a5done: + } + return; + } + __asm { + mov esi, imageSource + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPos + cmp eax, 0 + jl a6done + add eax, eax + add edi, eax + mov eax, yPos + mov ebx, _heightStart + cmp eax, ebx + jge a6addRowOffset + sub ebx, eax + mov eax, ebx + cmp height, eax + jle a6done + sub height, eax + a6skip: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, 0E0h + and cl, 1Fh + add esi, 1 + cmp bl, 20h + je a6skip + cmp bl, 0 + je a6skipStream + cmp bl, 40h + je a6skipRepeat + jmp a6skipNewline + a6skipStream: + add ecx, 1 + add esi, ecx + jmp a6skip + a6skipRepeat: + add esi, 1 + jmp a6skip + a6skipNewline: + sub eax, 1 + cmp eax, 0 + jg a6skip + mov eax, _heightStart + a6addRowOffset: + mov edx, _lineByteWidth + mul edx + add edi, eax + mov edx, _colorPalette + a6row: + push edi + a6token: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, 0E0h + and cl, 1Fh + add esi, 1 + cmp al, 20h + je a6transparent + cmp al, 0 + je a6stream + cmp al, 40h + je a6repeat + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jg a6row + jmp a6done + a6transparent: + add ecx, 1 + add ecx, ecx + add edi, ecx + jmp a6token + a6repeat: + 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, 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 + a6repeatLoop: + mov dx, word ptr [edi] + push ax + mov ebx, 0 + mov bx, 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 a6repeatLoop + pop edx + pop esi + jmp a6token + a6stream: + add ecx, 1 + a6streamLoop: + 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, 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 + mov ebx, 0 + mov bx, 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 edx + pop ecx + add esi, 1 + add edi, 2 + sub ecx, 1 + jne a6streamLoop + jmp a6token + a6done: + } + return; + } + DAT_TextureRenderCoreObject::instance.currentRenderSurface + = DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame; + _heightStart = this->mapGameSurfaceHeightRange.start; + _heightEnd = this->mapGameSurfaceHeightRange.end; + _startColumnParity = xPos & 1; + blendStrengthUnk = 4056 * 2; + _lineByteWidth = 4056 * 2; + if (height + yPos > _heightEnd) { + height = _heightEnd - yPos; + if (height <= 0) { + return; + } + } + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_555) { + __asm { + mov esi, imageSource + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPos + cmp eax, 0 + jl b5done + and eax, 0FFFFFFFEh + add edi, eax + mov eax, yPos + mov ebx, _heightStart + cmp eax, ebx + jge b5addRowOffset + sub ebx, eax + mov eax, ebx + cmp height, eax + jle b5done + sub height, eax + b5skip: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, 0E0h + and cl, 1Fh + add esi, 1 + cmp bl, 20h + je b5skip + cmp bl, 0 + je b5skipStream + cmp bl, 40h + je b5skipRepeat + jmp b5skipNewline + b5skipStream: + add ecx, 1 + add esi, ecx + jmp b5skip + b5skipRepeat: + add esi, 1 + jmp b5skip + b5skipNewline: + sub eax, 1 + cmp eax, 0 + jg b5skip + mov eax, _heightStart + b5addRowOffset: + mov edx, _lineByteWidth + mov ecx, eax + shr eax, 1 + mul edx + add edi, eax + mov edx, _colorPalette + b5row: + mov ebx, _startColumnParity + mov _columnOffset, ebx + push edi + b5token: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, 0E0h + and cl, 1Fh + add esi, 1 + cmp al, 20h + je b5transparent + cmp al, 0 + je b5stream + cmp al, 40h + je b5repeat + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jle b5done + b5rowSkip: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, 0E0h + and cl, 1Fh + add esi, 1 + cmp bl, 20h + je b5rowSkip + cmp bl, 0 + je b5rowSkipStream + cmp bl, 40h + je b5rowSkipRepeat + jmp b5rowSkipDone + b5rowSkipStream: + add ecx, 1 + add esi, ecx + jmp b5rowSkip + b5rowSkipRepeat: + add esi, 1 + jmp b5rowSkip + b5rowSkipDone: + sub height, 1 + cmp height, 0 + jg b5row + jmp b5done + b5transparent: + add ecx, 1 + add _columnOffset, ecx + jmp b5token + b5repeat: + 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, 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 + add ecx, 1 + mov ebx, _columnOffset + add _columnOffset, ecx + b5repeatLoop: + test ebx, 1 + jne b5repeatNext + mov dx, word ptr [edi + ebx] + push ax + push ebx + 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 ebx + pop ax + add dx, ax + mov word ptr [edi + ebx], dx + b5repeatNext: + add ebx, 1 + sub ecx, 1 + jne b5repeatLoop + pop edx + jmp b5token + b5stream: + mov eax, 0 + add ecx, 1 + mov ebx, _columnOffset + add _columnOffset, ecx + b5streamLoop: + test ebx, 1 + jne b5streamNext + 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, 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 + mov eax, _dstFilter + push ebx + 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 ebx + add word ptr [edi + ebx], dx + pop edx + b5streamNext: + add esi, 1 + add ebx, 1 + sub ecx, 1 + jne b5streamLoop + jmp b5token + b5done: + } + return; + } + __asm { + mov esi, imageSource + mov edi, DAT_TextureRenderCoreObject::instance.currentRenderSurface + mov eax, xPos + cmp eax, 0 + jl b6done + and eax, 0FFFFFFFEh + add edi, eax + mov eax, yPos + mov ebx, _heightStart + cmp eax, ebx + jge b6addRowOffset + sub ebx, eax + mov eax, ebx + cmp height, eax + jle b6done + sub height, eax + b6skip: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, 0E0h + and cl, 1Fh + add esi, 1 + cmp bl, 20h + je b6skip + cmp bl, 0 + je b6skipStream + cmp bl, 40h + je b6skipRepeat + jmp b6skipNewline + b6skipStream: + add ecx, 1 + add esi, ecx + jmp b6skip + b6skipRepeat: + add esi, 1 + jmp b6skip + b6skipNewline: + sub eax, 1 + cmp eax, 0 + jg b6skip + mov eax, _heightStart + b6addRowOffset: + mov edx, _lineByteWidth + mov ecx, eax + shr eax, 1 + mul edx + add edi, eax + mov edx, _colorPalette + b6row: + mov ebx, _startColumnParity + mov _columnOffset, ebx + push edi + b6token: + mov ecx, 0 + mov al, byte ptr [esi] + mov cl, byte ptr [esi] + and al, 0E0h + and cl, 1Fh + add esi, 1 + cmp al, 20h + je b6transparent + cmp al, 0 + je b6stream + cmp al, 40h + je b6repeat + pop edi + add edi, blendStrengthUnk + sub height, 1 + cmp height, 0 + jle b6done + b6rowSkip: + mov ecx, 0 + mov bl, byte ptr [esi] + mov cl, byte ptr [esi] + and bl, 0E0h + and cl, 1Fh + add esi, 1 + cmp bl, 20h + je b6rowSkip + cmp bl, 0 + je b6rowSkipStream + cmp bl, 40h + je b6rowSkipRepeat + jmp b6rowSkipDone + b6rowSkipStream: + add ecx, 1 + add esi, ecx + jmp b6rowSkip + b6rowSkipRepeat: + add esi, 1 + jmp b6rowSkip + b6rowSkipDone: + sub height, 1 + cmp height, 0 + jg b6row + jmp b6done + b6transparent: + add ecx, 1 + add _columnOffset, ecx + jmp b6token + b6repeat: + 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, 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 + add ecx, 1 + mov ebx, _columnOffset + add _columnOffset, ecx + b6repeatLoop: + test ebx, 1 + jne b6repeatNext + mov dx, word ptr [edi + ebx] + push ax + push ebx + 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, 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 + pop ax + add dx, ax + mov word ptr [edi + ebx], dx + b6repeatNext: + add ebx, 1 + sub ecx, 1 + jne b6repeatLoop + pop edx + jmp b6token + b6stream: + mov eax, 0 + add ecx, 1 + mov ebx, _columnOffset + add _columnOffset, ecx + b6streamLoop: + test ebx, 1 + jne b6streamNext + 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, 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 + mov eax, _dstFilter + push ebx + 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, 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 + b6streamNext: + add esi, 1 + add ebx, 1 + sub ecx, 1 + jne b6streamLoop + jmp b6token + b6done: + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ed989c9a21..78f24eb062 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 | 92.5% | gynt's asm with the zoomed path's surface pointer fixed; stack slots of the asm-only column offset and the C locals SHC_3BB0A8C1_0x00452900 | 100.0% | Reimplemented @@ -17003,7 +17003,7 @@ SHC_3BB0A8C1_0x00454EE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00454EF0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00454F00 | 0.0% | Pending +SHC_3BB0A8C1_0x00454F00 | 96.5% | the record index as a local, the pointers in the original's order; the test's index folded into its address SHC_3BB0A8C1_0x00455050 | 100.0% | Reimplemented @@ -17029,7 +17029,7 @@ SHC_3BB0A8C1_0x004558E0 | 0.0% | Pending SHC_3BB0A8C1_0x00455930 | 0.0% | Pending -SHC_3BB0A8C1_0x004559B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004559B0 | 93.1% | one sharing condition for the original's shared blocks; the header pointer's base and one re-test SHC_3BB0A8C1_0x00455B70 | 0.0% | Pending