Crates.io | ages-prs |
lib.rs | ages-prs |
version | 0.1.0 |
source | src |
created_at | 2020-02-29 18:03:20.610619 |
updated_at | 2020-02-29 18:03:20.610619 |
description | Compression and decompression of PRS, SEGA's LZ77 encoding. |
homepage | |
repository | https://github.com/HybridEidolon/rust-ages-prs |
max_upload_size | |
id | 213832 |
size | 43,945 |
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.
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)
}
For the "Legacy" variant:
For the "Modern" variant:
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.
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.