convert to unix line endings.
[Rockbox.git] / firmware / drivers / lcd-1bit-vert.c
blobc6fe40cdb7a1e6fafff6b12ab274344155f1e980
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Alan Korr
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
22 #include "lcd.h"
23 #include "kernel.h"
24 #include "thread.h"
25 #include <string.h>
26 #include <stdlib.h>
27 #include "file.h"
28 #include "debug.h"
29 #include "system.h"
30 #include "font.h"
31 #include "rbunicode.h"
32 #include "bidi.h"
33 #include "scroll_engine.h"
35 #ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */
36 #define LCDFN(fn) lcd_ ## fn
37 #define FBFN(fn) fb_ ## fn
38 #define LCDM(ma) LCD_ ## ma
39 #define LCDNAME "lcd_"
40 #define MAIN_LCD
41 #endif
43 /*** globals ***/
45 FBFN(data) LCDFN(framebuffer)[LCDM(FBHEIGHT)][LCDM(FBWIDTH)]
46 #if CONFIG_CPU != SH7034
47 IBSS_ATTR
48 #endif
51 static struct viewport default_vp =
53 .x = 0,
54 .y = 0,
55 .width = LCDM(WIDTH),
56 .height = LCDM(HEIGHT),
57 .font = FONT_SYSFIXED,
58 .drawmode = DRMODE_SOLID,
59 .xmargin = 0,
60 .ymargin = 0,
63 static struct viewport* current_vp = &default_vp;
65 /*** Viewports ***/
67 void LCDFN(set_viewport)(struct viewport* vp)
69 if (vp == NULL)
70 current_vp = &default_vp;
71 else
72 current_vp = vp;
75 void LCDFN(update_viewport)(void)
77 LCDFN(update_rect)(current_vp->x, current_vp->y,
78 current_vp->width, current_vp->height);
81 void LCDFN(update_viewport_rect)(int x, int y, int width, int height)
83 LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height);
86 /* LCD init */
87 void LCDFN(init)(void)
89 LCDFN(clear_display)();
90 #ifndef SIMULATOR
91 LCDFN(init_device)();
92 #endif
93 #ifdef MAIN_LCD
94 scroll_init();
95 #endif
98 /*** parameter handling ***/
100 void LCDFN(set_drawmode)(int mode)
102 current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
105 int LCDFN(get_drawmode)(void)
107 return current_vp->drawmode;
110 void LCDFN(setmargins)(int x, int y)
112 current_vp->xmargin = x;
113 current_vp->ymargin = y;
116 int LCDFN(getxmargin)(void)
118 return current_vp->xmargin;
121 int LCDFN(getymargin)(void)
123 return current_vp->ymargin;
126 int LCDFN(getwidth)(void)
128 return current_vp->width;
131 int LCDFN(getheight)(void)
133 return current_vp->height;
136 void LCDFN(setfont)(int newfont)
138 current_vp->font = newfont;
141 int LCDFN(getfont)(void)
143 return current_vp->font;
146 int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h)
148 return font_getstringsize(str, w, h, current_vp->font);
151 /*** low-level drawing functions ***/
153 static void setpixel(int x, int y)
155 LCDFN(framebuffer)[y>>3][x] |= 1 << (y & 7);
158 static void clearpixel(int x, int y)
160 LCDFN(framebuffer)[y>>3][x] &= ~(1 << (y & 7));
163 static void flippixel(int x, int y)
165 LCDFN(framebuffer)[y>>3][x] ^= 1 << (y & 7);
168 static void nopixel(int x, int y)
170 (void)x;
171 (void)y;
174 LCDFN(pixelfunc_type)* const LCDFN(pixelfuncs)[8] = {
175 flippixel, nopixel, setpixel, setpixel,
176 nopixel, clearpixel, nopixel, clearpixel
179 static void ICODE_ATTR flipblock(FBFN(data) *address, unsigned mask,
180 unsigned bits)
182 *address ^= bits & mask;
185 static void ICODE_ATTR bgblock(FBFN(data) *address, unsigned mask,
186 unsigned bits)
188 *address &= bits | ~mask;
191 static void ICODE_ATTR fgblock(FBFN(data) *address, unsigned mask,
192 unsigned bits)
194 *address |= bits & mask;
197 static void ICODE_ATTR solidblock(FBFN(data) *address, unsigned mask,
198 unsigned bits)
200 unsigned data = *(char*)address;
202 bits ^= data;
203 *address = data ^ (bits & mask);
206 static void ICODE_ATTR flipinvblock(FBFN(data) *address, unsigned mask,
207 unsigned bits)
209 *address ^= ~bits & mask;
212 static void ICODE_ATTR bginvblock(FBFN(data) *address, unsigned mask,
213 unsigned bits)
215 *address &= ~(bits & mask);
218 static void ICODE_ATTR fginvblock(FBFN(data) *address, unsigned mask,
219 unsigned bits)
221 *address |= ~bits & mask;
224 static void ICODE_ATTR solidinvblock(FBFN(data) *address, unsigned mask,
225 unsigned bits)
227 unsigned data = *(char *)address;
229 bits = ~bits ^ data;
230 *address = data ^ (bits & mask);
233 LCDFN(blockfunc_type)* const LCDFN(blockfuncs)[8] = {
234 flipblock, bgblock, fgblock, solidblock,
235 flipinvblock, bginvblock, fginvblock, solidinvblock
238 /*** drawing functions ***/
240 /* Clear the whole display */
241 void LCDFN(clear_display)(void)
243 unsigned bits = (current_vp->drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0;
245 memset(LCDFN(framebuffer), bits, sizeof LCDFN(framebuffer));
246 LCDFN(scroll_info).lines = 0;
249 /* Clear the current viewport */
250 void LCDFN(clear_viewport)(void)
252 int oldmode;
254 if (current_vp == &default_vp)
256 LCDFN(clear_display)();
258 else
260 oldmode = current_vp->drawmode;
262 /* Invert the INVERSEVID bit and set basic mode to SOLID */
263 current_vp->drawmode = (~current_vp->drawmode & DRMODE_INVERSEVID) |
264 DRMODE_SOLID;
266 LCDFN(fillrect)(0, 0, current_vp->width, current_vp->height);
268 current_vp->drawmode = oldmode;
270 LCDFN(scroll_stop)(current_vp);
274 /* Set a single pixel */
275 void LCDFN(drawpixel)(int x, int y)
277 if (((unsigned)x < (unsigned)current_vp->width) &&
278 ((unsigned)y < (unsigned)current_vp->height))
279 LCDFN(pixelfuncs)[current_vp->drawmode](current_vp->x + x, current_vp->y + y);
282 /* Draw a line */
283 void LCDFN(drawline)(int x1, int y1, int x2, int y2)
285 int numpixels;
286 int i;
287 int deltax, deltay;
288 int d, dinc1, dinc2;
289 int x, xinc1, xinc2;
290 int y, yinc1, yinc2;
291 LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[current_vp->drawmode];
293 deltax = abs(x2 - x1);
294 if (deltax == 0)
296 DEBUGF(LCDNAME "drawline() called for vertical line - optimisation.\n");
297 LCDFN(vline)(x1, y1, y2);
298 return;
300 deltay = abs(y2 - y1);
301 if (deltay == 0)
303 DEBUGF(LCDNAME "drawline() called for horizontal line - optimisation.\n");
304 LCDFN(hline)(x1, x2, y1);
305 return;
307 xinc2 = 1;
308 yinc2 = 1;
310 if (deltax >= deltay)
312 numpixels = deltax;
313 d = 2 * deltay - deltax;
314 dinc1 = deltay * 2;
315 dinc2 = (deltay - deltax) * 2;
316 xinc1 = 1;
317 yinc1 = 0;
319 else
321 numpixels = deltay;
322 d = 2 * deltax - deltay;
323 dinc1 = deltax * 2;
324 dinc2 = (deltax - deltay) * 2;
325 xinc1 = 0;
326 yinc1 = 1;
328 numpixels++; /* include endpoints */
330 if (x1 > x2)
332 xinc1 = -xinc1;
333 xinc2 = -xinc2;
336 if (y1 > y2)
338 yinc1 = -yinc1;
339 yinc2 = -yinc2;
342 x = x1;
343 y = y1;
345 for (i = 0; i < numpixels; i++)
347 if (((unsigned)x < (unsigned)current_vp->width)
348 && ((unsigned)y < (unsigned)current_vp->height))
349 pfunc(current_vp->x + x, current_vp->y + y);
351 if (d < 0)
353 d += dinc1;
354 x += xinc1;
355 y += yinc1;
357 else
359 d += dinc2;
360 x += xinc2;
361 y += yinc2;
366 /* Draw a horizontal line (optimised) */
367 void LCDFN(hline)(int x1, int x2, int y)
369 int x, width;
370 unsigned char *dst, *dst_end;
371 unsigned mask;
372 LCDFN(blockfunc_type) *bfunc;
374 /* direction flip */
375 if (x2 < x1)
377 x = x1;
378 x1 = x2;
379 x2 = x;
382 /* nothing to draw? */
383 if (((unsigned)y >= (unsigned)current_vp->height) || (x1 >= current_vp->width)
384 || (x2 < 0))
385 return;
387 /* clipping */
388 if (x1 < 0)
389 x1 = 0;
390 if (x2 >= current_vp->width)
391 x2 = current_vp->width-1;
393 width = x2 - x1 + 1;
395 /* adjust to viewport */
396 x1 += current_vp->x;
397 y += current_vp->y;
399 bfunc = LCDFN(blockfuncs)[current_vp->drawmode];
400 dst = &LCDFN(framebuffer)[y>>3][x1];
401 mask = 1 << (y & 7);
403 dst_end = dst + width;
405 bfunc(dst++, mask, 0xFFu);
406 while (dst < dst_end);
409 /* Draw a vertical line (optimised) */
410 void LCDFN(vline)(int x, int y1, int y2)
412 int ny;
413 FBFN(data) *dst;
414 unsigned mask, mask_bottom;
415 LCDFN(blockfunc_type) *bfunc;
417 /* direction flip */
418 if (y2 < y1)
420 ny = y1;
421 y1 = y2;
422 y2 = ny;
425 /* nothing to draw? */
426 if (((unsigned)x >= (unsigned)current_vp->width) || (y1 >= current_vp->height)
427 || (y2 < 0))
428 return;
430 /* clipping */
431 if (y1 < 0)
432 y1 = 0;
433 if (y2 >= current_vp->height)
434 y2 = current_vp->height-1;
436 /* adjust for viewport */
437 y1 += current_vp->y;
438 y2 += current_vp->y;
439 x += current_vp->x;
441 bfunc = LCDFN(blockfuncs)[current_vp->drawmode];
442 dst = &LCDFN(framebuffer)[y1>>3][x];
443 ny = y2 - (y1 & ~7);
444 mask = 0xFFu << (y1 & 7);
445 mask_bottom = 0xFFu >> (~ny & 7);
447 for (; ny >= 8; ny -= 8)
449 bfunc(dst, mask, 0xFFu);
450 dst += LCDM(WIDTH);
451 mask = 0xFFu;
453 mask &= mask_bottom;
454 bfunc(dst, mask, 0xFFu);
457 /* Draw a rectangular box */
458 void LCDFN(drawrect)(int x, int y, int width, int height)
460 if ((width <= 0) || (height <= 0))
461 return;
463 int x2 = x + width - 1;
464 int y2 = y + height - 1;
466 LCDFN(vline)(x, y, y2);
467 LCDFN(vline)(x2, y, y2);
468 LCDFN(hline)(x, x2, y);
469 LCDFN(hline)(x, x2, y2);
472 /* Fill a rectangular area */
473 void LCDFN(fillrect)(int x, int y, int width, int height)
475 int ny;
476 FBFN(data) *dst, *dst_end;
477 unsigned mask, mask_bottom;
478 unsigned bits = 0;
479 LCDFN(blockfunc_type) *bfunc;
480 bool fillopt = false;
482 /* nothing to draw? */
483 if ((width <= 0) || (height <= 0) || (x >= current_vp->width)
484 || (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0))
485 return;
487 /* clipping */
488 if (x < 0)
490 width += x;
491 x = 0;
493 if (y < 0)
495 height += y;
496 y = 0;
498 if (x + width > current_vp->width)
499 width = current_vp->width - x;
500 if (y + height > current_vp->height)
501 height = current_vp->height - y;
503 /* adjust for viewport */
504 x += current_vp->x;
505 y += current_vp->y;
507 if (current_vp->drawmode & DRMODE_INVERSEVID)
509 if (current_vp->drawmode & DRMODE_BG)
511 fillopt = true;
514 else
516 if (current_vp->drawmode & DRMODE_FG)
518 fillopt = true;
519 bits = 0xFFu;
522 bfunc = LCDFN(blockfuncs)[current_vp->drawmode];
523 dst = &LCDFN(framebuffer)[y>>3][x];
524 ny = height - 1 + (y & 7);
525 mask = 0xFFu << (y & 7);
526 mask_bottom = 0xFFu >> (~ny & 7);
528 for (; ny >= 8; ny -= 8)
530 if (fillopt && (mask == 0xFFu))
531 memset(dst, bits, width);
532 else
534 FBFN(data) *dst_row = dst;
536 dst_end = dst_row + width;
538 bfunc(dst_row++, mask, 0xFFu);
539 while (dst_row < dst_end);
542 dst += LCDM(WIDTH);
543 mask = 0xFFu;
545 mask &= mask_bottom;
547 if (fillopt && (mask == 0xFFu))
548 memset(dst, bits, width);
549 else
551 dst_end = dst + width;
553 bfunc(dst++, mask, 0xFFu);
554 while (dst < dst_end);
558 /* About Rockbox' internal bitmap format:
560 * A bitmap contains one bit for every pixel that defines if that pixel is
561 * black (1) or white (0). Bits within a byte are arranged vertically, LSB
562 * at top.
563 * The bytes are stored in row-major order, with byte 0 being top left,
564 * byte 1 2nd from left etc. The first row of bytes defines pixel rows
565 * 0..7, the second row defines pixel row 8..15 etc.
567 * This is the same as the internal lcd hw format. */
569 /* Draw a partial bitmap */
570 void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x,
571 int src_y, int stride, int x, int y,
572 int width, int height)
574 int shift, ny;
575 FBFN(data) *dst, *dst_end;
576 unsigned mask, mask_bottom;
577 LCDFN(blockfunc_type) *bfunc;
579 /* nothing to draw? */
580 if ((width <= 0) || (height <= 0) || (x >= current_vp->width)
581 || (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0))
582 return;
584 /* clipping */
585 if (x < 0)
587 width += x;
588 src_x -= x;
589 x = 0;
591 if (y < 0)
593 height += y;
594 src_y -= y;
595 y = 0;
597 if (x + width > current_vp->width)
598 width = current_vp->width - x;
599 if (y + height > current_vp->height)
600 height = current_vp->height - y;
602 /* adjust for viewport */
603 x += current_vp->x;
604 y += current_vp->y;
606 src += stride * (src_y >> 3) + src_x; /* move starting point */
607 src_y &= 7;
608 y -= src_y;
609 dst = &LCDFN(framebuffer)[y>>3][x];
610 shift = y & 7;
611 ny = height - 1 + shift + src_y;
613 bfunc = LCDFN(blockfuncs)[current_vp->drawmode];
614 mask = 0xFFu << (shift + src_y);
615 mask_bottom = 0xFFu >> (~ny & 7);
617 if (shift == 0)
619 bool copyopt = (current_vp->drawmode == DRMODE_SOLID);
621 for (; ny >= 8; ny -= 8)
623 if (copyopt && (mask == 0xFFu))
624 memcpy(dst, src, width);
625 else
627 const unsigned char *src_row = src;
628 FBFN(data) *dst_row = dst;
630 dst_end = dst_row + width;
632 bfunc(dst_row++, mask, *src_row++);
633 while (dst_row < dst_end);
636 src += stride;
637 dst += LCDM(WIDTH);
638 mask = 0xFFu;
640 mask &= mask_bottom;
642 if (copyopt && (mask == 0xFFu))
643 memcpy(dst, src, width);
644 else
646 dst_end = dst + width;
648 bfunc(dst++, mask, *src++);
649 while (dst < dst_end);
652 else
654 dst_end = dst + width;
657 const unsigned char *src_col = src++;
658 FBFN(data) *dst_col = dst++;
659 unsigned mask_col = mask;
660 unsigned data = 0;
662 for (y = ny; y >= 8; y -= 8)
664 data |= *src_col << shift;
666 if (mask_col & 0xFFu)
668 bfunc(dst_col, mask_col, data);
669 mask_col = 0xFFu;
671 else
672 mask_col >>= 8;
674 src_col += stride;
675 dst_col += LCDM(WIDTH);
676 data >>= 8;
678 data |= *src_col << shift;
679 bfunc(dst_col, mask_col & mask_bottom, data);
681 while (dst < dst_end);
685 /* Draw a full bitmap */
686 void LCDFN(bitmap)(const unsigned char *src, int x, int y, int width,
687 int height)
689 LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height);
692 /* put a string at a given pixel position, skipping first ofs pixel columns */
693 static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
695 unsigned short ch;
696 unsigned short *ucs;
697 struct font* pf = font_get(current_vp->font);
699 ucs = bidi_l2v(str, 1);
701 while ((ch = *ucs++) != 0 && x < current_vp->width)
703 int width;
704 const unsigned char *bits;
706 /* get proportional width and glyph bits */
707 width = font_get_width(pf, ch);
709 if (ofs > width)
711 ofs -= width;
712 continue;
715 bits = font_get_bits(pf, ch);
717 LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x, y, width - ofs,
718 pf->height);
720 x += width - ofs;
721 ofs = 0;
724 /* put a string at a given pixel position */
725 void LCDFN(putsxy)(int x, int y, const unsigned char *str)
727 LCDFN(putsxyofs)(x, y, 0, str);
730 /*** Line oriented text output ***/
732 /* put a string at a given char position */
733 void LCDFN(puts)(int x, int y, const unsigned char *str)
735 LCDFN(puts_style_offset)(x, y, str, STYLE_DEFAULT, 0);
738 void LCDFN(puts_style)(int x, int y, const unsigned char *str, int style)
740 LCDFN(puts_style_offset)(x, y, str, style, 0);
743 void LCDFN(puts_offset)(int x, int y, const unsigned char *str, int offset)
745 LCDFN(puts_style_offset)(x, y, str, STYLE_DEFAULT, offset);
748 /* put a string at a given char position, style, and pixel position,
749 * skipping first offset pixel columns */
750 void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str,
751 int style, int offset)
753 int xpos,ypos,w,h,xrect;
754 int lastmode = current_vp->drawmode;
756 /* make sure scrolling is turned off on the line we are updating */
757 LCDFN(scroll_stop_line)(current_vp, y);
759 if(!str || !str[0])
760 return;
762 LCDFN(getstringsize)(str, &w, &h);
763 xpos = current_vp->xmargin + x*w / utf8length(str);
764 ypos = current_vp->ymargin + y*h;
765 current_vp->drawmode = (style & STYLE_INVERT) ?
766 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
767 LCDFN(putsxyofs)(xpos, ypos, offset, str);
768 current_vp->drawmode ^= DRMODE_INVERSEVID;
769 xrect = xpos + MAX(w - offset, 0);
770 LCDFN(fillrect)(xrect, ypos, current_vp->width - xrect, h);
771 current_vp->drawmode = lastmode;
774 /*** scrolling ***/
776 void LCDFN(puts_scroll)(int x, int y, const unsigned char *string)
778 LCDFN(puts_scroll_style)(x, y, string, STYLE_DEFAULT);
781 void LCDFN(puts_scroll_style)(int x, int y, const unsigned char *string,
782 int style)
784 LCDFN(puts_scroll_style_offset)(x, y, string, style, 0);
787 void LCDFN(puts_scroll_offset)(int x, int y, const unsigned char *string,
788 int offset)
790 LCDFN(puts_scroll_style_offset)(x, y, string, STYLE_DEFAULT, offset);
793 void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
794 int style, int offset)
796 struct scrollinfo* s;
797 int w, h;
799 if ((unsigned)y >= (unsigned)current_vp->height)
800 return;
802 /* remove any previously scrolling line at the same location */
803 LCDFN(scroll_stop_line)(current_vp, y);
805 if (LCDFN(scroll_info.lines) >= LCDM(SCROLLABLE_LINES)) return;
807 s = &LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines];
809 s->start_tick = current_tick + LCDFN(scroll_info).delay;
810 s->style = style;
811 if (style & STYLE_INVERT) {
812 LCDFN(puts_style_offset)(x,y,string,STYLE_INVERT,offset);
814 else
815 LCDFN(puts_offset)(x,y,string,offset);
817 LCDFN(getstringsize)(string, &w, &h);
819 if (current_vp->width - x * 8 - current_vp->xmargin < w) {
820 /* prepare scroll line */
821 char *end;
823 memset(s->line, 0, sizeof s->line);
824 strcpy(s->line, string);
826 /* get width */
827 s->width = LCDFN(getstringsize)(s->line, &w, &h);
829 /* scroll bidirectional or forward only depending on the string
830 width */
831 if ( LCDFN(scroll_info).bidir_limit ) {
832 s->bidir = s->width < (current_vp->width - current_vp->xmargin) *
833 (100 + LCDFN(scroll_info).bidir_limit) / 100;
835 else
836 s->bidir = false;
838 if (!s->bidir) { /* add spaces if scrolling in the round */
839 strcat(s->line, " ");
840 /* get new width incl. spaces */
841 s->width = LCDFN(getstringsize)(s->line, &w, &h);
844 end = strchr(s->line, '\0');
845 strncpy(end, string, current_vp->width/2);
847 s->vp = current_vp;
848 s->y = y;
849 s->len = utf8length(string);
850 s->offset = offset;
851 s->startx = current_vp->xmargin + x * s->width / s->len;;
852 s->backward = false;
854 LCDFN(scroll_info).lines++;
858 void LCDFN(scroll_fn)(void)
860 struct font* pf;
861 struct scrollinfo* s;
862 int index;
863 int xpos, ypos;
864 int lastmode;
865 struct viewport* old_vp = current_vp;
867 for ( index = 0; index < LCDFN(scroll_info).lines; index++ ) {
868 s = &LCDFN(scroll_info).scroll[index];
870 /* check pause */
871 if (TIME_BEFORE(current_tick, s->start_tick))
872 continue;
874 LCDFN(set_viewport)(s->vp);
876 if (s->backward)
877 s->offset -= LCDFN(scroll_info).step;
878 else
879 s->offset += LCDFN(scroll_info).step;
881 pf = font_get(current_vp->font);
882 xpos = s->startx;
883 ypos = current_vp->ymargin + s->y * pf->height;
885 if (s->bidir) { /* scroll bidirectional */
886 if (s->offset <= 0) {
887 /* at beginning of line */
888 s->offset = 0;
889 s->backward = false;
890 s->start_tick = current_tick + LCDFN(scroll_info).delay * 2;
892 if (s->offset >= s->width - (current_vp->width - xpos)) {
893 /* at end of line */
894 s->offset = s->width - (current_vp->width - xpos);
895 s->backward = true;
896 s->start_tick = current_tick + LCDFN(scroll_info).delay * 2;
899 else {
900 /* scroll forward the whole time */
901 if (s->offset >= s->width)
902 s->offset %= s->width;
905 lastmode = current_vp->drawmode;
906 current_vp->drawmode = (s->style&STYLE_INVERT) ?
907 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
908 LCDFN(putsxyofs)(xpos, ypos, s->offset, s->line);
909 current_vp->drawmode = lastmode;
910 LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos, pf->height);
913 LCDFN(set_viewport)(old_vp);