Add file injector

This commit is contained in:
jam1garner 2020-02-11 17:00:37 -05:00
parent 0222c97c0b
commit 9e8b051eeb
2 changed files with 37 additions and 0 deletions

37
inject.py Normal file
View File

@ -0,0 +1,37 @@
import os, zlib, argparse
PACK_FILE_PATH = "robot_packed"
OUTPUT_FOLDER = "data/fighter/robot/script/"
OUTPUT_FILE = "packed"
OUTPUT_PATH = OUTPUT_FOLDER + OUTPUT_FILE
PACK_OFFSET = 0xB380
COMPRESSED_SIZE = 0x1B1D0
UNCOMPRESSED_SIZE = 0x5B2E0
if not os.path.exists(OUTPUT_FOLDER):
os.makedirs(OUTPUT_FOLDER)
parser = argparse.ArgumentParser(description="pack ROB's mscsb files")
parser.add_argument('in_file')
in_file = parser.parse_args().in_file
with open(in_file, 'rb') as f:
data = f.read()
assert len(data) <= UNCOMPRESSED_SIZE
data += b'\0' * (UNCOMPRESSED_SIZE - len(data))
compressed_data = zlib.compress(data)
assert len(compressed_data) <= COMPRESSED_SIZE
compressed_data += b'\0' * (COMPRESSED_SIZE - len(compressed_data))
with open(PACK_FILE_PATH, 'rb') as f:
pack_file_data = f.read()
with open(OUTPUT_PATH, 'wb') as f:
f.write(pack_file_data[:PACK_OFFSET])
f.write(compressed_data)
f.write(pack_file_data[PACK_OFFSET + COMPRESSED_SIZE:])

BIN
robot_packed Normal file

Binary file not shown.