From e7cbec7eda4532dfe284ad1b246036a286f3ecb2 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Tue, 7 Dec 2021 01:04:17 -0500 Subject: [PATCH] Implemented light colors/palettes for primary tilesets. --- src/fieldmap.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/fieldmap.c b/src/fieldmap.c index dfa6173176..35e8bc5290 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -894,6 +894,8 @@ static void FieldmapUnkDummy(void) void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u16 size) { u16 black = RGB_BLACK; + u32 low = 0; + u32 high = 0; if (tileset) { @@ -902,25 +904,31 @@ void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u16 size) LoadPalette(&black, destOffset, 2); LoadPalette(((u16*)tileset->palettes) + 1, destOffset + 1, size - 2); FieldmapPaletteDummy(destOffset + 1, (size - 2) >> 1); + low = 0; + high = NUM_PALS_IN_PRIMARY; } else if (tileset->isSecondary == TRUE) { - u8 i; LoadPalette(((u16*)tileset->palettes) + (NUM_PALS_IN_PRIMARY * 16), destOffset, size); - for (i = NUM_PALS_IN_PRIMARY; i < NUM_PALS_TOTAL; i++) { - if (tileset->lightPalettes & (1 << (i - NUM_PALS_IN_PRIMARY))) { // Mark as light palette - u16 index = i * 16; - gPlttBufferFaded[index] = gPlttBufferUnfaded[index] |= 0x8000; - if (tileset->customLightColor & (1 << (i - NUM_PALS_IN_PRIMARY))) // Mark as custom light color - gPlttBufferFaded[index+15] = gPlttBufferUnfaded[index+15] |= 0x8000; - } - } + low = NUM_PALS_IN_PRIMARY; + high = NUM_PALS_TOTAL; } else { LoadCompressedPalette((u32*)tileset->palettes, destOffset, size); FieldmapPaletteDummy(destOffset, size >> 1); } + if (tileset->isSecondary == FALSE || tileset->isSecondary == TRUE) { + u32 i; + for (i = low; i < high; i++) { + if (tileset->lightPalettes & (1 << (i - low))) { // Mark as light palette + u32 index = i * 16; + gPlttBufferFaded[index] = gPlttBufferUnfaded[index] |= 0x8000; + if (tileset->customLightColor & (1 << (i - low))) // Mark as custom light color + gPlttBufferFaded[index+15] = gPlttBufferUnfaded[index+15] |= 0x8000; + } + } + } } }