Files
isle/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp
Misha f50b771fff begin implementation of InfoCenter class (#444)
* Push changes

* fixes

* Implement Infocenter::HandleEndAction

* match Infocenter::StopCutScene

* implement Infocenter::HandleKeyPress

* fixes

* Update infocenter.cpp

* Update legoworld.cpp

* use enums

* WIP Fixes

* Fix

* Fix

* Fix

* Rename function

* Change enum

* Update enums

* Refactor another enum

* Refactor MxDSType

* Refactor HashTableOpt

* Fixes

* Refactor tickle enum

* Update other enums

* Add EnumConstantName to ncc

* Move enum to global namespace

* Rename enum

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
2024-01-17 17:53:53 +01:00

128 lines
2.7 KiB
C++

#include "mxloopingsmkpresenter.h"
#include "mxautolocker.h"
#include "mxdsmediaaction.h"
DECOMP_SIZE_ASSERT(MxLoopingSmkPresenter, 0x724);
// FUNCTION: LEGO1 0x100b48b0
MxLoopingSmkPresenter::MxLoopingSmkPresenter()
{
Init();
}
// FUNCTION: LEGO1 0x100b4950
MxLoopingSmkPresenter::~MxLoopingSmkPresenter()
{
Destroy(TRUE);
}
// FUNCTION: LEGO1 0x100b49b0
void MxLoopingSmkPresenter::Init()
{
this->m_elapsedDuration = 0;
this->m_flags &= ~c_bit2;
this->m_flags &= ~c_bit3;
}
// FUNCTION: LEGO1 0x100b49d0
void MxLoopingSmkPresenter::Destroy(MxBool p_fromDestructor)
{
m_criticalSection.Enter();
Init();
m_criticalSection.Leave();
if (!p_fromDestructor)
MxSmkPresenter::Destroy();
}
// FUNCTION: LEGO1 0x100b4a00
void MxLoopingSmkPresenter::VTable0x88()
{
if (m_mxSmack.m_smackTag.Frames == m_currentFrame) {
m_currentFrame = 0;
// TODO: struct incorrect, Palette at wrong offset?
memset(&m_mxSmack.m_smackTag.Palette[4], 0, sizeof(m_mxSmack.m_smackTag.Palette));
}
}
// FUNCTION: LEGO1 0x100b4a30
void MxLoopingSmkPresenter::NextFrame()
{
MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end)
ProgressTickleState(e_repeating);
else {
LoadFrame(chunk);
LoopChunk(chunk);
m_elapsedDuration += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
}
m_subscriber->DestroyChunk(chunk);
}
// FUNCTION: LEGO1 0x100b4a90
void MxLoopingSmkPresenter::VTable0x8c()
{
if (m_action->GetDuration() < m_elapsedDuration)
ProgressTickleState(e_unk5);
else {
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
LoadFrame(chunk);
m_elapsedDuration += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
}
}
// FUNCTION: LEGO1 0x100b4b00
void MxLoopingSmkPresenter::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 += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
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;
VTable0x8c();
m_loopingChunkCursor->Next(chunk);
if (m_currentTickleState != e_repeating)
break;
}
}
// FUNCTION: LEGO1 0x100b4cd0
MxResult MxLoopingSmkPresenter::AddToManager()
{
MxAutoLocker lock(&m_criticalSection);
return MxSmkPresenter::AddToManager();
}
// FUNCTION: LEGO1 0x100b4d40
void MxLoopingSmkPresenter::Destroy()
{
Destroy(FALSE);
}