diff --git a/include/PSX/AutoLBA/auto_lba.hpp b/include/PSX/AutoLBA/auto_lba.hpp index e1dc7358..51291181 100644 --- a/include/PSX/AutoLBA/auto_lba.hpp +++ b/include/PSX/AutoLBA/auto_lba.hpp @@ -31,12 +31,12 @@ namespace JabyEngine { return const_cast(this)->get_size_in_sectors(); } - constexpr bool isLZ4() const { + constexpr bool is_lz4() const { return bit::is_set(this->value, AutoLBAEntry::IsLZ4Compressed); } - constexpr bool isLZ4() const volatile { - return const_cast(this)->isLZ4(); + constexpr bool is_lz4() const volatile { + return const_cast(this)->is_lz4(); } }; } diff --git a/src/Library/src/File/Processor/cd_file_processor.cpp b/src/Library/src/File/Processor/cd_file_processor.cpp index 5e191bb9..e25b286c 100644 --- a/src/Library/src/File/Processor/cd_file_processor.cpp +++ b/src/Library/src/File/Processor/cd_file_processor.cpp @@ -52,7 +52,7 @@ namespace JabyEngine { return self.circular_buffer.allocate(); })); - printf(">>> CD needs to load LBA: %i -> %i\n", cur_lba.get_lba(), cur_lba.get_size_in_sectors()); + printf(">>> CD needs to load LBA: %i -> %i (is LZ4: [%s])\n", cur_lba.get_lba(), cur_lba.get_size_in_sectors(), cur_lba.is_lz4() ? "Yes" : "No"); } bool CDFileProcessor :: process_data() { diff --git a/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs b/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs index 74feb9f4..2cb8482b 100644 --- a/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs @@ -8,11 +8,6 @@ pub type LBANameVec = Vec; mod main; -/* -Size in sectors [22, 31]; -Is LZ4 compressed [19]; -LBA value [0, 18] -*/ #[repr(packed)] struct LBAEntry { raw: u32, @@ -20,10 +15,10 @@ struct LBAEntry { impl LBAEntry { const SIZE_IN_SECTOR_RANGE:BitRange = BitRange::from_to(22, 31); - const _IS_LZ4_COMPRESSED:Bit = Bit::at(19); + const IS_LZ4_COMPRESSED:Bit = Bit::at(19); const LBA_VALUE_RANGE:BitRange = BitRange::from_to(0, 18); - pub fn write_entry(&mut self, lba: usize, size_bytes: usize, _is_lz4: bool) -> Result<(), Error> { + pub fn write_entry(&mut self, lba: usize, size_bytes: usize, is_lz4: bool) -> Result<(), Error> { if lba > Self::LBA_VALUE_RANGE.max_value() { return Err(Error::from_text(format!("LBA of value {} is impossible and can not be encoded! Maximum LBA value is: {}", lba, Self::LBA_VALUE_RANGE.max_value()))); } @@ -40,7 +35,11 @@ impl LBAEntry { return Err(Error::from_str("LBA Entry will overwrite non-zero value!\nIs no space allocated for the LBA Entries?")); } - self.raw = Self::SIZE_IN_SECTOR_RANGE.or_value(Self::LBA_VALUE_RANGE.or_value(0, lba), size_in_sectors) as u32; + let new_raw = Self::LBA_VALUE_RANGE.or_value(0, lba); + let new_raw = Self::SIZE_IN_SECTOR_RANGE.or_value(new_raw, size_in_sectors); + let new_raw = Self::IS_LZ4_COMPRESSED.or_value(new_raw, is_lz4); + + self.raw = new_raw as u32; Ok(()) } }