Skip to content

Commit

Permalink
A2R: convert images with non-native image resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
twvd committed Nov 22, 2024
1 parent 511c0ee commit bc60e0c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion floppy/src/loaders/a2r3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ impl FloppyImageLoader for A2Rv3 {
let mut info = None;
let mut meta = String::new();
let mut captures = vec![];
let mut resolution = None;

// Parse chunks from file
while let Ok(chunk) = A2RChunkHeader::read(&mut cursor) {
Expand All @@ -164,7 +165,8 @@ impl FloppyImageLoader for A2Rv3 {
b"RWCP" => {
let rwcp = A2RChunkRwcp::read(&mut cursor)?;
if rwcp.resolution != 125000 {
bail!("Unsupported resolution: {}", rwcp.resolution);
debug!("Converting resolution: {} -> 125000", rwcp.resolution);
resolution = Some(rwcp.resolution);
}
while let A2RCaptureEntry::Capture(capture) =
A2RCaptureEntry::read(&mut cursor)?
Expand Down Expand Up @@ -227,6 +229,11 @@ impl FloppyImageLoader for A2Rv3 {
if b == 255 {
continue;
}
if let Some(res) = resolution {
// Perform conversion
let converted = last as u64 * res as u64 / 125000u64;
last = converted.try_into()?;
}
img.push_flux(side, track, last);
last = 0;
}
Expand Down

0 comments on commit bc60e0c

Please sign in to comment.