import mmap import struct import json from pathlib import Path # Generate Hiragana and Katakana characters hiragana = tuple(chr(i) for i in range(12353, 12436)) # \u3041 - \u3094 katakana = tuple(chr(i) for i in range(12450, 12532)) # \u30A2 - \u30F4 # Combine both into one tuple all_kana = hiragana + katakana # Print example print(all_kana) prop_data = Path(f"YGO_2020/bin/CARD_Prop.bin").read_bytes() # Get all the bytes language_code = 'J' offsets_data = Path(f"YGO_2020/bin/CARD_Indx_{language_code}.bin").read_bytes() # Get all the bytes name_data = Path(f"YGO_2020/bin/CARD_Name_{language_code}.bin").read_bytes() # Get all the bytes desc_data = Path(f"YGO_2020/bin/CARD_Desc_{language_code}.bin").read_bytes() offsets = [x[0] for x in struct.iter_unpack(" 0: if words.get(word) is None: words[word] = 0 print(word) words[word] = (words[word] + 1) word = '' else: word += char if len(word) > 0: if words.get(word) is None: words[word] = 0 print(word) words[word] = (words[word] + 1) end = desc_start_off while end + 1 < len(desc_data): ## Read 2 bytes at a time until null found if desc_data[end:end+2] == b"\x00\x00": break end += 2 desc = desc_data[desc_start_off:end].decode("utf-16le", errors="replace") #print(name) cd_db[cd_db_ctr] = {"nm":name, "de": desc, "nm_addr":hex(name_start_off), "de_addr":hex(desc_start_off)} cd_db_ctr += 1 #print() ## Iterate offset off += 2 language_code = 'E' offsets_data = Path(f"YGO_2020/bin/CARD_Indx_{language_code}.bin").read_bytes() # Get all the bytes name_data = Path(f"YGO_2020/bin/CARD_Name_{language_code}.bin").read_bytes() # Get all the bytes desc_data = Path(f"YGO_2020/bin/CARD_Desc_{language_code}.bin").read_bytes() offsets = [x[0] for x in struct.iter_unpack("