Skip to content

XPK Technical Documentation

Charlotte Koch edited this page Jul 1, 2020 · 8 revisions

Introduction

XPK is a raster graphics format. The format is not only used in Purple Moon games; Presage Software seemed to use it in other games from the same era. In fact, Anthony Kozar and Toastline have previously described the XPK format as it's used in Lode Runner 2. However, there's a key difference between how XPK is used in Lode Runner 2 versus Purple Moon's games ("C02" versus "B01") so I'll try to describe the entire format in this document, without requiring the reader to consult Toastline's research.

General Principles

A single XPK file may specify one or more individual graphics. For example, it may specify a single still image, or perhaps the individual frames of an animation. It's not currently well understood how the multiple-image format works, so this document currently describes the structure of a single image. With that in mind:

  • A single XPK graphic describes a raster of pixels.
  • Each pixel is either fully opaque with a color, or fully transparent. ("Boolean" transparency, no alpha blending to worry about.)
  • When decoding the image, one starts with a fully transparent canvas, and then fills in some, all, or none of the canvas with "paint" according to the instructions listed in the XPK file. I.e., there's no such thing as "transparent paint."
  • The dimensions of the canvas, and other such metadata, is accessible in a header which precedes the drawing instructions.
  • Color information is never stored directly in a XPK. Instead, colors are identified only by an index in a color lookup table (CLU). Therefore, one must "attach" a CLU to a XPK in order to properly decode the XPK.

Instructions

Luna Purpura has not consulted source code nor documentation of any kind from Presage Software. Therefore, the names of instructions are entirely Luna Purpura's invention.

Prefix Name Description
0x0 XPKINST_REPEAT
0x2 XPKINST_XSKIP
0x3 XPKINST_BIGXSKIP
0x4 XPKINST_RLE
0x5 XPKINST_BIGRLE
0x6 XPKINST_DIRECT
0x7 XPKINST_BIGDIRECT
0x8 XPKINST_LINEREPEAT
0xA XPKINST_SETXNL
0xB XPKINST_BIGSETXNL
0xC XPKINST_RLENL
0xD XPKINST_BIGRLENL
0xE XPKINST_DIRECTNL
0xF XPKINST_BIGDIRECTNL