From 97b502362d7cefe220de3de0972d8494470adc6f Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 17 Apr 2024 10:05:51 -0400 Subject: [PATCH] Implement/match LegoTextureInfo::FUN_10066010 (#815) --- .../legoomni/src/common/legotextureinfo.cpp | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp index 2a750a48..7463524c 100644 --- a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp +++ b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp @@ -184,9 +184,34 @@ BOOL LegoTextureInfo::GetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo*& p_text return FALSE; } -// STUB: LEGO1 0x10066010 +// FUNCTION: LEGO1 0x10066010 LegoResult LegoTextureInfo::FUN_10066010(LegoU8* p_bits) { - // TODO - return SUCCESS; + if (m_surface != NULL && m_texture != NULL) { + DDSURFACEDESC desc; + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + + if (m_surface->Lock(NULL, &desc, 0, NULL) == DD_OK) { + MxU8* surface = (MxU8*) desc.lpSurface; + LegoU8* bits = p_bits; + + if (desc.dwWidth == desc.lPitch) { + memcpy(desc.lpSurface, p_bits, desc.dwWidth * desc.dwHeight); + } + else { + for (MxS32 i = 0; i < desc.dwHeight; i++) { + memcpy(surface, bits, desc.dwWidth); + surface += desc.lPitch; + bits += desc.dwWidth; + } + } + + m_surface->Unlock(desc.lpSurface); + m_texture->Changed(TRUE, FALSE); + return SUCCESS; + } + } + + return FAILURE; }