gists/ds1/param_notes.py
2019-03-11 06:20:06 +01:00

27 lines
741 B
Python

from sys import argv
from struct import unpack as U
big_endian = False
if len(argv) > 2:
big_endian = argv[2] == "big"
with open(argv[1], "rb") as f:
f.seek(0xA)
if big_endian:
count = U(">h", f.read(2))[0]
else:
count = U("<h", f.read(2))[0]
for i in range(count):
f.seek(0x30 + i * 3 * 4)
if big_endian:
entryID, paramAddr, infoAddr = U(">iii", f.read(3 * 4))
else:
entryID, paramAddr, infoAddr = U("<iii", f.read(3 * 4))
if infoAddr not in (0, -1):
f.seek(infoAddr)
string = f.read()
string = string[:string.index(b"\0")]
print(entryID, string.decode("shift-jis", errors="replace"), sep="\t")