Skip to content

Commit

Permalink
Move CreateStreamObject to proper location (#1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
foxtacles authored Dec 20, 2024
1 parent c9acd9a commit 5a61cf6
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 72 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions LEGO1/omni/include/mxdsobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "mxatom.h"
#include "mxcore.h"

class MxDSFile;
class MxPresenter;

// VTABLE: LEGO1 0x100dc868
Expand Down Expand Up @@ -104,5 +105,6 @@ class MxDSObject : public MxCore {
};

MxDSObject* DeserializeDSObjectDispatch(MxU8*&, MxS16);
MxDSObject* CreateStreamObject(MxDSFile*, MxS16);

#endif // MXDSOBJECT_H
32 changes: 21 additions & 11 deletions LEGO1/omni/include/mxdssource.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#define MXDSSOURCE_H

#include "mxcore.h"

class MxDSBuffer;
#include "mxdsbuffer.h"

// VTABLE: LEGO1 0x100dc8c8
// SIZE 0x14
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion LEGO1/omni/include/mxutilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 37 additions & 0 deletions LEGO1/omni/src/action/mxdsobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
36 changes: 0 additions & 36 deletions LEGO1/omni/src/common/mxutilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions LEGO1/omni/src/stream/mxdsfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
23 changes: 0 additions & 23 deletions LEGO1/omni/src/stream/mxdssource.cpp

This file was deleted.

0 comments on commit 5a61cf6

Please sign in to comment.