diff options
Diffstat (limited to 'firmware/drivers/lcd-16bit-vert.c')
-rw-r--r-- | firmware/drivers/lcd-16bit-vert.c | 368 |
1 files changed, 5 insertions, 363 deletions
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c index 17a1a2dda2..1d9e207bd9 100644 --- a/firmware/drivers/lcd-16bit-vert.c +++ b/firmware/drivers/lcd-16bit-vert.c | |||
@@ -21,6 +21,7 @@ | |||
21 | * KIND, either express or implied. | 21 | * KIND, either express or implied. |
22 | * | 22 | * |
23 | ****************************************************************************/ | 23 | ****************************************************************************/ |
24 | |||
24 | #include "config.h" | 25 | #include "config.h" |
25 | 26 | ||
26 | #include "cpu.h" | 27 | #include "cpu.h" |
@@ -37,234 +38,14 @@ | |||
37 | #include "bidi.h" | 38 | #include "bidi.h" |
38 | #include "scroll_engine.h" | 39 | #include "scroll_engine.h" |
39 | 40 | ||
40 | enum fill_opt { | 41 | #define ROW_INC 1 |
41 | OPT_NONE = 0, | 42 | #define COL_INC LCD_HEIGHT |
42 | OPT_SET, | ||
43 | OPT_COPY | ||
44 | }; | ||
45 | |||
46 | /*** globals ***/ | ||
47 | fb_data lcd_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH] | ||
48 | IRAM_LCDFRAMEBUFFER CACHEALIGN_AT_LEAST_ATTR(16); | ||
49 | |||
50 | |||
51 | static fb_data* lcd_backdrop = NULL; | ||
52 | static long lcd_backdrop_offset IDATA_ATTR = 0; | ||
53 | |||
54 | static struct viewport default_vp = | ||
55 | { | ||
56 | .x = 0, | ||
57 | .y = 0, | ||
58 | .width = LCD_WIDTH, | ||
59 | .height = LCD_HEIGHT, | ||
60 | .font = FONT_SYSFIXED, | ||
61 | .drawmode = DRMODE_SOLID, | ||
62 | .fg_pattern = LCD_DEFAULT_FG, | ||
63 | .bg_pattern = LCD_DEFAULT_BG, | ||
64 | .lss_pattern = LCD_DEFAULT_BG, | ||
65 | .lse_pattern = LCD_DEFAULT_BG, | ||
66 | .lst_pattern = LCD_DEFAULT_BG, | ||
67 | }; | ||
68 | |||
69 | /* The Gigabeat target build requires access to the current fg_pattern | ||
70 | in lcd-meg-fx.c */ | ||
71 | #if defined(SIMULATOR) | ||
72 | static struct viewport* current_vp IDATA_ATTR = &default_vp; | ||
73 | #else | ||
74 | struct viewport* current_vp IDATA_ATTR = &default_vp; | ||
75 | #endif | ||
76 | |||
77 | /* LCD init */ | ||
78 | void lcd_init(void) | ||
79 | { | ||
80 | lcd_clear_display(); | ||
81 | |||
82 | /* Call device specific init */ | ||
83 | lcd_init_device(); | ||
84 | scroll_init(); | ||
85 | } | ||
86 | /*** Viewports ***/ | ||
87 | |||
88 | void lcd_set_viewport(struct viewport* vp) | ||
89 | { | ||
90 | if (vp == NULL) | ||
91 | current_vp = &default_vp; | ||
92 | else | ||
93 | current_vp = vp; | ||
94 | |||
95 | #if defined(SIMULATOR) | ||
96 | /* Force the viewport to be within bounds. If this happens it should | ||
97 | * be considered an error - the viewport will not draw as it might be | ||
98 | * expected. | ||
99 | */ | ||
100 | if((unsigned) current_vp->x > (unsigned) LCD_WIDTH | ||
101 | || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT | ||
102 | || current_vp->x + current_vp->width > LCD_WIDTH | ||
103 | || current_vp->y + current_vp->height > LCD_HEIGHT) | ||
104 | { | ||
105 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
106 | DEBUGF("ERROR: " | ||
107 | #else | ||
108 | DEBUGF("NOTE: " | ||
109 | #endif | ||
110 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
111 | current_vp->x, current_vp->y, | ||
112 | current_vp->width, current_vp->height); | ||
113 | } | ||
114 | |||
115 | #endif | ||
116 | } | ||
117 | |||
118 | void lcd_update_viewport(void) | ||
119 | { | ||
120 | lcd_update_rect(current_vp->x, current_vp->y, | ||
121 | current_vp->width, current_vp->height); | ||
122 | } | ||
123 | |||
124 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
125 | { | ||
126 | lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
127 | } | ||
128 | |||
129 | /*** parameter handling ***/ | ||
130 | |||
131 | void lcd_set_drawmode(int mode) | ||
132 | { | ||
133 | current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); | ||
134 | } | ||
135 | |||
136 | int lcd_get_drawmode(void) | ||
137 | { | ||
138 | return current_vp->drawmode; | ||
139 | } | ||
140 | |||
141 | void lcd_set_foreground(unsigned color) | ||
142 | { | ||
143 | current_vp->fg_pattern = color; | ||
144 | } | ||
145 | |||
146 | unsigned lcd_get_foreground(void) | ||
147 | { | ||
148 | return current_vp->fg_pattern; | ||
149 | } | ||
150 | |||
151 | void lcd_set_background(unsigned color) | ||
152 | { | ||
153 | current_vp->bg_pattern = color; | ||
154 | } | ||
155 | |||
156 | unsigned lcd_get_background(void) | ||
157 | { | ||
158 | return current_vp->bg_pattern; | ||
159 | } | ||
160 | |||
161 | void lcd_set_selector_start(unsigned color) | ||
162 | { | ||
163 | current_vp->lss_pattern = color; | ||
164 | } | ||
165 | |||
166 | void lcd_set_selector_end(unsigned color) | ||
167 | { | ||
168 | current_vp->lse_pattern = color; | ||
169 | } | ||
170 | |||
171 | void lcd_set_selector_text(unsigned color) | ||
172 | { | ||
173 | current_vp->lst_pattern = color; | ||
174 | } | ||
175 | |||
176 | void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) | ||
177 | { | ||
178 | lcd_set_drawmode(mode); | ||
179 | current_vp->fg_pattern = fg_color; | ||
180 | current_vp->bg_pattern = bg_color; | ||
181 | } | ||
182 | |||
183 | int lcd_getwidth(void) | ||
184 | { | ||
185 | return current_vp->width; | ||
186 | } | ||
187 | |||
188 | int lcd_getheight(void) | ||
189 | { | ||
190 | return current_vp->height; | ||
191 | } | ||
192 | |||
193 | void lcd_setfont(int newfont) | ||
194 | { | ||
195 | current_vp->font = newfont; | ||
196 | } | ||
197 | |||
198 | int lcd_getfont(void) | ||
199 | { | ||
200 | return current_vp->font; | ||
201 | } | ||
202 | |||
203 | int lcd_getstringsize(const unsigned char *str, int *w, int *h) | ||
204 | { | ||
205 | return font_getstringsize(str, w, h, current_vp->font); | ||
206 | } | ||
207 | |||
208 | /*** low-level drawing functions ***/ | ||
209 | 43 | ||
210 | #define LCDADDR(x, y) (&lcd_framebuffer[0][0] + LCD_HEIGHT*(x) + (y)) | 44 | #define LCDADDR(x, y) (&lcd_framebuffer[0][0] + LCD_HEIGHT*(x) + (y)) |
211 | 45 | ||
212 | static void ICODE_ATTR setpixel(fb_data *address) | 46 | #include "lcd-16bit-common.c" |
213 | { | ||
214 | *address = current_vp->fg_pattern; | ||
215 | } | ||
216 | |||
217 | static void ICODE_ATTR clearpixel(fb_data *address) | ||
218 | { | ||
219 | *address = current_vp->bg_pattern; | ||
220 | } | ||
221 | |||
222 | static void ICODE_ATTR clearimgpixel(fb_data *address) | ||
223 | { | ||
224 | *address = *(fb_data *)((long)address + lcd_backdrop_offset); | ||
225 | } | ||
226 | |||
227 | static void ICODE_ATTR flippixel(fb_data *address) | ||
228 | { | ||
229 | *address = ~(*address); | ||
230 | } | ||
231 | |||
232 | static void ICODE_ATTR nopixel(fb_data *address) | ||
233 | { | ||
234 | (void)address; | ||
235 | } | ||
236 | |||
237 | lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[8] = { | ||
238 | flippixel, nopixel, setpixel, setpixel, | ||
239 | nopixel, clearpixel, nopixel, clearpixel | ||
240 | }; | ||
241 | |||
242 | lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[8] = { | ||
243 | flippixel, nopixel, setpixel, setpixel, | ||
244 | nopixel, clearimgpixel, nopixel, clearimgpixel | ||
245 | }; | ||
246 | |||
247 | lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor; | ||
248 | |||
249 | void lcd_set_backdrop(fb_data* backdrop) | ||
250 | { | ||
251 | lcd_backdrop = backdrop; | ||
252 | if (backdrop) | ||
253 | { | ||
254 | lcd_backdrop_offset = (long)backdrop - (long)&lcd_framebuffer[0][0]; | ||
255 | lcd_fastpixelfuncs = lcd_fastpixelfuncs_backdrop; | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | lcd_backdrop_offset = 0; | ||
260 | lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor; | ||
261 | } | ||
262 | } | ||
263 | 47 | ||
264 | fb_data* lcd_get_backdrop(void) | 48 | #include "lcd-bitmap-common.c" |
265 | { | ||
266 | return lcd_backdrop; | ||
267 | } | ||
268 | 49 | ||
269 | /*** drawing functions ***/ | 50 | /*** drawing functions ***/ |
270 | 51 | ||
@@ -318,120 +99,6 @@ void lcd_clear_viewport(void) | |||
318 | } | 99 | } |
319 | } | 100 | } |
320 | 101 | ||
321 | /* Clear the whole display */ | ||
322 | void lcd_clear_display(void) | ||
323 | { | ||
324 | struct viewport* old_vp = current_vp; | ||
325 | |||
326 | current_vp = &default_vp; | ||
327 | |||
328 | lcd_clear_viewport(); | ||
329 | |||
330 | current_vp = old_vp; | ||
331 | } | ||
332 | |||
333 | /* Set a single pixel */ | ||
334 | void lcd_drawpixel(int x, int y) | ||
335 | { | ||
336 | if ( ((unsigned)x < (unsigned)current_vp->width) | ||
337 | && ((unsigned)y < (unsigned)current_vp->height) | ||
338 | #if defined(HAVE_VIEWPORT_CLIP) | ||
339 | && ((unsigned)x < (unsigned)LCD_WIDTH) | ||
340 | && ((unsigned)y < (unsigned)LCD_HEIGHT) | ||
341 | #endif | ||
342 | ) | ||
343 | lcd_fastpixelfuncs[current_vp->drawmode](LCDADDR(current_vp->x+x, current_vp->y+y)); | ||
344 | } | ||
345 | |||
346 | /* Draw a line */ | ||
347 | void lcd_drawline(int x1, int y1, int x2, int y2) | ||
348 | { | ||
349 | int numpixels; | ||
350 | int i; | ||
351 | int deltax, deltay; | ||
352 | int d, dinc1, dinc2; | ||
353 | int x, xinc1, xinc2; | ||
354 | int y, yinc1, yinc2; | ||
355 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[current_vp->drawmode]; | ||
356 | |||
357 | deltay = abs(y2 - y1); | ||
358 | if (deltay == 0) | ||
359 | { | ||
360 | /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */ | ||
361 | lcd_hline(x1, x2, y1); | ||
362 | return; | ||
363 | } | ||
364 | deltax = abs(x2 - x1); | ||
365 | if (deltax == 0) | ||
366 | { | ||
367 | /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */ | ||
368 | lcd_vline(x1, y1, y2); | ||
369 | return; | ||
370 | } | ||
371 | xinc2 = 1; | ||
372 | yinc2 = 1; | ||
373 | |||
374 | if (deltax >= deltay) | ||
375 | { | ||
376 | numpixels = deltax; | ||
377 | d = 2 * deltay - deltax; | ||
378 | dinc1 = deltay * 2; | ||
379 | dinc2 = (deltay - deltax) * 2; | ||
380 | xinc1 = 1; | ||
381 | yinc1 = 0; | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | numpixels = deltay; | ||
386 | d = 2 * deltax - deltay; | ||
387 | dinc1 = deltax * 2; | ||
388 | dinc2 = (deltax - deltay) * 2; | ||
389 | xinc1 = 0; | ||
390 | yinc1 = 1; | ||
391 | } | ||
392 | numpixels++; /* include endpoints */ | ||
393 | |||
394 | if (x1 > x2) | ||
395 | { | ||
396 | xinc1 = -xinc1; | ||
397 | xinc2 = -xinc2; | ||
398 | } | ||
399 | |||
400 | if (y1 > y2) | ||
401 | { | ||
402 | yinc1 = -yinc1; | ||
403 | yinc2 = -yinc2; | ||
404 | } | ||
405 | |||
406 | x = x1; | ||
407 | y = y1; | ||
408 | |||
409 | for (i = 0; i < numpixels; i++) | ||
410 | { | ||
411 | if ( ((unsigned)x < (unsigned)current_vp->width) | ||
412 | && ((unsigned)y < (unsigned)current_vp->height) | ||
413 | #if defined(HAVE_VIEWPORT_CLIP) | ||
414 | && ((unsigned)x < (unsigned)LCD_WIDTH) | ||
415 | && ((unsigned)y < (unsigned)LCD_HEIGHT) | ||
416 | #endif | ||
417 | ) | ||
418 | pfunc(LCDADDR(x + current_vp->x, y + current_vp->y)); | ||
419 | |||
420 | if (d < 0) | ||
421 | { | ||
422 | d += dinc1; | ||
423 | x += xinc1; | ||
424 | y += yinc1; | ||
425 | } | ||
426 | else | ||
427 | { | ||
428 | d += dinc2; | ||
429 | x += xinc2; | ||
430 | y += yinc2; | ||
431 | } | ||
432 | } | ||
433 | } | ||
434 | |||
435 | /* Draw a horizontal line (optimised) */ | 102 | /* Draw a horizontal line (optimised) */ |
436 | void lcd_hline(int x1, int x2, int y) | 103 | void lcd_hline(int x1, int x2, int y) |
437 | { | 104 | { |
@@ -585,21 +252,6 @@ void lcd_vline(int x, int y1, int y2) | |||
585 | } | 252 | } |
586 | } | 253 | } |
587 | 254 | ||
588 | /* Draw a rectangular box */ | ||
589 | void lcd_drawrect(int x, int y, int width, int height) | ||
590 | { | ||
591 | if ((width <= 0) || (height <= 0)) | ||
592 | return; | ||
593 | |||
594 | int x2 = x + width - 1; | ||
595 | int y2 = y + height - 1; | ||
596 | |||
597 | lcd_vline(x, y, y2); | ||
598 | lcd_vline(x2, y, y2); | ||
599 | lcd_hline(x, x2, y); | ||
600 | lcd_hline(x, x2, y2); | ||
601 | } | ||
602 | |||
603 | /* Fill a rectangular area */ | 255 | /* Fill a rectangular area */ |
604 | void lcd_fillrect(int x, int y, int width, int height) | 256 | void lcd_fillrect(int x, int y, int width, int height) |
605 | { | 257 | { |
@@ -792,8 +444,6 @@ void lcd_bitmap(const fb_data *src, int x, int y, int width, int height) | |||
792 | lcd_bitmap_part(src, 0, 0, STRIDE(SCREEN_MAIN, width, height), x, y, width, height); | 444 | lcd_bitmap_part(src, 0, 0, STRIDE(SCREEN_MAIN, width, height), x, y, width, height); |
793 | } | 445 | } |
794 | 446 | ||
795 | #if !defined(TOSHIBA_GIGABEAT_F) && !defined(TOSHIBA_GIGABEAT_S) \ | ||
796 | || defined(SIMULATOR) | ||
797 | /* Draw a partial native bitmap */ | 447 | /* Draw a partial native bitmap */ |
798 | void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | 448 | void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, |
799 | int src_y, int stride, int x, | 449 | int src_y, int stride, int x, |
@@ -874,7 +524,6 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
874 | } | 524 | } |
875 | while (dst < dst_end); | 525 | while (dst < dst_end); |
876 | } | 526 | } |
877 | #endif /* !defined(TOSHIBA_GIGABEAT_F) || defined(SIMULATOR) */ | ||
878 | 527 | ||
879 | /* Draw a full native bitmap with a transparent color */ | 528 | /* Draw a full native bitmap with a transparent color */ |
880 | void lcd_bitmap_transparent(const fb_data *src, int x, int y, | 529 | void lcd_bitmap_transparent(const fb_data *src, int x, int y, |
@@ -883,10 +532,3 @@ void lcd_bitmap_transparent(const fb_data *src, int x, int y, | |||
883 | lcd_bitmap_transparent_part(src, 0, 0, | 532 | lcd_bitmap_transparent_part(src, 0, 0, |
884 | STRIDE(SCREEN_MAIN, width, height), x, y, width, height); | 533 | STRIDE(SCREEN_MAIN, width, height), x, y, width, height); |
885 | } | 534 | } |
886 | |||
887 | #define ROW_INC 1 | ||
888 | #define COL_INC LCD_HEIGHT | ||
889 | |||
890 | #include "lcd-16bit-common.c" | ||
891 | |||
892 | #include "lcd-bitmap-common.c" | ||