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