From 35e5a62ff747e83459ece70a5ded139c2c42685b Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 19 Jan 2024 10:33:04 -0500 Subject: [PATCH] Implement/match MxLoopingFlcPresenter remaining functions (#459) * Implement/match MxLoopingFlcPresenter remaining functions * Remove include * Change to long --- LEGO1/omni/include/mxloopingflcpresenter.h | 8 +- .../omni/src/video/mxloopingflcpresenter.cpp | 79 ++++++++++++++++++- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/LEGO1/omni/include/mxloopingflcpresenter.h b/LEGO1/omni/include/mxloopingflcpresenter.h index 9e035afc..7075332d 100644 --- a/LEGO1/omni/include/mxloopingflcpresenter.h +++ b/LEGO1/omni/include/mxloopingflcpresenter.h @@ -18,7 +18,11 @@ class MxLoopingFlcPresenter : public MxFlcPresenter { return "MxLoopingFlcPresenter"; } - virtual void NextFrame() override; // vtable+0x64 + virtual void RepeatingTickle() override; // vtable+0x24 + virtual MxResult AddToManager() override; // vtable+0x34 + virtual void Destroy() override; // vtable+0x38 + virtual void NextFrame() override; // vtable+0x64 + virtual void VTable0x88(); // vtable+0x88 // SYNTHETIC: LEGO1 0x100b4390 // MxLoopingFlcPresenter::`scalar deleting destructor' @@ -27,7 +31,7 @@ class MxLoopingFlcPresenter : public MxFlcPresenter { void Init(); void Destroy(MxBool p_fromDestructor); - undefined4 m_unk0x68; + MxLong m_elapsedDuration; // 0x68 }; #endif // MXLOOPINGFLCPRESENTER_H diff --git a/LEGO1/omni/src/video/mxloopingflcpresenter.cpp b/LEGO1/omni/src/video/mxloopingflcpresenter.cpp index b8d9bd45..59540cb3 100644 --- a/LEGO1/omni/src/video/mxloopingflcpresenter.cpp +++ b/LEGO1/omni/src/video/mxloopingflcpresenter.cpp @@ -19,7 +19,7 @@ MxLoopingFlcPresenter::~MxLoopingFlcPresenter() // FUNCTION: LEGO1 0x100b4410 void MxLoopingFlcPresenter::Init() { - this->m_unk0x68 = 0; + this->m_elapsedDuration = 0; this->m_flags &= ~c_bit2; this->m_flags &= ~c_bit3; } @@ -45,8 +45,83 @@ void MxLoopingFlcPresenter::NextFrame() else { LoadFrame(chunk); LoopChunk(chunk); - m_unk0x68 += m_flcHeader->speed; + m_elapsedDuration += m_flcHeader->speed; } m_subscriber->DestroyChunk(chunk); } + +// FUNCTION: LEGO1 0x100b44c0 +void MxLoopingFlcPresenter::VTable0x88() +{ + if (m_action->GetDuration() < m_elapsedDuration) + ProgressTickleState(e_unk5); + else { + MxStreamChunk* chunk; + m_loopingChunkCursor->Current(chunk); + LoadFrame(chunk); + m_elapsedDuration += m_flcHeader->speed; + } +} + +// FUNCTION: LEGO1 0x100b4520 +void MxLoopingFlcPresenter::RepeatingTickle() +{ + for (MxS16 i = 0; i < m_unk0x5c; i++) { + if (!m_loopingChunkCursor->HasMatch()) { + MxStreamChunk* chunk; + MxStreamChunkListCursor cursor(m_loopingChunks); + + cursor.Last(chunk); + MxLong time = chunk->GetTime(); + + cursor.First(chunk); + + time -= chunk->GetTime(); + time += m_flcHeader->speed; + + cursor.Reset(); + while (cursor.Next(chunk)) + chunk->SetTime(chunk->GetTime() + time); + + m_loopingChunkCursor->Next(); + } + + MxStreamChunk* chunk; + m_loopingChunkCursor->Current(chunk); + + if (m_action->GetElapsedTime() < chunk->GetTime()) + break; + + VTable0x88(); + + m_loopingChunkCursor->Next(chunk); + + if (m_currentTickleState != e_repeating) + break; + } +} + +// FUNCTION: LEGO1 0x100b4860 +MxResult MxLoopingFlcPresenter::AddToManager() +{ + MxResult result = FAILURE; + MxBool locked = FALSE; + + if (MxFlcPresenter::AddToManager() == SUCCESS) { + m_criticalSection.Enter(); + locked = TRUE; + result = SUCCESS; + } + + if (locked) + m_criticalSection.Leave(); + + return result; +} + +// FUNCTION: LEGO1 0x100b48a0 +void MxLoopingFlcPresenter::Destroy() +{ + Destroy(FALSE); +}