ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

PAL

From ModEnc
Jump to: navigation, search

PAL files contain the colour palettes for various in-game objects.

Format

The PAL file format is very simple. It is a series of 256 colours, each represented by 3 bytes in the RGB format:

struct PAL{
  unsigned char red;
  unsigned char green;
  unsigned char blue;
} colours[256];

Each colour value (red, green and blue) is represented by 6 bits only, which means 63 is the highest a colour value can get (rather than 255). For example, pure red would be represented as 00111111 (63 in decimal) in the red byte. The highest two bits are always zero, so that one colour value still takes 8 bits in the file.

However, the game converts this 18-bit palette to true 16-bit (Hi-Colour) by ignoring the least significant bit of the red and blue channels. Therefore it's best to design custom palettes in a 5:6:5 format to avoid colour loss. This conversion effect is demonstrated here.

Relation with SHPs

SHP files refer to the colour indices in a PAL file. Depending on the object type and PAL file, some indices have very specific effects tied to them:

  • In all SHPs, the first colour of the PAL (index #0, the first 3 bytes) is used as the transparent colour of the SHP image (i.e. it will not be copied to the screen when drawn).
  • In all shadow frames, all colours aside from #0 (transparent) will be rendered as shadow. A convention is to use colour #1 as in the original TS/RA2.
  • In all SHPs using UNITxxx.PAL (where xxx is the theatre ID):
    • In all remappable images, the colours #16 to #31 are the different remap stages.
    • Depending on the object type, some or all colours on the range #204 to #254 are ignored, causing the pixels to be rendered magenta in-game. See this topic for more information.
    • In all SHPs, colours #240 to #254 are not affected by map brightness (similar to UseNormalLight), hence they're useful for making things like muzzle flashes glow in the dark.