From 50f14cb150cb0620a2ef2f3b0c42e014d1794b1a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 16 Oct 2023 16:02:00 -0400 Subject: [PATCH] Match MxVideoPresenter::Destroy to ~88% --- LEGO1/mxvideopresenter.cpp | 36 +++++++++++++++++------------------- LEGO1/mxvideopresenter.h | 14 ++++++++------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/LEGO1/mxvideopresenter.cpp b/LEGO1/mxvideopresenter.cpp index eeb5b06c..a22adcd4 100644 --- a/LEGO1/mxvideopresenter.cpp +++ b/LEGO1/mxvideopresenter.cpp @@ -2,6 +2,7 @@ #include "MxVideoManager.h" DECOMP_SIZE_ASSERT(MxVideoPresenter, 0x64); +DECOMP_SIZE_ASSERT(MxVideoPresenter::UnkStruct, 0xc); // OFFSET: LEGO1 0x1000c700 void MxVideoPresenter::VTable0x5c(undefined4 p_unknown1) @@ -40,7 +41,7 @@ void MxVideoPresenter::Destroy() } // OFFSET: LEGO1 0x1000c7b0 -MxCore* MxVideoPresenter::VTable0x78() +LPDIRECTDRAWSURFACE MxVideoPresenter::VTable0x78() { return m_unk58; } @@ -74,12 +75,13 @@ void MxVideoPresenter::Init() m_unk58 = NULL; m_unk60 = -1; m_flags = m_flags & 0xfe; - if (MVideoManager() != NULL) - { + + if (MVideoManager() != NULL) { MVideoManager(); m_flags = m_flags | 2; m_flags = m_flags & 0xfb; } + m_flags = m_flags & 0xf7; m_flags = m_flags & 0xef; } @@ -87,39 +89,35 @@ void MxVideoPresenter::Init() // OFFSET: LEGO1 0x100b27b0 void MxVideoPresenter::Destroy(MxBool p_fromDestructor) { - MxRect32 rect; if (MVideoManager() != NULL) - { MVideoManager()->RemovePresenter(*this); - } - if(m_unk58 != NULL) - { - m_unk58->Tickle(); + if (m_unk58) { + m_unk58->Release(); m_unk58 = NULL; m_flags = m_flags & 0xfd; m_flags = m_flags & 0xfb; } - if (MVideoManager() != NULL && m_unk54 != NULL && m_bitmap != NULL) - { - rect.m_right = GetWidth() + rect.m_left; - rect.m_bottom = GetHeight() + rect.m_top; - rect.m_left = GetLocationX(); - rect.m_top = GetLocationY(); + if (MVideoManager() && (m_unk54 || m_bitmap)) { + MxS32 height = GetHeight(); + MxS32 width = GetWidth(); + + MxS32 x = GetLocationX(); + MxS32 y = GetLocationY(); + MxRect32 rect(x, y, x + width, y + height); MVideoManager()->InvalidateRect(rect); MVideoManager()->vtable0x34(rect.m_left, rect.m_top, rect.GetWidth(), rect.GetHeight()); } delete m_bitmap; - delete m_unk58; + delete m_unk54; Init(); + if (!p_fromDestructor) - { - // TODO MxMediaPresenter->Destroy(FALSE) - } + MxMediaPresenter::Destroy(FALSE); } // OFFSET: LEGO1 0x100b28b0 STUB diff --git a/LEGO1/mxvideopresenter.h b/LEGO1/mxvideopresenter.h index 6caeabc2..30a6ada7 100644 --- a/LEGO1/mxvideopresenter.h +++ b/LEGO1/mxvideopresenter.h @@ -42,22 +42,24 @@ class MxVideoPresenter : public MxMediaPresenter virtual void VTable0x6c(); // vtable+0x6c virtual void VTable0x70(); // vtable+0x70 virtual undefined VTable0x74(); // vtable+0x74 - virtual MxCore* VTable0x78(); // vtable+0x78 + virtual LPDIRECTDRAWSURFACE VTable0x78(); // vtable+0x78 virtual MxBool VTable0x7c(); // vtable+0x7c 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. - typedef struct { - undefined unk0[8]; + struct UnkStruct { + undefined unk0[4]; MxU16 width; MxU16 height; - } unknown_meta_struct; + + virtual ~UnkStruct() {} + }; MxBitmap *m_bitmap; - unknown_meta_struct *m_unk54; - MxCore* m_unk58; + UnkStruct *m_unk54; + LPDIRECTDRAWSURFACE m_unk58; undefined2 m_unk5c; unsigned char m_flags; // 0x5e MxLong m_unk60;