1 /***************************************************************************
2 * Copyright (C) 2010 PCSX4ALL Team *
3 * Copyright (C) 2010 Unai *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
19 ***************************************************************************/
24 // GPU Blending operations functions
27 #define gpuBlending00(uSrc,uDst) \
29 asm ("and %[src], %[src], %[msk]\n" \
30 "and %[dst], %[dst], %[msk]\n" \
31 "add %[src], %[dst], %[src]\n" \
32 "mov %[src], %[src], lsr #1\n" \
33 : [src] "=&r" (uSrc), [dst] "=&r" (uDst) : "0" (uSrc), "1" (uDst), [msk] "r" (uMsk)); \
36 #define gpuBlending00(uSrc,uDst) \
38 uSrc = (((uDst & uMsk) + (uSrc & uMsk)) >> 1); \
42 // 1.0 x Back + 1.0 x Forward
44 #define gpuBlending01(uSrc,uDst) \
47 asm ("and %[dt], %[dst], #0x7C00\n" \
48 "and %[st], %[src], #0x7C00\n" \
49 "add %[out], %[dt], %[st] \n" \
50 "cmp %[out], #0x7C00 \n" \
51 "movhi %[out], #0x7C00 \n" \
52 "and %[dt], %[dst], #0x03E0\n" \
53 "and %[st], %[src], #0x03E0\n" \
54 "add %[dt], %[dt], %[st] \n" \
55 "cmp %[dt], #0x03E0 \n" \
56 "movhi %[dt], #0x03E0 \n" \
57 "orr %[out], %[out], %[dt] \n" \
58 "and %[dt], %[dst], #0x001F\n" \
59 "and %[st], %[src], #0x001F\n" \
60 "add %[dt], %[dt], %[st] \n" \
61 "cmp %[dt], #0x001F \n" \
62 "movhi %[dt], #0x001F \n" \
63 "orr %[src], %[out], %[dt] \n" \
64 : [src] "=r" (uSrc), [st] "=&r" (st), [dt] "=&r" (dt), [out] "=&r" (out) \
65 : [dst] "r" (uDst), "0" (uSrc) : "cc"); \
68 #define gpuBlending01(uSrc,uDst) \
71 bb = (uDst & 0x7C00) + (uSrc & 0x7C00); if (bb > 0x7C00) bb = 0x7C00; \
72 gg = (uDst & 0x03E0) + (uSrc & 0x03E0); if (gg > 0x03E0) gg = 0x03E0; bb |= gg; \
73 rr = (uDst & 0x001F) + (uSrc & 0x001F); if (rr > 0x001F) rr = 0x001F; bb |= rr; \
78 // 1.0 x Back - 1.0 x Forward */
80 #define gpuBlending02(uSrc,uDst) \
83 asm ("and %[dt], %[dst], #0x7C00\n" \
84 "and %[st], %[src], #0x7C00\n" \
85 "subs %[out], %[dt], %[st] \n" \
86 "movmi %[out], #0x0000 \n" \
87 "and %[dt], %[dst], #0x03E0\n" \
88 "and %[st], %[src], #0x03E0\n" \
89 "subs %[dt], %[dt], %[st] \n" \
90 "orrpl %[out], %[out], %[dt] \n" \
91 "and %[dt], %[dst], #0x001F\n" \
92 "and %[st], %[src], #0x001F\n" \
93 "subs %[dt], %[dt], %[st] \n" \
94 "orrpl %[out], %[out], %[dt] \n" \
95 "mov %[src], %[out] \n" \
96 : [src] "=r" (uSrc), [st] "=&r" (st), [dt] "=&r" (dt), [out] "=&r" (out) \
97 : [dst] "r" (uDst), "0" (uSrc) : "cc"); \
100 int btest(int s, int d)
106 #define gpuBlending02(uSrc,uDst) \
109 bb = (uDst & 0x7C00) - (uSrc & 0x7C00); if (bb < 0) bb = 0; \
110 gg = (uDst & 0x03E0) - (uSrc & 0x03E0); if (gg > 0) bb |= gg; \
111 rr = (uDst & 0x001F) - (uSrc & 0x001F); if (rr > 0) bb |= rr; \
116 // 1.0 x Back + 0.25 x Forward */
118 #define gpuBlending03(uSrc,uDst) \
121 asm ("mov %[src], %[src], lsr #2 \n" \
122 "and %[dt], %[dst], #0x7C00\n" \
123 "and %[st], %[src], #0x1C00\n" \
124 "add %[out], %[dt], %[st] \n" \
125 "cmp %[out], #0x7C00 \n" \
126 "movhi %[out], #0x7C00 \n" \
127 "and %[dt], %[dst], #0x03E0\n" \
128 "and %[st], %[src], #0x00E0\n" \
129 "add %[dt], %[dt], %[st] \n" \
130 "cmp %[dt], #0x03E0 \n" \
131 "movhi %[dt], #0x03E0 \n" \
132 "orr %[out], %[out], %[dt] \n" \
133 "and %[dt], %[dst], #0x001F\n" \
134 "and %[st], %[src], #0x0007\n" \
135 "add %[dt], %[dt], %[st] \n" \
136 "cmp %[dt], #0x001F \n" \
137 "movhi %[dt], #0x001F \n" \
138 "orr %[src], %[out], %[dt] \n" \
139 : [src] "=r" (uSrc), [st] "=&r" (st), [dt] "=&r" (dt), [out] "=&r" (out) \
140 : [dst] "r" (uDst), "0" (uSrc) : "cc"); \
143 #define gpuBlending03(uSrc,uDst) \
147 bb = (uDst & 0x7C00) + (uSrc & 0x1C00); if (bb > 0x7C00) bb = 0x7C00; \
148 gg = (uDst & 0x03E0) + (uSrc & 0x00E0); if (gg > 0x03E0) gg = 0x03E0; bb |= gg; \
149 rr = (uDst & 0x001F) + (uSrc & 0x0007); if (rr > 0x001F) rr = 0x001F; bb |= rr; \
154 #endif //_OP_BLEND_H_