Skip to main content

unpacking crunch-mania files from the Amiga days

Project description

📦 crunchmania

A Python decompressor for Crunch-Mania files from the Amiga era.

The format

Crunch-Mania was a file cruncher for the Commodore Amiga, written by Thomas Schwarz and released between 1989 and 1994. It was designed for in-place decompression: the compressed data is read backward and the output is written backward, so a file can be decompressed into the same memory it occupies.

There are four format variants, identified by a 4-byte magic at offset 0:

Magic Mode Delta Description
CrM! Standard No Fixed Huffman + VLC
CrM2 LZH No Dynamic Huffman per block
Crm! Standard Yes Standard + delta encoding
Crm2 LZH Yes LZH + delta encoding

The lowercase m variants apply a cumulative byte delta as a post-processing step, used for sample data where adjacent bytes tend to have similar values.

Several Amiga demos and games used obfuscated copies of the format with different magic bytes (Iron, DCS!, MSS!, etc). These are detected and handled transparently.

The 14-byte header is followed by the packed data stream, which is read from the end toward the start using an LSB-first bit reader initialized from the last 6 bytes of the packed block.

Installation

pip install crunchmania

CLI usage

# Show file info
crunchmania info packed_file.crm

# Decompress a file
crunchmania unpack packed_file.crm output_file

# Scan a file for embedded CrM blocks
crunchmania scan amiga_disk.adf

Library usage

from crunchmania import unpack, parse_header

data = open("packed_file.crm", "rb").read()

# Inspect the header
header = parse_header(data)
print(f"{header.magic!r}, {header.packed_size} -> {header.unpacked_size}")

# Decompress
output = unpack(data)

License

WTFPL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crunchmania-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crunchmania-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file crunchmania-0.1.0.tar.gz.

File metadata

  • Download URL: crunchmania-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for crunchmania-0.1.0.tar.gz
Algorithm Hash digest
SHA256 69c878bea9bcb92a77a550f861ab535ea5eeb1721fdc1bcbddf3b722b47a9261
MD5 3c32d74b22202527b3f95c6ef9279d92
BLAKE2b-256 1694eec64d35eabe1123f0c48dc12ee6b906c40d2d67c38388acf95091204fec

See more details on using hashes here.

File details

Details for the file crunchmania-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crunchmania-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for crunchmania-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68beeb4532d2817d789a053a507129c9213a10934b8d2a0739a50fccb7209fc8
MD5 b9f55564e91fc28c1f2461ed82e15d4a
BLAKE2b-256 042aafa20c6771a27f6332facd9fc72bf79624708b8c01fa69c1fa6de1a44b03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page