Implement FUN_100b6e10 and MxRect32 adjustments (#390)

* Some WIP rect

* Adjustments to MxRect32

* Spacing

* Changes

* Spacing

* Spacing
This commit is contained in:
Christian Semmler 2023-12-29 23:55:36 -05:00 committed by GitHub
parent b4b73465d0
commit bb22b21260
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 129 additions and 41 deletions

View file

@ -695,6 +695,52 @@ MxResult Start(MxDSAction* p_dsAction)
return MxOmni::GetInstance()->Start(p_dsAction);
}
// Probably should be somewhere else
// FUNCTION: LEGO1 0x100b6e10
MxBool FUN_100b6e10(
MxS32 p_bitmapWidth,
MxS32 p_bitmapHeight,
MxS32 p_videoParamWidth,
MxS32 p_videoParamHeight,
MxS32* p_left,
MxS32* p_top,
MxS32* p_right,
MxS32* p_bottom,
MxS32* p_width,
MxS32* p_height
)
{
MxPoint32 topLeft(*p_left, *p_top);
MxRect32 bitmapRect(MxPoint32(0, 0), MxSize32(p_bitmapWidth, p_bitmapHeight));
MxPoint32 bottomRight(*p_right, *p_bottom);
MxRect32 videoParamRect(MxPoint32(0, 0), MxSize32(p_videoParamWidth, p_videoParamHeight));
MxRect32 rect(0, 0, *p_width, *p_height);
rect.AddPoint(topLeft);
if (!rect.IntersectsWith(bitmapRect))
return FALSE;
rect.Intersect(bitmapRect);
rect.SubtractPoint(topLeft);
rect.AddPoint(bottomRight);
if (!rect.IntersectsWith(videoParamRect))
return FALSE;
rect.Intersect(videoParamRect);
rect.SubtractPoint(bottomRight);
*p_left += rect.GetLeft();
*p_top += rect.GetTop();
*p_right += rect.GetLeft();
*p_bottom += rect.GetTop();
*p_width = rect.GetWidth();
*p_height = rect.GetHeight();
return TRUE;
}
// FUNCTION: LEGO1 0x100b6ff0
void MakeSourceName(char* p_output, const char* p_input)
{

View file

@ -166,6 +166,19 @@ void FUN_10015820(MxU32, MxU32);
LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid);
MxDSAction& GetCurrentAction();
MxBool FUN_100b6e10(
MxS32 p_bitmapWidth,
MxS32 p_bitmapHeight,
MxS32 p_videoParamWidth,
MxS32 p_videoParamHeight,
MxS32* p_left,
MxS32* p_top,
MxS32* p_right,
MxS32* p_bottom,
MxS32* p_width,
MxS32* p_height
);
void PlayMusic(MxU32 p_index);
void SetIsWorldActive(MxBool p_isWorldActive);
void RegisterScripts();

View file

@ -6,12 +6,7 @@
class MxPoint32 {
public:
MxPoint32() {}
MxPoint32(MxS32 p_x, MxS32 p_y)
{
this->m_x = p_x;
this->m_y = p_y;
}
MxPoint32(MxS32 p_x, MxS32 p_y) { CopyFrom(p_x, p_y); }
MxPoint32(const MxPoint32& p_point)
{
this->m_x = p_point.m_x;
@ -25,8 +20,14 @@ public:
inline void SetY(MxS32 p_y) { m_y = p_y; }
private:
MxS32 m_x;
MxS32 m_y;
inline void CopyFrom(MxS32 p_x, MxS32 p_y)
{
this->m_x = p_x;
this->m_y = p_y;
}
MxS32 m_x; // 0x00
MxS32 m_y; // 0x04
};
#endif // MXPOINT32_H

View file

@ -8,16 +8,8 @@
class MxRect32 {
public:
MxRect32() {}
MxRect32(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom)
{
this->m_left = p_left;
this->m_top = p_top;
this->m_right = p_right;
this->m_bottom = p_bottom;
}
MxRect32(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom) { CopyFrom(p_left, p_top, p_right, p_bottom); }
MxRect32(const MxPoint32& p_point, const MxSize32& p_size) { CopyFrom(p_point, p_size); }
MxRect32(const MxRect32& p_a, const MxRect32& p_b)
{
m_left = Max(p_a.m_left, p_b.m_left);
@ -56,10 +48,12 @@ public:
this->m_bottom += p_point.GetY();
}
inline void SetSize(const MxSize32& p_size)
inline void SubtractPoint(const MxPoint32& p_point)
{
this->m_right = p_size.GetWidth();
this->m_bottom = p_size.GetHeight();
this->m_left -= p_point.GetX();
this->m_top -= p_point.GetY();
this->m_right -= p_point.GetX();
this->m_bottom -= p_point.GetY();
}
inline void UpdateBounds(const MxRect32& p_rect)
@ -92,6 +86,15 @@ public:
inline void SetRight(MxS32 p_right) { m_right = p_right; }
inline void SetBottom(MxS32 p_bottom) { m_bottom = p_bottom; }
private:
inline void CopyFrom(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom)
{
this->m_left = p_left;
this->m_top = p_top;
this->m_right = p_right;
this->m_bottom = p_bottom;
}
inline void CopyFrom(const MxRect32& p_rect)
{
this->m_left = p_rect.m_left;
@ -100,15 +103,17 @@ public:
this->m_bottom = p_rect.m_bottom;
}
inline void CopyFrom(const MxPoint32& p_point, const MxSize32& p_size)
// The address might also be the constructor that calls CopyFrom
// FUNCTION: LEGO1 0x100b6fc0
inline MxRect32* CopyFrom(const MxPoint32& p_point, const MxSize32& p_size)
{
this->m_left = p_point.GetX();
this->m_top = p_point.GetY();
this->m_right = p_size.GetWidth() + p_point.GetX();
this->m_bottom = p_size.GetHeight() + p_point.GetY();
this->m_right = p_size.GetWidth() + p_point.GetX() - 1;
this->m_bottom = p_size.GetHeight() + p_point.GetY() - 1;
return this;
}
private:
inline static MxS32 Min(MxS32 p_a, MxS32 p_b) { return p_a <= p_b ? p_a : p_b; };
inline static MxS32 Max(MxS32 p_a, MxS32 p_b) { return p_a <= p_b ? p_b : p_a; };

View file

@ -6,13 +6,13 @@
class MxSize32 {
public:
MxSize32() {}
MxSize32(MxS32 p_width, MxS32 p_height) { Assign(p_width, p_height); }
MxSize32(MxS32 p_width, MxS32 p_height) { CopyFrom(p_width, p_height); }
inline MxS32 GetWidth() const { return m_width; }
inline MxS32 GetHeight() const { return m_height; }
private:
inline void Assign(MxS32 p_width, MxS32 p_height)
inline void CopyFrom(MxS32 p_width, MxS32 p_height)
{
this->m_width = p_width;
this->m_height = p_height;

View file

@ -71,7 +71,13 @@ void MxStillPresenter::LoadFrame(MxStreamChunk* p_chunk)
{
memcpy(m_bitmap->GetBitmapData(), p_chunk->GetData(), p_chunk->GetLength());
MxRect32 rect(m_location, MxSize32(GetWidth() - 1, GetHeight() - 1));
// MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
MxS32 height = GetHeight() - 1;
MxS32 width = GetWidth() - 1;
MxS32 x = m_location.GetX();
MxS32 y = m_location.GetY();
MxRect32 rect(x, y, width + x, height + y);
MVideoManager()->InvalidateRect(rect);
if (m_flags & Flag_Bit2) {
@ -170,7 +176,13 @@ void MxStillPresenter::Enable(MxBool p_enable)
MxVideoPresenter::Enable(p_enable);
if (MVideoManager() && (m_alpha || m_bitmap)) {
MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
// MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
MxS32 height = GetHeight();
MxS32 width = GetWidth();
MxS32 x = m_location.GetX();
MxS32 y = m_location.GetY();
MxRect32 rect(x, y, width + x, height + y);
MVideoManager()->InvalidateRect(rect);
MVideoManager()->VTable0x34(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
}

View file

@ -215,7 +215,13 @@ void MxVideoPresenter::Destroy(MxBool p_fromDestructor)
}
if (MVideoManager() && (m_alpha || m_bitmap)) {
MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
// MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
MxS32 height = GetHeight();
MxS32 width = GetWidth();
MxS32 x = m_location.GetX();
MxS32 y = m_location.GetY();
MxRect32 rect(x, y, x + width, y + height);
MVideoManager()->InvalidateRect(rect);
MVideoManager()->VTable0x34(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
}
@ -347,15 +353,20 @@ void MxVideoPresenter::PutFrame()
{
MxDisplaySurface* displaySurface = MVideoManager()->GetDisplaySurface();
MxRegion* region = MVideoManager()->GetRegion();
MxRect32 rect(m_location, MxSize32(GetWidth() - 1, GetHeight() - 1));
MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
LPDIRECTDRAWSURFACE ddSurface = displaySurface->GetDirectDrawSurface2();
MxRect32 rectSrc, rectDest;
if (m_action->GetFlags() & MxDSAction::Flag_Bit5) {
if (m_unk0x58) {
// TODO: Match
rectSrc.CopyFrom(MxPoint32(0, 0), MxSize32(GetWidth(), GetHeight()));
rectDest.CopyFrom(m_location, MxSize32(GetWidth(), GetHeight()));
rectSrc.SetPoint(MxPoint32(0, 0));
rectSrc.SetRight(GetWidth());
rectSrc.SetBottom(GetHeight());
rectDest.SetPoint(m_location);
rectDest.SetRight(rectDest.GetLeft() + GetWidth());
rectDest.SetBottom(rectDest.GetTop() + GetHeight());
switch (PrepareRects(rectDest, rectSrc)) {
case 0:
@ -391,15 +402,15 @@ void MxVideoPresenter::PutFrame()
while (regionRect = cursor.VTable0x24(rect)) {
if (regionRect->GetWidth() >= 1 && regionRect->GetHeight() >= 1) {
if (m_unk0x58) {
// TODO: Match
rectSrc.CopyFrom(
MxPoint32(regionRect->GetLeft() - m_location.GetX(), regionRect->GetTop() - m_location.GetY()),
MxSize32(regionRect->GetWidth(), regionRect->GetHeight())
);
rectDest.CopyFrom(
MxPoint32(regionRect->GetLeft(), regionRect->GetTop()),
MxSize32(regionRect->GetWidth(), regionRect->GetHeight())
);
rectSrc.SetLeft(regionRect->GetLeft() - m_location.GetX());
rectSrc.SetTop(regionRect->GetTop() - m_location.GetY());
rectSrc.SetRight(rectSrc.GetLeft() + regionRect->GetWidth());
rectSrc.SetBottom(rectSrc.GetTop() + regionRect->GetHeight());
rectDest.SetLeft(regionRect->GetLeft());
rectDest.SetTop(regionRect->GetTop());
rectDest.SetRight(rectDest.GetLeft() + regionRect->GetWidth());
rectDest.SetBottom(rectDest.GetTop() + regionRect->GetHeight());
}
if (m_action->GetFlags() & MxDSAction::Flag_Bit4) {