Mercurial > hg > dmlib
annotate src/dmengine.h @ 1263:4e9deb14e67f
Fix audio sync with nosound.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 22 May 2015 20:41:53 +0300 |
parents | 782516a8e3dd |
children | 6732a5ca1fae |
rev | line source |
---|---|
642
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
1 /* |
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
2 * dmlib |
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
3 * -- Demo engine / editor common code and definitions |
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
4 * Programmed and designed by Matti 'ccr' Hamalainen |
863 | 5 * (C) Copyright 2012-2015 Tecnic Software productions (TNSP) |
642
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
6 */ |
372 | 7 #ifndef DMENGINE_H |
8 #define DMENGINE_H | |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 #include "dmlib.h" |
310
713c8018c3ce
Fix includes in the dmsimple engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
11 #include <SDL_events.h> |
713c8018c3ce
Fix includes in the dmsimple engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
288
diff
changeset
|
12 #include <SDL_audio.h> |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 #include "dmres.h" |
368 | 14 #include "dmvecmat.h" |
977
4a6dece98cb2
Include dmcurves.h in dmengine.h.
Matti Hamalainen <ccr@tnsp.org>
parents:
884
diff
changeset
|
15 #include "dmcurves.h" |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 |
105
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
17 #ifdef DM_USE_JSS |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 #include "jss.h" |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 #include "jssmod.h" |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 #include "jssmix.h" |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 #include "jssplr.h" |
105
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
22 #endif |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 |
317 | 25 #ifdef __cplusplus |
26 extern "C" { | |
27 #endif | |
28 | |
1153 | 29 // Video setup window size |
620 | 30 #define DM_VSETUP_WIDTH 640 |
31 #define DM_VSETUP_HEIGHT 480 | |
593 | 32 |
597
8a9361179a1a
More work on the video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents:
593
diff
changeset
|
33 |
593 | 34 // Video setup type |
641
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
35 enum |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
36 { |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
37 DM_VSETUP_NONE = 0x00, // No video setup, just set window/screen to what demo specifies |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
38 DM_VSETUP_ASPECT = 0x01, // Only modes that match the optVidAspect aspect ratio are ok |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
39 DM_VSETUP_ANY = 0x02, // Any available mode is okay, the code can adapt |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
40 }; |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
41 |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
42 // Audio setup type |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
43 enum |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
44 { |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
45 DM_ASETUP_NONE = 0, |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
46 DM_ASETUP_JSS = 1, |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
47 DM_ASETUP_TREMOR = 2, |
c3852e49a610
Change how audio configuration works.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
48 }; |
593 | 49 |
50 | |
317 | 51 |
368 | 52 #define DT_MAGIC_ID "SDMETLNE" |
53 #define DT_MAX_EFFECT_PARAMS 16 | |
54 #define DT_MAX_NAME_LENGTH 32 | |
55 #define DT_FLOAT_STORE_SIZE 16 | |
56 | |
57 | |
58 enum | |
59 { | |
60 EFIT_SET, // No interpolation, just "set" the value | |
61 EFIT_LINEAR, // Linear interpolation | |
62 EFIT_SMOOTH, // Smoothstep interpolation | |
63 }; | |
64 | |
65 enum | |
66 { | |
67 EFPT_INT, | |
68 EFPT_FLOAT, | |
69 EFPT_STRING, | |
70 EFPT_VECTOR, | |
71 EFPT_MATRIX, | |
72 }; | |
73 | |
74 | |
75 typedef struct | |
76 { | |
77 int type; // Interpolation type (EFIT_*) between this and next point | |
78 int time; // Offsets to event start, -1 == attach to event start, -2 = event end (if event) | |
79 | |
80 int vint; | |
81 DMFloat vfloat; | |
82 DMVector vector; | |
83 DMMatrix matrix; | |
84 } DMTimelinePoint; | |
85 | |
86 | |
87 typedef struct | |
88 { | |
89 int npoints, nallocated; | |
90 DMTimelinePoint *points; | |
91 } DMTimelinePoints; | |
92 | |
93 | |
94 typedef struct | |
95 { | |
96 char *name; // Name / description of the parameter | |
97 int type; // Type (EFPT_*) | |
98 | |
99 DMTimelinePoints pts; | |
100 char *vstr; | |
101 | |
102 // Current values (interpolated) | |
103 int vint; | |
104 DMFloat vfloat; | |
105 DMVector vvector; | |
106 DMMatrix vmatrix; | |
107 } DMTimelineEventParam; | |
108 | |
109 | |
110 typedef struct | |
111 { | |
112 char name[DT_MAX_NAME_LENGTH]; | |
113 Uint32 type; | |
114 } DMFTimelineEventParam; | |
115 | |
116 | |
117 struct DMEngineData; | |
118 | |
119 | |
849 | 120 typedef struct _DMEffect |
368 | 121 { |
122 char * name; | |
123 int type; | |
849 | 124 |
125 int (*init)(struct DMEngineData *, const struct _DMEffect *eff, void **data); | |
126 void (*shutdown)(struct DMEngineData *, const struct _DMEffect *eff, void *data); | |
884
18cd96a27dee
API changes to be used in future.
Matti Hamalainen <ccr@tnsp.org>
parents:
868
diff
changeset
|
127 int (*render)(struct DMEngineData *, const struct _DMEffect *eff, void *data, const DMTimelineEventParam *params, const int time); |
368 | 128 |
129 int nparams; | |
130 DMTimelineEventParam params[DT_MAX_EFFECT_PARAMS]; | |
131 } DMEffect; | |
132 | |
133 | |
573
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
134 #ifdef DM_USE_TIMELINE |
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
135 |
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
136 |
368 | 137 typedef struct |
138 { | |
139 Uint32 start, duration; | |
140 char effectName[DT_MAX_NAME_LENGTH]; | |
141 Uint32 nparams; | |
142 } DMFTimelineEvent; | |
143 | |
144 | |
145 typedef struct | |
146 { | |
147 int start, duration; | |
148 DMEffect *effect; | |
149 int nparams; | |
150 DMTimelineEventParam *params; | |
151 } DMTimelineEvent; | |
152 | |
153 | |
154 typedef struct | |
155 { | |
156 BOOL enabled; | |
157 DMTimelinePoints points; | |
158 } DMTimelineCurve; | |
159 | |
160 | |
161 typedef struct | |
162 { | |
638
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
636
diff
changeset
|
163 Uint32 index, layer; |
368 | 164 char name[DT_MAX_NAME_LENGTH]; |
165 Uint8 enabled; | |
166 Uint32 nevents; | |
167 } DMFTimelineTrack; | |
168 | |
169 | |
170 typedef struct | |
171 { | |
638
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
636
diff
changeset
|
172 int index; // Track index |
1153 | 173 int layer; // Render order / layer |
368 | 174 char *name; // Name of the timeline track |
175 BOOL enabled; // Enabled? | |
176 | |
177 int nevents, nallocated; // Number of events | |
178 DMTimelineEvent **events; // Events | |
179 | |
180 DMTimelineCurve composite; // Composite curve (transparency of the "layer") | |
181 } DMTimelineTrack; | |
182 | |
183 | |
184 typedef struct | |
185 { | |
186 char magic[8]; | |
187 char name[DT_MAX_NAME_LENGTH]; | |
188 Uint32 ntracks; | |
189 Uint32 duration; | |
190 } DMFTimeline; | |
191 | |
192 | |
193 typedef struct | |
194 { | |
195 char *name; | |
196 int ntracks, nallocated, duration; | |
197 DMTimelineTrack **tracks; | |
198 } DMTimeline; | |
199 | |
200 | |
201 typedef struct | |
202 { | |
203 DMTimelineTrack *track; | |
204 DMTimelineEvent *event; | |
205 } DMPreparedEvent; | |
206 | |
207 | |
208 typedef struct _DMPreparedEventGroup | |
209 { | |
210 int start, end, nevents, nallocated; | |
211 DMPreparedEvent *events; | |
212 | |
213 struct _DMPreparedEventGroup *next, *prev; | |
214 } DMPreparedEventGroup; | |
215 | |
216 | |
217 typedef struct | |
218 { | |
219 int duration, ngroups, pos; | |
220 DMPreparedEventGroup **groups; | |
221 } DMPreparedTimeline; | |
222 | |
573
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
223 #endif |
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
224 |
368 | 225 |
367 | 226 typedef struct DMEngineData |
359
59045853853d
Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
227 { |
59045853853d
Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
228 DMResourceLib *resources; |
368 | 229 void **effectData; |
359
59045853853d
Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
230 |
573
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
231 #ifdef DM_USE_TIMELINE |
354 | 232 DMResource *timeline; |
345
cac13f180169
Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents:
342
diff
changeset
|
233 DMTimeline *tl; |
cac13f180169
Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents:
342
diff
changeset
|
234 DMPreparedTimeline *ptl; |
573
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
235 #endif |
345
cac13f180169
Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents:
342
diff
changeset
|
236 |
361 | 237 int frameTime, frameCount, |
238 startTime, endTime, | |
868
2c6b092328be
Possibly improve audio synchronization.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
239 startTimeAudio, offsetTime, |
390
a7ee3567f718
Remove adjustTime variable, it is not needed anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
240 pauseTime; |
93
15fdd5573344
Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
241 |
15fdd5573344
Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
242 BOOL pauseFlag, paused, exitFlag; |
361 | 243 |
1153 | 244 // Rendering |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 SDL_Surface *screen; |
1153 | 246 |
247 // Events | |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 SDL_Event event; |
578
cf5d44b36851
Add some initial code for video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents:
573
diff
changeset
|
249 |
1153 | 250 // Setup information |
593 | 251 int optVidWidth, optVidHeight, |
252 optVidDepth, optVFlags, | |
253 optVidAspect, optVidSetup; | |
753
8dd6d512cbb2
Add variable for detecting if we are in "native" video resolution.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
254 BOOL optVidNative; |
578
cf5d44b36851
Add some initial code for video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents:
573
diff
changeset
|
255 |
cf5d44b36851
Add some initial code for video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents:
573
diff
changeset
|
256 int optResFlags; |
105
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
257 char *optDataPath, *optPackFilename; |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 |
783 | 259 // Audio related |
754 | 260 SDL_AudioSpec optAfmt; |
261 int optAudioSetup; | |
755
614df17de975
Add mutex locking to audio stream stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
754
diff
changeset
|
262 |
785 | 263 int audioStatus; // Current status of audio output (SDL_AUDIO_PLAYING, etc.) |
755
614df17de975
Add mutex locking to audio stream stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
754
diff
changeset
|
264 DMMutex *audioStreamMutex; |
754 | 265 Uint8 * audioStreamBuf; |
785 | 266 size_t audioStreamLen; // Length in samples |
791
7ea8775b265a
Move audio callback code to dmengine.
Matti Hamalainen <ccr@tnsp.org>
parents:
786
diff
changeset
|
267 Uint32 audioTimePos; // Approximate audio time (in milliseconds) |
786
bc95f8a6d89c
Add audio sample size information into the engine structure.
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
268 int audioSampleSize; // Size of one audio sample in bytes (incl. all channels) |
754 | 269 |
781
e15e0469499a
Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
270 // No-sound audio simulation thread stuff |
e15e0469499a
Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
271 SDL_Thread *audioSimThread; |
e15e0469499a
Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
272 Uint8 * audioSimBuf; |
e15e0469499a
Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
273 size_t audioSimBufSize; |
782
2f32e178854a
Fix the audio simulation code to actually compile.
Matti Hamalainen <ccr@tnsp.org>
parents:
781
diff
changeset
|
274 BOOL audioSimDone; |
2f32e178854a
Fix the audio simulation code to actually compile.
Matti Hamalainen <ccr@tnsp.org>
parents:
781
diff
changeset
|
275 int audioSimDelay; |
781
e15e0469499a
Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents:
756
diff
changeset
|
276 |
105
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
277 #ifdef DM_USE_JSS |
754 | 278 JSSMixer *jssDev; |
279 JSSPlayer *jssPlr; | |
280 int jssFormat; | |
105
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
281 #endif |
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
282 |
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
283 #ifdef DM_USE_TREMOR |
359
59045853853d
Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
284 DMResource *audioRes; |
113 | 285 size_t audioPos; |
105
d5d27f262227
Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
286 #endif |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
287 |
366
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
288 int (*demoInit)(struct DMEngineData *); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
289 int (*demoInitPreVideo)(struct DMEngineData *); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
290 int (*demoInitPostVideo)(struct DMEngineData *); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
291 int (*demoRender)(struct DMEngineData *); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
292 void (*demoShutdown)(struct DMEngineData *); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
293 void (*demoQuit)(struct DMEngineData *); |
127
ab4086db7dad
Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
294 |
622 | 295 // Setup specifics |
848
30f9af5e80f2
Add setup data options for menu bar position/size adjustments.
Matti Hamalainen <ccr@tnsp.org>
parents:
847
diff
changeset
|
296 DMVector setupMenuPos, setupMenuDim, setupText1Pos, setupText2Pos, |
30f9af5e80f2
Add setup data options for menu bar position/size adjustments.
Matti Hamalainen <ccr@tnsp.org>
parents:
847
diff
changeset
|
297 setupMenuBarOffs, setupMenuBarDimAdj; |
635
7092cd50bc08
Add condensed text configuration option to setup screen config.
Matti Hamalainen <ccr@tnsp.org>
parents:
623
diff
changeset
|
298 BOOL setupMenuCenter, setupTextCondensed; |
847
cf142447dd63
Add "enter to start" text for the setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents:
846
diff
changeset
|
299 char setupTextFullscreen[64], setupTextWindowed[64], setupTextPrefix[64], setupTextEnterToStart[64]; |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
300 } DMEngineData; |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
301 |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
302 |
382
371edff7dc3d
Fix extern variables to match what are actually declared in dmengine.c
Matti Hamalainen <ccr@tnsp.org>
parents:
375
diff
changeset
|
303 extern DMEffect *engineEffects; |
371edff7dc3d
Fix extern variables to match what are actually declared in dmengine.c
Matti Hamalainen <ccr@tnsp.org>
parents:
375
diff
changeset
|
304 extern int nengineEffects, nengineEffectsAlloc; |
368 | 305 |
306 | |
307 // Effect registration | |
308 int engineRegisterEffect(const DMEffect *ef); | |
371
56bd2693472f
Oops, the function prototypes were incorrect.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
309 int engineInitializeEffects(DMEngineData *); |
56bd2693472f
Oops, the function prototypes were incorrect.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
310 void engineShutdownEffects(DMEngineData *); |
368 | 311 DMEffect *engineFindEffect(const char *name, const int nparams); |
312 DMEffect *engineFindEffectByName(const char *name); | |
313 | |
314 | |
573
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
315 #ifdef DM_USE_TIMELINE |
368 | 316 // Basic timeline handling |
317 int dmLoadTimeline(DMResource *res, DMTimeline **tl); | |
318 void dmFreeTimeline(DMTimeline *tl); | |
319 | |
320 void dmFreeTimelinePoints(DMTimelinePoints *points); | |
321 void dmFreeTimelineEventParam(DMTimelineEventParam *param); | |
322 void dmFreeTimelineEvent(DMTimelineEvent *event); | |
323 void dmFreeTimelineTrack(DMTimelineTrack *track); | |
324 | |
325 | |
326 // Execution related | |
327 int dmPrepareTimeline(DMTimeline *tl, DMPreparedTimeline *ptl); | |
328 void dmFreePreparedTimelineData(DMPreparedTimeline *ptl); | |
329 | |
330 int dmSeekTimeline(DMPreparedTimeline *tl, int time); | |
884
18cd96a27dee
API changes to be used in future.
Matti Hamalainen <ccr@tnsp.org>
parents:
868
diff
changeset
|
331 int dmExecuteTimeline(DMPreparedTimeline *tl, DMEngineData *engine, int time); |
368 | 332 |
333 | |
334 // Editing/saving related functions | |
395
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
335 int dmCopyTimelinePoints(const DMTimelinePoints *src, DMTimelinePoints *dst); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
336 int dmCopyTimelineEventParam(const DMTimelineEventParam *src, DMTimelineEventParam *dst); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
337 int dmCopyTimelineEvent(const DMTimelineEvent *src, DMTimelineEvent **pdst); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
338 int dmCopyTimelineCurve(const DMTimelineCurve *src, DMTimelineCurve *dst); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
339 int dmCopyTimelineTrack(const DMTimelineTrack *src, DMTimelineTrack **pdst); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
340 int dmCopyTimeline(const DMTimeline *src, DMTimeline **pdst); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
341 |
368 | 342 int dmSaveTimeline(DMResource *res, DMTimeline *tl); |
343 | |
344 int dmTimelineNew(DMTimeline **tl, const char *name); | |
345 int dmTimelineAddTrack(DMTimeline *tl, DMTimelineTrack **track, const char *name); | |
346 int dmTimelineTrackAddEvent(DMTimelineTrack *track, int start, int duration, DMTimelineEvent **pev); | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
347 int dmTimelineEventSetEffect(DMTimelineEvent *event, DMEffect *ef); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
348 int dmTimelineEventSetEffectByIndex(DMTimelineEvent *event, const int index); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
349 int dmTimelineEventSetEffectByName(DMTimelineEvent *event, const char *name); |
368 | 350 |
573
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
351 #endif // DM_USE_TIMELINE |
14640d0688d3
Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
352 |
368 | 353 |
354 // Resource helpers | |
366
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
355 #define engineGetResImage(eng, x, name) \ |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
356 do { \ |
366
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
357 if ((x = (SDL_Surface *) engineGetResource(eng, name)) == NULL) \ |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
358 return DMERR_INIT_FAIL; \ |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
359 } while (0) |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
360 |
366
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
361 #define engineGetResModule(eng, x, name) \ |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
362 do { \ |
366
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
363 if ((x = (JSSModule *) engineGetResource(eng, name)) == NULL) \ |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
364 return DMERR_INIT_FAIL; \ |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 } while (0) |
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
642
diff
changeset
|
367 #define engineFindResource(eng, name) dmResourceFind((eng)->resources, name) |
367 | 368 |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 |
342
c6ec970dc3cf
Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents:
335
diff
changeset
|
370 int engineClassifier(DMResource *res); |
366
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
371 void * engineGetResource(DMEngineData *eng, const char *name); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
372 int engineGetTime(DMEngineData *eng, int t); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
373 int engineGetTimeDTi(DMEngineData *eng); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
374 int engineGetTick(DMEngineData *eng); |
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
375 float engineGetTimeDT(DMEngineData *eng); |
368 | 376 |
846 | 377 int engineInitAudioParts(DMEngineData *engine); |
791
7ea8775b265a
Move audio callback code to dmengine.
Matti Hamalainen <ccr@tnsp.org>
parents:
786
diff
changeset
|
378 void engineAudioCallback(void *userdata, Uint8 *stream, int len); |
1263
4e9deb14e67f
Fix audio sync with nosound.
Matti Hamalainen <ccr@tnsp.org>
parents:
1153
diff
changeset
|
379 void enginePauseAudio(DMEngineData *engine, int status); |
593 | 380 int engineGetVideoAspect(int width, int height); |
381 | |
382 | |
368 | 383 // Implemented in actual demo code |
366
38e10b5f4e09
Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents:
361
diff
changeset
|
384 int demoPreInit(DMEngineData *eng); |
32
d1a6833a5d67
Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
385 |
317 | 386 |
387 #ifdef __cplusplus | |
388 } | |
389 #endif | |
390 | |
372 | 391 #endif // DMENGINE_H |