Pal animations

This article tries to explain how palette animations worked in the Fallout games. These special animations are based on PAL files in spite of the FRM-based "frame animations".

Conversion: palette -> RGB
+-+                                  | Brightness(currentGamma) (****) | +-+                                                   |                +--+                                   V                |  Palette     |                     ++         +-+                 +-+ |  from       |                     |    Color transformation    |         |   System    |                 | DirectDraw  | | PAL-file (*) |                    |          table (**)        |         |   palette   |                 |   palette   | +-++                    ++---+         +-+---+                 +-+---+ |     | Red    |>|  0 |  pow(0, currentGamma) |         |     | Red   |                 |     | Red   | |    ++                     ++---+         |     +---+                 |     +---+ |  0  | Green  |                     |  1 |  pow(1, currentGamma) |>|  0  | Green |                 |  0  | Green | |    ++                     ++---+         |     +---+                 |     +---+ |     | Blue   |                     |            ... |        |     | Blue  |                 |     | Blue  | +-++                    ++---+         +-+---+   Red   << 2    +-+---+ |    | Red    |               +>| 63 |  pow(63, currentGamma)|         |     | Red   |-- Green << 2 -->|     | Red   | |    ++               |     ++---+         |     +---+   Blue  << 2    |     +---+ | 1  | Green  |               |                                            |  1  | Green |                 |  1  | Green | |    ++               |                                            |     +---+                 |     +---+ |     | Blue   |               |                                            |     | Blue  |                 |     | Blue  | +-++              |                                            +-+---+                 +-+---+ |     ...      |               |                                            |     ...     |                 |     ...     | +-++                                                            +-+---+                 +-+---+ |     | Red    |           Red   >> 2                                       |     | Red   |                 |     | Red   | |    ++           Green >> 2                                       |     +---+                 |     +---+ | 255 | Green |           Blue  >> 2                                       | 255 | Green |                 | 255 | Green | |    ++                                                            |     +---+                 |     +---+ |     | Blue   |               |                                            |     | Blue  |                 |     | Blue  | +-++              |                                            +-+---+                 +-+---+                                |                                |                                | +---+  | |   Animated colors (***)   |--+ +---+


 * * - If at the stage of PAL-file loading the value of one of color's components is not in the range between 0 .. 63, the value of all components of this color are to 0.
 * ** - If the result of the function turns out to be smaller than 0, the value of the corresponding element of the table is set to 0. If the result of the function turns out bigger than 63, the value of the corresponding element of the table set to 63. (pow - power function)
 * *** - Details in the animated colors section
 * **** - In Fallout the variable currentGamma has the double type and can have a range from 1.000000 up to 1.179993.

It's important to know that the used algorithm of brightness adjusting isn't fully working: the 0th and 1st element of the color transformation table never change.

Conversion: RGB -> palette index
The conversion is based on the following scheme:

Red               Green                 Blue +-|-+   +-|-+    +-|-+ |7|6|5|4|3|2|1|0|    |7|6|5|4|3|2|1|0|    |7|6|5|4|3|2|1|0| +-|-+    +-|-+    +-|-+      |                    |                    |      |                    |                    |      +-+              |              +-+            |              |              |            V              V              V  +-|--|--|--+ |0|R7|R6|R5|R4|R3|G7|G6|G5|G4|G3|B7|B6|B5|B4|B3| +-|--|--|--+

The resulting value is used as a transformation table index that is read from the corresponding PAL-file. Value of the table on corresponding index is a required index into palette. (I've absolutely got no clue what the last sentence means.)

Animated colors
In the Fallout games "animated colors" have been used to reduce the filesize of graphics. It allows you to use one frame with changing colors, instead of the several frames with static colors.

The user can control the "animated colors" with two parameters in fallout2.cfg and mapper2.cfg: [system] color_cycling=1 cycle_speed_factor=1


 * color_cycling - (1) / (0) enables / disables palette animations.
 * cycle_speed_factor - Adjusts the animation speed; the larger the value the slower the animation speed.

Animated color groups


There are six groups of "animated colors" with different initial parameters: (change time for cycle_speed_factor=1)

Example function
The algorithm of color changing is explained by this function: Javascript: