Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 244 | chris | 1 | // This file is included by SWTri.cpp and should not be built directly by the project. |
| 2 | |||
| 3 | unsigned int tex; |
||
| 4 | #if !defined(LINEAR_BLEND) |
||
| 5 | { |
||
| 6 | unsigned int t_pos = ((v)>>16)*tex_pitch + ((u)>>16); |
||
| 7 | tex = t_pos<tex_endpos?pTexture[t_pos]:0; |
||
| 8 | } |
||
| 9 | #else |
||
| 10 | { |
||
| 11 | int umid = u-0x8000; |
||
| 12 | int vmid = v-0x8000; |
||
| 13 | int umidfloor = FixedFloor(umid); |
||
| 14 | int vmidfloor = FixedFloor(vmid); |
||
| 15 | |||
| 16 | unsigned int t_pos = (vmidfloor>>16)*tex_pitch + (umidfloor>>16); |
||
| 17 | |||
| 18 | unsigned int t00 = t_pos<tex_endpos?pTexture[t_pos]:0; |
||
| 19 | unsigned int t10 = t_pos+1<tex_endpos?pTexture[t_pos+1]:0; |
||
| 20 | unsigned int t01 = t_pos+tex_pitch<tex_endpos?pTexture[t_pos+tex_pitch]:0; |
||
| 21 | unsigned int t11 = t_pos+tex_pitch+1<tex_endpos?pTexture[t_pos+tex_pitch+1]:0; |
||
| 22 | |||
| 23 | int aUFactor = ((umid-umidfloor) & 0xFFFE) + 1; // aUFactor needs to be between 1 and 0xFFFF to avoid overflow |
||
| 24 | int aVFactor = ((vmid-vmidfloor) & 0xFFFE) + 1; // ditto for aVFactor |
||
| 25 | int a00 = ((t00 >> 24) * ((ulong) ((0x10000 - aUFactor) * (0x10000 - aVFactor)) >> 16)) >> 16; |
||
| 26 | int a10 = ((t10 >> 24) * ((ulong) (( aUFactor) * (0x10000 - aVFactor)) >> 16)) >> 16; |
||
| 27 | int a01 = ((t01 >> 24) * ((ulong) ((0x10000 - aUFactor) * ( aVFactor)) >> 16)) >> 16; |
||
| 28 | int a11 = ((t11 >> 24) * ((ulong) (( aUFactor) * ( aVFactor)) >> 16)) >> 16; |
||
| 29 | unsigned int r = (((t00&0x00FF0000)*a00 + (t10&0x00FF0000)*a10 + (t01&0x00FF0000)*a01 + (t11&0x00FF0000)*a11)>>8)&0xFF0000; |
||
| 30 | unsigned int g = (((t00&0x0000FF00)*a00 + (t10&0x0000FF00)*a10 + (t01&0x0000FF00)*a01 + (t11&0x0000FF00)*a11)>>8)&0x00FF00; |
||
| 31 | unsigned int b = (((t00&0x000000FF)*a00 + (t10&0x000000FF)*a10 + (t01&0x000000FF)*a01 + (t11&0x000000FF)*a11)>>8)&0x0000FF; |
||
| 32 | unsigned int a = ((a00 + a10 + a01 + a11)<<24)&0xFF000000; |
||
| 33 | |||
| 34 | tex = a|r|g|b; |
||
| 35 | } |
||
| 36 | #endif |
||
| 37 | |||
| 38 | unsigned int alpha; |
||
| 39 | #if defined (TEX_ALPHA) |
||
| 40 | alpha = tex>>24; |
||
| 41 | #else |
||
| 42 | alpha = 0xFF; |
||
| 43 | #endif |
||
| 44 |