Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Diablo CEL and CL2 sprites

From ReverseEngineering.wiki
Format
Developer Blizzard North
Uses Format:MPQ (MoPaQ)
Extensions .cel, .cl2, .clx (DevilutionX)
Endianness little
On this wiki Facts · Code · Notes · Topics

Run-length encoded sprite containers of Diablo (1996) and Hellfire, stored inside DIABDAT.MPQ: .CEL (transparent runs and literal pixel runs) and .CL2 (transparent runs, fill runs, literal runs), both with a little-endian frame offset table and no width in the file; DevilutionX converts them at load time to its own CLX format.

Overview

Diablo keeps its sprites in .CEL files and (for monsters, players and missiles) .CL2 files, both packed in DIABDAT.MPQ (Format:MPQ (MoPaQ)). Neither stores a frame width: the game code passes the width of each sprite when it draws it, so a viewer needs the width from outside (a table in the game, or a guess). Pixels are 8-bit indices into the level or UI palette (see Format:PCX#Palette trailer and the .PAL files below).

File layout

A file is either one frame list or a list of groups (for example the 8 directions of a monster animation).

  • Frame list: u32 frame count N, then N+1 u32 offsets (relative to the start of the list; the last one is the end of the list), then frame data.
  • Grouped file: a table of u32 group offsets at the start; each group is a frame list as above. Tools detect it like this: read the first u32 as N; if the u32 at offset 4*N+4 is not equal to the file size, the first u32 is really the size of the group table (N/4 groups).

CEL frames

A CEL frame may start with a 10-byte header whose first u16 is 10 (the header size; it holds offsets used by the game for drawing parts of the frame); when the first u16 of a frame is not 10 the pixel data starts at once. Pixel data is a sequence of commands that fill a line of the frame width and then continue on the next line:

  • control byte 0x80..0xFF: a run of (256 - control) transparent pixels (1..128);
  • control byte 0x01..0x7F: that many literal pixel bytes follow. A line ends when the widths add up to the frame width, so the height is the number of lines until the end of the frame data.

CL2 frames

CL2 frames start with a header whose first u16 is its own size (the pixel data begins at that offset from the frame start). Commands:

  • 0x00..0x7F: a run of control transparent pixels;
  • 0x80..0xBE: a fill run of (0xBF - control) pixels (1..63) with the colour given by the single byte that follows;
  • 0xBF..0xFF: (256 - control) literal pixel bytes (1..65) follow. In CL2 runs may continue across line ends; the decoder tracks the remaining width of the line.

CLX (DevilutionX)

DevilutionX converts CEL, CL2 and PCX art to CLX when the assets are loaded or in its own data files: the same list layout, with a 6-byte frame header (u16 header size = 6, u16 width, u16 height). So CLX does store the width, and its commands match those of CL2.

Palettes

DevilutionX reads a 768-byte .PAL file (256 RGB triples, no header) next to an unpacked CLX image, and takes the palette from the end of a PCX file otherwise.

Pitfalls

  • A tool that takes the first u32 for a frame count misreads grouped files; use the file-size test above.
  • Unverified: the exact meaning of the 5 offsets in the 10-byte CEL header (they appear to mark 32-line blocks used for clipped drawing).

Code & repositories

  • diasurgical/devilution and diasurgical/devilutionX: see Software:Diablo and Software:DevilutionX.
  • https://github.com/diasurgical/devilutionX @ a927236209828a1f1dcb7ef32bdd03a288710c29 · license: LicenseRef-Sustainable-Use-1.0 (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
    Portable Diablo/Hellfire port; CEL/CL2/PCX to CLX converters
    Tested on: source read, not run: Diablo data files (not run) · checked 2026-10-18