From fbc88e66d9534eb5e6daefb7fb64b7f87cd906ac Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 1 Jul 2020 14:59:36 +0100 Subject: [PATCH] scp: More fixes: 1. Detect non-index-cued images and clip first partial revolutions 2. Detect and handle empty TDH structures (no flux samples) 3. Set the 96tpi flag in exported SCP images --- scripts/greaseweazle/image/scp.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/greaseweazle/image/scp.py b/scripts/greaseweazle/image/scp.py index 381e009c..2766fb39 100644 --- a/scripts/greaseweazle/image/scp.py +++ b/scripts/greaseweazle/image/scp.py @@ -42,6 +42,10 @@ def from_file(cls, dat): (sig, _, _, nr_revs, _, _, flags, _, single_sided, _, _) = header error.check(sig == b"SCP", "SCP: Bad signature") + index_cued = flags & 1 or nr_revs == 1 + if not index_cued: + nr_revs -= 1 + # Some tools generate a short TLUT. We handle this by truncating the # TLUT at the first Track Data Header. trk_offs = struct.unpack("<168I", dat[16:0x2b0]) @@ -68,12 +72,21 @@ def from_file(cls, dat): # Parse the SCP track header and extract the flux data. thdr = dat[trk_off:trk_off+4+12*nr_revs] - sig, tnr, _, _, s_off = struct.unpack("<3sB3I", thdr[:16]) + sig, tnr = struct.unpack("<3sB", thdr[:4]) error.check(sig == b"TRK", "SCP: Missing track signature") error.check(tnr == trknr, "SCP: Wrong track number in header") + _off = 12 if index_cued else 24 # skip first partial rev + s_off, = struct.unpack("