From 34849df4b220dc89be929c68ec98ca1c4922c266 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sun, 24 Dec 2023 20:16:32 -0500 Subject: [PATCH] more mxdiskstreamcontroller methods --- LEGO1/legosoundmanager.cpp | 2 +- LEGO1/mxdiskstreamcontroller.cpp | 79 +++++++++++++++++++++++++++++--- LEGO1/mxdiskstreamprovider.cpp | 35 +++++++++++++- LEGO1/mxdsbuffer.cpp | 8 ++-- LEGO1/mxdsbuffer.h | 5 +- LEGO1/mxdsstreamingaction.h | 2 + LEGO1/mxnextactiondatastart.h | 2 + LEGO1/mxstreamcontroller.cpp | 5 ++ LEGO1/mxstreamcontroller.h | 1 + 9 files changed, 124 insertions(+), 15 deletions(-) diff --git a/LEGO1/legosoundmanager.cpp b/LEGO1/legosoundmanager.cpp index a74ca419..8b8376fa 100644 --- a/LEGO1/legosoundmanager.cpp +++ b/LEGO1/legosoundmanager.cpp @@ -29,7 +29,7 @@ void LegoSoundManager::Destroy(MxBool p_fromDestructor) // STUB: LEGO1 0x100299f0 MxResult LegoSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread) { - return FAILURE; + return SUCCESS; } // FUNCTION: LEGO1 0x1002a390 diff --git a/LEGO1/mxdiskstreamcontroller.cpp b/LEGO1/mxdiskstreamcontroller.cpp index 71ebc827..fef2864e 100644 --- a/LEGO1/mxdiskstreamcontroller.cpp +++ b/LEGO1/mxdiskstreamcontroller.cpp @@ -1,5 +1,6 @@ #include "mxdiskstreamcontroller.h" +#include "mxactionnotificationparam.h" #include "mxautolocker.h" #include "mxdiskstreamprovider.h" #include "mxdsstreamingaction.h" @@ -181,10 +182,30 @@ MxResult MxDiskStreamController::FUN_100c7d10() return SUCCESS; } -// STUB: LEGO1 0x100c7db0 +// FUNCTION: LEGO1 0x100c7db0 MxDSStreamingAction* MxDiskStreamController::FUN_100c7db0() { - // TODO + MxAutoLocker lock(&this->m_criticalSection); + + for (MxStreamListMxNextActionDataStart::iterator it = m_nextActionList.begin(); it != m_nextActionList.end(); + it++) { + MxNextActionDataStart* data = *it; + + for (MxStreamListMxDSAction::iterator it2 = m_list0x64.begin(); it2 != m_list0x64.end(); it++) { + MxDSStreamingAction* streamingAction = (MxDSStreamingAction*) *it2; + + if (streamingAction->GetObjectId() == data->GetObjectId() && + streamingAction->GetUnknown24() == data->GetUnknown24() && + streamingAction->GetBufferOffset() == data->GetData()) { + m_nextActionList.erase(it); + data->SetData(m_provider->GetFileSize() + data->GetData()); + m_nextActionList.push_back(data); + + m_list0x64.erase(it2); + return streamingAction; + } + } + } return NULL; } @@ -224,11 +245,39 @@ MxResult MxDiskStreamController::VTable0x20(MxDSAction* p_action) return SUCCESS; } -// STUB: LEGO1 0x100c8160 +// FUNCTION: LEGO1 0x100c8160 MxResult MxDiskStreamController::VTable0x24(MxDSAction* p_action) { - // TODO - return FAILURE; + MxAutoLocker lock(&this->m_criticalSection); + if (m_unk0x54.Find(p_action, FALSE) == NULL) { + if (VTable0x30(p_action) == SUCCESS) { + MxOmni::GetInstance()->NotifyCurrentEntity( + &MxEndActionNotificationParam(c_notificationEndAction, NULL, p_action, TRUE) + ); + } + } + + MxDSAction action; + if (m_provider) { + m_provider->VTable0x20(p_action); + } + + do { + if (m_action0x60 != NULL) { + delete m_action0x60; + m_action0x60 = NULL; + } + + action = *p_action; + MxStreamController::VTable0x24(&action); + } while (m_action0x60 != NULL); + + if (m_unk0x3c.size() == 0) { + m_unk0x70 = 0; + m_unk0xc4 = 0; + } + + return SUCCESS; } // FUNCTION: LEGO1 0x100c8360 @@ -269,10 +318,26 @@ void MxDiskStreamController::InsertToList74(MxDSBuffer* p_buffer) m_list0x74.push_back(p_buffer); } -// STUB: LEGO1 0x100c8540 +// FUNCTION: LEGO1 0x100c8540 void MxDiskStreamController::FUN_100c8540() { - // TODO + MxAutoLocker lock(&this->m_criticalSection); + for (list::iterator it = m_list0x74.begin(); it != m_list0x74.end(); it++) { + MxDSBuffer* buf = *it; + if (buf->GetRefCount() == 0) { + m_list0x74.erase(it); + FUN_100c7ce0(buf); + } + } + MxDSStreamingAction* action; + if (m_nextActionList.size() == 0 && m_list0x64.size() == 0) { + do { + action = (MxDSStreamingAction*)m_list0x64.front(); + m_list0xb8.pop_front(); + + FUN_100c7cb0(action); + } while (m_list0x64.size() != 0); + } } // FUNCTION: LEGO1 0x100c8640 diff --git a/LEGO1/mxdiskstreamprovider.cpp b/LEGO1/mxdiskstreamprovider.cpp index a8d15984..6bd25215 100644 --- a/LEGO1/mxdiskstreamprovider.cpp +++ b/LEGO1/mxdiskstreamprovider.cpp @@ -1,6 +1,8 @@ #include "mxdiskstreamprovider.h" +#include "mxautolocker.h" #include "mxdsbuffer.h" +#include "mxdsstreamingaction.h" #include "mxomni.h" #include "mxstreamcontroller.h" #include "mxstring.h" @@ -8,6 +10,9 @@ DECOMP_SIZE_ASSERT(MxDiskStreamProvider, 0x60); +// GLOBAL: LEGO1 0x10102878 +MxU32 DAT_10102878 = 0; + // FUNCTION: LEGO1 0x100d0f30 MxResult MxDiskStreamProviderThread::Run() { @@ -87,10 +92,36 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete() return SUCCESS; } -// STUB: LEGO1 0x100d1780 +// FUNCTION: LEGO1 0x100d1780 MxResult MxDiskStreamProvider::FUN_100d1780(MxDSStreamingAction* p_action) { - // TODO + if (m_remainingWork == 0) { + if (p_action->GetUnknown94() > 0 && !p_action->GetUnknowna0()) { + MxDSBuffer* buffer = new MxDSBuffer(); + if (buffer) { + if (buffer->AllocateBuffer(GetFileSize(), MxDSBufferType_Allocate) == SUCCESS) { + p_action->SetUnknowna0(buffer); + } + else { + delete buffer; + return FAILURE; + } + } + } + + if (p_action->GetUnknowna0()->GetWriteOffset() < 0x20000) { + DAT_10102878++; + } + + { + MxAutoLocker lock(&m_criticalSection); + m_list.push_back(p_action); + } + + m_unk0x35 = 1; + m_busySemaphore.Release(1); + return SUCCESS; + } return FAILURE; } diff --git a/LEGO1/mxdsbuffer.cpp b/LEGO1/mxdsbuffer.cpp index 0060dbdc..644d89bc 100644 --- a/LEGO1/mxdsbuffer.cpp +++ b/LEGO1/mxdsbuffer.cpp @@ -127,6 +127,7 @@ MxResult MxDSBuffer::FUN_100c67b0( ) { // TODO STUB + OutputDebugStringA("MxDSBuffer::FUN_100c67b0\n"); return FAILURE; } @@ -135,7 +136,7 @@ MxResult MxDSBuffer::CreateObject( MxStreamController* p_controller, MxU32* p_data, MxDSAction* p_action, - undefined4 p_undefined + MxDSStreamingAction** p_streamingAction ) { if (p_data == NULL) { @@ -157,7 +158,7 @@ MxResult MxDSBuffer::CreateObject( return SUCCESS; } - return ParseChunk(p_controller, p_data, p_action, p_undefined, chunk); + return ParseChunk(p_controller, p_data, p_action, p_streamingAction, chunk); } delete header; @@ -207,11 +208,12 @@ MxResult MxDSBuffer::ParseChunk( MxStreamController* p_controller, MxU32* p_data, MxDSAction* p_action, - undefined4, + MxDSStreamingAction** p_streamingAction, MxStreamChunk* p_header ) { // TODO + OutputDebugStringA("MxDSBuffer::ParseChunk not implemented\n"); return FAILURE; } diff --git a/LEGO1/mxdsbuffer.h b/LEGO1/mxdsbuffer.h index d8532a55..f396a9e2 100644 --- a/LEGO1/mxdsbuffer.h +++ b/LEGO1/mxdsbuffer.h @@ -42,17 +42,18 @@ class MxDSBuffer : public MxCore { MxStreamController* p_controller, MxU32* p_data, MxDSAction* p_action, - undefined4 p_undefined + MxDSStreamingAction** p_streamingAction ); MxResult StartPresenterFromAction(MxStreamController* p_controller, MxDSAction* p_action1, MxDSAction* p_action2); MxResult ParseChunk( MxStreamController* p_controller, MxU32* p_data, MxDSAction* p_action, - undefined4, + MxDSStreamingAction** p_streamingAction, MxStreamChunk* p_header ); static MxCore* ReadChunk(MxDSBuffer* p_buffer, MxU32* p_chunkData, MxU16 p_flags); + void SwapBuffers(); MxU8 ReleaseRef(MxDSChunk*); void AddRef(MxDSChunk* p_chunk); void FUN_100c6f80(MxU32 p_writeOffset); diff --git a/LEGO1/mxdsstreamingaction.h b/LEGO1/mxdsstreamingaction.h index 1766bd76..703b7a14 100644 --- a/LEGO1/mxdsstreamingaction.h +++ b/LEGO1/mxdsstreamingaction.h @@ -32,11 +32,13 @@ class MxDSStreamingAction : public MxDSAction { void FUN_100cd2d0(); inline MxU32 GetUnknown94() { return m_unk0x94; } + inline MxU32 GetUnknown9c() { return m_unk0x9c; } inline MxDSBuffer* GetUnknowna0() { return m_unk0xa0; } inline MxDSBuffer* GetUnknowna4() { return m_unk0xa4; } inline MxDSAction* GetInternalAction() { return m_internalAction; } inline MxU32 GetBufferOffset() { return m_bufferOffset; } inline void SetUnknown94(MxU32 p_unk0x94) { m_unk0x94 = p_unk0x94; } + inline void SetUnknown9c(MxU32 p_unk0x9c) { m_unk0x9c = p_unk0x9c; } inline void SetUnknowna0(MxDSBuffer* p_unk0xa0) { m_unk0xa0 = p_unk0xa0; } inline void SetBufferOffset(MxU32 p_bufferOffset) { m_bufferOffset = p_bufferOffset; } diff --git a/LEGO1/mxnextactiondatastart.h b/LEGO1/mxnextactiondatastart.h index 10d2a2f2..09510a17 100644 --- a/LEGO1/mxnextactiondatastart.h +++ b/LEGO1/mxnextactiondatastart.h @@ -30,6 +30,8 @@ class MxNextActionDataStart : public MxCore { inline MxU32 GetObjectId() const { return m_objectId; } inline MxS16 GetUnknown24() const { return m_unk0x24; } + inline MxU32 GetData() const { return m_data; } + inline void SetData(MxU32 p_data) { m_data = p_data; } private: MxU32 m_objectId; diff --git a/LEGO1/mxstreamcontroller.cpp b/LEGO1/mxstreamcontroller.cpp index 92dcfb26..cbedd040 100644 --- a/LEGO1/mxstreamcontroller.cpp +++ b/LEGO1/mxstreamcontroller.cpp @@ -5,6 +5,7 @@ #include "mxautolocker.h" #include "mxdsstreamingaction.h" #include "mxnextactiondatastart.h" +#include "mxstl/stlcompat.h" #include "mxstreamchunk.h" #include "mxtimer.h" @@ -81,12 +82,14 @@ MxResult MxStreamController::Open(const char* p_filename) void MxStreamController::FUN_100c15d0(MxDSSubscriber* p_subscriber) { // TODO + OutputDebugStringA("MxStreamController::FUN_100c15d0\n"); } // STUB: LEGO1 0x100c1620 void MxStreamController::FUN_100c1620(MxDSSubscriber* p_subscriber) { // TODO + OutputDebugStringA("MxStreamController::FUN_100c1620\n"); } // FUNCTION: LEGO1 0x100c1690 @@ -255,6 +258,7 @@ MxPresenter* MxStreamController::FUN_100c1e70(MxDSAction& p_action) MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action) { // TODO + OutputDebugStringA("MxStreamController::FUN_100c1f00\n"); return FAILURE; } @@ -262,5 +266,6 @@ MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action) MxBool MxStreamController::FUN_100c20d0(MxDSObject& p_obj) { // TODO + OutputDebugStringA("MxStreamController::FUN_100c20d0\n"); return TRUE; } diff --git a/LEGO1/mxstreamcontroller.h b/LEGO1/mxstreamcontroller.h index ca3b09b3..b8a5bfbd 100644 --- a/LEGO1/mxstreamcontroller.h +++ b/LEGO1/mxstreamcontroller.h @@ -53,6 +53,7 @@ class MxStreamController : public MxCore { MxResult InsertActionToList54(MxDSAction* p_action); inline MxAtomId& GetAtom() { return m_atom; }; + inline MxStreamListMxDSAction& GetUnk0x3c() { return m_unk0x3c; }; inline MxStreamListMxDSAction& GetUnk0x54() { return m_unk0x54; }; protected: