summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/color_picker.c38
-rw-r--r--apps/gui/line.h4
-rw-r--r--apps/gui/skin_engine/skin_render.c6
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/SOURCES3
-rw-r--r--apps/plugins/SUBDIRS2
-rw-r--r--apps/plugins/doom/i_video.c2
-rw-r--r--apps/plugins/fft/fft.c8
-rw-r--r--apps/plugins/fire.c16
-rw-r--r--apps/plugins/fractals/mandelbrot_set.c5
-rw-r--r--apps/plugins/imageviewer/jpeg/yuv2rgb.c8
-rw-r--r--apps/plugins/imageviewer/ppm/ppm_decoder.c4
-rw-r--r--apps/plugins/invadrox.c9
-rw-r--r--apps/plugins/lib/bmp_smooth_scale.c186
-rw-r--r--apps/plugins/lib/osd.c3
-rw-r--r--apps/plugins/lib/pluginlib_bmp.c6
-rw-r--r--apps/plugins/lib/xlcd_draw.c12
-rw-r--r--apps/plugins/logo.c8
-rw-r--r--apps/plugins/lua/rocklib.c4
-rw-r--r--apps/plugins/mpegplayer/alloc.c1
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c32
-rw-r--r--apps/plugins/pacbox/arcade.c2
-rw-r--r--apps/plugins/pictureflow/pictureflow.c62
-rw-r--r--apps/plugins/plasma.c2
-rw-r--r--apps/plugins/rockblox.c2
-rw-r--r--apps/plugins/rockboy/lcd-gb.h6
-rw-r--r--apps/plugins/rockboy/lcd.c14
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c9
-rw-r--r--apps/plugins/superdom.c4
-rw-r--r--apps/plugins/zxbox/zxvid_16bpp.c6
-rw-r--r--apps/recorder/bmp.c17
-rw-r--r--apps/recorder/resize.c12
33 files changed, 284 insertions, 213 deletions
diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c
index 907b1744c5..a66b131560 100644
--- a/apps/gui/color_picker.c
+++ b/apps/gui/color_picker.c
@@ -60,7 +60,7 @@ struct rgb_pick
60/* list of primary colors */ 60/* list of primary colors */
61#define SB_PRIM 0 61#define SB_PRIM 0
62#define SB_FILL 1 62#define SB_FILL 1
63static const fb_data prim_rgb[][3] = 63static const unsigned prim_rgb[][3] =
64{ 64{
65 /* Foreground colors for sliders */ 65 /* Foreground colors for sliders */
66 { 66 {
@@ -87,13 +87,13 @@ static const unsigned char rgb_max[3] =
87/* Unpacks the color value into native rgb values and 24 bit rgb values */ 87/* Unpacks the color value into native rgb values and 24 bit rgb values */
88static void unpack_rgb(struct rgb_pick *rgb) 88static void unpack_rgb(struct rgb_pick *rgb)
89{ 89{
90 unsigned color = _LCD_UNSWAP_COLOR(rgb->color); 90 unsigned color = rgb->color;
91 rgb->red = _RGB_UNPACK_RED(color); 91 rgb->red = RGB_UNPACK_RED(color);
92 rgb->green = _RGB_UNPACK_GREEN(color); 92 rgb->green = RGB_UNPACK_GREEN(color);
93 rgb->blue = _RGB_UNPACK_BLUE(color); 93 rgb->blue = RGB_UNPACK_BLUE(color);
94 rgb->r = _RGB_UNPACK_RED_LCD(color); 94 rgb->r = RGB_UNPACK_RED_LCD(color);
95 rgb->g = _RGB_UNPACK_GREEN_LCD(color); 95 rgb->g = RGB_UNPACK_GREEN_LCD(color);
96 rgb->b = _RGB_UNPACK_BLUE_LCD(color); 96 rgb->b = RGB_UNPACK_BLUE_LCD(color);
97} 97}
98 98
99/* Packs the native rgb colors into a color value */ 99/* Packs the native rgb colors into a color value */
@@ -159,6 +159,7 @@ static void draw_screen(struct screen *display, char *title,
159 int max_label_width; 159 int max_label_width;
160 int text_x, text_top; 160 int text_x, text_top;
161 int slider_x, slider_width; 161 int slider_x, slider_width;
162 int value_width;
162 bool display_three_rows; 163 bool display_three_rows;
163 struct viewport vp; 164 struct viewport vp;
164 165
@@ -185,7 +186,12 @@ static void draw_screen(struct screen *display, char *title,
185 TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN; 186 TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN;
186 text_x = SELECTOR_WIDTH; 187 text_x = SELECTOR_WIDTH;
187 slider_x = text_x + max_label_width + SLIDER_TEXT_MARGIN; 188 slider_x = text_x + max_label_width + SLIDER_TEXT_MARGIN;
188 slider_width = vp.width - slider_x*2 - max_label_width; 189 slider_width = vp.width - text_x - slider_x - SLIDER_TEXT_MARGIN;
190 if (display->depth >= 24)
191 display->getstringsize("255", &value_width, NULL);
192 else
193 display->getstringsize("63", &value_width, NULL);
194 slider_width -= value_width;
189 line_height = char_height + 2*SELECTOR_TB_MARGIN; 195 line_height = char_height + 2*SELECTOR_TB_MARGIN;
190 196
191 /* Find out if there's enough room for three sliders or just 197 /* Find out if there's enough room for three sliders or just
@@ -252,7 +258,10 @@ static void draw_screen(struct screen *display, char *title,
252 vp.flags &= ~VP_FLAG_ALIGNMENT_MASK; 258 vp.flags &= ~VP_FLAG_ALIGNMENT_MASK;
253 display->putsxy(text_x, text_top, buf); 259 display->putsxy(text_x, text_top, buf);
254 /* Draw color value */ 260 /* Draw color value */
255 snprintf(buf, 3, "%02d", rgb->rgb_val[i]); 261 if (display->depth >= 24)
262 snprintf(buf, 4, "%03d", rgb->rgb_val[i]);
263 else
264 snprintf(buf, 3, "%02d", rgb->rgb_val[i]);
256 vp.flags |= VP_FLAG_ALIGN_RIGHT; 265 vp.flags |= VP_FLAG_ALIGN_RIGHT;
257 display->putsxy(text_x, text_top, buf); 266 display->putsxy(text_x, text_top, buf);
258 267
@@ -324,7 +333,7 @@ static int touchscreen_slider(struct screen *display,
324{ 333{
325 short x, y; 334 short x, y;
326 int char_height, line_height; 335 int char_height, line_height;
327 int max_label_width; 336 int max_label_width, value_width;
328 int text_top, slider_x, slider_width; 337 int text_top, slider_x, slider_width;
329 bool display_three_rows; 338 bool display_three_rows;
330 int button; 339 int button;
@@ -345,7 +354,12 @@ static int touchscreen_slider(struct screen *display,
345 text_top = MARGIN_TOP + char_height + 354 text_top = MARGIN_TOP + char_height +
346 TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN; 355 TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN;
347 slider_x = SELECTOR_WIDTH + max_label_width + SLIDER_TEXT_MARGIN; 356 slider_x = SELECTOR_WIDTH + max_label_width + SLIDER_TEXT_MARGIN;
348 slider_width = vp.width - slider_x*2 - max_label_width; 357 slider_width = vp.width - SELECTOR_WIDTH - slider_x - SLIDER_TEXT_MARGIN;
358 if (display->depth >= 24)
359 display->getstringsize("255", &value_width, NULL);
360 else
361 display->getstringsize("63", &value_width, NULL);
362 slider_width -= value_width;
349 line_height = char_height + 2*SELECTOR_TB_MARGIN; 363 line_height = char_height + 2*SELECTOR_TB_MARGIN;
350 364
351 /* same logic as in draw_screen */ 365 /* same logic as in draw_screen */
diff --git a/apps/gui/line.h b/apps/gui/line.h
index c14f04d9a2..8a1cc05af2 100644
--- a/apps/gui/line.h
+++ b/apps/gui/line.h
@@ -66,10 +66,10 @@ struct line_desc {
66 int16_t line; 66 int16_t line;
67 /* line text color if STYLE_COLORED is specified, in native 67 /* line text color if STYLE_COLORED is specified, in native
68 * lcd format (convert with LCD_RGBPACK() if necessary) */ 68 * lcd format (convert with LCD_RGBPACK() if necessary) */
69 fb_data text_color; 69 unsigned text_color;
70 /* line color if STYLE_COLORBAR or STYLE_GRADIENT is specified, in native 70 /* line color if STYLE_COLORBAR or STYLE_GRADIENT is specified, in native
71 * lcd format (convert with LCD_RGBPACK() if necessary) */ 71 * lcd format (convert with LCD_RGBPACK() if necessary) */
72 fb_data line_color, line_end_color; 72 unsigned line_color, line_end_color;
73 /* line decorations, see STYLE_DEFAULT etc. */ 73 /* line decorations, see STYLE_DEFAULT etc. */
74 enum line_styles style; 74 enum line_styles style;
75 /* whether the line can scroll */ 75 /* whether the line can scroll */
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index 700694e382..4415619b7e 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -136,9 +136,9 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
136 * come before the text style tag color fields need to be preserved */ 136 * come before the text style tag color fields need to be preserved */
137 if (data->style & STYLE_GRADIENT) 137 if (data->style & STYLE_GRADIENT)
138 { 138 {
139 fb_data tc = linedes->text_color, 139 unsigned tc = linedes->text_color,
140 lc = linedes->line_color, 140 lc = linedes->line_color,
141 lec = linedes->line_end_color; 141 lec = linedes->line_end_color;
142 *linedes = *data; 142 *linedes = *data;
143 linedes->text_color = tc; 143 linedes->text_color = tc;
144 linedes->line_color = lc; 144 linedes->line_color = lc;
diff --git a/apps/plugin.c b/apps/plugin.c
index 4bed707c11..d0e6ade547 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -184,7 +184,7 @@ static const struct plugin_api rockbox_api = {
184 lcd_get_backdrop, 184 lcd_get_backdrop,
185 lcd_set_backdrop, 185 lcd_set_backdrop,
186#endif 186#endif
187#if LCD_DEPTH == 16 187#if LCD_DEPTH >= 16
188 lcd_bitmap_transparent_part, 188 lcd_bitmap_transparent_part,
189 lcd_bitmap_transparent, 189 lcd_bitmap_transparent,
190#if MEMORYSIZE > 2 190#if MEMORYSIZE > 2
diff --git a/apps/plugin.h b/apps/plugin.h
index fd4e468b91..1ed1c041d1 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -242,7 +242,7 @@ struct plugin_api {
242 fb_data* (*lcd_get_backdrop)(void); 242 fb_data* (*lcd_get_backdrop)(void);
243 void (*lcd_set_backdrop)(fb_data* backdrop); 243 void (*lcd_set_backdrop)(fb_data* backdrop);
244#endif 244#endif
245#if LCD_DEPTH == 16 245#if LCD_DEPTH >= 16
246 void (*lcd_bitmap_transparent_part)(const fb_data *src, 246 void (*lcd_bitmap_transparent_part)(const fb_data *src,
247 int src_x, int src_y, int stride, 247 int src_x, int src_y, int stride,
248 int x, int y, int width, int height); 248 int x, int y, int width, int height);
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 59bd4023cc..c56cd5eb46 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -195,7 +195,8 @@ codebuster.c
195fireworks.c 195fireworks.c
196#endif 196#endif
197 197
198#if LCD_DEPTH >= 16 198#if LCD_DEPTH == 16
199/* FIXME: make it work with 24bit (needs lot of memory) */
199rockpaint.c 200rockpaint.c
200#endif 201#endif
201 202
diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS
index c22977f137..8e653983b7 100644
--- a/apps/plugins/SUBDIRS
+++ b/apps/plugins/SUBDIRS
@@ -22,7 +22,7 @@ clock
22rockboy 22rockboy
23#endif 23#endif
24 24
25#ifdef HAVE_TAGCACHE 25#if defined(HAVE_TAGCACHE)
26pictureflow 26pictureflow
27#endif 27#endif
28 28
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index 57803fb57d..10aee392a2 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -790,7 +790,7 @@ static void I_UploadNewPalette(int pal)
790#ifndef HAVE_LCD_COLOR 790#ifndef HAVE_LCD_COLOR
791 paldata[i]=(3*r+6*g+b)/10; 791 paldata[i]=(3*r+6*g+b)/10;
792#else 792#else
793 paldata[i] = LCD_RGBPACK(r,g,b); 793 paldata[i] = FB_RGBPACK(r,g,b);
794#endif 794#endif
795 } 795 }
796 796
diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index e591954664..2b7f6a4fbe 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -929,13 +929,15 @@ static void draw_spectrogram_vertical(unsigned this_max, unsigned graph_max)
929 if(bins_acc >= ARRAYLEN_PLOT) 929 if(bins_acc >= ARRAYLEN_PLOT)
930 { 930 {
931 unsigned index = (SHADES-1)*bins_max / graph_max; 931 unsigned index = (SHADES-1)*bins_max / graph_max;
932 unsigned color;
932 933
933 /* These happen because we exaggerate the graph a little for 934 /* These happen because we exaggerate the graph a little for
934 * linear mode */ 935 * linear mode */
935 if(index >= SHADES) 936 if(index >= SHADES)
936 index = SHADES-1; 937 index = SHADES-1;
937 938
938 mylcd_set_foreground(SPECTROGRAPH_PALETTE(index)); 939 color = FB_UNPACK_SCALAR_LCD(SPECTROGRAPH_PALETTE(index));
940 mylcd_set_foreground(color);
939 mylcd_drawpixel(fft_spectrogram_pos, y); 941 mylcd_drawpixel(fft_spectrogram_pos, y);
940 942
941 if(--y < 0) 943 if(--y < 0)
@@ -973,13 +975,15 @@ static void draw_spectrogram_horizontal(unsigned this_max, unsigned graph_max)
973 if(bins_acc >= ARRAYLEN_PLOT) 975 if(bins_acc >= ARRAYLEN_PLOT)
974 { 976 {
975 unsigned index = (SHADES-1)*bins_max / graph_max; 977 unsigned index = (SHADES-1)*bins_max / graph_max;
978 unsigned color;
976 979
977 /* These happen because we exaggerate the graph a little for 980 /* These happen because we exaggerate the graph a little for
978 * linear mode */ 981 * linear mode */
979 if(index >= SHADES) 982 if(index >= SHADES)
980 index = SHADES-1; 983 index = SHADES-1;
981 984
982 mylcd_set_foreground(SPECTROGRAPH_PALETTE(index)); 985 color = FB_UNPACK_SCALAR_LCD(SPECTROGRAPH_PALETTE(index));
986 mylcd_set_foreground(color);
983 mylcd_drawpixel(x, fft_spectrogram_pos); 987 mylcd_drawpixel(x, fft_spectrogram_pos);
984 988
985 if(++x >= LCD_WIDTH) 989 if(++x >= LCD_WIDTH)
diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c
index 478296b5f8..4fc30173da 100644
--- a/apps/plugins/fire.c
+++ b/apps/plugins/fire.c
@@ -100,20 +100,20 @@ static void color_palette_init(fb_data* palette)
100 int i; 100 int i;
101 for (i = 0; i < 32; i++){ 101 for (i = 0; i < 32; i++){
102 /* black to blue, 32 values*/ 102 /* black to blue, 32 values*/
103 palette[i]=LCD_RGBPACK(0, 0, 2*i); 103 palette[i]=FB_RGBPACK(0, 0, 2*i);
104 104
105 /* blue to red, 32 values*/ 105 /* blue to red, 32 values*/
106 palette[i + 32]=LCD_RGBPACK(8*i, 0, 64 - 2*i); 106 palette[i + 32]=FB_RGBPACK(8*i, 0, 64 - 2*i);
107 107
108 /* red to yellow, 32 values*/ 108 /* red to yellow, 32 values*/
109 palette[i + 64]=LCD_RGBPACK(255, 8*i, 0); 109 palette[i + 64]=FB_RGBPACK(255, 8*i, 0);
110 110
111 /* yellow to white, 162 values */ 111 /* yellow to white, 162 values */
112 palette[i + 96]=LCD_RGBPACK(255, 255, 0 + 4*i); 112 palette[i + 96]=FB_RGBPACK(255, 255, 0 + 4*i);
113 palette[i + 128]=LCD_RGBPACK(255, 255, 64 + 4*i); 113 palette[i + 128]=FB_RGBPACK(255, 255, 64 + 4*i);
114 palette[i + 160]=LCD_RGBPACK(255, 255, 128 + 4*i); 114 palette[i + 160]=FB_RGBPACK(255, 255, 128 + 4*i);
115 palette[i + 192]=LCD_RGBPACK(255, 255, 192 + i); 115 palette[i + 192]=FB_RGBPACK(255, 255, 192 + i);
116 palette[i + 224]=LCD_RGBPACK(255, 255, 224 + i); 116 palette[i + 224]=FB_RGBPACK(255, 255, 224 + i);
117 } 117 }
118#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) 118#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
119 rb->lcd_pal256_update_pal(palette); 119 rb->lcd_pal256_update_pal(palette);
diff --git a/apps/plugins/fractals/mandelbrot_set.c b/apps/plugins/fractals/mandelbrot_set.c
index 6e47527a20..583095913f 100644
--- a/apps/plugins/fractals/mandelbrot_set.c
+++ b/apps/plugins/fractals/mandelbrot_set.c
@@ -43,8 +43,8 @@ static fb_data imgbuffer[LCD_HEIGHT];
43#endif 43#endif
44 44
45#ifdef HAVE_LCD_COLOR 45#ifdef HAVE_LCD_COLOR
46#define COLOR(iter) (fb_data)LCOLOR(iter) 46#define COLOR(iter) FB_SCALARPACK(LCOLOR(iter))
47#define CONVERGENCE_COLOR LCD_RGBPACK(0, 0, 0) 47#define CONVERGENCE_COLOR FB_RGBPACK(0, 0, 0)
48#else /* greyscale */ 48#else /* greyscale */
49#define COLOR(iter) (unsigned char)LCOLOR(iter) 49#define COLOR(iter) (unsigned char)LCOLOR(iter)
50#define CONVERGENCE_COLOR 0 50#define CONVERGENCE_COLOR 0
@@ -413,4 +413,3 @@ static int mandelbrot_precision(int d)
413 413
414 return changed; 414 return changed;
415} 415}
416
diff --git a/apps/plugins/imageviewer/jpeg/yuv2rgb.c b/apps/plugins/imageviewer/jpeg/yuv2rgb.c
index 2395f232b2..764dc71a47 100644
--- a/apps/plugins/imageviewer/jpeg/yuv2rgb.c
+++ b/apps/plugins/imageviewer/jpeg/yuv2rgb.c
@@ -106,7 +106,7 @@ static fb_data pixel_to_lcd_colour(void)
106 b = component_to_lcd(p->b, LCD_BLUE_BITS, NODITHER_DELTA); 106 b = component_to_lcd(p->b, LCD_BLUE_BITS, NODITHER_DELTA);
107 b = clamp_component_bits(b, LCD_BLUE_BITS); 107 b = clamp_component_bits(b, LCD_BLUE_BITS);
108 108
109 return LCD_RGBPACK_LCD(r, g, b); 109 return FB_RGBPACK_LCD(r, g, b);
110} 110}
111 111
112/** write a monochrome pixel to the colour LCD **/ 112/** write a monochrome pixel to the colour LCD **/
@@ -119,7 +119,7 @@ static fb_data pixel_to_lcd_gray(void)
119 b = component_to_lcd(g, LCD_BLUE_BITS, NODITHER_DELTA); 119 b = component_to_lcd(g, LCD_BLUE_BITS, NODITHER_DELTA);
120 g = component_to_lcd(g, LCD_GREEN_BITS, NODITHER_DELTA); 120 g = component_to_lcd(g, LCD_GREEN_BITS, NODITHER_DELTA);
121 121
122 return LCD_RGBPACK_LCD(r, g, b); 122 return FB_RGBPACK_LCD(r, g, b);
123} 123}
124 124
125/** 125/**
@@ -163,7 +163,7 @@ static fb_data pixel_odither_to_lcd(void)
163 163
164 p->col += p->inc; 164 p->col += p->inc;
165 165
166 return LCD_RGBPACK_LCD(r, g, b); 166 return FB_RGBPACK_LCD(r, g, b);
167} 167}
168 168
169/** 169/**
@@ -217,7 +217,7 @@ static fb_data pixel_fsdither_to_lcd(void)
217 distribute_error(&p->ce[BLU], &p->e[BLU], bc, epos, inc); 217 distribute_error(&p->ce[BLU], &p->e[BLU], bc, epos, inc);
218 218
219 /* Pack and return pixel */ 219 /* Pack and return pixel */
220 return LCD_RGBPACK_LCD(r, g, b); 220 return FB_RGBPACK_LCD(r, g, b);
221} 221}
222 222
223/* Functions for each output mode, colour then grayscale. */ 223/* Functions for each output mode, colour then grayscale. */
diff --git a/apps/plugins/imageviewer/ppm/ppm_decoder.c b/apps/plugins/imageviewer/ppm/ppm_decoder.c
index be459293fe..4a86be1a3a 100644
--- a/apps/plugins/imageviewer/ppm/ppm_decoder.c
+++ b/apps/plugins/imageviewer/ppm/ppm_decoder.c
@@ -197,7 +197,7 @@ static int read_ppm_row(int fd, struct ppm_info *ppm, int row)
197 { 197 {
198 return PLUGIN_ERROR; 198 return PLUGIN_ERROR;
199 } 199 }
200 *dst = LCD_RGBPACK( 200 *dst = FB_RGBPACK(
201 (255 * r)/ppm->maxval, 201 (255 * r)/ppm->maxval,
202 (255 * g)/ppm->maxval, 202 (255 * g)/ppm->maxval,
203 (255 * b)/ppm->maxval); 203 (255 * b)/ppm->maxval);
@@ -216,7 +216,7 @@ static int read_ppm_row(int fd, struct ppm_info *ppm, int row)
216 { 216 {
217 return PLUGIN_ERROR; 217 return PLUGIN_ERROR;
218 } 218 }
219 *dst = LCD_RGBPACK( 219 *dst = FB_RGBPACK(
220 (255 * r)/ppm->maxval, 220 (255 * r)/ppm->maxval,
221 (255 * g)/ppm->maxval, 221 (255 * g)/ppm->maxval,
222 (255 * b)/ppm->maxval); 222 (255 * b)/ppm->maxval);
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index ef53715753..158ad2f4d7 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -1027,7 +1027,7 @@ static inline void draw_ship(void)
1027} 1027}
1028 1028
1029 1029
1030static inline void fire_alpha(int xc, int yc, fb_data color) 1030static inline void fire_alpha(int xc, int yc, unsigned color)
1031{ 1031{
1032 int oldmode = rb->lcd_get_drawmode(); 1032 int oldmode = rb->lcd_get_drawmode();
1033 1033
@@ -1128,12 +1128,12 @@ static void move_fire(void)
1128 /* Check for hit*/ 1128 /* Check for hit*/
1129 for (i = FIRE_SPEED; i >= 0; i--) { 1129 for (i = FIRE_SPEED; i >= 0; i--) {
1130 pix = get_pixel(fire_x, fire_y + i); 1130 pix = get_pixel(fire_x, fire_y + i);
1131 if(pix == screen_white) { 1131 if(!memcmp(&pix, &screen_white, sizeof(fb_data))) {
1132 hit_white = true; 1132 hit_white = true;
1133 fire_y += i; 1133 fire_y += i;
1134 break; 1134 break;
1135 } 1135 }
1136 if(pix == screen_green) { 1136 if(!memcmp(&pix, &screen_green, sizeof(fb_data))) {
1137 hit_green = true; 1137 hit_green = true;
1138 fire_y += i; 1138 fire_y += i;
1139 break; 1139 break;
@@ -1336,7 +1336,8 @@ static void move_bombs(void)
1336 /* Check for green (ship or shield) */ 1336 /* Check for green (ship or shield) */
1337 for (j = BOMB_HEIGHT; j >= BOMB_HEIGHT - BOMB_SPEED; j--) { 1337 for (j = BOMB_HEIGHT; j >= BOMB_HEIGHT - BOMB_SPEED; j--) {
1338 bombs[i].target = 0; 1338 bombs[i].target = 0;
1339 if(get_pixel(bombs[i].x + BOMB_WIDTH / 2, bombs[i].y + j) == screen_green) { 1339 fb_data pix = get_pixel(bombs[i].x + BOMB_WIDTH / 2, bombs[i].y + j);
1340 if(!memcmp(&pix, &screen_green, sizeof(fb_data))) {
1340 /* Move to hit pixel */ 1341 /* Move to hit pixel */
1341 bombs[i].x += BOMB_WIDTH / 2; 1342 bombs[i].x += BOMB_WIDTH / 2;
1342 bombs[i].y += j; 1343 bombs[i].y += j;
diff --git a/apps/plugins/lib/bmp_smooth_scale.c b/apps/plugins/lib/bmp_smooth_scale.c
index e99ff33d71..c5f258cdbf 100644
--- a/apps/plugins/lib/bmp_smooth_scale.c
+++ b/apps/plugins/lib/bmp_smooth_scale.c
@@ -130,38 +130,38 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
130 130
131 if (XAP > 0) { 131 if (XAP > 0) {
132 pix = ypoint + xpoint; 132 pix = ypoint + xpoint;
133 r = RGB_UNPACK_RED(*pix) * INV_XAP; 133 r = FB_UNPACK_RED(*pix) * INV_XAP;
134 g = RGB_UNPACK_GREEN(*pix) * INV_XAP; 134 g = FB_UNPACK_GREEN(*pix) * INV_XAP;
135 b = RGB_UNPACK_BLUE(*pix) * INV_XAP; 135 b = FB_UNPACK_BLUE(*pix) * INV_XAP;
136 pix++; 136 pix++;
137 r += RGB_UNPACK_RED(*pix) * XAP; 137 r += FB_UNPACK_RED(*pix) * XAP;
138 g += RGB_UNPACK_GREEN(*pix) * XAP; 138 g += FB_UNPACK_GREEN(*pix) * XAP;
139 b += RGB_UNPACK_BLUE(*pix) * XAP; 139 b += FB_UNPACK_BLUE(*pix) * XAP;
140 pix += sow; 140 pix += sow;
141 rr = RGB_UNPACK_RED(*pix) * XAP; 141 rr = FB_UNPACK_RED(*pix) * XAP;
142 gg = RGB_UNPACK_GREEN(*pix) * XAP; 142 gg = FB_UNPACK_GREEN(*pix) * XAP;
143 bb = RGB_UNPACK_BLUE(*pix) * XAP; 143 bb = FB_UNPACK_BLUE(*pix) * XAP;
144 pix--; 144 pix--;
145 rr += RGB_UNPACK_RED(*pix) * INV_XAP; 145 rr += FB_UNPACK_RED(*pix) * INV_XAP;
146 gg += RGB_UNPACK_GREEN(*pix) * INV_XAP; 146 gg += FB_UNPACK_GREEN(*pix) * INV_XAP;
147 bb += RGB_UNPACK_BLUE(*pix) * INV_XAP; 147 bb += FB_UNPACK_BLUE(*pix) * INV_XAP;
148 r = ((rr * YAP) + (r * INV_YAP)) >> 16; 148 r = ((rr * YAP) + (r * INV_YAP)) >> 16;
149 g = ((gg * YAP) + (g * INV_YAP)) >> 16; 149 g = ((gg * YAP) + (g * INV_YAP)) >> 16;
150 b = ((bb * YAP) + (b * INV_YAP)) >> 16; 150 b = ((bb * YAP) + (b * INV_YAP)) >> 16;
151 *dptr++ = LCD_RGBPACK(r, g, b); 151 *dptr++ = FB_RGBPACK(r, g, b);
152 } else { 152 } else {
153 pix = ypoint + xpoint; 153 pix = ypoint + xpoint;
154 r = RGB_UNPACK_RED(*pix) * INV_YAP; 154 r = FB_UNPACK_RED(*pix) * INV_YAP;
155 g = RGB_UNPACK_GREEN(*pix) * INV_YAP; 155 g = FB_UNPACK_GREEN(*pix) * INV_YAP;
156 b = RGB_UNPACK_BLUE(*pix) * INV_YAP; 156 b = FB_UNPACK_BLUE(*pix) * INV_YAP;
157 pix += sow; 157 pix += sow;
158 r += RGB_UNPACK_RED(*pix) * YAP; 158 r += FB_UNPACK_RED(*pix) * YAP;
159 g += RGB_UNPACK_GREEN(*pix) * YAP; 159 g += FB_UNPACK_GREEN(*pix) * YAP;
160 b += RGB_UNPACK_BLUE(*pix) * YAP; 160 b += FB_UNPACK_BLUE(*pix) * YAP;
161 r >>= 8; 161 r >>= 8;
162 g >>= 8; 162 g >>= 8;
163 b >>= 8; 163 b >>= 8;
164 *dptr++ = LCD_RGBPACK(r, g, b); 164 *dptr++ = FB_RGBPACK(r, g, b);
165 } 165 }
166 } 166 }
167 } else { 167 } else {
@@ -176,17 +176,17 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
176 176
177 if (XAP > 0) { 177 if (XAP > 0) {
178 pix = ypoint + xpoint; 178 pix = ypoint + xpoint;
179 r = RGB_UNPACK_RED(*pix) * INV_XAP; 179 r = FB_UNPACK_RED(*pix) * INV_XAP;
180 g = RGB_UNPACK_GREEN(*pix) * INV_XAP; 180 g = FB_UNPACK_GREEN(*pix) * INV_XAP;
181 b = RGB_UNPACK_BLUE(*pix) * INV_XAP; 181 b = FB_UNPACK_BLUE(*pix) * INV_XAP;
182 pix++; 182 pix++;
183 r += RGB_UNPACK_RED(*pix) * XAP; 183 r += FB_UNPACK_RED(*pix) * XAP;
184 g += RGB_UNPACK_GREEN(*pix) * XAP; 184 g += FB_UNPACK_GREEN(*pix) * XAP;
185 b += RGB_UNPACK_BLUE(*pix) * XAP; 185 b += FB_UNPACK_BLUE(*pix) * XAP;
186 r >>= 8; 186 r >>= 8;
187 g >>= 8; 187 g >>= 8;
188 b >>= 8; 188 b >>= 8;
189 *dptr++ = LCD_RGBPACK(r, g, b); 189 *dptr++ = FB_RGBPACK(r, g, b);
190 } else 190 } else
191 *dptr++ = sptr[xpoint]; 191 *dptr++ = sptr[xpoint];
192 } 192 }
@@ -221,37 +221,37 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
221 val_x += inc_x; 221 val_x += inc_x;
222 222
223 pix = ypoint + xpoint; 223 pix = ypoint + xpoint;
224 r = (RGB_UNPACK_RED(*pix) * yap) >> 10; 224 r = (FB_UNPACK_RED(*pix) * yap) >> 10;
225 g = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; 225 g = (FB_UNPACK_GREEN(*pix) * yap) >> 10;
226 b = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; 226 b = (FB_UNPACK_BLUE(*pix) * yap) >> 10;
227 pix += sow; 227 pix += sow;
228 for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 228 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
229 r += (RGB_UNPACK_RED(*pix) * Cy) >> 10; 229 r += (FB_UNPACK_RED(*pix) * Cy) >> 10;
230 g += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; 230 g += (FB_UNPACK_GREEN(*pix) * Cy) >> 10;
231 b += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; 231 b += (FB_UNPACK_BLUE(*pix) * Cy) >> 10;
232 pix += sow; 232 pix += sow;
233 } 233 }
234 if (j > 0) { 234 if (j > 0) {
235 r += (RGB_UNPACK_RED(*pix) * j) >> 10; 235 r += (FB_UNPACK_RED(*pix) * j) >> 10;
236 g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 236 g += (FB_UNPACK_GREEN(*pix) * j) >> 10;
237 b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 237 b += (FB_UNPACK_BLUE(*pix) * j) >> 10;
238 } 238 }
239 if (XAP > 0) { 239 if (XAP > 0) {
240 pix = ypoint + xpoint + 1; 240 pix = ypoint + xpoint + 1;
241 rr = (RGB_UNPACK_RED(*pix) * yap) >> 10; 241 rr = (FB_UNPACK_RED(*pix) * yap) >> 10;
242 gg = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; 242 gg = (FB_UNPACK_GREEN(*pix) * yap) >> 10;
243 bb = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; 243 bb = (FB_UNPACK_BLUE(*pix) * yap) >> 10;
244 pix += sow; 244 pix += sow;
245 for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 245 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
246 rr += (RGB_UNPACK_RED(*pix) * Cy) >> 10; 246 rr += (FB_UNPACK_RED(*pix) * Cy) >> 10;
247 gg += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; 247 gg += (FB_UNPACK_GREEN(*pix) * Cy) >> 10;
248 bb += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; 248 bb += (FB_UNPACK_BLUE(*pix) * Cy) >> 10;
249 pix += sow; 249 pix += sow;
250 } 250 }
251 if (j > 0) { 251 if (j > 0) {
252 rr += (RGB_UNPACK_RED(*pix) * j) >> 10; 252 rr += (FB_UNPACK_RED(*pix) * j) >> 10;
253 gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 253 gg += (FB_UNPACK_GREEN(*pix) * j) >> 10;
254 bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 254 bb += (FB_UNPACK_BLUE(*pix) * j) >> 10;
255 } 255 }
256 r = r * INV_XAP; 256 r = r * INV_XAP;
257 g = g * INV_XAP; 257 g = g * INV_XAP;
@@ -264,7 +264,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
264 g >>= 4; 264 g >>= 4;
265 b >>= 4; 265 b >>= 4;
266 } 266 }
267 *dptr = LCD_RGBPACK(r, g, b); 267 *dptr = FB_RGBPACK(r, g, b);
268 dptr++; 268 dptr++;
269 } 269 }
270 } 270 }
@@ -297,37 +297,37 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
297 xap = XAP & 0xffff; 297 xap = XAP & 0xffff;
298 298
299 pix = ypoint + xpoint; 299 pix = ypoint + xpoint;
300 r = (RGB_UNPACK_RED(*pix) * xap) >> 10; 300 r = (FB_UNPACK_RED(*pix) * xap) >> 10;
301 g = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; 301 g = (FB_UNPACK_GREEN(*pix) * xap) >> 10;
302 b = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; 302 b = (FB_UNPACK_BLUE(*pix) * xap) >> 10;
303 pix++; 303 pix++;
304 for (j = (1 << 14) - xap; j > Cx; j -= Cx) { 304 for (j = (1 << 14) - xap; j > Cx; j -= Cx) {
305 r += (RGB_UNPACK_RED(*pix) * Cx) >> 10; 305 r += (FB_UNPACK_RED(*pix) * Cx) >> 10;
306 g += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; 306 g += (FB_UNPACK_GREEN(*pix) * Cx) >> 10;
307 b += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; 307 b += (FB_UNPACK_BLUE(*pix) * Cx) >> 10;
308 pix++; 308 pix++;
309 } 309 }
310 if (j > 0) { 310 if (j > 0) {
311 r += (RGB_UNPACK_RED(*pix) * j) >> 10; 311 r += (FB_UNPACK_RED(*pix) * j) >> 10;
312 g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 312 g += (FB_UNPACK_GREEN(*pix) * j) >> 10;
313 b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 313 b += (FB_UNPACK_BLUE(*pix) * j) >> 10;
314 } 314 }
315 if (YAP > 0) { 315 if (YAP > 0) {
316 pix = ypoint + xpoint + sow; 316 pix = ypoint + xpoint + sow;
317 rr = (RGB_UNPACK_RED(*pix) * xap) >> 10; 317 rr = (FB_UNPACK_RED(*pix) * xap) >> 10;
318 gg = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; 318 gg = (FB_UNPACK_GREEN(*pix) * xap) >> 10;
319 bb = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; 319 bb = (FB_UNPACK_BLUE(*pix) * xap) >> 10;
320 pix++; 320 pix++;
321 for (j = (1 << 14) - xap; j > Cx; j -= Cx) { 321 for (j = (1 << 14) - xap; j > Cx; j -= Cx) {
322 rr += (RGB_UNPACK_RED(*pix) * Cx) >> 10; 322 rr += (FB_UNPACK_RED(*pix) * Cx) >> 10;
323 gg += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; 323 gg += (FB_UNPACK_GREEN(*pix) * Cx) >> 10;
324 bb += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; 324 bb += (FB_UNPACK_BLUE(*pix) * Cx) >> 10;
325 pix++; 325 pix++;
326 } 326 }
327 if (j > 0) { 327 if (j > 0) {
328 rr += (RGB_UNPACK_RED(*pix) * j) >> 10; 328 rr += (FB_UNPACK_RED(*pix) * j) >> 10;
329 gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 329 gg += (FB_UNPACK_GREEN(*pix) * j) >> 10;
330 bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 330 bb += (FB_UNPACK_BLUE(*pix) * j) >> 10;
331 } 331 }
332 r = r * INV_YAP; 332 r = r * INV_YAP;
333 g = g * INV_YAP; 333 g = g * INV_YAP;
@@ -340,7 +340,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
340 g >>= 4; 340 g >>= 4;
341 b >>= 4; 341 b >>= 4;
342 } 342 }
343 *dptr = LCD_RGBPACK(r, g, b); 343 *dptr = FB_RGBPACK(r, g, b);
344 dptr++; 344 dptr++;
345 } 345 }
346 } 346 }
@@ -378,20 +378,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
378 378
379 pix = sptr; 379 pix = sptr;
380 sptr += sow; 380 sptr += sow;
381 rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; 381 rx = (FB_UNPACK_RED(*pix) * xap) >> 9;
382 gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; 382 gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9;
383 bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; 383 bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9;
384 pix++; 384 pix++;
385 for (i = (1 << 14) - xap; i > Cx; i -= Cx) { 385 for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
386 rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; 386 rx += (FB_UNPACK_RED(*pix) * Cx) >> 9;
387 gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; 387 gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9;
388 bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; 388 bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9;
389 pix++; 389 pix++;
390 } 390 }
391 if (i > 0) { 391 if (i > 0) {
392 rx += (RGB_UNPACK_RED(*pix) * i) >> 9; 392 rx += (FB_UNPACK_RED(*pix) * i) >> 9;
393 gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; 393 gx += (FB_UNPACK_GREEN(*pix) * i) >> 9;
394 bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; 394 bx += (FB_UNPACK_BLUE(*pix) * i) >> 9;
395 } 395 }
396 396
397 r = (rx * yap) >> 14; 397 r = (rx * yap) >> 14;
@@ -401,20 +401,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
401 for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 401 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
402 pix = sptr; 402 pix = sptr;
403 sptr += sow; 403 sptr += sow;
404 rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; 404 rx = (FB_UNPACK_RED(*pix) * xap) >> 9;
405 gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; 405 gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9;
406 bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; 406 bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9;
407 pix++; 407 pix++;
408 for (i = (1 << 14) - xap; i > Cx; i -= Cx) { 408 for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
409 rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; 409 rx += (FB_UNPACK_RED(*pix) * Cx) >> 9;
410 gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; 410 gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9;
411 bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; 411 bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9;
412 pix++; 412 pix++;
413 } 413 }
414 if (i > 0) { 414 if (i > 0) {
415 rx += (RGB_UNPACK_RED(*pix) * i) >> 9; 415 rx += (FB_UNPACK_RED(*pix) * i) >> 9;
416 gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; 416 gx += (FB_UNPACK_GREEN(*pix) * i) >> 9;
417 bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; 417 bx += (FB_UNPACK_BLUE(*pix) * i) >> 9;
418 } 418 }
419 419
420 r += (rx * Cy) >> 14; 420 r += (rx * Cy) >> 14;
@@ -424,20 +424,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
424 if (j > 0) { 424 if (j > 0) {
425 pix = sptr; 425 pix = sptr;
426 sptr += sow; 426 sptr += sow;
427 rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; 427 rx = (FB_UNPACK_RED(*pix) * xap) >> 9;
428 gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; 428 gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9;
429 bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; 429 bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9;
430 pix++; 430 pix++;
431 for (i = (1 << 14) - xap; i > Cx; i -= Cx) { 431 for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
432 rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; 432 rx += (FB_UNPACK_RED(*pix) * Cx) >> 9;
433 gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; 433 gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9;
434 bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; 434 bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9;
435 pix++; 435 pix++;
436 } 436 }
437 if (i > 0) { 437 if (i > 0) {
438 rx += (RGB_UNPACK_RED(*pix) * i) >> 9; 438 rx += (FB_UNPACK_RED(*pix) * i) >> 9;
439 gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; 439 gx += (FB_UNPACK_GREEN(*pix) * i) >> 9;
440 bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; 440 bx += (FB_UNPACK_BLUE(*pix) * i) >> 9;
441 } 441 }
442 442
443 r += (rx * j) >> 14; 443 r += (rx * j) >> 14;
@@ -445,7 +445,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
445 b += (bx * j) >> 14; 445 b += (bx * j) >> 14;
446 } 446 }
447 447
448 *dptr = LCD_RGBPACK(r >> 5, g >> 5, b >> 5); 448 *dptr = FB_RGBPACK(r >> 5, g >> 5, b >> 5);
449 dptr++; 449 dptr++;
450 } 450 }
451 } 451 }
diff --git a/apps/plugins/lib/osd.c b/apps/plugins/lib/osd.c
index 598a76759c..e6fc39178a 100644
--- a/apps/plugins/lib/osd.c
+++ b/apps/plugins/lib/osd.c
@@ -112,6 +112,9 @@ static struct osd grey_osd;
112# define _OSD_WIDTH2BYTES(w) ((w)*2) 112# define _OSD_WIDTH2BYTES(w) ((w)*2)
113# define _OSD_BYTES2WIDTH(b) ((b)/2) 113# define _OSD_BYTES2WIDTH(b) ((b)/2)
114# endif /* end stride type selection */ 114# endif /* end stride type selection */
115#elif LCD_DEPTH == 24
116# define _OSD_WIDTH2BYTES(w) ((w)*3)
117# define _OSD_BYTES2WIDTH(b) ((b)/3)
115#else /* other LCD depth */ 118#else /* other LCD depth */
116# error Unknown LCD depth; please define macros 119# error Unknown LCD depth; please define macros
117#endif /* LCD_DEPTH */ 120#endif /* LCD_DEPTH */
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c
index f1dd9b7b38..f3edfbf425 100644
--- a/apps/plugins/lib/pluginlib_bmp.c
+++ b/apps/plugins/lib/pluginlib_bmp.c
@@ -70,9 +70,9 @@ int save_bmp_file( char* filename, struct bitmap *bm )
70 fb_data *d = (fb_data*)( bm->data ) + (x+y*bm->width); 70 fb_data *d = (fb_data*)( bm->data ) + (x+y*bm->width);
71 unsigned char c[] = 71 unsigned char c[] =
72 { 72 {
73 RGB_UNPACK_BLUE( *d ), 73 FB_UNPACK_BLUE( *d ),
74 RGB_UNPACK_GREEN( *d ), 74 FB_UNPACK_GREEN( *d ),
75 RGB_UNPACK_RED( *d ) 75 FB_UNPACK_RED( *d )
76 }; 76 };
77 rb->write( fh, c, 3 ); 77 rb->write( fh, c, 3 );
78 } 78 }
diff --git a/apps/plugins/lib/xlcd_draw.c b/apps/plugins/lib/xlcd_draw.c
index 3be15718f6..83ddf68e5c 100644
--- a/apps/plugins/lib/xlcd_draw.c
+++ b/apps/plugins/lib/xlcd_draw.c
@@ -170,7 +170,7 @@ void xlcd_filltriangle_screen(struct screen* display,
170 xlcd_filltriangle_vertical(display, x1, y1, x2, y2, x3, y3); 170 xlcd_filltriangle_vertical(display, x1, y1, x2, y2, x3, y3);
171} 171}
172 172
173#if LCD_DEPTH >= 8 173#if LCD_DEPTH >= 8 && LCD_DEPTH <= 16
174 174
175#ifdef HAVE_LCD_COLOR 175#ifdef HAVE_LCD_COLOR
176static const fb_data graylut[256] = { 176static const fb_data graylut[256] = {
@@ -244,6 +244,8 @@ static const fb_data graylut[256] = {
244}; 244};
245#endif /* HAVE_LCD_COLOR */ 245#endif /* HAVE_LCD_COLOR */
246 246
247/* unused functions, enable when needed */
248#if 0
247/* Draw a partial greyscale bitmap, canonical 8 bit format */ 249/* Draw a partial greyscale bitmap, canonical 8 bit format */
248void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, 250void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
249 int stride, int x, int y, int width, int height) 251 int stride, int x, int y, int width, int height)
@@ -286,7 +288,13 @@ void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
286 288
287#ifdef HAVE_LCD_COLOR 289#ifdef HAVE_LCD_COLOR
288 do 290 do
291#if LCD_DEPTH == 16
289 *dst_row++ = graylut[*src_row++]; 292 *dst_row++ = graylut[*src_row++];
293#else
294 /* untested change because this function is completely unused */
295 *dst_row->r = *dst_row->g = *dst_row->b = *src_row++;
296 dst_row++;
297#endif
290 while (src_row < row_end); 298 while (src_row < row_end);
291#endif 299#endif
292 300
@@ -302,6 +310,7 @@ void xlcd_gray_bitmap(const unsigned char *src, int x, int y, int width,
302{ 310{
303 xlcd_gray_bitmap_part(src, 0, 0, width, x, y, width, height); 311 xlcd_gray_bitmap_part(src, 0, 0, width, x, y, width, height);
304} 312}
313#endif
305 314
306#ifdef HAVE_LCD_COLOR 315#ifdef HAVE_LCD_COLOR
307/* Draw a partial colour bitmap, canonical 24 bit RGB format */ 316/* Draw a partial colour bitmap, canonical 24 bit RGB format */
@@ -379,4 +388,3 @@ void xlcd_color_bitmap(const unsigned char *src, int x, int y, int width,
379#endif /* LCD_DEPTH >= 8 */ 388#endif /* LCD_DEPTH >= 8 */
380 389
381#endif /* HAVE_LCD_BITMAP */ 390#endif /* HAVE_LCD_BITMAP */
382
diff --git a/apps/plugins/logo.c b/apps/plugins/logo.c
index aae9e54562..a7257fae4b 100644
--- a/apps/plugins/logo.c
+++ b/apps/plugins/logo.c
@@ -42,14 +42,12 @@ static const struct button_mapping *plugin_contexts[]
42#define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo 42#define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo
43#define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo 43#define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo
44#define REMOTE_LOGO remote_rockboxlogo 44#define REMOTE_LOGO remote_rockboxlogo
45extern const fb_remote_data remote_rockboxlogo[];
46#endif /* HAVE_REMOTE_LCD */ 45#endif /* HAVE_REMOTE_LCD */
47 46
48#define LOGO rockboxlogo 47#define LOGO rockboxlogo
49#include "pluginbitmaps/rockboxlogo.h" 48#include "pluginbitmaps/rockboxlogo.h"
50#define LOGO_WIDTH BMPWIDTH_rockboxlogo 49#define LOGO_WIDTH BMPWIDTH_rockboxlogo
51#define LOGO_HEIGHT BMPHEIGHT_rockboxlogo 50#define LOGO_HEIGHT BMPHEIGHT_rockboxlogo
52extern const fb_data rockboxlogo[];
53 51
54#else /* !LCD_BITMAP */ 52#else /* !LCD_BITMAP */
55#define DISPLAY_WIDTH 55 53#define DISPLAY_WIDTH 55
@@ -103,10 +101,10 @@ enum plugin_status plugin_start(const void* parameter) {
103 while (1) { 101 while (1) {
104#ifdef HAVE_LCD_BITMAP 102#ifdef HAVE_LCD_BITMAP
105 rb->lcd_clear_display(); 103 rb->lcd_clear_display();
106 rb->lcd_bitmap(LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT); 104 rb->lcd_bitmap((const fb_data*)LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT);
107#ifdef REMOTE_LOGO 105#ifdef REMOTE_LOGO
108 rb->lcd_remote_clear_display(); 106 rb->lcd_remote_clear_display();
109 rb->lcd_remote_bitmap(REMOTE_LOGO, 107 rb->lcd_remote_bitmap((const fb_data*)REMOTE_LOGO,
110 (x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH), 108 (x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH),
111 (y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT), 109 (y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT),
112 REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT); 110 REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT);
@@ -195,5 +193,3 @@ enum plugin_status plugin_start(const void* parameter) {
195 } 193 }
196 } 194 }
197} 195}
198
199
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 27c1177748..2268063d3f 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -138,14 +138,14 @@ static fb_data* rli_element(lua_State *L)
138 138
139static int rli_set(lua_State *L) 139static int rli_set(lua_State *L)
140{ 140{
141 fb_data newvalue = (fb_data) luaL_checknumber(L, 4); 141 fb_data newvalue = FB_SCALARPACK((unsigned)luaL_checknumber(L, 4));
142 *rli_element(L) = newvalue; 142 *rli_element(L) = newvalue;
143 return 0; 143 return 0;
144} 144}
145 145
146static int rli_get(lua_State *L) 146static int rli_get(lua_State *L)
147{ 147{
148 lua_pushnumber(L, *rli_element(L)); 148 lua_pushnumber(L, FB_UNPACK_SCALAR_LCD(*rli_element(L)));
149 return 1; 149 return 1;
150} 150}
151 151
diff --git a/apps/plugins/mpegplayer/alloc.c b/apps/plugins/mpegplayer/alloc.c
index eb58c67f44..cbf930a7eb 100644
--- a/apps/plugins/mpegplayer/alloc.c
+++ b/apps/plugins/mpegplayer/alloc.c
@@ -231,4 +231,3 @@ void codec_free(void* ptr)
231#endif 231#endif
232 (void)ptr; 232 (void)ptr;
233} 233}
234
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 2e84a870a9..97fe7d3f4c 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -702,7 +702,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src,
702 dst_col--; 702 dst_col--;
703 703
704 if (data & 1) 704 if (data & 1)
705 *dst_col = fg_pattern; 705 *dst_col = FB_SCALARPACK(fg_pattern);
706#if 0 706#if 0
707 else 707 else
708 *dst_col = bg_pattern; 708 *dst_col = bg_pattern;
@@ -719,7 +719,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src,
719 while (src < src_end); 719 while (src < src_end);
720} 720}
721 721
722/* draw alpha bitmap for anti-alias font */ 722
723#define ALPHA_COLOR_FONT_DEPTH 2 723#define ALPHA_COLOR_FONT_DEPTH 2
724#define ALPHA_COLOR_LOOKUP_SHIFT (1 << ALPHA_COLOR_FONT_DEPTH) 724#define ALPHA_COLOR_LOOKUP_SHIFT (1 << ALPHA_COLOR_FONT_DEPTH)
725#define ALPHA_COLOR_LOOKUP_SIZE ((1 << ALPHA_COLOR_LOOKUP_SHIFT) - 1) 725#define ALPHA_COLOR_LOOKUP_SIZE ((1 << ALPHA_COLOR_LOOKUP_SHIFT) - 1)
@@ -727,6 +727,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src,
727#define ALPHA_COLOR_PIXEL_PER_WORD (32 >> ALPHA_COLOR_FONT_DEPTH) 727#define ALPHA_COLOR_PIXEL_PER_WORD (32 >> ALPHA_COLOR_FONT_DEPTH)
728#ifdef CPU_ARM 728#ifdef CPU_ARM
729#define BLEND_INIT do {} while (0) 729#define BLEND_INIT do {} while (0)
730#define BLEND_FINISH do {} while(0)
730#define BLEND_START(acc, color, alpha) \ 731#define BLEND_START(acc, color, alpha) \
731 asm volatile("mul %0, %1, %2" : "=&r" (acc) : "r" (color), "r" (alpha)) 732 asm volatile("mul %0, %1, %2" : "=&r" (acc) : "r" (color), "r" (alpha))
732#define BLEND_CONT(acc, color, alpha) \ 733#define BLEND_CONT(acc, color, alpha) \
@@ -734,13 +735,18 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src,
734#define BLEND_OUT(acc) do {} while (0) 735#define BLEND_OUT(acc) do {} while (0)
735#elif defined(CPU_COLDFIRE) 736#elif defined(CPU_COLDFIRE)
736#define ALPHA_BITMAP_READ_WORDS 737#define ALPHA_BITMAP_READ_WORDS
737#define BLEND_INIT coldfire_set_macsr(EMAC_UNSIGNED) 738#define BLEND_INIT \
739 unsigned long _macsr = coldfire_get_macsr(); \
740 coldfire_set_macsr(EMAC_UNSIGNED)
741#define BLEND_FINISH \
742 coldfire_set_macsr(_macsr)
738#define BLEND_START(acc, color, alpha) \ 743#define BLEND_START(acc, color, alpha) \
739 asm volatile("mac.l %0, %1, %%acc0" :: "%d" (color), "d" (alpha)) 744 asm volatile("mac.l %0, %1, %%acc0" :: "%d" (color), "d" (alpha))
740#define BLEND_CONT BLEND_START 745#define BLEND_CONT BLEND_START
741#define BLEND_OUT(acc) asm volatile("movclr.l %%acc0, %0" : "=d" (acc)) 746#define BLEND_OUT(acc) asm volatile("movclr.l %%acc0, %0" : "=d" (acc))
742#else 747#else
743#define BLEND_INIT do {} while (0) 748#define BLEND_INIT do {} while (0)
749#define BLEND_FINISH do {} while(0)
744#define BLEND_START(acc, color, alpha) ((acc) = (color) * (alpha)) 750#define BLEND_START(acc, color, alpha) ((acc) = (color) * (alpha))
745#define BLEND_CONT(acc, color, alpha) ((acc) += (color) * (alpha)) 751#define BLEND_CONT(acc, color, alpha) ((acc) += (color) * (alpha))
746#define BLEND_OUT(acc) do {} while (0) 752#define BLEND_OUT(acc) do {} while (0)
@@ -749,6 +755,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src,
749/* Blend the given two colors */ 755/* Blend the given two colors */
750static inline unsigned blend_two_colors(unsigned c1, unsigned c2, unsigned a) 756static inline unsigned blend_two_colors(unsigned c1, unsigned c2, unsigned a)
751{ 757{
758#if LCD_DEPTH == 16
752 a += a >> (ALPHA_COLOR_LOOKUP_SHIFT - 1); 759 a += a >> (ALPHA_COLOR_LOOKUP_SHIFT - 1);
753#if (LCD_PIXELFORMAT == RGB565SWAPPED) 760#if (LCD_PIXELFORMAT == RGB565SWAPPED)
754 c1 = swap16(c1); 761 c1 = swap16(c1);
@@ -767,6 +774,20 @@ static inline unsigned blend_two_colors(unsigned c1, unsigned c2, unsigned a)
767#else 774#else
768 return p; 775 return p;
769#endif 776#endif
777
778#else /* LCD_DEPTH == 24 */
779 unsigned s = c1;
780 unsigned d = c2;
781 unsigned s1 = s & 0xff00ff;
782 unsigned d1 = d & 0xff00ff;
783 a += a >> (ALPHA_COLOR_LOOKUP_SHIFT - 1);
784 d1 = (d1 + ((s1 - d1) * a >> ALPHA_COLOR_LOOKUP_SHIFT)) & 0xff00ff;
785 s &= 0xff00;
786 d &= 0xff00;
787 d = (d + ((s - d) * a >> ALPHA_COLOR_LOOKUP_SHIFT)) & 0xff00;
788
789 return d1 | d;
790#endif
770} 791}
771 792
772static void draw_oriented_alpha_bitmap_part(const unsigned char *src, 793static void draw_oriented_alpha_bitmap_part(const unsigned char *src,
@@ -849,8 +870,9 @@ static void draw_oriented_alpha_bitmap_part(const unsigned char *src,
849#endif 870#endif
850 do 871 do
851 { 872 {
852 *dst=blend_two_colors(*dst, fg_pattern, 873 unsigned color = blend_two_colors(FB_UNPACK_SCALAR_LCD(*dst), fg_pattern,
853 data & ALPHA_COLOR_LOOKUP_SIZE ); 874 data & ALPHA_COLOR_LOOKUP_SIZE );
875 *dst= FB_SCALARPACK(color);
854 dst += LCD_WIDTH; 876 dst += LCD_WIDTH;
855 UPDATE_SRC_ALPHA; 877 UPDATE_SRC_ALPHA;
856 } 878 }
diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c
index 426a81d487..236b5fc63d 100644
--- a/apps/plugins/pacbox/arcade.c
+++ b/apps/plugins/pacbox/arcade.c
@@ -340,7 +340,7 @@ void decodeROMs(void)
340 for( i=0; i<256; i++ ) { 340 for( i=0; i<256; i++ ) {
341 c = decoded_palette[ color_data_[i] & 0x0F ]; 341 c = decoded_palette[ color_data_[i] & 0x0F ];
342#ifdef HAVE_LCD_COLOR 342#ifdef HAVE_LCD_COLOR
343 palette[i] = LCD_RGBPACK((unsigned char) (c), 343 palette[i] = FB_RGBPACK((unsigned char) (c),
344 (unsigned char) (c >> 8), 344 (unsigned char) (c >> 8),
345 (unsigned char) (c >> 16)); 345 (unsigned char) (c >> 16));
346#else 346#else
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 796b66a48d..1003b0c65c 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -470,7 +470,6 @@ static int pf_state;
470 470
471/** code */ 471/** code */
472static bool free_slide_prio(int prio); 472static bool free_slide_prio(int prio);
473static inline unsigned fade_color(pix_t c, unsigned a);
474bool load_new_slide(void); 473bool load_new_slide(void);
475int load_surface(int); 474int load_surface(int);
476 475
@@ -646,10 +645,15 @@ static inline PFreal fcos(int iangle)
646 return fsin(iangle + (IANGLE_MAX >> 2)); 645 return fsin(iangle + (IANGLE_MAX >> 2));
647} 646}
648 647
649static inline unsigned scale_val(unsigned val, unsigned bits) 648/* scales the 8bit subpixel value to native lcd format, indicated by bits */
649static inline unsigned scale_subpixel_lcd(unsigned val, unsigned bits)
650{ 650{
651 (void) bits;
652#if LCD_PIXELFORMAT != RGB888
651 val = val * ((1 << bits) - 1); 653 val = val * ((1 << bits) - 1);
652 return ((val >> 8) + val + 128) >> 8; 654 val = ((val >> 8) + val + 128) >> 8;
655#endif
656 return val;
653} 657}
654 658
655static void output_row_8_transposed(uint32_t row, void * row_in, 659static void output_row_8_transposed(uint32_t row, void * row_in,
@@ -666,10 +670,10 @@ static void output_row_8_transposed(uint32_t row, void * row_in,
666 unsigned r, g, b; 670 unsigned r, g, b;
667 for (; dest < end; dest += ctx->bm->height) 671 for (; dest < end; dest += ctx->bm->height)
668 { 672 {
669 r = scale_val(qp->red, 5); 673 r = scale_subpixel_lcd(qp->red, 5);
670 g = scale_val(qp->green, 6); 674 g = scale_subpixel_lcd(qp->green, 6);
671 b = scale_val((qp++)->blue, 5); 675 b = scale_subpixel_lcd((qp++)->blue, 5);
672 *dest = LCD_RGBPACK_LCD(r,g,b); 676 *dest = FB_RGBPACK_LCD(r,g,b);
673 } 677 }
674#endif 678#endif
675} 679}
@@ -690,11 +694,11 @@ static void output_row_32_transposed(uint32_t row, void * row_in,
690 int r, g, b; 694 int r, g, b;
691 for (; dest < end; dest += ctx->bm->height) 695 for (; dest < end; dest += ctx->bm->height)
692 { 696 {
693 r = scale_val(SC_OUT(qp->r, ctx), 5); 697 r = scale_subpixel_lcd(SC_OUT(qp->r, ctx), 5);
694 g = scale_val(SC_OUT(qp->g, ctx), 6); 698 g = scale_subpixel_lcd(SC_OUT(qp->g, ctx), 6);
695 b = scale_val(SC_OUT(qp->b, ctx), 5); 699 b = scale_subpixel_lcd(SC_OUT(qp->b, ctx), 5);
696 qp++; 700 qp++;
697 *dest = LCD_RGBPACK_LCD(r,g,b); 701 *dest = FB_RGBPACK_LCD(r,g,b);
698 } 702 }
699#endif 703#endif
700} 704}
@@ -714,10 +718,10 @@ static void output_row_32_transposed_fromyuv(uint32_t row, void * row_in,
714 v = SC_OUT(qp->r, ctx); 718 v = SC_OUT(qp->r, ctx);
715 qp++; 719 qp++;
716 yuv_to_rgb(y, u, v, &r, &g, &b); 720 yuv_to_rgb(y, u, v, &r, &g, &b);
717 r = scale_val(r, 5); 721 r = scale_subpixel_lcd(r, 5);
718 g = scale_val(g, 6); 722 g = scale_subpixel_lcd(g, 6);
719 b = scale_val(b, 5); 723 b = scale_subpixel_lcd(b, 5);
720 *dest = LCD_RGBPACK_LCD(r, g, b); 724 *dest = FB_RGBPACK_LCD(r, g, b);
721 } 725 }
722} 726}
723#endif 727#endif
@@ -1793,14 +1797,13 @@ static void recalc_offsets(void)
1793 offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2); 1797 offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2);
1794} 1798}
1795 1799
1796
1797/** 1800/**
1798 Fade the given color by spreading the fb_data (ushort) 1801 Fade the given color by spreading the fb_data
1799 to an uint, multiply and compress the result back to a ushort. 1802 to an uint, multiply and compress the result back to a fb_data.
1800 */ 1803 */
1801#if (LCD_PIXELFORMAT == RGB565SWAPPED) 1804static inline pix_t fade_color(pix_t c, unsigned a)
1802static inline unsigned fade_color(pix_t c, unsigned a)
1803{ 1805{
1806#if (LCD_PIXELFORMAT == RGB565SWAPPED)
1804 unsigned int result; 1807 unsigned int result;
1805 c = swap16(c); 1808 c = swap16(c);
1806 a = (a + 2) & 0x1fc; 1809 a = (a + 2) & 0x1fc;
@@ -1808,24 +1811,29 @@ static inline unsigned fade_color(pix_t c, unsigned a)
1808 result |= ((c & 0x7e0) * a) & 0x7e000; 1811 result |= ((c & 0x7e0) * a) & 0x7e000;
1809 result >>= 8; 1812 result >>= 8;
1810 return swap16(result); 1813 return swap16(result);
1811} 1814
1812#elif LCD_PIXELFORMAT == RGB565 1815#elif LCD_PIXELFORMAT == RGB565
1813static inline unsigned fade_color(pix_t c, unsigned a)
1814{
1815 unsigned int result; 1816 unsigned int result;
1816 a = (a + 2) & 0x1fc; 1817 a = (a + 2) & 0x1fc;
1817 result = ((c & 0xf81f) * a) & 0xf81f00; 1818 result = ((c & 0xf81f) * a) & 0xf81f00;
1818 result |= ((c & 0x7e0) * a) & 0x7e000; 1819 result |= ((c & 0x7e0) * a) & 0x7e000;
1819 result >>= 8; 1820 result >>= 8;
1820 return result; 1821 return result;
1821} 1822
1823#elif LCD_PIXELFORMAT == RGB888
1824 unsigned int pixel = FB_UNPACK_SCALAR_LCD(c);
1825 unsigned int result;
1826 a = (a + 2) & 0x1fc;
1827 result = ((pixel & 0xff00ff) * a) & 0xff00ff00;
1828 result |= ((pixel & 0x00ff00) * a) & 0x00ff0000;
1829 result >>= 8;
1830 return FB_SCALARPACK(result);
1831
1822#else 1832#else
1823static inline unsigned fade_color(pix_t c, unsigned a)
1824{
1825 unsigned val = c; 1833 unsigned val = c;
1826 return MULUQ(val, a) >> 8; 1834 return MULUQ(val, a) >> 8;
1827}
1828#endif 1835#endif
1836}
1829 1837
1830/** 1838/**
1831 * Render a single slide 1839 * Render a single slide
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index 5b2b3ae94d..541d53cdef 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -105,7 +105,7 @@ static void shades_generate(int time)
105 if (blue > 255) 105 if (blue > 255)
106 blue= 510 - blue; 106 blue= 510 - blue;
107 107
108 colours[i] = LCD_RGBPACK(red, green, blue); 108 colours[i] = FB_RGBPACK(red, green, blue);
109 109
110 r++; g++; b++; 110 r++; g++; b++;
111 } 111 }
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 77e834e52b..762f5befc4 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -789,7 +789,7 @@ static const short scoring[4] = { /* scoring for each number of lines */
789struct figure 789struct figure
790{ 790{
791#if LCD_DEPTH >= 2 791#if LCD_DEPTH >= 2
792 unsigned short color[3]; /* color of figure (light,middle,shadow) */ 792 unsigned int color[3]; /* color of figure (light,middle,shadow) */
793#endif 793#endif
794 unsigned short max_or; /* max orientations */ 794 unsigned short max_or; /* max orientations */
795 signed short shapeX[4], shapeY[4]; /* implementation of figures */ 795 signed short shapeX[4], shapeY[4]; /* implementation of figures */
diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h
index 36b971a88b..239ccbec74 100644
--- a/apps/plugins/rockboy/lcd-gb.h
+++ b/apps/plugins/rockboy/lcd-gb.h
@@ -3,6 +3,7 @@
3#ifndef __LCD_GB_H__ 3#ifndef __LCD_GB_H__
4#define __LCD_GB_H__ 4#define __LCD_GB_H__
5 5
6#include "lcd.h"
6#include "defs.h" 7#include "defs.h"
7 8
8struct vissprite 9struct vissprite
@@ -23,7 +24,7 @@ struct scan
23#elif LCD_DEPTH > 4 24#elif LCD_DEPTH > 4
24 byte buf[256]; 25 byte buf[256];
25#endif 26#endif
26 un16 pal[64]; 27 fb_data pal[64];
27 byte pri[256]; 28 byte pri[256];
28 struct vissprite vs[16]; 29 struct vissprite vs[16];
29 int ns, l, x, y, s, t, u, v, wx, wy, wt, wv; 30 int ns, l, x, y, s, t, u, v, wx, wy, wt, wv;
@@ -61,6 +62,3 @@ void pal_dirty(void) ICODE_ATTR;
61void lcd_reset(void); 62void lcd_reset(void);
62 63
63#endif 64#endif
64
65
66
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 2dc983f812..e8d43f772a 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -19,7 +19,7 @@ struct scan scan IBSS_ATTR;
19#define BG (scan.bg) 19#define BG (scan.bg)
20#define WND (scan.wnd) 20#define WND (scan.wnd)
21 21
22#if LCD_DEPTH ==16 22#if LCD_DEPTH >= 16
23#define BUF (scan.buf) 23#define BUF (scan.buf)
24#else 24#else
25#define BUF (scan.buf[scanline_ind]) 25#define BUF (scan.buf[scanline_ind])
@@ -1154,6 +1154,7 @@ void set_pal(void)
1154static void updatepalette(int i) 1154static void updatepalette(int i)
1155{ 1155{
1156 int c, r, g, b; 1156 int c, r, g, b;
1157 fb_data px;
1157 1158
1158 c = (lcd.pal[i<<1] | ((int)lcd.pal[(i<<1)|1] << 8)) & 0x7FFF; 1159 c = (lcd.pal[i<<1] | ((int)lcd.pal[(i<<1)|1] << 8)) & 0x7FFF;
1159 r = (c & 0x001F) << 3; 1160 r = (c & 0x001F) << 3;
@@ -1167,18 +1168,16 @@ static void updatepalette(int i)
1167 g = (g >> fb.cc[1].r) << fb.cc[1].l; 1168 g = (g >> fb.cc[1].r) << fb.cc[1].l;
1168 b = (b >> fb.cc[2].r) << fb.cc[2].l; 1169 b = (b >> fb.cc[2].r) << fb.cc[2].l;
1169 1170
1170#if LCD_PIXELFORMAT == RGB565
1171 c = r|g|b; 1171 c = r|g|b;
1172#elif LCD_PIXELFORMAT == RGB565SWAPPED 1172
1173 c = swap16(r|g|b); 1173 px = FB_SCALARPACK_LCD(c);
1174#endif
1175 1174
1176 /* updatepalette might get called, but the pallete does not necessarily 1175 /* updatepalette might get called, but the pallete does not necessarily
1177 * need to be updated. 1176 * need to be updated.
1178 */ 1177 */
1179 if(PAL[i]!=c) 1178 if(memcmp(&PAL[i], &px, sizeof(fb_data)))
1180 { 1179 {
1181 PAL[i] = c; 1180 PAL[i] = px;
1182#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) 1181#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
1183 rb->lcd_pal256_update_pal(PAL); 1182 rb->lcd_pal256_update_pal(PAL);
1184#endif 1183#endif
@@ -1256,4 +1255,3 @@ void lcd_reset(void)
1256 lcd_begin(); 1255 lcd_begin();
1257 vram_dirty(); 1256 vram_dirty();
1258} 1257}
1259
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c
index 1bf63b7a74..a758f73da3 100644
--- a/apps/plugins/rockboy/sys_rockbox.c
+++ b/apps/plugins/rockboy/sys_rockbox.c
@@ -261,12 +261,21 @@ void vid_init(void)
261 fb.enabled=1; 261 fb.enabled=1;
262 262
263#if defined(HAVE_LCD_COLOR) 263#if defined(HAVE_LCD_COLOR)
264#if LCD_DEPTH == 24
265 fb.cc[0].r = 0; /* 8-8 (wasted bits on red) */
266 fb.cc[0].l = 16; /* this is the offset to the R bits (24-8) */
267 fb.cc[1].r = 0; /* 8-6 (wasted bits on green) */
268 fb.cc[1].l = 8; /* This is the offset to the G bits (24-8-8) */
269 fb.cc[2].r = 0; /* 8-5 (wasted bits on red) */
270 fb.cc[2].l = 0; /* This is the offset to the B bits (24-8-8-8) */
271#else
264 fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */ 272 fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */
265 fb.cc[0].l = 11; /* this is the offset to the R bits (16-5) */ 273 fb.cc[0].l = 11; /* this is the offset to the R bits (16-5) */
266 fb.cc[1].r = 2; /* 8-6 (wasted bits on green) */ 274 fb.cc[1].r = 2; /* 8-6 (wasted bits on green) */
267 fb.cc[1].l = 5; /* This is the offset to the G bits (16-5-6) */ 275 fb.cc[1].l = 5; /* This is the offset to the G bits (16-5-6) */
268 fb.cc[2].r = 3; /* 8-5 (wasted bits on red) */ 276 fb.cc[2].r = 3; /* 8-5 (wasted bits on red) */
269 fb.cc[2].l = 0; /* This is the offset to the B bits (16-5-6-5) */ 277 fb.cc[2].l = 0; /* This is the offset to the B bits (16-5-6-5) */
278#endif
270#else 279#else
271 fb.mode=3; 280 fb.mode=3;
272#endif 281#endif
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c
index be480bcbb1..5e1479cd3b 100644
--- a/apps/plugins/superdom.c
+++ b/apps/plugins/superdom.c
@@ -23,8 +23,6 @@
23#include "lib/display_text.h" 23#include "lib/display_text.h"
24#include "pluginbitmaps/superdom_boarditems.h" 24#include "pluginbitmaps/superdom_boarditems.h"
25 25
26
27extern const fb_data superdom_boarditems[];
28char buf[255]; 26char buf[255];
29 27
30#define COLOUR_DARK 0 28#define COLOUR_DARK 0
@@ -32,7 +30,7 @@ char buf[255];
32 30
33#define MARGIN 5 31#define MARGIN 5
34 32
35#if (LCD_DEPTH == 16) 33#if (LCD_DEPTH >= 16)
36#define MY_BITMAP_PART rb->lcd_bitmap_transparent_part 34#define MY_BITMAP_PART rb->lcd_bitmap_transparent_part
37#else 35#else
38#define MY_BITMAP_PART rb->lcd_mono_bitmap_part 36#define MY_BITMAP_PART rb->lcd_mono_bitmap_part
diff --git a/apps/plugins/zxbox/zxvid_16bpp.c b/apps/plugins/zxbox/zxvid_16bpp.c
index 19ac0f2d5c..6380d3d7d7 100644
--- a/apps/plugins/zxbox/zxvid_16bpp.c
+++ b/apps/plugins/zxbox/zxvid_16bpp.c
@@ -12,7 +12,7 @@
12#define IB0 (0xFF-B0) 12#define IB0 (0xFF-B0)
13#define IB1 (0xFF-B1) 13#define IB1 (0xFF-B1)
14 14
15static const fb_data _16bpp_colors[32] = { 15static const unsigned _16bpp_colors[32] = {
16 /* normal */ 16 /* normal */
17 LCD_RGBPACK(N0, N0, N0), LCD_RGBPACK(N0, N0, N1), 17 LCD_RGBPACK(N0, N0, N0), LCD_RGBPACK(N0, N0, N1),
18 LCD_RGBPACK(N1, N0, N0), LCD_RGBPACK(N1, N0, N1), 18 LCD_RGBPACK(N1, N0, N0), LCD_RGBPACK(N1, N0, N1),
@@ -60,7 +60,7 @@ void update_screen(void)
60 */ 60 */
61 frameb = rb->lcd_framebuffer; 61 frameb = rb->lcd_framebuffer;
62 for ( y = 0 ; y < HEIGHT*WIDTH; y++ ){ 62 for ( y = 0 ; y < HEIGHT*WIDTH; y++ ){
63 frameb[y] = _16bpp_colors[(unsigned)sp_image[y]]; 63 frameb[y] = FB_SCALARPACK(_16bpp_colors[(unsigned)sp_image[y]]);
64 } 64 }
65 65
66#else 66#else
@@ -74,7 +74,7 @@ void update_screen(void)
74 srcx = 0; /* reset our x counter before each row... */ 74 srcx = 0; /* reset our x counter before each row... */
75 for(x = 0; x < LCD_WIDTH; x++) 75 for(x = 0; x < LCD_WIDTH; x++)
76 { 76 {
77 *frameb = _16bpp_colors[image[srcx>>16]]; 77 *frameb = FB_SCALARPACK(_16bpp_colors[image[srcx>>16]]);
78 srcx += X_STEP; /* move through source image */ 78 srcx += X_STEP; /* move through source image */
79 frameb++; 79 frameb++;
80 } 80 }
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c
index a6d6dd71b1..a9cc34b2c6 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -455,7 +455,7 @@ void output_row_8_native(uint32_t row, void * row_in,
455 *dest++ |= vi_pattern[bright] << shift; 455 *dest++ |= vi_pattern[bright] << shift;
456 } 456 }
457#endif /* LCD_PIXELFORMAT */ 457#endif /* LCD_PIXELFORMAT */
458#elif LCD_DEPTH == 16 458#elif LCD_DEPTH >= 16
459 /* iriver h300, colour iPods, X5 */ 459 /* iriver h300, colour iPods, X5 */
460 (void)fb_width; 460 (void)fb_width;
461 fb_data *dest = STRIDE_MAIN((fb_data *)ctx->bm->data + fb_width * row, 461 fb_data *dest = STRIDE_MAIN((fb_data *)ctx->bm->data + fb_width * row,
@@ -470,15 +470,18 @@ void output_row_8_native(uint32_t row, void * row_in,
470 bm_alpha += ALIGN_UP(ctx->bm->width, 2) * row/2; 470 bm_alpha += ALIGN_UP(ctx->bm->width, 2) * row/2;
471 471
472 for (col = 0; col < ctx->bm->width; col++) { 472 for (col = 0; col < ctx->bm->width; col++) {
473 (void) delta;
473 if (ctx->dither) 474 if (ctx->dither)
474 delta = DITHERXDY(col,dy); 475 delta = DITHERXDY(col,dy);
475 r = qp->red; 476 r = qp->red;
476 g = qp->green; 477 g = qp->green;
477 b = qp->blue; 478 b = qp->blue;
479#if LCD_DEPTH < 24
478 r = (31 * r + (r >> 3) + delta) >> 8; 480 r = (31 * r + (r >> 3) + delta) >> 8;
479 g = (63 * g + (g >> 2) + delta) >> 8; 481 g = (63 * g + (g >> 2) + delta) >> 8;
480 b = (31 * b + (b >> 3) + delta) >> 8; 482 b = (31 * b + (b >> 3) + delta) >> 8;
481 *dest = LCD_RGBPACK_LCD(r, g, b); 483#endif
484 *dest = FB_RGBPACK_LCD(r, g, b);
482 dest += STRIDE_MAIN(1, ctx->bm->height); 485 dest += STRIDE_MAIN(1, ctx->bm->height);
483 if (bm_alpha) { 486 if (bm_alpha) {
484 /* pack alpha channel for 2 pixels into 1 byte and negate 487 /* pack alpha channel for 2 pixels into 1 byte and negate
@@ -526,8 +529,8 @@ int read_bmp_fd(int fd,
526 bool dither = false; 529 bool dither = false;
527#endif 530#endif
528 531
529#ifdef HAVE_REMOTE_LCD
530 bool remote = false; 532 bool remote = false;
533#ifdef HAVE_REMOTE_LCD
531 if (format & FORMAT_REMOTE) { 534 if (format & FORMAT_REMOTE) {
532 remote = true; 535 remote = true;
533#if LCD_REMOTE_DEPTH == 1 536#if LCD_REMOTE_DEPTH == 1
@@ -710,9 +713,7 @@ int read_bmp_fd(int fd,
710 case 16: 713 case 16:
711#if LCD_DEPTH >= 16 714#if LCD_DEPTH >= 16
712 /* don't dither 16 bit BMP to LCD with same or larger depth */ 715 /* don't dither 16 bit BMP to LCD with same or larger depth */
713#ifdef HAVE_REMOTE_LCD
714 if (!remote) 716 if (!remote)
715#endif
716 dither = false; 717 dither = false;
717#endif 718#endif
718 if (compression == 0) { /* BI_RGB, i.e. 15 bit */ 719 if (compression == 0) { /* BI_RGB, i.e. 15 bit */
@@ -755,6 +756,12 @@ int read_bmp_fd(int fd,
755 break; 756 break;
756 } 757 }
757 758
759#if LCD_DEPTH >= 24
760 /* Never dither 24/32 bit BMP to 24 bit LCDs */
761 if (depth >= 24 && !remote)
762 dither = false;
763#endif
764
758 /* Search to the beginning of the image data */ 765 /* Search to the beginning of the image data */
759 lseek(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET); 766 lseek(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET);
760 767
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c
index 32384537d4..ac6b7a3120 100644
--- a/apps/recorder/resize.c
+++ b/apps/recorder/resize.c
@@ -680,6 +680,7 @@ static void output_row_32_native_fromyuv(uint32_t row, void * row_in,
680 unsigned r, g, b, y, u, v; 680 unsigned r, g, b, y, u, v;
681 681
682 for (col = 0; col < ctx->bm->width; col++) { 682 for (col = 0; col < ctx->bm->width; col++) {
683 (void) delta;
683 if (ctx->dither) 684 if (ctx->dither)
684 delta = DITHERXDY(col,dy); 685 delta = DITHERXDY(col,dy);
685 y = SC_OUT(qp->b, ctx); 686 y = SC_OUT(qp->b, ctx);
@@ -687,10 +688,12 @@ static void output_row_32_native_fromyuv(uint32_t row, void * row_in,
687 v = SC_OUT(qp->r, ctx); 688 v = SC_OUT(qp->r, ctx);
688 qp++; 689 qp++;
689 yuv_to_rgb(y, u, v, &r, &g, &b); 690 yuv_to_rgb(y, u, v, &r, &g, &b);
691#if LCD_DEPTH < 24
690 r = (31 * r + (r >> 3) + delta) >> 8; 692 r = (31 * r + (r >> 3) + delta) >> 8;
691 g = (63 * g + (g >> 2) + delta) >> 8; 693 g = (63 * g + (g >> 2) + delta) >> 8;
692 b = (31 * b + (b >> 3) + delta) >> 8; 694 b = (31 * b + (b >> 3) + delta) >> 8;
693 *dest = LCD_RGBPACK_LCD(r, g, b); 695#endif
696 *dest = FB_RGBPACK_LCD(r, g, b);
694 dest += DEST_STEP; 697 dest += DEST_STEP;
695 } 698 }
696} 699}
@@ -764,7 +767,7 @@ static void output_row_32_native(uint32_t row, void * row_in,
764 *dest++ |= vi_pattern[bright] << shift; 767 *dest++ |= vi_pattern[bright] << shift;
765 } 768 }
766#endif /* LCD_PIXELFORMAT */ 769#endif /* LCD_PIXELFORMAT */
767#elif LCD_DEPTH == 16 770#elif LCD_DEPTH >= 16
768 /* iriver h300, colour iPods, X5 */ 771 /* iriver h300, colour iPods, X5 */
769 (void)fb_width; 772 (void)fb_width;
770 fb_data *dest = STRIDE_MAIN((fb_data *)ctx->bm->data + fb_width * row, 773 fb_data *dest = STRIDE_MAIN((fb_data *)ctx->bm->data + fb_width * row,
@@ -780,16 +783,19 @@ static void output_row_32_native(uint32_t row, void * row_in,
780 bm_alpha += ALIGN_UP(ctx->bm->width, 2)*row/2; 783 bm_alpha += ALIGN_UP(ctx->bm->width, 2)*row/2;
781 784
782 for (col = 0; col < ctx->bm->width; col++) { 785 for (col = 0; col < ctx->bm->width; col++) {
786 (void) delta;
783 if (ctx->dither) 787 if (ctx->dither)
784 delta = DITHERXDY(col,dy); 788 delta = DITHERXDY(col,dy);
785 q0 = *qp++; 789 q0 = *qp++;
786 r = SC_OUT(q0.r, ctx); 790 r = SC_OUT(q0.r, ctx);
787 g = SC_OUT(q0.g, ctx); 791 g = SC_OUT(q0.g, ctx);
788 b = SC_OUT(q0.b, ctx); 792 b = SC_OUT(q0.b, ctx);
793#if LCD_DEPTH < 24
789 r = (31 * r + (r >> 3) + delta) >> 8; 794 r = (31 * r + (r >> 3) + delta) >> 8;
790 g = (63 * g + (g >> 2) + delta) >> 8; 795 g = (63 * g + (g >> 2) + delta) >> 8;
791 b = (31 * b + (b >> 3) + delta) >> 8; 796 b = (31 * b + (b >> 3) + delta) >> 8;
792 *dest = LCD_RGBPACK_LCD(r, g, b); 797#endif
798 *dest = FB_RGBPACK_LCD(r, g, b);
793 dest += STRIDE_MAIN(1, ctx->bm->height); 799 dest += STRIDE_MAIN(1, ctx->bm->height);
794 if (bm_alpha) { 800 if (bm_alpha) {
795 /* pack alpha channel for 2 pixels into 1 byte */ 801 /* pack alpha channel for 2 pixels into 1 byte */