Isle
Loading...
Searching...
No Matches
mxstillpresenter.cpp
Go to the documentation of this file.
1#include "mxstillpresenter.h"
2
3#include "decomp.h"
4#include "define.h"
6#include "mxdisplaysurface.h"
7#include "mxdsmediaaction.h"
8#include "mxdssubscriber.h"
9#include "mxmisc.h"
10#include "mxomni.h"
11#include "mxpalette.h"
12#include "mxutilities.h"
13#include "mxvideomanager.h"
14
16
17// FUNCTION: LEGO1 0x100b9c70
18void MxStillPresenter::Destroy(MxBool p_fromDestructor)
19{
21
22 if (m_bitmapInfo) {
23 delete m_bitmapInfo;
24 }
25 m_bitmapInfo = NULL;
26
28
29 if (!p_fromDestructor) {
31 }
32}
33
34// FUNCTION: LEGO1 0x100b9cc0
36{
37 if (m_bitmapInfo) {
38 delete m_bitmapInfo;
39 }
40
41 MxU8* data = new MxU8[p_chunk->GetLength()];
42 m_bitmapInfo = (MxBITMAPINFO*) data;
43 memcpy(m_bitmapInfo, p_chunk->GetData(), p_chunk->GetLength());
44}
45
46// FUNCTION: LEGO1 0x100b9d10
48{
49 if (m_frameBitmap) {
50 delete m_frameBitmap;
51 }
52
54 m_frameBitmap->ImportBitmapInfo(m_bitmapInfo);
55
56 delete m_bitmapInfo;
57 m_bitmapInfo = NULL;
58}
59
60// FUNCTION: LEGO1 0x100b9db0
62{
63 MxStreamChunk* chunk = NextChunk();
64 LoadFrame(chunk);
66}
67
68// FUNCTION: LEGO1 0x100b9dd0
70{
71 memcpy(m_frameBitmap->GetImage(), p_chunk->GetData(), p_chunk->GetLength());
72
73 // MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
74 MxS32 height = GetHeight() - 1;
75 MxS32 width = GetWidth() - 1;
76 MxS32 x = m_location.GetX();
77 MxS32 y = m_location.GetY();
78
79 MxRect32 rect(x, y, width + x, height + y);
81
82 if (GetBit1()) {
83 undefined4 und = 0;
86 &und,
87 GetBit3(),
89 );
90
91 delete m_alpha;
93
94 delete m_frameBitmap;
96
97 if (m_unk0x58 && und) {
99 }
100 else {
101 SetBit2(FALSE);
102 }
103 }
104}
105
106// FUNCTION: LEGO1 0x100b9f30
108{
110 MVideoManager()->RealizePalette(palette);
111 delete palette;
112}
113
114// FUNCTION: LEGO1 0x100b9f60
116{
118
119 if (m_currentTickleState == e_streaming && ((MxDSMediaAction*) m_action)->GetPaletteManagement()) {
121 }
122}
123
124// FUNCTION: LEGO1 0x100b9f90
126{
127 MxStreamChunk* chunk = CurrentChunk();
128
129 if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
130 m_chunkTime = chunk->GetTime();
131 NextFrame();
133
134 if (m_action->GetDuration() == -1 && m_compositePresenter) {
136 }
137 }
138}
139
140// FUNCTION: LEGO1 0x100b9ff0
142{
143 if (m_action->GetDuration() != -1) {
146 }
147 }
148}
149
150// FUNCTION: LEGO1 0x100ba040
151// FUNCTION: BETA10 0x10142724
153{
154 MxPoint32 oldLocation(m_location);
155 m_location.SetX(p_x);
156 m_location.SetY(p_y);
157
158 if (IsEnabled()) {
159 MxRect32 area(0, 0, GetWidth() - 1, GetHeight() - 1);
160
161 MxRect32 rectA(area);
162 rectA += oldLocation;
163
164 MxRect32 rectB(area);
165 rectB += m_location;
166
168 MVideoManager()->UpdateView(rectA.GetLeft(), rectA.GetTop(), rectA.GetWidth(), rectA.GetHeight());
169
171 MVideoManager()->UpdateView(rectB.GetLeft(), rectB.GetTop(), rectB.GetWidth(), rectB.GetHeight());
172 }
173}
174
175// FUNCTION: LEGO1 0x100ba140
177{
178 MxPresenter::Enable(p_enable);
179
180 if (MVideoManager() && (m_alpha || m_frameBitmap)) {
181 // MxRect32 rect(m_location, MxSize32(GetWidth(), GetHeight()));
182 MxS32 height = GetHeight();
183 MxS32 width = GetWidth();
184 MxS32 x = m_location.GetX();
185 MxS32 y = m_location.GetY();
186
187 MxRect32 rect(x, y, width + x, height + y);
189 MVideoManager()->UpdateView(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
190 }
191}
192
193// FUNCTION: LEGO1 0x100ba1e0
195{
197
199 SetBit3(TRUE);
200 }
201
202 MxU16 extraLength;
203 char* extraData;
204 m_action->GetExtra(extraLength, extraData);
205
206 if (extraLength) {
207 char extraCopy[512];
208 memcpy(extraCopy, extraData, extraLength);
209 extraCopy[extraLength] = '\0';
210
211 char output[512];
212 if (KeyValueStringParse(output, g_strVISIBILITY, extraCopy)) {
213 if (strcmpi(output, "FALSE") == 0) {
214 Enable(FALSE);
215 }
216 }
217
218 if (KeyValueStringParse(output, g_strBMP_ISMAP, extraCopy)) {
219 SetBit4(TRUE);
220 SetBit1(FALSE);
221 SetBit2(FALSE);
222 }
223 }
224}
225
226// FUNCTION: LEGO1 0x100ba2c0
228{
229 MxResult result = FAILURE;
230 MxStillPresenter* presenter = new MxStillPresenter;
231
232 if (presenter) {
233 if (presenter->AddToManager() == SUCCESS) {
234 MxDSAction* action = GetAction()->Clone();
235
236 if (action && presenter->StartAction(NULL, action) == SUCCESS) {
237 presenter->SetBit0(GetBit0());
238 presenter->SetBit1(GetBit1());
239 presenter->SetBit2(GetBit2());
240 presenter->SetBit3(GetBit3());
241 presenter->SetBit4(GetBit4());
242
243 if (m_frameBitmap) {
244 presenter->m_frameBitmap = new MxBitmap;
245
246 if (!presenter->m_frameBitmap || presenter->m_frameBitmap->ImportBitmap(m_frameBitmap) != SUCCESS) {
247 goto done;
248 }
249 }
250
251 if (m_unk0x58) {
253 }
254
255 if (m_alpha) {
257 }
258
259 result = SUCCESS;
260 }
261 }
262 }
263
264done:
265 if (result != SUCCESS) {
266 delete presenter;
267 presenter = NULL;
268 }
269
270 return presenter;
271}
[AI] Represents an 8bpp or high color device-independent bitmap (DIB) and provides operations for bit...
Definition: mxbitmap.h:55
virtual MxPalette * CreatePalette()
[AI] Allocates or clones the current palette for the bitmap.
Definition: mxbitmap.cpp:352
virtual MxResult ImportBitmap(MxBitmap *p_bitmap)
[AI] Imports the contents of another bitmap into this bitmap, allocating new storage and copying meta...
Definition: mxbitmap.cpp:136
virtual MxResult ImportBitmapInfo(MxBITMAPINFO *p_info)
[AI] Imports bitmap header/palette info (but not pixel data) from the given info block.
Definition: mxbitmap.cpp:98
MxU8 * GetImage() const
[AI] Retrieves the pointer to the image pixel data.
Definition: mxbitmap.h:248
virtual void VTable0x60(MxPresenter *p_presenter)
[AI] Advance sequencing for serial multi-actions: promotes the next presenter in sequence to e_ready ...
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.
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
MxU32 GetFlags()
[AI] Returns the flag field for this action (bitmask).
Definition: mxdsaction.h:177
MxLong GetStartTime() const
[AI] Gets the nominal start time for the action, as loaded or scheduled.
Definition: mxdsaction.h:198
void GetExtra(MxU16 &p_extraLength, char *&p_extraData)
[AI] Retrieves the extra data and its length for this action.
Definition: mxdsaction.h:168
virtual MxLong GetDuration()
[AI] Gets the duration for which this action is intended to run.
Definition: mxdsaction.cpp:39
virtual MxLong GetElapsedTime()
[AI] Gets elapsed time for this action since the last time field 0x90 was set.
Definition: mxdsaction.cpp:159
virtual MxDSAction * Clone()
[AI] Clones (deep-copies) this action and returns a new pointer.
Definition: mxdsaction.cpp:146
@ c_bit5
[AI] Unknown - possibly reserved [AI]
Definition: mxdsaction.h:24
@ c_bit4
[AI] Unknown - possibly reserved [AI]
Definition: mxdsaction.h:23
MxU32 GetLength()
[AI] Returns the length in bytes of the data payload. [AI]
Definition: mxdschunk.h:105
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
MxDSMediaAction extends MxDSAction to add media-specific playback properties and management.
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src)
[AI] Creates a deep copy of the provided surface (new DirectDraw surface with same content).
virtual LPDIRECTDRAWSURFACE VTable0x44(MxBitmap *p_bitmap, undefined4 *p_ret, undefined4 p_doNotWriteToSurface, undefined4 p_transparent)
[AI] Allocates a DirectDraw surface for a bitmap to allow hardware blitting/transparency.
MxStreamChunk * CurrentChunk()
[AI] Returns a pointer to the current data chunk at the head of the stream, without consuming it.
MxStreamChunk * NextChunk()
[AI] Returns the next data chunk in the stream, removing it from the stream queue.
MxDSSubscriber * m_subscriber
[AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter.
MxResult StartAction(MxStreamController *, MxDSAction *) override
[AI] Begins a new media playback action, wiring up the stream and chunk lists as needed.
MxVideoManager * GetVideoManager() const
[AI] Returns the video media manager (for handling FLC/SMK/etc.), if present.
Definition: mxomni.h:234
static MxOmni * GetInstance()
[AI] Returns the singleton instance of the MxOmni subsystem coordinator.
Definition: mxomni.cpp:289
[AI] Encapsulates a DirectDraw 8-bit (256 color) palette for use with DirectX rendering.
Definition: mxpalette.h:17
[AI] 2D point with 32-bit signed integer coordinates.
Definition: mxgeometry.h:487
void SetY(T p_y)
[AI] Set Y coordinate.
Definition: mxgeometry.h:65
T GetY() const
[AI] Get Y coordinate.
Definition: mxgeometry.h:53
void SetX(T p_x)
[AI] Set X coordinate.
Definition: mxgeometry.h:59
T GetX() const
[AI] Get X coordinate.
Definition: mxgeometry.h:48
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
virtual void Enable(MxBool p_enable)
[AI] Enables or disables this presenter (controls action flags accordingly).
MxBool IsEnabled()
[AI] Returns whether this presenter is logically enabled (based on the associated action's flags).
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
Definition: mxpresenter.h:199
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
Definition: mxpresenter.h:28
@ e_freezing
[AI] Temporarily suspending updates or playback.
Definition: mxpresenter.h:29
@ e_streaming
[AI] Streaming or rendering actively.
Definition: mxpresenter.h:27
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
MxCompositePresenter * m_compositePresenter
[AI] Owner composite presenter, if any.
Definition: mxpresenter.h:217
MxPoint32 m_location
[AI] 2D display location for the presenter.
Definition: mxpresenter.h:205
MxDSAction * GetAction() const
[AI] Returns the current action being presented.
Definition: mxpresenter.h:175
[AI] Rectangle using 32-bit signed integer coordinates.
Definition: mxgeometry.h:706
T GetTop() const
[AI] Get the top edge.
Definition: mxgeometry.h:231
T GetWidth() const
[AI] Get the rectangle's width.
Definition: mxgeometry.h:262
T GetHeight() const
[AI] Get the rectangle's height.
Definition: mxgeometry.h:268
T GetLeft() const
[AI] Get the left edge.
Definition: mxgeometry.h:221
[AI] Presenter for single still image/bitmap media sources in the game.
void CreateBitmap() override
[AI] Allocates and constructs the bitmap from internal bitmap info, importing palette and image layou...
void ParseExtra() override
[AI] Parses extra action data for bitmap configuration, such as visibility or image mapping,...
void LoadFrame(MxStreamChunk *p_chunk) override
[AI] Copies frame image data from chunk to presenter's bitmap and prepares for rendering,...
void LoadHeader(MxStreamChunk *p_chunk) override
[AI] Loads header chunk data into the presenter's bitmap info buffer (BITMAPINFO structure).
void StartingTickle() override
[AI] Handles transition to the starting state of the presenter, processing palette realization if nee...
void RepeatingTickle() override
[AI] Repetition tickle logic—handles repeated action/time-based state changes.
virtual MxStillPresenter * Clone()
[AI] Clones the presenter, attempting to fully duplicate internal state and associated memory resourc...
MxStillPresenter()
[AI] Constructs an MxStillPresenter.
void Destroy() override
[AI] Destroys the presenter's resources, optionally called by the destructor for complete cleanup.
void RealizePalette() override
[AI] Realizes/updates the palette in the current video environment using the frame bitmap and notifie...
virtual void SetPosition(MxS32 p_x, MxS32 p_y)
[AI] Sets the pixel-based position of the presented image.
void StreamingTickle() override
[AI] Main frame advancing logic, loads the next frame if the elapsed time is appropriate.
void Enable(MxBool p_enable) override
[AI] Sets the enabled/disabled state of the presenter, updating the video manager's rendering as need...
void NextFrame() override
[AI] Loads the next single image frame from the stream and updates the presenter's display state.
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
Definition: mxstreamchunk.h:19
virtual MxResult RealizePalette(MxPalette *p_palette)
[AI] Applies (realizes) the palette to both MxVideoParam and hardware palette, and updates the displa...
virtual void UpdateView(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height)
[AI] Updates the visible video sub-rectangle inside the overall frame; typically for sub-region blits...
void InvalidateRect(MxRect32 &p_rect)
[AI] Invalidates a rectangular region in the display; marks it for redraw on next tick.
MxDisplaySurface * GetDisplaySurface()
[AI] Returns the display surface used for video output; for direct drawing and palette operations.
Opaque mask used for efficient hit testing against video transparency.
BYTE GetBit0()
Gets internal miscellaneous state flags (bits 0-4).
void StartingTickle() override
Advance logic for the "starting" tickle state (frame setup).
void SetBit2(BOOL p_e)
MxBitmap * m_frameBitmap
Bitmap for current video frame. [AI].
virtual MxS32 GetHeight()
Returns the height of the current bitmap or alpha mask in pixels.
virtual MxS32 GetWidth()
Returns the width of the current bitmap or alpha mask in pixels.
void SetBit3(BOOL p_e)
void SetBit0(BOOL p_e)
Sets internal miscellaneous state flags.
LPDIRECTDRAWSURFACE m_unk0x58
DirectDraw surface for hardware video rendering. [AI].
void SetBit1(BOOL p_e)
AlphaMask * m_alpha
Alpha mask for hit testing. May be null. [AI].
MxResult AddToManager() override
Adds this presenter to the global video manager.
void Destroy() override
Destroys internal resources for the presenter.
void SetBit4(BOOL p_e)
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
unsigned int undefined4
Definition: decomp.h:28
const char * g_strBMP_ISMAP
[AI] Denotes a BMP resource that acts as a map; used for interpreting image assets as collision/level...
Definition: define.cpp:137
const char * g_strVISIBILITY
[AI] Used when specifying visibility toggles or changes for objects/entities in scripting.
Definition: define.cpp:121
#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
MxVideoManager * MVideoManager()
[AI] Returns the video manager used for video/cutscene presenter management.
Definition: mxmisc.cpp:65
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned short MxU16
[AI]
Definition: mxtypes.h:20
MxBool KeyValueStringParse(char *, const char *, const char *)
Searches p_string for a key command and copies its associated value to p_output.
Definition: mxutilities.cpp:85
[AI] Represents a bitmap information header plus a 256-color palette, matching the layout for 8-bit D...
Definition: mxbitmap.h:25