pokegold-spaceworld/tools/dump_text.py

51 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/python3
from sys import argv, stdout
char_table = [
"?", "イ゛", "", "エ゛", "オ゛", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "<PLAY_G>", "<0x15>", "<0x16>", "ネ゛", "<JP_18>", "", "", "", "", "<NI>", "<TTE>", "<WO>",
"ィ゛", "あ゛", "<TA!>", "<KOUGEKI>", "<WA>", "<NO>", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "<ROUTE>", "<WATASHI>", "<KOKO_WA>", "<RED>", "<GREEN>", "", "", "", "", "", "<ENEMY>",
"", "", "", "", "", "", "", "", "", "<MOM>", "<GA>", "<_CONT>", "<SCROLL>", "も゜", "<NEXT>", "<LINE>",
"@", "<PARA>", "<PLAYER>", "<RIVAL>", "#", "<CONT>", "<……>", "<DONE>", "<PROMPT>", "<TARGET>", "<USER>", "<PC>", "<TM>", "<TRAINER>", "<ROCKET>", "<DEXEND>",
"", "", "", "D", "E", "F", "G", "H", "I", "V", "S", "L", "M", ":", "", "",
"", "", "", "", "", "<・・・>", "", "", "", "", "", "", "", "", "", " ",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "×", ".", "/", "", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
]
if len(argv) != 4:
print(f"Usage: {argv[0]} path/to/ROM.gb start_offset end_offset\noffsets are in the form bank:address (both hex), and end_offset is *not* included.")
exit(1)
try:
start_bank,start_addr = [ int(s, 16) for s in argv[2].split(':') ]
end_bank, end_addr = [ int(s, 16) for s in argv[3].split(':') ]
if start_bank != 0:
start_addr += (start_bank - 1) * 0x4000
if end_bank != 0:
end_addr += (end_bank - 1) * 0x4000
except Error:
print("Please specify valid offsets (bank:address, both hex)")
exit(1)
with open(argv[1], "rb") as f:
f.seek(start_addr)
string = ""
while start_addr < end_addr:
string += char_table[ int.from_bytes(f.read(1), "little") ]
start_addr += 1
stdout.buffer.write( f"db \"{string}\"\n".encode('utf-8') )