Skip to content

Commit

Permalink
gw convert: New option --reverse to reverse track data for flippy disks
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed Aug 21, 2024
1 parent 4a728e3 commit d79e99f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/greaseweazle/flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ def cue_at_index(self) -> None:
self.sector_list = self.sector_list[1:]


def reverse(self) -> None:

assert self.sector_list is None

was_index_cued = self.index_cued
flux_sum = sum(self.list)

self.index_cued = False
self.list.reverse()
self.index_list.reverse()

to_index = flux_sum - sum(self.index_list)
if to_index <= 0:
if to_index < 0:
self.list.insert(0, -to_index)
flux_sum += -to_index
self.index_list = self.index_list[1:]
self.index_cued = True
else:
self.index_list[0] = to_index

if was_index_cued:
self.index_list.append(flux_sum - sum(self.index_list))


def set_nr_revs(self, revs:int) -> None:

self.cue_at_index()
Expand Down
6 changes: 6 additions & 0 deletions src/greaseweazle/tools/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def process_input_track(
if track is None:
return None

if args.reverse:
track = track.flux()
track.reverse()

if args.hard_sectors:
track = track.flux()
track.identify_hard_sectors()
Expand Down Expand Up @@ -132,6 +136,8 @@ def main(argv) -> None:
help="manual PLL parameter override")
parser.add_argument("--hard-sectors", action="store_true",
help="convert index positions to hard sectors")
parser.add_argument("--reverse", action="store_true",
help="reverse track data (flippy disk)")
parser.add_argument("in_file", help="input filename")
parser.add_argument("out_file", help="output filename")
parser.description = description
Expand Down

0 comments on commit d79e99f

Please sign in to comment.