From 045b9d5c48cb1bcbfb2151ce5e72a5ed857aeea1 Mon Sep 17 00:00:00 2001 From: Jaby Date: Mon, 10 Oct 2022 20:50:20 +0200 Subject: [PATCH] Add SystemArea and PVD --- src/Tools/psxcdgen_ex/src/main.rs | 2 ++ src/Tools/psxcdgen_ex/src/types/layout.rs | 5 ++++ src/Tools/psxcdgen_ex/src/types/mod.rs | 28 +++++++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Tools/psxcdgen_ex/src/main.rs b/src/Tools/psxcdgen_ex/src/main.rs index 51ccb58c..8670e29c 100644 --- a/src/Tools/psxcdgen_ex/src/main.rs +++ b/src/Tools/psxcdgen_ex/src/main.rs @@ -31,6 +31,8 @@ fn run_main() -> Result<(), Error> { for element in desc.get_memory_layout().iter() { match element { + Layout::SystemArea(_) => println!("SystemArea:"), + Layout::PVD(_) => println!("PVD:"), Layout::Directory{name, properties: _} => println!("Dir: {}", name), Layout::Data(data) => println!("File: {}", data), } diff --git a/src/Tools/psxcdgen_ex/src/types/layout.rs b/src/Tools/psxcdgen_ex/src/types/layout.rs index 996fa119..fa9c31f2 100644 --- a/src/Tools/psxcdgen_ex/src/types/layout.rs +++ b/src/Tools/psxcdgen_ex/src/types/layout.rs @@ -18,12 +18,17 @@ macro_rules! declare_memory_layout { pub fn new(parent: &$($val),* CDDesc) -> Vec<[< Layout$($val:camel),* >]> { let mut layout = Vec::new(); + layout.push([< Layout$($val:camel),* >]::SystemArea(&$($val),* parent.system_area)); + layout.push([< Layout$($val:camel),* >]::PVD(&$($val),* parent.pvd)); + [< add_dir_and_subdir $(_$val),* >](&mut layout, &$($val),* parent.root); layout } } pub enum [< Layout$($val:camel),* >]<'a> { + SystemArea(&'a $($val),* SystemArea), + PVD(&'a $($val),* PrimaryVolumeDescriptor), Directory{name: &'a $($val),* DirectoryName, properties: &'a $($val),* Properties}, Data(&'a $($val),* Data) } diff --git a/src/Tools/psxcdgen_ex/src/types/mod.rs b/src/Tools/psxcdgen_ex/src/types/mod.rs index a8bff649..d1b5cb33 100644 --- a/src/Tools/psxcdgen_ex/src/types/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/mod.rs @@ -4,13 +4,15 @@ use cdtypes::types::cdstring::DString; use tool_helper::Error; pub struct CDDesc { - pub root: Directory + system_area: SystemArea, + pvd: PrimaryVolumeDescriptor, + pub root: Directory } impl CDDesc { pub fn new() -> CDDesc { match Directory::new("root") { - Ok(root) => CDDesc{root}, + Ok(root) => CDDesc{system_area: SystemArea::new(), pvd: PrimaryVolumeDescriptor::new(), root}, Err(error) => panic!("Creating root directory failed with: {}", error) } } @@ -24,6 +26,24 @@ impl CDDesc { } } +pub struct SystemArea { +} + +impl SystemArea { + pub fn new() -> SystemArea { + SystemArea{} + } +} + +pub struct PrimaryVolumeDescriptor { +} + +impl PrimaryVolumeDescriptor { + pub fn new() -> PrimaryVolumeDescriptor { + PrimaryVolumeDescriptor{} + } +} + pub struct Directory { name: DirectoryName, properties: Properties, @@ -121,12 +141,12 @@ impl std::fmt::Display for FileName { pub struct Properties { pub lba: Option, - pub length: Option + pub size_b: Option } impl Default for Properties { fn default() -> Self { - Properties{lba: None, length: None} + Properties{lba: None, size_b: None} } }