21 m_pIntoBuffer2 =
NULL;
36 assert(m_referenceCount == 0);
38 if (m_pBuffer !=
NULL) {
66 m_pBuffer =
new MxU8[p_bufferSize];
75 m_pIntoBuffer = m_pBuffer;
76 m_pIntoBuffer2 = m_pBuffer;
78 if (m_pBuffer !=
NULL) {
79 m_bytesRemaining = p_bufferSize;
80 m_writeOffset = m_bytesRemaining;
92 m_pIntoBuffer = p_buffer;
93 m_pIntoBuffer2 = p_buffer;
94 m_bytesRemaining = p_size;
95 m_writeOffset = p_size;
109 MxU8* data = m_pBuffer;
112 if (m_unk0x30 ==
NULL) {
117 if (*p_streamingAction !=
NULL) {
118 MxDSBuffer* buffer = (*p_streamingAction)->GetUnknowna0();
125 buffer->m_unk0x30 = m_unk0x30;
132 (*p_streamingAction)->ClearUnknowna0();
136 *p_streamingAction =
NULL;
149 else if (result == 1) {
170 if (p_data ==
NULL) {
176 if (header ==
NULL) {
180 if (*p_data ==
FOURCC(
'M',
'x',
'O',
'b')) {
184 else if (*p_data ==
FOURCC(
'M',
'x',
'C',
'h')) {
186 if (!m_unk0x30->
HasId((chunk)->GetObjectId())) {
191 return ParseChunk(p_controller, p_data, p_action, p_streamingAction, chunk);
231 else if (p_objectheader) {
232 delete p_objectheader;
273 (*p_streamingAction)->SetUnknowna0(buffer);
327 MxU8* dataStart = (
MxU8*) p_chunkData + 8;
329 switch (*p_chunkData) {
330 case FOURCC(
'M',
'x',
'O',
'b'): {
335 case FOURCC(
'M',
'x',
'C',
'h'): {
356 if (m_pIntoBuffer !=
NULL) {
358 switch (*(
MxU32*) m_pIntoBuffer) {
359 case FOURCC(
'M',
'x',
'O',
'b'):
360 case FOURCC(
'M',
'x',
'C',
'h'):
361 result = m_pIntoBuffer;
362 m_pIntoBuffer += (*(
MxU32*) (m_pIntoBuffer + 4) & 1) + *(
MxU32*) (m_pIntoBuffer + 4);
365 if (m_pBuffer + m_writeOffset - 8 < m_pIntoBuffer) {
366 m_pIntoBuffer =
NULL;
370 case FOURCC(
'M',
'x',
'D',
'a'):
371 case FOURCC(
'M',
'x',
'S',
't'):
374 case FOURCC(
'M',
'x',
'H',
'd'):
375 m_pIntoBuffer += *(
MxU32*) (m_pIntoBuffer + 4) + 8;
377 case FOURCC(
'L',
'I',
'S',
'T'):
378 case FOURCC(
'R',
'I',
'F',
'F'):
382 m_pIntoBuffer =
NULL;
387 if (m_pIntoBuffer > m_pBuffer + m_writeOffset - 8) {
388 m_pIntoBuffer =
NULL;
394 m_pIntoBuffer2 = result;
401 if (m_referenceCount != 0) {
421 if (m_mode ==
e_allocate && m_bytesRemaining != 0) {
425 if (m_writeOffset == m_bytesRemaining) {
427 bytesRead = *(
MxU32*) (p_data + 4) + 8;
434 if (bytesRead <= m_bytesRemaining) {
435 memcpy(m_pBuffer + m_writeOffset - m_bytesRemaining, ptr, bytesRead);
437 if (m_writeOffset == m_bytesRemaining) {
441 m_bytesRemaining -= bytesRead;
452 if (p_writeOffset < m_writeOffset) {
453 m_pIntoBuffer2 = m_pBuffer + p_writeOffset;
454 m_pIntoBuffer = m_pBuffer + p_writeOffset;
461 MxU8* current = p_data ? p_data : m_pBuffer;
462 MxU8* end = m_writeOffset + m_pBuffer - 8;
464 while (current <= end) {
465 switch (*((
MxU32*) current)) {
466 case FOURCC(
'L',
'I',
'S',
'T'):
467 case FOURCC(
'R',
'I',
'F',
'F'):
470 case FOURCC(
'M',
'x',
'D',
'a'):
471 case FOURCC(
'M',
'x',
'S',
't'):
474 case FOURCC(
'M',
'x',
'O',
'b'):
475 case FOURCC(
'M',
'x',
'C',
'h'):
476 if (current != p_data) {
479 current = ((
MxU32) current & 1) + current;
482 case FOURCC(
'M',
'x',
'H',
'd'):
483 current += (((
MxU32*) current)[1] + 8);
499 if (m_writeOffset >= p_buf->m_writeOffset) {
500 memcpy(m_pBuffer, p_buf->m_pBuffer, p_buf->m_writeOffset);
504 m_unk0x1c = p_buf->m_unk0x1c;
511 if (p_buffer1 && p_buffer2) {
514 ((
MxU32*) p_buffer1)[1] += size;
[AI] Base virtual class for all Mindscape engine (Mx) objects.
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
MxU32 GetFlags()
[AI] Returns the flag field for this action (bitmask).
virtual void SetDuration(MxLong p_duration)
[AI] Sets the duration of this action in ticks or time units.
MxCore * GetUnknown84()
[AI] Returns a pointer to an associated or auxiliary core object.
MxS32 GetLoopCount()
[AI] Returns the loop count for this action.
virtual void SetUnknown90(MxLong p_unk0x90)
[AI] Set unknown value at offset 0x90, used as baseline in GetElapsedTime.
virtual MxLong GetUnknown90()
[AI] Gets the unknown value at offset 0x90, likely a start timestamp.
void SetOrigin(MxCore *p_origin)
[AI] Sets the origin core pointer for this action, if spatially transforming/localizing this action.
void SetFlags(MxU32 p_flags)
[AI] Sets the flag bitmask controlling action logic (enabled, looping, etc).
virtual MxLong GetDuration()
[AI] Gets the duration for which this action is intended to run.
void SetUnknown84(MxCore *p_unk0x84)
[AI] Sets the auxiliary core pointer for this action.
void SetLoopCount(MxS32 p_loopCount)
[AI] Sets the loop count for this action.
virtual MxDSAction * Clone()
[AI] Clones (deep-copies) this action and returns a new pointer.
virtual void MergeFrom(MxDSAction &p_dsAction)
[AI] Copies/merges properties from another action.
MxCore * GetOrigin()
[AI] Returns a pointer to the "origin" core object, which may be used to localize the action.
@ c_bit3
[AI] Unknown - possibly reserved [AI]
[AI] Buffer for managing streamed DS (Data Stream) chunks and actions.
MxU8 * SkipToData()
[AI] Scans this buffer forward to the next valid object or chunk and returns a pointer to its start.
MxResult FUN_100c7090(MxDSBuffer *p_buf)
[AI] Copies buffer data and selected internal state from another buffer, if space allows.
MxResult SetBufferPointer(MxU8 *p_buffer, MxU32 p_size)
[AI] Sets a buffer pointer and records its size.
MxResult CalcBytesRemaining(MxU8 *p_data)
[AI] Calculates pending bytes remaining to be streamed, updates buffer state accordingly.
MxU8 * GetBuffer()
[AI] Returns a pointer to the managed chunk data buffer.
void AddRef(MxDSChunk *p_chunk)
[AI] Increment reference count for this buffer (ownership by a chunk).
MxU8 ReleaseRef(MxDSChunk *)
[AI] Decrement the buffer's chunk reference count.
MxResult StartPresenterFromAction(MxStreamController *p_controller, MxDSAction *p_action1, MxDSAction *p_action2)
[AI] Launches a presenter for the given action if not already present.
MxResult CreateObject(MxStreamController *p_controller, MxU32 *p_data, MxDSAction *p_action, MxDSStreamingAction **p_streamingAction)
[AI] Creates a presenter/action object by deserializing a data block.
~MxDSBuffer() override
[AI] Destructor: Releases memory appropriately based on buffer management mode and asserts no referen...
MxDSBuffer()
[AI] Constructs a buffer object and initializes all internal pointers and counters.
MxU8 * FUN_100c6fa0(MxU8 *p_data)
[AI] Finds the next chunk boundary in the buffer, starting from an optional pointer.
MxResult AllocateBuffer(MxU32 p_bufferSize, Type p_mode)
[AI] Allocates a buffer of a given size and memory mode.
MxResult ParseChunk(MxStreamController *p_controller, MxU32 *p_data, MxDSAction *p_action, MxDSStreamingAction **p_streamingAction, MxStreamChunk *p_header)
[AI] Parses an MxStreamChunk for logical streaming actions, nested chunks, EoS, and splitting.
void FUN_100c6f80(MxU32 p_writeOffset)
[AI] Sets the buffer's internal streaming position to the given write offset.
static MxResult Append(MxU8 *p_buffer1, MxU8 *p_buffer2)
[AI] Appends one chunk/data stream buffer to another, adjusting sizes/headers.
MxResult FUN_100c67b0(MxStreamController *p_controller, MxDSAction *p_action, MxDSStreamingAction **p_streamingAction)
[AI] Executes streaming action startup and object creation loop from an initial SI chunk.
MxU32 GetBytesRemaining()
[AI] Returns the number of bytes remaining to stream in this buffer.
static MxCore * ReadChunk(MxDSBuffer *p_buffer, MxU32 *p_chunkData, MxU16 p_flags)
[AI] Reads an SI file object/chunk at given position in a buffer.
Type
[AI] Buffer memory management type.
@ e_preallocated
[AI] Preallocated memory passed in from outside.
@ e_allocate
[AI] Newly allocated memory with new[].
@ e_chunk
[AI] Chunk-managed memory (from Streamer pool).
@ e_unknown
[AI] Unknown/other (may be unused or special).
MxBool HasRef()
[AI] Checks whether there are any active references to this buffer.
[AI] Represents a chunk of data extracted from a stream (typically from a Mindscape/Mx SI file or str...
static MxU32 GetHeaderSize()
[AI] Returns the fixed size of the chunk header, typically used for parsing binary streams.
undefined4 GetObjectId()
[AI] Returns the object id of this chunk. [AI]
MxU32 GetLength()
[AI] Returns the length in bytes of the data payload. [AI]
MxLong GetTime()
[AI] Returns the time (timestamp or tick) associated with this chunk. [AI]
MxU16 GetChunkFlags()
[AI] Returns the chunk's flag bitfield. [AI]
void SetTime(MxLong p_time)
[AI] Sets the time (timestamp/tick/frame) associated with this chunk.
MxDSObject * Find(MxDSObject *p_action)
[AI] Finds a matching object in the list without removing it.
[AI] Base class for any object deserialized from an SI (script/data) file in the LEGO Island engine.
const MxAtomId & GetAtomId()
[AI] Returns a const-reference to the object's atom identifier.
void SetUnknown28(MxPresenter *p_unk0x28)
[AI] Sets the pointer at 0x28 (presenter or handler).
virtual void SetAtomId(MxAtomId p_atomId)
[AI] Sets the atom id for this object instance, used for indexing or lookup.
MxPresenter * GetUnknown28()
[AI] Returns the pointer stored at 0x28, likely a presenter or handler for this DS object.
MxS16 GetUnknown24()
[AI] Returns the unknown 0x24 value (may be data version or usage state). [AI]
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
[AI] Represents an action that streams data from a buffer within a DirectScript (DS) media timeline.
void SetBufferOffset(MxU32 p_bufferOffset)
[AI] Sets the current buffer read offset.
void FUN_100cd2d0()
[AI] Updates duration, loop count, and accumulates advanced streaming time for repeated playback.
MxBool HasId(MxU32 p_objectId) override
[AI] Determines if this action or its internal action correspond to the given object ID.
MxDSAction * GetInternalAction()
[AI] Returns the internal sub-action representing the actual user-level action being streamed.
void SetInternalAction(MxDSAction *p_dsAction)
[AI] Sets or replaces the internal action held by this streaming action (ownership is transferred).
MxLong GetUnknowna8()
[AI] Accumulated streaming duration, used for repeat or seek calculations.
void SetUnknown94(MxU32 p_unk0x94)
[AI] Sets the streaming offset/status at 0x94.
MxU32 GetBufferOffset()
[AI] Gets the buffer offset where streaming is currently positioned.
[AI] Controller for streaming from disk-based SI resources, manages buffers and streaming actions.
[AI] Contains data for scheduling the next action in a process, storing an object id,...
void SetData(MxU32 p_data)
[AI] Sets the data value for this action instance.
static MxOmni * GetInstance()
[AI] Returns the singleton instance of the MxOmni subsystem coordinator.
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
static MxU32 * IntoLength(MxU8 *p_buffer)
[AI] Utility to cast a chunk header buffer into the data length field pointer, facilitating direct pa...
MxResult ReadChunk(MxDSBuffer *p_buffer, MxU8 *p_chunkData)
[AI] Reads the chunk's header and initializes from a chunk data buffer of a streamed data segment.
MxResult SendChunk(MxDSSubscriberList &p_subscriberList, MxBool p_append, MxS16 p_obj24val)
[AI] Dispatches this stream chunk to a list of subscribers matching certain criteria.
static MxU16 * IntoFlags(MxU8 *p_buffer)
[AI] Utility to cast a chunk header buffer into the flags field pointer, facilitating direct parsing.
[AI] Controller for streaming and managing multimedia resources and actions during gameplay.
MxStreamProvider * GetProvider()
[AI] Retrieves the current stream provider abstraction used to access file/memory resources.
MxNextActionDataStart * FindNextActionDataStartFromStreamingAction(MxDSStreamingAction *p_action)
[AI] Finds the corresponding next action data start (offset info) for a streaming action.
MxDSSubscriberList & GetSubscriberList()
[AI] Returns the list of current stream subscribers.
MxDSObjectList & GetUnk0x3c()
[AI] Returns the list of actions currently being streamed ("in progress" list).
virtual MxResult VTable0x30(MxDSAction *p_action)
[AI] Removes a completed action from in-progress ("unk0x3c") list and deletes its data block.
MxResult InsertActionToList54(MxDSAction *p_action)
[AI] Inserts a clone of the provided action into the pending ("unk0x54") list.
virtual void VTable0x20(MxDSAction *p_action)
[AI] Virtual hook for subclasses to react to new stream actions being queued.
virtual MxU32 * GetBufferForDWords()=0
[AI] Returns a pointer to the underlying buffer, cast as an array of DWORDs, for streaming purposes.
void ReleaseMemoryBlock(MxU8 *p_block, MxU32 p_blockSize)
Return a previously-acquired memory block to the pool.
MxU8 * GetMemoryBlock(MxU32 p_blockSize)
Allocate a temporary memory block from the streamer pool.
#define DECOMP_SIZE_ASSERT(T, S)
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
#define DS_CHUNK_END_OF_STREAM
[AI] Flag bit indicating this chunk is the last in its stream.
#define DS_CHUNK_SPLIT
[AI] Flag indicating this chunk is split (i.e., fragmented and needs reassembling).
MxDSObject * DeserializeDSObjectDispatch(MxU8 *&, MxS16)
[AI] Reads and deserializes a DS object of the specific type from an SI buffer.
MxStreamer * Streamer()
[AI] Returns the global streamer used for all chunked media streaming (SI file, audio,...
#define FOURCC(a, b, c, d)
[AI] Macro to compose a 32-bit code from four 8-bit characters (e.g., for resource and chunk IDs).