Kings of the Beach PAK Format
|Minimum size (pixels)||8×1|
|Maximum size (pixels)||320×200|
The images in the game Kings of the Beach are in a 4-bit planar format which is compressed using RLE.
The file header is included in the RLE-compressed data, meaning the data needs to be decompressed before it can be parsed.
The compressed file format is the following:
|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.
After decompression, the header can be read.
|0x00||UINT8||ByteWidth||Byte width of one planar scanline in the image data.|
|0x01||UINT8||Height||Height of the image, in pixels.|
There is no colour palette in the file; it uses the standard EGA palette.
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:
When decoded to 1 bpp using a stride of
ByteWidth * 4, the four planes show up horizontally:
The final image, after combining the planes per line, and viewed with the EGA palette, will become this:
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.
The following tools are able to work with files in this format.
|Name||Platform||View images in this format?||Convert/export to another file/format?||Import from another file/format?||Access hidden data?||Edit metadata?||Notes|
|Engie File Converter||Windows||Yes||Yes||Yes||N/A||N/A|