mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 16:34:06 +00:00
implement MxDSBuffer object creation (#340)
* push changes * Update mxstreamcontroller.cpp * fix build * MxStreamChunk * fix format * Match functions * Add a comment --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#include "mxdsbuffer.h"
|
||||
|
||||
#include "mxdschunk.h"
|
||||
#include "mxdsstreamingaction.h"
|
||||
#include "mxomni.h"
|
||||
#include "mxstreamchunk.h"
|
||||
#include "mxstreamcontroller.h"
|
||||
#include "mxstreamer.h"
|
||||
|
||||
@@ -9,7 +12,7 @@ DECOMP_SIZE_ASSERT(MxDSBuffer, 0x34);
|
||||
// FUNCTION: LEGO1 0x100c6470
|
||||
MxDSBuffer::MxDSBuffer()
|
||||
{
|
||||
m_unk0x20 = 0;
|
||||
m_refcount = 0;
|
||||
m_pBuffer = NULL;
|
||||
m_pIntoBuffer = NULL;
|
||||
m_pIntoBuffer2 = NULL;
|
||||
@@ -49,7 +52,7 @@ MxResult MxDSBuffer::AllocateBuffer(MxU32 p_bufferSize, MxDSBufferType p_mode)
|
||||
else if (p_mode == MxDSBufferType_Chunk) {
|
||||
MxStreamer* streamer = Streamer();
|
||||
// I have no clue as to what this does, or even if its correct. Maybe it's related to storing chunks in
|
||||
// MxRamStreamController?
|
||||
// MxDiskStreamController?
|
||||
if (p_bufferSize >> 10 == 0x40) {
|
||||
i = 0;
|
||||
while (i < 22) {
|
||||
@@ -126,6 +129,132 @@ MxResult MxDSBuffer::FUN_100c67b0(MxStreamController* p_controller, MxDSAction*
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c68a0
|
||||
MxResult MxDSBuffer::CreateObject(
|
||||
MxStreamController* p_controller,
|
||||
MxU32* p_data,
|
||||
MxDSAction* p_action,
|
||||
undefined4 p_undefined
|
||||
)
|
||||
{
|
||||
if (p_data == NULL) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
MxCore* header = ReadChunk(this, p_data, p_action->GetUnknown24());
|
||||
|
||||
if (header == NULL) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (*p_data == FOURCC('M', 'x', 'O', 'b'))
|
||||
return StartPresenterFromAction(p_controller, p_action, (MxDSAction*) header);
|
||||
else if (*p_data == FOURCC('M', 'x', 'C', 'h')) {
|
||||
MxStreamChunk* chunk = (MxStreamChunk*) header;
|
||||
if (!m_unk0x30->HasId((chunk)->GetObjectId())) {
|
||||
delete header;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
return ParseChunk(p_controller, p_data, p_action, p_undefined, chunk);
|
||||
}
|
||||
|
||||
delete header;
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c6960
|
||||
MxResult MxDSBuffer::StartPresenterFromAction(
|
||||
MxStreamController* p_controller,
|
||||
MxDSAction* p_action1,
|
||||
MxDSAction* p_objectheader
|
||||
)
|
||||
{
|
||||
if (!m_unk0x30->GetInternalAction()) {
|
||||
p_objectheader->SetAtomId(p_action1->GetAtomId());
|
||||
p_objectheader->SetUnknown28(p_action1->GetUnknown28());
|
||||
p_objectheader->SetUnknown84(p_action1->GetUnknown84());
|
||||
p_objectheader->SetOrigin(p_action1->GetOrigin());
|
||||
p_objectheader->SetUnknown90(p_action1->GetUnknown90());
|
||||
p_objectheader->MergeFrom(*p_action1);
|
||||
|
||||
m_unk0x30->SetInternalAction(p_objectheader->Clone());
|
||||
|
||||
p_controller->InsertActionToList54(p_objectheader);
|
||||
|
||||
if (MxOmni::GetInstance()->CreatePresenter(p_controller, *p_objectheader) != SUCCESS) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
m_unk0x30->SetLoopCount(p_objectheader->GetLoopCount());
|
||||
m_unk0x30->SetFlags(p_objectheader->GetFlags());
|
||||
m_unk0x30->SetDuration(p_objectheader->GetDuration());
|
||||
|
||||
if (m_unk0x30->GetInternalAction() == NULL) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
else if (p_objectheader) {
|
||||
delete p_objectheader;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100c6a50
|
||||
MxResult MxDSBuffer::ParseChunk(
|
||||
MxStreamController* p_controller,
|
||||
MxU32* p_data,
|
||||
MxDSAction* p_action,
|
||||
undefined4,
|
||||
MxStreamChunk* p_header
|
||||
)
|
||||
{
|
||||
// TODO
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c6d00
|
||||
MxCore* MxDSBuffer::ReadChunk(MxDSBuffer* p_buffer, MxU32* p_chunkData, MxU16 p_flags)
|
||||
{
|
||||
// This function reads a chunk. If it is an object, this function returns an MxDSObject. If it is a chunk, returns a
|
||||
// MxDSChunk.
|
||||
MxCore* result = NULL;
|
||||
MxU8* dataStart = (MxU8*) p_chunkData + 8;
|
||||
|
||||
switch (*p_chunkData) {
|
||||
case FOURCC('M', 'x', 'O', 'b'):
|
||||
result = DeserializeDSObjectDispatch(&dataStart, p_flags);
|
||||
break;
|
||||
case FOURCC('M', 'x', 'C', 'h'):
|
||||
result = new MxStreamChunk();
|
||||
if (result != NULL && ((MxStreamChunk*) result)->ReadChunk(p_buffer, (MxU8*) p_chunkData) != SUCCESS) {
|
||||
delete result;
|
||||
result = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c6ec0
|
||||
MxU8 MxDSBuffer::ReleaseRef(MxDSChunk*)
|
||||
{
|
||||
if (m_refcount != 0) {
|
||||
m_refcount--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c6ee0
|
||||
void MxDSBuffer::AddRef(MxDSChunk* p_chunk)
|
||||
{
|
||||
if (p_chunk) {
|
||||
m_refcount++;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c6f80
|
||||
void MxDSBuffer::FUN_100c6f80(MxU32 p_writeOffset)
|
||||
{
|
||||
|
Reference in New Issue
Block a user