diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/SOURCES | 2 | ||||
-rw-r--r-- | apps/plugins/fire.c | 100 |
2 files changed, 98 insertions, 4 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index a3bfa07296..2043be4696 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES | |||
@@ -25,8 +25,8 @@ viewer.c | |||
25 | #if CONFIG_LCD != LCD_IPOD2BPP /* Plugins needing the grayscale lib */ | 25 | #if CONFIG_LCD != LCD_IPOD2BPP /* Plugins needing the grayscale lib */ |
26 | #ifndef HAVE_LCD_COLOR | 26 | #ifndef HAVE_LCD_COLOR |
27 | grayscale.c | 27 | grayscale.c |
28 | fire.c | ||
29 | #endif | 28 | #endif |
29 | fire.c | ||
30 | jpeg.c | 30 | jpeg.c |
31 | mandelbrot.c | 31 | mandelbrot.c |
32 | plasma.c | 32 | plasma.c |
diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c index 5bcf909108..a8d8d0afdb 100644 --- a/apps/plugins/fire.c +++ b/apps/plugins/fire.c | |||
@@ -22,7 +22,9 @@ | |||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | 23 | ||
24 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 24 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ |
25 | #ifndef HAVE_LCD_COLOR | ||
25 | #include "gray.h" | 26 | #include "gray.h" |
27 | #endif | ||
26 | 28 | ||
27 | PLUGIN_HEADER | 29 | PLUGIN_HEADER |
28 | 30 | ||
@@ -34,11 +36,13 @@ static unsigned int gbuf_size = 0; | |||
34 | 36 | ||
35 | static unsigned char fire[LCD_HEIGHT+3][LCD_WIDTH]; | 37 | static unsigned char fire[LCD_HEIGHT+3][LCD_WIDTH]; |
36 | static unsigned char cooling_map[LCD_HEIGHT][LCD_WIDTH]; | 38 | static unsigned char cooling_map[LCD_HEIGHT][LCD_WIDTH]; |
39 | #ifndef HAVE_LCD_COLOR | ||
37 | static unsigned char draw_buffer[8*LCD_WIDTH]; | 40 | static unsigned char draw_buffer[8*LCD_WIDTH]; |
41 | #endif | ||
38 | 42 | ||
39 | /* Key assignement */ | 43 | /* Key assignement */ |
40 | 44 | ||
41 | #if CONFIG_KEYPAD == IRIVER_H100_PAD | 45 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
42 | #define FIRE_QUIT BUTTON_OFF | 46 | #define FIRE_QUIT BUTTON_OFF |
43 | #define FIRE_SWITCH_FLAMES_TYPE BUTTON_MODE | 47 | #define FIRE_SWITCH_FLAMES_TYPE BUTTON_MODE |
44 | #define FIRE_SWITCH_FLAMES_MOVING BUTTON_REC | 48 | #define FIRE_SWITCH_FLAMES_MOVING BUTTON_REC |
@@ -66,6 +70,13 @@ static unsigned char draw_buffer[8*LCD_WIDTH]; | |||
66 | #define FIRE_INCREASE_MULT BUTTON_SCROLL_FWD | 70 | #define FIRE_INCREASE_MULT BUTTON_SCROLL_FWD |
67 | #define FIRE_DECREASE_MULT BUTTON_SCROLL_BACK | 71 | #define FIRE_DECREASE_MULT BUTTON_SCROLL_BACK |
68 | 72 | ||
73 | #elif (CONFIG_KEYPAD == IAUDIO_X5_PAD) | ||
74 | #define FIRE_QUIT BUTTON_REC | ||
75 | #define FIRE_SWITCH_FLAMES_TYPE BUTTON_LEFT | ||
76 | #define FIRE_SWITCH_FLAMES_MOVING BUTTON_RIGHT | ||
77 | #define FIRE_INCREASE_MULT BUTTON_UP | ||
78 | #define FIRE_DECREASE_MULT BUTTON_DOWN | ||
79 | |||
69 | #endif | 80 | #endif |
70 | 81 | ||
71 | #define MIN_FLAME_VALUE 0 | 82 | #define MIN_FLAME_VALUE 0 |
@@ -79,7 +90,8 @@ static unsigned char draw_buffer[8*LCD_WIDTH]; | |||
79 | #define MULU16(a, b) ((unsigned long) \ | 90 | #define MULU16(a, b) ((unsigned long) \ |
80 | (((unsigned short) (a)) * ((unsigned short) (b)))) | 91 | (((unsigned short) (a)) * ((unsigned short) (b)))) |
81 | 92 | ||
82 | static unsigned char palette[255]= | 93 | #ifndef HAVE_LCD_COLOR |
94 | static const unsigned char palette[255]= | ||
83 | {/* logarithmic histogram equalisation */ | 95 | {/* logarithmic histogram equalisation */ |
84 | 96 | ||
85 | 0, 15, 31, 50, 63, 74, 82, 89, 95, 101, 105, 110, 114, 118, 121, | 97 | 0, 15, 31, 50, 63, 74, 82, 89, 95, 101, 105, 110, 114, 118, 121, |
@@ -100,6 +112,64 @@ static unsigned char palette[255]= | |||
100 | 249, 249, 249, 249, 250, 250, 250, 250, 250, 251, 251, 251, 251, 251, 252, | 112 | 249, 249, 249, 249, 250, 250, 250, 250, 250, 251, 251, 251, 251, 251, 252, |
101 | 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254 | 113 | 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254 |
102 | }; | 114 | }; |
115 | #else | ||
116 | #define L(r,g,b) LCD_RGBPACK(r,g,b) | ||
117 | |||
118 | static const fb_data colorpalette[256] = { | ||
119 | L(248,246,211), L(248,246,203), L(248,245,196), L(248,245,189), L(247,245,182), | ||
120 | L(248,245,174), L(248,244,167), L(248,244,160), L(248,243,153), L(247,243,145), | ||
121 | L(248,243,138), L(247,243,131), L(247,243,125), L(248,242,117), L(248,242,110), | ||
122 | L(247,242,102), L(248,241, 94), L(247,240, 85), L(247,241, 78), L(248,240, 70), | ||
123 | L(247,239, 63), L(247,240, 55), L(247,239, 47), L(247,239, 39), L(247,238, 31), | ||
124 | L(247,238, 23), L(247,236, 19), L(248,232, 21), L(248,228, 22), L(248,224, 23), | ||
125 | L(248,219, 25), L(249,215, 26), L(249,211, 27), L(249,206, 29), L(249,203, 30), | ||
126 | L(249,199, 31), L(250,194, 33), L(250,190, 34), L(251,186, 35), L(251,181, 37), | ||
127 | L(252,177, 38), L(251,172, 40), L(252,168, 41), L(252,163, 42), L(253,158, 44), | ||
128 | L(253,154, 45), L(253,149, 46), L(254,145, 48), L(253,141, 50), L(253,137, 49), | ||
129 | L(253,135, 49), L(252,133, 48), L(251,130, 47), L(249,129, 47), L(248,128, 46), | ||
130 | L(247,125, 46), L(247,124, 44), L(246,122, 44), L(244,119, 43), L(243,118, 43), | ||
131 | L(242,115, 42), L(242,113, 41), L(241,112, 40), L(240,109, 39), L(238,107, 39), | ||
132 | L(237,105, 38), L(236,103, 37), L(235,101, 37), L(234, 99, 36), L(233, 97, 35), | ||
133 | L(232, 95, 34), L(231, 93, 33), L(230, 91, 32), L(229, 89, 32), L(228, 86, 31), | ||
134 | L(227, 85, 30), L(226, 82, 29), L(225, 80, 29), L(224, 78, 28), L(223, 76, 28), | ||
135 | L(222, 74, 26), L(221, 72, 26), L(220, 69, 25), L(218, 67, 24), L(217, 64, 23), | ||
136 | L(215, 60, 22), L(213, 57, 21), L(212, 54, 19), L(210, 50, 18), L(208, 47, 17), | ||
137 | L(207, 44, 16), L(205, 41, 14), L(203, 37, 13), L(202, 34, 12), L(201, 30, 11), | ||
138 | L(199, 27, 10), L(197, 24, 9), L(196, 21, 8), L(194, 18, 7), L(192, 14, 5), | ||
139 | L(191, 11, 4), L(189, 8, 3), L(187, 5, 1), L(186, 2, 0), L(184, 0, 0), | ||
140 | L(181, 0, 0), L(178, 0, 0), L(175, 0, 0), L(172, 0, 0), L(170, 0, 0), | ||
141 | L(167, 0, 0), L(165, 0, 0), L(162, 0, 0), L(159, 0, 0), L(156, 0, 0), | ||
142 | L(153, 0, 0), L(152, 0, 0), L(149, 0, 0), L(146, 0, 0), L(143, 0, 0), | ||
143 | L(141, 0, 0), L(138, 0, 0), L(135, 0, 0), L(132, 0, 0), L(129, 0, 0), | ||
144 | L(127, 0, 0), L(126, 0, 0), L(123, 0, 0), L(120, 0, 0), L(117, 0, 0), | ||
145 | L(115, 0, 0), L(112, 0, 0), L(109, 0, 0), L(106, 0, 0), L(104, 0, 0), | ||
146 | L(101, 0, 0), L( 98, 0, 0), L( 95, 0, 0), L( 93, 0, 0), L( 92, 0, 0), | ||
147 | L( 91, 0, 0), L( 91, 0, 0), L( 90, 0, 0), L( 89, 0, 0), L( 88, 0, 0), | ||
148 | L( 88, 0, 0), L( 87, 0, 0), L( 86, 0, 0), L( 85, 0, 0), L( 84, 0, 0), | ||
149 | L( 84, 0, 0), L( 82, 0, 0), L( 82, 0, 0), L( 81, 0, 0), L( 80, 0, 0), | ||
150 | L( 80, 0, 0), L( 79, 0, 0), L( 78, 0, 0), L( 77, 0, 0), L( 76, 0, 0), | ||
151 | L( 76, 0, 0), L( 75, 0, 0), L( 74, 0, 0), L( 73, 0, 0), L( 72, 0, 0), | ||
152 | L( 72, 0, 0), L( 71, 0, 0), L( 70, 0, 0), L( 69, 0, 0), L( 68, 0, 0), | ||
153 | L( 68, 0, 0), L( 67, 0, 0), L( 66, 0, 0), L( 65, 0, 0), L( 65, 0, 0), | ||
154 | L( 63, 0, 0), L( 62, 0, 0), L( 62, 0, 0), L( 61, 0, 0), L( 60, 0, 0), | ||
155 | L( 59, 0, 0), L( 58, 0, 0), L( 58, 0, 0), L( 58, 0, 0), L( 57, 0, 0), | ||
156 | L( 56, 0, 0), L( 54, 0, 0), L( 54, 0, 0), L( 53, 0, 0), L( 52, 0, 0), | ||
157 | L( 52, 0, 0), L( 51, 0, 0), L( 50, 0, 0), L( 49, 0, 0), L( 48, 0, 0), | ||
158 | L( 47, 0, 0), L( 47, 0, 0), L( 46, 0, 0), L( 45, 0, 0), L( 44, 0, 0), | ||
159 | L( 44, 0, 0), L( 43, 0, 0), L( 42, 0, 0), L( 42, 0, 0), L( 40, 0, 0), | ||
160 | L( 40, 0, 0), L( 39, 0, 0), L( 38, 0, 0), L( 38, 0, 0), L( 37, 0, 0), | ||
161 | L( 36, 0, 0), L( 35, 0, 0), L( 34, 0, 0), L( 33, 0, 0), L( 32, 0, 0), | ||
162 | L( 32, 0, 0), L( 31, 0, 0), L( 30, 0, 0), L( 30, 0, 0), L( 28, 0, 0), | ||
163 | L( 28, 0, 0), L( 27, 0, 0), L( 26, 0, 0), L( 25, 0, 0), L( 25, 0, 0), | ||
164 | L( 23, 0, 0), L( 23, 0, 0), L( 22, 0, 0), L( 21, 0, 0), L( 21, 0, 0), | ||
165 | L( 20, 0, 0), L( 19, 0, 0), L( 18, 0, 0), L( 18, 0, 0), L( 16, 0, 0), | ||
166 | L( 16, 0, 0), L( 15, 0, 0), L( 14, 0, 0), L( 14, 0, 0), L( 13, 0, 0), | ||
167 | L( 12, 0, 0), L( 11, 0, 0), L( 10, 0, 0), L( 9, 0, 0), L( 9, 0, 0), | ||
168 | L( 8, 0, 0), L( 7, 0, 0), L( 6, 0, 0), L( 5, 0, 0), L( 5, 0, 0), | ||
169 | L( 4, 0, 0), L( 3, 0, 0), L( 3, 0, 0), L( 2, 0, 0), L( 1, 0, 0), | ||
170 | L( 0, 0, 0) | ||
171 | }; | ||
172 | #endif | ||
103 | 173 | ||
104 | static inline void tab_init_rand(unsigned char *tab, unsigned int tab_size, | 174 | static inline void tab_init_rand(unsigned char *tab, unsigned int tab_size, |
105 | int rand_max) | 175 | int rand_max) |
@@ -189,6 +259,7 @@ static inline void fire_generate(int mult, int flames_type, bool moving) | |||
189 | 259 | ||
190 | static inline void fire_draw(void) | 260 | static inline void fire_draw(void) |
191 | { | 261 | { |
262 | #ifndef HAVE_LCD_COLOR | ||
192 | int block; | 263 | int block; |
193 | unsigned char *dest, *end; | 264 | unsigned char *dest, *end; |
194 | unsigned char *src = &fire[0][0]; | 265 | unsigned char *src = &fire[0][0]; |
@@ -204,6 +275,17 @@ static inline void fire_draw(void) | |||
204 | 275 | ||
205 | gray_ub_gray_bitmap(draw_buffer, 0, block, LCD_WIDTH, 8); | 276 | gray_ub_gray_bitmap(draw_buffer, 0, block, LCD_WIDTH, 8); |
206 | } | 277 | } |
278 | #else | ||
279 | fb_data* dest = rb->lcd_framebuffer; | ||
280 | fb_data* end = rb->lcd_framebuffer+(LCD_WIDTH*LCD_HEIGHT); | ||
281 | unsigned char* src = &fire[0][0]; | ||
282 | |||
283 | while (dest < end) | ||
284 | { | ||
285 | *(dest++) = colorpalette[*(src++)]; | ||
286 | } | ||
287 | rb->lcd_update(); | ||
288 | #endif | ||
207 | } | 289 | } |
208 | 290 | ||
209 | void cleanup(void *parameter) | 291 | void cleanup(void *parameter) |
@@ -213,7 +295,9 @@ void cleanup(void *parameter) | |||
213 | #if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ) | 295 | #if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ) |
214 | rb->cpu_boost(false); | 296 | rb->cpu_boost(false); |
215 | #endif | 297 | #endif |
298 | #ifndef HAVE_LCD_COLOR | ||
216 | gray_release(); | 299 | gray_release(); |
300 | #endif | ||
217 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); | 301 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); |
218 | } | 302 | } |
219 | 303 | ||
@@ -225,25 +309,35 @@ void cleanup(void *parameter) | |||
225 | int main(void) | 309 | int main(void) |
226 | { | 310 | { |
227 | int shades, button; | 311 | int shades, button; |
312 | #ifdef HAVE_LCD_COLOR | ||
313 | int mult = 267; | ||
314 | #else | ||
228 | int mult = 261; | 315 | int mult = 261; |
316 | #endif | ||
229 | int flames_type=0; | 317 | int flames_type=0; |
230 | bool moving=true; | 318 | bool moving=true; |
231 | /* get the remainder of the plugin buffer */ | 319 | /* get the remainder of the plugin buffer */ |
232 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); | 320 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
233 | 321 | ||
322 | #ifdef HAVE_LCD_COLOR | ||
323 | shades = 256; | ||
324 | #else | ||
234 | shades = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8, | 325 | shades = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8, |
235 | 32, NULL) + 1; | 326 | 32, NULL) + 1; |
236 | if(shades <= 1) | 327 | if(shades <= 1) |
237 | { | 328 | { |
238 | rb->splash(HZ, true, "not enougth memory"); | 329 | rb->splash(HZ, true, "not enough memory"); |
239 | return PLUGIN_ERROR; | 330 | return PLUGIN_ERROR; |
240 | } | 331 | } |
332 | #endif | ||
241 | 333 | ||
242 | #if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ) | 334 | #if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ) |
243 | rb->cpu_boost(true); | 335 | rb->cpu_boost(true); |
244 | #endif | 336 | #endif |
337 | #ifndef HAVE_LCD_COLOR | ||
245 | /* switch on grayscale overlay */ | 338 | /* switch on grayscale overlay */ |
246 | gray_show(true); | 339 | gray_show(true); |
340 | #endif | ||
247 | rb->memset(&fire[0][0], 0, sizeof(fire)); | 341 | rb->memset(&fire[0][0], 0, sizeof(fire)); |
248 | tab_init_rand(&cooling_map[0][0], LCD_HEIGHT*LCD_WIDTH, COOL_MAX); | 342 | tab_init_rand(&cooling_map[0][0], LCD_HEIGHT*LCD_WIDTH, COOL_MAX); |
249 | while (true) | 343 | while (true) |