1
0
Fork 0

Codechange: Off-by-one in colour gradient initialisation.

Remap sprites start with a count byte followed by 256 entries, but
SetupColoursAndInitialWindow did not take account of this extra byte and
therefore started at palette index 0xC5 instead of 0xC6. This caused the
first colour of each gradient to be incorrect and all shades were actually
1 step lower in the gradient than indicated.
pull/12177/head
Peter Nelson 2023-12-28 16:06:35 +00:00 committed by Peter Nelson
parent 912d7bd80e
commit 86be6d7e0b
2 changed files with 3 additions and 2 deletions

View File

@ -541,7 +541,7 @@ void ShowSelectGameWindow();
void SetupColoursAndInitialWindow()
{
for (Colours i = COLOUR_BEGIN; i != COLOUR_END; i++) {
const byte *b = GetNonSprite(GENERAL_SPRITE_COLOUR(i), SpriteType::Recolour);
const byte *b = GetNonSprite(GENERAL_SPRITE_COLOUR(i), SpriteType::Recolour) + 1;
assert(b != nullptr);
for (ColourShade j = SHADE_BEGIN; j < SHADE_END; j++) {
SetColourGradient(i, j, b[0xC6 + j]);

View File

@ -42,13 +42,14 @@ TextColour GetContrastColour(uint8_t background, uint8_t threshold = 128);
enum ColourShade : uint8_t {
SHADE_BEGIN = 0,
SHADE_DARKEST,
SHADE_DARKEST = SHADE_BEGIN,
SHADE_DARKER,
SHADE_DARK,
SHADE_NORMAL,
SHADE_LIGHT,
SHADE_LIGHTER,
SHADE_LIGHTEST,
SHADE_LIGHTEREST,
SHADE_END,
};
DECLARE_POSTFIX_INCREMENT(ColourShade)