diff options
-rw-r--r-- | firmware/drivers/lcd-16bit-common.c | 369 | ||||
-rw-r--r-- | firmware/drivers/lcd-16bit-vert.c | 368 | ||||
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 359 |
3 files changed, 369 insertions, 727 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c index 89d6dce966..7253524976 100644 --- a/firmware/drivers/lcd-16bit-common.c +++ b/firmware/drivers/lcd-16bit-common.c | |||
@@ -28,6 +28,357 @@ | |||
28 | #error ROW_INC or COL_INC not defined | 28 | #error ROW_INC or COL_INC not defined |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | enum fill_opt { | ||
32 | OPT_NONE = 0, | ||
33 | OPT_SET, | ||
34 | OPT_COPY | ||
35 | }; | ||
36 | |||
37 | /*** globals ***/ | ||
38 | fb_data lcd_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH] | ||
39 | IRAM_LCDFRAMEBUFFER CACHEALIGN_AT_LEAST_ATTR(16); | ||
40 | |||
41 | |||
42 | static fb_data* lcd_backdrop = NULL; | ||
43 | static long lcd_backdrop_offset IDATA_ATTR = 0; | ||
44 | |||
45 | static struct viewport default_vp = | ||
46 | { | ||
47 | .x = 0, | ||
48 | .y = 0, | ||
49 | .width = LCD_WIDTH, | ||
50 | .height = LCD_HEIGHT, | ||
51 | .font = FONT_SYSFIXED, | ||
52 | .drawmode = DRMODE_SOLID, | ||
53 | .fg_pattern = LCD_DEFAULT_FG, | ||
54 | .bg_pattern = LCD_DEFAULT_BG, | ||
55 | .lss_pattern = LCD_DEFAULT_BG, | ||
56 | .lse_pattern = LCD_DEFAULT_BG, | ||
57 | .lst_pattern = LCD_DEFAULT_BG, | ||
58 | }; | ||
59 | |||
60 | static struct viewport* current_vp IDATA_ATTR = &default_vp; | ||
61 | |||
62 | /* LCD init */ | ||
63 | void lcd_init(void) | ||
64 | { | ||
65 | lcd_clear_display(); | ||
66 | |||
67 | /* Call device specific init */ | ||
68 | lcd_init_device(); | ||
69 | scroll_init(); | ||
70 | } | ||
71 | /*** Viewports ***/ | ||
72 | |||
73 | void lcd_set_viewport(struct viewport* vp) | ||
74 | { | ||
75 | if (vp == NULL) | ||
76 | current_vp = &default_vp; | ||
77 | else | ||
78 | current_vp = vp; | ||
79 | |||
80 | #if defined(SIMULATOR) | ||
81 | /* Force the viewport to be within bounds. If this happens it should | ||
82 | * be considered an error - the viewport will not draw as it might be | ||
83 | * expected. | ||
84 | */ | ||
85 | if((unsigned) current_vp->x > (unsigned) LCD_WIDTH | ||
86 | || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT | ||
87 | || current_vp->x + current_vp->width > LCD_WIDTH | ||
88 | || current_vp->y + current_vp->height > LCD_HEIGHT) | ||
89 | { | ||
90 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
91 | DEBUGF("ERROR: " | ||
92 | #else | ||
93 | DEBUGF("NOTE: " | ||
94 | #endif | ||
95 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
96 | current_vp->x, current_vp->y, | ||
97 | current_vp->width, current_vp->height); | ||
98 | } | ||
99 | |||
100 | #endif | ||
101 | } | ||
102 | |||
103 | void lcd_update_viewport(void) | ||
104 | { | ||
105 | lcd_update_rect(current_vp->x, current_vp->y, | ||
106 | current_vp->width, current_vp->height); | ||
107 | } | ||
108 | |||
109 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
110 | { | ||
111 | lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
112 | } | ||
113 | |||
114 | /*** parameter handling ***/ | ||
115 | |||
116 | void lcd_set_drawmode(int mode) | ||
117 | { | ||
118 | current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); | ||
119 | } | ||
120 | |||
121 | int lcd_get_drawmode(void) | ||
122 | { | ||
123 | return current_vp->drawmode; | ||
124 | } | ||
125 | |||
126 | void lcd_set_foreground(unsigned color) | ||
127 | { | ||
128 | current_vp->fg_pattern = color; | ||
129 | } | ||
130 | |||
131 | unsigned lcd_get_foreground(void) | ||
132 | { | ||
133 | return current_vp->fg_pattern; | ||
134 | } | ||
135 | |||
136 | void lcd_set_background(unsigned color) | ||
137 | { | ||
138 | current_vp->bg_pattern = color; | ||
139 | } | ||
140 | |||
141 | unsigned lcd_get_background(void) | ||
142 | { | ||
143 | return current_vp->bg_pattern; | ||
144 | } | ||
145 | |||
146 | void lcd_set_selector_start(unsigned color) | ||
147 | { | ||
148 | current_vp->lss_pattern = color; | ||
149 | } | ||
150 | |||
151 | void lcd_set_selector_end(unsigned color) | ||
152 | { | ||
153 | current_vp->lse_pattern = color; | ||
154 | } | ||
155 | |||
156 | void lcd_set_selector_text(unsigned color) | ||
157 | { | ||
158 | current_vp->lst_pattern = color; | ||
159 | } | ||
160 | |||
161 | void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) | ||
162 | { | ||
163 | lcd_set_drawmode(mode); | ||
164 | current_vp->fg_pattern = fg_color; | ||
165 | current_vp->bg_pattern = bg_color; | ||
166 | } | ||
167 | |||
168 | int lcd_getwidth(void) | ||
169 | { | ||
170 | return current_vp->width; | ||
171 | } | ||
172 | |||
173 | int lcd_getheight(void) | ||
174 | { | ||
175 | return current_vp->height; | ||
176 | } | ||
177 | |||
178 | void lcd_setfont(int newfont) | ||
179 | { | ||
180 | current_vp->font = newfont; | ||
181 | } | ||
182 | |||
183 | int lcd_getfont(void) | ||
184 | { | ||
185 | return current_vp->font; | ||
186 | } | ||
187 | |||
188 | int lcd_getstringsize(const unsigned char *str, int *w, int *h) | ||
189 | { | ||
190 | return font_getstringsize(str, w, h, current_vp->font); | ||
191 | } | ||
192 | |||
193 | /*** low-level drawing functions ***/ | ||
194 | |||
195 | static void ICODE_ATTR setpixel(fb_data *address) | ||
196 | { | ||
197 | *address = current_vp->fg_pattern; | ||
198 | } | ||
199 | |||
200 | static void ICODE_ATTR clearpixel(fb_data *address) | ||
201 | { | ||
202 | *address = current_vp->bg_pattern; | ||
203 | } | ||
204 | |||
205 | static void ICODE_ATTR clearimgpixel(fb_data *address) | ||
206 | { | ||
207 | *address = *(fb_data *)((long)address + lcd_backdrop_offset); | ||
208 | } | ||
209 | |||
210 | static void ICODE_ATTR flippixel(fb_data *address) | ||
211 | { | ||
212 | *address = ~(*address); | ||
213 | } | ||
214 | |||
215 | static void ICODE_ATTR nopixel(fb_data *address) | ||
216 | { | ||
217 | (void)address; | ||
218 | } | ||
219 | |||
220 | lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[8] = { | ||
221 | flippixel, nopixel, setpixel, setpixel, | ||
222 | nopixel, clearpixel, nopixel, clearpixel | ||
223 | }; | ||
224 | |||
225 | lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[8] = { | ||
226 | flippixel, nopixel, setpixel, setpixel, | ||
227 | nopixel, clearimgpixel, nopixel, clearimgpixel | ||
228 | }; | ||
229 | |||
230 | lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor; | ||
231 | |||
232 | void lcd_set_backdrop(fb_data* backdrop) | ||
233 | { | ||
234 | lcd_backdrop = backdrop; | ||
235 | if (backdrop) | ||
236 | { | ||
237 | lcd_backdrop_offset = (long)backdrop - (long)&lcd_framebuffer[0][0]; | ||
238 | lcd_fastpixelfuncs = lcd_fastpixelfuncs_backdrop; | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | lcd_backdrop_offset = 0; | ||
243 | lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | fb_data* lcd_get_backdrop(void) | ||
248 | { | ||
249 | return lcd_backdrop; | ||
250 | } | ||
251 | |||
252 | /* Clear the whole display */ | ||
253 | void lcd_clear_display(void) | ||
254 | { | ||
255 | struct viewport* old_vp = current_vp; | ||
256 | |||
257 | current_vp = &default_vp; | ||
258 | |||
259 | lcd_clear_viewport(); | ||
260 | |||
261 | current_vp = old_vp; | ||
262 | } | ||
263 | |||
264 | /* Set a single pixel */ | ||
265 | void lcd_drawpixel(int x, int y) | ||
266 | { | ||
267 | if ( ((unsigned)x < (unsigned)current_vp->width) | ||
268 | && ((unsigned)y < (unsigned)current_vp->height) | ||
269 | #if defined(HAVE_VIEWPORT_CLIP) | ||
270 | && ((unsigned)x < (unsigned)LCD_WIDTH) | ||
271 | && ((unsigned)y < (unsigned)LCD_HEIGHT) | ||
272 | #endif | ||
273 | ) | ||
274 | lcd_fastpixelfuncs[current_vp->drawmode](LCDADDR(current_vp->x+x, current_vp->y+y)); | ||
275 | } | ||
276 | |||
277 | /* Draw a line */ | ||
278 | void lcd_drawline(int x1, int y1, int x2, int y2) | ||
279 | { | ||
280 | int numpixels; | ||
281 | int i; | ||
282 | int deltax, deltay; | ||
283 | int d, dinc1, dinc2; | ||
284 | int x, xinc1, xinc2; | ||
285 | int y, yinc1, yinc2; | ||
286 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[current_vp->drawmode]; | ||
287 | |||
288 | deltay = abs(y2 - y1); | ||
289 | if (deltay == 0) | ||
290 | { | ||
291 | /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */ | ||
292 | lcd_hline(x1, x2, y1); | ||
293 | return; | ||
294 | } | ||
295 | deltax = abs(x2 - x1); | ||
296 | if (deltax == 0) | ||
297 | { | ||
298 | /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */ | ||
299 | lcd_vline(x1, y1, y2); | ||
300 | return; | ||
301 | } | ||
302 | xinc2 = 1; | ||
303 | yinc2 = 1; | ||
304 | |||
305 | if (deltax >= deltay) | ||
306 | { | ||
307 | numpixels = deltax; | ||
308 | d = 2 * deltay - deltax; | ||
309 | dinc1 = deltay * 2; | ||
310 | dinc2 = (deltay - deltax) * 2; | ||
311 | xinc1 = 1; | ||
312 | yinc1 = 0; | ||
313 | } | ||
314 | else | ||
315 | { | ||
316 | numpixels = deltay; | ||
317 | d = 2 * deltax - deltay; | ||
318 | dinc1 = deltax * 2; | ||
319 | dinc2 = (deltax - deltay) * 2; | ||
320 | xinc1 = 0; | ||
321 | yinc1 = 1; | ||
322 | } | ||
323 | numpixels++; /* include endpoints */ | ||
324 | |||
325 | if (x1 > x2) | ||
326 | { | ||
327 | xinc1 = -xinc1; | ||
328 | xinc2 = -xinc2; | ||
329 | } | ||
330 | |||
331 | if (y1 > y2) | ||
332 | { | ||
333 | yinc1 = -yinc1; | ||
334 | yinc2 = -yinc2; | ||
335 | } | ||
336 | |||
337 | x = x1; | ||
338 | y = y1; | ||
339 | |||
340 | for (i = 0; i < numpixels; i++) | ||
341 | { | ||
342 | if ( ((unsigned)x < (unsigned)current_vp->width) | ||
343 | && ((unsigned)y < (unsigned)current_vp->height) | ||
344 | #if defined(HAVE_VIEWPORT_CLIP) | ||
345 | && ((unsigned)x < (unsigned)LCD_WIDTH) | ||
346 | && ((unsigned)y < (unsigned)LCD_HEIGHT) | ||
347 | #endif | ||
348 | ) | ||
349 | pfunc(LCDADDR(x + current_vp->x, y + current_vp->y)); | ||
350 | |||
351 | if (d < 0) | ||
352 | { | ||
353 | d += dinc1; | ||
354 | x += xinc1; | ||
355 | y += yinc1; | ||
356 | } | ||
357 | else | ||
358 | { | ||
359 | d += dinc2; | ||
360 | x += xinc2; | ||
361 | y += yinc2; | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | |||
366 | /* Draw a rectangular box */ | ||
367 | void lcd_drawrect(int x, int y, int width, int height) | ||
368 | { | ||
369 | if ((width <= 0) || (height <= 0)) | ||
370 | return; | ||
371 | |||
372 | int x2 = x + width - 1; | ||
373 | int y2 = y + height - 1; | ||
374 | |||
375 | lcd_vline(x, y, y2); | ||
376 | lcd_vline(x2, y, y2); | ||
377 | lcd_hline(x, x2, y); | ||
378 | lcd_hline(x, x2, y2); | ||
379 | } | ||
380 | |||
381 | |||
31 | /* About Rockbox' internal monochrome bitmap format: | 382 | /* About Rockbox' internal monochrome bitmap format: |
32 | * | 383 | * |
33 | * A bitmap contains one bit for every pixel that defines if that pixel is | 384 | * A bitmap contains one bit for every pixel that defines if that pixel is |
@@ -54,7 +405,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
54 | 405 | ||
55 | /******************** Image in viewport clipping **********************/ | 406 | /******************** Image in viewport clipping **********************/ |
56 | /* nothing to draw? */ | 407 | /* nothing to draw? */ |
57 | if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || | 408 | if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || |
58 | (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) | 409 | (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) |
59 | return; | 410 | return; |
60 | 411 | ||
@@ -74,18 +425,18 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
74 | width = current_vp->width - x; | 425 | width = current_vp->width - x; |
75 | if (y + height > current_vp->height) | 426 | if (y + height > current_vp->height) |
76 | height = current_vp->height - y; | 427 | height = current_vp->height - y; |
77 | 428 | ||
78 | /* adjust for viewport */ | 429 | /* adjust for viewport */ |
79 | x += current_vp->x; | 430 | x += current_vp->x; |
80 | y += current_vp->y; | 431 | y += current_vp->y; |
81 | 432 | ||
82 | #if defined(HAVE_VIEWPORT_CLIP) | 433 | #if defined(HAVE_VIEWPORT_CLIP) |
83 | /********************* Viewport on screen clipping ********************/ | 434 | /********************* Viewport on screen clipping ********************/ |
84 | /* nothing to draw? */ | 435 | /* nothing to draw? */ |
85 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 436 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
86 | || (x + width <= 0) || (y + height <= 0)) | 437 | || (x + width <= 0) || (y + height <= 0)) |
87 | return; | 438 | return; |
88 | 439 | ||
89 | /* clip image in viewport in screen */ | 440 | /* clip image in viewport in screen */ |
90 | if (x < 0) | 441 | if (x < 0) |
91 | { | 442 | { |
@@ -109,7 +460,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
109 | src_y &= 7; | 460 | src_y &= 7; |
110 | src_end = src + width; | 461 | src_end = src + width; |
111 | dst_col = LCDADDR(x, y); | 462 | dst_col = LCDADDR(x, y); |
112 | 463 | ||
113 | 464 | ||
114 | if (drmode & DRMODE_INVERSEVID) | 465 | if (drmode & DRMODE_INVERSEVID) |
115 | { | 466 | { |
@@ -200,7 +551,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
200 | bo = lcd_backdrop_offset; | 551 | bo = lcd_backdrop_offset; |
201 | do | 552 | do |
202 | { | 553 | { |
203 | *dst = (data & 0x01) ? fg | 554 | *dst = (data & 0x01) ? fg |
204 | : *(fb_data *)((long)dst + bo); | 555 | : *(fb_data *)((long)dst + bo); |
205 | dst += ROW_INC; | 556 | dst += ROW_INC; |
206 | UPDATE_SRC; | 557 | UPDATE_SRC; |
@@ -348,10 +699,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
348 | #if defined(HAVE_VIEWPORT_CLIP) | 699 | #if defined(HAVE_VIEWPORT_CLIP) |
349 | /********************* Viewport on screen clipping ********************/ | 700 | /********************* Viewport on screen clipping ********************/ |
350 | /* nothing to draw? */ | 701 | /* nothing to draw? */ |
351 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 702 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
352 | || (x + width <= 0) || (y + height <= 0)) | 703 | || (x + width <= 0) || (y + height <= 0)) |
353 | return; | 704 | return; |
354 | 705 | ||
355 | /* clip image in viewport in screen */ | 706 | /* clip image in viewport in screen */ |
356 | if (x < 0) | 707 | if (x < 0) |
357 | { | 708 | { |
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" | ||
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index 844db296c6..60dfc7bcf2 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2005 by Dave Chapman | 10 | * Copyright (C) 2005 by Dave Chapman |
11 | * | ||
12 | * Copyright (C) 2009 by Karl Kurbjun | 11 | * Copyright (C) 2009 by Karl Kurbjun |
13 | * | 12 | * |
14 | * Rockbox driver for 16-bit colour LCDs | 13 | * Rockbox driver for 16-bit colour LCDs |
@@ -39,228 +38,14 @@ | |||
39 | #include "bidi.h" | 38 | #include "bidi.h" |
40 | #include "scroll_engine.h" | 39 | #include "scroll_engine.h" |
41 | 40 | ||
42 | enum fill_opt { | 41 | #define ROW_INC LCD_WIDTH |
43 | OPT_NONE = 0, | 42 | #define COL_INC 1 |
44 | OPT_SET, | ||
45 | OPT_COPY | ||
46 | }; | ||
47 | |||
48 | /*** globals ***/ | ||
49 | fb_data lcd_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH] | ||
50 | IRAM_LCDFRAMEBUFFER CACHEALIGN_AT_LEAST_ATTR(16); | ||
51 | |||
52 | |||
53 | static fb_data* lcd_backdrop = NULL; | ||
54 | static long lcd_backdrop_offset IDATA_ATTR = 0; | ||
55 | |||
56 | static struct viewport default_vp = | ||
57 | { | ||
58 | .x = 0, | ||
59 | .y = 0, | ||
60 | .width = LCD_WIDTH, | ||
61 | .height = LCD_HEIGHT, | ||
62 | .font = FONT_SYSFIXED, | ||
63 | .drawmode = DRMODE_SOLID, | ||
64 | .fg_pattern = LCD_DEFAULT_FG, | ||
65 | .bg_pattern = LCD_DEFAULT_BG, | ||
66 | .lss_pattern = LCD_DEFAULT_BG, | ||
67 | .lse_pattern = LCD_DEFAULT_BG, | ||
68 | .lst_pattern = LCD_DEFAULT_BG, | ||
69 | }; | ||
70 | |||
71 | static struct viewport* current_vp IDATA_ATTR = &default_vp; | ||
72 | |||
73 | /* LCD init */ | ||
74 | void lcd_init(void) | ||
75 | { | ||
76 | lcd_clear_display(); | ||
77 | |||
78 | /* Call device specific init */ | ||
79 | lcd_init_device(); | ||
80 | scroll_init(); | ||
81 | } | ||
82 | /*** Viewports ***/ | ||
83 | |||
84 | void lcd_set_viewport(struct viewport* vp) | ||
85 | { | ||
86 | if (vp == NULL) | ||
87 | current_vp = &default_vp; | ||
88 | else | ||
89 | current_vp = vp; | ||
90 | |||
91 | #if defined(SIMULATOR) | ||
92 | /* Force the viewport to be within bounds. If this happens it should | ||
93 | * be considered an error - the viewport will not draw as it might be | ||
94 | * expected. | ||
95 | */ | ||
96 | if((unsigned) current_vp->x > (unsigned) LCD_WIDTH | ||
97 | || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT | ||
98 | || current_vp->x + current_vp->width > LCD_WIDTH | ||
99 | || current_vp->y + current_vp->height > LCD_HEIGHT) | ||
100 | { | ||
101 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
102 | DEBUGF("ERROR: " | ||
103 | #else | ||
104 | DEBUGF("NOTE: " | ||
105 | #endif | ||
106 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
107 | current_vp->x, current_vp->y, | ||
108 | current_vp->width, current_vp->height); | ||
109 | } | ||
110 | |||
111 | #endif | ||
112 | } | ||
113 | |||
114 | void lcd_update_viewport(void) | ||
115 | { | ||
116 | lcd_update_rect(current_vp->x, current_vp->y, | ||
117 | current_vp->width, current_vp->height); | ||
118 | } | ||
119 | |||
120 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
121 | { | ||
122 | lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
123 | } | ||
124 | |||
125 | /*** parameter handling ***/ | ||
126 | |||
127 | void lcd_set_drawmode(int mode) | ||
128 | { | ||
129 | current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); | ||
130 | } | ||
131 | |||
132 | int lcd_get_drawmode(void) | ||
133 | { | ||
134 | return current_vp->drawmode; | ||
135 | } | ||
136 | |||
137 | void lcd_set_foreground(unsigned color) | ||
138 | { | ||
139 | current_vp->fg_pattern = color; | ||
140 | } | ||
141 | |||
142 | unsigned lcd_get_foreground(void) | ||
143 | { | ||
144 | return current_vp->fg_pattern; | ||
145 | } | ||
146 | |||
147 | void lcd_set_background(unsigned color) | ||
148 | { | ||
149 | current_vp->bg_pattern = color; | ||
150 | } | ||
151 | |||
152 | unsigned lcd_get_background(void) | ||
153 | { | ||
154 | return current_vp->bg_pattern; | ||
155 | } | ||
156 | |||
157 | void lcd_set_selector_start(unsigned color) | ||
158 | { | ||
159 | current_vp->lss_pattern = color; | ||
160 | } | ||
161 | |||
162 | void lcd_set_selector_end(unsigned color) | ||
163 | { | ||
164 | current_vp->lse_pattern = color; | ||
165 | } | ||
166 | |||
167 | void lcd_set_selector_text(unsigned color) | ||
168 | { | ||
169 | current_vp->lst_pattern = color; | ||
170 | } | ||
171 | |||
172 | void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) | ||
173 | { | ||
174 | lcd_set_drawmode(mode); | ||
175 | current_vp->fg_pattern = fg_color; | ||
176 | current_vp->bg_pattern = bg_color; | ||
177 | } | ||
178 | |||
179 | int lcd_getwidth(void) | ||
180 | { | ||
181 | return current_vp->width; | ||
182 | } | ||
183 | |||
184 | int lcd_getheight(void) | ||
185 | { | ||
186 | return current_vp->height; | ||
187 | } | ||
188 | |||
189 | void lcd_setfont(int newfont) | ||
190 | { | ||
191 | current_vp->font = newfont; | ||
192 | } | ||
193 | |||
194 | int lcd_getfont(void) | ||
195 | { | ||
196 | return current_vp->font; | ||
197 | } | ||
198 | |||
199 | int lcd_getstringsize(const unsigned char *str, int *w, int *h) | ||
200 | { | ||
201 | return font_getstringsize(str, w, h, current_vp->font); | ||
202 | } | ||
203 | |||
204 | /*** low-level drawing functions ***/ | ||
205 | 43 | ||
206 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) | 44 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) |
207 | 45 | ||
208 | static void ICODE_ATTR setpixel(fb_data *address) | 46 | #include "lcd-16bit-common.c" |
209 | { | ||
210 | *address = current_vp->fg_pattern; | ||
211 | } | ||
212 | |||
213 | static void ICODE_ATTR clearpixel(fb_data *address) | ||
214 | { | ||
215 | *address = current_vp->bg_pattern; | ||
216 | } | ||
217 | |||
218 | static void ICODE_ATTR clearimgpixel(fb_data *address) | ||
219 | { | ||
220 | *address = *(fb_data *)((long)address + lcd_backdrop_offset); | ||
221 | } | ||
222 | |||
223 | static void ICODE_ATTR flippixel(fb_data *address) | ||
224 | { | ||
225 | *address = ~(*address); | ||
226 | } | ||
227 | |||
228 | static void ICODE_ATTR nopixel(fb_data *address) | ||
229 | { | ||
230 | (void)address; | ||
231 | } | ||
232 | |||
233 | lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[8] = { | ||
234 | flippixel, nopixel, setpixel, setpixel, | ||
235 | nopixel, clearpixel, nopixel, clearpixel | ||
236 | }; | ||
237 | |||
238 | lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[8] = { | ||
239 | flippixel, nopixel, setpixel, setpixel, | ||
240 | nopixel, clearimgpixel, nopixel, clearimgpixel | ||
241 | }; | ||
242 | |||
243 | lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor; | ||
244 | |||
245 | void lcd_set_backdrop(fb_data* backdrop) | ||
246 | { | ||
247 | lcd_backdrop = backdrop; | ||
248 | if (backdrop) | ||
249 | { | ||
250 | lcd_backdrop_offset = (long)backdrop - (long)&lcd_framebuffer[0][0]; | ||
251 | lcd_fastpixelfuncs = lcd_fastpixelfuncs_backdrop; | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | lcd_backdrop_offset = 0; | ||
256 | lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor; | ||
257 | } | ||
258 | } | ||
259 | 47 | ||
260 | fb_data* lcd_get_backdrop(void) | 48 | #include "lcd-bitmap-common.c" |
261 | { | ||
262 | return lcd_backdrop; | ||
263 | } | ||
264 | 49 | ||
265 | /*** drawing functions ***/ | 50 | /*** drawing functions ***/ |
266 | 51 | ||
@@ -314,120 +99,6 @@ void lcd_clear_viewport(void) | |||
314 | } | 99 | } |
315 | } | 100 | } |
316 | 101 | ||
317 | /* Clear the whole display */ | ||
318 | void lcd_clear_display(void) | ||
319 | { | ||
320 | struct viewport* old_vp = current_vp; | ||
321 | |||
322 | current_vp = &default_vp; | ||
323 | |||
324 | lcd_clear_viewport(); | ||
325 | |||
326 | current_vp = old_vp; | ||
327 | } | ||
328 | |||
329 | /* Set a single pixel */ | ||
330 | void lcd_drawpixel(int x, int y) | ||
331 | { | ||
332 | if ( ((unsigned)x < (unsigned)current_vp->width) | ||
333 | && ((unsigned)y < (unsigned)current_vp->height) | ||
334 | #if defined(HAVE_VIEWPORT_CLIP) | ||
335 | && ((unsigned)x < (unsigned)LCD_WIDTH) | ||
336 | && ((unsigned)y < (unsigned)LCD_HEIGHT) | ||
337 | #endif | ||
338 | ) | ||
339 | lcd_fastpixelfuncs[current_vp->drawmode](LCDADDR(current_vp->x+x, current_vp->y+y)); | ||
340 | } | ||
341 | |||
342 | /* Draw a line */ | ||
343 | void lcd_drawline(int x1, int y1, int x2, int y2) | ||
344 | { | ||
345 | int numpixels; | ||
346 | int i; | ||
347 | int deltax, deltay; | ||
348 | int d, dinc1, dinc2; | ||
349 | int x, xinc1, xinc2; | ||
350 | int y, yinc1, yinc2; | ||
351 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[current_vp->drawmode]; | ||
352 | |||
353 | deltay = abs(y2 - y1); | ||
354 | if (deltay == 0) | ||
355 | { | ||
356 | /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */ | ||
357 | lcd_hline(x1, x2, y1); | ||
358 | return; | ||
359 | } | ||
360 | deltax = abs(x2 - x1); | ||
361 | if (deltax == 0) | ||
362 | { | ||
363 | /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */ | ||
364 | lcd_vline(x1, y1, y2); | ||
365 | return; | ||
366 | } | ||
367 | xinc2 = 1; | ||
368 | yinc2 = 1; | ||
369 | |||
370 | if (deltax >= deltay) | ||
371 | { | ||
372 | numpixels = deltax; | ||
373 | d = 2 * deltay - deltax; | ||
374 | dinc1 = deltay * 2; | ||
375 | dinc2 = (deltay - deltax) * 2; | ||
376 | xinc1 = 1; | ||
377 | yinc1 = 0; | ||
378 | } | ||
379 | else | ||
380 | { | ||
381 | numpixels = deltay; | ||
382 | d = 2 * deltax - deltay; | ||
383 | dinc1 = deltax * 2; | ||
384 | dinc2 = (deltax - deltay) * 2; | ||
385 | xinc1 = 0; | ||
386 | yinc1 = 1; | ||
387 | } | ||
388 | numpixels++; /* include endpoints */ | ||
389 | |||
390 | if (x1 > x2) | ||
391 | { | ||
392 | xinc1 = -xinc1; | ||
393 | xinc2 = -xinc2; | ||
394 | } | ||
395 | |||
396 | if (y1 > y2) | ||
397 | { | ||
398 | yinc1 = -yinc1; | ||
399 | yinc2 = -yinc2; | ||
400 | } | ||
401 | |||
402 | x = x1; | ||
403 | y = y1; | ||
404 | |||
405 | for (i = 0; i < numpixels; i++) | ||
406 | { | ||
407 | if ( ((unsigned)x < (unsigned)current_vp->width) | ||
408 | && ((unsigned)y < (unsigned)current_vp->height) | ||
409 | #if defined(HAVE_VIEWPORT_CLIP) | ||
410 | && ((unsigned)x < (unsigned)LCD_WIDTH) | ||
411 | && ((unsigned)y < (unsigned)LCD_HEIGHT) | ||
412 | #endif | ||
413 | ) | ||
414 | pfunc(LCDADDR(x + current_vp->x, y + current_vp->y)); | ||
415 | |||
416 | if (d < 0) | ||
417 | { | ||
418 | d += dinc1; | ||
419 | x += xinc1; | ||
420 | y += yinc1; | ||
421 | } | ||
422 | else | ||
423 | { | ||
424 | d += dinc2; | ||
425 | x += xinc2; | ||
426 | y += yinc2; | ||
427 | } | ||
428 | } | ||
429 | } | ||
430 | |||
431 | /* Draw a horizontal line (optimised) */ | 102 | /* Draw a horizontal line (optimised) */ |
432 | void lcd_hline(int x1, int x2, int y) | 103 | void lcd_hline(int x1, int x2, int y) |
433 | { | 104 | { |
@@ -581,21 +252,6 @@ void lcd_vline(int x, int y1, int y2) | |||
581 | while (dst <= dst_end); | 252 | while (dst <= dst_end); |
582 | } | 253 | } |
583 | 254 | ||
584 | /* Draw a rectangular box */ | ||
585 | void lcd_drawrect(int x, int y, int width, int height) | ||
586 | { | ||
587 | if ((width <= 0) || (height <= 0)) | ||
588 | return; | ||
589 | |||
590 | int x2 = x + width - 1; | ||
591 | int y2 = y + height - 1; | ||
592 | |||
593 | lcd_vline(x, y, y2); | ||
594 | lcd_vline(x2, y, y2); | ||
595 | lcd_hline(x, x2, y); | ||
596 | lcd_hline(x, x2, y2); | ||
597 | } | ||
598 | |||
599 | /* Fill a rectangular area */ | 255 | /* Fill a rectangular area */ |
600 | void lcd_fillrect(int x, int y, int width, int height) | 256 | void lcd_fillrect(int x, int y, int width, int height) |
601 | { | 257 | { |
@@ -912,10 +568,3 @@ void lcd_bitmap_transparent(const fb_data *src, int x, int y, | |||
912 | { | 568 | { |
913 | lcd_bitmap_transparent_part(src, 0, 0, width, x, y, width, height); | 569 | lcd_bitmap_transparent_part(src, 0, 0, width, x, y, width, height); |
914 | } | 570 | } |
915 | |||
916 | #define ROW_INC LCD_WIDTH | ||
917 | #define COL_INC 1 | ||
918 | |||
919 | #include "lcd-16bit-common.c" | ||
920 | |||
921 | #include "lcd-bitmap-common.c" | ||