diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index 535574fc..725c3e02 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -3,7 +3,7 @@ Jaby %PSX_LICENSE_PATH%/%PSX_LICENSE%.DAT - + System.cnf.subst ../application/bin/%PSX_TV_FORMAT%/PSX-release/PoolBox.psexe @@ -37,12 +37,5 @@ ../assets/bin/Evacuation.xa - - - ../assets/bin/fox.xa - ../assets/bin/fox.xa - ../assets/bin/fox.xa - ../assets/bin/fox.xa - \ No newline at end of file diff --git a/src/Tools/cdtypes/Cargo.toml b/src/Tools/cdtypes/Cargo.toml index 7a9d7b6c..8ade8d47 100644 --- a/src/Tools/cdtypes/Cargo.toml +++ b/src/Tools/cdtypes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cdtypes" -version = "0.7.0" +version = "0.7.1" edition = "2021" [profile.release] diff --git a/src/Tools/cdtypes/src/types/sector.rs b/src/Tools/cdtypes/src/types/sector.rs index c5bee669..6c02a707 100644 --- a/src/Tools/cdtypes/src/types/sector.rs +++ b/src/Tools/cdtypes/src/types/sector.rs @@ -332,10 +332,12 @@ impl Audio { pub struct Mode0 { pub sync: Sync, pub header: Header, - pub zero: [u8;2336] + pub zero: [u8;Mode0::DATA_SIZE] } impl Mode0 { + pub const DATA_SIZE:usize = 2336; + pub fn new() -> Mode0 { Mode0{sync: Sync::new(), header: Header::new(0), zero: [0; 2336]} } diff --git a/src/Tools/psxcdgen_ex/Cargo.toml b/src/Tools/psxcdgen_ex/Cargo.toml index f4f11e57..1f7d6707 100644 --- a/src/Tools/psxcdgen_ex/Cargo.toml +++ b/src/Tools/psxcdgen_ex/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "psxcdgen_ex" -version = "0.5.0" +version = "0.6.0" edition = "2021" [profile.release] diff --git a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs index 32e25fe4..7571922b 100644 --- a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs +++ b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs @@ -41,7 +41,7 @@ fn parse_iso_project(iso_project: roxmltree::Node, config: &mut Configuration) - } else { - print_warning("Found more than 1 track. Track will be ignored".to_owned()); + print_warning("Found more than 1 track. Multi-Tracks are not supported yet. Track will be ignored".to_owned()); Ok(()) } }, diff --git a/src/Tools/psxcdgen_ex/src/encoder/builder.rs b/src/Tools/psxcdgen_ex/src/encoder/builder.rs index 4c4b7ccb..c6a3c33d 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/builder.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/builder.rs @@ -165,6 +165,10 @@ pub fn create_xa_audio_for(data: &Vec) -> Vec { sectors } +pub fn create_mode0_zero() -> Mode0 { + Mode0::new() +} + pub fn create_xa_data_zero() -> Mode2Form1 { create_xa_data_for_raw(SubMode::default_form1(), &[0u8; Mode2Form1::DATA_SIZE]) } diff --git a/src/Tools/psxcdgen_ex/src/encoder/cd.rs b/src/Tools/psxcdgen_ex/src/encoder/cd.rs index 48f57748..90e0f5a0 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/cd.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/cd.rs @@ -8,7 +8,7 @@ use std::io::{Read, Seek, SeekFrom}; const ROOT_DIR_NAME:&'static str = "\x00"; pub mod length_of { - use cdtypes::types::helper::{sector_count_mode2_form1, sector_count_mode2_form2}; + use cdtypes::types::{sector::Mode0, helper::{sector_count_mode2_form1, sector_count_mode2_form2}}; use crate::types::FileType; use super::{Directory, File, LengthInfo, PathTable}; @@ -46,6 +46,10 @@ pub mod length_of { LengthInfo{bytes: Some(fake_size), sectors: sector_count_mode2_form1(fake_size)} } } + + pub fn lead_out(sectors: usize) -> LengthInfo { + LengthInfo{bytes: Some(sectors*Mode0::DATA_SIZE), sectors} + } } pub fn calculate_length_for(element: &Layout) -> LengthInfo { @@ -133,6 +137,7 @@ pub fn encode_image(cd_desc: &CDDesc, sec_writer: &mut dyn SectorWriter) -> Resu } } + process_lead_out(cd_desc.lead_out_sectors, sec_writer)?; process_end_dummy_section(cd_desc.end_dummy_padding, sec_writer)?; process_cd_da(&cd_desc.cd_da_tracks, sec_writer) } @@ -387,6 +392,13 @@ fn write_dummy(sec_writer: &mut dyn SectorWriter, sectors: usize) -> Result<(), Ok(()) } +fn process_lead_out(sectors: usize, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> { + for _ in 0..sectors { + sec_writer.write_empty(builder::create_mode0_zero())?; + } + Ok(()) +} + fn process_end_dummy_section(padding: usize, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> { write_dummy(sec_writer, sector_count_mode2_form1(padding)) } diff --git a/src/Tools/psxcdgen_ex/src/lib.rs b/src/Tools/psxcdgen_ex/src/lib.rs index 8b1dd915..adc7134f 100644 --- a/src/Tools/psxcdgen_ex/src/lib.rs +++ b/src/Tools/psxcdgen_ex/src/lib.rs @@ -263,5 +263,7 @@ fn parse_configuration(config: config_reader::Configuration) -> Result<(CDDesc, parse_dir(&mut cd_desc.root.borrow_mut(), config.root, &mut lba_embedded_files)?; parse_cd_da(&mut cd_desc.cd_da_tracks, config.cd_audio_files)?; + + cd_desc.lead_out_sectors = config.lead_out_sectors.unwrap_or(0); Ok((cd_desc, lba_embedded_files)) } diff --git a/src/Tools/psxcdgen_ex/src/main.rs b/src/Tools/psxcdgen_ex/src/main.rs index 82609fef..13e63f9c 100644 --- a/src/Tools/psxcdgen_ex/src/main.rs +++ b/src/Tools/psxcdgen_ex/src/main.rs @@ -29,10 +29,14 @@ fn run_main(cmd_line: CommandLine) -> Result<(), Error> { let content_size = desc.get_content_size(); if content_size < PKG_MINIMUM_CONTENT_SIZE { let missing_size = PKG_MINIMUM_CONTENT_SIZE - content_size; - desc.set_end_padding(missing_size); + desc.end_dummy_padding = missing_size; tool_helper::print_warning(format!("Content size {}b smaller then {}b.\nCD will be padded with {}b to work as a .pkg", content_size, PKG_MINIMUM_CONTENT_SIZE, missing_size)); } + if desc.lead_out_sectors == 0 { + tool_helper::print_warning(format!("Consider adding a 2 second lead-out to your track (Add attribute 'lead-out=\"0:2:0\"' to your Track) for supporting the PS3")); + } + write_image(&desc, cmd_line.output_type, cmd_line.output_file)?; if let Some(list_content_option) = cmd_line.list_content { diff --git a/src/Tools/psxcdgen_ex/src/types/mod.rs b/src/Tools/psxcdgen_ex/src/types/mod.rs index b1ecbfb5..74f2cf3f 100644 --- a/src/Tools/psxcdgen_ex/src/types/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/mod.rs @@ -9,7 +9,7 @@ use std::{cell::RefCell, path::PathBuf, rc::Rc}; pub use file_map::FileSystemMap; pub use tool_helper::Error; -use crate::types::helper::InterleavedXASizes; +use crate::{encoder::cd, types::helper::InterleavedXASizes}; pub type SharedPtr = Rc>; pub type RawData = Vec; @@ -24,8 +24,8 @@ pub struct CDDesc { pub(super) root: SharedPtr, pub(super) cd_da_tracks: Vec>, pub(super) vol_sector_count: usize, - pub(super) lead_out_sectors: Option, - pub(super) end_dummy_padding: usize + pub lead_out_sectors: usize, + pub end_dummy_padding: usize } impl CDDesc { @@ -38,7 +38,7 @@ impl CDDesc { root: new_shared_ptr(root), cd_da_tracks: Vec::new(), vol_sector_count: 0, - lead_out_sectors: None, + lead_out_sectors: 0, end_dummy_padding: 0 }, Err(error) => panic!("Creating root directory failed with: {}", error) @@ -57,10 +57,6 @@ impl CDDesc { self.root.borrow_mut().add_file(file); } - pub fn set_end_padding(&mut self, padding: usize) { - self.end_dummy_padding = padding - } - pub fn create_file_map(&self) -> FileSystemMap { file_map::new_file_map(&self.root.borrow()) } @@ -75,6 +71,7 @@ impl CDDesc { } }); + size += cd::length_of::lead_out(self.lead_out_sectors).bytes.unwrap_or(0); size }