From 7010b9e67bde544f2ffb5033f9ad17259aa575b1 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 20 Dec 2024 14:07:45 -0700 Subject: [PATCH] Move `CreateStreamObject` to proper location --- CMakeLists.txt | 1 - LEGO1/omni/include/mxdsobject.h | 2 ++ LEGO1/omni/include/mxdssource.h | 32 +++++++++++++++-------- LEGO1/omni/include/mxutilities.h | 1 - LEGO1/omni/src/action/mxdsobject.cpp | 37 +++++++++++++++++++++++++++ LEGO1/omni/src/common/mxutilities.cpp | 36 -------------------------- LEGO1/omni/src/stream/mxdsfile.cpp | 1 + LEGO1/omni/src/stream/mxdssource.cpp | 23 ----------------- 8 files changed, 61 insertions(+), 72 deletions(-) delete mode 100644 LEGO1/omni/src/stream/mxdssource.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cd1c901de..e8cd185e37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,7 +251,6 @@ function(add_lego_libraries NAME) LEGO1/omni/src/stream/mxdsbuffer.cpp LEGO1/omni/src/stream/mxdschunk.cpp LEGO1/omni/src/stream/mxdsfile.cpp - LEGO1/omni/src/stream/mxdssource.cpp LEGO1/omni/src/stream/mxdssubscriber.cpp LEGO1/omni/src/stream/mxio.cpp LEGO1/omni/src/stream/mxramstreamcontroller.cpp diff --git a/LEGO1/omni/include/mxdsobject.h b/LEGO1/omni/include/mxdsobject.h index eb80044b06..6e3d2fc3d8 100644 --- a/LEGO1/omni/include/mxdsobject.h +++ b/LEGO1/omni/include/mxdsobject.h @@ -5,6 +5,7 @@ #include "mxatom.h" #include "mxcore.h" +class MxDSFile; class MxPresenter; // VTABLE: LEGO1 0x100dc868 @@ -104,5 +105,6 @@ class MxDSObject : public MxCore { }; MxDSObject* DeserializeDSObjectDispatch(MxU8*&, MxS16); +MxDSObject* CreateStreamObject(MxDSFile*, MxS16); #endif // MXDSOBJECT_H diff --git a/LEGO1/omni/include/mxdssource.h b/LEGO1/omni/include/mxdssource.h index 06f5e5563b..745c26566c 100644 --- a/LEGO1/omni/include/mxdssource.h +++ b/LEGO1/omni/include/mxdssource.h @@ -2,8 +2,7 @@ #define MXDSSOURCE_H #include "mxcore.h" - -class MxDSBuffer; +#include "mxdsbuffer.h" // VTABLE: LEGO1 0x100dc8c8 // SIZE 0x14 @@ -27,15 +26,26 @@ class MxDSSource : public MxCore { return !strcmp(p_name, MxDSSource::ClassName()) || MxCore::IsA(p_name); } - virtual MxLong Open(MxULong) = 0; // vtable+0x14 - virtual MxLong Close() = 0; // vtable+0x18 - virtual MxResult ReadToBuffer(MxDSBuffer* p_buffer); // vtable+0x1c - virtual MxResult Read(unsigned char*, MxULong) = 0; // vtable+0x20 - virtual MxLong Seek(MxLong, MxS32) = 0; // vtable+0x24 - virtual MxULong GetBufferSize() = 0; // vtable+0x28 - virtual MxULong GetStreamBuffersNum() = 0; // vtable+0x2c - virtual MxLong GetLengthInDWords(); // vtable+0x30 - virtual MxU32* GetBuffer(); // vtable+0x34 + virtual MxLong Open(MxULong) = 0; // vtable+0x14 + virtual MxLong Close() = 0; // vtable+0x18 + + // FUNCTION: LEGO1 0x100bffd0 + virtual MxResult ReadToBuffer(MxDSBuffer* p_buffer) + { + return Read(p_buffer->GetBuffer(), p_buffer->GetWriteOffset()); + } // vtable+0x1c + + virtual MxResult Read(unsigned char*, MxULong) = 0; // vtable+0x20 + virtual MxLong Seek(MxLong, MxS32) = 0; // vtable+0x24 + virtual MxULong GetBufferSize() = 0; // vtable+0x28 + virtual MxULong GetStreamBuffersNum() = 0; // vtable+0x2c + + // FUNCTION: LEGO1 0x100bfff0 + virtual MxLong GetLengthInDWords() { return m_lengthInDWords; } // vtable+0x30 + + // FUNCTION: LEGO1 0x100c0000 + virtual MxU32* GetBuffer() { return m_pBuffer; } // vtable+0x34 + MxLong GetPosition() const { return m_position; } protected: diff --git a/LEGO1/omni/include/mxutilities.h b/LEGO1/omni/include/mxutilities.h index 59ff7d89fa..c7a2bcfb9a 100644 --- a/LEGO1/omni/include/mxutilities.h +++ b/LEGO1/omni/include/mxutilities.h @@ -76,7 +76,6 @@ void OmniError(const char* p_message, MxS32 p_status); void SetOmniUserMessage(void (*p_omniUserMessage)(const char*, MxS32)); MxBool ContainsPresenter(MxCompositePresenterList& p_presenterList, MxPresenter* p_presenter); void FUN_100b7220(MxDSAction* p_action, MxU32 p_newFlags, MxBool p_setFlags); -MxDSObject* CreateStreamObject(MxDSFile*, MxS16); MxBool KeyValueStringParse(char*, const char*, const char*); #endif // MXUTILITIES_H diff --git a/LEGO1/omni/src/action/mxdsobject.cpp b/LEGO1/omni/src/action/mxdsobject.cpp index ae266fe04e..3bb189c712 100644 --- a/LEGO1/omni/src/action/mxdsobject.cpp +++ b/LEGO1/omni/src/action/mxdsobject.cpp @@ -3,6 +3,7 @@ #include "mxdsaction.h" #include "mxdsanim.h" #include "mxdsevent.h" +#include "mxdsfile.h" #include "mxdsmediaaction.h" #include "mxdsmultiaction.h" #include "mxdsobjectaction.h" @@ -227,3 +228,39 @@ MxDSObject* DeserializeDSObjectDispatch(MxU8*& p_source, MxS16 p_flags) return obj; } + +// FUNCTION: LEGO1 0x100c0280 +MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs) +{ + MxU8* buf; + _MMCKINFO tmpChunk; + + if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], SEEK_SET)) { + return NULL; + } + + if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) { + if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) { + + buf = new MxU8[tmpChunk.cksize]; + if (!buf) { + return NULL; + } + + if (p_file->Read(buf, tmpChunk.cksize) != 0) { + return NULL; + } + + // Save a copy so we can clean up properly, because + // this function will alter the pointer value. + MxU8* copy = buf; + MxDSObject* obj = DeserializeDSObjectDispatch(buf, -1); + delete[] copy; + return obj; + } + + return NULL; + } + + return NULL; +} diff --git a/LEGO1/omni/src/common/mxutilities.cpp b/LEGO1/omni/src/common/mxutilities.cpp index c943bde5f3..c1a102f578 100644 --- a/LEGO1/omni/src/common/mxutilities.cpp +++ b/LEGO1/omni/src/common/mxutilities.cpp @@ -158,39 +158,3 @@ void FUN_100b7220(MxDSAction* p_action, MxU32 p_newFlags, MxBool p_setFlags) } } } - -// Should probably be somewhere else -// FUNCTION: LEGO1 0x100c0280 -MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs) -{ - MxU8* buf; - _MMCKINFO tmpChunk; - - if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], SEEK_SET)) { - return NULL; - } - - if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) { - if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) { - - buf = new MxU8[tmpChunk.cksize]; - if (!buf) { - return NULL; - } - - if (p_file->Read(buf, tmpChunk.cksize) != 0) { - return NULL; - } - - // Save a copy so we can clean up properly, because - // this function will alter the pointer value. - MxU8* copy = buf; - MxDSObject* obj = DeserializeDSObjectDispatch(buf, -1); - delete[] copy; - return obj; - } - return NULL; - } - - return NULL; -} diff --git a/LEGO1/omni/src/stream/mxdsfile.cpp b/LEGO1/omni/src/stream/mxdsfile.cpp index 54195f9288..51ca661544 100644 --- a/LEGO1/omni/src/stream/mxdsfile.cpp +++ b/LEGO1/omni/src/stream/mxdsfile.cpp @@ -8,6 +8,7 @@ #define SI_MAJOR_VERSION 2 #define SI_MINOR_VERSION 2 +DECOMP_SIZE_ASSERT(MxDSSource, 0x14) DECOMP_SIZE_ASSERT(MxDSFile::ChunkHeader, 0x0c) DECOMP_SIZE_ASSERT(MxDSFile, 0x7c) diff --git a/LEGO1/omni/src/stream/mxdssource.cpp b/LEGO1/omni/src/stream/mxdssource.cpp deleted file mode 100644 index c2d86abb9b..0000000000 --- a/LEGO1/omni/src/stream/mxdssource.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "mxdssource.h" - -#include "mxdsbuffer.h" - -DECOMP_SIZE_ASSERT(MxDSSource, 0x14) - -// FUNCTION: LEGO1 0x100bffd0 -MxResult MxDSSource::ReadToBuffer(MxDSBuffer* p_buffer) -{ - return Read(p_buffer->GetBuffer(), p_buffer->GetWriteOffset()); -} - -// FUNCTION: LEGO1 0x100bfff0 -MxLong MxDSSource::GetLengthInDWords() -{ - return m_lengthInDWords; -} - -// FUNCTION: LEGO1 0x100c0000 -MxU32* MxDSSource::GetBuffer() -{ - return m_pBuffer; -}