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
| from struct import unpack | |
| from binascii import hexlify, unhexlify | |
| from os import getcwd, mkdir | |
| from os.path import exists | |
| from PIL import Image | |
| import sys | |
| #sys.argv.append("Sonic.bin") | |
| do_extract = 1 | |
| with open(sys.argv[1], "rb") as f: |
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
| def getstr(f): | |
| ret = "";char = f.read(1) | |
| while char != "\x00": | |
| ret += char | |
| char = f.read(1) | |
| return ret | |
| def getustr(f): | |
| ret = "";char = f.read(2) | |
| while char != "\x00\x00": |
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
| # ------------------------------------- | |
| # data is aligned to nearest 0x80 | |
| # header size is normally 0x7C aka | |
| # 0x80 aligned, minus 4 | |
| # (doesn't include 4 bytes for the header size) | |
| # then data size starting at [header_size + 4] | |
| # then number of files, read 12 bytes each and seek | |
| # 12 = hash(?), start pos, end pos (from start of file) | |
| # then just seek to [header_size + 4] and extract files | |
| from struct import pack, unpack |
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
| from struct import pack, unpack | |
| from os import remove, rename | |
| import sys | |
| do_replace = 1 | |
| with open(sys.argv[1], "rb") as f: | |
| name = sys.argv[1].split(".") | |
| name = ".".join(name[:-1]) + ".dec." + name[-1] | |
| with open(name, "wb+") as o: |
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
| from struct import pack, unpack | |
| from os import mkdir, makedirs, listdir | |
| from os.path import exists | |
| import sys | |
| def half(en, f): | |
| return unpack("%sH" % en, f.read(2))[0] | |
| def full(en, f): | |
| return unpack("%sI" % en, f.read(4))[0] |
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
| from struct import unpack | |
| from PIL import Image | |
| from os import mkdir | |
| from os.path import exists | |
| import sys | |
| class I4_Texture: | |
| def __init__(self, width, height, color): | |
| self.image = Image.new("RGB", (width, height)) | |
| self.img = self.image.load() |
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
| from parse_tpl import * | |
| from os import mkdir | |
| from os.path import exists | |
| name = "banner" | |
| width = 96 | |
| height = 32 | |
| if not exists(name): | |
| mkdir(name) |
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
| #Very slow, loads whole file into memory to try decompression | |
| from zlib import decompress | |
| import sys | |
| size = 0 | |
| with open(sys.argv[1], "rb") as f: | |
| compressed = f.read() | |
| total_size = f.tell() | |
| output = "" | |
| for i in range(total_size): |
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
| from zlib import decompress | |
| from io import BytesIO | |
| import sys | |
| data = open(sys.argv[1], "rb").read() | |
| #use this without making giant range() array | |
| size = len(data) - 1 | |
| #better than a string ? | |
| output = BytesIO() | |
| #get byte 0 for the loop |
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
| from struct import unpack | |
| import sys | |
| with open(sys.argv[1], "rb") as f: | |
| base = ".".join(sys.argv[1].split(".")[:-1]) | |
| with open(base + ".sarc", "wb+") as o: | |
| assert f.read(4) == b"Yaz0" | |
| unc_size = unpack(">I", f.read(4))[0] | |
| o.write(b"\x00" * unc_size) #pre-allocate | |
| o.seek(0);f.seek(16) |