Debian Codegraph @

plugins/actor/oinksie/scene.c

raw
1 /* Libvisual-plugins - Standard plugins for libvisual
2 *
3 * Copyright (C) 2002, 2003, 2004, 2005, 2006 Dennis Smit <[email protected]>
4 *
5 * Authors: Dennis Smit <[email protected]>
6 *
7 * $Id: scene.c,v 1.10 2006/01/22 13:25:26 synap Exp $
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include "oinksie.h"
25 #include "common.h"
26 #include "screen.h"
27 #include "table.h"
28 #include "gfx-palette.h"
29 #include "gfx-scope.h"
30 #include "gfx-blur.h"
31 #include "gfx-misc.h"
32 #include "gfx-analyzer.h"
33 #include "gfx-background.h"
34 #include "oink-config.h"
35 #include "misc.h"
36 #include "scene.h"
37
38 void _oink_scene_scope_special (OinksiePrivate *priv, uint8_t *buf)
39 {
40 if (visual_random_context_int_range (priv->rcontext, 0, 500) == 42)
41 {
42 priv->scene.scopestereo_adder = priv->screen_halfheight / 100;
43 priv->scene.scopestereo_start = 1 - priv->scene.scopestereo_start;
44 priv->scene.scopestereo_space = priv->screen_halfheight + 10;
45
46 if (priv->scene.scopestereo_start == TRUE)
47 priv->scene.scopestereo_enabled = TRUE;
48 }
49
50 if (priv->scene.scopestereo_enabled && priv->config.scopemode != 2 && priv->config.scopemode != 6)
51 {
52 if (priv->scene.scopestereo_start == TRUE)
53 {
54 priv->scene.scopestereo_space -= priv->scene.scopestereo_adder;
55 _oink_gfx_scope_stereo (priv, buf, 235, 235 - (priv->audio.bass * 2), priv->screen_height / 6, priv->scene.scopestereo_space, 0);
56
57 if (priv->scene.scopestereo_space < priv->screen_halfheight)
58 priv->scene.scopestereo_start = FALSE;
59 }
60 else
61 {
62 _oink_gfx_scope_stereo (priv, buf, 235, 235 - (priv->audio.bass * 2), priv->screen_height / 6, priv->screen_halfheight, 0);
63 }
64 }
65 }
66
67 void _oink_scene_background_special (OinksiePrivate *priv, uint8_t *buf)
68 {
69 if (priv->audio.beat == TRUE)
70 {
71 if (visual_random_context_int_range (priv->rcontext, 0, 140) == 42 && priv->scene.ball_enabled == FALSE)
72 {
73 priv->scene.ball_enabled = TRUE;
74
75 priv->scene.ball_xstart = visual_random_context_int_range (priv->rcontext, 0, priv->screen_width - 1);
76 priv->scene.ball_ystart = priv->screen_height;
77
78 priv->scene.ball_distance = _oink_line_length (priv->screen_halfheight, priv->scene.ball_ystart,
79 priv->screen_halfwidth, priv->scene.ball_xstart);
80
81 /* FIXME use fps data instead of '25' here */
82 priv->scene.ball_adder = (priv->scene.ball_distance / (25 + 1)) + 1;
83 }
84
85 if (visual_random_context_int_range (priv->rcontext, 0, 5) == 4)
86 priv->scene.circles_direction = 1 - priv->scene.circles_direction;
87 }
88
89 if (priv->scene.circles_direction == 0)
90 priv->scene.circles_turn += priv->audio.bass * 4;
91 else
92 priv->scene.circles_turn -= priv->audio.bass * 4;
93
94 if (visual_random_context_int_range (priv->rcontext, 0, 450) == 42)
95 {
96 priv->scene.ballsine_enabled = 1 - priv->scene.ballsine_enabled;
97 priv->scene.ballsine_infade = 0;
98 }
99
100 if (visual_random_context_int_range (priv->rcontext, 0, 160) == 42)
101 priv->scene.ballsine_direction = 1 - priv->scene.ballsine_direction;
102
103 if (priv->scene.ball_enabled == TRUE)
104 {
105 _oink_gfx_background_ball_shooting (priv, buf, 250, priv->scene.ball_distance,
106 priv->scene.ball_xstart, priv->scene.ball_ystart,
107 priv->screen_halfwidth, priv->screen_halfheight);
108
109 priv->scene.ball_distance -= priv->scene.ball_adder;
110
111 if (priv->scene.ball_distance < 0)
112 {
113 priv->scene.ball_enabled = FALSE;
114 }
115 }
116
117 if (priv->scene.circles_enabled == TRUE)
118 {
119 if (priv->audio.energy > ((priv->screen_xysmallest / 10) + 2) / 2)
120 {
121 if (priv->audio.energy > (priv->screen_xysmallest / 2) - ((priv->screen_xysmallest / 10) + 2))
122 {
123 priv->scene.ball_spread = (priv->screen_xysmallest / 2) - ((priv->screen_xysmallest / 10) + 2);
124 }
125 else
126 {
127 if (priv->screen_xysmallest / 2 > 100)
128 {
129 priv->scene.ball_spread = (int) ((float) ((priv->audio.energy * (float)
130 (priv->screen_xysmallest / 100.00)) / 2))
131 - ((priv->screen_xysmallest / 10) + 2);
132 }
133 else
134 {
135 priv->scene.ball_spread = priv->audio.energy;
136 }
137 }
138 }
139 else
140 {
141 priv->scene.ball_spread = (priv->screen_xysmallest / 10) + 2;
142 }
143
144 _oink_gfx_background_circles_filled (priv, buf, 250, priv->screen_xysmallest / 10, 5, priv->scene.ball_spread,
145 priv->scene.circles_turn, priv->screen_halfwidth, priv->screen_halfheight);
146
147 }
148 /*
149 if (priv->scene.ballsine_enabled == TRUE)
150 {
151 if (priv->audio.beat == 1 && visual_random_context_int_range (priv->rcontext, 0, 42) == 0)
152 priv->scene.ballsine_infade = 0;
153
154 if (priv->scene.ballsine_infade < 240)
155 priv->scene.ballsine_infade += 10;
156
157 _oink_gfx_background_circles_sine (priv, priv->drawbuf, priv->scene.ballsine_infade,
158 priv->scene.ballsine_rotate, priv->scene.ballsine_scroll, 80, 50);
159
160 if (priv->scene.ballsine_direction == 0)
161 {
162 priv->scene.ballsine_scroll += ((priv->audio.energy >> 3) + 1);
163 priv->scene.ballsine_rotate += ((priv->audio.energy >> 3) + 1);
164 }
165 else
166 {
167 priv->scene.ballsine_scroll -= ((priv->audio.energy >> 3) + 1);
168 priv->scene.ballsine_rotate -= ((priv->audio.energy >> 3) + 1);
169 }
170 }
171 */
172 }
173
174 void _oink_scene_background_select (OinksiePrivate *priv, uint8_t *buf)
175 {
176 if (visual_random_context_int_range (priv->rcontext, 0, 5) == 4 && priv->audio.beat == TRUE)
177 priv->scene.floaters_direction = 1 - priv->scene.floaters_direction;
178
179 if (priv->scene.floaters_direction == 0)
180 priv->scene.floaters_turn += priv->audio.bass * 4;
181 else
182 priv->scene.floaters_turn -= priv->audio.bass * 4;
183
184
185 switch (priv->config.backgroundmode)
186 {
187 case 0:
188 _oink_gfx_background_floaters (priv, buf, 245, 5, 6, 0, priv->scene.floaters_turn,
189 priv->screen_height - (priv->screen_height / 4), 0, priv->audio.energy);
190 break;
191
192 case 1:
193 _oink_gfx_background_floaters (priv, buf, 245, 10, 4, 0, priv->scene.floaters_turn * 2,
194 priv->screen_halfheight, 0, priv->audio.energy);
195
196 _oink_gfx_background_floaters (priv, buf, 245, 5, 6, 0, priv->scene.floaters_turn,
197 priv->screen_height - (priv->screen_height / 4), 0, priv->audio.energy);
198 break;
199
200 /* case 2:
201 _oink_gfx_background_circles_star (priv, priv->drawbuf, 242,
202 priv->screen_xysmallest / 4,
203 5, 6, priv->audio.bass * 3, priv->audio.tripple * 30,
204 priv->screen_halfwidth, priv->screen_halfheight);
205 break;
206 */
207 default:
208 break;
209 }
210
211 }
212
213 void _oink_scene_blur_select (OinksiePrivate *priv, uint8_t *buf)
214 {
215 switch (priv->config.blurmode)
216 {
217 case 0:
218 _oink_gfx_blur_midstrange (priv, buf);
219 break;
220
221 case 1:
222 _oink_gfx_blur_middle (priv, buf);
223 break;
224
225 case 2:
226 _oink_gfx_blur_midstrange (priv, buf);
227 break;
228
229 default:
230 _oink_gfx_blur_midstrange (priv, buf);
231 break;
232 }
233 }
234
235 void _oink_scene_scope_select (OinksiePrivate *priv, uint8_t *buf, int color, int height)
236 {
237 switch (priv->config.scopemode)
238 {
239 case 0:
240 case 1:
241 _oink_gfx_scope_normal (priv, buf, color, height);
242 break;
243
244 case 2:
245 _oink_gfx_analyzer_stereo (priv, priv->drawbuf, color, priv->screen_height - 20);
246 break;
247
248 case 3:
249 case 4:
250 _oink_gfx_scope_bulbous (priv, buf, color, height);
251 break;
252
253 case 5:
254 _oink_gfx_scope_circle (priv, buf, 250, MIN (priv->screen_width, priv->screen_height) / 4,
255 priv->screen_halfwidth, priv->screen_halfheight);
256 break;
257
258 case 6:
259 priv->scene.rotate += 10;
260 _oink_gfx_scope_stereo (priv, buf, 250, 250,
261 priv->screen_height / 6, priv->screen_halfheight + (priv->screen_halfheight / 2),
262 priv->scene.rotate);
263 break;
264
265 case 7:
266 priv->scene.rotate += 2;
267 _oink_gfx_scope_stereo (priv, buf, 250, 250, priv->screen_height / 6, priv->screen_halfheight + (priv->screen_halfheight / 2),
268 (int) (_oink_table_sin[priv->scene.rotate % OINK_TABLE_NORMAL_SIZE] * 150) + 600);
269 break;
270
271 default:
272 _oink_gfx_scope_bulbous (priv, buf, color, height);
273 break;
274 }
275 }
276
277 void _oink_scene_randomize (OinksiePrivate *priv)
278 {
279 _oink_config_random_scopemode (priv);
280 _oink_config_random_blurmode (priv);
281 _oink_config_random_backgroundmode (priv);
282
283 _oink_gfx_palette_build (priv, priv->config.acidpalette);
284 }
285
286 void _oink_scene_render (OinksiePrivate *priv)
287 {
288 time (&priv->timing);
289
290 if (priv->drawbuf == NULL)
291 return;
292
293 if (priv->config.scenenew == TRUE)
294 _oink_scene_randomize (priv);
295
296 priv->config.scenenew = FALSE;
297
298 if (priv->audio.beat == TRUE)
299 {
300 if (visual_random_context_int_range (priv->rcontext, 0, 50) == 0)
301 _oink_config_random_scopemode (priv);
302
303 if (visual_random_context_int_range (priv->rcontext, 0, 40) == 0)
304 _oink_config_random_blurmode (priv);
305
306 if (visual_random_context_int_range (priv->rcontext, 0, 20) == 0)
307 _oink_gfx_palette_build (priv, priv->config.acidpalette);
308 }
309
310 _oink_gfx_blur_fade (priv, priv->drawbuf, priv->audio.bass / 2);
311
312 _oink_scene_background_select (priv, priv->drawbuf);
313
314 if (visual_random_context_int_range (priv->rcontext, 0, 500) == 42)
315 _oink_scene_randomize (priv);
316
317 switch (priv->audio.musicmood)
318 {
319 case 0:
320 _oink_scene_scope_select (priv, priv->drawbuf, 245, priv->screen_height / 4);
321 break;
322
323 case 1:
324 _oink_scene_scope_select (priv, priv->drawbuf, priv->audio.bass * 21, priv->screen_height / 4);
325 break;
326
327 case 2:
328 _oink_scene_scope_select (priv, priv->drawbuf, priv->audio.bass * 14, priv->screen_height / 4);
329 break;
330
331 default:
332 break;
333 }
334
335 _oink_scene_scope_special (priv, priv->drawbuf);
336 _oink_scene_background_special (priv, priv->drawbuf);
337 _oink_scene_blur_select (priv, priv->drawbuf);
338
339 priv->timing_prev = priv->timing;
340 }
341