mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 08:24:16 +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:
55
LEGO1/mxstreamchunk.cpp
Normal file
55
LEGO1/mxstreamchunk.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "mxstreamchunk.h"
|
||||
|
||||
#include "legoutil.h"
|
||||
#include "mxdsbuffer.h"
|
||||
|
||||
// FUNCTION: LEGO1 0x100c2fe0
|
||||
MxStreamChunk::~MxStreamChunk()
|
||||
{
|
||||
if (m_buffer) {
|
||||
m_buffer->ReleaseRef(this);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c3050
|
||||
MxResult MxStreamChunk::ReadChunk(MxDSBuffer* p_buffer, MxU8* p_chunkData)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
|
||||
if (p_chunkData != NULL && *(MxU32*) p_chunkData == FOURCC('M', 'x', 'C', 'h')) {
|
||||
if (ReadChunkHeader(p_chunkData + 8)) {
|
||||
if (p_buffer) {
|
||||
SetBuffer(p_buffer);
|
||||
p_buffer->AddRef(this);
|
||||
}
|
||||
result = SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c30a0
|
||||
MxU32 MxStreamChunk::ReadChunkHeader(MxU8* p_chunkData)
|
||||
{
|
||||
MxU32 headersize = 0;
|
||||
if (p_chunkData) {
|
||||
MxU8* chunkData = p_chunkData;
|
||||
// Note: the alpha debug version uses memcpy calls here,
|
||||
// but the code generation is the same.
|
||||
GetScalar(&p_chunkData, m_flags);
|
||||
GetScalar(&p_chunkData, m_objectId);
|
||||
GetScalar(&p_chunkData, m_time);
|
||||
GetScalar(&p_chunkData, m_length);
|
||||
m_data = p_chunkData;
|
||||
headersize = p_chunkData - chunkData;
|
||||
}
|
||||
|
||||
return headersize;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c3170
|
||||
void MxStreamChunk::SetBuffer(MxDSBuffer* p_buffer)
|
||||
{
|
||||
m_buffer = p_buffer;
|
||||
}
|
Reference in New Issue
Block a user