mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 12:02:30 +01:00
update msg building for precomp
This commit is contained in:
parent
559007d861
commit
715e469ab9
@ -338,10 +338,12 @@ def strip_c_comments(text):
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(argv) < 3:
|
||||
print("usage: parse_compile.py [in.msg] [out.msgpack]")
|
||||
print("usage: parse_compile.py [in.msg] [out.msgpack] [--c]")
|
||||
exit(1)
|
||||
|
||||
_, filename, outfile = argv
|
||||
filename = argv[1]
|
||||
outfile = argv[2]
|
||||
is_output_format_c = "--c" in argv
|
||||
|
||||
messages = []
|
||||
|
||||
@ -392,7 +394,17 @@ if __name__ == "__main__":
|
||||
|
||||
directive = directive.split(":")
|
||||
|
||||
if directive[0] != "#message" or len(directive) != 3:
|
||||
if directive[0] != "#message":
|
||||
print(f"{filename}:{lineno}: expected #message directive")
|
||||
exit(1)
|
||||
if is_output_format_c:
|
||||
if len(directive) != 2:
|
||||
print(f"{filename}:{lineno}: expected #message:NAME directive")
|
||||
exit(1)
|
||||
|
||||
message = Message(directive[1], None, None)
|
||||
else:
|
||||
if len(directive) != 3:
|
||||
print(f"{filename}:{lineno}: expected #message:SECTION:INDEX directive")
|
||||
exit(1)
|
||||
|
||||
@ -1100,6 +1112,17 @@ if __name__ == "__main__":
|
||||
print(f"{filename}: missing [end]")
|
||||
exit(1)
|
||||
|
||||
if is_output_format_c:
|
||||
with open(outfile, "w") as f:
|
||||
f.write(f"#include <ultra64.h>\n")
|
||||
|
||||
for message in messages:
|
||||
f.write(f"static s8 {message.name}[] = {{\n")
|
||||
for b in message.bytes:
|
||||
f.write(f"0x{b:02X},")
|
||||
f.write(f"\n}};\n")
|
||||
|
||||
else:
|
||||
with open(outfile, "wb") as f:
|
||||
msgpack.pack([{
|
||||
"section": message.section,
|
||||
|
Loading…
Reference in New Issue
Block a user