From f32e843f8cbac0b5b586fb45bf1f07252c4f3842 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 5 Sep 2023 15:12:13 +0100 Subject: [PATCH] MasterTrack: Fix weak region running to the very end of the track This is seen in some weird HFEv3 images in issue #346 Refs #346 --- src/greaseweazle/track.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/greaseweazle/track.py b/src/greaseweazle/track.py index cc05f54b..537bbaf5 100644 --- a/src/greaseweazle/track.py +++ b/src/greaseweazle/track.py @@ -170,7 +170,7 @@ def _flux(self, for_writeout, cue_at_index) -> Union[Flux, WriteoutFlux]: # Weak regions need special processing for correct flux representation. for s,n in self.weak: e = s + n - assert 0 < s < e < bitlen + assert 0 < s < e <= bitlen pattern = bitarray(endian="big") if n < 400 or self.force_random_weak: # Short weak regions are written with no flux transitions. @@ -194,7 +194,7 @@ def _flux(self, for_writeout, cue_at_index) -> Union[Flux, WriteoutFlux]: # clocked out a 0. bits[s] = not bits[s-1] # Similarly modify the last bit of the weak region. - bits[e-1] = not(bits[e-2] or bits[e]) + bits[e-1] = not(bits[e-2] or bits[e % bitlen]) if cue_at_index: # Rotate data to start at the index.