From e05d4fa19330455d78bba397c6f02b54eb50a5f8 Mon Sep 17 00:00:00 2001 From: Mc-muffin <8714476+Mc-muffin@users.noreply.github.com> Date: Wed, 6 Sep 2023 03:34:22 -0500 Subject: [PATCH] Create bin_to_tbl.py --- bin_to_tbl.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 bin_to_tbl.py diff --git a/bin_to_tbl.py b/bin_to_tbl.py new file mode 100644 index 0000000..bff9383 --- /dev/null +++ b/bin_to_tbl.py @@ -0,0 +1,29 @@ +import json + +big_ass_array = [] +TBL_BIN_PATH = "./00014.bin" + +with open(TBL_BIN_PATH, "rb") as f: + while cp := f.read(2): + cp = cp[::-1] + big_ass_array.append(cp.decode("cp932")) + +data = dict() +for index in range(len(big_ass_array)): + + btm = (index % 0xBB) + 0x40 + if 0x5B < btm: + btm += 1 + if 0x7E < btm: + btm += 1 + + top = (index // 0xBB) + 0x99 + if 0x9F < top: + top += 0x40 + + character = btm | (top << 8) + + data[f"{character:X}"] = big_ass_array[index] + +with open("tbl.json", "w", encoding="utf-8") as f: + json.dump(data, f, ensure_ascii=False, indent=4)