annotate demo.c @ 5:dcec61df1633

More work.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 22 May 2015 01:58:55 +0300
parents 37b33851cfbb
children dde02bd75871
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include "dmengine.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #include "dmtext.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 #include "dmfft.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 #include "dmvecmat.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 #include <math.h>
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 static int demoInit(DMEngineData *engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 static void demoShutdown(DMEngineData *engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 static int demoRender(DMEngineData *engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 int demoPreInit(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 dmInitProg("bussi",
2
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
15 "Bussi by AnCiat ProDucTionz",
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 "0", "ENGINE INITTIALISSSIZING!!!!!", NULL);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 engine->optPackFilename = "bussi.dat";
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 engine->optDataPath = NULL;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 engine->optResFlags = DRF_USE_PACK | DRF_PRELOAD_RES | DRF_USE_STDIO;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 engine->optAudioSetup = DM_ASETUP_JSS;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 engine->optVidSetup = DM_VSETUP_ASPECT;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 engine->optVidWidth = 640;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 engine->optVidHeight = 480;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 engine->optVidDepth = 32;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 engine->optVFlags = SDL_SWSURFACE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 engine->demoInit = demoInit;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 engine->demoRender = demoRender;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 engine->demoShutdown = demoShutdown;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 return DMERR_OK;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #define FFT_SIZE 128
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 DMFFTContext fft;
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
40 DMResource *teksti = NULL;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
41 DMBitmapFont *font = NULL;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
42
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
43 typedef struct
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
44 {
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
45 int layer;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
46 char *filename;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
47 SDL_Surface *img;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
48 } DMItemDef;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
49
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
50
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
51 DMItemDef items[] =
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
52 {
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
53 { 1, "viitta.png", NULL },
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
54 { 1, "puu_pv_1.png", NULL },
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
55 { 0, "puu_pv_2.png", NULL },
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
56 };
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
57
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
58 static const int nitems = sizeof(items) / sizeof(items[0]);
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
59
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
60
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 static int demoInit(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 int i;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 JSSModule *mod = NULL;
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
67 SDL_Color pal[DMFONT_NPALETTE];
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
68 DMResource *tmp;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
70 // FFT init
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 dmInitializeFFT(&fft, FFT_SIZE);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
73 // Skrolliteksti
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
74 if ((teksti = engineFindResource(engine, "skrolli.txt")) == NULL)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
75 return DMERR_INIT_FAIL;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
76
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
77 // Skrollerin fontti
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
78 if ((tmp = engineFindResource(engine, "fontti.dmf")) == NULL)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
79 return DMERR_INIT_FAIL;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
80
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
81 if ((i = dmLoadBitmapFont(tmp, &font)) != DMERR_OK)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
82 return i;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
83
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
84 for (i = 0; i < DMFONT_NPALETTE; i++)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
85 {
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
86 pal[i].r = pal[i].g = pal[i].b = i * 8;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
87 pal[i].unused = i > 0 ? 255 : 0;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
88 }
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
89
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
90 dmSetBitmapFontPalette(font, pal, 0, DMFONT_NPALETTE);
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
91
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
92 // Musa
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 engineGetResModule(engine, mod, "pas2.xm");
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 if ((i = jssConvertModuleForPlaying(mod)) != DMERR_OK)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 dmErrorMsg("Could not convert module for playing, %d: %s\n",
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 i, dmErrorStr(i));
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 return DMERR_INIT_FAIL;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 jvmSetCallback(engine->jssDev, jmpExec, engine->jssPlr);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 jmpSetModule(engine->jssPlr, mod);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 jmpPlayOrder(engine->jssPlr, 0);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 jvmSetGlobalVol(engine->jssDev, 55);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
107
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
108 // Osa kuvadatasta
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
109 for (i = 0; i < nitems; i++)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
110 engineGetResImage(engine, items[i].img, items[i].filename);
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
111
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 // Jne
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 srand(15);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 return DMERR_OK;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 static void demoShutdown(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 (void) engine;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 dmEndFFT(&fft);
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
123 dmFreeBitmapFont(font);
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 static inline float dmCX(DMEngineData *engine, const float x)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 return (x * engine->screen->w);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 static inline float dmCY(DMEngineData *engine, const float y)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 return (y * engine->screen->h);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 static inline float dmQX(DMEngineData *engine, SDL_Surface *img, const float x)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 return engine->optVidNative ? (img->w * x) : (img->w * engine->screen->w * x) / 640.0f;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 static inline float dmQY(DMEngineData *engine, SDL_Surface *img, const float y)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 return engine->optVidNative ? (img->h * y) : (img->h * engine->screen->h * y) / 480.0f;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 #define DM_RADIAL_BLUR(YC, XC) \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 DMVector p1 = { xc, yc, 0, 0 }, p2 = { cx, cy, 0, 0 }, v; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 dm_vector_sub_r(&v, &p2, &p1); \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 dm_vector_scale(&v, scale); \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 dm_vector_add(&v, &p1); \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 if (v.y YC || v.x XC) continue; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 DMColor *dp = pix + xc, \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 *q = ((DMColor *)img->pixels) + ((int)(v.y) * pitch) + (int)v.x; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 dp->r = (q->r + dp->r) / 2; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 dp->g = (q->g + dp->g) / 2; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 dp->b = (q->b + dp->b) / 2;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 void dmRadialBlur(SDL_Surface *img, const int cx, const int cy, const DMFloat scale)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 const int pitch = img->pitch / sizeof(DMColor);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 int xc, yc;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 #pragma omp parallel private(yc, xc) shared(img)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 #pragma omp sections nowait
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 for (yc = cy; yc >= 0; yc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 for (xc = cx + 1; xc < img->w; xc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 DM_RADIAL_BLUR(< 0, >= img->w)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 for (yc = cy; yc >= 0; yc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 for (xc = cx; xc > 0; xc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 DM_RADIAL_BLUR(< 0, < 0)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 for (yc = cy + 1; yc < img->h; yc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 for (xc = cx; xc > 0; xc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 DM_RADIAL_BLUR(>= img->h, < 0)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 for (yc = cy + 1; yc < img->h; yc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 for (xc = cx + 1; xc < img->w; xc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 DM_RADIAL_BLUR(>= img->h, >= img->w)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 static int demoRender(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 float t = engineGetTimeDT(engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
222 //
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 // Do FFT
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
224 //
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 DMFFTType fftPow = 0;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 BOOL fftOK = FALSE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 static DMFFTType fftAmp[FFT_SIZE / 2];
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 static DMFFTType fftData[FFT_SIZE];
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 dmMutexLock(engine->audioStreamMutex);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231 if (engine->audioStreamBuf != 0 && engine->audioStreamLen > FFT_SIZE)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 int i;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 Sint16 *buf = (Sint16 *) engine->audioStreamBuf;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 for (i = 0; i < FFT_SIZE; i++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 fftData[i] = *buf;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 buf += 2;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 fftOK = TRUE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 dmMutexUnlock(engine->audioStreamMutex);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 if (fftOK)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 dmRealFFT(&fft, fftData);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 dmConvertFFTtoPowerAndSum(&fft, fftData, fftAmp, 1.0, &fftPow, 0.00004f);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
250
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
251 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
252 // Taustaskrolli
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
253 //
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 {
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
255 static SDL_Surface *tausta = NULL,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
256 *aurinko = NULL,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
257 *bussi = NULL,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
258 *rengas = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
259
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
260 static DMScaledBlitFunc cblit = NULL, ablit = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
261 static BOOL nollattu = FALSE;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
262 static DMLerpContext fadeLerp, fadeLerp2, fadeLerp3;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
263
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
264 if (!nollattu)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
265 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
266 dmLerpInit(&fadeLerp, 0, 255, 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
267 dmLerpInit(&fadeLerp2, 0, 255, 4000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
268 dmLerpInit(&fadeLerp3, 0, 1.2, 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
269 engineGetResImage(engine, tausta, "tausta_pv.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
270 engineGetResImage(engine, aurinko, "aurinko.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
271 engineGetResImage(engine, bussi, "auto.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
272 engineGetResImage(engine, rengas, "rengas.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
273 cblit = dmGetScaledBlitFunc(tausta->format, engine->screen->format, DMD_NONE);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
274 ablit = dmGetScaledBlitFunc(bussi->format, engine->screen->format, DMD_TRANSPARENT);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
275 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
276
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
277 int x1 = - ((int)dmQX(engine, tausta, t * 0.2) % tausta->w),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
278 x2 = x1 + tausta->w;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
279
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
280 int fadeVal;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
281 if (t < 3 || t > 64)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
282 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
283 if (t < 3)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
284 fadeVal = dmLerpSCurveClamp(&fadeLerp, engineGetTime(engine, 0));
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
285 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
286 fadeVal = dmLerpSCurveClamp(&fadeLerp2, engineGetTime(engine, 64));
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
287
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
288 dmClearSurface(engine->screen, dmMapRGB(engine->screen, 0,0,0));
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
289 dmScaledBlitSurface32to32TransparentGA(tausta, x1, 0, tausta->w, tausta->h, engine->screen, fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
290 dmScaledBlitSurface32to32TransparentGA(tausta, x2, 0, tausta->w, tausta->h, engine->screen, fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
291 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
292 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
293 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
294 fadeVal = 255;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
295 cblit(tausta, x1, 0, tausta->w, tausta->h, engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
296 cblit(tausta, x2, 0, tausta->w, tausta->h, engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
297 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
298
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
299 float qm = sin(t * 0.1 + fftPow * 5) * 15, qm2 = qm*2;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
300 dmScaledBlitSurface32to32TransparentGA(aurinko,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
301 dmCX(engine, 0.8 - dmLerpSCurveClamp(&fadeLerp3, engineGetTime(engine, 0) * 0.01) * 0.3 ) - qm,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
302 dmCY(engine, 0.05) - qm,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
303 aurinko->w + qm2, aurinko->h + qm2,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
304 engine->screen, fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
305
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
306
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
307 // Bussi ajaa sisään
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
308 if (t > 14)
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
309 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
310 float
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
311 dt = engineGetTime(engine, 14),
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
312 ajelu = dmLerpSCurveClamp(&fadeLerp3, dt),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
313 xc = dmCX(engine, -1 + ajelu),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
314 yc = dmCY(engine, 0.35 + sin(t * 10) * 0.005),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
315 yc2 = yc + dmQY(engine, bussi, 0.7) + dmCY(engine, sin(t * 20) * 0.001);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
316
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
317 ablit(rengas, xc + dmQX(engine, bussi, 0.07), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
318 ablit(rengas, xc + dmQX(engine, bussi, 0.80), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
319 ablit(bussi, xc, yc, dmQX(engine, bussi, 1), dmQY(engine, bussi, 1), engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
320 }
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
321
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
322
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
323 // Puut ym. liikennejutut
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
324 if (t > 10)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
325 {
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
326 }
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
327 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
328
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
329 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
330 // AP logo
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
331 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
332 if (t > 4 && t < 8)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
333 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
334 int dt = engineGetTime(engine, 4);
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 static DMLerpContext fadeLerp;
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
336 static SDL_Surface *logo = NULL;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 static BOOL nollattu = FALSE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 if (!nollattu)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 {
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
340 dmLerpInit(&fadeLerp, 0, 255, 1000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
341 engineGetResImage(engine, logo, "ap.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
342 nollattu = TRUE;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
343 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
344
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
345 int fadeVal;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
346 if (dt < 1000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
347 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
348 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
349 if (dt > 3000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
350 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
351 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
352 fadeVal = 255;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
354 dmScaledBlitSurface32to32TransparentGA(logo,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
355 dmQX(engine, logo, 0.2),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
356 dmQY(engine, logo, 0.3),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
357 dmQX(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
358 dmQY(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
359 engine->screen, fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
360 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
361
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
362 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
363 // BUSSI logo
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
364 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
365 if (t > 10 && t < 14)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
366 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
367 int dt = engineGetTime(engine, 10);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
368 static DMLerpContext fadeLerp;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
369 static SDL_Surface *logo = NULL, *logo2 = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
370 static BOOL nollattu = FALSE;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
371 if (!nollattu)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
372 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
373 dmLerpInit(&fadeLerp, 0, 255, 1000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
374 engineGetResImage(engine, logo, "bussi_logo.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
375 engineGetResImage(engine, logo2, "dosa.png");
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 nollattu = TRUE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
379 int fadeVal, fadeVal2;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
380 if (dt < 1000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
381 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
382 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
383 if (dt > 3000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
384 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
385 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
386 fadeVal = 255;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
387
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
388 if (dt > 1000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
389 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
390 if (dt < 2000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
391 fadeVal2 = dmLerpSCurveClamp(&fadeLerp, dt - 1000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
392 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
393 if (dt > 3000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
394 fadeVal2 = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
395 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
396 fadeVal2 = 255;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
397 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
398 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
399 fadeVal2 = 0;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
401 dmScaledBlitSurface32to32TransparentGA(logo,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
402 dmCX(engine, 0.10),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
403 dmCY(engine, 0.2),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
404 dmQX(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
405 dmQY(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
406 engine->screen, fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
407
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
408 dmScaledBlitSurface32to32TransparentGA(logo2,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
409 dmCX(engine, 0.6),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
410 dmCY(engine, 0.6),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
411 dmQX(engine, logo2, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
412 dmQY(engine, logo2, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
413 engine->screen, fadeVal2);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
414 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
415
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
417 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
418 static DMScaledBlitFunc cblit = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
419 static SDL_Surface *maski = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
420 static BOOL nollattu = FALSE;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
421
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
422 if (!nollattu)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
423 {
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
424 engineGetResImage(engine, maski, "maski.png");
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
425 cblit = dmGetScaledBlitFunc(maski->format, engine->screen->format, DMD_TRANSPARENT);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
426 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
427
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
428 cblit(maski,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
429 0, 0,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
430 dmQX(engine, maski, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
431 dmQY(engine, maski, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
432 engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
433 }
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
434
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
435 if (t > 70)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
436 return 1;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
437 else
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
438 return DMERR_OK;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 }