From 7c6807de8ffc172a99f358e5457e889df0eaf9cb Mon Sep 17 00:00:00 2001 From: disinvite Date: Mon, 2 Oct 2023 18:09:30 -0400 Subject: [PATCH] MxTransitionManager::Dissolve --- LEGO1/mxdisplaysurface.h | 1 + LEGO1/mxtransitionmanager.cpp | 97 +++++++++++++++++++++++++++++++++++ LEGO1/mxtransitionmanager.h | 8 ++- 3 files changed, 105 insertions(+), 1 deletion(-) diff --git a/LEGO1/mxdisplaysurface.h b/LEGO1/mxdisplaysurface.h index 4c2c3866..9bbc44bc 100644 --- a/LEGO1/mxdisplaysurface.h +++ b/LEGO1/mxdisplaysurface.h @@ -33,6 +33,7 @@ class MxDisplaySurface : public MxCore virtual void ReleaseDC(HDC p_hdc); virtual undefined4 vtable44(undefined4, undefined4*, undefined4, undefined4); + inline LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return this->m_ddSurface1; } inline LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return this->m_ddSurface2; } private: diff --git a/LEGO1/mxtransitionmanager.cpp b/LEGO1/mxtransitionmanager.cpp index c5a0cb27..fe0e3950 100644 --- a/LEGO1/mxtransitionmanager.cpp +++ b/LEGO1/mxtransitionmanager.cpp @@ -4,6 +4,9 @@ DECOMP_SIZE_ASSERT(MxTransitionManager, 0x900); +// 0x100f4378 +RECT g_rect_100f4378 = {0, 0, 640, 480}; + // OFFSET: LEGO1 0x1004b8d0 MxTransitionManager::MxTransitionManager() { @@ -38,12 +41,106 @@ MxResult MxTransitionManager::Tickle() return 0; } +// OFFSET: LEGO1 0x1004bc30 STUB +void MxTransitionManager::EndTransition(MxBool) +{ + // TODO +} + +// OFFSET: LEGO1 0x1004bd10 +void MxTransitionManager::Transition_Dissolve() +{ + // If the animation is finished + if (m_animationTimer == 40) { + m_animationTimer = 0; + EndTransition(TRUE); + return; + } + + // If we are starting the animation + if (m_animationTimer == 0) { + // Populate + for (int i = 0; i < 640; i++) { + m_pad36[i] = i; + } + + // Randomize (sorta) + for (i = 0; i < 640; i++) { + int swap_ofs = rand() % 640; + undefined2 t = m_pad36[i]; + m_pad36[i] = m_pad36[swap_ofs]; + m_pad36[swap_ofs] = t; + } + + for (i = 0; i < 480; i++) { + m_pad536[i] = rand() % 640; + } + } + + // Else run one tick of the animation + DDSURFACEDESC ddsd; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + + HRESULT res = m_ddSurface->Lock(NULL, &ddsd, 1, NULL); + if (res == DDERR_SURFACELOST) { + m_ddSurface->Restore(); + res = m_ddSurface->Lock(NULL, &ddsd, 1, NULL); + } + + if (res == DD_OK) { + FUN_1004c4d0(&ddsd); + + for (int i = 0; i < 640; i++) { + if (m_animationTimer * 16 > m_pad36[i]) + continue; + + if (m_animationTimer * 16 + 15 < m_pad36[i]) + continue; + + for (int j = 0; j < 480; j++) { + int jt = (m_pad536[j] + i) % 640; + + if (ddsd.ddpfPixelFormat.dwRGBBitCount == 8) { + MxU8 *pix = (MxU8*)ddsd.lpSurface; + pix[j * ddsd.lPitch + jt] = 0; + } else { + MxU16 *pix = (MxU16*)ddsd.lpSurface; + pix[j * ddsd.lPitch + jt] = 0; + } + } + } + + FUN_1004c580(&ddsd); + m_ddSurface->Unlock(ddsd.lpSurface); + + if (VideoManager()->GetVideoParam().flags().GetFlipSurfaces()) { + LPDIRECTDRAWSURFACE surf = VideoManager()->GetDisplaySurface()->GetDirectDrawSurface1(); + surf->BltFast(NULL, NULL, m_ddSurface, &g_rect_100f4378, 0x10); + } + + m_animationTimer++; + } +} + // 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 { diff --git a/LEGO1/mxtransitionmanager.h b/LEGO1/mxtransitionmanager.h index 723366c1..35101bed 100644 --- a/LEGO1/mxtransitionmanager.h +++ b/LEGO1/mxtransitionmanager.h @@ -89,6 +89,11 @@ class MxTransitionManager : public MxCore MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_unk, MxBool p_playMusicInAnim); private: + void EndTransition(MxBool); + void Transition_Dissolve(); + void FUN_1004c4d0(DDSURFACEDESC*); + void FUN_1004c580(DDSURFACEDESC*); + MxTransitionManagerUnknownSubclass1 *m_unk08; undefined4 m_unk0c; undefined4 m_unk10; @@ -102,7 +107,8 @@ class MxTransitionManager : public MxCore TransitionType m_transitionType; LPDIRECTDRAWSURFACE m_ddSurface; MxU16 m_animationTimer; - undefined m_pad36[0x8c2]; + undefined2 m_pad36[640]; // 0x36 + undefined2 m_pad536[480]; // 0x536 MxULong m_systemTime; MxS32 m_animationSpeed; };