Compare commits

..

No commits in common. "c81348fb10cdc074b1aa112252cf351759ab2f55" and "1cca6005050fd7cb8d64c8f7d7719d78d7f3ebe2" have entirely different histories.

4 changed files with 18 additions and 24 deletions

2
.gitignore vendored
View file

@ -1,3 +1 @@
/target
exported_symbols.txt
patchData.json

8
Cargo.lock generated
View file

@ -13,7 +13,7 @@ name = "bin_comp"
version = "0.1.0"
dependencies = [
"anyhow",
"enemize",
"serde",
"serde_json",
"tempfile",
]
@ -31,12 +31,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "enemize"
name = "enemize-rs"
version = "0.1.0"
dependencies = [
"anyhow",
"serde",
"serde_json",
"md5",
]
[[package]]

View file

@ -1,11 +1,9 @@
[package]
name = "enemize"
name = "enemize-rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde = { version = 1.0, features = ["derive"] }

View file

@ -1,40 +1,40 @@
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use serde::Serialize;
pub mod rom;
#[derive(Deserialize, Serialize)]
#[derive(Serialize)]
pub struct Patch {
pub address: usize,
pub patch_data: Vec<u8>,
}
#[derive(Deserialize, Serialize)]
#[derive(Serialize)]
pub struct PatchSet {
filename: PathBuf,
patches: Vec<Patch>,
patches: Vec<Patch>
}
impl PatchSet {
pub fn load(filename: &Path) -> Result<PatchSet, anyhow::Error> {
pub fn load(filename: Path) -> Result<PatchSet, anyhow::Error> {
let patches = {
let file = File::open(filename)?;
let buffer = std::io::BufReader::new(file);
let mut file = File::open(filename)?;
let mut buffer = std::io::BufReader::new(file);
serde_json::from_reader(buffer)?
};
Ok(PatchSet {
PatchSet {
filename: filename.into(),
patches: patches,
})
patches: patches
}
}
pub fn filename(&self) -> &Path {
pub fn filename(&self) -> Path {
self.filename.as_path()
}
pub fn patch_rom(self, rom: &mut RomData) {
pub fn patchRom(&self, &mut rom: RomData) {
for patch in self.patches {
rom.patch_data(patch);
}