summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-07-28 07:35:45 +0000
committerJens Arnold <amiconn@rockbox.org>2006-07-28 07:35:45 +0000
commit05ddd9a44eb565e936274b6f73fc76f7476113a7 (patch)
tree0c2a5a8db4c86196deb06615b246d66e920784b7
parentcb36fec3922cb1317bdb06a6497370f188694d4e (diff)
downloadrockbox-05ddd9a44eb565e936274b6f73fc76f7476113a7.tar.gz
rockbox-05ddd9a44eb565e936274b6f73fc76f7476113a7.zip
X5 remote LCD drawing. This will break target linking atm - lcd_remote_update[_rect]() are not yet implemented.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10347 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/color_picker.c4
-rw-r--r--apps/plugin.c8
-rw-r--r--apps/plugin.h14
-rw-r--r--apps/plugins/snow.c4
-rw-r--r--apps/plugins/stats.c24
-rw-r--r--firmware/SOURCES10
-rwxr-xr-xfirmware/drivers/lcd-remote-2bit-vi.c1085
-rw-r--r--firmware/export/config-iaudiox5.h9
-rw-r--r--firmware/export/config.h2
-rw-r--r--tools/bmp2rb.c22
-rwxr-xr-xtools/configure2
-rw-r--r--uisimulator/sdl/SOURCES2
-rw-r--r--uisimulator/sdl/lcd-remote-bitmap.c (renamed from uisimulator/sdl/lcd-remote.c)13
-rw-r--r--uisimulator/sdl/lcd-remote-bitmap.h (renamed from uisimulator/sdl/lcd-remote.h)1
-rw-r--r--uisimulator/sdl/uisdl.c2
-rw-r--r--uisimulator/sdl/uisdl.h16
16 files changed, 1181 insertions, 37 deletions
diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c
index edf6a49570..f2e482c651 100644
--- a/apps/gui/color_picker.c
+++ b/apps/gui/color_picker.c
@@ -73,6 +73,10 @@
73#define SLIDER_OK BUTTON_SELECT 73#define SLIDER_OK BUTTON_SELECT
74#define SLIDER_CANCEL BUTTON_PLAY 74#define SLIDER_CANCEL BUTTON_PLAY
75 75
76/* FIXME: chosen at will to make it compile */
77#define SLIDER_RC_OK BUTTON_RC_PLAY
78#define SLIDER_RC_CANCEL BUTTON_RC_REC
79
76#endif 80#endif
77 81
78static const int max_val[3] = {LCD_MAX_RED,LCD_MAX_GREEN,LCD_MAX_BLUE}; 82static const int max_val[3] = {LCD_MAX_RED,LCD_MAX_GREEN,LCD_MAX_BLUE};
diff --git a/apps/plugin.c b/apps/plugin.c
index e7909f764b..f9f7e42b80 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -454,6 +454,14 @@ static const struct plugin_api rockbox_api = {
454 font_get_bits, 454 font_get_bits,
455 font_load, 455 font_load,
456#endif 456#endif
457#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
458 lcd_remote_set_foreground,
459 lcd_remote_get_foreground,
460 lcd_remote_set_background,
461 lcd_remote_get_background,
462 lcd_remote_bitmap_part,
463 lcd_remote_bitmap,
464#endif
457}; 465};
458 466
459int plugin_load(const char* plugin, void* parameter) 467int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 3cd3fa6b63..0187de8678 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -104,7 +104,7 @@
104#define PLUGIN_MAGIC 0x526F634B /* RocK */ 104#define PLUGIN_MAGIC 0x526F634B /* RocK */
105 105
106/* increase this every time the api struct changes */ 106/* increase this every time the api struct changes */
107#define PLUGIN_API_VERSION 24 107#define PLUGIN_API_VERSION 25
108 108
109/* update this to latest version if a change to the api struct breaks 109/* update this to latest version if a change to the api struct breaks
110 backwards compatibility (and please take the opportunity to sort in any 110 backwards compatibility (and please take the opportunity to sort in any
@@ -221,7 +221,7 @@ struct plugin_api {
221 void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style); 221 void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style);
222 void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string, 222 void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string,
223 int style); 223 int style);
224 unsigned char* lcd_remote_framebuffer; 224 fb_remote_data* lcd_remote_framebuffer;
225 void (*lcd_remote_update)(void); 225 void (*lcd_remote_update)(void);
226 void (*lcd_remote_update_rect)(int x, int y, int width, int height); 226 void (*lcd_remote_update_rect)(int x, int y, int width, int height);
227 227
@@ -529,6 +529,16 @@ struct plugin_api {
529 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); 529 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
530 struct font* (*font_load)(const char *path); 530 struct font* (*font_load)(const char *path);
531#endif 531#endif
532#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
533 void (*lcd_remote_set_foreground)(unsigned foreground);
534 unsigned (*lcd_remote_get_foreground)(void);
535 void (*lcd_remote_set_background)(unsigned foreground);
536 unsigned (*lcd_remote_get_background)(void);
537 void (*lcd_remote_bitmap_part)(const fb_remote_data *src, int src_x, int src_y,
538 int stride, int x, int y, int width, int height);
539 void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width,
540 int height);
541#endif
532}; 542};
533 543
534/* plugin header */ 544/* plugin header */
diff --git a/apps/plugins/snow.c b/apps/plugins/snow.c
index bde8be883c..35efad70da 100644
--- a/apps/plugins/snow.c
+++ b/apps/plugins/snow.c
@@ -140,8 +140,8 @@ static void snow_move(void)
140#ifdef HAVE_REMOTE_LCD 140#ifdef HAVE_REMOTE_LCD
141 if (particles[i][0] <= LCD_REMOTE_WIDTH 141 if (particles[i][0] <= LCD_REMOTE_WIDTH
142 && particles[i][1] <= LCD_REMOTE_HEIGHT) { 142 && particles[i][1] <= LCD_REMOTE_HEIGHT) {
143 rb->lcd_remote_bitmap(flake,particles[i][0],particles[i][1], 143 rb->lcd_remote_mono_bitmap(flake,particles[i][0],particles[i][1],
144 FLAKE_WIDTH,FLAKE_WIDTH); 144 FLAKE_WIDTH,FLAKE_WIDTH);
145 } 145 }
146#endif 146#endif
147 } 147 }
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index 1e538f90b4..c6ed928de5 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -30,20 +30,30 @@ static int fontwidth, fontheight;
30 30
31#if CONFIG_KEYPAD == PLAYER_PAD 31#if CONFIG_KEYPAD == PLAYER_PAD
32#define STATS_STOP BUTTON_STOP 32#define STATS_STOP BUTTON_STOP
33#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ 33
34 (CONFIG_KEYPAD == IPOD_3G_PAD) 34#elif (CONFIG_KEYPAD == RECORDER_PAD) \
35 || (CONFIG_KEYPAD == ONDIO_PAD)
36#define STATS_STOP BUTTON_OFF
37
38#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \
39 || (CONFIG_KEYPAD == IRIVER_H300_PAD)
40#define STATS_STOP BUTTON_OFF
41#define STATS_STOP_REMOTE BUTTON_RC_STOP
42
43#elif (CONFIG_KEYPAD == IPOD_4G_PAD) \
44 || (CONFIG_KEYPAD == IPOD_3G_PAD)
35#define STATS_STOP BUTTON_MENU 45#define STATS_STOP BUTTON_MENU
46
36#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD 47#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
37#define STATS_STOP BUTTON_PLAY 48#define STATS_STOP BUTTON_PLAY
49
38#elif CONFIG_KEYPAD == IAUDIO_X5_PAD 50#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
39#define STATS_STOP BUTTON_POWER 51#define STATS_STOP BUTTON_POWER
52#define STATS_STOP_REMOTE BUTTON_RC_PLAY
53
40#elif CONFIG_KEYPAD == GIGABEAT_PAD 54#elif CONFIG_KEYPAD == GIGABEAT_PAD
41#define STATS_STOP BUTTON_A 55#define STATS_STOP BUTTON_A
42#else 56
43#define STATS_STOP BUTTON_OFF
44#endif
45#ifdef HAVE_REMOTE_LCD
46#define STATS_STOP_REMOTE BUTTON_RC_STOP
47#endif 57#endif
48 58
49/* TODO: Better get the exts from the filetypes var in tree.c */ 59/* TODO: Better get the exts from the filetypes var in tree.c */
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 70a4c4ad25..601fcab3a2 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -80,6 +80,13 @@ drivers/lcd-h100.c
80drivers/lcd-16bit.c 80drivers/lcd-16bit.c
81#endif 81#endif
82#endif 82#endif
83#ifdef HAVE_REMOTE_LCD
84#if LCD_REMOTE_DEPTH == 1
85drivers/lcd-h100-remote.c
86#elif LCD_REMOTE_DEPTH == 2
87drivers/lcd-remote-2bit-vi.c
88#endif
89#endif
83#if CONFIG_LCD==LCD_IPODNANO || CONFIG_LCD==LCD_IPODCOLOR || CONFIG_LCD == LCD_IPOD2BPP 90#if CONFIG_LCD==LCD_IPODNANO || CONFIG_LCD==LCD_IPODCOLOR || CONFIG_LCD == LCD_IPOD2BPP
84drivers/lcd-ipod.c 91drivers/lcd-ipod.c
85#endif 92#endif
@@ -178,9 +185,6 @@ usb.c
178bitswap.S 185bitswap.S
179descramble.S 186descramble.S
180#endif 187#endif
181#ifdef HAVE_REMOTE_LCD
182drivers/lcd-h100-remote.c
183#endif
184#if defined(HAVE_UDA1380) && !defined(SIMULATOR) 188#if defined(HAVE_UDA1380) && !defined(SIMULATOR)
185drivers/uda1380.c 189drivers/uda1380.c
186#elif defined(HAVE_WM8975) && !defined(SIMULATOR) 190#elif defined(HAVE_WM8975) && !defined(SIMULATOR)
diff --git a/firmware/drivers/lcd-remote-2bit-vi.c b/firmware/drivers/lcd-remote-2bit-vi.c
new file mode 100755
index 0000000000..cf486b5d0d
--- /dev/null
+++ b/firmware/drivers/lcd-remote-2bit-vi.c
@@ -0,0 +1,1085 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 Jens Arnold
11 *
12 * Rockbox driver for 2bit vertically interleaved remote LCDs
13 *
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include "cpu.h"
23#include "lcd.h"
24#include "lcd-remote.h"
25#include "kernel.h"
26#include "thread.h"
27#include <string.h>
28#include <stdlib.h>
29#include "memory.h"
30#include "file.h"
31#include "debug.h"
32#include "system.h"
33#include "font.h"
34#include "rbunicode.h"
35#include "bidi.h"
36
37#define SCROLLABLE_LINES (((LCD_REMOTE_HEIGHT+4)/5 < 32) ? (LCD_REMOTE_HEIGHT+4)/5 : 32)
38
39/*** globals ***/
40
41fb_remote_data lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_FBWIDTH]
42 IBSS_ATTR;
43
44static const fb_data patterns[4] = {0xFFFF, 0xFF00, 0x00FF, 0x0000};
45
46static unsigned fg_pattern IDATA_ATTR = 0xFFFF; /* initially black */
47static unsigned bg_pattern IDATA_ATTR = 0x0000; /* initially white */
48static int drawmode = DRMODE_SOLID;
49static int xmargin = 0;
50static int ymargin = 0;
51static int curfont = FONT_SYSFIXED;
52
53/* scrolling */
54static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */
55static void scroll_thread(void);
56static long scroll_stack[DEFAULT_STACK_SIZE/sizeof(long)];
57static const char scroll_name[] = "remote_scroll";
58static int scroll_ticks = 12; /* # of ticks between updates*/
59static int scroll_delay = HZ/2; /* ticks delay before start */
60static int scroll_step = 6; /* pixels per scroll step */
61static int bidir_limit = 50; /* percent */
62static struct scrollinfo scroll[SCROLLABLE_LINES];
63
64static const char scroll_tick_table[16] = {
65 /* Hz values:
66 1, 1.25, 1.55, 2, 2.5, 3.12, 4, 5, 6.25, 8.33, 10, 12.5, 16.7, 20, 25, 33 */
67 100, 80, 64, 50, 40, 32, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3
68};
69
70
71/* LCD init */
72void lcd_remote_init(void)
73{
74 lcd_remote_clear_display();
75#if 0 /* FIXME */
76 /* Call device specific init */
77 remote_init();
78#endif
79 create_thread(scroll_thread, scroll_stack,
80 sizeof(scroll_stack), scroll_name);
81}
82
83/*** parameter handling ***/
84
85void lcd_remote_set_drawmode(int mode)
86{
87 drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
88}
89
90int lcd_remote_get_drawmode(void)
91{
92 return drawmode;
93}
94
95void lcd_remote_set_foreground(unsigned brightness)
96{
97 fg_pattern = patterns[brightness & 3];
98}
99
100unsigned lcd_remote_get_foreground(void)
101{
102 return (~fg_pattern >> 7) & 3;
103}
104
105void lcd_remote_set_background(unsigned brightness)
106{
107 bg_pattern = patterns[brightness & 3];
108}
109
110unsigned lcd_remote_get_background(void)
111{
112 return (~bg_pattern >> 7) & 3;
113}
114
115void lcd_remote_set_drawinfo(int mode, unsigned fg_brightness,
116 unsigned bg_brightness)
117{
118 lcd_remote_set_drawmode(mode);
119 lcd_remote_set_foreground(fg_brightness);
120 lcd_remote_set_background(bg_brightness);
121}
122
123void lcd_remote_setmargins(int x, int y)
124{
125 xmargin = x;
126 ymargin = y;
127}
128
129int lcd_remote_getxmargin(void)
130{
131 return xmargin;
132}
133
134int lcd_remote_getymargin(void)
135{
136 return ymargin;
137}
138
139void lcd_remote_setfont(int newfont)
140{
141 curfont = newfont;
142}
143
144int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h)
145{
146 return font_getstringsize(str, w, h, curfont);
147}
148
149/*** low-level drawing functions ***/
150
151static void setpixel(int x, int y)
152{
153 unsigned mask = 0x0101 << (y & 7);
154 fb_remote_data *address = &lcd_remote_framebuffer[y>>3][x];
155 unsigned data = *address;
156
157 *address = data ^ ((data ^ fg_pattern) & mask);
158}
159
160static void clearpixel(int x, int y)
161{
162 unsigned mask = 0x0101 << (y & 7);
163 fb_remote_data *address = &lcd_remote_framebuffer[y>>3][x];
164 unsigned data = *address;
165
166 *address = data ^ ((data ^ bg_pattern) & mask);
167}
168
169static void flippixel(int x, int y)
170{
171 unsigned mask = 0x0101 << (y & 7);
172 fb_remote_data *address = &lcd_remote_framebuffer[y>>3][x];
173
174 *address ^= mask;
175}
176
177static void nopixel(int x, int y)
178{
179 (void)x;
180 (void)y;
181}
182
183lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8] = {
184 flippixel, nopixel, setpixel, setpixel,
185 nopixel, clearpixel, nopixel, clearpixel
186};
187
188/* 'mask' and 'bits' contain 2 bits per pixel */
189static void flipblock(fb_remote_data *address, unsigned mask, unsigned bits)
190 ICODE_ATTR;
191static void flipblock(fb_remote_data *address, unsigned mask, unsigned bits)
192{
193 *address ^= bits & mask;
194}
195
196static void bgblock(fb_remote_data *address, unsigned mask, unsigned bits)
197 ICODE_ATTR;
198static void bgblock(fb_remote_data *address, unsigned mask, unsigned bits)
199{
200 unsigned data = *address;
201
202 *address = data ^ ((data ^ bg_pattern) & mask & ~bits);
203}
204
205static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits)
206 ICODE_ATTR;
207static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits)
208{
209 unsigned data = *address;
210
211 *address = data ^ ((data ^ fg_pattern) & mask & bits);
212}
213
214static void solidblock(fb_remote_data *address, unsigned mask, unsigned bits)
215 ICODE_ATTR;
216static void solidblock(fb_remote_data *address, unsigned mask, unsigned bits)
217{
218 unsigned data = *address;
219 unsigned bgp = bg_pattern;
220
221 bits = bgp ^ ((bgp ^ fg_pattern) & bits);
222 *address = data ^ ((data ^ bits) & mask);
223}
224
225static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits)
226 ICODE_ATTR;
227static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits)
228{
229 *address ^= ~bits & mask;
230}
231
232static void bginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
233 ICODE_ATTR;
234static void bginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
235{
236 unsigned data = *address;
237
238 *address = data ^ ((data ^ bg_pattern) & mask & bits);
239}
240
241static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
242 ICODE_ATTR;
243static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
244{
245 unsigned data = *address;
246
247 *address = data ^ ((data ^ fg_pattern) & mask & ~bits);
248}
249
250static void solidinvblock(fb_remote_data *address, unsigned mask, unsigned bits)
251 ICODE_ATTR;
252static void solidinvblock(fb_remote_data *address, unsigned mask, unsigned bits)
253{
254 unsigned data = *address;
255 unsigned fgp = fg_pattern;
256
257 bits = fgp ^ ((fgp ^ bg_pattern) & bits);
258 *address = data ^ ((data ^ bits) & mask);
259}
260
261lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8] = {
262 flipblock, bgblock, fgblock, solidblock,
263 flipinvblock, bginvblock, fginvblock, solidinvblock
264};
265
266static inline void setblock(fb_remote_data *address, unsigned mask, unsigned bits)
267{
268 unsigned data = *address;
269
270 bits ^= data;
271 *address = data ^ (bits & mask);
272}
273
274/*** drawing functions ***/
275
276/* Clear the whole display */
277void lcd_remote_clear_display(void)
278{
279 unsigned bits = (drawmode & DRMODE_INVERSEVID) ? fg_pattern : bg_pattern;
280
281 memset16(lcd_remote_framebuffer, bits, sizeof lcd_remote_framebuffer / 2);
282 scrolling_lines = 0;
283}
284
285/* Set a single pixel */
286void lcd_remote_drawpixel(int x, int y)
287{
288 if (((unsigned)x < LCD_REMOTE_WIDTH) && ((unsigned)y < LCD_REMOTE_HEIGHT))
289 lcd_remote_pixelfuncs[drawmode](x, y);
290}
291
292/* Draw a line */
293void lcd_remote_drawline(int x1, int y1, int x2, int y2)
294{
295 int numpixels;
296 int i;
297 int deltax, deltay;
298 int d, dinc1, dinc2;
299 int x, xinc1, xinc2;
300 int y, yinc1, yinc2;
301 lcd_remote_pixelfunc_type *pfunc = lcd_remote_pixelfuncs[drawmode];
302
303 deltax = abs(x2 - x1);
304 deltay = abs(y2 - y1);
305 xinc2 = 1;
306 yinc2 = 1;
307
308 if (deltax >= deltay)
309 {
310 numpixels = deltax;
311 d = 2 * deltay - deltax;
312 dinc1 = deltay * 2;
313 dinc2 = (deltay - deltax) * 2;
314 xinc1 = 1;
315 yinc1 = 0;
316 }
317 else
318 {
319 numpixels = deltay;
320 d = 2 * deltax - deltay;
321 dinc1 = deltax * 2;
322 dinc2 = (deltax - deltay) * 2;
323 xinc1 = 0;
324 yinc1 = 1;
325 }
326 numpixels++; /* include endpoints */
327
328 if (x1 > x2)
329 {
330 xinc1 = -xinc1;
331 xinc2 = -xinc2;
332 }
333
334 if (y1 > y2)
335 {
336 yinc1 = -yinc1;
337 yinc2 = -yinc2;
338 }
339
340 x = x1;
341 y = y1;
342
343 for (i = 0; i < numpixels; i++)
344 {
345 if (((unsigned)x < LCD_REMOTE_WIDTH) && ((unsigned)y < LCD_REMOTE_HEIGHT))
346 pfunc(x, y);
347
348 if (d < 0)
349 {
350 d += dinc1;
351 x += xinc1;
352 y += yinc1;
353 }
354 else
355 {
356 d += dinc2;
357 x += xinc2;
358 y += yinc2;
359 }
360 }
361}
362
363/* Draw a horizontal line (optimised) */
364void lcd_remote_hline(int x1, int x2, int y)
365{
366 int x;
367 fb_remote_data *dst, *dst_end;
368 unsigned mask;
369 lcd_remote_blockfunc_type *bfunc;
370
371 /* direction flip */
372 if (x2 < x1)
373 {
374 x = x1;
375 x1 = x2;
376 x2 = x;
377 }
378
379 /* nothing to draw? */
380 if (((unsigned)y >= LCD_REMOTE_HEIGHT) || (x1 >= LCD_REMOTE_WIDTH)
381 || (x2 < 0))
382 return;
383
384 /* clipping */
385 if (x1 < 0)
386 x1 = 0;
387 if (x2 >= LCD_REMOTE_WIDTH)
388 x2 = LCD_REMOTE_WIDTH-1;
389
390 bfunc = lcd_remote_blockfuncs[drawmode];
391 dst = &lcd_remote_framebuffer[y>>3][x1];
392 mask = 0x0101 << (y & 7);
393
394 dst_end = dst + x2 - x1;
395 do
396 bfunc(dst++, mask, 0xFFFFu);
397 while (dst <= dst_end);
398}
399
400/* Draw a vertical line (optimised) */
401void lcd_remote_vline(int x, int y1, int y2)
402{
403 int ny;
404 fb_remote_data *dst;
405 unsigned mask, mask_bottom;
406 lcd_remote_blockfunc_type *bfunc;
407
408 /* direction flip */
409 if (y2 < y1)
410 {
411 ny = y1;
412 y1 = y2;
413 y2 = ny;
414 }
415
416 /* nothing to draw? */
417 if (((unsigned)x >= LCD_REMOTE_WIDTH) || (y1 >= LCD_REMOTE_HEIGHT)
418 || (y2 < 0))
419 return;
420
421 /* clipping */
422 if (y1 < 0)
423 y1 = 0;
424 if (y2 >= LCD_REMOTE_HEIGHT)
425 y2 = LCD_REMOTE_HEIGHT-1;
426
427 bfunc = lcd_remote_blockfuncs[drawmode];
428 dst = &lcd_remote_framebuffer[y1>>3][x];
429 ny = y2 - (y1 & ~7);
430 mask = (0xFFu << (y1 & 7)) & 0xFFu;
431 mask |= mask << 8;
432 mask_bottom = 0xFFu >> (~ny & 7);
433 mask_bottom |= mask_bottom << 8;
434
435 for (; ny >= 8; ny -= 8)
436 {
437 bfunc(dst, mask, 0xFFFFu);
438 dst += LCD_REMOTE_WIDTH;
439 mask = 0xFFFFu;
440 }
441 mask &= mask_bottom;
442 bfunc(dst, mask, 0xFFFFu);
443}
444
445/* Draw a rectangular box */
446void lcd_remote_drawrect(int x, int y, int width, int height)
447{
448 if ((width <= 0) || (height <= 0))
449 return;
450
451 int x2 = x + width - 1;
452 int y2 = y + height - 1;
453
454 lcd_remote_vline(x, y, y2);
455 lcd_remote_vline(x2, y, y2);
456 lcd_remote_hline(x, x2, y);
457 lcd_remote_hline(x, x2, y2);
458}
459
460/* Fill a rectangular area */
461void lcd_remote_fillrect(int x, int y, int width, int height)
462{
463 int ny;
464 fb_remote_data *dst, *dst_end;
465 unsigned mask, mask_bottom;
466 unsigned bits = 0;
467 lcd_remote_blockfunc_type *bfunc;
468 bool fillopt = false;
469
470 /* nothing to draw? */
471 if ((width <= 0) || (height <= 0) || (x >= LCD_REMOTE_WIDTH)
472 || (y >= LCD_REMOTE_HEIGHT) || (x + width <= 0) || (y + height <= 0))
473 return;
474
475 /* clipping */
476 if (x < 0)
477 {
478 width += x;
479 x = 0;
480 }
481 if (y < 0)
482 {
483 height += y;
484 y = 0;
485 }
486 if (x + width > LCD_REMOTE_WIDTH)
487 width = LCD_REMOTE_WIDTH - x;
488 if (y + height > LCD_REMOTE_HEIGHT)
489 height = LCD_REMOTE_HEIGHT - y;
490
491 if (drawmode & DRMODE_INVERSEVID)
492 {
493 if (drawmode & DRMODE_BG)
494 {
495 fillopt = true;
496 bits = bg_pattern;
497 }
498 }
499 else
500 {
501 if (drawmode & DRMODE_FG)
502 {
503 fillopt = true;
504 bits = fg_pattern;
505 }
506 }
507 bfunc = lcd_remote_blockfuncs[drawmode];
508 dst = &lcd_remote_framebuffer[y>>3][x];
509 ny = height - 1 + (y & 7);
510 mask = (0xFFu << (y & 7)) & 0xFFu;
511 mask |= mask << 8;
512 mask_bottom = 0xFFu >> (~ny & 7);
513 mask_bottom |= mask_bottom << 8;
514
515 for (; ny >= 8; ny -= 8)
516 {
517 if (fillopt && (mask == 0xFFFFu))
518 memset16(dst, bits, width);
519 else
520 {
521 fb_remote_data *dst_row = dst;
522
523 dst_end = dst_row + width;
524 do
525 bfunc(dst_row++, mask, 0xFFFFu);
526 while (dst_row < dst_end);
527 }
528
529 dst += LCD_REMOTE_WIDTH;
530 mask = 0xFFFFu;
531 }
532 mask &= mask_bottom;
533
534 if (fillopt && (mask == 0xFFFFu))
535 memset16(dst, bits, width);
536 else
537 {
538 dst_end = dst + width;
539 do
540 bfunc(dst++, mask, 0xFFFFu);
541 while (dst < dst_end);
542 }
543}
544
545/* About Rockbox' internal monochrome bitmap format:
546 *
547 * A bitmap contains one bit for every pixel that defines if that pixel is
548 * black (1) or white (0). Bits within a byte are arranged vertically, LSB
549 * at top.
550 * The bytes are stored in row-major order, with byte 0 being top left,
551 * byte 1 2nd from left etc. The first row of bytes defines pixel rows
552 * 0..7, the second row defines pixel row 8..15 etc.
553 *
554 * This is similar to the internal lcd hw format. */
555
556/* Draw a partial monochrome bitmap */
557void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
558 int stride, int x, int y, int width, int height)
559 ICODE_ATTR;
560void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
561 int stride, int x, int y, int width, int height)
562{
563 int shift, ny;
564 fb_remote_data *dst, *dst_end;
565 unsigned data, mask, mask_bottom;
566 lcd_remote_blockfunc_type *bfunc;
567
568 /* nothing to draw? */
569 if ((width <= 0) || (height <= 0) || (x >= LCD_REMOTE_WIDTH)
570 || (y >= LCD_REMOTE_HEIGHT) || (x + width <= 0) || (y + height <= 0))
571 return;
572
573 /* clipping */
574 if (x < 0)
575 {
576 width += x;
577 src_x -= x;
578 x = 0;
579 }
580 if (y < 0)
581 {
582 height += y;
583 src_y -= y;
584 y = 0;
585 }
586 if (x + width > LCD_REMOTE_WIDTH)
587 width = LCD_REMOTE_WIDTH - x;
588 if (y + height > LCD_REMOTE_HEIGHT)
589 height = LCD_REMOTE_HEIGHT - y;
590
591 src += stride * (src_y >> 3) + src_x; /* move starting point */
592 src_y &= 7;
593 y -= src_y;
594 dst = &lcd_remote_framebuffer[y>>3][x];
595 shift = y & 7;
596 ny = height - 1 + shift + src_y;
597
598 bfunc = lcd_remote_blockfuncs[drawmode];
599 mask = 0xFFu << (shift + src_y);
600 /* not byte-doubled here because shift+src_y can be > 7 */
601 mask_bottom = 0xFFu >> (~ny & 7);
602 mask_bottom |= mask_bottom << 8;
603
604 if (shift == 0)
605 {
606 mask &= 0xFFu;
607 mask |= mask << 8;
608
609 for (; ny >= 8; ny -= 8)
610 {
611 const unsigned char *src_row = src;
612 fb_remote_data *dst_row = dst;
613
614 dst_end = dst_row + width;
615 do
616 {
617 data = *src_row++;
618 bfunc(dst_row++, mask, data | (data << 8));
619 }
620 while (dst_row < dst_end);
621
622 src += stride;
623 dst += LCD_REMOTE_WIDTH;
624 mask = 0xFFFFu;
625 }
626 mask &= mask_bottom;
627
628 dst_end = dst + width;
629 do
630 {
631 data = *src++;
632 bfunc(dst++, mask, data | (data << 8));
633 }
634 while (dst < dst_end);
635 }
636 else
637 {
638 unsigned ddata;
639
640 dst_end = dst + width;
641 do
642 {
643 const unsigned char *src_col = src++;
644 fb_remote_data *dst_col = dst++;
645 unsigned mask_col = mask & 0xFFu;
646
647 mask_col |= mask_col << 8;
648 data = 0;
649
650 for (y = ny; y >= 8; y -= 8)
651 {
652 data |= *src_col << shift;
653
654 if (mask_col)
655 {
656 ddata = data & 0xFFu;
657 bfunc(dst_col, mask_col, ddata | (ddata << 8));
658 mask_col = 0xFFFFu;
659 }
660 else
661 {
662 mask_col = (mask >> 8) & 0xFFu;
663 mask_col |= mask_col << 8;
664 }
665
666 src_col += stride;
667 dst_col += LCD_REMOTE_WIDTH;
668 data >>= 8;
669 }
670 data |= *src_col << shift;
671 mask_col &= mask_bottom;
672 ddata = data & 0xFFu;
673 bfunc(dst_col, mask_col, ddata | (ddata << 8));
674 }
675 while (dst < dst_end);
676 }
677}
678
679/* Draw a full monochrome bitmap */
680void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y, int width,
681 int height)
682{
683 lcd_remote_mono_bitmap_part(src, 0, 0, width, x, y, width, height);
684}
685
686/* About Rockbox' internal native bitmap format:
687 *
688 * A bitmap contains one bit in each byte of a pair of bytes for every pixel.
689 * 00 = white, 01 = light grey, 10 = dark grey, 11 = black. Bits within a byte
690 * are arranged vertically, LSB at top.
691 * The pairs of bytes are stored as shorts, in row-major order, with word 0
692 * being top left, word 1 2nd from left etc. The first row of words defines
693 * pixel rows 0..7, the second row defines pixel row 8..15 etc.
694 *
695 * This is the same as the internal lcd hw format. */
696
697/* Draw a partial native bitmap */
698void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x, int src_y,
699 int stride, int x, int y, int width, int height)
700 ICODE_ATTR;
701void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x, int src_y,
702 int stride, int x, int y, int width, int height)
703{
704 int shift, ny;
705 fb_remote_data *dst, *dst_end;
706 unsigned mask, mask_bottom;
707
708 /* nothing to draw? */
709 if ((width <= 0) || (height <= 0) || (x >= LCD_REMOTE_WIDTH)
710 || (y >= LCD_REMOTE_HEIGHT) || (x + width <= 0) || (y + height <= 0))
711 return;
712
713 /* clipping */
714 if (x < 0)
715 {
716 width += x;
717 src_x -= x;
718 x = 0;
719 }
720 if (y < 0)
721 {
722 height += y;
723 src_y -= y;
724 y = 0;
725 }
726 if (x + width > LCD_REMOTE_WIDTH)
727 width = LCD_REMOTE_WIDTH - x;
728 if (y + height > LCD_REMOTE_HEIGHT)
729 height = LCD_REMOTE_HEIGHT - y;
730
731 src += stride * (src_y >> 3) + src_x; /* move starting point */
732 src_y &= 7;
733 y -= src_y;
734 dst = &lcd_remote_framebuffer[y>>3][x];
735 shift = y & 7;
736 ny = height - 1 + shift + src_y;
737
738 mask = 0xFFu << (shift + src_y);
739 /* not byte-doubled here because shift+src_y can be > 7 */
740 mask_bottom = 0xFFu >> (~ny & 7);
741 mask_bottom |= mask_bottom << 8;
742
743 if (shift == 0)
744 {
745 mask &= 0xFFu;
746 mask |= mask << 8;
747
748 for (; ny >= 8; ny -= 8)
749 {
750 if (mask == 0xFFFFu)
751 memcpy(dst, src, width * sizeof(fb_remote_data));
752 else
753 {
754 const fb_remote_data *src_row = src;
755 fb_remote_data *dst_row = dst;
756
757 dst_end = dst_row + width;
758 do
759 setblock(dst_row++, mask, *src_row++);
760 while (dst_row < dst_end);
761 }
762 src += stride;
763 dst += LCD_REMOTE_WIDTH;
764 mask = 0xFFFFu;
765 }
766 mask &= mask_bottom;
767
768 if (mask == 0xFFFFu)
769 memcpy(dst, src, width * sizeof(fb_remote_data));
770 else
771 {
772 dst_end = dst + width;
773 do
774 setblock(dst++, mask, *src++);
775 while (dst < dst_end);
776 }
777 }
778 else
779 {
780 unsigned datamask = (0xFFu << shift) & 0xFFu;
781
782 datamask |= datamask << 8;
783
784 dst_end = dst + width;
785 do
786 {
787 const fb_remote_data *src_col = src++;
788 fb_remote_data *dst_col = dst++;
789 unsigned mask_col = mask & 0xFFu;
790 unsigned data, olddata = 0;
791
792 mask_col |= mask_col << 8;
793
794 for (y = ny; y >= 8; y -= 8)
795 {
796 data = *src_col << shift;
797
798 if (mask_col)
799 {
800 setblock(dst_col, mask_col,
801 olddata ^((olddata ^ data) & datamask));
802 mask_col = 0xFFFFu;
803 }
804 else
805 {
806 mask_col = (mask << 8) & 0xFFu;
807 mask_col |= mask_col << 8;
808 }
809 src_col += stride;
810 dst_col += LCD_REMOTE_WIDTH;
811 olddata = data >> 8;
812 }
813 data = *src_col << shift;
814 setblock(dst_col, mask_col & mask_bottom,
815 olddata ^((olddata ^ data) & datamask));
816 }
817 while (dst < dst_end);
818 }
819}
820
821/* Draw a full native bitmap */
822void lcd_remote_bitmap(const fb_remote_data *src, int x, int y, int width,
823 int height)
824{
825 lcd_remote_bitmap_part(src, 0, 0, width, x, y, width, height);
826}
827
828/* put a string at a given pixel position, skipping first ofs pixel columns */
829static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str)
830{
831 unsigned short ch;
832 unsigned short *ucs;
833 struct font* pf = font_get(curfont);
834
835 ucs = bidi_l2v(str, 1);
836
837 while ((ch = *ucs++) != 0 && x < LCD_REMOTE_WIDTH)
838 {
839 int width;
840 const unsigned char *bits;
841
842 /* get proportional width and glyph bits */
843 width = font_get_width(pf, ch);
844
845 if (ofs > width)
846 {
847 ofs -= width;
848 continue;
849 }
850
851 bits = font_get_bits(pf, ch);
852
853 lcd_remote_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs,
854 pf->height);
855
856 x += width - ofs;
857 ofs = 0;
858 }
859}
860
861/* put a string at a given pixel position */
862void lcd_remote_putsxy(int x, int y, const unsigned char *str)
863{
864 lcd_remote_putsxyofs(x, y, 0, str);
865}
866
867/*** line oriented text output ***/
868
869/* put a string at a given char position */
870void lcd_remote_puts(int x, int y, const unsigned char *str)
871{
872 lcd_remote_puts_style_offset(x, y, str, STYLE_DEFAULT, 0);
873}
874
875void lcd_remote_puts_style(int x, int y, const unsigned char *str, int style)
876{
877 lcd_remote_puts_style_offset(x, y, str, style, 0);
878}
879
880void lcd_remote_puts_offset(int x, int y, const unsigned char *str, int offset)
881{
882 lcd_remote_puts_style_offset(x, y, str, STYLE_DEFAULT, offset);
883}
884
885/* put a string at a given char position, style, and pixel position,
886 * skipping first offset pixel columns */
887void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str,
888 int style, int offset)
889{
890 int xpos,ypos,w,h,xrect;
891 int lastmode = drawmode;
892
893 /* make sure scrolling is turned off on the line we are updating */
894 scrolling_lines &= ~(1 << y);
895
896 if(!str || !str[0])
897 return;
898
899 lcd_remote_getstringsize(str, &w, &h);
900 xpos = xmargin + x*w / utf8length((char *)str);
901 ypos = ymargin + y*h;
902 drawmode = (style & STYLE_INVERT) ?
903 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
904 lcd_remote_putsxyofs(xpos, ypos, offset, str);
905 drawmode ^= DRMODE_INVERSEVID;
906 xrect = xpos + MAX(w - offset, 0);
907 lcd_remote_fillrect(xrect, ypos, LCD_REMOTE_WIDTH - xrect, h);
908 drawmode = lastmode;
909}
910
911/*** scrolling ***/
912
913/* Reverse the invert setting of the scrolling line (if any) at given char
914 position. Setting will go into affect next time line scrolls. */
915void lcd_remote_invertscroll(int x, int y)
916{
917 struct scrollinfo* s;
918
919 (void)x;
920
921 s = &scroll[y];
922 s->invert = !s->invert;
923}
924
925void lcd_remote_stop_scroll(void)
926{
927 scrolling_lines=0;
928}
929
930void lcd_remote_scroll_speed(int speed)
931{
932 scroll_ticks = scroll_tick_table[speed];
933}
934
935void lcd_remote_scroll_step(int step)
936{
937 scroll_step = step;
938}
939
940void lcd_remote_scroll_delay(int ms)
941{
942 scroll_delay = ms / (HZ / 10);
943}
944
945void lcd_remote_bidir_scroll(int percent)
946{
947 bidir_limit = percent;
948}
949
950void lcd_remote_puts_scroll(int x, int y, const unsigned char *string)
951{
952 lcd_remote_puts_scroll_style(x, y, string, STYLE_DEFAULT);
953}
954
955void lcd_remote_puts_scroll_style(int x, int y, const unsigned char *string, int style)
956{
957 lcd_remote_puts_scroll_style_offset(x, y, string, style, 0);
958}
959
960void lcd_remote_puts_scroll_offset(int x, int y, const unsigned char *string, int offset)
961{
962 lcd_remote_puts_scroll_style_offset(x, y, string, STYLE_DEFAULT, offset);
963}
964
965void lcd_remote_puts_scroll_style_offset(int x, int y, const unsigned char *string,
966 int style, int offset)
967{
968 struct scrollinfo* s;
969 int w, h;
970
971 s = &scroll[y];
972
973 s->start_tick = current_tick + scroll_delay;
974 s->invert = false;
975 if (style & STYLE_INVERT) {
976 s->invert = true;
977 lcd_remote_puts_style_offset(x,y,string,STYLE_INVERT,offset);
978 }
979 else
980 lcd_remote_puts_offset(x,y,string,offset);
981
982 lcd_remote_getstringsize(string, &w, &h);
983
984 if (LCD_REMOTE_WIDTH - x * 8 - xmargin < w) {
985 /* prepare scroll line */
986 char *end;
987
988 memset(s->line, 0, sizeof s->line);
989 strcpy(s->line, (char *)string);
990
991 /* get width */
992 s->width = lcd_remote_getstringsize((unsigned char *)s->line, &w, &h);
993
994 /* scroll bidirectional or forward only depending on the string
995 width */
996 if ( bidir_limit ) {
997 s->bidir = s->width < (LCD_REMOTE_WIDTH - xmargin) *
998 (100 + bidir_limit) / 100;
999 }
1000 else
1001 s->bidir = false;
1002
1003 if (!s->bidir) { /* add spaces if scrolling in the round */
1004 strcat(s->line, " ");
1005 /* get new width incl. spaces */
1006 s->width = lcd_remote_getstringsize((unsigned char *)s->line, &w, &h);
1007 }
1008
1009 end = strchr(s->line, '\0');
1010 strncpy(end, (char *)string, LCD_REMOTE_WIDTH/2);
1011
1012 s->len = utf8length((char *)string);
1013 s->offset = offset;
1014 s->startx = x;
1015 s->backward = false;
1016 scrolling_lines |= (1<<y);
1017 }
1018 else
1019 /* force a bit switch-off since it doesn't scroll */
1020 scrolling_lines &= ~(1<<y);
1021}
1022
1023static void scroll_thread(void)
1024{
1025 struct font* pf;
1026 struct scrollinfo* s;
1027 int index;
1028 int xpos, ypos;
1029 int lastmode;
1030
1031 /* initialize scroll struct array */
1032 scrolling_lines = 0;
1033
1034 while ( 1 ) {
1035 for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
1036 /* really scroll? */
1037 if ( !(scrolling_lines&(1<<index)) )
1038 continue;
1039
1040 s = &scroll[index];
1041
1042 /* check pause */
1043 if (TIME_BEFORE(current_tick, s->start_tick))
1044 continue;
1045
1046 if (s->backward)
1047 s->offset -= scroll_step;
1048 else
1049 s->offset += scroll_step;
1050
1051 pf = font_get(curfont);
1052 xpos = xmargin + s->startx * s->width / s->len;
1053 ypos = ymargin + index * pf->height;
1054
1055 if (s->bidir) { /* scroll bidirectional */
1056 if (s->offset <= 0) {
1057 /* at beginning of line */
1058 s->offset = 0;
1059 s->backward = false;
1060 s->start_tick = current_tick + scroll_delay * 2;
1061 }
1062 if (s->offset >= s->width - (LCD_REMOTE_WIDTH - xpos)) {
1063 /* at end of line */
1064 s->offset = s->width - (LCD_REMOTE_WIDTH - xpos);
1065 s->backward = true;
1066 s->start_tick = current_tick + scroll_delay * 2;
1067 }
1068 }
1069 else {
1070 /* scroll forward the whole time */
1071 if (s->offset >= s->width)
1072 s->offset %= s->width;
1073 }
1074
1075 lastmode = drawmode;
1076 drawmode = s->invert ?
1077 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
1078 lcd_remote_putsxyofs(xpos, ypos, s->offset, s->line);
1079 drawmode = lastmode;
1080 lcd_remote_update_rect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height);
1081 }
1082
1083 sleep(scroll_ticks);
1084 }
1085}
diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h
index 7ce230ee8e..5d081b4a22 100644
--- a/firmware/export/config-iaudiox5.h
+++ b/firmware/export/config-iaudiox5.h
@@ -27,17 +27,18 @@
27 27
28/* remote LCD */ 28/* remote LCD */
29#define LCD_REMOTE_WIDTH 128 29#define LCD_REMOTE_WIDTH 128
30#define LCD_REMOTE_HEIGHT 64 30#define LCD_REMOTE_HEIGHT 96
31#define LCD_REMOTE_DEPTH 1 31#define LCD_REMOTE_DEPTH 2
32
33#define LCD_REMOTE_PIXELFORMAT VERTICAL_INTERLEAVED
32 34
33#define CONFIG_KEYPAD IAUDIO_X5_PAD 35#define CONFIG_KEYPAD IAUDIO_X5_PAD
34 36
35/* Define this if you do software codec */ 37/* Define this if you do software codec */
36#define CONFIG_CODEC SWCODEC 38#define CONFIG_CODEC SWCODEC
37 39
38/* Define this if you have an remote lcd 40/* Define this if you have an remote lcd */
39#define HAVE_REMOTE_LCD 41#define HAVE_REMOTE_LCD
40*/
41 42
42#define CONFIG_LCD LCD_X5 43#define CONFIG_LCD LCD_X5
43 44
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 3768d857cb..684353e499 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -92,6 +92,8 @@
92/* LCD_PIXELFORMAT */ 92/* LCD_PIXELFORMAT */
93#define HORIZONTAL_PACKING 1 93#define HORIZONTAL_PACKING 1
94#define VERTICAL_PACKING 2 94#define VERTICAL_PACKING 2
95#define HORIZONTAL_INTERLEAVED 3
96#define VERTICAL_INTERLEAVED 4
95#define RGB565 565 97#define RGB565 565
96#define RGB565SWAPPED 3553 98#define RGB565SWAPPED 3553
97 99
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c
index 0262473fc1..478badefd7 100644
--- a/tools/bmp2rb.c
+++ b/tools/bmp2rb.c
@@ -326,6 +326,12 @@ int transform_bitmap(const struct RGBQUAD *src, int width, int height,
326 dst_h = height; 326 dst_h = height;
327 dst_d = 8; 327 dst_d = 8;
328 break; 328 break;
329
330 case 7: /* greyscale X5 remote 4-grey */
331 dst_w = width;
332 dst_h = (height + 7) / 8;
333 dst_d = 16;
334 break;
329 335
330 default: /* unknown */ 336 default: /* unknown */
331 debugf("error - Undefined destination format\n"); 337 debugf("error - Undefined destination format\n");
@@ -405,6 +411,17 @@ int transform_bitmap(const struct RGBQUAD *src, int width, int height,
405 (~brightness(src[row * width + col]) & 0xC0) >> (2 * (col & 3)); 411 (~brightness(src[row * width + col]) & 0xC0) >> (2 * (col & 3));
406 } 412 }
407 break; 413 break;
414
415 case 7: /* greyscale X5 remote 4-grey */
416 for (row = 0; row < height; row++)
417 for (col = 0; col < width; col++)
418 {
419 unsigned short data = (~brightness(src[row * width + col]) & 0xC0) >> 6;
420
421 data = (data | (data << 7)) & 0x0101;
422 (*dest)[(row/8) * dst_w + col] |= data << (row & 7);
423 }
424 break;
408 } 425 }
409 426
410 return 0; 427 return 0;
@@ -514,10 +531,11 @@ void print_usage(void)
514 "\t 0 Archos recorder, Ondio, Gmini 120/SP, Iriver H1x0 mono\n" 531 "\t 0 Archos recorder, Ondio, Gmini 120/SP, Iriver H1x0 mono\n"
515 "\t 1 Archos player graphics library\n" 532 "\t 1 Archos player graphics library\n"
516 "\t 2 Iriver H1x0 4-grey\n" 533 "\t 2 Iriver H1x0 4-grey\n"
517 "\t 3 Canonical 8-bit grayscale\n" 534 "\t 3 Canonical 8-bit greyscale\n"
518 "\t 4 16-bit packed 5-6-5 RGB (iriver H300)\n" 535 "\t 4 16-bit packed 5-6-5 RGB (iriver H300)\n"
519 "\t 5 16-bit packed and byte-swapped 5-6-5 RGB (iPod)\n" 536 "\t 5 16-bit packed and byte-swapped 5-6-5 RGB (iPod)\n"
520 "\t 6 Greayscale iPod 4-grey\n" 537 "\t 6 Greyscale iPod 4-grey\n"
538 "\t 7 Greyscale X5 remote 4-grey\n"
521 , APPLICATION_NAME); 539 , APPLICATION_NAME);
522 printf("build date: " __DATE__ "\n\n"); 540 printf("build date: " __DATE__ "\n\n");
523} 541}
diff --git a/tools/configure b/tools/configure
index 0962f41ce0..f155afd8db 100755
--- a/tools/configure
+++ b/tools/configure
@@ -705,7 +705,7 @@ toolsdir='\$(ROOTDIR)/tools'
705 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" 705 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
706 bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 706 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
707 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" 707 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0"
708 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" 708 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 7"
709 output="rockbox.iaudio" 709 output="rockbox.iaudio"
710 appextra="recorder:gui" 710 appextra="recorder:gui"
711 archosrom="" 711 archosrom=""
diff --git a/uisimulator/sdl/SOURCES b/uisimulator/sdl/SOURCES
index 41890048de..92bf021711 100644
--- a/uisimulator/sdl/SOURCES
+++ b/uisimulator/sdl/SOURCES
@@ -6,7 +6,7 @@ lcd-bitmap.c
6lcd-charcell.c 6lcd-charcell.c
7#endif 7#endif
8#ifdef HAVE_REMOTE_LCD 8#ifdef HAVE_REMOTE_LCD
9lcd-remote.c 9lcd-remote-bitmap.c
10#endif 10#endif
11lcd-sdl.c 11lcd-sdl.c
12sound.c 12sound.c
diff --git a/uisimulator/sdl/lcd-remote.c b/uisimulator/sdl/lcd-remote-bitmap.c
index 7231b50aea..21fa0d2ab4 100644
--- a/uisimulator/sdl/lcd-remote.c
+++ b/uisimulator/sdl/lcd-remote-bitmap.c
@@ -19,7 +19,7 @@
19 19
20#include "uisdl.h" 20#include "uisdl.h"
21#include "lcd-sdl.h" 21#include "lcd-sdl.h"
22#include "lcd-remote.h" 22#include "lcd-remote-bitmap.h"
23 23
24SDL_Surface *remote_surface; 24SDL_Surface *remote_surface;
25 25
@@ -27,10 +27,15 @@ SDL_Color remote_color_zero = {UI_REMOTE_BGCOLOR, 0};
27SDL_Color remote_backlight_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0}; 27SDL_Color remote_backlight_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0};
28SDL_Color remote_color_max = {0, 0, 0, 0}; 28SDL_Color remote_color_max = {0, 0, 0, 0};
29 29
30extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
31
32static unsigned long get_lcd_remote_pixel(int x, int y) { 30static unsigned long get_lcd_remote_pixel(int x, int y) {
33 return ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1); 31#if LCD_REMOTE_DEPTH == 1
32 return (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1;
33#elif LCD_REMOTE_DEPTH == 2
34#if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
35 unsigned bits = (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 0x0101;
36 return (bits | (bits >> 7)) & 3;
37#endif
38#endif
34} 39}
35 40
36void lcd_remote_update (void) 41void lcd_remote_update (void)
diff --git a/uisimulator/sdl/lcd-remote.h b/uisimulator/sdl/lcd-remote-bitmap.h
index 7def1e723c..09391726fb 100644
--- a/uisimulator/sdl/lcd-remote.h
+++ b/uisimulator/sdl/lcd-remote-bitmap.h
@@ -21,6 +21,7 @@
21#define __LCDREMOTE_H__ 21#define __LCDREMOTE_H__
22 22
23#include "lcd.h" 23#include "lcd.h"
24#include "lcd-remote.h"
24#include "SDL.h" 25#include "SDL.h"
25 26
26void sim_lcd_remote_init(void); 27void sim_lcd_remote_init(void);
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c
index 75531d263f..8c9d216f10 100644
--- a/uisimulator/sdl/uisdl.c
+++ b/uisimulator/sdl/uisdl.c
@@ -31,7 +31,7 @@
31#include "lcd-charcell.h" 31#include "lcd-charcell.h"
32#endif 32#endif
33#ifdef HAVE_REMOTE_LCD 33#ifdef HAVE_REMOTE_LCD
34#include "lcd-remote.h" 34#include "lcd-remote-bitmap.h"
35#endif 35#endif
36#include "thread-sdl.h" 36#include "thread-sdl.h"
37#include "SDL_mutex.h" 37#include "SDL_mutex.h"
diff --git a/uisimulator/sdl/uisdl.h b/uisimulator/sdl/uisdl.h
index afd9678f32..7deeff3bb8 100644
--- a/uisimulator/sdl/uisdl.h
+++ b/uisimulator/sdl/uisdl.h
@@ -176,22 +176,18 @@
176#elif defined(IAUDIO_X5) 176#elif defined(IAUDIO_X5)
177#define UI_TITLE "iAudio X5" 177#define UI_TITLE "iAudio X5"
178#define UI_WIDTH 300 /* width of GUI window */ 178#define UI_WIDTH 300 /* width of GUI window */
179#define UI_HEIGHT 462 /* height of GUI window */ 179#define UI_HEIGHT 558 /* height of GUI window */
180#define UI_LCD_BGCOLOR 90, 145, 90 /* bkgnd color of LCD (no backlight) */ 180/* high-colour */
181#define UI_LCD_BGCOLORLIGHT 230, 160, 60 /* bkgnd color of LCD (backlight) */
182#define UI_LCD_BLACK 0, 0, 0 /* black */
183#define UI_LCD_POSX 55 /* x position of lcd */ 181#define UI_LCD_POSX 55 /* x position of lcd */
184#define UI_LCD_POSY 61 /* y position of lcd (74 for real aspect) */ 182#define UI_LCD_POSY 61 /* y position of lcd (74 for real aspect) */
185#define UI_LCD_WIDTH LCD_WIDTH /* * 1.5 */ 183#define UI_LCD_WIDTH LCD_WIDTH /* * 1.5 */
186#define UI_LCD_HEIGHT LCD_HEIGHT /* * 1.5 */ 184#define UI_LCD_HEIGHT LCD_HEIGHT /* * 1.5 */
187 185#define UI_REMOTE_BGCOLOR 90, 145, 90 /* bkgnd of remote lcd (no bklight) */
186#define UI_REMOTE_BGCOLORLIGHT 130, 180, 250 /* bkgnd of remote lcd (bklight) */
188#define UI_REMOTE_POSX 12 /* x position of remote lcd */ 187#define UI_REMOTE_POSX 12 /* x position of remote lcd */
189#define UI_REMOTE_POSY 478 /* y position of remote lcd */ 188#define UI_REMOTE_POSY 462 /* y position of remote lcd */
190#define UI_REMOTE_WIDTH 128 189#define UI_REMOTE_WIDTH 128
191#define UI_REMOTE_HEIGHT 64 190#define UI_REMOTE_HEIGHT 96
192
193#define UI_REMOTE_BGCOLORLIGHT 250, 180, 130 /* bkgnd of remote lcd (bklight) */
194#define UI_REMOTE_BGCOLOR 90, 145, 90 /* bkgnd of remote lcd (no bklight) */
195 191
196#elif defined(GIGABEAT_F) 192#elif defined(GIGABEAT_F)
197#define UI_TITLE "Toshiba Gigabeat" 193#define UI_TITLE "Toshiba Gigabeat"