diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-09-01 00:14:36 -0700 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-09-01 00:14:36 -0700 |
commit | 6a7af346c0f12fc8126c3c62f4393ec3949d6c5c (patch) | |
tree | fd63e7757cab9d9c4ca5384aba1f3cc3f008d625 /redtools/add_map_labels_to_map_headers.py | |
parent | e2fb614cae9b0080382d76c620955b446d59a0a5 (diff) | |
parent | a5b718db57a361cf3c196d73cbc5b3e21d3ddf6e (diff) |
Merge pull request #3 from kanzure/dump-pokered-extras
Dump pokered extras
Diffstat (limited to 'redtools/add_map_labels_to_map_headers.py')
-rw-r--r-- | redtools/add_map_labels_to_map_headers.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/redtools/add_map_labels_to_map_headers.py b/redtools/add_map_labels_to_map_headers.py new file mode 100644 index 0000000..89e6f36 --- /dev/null +++ b/redtools/add_map_labels_to_map_headers.py @@ -0,0 +1,41 @@ +#author: Bryan Bishop <kanzure@gmail.com> +#date: 2011-01-04 +#purpose: insert labels into map headers +import sys + +asm = None +asm_lines = [] +def load_asm(): + global asm, asm_lines + asm = open("../pokered.asm", "r").read() + asm_lines = asm.split("\n") + +def find_with_start_of_line(name): + global asm_lines + for line in asm_lines: + if len(line) > len(name) and ": " in line: + if line[:len(name)] == name: return True + return False + +def process_lines(): + global asm, asm_lines + for line in asm_lines: + if not "_h:" in line: continue #skip + index = asm_lines.index(line) + name = line.split("_h:")[0] + + if "Blocks" in asm_lines[index+3]: continue #skip, already done + #if not (str(name + "Blocks:") in asm): continue #skip, no block label found + if not find_with_start_of_line(name + "Blocks:"): continue #skip + + orig_line = asm_lines[index+3] + fixed_line = orig_line.split(",") + fixed_line[0] = " dw " + name + "Blocks" + fixed_line = ",".join(fixed_line) + + asm_lines[index+3] = fixed_line + +if __name__ == "__main__": + load_asm() + process_lines() + sys.stdout.write("\n".join(asm_lines)) |