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