From 11a81ae185eabd751a26038f10be24638404b089 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 11 May 2023 18:06:23 +0100 Subject: [PATCH] d88, ibm: Do not warn on oversize track until duplicate sectors are removed Refs #315 --- src/greaseweazle/codec/ibm/ibm.py | 8 +++++--- src/greaseweazle/image/d88.py | 16 +++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/greaseweazle/codec/ibm/ibm.py b/src/greaseweazle/codec/ibm/ibm.py index b23a05a8..4ad243cb 100644 --- a/src/greaseweazle/codec/ibm/ibm.py +++ b/src/greaseweazle/codec/ibm/ibm.py @@ -666,7 +666,8 @@ def verify_track(self, flux) -> bool: return self.sectors == readback_track.sectors @classmethod - def from_config(cls, config: IBMTrackFormat, cyl: int, head: int): + def from_config(cls, config: IBMTrackFormat, cyl: int, head: int, + warn_on_oversize = True): def sec_n(i): return config.sz[i] if i < len(config.sz) else config.sz[-1] @@ -750,8 +751,9 @@ def sec_n(i): if tracklen > tracklen_bc * 105//100: t.oversized = True - print('T%d.%d: IBM: WARNING: Track is %.2f%% too long' - % (cyl, head, 100.0*tracklen/tracklen_bc)) + if warn_on_oversize: + print('T%d.%d: IBM: WARNING: Track is %.2f%% too long' + % (cyl, head, 100.0*tracklen/tracklen_bc)) tracklen_bc = max(tracklen_bc, tracklen) t.time_per_rev = 60 / rpm diff --git a/src/greaseweazle/image/d88.py b/src/greaseweazle/image/d88.py index 69e3bd6e..2a5b5a34 100644 --- a/src/greaseweazle/image/d88.py +++ b/src/greaseweazle/image/d88.py @@ -111,20 +111,22 @@ def from_file(cls, name: str) -> Image: track.secs = len(secs) track.sz = [x[3] for x in secs] track.finalise() - t = track.mk_track(cyl, head) + t = ibm.IBMTrackFormatted.from_config( + track, cyl, head, warn_on_oversize = False) - # If the track is oversized, remove duplicate sectors, if any + # If the track is oversized, remove duplicate sectors, and + # re-generate the track layout with oversize warning enabled. if t.oversized: new_secs = d88.remove_duplicate_sectors(secs) ndups = len(secs) - len(new_secs) if ndups != 0: print('T%d.%d: D88: Removed %d duplicate sectors ' 'from oversized track' % (cyl, head, ndups)) - # Generate the de-duplicated track layout - secs = new_secs - track.secs = len(secs) - track.sz = [x[3] for x in secs] - t = track.mk_track(cyl, head) + secs = new_secs + track.secs = len(secs) + track.sz = [x[3] for x in secs] + t = ibm.IBMTrackFormatted.from_config( + track, cyl, head, warn_on_oversize = True) for nr,s in enumerate(t.sectors): c,h,r,n,data = secs[nr]