From 25fdbab10d6047fbbfc4e5ad15b288796e648bb3 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 20 Sep 2025 14:19:55 +0800 Subject: [PATCH] Add script to unpack softpal text.dat --- unpack_softpal_text_dat.py | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 unpack_softpal_text_dat.py diff --git a/unpack_softpal_text_dat.py b/unpack_softpal_text_dat.py new file mode 100644 index 0000000..2f990e1 --- /dev/null +++ b/unpack_softpal_text_dat.py @@ -0,0 +1,73 @@ +import struct +from io import BytesIO +import json +from os.path import splitext + + +def read_u32(f): + return struct.unpack('> (8 - rshift)) + + +def decrypt(data: bytes) -> BytesIO: + pos = 0x10 + shift = 4 + decrypted = bytearray(data) + while pos + 4 <= len(decrypted): + data = decrypted[pos:pos+4] + data[0] = rotate_left(data[0], shift) + shift = (shift + 1) % 8 + data = struct.unpack(' [] []") + sys.exit(1) + + filename = sys.argv[1] + output = sys.argv[2] if len(sys.argv) > 2 else splitext(filename)[0] + '.json' + encoding = sys.argv[3] if len(sys.argv) > 3 else 'cp932' + + with open(filename, 'rb') as f: + table = load_text_data(f, encoding) + with open(output, 'w', encoding='utf-8') as f: + json.dump(table, f, ensure_ascii=False, indent=4) +