Fix palette corruption

This commit is contained in:
nukeykt 2019-10-16 13:46:15 +09:00 committed by Christoph Oelckers
parent 11845bb247
commit aa4bf2bb26

View file

@ -507,10 +507,6 @@ void FixPalette()
void TintPalette(int r, int g, int b) void TintPalette(int r, int g, int b)
{ {
int r2 = r;
int g2 = g;
int b2 = b;
palette_t *pPal = curpalettefaded; palette_t *pPal = curpalettefaded;
if (bCamera) { if (bCamera) {
@ -569,7 +565,6 @@ void TintPalette(int r, int g, int b)
btint += b; btint += b;
// do not modify r, g or b variables from this point on // do not modify r, g or b variables from this point on
b2 = b;
int nVal; int nVal;
// loc_17F49 // loc_17F49
@ -592,20 +587,23 @@ void TintPalette(int r, int g, int b)
#endif #endif
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
pPal->r += r; nVal = pPal->r + r;
if (pPal->r > 255) { if (nVal > 255) {
pPal->r = 255; nVal = 255;
} }
pPal->r = nVal;
pPal->g += g; nVal = pPal->g + g;
if (pPal->g > 255) { if (nVal > 255) {
pPal->g = 255; nVal = 255;
} }
pPal->g = nVal;
pPal->b += b; nVal = pPal->b + b;
if (pPal->b > 255) { if (nVal > 255) {
pPal->b = 255; nVal = 255;
} }
pPal->b = nVal;
pPal++; pPal++;
} }