Kings of the Beach PAK Format

From ModdingWiki
Jump to: navigation, search
Kings of the Beach PAK Format
Kings of the Beach PAK Format.png
Format typeImage
HardwareEGA
Colour depth4-bit
Minimum size (pixels)8×1
Maximum size (pixels)320×200
PaletteDefault EGA
Plane count4
Transparent pixels?No
Hitmap pixels?No
Games

The images in the game Kings of the Beach are in a 4-bit planar format which is compressed using RLE.

File format

The file header is included in the RLE-compressed data, meaning the data needs to be decompressed before it can be parsed.

Compressed data

The compressed file format is the following:

Data type Name Description
BYTE[FileLength-2] CompressedData Compressed data. Needs to be uncompressed first.
UINT16LE DecompressedLength The final two bytes of the file give the expected length of the CompressedData block after decompression, which can serve as data consistency check.

The game uses a very straightforward code-based RLE compression with one-byte codes, in which an enabled highest bit indicates a Copy command, and the remaining seven bits give the amount to be copied or repeated.

Decompressed data

After decompression, the header can be read.

Offset Data type Name Description
0x00 UINT8 ByteWidth Byte width of one planar scanline in the image data.
0x01 UINT8 Height Height of the image, in pixels.
0x02 BYTE[DecompressedLength-2] Data Image data.

There is no colour palette in the file; it uses the standard EGA palette.

Image data

The image is a 4-bit planar image, however, the planes are not saved as separate blocks. Instead, for each line of the image, the data will contain the data of all four planes as consecutive blocks. Since one planar line covers the full width in 1bpp, the final image width will be ByteWidth * 8. This also means that only images with a width divisible by 8 can be saved in this format.

When decoded to 1 bpp using the ByteWidth as stride, the four planes get alternated per four lines, like this:

Kings of the beach decompose vertical.png

When decoded to 1 bpp using a stride of ByteWidth * 4, the four planes show up horizontally:

Kings of the beach decompose horizontal.png

The final image, after combining the planes per line, and viewed with the EGA palette, will become this:

Kings of the beach final.png

Partial files

Sometimes, the size of the Data array will not match Height * ByteWidth * 4, but will match an exact but lower amount of ByteWidth * 4 lines. In that case, the image represents an overlap drawn over the top of a different image. This is used in the game to save the courts in different cities. The only full court image in the game files is the Brazil court, in RIOCOURT.PAK. All other court images have a header that indicates that they are meant to be full 320×200 images, but only contain the top 85 lines, which show the specific cityscape graphics for that location. The remainder of the image could be considered 'transparent', though there is no real way to represent this while also preserving the 4bpp format.

The Engie File Converter solves this issue by simply rendering the lower space as palette colour #0 black. When saving an image in the .PAK format it detects whether there is such blank space at the bottom of the image, and if found, offers a save option to allow saving in the partial format.

Tools

The following tools are able to work with files in this format.

Name PlatformView images in this format? Convert/export to another file/format? Import from another file/format? Access hidden data? Edit metadata? Notes
Engie File Converter WindowsYesYesYesN/AN/A