Palette data files: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
This number is weird, so I expect it's 65536, instead of 655536.
No edit summary
Line 1: Line 1:
Palette, palette mapping and transparancy data is stored in two files, palette.dat and lookup.dat.
'''Palettes''', '''palette mapping''', '''shading tables''', and '''transparancy data''' are stored in two files, ''PALETTE.DAT'' and ''LOOKUP.DAT''.


palette.dat
== PALETTE.DAT ==


index 0:
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.
768 bytes of palette data for the main palette. Each color stored as three bytes for red green and blue in that order. Values only range from 0 to 63 so scaling will be required for acceptable display on a modern system.


index 768:
=== Display Palette ===
two byte little endian integer containing number of "palookup" tables (used to make art look darker) This number is hereafter known as numpalookups
''(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.


index 770:
=== Shade Tables Amount ===
numpalookups "palookup" tables. Theese are simple 256 byte lookup tables which map from a color in the image to a color in the display palette.
''(byte 768 and byte 769)''


index 770+(numpalookups*256):
Two Bytes [[http://en.wikipedia.org/wiki/Endianness little endian]] integer containing the number of shading tables. This is used to make art look darker, and defines the amount of shade tables.
65536 bytes of transparancy data. Essentially a 2D array which takes two color indexes and returns a color index to display.


=== Shade Tables ===
''(byte 770 through byte (769 + (shade_number * 256))''


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


index 1:
=== Transparency Data Table ===
spritepals, Each spritepal has a prefix byte with it's spritepal number then 256 bytes of lookup data.
''(remaining 65536 bytes)''


index 1+(num_tables*768):
Essentially a 2D array which takes two color indexes and returns a color index to display.
alternate main palettes.
 
5 pallettes in the same format as the main palette (768 bytes each)
== LOOKUP.DAT ==
WATERpalette: used for underwater
 
SLIMEpalette: used for nightvision (in combination with a spritepal which is used to make enemy sprites glow) and presumablly something to do with slime.
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.
TITLEpalette: used for the screen where the words duke nukem 3D atomic fly in.
 
REALMSpalette: used for the 3D realms title screen
=== Number of Palette Swaps ===
BOSS1palette: used for the animiation you get after defeating the boss at the end of episode 1.
''(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_(environment)#Palette_Swaps | 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 [[Palette_(environment)#Global_Palettes | Palettes]].

Revision as of 20:11, 29 March 2012

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.

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.