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:Enigma (Sega Mega Drive)

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

Tilemap compression of Sega Mega Drive games: a 6-byte header (packet length, flag mask, incrementing and common 16-bit words) followed by a bit stream of run/copy packets, ended by a 7-bit pattern with count 15.

Overview

Enigma compresses 16-bit nametable (tilemap) words. It is not related to the Enigma Protector (Tool:Enigma Protector). Decoded from mdcomp's src/lib/enigma.cc (LGPL-3.0).

Stream

  • Header: byte packet length (bits per tile index), byte flag mask (which of the 5 high attribute bits are stored per tile), big-endian 16-bit incrementing start value, big-endian 16-bit common value.
  • Bit stream: first bit 0 = run of incrementing or common words: next bit 0 = incrementing from the running value, 1 = repeat the common value, 4-bit count + 1. First bit 1 = 2-bit mode: 0, 1, 2 = repeat a word read from the stream with delta 0, +1, -1 (4-bit count + 1); mode 3 = 4-bit count n, then n + 1 individually coded words; n = 15 ends the stream. See Fact:Enigma (Sega Mega Drive)/behavior/Packet coding.

Code & repositories

  • https://github.com/flamewing/mdcomp @ 72c6df405a75d322c5b3722da46c3abb864d3793 · license: LGPL-3.0-or-later (declared by the contributor; GitHub's detector did not recognize COPYING)
    Sega Mega Drive compression library and tools (Kosinski, Kosinski+, Nemesis, Enigma, Comper, Saxman, LZKN1 ...), LGPL-3.0-or-later.
    Tested on: source read, not run: source read · checked 2026-10-18; last activity 2026-10-11; Note: the latest release ships binaries; the wiki links only the source, never the binaries

See also

Format:Kosinski, Format:Nemesis (Sega Mega Drive)