annotate demo.c @ 19:da7ac3f7d014

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