Detect LZ4 files correctly now
This commit is contained in:
parent
5d0239bfe8
commit
1329536586
|
@ -31,12 +31,12 @@ namespace JabyEngine {
|
||||||
return const_cast<const AutoLBAEntry*>(this)->get_size_in_sectors();
|
return const_cast<const AutoLBAEntry*>(this)->get_size_in_sectors();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool isLZ4() const {
|
constexpr bool is_lz4() const {
|
||||||
return bit::is_set(this->value, AutoLBAEntry::IsLZ4Compressed);
|
return bit::is_set(this->value, AutoLBAEntry::IsLZ4Compressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool isLZ4() const volatile {
|
constexpr bool is_lz4() const volatile {
|
||||||
return const_cast<const AutoLBAEntry*>(this)->isLZ4();
|
return const_cast<const AutoLBAEntry*>(this)->is_lz4();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace JabyEngine {
|
||||||
return self.circular_buffer.allocate();
|
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() {
|
bool CDFileProcessor :: process_data() {
|
||||||
|
|
|
@ -8,11 +8,6 @@ pub type LBANameVec = Vec<String>;
|
||||||
|
|
||||||
mod main;
|
mod main;
|
||||||
|
|
||||||
/*
|
|
||||||
Size in sectors [22, 31];
|
|
||||||
Is LZ4 compressed [19];
|
|
||||||
LBA value [0, 18]
|
|
||||||
*/
|
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
struct LBAEntry {
|
struct LBAEntry {
|
||||||
raw: u32,
|
raw: u32,
|
||||||
|
@ -20,10 +15,10 @@ struct LBAEntry {
|
||||||
|
|
||||||
impl LBAEntry {
|
impl LBAEntry {
|
||||||
const SIZE_IN_SECTOR_RANGE:BitRange = BitRange::from_to(22, 31);
|
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);
|
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() {
|
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())));
|
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?"));
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue