Use SDL_Color for colors instead of colourTransform

colourTransform is a struct with only one member, a Uint32. The issue
with `Uint32`s is that it requires a bunch of bit shifting logic to edit
the colors. The issue with bit shifting logic is that people have a
tendency to hardcode the shift amounts instead of using the shift amount
variables of the SDL_PixelFormat, which makes it annoying to change the
color masks of surfaces.

This commit fixes both issues by unhardcoding the bit shift amounts in
DrawPixel and ReadPixel, and by axing the `Uint32`s in favor of using
SDL_Color.

According to the SDL_PixelFormat documentation (
https://wiki.libsdl.org/SDL2/SDL_PixelFormat ), the logic to read and
draw to pixels from colors below 32-bit was just wrong. Specifically,
for 8-bit, there's a color palette used instead of some intrinsic color
information stored in the pixel itself. But we shouldn't need that logic
anyways because we don't use colors below 32-bit. So I axed that too.
This commit is contained in:
Misa
2023-01-01 16:36:43 -08:00
parent f24265f0fb
commit 351a022ebd
13 changed files with 309 additions and 327 deletions

View File

@@ -65,7 +65,7 @@ void entclass::clear(void)
dir = 0;
actionframe = 0;
realcol = 0;
SDL_zero(realcol);
lerpoldxp = 0;
lerpoldyp = 0;
}
@@ -618,14 +618,14 @@ void entclass::updatecolour(void)
case 10: // 2x1 Sprite
case 13: // Special for epilogue: huge hero!
graphics.setcol(colour);
realcol = graphics.ct.colour;
realcol = graphics.ct;
break;
case 3: // Big chunky pixels!
realcol = graphics.bigchunkygetcol(colour);
break;
case 4: // Small pickups
graphics.huetilesetcol(colour);
realcol = graphics.ct.colour;
realcol = graphics.ct;
break;
case 11: // The fucking elephant
if (game.noflashingmode)
@@ -636,7 +636,7 @@ void entclass::updatecolour(void)
{
graphics.setcol(colour);
}
realcol = graphics.ct.colour;
realcol = graphics.ct;
break;
case 12: // Regular sprites that don't wrap
// if we're outside the screen, we need to draw indicators
@@ -648,7 +648,7 @@ void entclass::updatecolour(void)
{
graphics.setcol(colour);
}
realcol = graphics.ct.colour;
realcol = graphics.ct;
break;
default:
break;