gpulib: limit height
[pcsx_rearmed.git] / plugins / gpu_unai / gpu_arm.s
1 /*
2  * (C) GraÅžvydas "notaz" Ignotas, 2011
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
9 .text
10 .align 2
11
12 @ in: r0=dst, r2=pal, r12=0x1e
13 @ trashes r6-r8,lr,flags
14 .macro do_4_pixels rs ibase obase
15 .if \ibase - 1 < 0
16     and     r6, r12, \rs, lsl #1
17 .else
18     and     r6, r12, \rs, lsr #\ibase-1
19 .endif
20     and     r7, r12, \rs, lsr #\ibase+3
21     and     r8, r12, \rs, lsr #\ibase+7
22     and     lr, r12, \rs, lsr #\ibase+11
23     ldrh    r6, [r2, r6]
24     ldrh    r7, [r2, r7]
25     ldrh    r8, [r2, r8]
26     ldrh    lr, [r2, lr]
27     tst     r6, r6
28     strneh  r6, [r0, #\obase+0]
29     tst     r7, r7
30     strneh  r7, [r0, #\obase+2]
31     tst     r8, r8
32     strneh  r8, [r0, #\obase+4]
33     tst     lr, lr
34     strneh  lr, [r0, #\obase+6]
35 .endm
36
37 .global draw_spr16_full @ (u16 *d, void *s, u16 *pal, int lines)
38 draw_spr16_full:
39     stmfd   sp!, {r4-r8,lr}
40     mov     r12, #0x1e             @ empty pixel
41
42 0:
43     ldmia   r1, {r4,r5}
44     do_4_pixels r4, 0,  0
45     do_4_pixels r4, 16, 8
46     do_4_pixels r5, 0,  16
47     do_4_pixels r5, 16, 24
48     subs    r3, r3, #1
49     add     r0, r0, #2048
50     add     r1, r1, #2048
51     bgt     0b
52
53     ldmfd   sp!, {r4-r8,pc}
54
55 @ vim:filetype=armasm