-
Notifications
You must be signed in to change notification settings - Fork 4
/
msgdis.py
84 lines (58 loc) · 2.9 KB
/
msgdis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import argparse
import os
import msg_decode
import find_text_table
def main():
description = ""
epilog = ""
parser = argparse.ArgumentParser(description=description, epilog=epilog, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("code", help="code file to read.")
parser.add_argument("region", choices=["n", "p"], help="code file to read.")
args = parser.parse_args()
find_text_table.findTextTablesMMap(args.code)
find_text_table.read_tables(args.code)
jpn_message_data_static = os.path.join(os.path.split(args.code)[0], "jpn_message_data_static")
nes_message_data_static = os.path.join(os.path.split(args.code)[0], "nes_message_data_static")
if not find_text_table.regionIsPAL:
for i in range(len(find_text_table.jpn_message_entry_table)):
curEntry = find_text_table.jpn_message_entry_table[i]
if curEntry[0] == 0xFFFF:
continue
start = find_text_table.segmented_to_offset(curEntry[3])
nextEntry = find_text_table.jpn_message_entry_table[i+1]
end = find_text_table.segmented_to_offset(nextEntry[3])
# print("{:X},{},{},{:X}".format(*curEntry))
# print("{:X},{},{},{:X}".format(*nextEntry))
# print(f"{start:X},{end:X}")
print("char jpn_message_{:04X}[] = ".format(curEntry[0]))
data = msg_decode.read_data(jpn_message_data_static, start, end)
msg_decode.decode_msg(data, "jpn")
print(";\n")
# print("{:X}".format(len(data)))
for i in range(len(find_text_table.nes_message_entry_table)):
curEntry = find_text_table.nes_message_entry_table[i]
if curEntry[0] == 0xFFFF:
continue
start = find_text_table.segmented_to_offset(curEntry[3])
nextEntry = find_text_table.nes_message_entry_table[i+1]
end = find_text_table.segmented_to_offset(nextEntry[3])
# print("{:X},{},{},{:X}".format(*curEntry))
# print("{:X},{},{},{:X}".format(*nextEntry))
# print(f"{start:X},{end:X}")
print("char nes_message_{:04X}[] = ".format(curEntry[0]))
data = msg_decode.read_data(nes_message_data_static, start, end)
msg_decode.decode_msg(data, "nes")
print(";\n")
# print("{:X}".format(len(data)))
else:
for i,curEntry in enumerate(find_text_table.pal_combined_message_entry_table):
start = find_text_table.segmented_to_offset(curEntry[3])
nextEntry = find_text_table.pal_combined_message_entry_table[i+1]
end = find_text_table.segmented_to_offset(nextEntry[3])
if curEntry[0] == 0xFFFF:
continue
elif curEntry[0] == 0xFFFC:
print("#ifdef MESSAGE_FFFC")
print(");\n")
if __name__ == "__main__":
main()