Skip to content

Commit

Permalink
hfe: New write option "double_step"
Browse files Browse the repository at this point in the history
Sets the HFE header flag to indicate double stepping.
  • Loading branch information
keirf committed May 24, 2024
1 parent 5398d5c commit 75ee07f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/greaseweazle/image/hfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ class HFEOpts(ImageOpts):
"""bitrate: Bitrate of new HFE image file.
"""

w_settings = [ 'bitrate', 'version', 'interface', 'encoding' ]
w_settings = [ 'bitrate', 'version', 'interface', 'encoding',
'double_step' ]

def __init__(self) -> None:
self._bitrate: Optional[int] = None
self._version = 1
self._interface = 0xff
self._encoding = 0xff
self.double_step = False

@property
def bitrate(self) -> Optional[int]:
Expand Down Expand Up @@ -303,7 +305,7 @@ def hfev1_get_image(self) -> bytes:
tdat += slice + bytes([0x88] * (256 - len(slice)))

# Construct the image header.
header = struct.pack("<8s4B2H2BH",
header = struct.pack("<8s4B2H2BH2B",
b"HXCPICFE",
0,
n_cyl,
Expand All @@ -313,7 +315,9 @@ def hfev1_get_image(self) -> bytes:
0, # rpm (unused)
self.opts.interface,
1, # rsvd
1) # track list offset
1, # track list offset
0xff, # write_allowed
0xff if not self.opts.double_step else 0)

# Pad the header and TLUT to 512-byte blocks.
header += bytes([0xff] * (0x200 - len(header)))
Expand Down Expand Up @@ -653,7 +657,7 @@ def hfev3_get_image(hfe: HFE) -> bytes:
tdat += t[b*256:(b+1)*256]

# Construct the image header.
header = struct.pack("<8s4B2H2BH",
header = struct.pack("<8s4B2H2BH2B",
b"HXCHFEV3",
0,
n_cyl,
Expand All @@ -663,7 +667,9 @@ def hfev3_get_image(hfe: HFE) -> bytes:
0, # rpm (unused)
hfe.opts.interface,
1, # rsvd
1) # track list offset
1, # track list offset
0xff, # write_allowed
0xff if not hfe.opts.double_step else 0)

# Pad the header and TLUT to 512-byte blocks.
header += bytes([0xff] * (0x200 - len(header)))
Expand Down

0 comments on commit 75ee07f

Please sign in to comment.