* Fade each color of mPalette by a factor of 2, until mPalette reaches mPaletteNew * * @return True if still fading */
| 131 | * @return True if still fading |
| 132 | */ |
| 133 | bool cSurface::palette_FadeTowardNew() { |
| 134 | mPaletteAdjusting = false; |
| 135 | |
| 136 | // Loop each color |
| 137 | for(size_t cx = 0; cx < g_MaxColors; ++cx ) { |
| 138 | |
| 139 | // Each component of the current color |
| 140 | for( int i = 0; i < 3; ++i ) { |
| 141 | |
| 142 | int8 al = mPaletteNew[cx].getPos(i); |
| 143 | int8 bl = mPalette[cx].getPos(i); |
| 144 | |
| 145 | // Difference between current and target |
| 146 | al -= bl; |
| 147 | |
| 148 | // No Difference? |
| 149 | if(!al) |
| 150 | continue; |
| 151 | |
| 152 | // We divide by two, 3 times, unless we reach 1 (the last possible enabled bit) |
| 153 | if( al != 1 ) { |
| 154 | al >>= 1; |
| 155 | |
| 156 | if( al != 1 ) { |
| 157 | al >>= 1; |
| 158 | |
| 159 | if( al != 1 ) |
| 160 | al >>= 1; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // loc_13918 |
| 165 | // Set the new color |
| 166 | mPalette[cx].setPos(i, bl + al ); |
| 167 | |
| 168 | // Still fading |
| 169 | mPaletteAdjusting = true; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | surfaceSetToPalette(); |
| 174 | return !mPaletteAdjusting; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Immediately apply mPalette to the surface palette |
no test coverage detected