diff options
Diffstat (limited to 'apps/plugins/lib/gray_scroll_down.c')
-rw-r--r-- | apps/plugins/lib/gray_scroll_down.c | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/apps/plugins/lib/gray_scroll_down.c b/apps/plugins/lib/gray_scroll_down.c new file mode 100644 index 0000000000..3766ce1f73 --- /dev/null +++ b/apps/plugins/lib/gray_scroll_down.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Grayscale framework | ||
11 | * gray_scroll_down() 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 down by <count> pixels (<= 7) | ||
34 | ---------------------------------------------------------------------------- | ||
35 | black_border determines if the pixels scrolled in at the top are black | ||
36 | or white | ||
37 | |||
38 | Scrolling up/down pixel-wise is significantly slower than scrolling | ||
39 | left/right or scrolling up/down byte-wise because it involves bit | ||
40 | shifting. That's why it is asm optimized. | ||
41 | */ | ||
42 | void gray_scroll_down(int count, bool black_border) | ||
43 | { | ||
44 | unsigned filler; | ||
45 | |||
46 | if ((unsigned) count > 7) | ||
47 | return; | ||
48 | |||
49 | filler = black_border ? (0xFFu << count) : 0; | ||
50 | |||
51 | /* scroll column by column to minimize flicker */ | ||
52 | asm volatile ( | ||
53 | "mov #0,r6 \n" /* x = 0 */ | ||
54 | "mova .sd_shifttbl,r0 \n" /* calculate jump destination for */ | ||
55 | "mov.b @(r0,%6),%6 \n" /* shift amount from table */ | ||
56 | "bra .sd_cloop \n" /* skip table */ | ||
57 | "add r0,%6 \n" | ||
58 | |||
59 | ".align 2 \n" | ||
60 | ".sd_shifttbl: \n" /* shift jump offset table */ | ||
61 | ".byte .sd_shift0 - .sd_shifttbl \n" | ||
62 | ".byte .sd_shift1 - .sd_shifttbl \n" | ||
63 | ".byte .sd_shift2 - .sd_shifttbl \n" | ||
64 | ".byte .sd_shift3 - .sd_shifttbl \n" | ||
65 | ".byte .sd_shift4 - .sd_shifttbl \n" | ||
66 | ".byte .sd_shift5 - .sd_shifttbl \n" | ||
67 | ".byte .sd_shift6 - .sd_shifttbl \n" | ||
68 | ".byte .sd_shift7 - .sd_shifttbl \n" | ||
69 | |||
70 | ".sd_cloop: \n" /* repeat for every column */ | ||
71 | "mov %1,r2 \n" /* get start address */ | ||
72 | "mov #0,r3 \n" /* current_plane = 0 */ | ||
73 | |||
74 | ".sd_oloop: \n" /* repeat for every bitplane */ | ||
75 | "mov r2,r4 \n" /* get start address */ | ||
76 | "mov #0,r5 \n" /* current_row = 0 */ | ||
77 | "mov %5,r1 \n" /* get filler bits */ | ||
78 | |||
79 | ".sd_iloop: \n" /* repeat for all rows */ | ||
80 | "shlr8 r1 \n" /* shift right to get residue */ | ||
81 | "mov.b @r4,r0 \n" /* get data byte */ | ||
82 | "jmp @%6 \n" /* jump into shift "path" */ | ||
83 | "extu.b r0,r0 \n" /* extend unsigned */ | ||
84 | |||
85 | ".sd_shift6: \n" /* shift left by 0..7 bits */ | ||
86 | "shll2 r0 \n" | ||
87 | ".sd_shift4: \n" | ||
88 | "shll2 r0 \n" | ||
89 | ".sd_shift2: \n" | ||
90 | "bra .sd_shift0 \n" | ||
91 | "shll2 r0 \n" | ||
92 | ".sd_shift7: \n" | ||
93 | "shll2 r0 \n" | ||
94 | ".sd_shift5: \n" | ||
95 | "shll2 r0 \n" | ||
96 | ".sd_shift3: \n" | ||
97 | "shll2 r0 \n" | ||
98 | ".sd_shift1: \n" | ||
99 | "shll r0 \n" | ||
100 | ".sd_shift0: \n" | ||
101 | |||
102 | "or r0,r1 \n" /* combine with last residue */ | ||
103 | "mov.b r1,@r4 \n" /* store data */ | ||
104 | "add %2,r4 \n" /* address += width */ | ||
105 | "add #1,r5 \n" /* current_row++ */ | ||
106 | "cmp/hi r5,%3 \n" /* current_row < bheight ? */ | ||
107 | "bt .sd_iloop \n" | ||
108 | |||
109 | "add %4,r2 \n" /* start_address += plane_size */ | ||
110 | "add #1,r3 \n" /* current_plane++ */ | ||
111 | "cmp/hi r3,%0 \n" /* current_plane < depth ? */ | ||
112 | "bt .sd_oloop \n" | ||
113 | |||
114 | "add #1,%1 \n" /* start_address++ */ | ||
115 | "add #1,r6 \n" /* x++ */ | ||
116 | "cmp/hi r6,%2 \n" /* x < width ? */ | ||
117 | "bt .sd_cloop \n" | ||
118 | : /* outputs */ | ||
119 | : /* inputs */ | ||
120 | /* %0 */ "r"(_graybuf->depth), | ||
121 | /* %1 */ "r"(_graybuf->data), | ||
122 | /* %2 */ "r"(_graybuf->width), | ||
123 | /* %3 */ "r"(_graybuf->bheight), | ||
124 | /* %4 */ "r"(_graybuf->plane_size), | ||
125 | /* %5 */ "r"(filler), | ||
126 | /* %6 */ "r"(count) | ||
127 | : /* clobbers */ | ||
128 | "r0", "r1", "r2", "r3", "r4", "r5", "r6" | ||
129 | ); | ||
130 | } | ||
131 | |||
132 | #endif // #ifdef HAVE_LCD_BITMAP | ||
133 | #endif // #ifndef SIMULATOR | ||
134 | |||