Compare commits
No commits in common. "c81348fb10cdc074b1aa112252cf351759ab2f55" and "1cca6005050fd7cb8d64c8f7d7719d78d7f3ebe2" have entirely different histories.
c81348fb10
...
1cca600505
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1 @@
|
||||||
/target
|
/target
|
||||||
exported_symbols.txt
|
|
||||||
patchData.json
|
|
||||||
|
|
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -13,7 +13,7 @@ name = "bin_comp"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"enemize",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
@ -31,12 +31,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "enemize"
|
name = "enemize-rs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"md5",
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "enemize"
|
name = "enemize-rs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
serde = { version = 1.0, features = ["derive"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
serde_json = "1.0"
|
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
use std::fs::File;
|
use std::io::Read;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
|
||||||
pub mod rom;
|
pub mod rom;
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct Patch {
|
pub struct Patch {
|
||||||
pub address: usize,
|
pub address: usize,
|
||||||
pub patch_data: Vec<u8>,
|
pub patch_data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct PatchSet {
|
pub struct PatchSet {
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
patches: Vec<Patch>,
|
patches: Vec<Patch>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PatchSet {
|
impl PatchSet {
|
||||||
pub fn load(filename: &Path) -> Result<PatchSet, anyhow::Error> {
|
pub fn load(filename: Path) -> Result<PatchSet, anyhow::Error> {
|
||||||
let patches = {
|
let patches = {
|
||||||
let file = File::open(filename)?;
|
let mut file = File::open(filename)?;
|
||||||
let buffer = std::io::BufReader::new(file);
|
let mut buffer = std::io::BufReader::new(file);
|
||||||
serde_json::from_reader(buffer)?
|
serde_json::from_reader(buffer)?
|
||||||
};
|
};
|
||||||
Ok(PatchSet {
|
PatchSet {
|
||||||
filename: filename.into(),
|
filename: filename.into(),
|
||||||
patches: patches,
|
patches: patches
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filename(&self) -> &Path {
|
pub fn filename(&self) -> Path {
|
||||||
self.filename.as_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 {
|
for patch in self.patches {
|
||||||
rom.patch_data(patch);
|
rom.patch_data(patch);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue