glD3DRMIMAGE::CreateBuffer, LegoVideoManager::EnableRMDevice and LegoVideoManager::DisableRMDevice (#1241)

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

* Implement LegoVideoManager::EnableRMDevice

* Implement LegoVideoManager::DisableRMDevice

* clang-format

* Match `LegoVideoManager::EnableRMDevice`

* Remove padding

* Fix naming

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Anonymous Maarten
2024-12-19 22:52:33 +01:00
committed by GitHub
parent cb38cf7673
commit a8729dfef6
5 changed files with 190 additions and 42 deletions

View File

@@ -86,10 +86,46 @@ void TglD3DRMIMAGE::Destroy()
delete m_image.palette;
}
// STUB: LEGO1 0x100a13e0
inline static 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)
{
return Error;
if (!(IsPowerOfTwo(width) && IsPowerOfTwo(height) && width % 4 == 0)) {
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