1 unstable release

0.1.0 Feb 8, 2020

#5 in #truncation

MIT/Apache

5KB
77 lines

Parser for the IPS patch format.

Handles run-length encoded hunks as well as the truncation extension.

Example

Patching a ROM from an IPS file:

use std::fs::{self, File};
use std::io::{Seek, SeekFrom, Write};

use ips::Patch;

let mut rom = File::open("Super Metroid.sfc")?;
let patch_contents = fs::read("Hyper Metroid.ips")?;
let patch = Patch::parse(&patch_contents)?;

for hunk in patch.hunks() {
    rom.seek(SeekFrom::Start(hunk.offset() as u64))?;
    rom.write_all(hunk.payload())?;
}

if let Some(truncation) = patch.truncation() {
    rom.set_len(truncation as u64)?;
}

Dependencies

~1MB
~20K SLoC