summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Kukla <roolku@rockbox.org>2007-04-08 15:10:51 +0000
committerRobert Kukla <roolku@rockbox.org>2007-04-08 15:10:51 +0000
commit357a4182a715488c7a9e9a972a0c6a678fb207f8 (patch)
treebc80a535a7421059a4455d446c4247c659dffad5
parent9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c (diff)
downloadrockbox-357a4182a715488c7a9e9a972a0c6a678fb207f8.tar.gz
rockbox-357a4182a715488c7a9e9a972a0c6a678fb207f8.zip
FS#6604 - Starfield Pulses To Music
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13075 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/starfield.c58
1 files changed, 50 insertions, 8 deletions
diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c
index 0c3acec8fc..1c7635799d 100644
--- a/apps/plugins/starfield.c
+++ b/apps/plugins/starfield.c
@@ -76,8 +76,8 @@ static struct plugin_api* rb; /* global api struct pointer */
76 76
77 77
78#define MAX_STARS (LCD_WIDTH*LCD_HEIGHT*20)/100 78#define MAX_STARS (LCD_WIDTH*LCD_HEIGHT*20)/100
79#define INIT_STARS 600 79#define INIT_STARS 200
80#define STARFIELD_INCREASE_STEP 100 80#define STARFIELD_INCREASE_STEP 50
81#define INIT_SPACE_SPEED 1 81#define INIT_SPACE_SPEED 1
82#define STAR_MAX_VELOCITY 2 82#define STAR_MAX_VELOCITY 2
83/* 83/*
@@ -149,6 +149,7 @@ static inline void star_draw(struct star * star, int z_move)
149 star_init(star, z_move); 149 star_init(star, z_move);
150 return; 150 return;
151 } 151 }
152
152 rb->lcd_drawpixel(x_draw, y_draw); 153 rb->lcd_drawpixel(x_draw, y_draw);
153 if(star->z<5*Z_MAX_DIST/6) 154 if(star->z<5*Z_MAX_DIST/6)
154 { 155 {
@@ -217,15 +218,13 @@ static struct starfield starfield;
217int plugin_main(void) 218int plugin_main(void)
218{ 219{
219 char str_buffer[40]; 220 char str_buffer[40];
220 int button, t_disp=0; 221 int button, avg_peak, t_disp=0;
221 int font_h, font_w; 222 int font_h, font_w;
223 bool pulse=true;
222 rb->lcd_getstringsize("A", &font_w, &font_h); 224 rb->lcd_getstringsize("A", &font_w, &font_h);
223 starfield_init(&starfield); 225 starfield_init(&starfield);
224 starfield_add_stars(&starfield, INIT_STARS); 226 starfield_add_stars(&starfield, INIT_STARS);
225 227
226#if LCD_DEPTH > 1
227 rb->lcd_set_backdrop(NULL);
228#endif
229#ifdef HAVE_LCD_COLOR 228#ifdef HAVE_LCD_COLOR
230 rb->lcd_set_background(LCD_BLACK); 229 rb->lcd_set_background(LCD_BLACK);
231 rb->lcd_set_foreground(LCD_WHITE); 230 rb->lcd_set_foreground(LCD_WHITE);
@@ -236,10 +235,51 @@ int plugin_main(void)
236 rb->sleep(1); 235 rb->sleep(1);
237 rb->lcd_clear_display(); 236 rb->lcd_clear_display();
238 237
238 /* This will make the stars pulse to the music */
239 if(pulse==true){
240
241 /* Get the peaks. ( Borrowed from vu_meter ) */
242#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
243 int left_peak = rb->mas_codec_readreg(0xC);
244 int right_peak = rb->mas_codec_readreg(0xD);
245#elif (CONFIG_CODEC == SWCODEC)
246 int left_peak, right_peak;
247 rb->pcm_calculate_peaks(&left_peak, &right_peak);
248#endif
249 /* Devide peak data by 4098 to bring the max
250 value down from ~32k to 8 */
251 left_peak = left_peak/0x1000;
252 right_peak = right_peak/0x1000;
253
254 /* Make sure they dont stop */
255 if(left_peak<0x1)
256 left_peak = 0x1;
257 if(right_peak<0x1)
258 right_peak = 0x1;
259
260 /* And make sure they dont go over 8 */
261 if(left_peak>0x8)
262 left_peak = 0x8;
263 if(right_peak>0x8)
264 right_peak = 0x8;
265
266 /* We need the average of both chanels */
267 avg_peak = ( left_peak + right_peak )/2;
268
269 /* Set the speed to the peak meter */
270 starfield.z_move = avg_peak;
271
272 } /* if pulse */
273
239 starfield_move_and_draw(&starfield); 274 starfield_move_and_draw(&starfield);
240 275
276#ifdef HAVE_LCD_COLOR
277 rb->lcd_set_foreground(LCD_WHITE);
278#endif
279
280 /* if a parameter is updated (by the user), we must print it */
241 if (t_disp > 0) 281 if (t_disp > 0)
242 {/* if a parameter is updated (by the user), we must print it */ 282 {
243 --t_disp; 283 --t_disp;
244 rb->snprintf(str_buffer, sizeof(str_buffer), 284 rb->snprintf(str_buffer, sizeof(str_buffer),
245 "star:%d speed:%d", 285 "star:%d speed:%d",
@@ -255,11 +295,13 @@ int plugin_main(void)
255 case (STARFIELD_INCREASE_ZMOVE): 295 case (STARFIELD_INCREASE_ZMOVE):
256 case (STARFIELD_INCREASE_ZMOVE | BUTTON_REPEAT): 296 case (STARFIELD_INCREASE_ZMOVE | BUTTON_REPEAT):
257 ++(starfield.z_move); 297 ++(starfield.z_move);
298 pulse=false;
258 t_disp=MSG_DISP_TIME; 299 t_disp=MSG_DISP_TIME;
259 break; 300 break;
260 case (STARFIELD_DECREASE_ZMOVE): 301 case (STARFIELD_DECREASE_ZMOVE):
261 case (STARFIELD_DECREASE_ZMOVE | BUTTON_REPEAT): 302 case (STARFIELD_DECREASE_ZMOVE | BUTTON_REPEAT):
262 --(starfield.z_move); 303 --(starfield.z_move);
304 pulse=false;
263 t_disp=MSG_DISP_TIME; 305 t_disp=MSG_DISP_TIME;
264 break; 306 break;
265 case(STARFIELD_INCREASE_NB_STARS): 307 case(STARFIELD_INCREASE_NB_STARS):