Skip to content

Commit

Permalink
d88, ibm: Do not warn on oversize track until duplicate sectors are r…
Browse files Browse the repository at this point in the history
…emoved

Refs #315
  • Loading branch information
keirf committed May 11, 2023
1 parent dc08477 commit 11a81ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/greaseweazle/codec/ibm/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/greaseweazle/image/d88.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 11a81ae

Please sign in to comment.