From 2fa32c0382890d9ad9e74ddb0d38702d75d15ace Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 11 Jan 2024 09:51:39 -0500 Subject: [PATCH] Replace tickle code --- .../src/common/legoactioncontrolpresenter.cpp | 6 ++---- .../src/common/mxcompositemediapresenter.cpp | 6 ++---- .../src/control/mxcontrolpresenter.cpp | 4 +--- .../src/entity/legoentitypresenter.cpp | 3 +-- .../src/entity/legoworldpresenter.cpp | 6 ++---- .../src/video/legopalettepresenter.cpp | 4 ++-- .../omni/src/audio/mxloopingmidipresenter.cpp | 6 ++---- LEGO1/omni/src/audio/mxmidipresenter.cpp | 15 +++++-------- LEGO1/omni/src/audio/mxwavepresenter.cpp | 6 ++---- .../omni/src/common/mxcompositepresenter.cpp | 3 +-- LEGO1/omni/src/common/mxmediapresenter.cpp | 21 +++++++------------ LEGO1/omni/src/common/mxpresenter.cpp | 3 +-- LEGO1/omni/src/event/mxeventpresenter.cpp | 9 +++----- .../omni/src/video/mxloopingflcpresenter.cpp | 6 ++---- .../omni/src/video/mxloopingsmkpresenter.cpp | 12 ++++------- LEGO1/omni/src/video/mxstillpresenter.cpp | 9 +++----- LEGO1/omni/src/video/mxvideopresenter.cpp | 21 +++++++------------ 17 files changed, 47 insertions(+), 93 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legoactioncontrolpresenter.cpp b/LEGO1/lego/legoomni/src/common/legoactioncontrolpresenter.cpp index 3649bb50..75890bec 100644 --- a/LEGO1/lego/legoomni/src/common/legoactioncontrolpresenter.cpp +++ b/LEGO1/lego/legoomni/src/common/legoactioncontrolpresenter.cpp @@ -19,8 +19,7 @@ void LegoActionControlPresenter::ReadyTickle() if (chunk) { ParseExtra(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); m_subscriber->DestroyChunk(chunk); if (m_compositePresenter) { @@ -47,8 +46,7 @@ void LegoActionControlPresenter::RepeatingTickle() #else InvokeAction(m_unk0x50, MxAtomId(m_unk0x54.GetData(), LookupMode_LowerCase2), m_unk0x64, NULL); #endif - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Done; + ProgressTickleState(TickleState_Done); } } diff --git a/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp b/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp index 2a15d445..6b0a32ca 100644 --- a/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp +++ b/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp @@ -123,8 +123,7 @@ void MxCompositeMediaPresenter::StartingTickle() } if (!m_unk0x4c) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Streaming; + ProgressTickleState(TickleState_Streaming); MxLong time = Timer()->GetTime(); m_action->SetUnknown90(time); } @@ -138,8 +137,7 @@ MxResult MxCompositeMediaPresenter::Tickle() switch (m_currentTickleState) { case TickleState_Ready: - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); case TickleState_Starting: StartingTickle(); break; diff --git a/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp b/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp index 2c7fb81d..b7f8fa8e 100644 --- a/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp +++ b/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp @@ -88,9 +88,7 @@ void MxControlPresenter::ReadyTickle() { MxPresenter::ParseExtra(); TickleManager()->UnregisterClient(this); - - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Repeating; + ProgressTickleState(TickleState_Repeating); } // STUB: LEGO1 0x10044640 diff --git a/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp index 7a586c80..995705bd 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp @@ -69,8 +69,7 @@ void LegoEntityPresenter::ReadyTickle() m_objectBackend->SetLocation(m_action->GetLocation(), m_action->GetDirection(), m_action->GetUp(), TRUE); ParseExtra(); } - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); } } diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 02578675..9e5e930c 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -95,8 +95,7 @@ void LegoWorldPresenter::ReadyTickle() } ParseExtra(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); } // FUNCTION: LEGO1 0x10066ac0 @@ -116,8 +115,7 @@ void LegoWorldPresenter::StartingTickle() } } - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Streaming; + ProgressTickleState(TickleState_Streaming); } // STUB: LEGO1 0x10067a70 diff --git a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp index 821942b9..6fbc7803 100644 --- a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp @@ -76,8 +76,8 @@ void LegoPalettePresenter::ReadyTickle() if (chunk) { if (chunk->GetTime() <= m_action->GetElapsedTime()) { ParseExtra(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); + chunk = m_subscriber->NextChunk(); MxResult result = ParsePalette(chunk); m_subscriber->DestroyChunk(chunk); diff --git a/LEGO1/omni/src/audio/mxloopingmidipresenter.cpp b/LEGO1/omni/src/audio/mxloopingmidipresenter.cpp index 84b33229..921bc607 100644 --- a/LEGO1/omni/src/audio/mxloopingmidipresenter.cpp +++ b/LEGO1/omni/src/audio/mxloopingmidipresenter.cpp @@ -20,10 +20,8 @@ void MxLoopingMIDIPresenter::StreamingTickle() return; } - if (m_chunk->GetTime() + m_action->GetDuration() <= m_action->GetElapsedTime()) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Done; - } + if (m_chunk->GetTime() + m_action->GetDuration() <= m_action->GetElapsedTime()) + ProgressTickleState(TickleState_Done); } // FUNCTION: LEGO1 0x100c2ae0 diff --git a/LEGO1/omni/src/audio/mxmidipresenter.cpp b/LEGO1/omni/src/audio/mxmidipresenter.cpp index 95add150..b6d22d81 100644 --- a/LEGO1/omni/src/audio/mxmidipresenter.cpp +++ b/LEGO1/omni/src/audio/mxmidipresenter.cpp @@ -52,8 +52,7 @@ void MxMIDIPresenter::ReadyTickle() if (chunk) { m_subscriber->DestroyChunk(chunk); ParseExtra(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); } } @@ -62,19 +61,15 @@ void MxMIDIPresenter::StartingTickle() { MxStreamChunk* chunk = CurrentChunk(); - if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Streaming; - } + if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) + ProgressTickleState(TickleState_Streaming); } // FUNCTION: LEGO1 0x100c2910 void MxMIDIPresenter::StreamingTickle() { - if (m_chunk) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Done; - } + if (m_chunk) + ProgressTickleState(TickleState_Done); else m_chunk = NextChunk(); } diff --git a/LEGO1/omni/src/audio/mxwavepresenter.cpp b/LEGO1/omni/src/audio/mxwavepresenter.cpp index 4453ee18..e47a2630 100644 --- a/LEGO1/omni/src/audio/mxwavepresenter.cpp +++ b/LEGO1/omni/src/audio/mxwavepresenter.cpp @@ -118,8 +118,7 @@ void MxWavePresenter::ReadyTickle() memcpy(m_waveFormat, chunk->GetData(), chunk->GetLength()); m_subscriber->DestroyChunk(chunk); ParseExtra(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); } } @@ -170,8 +169,7 @@ void MxWavePresenter::StartingTickle() } else { SetVolume(((MxDSSound*) m_action)->GetVolume()); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Streaming; + ProgressTickleState(TickleState_Streaming); } } } diff --git a/LEGO1/omni/src/common/mxcompositepresenter.cpp b/LEGO1/omni/src/common/mxcompositepresenter.cpp index c863b7f5..0b787a42 100644 --- a/LEGO1/omni/src/common/mxcompositepresenter.cpp +++ b/LEGO1/omni/src/common/mxcompositepresenter.cpp @@ -221,8 +221,7 @@ void MxCompositePresenter::VTable0x60(MxPresenter* p_presenter) // FUNCTION: LEGO1 0x100b6bc0 void MxCompositePresenter::SetTickleState(TickleState p_tickleState) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = p_tickleState; + ProgressTickleState(p_tickleState); for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) { MxPresenter* presenter = *it; diff --git a/LEGO1/omni/src/common/mxmediapresenter.cpp b/LEGO1/omni/src/common/mxmediapresenter.cpp index 65c4b39d..56297f53 100644 --- a/LEGO1/omni/src/common/mxmediapresenter.cpp +++ b/LEGO1/omni/src/common/mxmediapresenter.cpp @@ -65,8 +65,7 @@ MxStreamChunk* MxMediaPresenter::CurrentChunk() m_subscriber->NextChunk(); m_subscriber->DestroyChunk(chunk); chunk = NULL; - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Done; + ProgressTickleState(TickleState_Done); } } @@ -85,8 +84,7 @@ MxStreamChunk* MxMediaPresenter::NextChunk() m_action->SetFlags(m_action->GetFlags() | MxDSAction::Flag_Bit7); m_subscriber->DestroyChunk(chunk); chunk = NULL; - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Done; + ProgressTickleState(TickleState_Done); } } @@ -183,8 +181,7 @@ void MxMediaPresenter::StreamingTickle() if (m_currentChunk->GetFlags() & MxDSChunk::Flag_End) { m_subscriber->DestroyChunk(m_currentChunk); m_currentChunk = NULL; - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Repeating; + ProgressTickleState(TickleState_Repeating); } else if (m_action->GetFlags() & MxDSAction::Flag_Looping) { LoopChunk(m_currentChunk); @@ -208,16 +205,12 @@ void MxMediaPresenter::RepeatingTickle() if (m_currentChunk) { MxLong time = m_currentChunk->GetTime(); - if (time <= m_action->GetElapsedTime() % m_action->GetLoopCount()) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_unk5; - } + if (time <= m_action->GetElapsedTime() % m_action->GetLoopCount()) + ProgressTickleState(TickleState_unk5); } else { - if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration()) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_unk5; - } + if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration()) + ProgressTickleState(TickleState_unk5); } } } diff --git a/LEGO1/omni/src/common/mxpresenter.cpp b/LEGO1/omni/src/common/mxpresenter.cpp index 3968c943..6582d43c 100644 --- a/LEGO1/omni/src/common/mxpresenter.cpp +++ b/LEGO1/omni/src/common/mxpresenter.cpp @@ -47,8 +47,7 @@ MxResult MxPresenter::StartAction(MxStreamController*, MxDSAction* p_action) this->m_location = MxPoint32(this->m_action->GetLocation()[0], this->m_action->GetLocation()[1]); this->m_displayZ = this->m_action->GetLocation()[2]; - this->m_previousTickleStates |= 1 << (unsigned char) previousTickleState; - this->m_currentTickleState = TickleState_Ready; + ProgressTickleState(TickleState_Ready); return SUCCESS; } diff --git a/LEGO1/omni/src/event/mxeventpresenter.cpp b/LEGO1/omni/src/event/mxeventpresenter.cpp index 6a0a0cbd..d934660a 100644 --- a/LEGO1/omni/src/event/mxeventpresenter.cpp +++ b/LEGO1/omni/src/event/mxeventpresenter.cpp @@ -71,8 +71,7 @@ void MxEventPresenter::ReadyTickle() CopyData(chunk); m_subscriber->DestroyChunk(chunk); ParseExtra(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); } } @@ -81,10 +80,8 @@ void MxEventPresenter::StartingTickle() { MxStreamChunk* chunk = NextChunk(); - if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Streaming; - } + if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) + ProgressTickleState(TickleState_Streaming); } // FUNCTION: LEGO1 0x100c2ef0 diff --git a/LEGO1/omni/src/video/mxloopingflcpresenter.cpp b/LEGO1/omni/src/video/mxloopingflcpresenter.cpp index fdd991a9..07af2513 100644 --- a/LEGO1/omni/src/video/mxloopingflcpresenter.cpp +++ b/LEGO1/omni/src/video/mxloopingflcpresenter.cpp @@ -40,10 +40,8 @@ void MxLoopingFlcPresenter::NextFrame() { MxStreamChunk* chunk = NextChunk(); - if (chunk->GetFlags() & MxDSChunk::Flag_End) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Repeating; - } + if (chunk->GetFlags() & MxDSChunk::Flag_End) + ProgressTickleState(TickleState_Repeating); else { LoadFrame(chunk); LoopChunk(chunk); diff --git a/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp b/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp index efa758cd..29ee1747 100644 --- a/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp +++ b/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp @@ -51,10 +51,8 @@ void MxLoopingSmkPresenter::NextFrame() { MxStreamChunk* chunk = NextChunk(); - if (chunk->GetFlags() & MxDSChunk::Flag_End) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Repeating; - } + if (chunk->GetFlags() & MxDSChunk::Flag_End) + ProgressTickleState(TickleState_Repeating); else { LoadFrame(chunk); LoopChunk(chunk); @@ -67,10 +65,8 @@ void MxLoopingSmkPresenter::NextFrame() // FUNCTION: LEGO1 0x100b4a90 void MxLoopingSmkPresenter::VTable0x8c() { - if (m_action->GetDuration() < m_elapsedDuration) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_unk5; - } + if (m_action->GetDuration() < m_elapsedDuration) + ProgressTickleState(TickleState_unk5); else { MxStreamChunk* chunk; m_loopingChunkCursor->Current(chunk); diff --git a/LEGO1/omni/src/video/mxstillpresenter.cpp b/LEGO1/omni/src/video/mxstillpresenter.cpp index 831a5e7b..ea3ba3a6 100644 --- a/LEGO1/omni/src/video/mxstillpresenter.cpp +++ b/LEGO1/omni/src/video/mxstillpresenter.cpp @@ -121,8 +121,7 @@ void MxStillPresenter::StreamingTickle() if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) { m_chunkTime = chunk->GetTime(); NextFrame(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Repeating; + ProgressTickleState(TickleState_Repeating); if (m_action->GetDuration() == -1 && m_compositePresenter) m_compositePresenter->VTable0x60(this); @@ -133,10 +132,8 @@ void MxStillPresenter::StreamingTickle() void MxStillPresenter::RepeatingTickle() { if (m_action->GetDuration() != -1) { - if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration()) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_unk5; - } + if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration()) + ProgressTickleState(TickleState_unk5); } } diff --git a/LEGO1/omni/src/video/mxvideopresenter.cpp b/LEGO1/omni/src/video/mxvideopresenter.cpp index 8054b502..765bb497 100644 --- a/LEGO1/omni/src/video/mxvideopresenter.cpp +++ b/LEGO1/omni/src/video/mxvideopresenter.cpp @@ -182,8 +182,7 @@ void MxVideoPresenter::NextFrame() if (chunk->GetFlags() & MxDSChunk::Flag_End) { m_subscriber->DestroyChunk(chunk); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Repeating; + ProgressTickleState(TickleState_Repeating); } else { LoadFrame(chunk); @@ -400,8 +399,7 @@ void MxVideoPresenter::ReadyTickle() LoadHeader(chunk); m_subscriber->DestroyChunk(chunk); ParseExtra(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Starting; + ProgressTickleState(TickleState_Starting); } } @@ -412,8 +410,7 @@ void MxVideoPresenter::StartingTickle() if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) { CreateBitmap(); - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Streaming; + ProgressTickleState(TickleState_Streaming); } } @@ -504,15 +501,11 @@ void MxVideoPresenter::Unk5Tickle() if (m_unk0x60 == -1) m_unk0x60 = m_action->GetElapsedTime(); - if (m_action->GetElapsedTime() >= m_unk0x60 + ((MxDSMediaAction*) m_action)->GetSustainTime()) { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Done; - } - } - else { - m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; - m_currentTickleState = TickleState_Done; + if (m_action->GetElapsedTime() >= m_unk0x60 + ((MxDSMediaAction*) m_action)->GetSustainTime()) + ProgressTickleState(TickleState_Done); } + else + ProgressTickleState(TickleState_Done); } }