Skip to content

Commit

Permalink
Merge pull request #103 from dyceron/fix-sr-alignment
Browse files Browse the repository at this point in the history
Adjust pkg alignment for SR
  • Loading branch information
ThanatosGit authored Nov 24, 2023
2 parents 19f7651 + ada594b commit 08cc1eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mercury_engine_data_structures/formats/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, target_game: Game):
self.int_size = typing.cast(construct.FormatField, Int32ul)
self._file_entry = _file_entry(target_game)
self.file_headers_type = PrefixedArray(self.int_size, self._file_entry).compile()
self.game = target_game

def _parse(self, stream, context, path) -> construct.Container:
# Skip over header size and data section size
Expand Down Expand Up @@ -114,8 +115,11 @@ def _build(self, obj: construct.Container, stream, context, path):
start_offset=start_offset,
end_offset=end_offset,
))
# Align to 8 bytes
pad = -(end_offset - start_offset) % 8
# Samus Returns aligns to 128 bytes, Dread aligns to 8 bytes
if self.game == Game.SAMUS_RETURNS:
pad = -(end_offset - start_offset) % 128
else:
pad = -(end_offset - start_offset) % 8
construct.stream_write(stream, b"\x00" * pad, pad, path)

files_end = construct.stream_tell(stream, path)
Expand Down

0 comments on commit 08cc1eb

Please sign in to comment.