summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/grey_sh.S
blob: f77d5b24cd4bcbcbe3f518dd27a87ff3829532d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/***************************************************************************
*             __________               __   ___.
*   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
*   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
*   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
*   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
*                     \/            \/     \/    \/            \/
* $Id$
*
* New greyscale framework
* SH1 assembler routines
*
* This is a generic framework to display 129 shades of grey on low-depth
* bitmap LCDs (Archos b&w, Iriver & Ipod 4-grey) within plugins.
*
* Copyright (C) 2008 Jens Arnold
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/

#include "config.h"
/* Plugins should not normally do this, but we need to check a macro, and
 * plugin.h would confuse the assembler. */
 
    .text
    .global     __grey_line1
    .type       __grey_line1, @function
    
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) && (LCD_DEPTH == 1)
    
/****************************************************************************
 * void _grey_line1(int width,                        r4
 *                  unsigned char *dst,               r5
 *                  const unsigned char *src,         r6
 *                  const unsigned char *lut);        r7
 */

__grey_line1:
    mov     #1, r0
    tst     r0, r6
    bt      .p1_h_end
    
    mov.b   @r6+, r0
    extu.b  r0, r0
    mov.b   @(r0, r7), r0
    add     #-1, r4
    mov.b   r0, @r5
    add     #8, r5
.p1_h_end:

    mov     #2, r0
    cmp/hs  r0, r4
    bf      .p2_t_end
    tst     r0, r6
    bt      .p2_h_end
    
    mov.w   @r6+, r1
    extu.b  r1, r0
    mov.b   @(r0, r7), r0
    shlr8   r1
    mov.b   r0, @(8, r5)
    extu.b  r1, r0
    mov.b   @(r0, r7), r0
    add     #-2, r4
    mov.b   r0, @r5
    add     #16, r5
.p2_h_end:

    add     #-4, r4
    cmp/pz  r4
    bf      .p4_end

    add     r6, r4

.p4_loop:
    mov.l   @r6+, r1
    swap.w  r1, r2
    extu.b  r2, r0
    mov.b   @(r0, r7), r0
    shlr8   r2
    mov.b   r0, @(8, r5)
    extu.b  r2, r0
    mov.b   @(r0, r7), r2
    extu.b  r1, r0
    mov.b   r2, @r5
    add     #16, r5
    mov.b   @(r0, r7), r0
    shlr8   r1
    mov.b   r0, @(8, r5)
    extu.b  r1, r0
    mov.b   @(r0, r7), r0
    cmp/hs  r6, r4
    mov.b   r0, @r5
    add     #16, r5
    bt      .p4_loop
    
    /* No need to correct the count, we're only testing bits from now on. */
    
.p4_end:
    mov     #2, r0
    tst     r0, r4
    bt      .p2_t_end
    
    mov.w   @r6+, r1
    extu.b  r1, r0
    mov.b   @(r0, r7), r0
    shlr8   r1
    mov.b   r0, @(8, r5)
    extu.b  r1, r0
    mov.b   @(r0, r7), r0
    mov.b   r0, @r5
    add     #16, r5
.p2_t_end:

    mov     #1, r0
    tst     r0, r4
    bt      .p1_t_end

    mov.b   @r6+, r0
    extu.b  r0, r0
    mov.b   @(r0, r7), r0
    rts
    mov.b   r0, @r5
.p1_t_end:

    rts
    nop
    .size   _grey_line1, . - _grey_line1

#endif