mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-26 14:13:55 -04:00
Fix AlphaMask functions (#1425)
This commit is contained in:
parent
3b63506648
commit
93d6c18c9a
@ -115,7 +115,7 @@ public:
|
|||||||
MxLong GetDataSize() const { return AlignToFourByte(m_bmiHeader->biWidth) * GetBmiHeightAbs(); }
|
MxLong GetDataSize() const { return AlignToFourByte(m_bmiHeader->biWidth) * GetBmiHeightAbs(); }
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x1002c4b0
|
// FUNCTION: BETA10 0x1002c4b0
|
||||||
MxBool IsTopDown()
|
MxBool IsTopDown() const
|
||||||
{
|
{
|
||||||
if (m_bmiHeader->biCompression == BI_RGB_TOPDOWN) {
|
if (m_bmiHeader->biCompression == BI_RGB_TOPDOWN) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
: -p_bitmap->AlignToFourByte(p_bitmap->GetBmiWidth()))
|
: -p_bitmap->AlignToFourByte(p_bitmap->GetBmiWidth()))
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x1002c320
|
// FUNCTION: BETA10 0x1002c320
|
||||||
MxU8* GetStart(MxS32 p_left, MxS32 p_top)
|
MxU8* GetStart(MxS32 p_left, MxS32 p_top) const
|
||||||
{
|
{
|
||||||
if (m_bmiHeader->biCompression == BI_RGB) {
|
if (m_bmiHeader->biCompression == BI_RGB) {
|
||||||
return m_data + p_left +
|
return m_data + p_left +
|
||||||
|
@ -15,17 +15,12 @@ DECOMP_SIZE_ASSERT(MxVideoPresenter::AlphaMask, 0x0c);
|
|||||||
MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
||||||
{
|
{
|
||||||
m_width = p_bitmap.GetBmiWidth();
|
m_width = p_bitmap.GetBmiWidth();
|
||||||
// DECOMP: ECX becomes word-sized if these are not two separate actions.
|
m_height = p_bitmap.GetBmiHeightAbs();
|
||||||
MxLong height = p_bitmap.GetBmiHeightAbs();
|
|
||||||
m_height = height;
|
|
||||||
|
|
||||||
MxS32 size = ((m_width * m_height) / 8) + 1;
|
MxS32 size = ((m_width * m_height) / 8) + 1;
|
||||||
m_bitmask = new MxU8[size];
|
m_bitmask = new MxU8[size];
|
||||||
memset(m_bitmask, 0, size);
|
memset(m_bitmask, 0, size);
|
||||||
|
|
||||||
MxU32 rowsBeforeTop;
|
|
||||||
MxU8* bitmapSrcPtr;
|
|
||||||
|
|
||||||
// The goal here is to enable us to walk through the bitmap's rows
|
// The goal here is to enable us to walk through the bitmap's rows
|
||||||
// in order, regardless of the orientation. We want to end up at the
|
// in order, regardless of the orientation. We want to end up at the
|
||||||
// start of the first row, which is either at position 0, or at
|
// start of the first row, which is either at position 0, or at
|
||||||
@ -34,37 +29,13 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
|||||||
// Reminder: Negative biHeight means this is a top-down DIB.
|
// Reminder: Negative biHeight means this is a top-down DIB.
|
||||||
// Otherwise it is bottom-up.
|
// Otherwise it is bottom-up.
|
||||||
|
|
||||||
switch (p_bitmap.GetBmiHeader()->biCompression) {
|
MxU8* bitmapSrcPtr = p_bitmap.GetStart(0, 0);
|
||||||
case BI_RGB: {
|
|
||||||
if (p_bitmap.GetBmiHeight() < 0) {
|
|
||||||
rowsBeforeTop = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rowsBeforeTop = p_bitmap.GetBmiHeightAbs() - 1;
|
|
||||||
}
|
|
||||||
bitmapSrcPtr = p_bitmap.GetImage() + (p_bitmap.GetBmiStride() * rowsBeforeTop);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BI_RGB_TOPDOWN:
|
|
||||||
bitmapSrcPtr = p_bitmap.GetImage();
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
if (p_bitmap.GetBmiHeight() < 0) {
|
|
||||||
rowsBeforeTop = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rowsBeforeTop = p_bitmap.GetBmiHeightAbs() - 1;
|
|
||||||
}
|
|
||||||
bitmapSrcPtr = p_bitmap.GetImage() + (p_bitmap.GetBmiStride() * rowsBeforeTop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// How many bytes are there for each row of the bitmap?
|
// How many bytes are there for each row of the bitmap?
|
||||||
// (i.e. the image stride)
|
// (i.e. the image stride)
|
||||||
// If this is a bottom-up DIB, we will walk it in reverse.
|
// If this is a bottom-up DIB, we will walk it in reverse.
|
||||||
// TODO: Same rounding trick as in MxBitmap
|
MxS32 rowSeek = p_bitmap.AlignToFourByte(m_width);
|
||||||
MxS32 rowSeek = ((m_width + 3) & -4);
|
if (p_bitmap.GetBmiHeader()->biCompression != BI_RGB_TOPDOWN && p_bitmap.GetBmiHeight() >= 0) {
|
||||||
if (p_bitmap.GetBmiHeader()->biCompression != BI_RGB_TOPDOWN && p_bitmap.GetBmiHeight() > 0) {
|
|
||||||
rowSeek = -rowSeek;
|
rowSeek = -rowSeek;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,9 +47,7 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
|||||||
MxU8* tPtr = bitmapSrcPtr;
|
MxU8* tPtr = bitmapSrcPtr;
|
||||||
for (MxS32 i = 0; i < m_width; i++) {
|
for (MxS32 i = 0; i < m_width; i++) {
|
||||||
if (*tPtr) {
|
if (*tPtr) {
|
||||||
// TODO: Second CDQ instruction for abs() should not be there.
|
m_bitmask[offset / 8] |= (1 << (offset % 8));
|
||||||
MxU32 shift = abs(offset) & 7;
|
|
||||||
m_bitmask[offset / 8] |= (1 << abs((MxS32) shift));
|
|
||||||
}
|
}
|
||||||
tPtr++;
|
tPtr++;
|
||||||
offset++;
|
offset++;
|
||||||
@ -116,7 +85,7 @@ MxS32 MxVideoPresenter::AlphaMask::IsHit(MxU32 p_x, MxU32 p_y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MxS32 pos = p_y * m_width + p_x;
|
MxS32 pos = p_y * m_width + p_x;
|
||||||
return m_bitmask[pos / 8] & (1 << abs(abs(pos) & 7)) ? 1 : 0;
|
return m_bitmask[pos / 8] & (1 << (pos % 8)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b2760
|
// FUNCTION: LEGO1 0x100b2760
|
||||||
|
Loading…
x
Reference in New Issue
Block a user