From c41cc9c29aa8a043a64fdafdf0134ca46acfcf17 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Fri, 22 Dec 2023 11:46:48 -0500 Subject: [PATCH] FUN_100c7d10 & FUN_100c8360 --- LEGO1/mxdiskstreamcontroller.cpp | 51 +++++++++++++++++++++++++++++++- LEGO1/mxdiskstreamcontroller.h | 2 ++ LEGO1/mxdsbuffer.cpp | 2 +- LEGO1/mxdsbuffer.h | 3 +- LEGO1/mxramstreamcontroller.cpp | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/LEGO1/mxdiskstreamcontroller.cpp b/LEGO1/mxdiskstreamcontroller.cpp index 930d1d76..19f63edc 100644 --- a/LEGO1/mxdiskstreamcontroller.cpp +++ b/LEGO1/mxdiskstreamcontroller.cpp @@ -160,12 +160,30 @@ void MxDiskStreamController::FUN_100c7ce0(MxDSBuffer* p_buffer) } } -// STUB: LEGO1 0x100c7d10 +// FUNCTION: LEGO1 0x100c7d10 MxResult MxDiskStreamController::FUN_100c7d10() { + MxAutoLocker lock(&this->m_criticalSection); + MxDSStreamingAction* action = FUN_100c7db0(); + if (action) { + if (FUN_100c8360(action) == SUCCESS) { + return SUCCESS; + } + else { + VTable0x24(action); + FUN_100c7cb0(action); + } + } return FAILURE; } +// STUB: LEGO1 0x100c7db0 +MxDSStreamingAction* MxDiskStreamController::FUN_100c7db0() +{ + // TODO + return NULL; +} + // FUNCTION: LEGO1 0x100c7f40 void MxDiskStreamController::FUN_100c7f40(MxDSStreamingAction* p_streamingaction) { @@ -209,6 +227,37 @@ MxResult MxDiskStreamController::VTable0x24(MxDSAction* p_action) return FAILURE; } +// FUNCTION: LEGO1 0x100c8360 +MxResult MxDiskStreamController::FUN_100c8360(MxDSStreamingAction* p_action) +{ + MxAutoLocker lock(&this->m_criticalSection); + MxDSBuffer* buffer = p_action->GetUnknowna0(); + MxDSStreamingAction* action2 = (MxDSStreamingAction*) m_list0x90.Find(p_action, TRUE); + buffer->FUN_100c6f80(p_action->GetUnknown94() - p_action->GetBufferOffset()); + buffer->FUN_100c67b0(this, p_action, &action2); + + if (buffer->GetRefCount()) { + p_action->SetUnknowna0(NULL); + InsertToList74(buffer); + } + + if (action2) { + if (action2->GetUnknowna0() == NULL) { + FUN_100c7cb0(action2); + } + else { + if (action2->GetObjectId() == -1) { + action2->SetObjectId(p_action->GetObjectId()); + } + + m_list0x90.push_back(action2); + } + } + + FUN_100c7cb0(p_action); + return SUCCESS; +} + // FUNCTION: LEGO1 0x100c84a0 void MxDiskStreamController::InsertToList74(MxDSBuffer* p_buffer) { diff --git a/LEGO1/mxdiskstreamcontroller.h b/LEGO1/mxdiskstreamcontroller.h index 4d5151b3..1d1cf7d5 100644 --- a/LEGO1/mxdiskstreamcontroller.h +++ b/LEGO1/mxdiskstreamcontroller.h @@ -54,7 +54,9 @@ class MxDiskStreamController : public MxStreamController { void FUN_100c7ce0(MxDSBuffer* p_buffer); MxResult FUN_100c7d10(); void FUN_100c7980(); + MxDSStreamingAction* FUN_100c7db0(); void FUN_100c7f40(MxDSStreamingAction* p_streamingaction); + MxResult FUN_100c8360(MxDSStreamingAction* p_action); void InsertToList74(MxDSBuffer* p_buffer); void FUN_100c8540(); void FUN_100c8720(); diff --git a/LEGO1/mxdsbuffer.cpp b/LEGO1/mxdsbuffer.cpp index 501cefd6..ae74ed4b 100644 --- a/LEGO1/mxdsbuffer.cpp +++ b/LEGO1/mxdsbuffer.cpp @@ -123,7 +123,7 @@ MxResult MxDSBuffer::SetBufferPointer(MxU32* p_buffer, MxU32 p_size) } // STUB: LEGO1 0x100c67b0 -MxResult MxDSBuffer::FUN_100c67b0(MxStreamController* p_controller, MxDSAction* p_action, undefined4*) +MxResult MxDSBuffer::FUN_100c67b0(MxStreamController* p_controller, MxDSAction* p_action, MxDSStreamingAction** p_streamingAction) { // TODO STUB return FAILURE; diff --git a/LEGO1/mxdsbuffer.h b/LEGO1/mxdsbuffer.h index 9c61b912..0aa40cb1 100644 --- a/LEGO1/mxdsbuffer.h +++ b/LEGO1/mxdsbuffer.h @@ -33,7 +33,7 @@ class MxDSBuffer : public MxCore { MxResult AllocateBuffer(MxU32 p_bufferSize, MxDSBufferType p_mode); MxResult SetBufferPointer(MxU32* p_buffer, MxU32 p_size); - MxResult FUN_100c67b0(MxStreamController* p_controller, MxDSAction* p_action, undefined4*); + MxResult FUN_100c67b0(MxStreamController* p_controller, MxDSAction* p_action, MxDSStreamingAction** p_streamingAction); MxResult CreateObject( MxStreamController* p_controller, MxU32* p_data, @@ -55,6 +55,7 @@ class MxDSBuffer : public MxCore { inline MxU8* GetBuffer() { return m_pBuffer; } inline MxU32 GetWriteOffset() { return m_writeOffset; } + inline MxU16 GetRefCount() { return m_refcount; } inline MxDSBufferType GetMode() { return m_mode; } private: diff --git a/LEGO1/mxramstreamcontroller.cpp b/LEGO1/mxramstreamcontroller.cpp index 24c5a79d..f4fc57ed 100644 --- a/LEGO1/mxramstreamcontroller.cpp +++ b/LEGO1/mxramstreamcontroller.cpp @@ -84,7 +84,7 @@ MxResult MxRAMStreamController::DeserializeObject(MxDSStreamingAction& p_action) { MxAutoLocker locker(&m_criticalSection); MxResult result; - undefined4 value = 0; + MxDSStreamingAction* value = 0; do { m_buffer.FUN_100c6f80(p_action.GetUnknown94()); result = m_buffer.FUN_100c67b0(this, &p_action, &value);