Skip to main content

packing/unpacking crunch-mania files from the Amiga days

Project description

📦 crunchmania

pic

A Python compressor/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.2.0.tar.gz (9.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.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crunchmania-0.2.0.tar.gz
  • Upload date:
  • Size: 9.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.2.0.tar.gz
Algorithm Hash digest
SHA256 6bb6a1858f659d5dbab1eceae1de28b30e8d260b4dadabf8fc46ddd58f40f15e
MD5 1167179c26a0acffbdc88a881d56884d
BLAKE2b-256 d4c83d740707d9d432055355f118ef0bb0158033e8041aaa004ae2d6e5446323

See more details on using hashes here.

File details

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

File metadata

  • Download URL: crunchmania-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47f8b04ccdfbed3799498d4af26617d00331a210a55db330a90fbe3e4aaa5ac4
MD5 a1d836abf6f8874c760d61f77238c391
BLAKE2b-256 545eb13924cbba6c7da701fb7ebce53e3dc7682020c1b559a22a39f58e912c6b

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