Duke Nukem II Palette Formats

From ModdingWiki
Jump to: navigation, 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

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! 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.

Despite the 0-68 range, the hardware palette can only store 64 different color values. To convert the palette values to standard 6-bit VGA values, you can use this formula:

val6 = Max(0, (val-1) - (val-1)/16)

A more efficient version might be:

IF val = 0
   val6 = 0
ELSE
   val6 = val-1
   val6 = val6 - val6/16
ENDIF

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. 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!)