fix red.
[kugel-rb.git] / apps / plugins / lib / grey_sh.S
blob5bc003c2b3d9251be806905a2c703bc08d06fa62
1 /***************************************************************************
2 *             __________               __   ___.
3 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7 *                     \/            \/     \/    \/            \/
8 * $Id$
10 * New greyscale framework
11 * SH1 assembler routines
13 * This is a generic framework to display 129 shades of grey on low-depth
14 * bitmap LCDs (Archos b&w, Iriver & Ipod 4-grey) within plugins.
16 * Copyright (C) 2008 Jens Arnold
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
23 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
24 * KIND, either express or implied.
26 ****************************************************************************/
28 #include "config.h"
29 /* Plugins should not normally do this, but we need to check a macro, and
30  * plugin.h would confuse the assembler. */
32     .text
33     .global     __grey_line1
34     .type       __grey_line1, @function
35     
36 #if (LCD_PIXELFORMAT == VERTICAL_PACKING) && (LCD_DEPTH == 1)
37     
38 /****************************************************************************
39  * void _grey_line1(int width,                        r4
40  *                  unsigned char *dst,               r5
41  *                  const unsigned char *src,         r6
42  *                  const unsigned char *lut);        r7
43  */
45 __grey_line1:
46     mov     #1, r0
47     tst     r0, r6
48     bt      .p1_h_end
49     
50     mov.b   @r6+, r0
51     extu.b  r0, r0
52     mov.b   @(r0, r7), r0
53     add     #-1, r4
54     mov.b   r0, @r5
55     add     #8, r5
56 .p1_h_end:
58     mov     #2, r0
59     cmp/hs  r0, r4
60     bf      .p2_t_end
61     tst     r0, r6
62     bt      .p2_h_end
63     
64     mov.w   @r6+, r1
65     extu.b  r1, r0
66     mov.b   @(r0, r7), r0
67     shlr8   r1
68     mov.b   r0, @(8, r5)
69     extu.b  r1, r0
70     mov.b   @(r0, r7), r0
71     add     #-2, r4
72     mov.b   r0, @r5
73     add     #16, r5
74 .p2_h_end:
76     add     #-4, r4
77     cmp/pz  r4
78     bf      .p4_end
80     add     r6, r4
82 .p4_loop:
83     mov.l   @r6+, r1
84     swap.w  r1, r2
85     extu.b  r2, r0
86     mov.b   @(r0, r7), r0
87     shlr8   r2
88     mov.b   r0, @(8, r5)
89     extu.b  r2, r0
90     mov.b   @(r0, r7), r2
91     extu.b  r1, r0
92     mov.b   r2, @r5
93     add     #16, r5
94     mov.b   @(r0, r7), r0
95     shlr8   r1
96     mov.b   r0, @(8, r5)
97     extu.b  r1, r0
98     mov.b   @(r0, r7), r0
99     cmp/hs  r6, r4
100     mov.b   r0, @r5
101     add     #16, r5
102     bt      .p4_loop
103     
104     /* No need to correct the count, we're only testing bits from now on. */
105     
106 .p4_end:
107     mov     #2, r0
108     tst     r0, r4
109     bt      .p2_t_end
110     
111     mov.w   @r6+, r1
112     extu.b  r1, r0
113     mov.b   @(r0, r7), r0
114     shlr8   r1
115     mov.b   r0, @(8, r5)
116     extu.b  r1, r0
117     mov.b   @(r0, r7), r0
118     mov.b   r0, @r5
119     add     #16, r5
120 .p2_t_end:
122     mov     #1, r0
123     tst     r0, r4
124     bt      .p1_t_end
126     mov.b   @r6+, r0
127     extu.b  r0, r0
128     mov.b   @(r0, r7), r0
129     rts
130     mov.b   r0, @r5
131 .p1_t_end:
133     rts
134     nop
135     .size   _grey_line1, . - _grey_line1
137 #endif