Tilengine 2.13 with per-tile palette selector


Per-tile palette selector

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



New getters

Additionally, this release adds various getters to retrieve the current position of layers and sprites:

  • TLN_GetSpriteX() and TLN_GetSpriteY() to get position of a sprite
  • TLN_GetLsyerX() and TLN_GetLayerY() to get postion of a background layer

Files

Linux ARMv7l (Raspberry Pi, BeagleBone...) 403 kB
25 days ago
Linux Desktop 32-bit 420 kB
25 days ago
Linux Desktop 64-bit 415 kB
25 days ago
Windows 32-bit 479 kB
25 days ago
Windows 64-bit 501 kB
25 days ago

Get Tilengine

Buy Now$5.00 USD or more

Comments

Log in with itch.io to leave a comment.

Hi!
Nice blog article. The multi-layer technique to store tile attributes is well explained. However, I noticed a small error : SNES has 16 palettes of 16 colors, not 8.

Hi! Thanks for your positive feedback :-)

However I'm afraid you're wrong about the number of palettes in SNES: According to official Nintendo development books for the SNES, it has 8 palettes of 16 colors each, selected with 3 bits in OBJ (sprite) and BG (background) registers. Here are the documentation pages: