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