Support XA-Audio (buggy)

This commit is contained in:
Jaby
2024-05-26 14:49:48 +02:00
parent c8ccd44a71
commit 61c300e37e
4 changed files with 43 additions and 27 deletions

View File

@@ -7,6 +7,6 @@ edition = "2021"
panic = "abort"
[dependencies]
byteorder = "1.5.0"
chrono = "0.4.31"
paste = "1.0.14"
byteorder = "1.5.0"
chrono = "0.4.31"
paste = "1.0.14"

View File

@@ -27,7 +27,7 @@ impl<'a> Reader<'a> {
None
}
fn process_audio_sector(&mut self) -> Result<Option<Sector>, Error> {
fn process_audio_sector(&mut self, _force: bool) -> Result<Option<Sector>, Error> {
let mut buffer = [0;std::mem::size_of::<Audio>()];
let bytes = self.file.read(&mut buffer)?;
@@ -42,7 +42,7 @@ impl<'a> Reader<'a> {
}
}
fn process_binary_sector(&mut self) -> Result<Option<Sector>, Error> {
fn process_binary_sector(&mut self, force: bool) -> Result<Option<Sector>, Error> {
fn make_ok_some(sector: Sector) -> Result<Option<Sector>, Error> {
Ok(Some(sector))
}
@@ -69,7 +69,15 @@ impl<'a> Reader<'a> {
}
}
Err(mode) => {
return Err(Error::TypeError(format!("Unkown Mode: {} @LBA: {}", mode, self.lba - 1)));
let error_str = format!("Unknown Mode: {} @LBA: {}", mode, self.lba - 1);
if force {
println!("Warning: {}", error_str);
return make_ok_some(Sector::Empty(Mode0::new()));
}
else {
return Err(Error::TypeError(error_str));
}
}
}
}
@@ -90,7 +98,7 @@ impl<'a> std::iter::Iterator for Reader<'a> {
}
};
match function(self) {
match function(self, true) {
Ok(sector) => {
if let Some(sector) = sector {
Some(Ok(sector))