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