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