0
|
1 #include "dmengine.h"
|
|
2 #include "dmtext.h"
|
|
3 #include "dmfft.h"
|
|
4 #include "dmvecmat.h"
|
|
5 #include <math.h>
|
|
6
|
|
7 static int demoInit(DMEngineData *engine);
|
|
8 static void demoShutdown(DMEngineData *engine);
|
|
9 static int demoRender(DMEngineData *engine);
|
|
10
|
|
11
|
|
12 int demoPreInit(DMEngineData *engine)
|
|
13 {
|
|
14 dmInitProg("bussi",
|
2
|
15 "Bussi by AnCiat ProDucTionz",
|
0
|
16 "0", "ENGINE INITTIALISSSIZING!!!!!", NULL);
|
|
17
|
|
18 engine->optPackFilename = "bussi.dat";
|
|
19 engine->optDataPath = NULL;
|
19
|
20
|
21
|
21 // engine->optResFlags = DRF_USE_PACK | DRF_PRELOAD_RES;
|
|
22 engine->optResFlags = DRF_USE_PACK | DRF_PRELOAD_RES | DRF_USE_STDIO;
|
0
|
23
|
|
24 engine->optAudioSetup = DM_ASETUP_JSS;
|
|
25
|
|
26 engine->optVidSetup = DM_VSETUP_ASPECT;
|
|
27 engine->optVidWidth = 640;
|
|
28 engine->optVidHeight = 480;
|
|
29 engine->optVidDepth = 32;
|
|
30 engine->optVFlags = SDL_SWSURFACE;
|
|
31
|
|
32 engine->demoInit = demoInit;
|
|
33 engine->demoRender = demoRender;
|
|
34 engine->demoShutdown = demoShutdown;
|
|
35
|
|
36 return DMERR_OK;
|
|
37 }
|
|
38
|
|
39
|
|
40 #define FFT_SIZE 128
|
|
41 DMFFTContext fft;
|
5
|
42 DMResource *teksti = NULL;
|
|
43 DMBitmapFont *font = NULL;
|
|
44
|
|
45 typedef struct
|
|
46 {
|
|
47 int layer;
|
13
|
48 int freq;
|
|
49 int max;
|
|
50 float ypos;
|
|
51 float speed;
|
5
|
52 char *filename;
|
|
53 SDL_Surface *img;
|
13
|
54 int count;
|
5
|
55 } DMItemDef;
|
|
56
|
|
57
|
13
|
58 typedef struct
|
5
|
59 {
|
13
|
60 BOOL enabled;
|
|
61 float xtime, xpos, ypos;
|
|
62 DMItemDef *ref;
|
|
63 } DMFooItemDef;
|
|
64
|
|
65
|
|
66 static DMItemDef items[] =
|
|
67 {
|
|
68 { 0, 3, 1, 0.53, 0.2, "viitta.png", NULL, 0 },
|
16
|
69 { 0, 1, 3, -0.2, 0.05, "pilvi.png", NULL, 0 },
|
13
|
70 { 0, 1, 3, 0.28 , 0.1 , "puu_pv_2.png", NULL, 0 },
|
|
71 { 1, 9, 2, 0.25 , 0.8 , "puu_pv_1.png", NULL, 0 },
|
5
|
72 };
|
|
73
|
|
74 static const int nitems = sizeof(items) / sizeof(items[0]);
|
|
75
|
|
76
|
0
|
77
|
|
78
|
|
79 static int demoInit(DMEngineData *engine)
|
|
80 {
|
|
81 int i;
|
|
82 JSSModule *mod = NULL;
|
5
|
83 SDL_Color pal[DMFONT_NPALETTE];
|
|
84 DMResource *tmp;
|
0
|
85
|
5
|
86 // FFT init
|
0
|
87 dmInitializeFFT(&fft, FFT_SIZE);
|
|
88
|
5
|
89 // Skrolliteksti
|
|
90 if ((teksti = engineFindResource(engine, "skrolli.txt")) == NULL)
|
|
91 return DMERR_INIT_FAIL;
|
|
92
|
|
93 // Skrollerin fontti
|
|
94 if ((tmp = engineFindResource(engine, "fontti.dmf")) == NULL)
|
|
95 return DMERR_INIT_FAIL;
|
|
96
|
|
97 if ((i = dmLoadBitmapFont(tmp, &font)) != DMERR_OK)
|
|
98 return i;
|
|
99
|
|
100 for (i = 0; i < DMFONT_NPALETTE; i++)
|
|
101 {
|
|
102 pal[i].r = pal[i].g = pal[i].b = i * 8;
|
|
103 pal[i].unused = i > 0 ? 255 : 0;
|
|
104 }
|
|
105
|
|
106 dmSetBitmapFontPalette(font, pal, 0, DMFONT_NPALETTE);
|
|
107
|
|
108 // Musa
|
0
|
109 engineGetResModule(engine, mod, "pas2.xm");
|
|
110
|
|
111 if ((i = jssConvertModuleForPlaying(mod)) != DMERR_OK)
|
|
112 {
|
|
113 dmErrorMsg("Could not convert module for playing, %d: %s\n",
|
|
114 i, dmErrorStr(i));
|
|
115 return DMERR_INIT_FAIL;
|
|
116 }
|
|
117
|
|
118 jvmSetCallback(engine->jssDev, jmpExec, engine->jssPlr);
|
|
119 jmpSetModule(engine->jssPlr, mod);
|
|
120 jmpPlayOrder(engine->jssPlr, 0);
|
|
121 jvmSetGlobalVol(engine->jssDev, 55);
|
|
122
|
5
|
123
|
|
124 // Osa kuvadatasta
|
|
125 for (i = 0; i < nitems; i++)
|
|
126 engineGetResImage(engine, items[i].img, items[i].filename);
|
|
127
|
0
|
128 // Jne
|
|
129 srand(15);
|
|
130
|
|
131 return DMERR_OK;
|
|
132 }
|
|
133
|
|
134
|
|
135 static void demoShutdown(DMEngineData *engine)
|
|
136 {
|
|
137 (void) engine;
|
|
138 dmEndFFT(&fft);
|
5
|
139 dmFreeBitmapFont(font);
|
0
|
140 }
|
|
141
|
|
142
|
|
143 static inline float dmCX(DMEngineData *engine, const float x)
|
|
144 {
|
|
145 return (x * engine->screen->w);
|
|
146 }
|
|
147
|
|
148
|
|
149 static inline float dmCY(DMEngineData *engine, const float y)
|
|
150 {
|
|
151 return (y * engine->screen->h);
|
|
152 }
|
|
153
|
|
154
|
|
155 static inline float dmQX(DMEngineData *engine, SDL_Surface *img, const float x)
|
|
156 {
|
|
157 return engine->optVidNative ? (img->w * x) : (img->w * engine->screen->w * x) / 640.0f;
|
|
158 }
|
|
159
|
|
160
|
|
161 static inline float dmQY(DMEngineData *engine, SDL_Surface *img, const float y)
|
|
162 {
|
|
163 return engine->optVidNative ? (img->h * y) : (img->h * engine->screen->h * y) / 480.0f;
|
|
164 }
|
|
165
|
|
166
|
|
167 #define DM_RADIAL_BLUR(YC, XC) \
|
|
168 DMVector p1 = { xc, yc, 0, 0 }, p2 = { cx, cy, 0, 0 }, v; \
|
|
169 dm_vector_sub_r(&v, &p2, &p1); \
|
|
170 dm_vector_scale(&v, scale); \
|
|
171 dm_vector_add(&v, &p1); \
|
|
172 if (v.y YC || v.x XC) continue; \
|
|
173 DMColor *dp = pix + xc, \
|
|
174 *q = ((DMColor *)img->pixels) + ((int)(v.y) * pitch) + (int)v.x; \
|
|
175 dp->r = (q->r + dp->r) / 2; \
|
|
176 dp->g = (q->g + dp->g) / 2; \
|
|
177 dp->b = (q->b + dp->b) / 2;
|
|
178
|
|
179
|
|
180
|
|
181 void dmRadialBlur(SDL_Surface *img, const int cx, const int cy, const DMFloat scale)
|
|
182 {
|
|
183 const int pitch = img->pitch / sizeof(DMColor);
|
|
184 int xc, yc;
|
|
185
|
|
186 #pragma omp parallel private(yc, xc) shared(img)
|
|
187 {
|
|
188 #pragma omp sections nowait
|
|
189 {
|
|
190 #pragma omp section
|
|
191 for (yc = cy; yc >= 0; yc--)
|
|
192 {
|
|
193 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
|
|
194 for (xc = cx + 1; xc < img->w; xc++)
|
|
195 {
|
|
196 DM_RADIAL_BLUR(< 0, >= img->w)
|
|
197 }
|
|
198 }
|
|
199
|
|
200 #pragma omp section
|
|
201 for (yc = cy; yc >= 0; yc--)
|
|
202 {
|
|
203 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
|
|
204 for (xc = cx; xc > 0; xc--)
|
|
205 {
|
|
206 DM_RADIAL_BLUR(< 0, < 0)
|
|
207 }
|
|
208 }
|
|
209
|
|
210 #pragma omp section
|
|
211 for (yc = cy + 1; yc < img->h; yc++)
|
|
212 {
|
|
213 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
|
|
214 for (xc = cx; xc > 0; xc--)
|
|
215 {
|
|
216 DM_RADIAL_BLUR(>= img->h, < 0)
|
|
217 }
|
|
218 }
|
|
219
|
|
220 #pragma omp section
|
|
221 for (yc = cy + 1; yc < img->h; yc++)
|
|
222 {
|
|
223 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
|
|
224 for (xc = cx + 1; xc < img->w; xc++)
|
|
225 {
|
|
226 DM_RADIAL_BLUR(>= img->h, >= img->w)
|
|
227 }
|
|
228 }
|
|
229 }
|
|
230 }
|
|
231 }
|
|
232
|
|
233
|
9
|
234 static int my_toupper(int ch)
|
|
235 {
|
|
236 switch (ch)
|
|
237 {
|
|
238 case 0xe4: return 142;
|
|
239 case 0xf6: return 153;
|
|
240 default:
|
|
241 if (ch >= 'a' && ch <= 'z')
|
|
242 return ch - 'a' + 'A';
|
|
243 else
|
|
244 return ch;
|
|
245 }
|
|
246 }
|
|
247
|
|
248
|
13
|
249 static DMItemDef * dmGetItem(int t)
|
|
250 {
|
|
251 int i;
|
|
252 for (i = 0; i < nitems; i++)
|
|
253 {
|
|
254 DMItemDef *def = &items[i];
|
|
255 if (t % def->freq == 0 && def->count <= def->max)
|
|
256 return def;
|
|
257 }
|
|
258 return NULL;
|
|
259 }
|
|
260
|
|
261
|
|
262 static void dmRenderItems(DMEngineData *engine, DMScaledBlitFunc ablit, DMFooItemDef *mitems, const int nmitems, const int layer)
|
|
263 {
|
|
264 int i;
|
|
265 for (i = 0; i < nmitems; i++)
|
|
266 {
|
|
267 DMFooItemDef *item = &mitems[i];
|
|
268
|
|
269 if (item->enabled && item->ref->layer == layer)
|
|
270 {
|
|
271 ablit(item->ref->img,
|
|
272 dmCX(engine, item->xpos),
|
|
273 dmCY(engine, item->ypos),
|
|
274 dmQX(engine, item->ref->img, 1),
|
|
275 dmQY(engine, item->ref->img, 1),
|
|
276 engine->screen);
|
|
277 }
|
|
278 }
|
|
279 }
|
|
280
|
9
|
281
|
0
|
282 static int demoRender(DMEngineData *engine)
|
|
283 {
|
|
284 float t = engineGetTimeDT(engine);
|
|
285
|
3
|
286 //
|
0
|
287 // Do FFT
|
3
|
288 //
|
0
|
289 DMFFTType fftPow = 0;
|
|
290 BOOL fftOK = FALSE;
|
|
291 static DMFFTType fftAmp[FFT_SIZE / 2];
|
|
292 static DMFFTType fftData[FFT_SIZE];
|
|
293
|
|
294 dmMutexLock(engine->audioStreamMutex);
|
|
295 if (engine->audioStreamBuf != 0 && engine->audioStreamLen > FFT_SIZE)
|
|
296 {
|
|
297 int i;
|
|
298 Sint16 *buf = (Sint16 *) engine->audioStreamBuf;
|
|
299 for (i = 0; i < FFT_SIZE; i++)
|
|
300 {
|
|
301 fftData[i] = *buf;
|
|
302 buf += 2;
|
|
303 }
|
|
304 fftOK = TRUE;
|
|
305 }
|
|
306 dmMutexUnlock(engine->audioStreamMutex);
|
|
307
|
|
308 if (fftOK)
|
|
309 {
|
|
310 dmRealFFT(&fft, fftData);
|
|
311 dmConvertFFTtoPowerAndSum(&fft, fftData, fftAmp, 1.0, &fftPow, 0.00004f);
|
|
312 }
|
|
313
|
3
|
314
|
|
315 //
|
|
316 // Taustaskrolli
|
|
317 //
|
0
|
318 {
|
3
|
319 static SDL_Surface *tausta = NULL,
|
|
320 *aurinko = NULL,
|
|
321 *bussi = NULL,
|
|
322 *rengas = NULL;
|
|
323
|
|
324 static DMScaledBlitFunc cblit = NULL, ablit = NULL;
|
|
325 static BOOL nollattu = FALSE;
|
|
326 static DMLerpContext fadeLerp, fadeLerp2, fadeLerp3;
|
|
327
|
|
328 if (!nollattu)
|
|
329 {
|
|
330 dmLerpInit(&fadeLerp, 0, 255, 3000);
|
|
331 dmLerpInit(&fadeLerp2, 0, 255, 4000);
|
|
332 dmLerpInit(&fadeLerp3, 0, 1.2, 3000);
|
|
333 engineGetResImage(engine, tausta, "tausta_pv.png");
|
|
334 engineGetResImage(engine, aurinko, "aurinko.png");
|
|
335 engineGetResImage(engine, bussi, "auto.png");
|
|
336 engineGetResImage(engine, rengas, "rengas.png");
|
|
337 cblit = dmGetScaledBlitFunc(tausta->format, engine->screen->format, DMD_NONE);
|
|
338 ablit = dmGetScaledBlitFunc(bussi->format, engine->screen->format, DMD_TRANSPARENT);
|
|
339 }
|
|
340
|
7
|
341 int x1 = - ((int)dmQX(engine, tausta, t * 0.2) % (int) dmQX(engine, tausta, 1)),
|
|
342 x2 = x1 + dmQX(engine, tausta, 1);
|
3
|
343
|
21
|
344 cblit(tausta, x1, 0, dmQX(engine, tausta, 1), dmQY(engine, tausta, 1), engine->screen);
|
|
345 cblit(tausta, x2, 0, dmQX(engine, tausta, 1), dmQY(engine, tausta, 1), engine->screen);
|
3
|
346
|
13
|
347 float qm = sin(t * 0.1 + fftPow * 5) * 0.05, qm2 = qm * 10;
|
21
|
348 ablit(aurinko,
|
13
|
349 dmCX(engine, 0.8 - dmLerpSCurveClamp(&fadeLerp3, engineGetTime(engine, 0) * 0.01) * 0.3 - qm),
|
|
350 dmCY(engine, 0.05 - qm),
|
|
351 dmQX(engine, aurinko, 1 + qm2),
|
|
352 dmQY(engine, aurinko, 1 + qm2),
|
21
|
353 engine->screen);
|
3
|
354
|
13
|
355 // Puut ym. liikennejutut
|
|
356 #define DM_MAX_MITEMS 16
|
|
357 static DMFooItemDef mitems[DM_MAX_MITEMS];
|
16
|
358 if (t > 6)
|
13
|
359 {
|
16
|
360 float dt = (t - 6);
|
13
|
361 static BOOL nollattu = FALSE;
|
|
362 int i;
|
|
363
|
|
364 if (!nollattu)
|
|
365 {
|
|
366 memset(mitems, 0, sizeof(mitems));
|
|
367 nollattu = TRUE;
|
|
368 }
|
|
369
|
|
370 for (i = 0; i < DM_MAX_MITEMS; i++)
|
|
371 {
|
|
372 DMFooItemDef *item = &mitems[i];
|
|
373 if (!item->enabled && (item->ref = dmGetItem((int) t * 10 + 1)) != NULL)
|
|
374 {
|
|
375 item->enabled = TRUE;
|
|
376 item->ref->count++;
|
|
377 item->xtime = dt;
|
|
378 item->ypos = item->ref->ypos + sin(dt) * 0.001f;
|
|
379 }
|
|
380 }
|
|
381 for (i = 0; i < DM_MAX_MITEMS; i++)
|
|
382 {
|
|
383 DMFooItemDef *item = &mitems[i];
|
|
384 if (item->enabled)
|
|
385 {
|
|
386 float xpos = (dt - item->xtime) * item->ref->speed;
|
|
387 if (xpos > 1.5)
|
|
388 {
|
|
389 item->enabled = FALSE;
|
|
390 item->ref->count--;
|
|
391 }
|
|
392 else
|
|
393 item->xpos = 1 - xpos;
|
|
394 }
|
|
395 }
|
|
396 }
|
|
397
|
|
398 dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 0);
|
3
|
399
|
|
400 // Bussi ajaa sisään
|
5
|
401 if (t > 14)
|
3
|
402 {
|
|
403 float
|
5
|
404 dt = engineGetTime(engine, 14),
|
3
|
405 ajelu = dmLerpSCurveClamp(&fadeLerp3, dt),
|
|
406 xc = dmCX(engine, -1 + ajelu),
|
13
|
407 yc = dmCY(engine, 0.38 + sin(t * 10) * 0.005),
|
3
|
408 yc2 = yc + dmQY(engine, bussi, 0.7) + dmCY(engine, sin(t * 20) * 0.001);
|
|
409
|
|
410 ablit(rengas, xc + dmQX(engine, bussi, 0.07), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
|
|
411 ablit(rengas, xc + dmQX(engine, bussi, 0.80), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
|
|
412 ablit(bussi, xc, yc, dmQX(engine, bussi, 1), dmQY(engine, bussi, 1), engine->screen);
|
|
413 }
|
21
|
414
|
5
|
415
|
13
|
416 dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 1);
|
3
|
417 }
|
|
418
|
|
419 //
|
|
420 // AP logo
|
|
421 //
|
|
422 if (t > 4 && t < 8)
|
|
423 {
|
|
424 int dt = engineGetTime(engine, 4);
|
0
|
425 static DMLerpContext fadeLerp;
|
3
|
426 static SDL_Surface *logo = NULL;
|
0
|
427 static BOOL nollattu = FALSE;
|
|
428 if (!nollattu)
|
|
429 {
|
3
|
430 dmLerpInit(&fadeLerp, 0, 255, 1000);
|
|
431 engineGetResImage(engine, logo, "ap.png");
|
|
432 nollattu = TRUE;
|
|
433 }
|
|
434
|
|
435 int fadeVal;
|
|
436 if (dt < 1000)
|
|
437 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt);
|
|
438 else
|
|
439 if (dt > 3000)
|
|
440 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
|
|
441 else
|
|
442 fadeVal = 255;
|
0
|
443
|
3
|
444 dmScaledBlitSurface32to32TransparentGA(logo,
|
|
445 dmQX(engine, logo, 0.2),
|
|
446 dmQY(engine, logo, 0.3),
|
|
447 dmQX(engine, logo, 1),
|
|
448 dmQY(engine, logo, 1),
|
|
449 engine->screen, fadeVal);
|
|
450 }
|
|
451
|
|
452 //
|
|
453 // BUSSI logo
|
|
454 //
|
|
455 if (t > 10 && t < 14)
|
|
456 {
|
|
457 int dt = engineGetTime(engine, 10);
|
|
458 static DMLerpContext fadeLerp;
|
|
459 static SDL_Surface *logo = NULL, *logo2 = NULL;
|
|
460 static BOOL nollattu = FALSE;
|
|
461 if (!nollattu)
|
|
462 {
|
|
463 dmLerpInit(&fadeLerp, 0, 255, 1000);
|
|
464 engineGetResImage(engine, logo, "bussi_logo.png");
|
|
465 engineGetResImage(engine, logo2, "dosa.png");
|
0
|
466 nollattu = TRUE;
|
|
467 }
|
|
468
|
3
|
469 int fadeVal, fadeVal2;
|
|
470 if (dt < 1000)
|
|
471 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt);
|
|
472 else
|
|
473 if (dt > 3000)
|
|
474 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
|
|
475 else
|
|
476 fadeVal = 255;
|
|
477
|
|
478 if (dt > 1000)
|
|
479 {
|
|
480 if (dt < 2000)
|
|
481 fadeVal2 = dmLerpSCurveClamp(&fadeLerp, dt - 1000);
|
|
482 else
|
|
483 if (dt > 3000)
|
|
484 fadeVal2 = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
|
|
485 else
|
|
486 fadeVal2 = 255;
|
|
487 }
|
|
488 else
|
|
489 fadeVal2 = 0;
|
0
|
490
|
3
|
491 dmScaledBlitSurface32to32TransparentGA(logo,
|
|
492 dmCX(engine, 0.10),
|
|
493 dmCY(engine, 0.2),
|
|
494 dmQX(engine, logo, 1),
|
|
495 dmQY(engine, logo, 1),
|
|
496 engine->screen, fadeVal);
|
|
497
|
|
498 dmScaledBlitSurface32to32TransparentGA(logo2,
|
|
499 dmCX(engine, 0.6),
|
|
500 dmCY(engine, 0.6),
|
|
501 dmQX(engine, logo2, 1),
|
|
502 dmQY(engine, logo2, 1),
|
|
503 engine->screen, fadeVal2);
|
|
504 }
|
|
505
|
0
|
506
|
13
|
507 //
|
9
|
508 // Skrolleri
|
13
|
509 //
|
|
510 if (t > 3)
|
9
|
511 {
|
|
512 int tt = engineGetTime(engine, 2);
|
|
513 static DMScaledBlitFunc cblit, qblit;
|
|
514 static BOOL nollattu = FALSE;
|
|
515 if (!nollattu)
|
|
516 {
|
|
517 cblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_TRANSPARENT);
|
|
518 qblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_SATURATE);
|
|
519 }
|
|
520
|
|
521 size_t txtLen = teksti->rawSize - 1;
|
|
522 Uint8 *txtData = teksti->rawData;
|
|
523 int fwidth = font->width * 2 + 2;
|
|
524 int xc, offs, scrollTime = tt / 10,
|
|
525 scrWidth = engine->screen->w / (dmQX(engine, font->glyphs[65], 1) + dmCX(engine, 0.001));
|
|
526
|
|
527 for (xc = offs = 0; offs < scrWidth; offs++)
|
|
528 {
|
|
529 int ch = txtData[((scrollTime / fwidth) + offs) % txtLen];
|
|
530 SDL_Surface *glyph = dmGetBMGlyph(font, my_toupper(ch));
|
|
531 if (glyph != NULL)
|
|
532 {
|
|
533 float mt = (offs * 20 + tt) / 100.0f;
|
|
534 int dx = xc - (scrollTime % fwidth),
|
|
535 dy = dmCY(engine, 0.8 + sin(mt) * 0.05),
|
|
536 dw = glyph->w * 2 * (1.0f + sin(mt) * 0.1f),
|
|
537 dh = glyph->h * 2 * (1.0f + cos(mt) * 0.2f);
|
|
538
|
|
539 cblit(glyph, dx+1, dy+1, dw+1, dh+1, engine->screen);
|
|
540 qblit(glyph, dx, dy, dw, dh, engine->screen);
|
|
541 }
|
|
542 xc += fwidth;
|
|
543 }
|
|
544 }
|
|
545
|
13
|
546 //
|
21
|
547 // Alku- ja Loppufeidi
|
13
|
548 //
|
9
|
549 {
|
21
|
550 static DMLerpContext fadeLerp, fadeLerp2;
|
9
|
551 static SDL_Surface *feidi = NULL;
|
|
552 static BOOL nollattu = FALSE;
|
|
553 if (!nollattu)
|
|
554 {
|
|
555 engineGetResImage(engine, feidi, "feidi.png");
|
21
|
556 dmLerpInit(&fadeLerp, 255, 0, 3000);
|
|
557 dmLerpInit(&fadeLerp2, 0, 255, 5000);
|
9
|
558 }
|
|
559
|
21
|
560 int fadeVal = -1;
|
|
561 if (t < 5)
|
|
562 fadeVal = dmLerpSCurveClamp(&fadeLerp, engineGetTime(engine, 0));
|
|
563 else
|
|
564 if (t > 70)
|
|
565 fadeVal = dmLerpSCurveClamp(&fadeLerp2, engineGetTime(engine, 70));
|
|
566
|
|
567 if (fadeVal >= 0)
|
|
568 {
|
|
569 dmScaledBlitSurface32to32TransparentGA(feidi,
|
|
570 0,
|
|
571 0,
|
|
572 dmQX(engine, feidi, 1),
|
|
573 dmQY(engine, feidi, 1),
|
|
574 engine->screen,
|
|
575 fadeVal);
|
|
576 }
|
9
|
577 }
|
|
578
|
13
|
579 //
|
|
580 // Maskaus
|
|
581 //
|
|
582 {
|
|
583 static DMScaledBlitFunc cblit = NULL;
|
|
584 static SDL_Surface *maski = NULL;
|
|
585 static BOOL nollattu = FALSE;
|
|
586
|
|
587 if (!nollattu)
|
|
588 {
|
|
589 engineGetResImage(engine, maski, "maski.png");
|
|
590 cblit = dmGetScaledBlitFunc(maski->format, engine->screen->format, DMD_TRANSPARENT);
|
|
591 }
|
|
592
|
|
593 cblit(maski,
|
|
594 0, 0,
|
|
595 dmQX(engine, maski, 1),
|
|
596 dmQY(engine, maski, 1),
|
|
597 engine->screen);
|
|
598 }
|
|
599
|
|
600
|
9
|
601 if (t > 75)
|
5
|
602 return 1;
|
|
603 else
|
|
604 return DMERR_OK;
|
0
|
605 }
|