Posted November 12, 2022 by megamarc
Tilengine 2.13 introduces a feature common to all 8/16-bit era video chipsets: the ability to set an individual palette on each tile of the tilemap.
This feature doesn't break any compatibility, as the standard per-tileset and per-layer palette schemes continues working without changes. But now, each tile descriptor adds three palette selector bits, which add the ability to set one of the new eight global palettes on that specific tile. These global palettes can be set with the API function TLN_SetGlobalPalette(int index, TLN_Palette palette). By default global palettes are not set, so the renderer ignores the palette selector bits and defaults to the layer or tileset palette. But once the corresponding global palette is set, it takes precedence and the renderer picks this one.
This is how actual 2D graphics work: there's no concept of tileset or layer palette. Insetad there's a fixed number of hardware palettes of 16 colors each. Sega Master System has 2, Sega MegaDrive/Genesis has 4, Super Nintendo has 8... And each tile of the tilemap can select which palette is using. This allows to create colour variations of the same tileset, and show more than 16 colors onscreen. Tilengine doesn't have this limitation as its palettes can have up to 256 colors each, but this new feature brings a closer approach on how these systems actually work.
Base tileset in plain green:
Main layer in Tiled using the base tileset
Palette-selector layer superimposed. Tile indexes in this layer are used to set the palette selector bits in tiles on main layer
Final output. Observe how colous in some tiles are changed respect to the base tileset colour according to the palette selector layer
Additionally, this release adds various getters to retrieve the current position of layers and sprites: