oh no i wanted music
This commit is contained in:
parent
c1d0668a3a
commit
f3482fbf08
30
scripts/extract_ktsl2stbin.py
Executable file
30
scripts/extract_ktsl2stbin.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p python3
|
||||
import struct
|
||||
import sys
|
||||
import pathlib
|
||||
|
||||
# i don't care about efficiency
|
||||
data = open(sys.argv[1], "rb").read()
|
||||
outdir = pathlib.Path(sys.argv[2])
|
||||
|
||||
if data[:4] != b"KTSR":
|
||||
raise Exception("what are you doing")
|
||||
|
||||
# there's some more stuff but i don't care, go straight to the entry
|
||||
off = 0x40
|
||||
idx = 0
|
||||
while off < len(data):
|
||||
|
||||
if data[off + 0x40 : off + 0x44] != b"KTSS":
|
||||
raise Exception("oh no offset broken")
|
||||
|
||||
(entry_size,) = struct.unpack("<I", data[off + 4 : off + 8])
|
||||
|
||||
(size,) = struct.unpack("<I", data[off + 0x44 : off + 0x48])
|
||||
outfile = (outdir / f"{idx}.ktss").open("wb")
|
||||
outfile.write(data[off + 0x40 : off + 0x40 + size])
|
||||
|
||||
off += entry_size
|
||||
idx += 1
|
||||
print(idx, hex(off))
|
Loading…
Reference in a new issue