mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-05-01 08:43:33 -04:00
MxVideoPresenter::IsHit (#244)
* MxVideoPresenter::IsHit * Apply clang-format * Minor logic fix --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
parent
b449da1fa3
commit
10ebdfa608
4 changed files with 91 additions and 15 deletions
|
@ -58,6 +58,7 @@ public:
|
||||||
|
|
||||||
inline BITMAPINFOHEADER* GetBmiHeader() const { return m_bmiHeader; }
|
inline BITMAPINFOHEADER* GetBmiHeader() const { return m_bmiHeader; }
|
||||||
inline MxLong GetBmiWidth() const { return m_bmiHeader->biWidth; }
|
inline MxLong GetBmiWidth() const { return m_bmiHeader->biWidth; }
|
||||||
|
inline MxLong GetBmiStride() const { return ((m_bmiHeader->biWidth + 3) & -4); }
|
||||||
inline MxLong GetBmiHeight() const { return m_bmiHeader->biHeight; }
|
inline MxLong GetBmiHeight() const { return m_bmiHeader->biHeight; }
|
||||||
inline MxLong GetBmiHeightAbs() const
|
inline MxLong GetBmiHeightAbs() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,10 +14,12 @@ public:
|
||||||
enum {
|
enum {
|
||||||
Flag_Looping = 0x01,
|
Flag_Looping = 0x01,
|
||||||
Flag_Bit3 = 0x04,
|
Flag_Bit3 = 0x04,
|
||||||
|
Flag_Bit4 = 0x08,
|
||||||
Flag_Bit5 = 0x10,
|
Flag_Bit5 = 0x10,
|
||||||
Flag_Enabled = 0x20,
|
Flag_Enabled = 0x20,
|
||||||
Flag_Parsed = 0x80,
|
Flag_Parsed = 0x80,
|
||||||
Flag_Bit9 = 0x200,
|
Flag_Bit9 = 0x200,
|
||||||
|
Flag_Bit10 = 0x400,
|
||||||
};
|
};
|
||||||
|
|
||||||
__declspec(dllexport) MxDSAction();
|
__declspec(dllexport) MxDSAction();
|
||||||
|
|
|
@ -118,14 +118,14 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
||||||
|
|
||||||
// TODO: would prefer not to use goto if we can figure this structure out
|
// TODO: would prefer not to use goto if we can figure this structure out
|
||||||
seek_to_last_row:
|
seek_to_last_row:
|
||||||
bitmap_src_ptr = ((p_bitmap.GetBmiWidth() + 3) & -4) * rows_before_top + p_bitmap.GetBitmapData();
|
bitmap_src_ptr = p_bitmap.GetBmiStride() * rows_before_top + p_bitmap.GetBitmapData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// TODO: Same rounding trick as in MxBitmap
|
||||||
MxS32 row_seek = ((m_height + 3) & -4);
|
MxS32 row_seek = ((m_width + 3) & -4);
|
||||||
if (p_bitmap.GetBmiHeight() < 0)
|
if (p_bitmap.GetBmiHeight() < 0)
|
||||||
row_seek = -row_seek;
|
row_seek = -row_seek;
|
||||||
|
|
||||||
|
@ -168,6 +168,16 @@ MxVideoPresenter::AlphaMask::~AlphaMask()
|
||||||
delete[] m_bitmask;
|
delete[] m_bitmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OFFSET: LEGO1 0x100b26f0
|
||||||
|
MxS32 MxVideoPresenter::AlphaMask::IsHit(MxU32 p_x, MxU32 p_y)
|
||||||
|
{
|
||||||
|
if (p_x >= m_width || p_y >= m_height)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
MxS32 pos = p_y * m_width + p_x;
|
||||||
|
return m_bitmask[pos / 8] & (1 << abs(abs(pos) & 7)) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100b2760
|
// OFFSET: LEGO1 0x100b2760
|
||||||
void MxVideoPresenter::Init()
|
void MxVideoPresenter::Init()
|
||||||
{
|
{
|
||||||
|
@ -228,6 +238,68 @@ void MxVideoPresenter::VTable0x64()
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OFFSET: LEGO1 0x100b2900
|
||||||
|
MxBool MxVideoPresenter::IsHit(MxS32 p_x, MxS32 p_y)
|
||||||
|
{
|
||||||
|
MxDSAction* action = GetAction();
|
||||||
|
if ((action == NULL) || (((action->GetFlags() & MxDSAction::Flag_Bit10) == 0) && !IsEnabled()) ||
|
||||||
|
(!m_bitmap && !m_alpha))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!m_bitmap)
|
||||||
|
return m_alpha->IsHit(p_x - GetLocationX(), p_y - GetLocationY());
|
||||||
|
|
||||||
|
MxLong heightAbs = m_bitmap->GetBmiHeightAbs();
|
||||||
|
|
||||||
|
MxLong min_x = GetLocationX();
|
||||||
|
MxLong min_y = GetLocationY();
|
||||||
|
|
||||||
|
MxLong max_y = min_y + heightAbs;
|
||||||
|
MxLong max_x = min_x + m_bitmap->GetBmiWidth();
|
||||||
|
|
||||||
|
if (p_x < min_x || p_x >= max_x || p_y < min_y || p_y >= max_y)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
MxU8* pixel;
|
||||||
|
|
||||||
|
MxLong biCompression = m_bitmap->GetBmiHeader()->biCompression;
|
||||||
|
MxLong height = m_bitmap->GetBmiHeight();
|
||||||
|
MxLong seek_row;
|
||||||
|
|
||||||
|
// DECOMP: Same basic layout as AlphaMask constructor
|
||||||
|
// The idea here is to again seek to the correct place in the bitmap's
|
||||||
|
// m_data buffer. The x,y args are (most likely) screen x and y, so we
|
||||||
|
// need to shift that to coordinates local to the bitmap by removing
|
||||||
|
// the MxPresenter location x and y coordinates.
|
||||||
|
if (biCompression == BI_RGB) {
|
||||||
|
if (biCompression == BI_RGB_TOPDOWN || height < 0) {
|
||||||
|
seek_row = p_y - GetLocationY();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
height = height > 0 ? height : -height;
|
||||||
|
seek_row = height - p_y - 1 + GetLocationY();
|
||||||
|
}
|
||||||
|
pixel = m_bitmap->GetBmiStride() * seek_row + m_bitmap->GetBitmapData() - GetLocationX() + p_x;
|
||||||
|
}
|
||||||
|
else if (biCompression == BI_RGB_TOPDOWN) {
|
||||||
|
pixel = m_bitmap->GetBitmapData();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
height = height > 0 ? height : -height;
|
||||||
|
height--;
|
||||||
|
pixel = m_bitmap->GetBmiStride() * height + m_bitmap->GetBitmapData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// DECOMP: m_flags is 1 byte, so no enum here
|
||||||
|
if (m_flags & 0x10)
|
||||||
|
return (MxBool) *pixel;
|
||||||
|
|
||||||
|
if ((GetAction()->GetFlags() & MxDSAction::Flag_Bit4) && *pixel == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100b2a70 STUB
|
// OFFSET: LEGO1 0x100b2a70 STUB
|
||||||
void MxVideoPresenter::VTable0x6c()
|
void MxVideoPresenter::VTable0x6c()
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,20 +30,19 @@ public:
|
||||||
|
|
||||||
virtual void Destroy() override; // vtable+0x38
|
virtual void Destroy() override; // vtable+0x38
|
||||||
|
|
||||||
virtual void VTable0x5c(undefined4 p_unknown1); // vtable+0x5c
|
virtual MxBool IsHit(MxS32 p_x, MxS32 p_y) override; // vtable+0x50
|
||||||
virtual void VTable0x60(); // vtable+0x60
|
virtual void VTable0x5c(undefined4 p_unknown1); // vtable+0x5c
|
||||||
virtual void VTable0x64(); // vtable+0x64
|
virtual void VTable0x60(); // vtable+0x60
|
||||||
virtual void VTable0x68(undefined4 p_unknown1); // vtable+0x68
|
virtual void VTable0x64(); // vtable+0x64
|
||||||
virtual void VTable0x6c(); // vtable+0x6c
|
virtual void VTable0x68(undefined4 p_unknown1); // vtable+0x68
|
||||||
virtual void VTable0x70(); // vtable+0x70
|
virtual void VTable0x6c(); // vtable+0x6c
|
||||||
virtual undefined VTable0x74(); // vtable+0x74
|
virtual void VTable0x70(); // vtable+0x70
|
||||||
virtual LPDIRECTDRAWSURFACE VTable0x78(); // vtable+0x78
|
virtual undefined VTable0x74(); // vtable+0x74
|
||||||
virtual MxBool VTable0x7c(); // vtable+0x7c
|
virtual LPDIRECTDRAWSURFACE VTable0x78(); // vtable+0x78
|
||||||
virtual MxS32 GetWidth(); // vtable+0x80
|
virtual MxBool VTable0x7c(); // vtable+0x7c
|
||||||
virtual MxS32 GetHeight(); // vtable+0x84
|
virtual MxS32 GetWidth(); // vtable+0x80
|
||||||
|
virtual MxS32 GetHeight(); // vtable+0x84
|
||||||
|
|
||||||
// TODO: Not sure what this is. Seems to have size of 12 bytes
|
|
||||||
// based on 0x100b9e9a. Values are copied from the bitmap header.
|
|
||||||
// SIZE 0xc
|
// SIZE 0xc
|
||||||
struct AlphaMask {
|
struct AlphaMask {
|
||||||
MxU8* m_bitmask;
|
MxU8* m_bitmask;
|
||||||
|
@ -53,6 +52,8 @@ public:
|
||||||
AlphaMask(const MxBitmap&);
|
AlphaMask(const MxBitmap&);
|
||||||
AlphaMask(const AlphaMask&);
|
AlphaMask(const AlphaMask&);
|
||||||
virtual ~AlphaMask();
|
virtual ~AlphaMask();
|
||||||
|
|
||||||
|
MxS32 IsHit(MxU32 p_x, MxU32 p_y);
|
||||||
};
|
};
|
||||||
|
|
||||||
MxBitmap* m_bitmap;
|
MxBitmap* m_bitmap;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue