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