mirror of
https://github.com/wiiu-env/ROBChain.git
synced 2024-12-04 07:54:13 +01:00
Add file injector
This commit is contained in:
parent
0222c97c0b
commit
9e8b051eeb
37
inject.py
Normal file
37
inject.py
Normal 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
BIN
robot_packed
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user