-
-
Save dogtopusfans/18d49d6ebca1519dea28f5b81c42323a to your computer and use it in GitHub Desktop.
Fix RGSS3A headers scrambled by Fux2Pack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import struct | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print('Usage:', sys.argv[0], '<fux2packedrgss3a>') | |
sys.exit(1) | |
hdr = struct.Struct('<8sI') | |
with open(sys.argv[1], 'rb+') as f: | |
header = hdr.unpack_from(f.read(12)) | |
if header[0] != b'Fux2Pack': | |
print('No fuxxed pack to fsck. Stop') | |
sys.exit(1) | |
# Old and good number theory | |
metadata_key = ((header[1] - 3) * 0x38E38E39) & 0xffffffff | |
print(hex(header[1]), '->', hex(metadata_key)) | |
f.seek(0) | |
f.write(hdr.pack(b'RGSSAD\x00\x03', metadata_key)) | |
print('Fscked. Good luck.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment