diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-clipzip')
-rw-r--r-- | firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c index dd815df05e..47d896a2f3 100644 --- a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c +++ b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c | |||
@@ -26,10 +26,6 @@ | |||
26 | #include "system.h" | 26 | #include "system.h" |
27 | #include "cpu.h" | 27 | #include "cpu.h" |
28 | 28 | ||
29 | #define CLAMP(x,min,max) \ | ||
30 | if ((x)<(min)) (x)=(min);\ | ||
31 | if ((x)>(max)) (x)=(max); | ||
32 | |||
33 | /* the detected lcd type (0 or 1) */ | 29 | /* the detected lcd type (0 or 1) */ |
34 | static int lcd_type; | 30 | static int lcd_type; |
35 | 31 | ||
@@ -306,26 +302,37 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
306 | fb_data *ptr; | 302 | fb_data *ptr; |
307 | fb_data pixel; | 303 | fb_data pixel; |
308 | int row, col; | 304 | int row, col; |
309 | int x_end = x + width - 1; | 305 | int x_end = x + width; |
310 | int y_end = y + height - 1; | 306 | int y_end = y + height; |
311 | 307 | ||
312 | /* check/correct bounds */ | 308 | /* check rectangle */ |
313 | CLAMP(x, 0, LCD_WIDTH - 1); | 309 | if ((x >= LCD_WIDTH) || (x_end <= 0) || (y >= LCD_HEIGHT) || (y_end <= 0)) { |
314 | CLAMP(x_end, 0, LCD_WIDTH - 1); | 310 | /* rectangle is outside visible display, do nothing */ |
315 | CLAMP(y, 0, LCD_HEIGHT - 1); | ||
316 | CLAMP(y_end, 0, LCD_HEIGHT - 1); | ||
317 | if ((x > x_end) || (y > y_end)) { | ||
318 | return; | 311 | return; |
319 | } | 312 | } |
313 | |||
314 | /* correct rectangle (if necessary) */ | ||
315 | if (x < 0) { | ||
316 | x = 0; | ||
317 | } | ||
318 | if (x_end > LCD_WIDTH) { | ||
319 | x_end = LCD_WIDTH; | ||
320 | } | ||
321 | if (y < 0) { | ||
322 | y = 0; | ||
323 | } | ||
324 | if (y_end > LCD_HEIGHT) { | ||
325 | y_end = LCD_HEIGHT; | ||
326 | } | ||
320 | 327 | ||
321 | /* setup GRAM write window */ | 328 | /* setup GRAM write window */ |
322 | lcd_setup_rect(x, x_end, y, y_end); | 329 | lcd_setup_rect(x, x_end - 1, y, y_end - 1); |
323 | 330 | ||
324 | /* write to GRAM */ | 331 | /* write to GRAM */ |
325 | lcd_write_cmd((lcd_type == 0) ? 0x08 : 0x0C); | 332 | lcd_write_cmd((lcd_type == 0) ? 0x08 : 0x0C); |
326 | for (row = y; row <= y_end; row++) { | 333 | for (row = y; row < y_end; row++) { |
327 | ptr = &lcd_framebuffer[row][x]; | 334 | ptr = &lcd_framebuffer[row][x]; |
328 | for (col = x; col <= x_end; col++) { | 335 | for (col = x; col < x_end; col++) { |
329 | pixel = *ptr++; | 336 | pixel = *ptr++; |
330 | lcd_write_dat((pixel >> 8) & 0xFF); | 337 | lcd_write_dat((pixel >> 8) & 0xFF); |
331 | lcd_write_dat((pixel >> 0) & 0xFF); | 338 | lcd_write_dat((pixel >> 0) & 0xFF); |