Merge branch 'rect-adjustments' into rectthing

This commit is contained in:
Christian Semmler 2023-12-29 22:56:08 -05:00
commit 484f55448c
3 changed files with 53 additions and 31 deletions

View File

@ -8,14 +8,9 @@
class MxRect32 { class MxRect32 {
public: public:
MxRect32() {} MxRect32() {}
MxRect32(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom) MxRect32(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom) { CopyFrom(p_left, p_top, p_right, p_bottom); }
{
this->m_left = p_left;
this->m_top = p_top;
this->m_right = p_right;
this->m_bottom = p_bottom;
}
// FUNCTION: LEGO1 0x100b6fc0
MxRect32(const MxPoint32& p_point, const MxSize32& p_size) { CopyFrom(p_point, p_size); } MxRect32(const MxPoint32& p_point, const MxSize32& p_size) { CopyFrom(p_point, p_size); }
MxRect32(const MxRect32& p_a, const MxRect32& p_b) MxRect32(const MxRect32& p_a, const MxRect32& p_b)
@ -64,12 +59,6 @@ class MxRect32 {
this->m_bottom -= p_point.GetY(); this->m_bottom -= p_point.GetY();
} }
inline void SetSize(const MxSize32& p_size)
{
this->m_right = p_size.GetWidth();
this->m_bottom = p_size.GetHeight();
}
inline void UpdateBounds(const MxRect32& p_rect) inline void UpdateBounds(const MxRect32& p_rect)
{ {
m_left = Min(m_left, p_rect.m_left); m_left = Min(m_left, p_rect.m_left);
@ -100,6 +89,15 @@ class MxRect32 {
inline void SetRight(MxS32 p_right) { m_right = p_right; } inline void SetRight(MxS32 p_right) { m_right = p_right; }
inline void SetBottom(MxS32 p_bottom) { m_bottom = p_bottom; } 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) inline void CopyFrom(const MxRect32& p_rect)
{ {
this->m_left = p_rect.m_left; this->m_left = p_rect.m_left;
@ -112,11 +110,10 @@ class MxRect32 {
{ {
this->m_left = p_point.GetX(); this->m_left = p_point.GetX();
this->m_top = p_point.GetY(); this->m_top = p_point.GetY();
this->m_right = p_size.GetWidth() + p_point.GetX(); this->m_right = p_size.GetWidth() + p_point.GetX() - 1;
this->m_bottom = p_size.GetHeight() + p_point.GetY(); this->m_bottom = p_size.GetHeight() + p_point.GetY() - 1;
} }
private:
inline static MxS32 Min(MxS32 p_a, MxS32 p_b) { return p_a <= p_b ? p_a : p_b; }; 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; }; inline static MxS32 Max(MxS32 p_a, MxS32 p_b) { return p_a <= p_b ? p_b : p_a; };

View File

@ -71,7 +71,13 @@ void MxStillPresenter::LoadFrame(MxStreamChunk* p_chunk)
{ {
memcpy(m_bitmap->GetBitmapData(), p_chunk->GetData(), p_chunk->GetLength()); 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); MVideoManager()->InvalidateRect(rect);
if (m_flags & Flag_Bit2) { if (m_flags & Flag_Bit2) {
@ -170,7 +176,14 @@ void MxStillPresenter::Enable(MxBool p_enable)
MxVideoPresenter::Enable(p_enable); MxVideoPresenter::Enable(p_enable);
if (MVideoManager() && (m_alpha || m_bitmap)) { 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()->InvalidateRect(rect);
MVideoManager()->VTable0x34(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); MVideoManager()->VTable0x34(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
} }

View File

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