From 54f2b43b4fa8b11ee122640042b8bd5c14ba32f9 Mon Sep 17 00:00:00 2001 From: jaby Date: Thu, 15 Aug 2024 15:05:48 -0500 Subject: [PATCH] Replace License Logo with TMD but results are bad? --- examples/PoolBox/iso/Config.xml | 3 ++- src/Tools/psxcdgen_ex/src/config_reader/xml.rs | 6 +++--- src/Tools/psxcdgen_ex/src/encoder/cd.rs | 16 ++++++++++++---- src/Tools/psxcdgen_ex/src/types/mod.rs | 12 +++++++++++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index 04d443fd..7f4f2699 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -9,7 +9,8 @@ --> Jaby - %PSX_LICENSE_PATH%/%PSX_LICENSE%.DAT + + %JABY_ENGINE_DIR%/bin/extern/32BIT.TMD System.cnf.subst diff --git a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs index cc64ca5d..5c629152 100644 --- a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs +++ b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs @@ -64,11 +64,11 @@ fn parse_root(root: roxmltree::Node, config: &mut Configuration) -> Result<(), E fn parse_description(description: roxmltree::Node, config: &mut Configuration) -> Result<(), Error> { fn parse_license_path(license: roxmltree::Node) -> LicenseFile { - LicenseFile::from_option(path_from_node(&license, tag_names::LICENSE).ok()) + LicenseFile::from_authentic_option(path_from_node(&license, tag_names::LICENSE).ok()) } fn parse_altlicense_path(license: roxmltree::Node) -> LicenseFile { - LicenseFile::from_option(path_from_node(&license, tag_names::ALTLICENSE).ok()) + LicenseFile::from_tmd_option(path_from_node(&license, tag_names::ALTLICENSE).ok()) } for node in description.descendants() { @@ -77,7 +77,7 @@ fn parse_description(description: roxmltree::Node, config: &mut Configuration) - "Publisher" => config.publisher = Some(String::from(node.text().unwrap_or_default())), tag_names::LICENSE => config.license_file = parse_license_path(node), tag_names::ALTLICENSE => config.license_file = parse_altlicense_path(node), - _ => () + _ => () } } } diff --git a/src/Tools/psxcdgen_ex/src/encoder/cd.rs b/src/Tools/psxcdgen_ex/src/encoder/cd.rs index f6b75098..b4983d01 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/cd.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/cd.rs @@ -237,11 +237,19 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit fn write_tmd_file(sec_writer: &mut dyn SectorWriter, tmd_file: BufferedInputFile) -> Result<(), Error> { fn write_license_string(sec_writer: &mut dyn SectorWriter, text: &str) -> Result<(), Error> { - let mut license_string_buffer = [0u8; Mode2Form1::DATA_SIZE]; + let text_len = text.len(); - license_string_buffer[..Mode2Form1::DATA_SIZE].copy_from_slice(text[0..text.len()].as_bytes()); - write_license_string_raw(sec_writer, &license_string_buffer)?; - Ok(()) + if text_len <= Mode2Form1::DATA_SIZE { + let mut license_string_buffer = [0u8; Mode2Form1::DATA_SIZE]; + + license_string_buffer[..text_len].copy_from_slice(text[0..text_len].as_bytes()); + write_license_string_raw(sec_writer, &license_string_buffer)?; + Ok(()) + } + + else { + Err(Error::from_text(format!("License string \"{}\" is longer then supported length {}", text, Mode2Form1::DATA_SIZE))) + } } fn write_license_logo(sec_writer: &mut dyn SectorWriter, mut tmd_file: BufferedInputFile) -> Result<(), Error> { diff --git a/src/Tools/psxcdgen_ex/src/types/mod.rs b/src/Tools/psxcdgen_ex/src/types/mod.rs index bb77d8db..c9137268 100644 --- a/src/Tools/psxcdgen_ex/src/types/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/mod.rs @@ -112,7 +112,7 @@ pub enum LicenseFile { } impl LicenseFile { - pub fn from_option(option: Option) -> LicenseFile { + pub fn from_authentic_option(option: Option) -> LicenseFile { if let Some(path) = option { LicenseFile::Authentic(path) } @@ -121,6 +121,16 @@ impl LicenseFile { LicenseFile::None } } + + pub fn from_tmd_option(option: Option) -> LicenseFile { + if let Some(path) = option { + LicenseFile::TMD(path) + } + + else { + LicenseFile::None + } + } } pub struct SystemArea {