2023-05-04 11:03:02 +02:00
|
|
|
#!/usr/bin/env python3
|
2021-05-08 08:54:34 +02:00
|
|
|
|
|
|
|
from sys import argv
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-07-29 19:03:17 +02:00
|
|
|
argv.pop(0) # python3
|
2024-01-11 12:41:11 +01:00
|
|
|
version = argv.pop(0)
|
|
|
|
out = argv.pop(0)
|
|
|
|
imgs = argv
|
|
|
|
|
|
|
|
imgs_bytes = []
|
|
|
|
for img in imgs:
|
|
|
|
with open(img, "rb") as f:
|
|
|
|
imgs_bytes.append(f.read())
|
|
|
|
|
|
|
|
if version == "jp":
|
|
|
|
# copyright, copyright pal, press start, logo
|
|
|
|
write_order = (1, 3, 2, 0)
|
|
|
|
elif version == "ique":
|
|
|
|
# press start, copyright, logo
|
|
|
|
write_order = (2, 1, 0)
|
2021-07-16 13:08:22 +02:00
|
|
|
else:
|
2024-01-11 12:41:11 +01:00
|
|
|
# copyright, press start, logo
|
|
|
|
write_order = (1, 2, 0)
|
2021-07-16 13:08:22 +02:00
|
|
|
|
2021-05-08 08:54:34 +02:00
|
|
|
with open(out, "wb") as f:
|
|
|
|
f.seek(0x10)
|
|
|
|
|
2024-01-11 12:41:11 +01:00
|
|
|
imgs_pos = [0] * len(imgs)
|
|
|
|
for i in write_order:
|
|
|
|
imgs_pos[i] = f.tell()
|
|
|
|
f.write(imgs_bytes[i])
|
2021-05-08 08:54:34 +02:00
|
|
|
|
2024-01-11 12:41:11 +01:00
|
|
|
if version == "jp":
|
2021-07-16 13:08:22 +02:00
|
|
|
# jp padding?
|
|
|
|
f.write(b"\x00" * 0x10)
|
|
|
|
|
2021-05-08 08:54:34 +02:00
|
|
|
f.seek(0)
|
2024-01-11 12:41:11 +01:00
|
|
|
for pos in imgs_pos:
|
|
|
|
f.write(pos.to_bytes(4, byteorder="big"))
|