MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / palette_FadeTowardNew

Method palette_FadeTowardNew

Source/Surface.cpp:133–175  ·  view source on GitHub ↗

* Fade each color of mPalette by a factor of 2, until mPalette reaches mPaletteNew * * @return True if still fading */

Source from the content-addressed store, hash-verified

131 * @return True if still fading
132 */
133bool 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

Callers 15

CycleMethod · 0.80
GUI_Select_File_LoopMethod · 0.80
Phase_CycleMethod · 0.80
Phase_PausedMethod · 0.80
VersionSwitchMethod · 0.80
Campaign_Select_SetupMethod · 0.80
Menu_LoopMethod · 0.80
Menu_DrawMethod · 0.80
Demo_Quiz_ShowScreenMethod · 0.80
Demo_QuizMethod · 0.80
Service_KIA_LoopMethod · 0.80

Calls 2

getPosMethod · 0.80
setPosMethod · 0.80

Tested by

no test coverage detected