diff options
| author | cadmic <cadmic24@gmail.com> | 2024-02-04 19:59:09 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-04 22:59:09 -0500 |
| commit | 54ffd50fa27aee5bc3123b3c73b6ecc2c447ebcb (patch) | |
| tree | 961f2dd319d84f83aea07439830e2d62038e1b35 /tools/compress.py | |
| parent | 454b1caa52b4447b57f57e929cbc831016d55c63 (diff) | |
Extract ROM segments from gc-eu-mq (take 2) (#1709)
* Extract ROM segments from gc-eu-mq (take 2)
* Apply suggestions from code review
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
* Typo
* dma_{start,names} -> dmadata_{start,names}
* Restore dest
* Don't assume rom location == vrom location
---------
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Diffstat (limited to 'tools/compress.py')
| -rwxr-xr-x | tools/compress.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/compress.py b/tools/compress.py index 45c29ceb4..d934ecb52 100755 --- a/tools/compress.py +++ b/tools/compress.py @@ -46,13 +46,13 @@ def set_sigint_ignored(): def compress_rom( rom_data: memoryview, - dmadata_offset: int, + dmadata_start: int, compress_entries_indices: set[int], n_threads: int = None, ): """ rom_data: the uncompressed rom data - dmadata_offset: the offset in the rom where the dmadata starts + dmadata_start: the offset in the rom where the dmadata starts compress_entries_indices: the indices in the dmadata of the segments that should be compressed n_threads: how many cores to use for compression """ @@ -60,7 +60,7 @@ def compress_rom( # Segments of the compressed rom (not all are compressed) compressed_rom_segments: list[RomSegment] = [] - dma_entries = dmadata.read_dmadata(rom_data, dmadata_offset) + dma_entries = dmadata.read_dmadata(rom_data, dmadata_start) # We sort the DMA entries by ROM start because `compress_entries_indices` # refers to indices in ROM order, but the uncompressed dmadata might not be # in ROM order. @@ -184,7 +184,7 @@ def compress_rom( compressed_rom_data[i] = i % 256 # Write the new dmadata - offset = dmadata_offset + offset = dmadata_start for dma_entry in compressed_rom_dma_entries: dma_entry.to_bin(compressed_rom_data[offset:]) offset += dmadata.DmaEntry.SIZE_BYTES @@ -207,8 +207,8 @@ def main(): help="path of the compressed rom to write out", ) parser.add_argument( - "--dma-start", - dest="dma_start", + "--dmadata-start", + dest="dmadata_start", type=lambda s: int(s, 16), required=True, help=( @@ -241,7 +241,7 @@ def main(): out_rom_p = Path(args.out_rom) - dmadata_offset = args.dma_start + dmadata_start = args.dmadata_start compress_ranges_str: str = args.compress_ranges compress_entries_indices = set() @@ -267,7 +267,7 @@ def main(): in_rom_data = in_rom_p.read_bytes() out_rom_data = compress_rom( memoryview(in_rom_data), - dmadata_offset, + dmadata_start, compress_entries_indices, n_threads, ) |
