Skip to content

Commit

Permalink
gw convert, write: Latch auto-detected IMG format
Browse files Browse the repository at this point in the history
Specifically, this fixes the reported trackspec.
  • Loading branch information
keirf committed Sep 28, 2024
1 parent 93dad04 commit b605c4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/greaseweazle/tools/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from greaseweazle.codec import codec
from greaseweazle.track import MasterTrack
from greaseweazle.image.image import Image
from greaseweazle.image.img import IMG

from greaseweazle import track
plls = track.plls
Expand Down Expand Up @@ -171,6 +172,10 @@ def main(argv) -> None:
Known formats:\n%s"""
% (args.format, codec.print_formats(
args.diskdefs)))
in_image = open_input_image(args, in_image_class)
if args.fmt_cls is None and isinstance(in_image, IMG):
args.fmt_cls = in_image.fmt
if args.fmt_cls is not None:
def_tracks = copy.copy(args.fmt_cls.tracks)
if def_tracks is None:
def_tracks = util.TrackSet('c=0-81:h=0-1')
Expand All @@ -184,11 +189,10 @@ def main(argv) -> None:
out_def_tracks.update_from_trackspec(args.out_tracks.trackspec)
args.out_tracks = out_def_tracks

print("Converting %s -> %s" % (args.tracks, args.out_tracks))
if args.format:
print("Format " + args.format)
print("Converting %s -> %s" % (args.tracks, args.out_tracks))

in_image = open_input_image(args, in_image_class)
with open_output_image(args, out_image_class) as out_image:
convert(args, in_image, out_image)

Expand Down
10 changes: 7 additions & 3 deletions src/greaseweazle/tools/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from greaseweazle import usb as USB
from greaseweazle.codec import codec
from greaseweazle.image import image
from greaseweazle.image.img import IMG
from greaseweazle.track import HasVerify, MasterTrack

# Read and parse the image file.
Expand Down Expand Up @@ -266,19 +267,22 @@ def main(argv) -> None:
Known formats:\n%s"""
% (args.format, codec.print_formats(
args.diskdefs)))
image = open_image(args, image_class)
if args.fmt_cls is None and isinstance(image, IMG):
args.fmt_cls = image.fmt
if args.fmt_cls is not None:
def_tracks = copy.copy(args.fmt_cls.tracks)
if def_tracks is None:
def_tracks = util.TrackSet('c=0-81:h=0-1')
if args.tracks is not None:
def_tracks.update_from_trackspec(args.tracks.trackspec)
args.tracks = def_tracks
usb = util.usb_open(args.device)
image = open_image(args, image_class)
if args.format:
print("Format " + args.format)
print("Writing " + str(args.tracks))
if args.precomp is not None:
print(args.precomp)
if args.format:
print("Format " + args.format)
try:
if args.densel is not None or args.gen_tg43:
prev_pin2 = usb.get_pin(2)
Expand Down

0 comments on commit b605c4e

Please sign in to comment.