Mercurial > hg > demos > krapula
annotate demo.c @ 69:f0b26daba6a9
Build adjustments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 29 Oct 2019 18:16:47 +0200 |
parents | aa06f72f6557 |
children |
rev | line source |
---|---|
39
57d67886153e
Update to latest engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
1 #include "dmengine.h" |
2 | 2 #include "dmvecmat.h" |
46 | 3 #include "dmperlin.h" |
2 | 4 #include <math.h> |
5 | |
32
94c099530548
Update to match engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
6 static int demoInit(); |
94c099530548
Update to match engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
7 static void demoShutdown(); |
94c099530548
Update to match engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
8 static void demoQuit(); |
94c099530548
Update to match engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
9 static int demoRender(); |
94c099530548
Update to match engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
10 |
46 | 11 static DMPerlinContext perlinCtx; |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
12 |
25
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
13 #define DM_COLORS (256) |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
14 |
2 | 15 void dmMakePalette(SDL_Surface *scr) |
16 { | |
17 SDL_Color pal[DM_COLORS]; | |
18 | |
69 | 19 for (int n = 0; n < DM_COLORS; n++) |
2 | 20 { |
21 pal[n].r = n; | |
22 pal[n].g = n; | |
23 pal[n].b = n; | |
24 } | |
25 | |
69 | 26 SDL_SetPaletteColors(scr->format->palette, pal, 0, DM_COLORS); |
2 | 27 } |
28 | |
29 | |
30 #define QWIDTH 256 | |
31 #define QHEIGHT 160 | |
32 | |
33 typedef Uint8 DMBlockMap[QHEIGHT][QWIDTH]; | |
34 | |
35 | |
36 void dmMakeBumpMap(DMBlockMap map, DMFloat q, DMFloat m) | |
37 { | |
38 int x, y; | |
39 for (y = 0; y < QHEIGHT; y++) | |
25
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
40 { |
2 | 41 for (x = 0; x < QWIDTH; x++) |
42 { | |
46 | 43 DMFloat f = 0.40f + dmPerlinNoise2D(&perlinCtx, x, y, 1.1f, q, 2); |
35
1bac8390dafc
This function is in dmlib now.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
44 map[y][x] = (int) (dmClamp10(f) * m); |
2 | 45 } |
25
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
46 } |
2 | 47 } |
48 | |
49 | |
50 void dmShadowTraceHeightMap(DMBlockMap lightMap, DMBlockMap pheightMap, DMVector *light) | |
51 { | |
52 int i, j; | |
53 | |
54 for (j = 0; j < QHEIGHT; j++) | |
55 for (i = 0; i < QWIDTH; i++) | |
56 { | |
57 DMVector vr, vl, va; | |
58 DMFloat vrayLen, vfactor; | |
59 int vlen; | |
60 BOOL wasHit; | |
61 | |
62 /* Perform shadow occlusion via simplistic raytracing */ | |
63 vr.x = i; | |
64 vr.y = j; | |
65 vr.z = light->z; // - 10.0; | |
66 // vr.z = pheightMap[j][i]; | |
67 | |
68 /* Calculate light vector vector */ | |
69 dm_vector_sub_r(&vl, &vr, light); | |
70 vrayLen = dm_vector_length(&vl); | |
71 | |
72 #if 1 | |
73 dm_vector_copy(&va, &vl); | |
74 dm_vector_normalize(&va); | |
75 dm_vector_scale(&va, 0.6f); | |
76 dm_vector_copy(&vr, light); | |
77 | |
78 vlen = 0; | |
79 wasHit = FALSE; | |
80 do | |
81 { | |
82 float h; | |
83 | |
84 /* If ray is inside the heightmap, get value */ | |
85 if (vr.x >= 0 && vr.y >= 0 && vr.x < QWIDTH && vr.y < QHEIGHT) | |
86 h = pheightMap[(int) vr.y][(int) vr.x]; | |
87 else | |
88 break; | |
89 | |
90 /* Check for hits */ | |
91 if (h > vr.z) | |
92 wasHit = TRUE; | |
93 else | |
94 { | |
95 /* Move forwards */ | |
96 dm_vector_add(&vr, &va); | |
97 vlen++; | |
98 } | |
99 } | |
100 while (!wasHit && vlen <= vrayLen); | |
101 | |
102 /* Check if the ray hit something, e.g. is this point occluded? */ | |
103 if (wasHit && vlen < vrayLen) | |
104 { | |
105 vfactor = vlen * 0.01; | |
106 } | |
107 else | |
108 vfactor = vlen * 0.02; | |
109 #endif | |
110 | |
111 #if 1 | |
112 { | |
113 /* Calculate light's intensity based on the angle it "hits" | |
114 * | |
115 * 1) Calculate the vectors that form the imaginary "plane" | |
116 * 2) Cross-product -> normal vector of the plane | |
117 * 2) Normalize the normal vector | |
118 * 3) Calculate light vector's hit angle by dot product | |
119 */ | |
120 DMVector v1, v2; | |
121 DMFloat c; | |
122 | |
123 v1.x = 2.0f; | |
124 v1.y = 0.0f; | |
125 v1.z = (DMFloat) (pheightMap[j][i] - pheightMap[j][i + 1]); | |
126 | |
127 v2.x = 0.0f; | |
128 v2.y = 2.0f; | |
129 v2.z = (DMFloat) (pheightMap[j][i] - pheightMap[j + 1][i]); | |
130 | |
131 dm_vector_cross(&vr, &v1, &v2); | |
132 dm_vector_normalize(&vr); | |
133 dm_vector_normalize(&vl); | |
134 c = dm_vector_dot(&vl, &vr); | |
135 | |
136 vrayLen = 255 - (vrayLen * 0.1) * vrayLen + (c * 128.0f) + (vfactor * vfactor * 1255); | |
137 } | |
138 #else | |
139 vrayLen = 255 - vrayLen * vrayLen * (vfactor * vfactor); | |
140 if (vrayLen < 0) vrayLen = 0; | |
141 vrayLen += pheightMap[j][i]; | |
142 #endif | |
143 | |
144 /* Clip result */ | |
145 if (vrayLen < 0) | |
146 vrayLen = 0; | |
147 else if (vrayLen > 255.0f) | |
148 vrayLen = 255.0f; | |
149 | |
150 lightMap[j][i] = vrayLen; | |
151 } | |
152 } | |
153 | |
154 | |
155 void dmShadowTraceHeightMap2(DMBlockMap lightMap, DMBlockMap pheightMap, DMVector *light) | |
156 { | |
157 int i, j; | |
158 | |
159 light->z = 150; | |
160 | |
161 for (j = 0; j < QHEIGHT; j++) | |
162 for (i = 0; i < QWIDTH; i++) | |
163 { | |
164 DMVector vr, vl, va; | |
165 DMFloat vrayLen, vfactor; | |
166 int vlen; | |
167 BOOL wasHit; | |
168 | |
169 /* Perform shadow occlusion via simplistic raytracing */ | |
170 vr.x = i; | |
171 vr.y = j; | |
172 vr.z = 200; //light->z; // - 10.0; | |
173 | |
174 /* Calculate light vector vector */ | |
175 dm_vector_sub_r(&vl, &vr, light); | |
176 vrayLen = dm_vector_length(&vl); | |
177 | |
178 #if 1 | |
179 dm_vector_copy(&va, &vl); | |
180 dm_vector_normalize(&va); | |
181 dm_vector_copy(&vr, light); | |
182 | |
183 vlen = 0; | |
184 wasHit = FALSE; | |
185 do | |
186 { | |
187 float h; | |
188 | |
189 /* If ray is inside the heightmap, get value */ | |
190 if (vr.x >= 0 && vr.y >= 0 && vr.x < QWIDTH && vr.y < QHEIGHT) | |
191 h = pheightMap[(int) vr.y][(int) vr.x]; | |
192 else | |
193 break; | |
194 | |
195 /* Check for hits */ | |
196 if (h > vr.z) | |
197 wasHit = TRUE; | |
198 else | |
199 { | |
200 /* Move forwards */ | |
201 dm_vector_add(&vr, &va); | |
202 vlen++; | |
203 } | |
204 } | |
205 while (!wasHit && vlen <= vrayLen); | |
206 | |
207 /* Check if the ray hit something, e.g. is this point occluded? */ | |
208 if (wasHit && vlen < vrayLen) | |
209 { | |
210 vfactor = vlen * 0.05; | |
211 } | |
212 else | |
213 vfactor = vlen * 0.001; | |
214 #endif | |
215 | |
216 #if 0 | |
217 { | |
218 /* Calculate light's intensity based on the angle it "hits" | |
219 * | |
220 * 1) Calculate the vectors that form the imaginary "plane" | |
221 * 2) Cross-product -> normal vector of the plane | |
222 * 2) Normalize the normal vector | |
223 * 3) Calculate light vector's hit angle by dot product | |
224 */ | |
225 DMVector v1, v2; | |
226 DMFloat c; | |
227 | |
228 v1.x = 2.0f; | |
229 v1.y = 0.0f; | |
230 v1.z = (DMFloat) (pheightMap[j][i] - pheightMap[j][i + 1]); | |
231 | |
232 v2.x = 0.0f; | |
233 v2.y = 2.0f; | |
234 v2.z = (DMFloat) (pheightMap[j][i] - pheightMap[j + 1][i]); | |
235 | |
236 dm_vector_cross(&vr, &v1, &v2); | |
237 dm_vector_normalize(&vr); | |
238 dm_vector_normalize(&vl); | |
239 c = dm_vector_dot(&vl, &vr); | |
240 | |
241 vrayLen = 255 - (vrayLen * 0.1) * vrayLen + (c * 128.0f) + (vfactor * vfactor * 1255); | |
242 } | |
243 #else | |
244 vrayLen = 255 - vrayLen * vrayLen * (vfactor * vfactor); | |
245 if (vrayLen < 0) vrayLen = 0; | |
246 vrayLen -= pheightMap[j][i]; | |
247 #endif | |
248 | |
249 /* Clip result */ | |
250 if (vrayLen < 0) | |
251 vrayLen = 0; | |
252 else if (vrayLen > 255.0f) | |
253 vrayLen = 255.0f; | |
254 | |
255 lightMap[j][i] = vrayLen; | |
256 } | |
257 } | |
258 | |
259 | |
260 #define CREDITS_SPEED 1000 | |
261 #define CREDITS_RAND 4 | |
262 | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
263 typedef struct |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
264 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
265 int x, y; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
266 } DMCoords; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
267 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
268 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
269 typedef struct |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
270 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
271 int x, y; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
272 char *filename; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
273 SDL_Surface *img; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
274 } DMCredits; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
275 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
276 |
2 | 277 |
278 static const DMCoords randomCoords[] = | |
279 { | |
280 { -300, -430 }, | |
281 { 700, -550 }, | |
282 { -200, 600 }, | |
283 { 700, 600 } | |
284 }; | |
285 const int nrandomCoords = sizeof(randomCoords) / sizeof(randomCoords[0]); | |
286 | |
287 | |
288 static DMCredits credits[] = | |
289 { | |
290 { 91, 223, "g4014.png", NULL }, | |
291 { 151, 250, "g4026.png", NULL }, | |
292 { 217, 227, "g4020.png", NULL }, | |
293 { 173, 268, "g4032.png", NULL }, | |
294 { 115, 359, "g4038.png", NULL }, | |
295 | |
296 { 437, 130, "g4062.png", NULL }, | |
297 { 457, 102, "g4068.png", NULL }, | |
298 { 450, 210, "g4056.png", NULL }, | |
299 | |
300 { 420, 320, "g4044.png", NULL }, | |
301 { 486, 381, "g4050.png", NULL }, | |
302 }; | |
303 | |
304 const int ncredits = sizeof(credits) / sizeof(credits[0]); | |
305 | |
306 | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
307 #define NOSFE_MIN 1 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
308 #define NOSFE_MAX 269 |
2 | 309 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
310 SDL_Surface *bmap; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
311 SDL_Surface *nosfe[NOSFE_MAX - NOSFE_MIN + 1]; |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
312 |
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
313 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
314 int demoPreInit(DMEngineData *engine) |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
315 { |
31
c7703611ea04
Update to match with engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
316 dmInitProg("krapula", |
c7703611ea04
Update to match with engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
317 "Lauantai Aamun Krapula", |
c7703611ea04
Update to match with engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
318 "0.2", "(c) 2012 Anciat Prodz & TNSP", "PENIS."); |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
319 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
320 engine->optPackFilename = "orvellys.dat"; |
59
7daf69b39f34
Cleanups, add license, file_id.diz, fix and update build system.
Matti Hamalainen <ccr@tnsp.org>
parents:
58
diff
changeset
|
321 engine->optResFlags = DRF_USE_PACK | DRF_PRELOAD_RES |
7daf69b39f34
Cleanups, add license, file_id.diz, fix and update build system.
Matti Hamalainen <ccr@tnsp.org>
parents:
58
diff
changeset
|
322 #ifdef DM_USE_STDIO |
56
301e379894ab
Enable stdiofs when DM_DEBUG=yes.
Matti Hamalainen <ccr@tnsp.org>
parents:
54
diff
changeset
|
323 | DRF_USE_STDIO |
301e379894ab
Enable stdiofs when DM_DEBUG=yes.
Matti Hamalainen <ccr@tnsp.org>
parents:
54
diff
changeset
|
324 #endif |
59
7daf69b39f34
Cleanups, add license, file_id.diz, fix and update build system.
Matti Hamalainen <ccr@tnsp.org>
parents:
58
diff
changeset
|
325 ; |
26
077d08c442f7
Update to match latest engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
326 |
59
7daf69b39f34
Cleanups, add license, file_id.diz, fix and update build system.
Matti Hamalainen <ccr@tnsp.org>
parents:
58
diff
changeset
|
327 engine->optAudioSetup = DM_ASETUP_JSS; |
44 | 328 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
329 engine->optVidSetup = DM_VSETUP_ASPECT; |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
330 engine->optVidWidth = 640; |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
331 engine->optVidHeight = 480; |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
332 engine->optVidDepth = 32; |
2 | 333 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
334 engine->demoInit = demoInit; |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
335 engine->demoRender = demoRender; |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
336 engine->demoShutdown = demoShutdown; |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
337 engine->demoQuit = demoQuit; |
32
94c099530548
Update to match engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
338 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
339 return DMERR_OK; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
340 } |
17 | 341 |
342 | |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
343 static int demoInit(DMEngineData *engine) |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
344 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
345 int i; |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
346 |
17 | 347 // Initialize effect stuff |
46 | 348 dmPerlinInit(&perlinCtx, 1234); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
349 |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
350 for (i = 0; i < NOSFE_MAX; i++) |
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
351 { |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
352 char fname[32]; |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
353 snprintf(fname, sizeof(fname), "%08d.jpg", NOSFE_MIN + i); |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
354 engineGetResImage(engine, nosfe[i], fname); |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
355 } |
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
356 |
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
357 for (i = 0; i < ncredits; i++) |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
358 engineGetResImage(engine, credits[i].img, credits[i].filename); |
2 | 359 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
360 bmap = SDL_CreateRGBSurface(SDL_SWSURFACE, QWIDTH, QHEIGHT, 8, 0, 0, 0, 0); |
2 | 361 |
17 | 362 |
363 // Initialize music player | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
364 JSSModule *mod = NULL; |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
365 engineGetResModule(engine, mod, "krapula.xm"); |
24
01f3af410abb
Update to match changes in the dmlib API and JSS engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
366 |
01f3af410abb
Update to match changes in the dmlib API and JSS engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
367 if ((i = jssConvertModuleForPlaying(mod)) != DMERR_OK) |
01f3af410abb
Update to match changes in the dmlib API and JSS engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
368 { |
46 | 369 dmErrorMsg("Could not convert module for playing, %d: %s\n", |
24
01f3af410abb
Update to match changes in the dmlib API and JSS engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
370 i, dmErrorStr(i)); |
01f3af410abb
Update to match changes in the dmlib API and JSS engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
371 return DMERR_INIT_FAIL; |
01f3af410abb
Update to match changes in the dmlib API and JSS engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
372 } |
01f3af410abb
Update to match changes in the dmlib API and JSS engine.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
373 |
44 | 374 jvmSetCallback(engine->jssDev, jmpExec, engine->jssPlr); |
375 jmpSetModule(engine->jssPlr, mod); | |
376 jmpPlayOrder(engine->jssPlr, 0); | |
377 jvmSetGlobalVol(engine->jssDev, 55); | |
2 | 378 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
379 return DMERR_OK; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
380 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
381 |
2 | 382 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
383 static void demoShutdown(DMEngineData *engine) |
25
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
384 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
385 (void) engine; |
25
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
386 SDL_FreeSurface(bmap); |
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
387 } |
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
388 |
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
389 |
32
94c099530548
Update to match engine changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
390 static void demoQuit() |
25
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
391 { |
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
392 dmPrint(0, "Krapulassa on kivaa.\n"); |
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
393 } |
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
394 |
98dcf1847e75
Cleanups, add the debug mode enabling option.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
395 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
396 static int demoRender(DMEngineData *engine) |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
397 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
398 float t = engineGetTimeDT(engine); |
2 | 399 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
400 if (t < 5) |
2 | 401 { |
49 | 402 // |
403 // Anciat prodz logo | |
404 // | |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
405 int dt = engineGetTime(engine, 0); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
406 static SDL_Surface *anciat; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
407 static DMLerpContext lerpX, lerpY, lerpD; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
408 static DMScaledBlitFunc nblit; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
409 DMVector light; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
410 static BOOL nollattu = FALSE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
411 if (!nollattu) |
2 | 412 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
413 engineGetResImage(engine, anciat, "anciat.png"); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
414 nblit = dmGetScaledBlitFunc(bmap->format, engine->screen->format, DMD_NONE); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
415 dmMakePalette(bmap); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
416 dmLerpInit(&lerpX, 0, QWIDTH, 5000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
417 dmLerpInit(&lerpY, QHEIGHT * 0.25, QHEIGHT * 0.75, 5000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
418 dmLerpInit(&lerpD, 0.04, 0.08, 5000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
419 nollattu = TRUE; |
2 | 420 } |
421 | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
422 light.x = dmLerpSCurve(&lerpX, dt); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
423 light.y = dmLerp1(&lerpY, dt); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
424 light.z = 128; |
2 | 425 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
426 dmShadowTraceHeightMap2(bmap->pixels, anciat->pixels, &light); |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
427 nblit(bmap, 0, 0, engine->screen->w, engine->screen->h, engine->screen); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
428 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
429 else |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
430 if (t < 10) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
431 { |
49 | 432 // |
433 // Demo "logo" texts | |
434 // | |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
435 int dt = engineGetTime(engine, 5); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
436 static SDL_Surface *logobg, *logolayer1, *logolayer2; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
437 static DMScaledBlitFunc nblit, kblit; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
438 static DMLerpContext lerpD; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
439 static BOOL nollattu = FALSE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
440 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
441 if (!nollattu) |
2 | 442 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
443 engineGetResImage(engine, logobg, "logobg.png"); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
444 engineGetResImage(engine, logolayer1, "logolayer1.png"); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
445 engineGetResImage(engine, logolayer2, "logolayer2.png"); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
446 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
447 nblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_TRANSPARENT); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
448 kblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_NONE); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
449 dmLerpInit(&lerpD, 0.01, 500, 10000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
450 nollattu = TRUE; |
2 | 451 } |
452 | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
453 float q = dmLerpSCurve(&lerpD, dt); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
454 float t = sin((float) dt / 150.0f); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
455 int x = t * 25.0f + q, y = t * 35.0f + q*2.0f, |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
456 w = t * 70.0f + q, h = t * 40.0f + q*2.0f; |
2 | 457 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
458 float t2 = sin((float) dt / 150.0f + 0.2f); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
459 int x2 = t2 * 25.0f + q, y2 = t * 35.0f + q*2.0f, |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
460 w2 = t2 * 70.0f + q, h2 = t * 40.0f + q*2.0f; |
2 | 461 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
462 kblit(logobg, 0, 0, engine->screen->w, engine->screen->h, engine->screen); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
463 nblit(logolayer1, -x, -y, engine->screen->w+w, engine->screen->h+h, engine->screen); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
464 nblit(logolayer2, -x2, -y2, engine->screen->w+w2, engine->screen->h+h2, engine->screen); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
465 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
466 else |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
467 if (t < 20) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
468 { |
49 | 469 // |
470 // "Gaytracing" | |
471 // | |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
472 int dt = engineGetTime(engine, 10); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
473 static SDL_Surface *gay, *logobg; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
474 static DMLerpContext lerpX, lerpY, lerpD; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
475 static DMScaledBlitFunc nblit, kblit; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
476 static BOOL nollattu = FALSE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
477 DMVector light; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
478 DMBlockMap heightMap; |
2 | 479 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
480 if (!nollattu) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
481 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
482 engineGetResImage(engine, gay, "gay.png"); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
483 engineGetResImage(engine, logobg, "logobg.png"); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
484 nblit = dmGetScaledBlitFunc(bmap->format, engine->screen->format, DMD_NONE); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
485 kblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_TRANSPARENT); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
486 dmMakePalette(bmap); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
487 dmLerpInit(&lerpX, QWIDTH, 0, 10000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
488 dmLerpInit(&lerpY, QHEIGHT * 0.25, QHEIGHT * 0.75, 10000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
489 dmLerpInit(&lerpD, 0.04, 0.08, 10000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
490 nollattu = TRUE; |
2 | 491 } |
492 | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
493 light.x = dmLerpSCurve(&lerpX, dt); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
494 light.y = QHEIGHT * 0.5 + sin(dmLerp1(&lerpY, dt)) * 0.5; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
495 light.z = 128; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
496 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
497 dmMakeBumpMap(heightMap, dmLerpSCurve(&lerpD, dt), 254); |
2 | 498 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
499 dmShadowTraceHeightMap(bmap->pixels, heightMap, &light); |
2 | 500 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
501 nblit(bmap, 0, 0, engine->screen->w, engine->screen->h, engine->screen); |
2 | 502 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
503 if ((dt / 100) % 10 < 5) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
504 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
505 kblit(gay, 0, 0, engine->screen->w, engine->screen->h, engine->screen); |
2 | 506 } |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
507 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
508 else |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
509 if (t < 45) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
510 { |
49 | 511 // |
512 // Nosfe video/animation + credits | |
513 // | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
514 static SDL_Surface *ruutu; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
515 static int currState, currCredit, creditStartTime; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
516 static DMLerpContext lerpX, lerpY, lerpZ; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
517 static DMScaledBlitFunc nblit, kblit; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
518 static BOOL stateChange, nollattu = FALSE; |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
519 int currFrame = engineGetTime(engine, 20) * 15 / 1000; |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
520 if (!nollattu) |
2 | 521 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
522 engineGetResImage(engine, ruutu, "ruutu.png"); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
523 dmClearSurface(ruutu, dmMapRGBA(ruutu, 0,0,0,0)); |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
524 nblit = dmGetScaledBlitFunc(nosfe[0]->format, engine->screen->format, DMD_NONE); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
525 kblit = dmGetScaledBlitFunc(credits[0].img->format, engine->screen->format, DMD_TRANSPARENT); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
526 currCredit = -1; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
527 currState = -1; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
528 stateChange = TRUE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
529 nollattu = TRUE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
530 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
531 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
532 float gt = 1.0f + sin(engineGetTime(engine, 0) / 250.0f); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
533 int g1 = gt * 25.0f, g2 = gt * 50.0f; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
534 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
535 nblit(nosfe[currFrame % NOSFE_MAX], -g1, -g1, engine->screen->w+g2, engine->screen->h+g2, engine->screen); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
536 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
537 if (t >= 30) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
538 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
539 int qtime = engineGetTime(engine, 30); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
540 int creditTime = engineGetTime(engine, 0) - creditStartTime; |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
541 float zscale; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
542 if ( ( (qtime / (CREDITS_SPEED + 500)) % 2) == 0 && currState == -1) |
2 | 543 stateChange = TRUE; |
544 | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
545 if (stateChange && currCredit < ncredits) |
2 | 546 { |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
547 stateChange = FALSE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
548 switch (currState) |
2 | 549 { |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
550 case 0: |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
551 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
552 int qt = (qtime / 100) % nrandomCoords; |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
553 creditStartTime = engineGetTime(engine, 0); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
554 creditTime = 0; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
555 dmLerpInit(&lerpX, randomCoords[qt].x, credits[currCredit].x - 50, CREDITS_SPEED); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
556 dmLerpInit(&lerpY, randomCoords[qt].y, credits[currCredit].y - 50, CREDITS_SPEED); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
557 dmLerpInit(&lerpZ, 5.0f, 0.0f, CREDITS_SPEED); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
558 currState = 1; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
559 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
560 break; |
2 | 561 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
562 case 2: |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
563 if (creditTime >= CREDITS_SPEED) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
564 creditTime = CREDITS_SPEED - 1; |
2 | 565 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
566 zscale = dmLerpSCurve(&lerpZ, creditTime); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
567 dmScaledBlitSurface32to32TransparentX( |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
568 credits[currCredit].img, |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
569 dmLerpSCurve(&lerpX, creditTime) - (zscale * credits[currCredit].img->w), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
570 dmLerpSCurve(&lerpY, creditTime) - (zscale * credits[currCredit].img->h), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
571 credits[currCredit].img->w * (1.0f + zscale), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
572 credits[currCredit].img->h * (1.0f + zscale), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
573 ruutu); |
2 | 574 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
575 currState = -1; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
576 break; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
577 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
578 default: |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
579 currCredit++; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
580 currState = 0; |
2 | 581 stateChange = TRUE; |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
582 break; |
2 | 583 } |
584 } | |
14
b2b506e1f42a
Add nice headache white fade synced to beat.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
585 |
2 | 586 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
587 if (currCredit > 0) |
2 | 588 { |
47 | 589 int zk = cos(engineGetTime(engine, 0) / 250.0f) * 25; |
590 kblit(ruutu, -zk, -zk, engine->screen->w + zk*2, engine->screen->h + zk*2, engine->screen); | |
15 | 591 } |
592 | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
593 if (currState == 1) |
15 | 594 { |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
595 if (creditTime >= CREDITS_SPEED) |
15 | 596 { |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
597 creditTime = CREDITS_SPEED; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
598 stateChange = TRUE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
599 currState = 2; |
15 | 600 } |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
601 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
602 zscale = dmLerpSCurve(&lerpZ, creditTime); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
603 kblit(credits[currCredit].img, |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
604 dmLerpSCurve(&lerpX, creditTime) - (zscale * credits[currCredit].img->w), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
605 dmLerpSCurve(&lerpY, creditTime) - (zscale * credits[currCredit].img->h), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
606 credits[currCredit].img->w * (1.0f + zscale), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
607 credits[currCredit].img->h * (1.0f + zscale), |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
608 engine->screen); |
15 | 609 } |
610 } | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
611 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
612 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
613 else |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
614 if (t < 60) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
615 { |
49 | 616 // |
617 // Greetings | |
618 // | |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
619 int dt = engineGetTime(engine, 45); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
620 static SDL_Surface *logobg, *greets; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
621 static DMScaledBlitFunc nblit, kblit; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
622 static DMLerpContext lerpD; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
623 static BOOL nollattu = FALSE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
624 |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
625 if (!nollattu) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
626 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
627 engineGetResImage(engine, logobg, "logobg.png"); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
628 engineGetResImage(engine, greets, "greetings.png"); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
629 nblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_TRANSPARENT); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
630 kblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_NONE); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
631 dmLerpInit(&lerpD, 0.01, 500, 10000); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
632 nollattu = TRUE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
633 } |
15 | 634 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
635 float q = dmLerpSCurve(&lerpD, dt); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
636 float t = sin((float) dt / 150.0f), |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
637 j = (1.0 + t) * 15; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
638 int x = t * 25.0f + q, y = t * 35.0f + q, |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
639 w = t * 70.0f + q*2.0f, h = t * 40.0f + q*2.0f; |
8
b3d6670c4324
Use new resource management system.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
640 |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
641 kblit(logobg, -j, -j, engine->screen->w+j*2.0f, engine->screen->h+j*2.0f, engine->screen); |
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
642 nblit(greets, -x, -y, engine->screen->w+w, engine->screen->h+h, engine->screen); |
2 | 643 } |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
644 else |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
645 engine->exitFlag = TRUE; |
2 | 646 |
647 | |
49 | 648 // |
649 // Flash/fade thingy | |
650 // | |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
651 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
652 static SDL_Surface *feidi; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
653 static int fadeStartTime; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
654 static BOOL fadeActive, nollattu = FALSE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
655 static DMLerpContext fadeLerp; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
656 BOOL hit; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
657 int ch; |
2 | 658 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
659 if (!nollattu) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
660 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
661 engineGetResImage(engine, feidi, "feidi.png"); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
662 dmLerpInit(&fadeLerp, 255, 0, 250); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
663 nollattu = TRUE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
664 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
665 |
44 | 666 JSS_LOCK(engine->jssPlr); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
667 for (hit = FALSE, ch = 0; ch < 6; ch++) |
44 | 668 if (engine->jssPlr->channels[ch].nextInstrument == 0) |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
669 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
670 hit = TRUE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
671 break; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
672 } |
44 | 673 JSS_UNLOCK(engine->jssPlr); |
2 | 674 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
675 if (hit && !fadeActive) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
676 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
677 fadeActive = TRUE; |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
678 fadeStartTime = engineGetTime(engine, 0); |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
679 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
680 if (fadeActive) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
681 { |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
682 int fadeTime = engineGetTime(engine, 0) - fadeStartTime; |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
683 if (fadeTime < 250) |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
684 { |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
685 dmScaledBlitSurface32to32TransparentGA(feidi, |
40
9cbb03e85597
Update to latest dmlib API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
686 0, 0, engine->screen->w, engine->screen->h, engine->screen, |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
687 dmLerpSCurve(&fadeLerp, fadeTime)); |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
688 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
689 else |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
690 fadeActive = FALSE; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
691 } |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
692 } |
2 | 693 |
21
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
694 return DMERR_OK; |
ea93b1d5c894
Use the dmsimple demo engine "framework".
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
695 } |