diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index b6c48b4a..ab0d2290 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -784,11 +784,11 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame) LegoOmni::GetInstance()->CreateBackgroundAudio(); BackgroundAudioManager()->Enable(this->m_useMusic); - MxStreamController* stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", 0); + MxStreamController* stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", MxStreamer::e_DiskStream); MxDSAction ds; if (!stream) { - stream = Streamer()->Open("\\lego\\scripts\\nocd", 0); + stream = Streamer()->Open("\\lego\\scripts\\nocd", MxStreamer::e_DiskStream); if (!stream) { return; } diff --git a/LEGO1/mxdsstreamingaction.h b/LEGO1/mxdsstreamingaction.h index 5b764c8f..1766bd76 100644 --- a/LEGO1/mxdsstreamingaction.h +++ b/LEGO1/mxdsstreamingaction.h @@ -41,14 +41,14 @@ class MxDSStreamingAction : public MxDSAction { inline void SetBufferOffset(MxU32 p_bufferOffset) { m_bufferOffset = p_bufferOffset; } private: - MxU32 m_unk0x94; - MxU32 m_bufferOffset; - MxS32 m_unk0x9c; - MxDSBuffer* m_unk0xa0; - MxDSBuffer* m_unk0xa4; - MxLong m_unk0xa8; - undefined2 m_unk0xac; - MxDSAction* m_internalAction; + MxU32 m_unk0x94; // 0x94 + MxU32 m_bufferOffset; // 0x98 + MxS32 m_unk0x9c; // 0x9c + MxDSBuffer* m_unk0xa0; // 0xa0 + MxDSBuffer* m_unk0xa4; // 0xa4 + MxLong m_unk0xa8; // 0xa8 + undefined2 m_unk0xac; // 0xac + MxDSAction* m_internalAction; // 0xb0 }; #endif // MXDSSTREAMINGACTION_H diff --git a/LEGO1/mxdssubscriber.h b/LEGO1/mxdssubscriber.h index 35961f54..13d62040 100644 --- a/LEGO1/mxdssubscriber.h +++ b/LEGO1/mxdssubscriber.h @@ -36,6 +36,9 @@ class MxDSSubscriber : public MxCore { MxStreamChunk* FUN_100b8360(); void FUN_100b8390(MxStreamChunk* p_chunk); + inline MxU32 GetObjectId() { return m_objectId; } + inline MxS16 GetUnknown48() { return m_unk0x48; } + private: MxStreamChunkList m_unk0x08; // 0x08 MxStreamChunkListCursor* m_unk0x20; // 0x20 diff --git a/LEGO1/mxstreamcontroller.cpp b/LEGO1/mxstreamcontroller.cpp index ed681b8c..92dcfb26 100644 --- a/LEGO1/mxstreamcontroller.cpp +++ b/LEGO1/mxstreamcontroller.cpp @@ -1,10 +1,12 @@ #include "mxstreamcontroller.h" #include "legoomni.h" +#include "legoutil.h" #include "mxautolocker.h" #include "mxdsstreamingaction.h" #include "mxnextactiondatastart.h" #include "mxstreamchunk.h" +#include "mxtimer.h" DECOMP_SIZE_ASSERT(MxStreamController, 0x64) DECOMP_SIZE_ASSERT(MxNextActionDataStart, 0x14) @@ -138,10 +140,60 @@ MxResult MxStreamController::FUN_100c1800(MxDSAction* p_action, MxU32 p_val) return SUCCESS; } -// STUB: LEGO1 0x100c1a00 -MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval) +// FUNCTION: LEGO1 0x100c1a00 +MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset) { - return FAILURE; + if (p_action->GetUnknown24() == -1) { + MxS16 newUnknown24 = -1; + + // These loops might be a template function in the list classes + for (MxStreamListMxDSAction::iterator it = m_unk0x54.begin(); it != m_unk0x54.end(); it++) { + MxDSAction* action = *it; + + if (action->GetObjectId() == p_action->GetObjectId()) + newUnknown24 = Max(newUnknown24, action->GetUnknown24()); + } + + if (newUnknown24 == -1) { + for (MxStreamListMxDSAction::iterator it = m_unk0x3c.begin(); it != m_unk0x3c.end(); it++) { + MxDSAction* action = *it; + + if (action->GetObjectId() == p_action->GetObjectId()) + newUnknown24 = Max(newUnknown24, action->GetUnknown24()); + } + + if (newUnknown24 == -1) { + for (MxStreamListMxDSSubscriber::iterator it = m_subscriberList.begin(); it != m_subscriberList.end(); + it++) { + MxDSSubscriber* subscriber = *it; + + if (subscriber->GetObjectId() == p_action->GetObjectId()) + newUnknown24 = Max(newUnknown24, subscriber->GetUnknown48()); + } + } + } + + p_action->SetUnknown24(newUnknown24 + 1); + } + else { + if (m_unk0x3c.Find(p_action, FALSE)) + return FAILURE; + } + + MxDSStreamingAction* streamingAction = new MxDSStreamingAction(*p_action, p_offset); + + if (!streamingAction) + return FAILURE; + + MxU32 fileSize = m_provider->GetFileSize(); + streamingAction->SetBufferOffset(fileSize * (p_offset / fileSize)); + streamingAction->SetObjectId(p_action->GetObjectId()); + + MxLong time = Timer()->GetTime(); + streamingAction->SetUnknown90(time); + + m_unk0x3c.push_back(streamingAction); + return SUCCESS; } // FUNCTION: LEGO1 0x100c1c10 diff --git a/LEGO1/mxstreamcontroller.h b/LEGO1/mxstreamcontroller.h index d3310338..ca3b09b3 100644 --- a/LEGO1/mxstreamcontroller.h +++ b/LEGO1/mxstreamcontroller.h @@ -46,7 +46,7 @@ class MxStreamController : public MxCore { void FUN_100c15d0(MxDSSubscriber* p_subscriber); void FUN_100c1620(MxDSSubscriber* p_subscriber); MxResult FUN_100c1800(MxDSAction* p_action, MxU32 p_val); - MxResult FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval); + MxResult FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset); MxPresenter* FUN_100c1e70(MxDSAction& p_action); MxResult FUN_100c1f00(MxDSAction* p_action); MxBool FUN_100c20d0(MxDSObject& p_obj);