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.