Pass lba calculation function as function

This commit is contained in:
jaby 2022-11-08 22:19:43 +01:00
parent 2e111ef6d0
commit 3995b95402
2 changed files with 6 additions and 5 deletions

View File

@ -5,14 +5,15 @@ pub mod encoder;
pub mod file_writer;
pub mod types;
use encoder::psx::calculate_psx_lbas;
use tool_helper::read_file;
use types::CDDesc;
pub fn process(config: config_reader::Configuration) -> Result<CDDesc, Error> {
pub type CalculateLBAFunction = fn(&mut types::CDDesc);
pub fn process(config: config_reader::Configuration, calculate_lba: CalculateLBAFunction) -> Result<CDDesc, Error> {
let mut cd_desc = parse_configuration(config)?;
calculate_psx_lbas(&mut cd_desc);
calculate_lba(&mut cd_desc);
Ok(cd_desc)
}

View File

@ -1,9 +1,9 @@
use psxcdgen_ex::{encoder::psx::encode_psx_image, file_writer::{ImageType, write_image}, types::{layout::Layout}, config_reader};
use psxcdgen_ex::{encoder::psx::{encode_psx_image, calculate_psx_lbas}, file_writer::{ImageType, write_image}, types::{layout::Layout}, config_reader};
use std::{path::PathBuf, str::FromStr};
use tool_helper::Error;
fn run_main() -> Result<(), Error> {
let desc = psxcdgen_ex::process(config_reader::parse_xml(std::fs::read_to_string("../Tests/ISO_Planschbecken.xml")?)?)?;
let desc = psxcdgen_ex::process(config_reader::parse_xml(std::fs::read_to_string("../Tests/ISO_Planschbecken.xml")?)?, calculate_psx_lbas)?;
println!("\n<== Planschbecken ==>");
for element in desc.get_memory_layout().iter() {