| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2010 PCSX4ALL Team * |
| 3 | * Copyright (C) 2010 Unai * |
| 4 | * * |
| 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. * |
| 9 | * * |
| 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. * |
| 14 | * * |
| 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 | ***************************************************************************/ |
| 20 | |
| 21 | #ifndef _OP_BLEND_H_ |
| 22 | #define _OP_BLEND_H_ |
| 23 | |
| 24 | // GPU Blending operations functions |
| 25 | |
| 26 | #define gpuBlending00(uSrc,uDst) \ |
| 27 | { \ |
| 28 | asm ("and %[src], %[src], %[msk]\n" \ |
| 29 | "and %[dst], %[dst], %[msk]\n" \ |
| 30 | "add %[src], %[dst], %[src]\n" \ |
| 31 | "mov %[src], %[src], lsr #1\n" \ |
| 32 | : [src] "=&r" (uSrc), [dst] "=&r" (uDst) : "0" (uSrc), "1" (uDst), [msk] "r" (uMsk)); \ |
| 33 | } |
| 34 | |
| 35 | // 1.0 x Back + 1.0 x Forward |
| 36 | #define gpuBlending01(uSrc,uDst) \ |
| 37 | { \ |
| 38 | u32 st,dt,out; \ |
| 39 | asm ("and %[dt], %[dst], #0x7C00\n" \ |
| 40 | "and %[st], %[src], #0x7C00\n" \ |
| 41 | "add %[out], %[dt], %[st] \n" \ |
| 42 | "cmp %[out], #0x7C00 \n" \ |
| 43 | "movhi %[out], #0x7C00 \n" \ |
| 44 | "and %[dt], %[dst], #0x03E0\n" \ |
| 45 | "and %[st], %[src], #0x03E0\n" \ |
| 46 | "add %[dt], %[dt], %[st] \n" \ |
| 47 | "cmp %[dt], #0x03E0 \n" \ |
| 48 | "movhi %[dt], #0x03E0 \n" \ |
| 49 | "orr %[out], %[out], %[dt] \n" \ |
| 50 | "and %[dt], %[dst], #0x001F\n" \ |
| 51 | "and %[st], %[src], #0x001F\n" \ |
| 52 | "add %[dt], %[dt], %[st] \n" \ |
| 53 | "cmp %[dt], #0x001F \n" \ |
| 54 | "movhi %[dt], #0x001F \n" \ |
| 55 | "orr %[src], %[out], %[dt] \n" \ |
| 56 | : [src] "=r" (uSrc), [st] "=&r" (st), [dt] "=&r" (dt), [out] "=&r" (out) \ |
| 57 | : [dst] "r" (uDst), "0" (uSrc) : "cc"); \ |
| 58 | } |
| 59 | |
| 60 | // 1.0 x Back - 1.0 x Forward */ |
| 61 | #define gpuBlending02(uSrc,uDst) \ |
| 62 | { \ |
| 63 | u32 st,dt,out; \ |
| 64 | asm ("and %[dt], %[dst], #0x7C00\n" \ |
| 65 | "and %[st], %[src], #0x7C00\n" \ |
| 66 | "subs %[out], %[dt], %[st] \n" \ |
| 67 | "movmi %[out], #0x0000 \n" \ |
| 68 | "and %[dt], %[dst], #0x03E0\n" \ |
| 69 | "and %[st], %[src], #0x03E0\n" \ |
| 70 | "subs %[dt], %[dt], %[st] \n" \ |
| 71 | "orrpl %[out], %[out], %[dt] \n" \ |
| 72 | "and %[dt], %[dst], #0x001F\n" \ |
| 73 | "and %[st], %[src], #0x001F\n" \ |
| 74 | "subs %[dt], %[dt], %[st] \n" \ |
| 75 | "orrpl %[out], %[out], %[dt] \n" \ |
| 76 | "mov %[src], %[out] \n" \ |
| 77 | : [src] "=r" (uSrc), [st] "=&r" (st), [dt] "=&r" (dt), [out] "=&r" (out) \ |
| 78 | : [dst] "r" (uDst), "0" (uSrc) : "cc"); \ |
| 79 | } |
| 80 | |
| 81 | // 1.0 x Back + 0.25 x Forward */ |
| 82 | #define gpuBlending03(uSrc,uDst) \ |
| 83 | { \ |
| 84 | u32 st,dt,out; \ |
| 85 | asm ("mov %[src], %[src], lsr #2 \n" \ |
| 86 | "and %[dt], %[dst], #0x7C00\n" \ |
| 87 | "and %[st], %[src], #0x1C00\n" \ |
| 88 | "add %[out], %[dt], %[st] \n" \ |
| 89 | "cmp %[out], #0x7C00 \n" \ |
| 90 | "movhi %[out], #0x7C00 \n" \ |
| 91 | "and %[dt], %[dst], #0x03E0\n" \ |
| 92 | "and %[st], %[src], #0x00E0\n" \ |
| 93 | "add %[dt], %[dt], %[st] \n" \ |
| 94 | "cmp %[dt], #0x03E0 \n" \ |
| 95 | "movhi %[dt], #0x03E0 \n" \ |
| 96 | "orr %[out], %[out], %[dt] \n" \ |
| 97 | "and %[dt], %[dst], #0x001F\n" \ |
| 98 | "and %[st], %[src], #0x0007\n" \ |
| 99 | "add %[dt], %[dt], %[st] \n" \ |
| 100 | "cmp %[dt], #0x001F \n" \ |
| 101 | "movhi %[dt], #0x001F \n" \ |
| 102 | "orr %[src], %[out], %[dt] \n" \ |
| 103 | : [src] "=r" (uSrc), [st] "=&r" (st), [dt] "=&r" (dt), [out] "=&r" (out) \ |
| 104 | : [dst] "r" (uDst), "0" (uSrc) : "cc"); \ |
| 105 | } |
| 106 | |
| 107 | #endif //_OP_BLEND_H_ |