From bb1782af46509c5cfe7d88e56411b95f7c8f42fc Mon Sep 17 00:00:00 2001 From: Regan Green Date: Wed, 4 Oct 2023 03:22:59 -0400 Subject: [PATCH] Implement MxTransitionManager::SubmitCopyRect --- LEGO1/mxdsaction.h | 2 + LEGO1/mxpresenter.h | 1 + LEGO1/mxtransitionmanager.cpp | 94 ++++++++++++++++++++++------------- LEGO1/mxtransitionmanager.h | 64 +++--------------------- 4 files changed, 71 insertions(+), 90 deletions(-) diff --git a/LEGO1/mxdsaction.h b/LEGO1/mxdsaction.h index 01dfcf2c..9a351334 100644 --- a/LEGO1/mxdsaction.h +++ b/LEGO1/mxdsaction.h @@ -57,6 +57,8 @@ class MxDSAction : public MxDSObject inline char *GetExtraData() { return m_extraData; } inline MxU16 GetExtraLength() const { return m_extraLength; } inline MxLong GetStartTime() const { return m_startTime; } + inline MxS32 GetLoopCount() { return m_loopCount; } + inline void SetLoopCount(MxS32 m_loopCount) { this->m_loopCount = m_loopCount; } inline const MxVector3Data &GetLocation() const { return m_location; } inline void SetOmni(MxOmni *p_omni) { m_omni = p_omni; } diff --git a/LEGO1/mxpresenter.h b/LEGO1/mxpresenter.h index 1537d2d3..c0757665 100644 --- a/LEGO1/mxpresenter.h +++ b/LEGO1/mxpresenter.h @@ -69,6 +69,7 @@ class MxPresenter : public MxCore MxBool IsEnabled(); inline MxS32 GetDisplayZ() { return this->m_displayZ; } + inline MxDSAction *GetAction() { return this->m_action; } protected: __declspec(dllexport) void Init(); diff --git a/LEGO1/mxtransitionmanager.cpp b/LEGO1/mxtransitionmanager.cpp index 61283718..425fb37c 100644 --- a/LEGO1/mxtransitionmanager.cpp +++ b/LEGO1/mxtransitionmanager.cpp @@ -13,9 +13,9 @@ MxTransitionManager::MxTransitionManager() m_animationTimer = 0; m_transitionType = NOT_TRANSITIONING; m_ddSurface = NULL; - m_unk08 = 0; - m_unk1c = 0; - m_unk20.bit0 = FALSE; + m_waitIndicator = NULL; + m_copyBuffer = NULL; + m_copyFlags.bit0 = FALSE; m_unk28.bit0 = FALSE; m_unk24 = 0; } @@ -23,11 +23,11 @@ MxTransitionManager::MxTransitionManager() // OFFSET: LEGO1 0x1004ba00 MxTransitionManager::~MxTransitionManager() { - free(m_unk1c); + free(m_copyBuffer); - if (m_unk08 != NULL) { - delete m_unk08->m_unk1c; - delete m_unk08; + if (m_waitIndicator != NULL) { + delete m_waitIndicator->GetAction(); + delete m_waitIndicator; } TickleManager()->UnregisterClient(this); @@ -90,7 +90,7 @@ void MxTransitionManager::Transition_Dissolve() } if (res == DD_OK) { - FUN_1004c4d0(ddsd); + SubmitCopyRect(ddsd); for (MxS32 i = 0; i < 640; i++) { // Select 16 columns on each tick @@ -115,7 +115,7 @@ void MxTransitionManager::Transition_Dissolve() } } - FUN_1004c580(ddsd); + SetupCopyRect(ddsd); m_ddSurface->Unlock(ddsd.lpSurface); if (VideoManager()->GetVideoParam().flags().GetFlipSurfaces()) { @@ -127,24 +127,6 @@ void MxTransitionManager::Transition_Dissolve() } } -// OFFSET: LEGO1 0x1004c470 STUB -void MxTransitionManager::SetWaitIndicator(MxVideoPresenter *videoPresenter) -{ - // TODO -} - -// OFFSET: LEGO1 0x1004c4d0 STUB -void MxTransitionManager::FUN_1004c4d0(DDSURFACEDESC &ddsc) -{ - // TODO -} - -// OFFSET: LEGO1 0x1004c580 STUB -void MxTransitionManager::FUN_1004c580(DDSURFACEDESC &ddsc) -{ - // TODO -} - // OFFSET: LEGO1 0x1004baa0 MxResult MxTransitionManager::GetDDrawSurfaceFromVideoManager() // vtable+0x14 { @@ -155,7 +137,7 @@ MxResult MxTransitionManager::GetDDrawSurfaceFromVideoManager() // vtable+0x14 // OFFSET: LEGO1 0x1004bb70 MxResult MxTransitionManager::StartTransition(TransitionType p_animationType, MxS32 p_speed, - MxBool p_unk, MxBool p_playMusicInAnim) + MxBool p_doCopy, MxBool p_playMusicInAnim) { if (this->m_transitionType == NOT_TRANSITIONING) { if (!p_playMusicInAnim) { @@ -165,14 +147,14 @@ MxResult MxTransitionManager::StartTransition(TransitionType p_animationType, Mx this->m_transitionType = p_animationType; - m_unk20.bit0 = p_unk; + m_copyFlags.bit0 = p_doCopy; - if (m_unk20.bit0 && m_unk08 != NULL) { - m_unk08->vtable54(1); + if (m_copyFlags.bit0 && m_waitIndicator != NULL) { + m_waitIndicator->Enable(TRUE); - MxTransitionManagerUnknownSubclass2 *iVar2 = m_unk08->m_unk1c; - iVar2->m_unk3c = 10000; - iVar2->m_unk30 |= 0x200; + MxDSAction *action = m_waitIndicator->GetAction(); + action->SetLoopCount(10000); + action->SetFlags(action->GetFlags() | 0x200); } MxU32 time = timeGetTime(); @@ -195,3 +177,47 @@ MxResult MxTransitionManager::StartTransition(TransitionType p_animationType, Mx } return FAILURE; } + +// OFFSET: LEGO1 0x1004c470 STUB +void MxTransitionManager::SetWaitIndicator(MxVideoPresenter *videoPresenter) +{ + // TODO +} + +// OFFSET: LEGO1 0x1004c4d0 +void MxTransitionManager::SubmitCopyRect(DDSURFACEDESC &ddsc) +{ + // Check if the copy rect is setup + if (m_copyFlags.bit0 == FALSE || m_waitIndicator == NULL || m_copyBuffer == NULL) { + return; + } + + // Copy the copy rect onto the surface + char *dst; + + DWORD bytesPerPixel = ddsc.ddpfPixelFormat.dwRGBBitCount / 8; + + const char *src = (const char *)m_copyBuffer; + + LONG copyPitch; + copyPitch = ((m_copyRect.right - m_copyRect.left) + 1) * bytesPerPixel; + + LONG y; + dst = (char *)ddsc.lpSurface + (ddsc.lPitch * m_copyRect.top) + (bytesPerPixel * m_copyRect.left); + + for (y = 0; y < m_copyRect.bottom - m_copyRect.top + 1; ++y) { + memcpy(dst, src, copyPitch); + src += copyPitch; + dst += ddsc.lPitch; + } + + // Free the copy buffer + free(m_copyBuffer); + m_copyBuffer = NULL; +} + +// OFFSET: LEGO1 0x1004c580 STUB +void MxTransitionManager::SetupCopyRect(DDSURFACEDESC &ddsc) +{ + // TODO +} diff --git a/LEGO1/mxtransitionmanager.h b/LEGO1/mxtransitionmanager.h index 09d3e622..4e559c67 100644 --- a/LEGO1/mxtransitionmanager.h +++ b/LEGO1/mxtransitionmanager.h @@ -5,52 +5,6 @@ #include "mxvideopresenter.h" #include "legoomni.h" -class MxTransitionManagerUnknownSubclass2 -{ -public: - virtual ~MxTransitionManagerUnknownSubclass2(){} - - undefined m_unk04[0x2c]; - undefined4 m_unk30; - undefined4 m_unk34; - undefined4 m_unk38; - undefined4 m_unk3c; - -}; - -// TODO: Don't know what this is yet -class MxTransitionManagerUnknownSubclass1 -{ -public: - virtual ~MxTransitionManagerUnknownSubclass1(){} - - virtual void vtable04(); - virtual void vtable08(); - virtual void vtable0c(); - virtual void vtable10(); - virtual void vtable14(); - virtual void vtable18(); - virtual void vtable1c(); - virtual void vtable20(); - virtual void vtable24(); - virtual void vtable28(); - virtual void vtable2c(); - virtual void vtable30(); - virtual void vtable34(); - virtual void vtable38(); - virtual void vtable3c(); - virtual void vtable40(); - virtual void vtable44(); - virtual void vtable48(); - virtual void vtable4c(); - virtual void vtable50(); - virtual void vtable54(undefined4 p_unk1); - - undefined m_unk04[0x18]; - MxTransitionManagerUnknownSubclass2 *m_unk1c; - -}; - // VTABLE 0x100d7ea0 class MxTransitionManager : public MxCore { @@ -86,21 +40,19 @@ class MxTransitionManager : public MxCore BROKEN // Unknown what this is supposed to be, it locks the game up }; - MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_unk, MxBool p_playMusicInAnim); + MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_doCopy, MxBool p_playMusicInAnim); private: void EndTransition(MxBool); void Transition_Dissolve(); - void FUN_1004c4d0(DDSURFACEDESC &); - void FUN_1004c580(DDSURFACEDESC &); + void SubmitCopyRect(DDSURFACEDESC &); + void SetupCopyRect(DDSURFACEDESC &); - MxTransitionManagerUnknownSubclass1 *m_unk08; - undefined4 m_unk0c; - undefined4 m_unk10; - undefined4 m_unk14; - undefined4 m_unk18; - void *m_unk1c; - flag_bitfield m_unk20; + MxVideoPresenter *m_waitIndicator; + RECT m_copyRect; + void *m_copyBuffer; + + flag_bitfield m_copyFlags; undefined4 m_unk24; flag_bitfield m_unk28;