Skip to content

Commit

Permalink
Update to use the now-updated ultimate-research/motion_list_rs (#446)
Browse files Browse the repository at this point in the history
* Patch motion_list.bin files on discovery

You can generate a motion_list.motdiff file using `yamlist diff [source file] [modded file] -o motion_list.motdiff`

* Cleanup

* update motion_lib dependency

* Fixed println
  • Loading branch information
WuBoytH authored Nov 1, 2022
1 parent e523252 commit 47c6c50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ msbt = { git = "https://github.com/RoccoDev/msbt-rs", branch = "feature/builder-
# For patch3audio
nus3audio = "1.2.0"
# For motion list patching
motion_list_rs = { git = "https://github.com/WuBoytH/motion_lib", branch = "motion-lib-only" }
motion_list_rs = "1.4.3"
serde_yaml = "0.8"
# For inputs
ninput = { git = "https://github.com/blu-dev/ninput" }
Expand Down
8 changes: 5 additions & 3 deletions src/fs/loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl ApiLoadType {
}

pub fn load_path(self, local: &Path, usr_fn: ApiCallback) -> Result<(usize, Vec<u8>), ApiLoaderError> {
println!("[ARCropolis::loader] Patching {:#?}", local.as_os_str());
match self {
ApiLoadType::Nus3bankPatch => {
let data = ApiLoader::handle_load_vanilla_file(local)?;
Expand Down Expand Up @@ -304,23 +305,24 @@ impl ApiLoadType {
};

let data = ApiLoader::handle_load_base_file(local)?;
let mut reader = std::io::Cursor::new(data);

let mut motion = motion_lib::disasm::disassemble(&mut std::io::Cursor::new(data))?;
let mut motion = motion_lib::read_stream(&mut reader)?;

for patch_path in patches.iter() {
let mut contents: String = String::default();
std::fs::File::open(patch_path)?.read_to_string(&mut contents)?;
if let Some(diff) = from_str(&contents)? {
println!("[ARCropolis::loader] Patching Motion List");
motion.apply(&diff);
}
else {
return Err(ApiLoaderError::Other("This isn't a motion list patch file!".to_string()));
}
}
println!("[ARCropolis::loader] Motion List Patching finished, writing to file...");
let new_data : Vec<u8> = Vec::new();
let mut cursor = std::io::Cursor::new(new_data);
motion_lib::asm::assemble(&mut cursor, &motion)?;
motion_lib::write_stream(&mut cursor, &motion)?;
let vec = cursor.into_inner();
Ok((vec.len(), vec))
}
Expand Down

0 comments on commit 47c6c50

Please sign in to comment.