annotate demo.c @ 13:952e27204992

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