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:HAM (Descent)

From ReverseEngineering.wiki
Format
Magic HAM!: 48 41 4D 21; sound file DSND: 44 53 4E 44; HXM: 48 58 4D 21
Extensions .ham, .s11, .s22, .hxm
Endianness little
On this wiki Facts · Code · Notes · Topics

Game-data file of Descent 2 (DESCENT2.HAM) and the sound archive that goes with it (DESCENT2.S11/.S22): HAM starts with the tag 'HAM!' and a version (HAMFILE_VERSION is 3 in Rebirth), then counted tables for textures, vclips, robots, weapons, polygon models and more; HXM/XHAM files extend robots.

HAM (Descent 2)

Read by Rebirth's read_hamfile (similar/main/piggy.cpp) and bm_read_all (similar/main/bm.cpp). All integers are little-endian int32 unless stated.

  1. int id must equal the tag bytes HAM! (MAKE_SIG('!','M','A','H') read little-endian), else the load fails with 'Failed to load ham file'.
  2. int version; Rebirth clamps it to the range 0..3 and only tests whether it is below 3. Comments in the source: version 1 to 2 added the marker model, 2 to 3 removed the sound files from the HAM.
  3. If version < 3 (the interactive PC demo and similar), an int sound_offset follows, and the sound archive is read from that file position at the end (the 20-byte sound headers of Format:PIG (Descent)).
  4. bm_read_all then reads, each table as a count followed by records: textures (count, int16 bitmap indices, tmap_info records), sounds (count, then two byte arrays Sounds and AltSounds), vclips, effect clips, wall clips, robot info, robot joints, weapons (record layout depends on the HAM version), powerups, polygon models (records followed by their model data), dying and dead model numbers, gauges (bitmap indices; the hires indices follow), object bitmaps with their pointers, the player ship, cockpits, the first multiplayer bitmap number, reactors, the marker model number and, only for version < 3, the two exit model numbers. The remaining body is a list of int16 bitmap translation values read until end of file.

Record sizes inside these tables were not summed here; use the Rebirth *_read functions.

Sound file (version 3 and later)

HAM version 3 or higher takes its sounds from descent2.s22 or descent2.s11 (22 kHz or 11 kHz depending on the sample-rate option): int id DSND (MAKE_SIG('D','N','S','D')), int version 1, int N_sounds, N_sounds 20-byte sound headers, then the sample data; a header's offset counts from the end of the header table.

HXM and extra HAM

Robot replacement files: an HXM file starts with the int 0x21584d48 (bytes HXM!) and a version that must be at least 1, then counted robot, joint, polygon model and object bitmap replacement tables. Extra-robot HAMs of missions of type descent2z (bm_read_extra_robots) start with XHAM and a version (the version value is read and ignored), then extra weapons, robots and joints appended to the base tables.

Unverified

Unverified: which HAM version numbers the retail Descent 2 files carry (the code only distinguishes below 3 from 3 and above); Descent 1 has no HAM, its game tables are inside the PIG.

Code & repositories

  • https://github.com/dxx-rebirth/dxx-rebirth @ 6943b924bea749543ef5729f31a28345e79716d2 · license: GPL-3.0-only (declared by the contributor; GitHub's detector did not recognize COPYING.txt)
    D1X-Rebirth/D2X-Rebirth source port of Descent 1 and 2: similar/main/piggy.cpp (PIG, HAM, sound files), similar/main/bm.cpp (game tables), d2x-rebirth/utilities/hogcreate.c and hogextract.c (HOG). Distributed under GPLv3 with a special exception for the original Parallax license (COPYING.txt); cite facts only.
    Tested on: source read, not run: source read at the cited commit, not run · checked 2026-10-19; last activity 2026-10-11