diff options
Diffstat (limited to 'firmware/drivers/lcd-1bit-vert.c')
-rw-r--r-- | firmware/drivers/lcd-1bit-vert.c | 121 |
1 files changed, 17 insertions, 104 deletions
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index 49c15c041e..e1b65ca9c0 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c | |||
@@ -92,6 +92,8 @@ static void *LCDFN(frameaddress_default)(int x, int y) | |||
92 | return fb->FBFN(ptr) + element;/*(element % fb->elems);*/ | 92 | return fb->FBFN(ptr) + element;/*(element % fb->elems);*/ |
93 | } | 93 | } |
94 | 94 | ||
95 | #include "lcd-bitmap-common.c" | ||
96 | |||
95 | /* LCD init */ | 97 | /* LCD init */ |
96 | void LCDFN(init)(void) | 98 | void LCDFN(init)(void) |
97 | { | 99 | { |
@@ -272,10 +274,8 @@ void LCDFN(clear_viewport)(void) | |||
272 | /* Set a single pixel */ | 274 | /* Set a single pixel */ |
273 | void LCDFN(drawpixel)(int x, int y) | 275 | void LCDFN(drawpixel)(int x, int y) |
274 | { | 276 | { |
275 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) | 277 | if (LCDFN(clip_viewport_pixel)(&x, &y)) |
276 | && ((unsigned)y < (unsigned)CURRENT_VP->height) | 278 | LCDFN(pixelfuncs)[CURRENT_VP->drawmode](x, y); |
277 | ) | ||
278 | LCDFN(pixelfuncs)[CURRENT_VP->drawmode](CURRENT_VP->x + x, CURRENT_VP->y + y); | ||
279 | } | 279 | } |
280 | 280 | ||
281 | /* Draw a line */ | 281 | /* Draw a line */ |
@@ -287,6 +287,7 @@ void LCDFN(drawline)(int x1, int y1, int x2, int y2) | |||
287 | int d, dinc1, dinc2; | 287 | int d, dinc1, dinc2; |
288 | int x, xinc1, xinc2; | 288 | int x, xinc1, xinc2; |
289 | int y, yinc1, yinc2; | 289 | int y, yinc1, yinc2; |
290 | int x_vp, y_vp, w_vp, h_vp; | ||
290 | LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[CURRENT_VP->drawmode]; | 291 | LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[CURRENT_VP->drawmode]; |
291 | 292 | ||
292 | deltax = abs(x2 - x1); | 293 | deltax = abs(x2 - x1); |
@@ -341,12 +342,15 @@ void LCDFN(drawline)(int x1, int y1, int x2, int y2) | |||
341 | x = x1; | 342 | x = x1; |
342 | y = y1; | 343 | y = y1; |
343 | 344 | ||
345 | x_vp = CURRENT_VP->x; | ||
346 | y_vp = CURRENT_VP->y; | ||
347 | w_vp = CURRENT_VP->width; | ||
348 | h_vp = CURRENT_VP->height; | ||
349 | |||
344 | for (i = 0; i < numpixels; i++) | 350 | for (i = 0; i < numpixels; i++) |
345 | { | 351 | { |
346 | if ( ((unsigned)x < (unsigned)CURRENT_VP->width) | 352 | if (x >= 0 && y >= 0 && x < w_vp && y < h_vp) |
347 | && ((unsigned)y < (unsigned)CURRENT_VP->height) | 353 | pfunc(x + x_vp, y + y_vp); |
348 | ) | ||
349 | pfunc(CURRENT_VP->x + x, CURRENT_VP->y + y); | ||
350 | 354 | ||
351 | if (d < 0) | 355 | if (d < 0) |
352 | { | 356 | { |
@@ -366,35 +370,14 @@ void LCDFN(drawline)(int x1, int y1, int x2, int y2) | |||
366 | /* Draw a horizontal line (optimised) */ | 370 | /* Draw a horizontal line (optimised) */ |
367 | void LCDFN(hline)(int x1, int x2, int y) | 371 | void LCDFN(hline)(int x1, int x2, int y) |
368 | { | 372 | { |
369 | int x, width; | 373 | int width; |
370 | unsigned char *dst, *dst_end; | 374 | unsigned char *dst, *dst_end; |
371 | unsigned mask; | 375 | unsigned mask; |
372 | LCDFN(blockfunc_type) *bfunc; | 376 | LCDFN(blockfunc_type) *bfunc; |
373 | 377 | ||
374 | /* direction flip */ | 378 | if (!LCDFN(clip_viewport_hline)(&x1, &x2, &y)) |
375 | if (x2 < x1) | ||
376 | { | ||
377 | x = x1; | ||
378 | x1 = x2; | ||
379 | x2 = x; | ||
380 | } | ||
381 | |||
382 | /******************** In viewport clipping **********************/ | ||
383 | /* nothing to draw? */ | ||
384 | if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width) | ||
385 | || (x2 < 0)) | ||
386 | return; | 379 | return; |
387 | 380 | ||
388 | if (x1 < 0) | ||
389 | x1 = 0; | ||
390 | if (x2 >= CURRENT_VP->width) | ||
391 | x2 = CURRENT_VP->width-1; | ||
392 | |||
393 | /* adjust to viewport */ | ||
394 | x1 += CURRENT_VP->x; | ||
395 | x2 += CURRENT_VP->x; | ||
396 | y += CURRENT_VP->y; | ||
397 | |||
398 | width = x2 - x1 + 1; | 381 | width = x2 - x1 + 1; |
399 | 382 | ||
400 | bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; | 383 | bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; |
@@ -416,30 +399,9 @@ void LCDFN(vline)(int x, int y1, int y2) | |||
416 | unsigned mask, mask_bottom; | 399 | unsigned mask, mask_bottom; |
417 | LCDFN(blockfunc_type) *bfunc; | 400 | LCDFN(blockfunc_type) *bfunc; |
418 | 401 | ||
419 | /* direction flip */ | 402 | if (!LCDFN(clip_viewport_vline)(&x, &y1, &y2)) |
420 | if (y2 < y1) | ||
421 | { | ||
422 | ny = y1; | ||
423 | y1 = y2; | ||
424 | y2 = ny; | ||
425 | } | ||
426 | |||
427 | /******************** In viewport clipping **********************/ | ||
428 | /* nothing to draw? */ | ||
429 | if (((unsigned)x >= (unsigned)CURRENT_VP->width) || (y1 >= CURRENT_VP->height) | ||
430 | || (y2 < 0)) | ||
431 | return; | 403 | return; |
432 | 404 | ||
433 | if (y1 < 0) | ||
434 | y1 = 0; | ||
435 | if (y2 >= CURRENT_VP->height) | ||
436 | y2 = CURRENT_VP->height-1; | ||
437 | |||
438 | /* adjust for viewport */ | ||
439 | y1 += CURRENT_VP->y; | ||
440 | y2 += CURRENT_VP->y; | ||
441 | x += CURRENT_VP->x; | ||
442 | |||
443 | bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; | 405 | bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; |
444 | dst = LCDFB(x,y1>>3); | 406 | dst = LCDFB(x,y1>>3); |
445 | ny = y2 - (y1 & ~7); | 407 | ny = y2 - (y1 & ~7); |
@@ -483,31 +445,9 @@ void LCDFN(fillrect)(int x, int y, int width, int height) | |||
483 | LCDFN(blockfunc_type) *bfunc; | 445 | LCDFN(blockfunc_type) *bfunc; |
484 | bool fillopt = false; | 446 | bool fillopt = false; |
485 | 447 | ||
486 | /******************** In viewport clipping **********************/ | 448 | if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, NULL, NULL)) |
487 | /* nothing to draw? */ | ||
488 | if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) | ||
489 | || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) | ||
490 | return; | 449 | return; |
491 | 450 | ||
492 | if (x < 0) | ||
493 | { | ||
494 | width += x; | ||
495 | x = 0; | ||
496 | } | ||
497 | if (y < 0) | ||
498 | { | ||
499 | height += y; | ||
500 | y = 0; | ||
501 | } | ||
502 | if (x + width > CURRENT_VP->width) | ||
503 | width = CURRENT_VP->width - x; | ||
504 | if (y + height > CURRENT_VP->height) | ||
505 | height = CURRENT_VP->height - y; | ||
506 | |||
507 | /* adjust for viewport */ | ||
508 | x += CURRENT_VP->x; | ||
509 | y += CURRENT_VP->y; | ||
510 | |||
511 | if (CURRENT_VP->drawmode & DRMODE_INVERSEVID) | 451 | if (CURRENT_VP->drawmode & DRMODE_INVERSEVID) |
512 | { | 452 | { |
513 | if (CURRENT_VP->drawmode & DRMODE_BG) | 453 | if (CURRENT_VP->drawmode & DRMODE_BG) |
@@ -582,34 +522,9 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, | |||
582 | unsigned mask, mask_bottom; | 522 | unsigned mask, mask_bottom; |
583 | LCDFN(blockfunc_type) *bfunc; | 523 | LCDFN(blockfunc_type) *bfunc; |
584 | 524 | ||
585 | /******************** Image in viewport clipping **********************/ | 525 | if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, &src_x, &src_y)) |
586 | /* nothing to draw? */ | ||
587 | if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) | ||
588 | || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) | ||
589 | return; | 526 | return; |
590 | 527 | ||
591 | /* clip image in viewport */ | ||
592 | if (x < 0) | ||
593 | { | ||
594 | width += x; | ||
595 | src_x -= x; | ||
596 | x = 0; | ||
597 | } | ||
598 | if (y < 0) | ||
599 | { | ||
600 | height += y; | ||
601 | src_y -= y; | ||
602 | y = 0; | ||
603 | } | ||
604 | if (x + width > CURRENT_VP->width) | ||
605 | width = CURRENT_VP->width - x; | ||
606 | if (y + height > CURRENT_VP->height) | ||
607 | height = CURRENT_VP->height - y; | ||
608 | |||
609 | /* adjust for viewport */ | ||
610 | x += CURRENT_VP->x; | ||
611 | y += CURRENT_VP->y; | ||
612 | |||
613 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 528 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
614 | src_y &= 7; | 529 | src_y &= 7; |
615 | y -= src_y; | 530 | y -= src_y; |
@@ -696,5 +611,3 @@ void LCDFN(bitmap)(const unsigned char *src, int x, int y, int width, | |||
696 | { | 611 | { |
697 | LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height); | 612 | LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height); |
698 | } | 613 | } |
699 | |||
700 | #include "lcd-bitmap-common.c" | ||