Compare commits

...

2 commits

Author SHA1 Message Date
Lyle Mantooth c81348fb10
Fix up compiler issues. 2022-05-24 22:53:15 -04:00
Lyle Mantooth 5f8f1b5655
Ignore generated files. 2022-05-24 22:49:58 -04:00
4 changed files with 24 additions and 18 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/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",
"serde",
"enemize",
"serde_json",
"tempfile",
]
@ -31,10 +31,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "enemize-rs"
name = "enemize"
version = "0.1.0"
dependencies = [
"md5",
"anyhow",
"serde",
"serde_json",
]
[[package]]

View file

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

View file

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