Mercurial > hg > demos > bussi
annotate demo.c @ 37:dc514b8d8cdd default tip
s/EXEEXT/BINEXT/g
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Dec 2019 18:22:11 +0200 |
parents | 0b74381be601 |
children |
rev | line source |
---|---|
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"; | |
27 | 19 engine->optResFlags = DRF_USE_PACK | DRF_PRELOAD_RES |
20 #ifdef DM_USE_STDIO | |
21 | DRF_USE_STDIO | |
22 #endif | |
23 ; | |
0 | 24 |
25 engine->optAudioSetup = DM_ASETUP_JSS; | |
26 engine->optVidSetup = DM_VSETUP_ASPECT; | |
27 engine->optVidWidth = 640; | |
28 engine->optVidHeight = 480; | |
29 engine->optVidDepth = 32; | |
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 | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
65 static DMItemDef items[] = |
13 | 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; | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
95 |
5 | 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; | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
102 pal[i].a = i > 0 ? 255 : 0; |
5 | 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 } | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
116 |
0 | 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 | |
34 | 148 static inline float dmCY(const DMEngineData *engine, const float y) |
0 | 149 { |
150 return (y * engine->screen->h); | |
151 } | |
152 | |
153 | |
34 | 154 static inline float dmQX(const DMEngineData *engine, const SDL_Surface *img, const float x) |
0 | 155 { |
156 return engine->optVidNative ? (img->w * x) : (img->w * engine->screen->w * x) / 640.0f; | |
157 } | |
158 | |
159 | |
34 | 160 static inline float dmQY(const DMEngineData *engine, const SDL_Surface *img, const float y) |
0 | 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) | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
206 } |
0 | 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) | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
216 } |
0 | 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) | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
226 } |
0 | 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 |
21 | 343 cblit(tausta, x1, 0, dmQX(engine, tausta, 1), dmQY(engine, tausta, 1), engine->screen); |
344 cblit(tausta, x2, 0, dmQX(engine, tausta, 1), dmQY(engine, tausta, 1), engine->screen); | |
3 | 345 |
13 | 346 float qm = sin(t * 0.1 + fftPow * 5) * 0.05, qm2 = qm * 10; |
21 | 347 ablit(aurinko, |
13 | 348 dmCX(engine, 0.8 - dmLerpSCurveClamp(&fadeLerp3, engineGetTime(engine, 0) * 0.01) * 0.3 - qm), |
349 dmCY(engine, 0.05 - qm), | |
350 dmQX(engine, aurinko, 1 + qm2), | |
351 dmQY(engine, aurinko, 1 + qm2), | |
21 | 352 engine->screen); |
3 | 353 |
13 | 354 // Puut ym. liikennejutut |
355 #define DM_MAX_MITEMS 16 | |
356 static DMFooItemDef mitems[DM_MAX_MITEMS]; | |
16 | 357 if (t > 6) |
13 | 358 { |
16 | 359 float dt = (t - 6); |
13 | 360 static BOOL nollattu = FALSE; |
361 int i; | |
362 | |
363 if (!nollattu) | |
364 { | |
365 memset(mitems, 0, sizeof(mitems)); | |
366 nollattu = TRUE; | |
367 } | |
368 | |
369 for (i = 0; i < DM_MAX_MITEMS; i++) | |
370 { | |
371 DMFooItemDef *item = &mitems[i]; | |
372 if (!item->enabled && (item->ref = dmGetItem((int) t * 10 + 1)) != NULL) | |
373 { | |
374 item->enabled = TRUE; | |
375 item->ref->count++; | |
376 item->xtime = dt; | |
377 item->ypos = item->ref->ypos + sin(dt) * 0.001f; | |
378 } | |
379 } | |
380 for (i = 0; i < DM_MAX_MITEMS; i++) | |
381 { | |
382 DMFooItemDef *item = &mitems[i]; | |
383 if (item->enabled) | |
384 { | |
385 float xpos = (dt - item->xtime) * item->ref->speed; | |
386 if (xpos > 1.5) | |
387 { | |
388 item->enabled = FALSE; | |
389 item->ref->count--; | |
390 } | |
391 else | |
392 item->xpos = 1 - xpos; | |
393 } | |
394 } | |
395 } | |
396 | |
397 dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 0); | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
398 |
3 | 399 // Bussi ajaa sisään |
5 | 400 if (t > 14) |
3 | 401 { |
402 float | |
5 | 403 dt = engineGetTime(engine, 14), |
3 | 404 ajelu = dmLerpSCurveClamp(&fadeLerp3, dt), |
405 xc = dmCX(engine, -1 + ajelu), | |
13 | 406 yc = dmCY(engine, 0.38 + sin(t * 10) * 0.005), |
3 | 407 yc2 = yc + dmQY(engine, bussi, 0.7) + dmCY(engine, sin(t * 20) * 0.001); |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
408 |
3 | 409 ablit(rengas, xc + dmQX(engine, bussi, 0.07), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen); |
410 ablit(rengas, xc + dmQX(engine, bussi, 0.80), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen); | |
411 ablit(bussi, xc, yc, dmQX(engine, bussi, 1), dmQY(engine, bussi, 1), engine->screen); | |
412 } | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
413 |
5 | 414 |
13 | 415 dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 1); |
3 | 416 } |
417 | |
418 // | |
419 // AP logo | |
420 // | |
421 if (t > 4 && t < 8) | |
422 { | |
423 int dt = engineGetTime(engine, 4); | |
0 | 424 static DMLerpContext fadeLerp; |
3 | 425 static SDL_Surface *logo = NULL; |
0 | 426 static BOOL nollattu = FALSE; |
427 if (!nollattu) | |
428 { | |
3 | 429 dmLerpInit(&fadeLerp, 0, 255, 1000); |
430 engineGetResImage(engine, logo, "ap.png"); | |
431 nollattu = TRUE; | |
432 } | |
433 | |
434 int fadeVal; | |
435 if (dt < 1000) | |
436 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt); | |
437 else | |
438 if (dt > 3000) | |
439 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000); | |
440 else | |
441 fadeVal = 255; | |
0 | 442 |
3 | 443 dmScaledBlitSurface32to32TransparentGA(logo, |
444 dmQX(engine, logo, 0.2), | |
445 dmQY(engine, logo, 0.3), | |
446 dmQX(engine, logo, 1), | |
447 dmQY(engine, logo, 1), | |
448 engine->screen, fadeVal); | |
449 } | |
450 | |
451 // | |
452 // BUSSI logo | |
453 // | |
454 if (t > 10 && t < 14) | |
455 { | |
456 int dt = engineGetTime(engine, 10); | |
457 static DMLerpContext fadeLerp; | |
458 static SDL_Surface *logo = NULL, *logo2 = NULL; | |
459 static BOOL nollattu = FALSE; | |
460 if (!nollattu) | |
461 { | |
462 dmLerpInit(&fadeLerp, 0, 255, 1000); | |
463 engineGetResImage(engine, logo, "bussi_logo.png"); | |
464 engineGetResImage(engine, logo2, "dosa.png"); | |
0 | 465 nollattu = TRUE; |
466 } | |
467 | |
3 | 468 int fadeVal, fadeVal2; |
469 if (dt < 1000) | |
470 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt); | |
471 else | |
472 if (dt > 3000) | |
473 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000); | |
474 else | |
475 fadeVal = 255; | |
476 | |
477 if (dt > 1000) | |
478 { | |
479 if (dt < 2000) | |
480 fadeVal2 = dmLerpSCurveClamp(&fadeLerp, dt - 1000); | |
481 else | |
482 if (dt > 3000) | |
483 fadeVal2 = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000); | |
484 else | |
485 fadeVal2 = 255; | |
486 } | |
487 else | |
488 fadeVal2 = 0; | |
0 | 489 |
3 | 490 dmScaledBlitSurface32to32TransparentGA(logo, |
491 dmCX(engine, 0.10), | |
492 dmCY(engine, 0.2), | |
493 dmQX(engine, logo, 1), | |
494 dmQY(engine, logo, 1), | |
495 engine->screen, fadeVal); | |
496 | |
497 dmScaledBlitSurface32to32TransparentGA(logo2, | |
498 dmCX(engine, 0.6), | |
499 dmCY(engine, 0.6), | |
500 dmQX(engine, logo2, 1), | |
501 dmQY(engine, logo2, 1), | |
502 engine->screen, fadeVal2); | |
503 } | |
504 | |
0 | 505 |
13 | 506 // |
9 | 507 // Skrolleri |
13 | 508 // |
509 if (t > 3) | |
9 | 510 { |
511 int tt = engineGetTime(engine, 2); | |
512 static DMScaledBlitFunc cblit, qblit; | |
513 static BOOL nollattu = FALSE; | |
514 if (!nollattu) | |
515 { | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
516 cblit = dmGetScaledBlitFunc(font->glyphs->format, engine->screen->format, DMD_TRANSPARENT); |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
517 qblit = dmGetScaledBlitFunc(font->glyphs->format, engine->screen->format, DMD_SATURATE); |
9 | 518 } |
519 | |
520 size_t txtLen = teksti->rawSize - 1; | |
521 Uint8 *txtData = teksti->rawData; | |
522 int fwidth = font->width * 2 + 2; | |
523 int xc, offs, scrollTime = tt / 10, | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
524 // v-- bug |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
525 scrWidth = engine->screen->w / (dmQX(engine, font->glyphs, 1) + dmCX(engine, 0.001)); |
9 | 526 |
527 for (xc = offs = 0; offs < scrWidth; offs++) | |
528 { | |
36
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
529 const int ch = txtData[((scrollTime / fwidth) + offs) % txtLen]; |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
530 SDL_Surface glyph; |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
531 |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
532 dmGetBMGlyph(&glyph, font, my_toupper(ch)); |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
533 |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
534 float mt = (offs * 20 + tt) / 100.0f; |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
535 int dx = xc - (scrollTime % fwidth), |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
536 dy = dmCY(engine, 0.8 + sin(mt) * 0.05), |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
537 dw = glyph.w * 2 * (1.0f + sin(mt) * 0.1f), |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
538 dh = glyph.h * 2 * (1.0f + cos(mt) * 0.2f); |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
539 |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
540 cblit(&glyph, dx+1, dy+1, dw+1, dh+1, engine->screen); |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
541 qblit(&glyph, dx, dy, dw, dh, engine->screen); |
0b74381be601
Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents:
34
diff
changeset
|
542 |
9 | 543 xc += fwidth; |
544 } | |
545 } | |
546 | |
13 | 547 // |
21 | 548 // Alku- ja Loppufeidi |
13 | 549 // |
9 | 550 { |
21 | 551 static DMLerpContext fadeLerp, fadeLerp2; |
9 | 552 static SDL_Surface *feidi = NULL; |
553 static BOOL nollattu = FALSE; | |
554 if (!nollattu) | |
555 { | |
556 engineGetResImage(engine, feidi, "feidi.png"); | |
21 | 557 dmLerpInit(&fadeLerp, 255, 0, 3000); |
558 dmLerpInit(&fadeLerp2, 0, 255, 5000); | |
9 | 559 } |
560 | |
21 | 561 int fadeVal = -1; |
562 if (t < 5) | |
563 fadeVal = dmLerpSCurveClamp(&fadeLerp, engineGetTime(engine, 0)); | |
564 else | |
565 if (t > 70) | |
566 fadeVal = dmLerpSCurveClamp(&fadeLerp2, engineGetTime(engine, 70)); | |
567 | |
568 if (fadeVal >= 0) | |
569 { | |
570 dmScaledBlitSurface32to32TransparentGA(feidi, | |
571 0, | |
572 0, | |
573 dmQX(engine, feidi, 1), | |
574 dmQY(engine, feidi, 1), | |
575 engine->screen, | |
576 fadeVal); | |
577 } | |
9 | 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 } |