Duke Nukem II Palette Formats

From ModdingWiki
Jump to navigation Jump to search

There are two different palette formats used by Duke Nukem II.

16-Color Palette

Duke Nukem II Palette Formats
Format typePalette
HardwareVGA
Colour depth18-bit
Number of colours16
Games

The 16-color palette is the most common palette format. It can be found in:

  • 16-color images
  • individual palette files (*.PAL)
  • the game's main executable (offsets are for the decompressed registered version executable):
    • in-game palette at offset 0x1B068
    • "The End ...until Duke 3-D" message (actor no. 175) palette at offset 0x1B098

The palette stores each entry's red, green and blue value (in that order) each as one byte value, resulting in a total size of 48 bytes. However, the color values are not standard 6-bit VGA values - they range from 0 to 68 (inclusive). This is because the game doesn't directly submit these values to the VGA hardware, but always in conjunction with a fade-in effect. During the fade, the game repeatedly adds the palette values to an accumulator buffer (of 16-bit values) over the course of 15 steps, and divides the accumulated values by 16 before sending the result to the hardware. Combined with a short delay after each step, this results in progressive brighter colors, until the fade-in stops.

Consequently, to convert the palette values to standard 6-bit VGA values, you can use this formula:

val6 = val*15 / 16

The following table lists all the palette values and the corresponding 8-bit values.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 0 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56
16 60 60 65 69 73 77 81 85 89 93 97 101 105 109 113 117
32 121 121 125 130 134 138 142 146 150 154 158 162 166 170 174 178
48 182 182 186 190 195 199 203 207 211 215 219 223 227 231 235 239
64 243 243 247 251 255

It is possible to use palette values greater than 68, but that will result in color errors during fade-in and fade-out.

See VGA Palette for details on converting between 6-bit and 8-bit values.

256-Color Palette

Duke Nukem II Palette Formats
Format typePalette
HardwareVGA
Colour depth18-bit
Number of colours256
Games

"Real" VGA palettes are stored in:

These are 768-byte files in classic (6-bit) VGA Palette format.

Credits

This file format was reverse engineered by K1n9_Duk3. lethal-guitar added some additional information regarding conversion of the 6-bit palette entries. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)