Palette data files

From EDukeWiki
Jump to navigation Jump to search

Palettes, palette mapping, shading tables, and transparancy data are stored in two files, PALETTE.DAT and LOOKUP.DAT.

PALETTE.DAT

PALETTE.DAT contains the basic palette, shading info, and transparency information. It is a binary format file, and is used by all common Build engine games, including Blood, Duke Nukem 3D, and Shadow Warrior.

Display Palette

(byte 0 through byte 767) This contains 768 bytes of game palette data, alternating between R and G and B, for a total of 256 RGB colors. The colors range from 0 to 63, so scaling will be required for acceptable display on a modern operating system. This is because of DOS-based memory constraints that don't exist in modern systems. Scale up by 4x.

Shade Tables Amount

(byte 768 and byte 769)

Two Bytes [little endian] integer containing the number of shading tables. This is used to make art look darker, and defines the amount of shade tables.

Shade Tables

(byte 770 through byte (769 + (shade_number * 256))

An array of shade tables. These simply point to an index in the Display Palette (0-255) for each entry.

Transparency Data Table

(remaining 65536 bytes)

Essentially a 2D array which takes two color indexes and returns a color index to display.

LOOKUP.DAT

LOOKUP.DAT contains the palette range swaps (25 of them in Duke Nukem 3D using the default LOOKUP.DAT), as well as alternate palettes used for things like the title screen. This is used by Duke Nukem 3D and it's derivatives only. It too, like PALETTE.DAT, is a binary file.

Number of Palette Swaps

(byte 0)

Number of spritepals (hereon out known as palette_swaps). This is the number of "recolor" abilities.

Palette Swap Tables

(byte 1) The tables for palettes are made up of this structure:

palette_swap_index - an index number for the table to follow. This is important, as analysis of the LOOKUP.DAT reveals not all palette swaps are in order.

palette_swap_table[256] - an array of 256 bytes (a byte in this context is a data ranging 0 through 255, aka an unsigned 8-bit int) pointing to the color index in PALETTE.DAT's main palette to remap to, or in some cases the alternate display palettes below. For example, if palette_swap_table[0] through palette_swap_table[255] are all equal to 0, the whole palette for that object/art/etc is remapped to the color at 0 (in Duke 3D's palette, it's pitch black). This is the case for palette swap #4.

There is one index+table for each number of palette swaps. The total amount of data should be ((1 byte + 256 bytes) * palette_swaps).

Alternate Display Palettes

Right after the Palette Swap Tables, the rest of the data is an array of 768 byte blocks for alternate palettes. Unlike the display palette in PALETTE.DAT, these are used for specific purposes and are quite different than the palette swap tables in that the actual color data is different for these, while the palette swap tables are just remapping existing color indexes to other indexes or ranges..

For more information on the default palettes see Palettes.