annotate demo.c @ 16:80634079f275

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