2023-06-29 04:10:08 -04:00
|
|
|
#include "mxloopingsmkpresenter.h"
|
|
|
|
|
2024-03-12 10:23:50 -04:00
|
|
|
#include "mxautolock.h"
|
2023-12-22 14:05:42 -05:00
|
|
|
#include "mxdsmediaaction.h"
|
2023-07-02 03:00:28 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxLoopingSmkPresenter, 0x724);
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b48b0
|
2023-06-29 04:10:08 -04:00
|
|
|
MxLoopingSmkPresenter::MxLoopingSmkPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b4950
|
2023-06-29 04:10:08 -04:00
|
|
|
MxLoopingSmkPresenter::~MxLoopingSmkPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy(TRUE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b49b0
|
2023-06-29 04:10:08 -04:00
|
|
|
void MxLoopingSmkPresenter::Init()
|
|
|
|
{
|
2024-01-29 11:29:12 -05:00
|
|
|
m_elapsedDuration = 0;
|
|
|
|
SetBit1(FALSE);
|
|
|
|
SetBit2(FALSE);
|
2023-10-04 13:30:37 -04:00
|
|
|
}
|
|
|
|
|
2023-12-22 14:05:42 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b49d0
|
2023-10-13 12:43:45 -04:00
|
|
|
void MxLoopingSmkPresenter::Destroy(MxBool p_fromDestructor)
|
2023-10-04 13:30:37 -04:00
|
|
|
{
|
2023-12-22 14:05:42 -05:00
|
|
|
m_criticalSection.Enter();
|
|
|
|
Init();
|
|
|
|
m_criticalSection.Leave();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!p_fromDestructor) {
|
2023-12-22 14:05:42 -05:00
|
|
|
MxSmkPresenter::Destroy();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-22 14:05:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (chunk->GetFlags() & MxDSChunk::c_end) {
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_repeating);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-22 14:05:42 -05:00
|
|
|
else {
|
|
|
|
LoadFrame(chunk);
|
2024-01-08 13:07:13 -05:00
|
|
|
LoopChunk(chunk);
|
2023-12-22 14:05:42 -05:00
|
|
|
m_elapsedDuration += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
|
|
|
|
}
|
|
|
|
|
2024-02-17 10:35:10 -05:00
|
|
|
m_subscriber->FreeDataChunk(chunk);
|
2023-12-22 14:05:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b4a90
|
|
|
|
void MxLoopingSmkPresenter::VTable0x8c()
|
|
|
|
{
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_action->GetDuration() < m_elapsedDuration) {
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_unk5);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-22 14:05:42 -05:00
|
|
|
else {
|
|
|
|
MxStreamChunk* chunk;
|
2024-01-08 13:07:13 -05:00
|
|
|
m_loopingChunkCursor->Current(chunk);
|
2023-12-22 14:05:42 -05:00
|
|
|
LoadFrame(chunk);
|
|
|
|
m_elapsedDuration += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b4b00
|
|
|
|
void MxLoopingSmkPresenter::RepeatingTickle()
|
|
|
|
{
|
|
|
|
for (MxS16 i = 0; i < m_unk0x5c; i++) {
|
2024-01-08 13:07:13 -05:00
|
|
|
if (!m_loopingChunkCursor->HasMatch()) {
|
2023-12-22 14:05:42 -05:00
|
|
|
MxStreamChunk* chunk;
|
2024-01-08 13:07:13 -05:00
|
|
|
MxStreamChunkListCursor cursor(m_loopingChunks);
|
2023-12-22 14:05:42 -05:00
|
|
|
|
|
|
|
cursor.Last(chunk);
|
|
|
|
MxLong time = chunk->GetTime();
|
|
|
|
|
|
|
|
cursor.First(chunk);
|
|
|
|
|
|
|
|
time -= chunk->GetTime();
|
|
|
|
time += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
|
|
|
|
|
|
|
|
cursor.Reset();
|
2024-02-01 15:42:10 -05:00
|
|
|
while (cursor.Next(chunk)) {
|
2023-12-22 14:05:42 -05:00
|
|
|
chunk->SetTime(chunk->GetTime() + time);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-22 14:05:42 -05:00
|
|
|
|
2024-01-08 13:07:13 -05:00
|
|
|
m_loopingChunkCursor->Next();
|
2023-12-22 14:05:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MxStreamChunk* chunk;
|
2024-01-08 13:07:13 -05:00
|
|
|
m_loopingChunkCursor->Current(chunk);
|
2023-12-22 14:05:42 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_action->GetElapsedTime() < chunk->GetTime()) {
|
2023-12-22 14:05:42 -05:00
|
|
|
break;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-22 14:05:42 -05:00
|
|
|
|
|
|
|
VTable0x8c();
|
|
|
|
|
2024-01-08 13:07:13 -05:00
|
|
|
m_loopingChunkCursor->Next(chunk);
|
2023-12-22 14:05:42 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_currentTickleState != e_repeating) {
|
2023-12-22 14:05:42 -05:00
|
|
|
break;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-22 14:05:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b4cd0
|
|
|
|
MxResult MxLoopingSmkPresenter::AddToManager()
|
|
|
|
{
|
2024-03-12 10:23:50 -04:00
|
|
|
AUTOLOCK(m_criticalSection);
|
2023-12-22 14:05:42 -05:00
|
|
|
return MxSmkPresenter::AddToManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b4d40
|
|
|
|
void MxLoopingSmkPresenter::Destroy()
|
|
|
|
{
|
|
|
|
Destroy(FALSE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|