Răsfoiți Sursa

Various bugfixes for format handling in conjunction with raw (HFE,SCP,KF) files

Keir Fraser 3 ani în urmă
părinte
comite
c7aec389e8

+ 1 - 4
scripts/greaseweazle/codec/amiga/amigados.py

@@ -67,11 +67,8 @@ class AmigaDOS:
             self.sector[sec] = bytes(16), tdat[sec*512:(sec+1)*512]
         return totsize
 
-    def flux_for_writeout(self, *args, **kwargs):
-        return self.raw_track().flux_for_writeout(args, kwargs)
-
     def flux(self, *args, **kwargs):
-        return self.raw_track().flux(args, kwargs)
+        return self.raw_track().flux(*args, **kwargs)
 
 
     def decode_raw(self, track):

+ 1 - 4
scripts/greaseweazle/codec/ibm/fm.py

@@ -70,11 +70,8 @@ class IBM_FM:
     def nr_missing(self):
         return len(list(filter(lambda x: x.crc != 0, self.sectors)))
 
-    def flux_for_writeout(self, *args, **kwargs):
-        return self.raw_track().flux_for_writeout(args, kwargs)
-
     def flux(self, *args, **kwargs):
-        return self.raw_track().flux(args, kwargs)
+        return self.raw_track().flux(*args, **kwargs)
 
 
     def decode_raw(self, track):

+ 1 - 5
scripts/greaseweazle/codec/ibm/mfm.py

@@ -128,12 +128,8 @@ class IBM_MFM:
     def nr_missing(self):
         return len(list(filter(lambda x: x.crc != 0, self.sectors)))
 
-    def flux_for_writeout(self, *args, **kwargs):
-        return self.raw_track().flux_for_writeout(args, kwargs)
-
     def flux(self, *args, **kwargs):
-        return self.raw_track().flux(args, kwargs)
-
+        return self.raw_track().flux(*args, **kwargs)
 
     def decode_raw(self, track):
         track.cue_at_index()

+ 2 - 0
scripts/greaseweazle/flux.py

@@ -55,6 +55,8 @@ class Flux:
 
     def flux_for_writeout(self):
 
+        error.check(self.index_cued,
+                    "Cannot write non-index-cued raw flux")
         error.check(self.splice == 0 or len(self.index_list) > 1,
                     "Cannot write single-revolution unaligned raw flux")
         splice_at_index = (self.splice == 0)

+ 5 - 0
scripts/greaseweazle/tools/write.py

@@ -20,8 +20,10 @@ from greaseweazle.codec import formats
 def open_image(args, image_class):
     try:
         image = image_class.from_file(args.file)
+        args.raw_image_class = True
     except TypeError:
         image = image_class.from_file(args.file, args.fmt_cls)
+        args.raw_image_class = False
     return image
 
 # write_from_image:
@@ -52,6 +54,9 @@ def write_from_image(usb, args, image):
             usb.erase_track(drive.ticks_per_rev * 1.1)
             continue
 
+        if args.raw_image_class and args.fmt_cls is not None:
+            track = args.fmt_cls.decode_track(cyl, head, track).raw_track()
+
         if args.precomp is not None:
             track.precomp = args.precomp.track_precomp(cyl)
         flux = track.flux_for_writeout()

+ 13 - 6
scripts/greaseweazle/track.py

@@ -8,7 +8,7 @@
 import binascii
 import itertools as it
 from bitarray import bitarray
-from greaseweazle.flux import WriteoutFlux
+from greaseweazle.flux import Flux, WriteoutFlux
 from greaseweazle import optimised
 
 # Precompensation to apply to a MasterTrack for writeout.
@@ -126,7 +126,7 @@ class MasterTrack:
             # Similarly modify the last bit of the weak region.
             bits[e-1] = not(bits[e-2] or bits[e])
 
-        if cue_at_index:
+        if cue_at_index or not for_writeout:
             # Rotate data to start at the index.
             index = -self.splice % bitlen
             if index != 0:
@@ -193,10 +193,17 @@ class MasterTrack:
             flux_list.append(flux_ticks)
 
         # Package up the flux for return.
-        flux = WriteoutFlux(ticks_to_index, flux_list,
-                            ticks_to_index / self.time_per_rev,
-                            index_cued = cue_at_index,
-                            terminate_at_index = splice_at_index)
+        if for_writeout:
+            flux = WriteoutFlux(ticks_to_index, flux_list,
+                                ticks_to_index / self.time_per_rev,
+                                index_cued = cue_at_index,
+                                terminate_at_index = splice_at_index)
+        else:
+            flux = Flux([ticks_to_index]*2, flux_list*2,
+                        ticks_to_index / self.time_per_rev,
+                        index_cued = True)
+            flux.splice = sum(bit_ticks[:self.splice])
+
         return flux