FXX and WXX file format

From DF21 Wiki

FXX and WXX are the image format for high resolution sprites in the Dark Forces Remaster. They replace FMEs and WAXes respectively. FXX and WXX are actually the same format, differing only in file extension.

FXX and WXX are true colour with an alpha channel.

FXX and WXX sprites will be loaded in place of a classic sprite if they have the same name (eg. hello.WAX, hello.WXX). Their image(s) must be exactly double the dimensions of the image(s) in the FME or WAX they are substituting for.

File format

FXX/WXX files contain minimal metadata. The game obtains key data (widths and heights of images, offsets, animation sequences, frame rates, etc.) from the corresponding FME or WAX.

Header

The FXX/WXX header is as follows.

FXX/WXX header
{ 
   NumImages        int32                       // Number of images contained in this file
   ImageSizes       int32[NumImages]            // The values are the number of pixels in each image
}

FXXs will only have one image, WXXs may have one or more corresponding to the number of images in the base WAX.

The header is followed by the data for each image.

Image data

Images are encoded simply as an array of pixels. Pixels are arranged by rows (note this is different from FMEs and WAXs where pixels are arranged by columns). For some reason, rows are arranged from right-to-left.

Each pixel is a 4 byte struct:

Pixel 
{
   Red      byte
   Blue     byte
   Green    byte
   Alpha    byte
}

Each value can be between 0 and 0xFF.

The way the Alpha channel is handled by the game is as follows:

0 The pixel will be transparent
Any value from 0x1 to 0xFE The pixel will be full-bright (fully lit in all light levels and produce bloom)
0xFF An ordinary pixel.

Order of images

In a WXX file, the images are ordered corresponding to the order in which cells are encountered in a WAX, as the WAX sequences and frames are traversed.

Note, this is often not the same as the order of cells in a WAX. For example, first frame of the first sequence of the Imperial Officer WAX points to the 12th cell in the WAX. Therefore the first image in the Imperial Officer WXX corresponds to the 12th cell.