summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-02-16 16:07:21 +0000
committerDave Chapman <dave@dchapman.com>2006-02-16 16:07:21 +0000
commitb0f05809d54a22deb0c32e99397e3f055ae61570 (patch)
tree2ec43f731338f7ddc2a19594bbc24e33ee0f229e
parent57580224a41506cdeed8cbe42694cb9e612c76fc (diff)
downloadrockbox-b0f05809d54a22deb0c32e99397e3f055ae61570.tar.gz
rockbox-b0f05809d54a22deb0c32e99397e3f055ae61570.zip
Patch #1432941 - Colour support for Plasma by Mikael Magnusson
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8702 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/SOURCES2
-rw-r--r--apps/plugins/plasma.c63
-rw-r--r--docs/CREDITS2
3 files changed, 62 insertions, 5 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 32fec1bae0..3e7ca5894c 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -26,8 +26,8 @@ metronome.c
26#if CONFIG_LCD != LCD_IPOD2BPP 26#if CONFIG_LCD != LCD_IPOD2BPP
27#ifndef HAVE_LCD_COLOR 27#ifndef HAVE_LCD_COLOR
28fire.c 28fire.c
29plasma.c
30#endif 29#endif
30plasma.c
31jpeg.c 31jpeg.c
32mandelbrot.c 32mandelbrot.c
33#endif 33#endif
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index bb2c746473..f9fc80e81c 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -26,18 +26,26 @@
26#include "plugin.h" 26#include "plugin.h"
27 27
28#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ 28#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
29#ifdef HAVE_LCD_COLOR
30#include "xlcd.h"
31#else
29#include "gray.h" 32#include "gray.h"
33#endif
30 34
31PLUGIN_HEADER 35PLUGIN_HEADER
32 36
33/******************************* Globals ***********************************/ 37/******************************* Globals ***********************************/
34 38
35static struct plugin_api* rb; /* global api struct pointer */ 39static struct plugin_api* rb; /* global api struct pointer */
36static unsigned char *gbuf;
37static unsigned int gbuf_size = 0;
38static unsigned char wave_array[256]; /* Pre calculated wave array */ 40static unsigned char wave_array[256]; /* Pre calculated wave array */
39static unsigned char colours[256]; /* Smooth transition of shades */ 41static unsigned char colours[256]; /* Smooth transition of shades */
42#ifdef HAVE_LCD_COLOR
43static unsigned char colorbuffer[3*LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */
44#else
40static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */ 45static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */
46static unsigned char *gbuf;
47static unsigned int gbuf_size = 0;
48#endif
41static unsigned char sp1, sp2, sp3, sp4; /* Speed of plasma */ 49static unsigned char sp1, sp2, sp3, sp4; /* Speed of plasma */
42static int plasma_frequency; 50static int plasma_frequency;
43 51
@@ -52,6 +60,16 @@ static int plasma_frequency;
52#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN 60#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
53#endif 61#endif
54 62
63#ifdef HAVE_LCD_COLOR
64#if CONFIG_KEYPAD == IAUDIO_X5_PAD
65#define PLASMA_REGEN_COLORS BUTTON_SELECT
66#elif CONFIG_KEYPAD == IPOD_4G_PAD
67#define PLASMA_REGEN_COLORS BUTTON_SELECT
68#elif CONFIG_KEYPAD == IRIVER_H300_PAD
69#define PLASMA_REGEN_COLORS BUTTON_SELECT
70#endif
71#endif
72
55#define WAV_AMP 90 73#define WAV_AMP 90
56 74
57 75
@@ -152,7 +170,9 @@ void cleanup(void *parameter)
152{ 170{
153 (void)parameter; 171 (void)parameter;
154 172
173#ifndef HAVE_LCD_COLOR
155 gray_release(); 174 gray_release();
175#endif
156 rb->backlight_set_timeout(rb->global_settings->backlight_timeout); 176 rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
157} 177}
158 178
@@ -167,19 +187,32 @@ int main(void)
167 int shades, button, x, y; 187 int shades, button, x, y;
168 unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z; 188 unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z;
169 int n=0; 189 int n=0;
170 190#ifdef HAVE_LCD_COLOR
191 int time=0;
192 int redfactor=1, greenfactor=2, bluefactor=3;
193 int redphase=0, greenphase=50, bluephase=100; /* lower chance of gray at *
194 * regular intervals */
195#endif
171 /*Generate the neccesary pre calced stuff*/ 196 /*Generate the neccesary pre calced stuff*/
172 wave_table_generate(); 197 wave_table_generate();
173 shades_generate(); 198 shades_generate();
174 199
200#ifdef HAVE_LCD_COLOR
201 shades = 256;
202#else
175 /* get the remainder of the plugin buffer */ 203 /* get the remainder of the plugin buffer */
176 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); 204 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
177 205
178 shades = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8, 206 shades = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8,
179 32, NULL) + 1; 207 32, NULL) + 1;
208#endif
180 209
210#ifdef HAVE_LCD_COLOR
211 xlcd_init(rb);
212#else
181 /* switch on grayscale overlay */ 213 /* switch on grayscale overlay */
182 gray_show(true); 214 gray_show(true);
215#endif
183 sp1 = 4; 216 sp1 = 4;
184 sp2 = 2; 217 sp2 = 2;
185 sp3 = 4; 218 sp3 = 4;
@@ -198,7 +231,15 @@ int main(void)
198 { 231 {
199 z = wave_array[t1] + wave_array[t2] + wave_array[t3] 232 z = wave_array[t1] + wave_array[t2] + wave_array[t3]
200 + wave_array[t4]; 233 + wave_array[t4];
234#ifdef HAVE_LCD_COLOR
235 colorbuffer[n] = colours[(z+time*redfactor+redphase)%256];
236 ++n;
237 colorbuffer[n] = colours[(z+time*greenfactor+greenphase)%256];
238 ++n;
239 colorbuffer[n] = colours[(z+time*bluefactor+bluephase)%256];
240#else
201 graybuffer[n] = colours[z]; 241 graybuffer[n] = colours[z];
242#endif
202 t3+=1; 243 t3+=1;
203 t4+=2; 244 t4+=2;
204 ++n; 245 ++n;
@@ -211,7 +252,13 @@ int main(void)
211 p2-=sp2; 252 p2-=sp2;
212 p3+=sp3; 253 p3+=sp3;
213 p4-=sp4; 254 p4-=sp4;
255#ifdef HAVE_LCD_COLOR
256 time++;
257 xlcd_color_bitmap(colorbuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
258 rb->lcd_update();
259#else
214 gray_ub_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); 260 gray_ub_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
261#endif
215 262
216 button = rb->button_get(false); 263 button = rb->button_get(false);
217 264
@@ -234,6 +281,16 @@ int main(void)
234 wave_table_generate(); 281 wave_table_generate();
235 } 282 }
236 break; 283 break;
284#ifdef HAVE_LCD_COLOR
285 case (PLASMA_REGEN_COLORS):
286 redfactor=rb->rand()%4;
287 greenfactor=rb->rand()%4;
288 bluefactor=rb->rand()%4;
289 redphase=rb->rand()%256;
290 greenphase=rb->rand()%256;
291 bluephase=rb->rand()%256;
292 break;
293#endif
237 294
238 default: 295 default:
239 if (rb->default_event_handler_ex(button, cleanup, NULL) 296 if (rb->default_event_handler_ex(button, cleanup, NULL)
diff --git a/docs/CREDITS b/docs/CREDITS
index 3d67cbd937..6b107cf16f 100644
--- a/docs/CREDITS
+++ b/docs/CREDITS
@@ -167,4 +167,4 @@ Imre Herceg
167Seven Le Mesle 167Seven Le Mesle
168Craig Bachelor 168Craig Bachelor
169Nikolaj Christensen 169Nikolaj Christensen
170 170Mikael Magnusson