#sega #modding #prs #encoder #game #lz77 #encoding

ages-prs

Compression and decompression of PRS, SEGA's LZ77 encoding

1 unstable release

0.1.0 Feb 29, 2020

#730 in Compression


Used in ages-ice-archive

MIT/Apache

22KB
421 lines

ages-prs: PRS de/compression for Rust

Build Status Crate API

IO types for compressing and decompressing PRS encoded buffers.

PRS is an LZ77 encoding used by several games made published by SEGA. It is mostly used for compressing game assets e.g. textures and game data, and occasionally used for message compression in network games' application protocols.

The API surface is intentionally minimal. The underlying LZ77 implementation is not exposed; currently, this crate uses libflate's LZ77 encoder.

This crate should work out-of-the-box when targeting WebAssembly, though it is not tested yet.

Usage

Add to your Cargo.toml:

[dependencies]
ages-prs = "0.1"

Within your code:

use std::io::{self, Cursor, Read};
use ages_prs::LegacyPrsDecoder;

// unitxt_j.prs contains localized strings used in Phantasy Star Online's UI.
// PSO uses "legacy" variant PRS.

fn decompress_unitxt() -> io::Result<Vec<u8>> {
    let mut data = Vec::with_capacity(2048);
    let file = File::open("unitxt_js.prs")?;
    let mut decoder = LegacyPrsDecoder::new(file);

    decoder.read_to_end(&mut data)?;

    Ok(data)
}

Games supported

For the "Legacy" variant:

  • Phantasy Star Online (all versions)
  • Sonic Adventure
  • Sonic Adventure 2

For the "Modern" variant:

  • Phantasy Star Universe
  • Phantasy Star Online 2

These lists are not comprehensive. SEGA has used PRS in many games since as early as the SEGA Saturn, and it has received various alterations over the years.

License

ages-prs is dual-licensed for compatibility with the rest of the Rust public ecosystem.

ages-prs is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Dependencies