Improve match of MxVideoPresenter::PutFrame (#606)

* Improve match of PutFrame

* Fix

* Fix

* Fix
This commit is contained in:
Christian Semmler 2024-02-29 20:45:30 -05:00 committed by GitHub
parent 49d6c88912
commit 79713698cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 61 deletions

View file

@ -113,6 +113,8 @@ class MxPresenter : public MxCore {
inline MxS32 GetCurrentTickleState() const { return this->m_currentTickleState; } inline MxS32 GetCurrentTickleState() const { return this->m_currentTickleState; }
inline MxPoint32 GetLocation() const { return this->m_location; } inline MxPoint32 GetLocation() const { return this->m_location; }
inline MxS32 GetX() const { return this->m_location.GetX(); }
inline MxS32 GetY() const { return this->m_location.GetY(); }
inline MxS32 GetDisplayZ() const { return this->m_displayZ; } inline MxS32 GetDisplayZ() const { return this->m_displayZ; }
inline MxDSAction* GetAction() const { return this->m_action; } inline MxDSAction* GetAction() const { return this->m_action; }

View file

@ -89,7 +89,7 @@ class MxVideoPresenter : public MxMediaPresenter {
// MxVideoPresenter::AlphaMask::`scalar deleting destructor' // MxVideoPresenter::AlphaMask::`scalar deleting destructor'
}; };
inline MxS32 PrepareRects(MxRect32& p_rectDest, MxRect32& p_rectSrc); inline MxS32 PrepareRects(RECT& p_rectDest, RECT& p_rectSrc);
inline MxBitmap* GetBitmap() { return m_bitmap; } inline MxBitmap* GetBitmap() { return m_bitmap; }
inline AlphaMask* GetAlphaMask() { return m_alpha; } inline AlphaMask* GetAlphaMask() { return m_alpha; }

View file

@ -253,47 +253,41 @@ MxBool MxVideoPresenter::IsHit(MxS32 p_x, MxS32 p_y)
return TRUE; return TRUE;
} }
inline MxS32 MxVideoPresenter::PrepareRects(MxRect32& p_rectDest, MxRect32& p_rectSrc) inline MxS32 MxVideoPresenter::PrepareRects(RECT& p_rectDest, RECT& p_rectSrc)
{ {
if (p_rectDest.GetTop() > 480 || p_rectDest.GetLeft() > 640 || p_rectSrc.GetTop() > 480 || if (p_rectDest.top > 480 || p_rectDest.left > 640 || p_rectSrc.top > 480 || p_rectSrc.left > 640) {
p_rectSrc.GetLeft() > 640) {
return -1; return -1;
} }
if (p_rectDest.GetBottom() > 480) { if (p_rectDest.bottom > 480) {
p_rectDest.SetBottom(480); p_rectDest.bottom = 480;
} }
if (p_rectDest.GetRight() > 640) { if (p_rectDest.right > 640) {
p_rectDest.SetRight(640); p_rectDest.right = 640;
} }
if (p_rectSrc.GetBottom() > 480) { if (p_rectSrc.bottom > 480) {
p_rectSrc.SetBottom(480); p_rectSrc.bottom = 480;
} }
if (p_rectSrc.GetRight() > 640) { if (p_rectSrc.right > 640) {
p_rectSrc.SetRight(640); p_rectSrc.right = 640;
} }
MxS32 height = p_rectDest.GetHeight(); LONG height, width;
if (height <= 1) { if ((height = (p_rectDest.bottom - p_rectDest.top) + 1) <= 1 ||
(width = (p_rectDest.right - p_rectDest.left) + 1) <= 1) {
return -1; return -1;
} }
else if ((p_rectSrc.right - p_rectSrc.left + 1) == width && (p_rectSrc.bottom - p_rectSrc.top + 1) == height) {
MxS32 width = p_rectDest.GetWidth();
if (width <= 1) {
return -1;
}
if (p_rectSrc.GetRight() - width - p_rectSrc.GetLeft() == -1 &&
p_rectSrc.GetBottom() - height - p_rectSrc.GetTop() == -1) {
return 1; return 1;
} }
else {
p_rectSrc.SetRight(p_rectSrc.GetLeft() + width - 1); p_rectSrc.right = (p_rectSrc.left + width) - 1;
p_rectSrc.SetBottom(p_rectSrc.GetTop() + height - 1); p_rectSrc.bottom = (p_rectSrc.top + height) - 1;
return 0; return 0;
}
} }
// FUNCTION: LEGO1 0x100b2a70 // FUNCTION: LEGO1 0x100b2a70
@ -301,33 +295,29 @@ 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(), GetHeight())); MxRect32 rect(MxPoint32(0, 0), MxSize32(GetWidth(), GetHeight()));
rect.AddPoint(GetLocation());
LPDIRECTDRAWSURFACE ddSurface = displaySurface->GetDirectDrawSurface2(); LPDIRECTDRAWSURFACE ddSurface = displaySurface->GetDirectDrawSurface2();
MxRect32 rectSrc, rectDest;
if (m_action->GetFlags() & MxDSAction::c_bit5) { if (m_action->GetFlags() & MxDSAction::c_bit5) {
if (m_unk0x58) { if (m_unk0x58) {
// TODO: Match RECT src, dest;
rectSrc.SetPoint(MxPoint32(0, 0)); src.top = 0;
rectSrc.SetRight(GetWidth()); src.left = 0;
rectSrc.SetBottom(GetHeight()); src.right = GetWidth();
src.bottom = GetHeight();
rectDest.SetPoint(m_location); dest.left = GetX();
rectDest.SetRight(rectDest.GetLeft() + GetWidth()); dest.top = GetY();
rectDest.SetBottom(rectDest.GetTop() + GetHeight()); dest.right = dest.left + GetWidth();
dest.bottom = dest.top + GetHeight();
switch (PrepareRects(rectDest, rectSrc)) { switch (PrepareRects(src, dest)) {
case 0: case 0:
ddSurface->Blt((LPRECT) &rectDest, m_unk0x58, (LPRECT) &rectSrc, DDBLT_KEYSRC, NULL); ddSurface->Blt(&dest, m_unk0x58, &src, DDBLT_KEYSRC, NULL);
break; break;
case 1: case 1:
ddSurface->BltFast( ddSurface->BltFast(dest.left, dest.top, m_unk0x58, &src, DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT);
rectDest.GetLeft(),
rectDest.GetTop(),
m_unk0x58,
(LPRECT) &rectSrc,
DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT
);
} }
} }
else { else {
@ -349,29 +339,31 @@ 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) { RECT src, dest;
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()); if (m_unk0x58) {
rectDest.SetTop(regionRect->GetTop()); src.left = regionRect->GetLeft() - GetX();
rectDest.SetRight(rectDest.GetLeft() + regionRect->GetWidth()); src.top = regionRect->GetTop() - GetY();
rectDest.SetBottom(rectDest.GetTop() + regionRect->GetHeight()); src.right = src.left + regionRect->GetWidth();
src.bottom = src.top + regionRect->GetHeight();
dest.left = regionRect->GetLeft();
dest.top = regionRect->GetTop();
dest.right = dest.left + regionRect->GetWidth();
dest.bottom = dest.top + regionRect->GetHeight();
} }
if (m_action->GetFlags() & MxDSAction::c_bit4) { if (m_action->GetFlags() & MxDSAction::c_bit4) {
if (m_unk0x58) { if (m_unk0x58) {
if (PrepareRects(rectDest, rectSrc) >= 0) { if (PrepareRects(src, dest) >= 0) {
ddSurface->Blt((LPRECT) &rectDest, m_unk0x58, (LPRECT) &rectSrc, DDBLT_KEYSRC, NULL); ddSurface->Blt(&dest, m_unk0x58, &src, DDBLT_KEYSRC, NULL);
} }
} }
else { else {
displaySurface->VTable0x30( displaySurface->VTable0x30(
m_bitmap, m_bitmap,
regionRect->GetLeft() - m_location.GetX(), regionRect->GetLeft() - GetX(),
regionRect->GetTop() - m_location.GetY(), regionRect->GetTop() - GetY(),
regionRect->GetLeft(), regionRect->GetLeft(),
regionRect->GetTop(), regionRect->GetTop(),
regionRect->GetWidth(), regionRect->GetWidth(),
@ -381,15 +373,15 @@ void MxVideoPresenter::PutFrame()
} }
} }
else if (m_unk0x58) { else if (m_unk0x58) {
if (PrepareRects(rectDest, rectSrc) >= 0) { if (PrepareRects(src, dest) >= 0) {
ddSurface->Blt((LPRECT) &rectDest, m_unk0x58, (LPRECT) &rectSrc, 0, NULL); ddSurface->Blt(&dest, m_unk0x58, &src, 0, NULL);
} }
} }
else { else {
displaySurface->VTable0x28( displaySurface->VTable0x28(
m_bitmap, m_bitmap,
regionRect->GetLeft() - m_location.GetX(), regionRect->GetLeft() - GetX(),
regionRect->GetTop() - m_location.GetY(), regionRect->GetTop() - GetY(),
regionRect->GetLeft(), regionRect->GetLeft(),
regionRect->GetTop(), regionRect->GetTop(),
regionRect->GetWidth(), regionRect->GetWidth(),