diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-01-15 17:20:06 -0600 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-01-15 17:20:06 -0600 |
commit | f0d8e69adcb176e82deb588c6b6e1ba8a12f5123 (patch) | |
tree | 6c33b6ab3536059e2c96365d7190617ecb6a11ef /extras/replace_dimensions.py | |
parent | f8291c9cda3d4be6ba29a61280bd33e89f375e35 (diff) |
replace connection pointers with formulas
hg-commit-id: 92972d3acaea
Diffstat (limited to 'extras/replace_dimensions.py')
-rw-r--r-- | extras/replace_dimensions.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/extras/replace_dimensions.py b/extras/replace_dimensions.py index 86645e83..99692cce 100644 --- a/extras/replace_dimensions.py +++ b/extras/replace_dimensions.py @@ -4,7 +4,8 @@ #replace dimensions with constants import sys #for non-newline-terminated output :/ from add_map_labels_to_map_headers import find_with_start_of_line -from pretty_map_headers import map_name_cleaner, spacing +from pretty_map_headers import map_name_cleaner, spacing, offset_to_pointer, map_constants +from connection_helper import print_connections asm = None asm_lines = None @@ -23,7 +24,7 @@ def find_line_starting_with(value): id += 1 return False #not found -def replace_dimensions(): +def replace_values(): global asm_lines for map_id in extract_maps.map_headers.keys(): if map_id in extract_maps.bad_maps: continue #skip @@ -34,9 +35,28 @@ def replace_dimensions(): line_number = find_line_starting_with(label_name) if line_number == False: continue #skip, not found + #replace dimensions if necessary if "dimensions" in asm_lines[line_number + 2] and "$" in asm_lines[line_number + 2] and not "\t" in asm_lines[line_number+2]: asm_lines[line_number + 2] = spacing + "db " + clean_name + "Height, " + clean_name + "Width ; dimensions (y, x)" + #skip the rest of this if there are no connections + if len(map1["connections"]) == 0: continue + if not "; connections data" in asm_lines[line_number + 6]: continue + + connection_offset = line_number + 8 + + for connection_id in map1["connections"]: + if "dw $" in asm_lines[connection_offset + 1]: + formula = print_connections(map_id, in_connection_id=connection_id) + + temp_line = asm_lines[connection_offset + 1] + temp_line = spacing + "dw " + formula + temp_line[12:] + + asm_lines[connection_offset + 1] = temp_line + + connection_offset += 6 + + if __name__ == "__main__": import extract_maps extract_maps.load_rom() @@ -44,6 +64,6 @@ if __name__ == "__main__": extract_maps.read_all_map_headers() load_asm() - replace_dimensions() + replace_values() sys.stdout.write("\n".join(asm_lines)) |