Jump to content

Palette data files: Difference between revisions

From EDukeWiki
mNo edit summary
No edit summary
 
Line 19: Line 19:
An array of shade tables. These simply point to an index in the Display Palette (0-255) for each entry.
An array of shade tables. These simply point to an index in the Display Palette (0-255) for each entry.


=== Transparency Data Table ===
=== Translucency Blending Table ===
''(remaining 65536 bytes)''
''(remaining 65536 bytes)''


Essentially a 2D array which takes two color indexes and returns a color index to display.
Essentially a 2D array which takes two color indexes and returns a color index to display. The original games used this for 33% translucency, which doubles as 66% when the two colors are swapped.
 
=== Garbage Data ===
 
A properly formed PALETTE.DAT will be exactly 74,498 bytes long. However, Duke Nukem 3D's instance of this file harmlessly contains an extra 8,192 bytes for a total of 82,690. The extra data is not that interesting: It is nothing more than several overlapping copies of the ending portion of the blend table.
 
=== EDuke32 extension ===
 
EDuke32 adds support for additional blending tables, though a further improved version of this functionality is available through the [[Blendtable (DEF)|blendtable def syntax]].
 
To distinguish from the aforementioned garbage data, the engine first looks for the string <code>MoreBlendTab</code>.
 
Pseudocode for the rest:
 
char magic[12] = "MoreBlendTab";
uint8_t numAdditionalBlendTabs;
struct {
    uint8_t blendnum;  // the .blend index
    uint8_t blendTab[256][256];
} additionalBlendTabs[numAdditionalBlendTabs];


== LOOKUP.DAT ==
== LOOKUP.DAT ==
Line 48: Line 67:


For more information on the default palettes see [[Palette_(environment)#Global_Palettes | Palettes]].
For more information on the default palettes see [[Palette_(environment)#Global_Palettes | Palettes]].
[[Category:Palette editing]]

Latest revision as of 20:50, 10 March 2026

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.

Translucency Blending Table

(remaining 65536 bytes)

Essentially a 2D array which takes two color indexes and returns a color index to display. The original games used this for 33% translucency, which doubles as 66% when the two colors are swapped.

Garbage Data

A properly formed PALETTE.DAT will be exactly 74,498 bytes long. However, Duke Nukem 3D's instance of this file harmlessly contains an extra 8,192 bytes for a total of 82,690. The extra data is not that interesting: It is nothing more than several overlapping copies of the ending portion of the blend table.

EDuke32 extension

EDuke32 adds support for additional blending tables, though a further improved version of this functionality is available through the blendtable def syntax.

To distinguish from the aforementioned garbage data, the engine first looks for the string MoreBlendTab.

Pseudocode for the rest:

char magic[12] = "MoreBlendTab";
uint8_t numAdditionalBlendTabs;
struct {
    uint8_t blendnum;  // the .blend index
    uint8_t blendTab[256][256];
} additionalBlendTabs[numAdditionalBlendTabs];

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.