mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-20 23:01:16 +00:00
Implement TglD3DRMIMAGE::CreateBuffer (ecx/edi are swapped)
This commit is contained in:
parent
18fc084a3f
commit
1a903f06e0
@ -86,10 +86,38 @@ 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)
|
||||||
{
|
{
|
||||||
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
|
// FUNCTION: LEGO1 0x100a1510
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user