aboutsummaryrefslogtreecommitdiff
path: root/graphics/scaler/scale2xARM.s
blob: a56e78447fbac864dcde4a9a2d6f46b5bdd99f99 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@ ScummVM - Graphic Adventure Engine
@
@ ScummVM is the legal property of its developers, whose names
@ are too numerous to list here. Please refer to the COPYRIGHT
@ file distributed with this source distribution.
@
@ This program is free software@ you can redistribute it and/or
@ modify it under the terms of the GNU General Public License
@ as published by the Free Software Foundation@ either version 2
@ of the License, or (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY@ without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program@ if not, write to the Free Software
@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@
@ @author Robin Watts (robin@wss.co.uk)

        .text

        .global scale2x_8_arm
        .global scale2x_16_arm
        .global scale2x_32_arm

        @ r0 = dst0
        @ r1 = dst1
        @ r2 = src
        @ r3 = src_prev
        @ r4 = src_next
        @ r5 = len


        @ We hold:       r10            B
        @            r8  r14 r7       D E F
        @                r12            H
        .align 2
scale2x_8_arm:
        STMFD   r13!,{r4-r5,r7-r8,r10-r11,r14}
        LDR     r4, [r13,#4*7]
        LDR     r5, [r13,#4*8]

        LDRB    r14,[r2], #1
        CMP     r3, #0          @ Set NE
        @ Stall on Xscale
        MOV     r8, r14
        B       loop8
same8:
        STRB    r14,[r0], #1
        STRB    r14,[r0], #1
        STRB    r14,[r1], #1
        STRB    r14,[r1], #1
        SUBS    r5, r5, #1
        MOV     r8, r14
        MOV     r14,r7
        BLT     end8
loop8:
        LDRNEB  r7, [r3], #1    @ As long as we aren't on the last pixel
        LDRB    r10,[r2], #1
        LDRB    r12,[r4], #1
        @ Stall on Xscale
        CMP     r7, r8
        CMPNE   r10,r12
        BEQ     same8
        CMP     r8, r10
        STREQB  r8, [r0], #1
        STRNEB  r14,[r0], #1
        CMP     r10,r7
        STREQB  r7, [r0], #1
        STRNEB  r14,[r0], #1
        CMP     r8, r12
        STREQB  r8, [r1], #1
        STRNEB  r14,[r1], #1
        CMP     r12,r7
        STREQB  r7, [r1], #1
        STRNEB  r14,[r1], #1

        SUBS    r5, r5, #1
        MOV     r8, r14
        MOV     r14,r7
        BGE     loop8
end8:

        LDMFD   r13!,{r4-r5,r7-r8,r10-r11,PC}

        .align 2
scale2x_16_arm:
        STMFD   r13!,{r4-r5,r7-r8,r10-r11,r14}
        LDR     r4, [r13,#4*7]
        LDR     r5, [r13,#4*8]

        LDRH    r14,[r3], #2
        CMP     r3, #0          @ Set NE
        @ Stall on Xscale
        MOV     r8, r14
        B       loop16
same16:
        STRH    r14,[r0], #2
        STRH    r14,[r0], #2
        STRH    r14,[r1], #2
        STRH    r14,[r1], #2
        SUBS    r5, r5, #1
        MOV     r8, r14
        MOV     r14,r7
        BLT     end16
loop16:
        LDRNEH  r7, [r3], #2    @ As long as we aren't on the last pixel
        LDRH    r10,[r2], #2
        LDRH    r12,[r4], #2
        @ Stall on Xscale
        CMP     r7, r8
        CMPNE   r10,r12
        BEQ     same16
        CMP     r8, r10
        STREQH  r8, [r0], #2
        STRNEH  r14,[r0], #2
        CMP     r10,r7
        STREQH  r7, [r0], #2
        STRNEH  r14,[r0], #2
        CMP     r8, r12
        STREQH  r8, [r1], #2
        STRNEH  r14,[r1], #2
        CMP     r12,r7
        STREQH  r7, [r1], #2
        STRNEH  r14,[r1], #2

        SUBS    r5, r5, #1
        MOV     r8, r14
        MOV     r14,r7
        BGE     loop16
end16:

        LDMFD   r13!,{r4-r5,r7-r8,r10-r11,PC}

        .align 2
scale2x_32_arm:
        STMFD   r13!,{r4-r5,r7-r8,r10-r11,r14}
        LDR     r4, [r13,#4*7]
        LDR     r5, [r13,#4*8]

        LDR     r14,[r3], #4
        CMP     r3, #0          @ Set NE
        @ Stall on Xscale
        MOV     r8, r14
        B       loop32
same32:
        STR     r14,[r0], #4
        STR     r14,[r0], #4
        STR     r14,[r1], #4
        STR     r14,[r1], #4
        SUBS    r5, r5, #1
        MOV     r8, r14
        MOV     r14,r7
        BLT     end32
loop32:
        LDRNE   r7, [r3], #4    @ As long as we aren't on the last pixel
        LDR     r10,[r2], #4
        LDR     r12,[r4], #4
        @ Stall on Xscale
        CMP     r7, r8
        CMPNE   r10,r12
        BEQ     same32
        CMP     r8, r10
        STREQ   r8, [r0], #4
        STRNE   r14,[r0], #4
        CMP     r10,r7
        STREQ   r7, [r0], #4
        STRNE   r14,[r0], #4
        CMP     r8, r12
        STREQ   r8, [r1], #4
        STRNE   r14,[r1], #4
        CMP     r12,r7
        STREQ   r7, [r1], #4
        STRNE   r14,[r1], #4

        SUBS    r5, r5, #1
        MOV     r8, r14
        MOV     r14,r7
        BGE     loop32
end32:

        LDMFD   r13!,{r4-r5,r7-r8,r10-r11,PC}