Implemented light colors/palettes for primary tilesets.

This commit is contained in:
Ariel A 2021-12-07 01:04:17 -05:00
parent bd3c9ed3b9
commit e7cbec7eda

View file

@ -894,6 +894,8 @@ static void FieldmapUnkDummy(void)
void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u16 size) void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u16 size)
{ {
u16 black = RGB_BLACK; u16 black = RGB_BLACK;
u32 low = 0;
u32 high = 0;
if (tileset) if (tileset)
{ {
@ -902,25 +904,31 @@ void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u16 size)
LoadPalette(&black, destOffset, 2); LoadPalette(&black, destOffset, 2);
LoadPalette(((u16*)tileset->palettes) + 1, destOffset + 1, size - 2); LoadPalette(((u16*)tileset->palettes) + 1, destOffset + 1, size - 2);
FieldmapPaletteDummy(destOffset + 1, (size - 2) >> 1); FieldmapPaletteDummy(destOffset + 1, (size - 2) >> 1);
low = 0;
high = NUM_PALS_IN_PRIMARY;
} }
else if (tileset->isSecondary == TRUE) else if (tileset->isSecondary == TRUE)
{ {
u8 i;
LoadPalette(((u16*)tileset->palettes) + (NUM_PALS_IN_PRIMARY * 16), destOffset, size); LoadPalette(((u16*)tileset->palettes) + (NUM_PALS_IN_PRIMARY * 16), destOffset, size);
for (i = NUM_PALS_IN_PRIMARY; i < NUM_PALS_TOTAL; i++) { low = NUM_PALS_IN_PRIMARY;
if (tileset->lightPalettes & (1 << (i - NUM_PALS_IN_PRIMARY))) { // Mark as light palette high = NUM_PALS_TOTAL;
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;
}
}
} }
else else
{ {
LoadCompressedPalette((u32*)tileset->palettes, destOffset, size); LoadCompressedPalette((u32*)tileset->palettes, destOffset, size);
FieldmapPaletteDummy(destOffset, size >> 1); 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;
}
}
}
} }
} }