parent
b23d05f850
commit
beb010cd0f
|
@ -196,6 +196,8 @@ int _Color2RGB_(int a1)
|
|||
void colorPaletteFadeBetween(unsigned char* oldPalette, unsigned char* newPalette, int steps)
|
||||
{
|
||||
for (int step = 0; step < steps; step++) {
|
||||
sharedFpsLimiter.mark();
|
||||
|
||||
unsigned char palette[768];
|
||||
|
||||
for (int index = 0; index < 768; index++) {
|
||||
|
@ -210,10 +212,13 @@ void colorPaletteFadeBetween(unsigned char* oldPalette, unsigned char* newPalett
|
|||
|
||||
_setSystemPalette(palette);
|
||||
renderPresent();
|
||||
sharedFpsLimiter.throttle();
|
||||
}
|
||||
|
||||
sharedFpsLimiter.mark();
|
||||
_setSystemPalette(newPalette);
|
||||
renderPresent();
|
||||
sharedFpsLimiter.throttle();
|
||||
}
|
||||
|
||||
// 0x4C73D4
|
||||
|
|
|
@ -41,20 +41,14 @@ void paletteInit()
|
|||
|
||||
colorPaletteSetTransitionCallback(NULL);
|
||||
|
||||
unsigned int diff = getTicksSince(tick);
|
||||
// Actual fade duration will never be 0 since |colorPaletteFadeBetween| uses
|
||||
// frame rate throttling.
|
||||
unsigned int actualFadeDuration = getTicksSince(tick);
|
||||
|
||||
// NOTE: Modern CPUs are super fast, so it's possible that less than 10ms
|
||||
// (the resolution of underlying GetTicks) is needed to fade between two
|
||||
// palettes, which leads to zero diff, which in turn leads to unpredictable
|
||||
// number of fade steps. To fix that the fallback value is used (46). This
|
||||
// value is commonly seen when running the game in 1 core VM.
|
||||
if (diff == 0) {
|
||||
diff = 46;
|
||||
}
|
||||
// Calculate fade steps needed to perform fading in about 700 ms.
|
||||
gPaletteFadeSteps = 60 * 700 / actualFadeDuration;
|
||||
|
||||
gPaletteFadeSteps = (int)(60.0 / (diff * (1.0 / 700.0)));
|
||||
|
||||
debugPrint("\nFade time is %u\nFade steps are %d\n", diff, gPaletteFadeSteps);
|
||||
debugPrint("\nFade time is %u\nFade steps are %d\n", actualFadeDuration, gPaletteFadeSteps);
|
||||
}
|
||||
|
||||
// NOTE: Collapsed.
|
||||
|
|
Loading…
Reference in New Issue