From f9f296f254fbd3140992b987d93462bfa44bfe6d Mon Sep 17 00:00:00 2001 From: jaby Date: Sun, 23 Oct 2022 13:58:34 +0200 Subject: [PATCH] Write more PVD values --- src/Tools/cdtypes/src/types/pvd.rs | 4 +-- .../src/iso_writer/psx/encoder/mod.rs | 3 ++- src/Tools/psxcdgen_ex/src/encoder/psx.rs | 25 +++++++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Tools/cdtypes/src/types/pvd.rs b/src/Tools/cdtypes/src/types/pvd.rs index 803033f8..cee78463 100644 --- a/src/Tools/cdtypes/src/types/pvd.rs +++ b/src/Tools/cdtypes/src/types/pvd.rs @@ -54,7 +54,7 @@ pub struct VolumeDescriptorTerminator { } impl PrimaryVolumeDescriptor { - pub fn psx_default() -> PrimaryVolumeDescriptor { + pub fn new() -> PrimaryVolumeDescriptor { PrimaryVolumeDescriptor{ volume_type: [1], std_id: ['C' as u8, 'D' as u8, '0' as u8, '0' as u8, '1' as u8], @@ -88,7 +88,7 @@ impl PrimaryVolumeDescriptor { file_struct_version: [1], reserved_4: [0], app_use_area: [0; 141], - 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], + cd_xa_id: [0;8], cd_xa_flags: [0; 2], cd_xa_startup_dir: [0; 8], cd_xa_reserved: [0; 8], diff --git a/src/Tools/psxcdgen/src/iso_writer/psx/encoder/mod.rs b/src/Tools/psxcdgen/src/iso_writer/psx/encoder/mod.rs index d6182563..c0d23901 100644 --- a/src/Tools/psxcdgen/src/iso_writer/psx/encoder/mod.rs +++ b/src/Tools/psxcdgen/src/iso_writer/psx/encoder/mod.rs @@ -123,7 +123,7 @@ pub fn write_pvd(mut desc: PVDDesc, sectors: &mut Vec, conte let sectors_size = sectors.len(); let now_date = Date::now(); - let mut raw_pvd = PrimaryVolumeDescriptor::psx_default(); + let mut raw_pvd = PrimaryVolumeDescriptor::new(); raw_pvd.system_id = AString::from_str("PLAYSTATION")?; if desc.volume_identifier.len() > 8 { @@ -135,6 +135,7 @@ pub fn write_pvd(mut desc: PVDDesc, sectors: &mut Vec, conte raw_pvd.app_id = AString::from_str("PLAYSTATION")?; raw_pvd.vol_create_time = now_date; raw_pvd.vol_space_size.write((sectors_size - 2) as u32); + raw_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_root_dir_record(&mut raw_pvd, content_layout.root_lba); write_path_table(&mut raw_pvd, content_layout.path_table); diff --git a/src/Tools/psxcdgen_ex/src/encoder/psx.rs b/src/Tools/psxcdgen_ex/src/encoder/psx.rs index 652b8cbc..cea6d7a7 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::{helper::sector_count_mode2_form1, pvd as cd_pvd}; +use cdtypes::types::{cdstring::{AString, DString}, date::Date, helper::sector_count_mode2_form1, pvd as cd_pvd}; const SYSTEM_AREA_SECTOR_COUNT:usize = 16; const PVD_SECTOR_COUNT:usize = 2; @@ -93,15 +93,36 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit } fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> { + const PLAYSATATION_STR:&'static str = "PLAYSTATION"; let path_table = path_table.borrow(); if pvd.track_rel_lba != 16 { return Err(Error::from_text(format!("PVD required to start at sector 16 of Track - found LBA: {}", pvd.track_rel_lba))); } - let mut cd_pvd = cd_pvd::PrimaryVolumeDescriptor::psx_default(); + let mut cd_pvd = cd_pvd::PrimaryVolumeDescriptor::new(); + let now = Date::now(); //Config pvd here + cd_pvd.system_id = AString::from_str(PLAYSATATION_STR)?; + cd_pvd.volume_id = DString::from_str("PSX")?; + &cd_pvd.vol_space_size; + + &cd_pvd.path_table_size; + &cd_pvd.path_table_1; + &cd_pvd.path_table_2; + &cd_pvd.path_table_3; + &cd_pvd.path_table_4; + + &cd_pvd.root_dir_record; + + &cd_pvd.publisher_id; //< Company name + &cd_pvd.data_preparer; + cd_pvd.app_id = AString::from_str(PLAYSATATION_STR)?; + + cd_pvd.vol_create_time = now; + + 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]; 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())))?;