diff options
Diffstat (limited to 'apps/plugins/lib/gray_scroll_left.c')
-rw-r--r-- | apps/plugins/lib/gray_scroll_left.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/apps/plugins/lib/gray_scroll_left.c b/apps/plugins/lib/gray_scroll_left.c new file mode 100644 index 0000000000..22bcc03629 --- /dev/null +++ b/apps/plugins/lib/gray_scroll_left.c | |||
@@ -0,0 +1,100 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Grayscale framework | ||
11 | * gray_scroll_left() function | ||
12 | * | ||
13 | * This is a generic framework to use grayscale display within Rockbox | ||
14 | * plugins. It obviously does not work for the player. | ||
15 | * | ||
16 | * Copyright (C) 2004 Jens Arnold | ||
17 | * | ||
18 | * All files in this archive are subject to the GNU General Public License. | ||
19 | * See the file COPYING in the source tree root for full license agreement. | ||
20 | * | ||
21 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
22 | * KIND, either express or implied. | ||
23 | * | ||
24 | ****************************************************************************/ | ||
25 | |||
26 | #ifndef SIMULATOR /* not for simulator by now */ | ||
27 | #include "plugin.h" | ||
28 | |||
29 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | ||
30 | #include "gray.h" | ||
31 | |||
32 | /*--------------------------------------------------------------------------- | ||
33 | Scroll the whole grayscale buffer left by <count> pixels | ||
34 | ---------------------------------------------------------------------------- | ||
35 | black_border determines if the pixels scrolled in at the right are black | ||
36 | or white | ||
37 | |||
38 | Scrolling left/right by an even pixel count is almost twice as fast as | ||
39 | scrolling by an odd pixel count. | ||
40 | */ | ||
41 | void gray_scroll_left(int count, bool black_border) | ||
42 | { | ||
43 | int by, d; | ||
44 | unsigned filler; | ||
45 | unsigned char *ptr; | ||
46 | |||
47 | if ((unsigned) count >= (unsigned) _graybuf->width) | ||
48 | return; | ||
49 | |||
50 | filler = black_border ? 0xFF : 0; | ||
51 | |||
52 | /* Scroll row by row to minimize flicker (byte rows = 8 pixels each) */ | ||
53 | for (by = 0; by < _graybuf->bheight; by++) | ||
54 | { | ||
55 | ptr = _graybuf->data + MULU16(_graybuf->width, by); | ||
56 | for (d = 0; d < _graybuf->depth; d++) | ||
57 | { | ||
58 | asm volatile ( | ||
59 | "mov %0,r1 \n" /* check if both source... */ | ||
60 | "or %2,r1 \n" /* ...and offset are even */ | ||
61 | "shlr r1 \n" /* -> lsb = 0 */ | ||
62 | "bf .sl_start2 \n" /* -> copy word-wise */ | ||
63 | |||
64 | "add #-1,%2 \n" /* copy byte-wise */ | ||
65 | ".sl_loop1: \n" | ||
66 | "mov.b @%0+,r1 \n" | ||
67 | "mov.b r1,@(%2,%0) \n" | ||
68 | "cmp/hi %0,%1 \n" | ||
69 | "bt .sl_loop1 \n" | ||
70 | |||
71 | "bra .sl_end \n" | ||
72 | "nop \n" | ||
73 | |||
74 | ".sl_start2: \n" /* copy word-wise */ | ||
75 | "add #-2,%2 \n" | ||
76 | ".sl_loop2: \n" | ||
77 | "mov.w @%0+,r1 \n" | ||
78 | "mov.w r1,@(%2,%0) \n" | ||
79 | "cmp/hi %0,%1 \n" | ||
80 | "bt .sl_loop2 \n" | ||
81 | |||
82 | ".sl_end: \n" | ||
83 | : /* outputs */ | ||
84 | : /* inputs */ | ||
85 | /* %0 */ "r"(ptr + count), | ||
86 | /* %1 */ "r"(ptr + _graybuf->width), | ||
87 | /* %2 */ "z"(-count) | ||
88 | : /* clobbers */ | ||
89 | "r1" | ||
90 | ); | ||
91 | |||
92 | _gray_rb->memset(ptr + _graybuf->width - count, filler, count); | ||
93 | ptr += _graybuf->plane_size; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | #endif // #ifdef HAVE_LCD_BITMAP | ||
99 | #endif // #ifndef SIMULATOR | ||
100 | |||