2021-05-08 08:54:34 +02:00
|
|
|
#! /usr/bin/python3
|
|
|
|
|
|
|
|
from sys import argv
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
argv.pop(0) # python3
|
2021-07-16 13:08:22 +02:00
|
|
|
|
|
|
|
if len(argv) > 4:
|
|
|
|
out, img1, img2, img3, img2_pal = argv
|
|
|
|
else:
|
|
|
|
out, img1, img2, img3 = argv
|
|
|
|
img2_pal = None
|
2021-05-08 08:54:34 +02:00
|
|
|
|
|
|
|
with open(img1, "rb") as f:
|
|
|
|
img1 = f.read()
|
|
|
|
|
|
|
|
with open(img2, "rb") as f:
|
|
|
|
img2 = f.read()
|
|
|
|
|
|
|
|
with open(img3, "rb") as f:
|
|
|
|
img3 = f.read()
|
|
|
|
|
2021-07-16 13:08:22 +02:00
|
|
|
if img2_pal:
|
|
|
|
with open(img2_pal, "rb") as f:
|
|
|
|
img2_pal = f.read()
|
|
|
|
|
2021-05-08 08:54:34 +02:00
|
|
|
with open(out, "wb") as f:
|
|
|
|
f.seek(0x10)
|
|
|
|
|
|
|
|
pos2 = f.tell()
|
|
|
|
f.write(img2)
|
|
|
|
|
2021-07-16 13:08:22 +02:00
|
|
|
if img2_pal:
|
|
|
|
pos2_pal = f.tell()
|
|
|
|
f.write(img2_pal)
|
|
|
|
else:
|
|
|
|
pos2_pal = None
|
|
|
|
|
2021-05-08 08:54:34 +02:00
|
|
|
pos3 = f.tell()
|
|
|
|
f.write(img3)
|
|
|
|
|
|
|
|
pos1 = f.tell()
|
|
|
|
f.write(img1)
|
|
|
|
|
2021-07-16 13:08:22 +02:00
|
|
|
if img2_pal:
|
|
|
|
# jp padding?
|
|
|
|
f.write(b"\x00" * 0x10)
|
|
|
|
|
2021-05-08 08:54:34 +02:00
|
|
|
f.seek(0)
|
|
|
|
f.write(pos1.to_bytes(4, byteorder="big"))
|
|
|
|
f.write(pos2.to_bytes(4, byteorder="big"))
|
|
|
|
f.write(pos3.to_bytes(4, byteorder="big"))
|
2021-07-16 13:08:22 +02:00
|
|
|
if pos2_pal:
|
|
|
|
f.write(pos2_pal.to_bytes(4, byteorder="big"))
|