sega_cmp 0.2.0

Library to compress data using Sega's CMP format
Documentation
  • Coverage
  • 87.5%
    7 out of 8 items documented0 out of 4 items with examples
  • Size
  • Source code size: 28.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 401.56 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • studio-lucia/sega_cmp
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mistydemeo

This crate provides support for compressing files using Sega's CMP run-length encoding scheme, which was used in games for the Sega Saturn game console.

Run-length encoding is a simple kind of compression which works by analyzing data for repetitive sequences of data (or "runs"); any repeating sequences can be replaced by commands to repeat X data N times.

For example, imagine the text AAAAAAAABBBBAABA. If you described it in terms of patterns, you could think of it as being 8A4B2A1B1A - which takes up 10 bytes instead of 16.

Sega included CMP in the official Saturn SDK; they provided a closed-source commandline tool to compress data and source code to do compression from within games. As a result, many games used it for data with lots of repetitive content such as text and graphics. This crate's CMP implementation aims to be 100% compatible with the original decoder; it produces identical compressed data to the original encoder. Its output has been tested to work in commercial Saturn games which use CMP.

This crate provides two basic functions: the header-generating create_header, and the data-creating compress. Most Saturn games store both in the same place, with the header followed immedaitely by the compressed data.