d57557c0 |
1 | /* |
2 | * (C) GraÅžvydas "notaz" Ignotas, 2013 |
3 | * |
4 | * This work is licensed under the terms of GNU GPL version 2 or later. |
5 | * See the COPYING file in the top-level directory. |
6 | */ |
7 | |
8 | #include "arm_features.h" |
9 | |
10 | .text |
11 | .align 2 |
12 | |
13 | @ lr=0x001f001f |
14 | @ trashes r11, r12 |
15 | .macro bgr555_to_rgb565_one rn |
16 | and r11, lr, \rn |
17 | and r12, lr, \rn, lsr #5 |
18 | and \rn, lr, \rn, lsr #10 |
19 | orr r12, r11, lsl #5 |
20 | orr \rn, r12, lsl #6 |
21 | .endm |
22 | |
23 | .macro pld_ reg offs=#0 |
24 | #ifdef HAVE_ARMV6 |
25 | pld [\reg, \offs] |
26 | #endif |
27 | .endm |
28 | |
5c6457c3 |
29 | FUNCTION(bgr555_to_rgb565): @ void *dst, const void *src, int bytes |
d57557c0 |
30 | pld_ r1 |
31 | push {r4-r11,lr} |
32 | mov lr, #0x001f |
33 | subs r2, #4*8 |
34 | orr lr, lr, lsl #16 |
35 | blt 1f |
36 | |
37 | 0: |
38 | ldmia r1!, {r3-r10} |
39 | subs r2, #4*8 |
40 | bgr555_to_rgb565_one r3 |
41 | |
42 | pld_ r1, #32*2 |
43 | bgr555_to_rgb565_one r4 |
44 | bgr555_to_rgb565_one r5 |
45 | bgr555_to_rgb565_one r6 |
46 | bgr555_to_rgb565_one r7 |
47 | bgr555_to_rgb565_one r8 |
48 | bgr555_to_rgb565_one r9 |
49 | bgr555_to_rgb565_one r10 |
50 | stmia r0!, {r3-r10} |
51 | bge 0b |
52 | |
53 | 1: |
54 | adds r2, #4*8 |
55 | popeq {r4-r11,pc} |
56 | |
57 | 2: |
58 | ldr r3, [r1], #4 |
59 | subs r2, #4 |
60 | bgr555_to_rgb565_one r3 |
61 | str r3, [r0], #4 |
62 | bgt 2b |
63 | |
64 | pop {r4-r11,pc} |