import struct import json import sys class BGIScript: def __init__(self, path: str): self.path = path with open(path, 'rb') as f: self.data = bytearray(f.read()) self.read_header() self.get_instr_end() def read_header(self): self.header_size = struct.unpack('= 3: json_f = sys.argv[2] output = f"../patched/{base}" if len(sys.argv) >= 4: output = sys.argv[3] scr = BGIScript(base) print(scr.header_size) print(scr.iPos) print(scr.last_pos) with open(json_f, "r", encoding="utf-8") as f: data = json.load(f) scr.setup_values(data) scr.save_as(output)