summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c')
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
index f9d5e5ace1..3332e0c78c 100644
--- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
+++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
@@ -444,43 +444,43 @@ void lcd_update(void)
444void lcd_update_rect(int x, int y, int width, int height) 444void lcd_update_rect(int x, int y, int width, int height)
445{ 445{
446 const fb_data *ptr; 446 const fb_data *ptr;
447 int xmax, ymax;
448 447
449 if (!display_on) 448 if (!display_on)
450 return; 449 return;
451 450
452 xmax = x + width; 451 /* nothing to draw? */
453 if (xmax >= LCD_WIDTH) 452 if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) ||
454 xmax = LCD_WIDTH - 1; /* Clip right */ 453 (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0))
455 if (x < 0) 454 return;
456 x = 0; /* Clip left */
457 if (x >= xmax)
458 return; /* nothing left to do */
459
460 width = xmax - x + 1; /* Fix width */
461 455
462 ymax = y + height; 456 if (x < 0)
463 if (ymax >= LCD_HEIGHT) 457 { /* clip left */
464 ymax = LCD_HEIGHT - 1; /* Clip bottom */ 458 width += x;
459 x = 0;
460 }
465 if (y < 0) 461 if (y < 0)
466 y = 0; /* Clip top */ 462 { /* clip top */
467 if (y >= ymax) 463 height += y;
468 return; /* nothing left to do */ 464 y = 0;
465 }
466 if (x + width > LCD_WIDTH)
467 width = LCD_WIDTH - x; /* clip right */
468 if (y + height > LCD_HEIGHT)
469 height = LCD_HEIGHT - y; /* clip bottom */
469 470
470 lcd_write_reg(R_ENTRY_MODE, r_entry_mode); 471 lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
471 472
472 lcd_window_x(x, xmax); 473 lcd_window_x(x, x + width - 1);
473 lcd_window_y(y, ymax); 474 lcd_window_y(y, y + height -1);
474 475
475 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 476 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
476 477
477 ptr = &lcd_framebuffer[y][x]; 478 ptr = &lcd_framebuffer[y][x];
478 479
479 height = ymax - y; /* fix height */
480 do 480 do
481 { 481 {
482 lcd_write_data(ptr, width); 482 lcd_write_data(ptr, width);
483 ptr += LCD_WIDTH; 483 ptr += LCD_WIDTH;
484 } 484 }
485 while (--height >= 0); 485 while (--height > 0);
486} 486}