2 * some color conversion and blitting routines
\r
3 * (C) notaz, 2006-2009
\r
5 * This work is licensed under the terms of MAME license.
\r
6 * See COPYING file in the top-level directory.
\r
12 @ Convert 0000bbb0 ggg0rrr0 0000bbb0 ggg0rrr0
\r
13 @ to 00000000 rrr00000 ggg00000 bbb00000 ...
\r
15 @ lr = 0x00e000e0, out: r3=lower_pix, r2=higher_pix; trashes rin
\r
16 .macro convRGB32_2 rin sh=0
\r
17 and r2, lr, \rin, lsr #4 @ blue
\r
19 orr r2, r2, r3, lsl #8 @ g0b0g0b0
\r
21 mov r3, r2, lsl #16 @ g0b00000
\r
22 and \rin,lr, \rin, ror #12 @ 00r000r0 (reversed)
\r
23 orr r3, r3, \rin, lsr #16 @ g0b000r0
\r
25 mov r3, r3, ror #17 @ shadow mode
\r
27 adds r3, r3, #0x40000000 @ green
\r
28 orrcs r3, r3, #0xe0000000
\r
30 adds r3, r3, #0x40000000
\r
31 orrcs r3, r3, #0xe0000000
\r
33 adds r3, r3, #0x40000000
\r
34 orrcs r3, r3, #0xe0000000
\r
37 mov r3, r3, ror #16 @ r3=low
\r
40 orr r3, r3, r3, lsr #3
\r
44 orr r2, r2, \rin, lsl #16
\r
49 adds r2, r2, #0x40000000 @ blue
\r
50 orrcs r2, r2, #0xe0000000
\r
52 adds r2, r2, #0x40000000
\r
53 orrcs r2, r2, #0xe0000000
\r
55 adds r2, r2, #0x40000000
\r
56 orrcs r2, r2, #0xe0000000
\r
60 orr r2, r2, r2, lsr #3
\r
62 str r2, [r0, #0x40*2*4]
\r
68 .global bgr444_to_rgb32 @ void *to, void *from
\r
71 stmfd sp!, {r4-r7,lr}
\r
73 mov r12, #0x40>>3 @ repeats
\r
87 ldmfd sp!, {r4-r7,pc}
\r
90 .global bgr444_to_rgb32_sh @ void *to, void *from
\r
93 stmfd sp!, {r4-r7,lr}
\r
95 mov r12, #0x40>>3 @ repeats
\r
110 mov r12, #0x40>>3 @ repeats
\r
111 sub r1, r1, #0x40*2
\r
123 ldmfd sp!, {r4-r7,lr}
\r
127 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
131 .global vidcpy_m2 @ void *dest, void *src, int m32col, int with_32c_border
\r
133 stmfd sp!, {r4-r6,lr}
\r
135 mov r12, #224 @ lines
\r
147 sub r6, r6, lr, lsr #5 @ -= 2 in 32col mode
\r
160 bne vidCpyM2_loop_out
\r
162 ldmfd sp!, {r4-r6,pc}
\r
165 .global vidcpy_m2_rot @ void *dest, void *src, int m32col, int with_32c_border
\r
167 stmfd sp!,{r4-r8,lr}
\r
170 subne r1, r1, #32 @ adjust
\r
177 vidcpy_m2_rot_loop:
\r
178 @ a bit lame but oh well..
\r
184 adr lr, after_rot_blit8
\r
185 stmfd sp!,{r4-r8,lr}
\r
192 ldmgefd sp!,{r4-r8,pc}
\r
193 b vidcpy_m2_rot_loop
\r
196 .global rotated_blit8 @ void *dst, void *linesx4, u32 y, int is_32col
\r
198 stmfd sp!,{r4-r8,lr}
\r
202 add r0, r0, #(240*320)
\r
203 sub r0, r0, #(240+4) @ y starts from 4
\r
207 subne r0, r0, #(240*32)
\r
212 rotated_blit_loop8:
\r
219 mov r6, r2, lsl #24
\r
221 orr r6, r6, r3, lsl #24
\r
223 orr r6, r6, r4, lsl #24
\r
225 orr r6, r6, r5, lsl #24
\r
226 str r6, [r0], #-240
\r
228 and r6, r3, #0xff00
\r
229 and r7, r2, #0xff00
\r
230 orr r6, r6, r7, lsr #8
\r
231 and r7, r4, #0xff00
\r
232 orr r6, r6, r7, lsl #8
\r
233 and r7, r5, #0xff00
\r
234 orr r6, r6, r7, lsl #16
\r
235 str r6, [r0], #-240
\r
237 and r6, r4, #0xff0000
\r
238 and r7, r2, #0xff0000
\r
239 orr r6, r6, r7, lsr #16
\r
240 and r7, r3, #0xff0000
\r
241 orr r6, r6, r7, lsr #8
\r
242 and r7, r5, #0xff0000
\r
243 orr r6, r6, r7, lsl #8
\r
244 str r6, [r0], #-240
\r
246 mov r6, r5, lsr #24
\r
248 orr r6, r6, r4, lsr #24
\r
250 orr r6, r6, r3, lsr #24
\r
252 orr r6, r6, r2, lsr #24
\r
253 str r6, [r0], #-240
\r
257 bne rotated_blit_loop8
\r
259 ldmfd sp!,{r4-r8,pc}
\r
266 mov r6, r2, lsl #16
\r
267 mov r7, r3, lsl #16
\r
268 orr r7, r7, r6, lsr #16
\r
269 mov r6, r4, lsl #16
\r
270 mov r8, r5, lsl #16
\r
271 orr r8, r8, r6, lsr #16
\r
275 mov r6, r2, lsr #16
\r
276 mov r7, r3, lsr #16
\r
277 orr r7, r6, r7, lsl #16
\r
278 mov r6, r4, lsr #16
\r
279 mov r8, r5, lsr #16
\r
280 orr r8, r6, r8, lsl #16
\r
283 .global rotated_blit16 @ void *dst, void *linesx4, u32 y, int is_32col
\r
285 stmfd sp!,{r4-r8,lr}
\r
287 add r0, r0, #(240*320)*2
\r
288 sub r0, r0, #(240+4)*2 @ y starts from 4
\r
289 add r0, r0, r2, lsl #1
\r
292 subne r0, r0, #(240*32)*2
\r
293 addne r1, r1, #32*2
\r
297 rotated_blit_loop16:
\r
298 ldr r2, [r1, #320*0*2]
\r
299 ldr r3, [r1, #320*1*2]
\r
300 ldr r4, [r1, #320*2*2]
\r
301 ldr r5, [r1, #320*3*2]
\r
309 ldr r2, [r1, #320*0*2+4]
\r
310 ldr r3, [r1, #320*1*2+4]
\r
311 ldr r4, [r1, #320*2*2+4]
\r
312 ldr r5, [r1, #320*3*2+4]
\r
322 bne rotated_blit_loop16
\r
324 ldmfd sp!,{r4-r8,pc}
\r
327 .global spend_cycles @ c
\r
330 mov r0, r0, lsr #2 @ 4 cycles/iteration
\r
331 sub r0, r0, #2 @ entry/exit/init
\r
338 @ vim:filetype=armasm
\r