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/make_map_size_constants.py | |
parent | e2fb614cae9b0080382d76c620955b446d59a0a5 (diff) | |
parent | a5b718db57a361cf3c196d73cbc5b3e21d3ddf6e (diff) |
Merge pull request #3 from kanzure/dump-pokered-extras
Dump pokered extras
Diffstat (limited to 'redtools/make_map_size_constants.py')
-rw-r--r-- | redtools/make_map_size_constants.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/redtools/make_map_size_constants.py b/redtools/make_map_size_constants.py new file mode 100644 index 0000000..4dfb1be --- /dev/null +++ b/redtools/make_map_size_constants.py @@ -0,0 +1,37 @@ +#author: Bryan Bishop <kanzure@gmail.com> +#date: 2012-01-15 +#dump map height/width constants +import extract_maps +from pretty_map_headers import map_name_cleaner, map_constants + +def get_map_size_constants(do_sed=False): + output = "" + sed_lines = "" + for map_id in extract_maps.map_headers.keys(): + if map_id in extract_maps.bad_maps: continue #skip + + map2 = extract_maps.map_headers[map_id] + base_name = map_name_cleaner(map2["name"], None)[:-2] + constant_name = map_constants[map_id] + + height = int(map2["y"], 16) + width = int(map2["x"], 16) + + output += "; " + base_name + "_h map_id=" + str(map_id) + "\n" + output += constant_name + "_HEIGHT EQU $%.2x\n" % (height) + output += constant_name + "_WIDTH EQU $%.2x\n" % (width) + output += "\n" + + sed_lines += "sed -i 's/" + base_name + "Height/" + constant_name + "_HEIGHT" + "/g' main.asm" + "\n" + sed_lines += "sed -i 's/" + base_name + "Width/" + constant_name + "_WIDTH" + "/g' main.asm" + "\n" + + if do_sed: + return sed_lines + else: + return output + +if __name__ == "__main__": + extract_maps.load_rom() + extract_maps.load_map_pointers() + extract_maps.read_all_map_headers() + print get_map_size_constants(do_sed=True) |