annotate src/dmengine.h @ 2294:7f6ba3b32f54

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 03 Jul 2019 10:28:43 +0300
parents 78a0f44aa8b5
children 9807ae37ad69
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
27949209238b Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 849
diff changeset
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
29f0babc686f s/DMSIMPLE/DMENGINE/
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
7 #ifndef DMENGINE_H
29f0babc686f s/DMSIMPLE/DMENGINE/
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
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
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
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
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
25 #ifdef __cplusplus
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
26 extern "C" {
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
27 #endif
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
28
1153
782516a8e3dd Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 977
diff changeset
29 // Video setup window size
620
5fda51e99fe5 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 597
diff changeset
30 #define DM_VSETUP_WIDTH 640
5fda51e99fe5 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 597
diff changeset
31 #define DM_VSETUP_HEIGHT 480
593
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
32
597
8a9361179a1a More work on the video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents: 593
diff changeset
33
593
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
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
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
49
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
50
317
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
51
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
52 #define DT_MAGIC_ID "SDMETLNE"
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
53 #define DT_MAX_EFFECT_PARAMS 16
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
54 #define DT_MAX_NAME_LENGTH 32
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
55 #define DT_FLOAT_STORE_SIZE 16
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
56
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
57
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
58 enum
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
59 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
60 EFIT_SET, // No interpolation, just "set" the value
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
61 EFIT_LINEAR, // Linear interpolation
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
62 EFIT_SMOOTH, // Smoothstep interpolation
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
63 };
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
64
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
65 enum
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
66 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
67 EFPT_INT,
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
68 EFPT_FLOAT,
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
69 EFPT_STRING,
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
70 EFPT_VECTOR,
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
71 EFPT_MATRIX,
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
72 };
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
73
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
74
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
75 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
76 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
77 int type; // Interpolation type (EFIT_*) between this and next point
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
78 int time; // Offsets to event start, -1 == attach to event start, -2 = event end (if event)
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
79
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
80 int vint;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
81 DMFloat vfloat;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
82 DMVector vector;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
83 DMMatrix matrix;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
84 } DMTimelinePoint;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
85
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
86
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
87 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
88 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
89 int npoints, nallocated;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
90 DMTimelinePoint *points;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
91 } DMTimelinePoints;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
92
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
93
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
94 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
95 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
96 char *name; // Name / description of the parameter
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
97 int type; // Type (EFPT_*)
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
98
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
99 DMTimelinePoints pts;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
100 char *vstr;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
101
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
102 // Current values (interpolated)
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
103 int vint;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
104 DMFloat vfloat;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
105 DMVector vvector;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
106 DMMatrix vmatrix;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
107 } DMTimelineEventParam;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
108
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
109
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
110 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
111 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
112 char name[DT_MAX_NAME_LENGTH];
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
113 Uint32 type;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
114 } DMFTimelineEventParam;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
115
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
116
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
117 struct DMEngineData;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
118
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
119
849
00729394df6a Effects API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 848
diff changeset
120 typedef struct _DMEffect
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
121 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
122 char * name;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
123 int type;
849
00729394df6a Effects API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 848
diff changeset
124
1688
51ce7edd5054 Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
125 // init() - called at demo start/loading phase
849
00729394df6a Effects API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 848
diff changeset
126 int (*init)(struct DMEngineData *, const struct _DMEffect *eff, void **data);
1688
51ce7edd5054 Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
127
51ce7edd5054 Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
128 // shutdown() - called at demo shutdown
849
00729394df6a Effects API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 848
diff changeset
129 void (*shutdown)(struct DMEngineData *, const struct _DMEffect *eff, void *data);
1688
51ce7edd5054 Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
130
51ce7edd5054 Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
131 // called to render a frame
884
18cd96a27dee API changes to be used in future.
Matti Hamalainen <ccr@tnsp.org>
parents: 868
diff changeset
132 int (*render)(struct DMEngineData *, const struct _DMEffect *eff, void *data, const DMTimelineEventParam *params, const int time);
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
133
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
134 int nparams;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
135 DMTimelineEventParam params[DT_MAX_EFFECT_PARAMS];
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
136 } DMEffect;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
137
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
138
573
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
139 #ifdef DM_USE_TIMELINE
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
140
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
141
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
142 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
143 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
144 Uint32 start, duration;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
145 char effectName[DT_MAX_NAME_LENGTH];
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
146 Uint32 nparams;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
147 } DMFTimelineEvent;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
148
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
149
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
150 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
151 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
152 int start, duration;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
153 DMEffect *effect;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
154 int nparams;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
155 DMTimelineEventParam *params;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
156 } DMTimelineEvent;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
157
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
158
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
159 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
160 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
161 BOOL enabled;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
162 DMTimelinePoints points;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
163 } DMTimelineCurve;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
164
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
165
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
166 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
167 {
638
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 636
diff changeset
168 Uint32 index, layer;
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
169 char name[DT_MAX_NAME_LENGTH];
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
170 Uint8 enabled;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
171 Uint32 nevents;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
172 } DMFTimelineTrack;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
173
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
174
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
175 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
176 {
638
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 636
diff changeset
177 int index; // Track index
1153
782516a8e3dd Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 977
diff changeset
178 int layer; // Render order / layer
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
179 char *name; // Name of the timeline track
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
180 BOOL enabled; // Enabled?
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
181
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
182 int nevents, nallocated; // Number of events
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
183 DMTimelineEvent **events; // Events
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
184
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
185 DMTimelineCurve composite; // Composite curve (transparency of the "layer")
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
186 } DMTimelineTrack;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
187
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
188
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
189 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
190 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
191 char magic[8];
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
192 char name[DT_MAX_NAME_LENGTH];
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
193 Uint32 ntracks;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
194 Uint32 duration;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
195 } DMFTimeline;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
196
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
197
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
198 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
199 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
200 char *name;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
201 int ntracks, nallocated, duration;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
202 DMTimelineTrack **tracks;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
203 } DMTimeline;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
204
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
205
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
206 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
207 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
208 DMTimelineTrack *track;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
209 DMTimelineEvent *event;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
210 } DMPreparedEvent;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
211
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
212
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
213 typedef struct _DMPreparedEventGroup
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
214 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
215 int start, end, nevents, nallocated;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
216 DMPreparedEvent *events;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
217
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
218 struct _DMPreparedEventGroup *next, *prev;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
219 } DMPreparedEventGroup;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
220
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
221
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
222 typedef struct
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
223 {
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
224 int duration, ngroups, pos;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
225 DMPreparedEventGroup **groups;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
226 } DMPreparedTimeline;
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
227
573
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
228 #endif
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
229
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
230
367
9875c65029af Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
231 typedef struct DMEngineData
359
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
232 {
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
233 DMResourceLib *resources;
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
234 void **effectData;
359
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
235
573
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
236 #ifdef DM_USE_TIMELINE
354
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 345
diff changeset
237 DMResource *timeline;
345
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
238 DMTimeline *tl;
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
239 DMPreparedTimeline *ptl;
573
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
240 #endif
345
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
241
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
242 int frameTime, frameCount,
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
243 startTime, endTime,
868
2c6b092328be Possibly improve audio synchronization.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
244 startTimeAudio, offsetTime,
390
a7ee3567f718 Remove adjustTime variable, it is not needed anymore.
Matti Hamalainen <ccr@tnsp.org>
parents: 382
diff changeset
245 pauseTime;
93
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
246
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
247 BOOL pauseFlag, paused, exitFlag;
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
248
1153
782516a8e3dd Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 977
diff changeset
249 // Rendering
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1321
diff changeset
250 SDL_Window *window;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1321
diff changeset
251 SDL_Renderer *renderer;
2043
cbb3463fea2a Initial dabbling for SDL2 migration of the SW rendering / dmsimple.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
252
cbb3463fea2a Initial dabbling for SDL2 migration of the SW rendering / dmsimple.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
253 // Software rendering
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 SDL_Surface *screen;
2043
cbb3463fea2a Initial dabbling for SDL2 migration of the SW rendering / dmsimple.
Matti Hamalainen <ccr@tnsp.org>
parents: 2013
diff changeset
255 SDL_Texture *texture;
1153
782516a8e3dd Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 977
diff changeset
256
782516a8e3dd Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 977
diff changeset
257 // Events
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 SDL_Event event;
578
cf5d44b36851 Add some initial code for video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
259
1153
782516a8e3dd Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 977
diff changeset
260 // Setup information
593
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
261 int optVidWidth, optVidHeight,
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
262 optVidDepth, optVFlags,
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
263 optVidAspect, optVidSetup;
753
8dd6d512cbb2 Add variable for detecting if we are in "native" video resolution.
Matti Hamalainen <ccr@tnsp.org>
parents: 721
diff changeset
264 BOOL optVidNative;
578
cf5d44b36851 Add some initial code for video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
265
cf5d44b36851 Add some initial code for video setup screen.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
266 int optResFlags;
2106
78a0f44aa8b5 Clean out the resource path handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2043
diff changeset
267 char *optPackFilename;
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268
783
865f45701390 Fix audio support.
Matti Hamalainen <ccr@tnsp.org>
parents: 782
diff changeset
269 // Audio related
754
ce7acde37dc7 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 753
diff changeset
270 SDL_AudioSpec optAfmt;
ce7acde37dc7 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 753
diff changeset
271 int optAudioSetup;
755
614df17de975 Add mutex locking to audio stream stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 754
diff changeset
272
785
dbf5772690a8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 783
diff changeset
273 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
274 DMMutex *audioStreamMutex;
754
ce7acde37dc7 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 753
diff changeset
275 Uint8 * audioStreamBuf;
785
dbf5772690a8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 783
diff changeset
276 size_t audioStreamLen; // Length in samples
791
7ea8775b265a Move audio callback code to dmengine.
Matti Hamalainen <ccr@tnsp.org>
parents: 786
diff changeset
277 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
278 int audioSampleSize; // Size of one audio sample in bytes (incl. all channels)
754
ce7acde37dc7 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 753
diff changeset
279
781
e15e0469499a Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents: 756
diff changeset
280 // 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
281 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
282 Uint8 * audioSimBuf;
e15e0469499a Add initial code for simulating audio playback while in no-sound situation.
Matti Hamalainen <ccr@tnsp.org>
parents: 756
diff changeset
283 size_t audioSimBufSize;
782
2f32e178854a Fix the audio simulation code to actually compile.
Matti Hamalainen <ccr@tnsp.org>
parents: 781
diff changeset
284 BOOL audioSimDone;
2f32e178854a Fix the audio simulation code to actually compile.
Matti Hamalainen <ccr@tnsp.org>
parents: 781
diff changeset
285 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
286
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
287 #ifdef DM_USE_JSS
754
ce7acde37dc7 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 753
diff changeset
288 JSSMixer *jssDev;
ce7acde37dc7 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 753
diff changeset
289 JSSPlayer *jssPlr;
ce7acde37dc7 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 753
diff changeset
290 int jssFormat;
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
291 #endif
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
292
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
293 #ifdef DM_USE_TREMOR
359
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
294 DMResource *audioRes;
113
34ccf783ecca Fix some warnings.
Matti Hamalainen <ccr@tnsp.org>
parents: 110
diff changeset
295 size_t audioPos;
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
296 #endif
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
298 int (*demoInit)(struct DMEngineData *);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
299 int (*demoInitPreVideo)(struct DMEngineData *);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
300 int (*demoInitPostVideo)(struct DMEngineData *);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
301 int (*demoRender)(struct DMEngineData *);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
302 void (*demoShutdown)(struct DMEngineData *);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
303 void (*demoQuit)(struct DMEngineData *);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 } DMEngineData;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306
382
371edff7dc3d Fix extern variables to match what are actually declared in dmengine.c
Matti Hamalainen <ccr@tnsp.org>
parents: 375
diff changeset
307 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
308 extern int nengineEffects, nengineEffectsAlloc;
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
309
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
310
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
311 // Effect registration
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
312 int engineRegisterEffect(const DMEffect *ef);
371
56bd2693472f Oops, the function prototypes were incorrect.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
313 int engineInitializeEffects(DMEngineData *);
56bd2693472f Oops, the function prototypes were incorrect.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
314 void engineShutdownEffects(DMEngineData *);
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
315 DMEffect *engineFindEffect(const char *name, const int nparams);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
316 DMEffect *engineFindEffectByName(const char *name);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
317
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
318
573
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
319 #ifdef DM_USE_TIMELINE
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
320 // Basic timeline handling
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
321 int dmLoadTimeline(DMResource *res, DMTimeline **tl);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
322 void dmFreeTimeline(DMTimeline *tl);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
323
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
324 void dmFreeTimelinePoints(DMTimelinePoints *points);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
325 void dmFreeTimelineEventParam(DMTimelineEventParam *param);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
326 void dmFreeTimelineEvent(DMTimelineEvent *event);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
327 void dmFreeTimelineTrack(DMTimelineTrack *track);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
328
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
329
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
330 // Execution related
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
331 int dmPrepareTimeline(DMTimeline *tl, DMPreparedTimeline *ptl);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
332 void dmFreePreparedTimelineData(DMPreparedTimeline *ptl);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
333
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
334 int dmSeekTimeline(DMPreparedTimeline *tl, int time);
884
18cd96a27dee API changes to be used in future.
Matti Hamalainen <ccr@tnsp.org>
parents: 868
diff changeset
335 int dmExecuteTimeline(DMPreparedTimeline *tl, DMEngineData *engine, int time);
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
336
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
337
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
338 // Editing/saving related functions
395
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 390
diff changeset
339 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
340 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
341 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
342 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
343 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
344 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
345
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1688
diff changeset
346 int dmSaveTimeline(DMResource *res, const DMTimeline *tl);
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
347
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
348 int dmTimelineNew(DMTimeline **tl, const char *name);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
349 int dmTimelineAddTrack(DMTimeline *tl, DMTimelineTrack **track, const char *name);
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
350 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
351 int dmTimelineEventSetEffect(DMTimelineEvent *event, DMEffect *ef);
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
352 int dmTimelineEventSetEffectByIndex(DMTimelineEvent *event, const int index);
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
353 int dmTimelineEventSetEffectByName(DMTimelineEvent *event, const char *name);
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
354
573
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
355 #endif // DM_USE_TIMELINE
14640d0688d3 Make timeline stuff optional.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
356
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
357
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
358 // Resource helpers
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
359 #define engineGetResImage(eng, x, name) \
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 do { \
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
361 if ((x = (SDL_Surface *) engineGetResource(eng, name)) == NULL) \
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 return DMERR_INIT_FAIL; \
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 } while (0)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
365 #define engineGetResModule(eng, x, name) \
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 do { \
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
367 if ((x = (JSSModule *) engineGetResource(eng, name)) == NULL) \
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 return DMERR_INIT_FAIL; \
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 } while (0)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370
721
bb14d7907eb2 Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
371 #define engineFindResource(eng, name) dmResourceFind((eng)->resources, name)
367
9875c65029af Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
372
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 335
diff changeset
374 int engineClassifier(DMResource *res);
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
375 void * engineGetResource(DMEngineData *eng, const char *name);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
376 int engineGetTime(DMEngineData *eng, int t);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
377 int engineGetTimeDTi(DMEngineData *eng);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
378 int engineGetTick(DMEngineData *eng);
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
379 float engineGetTimeDT(DMEngineData *eng);
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
380
846
05a3ee1ca964 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
381 int engineInitAudioParts(DMEngineData *engine);
791
7ea8775b265a Move audio callback code to dmengine.
Matti Hamalainen <ccr@tnsp.org>
parents: 786
diff changeset
382 void engineAudioCallback(void *userdata, Uint8 *stream, int len);
1263
4e9deb14e67f Fix audio sync with nosound.
Matti Hamalainen <ccr@tnsp.org>
parents: 1153
diff changeset
383 void enginePauseAudio(DMEngineData *engine, int status);
593
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
384 int engineGetVideoAspect(int width, int height);
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
385
17bf1704d42e More work on video setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
386
368
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
387 // Implemented in actual demo code
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
388 int demoPreInit(DMEngineData *eng);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389
317
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
390
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
391 #ifdef __cplusplus
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
392 }
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
393 #endif
adb101296bb8 Add C++ protectors.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
394
372
29f0babc686f s/DMSIMPLE/DMENGINE/
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
395 #endif // DMENGINE_H