diff --git a/src/Tools/psxcdgen_ex/planschi.bin b/src/Tools/psxcdgen_ex/planschi.bin index b1b2e1f5..68935bb1 100644 Binary files a/src/Tools/psxcdgen_ex/planschi.bin and b/src/Tools/psxcdgen_ex/planschi.bin differ diff --git a/src/Tools/psxcdgen_ex/src/encoder/psx.rs b/src/Tools/psxcdgen_ex/src/encoder/psx.rs index f7589870..683fc192 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/psx.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/psx.rs @@ -1,7 +1,7 @@ use super::{*, Sector, SectorWriter, {CDDesc, Error}}; use super::super::types::{layout::Layout, *}; use builder::SubModeBuilder; -use cdtypes::types::{cdstring::{AString, DString}, date::Date, helper::sector_count_mode2_form1, pvd as cd_pvd, lsb_msb::*, sector::Mode2Form1}; +use cdtypes::types::{cdstring::{AString, DString}, date::*, dir_record::DirectoryRecord, helper::sector_count_mode2_form1, pvd as cd_pvd, lsb_msb::*, sector::Mode2Form1}; const SYSTEM_AREA_SECTOR_COUNT:usize = 16; const PVD_SECTOR_COUNT:usize = 2; @@ -76,7 +76,7 @@ pub fn encode_psx_image(cd_desc: CDDesc, sec_writer: &mut dyn SectorWriter) -> R for element in cd_desc.get_memory_layout() { match element { Layout::SystemArea(system_area) => process_system_area(&system_area.borrow(), sec_writer)?, - Layout::PVD(pvd) => process_pvd(&pvd.borrow(), cd_desc.path_table.clone(), sec_writer, vol_sector_count)?, + Layout::PVD(pvd) => process_pvd(&pvd.borrow(), cd_desc.path_table.clone(), cd_desc.root.clone(), vol_sector_count, sec_writer)?, _ => () } } @@ -97,10 +97,11 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit Ok(()) } -fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr, sec_writer: &mut dyn SectorWriter, vol_sector_count: usize) -> Result<(), Error> { +fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr, root_dir: SharedPtr, vol_sector_count: usize, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> { const PLAYSATATION_STR:&'static str = "PLAYSTATION"; let path_table = validate_path_table(&path_table)?; + let root_dir = root_dir.borrow(); let pvd_lba = pvd.track_rel_lba; if pvd_lba != 16 { @@ -116,14 +117,22 @@ fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr, cd_pvd.volume_id = DString::from_str("PSX")?; cd_pvd.vol_space_size.write(vol_sector_count as u32); + //Set PathTable values cd_pvd.path_table_size.write(path_table.size_bytes as u32); cd_pvd.path_table_1.write(path_table.get_track_rel_lba_for(1, sector_count_mode2_form1) as u32); cd_pvd.path_table_2.write(path_table.get_track_rel_lba_for(2, sector_count_mode2_form1) as u32); cd_pvd.path_table_3.write(path_table.get_track_rel_lba_for(3, sector_count_mode2_form1) as u32); cd_pvd.path_table_4.write(path_table.get_track_rel_lba_for(4, sector_count_mode2_form1) as u32); - &cd_pvd.root_dir_record; - + //Set Root Directory Record + let root_dir_record = unsafe{std::mem::transmute::<&mut [u8; 34], &mut DirectoryRecord>(&mut cd_pvd.root_dir_record)}; + unsafe{root_dir_record.new("\x00", false)}; + root_dir_record.data_block_number.write(root_dir.properties.track_rel_lba as u32); + root_dir_record.data_size.write(root_dir.get_size() as u32); + root_dir_record.time_stamp = SmallDate::now(); + root_dir_record.set_directory(); + + //Set other stuff cd_pvd.publisher_id = AString::from_str(pvd.publisher.as_str())?; cd_pvd.data_preparer = AString::from_str("JABYENGINE PSXCDGEN_EX")?; cd_pvd.app_id = AString::from_str(PLAYSATATION_STR)?; @@ -132,6 +141,7 @@ fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr, cd_pvd.cd_xa_id = ['C' as u8, 'D' as u8, '-' as u8, 'X' as u8, 'A' as u8, '0' as u8, '0' as u8, '1' as u8]; + //Write PVD and VDT sec_writer.write(Sector::CDXAData(builder::create_xa_data_for(SubModeBuilder::new_mode1().set_eor().create(), &cd_pvd)))?; sec_writer.write(Sector::CDXAData(builder::create_xa_data_for(SubModeBuilder::new_mode1().set_eor().set_eof().create(), &cd_pvd::VolumeDescriptorTerminator::new())))?; Ok(())