Replace License Logo with TMD but results are bad?

This commit is contained in:
Jaby 2024-08-15 15:05:48 -05:00
parent 25002240e7
commit b50fee186a
4 changed files with 28 additions and 9 deletions

View File

@ -9,7 +9,8 @@
</Defaults>-->
<Description>
<Publisher>Jaby</Publisher>
<License>%PSX_LICENSE_PATH%/%PSX_LICENSE%.DAT</License>
<!--<License>%PSX_LICENSE_PATH%/%PSX_LICENSE%.DAT</License>-->
<AltLicense>%JABY_ENGINE_DIR%/bin/extern/32BIT.TMD</AltLicense>
</Description>
<Filesystem lead-out="0:2:0">
<File name = "SYSTEM.CNF">System.cnf.subst</File>

View File

@ -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),
_ => ()
_ => ()
}
}
}

View File

@ -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> {

View File

@ -112,7 +112,7 @@ pub enum LicenseFile {
}
impl LicenseFile {
pub fn from_option(option: Option<PathBuf>) -> LicenseFile {
pub fn from_authentic_option(option: Option<PathBuf>) -> LicenseFile {
if let Some(path) = option {
LicenseFile::Authentic(path)
}
@ -121,6 +121,16 @@ impl LicenseFile {
LicenseFile::None
}
}
pub fn from_tmd_option(option: Option<PathBuf>) -> LicenseFile {
if let Some(path) = option {
LicenseFile::TMD(path)
}
else {
LicenseFile::None
}
}
}
pub struct SystemArea {