Adjustments to MxRect32

This commit is contained in:
Christian Semmler 2023-12-29 22:45:08 -05:00
parent b4b73465d0
commit ee36b9a9c8
3 changed files with 53 additions and 31 deletions

View File

@ -8,14 +8,9 @@
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); }
// FUNCTION: LEGO1 0x100b6fc0
MxRect32(const MxPoint32& p_point, const MxSize32& p_size) { CopyFrom(p_point, p_size); }
MxRect32(const MxRect32& p_a, const MxRect32& p_b)
@ -56,12 +51,6 @@ class MxRect32 {
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)
{
m_left = Min(m_left, p_rect.m_left);
@ -92,6 +81,15 @@ class MxRect32 {
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;
@ -104,11 +102,10 @@ class MxRect32 {
{
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;
}
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

@ -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,14 @@ 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,14 @@ 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 +354,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 +403,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) {