DAT (Duke Nukem 3D)
From Just Solve the File Format Problem
(Difference between revisions)
m |
|||
(11 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
}} | }} | ||
− | The '''DAT''' format is a palette format used by [[Build Engine]] | + | The '''DAT''' format is a palette format used by ''Duke Nukem 3D'' (a [[:Category:Build_Engine_formats|Build Engine]] game). Typically, these files are named <code>PALETTE.DAT</code>. |
The format contains three chunks: | The format contains three chunks: | ||
Line 12: | Line 12: | ||
* '''Shading Lookup Table''' which is used to reference the colors in the palette at different brightnesses, from full-bright to black. | * '''Shading Lookup Table''' which is used to reference the colors in the palette at different brightnesses, from full-bright to black. | ||
* '''Translucent Lookup Table''', which given any two colors, provides reference to the closest matching color in the palette representing the blend of those two colors. | * '''Translucent Lookup Table''', which given any two colors, provides reference to the closest matching color in the palette representing the blend of those two colors. | ||
− | |||
== File signature == | == File signature == | ||
− | + | This format does not contain a file signature/magic bytes. | |
== Specification == | == Specification == | ||
− | Ken Silverman, the original author of the [[Build Engine]], provided the following documentation of the format: | + | Ken Silverman, the original author of the [[:Category:Build_Engine_formats|Build Engine]], provided the following documentation of the format: |
<pre> | <pre> | ||
Line 66: | Line 65: | ||
their palette. | their palette. | ||
</pre> | </pre> | ||
+ | |||
+ | == Sample files == | ||
+ | |||
+ | * [https://archive.org/details/cdrom-boot-disc-01 Boot Disc Issue 01] → CONTENT/DEMOS/GAMES/DUKE3D/DUKE3D.GRP ([[GRP (Duke Nukem 3D)|GRP]] format) → PALETTE.DAT (from the Duke3D demo) | ||
+ | |||
+ | == See also == | ||
+ | |||
+ | * [https://moddingwiki.shikadi.net/wiki/Duke_Nukem_3D_Palette_Format ''Duke Nukem 3D Palette Format'' on the ''DOS Game Modding Wiki''] | ||
+ | |||
+ | [[Category:Build Engine formats]] | ||
+ | [[Category:Palettes]] | ||
+ | [[Category:Game data files]] |
Latest revision as of 20:11, 27 June 2023
The DAT format is a palette format used by Duke Nukem 3D (a Build Engine game). Typically, these files are named PALETTE.DAT
.
The format contains three chunks:
- A palette of 256 colors, based on the VGA 262,144 color palette. Colors are stored as a tuple of 3 bytes in sequence, comprising the red, blue and green component. Each component's value is in the range of 0-63.
- Shading Lookup Table which is used to reference the colors in the palette at different brightnesses, from full-bright to black.
- Translucent Lookup Table, which given any two colors, provides reference to the closest matching color in the palette representing the blend of those two colors.
Contents |
[edit] File signature
This format does not contain a file signature/magic bytes.
[edit] Specification
Ken Silverman, the original author of the Build Engine, provided the following documentation of the format:
http://advsys.net/ken/palette.txt Here's some pseudo-C code which explains how to load the PALETTE.DAT file: char palette[768], palookup[numpalookups][256], transluc[256][256]; short numpalookups; fil = open("PALETTE.DAT",...); read(fil,palette,768); read(fil,&numpalookups,2); read(fil,palookup,numpalookups*256); read(fil,transluc,65536); close(fil); PALETTE: This 768 byte array is exactly the palette you want. The format is: Red0, Green0, Blue0, Red1, Green1, Blue1, ..., Blue255 The colors are based on the VGA 262,144 color palette. The values range from 0-63, so if you want to convert it to a windows palette you will have to multiply each byte by 4. NUMPALOOKUPS: The number of shading tables used. Usually this number is 32, but 16 or 64 have also been used. Each of the 256 colors of the VGA palette can take on any of "numpalookups" number of shades. PALOOKUP: The shading table. If numpalookups = 32, then this table is: (32 shades) * (256 colors) = 8192 bytes (8K). The shade tables are often made to go from normal brightness (shade #0) down to pitch black (shade #31) So the first 256 bytes of the table would be for shade #0, etc... TRANSLUC: 64K translucent lookup table. Given any 2 colors of the palette, this lookup table gives the best match of the 2 colors when mixed together. Here's a funny story: I noticed that Duke3D's PALETTE.DAT file is 8K longer than it should be. Any PALETTE.DAT file with 32 shades and translucent table should be 74,498 bytes. Duke3D's palette is 82,690 bytes, but it only has 32 shades! The reason is that at one time, Duke3D had 64 shades in their "palookup" table. Then when we noticed that this extra memory overhead slowed down the frame rate of the game noticably, it was converted back to 32 shades. The problem is that my palette conversion program never truncated off the end of the file. So the last 8K of Duke3D's PALETTE.DAT is the last 8K of a translucent table that was based on an older version of their palette.
[edit] Sample files
- Boot Disc Issue 01 → CONTENT/DEMOS/GAMES/DUKE3D/DUKE3D.GRP (GRP format) → PALETTE.DAT (from the Duke3D demo)