added files to rel
[picodrive.git] / platform / gp2x / asmutils.s
... / ...
CommitLineData
1@ vim:filetype=armasm\r
2@ some color conversion and blitting routines\r
3\r
4@ (c) Copyright 2006, notaz\r
5@ All Rights Reserved\r
6\r
7@ vim:filetype=armasm\r
8\r
9@ Convert 0000bbb0 ggg0rrr0 0000bbb0 ggg0rrr0\r
10@ to 00000000 rrr00000 ggg00000 bbb00000 ...\r
11\r
12@ lr = 0x00e000e0, out: r3=lower_pix, r2=higher_pix; trashes rin\r
13@ if sh==2, r8=0x00404040 (sh!=0 destroys flags!)\r
14.macro convRGB32_2 rin sh=0\r
15 and r2, lr, \rin, lsr #4 @ blue\r
16 and r3, \rin, lr\r
17 orr r2, r2, r3, lsl #8 @ g0b0g0b0\r
18\r
19 mov r3, r2, lsl #16 @ g0b00000\r
20 and \rin,lr, \rin, ror #12 @ 00r000r0 (reversed)\r
21 orr r3, r3, \rin, lsr #16 @ g0b000r0\r
22.if \sh == 1\r
23 mov r3, r3, ror #17 @ shadow mode\r
24.elseif \sh == 2\r
25 adds r3, r3, #0x40000000 @ green\r
26 orrcs r3, r3, #0xe0000000\r
27 mov r3, r3, ror #8\r
28 adds r3, r3, #0x40000000\r
29 orrcs r3, r3, #0xe0000000\r
30 mov r3, r3, ror #16\r
31 adds r3, r3, #0x40000000\r
32 orrcs r3, r3, #0xe0000000\r
33 mov r3, r3, ror #24\r
34.else\r
35 mov r3, r3, ror #16 @ r3=low\r
36.endif\r
37\r
38 orr r3, r3, r3, lsr #3\r
39 str r3, [r0], #4\r
40\r
41 mov r2, r2, lsr #16\r
42 orr r2, r2, \rin, lsl #16\r
43.if \sh == 1\r
44 mov r2, r2, lsr #1\r
45.elseif \sh == 2\r
46 mov r2, r2, ror #8\r
47 adds r2, r2, #0x40000000 @ blue\r
48 orrcs r2, r2, #0xe0000000\r
49 mov r2, r2, ror #8\r
50 adds r2, r2, #0x40000000\r
51 orrcs r2, r2, #0xe0000000\r
52 mov r2, r2, ror #8\r
53 adds r2, r2, #0x40000000\r
54 orrcs r2, r2, #0xe0000000\r
55 mov r2, r2, ror #8\r
56.endif\r
57\r
58 orr r2, r2, r2, lsr #3\r
59 str r2, [r0], #4\r
60.endm\r
61\r
62\r
63.global vidConvCpyRGB32 @ void *to, void *from, int pixels\r
64\r
65vidConvCpyRGB32:\r
66 stmfd sp!, {r4-r7,lr}\r
67\r
68 mov r12, r2, lsr #3 @ repeats\r
69 mov lr, #0x00e00000\r
70 orr lr, lr, #0x00e0\r
71\r
72.loopRGB32:\r
73 subs r12, r12, #1\r
74\r
75 ldmia r1!, {r4-r7}\r
76 convRGB32_2 r4\r
77 convRGB32_2 r5\r
78 convRGB32_2 r6\r
79 convRGB32_2 r7\r
80\r
81 bgt .loopRGB32\r
82\r
83 ldmfd sp!, {r4-r7,lr}\r
84 bx lr\r
85\r
86\r
87.global vidConvCpyRGB32sh @ void *to, void *from, int pixels\r
88\r
89vidConvCpyRGB32sh:\r
90 stmfd sp!, {r4-r7,lr}\r
91\r
92 mov r12, r2, lsr #3 @ repeats\r
93 mov lr, #0x00e00000\r
94 orr lr, lr, #0x00e0\r
95\r
96.loopRGB32sh:\r
97 subs r12, r12, #1\r
98\r
99 ldmia r1!, {r4-r7}\r
100 convRGB32_2 r4, 1\r
101 convRGB32_2 r5, 1\r
102 convRGB32_2 r6, 1\r
103 convRGB32_2 r7, 1\r
104\r
105 bgt .loopRGB32sh\r
106\r
107 ldmfd sp!, {r4-r7,lr}\r
108 bx lr\r
109\r
110\r
111.global vidConvCpyRGB32hi @ void *to, void *from, int pixels\r
112\r
113vidConvCpyRGB32hi:\r
114 stmfd sp!, {r4-r7,lr}\r
115\r
116 mov r12, r2, lsr #3 @ repeats\r
117 mov lr, #0x00e00000\r
118 orr lr, lr, #0x00e0\r
119\r
120.loopRGB32hi:\r
121 ldmia r1!, {r4-r7}\r
122 convRGB32_2 r4, 2\r
123 convRGB32_2 r5, 2\r
124 convRGB32_2 r6, 2\r
125 convRGB32_2 r7, 2\r
126\r
127 subs r12, r12, #1\r
128 bgt .loopRGB32hi\r
129\r
130 ldmfd sp!, {r4-r7,lr}\r
131 bx lr\r
132\r
133\r
134@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
135\r
136\r
137@ mode2 blitter for 40 cols\r
138.global vidCpyM2_40col @ void *dest, void *src\r
139\r
140vidCpyM2_40col:\r
141 stmfd sp!, {r4-r6,lr}\r
142\r
143 mov r12, #224 @ lines\r
144 add r1, r1, #8\r
145\r
146vidCpyM2_40_loop_out:\r
147 mov r6, #10\r
148vidCpyM2_40_loop:\r
149 subs r6, r6, #1\r
150 ldmia r1!, {r2-r5}\r
151 stmia r0!, {r2-r5}\r
152 ldmia r1!, {r2-r5}\r
153 stmia r0!, {r2-r5}\r
154 bne vidCpyM2_40_loop\r
155 subs r12,r12,#1\r
156 add r1, r1, #8\r
157 bne vidCpyM2_40_loop_out\r
158\r
159 ldmfd sp!, {r4-r6,lr}\r
160 bx lr\r
161\r
162\r
163@ mode2 blitter for 32 cols\r
164.global vidCpyM2_32col @ void *dest, void *src\r
165\r
166vidCpyM2_32col:\r
167 stmfd sp!, {r4-r6,lr}\r
168\r
169 mov r12, #224 @ lines\r
170 add r1, r1, #8\r
171 add r0, r0, #32\r
172\r
173vidCpyM2_32_loop_out:\r
174 mov r6, #8\r
175vidCpyM2_32_loop:\r
176 subs r6, r6, #1\r
177 ldmia r1!, {r2-r5}\r
178 stmia r0!, {r2-r5}\r
179 ldmia r1!, {r2-r5}\r
180 stmia r0!, {r2-r5}\r
181 bne vidCpyM2_32_loop\r
182 subs r12,r12,#1\r
183 add r0, r0, #64\r
184 add r1, r1, #8+64\r
185 bne vidCpyM2_32_loop_out\r
186\r
187 ldmfd sp!, {r4-r6,lr}\r
188 bx lr\r
189\r
190\r
191@ mode2 blitter for 32 cols with no borders\r
192.global vidCpyM2_32col_nobord @ void *dest, void *src\r
193\r
194vidCpyM2_32col_nobord:\r
195 stmfd sp!, {r4-r6,lr}\r
196\r
197 mov r12, #224 @ lines\r
198 add r1, r1, #8\r
199 b vidCpyM2_32_loop_out\r
200\r
201\r
202.global spend_cycles @ c\r
203\r
204spend_cycles:\r
205 mov r0, r0, lsr #2 @ 4 cycles/iteration\r
206 sub r0, r0, #2 @ entry/exit/init\r
207.sc_loop:\r
208 subs r0, r0, #1\r
209 bpl .sc_loop\r
210\r
211 bx lr\r
212\r
213\r
214@ test\r
215.global flushcache\r
216\r
217flushcache:\r
218 swi #0x9f0002\r
219 mov pc, lr\r
220\r