From e4e3ee9bbd6fd2d17b706223241fb5c9805f9bc5 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 13 Oct 2023 12:05:13 +0100 Subject: [PATCH] MasterTrack: Fix weak region running from the very start of the track This is seen in some BBC HFEv3 images, eg. Crazy Tracer by Acornsoft downloadable here: https://drive.google.com/drive/mobile/folders/140xzJarpb3HX04MaqR_m8AzDoG3Bdyky Also disallow ridiculously short weak regions to avoid any further crashes in the weak-flux generator due to reasonable assumptions about minimum lengths of the weak region and the overall track. --- src/greaseweazle/track.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/greaseweazle/track.py b/src/greaseweazle/track.py index 537bbaf5..37929ffe 100644 --- a/src/greaseweazle/track.py +++ b/src/greaseweazle/track.py @@ -168,9 +168,10 @@ def _flux(self, for_writeout, cue_at_index) -> Union[Flux, WriteoutFlux]: ticks_to_index = sum(bit_ticks) # Weak regions need special processing for correct flux representation. - for s,n in self.weak: + for s, n in self.weak: + if n < 2: continue # Too short to reliably weaken 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.