#sega #cmp #format #was #header #created

sega_cmp

Library to compress data using Sega's CMP format

2 unstable releases

Uses old Rust 2015

0.2.0 Feb 17, 2018
0.1.0 Feb 17, 2018

#652 in Compression

44 downloads per month

LGPL-3.0

27KB
495 lines

sega_cmp

This Rust crate provides an implementation of Sega's CMP run-length encoding compression format. This format was created by Sega, and used in many Saturn games by Sega and third parties. This library aims to provide a 100%-compatible compressor able to be used to replace data in retail Saturn games.

This crate embeds C code written by @MrConan1.

Contributing

  1. Fork the repository
  2. Create a new branch
  3. Commit your changes
  4. Open a pull request
  5. 🎉

Bugs and support

Please report any issues on this repository's issue tracker. I'll try to do whatever I can to help!


lib.rs:

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.

Dependencies

~210KB