Implement TglD3DRMIMAGE::CreateBuffer (ecx/edi are swapped)

This commit is contained in:
Anonymous Maarten 2024-12-19 15:50:28 +01:00
parent 18fc084a3f
commit 1a903f06e0

View File

@ -86,11 +86,39 @@ void TglD3DRMIMAGE::Destroy()
delete m_image.palette; delete m_image.palette;
} }
// STUB: LEGO1 0x100a13e0 static inline int IsPowerOfTwo(int v) {
int m = 0;
while (v > 2 && m == 0) {
m = v % 2;
v /= 2;
}
return v == 2 && m == 0;
}
// FUNCTION: LEGO1 0x100a13e0
Result TglD3DRMIMAGE::CreateBuffer(int width, int height, int depth, void* pBuffer, int useBuffer) Result TglD3DRMIMAGE::CreateBuffer(int width, int height, int depth, void* pBuffer, int useBuffer)
{ {
if (!(IsPowerOfTwo(width) && IsPowerOfTwo(height) && width % 4 == 0)) {
return Error; return Error;
} }
m_image.width = width;
m_image.height = height;
m_image.depth = depth;
m_image.bytes_per_line = width;
if (!m_texelsAllocatedByClient) {
delete[] m_image.buffer1;
m_image.buffer1 = NULL;
}
if (useBuffer) {
m_texelsAllocatedByClient = 1;
m_image.buffer1 = (char *)pBuffer;
} else {
m_image.buffer1 = new char[width * height];
memcpy(m_image.buffer1, pBuffer, width * height);
m_texelsAllocatedByClient = 0;
}
return Success;
}
// FUNCTION: LEGO1 0x100a1510 // FUNCTION: LEGO1 0x100a1510
void TglD3DRMIMAGE::FillRowsOfTexture(int y, int height, char* pContent) void TglD3DRMIMAGE::FillRowsOfTexture(int y, int height, char* pContent)