diff --git a/LEGO1/mxdiskstreamcontroller.cpp b/LEGO1/mxdiskstreamcontroller.cpp index 9e37edc4..0c74c3a7 100644 --- a/LEGO1/mxdiskstreamcontroller.cpp +++ b/LEGO1/mxdiskstreamcontroller.cpp @@ -16,6 +16,52 @@ MxDiskStreamController::~MxDiskStreamController() MxResult MxDiskStreamController::Tickle() { // TODO - return 0; } + +// OFFSET: LEGO1 0x100c7790 STUB +MxResult MxDiskStreamController::Open(const char *p_filename) +{ + // TODO + return FAILURE; +} + +// OFFSET: LEGO1 0x100c7880 +MxResult MxDiskStreamController::vtable0x18(undefined4 p_unknown, undefined4 p_unknown2) +{ + return SUCCESS; +} + +// OFFSET: LEGO1 0x100c7ff0 STUB +MxResult MxDiskStreamController::vtable0x20(MxDSAction* p_action) +{ + // TODO + return FAILURE; +} + +// OFFSET: LEGO1 0x100c8160 STUB +MxResult MxDiskStreamController::vtable0x24(undefined4 p_unknown) +{ + // TODO + return FAILURE; +} + +// OFFSET: LEGO1 0x100c7ac0 STUB +MxResult MxDiskStreamController::vtable0x28() +{ + // TODO + return FAILURE; +} + +// OFFSET: LEGO1 0x100c7c00 STUB +MxResult MxDiskStreamController::vtable0x30(undefined4 p_unknown) +{ + // TODO + return FAILURE; +} + +// OFFSET: LEGO1 0x100c7960 +MxResult MxDiskStreamController::vtable0x34(undefined4 p_unknown) +{ + return FAILURE; +} diff --git a/LEGO1/mxdiskstreamcontroller.h b/LEGO1/mxdiskstreamcontroller.h index 1f66984c..5457a9b5 100644 --- a/LEGO1/mxdiskstreamcontroller.h +++ b/LEGO1/mxdiskstreamcontroller.h @@ -15,6 +15,13 @@ class MxDiskStreamController : public MxStreamController virtual ~MxDiskStreamController() override; virtual MxResult Tickle() override; // vtable+0x8 + virtual MxResult Open(const char *p_filename) override; // vtable+0x14 + virtual MxResult vtable0x18(undefined4 p_unknown, undefined4 p_unknown2) override; //vtable+0x18 + virtual MxResult vtable0x20(MxDSAction* p_action) override; //vtable+0x20 + virtual MxResult vtable0x24(undefined4 p_unknown) override; //vtable+0x24 + virtual MxResult vtable0x28() override; //vtable+0x28 + virtual MxResult vtable0x30(undefined4 p_unknown) override; //vtable+0x30 + virtual MxResult vtable0x34(undefined4 p_unknown); //vtable+0x34 // OFFSET: LEGO1 0x100c7360 inline virtual const char *ClassName() const override // vtable+0x0c diff --git a/LEGO1/mxdiskstreamprovider.cpp b/LEGO1/mxdiskstreamprovider.cpp index 4dcb02cf..9555a8cf 100644 --- a/LEGO1/mxdiskstreamprovider.cpp +++ b/LEGO1/mxdiskstreamprovider.cpp @@ -45,4 +45,41 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete() void MxDiskStreamProvider::PerformWork() { // TODO -} \ No newline at end of file +} + +// OFFSET: LEGO1 0x100d13d0 STUB +MxResult MxDiskStreamProvider::SetResourceToGet(void* p_resource) +{ + // TODO + return FAILURE; +} + +// OFFSET: LEGO1 0x100d1e90 +MxU32 MxDiskStreamProvider::GetFileSize() +{ + return m_pFile->GetBufferSize(); +} + +// OFFSET: LEGO1 0x100d1ea0 +MxU32 MxDiskStreamProvider::GetStreamBuffersNum() +{ + return m_pFile->GetStreamBuffersNum(); +} + +// OFFSET: LEGO1 0x100d15e0 STUB +void MxDiskStreamProvider::vtable0x20(undefined4 p_unknown1) +{ + // TODO +} + +// OFFSET: LEGO1 0x100d1eb0 +MxU32 MxDiskStreamProvider::GetLengthInDWords() +{ + return m_pFile->GetLengthInDWords(); +} + +// OFFSET: LEGO1 0x100d1ec0 +MxU32* MxDiskStreamProvider::GetBufferForDWords() +{ + return m_pFile->GetBuffer(); +} diff --git a/LEGO1/mxdiskstreamprovider.h b/LEGO1/mxdiskstreamprovider.h index c797a0de..c35826b8 100644 --- a/LEGO1/mxdiskstreamprovider.h +++ b/LEGO1/mxdiskstreamprovider.h @@ -49,6 +49,13 @@ class MxDiskStreamProvider : public MxStreamProvider void PerformWork(); + virtual MxResult SetResourceToGet(void* p_resource) override; //vtable+0x14 + virtual MxU32 GetFileSize() override; //vtable+0x18 + virtual MxU32 GetStreamBuffersNum() override; //vtable+0x1c + virtual void vtable0x20(undefined4 p_unknown1) override; //vtable+0x20 + virtual MxU32 GetLengthInDWords() override; //vtable+0x24 + virtual MxU32* GetBufferForDWords()override; //vtable+0x28 + private: MxDiskStreamProviderThread m_thread; // 0x10 MxSemaphore m_busySemaphore; // 0x2c diff --git a/LEGO1/mxdsfile.cpp b/LEGO1/mxdsfile.cpp index ca6e96fb..d1c87032 100644 --- a/LEGO1/mxdsfile.cpp +++ b/LEGO1/mxdsfile.cpp @@ -81,7 +81,7 @@ MxLong MxDSFile::ReadChunks() } MxULong* pLengthInDWords = &m_lengthInDWords; m_io.Read(pLengthInDWords, 4); - m_pBuffer = malloc(*pLengthInDWords * 4); + m_pBuffer = new MxU32[*pLengthInDWords]; m_io.Read(m_pBuffer, *pLengthInDWords * 4); return 0; } @@ -120,7 +120,7 @@ MxLong MxDSFile::Close() if (m_lengthInDWords != 0) { m_lengthInDWords = 0; - free(m_pBuffer); + delete[] m_pBuffer; m_pBuffer = NULL; } return 0; diff --git a/LEGO1/mxdssource.cpp b/LEGO1/mxdssource.cpp index 4dfb5386..86c4f9fb 100644 --- a/LEGO1/mxdssource.cpp +++ b/LEGO1/mxdssource.cpp @@ -14,7 +14,7 @@ MxLong MxDSSource::GetLengthInDWords() } // OFFSET: LEGO1 0x100c0000 -void *MxDSSource::GetBuffer() +MxU32 *MxDSSource::GetBuffer() { return m_pBuffer; } \ No newline at end of file diff --git a/LEGO1/mxdssource.h b/LEGO1/mxdssource.h index 67cbc6c7..626eaf37 100644 --- a/LEGO1/mxdssource.h +++ b/LEGO1/mxdssource.h @@ -34,11 +34,11 @@ class MxDSSource : public MxCore virtual MxULong GetBufferSize() = 0; virtual MxULong GetStreamBuffersNum() = 0; virtual MxLong GetLengthInDWords(); - virtual void* GetBuffer(); // 0x34 + virtual MxU32* GetBuffer(); // 0x34 protected: MxULong m_lengthInDWords; - void* m_pBuffer; + MxU32* m_pBuffer; MxLong m_position; }; diff --git a/LEGO1/mxramstreamprovider.cpp b/LEGO1/mxramstreamprovider.cpp index 9b052699..1b44d84f 100644 --- a/LEGO1/mxramstreamprovider.cpp +++ b/LEGO1/mxramstreamprovider.cpp @@ -41,7 +41,7 @@ MxU32 MxRAMStreamProvider::GetFileSize() } // OFFSET: LEGO1 0x100d0940 -MxU32 MxRAMStreamProvider::vtable0x1C() +MxU32 MxRAMStreamProvider::GetStreamBuffersNum() { return 1; } @@ -53,7 +53,7 @@ MxU32 MxRAMStreamProvider::GetLengthInDWords() } // OFFSET: LEGO1 0x100d0960 -void* MxRAMStreamProvider::GetBufferForDWords() +MxU32* MxRAMStreamProvider::GetBufferForDWords() { return m_bufferForDWords; } diff --git a/LEGO1/mxramstreamprovider.h b/LEGO1/mxramstreamprovider.h index 4a22b013..48e0dcae 100644 --- a/LEGO1/mxramstreamprovider.h +++ b/LEGO1/mxramstreamprovider.h @@ -9,19 +9,19 @@ class MxRAMStreamProvider : public MxStreamProvider public: MxRAMStreamProvider(); virtual ~MxRAMStreamProvider() override; - + virtual MxResult SetResourceToGet(void* p_resource) override; //vtable+0x14 virtual MxU32 GetFileSize() override; //vtable+0x18 - virtual MxU32 vtable0x1C() override; //vtable+0x1c + virtual MxU32 GetStreamBuffersNum() override; //vtable+0x1c virtual MxU32 GetLengthInDWords() override; //vtable+0x24 - virtual void* GetBufferForDWords() override; //vtable+0x28 + virtual MxU32* GetBufferForDWords() override; //vtable+0x28 protected: MxU32 m_bufferSize; MxU32 m_fileSize; void* m_pBufferOfFileSize; MxU32 m_lengthInDWords; - void* m_bufferForDWords; + MxU32* m_bufferForDWords; }; #endif // MXRAMSTREAMPROVIDER_H diff --git a/LEGO1/mxstreamcontroller.cpp b/LEGO1/mxstreamcontroller.cpp index 36b85ebc..89b2fa51 100644 --- a/LEGO1/mxstreamcontroller.cpp +++ b/LEGO1/mxstreamcontroller.cpp @@ -45,11 +45,26 @@ MxResult MxStreamController::vtable0x1C(undefined4 p_unknown, undefined4 p_unkno return FAILURE; } -// OFFSET: LEGO1 0x100c1690 STUB +// OFFSET: LEGO1 0x100c1690 MxResult MxStreamController::vtable0x20(MxDSAction* p_action) { - // TODO STUB - return FAILURE; + MxAutoLocker locker(&m_criticalSection); + + MxResult result; + MxU32 offset = 0; + + MxS32 objectId = p_action->GetObjectId(); + MxStreamProvider *provider = m_provider; + + if ((MxS32) provider->GetLengthInDWords() > objectId) + offset = provider->GetBufferForDWords()[objectId]; + + if (offset) + result = vtable0x2c(p_action, offset); + else + result = FAILURE; + + return result; } // OFFSET: LEGO1 0x100c1740 STUB @@ -66,7 +81,7 @@ MxResult MxStreamController::vtable0x28() } // OFFSET: LEGO1 0x100c1c10 STUB -MxResult MxStreamController::vtable0x2c(undefined4 p_unknown1, undefined4 p_unknow2) +MxResult MxStreamController::vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval) { return FAILURE; } diff --git a/LEGO1/mxstreamcontroller.h b/LEGO1/mxstreamcontroller.h index 59490d2c..539af0bd 100644 --- a/LEGO1/mxstreamcontroller.h +++ b/LEGO1/mxstreamcontroller.h @@ -7,6 +7,7 @@ #include "mxcore.h" #include "mxdsobject.h" #include "mxdsaction.h" +#include "mxstreamprovider.h" // VTABLE 0x100dc968 // SIZE 0x64 @@ -36,7 +37,7 @@ class MxStreamController : public MxCore virtual MxResult vtable0x20(MxDSAction* p_action); //vtable+0x20 virtual MxResult vtable0x24(undefined4 p_unknown); //vtable+0x24 virtual MxResult vtable0x28(); //vtable+0x28 - virtual MxResult vtable0x2c(undefined4 p_unknown1, undefined4 p_unknow2); //vtable+0x2c + virtual MxResult vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval); //vtable+0x2c virtual MxResult vtable0x30(undefined4 p_unknown); //vtable+0x30 MxBool FUN_100c20d0(MxDSObject &p_obj); @@ -45,7 +46,7 @@ class MxStreamController : public MxCore protected: MxCriticalSection m_criticalSection; MxAtomId atom; - undefined4 m_unk28; // MxStreamProvider* + MxStreamProvider* m_provider; // MxStreamProvider* undefined4 m_unk2c; undefined m_unk30[0x34]; }; diff --git a/LEGO1/mxstreamprovider.h b/LEGO1/mxstreamprovider.h index 3cb11144..fb210f80 100644 --- a/LEGO1/mxstreamprovider.h +++ b/LEGO1/mxstreamprovider.h @@ -26,10 +26,10 @@ class MxStreamProvider : public MxCore virtual MxResult SetResourceToGet(void* p_resource); //vtable+0x14 virtual MxU32 GetFileSize() = 0; //vtable+0x18 - virtual MxU32 vtable0x1C() = 0; //vtable+0x1c + virtual MxU32 GetStreamBuffersNum() = 0; //vtable+0x1c virtual void vtable0x20(undefined4 p_unknown1); //vtable+0x20 virtual MxU32 GetLengthInDWords() = 0; //vtable+0x24 - virtual void* GetBufferForDWords() = 0; //vtable+0x28 + virtual MxU32* GetBufferForDWords() = 0; //vtable+0x28 protected: void *m_pLookup;