Isle
Loading...
Searching...
No Matches
legopalettepresenter.cpp
Go to the documentation of this file.
2
3#include "legovideomanager.h"
4#include "misc.h"
5#include "misc/legostorage.h"
6#include "mxdsaction.h"
7#include "mxdssubscriber.h"
8#include "mxpalette.h"
9#include "mxstreamchunk.h"
10
12
13// FUNCTION: LEGO1 0x10079e50
15{
16 Init();
17}
18
19// FUNCTION: LEGO1 0x1007a070
21{
23}
24
25// FUNCTION: LEGO1 0x1007a0d0
26void LegoPalettePresenter::Init()
27{
28 m_palette = NULL;
29}
30
31// FUNCTION: LEGO1 0x1007a0e0
32void LegoPalettePresenter::Destroy(MxBool p_fromDestructor)
33{
35 if (m_palette) {
36 delete m_palette;
37 }
38 Init();
40 if (!p_fromDestructor) {
42 }
43}
44
45// FUNCTION: LEGO1 0x1007a120
47{
49}
50
51// FUNCTION: LEGO1 0x1007a130
53{
54 MxU8 buffer[40];
55 RGBQUAD palette[256];
56 MxResult result = FAILURE;
57
58 LegoMemory stream((char*) p_chunk->GetData());
59 if (stream.Read(buffer, sizeof(buffer)) == SUCCESS) {
60 if (stream.Read(palette, sizeof(palette)) == SUCCESS) {
61 m_palette = new MxPalette(palette);
62 if (m_palette) {
63 result = SUCCESS;
64 }
65 }
66 }
67
68 if (result != SUCCESS && m_palette) {
69 delete m_palette;
70 m_palette = NULL;
71 }
72
73 return result;
74}
75
76// FUNCTION: LEGO1 0x1007a230
78{
80 if (chunk) {
81 if (chunk->GetTime() <= m_action->GetElapsedTime()) {
82 ParseExtra();
84
85 chunk = m_subscriber->PopData();
86 MxResult result = ParsePalette(chunk);
88
89 if (result == SUCCESS) {
90 VideoManager()->RealizePalette(m_palette);
91 }
92 EndAction();
93 }
94 }
95}
Implementation of LegoStorage for memory-backed buffers.
Definition: legostorage.h:317
LegoResult Read(void *p_buffer, LegoU32 p_size) override
Reads bytes from memory buffer at current position.
Definition: legostorage.cpp:20
Class responsible for presenting and handling palettes for video sequences that require palette manag...
MxResult ParsePalette(MxStreamChunk *p_chunk)
Parses a palette from a chunk in the streaming media resource.
void ReadyTickle() override
Called by the tickle manager when presenter is in Ready state; handles next palette chunk if availabl...
void Destroy() override
Handles destruction and cleanup of palette presenter resources (public destroy invocation).
~LegoPalettePresenter() override
Cleans up and releases owned resources, including any loaded palette.
MxResult RealizePalette(MxPalette *) override
[AI] Sets the realized palette to use for rendering and updates the display surface.
void Enter()
[AI] Acquires/gains entry to the critical section or mutex, blocking if not available.
void Leave()
[AI] Releases/leaves the critical section or mutex.
virtual MxLong GetElapsedTime()
[AI] Gets elapsed time for this action since the last time field 0x90 was set.
Definition: mxdsaction.cpp:159
MxLong GetTime()
[AI] Returns the time (timestamp or tick) associated with this chunk. [AI]
Definition: mxdschunk.h:102
MxU8 * GetData()
[AI] Returns a pointer to the start of the data payload. [AI]
Definition: mxdschunk.h:108
MxStreamChunk * PopData()
[AI] Pops the next available pending data chunk for consumption, moving it to the consumed list.
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
MxStreamChunk * PeekData()
[AI] Returns but does not remove the first pending data chunk ("peek" operation).
MxDSSubscriber * m_subscriber
[AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter.
[AI] Encapsulates a DirectDraw 8-bit (256 color) palette for use with DirectX rendering.
Definition: mxpalette.h:17
virtual void ParseExtra()
[AI] Parses additional data from the associated action for configuration or world interaction.
Definition: mxpresenter.cpp:80
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
Definition: mxpresenter.h:72
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
@ e_starting
[AI] In the process of starting playback/presentation.
Definition: mxpresenter.h:26
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
Definition: mxstreamchunk.h:19
void EndAction() override
Signals the end of the current playback action.
void Destroy() override
Destroys internal resources for the presenter.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
Definition: misc.cpp:29
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
unsigned char MxU8
[AI]
Definition: mxtypes.h:8