add basic .Z support
[pcsx_rearmed.git] / frontend / arm_utils.s
CommitLineData
a327967e 1/*
2 * (C) Gražvydas "notaz" Ignotas, 2010
3 *
69af03a2 4 * This work is licensed under the terms of any of these licenses
5 * (at your option):
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
a327967e 8 * See the COPYING file in the top-level directory.
9 */
10
11.text
12.align 2
13
14.global bgr555_to_rgb565
15bgr555_to_rgb565:
d352cde2 16 mov r3, #0x07c0
a327967e 17 vdup.16 q15, r3
d352cde2 18 sub r2, r2, #64
a327967e 190:
20 vldmia r1!, {q0-q3}
d352cde2 21 vshl.u16 q4, q0, #11
22 vshl.u16 q5, q1, #11
23 vshl.u16 q6, q2, #11
24 vshl.u16 q7, q3, #11
25 vsri.u16 q4, q0, #10
26 vsri.u16 q5, q1, #10
27 vsri.u16 q6, q2, #10
28 vsri.u16 q7, q3, #10
a327967e 29 vshl.u16 q0, q0, #1
30 vshl.u16 q1, q1, #1
31 vshl.u16 q2, q2, #1
32 vshl.u16 q3, q3, #1
d352cde2 33 vbit q4, q0, q15
34 vbit q5, q1, q15
35 vbit q6, q2, q15
36 vbit q7, q3, q15
37 vstmia r0!, {q4-q7}
38 subs r2, r2, #64
39 bge 0b
40
41 adds r2, r2, #64
42 bxeq lr
43
44 @ handle the remainder
450:
46 vld1.16 {q0}, [r1, :64]!
47 vshl.u16 q1, q0, #11
48 vshl.u16 q2, q0, #1
49 vsri.u16 q1, q0, #10
50 vbit q1, q2, q15
51 subs r2, r2, #16
52 vst1.16 {q1}, [r0, :64]!
53 bgt 0b
a327967e 54
55 bx lr
56
1972732a 57
58.global bgr888_to_rgb888
59bgr888_to_rgb888:
60 @ r2 /= 48
61 mov r2, r2, lsr #4
62 movw r3, #0x5556
63 movt r3, #0x5555
64 umull r12,r2, r3, r2
650:
66 vld3.8 {d0-d2}, [r1, :64]!
67 vld3.8 {d3-d5}, [r1, :64]!
68 vswp d0, d2
69 vswp d3, d5
70 vst3.8 {d0-d2}, [r0, :64]!
71 vst3.8 {d3-d5}, [r0, :64]!
72 subs r2, r2, #1
73 bne 0b
74
75 bx lr
76
77
a327967e 78@ vim:filetype=armasm