| 2095 | |
| 2096 | #define ADD_4_BITS(x) (((x)&1) + (((x) >> 1) & 1) + (((x) >> 2) & 1) + (((x) >> 3) & 1)) |
| 2097 | void xAnimPoolInit(xMemPool* pool, U32 count, U32 singles, U32 blendFlags, U32 effectMax) |
| 2098 | { |
| 2099 | effectMax += effectMax & 1; |
| 2100 | |
| 2101 | U32 size = |
| 2102 | (effectMax * sizeof(xAnimActiveEffect) + sizeof(xAnimSingle)) * |
| 2103 | (ADD_4_BITS((blendFlags & 0xffff) & ((int)(1 << singles) - 1 >> 0x0)) + |
| 2104 | ADD_4_BITS((blendFlags & 0xffff) & ((int)(1 << singles) - 1 >> 0x4)) + |
| 2105 | ADD_4_BITS((blendFlags & 0xffff) & ((int)(1 << singles) - 1 >> 0x8)) + |
| 2106 | ADD_4_BITS((blendFlags & 0xffff) & ((int)(1 << singles) - 1 >> 0xC)) + singles) + |
| 2107 | sizeof(xAnimPlay); |
| 2108 | |
| 2109 | U32 i; |
| 2110 | void* buffer = xMemAllocSize(count * size); |
| 2111 | |
| 2112 | xAnimPlay* play = (xAnimPlay*)buffer; |
| 2113 | play->NumSingle = singles; |
| 2114 | |
| 2115 | xAnimSingle* currsingle; |
| 2116 | play->Single = currsingle = (xAnimSingle*)((U32)play + sizeof(xAnimPlay)); |
| 2117 | currsingle += singles; |
| 2118 | |
| 2119 | for (i = 0; i < singles; ++i) |
| 2120 | { |
| 2121 | if (blendFlags & (1 << i)) |
| 2122 | { |
| 2123 | play->Single[i].Blend = currsingle; |
| 2124 | currsingle->Blend = NULL; |
| 2125 | currsingle++; |
| 2126 | } |
| 2127 | else |
| 2128 | { |
| 2129 | play->Single[i].Blend = NULL; |
| 2130 | } |
| 2131 | } |
| 2132 | |
| 2133 | xAnimActiveEffect* curract = (xAnimActiveEffect*)currsingle; |
| 2134 | for (i = 0; i < play->NumSingle; ++i) |
| 2135 | { |
| 2136 | currsingle = &play->Single[i]; |
| 2137 | while (currsingle) |
| 2138 | { |
| 2139 | currsingle->ActiveCount = effectMax; |
| 2140 | if (effectMax != 0) |
| 2141 | { |
| 2142 | currsingle->ActiveList = curract; |
| 2143 | curract += effectMax; |
| 2144 | } |
| 2145 | else |
| 2146 | { |
| 2147 | currsingle->ActiveList = NULL; |
| 2148 | } |
| 2149 | |
| 2150 | currsingle = currsingle->Blend; |
| 2151 | } |
| 2152 | } |
| 2153 | |
| 2154 | play->Pool = pool; |
no test coverage detected