-
Notifications
You must be signed in to change notification settings - Fork 1
/
inject.py
37 lines (26 loc) · 987 Bytes
/
inject.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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:])