diff options
Diffstat (limited to 'redtools')
-rw-r--r-- | redtools/analyze_incbins.py | 32 | ||||
-rw-r--r-- | redtools/analyze_texts.py | 38 | ||||
-rw-r--r-- | redtools/connection_helper.py | 8 | ||||
-rw-r--r-- | redtools/extract_tileblocks.py | 6 | ||||
-rw-r--r-- | redtools/extract_tilesets.py | 8 | ||||
-rw-r--r-- | redtools/fix_labels.py | 24 | ||||
-rw-r--r-- | redtools/gbz80disasm.py | 16 | ||||
-rw-r--r-- | redtools/generate_sys.py | 3 | ||||
-rw-r--r-- | redtools/insert_object_data.py | 16 | ||||
-rw-r--r-- | redtools/insert_texts.py | 92 | ||||
-rw-r--r-- | redtools/make_map_size_constants.py | 8 | ||||
-rw-r--r-- | redtools/map_block_dumper.py | 26 | ||||
-rw-r--r-- | redtools/pretty_map_headers.py | 16 | ||||
-rw-r--r-- | redtools/pretty_text.py | 6 | ||||
-rw-r--r-- | redtools/pretty_trainer_headers.py | 28 | ||||
-rw-r--r-- | redtools/replace_dimensions.py | 9 | ||||
-rw-r--r-- | redtools/romvisualizer.py | 5 | ||||
-rw-r--r-- | redtools/romviz.py | 12 | ||||
-rw-r--r-- | redtools/sprite_helper.py | 16 | ||||
-rw-r--r-- | redtools/text_pointers.py | 16 |
20 files changed, 211 insertions, 174 deletions
diff --git a/redtools/analyze_incbins.py b/redtools/analyze_incbins.py index db503ff..9bddacd 100644 --- a/redtools/analyze_incbins.py +++ b/redtools/analyze_incbins.py @@ -1,3 +1,5 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-03 #purpose: map which addresses are left @@ -6,11 +8,11 @@ import sys, os from copy import copy, deepcopy import subprocess import json -from extract_maps import rom, assert_rom, load_rom, calculate_pointer, load_map_pointers, read_all_map_headers, map_headers -from pokered_dir import pokered_dir +from .extract_maps import rom, assert_rom, load_rom, calculate_pointer, load_map_pointers, read_all_map_headers, map_headers +from .pokered_dir import pokered_dir try: - from pretty_map_headers import map_header_pretty_printer, map_name_cleaner + from .pretty_map_headers import map_header_pretty_printer, map_name_cleaner except Exception: pass @@ -183,9 +185,9 @@ def generate_diff_insert(line_number, newline): diffcontent = subprocess.check_output( "diff -u {0} {1}".format(os.path.join(pokered_dir, "main.asm"), newfile_filename), shell=True) - except AttributeError, exc: + except AttributeError as exc: raise exc - except Exception, exc: + except Exception as exc: diffcontent = exc.output os.system("rm " + original_filename) @@ -197,7 +199,7 @@ def insert_map_header_asm(map_id): map = map_headers[map_id] line_number = find_incbin_to_replace_for(map["address"]) if line_number == None: # or map_name_cleaner(map["name"], 0) in "\n".join(line for line in asm): - print "i think map id=" + str(map_id) + " has previously been added." + print("i think map id=" + str(map_id) + " has previously been added.") return #this map has already been added i bet newlines = split_incbin_line_into_three(line_number, map["address"], 12 + (11 * len(map["connections"]))) @@ -213,8 +215,8 @@ def insert_map_header_asm(map_id): diff = generate_diff_insert(line_number, newlines) - print diff - print "... Applying diff." + print(diff) + print("... Applying diff.") #write the diff to a file fh = open("temp.patch", "w") @@ -236,7 +238,7 @@ def wrapper_insert_map_header_asm(map_id): def dump_all_remaining_maps(): for map_id in map_headers: - print "Inserting map id=" + str(map_id) + print("Inserting map id=" + str(map_id)) wrapper_insert_map_header_asm(map_id) def reset_incbins(): @@ -249,7 +251,7 @@ def reset_incbins(): process_incbins() def apply_diff(diff, try_fixing=True, do_compile=True): - print "... Applying diff." + print("... Applying diff.") #write the diff to a file fh = open("temp.patch", "w") @@ -272,7 +274,7 @@ def apply_diff(diff, try_fixing=True, do_compile=True): try: subprocess.check_call("cd {0}; make clean; LC_CTYPE=C make".format(pokered_dir), shell=True) return True - except Exception, exc: + except Exception as exc: if try_fixing: os.system("mv {0} {1}".format( os.path.join(pokered_dir, "main1.asm"), @@ -390,7 +392,7 @@ def get_labels_between(start_line_id, end_line_id, bank_id): else: local_pointer = hex((address % 0x4000) + 0x4000).replace("0x", "$") - print line_label + " is at " + hex(address) + print(line_label + " is at " + hex(address)) label = { "line_number": line_id, @@ -438,7 +440,7 @@ def scan_for_predefined_labels(): else: end_line_id = len(asm) - 1 - print "bank" + abbreviation + " starts at " + str(start_line_id) + " to " + str(end_line_id) + print("bank" + abbreviation + " starts at " + str(start_line_id) + " to " + str(end_line_id)) bank_intervals[bank_id] = { "start": start_line_id, @@ -502,6 +504,6 @@ if __name__ == "__main__": #dump_all_remaining_maps() scan_for_predefined_labels() - print "Errors:" - print label_errors + print("Errors:") + print(label_errors) diff --git a/redtools/analyze_texts.py b/redtools/analyze_texts.py index 08b8ab0..0f17a38 100644 --- a/redtools/analyze_texts.py +++ b/redtools/analyze_texts.py @@ -1,11 +1,13 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-06 #analyze texts, how many commands are unknown? -import extract_maps -import analyze_incbins #for asm +from . import extract_maps +from . import analyze_incbins #for asm try: - from pretty_map_headers import map_name_cleaner, txt_bytes, spacing, constant_abbreviation_bytes -except Exception, exc: pass + from .pretty_map_headers import map_name_cleaner, txt_bytes, spacing, constant_abbreviation_bytes +except Exception as exc: pass from operator import itemgetter import sys debug = False #set to True to increase logging output @@ -31,7 +33,7 @@ def how_many_until(byte, starting): def print_command_debug_info(command_byte, text_id, text_pointer, map_id): if debug: - print "byte is " + str(command_byte) + " on text #" + str(text_id) + " at " + hex(text_pointer) + " on map " + str(map_id) + " (" + extract_maps.map_headers[map_id]["name"] + ")" + print("byte is " + str(command_byte) + " on text #" + str(text_id) + " at " + hex(text_pointer) + " on map " + str(map_id) + " (" + extract_maps.map_headers[map_id]["name"] + ")") def add_command_byte_to_totals(byte): global totals @@ -155,7 +157,7 @@ def parse_text_script(text_pointer, text_id, map_id, txfar=False): #use this to look at the surrounding bytes if debug: - print "next command is: " + hex(ord(extract_maps.rom[offset])) + " ... we are at command number: " + str(command_counter) + " near " + hex(offset) + " on map_id=" + str(map_id) + " for text_id=" + str(text_id) + " and txfar(recursion)=" + str(txfar) + print("next command is: " + hex(ord(extract_maps.rom[offset])) + " ... we are at command number: " + str(command_counter) + " near " + hex(offset) + " on map_id=" + str(map_id) + " for text_id=" + str(text_id) + " and txfar(recursion)=" + str(txfar)) elif command_byte == 0x7: #07 = shift texts 1 row above (2nd line becomes 1st line); address for next text = 2nd line. [07] size = 1 @@ -317,7 +319,7 @@ def parse_text_script(text_pointer, text_id, map_id, txfar=False): #if len(commands) > 0: # print "Unknown text command " + hex(command_byte) + " at " + hex(offset) + ", script began with " + hex(commands[0]["type"]) if debug: - print "Unknown text command at " + hex(offset) + " - command: " + hex(ord(extract_maps.rom[offset])) + " on map_id=" + str(map_id) + " text_id=" + str(text_id) + print("Unknown text command at " + hex(offset) + " - command: " + hex(ord(extract_maps.rom[offset])) + " on map_id=" + str(map_id) + " text_id=" + str(text_id)) #end at the first unknown command end = True @@ -359,7 +361,7 @@ def analyze_texts(): if debug: if len(TX_FAR.keys()) > 0: #print "TX_FAR object: " + str(TX_FAR) - print "processing a TX_FAR at " + hex(commands[command_id]["pointer"]) + "... first byte is: " + str(ord(extract_maps.rom[commands[command_id]["pointer"]])) + " .. offset: " + hex(commands[command_id]["pointer"]) + print("processing a TX_FAR at " + hex(commands[command_id]["pointer"]) + "... first byte is: " + str(ord(extract_maps.rom[commands[command_id]["pointer"]])) + " .. offset: " + hex(commands[command_id]["pointer"])) ##sys.exit(0) commands[command_id]["TX_FAR"] = TX_FAR @@ -382,7 +384,7 @@ def find_missing_08s(all_texts): if "type" in current_line.keys(): if current_line["type"] == 0x8: missing_08s += 1 - print "missing $08 on map_id=" + str(map_id) + " text_id=" + str(text_id) + " line_id=" + str(line_id) + " at " + hex(current_line["start_address"]) + print("missing $08 on map_id=" + str(map_id) + " text_id=" + str(text_id) + " line_id=" + str(line_id) + " at " + hex(current_line["start_address"])) return missing_08s def text_pretty_printer_at(start_address, label="SomeLabel"): @@ -412,7 +414,7 @@ def text_pretty_printer_at(start_address, label="SomeLabel"): if not "lines" in commands[this_command].keys(): command = commands[this_command] if not "type" in command.keys(): - print "ERROR in command: " + str(command) + print("ERROR in command: " + str(command)) continue #dunno what to do here? if command["type"] == 0x1: #TX_RAM @@ -501,7 +503,7 @@ def text_pretty_printer_at(start_address, label="SomeLabel"): byte_count += 1 had_db_last = True else: - print "ERROR in command: " + hex(command["type"]) + print("ERROR in command: " + hex(command["type"])) had_db_last = False #everything else is for $0s, really @@ -585,7 +587,7 @@ def text_pretty_printer_at(start_address, label="SomeLabel"): if len(output)!=0 and output[-1] == "\n": include_newline = "" output += include_newline + "; " + hex(start_address) + " + " + str(byte_count) + " bytes = " + hex(start_address + byte_count) - print output + print(output) return (output, byte_count) def is_label_in_asm(label): @@ -619,16 +621,16 @@ def find_undone_texts(): address = extract_maps.map_headers[map_id]["texts"][text_id][1]["start_address"] if not is_label_in_asm(label): - print label + " map_id=" + str(map_id) + " text_id=" + str(text_id) + " at " + hex(address) + " byte is: " + hex(ord(extract_maps.rom[address])) + print(label + " map_id=" + str(map_id) + " text_id=" + str(text_id) + " at " + hex(address) + " byte is: " + hex(ord(extract_maps.rom[address]))) if not address in usable_table.keys(): usable_table[address] = 1 else: usable_table[address] += 1 - print "\n\n which ones are priority?" + print("\n\n which ones are priority?") sorted_results = sorted(usable_table.iteritems(), key=itemgetter(1), reverse=True) for result in sorted_results: - print str(result[1]) + " times: " + hex(result[0]) + print(str(result[1]) + " times: " + hex(result[0])) def scan_rom_for_tx_fars(printer=True): """find TX_FARs @@ -675,14 +677,14 @@ def scan_rom_for_tx_fars(printer=True): if address_bundle[0] in pre_handled: continue #already did this - print "-------" - print "TX_FAR is at: " + hex(address_bundle[1]) + print("-------") + print("TX_FAR is at: " + hex(address_bundle[1])) #let's try printing out the TX_FAR? text_pretty_printer_at(address_bundle[1], "blah") text_pretty_printer_at(address_bundle[0], "_blah") - print "-------" + print("-------") pre_handled.append(address_bundle[0]) return possible_tx_far_targets diff --git a/redtools/connection_helper.py b/redtools/connection_helper.py index c15b358..d6306ad 100644 --- a/redtools/connection_helper.py +++ b/redtools/connection_helper.py @@ -1,8 +1,10 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-15 #help with connection math -import extract_maps -from pretty_map_headers import map_constants, map_name_cleaner, offset_to_pointer +from . import extract_maps +from .pretty_map_headers import map_constants, map_name_cleaner, offset_to_pointer def print_connections(map_id, in_connection_id=None, do_output=False): map1 = extract_maps.map_headers[map_id] @@ -101,4 +103,4 @@ if __name__ == "__main__": for map_id in extract_maps.map_headers.keys(): if map_id not in extract_maps.bad_maps: - print print_connections(map_id, do_output=True) + print(print_connections(map_id, do_output=True)) diff --git a/redtools/extract_tileblocks.py b/redtools/extract_tileblocks.py index 1d01c34..a8a8182 100644 --- a/redtools/extract_tileblocks.py +++ b/redtools/extract_tileblocks.py @@ -1,3 +1,5 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-14 #split out blocksets into binary data files @@ -5,7 +7,7 @@ # but it's too many lines and will probably crash rgbasm. import sys -import extract_maps +from . import extract_maps extract_maps.load_rom() spacing = " " @@ -77,7 +79,7 @@ for tileblock_id in tileblocks.keys(): fh.write(main_data) fh.close() - print output + print(output) """ Tset00_Block: diff --git a/redtools/extract_tilesets.py b/redtools/extract_tilesets.py index a0eb477..ca99606 100644 --- a/redtools/extract_tilesets.py +++ b/redtools/extract_tilesets.py @@ -1,7 +1,9 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-14 #throw tilesets into separate files -import extract_maps +from . import extract_maps extract_maps.load_rom() locations = { @@ -29,9 +31,9 @@ locations = { for tileset_id in locations.keys(): tileset = locations[tileset_id] - print "writing ../gfx/tilesets/" + tileset[2] + ".2bpp" + print("writing ../gfx/tilesets/" + tileset[2] + ".2bpp") fh = open("../gfx/tilesets/" + tileset[2] + ".2bpp", "w") fh.write(extract_maps.rom[tileset[0]:tileset[1]]) fh.close() -print "Done." +print("Done.") diff --git a/redtools/fix_labels.py b/redtools/fix_labels.py index 321a18e..13350f6 100644 --- a/redtools/fix_labels.py +++ b/redtools/fix_labels.py @@ -1,12 +1,14 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-27 #fix trainer header labels to not suck so much -import analyze_incbins +from . import analyze_incbins def replace_trainer_header_labels(debug=False): """trainer header labels could be better""" asm = analyze_incbins.asm - if debug: print str(type(asm)) + if debug: print(str(type(asm))) single_asm = "\n".join(asm) current_map_name = "asdjkl;" line_id = 0 @@ -31,8 +33,8 @@ def replace_trainer_header_labels(debug=False): new_label = current_map_name + "TH" + str(trainer_header_counter) #trainer_header_name single_asm = single_asm.replace(old_label + ":", new_label + ":") single_asm = single_asm.replace(old_label + "\n", new_label + "\n") - if debug: print "old_label = " + old_label - if debug: print "new_label = " + new_label + if debug: print("old_label = " + old_label) + if debug: print("new_label = " + new_label) trainer_header_counter += 1 @@ -50,8 +52,8 @@ def replace_trainer_header_labels(debug=False): single_asm = single_asm.replace(old_label + ":", new_label + ":") single_asm = single_asm.replace(old_label + "\n", new_label + "\n") single_asm = single_asm.replace(old_label + " ;", new_label + " ;") - if debug: print "old_label = " + old_label - if debug: print "new_label = " + new_label + if debug: print("old_label = " + old_label) + if debug: print("new_label = " + new_label) #replace a text label elif " TextAfterBattle" in line and not current_map_name in line: old_label = line.split("dw ")[1].split(" ;")[0] @@ -59,8 +61,8 @@ def replace_trainer_header_labels(debug=False): single_asm = single_asm.replace(old_label + ":", new_label + ":") single_asm = single_asm.replace(old_label + "\n", new_label + "\n") single_asm = single_asm.replace(old_label + " ;", new_label + " ;") - if debug: print "old_label = " + old_label - if debug: print "new_label = " + new_label + if debug: print("old_label = " + old_label) + if debug: print("new_label = " + new_label) #replace a text label elif " TextEndBattle" in line and not current_map_name in line: old_label = line.split("dw ")[1].split(" ;")[0] @@ -68,12 +70,12 @@ def replace_trainer_header_labels(debug=False): single_asm = single_asm.replace(old_label + ":", new_label + ":") single_asm = single_asm.replace(old_label + "\n", new_label + "\n") single_asm = single_asm.replace(old_label + " ;", new_label + " ;") - if debug: print "old_label = " + old_label - if debug: print "new_label = " + new_label + if debug: print("old_label = " + old_label) + if debug: print("new_label = " + new_label) line_id += 1 - print single_asm + print(single_asm) if __name__ == "__main__": analyze_incbins.load_asm() diff --git a/redtools/gbz80disasm.py b/redtools/gbz80disasm.py index 396ce5b..f6711a8 100644 --- a/redtools/gbz80disasm.py +++ b/redtools/gbz80disasm.py @@ -1,10 +1,12 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-09 -import extract_maps +from . import extract_maps import os import json from copy import copy, deepcopy -from pretty_map_headers import random_hash, map_name_cleaner +from .pretty_map_headers import random_hash, map_name_cleaner from ctypes import c_int8 import sys @@ -530,7 +532,7 @@ temp_opt_table = [ conflict_table = {} for line in temp_opt_table: if line[1] in conflict_table.keys(): - print "CONFLICT: " + line[0] + " ($" + hex(line[1])[2:] + ") .... " + conflict_table[line[1]] + print("CONFLICT: " + line[0] + " ($" + hex(line[1])[2:] + ") .... " + conflict_table[line[1]]) else: conflict_table[line[1]] = line[0] @@ -562,8 +564,8 @@ def load_labels(filename="labels.json"): if os.path.exists(filename): all_labels = json.loads(open(filename, "r").read()) else: - print "You must run analyze_incbins.scan_for_predefined_labels() to create \"labels.json\". Trying..." - import analyze_incbins + print("You must run analyze_incbins.scan_for_predefined_labels() to create \"labels.json\". Trying...") + from . import analyze_incbins analyze_incbins.scan_for_predefined_labels() load_labels() @@ -607,7 +609,7 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000): bank_id = 0 if original_offset > 0x8000: bank_id = original_offset / 0x4000 - print "bank id is: " + str(bank_id) + print("bank id is: " + str(bank_id)) last_hl_address = None #for when we're scanning the main map script last_a_address = None @@ -849,4 +851,4 @@ if __name__ == "__main__": extract_maps.load_map_pointers() extract_maps.read_all_map_headers() - print output_bank_opcodes(int(sys.argv[1], 16))[0] + print(output_bank_opcodes(int(sys.argv[1], 16))[0]) diff --git a/redtools/generate_sys.py b/redtools/generate_sys.py index 7295703..a321cf4 100644 --- a/redtools/generate_sys.py +++ b/redtools/generate_sys.py @@ -1,6 +1,7 @@ +from __future__ import absolute_import import json -import analyze_incbins +from . import analyze_incbins analyze_incbins.scan_for_predefined_labels() with open('../pokered.sym', 'w') as sym: diff --git a/redtools/insert_object_data.py b/redtools/insert_object_data.py index e779c10..b275078 100644 --- a/redtools/insert_object_data.py +++ b/redtools/insert_object_data.py @@ -1,10 +1,12 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-05 #insert object data into pokered.asm -import extract_maps -from pretty_map_headers import map_name_cleaner, object_data_pretty_printer, make_object_label_name, make_text_label, map_constants -from analyze_incbins import asm, offset_to_pointer, find_incbin_to_replace_for, split_incbin_line_into_three, generate_diff_insert, load_asm, isolate_incbins, process_incbins -import analyze_incbins +from . import extract_maps +from .pretty_map_headers import map_name_cleaner, object_data_pretty_printer, make_object_label_name, make_text_label, map_constants +from .analyze_incbins import asm, offset_to_pointer, find_incbin_to_replace_for, split_incbin_line_into_three, generate_diff_insert, load_asm, isolate_incbins, process_incbins +from . import analyze_incbins import os, sys import subprocess spacing = " " @@ -17,7 +19,7 @@ def insert_object(map_id): line_number = find_incbin_to_replace_for(address) if line_number == None: - print "skipping object data for map " + str(map["id"]) + " at " + map["object_data_pointer"] + " for " + str(size) + " bytes." + print("skipping object data for map " + str(map["id"]) + " at " + map["object_data_pointer"] + " for " + str(size) + " bytes.") return newlines = split_incbin_line_into_three(line_number, address, size) @@ -36,9 +38,9 @@ def insert_object(map_id): newlines = "\n".join(line for line in newlines) diff = generate_diff_insert(line_number, newlines) - print diff + print(diff) - print "... Applying diff." + print("... Applying diff.") #write the diff to a file fh = open("temp.patch", "w") diff --git a/redtools/insert_texts.py b/redtools/insert_texts.py index d5a8015..f89d2da 100644 --- a/redtools/insert_texts.py +++ b/redtools/insert_texts.py @@ -1,14 +1,16 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-07, 2012-01-17, 2012-01-27 #insert TX_FAR targets into pokered.asm #and other insertion tasks -import extract_maps -from analyze_texts import analyze_texts, text_pretty_printer_at, scan_rom_for_tx_fars -from pretty_map_headers import map_name_cleaner, make_text_label, map_constants, find_all_tx_fars, tx_far_pretty_printer, tx_far_label_maker -import pretty_map_headers -from analyze_incbins import asm, offset_to_pointer, find_incbin_to_replace_for, split_incbin_line_into_three, generate_diff_insert, load_asm, isolate_incbins, process_incbins, reset_incbins, apply_diff -import analyze_incbins -from gbz80disasm import text_asm_pretty_printer, output_bank_opcodes, load_labels, find_label +from . import extract_maps +from .analyze_texts import analyze_texts, text_pretty_printer_at, scan_rom_for_tx_fars +from .pretty_map_headers import map_name_cleaner, make_text_label, map_constants, find_all_tx_fars, tx_far_pretty_printer, tx_far_label_maker +from . import pretty_map_headers +from .analyze_incbins import asm, offset_to_pointer, find_incbin_to_replace_for, split_incbin_line_into_three, generate_diff_insert, load_asm, isolate_incbins, process_incbins, reset_incbins, apply_diff +from . import analyze_incbins +from .gbz80disasm import text_asm_pretty_printer, output_bank_opcodes, load_labels, find_label import os, sys import subprocess spacing = " " @@ -66,13 +68,13 @@ def insert_tx_far(map_id, text_id, tx_far_line=None): line_number = find_incbin_to_replace_for(start_address) if line_number == None: - print "skipping tx_far for map_id=" + str(map_id) + " text_id=" + str(text_id) + " text_pointer=" + hex(text_pointer) + " tx_far_start_address=" + hex(start_address) + print("skipping tx_far for map_id=" + str(map_id) + " text_id=" + str(text_id) + " text_pointer=" + hex(text_pointer) + " tx_far_start_address=" + hex(start_address)) return #also do a name check label = tx_far_label_maker(extract_maps.map_headers[map_id]["name"], text_id) if (label + ":") in "\n".join(analyze_incbins.asm): - print "skipping tx_far for map_id=" + str(map_id) + " text_id=" + str(text_id) + " text_pointer=" + hex(text_pointer) + " tx_far_start_address=" + hex(start_address) + print("skipping tx_far for map_id=" + str(map_id) + " text_id=" + str(text_id) + " text_pointer=" + hex(text_pointer) + " tx_far_start_address=" + hex(start_address)) return newlines = split_incbin_line_into_three(line_number, start_address, end_address - start_address) @@ -105,8 +107,8 @@ def insert_tx_far(map_id, text_id, tx_far_line=None): newlines = newlines.replace("Char52", "$52") diff = generate_diff_insert(line_number, newlines) - print "working on map_id=" + str(map_id) + " text_id=" + str(text_id) - print diff + print("working on map_id=" + str(map_id) + " text_id=" + str(text_id)) + print(diff) apply_diff(diff) def insert_all_tx_far_targets(): @@ -184,12 +186,12 @@ def insert_texts_label(map_id): line_number = find_incbin_to_replace_for(texts_pointer) if line_number == None: - print "skipping texts label for map_id=" + str(map_id) + " texts_pointer=" + hex(texts_pointer) + " because the address is taken" + print("skipping texts label for map_id=" + str(map_id) + " texts_pointer=" + hex(texts_pointer) + " because the address is taken") return #also do a name check if (label + ":") in "\n".join(analyze_incbins.asm): - print "skipping texts label for map_id=" + str(map_id) + " texts_pointer=" + hex(texts_pointer) + " because the label is already used" + print("skipping texts label for map_id=" + str(map_id) + " texts_pointer=" + hex(texts_pointer) + " because the label is already used") return newlines = split_incbin_line_into_three(line_number, texts_pointer, len(map2["referenced_texts"])*2 ) @@ -208,8 +210,8 @@ def insert_texts_label(map_id): newlines = newlines.replace("$x", "$") diff = generate_diff_insert(line_number, newlines) - print "working on map_id=" + str(map_id) + " texts_pointer=" + hex(texts_pointer) - print diff + print("working on map_id=" + str(map_id) + " texts_pointer=" + hex(texts_pointer)) + print(diff) apply_diff(diff) #untested as of 2012-01-07 @@ -241,7 +243,7 @@ def txt_to_tx_far_pretty_printer(address, label, target_label, include_byte=Fals def insert_text_label_tx_far(map_id, text_id): if map_id in extract_maps.bad_maps: - print "bad map id=" + str(map_id) + print("bad map id=" + str(map_id)) return map2 = extract_maps.map_headers[map_id] if map2["texts"][text_id] == {0: {}}: return None @@ -253,7 +255,7 @@ def insert_text_label_tx_far(map_id, text_id): if 0x4000 <= start_address <= 0x7fff: start_address = extract_maps.calculate_pointer(start_address, int(map2["bank"],16)) include_byte = False - print map2["texts"][text_id] + print(map2["texts"][text_id]) if "type" in map2["texts"][text_id][1].keys(): if map2["texts"][text_id][1]["type"] == 0x50: include_byte = True @@ -261,12 +263,12 @@ def insert_text_label_tx_far(map_id, text_id): line_number = find_incbin_to_replace_for(start_address) if line_number == None: - print "skipping text label that calls TX_FAR for map_id=" + str(map_id) + " text_id=" + str(text_id) + " because the address is taken " + hex(start_address) + print("skipping text label that calls TX_FAR for map_id=" + str(map_id) + " text_id=" + str(text_id) + " because the address is taken " + hex(start_address)) return #also do a name check if 1 < ("\n".join(analyze_incbins.asm)).count("\n" + label + ":"): - print "skipping text label that calls TX_FAR for map_id=" + str(map_id) + " text_id" + str(text_id) + " because the label is already used (" + label + ":)" + print("skipping text label that calls TX_FAR for map_id=" + str(map_id) + " text_id" + str(text_id) + " because the label is already used (" + label + ":)") return extra = 0 @@ -288,8 +290,8 @@ def insert_text_label_tx_far(map_id, text_id): newlines = newlines.replace("$x", "$") diff = generate_diff_insert(line_number, newlines) - print "working on map_id=" + str(map_id) + " text_id=" + str(text_id) - print diff + print("working on map_id=" + str(map_id) + " text_id=" + str(text_id)) + print(diff) apply_diff(diff) def insert_all_text_labels(): @@ -321,17 +323,17 @@ def insert_08_asm(map_id, text_id, line_id=0): start_address = all_texts[map_id][text_id][line_id]["start_address"] (text_asm, end_address) = text_asm_pretty_printer(label, start_address) - print "end address is: " + hex(end_address) + print("end address is: " + hex(end_address)) #find where to insert the assembly line_number = find_incbin_to_replace_for(start_address) if line_number == None: - print "skipping text label for a $08 on map_id=" + str(map_id) + " text_id=" + str(text_id) + " because the address is taken" + print("skipping text label for a $08 on map_id=" + str(map_id) + " text_id=" + str(text_id) + " because the address is taken") return #also do a name check if 1 <= ("\n".join(analyze_incbins.asm)).count("\n" + label + ":"): - print "skipping text label for a $08 on map_id=" + str(map_id) + " text_id=" + str(text_id) + " because the label is already taken (" + label + ":)" + print("skipping text label for a $08 on map_id=" + str(map_id) + " text_id=" + str(text_id) + " because the label is already taken (" + label + ":)") return newlines = split_incbin_line_into_three(line_number, start_address, end_address - start_address ) @@ -351,8 +353,8 @@ def insert_08_asm(map_id, text_id, line_id=0): newlines = newlines.replace("$x", "$") diff = generate_diff_insert(line_number, newlines) - print "working on map_id=" + str(map_id) + " text_id=" + str(text_id) - print diff + print("working on map_id=" + str(map_id) + " text_id=" + str(text_id)) + print(diff) result = apply_diff(diff) if result == False: @@ -376,7 +378,7 @@ def insert_all_08s(): text_id = the_08_line[1] line_id = the_08_line[2] - print "processing map_id=" + str(map_id) + " text_id=" + str(text_id) + print("processing map_id=" + str(map_id) + " text_id=" + str(text_id)) insert_08_asm(map_id, text_id, line_id) #reset everything @@ -396,17 +398,17 @@ def insert_all_08s(): def insert_asm(start_address, label, text_asm=None, end_address=None): if text_asm == None and end_address == None: (text_asm, end_address) = text_asm_pretty_printer(label, start_address, include_08=False) - print "end address is: " + hex(end_address) + print("end address is: " + hex(end_address)) #find where to insert the assembly line_number = find_incbin_to_replace_for(start_address) if line_number == None: - print "skipping asm because the address is taken" + print("skipping asm because the address is taken") return False #name check if (label + ":") in "\n".join(analyze_incbins.asm): - print "skipping asm because the label is taken" + print("skipping asm because the label is taken") return False newlines = split_incbin_line_into_three(line_number, start_address, end_address - start_address ) @@ -426,7 +428,7 @@ def insert_asm(start_address, label, text_asm=None, end_address=None): newlines = newlines.replace("$x", "$") diff = generate_diff_insert(line_number, newlines) - print diff + print(diff) result = apply_diff(diff, try_fixing=True) return True @@ -436,13 +438,13 @@ def insert_text(address, label, apply=False, try_fixing=True): line_number = find_incbin_to_replace_for(start_address) if line_number == None: - print "skipping text at " + hex(start_address) + " with address " + label + print("skipping text at " + hex(start_address) + " with address " + label) return "skip" #another reason to skip is if the interval is 0 processed_incbin = analyze_incbins.processed_incbins[line_number] if processed_incbin["interval"] == 0: - print "skipping text at " + hex(start_address) + " with address " + label + " because the interval is 0" + print("skipping text at " + hex(start_address) + " with address " + label + " because the interval is 0") return "skip" text_asm, byte_count = text_pretty_printer_at(start_address, label) @@ -466,7 +468,7 @@ def insert_text(address, label, apply=False, try_fixing=True): newlines = newlines.replace("Char52", "$52") diff = generate_diff_insert(line_number, newlines) - print diff + print(diff) if apply: return apply_diff(diff, try_fixing=try_fixing) else: #simulate a successful insertion @@ -560,16 +562,16 @@ def scan_for_map_scripts_pointer(): isolate_incbins() process_incbins() - print "map_id=" + str(map_id) + " scripts are: " + str(script_pointers) + print("map_id=" + str(map_id) + " scripts are: " + str(script_pointers)) if last_hl_address == None: last_hl_address = "None" else: last_hl_address = hex(last_hl_address) if hl_pointer != None and hl_pointer != "None": hl_pointer = hex(hl_pointer) - print "map_id=" + str(map_id) + " " + map2["name"] + " script_pointer=" + hex(script_pointer) + " script_pointers=" + hl_pointer + first_script_text - print main_asm_output - print "\n\n" + print("map_id=" + str(map_id) + " " + map2["name"] + " script_pointer=" + hex(script_pointer) + " script_pointers=" + hl_pointer + first_script_text) + print(main_asm_output) + print("\n\n") #insert asm for the main script result = insert_asm(script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script") @@ -625,8 +627,8 @@ def scan_for_map_scripts_pointer(): isolate_incbins() process_incbins() else: - print "trouble inserting map script pointer list" - print script_asm + print("trouble inserting map script pointer list") + print(script_asm) sys.exit(0) def scan_rom_for_tx_fars_and_insert(): @@ -647,7 +649,7 @@ def scan_rom_for_tx_fars_and_insert(): #let's also do a quick check if it might be in the file already if not (": ; " + hex(tx_far_address) in analyze_incbins.asm): - print "inserting text at " + hex(tx_far_address) + print("inserting text at " + hex(tx_far_address)) result = insert_text(tx_far_target_address, tx_far_target_label, apply=True) else: #we can't just pretend like it worked, because we don't know what label was used @@ -662,7 +664,7 @@ def scan_rom_for_tx_fars_and_insert(): result2 = insert_text(tx_far_address, tx_far_label, apply=True) local_reset_incbins() elif result == "skip": - print "skipping " + hex(tx_far_address) + print("skipping " + hex(tx_far_address)) # result2 = insert_text(tx_far_address, tx_far_label, apply=True) # local_reset_incbins() @@ -787,12 +789,12 @@ def insert_base_stats(id): line_number = find_incbin_to_replace_for(address) label = get_mon_name(id).title() + "BaseStats" if line_number == None: - print "skipping, already inserted at " + hex(address) + print("skipping, already inserted at " + hex(address)) return #also do a name check if (label + ":") in "\n".join(analyze_incbins.asm): - print "skipping " + label + " because it is already in use.." + print("skipping " + label + " because it is already in use..") return newlines = split_incbin_line_into_three(line_number, address, 28 ) @@ -811,7 +813,7 @@ def insert_base_stats(id): newlines = newlines.replace("$x", "$") diff = generate_diff_insert(line_number, newlines) - print diff + print(diff) apply_diff(diff, try_fixing=False, do_compile=False) def insert_all_base_stats(): diff --git a/redtools/make_map_size_constants.py b/redtools/make_map_size_constants.py index 4dfb1be..70b12c5 100644 --- a/redtools/make_map_size_constants.py +++ b/redtools/make_map_size_constants.py @@ -1,8 +1,10 @@ +from __future__ import print_function +from __future__ import absolute_import #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 +from . import extract_maps +from .pretty_map_headers import map_name_cleaner, map_constants def get_map_size_constants(do_sed=False): output = "" @@ -34,4 +36,4 @@ 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) + print(get_map_size_constants(do_sed=True)) diff --git a/redtools/map_block_dumper.py b/redtools/map_block_dumper.py index 1ffa1e6..add52d2 100644 --- a/redtools/map_block_dumper.py +++ b/redtools/map_block_dumper.py @@ -1,11 +1,13 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-03 #purpose: extract .blk files from baserom.gbc #note: use python2.7 because of subprocess in analyze_incbins -import extract_maps #rom, assert_rom, load_rom, calculate_pointer, load_map_pointers, read_all_map_headers, map_headers -from pretty_map_headers import map_name_cleaner -from analyze_incbins import asm, offset_to_pointer, find_incbin_to_replace_for, split_incbin_line_into_three, generate_diff_insert, load_asm, isolate_incbins, process_incbins -import analyze_incbins +from . import extract_maps #rom, assert_rom, load_rom, calculate_pointer, load_map_pointers, read_all_map_headers, map_headers +from .pretty_map_headers import map_name_cleaner +from .analyze_incbins import asm, offset_to_pointer, find_incbin_to_replace_for, split_incbin_line_into_three, generate_diff_insert, load_asm, isolate_incbins, process_incbins +from . import analyze_incbins import os, sys import subprocess spacing = " " @@ -32,7 +34,7 @@ def extract_map_block_data(map_id, savefile=False): full_filepath = "maps/" + filename + ".blk" if savefile: - print "Saving ../maps/" + filename + ".blk for map id=" + str(map_id) + print("Saving ../maps/" + filename + ".blk for map id=" + str(map_id)) fh = open("../maps/" + filename + ".blk", "w") fh.write(blocksdata) fh.close() @@ -61,12 +63,12 @@ def insert_map_block_label(map_id): x = int(map["x"], 16) size = x*y - print "map name: " + map["name"] - print "map address: " + map["map_pointer"] + print("map name: " + map["name"]) + print("map address: " + map["map_pointer"]) line_number = find_incbin_to_replace_for(address) if line_number == None: - print "skipping map id=" + str(map_id) + " probably because it was already done." + print("skipping map id=" + str(map_id) + " probably because it was already done.") used_map_pointers.append(map["map_pointer"]) return @@ -90,8 +92,8 @@ def insert_map_block_label(map_id): newlines = newlines.replace("$x", "$") diff = generate_diff_insert(line_number, newlines) - print diff - print "... Applying diff." + print(diff) + print("... Applying diff.") #write the diff to a file fh = open("temp.patch", "w") @@ -141,14 +143,14 @@ def insert_all_labels(): #check if this label is already in there cleaned_name, label_text, filename, full_filepath = make_labels(mapmap["name"]) if label_text in "\n".join(line for line in analyze_incbins.asm): - print "skipping (found label text in asm already)" + print("skipping (found label text in asm already)") used_map_pointers.append(mapmap["map_pointer"]) continue #skip this one isolate_incbins() process_incbins() - print "XYZ|" + mapmap["name"] + print("XYZ|" + mapmap["name"]) insert_map_block_label(map) used_map_pointers.append(mapmap["map_pointer"]) diff --git a/redtools/pretty_map_headers.py b/redtools/pretty_map_headers.py index ef26be3..2534622 100644 --- a/redtools/pretty_map_headers.py +++ b/redtools/pretty_map_headers.py @@ -2,12 +2,14 @@ #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-02 #purpose: dump asm for each map header +from __future__ import print_function +from __future__ import absolute_import import json -import extract_maps -import sprite_helper +from . import extract_maps +from . import sprite_helper import random import string -import analyze_texts #hopefully not a dependency loop +from . import analyze_texts #hopefully not a dependency loop base = 16 spacing = " " @@ -395,7 +397,7 @@ def write_connections(north, south, west, east): if not north and south and not west and east: return "SOUTH | EAST" if north and not south and west and not east: return "NORTH | WEST" if north and not south and not west and east: return "NORTH | EAST" - raise Exception, "unpredicted outcome on write_connections" + raise Exception("unpredicted outcome on write_connections") #TODO: make this elegant def connection_line(byte): @@ -551,7 +553,7 @@ def object_data_pretty_printer(map_id): try: warp_to_map_constant = map_constants[warp_to_map_id] - except Exception, exc: + except Exception as exc: warp_to_map_constant = "$" + hex(warp_to_map_id)[2:] output += spacing + "db $" + hex(int(y))[2:] + ", $" + hex(int(x))[2:] + ", $" + hex(int(warp_to_point))[2:] + ", " + warp_to_map_constant + "\n" @@ -606,7 +608,7 @@ def object_data_pretty_printer(map_id): try: previous_location = map_constants[object["warps"][warp_to_id]["warp_to_map_id"]] comment = " ; " + previous_location - except Exception, exc: + except Exception as exc: comment = "" output += spacing + "EVENT_DISP $" + map_width[2:] + ", $" + warp_to_y + ", $" + warp_to_x + comment + "\n" @@ -727,7 +729,7 @@ def print_all_headers(): for map in maps: output = map_header_pretty_printer(map) - if output != "": print output + if output != "": print(output) if __name__ == "__main__": #read binary data from file diff --git a/redtools/pretty_text.py b/redtools/pretty_text.py index 4933dca..dd17a12 100644 --- a/redtools/pretty_text.py +++ b/redtools/pretty_text.py @@ -1,14 +1,16 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-16 from optparse import OptionParser -from analyze_texts import text_pretty_printer_at +from .analyze_texts import text_pretty_printer_at def main(): usage = "usage: %prog address label" parser = OptionParser(usage) (options, args) = parser.parse_args() if len(args) == 1: - print "usage: python pretty_text.py address label" + print("usage: python pretty_text.py address label") args.append("UnnamedText_" + (args[0].replace("0x", ""))) elif len(args) != 2: parser.error("we need both an address and a label") diff --git a/redtools/pretty_trainer_headers.py b/redtools/pretty_trainer_headers.py index 5bfc2be..47d68db 100644 --- a/redtools/pretty_trainer_headers.py +++ b/redtools/pretty_trainer_headers.py @@ -1,8 +1,10 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-24 from optparse import OptionParser -from gbz80disasm import load_labels, find_label -from extract_maps import calculate_pointer +from .gbz80disasm import load_labels, find_label +from .extract_maps import calculate_pointer import sys spacing = "\t" rom = None @@ -46,8 +48,8 @@ def pretty_print_trainer_header(address, label=None): partial_pointer = (pointer_byte1 + (pointer_byte2 << 8)) label = find_label(partial_pointer, bank_id) if label == None: - print "label not found for (TextBeforeBattle) " + hex(calculate_pointer(partial_pointer, bank_id)) - print "" + print("label not found for (TextBeforeBattle) " + hex(calculate_pointer(partial_pointer, bank_id))) + print("") label = "$" + hex(partial_pointer)[2:] #sys.exit(0) @@ -59,8 +61,8 @@ def pretty_print_trainer_header(address, label=None): partial_pointer = (pointer_byte1 + (pointer_byte2 << 8)) label = find_label(partial_pointer, bank_id) if label == None: - print "label not found for (TextAfterBattle) " + hex(calculate_pointer(partial_pointer, bank_id)) - print "" + print("label not found for (TextAfterBattle) " + hex(calculate_pointer(partial_pointer, bank_id))) + print("") label = "$" + hex(partial_pointer)[2:] #sys.exit(0) @@ -72,8 +74,8 @@ def pretty_print_trainer_header(address, label=None): partial_pointer = (pointer_byte1 + (pointer_byte2 << 8)) label = find_label(partial_pointer, bank_id) if label == None: - print "label not found for (TextEndBattle) " + hex(calculate_pointer(partial_pointer, bank_id)) - print "" + print("label not found for (TextEndBattle) " + hex(calculate_pointer(partial_pointer, bank_id))) + print("") label = "$" + hex(partial_pointer)[2:] #sys.exit(0) @@ -85,8 +87,8 @@ def pretty_print_trainer_header(address, label=None): partial_pointer = (pointer_byte1 + (pointer_byte2 << 8)) label = find_label(partial_pointer, bank_id) if label == None: - print "label not found for (TextEndBattle) " + hex(calculate_pointer(partial_pointer, bank_id)) - print "" + print("label not found for (TextEndBattle) " + hex(calculate_pointer(partial_pointer, bank_id))) + print("") label = "$" + hex(partial_pointer)[2:] #sys.exit(0) @@ -99,7 +101,7 @@ def pretty_print_trainer_header(address, label=None): def all_trainer_headers_at(address): i = 0 while ord(rom[address + (i*12)]) != 0xff: - print pretty_print_trainer_header(address + (i*12)) + print(pretty_print_trainer_header(address + (i*12))) i += 1 def main(): @@ -109,7 +111,7 @@ def main(): parser = OptionParser(usage) (options, args) = parser.parse_args() if len(args) == 1: - print "usage: python pretty_trainer_headers.py address label\n" + print("usage: python pretty_trainer_headers.py address label\n") args.append("TrainerHeader_" + (args[0].replace("0x", ""))) elif len(args) != 2: parser.error("we need both an address and a label") @@ -120,7 +122,7 @@ def main(): rom = open("../baserom.gbc", "r").read() #print pretty_print_trainer_header(address, label) - print all_trainer_headers_at(address) + print(all_trainer_headers_at(address)) if __name__ == "__main__": main() diff --git a/redtools/replace_dimensions.py b/redtools/replace_dimensions.py index fc089f7..b8bb717 100644 --- a/redtools/replace_dimensions.py +++ b/redtools/replace_dimensions.py @@ -1,10 +1,11 @@ +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-15 #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, offset_to_pointer, map_constants -from connection_helper import print_connections +from .add_map_labels_to_map_headers import find_with_start_of_line +from .pretty_map_headers import map_name_cleaner, spacing, offset_to_pointer, map_constants +from .connection_helper import print_connections from ctypes import c_int8 # X/Y_Movement_Of_Connection @@ -234,7 +235,7 @@ def replace_values(): connection_offset += 6 if __name__ == "__main__": - import extract_maps + from . import extract_maps extract_maps.load_rom() extract_maps.load_map_pointers() extract_maps.read_all_map_headers() diff --git a/redtools/romvisualizer.py b/redtools/romvisualizer.py index 516ac91..c294556 100644 --- a/redtools/romvisualizer.py +++ b/redtools/romvisualizer.py @@ -1,3 +1,4 @@ +from __future__ import print_function #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-13 import os @@ -7,7 +8,7 @@ changeset_numbers = range(1145, 1149) def take_snapshot_image(changeset_number): "turn main.asm into an image at a certain version" - print "reverting main.asm to r" + str(changeset_number) + print("reverting main.asm to r" + str(changeset_number)) #revert the file (it used to be common.asm) os.system("rm ../main.asm; rm ../common.asm; rm ../pokered.asm") @@ -15,7 +16,7 @@ def take_snapshot_image(changeset_number): os.system("hg revert ../common.asm -r" + str(changeset_number)) os.system("hg revert ../pokered.asm -r" + str(changeset_number)) - print "generating the image.." + print("generating the image..") #draw the image os.system("python romviz.py") diff --git a/redtools/romviz.py b/redtools/romviz.py index 3f07d65..23661b3 100644 --- a/redtools/romviz.py +++ b/redtools/romviz.py @@ -1,17 +1,19 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-10 #show me an image import Image from math import floor -import extract_maps -import analyze_incbins +from . import extract_maps +from . import analyze_incbins -print "loading rom.." +print("loading rom..") extract_maps.load_rom() #extract_maps.load_map_pointers() #extract_maps.read_all_map_headers() -print "analyzing incbins.." +print("analyzing incbins..") analyze_incbins.load_asm() analyze_incbins.isolate_incbins() analyze_incbins.process_incbins() @@ -26,7 +28,7 @@ im.putpalette([ 126, 30, 156, ]) -print "drawing incbins..." +print("drawing incbins...") for incbin_key in analyze_incbins.processed_incbins: incbin = analyze_incbins.processed_incbins[incbin_key] start = incbin["start"] diff --git a/redtools/sprite_helper.py b/redtools/sprite_helper.py index ee7a5f4..9e4c804 100644 --- a/redtools/sprite_helper.py +++ b/redtools/sprite_helper.py @@ -1,4 +1,6 @@ -import extract_maps +from __future__ import print_function +from __future__ import absolute_import +from . import extract_maps spacing = "\t" #provided by sawakita @@ -172,7 +174,7 @@ def load_icons(): pic = thing["picture_number"] unique_icons.add(pic) - if not icons.has_key(pic): icons[pic] = [] + if pic not in icons: icons[pic] = [] alerter = None if int(thing["y"])-4 > int(map["y"], 16)*2: alerter = True @@ -199,7 +201,7 @@ def print_appearances(): output += spacing + ".. in " + appearance[0] + " at (" + str(appearance[1]) + ", " + str(appearance[2]) + ")" + outside_alert + "\n" output += "\n" - print output + print(output) def insert_todo_sprites(): load_icons() @@ -251,7 +253,7 @@ def sprite_printer(): value = hex(key)[2:] if len(value) == 1: value = "0" + value - print sprites[key] + extra + " EQU $" + value + print(sprites[key] + extra + " EQU $" + value) def parse_sprite_sheet_pointer_table(): """parses the bytes making up the pointer table @@ -321,7 +323,7 @@ def parse_sprite_sheet_pointer_table(): data_entry["byte_count"] += 64 setter3 = True - print ("$%.2x " % (sprite_id)) + sprite_name + " has $%.2x bytes" % (byte_count) + " pointing to 0x%.x" % (pointer) + " bank is $%.2x" % (bank) + " with pose_count=" + str(data_entry["poses"]) + print(("$%.2x " % (sprite_id)) + sprite_name + " has $%.2x bytes" % (byte_count) + " pointing to 0x%.x" % (pointer) + " bank is $%.2x" % (bank) + " with pose_count=" + str(data_entry["poses"])) ptable_sheet_data[sprite_id] = data_entry return ptable_sheet_data @@ -398,5 +400,5 @@ if __name__ == "__main__": #sprite_printer() ptable_sheet_data = parse_sprite_sheet_pointer_table() - print pretty_print_sheet_incbins(ptable_sheet_data) - print pretty_print_sheet_data(ptable_sheet_data) + print(pretty_print_sheet_incbins(ptable_sheet_data)) + print(pretty_print_sheet_data(ptable_sheet_data)) diff --git a/redtools/text_pointers.py b/redtools/text_pointers.py index f0f74da..84e1e79 100644 --- a/redtools/text_pointers.py +++ b/redtools/text_pointers.py @@ -1,8 +1,10 @@ +from __future__ import print_function +from __future__ import absolute_import #author: Bryan Bishop <kanzure@gmail.com> #date: 2012-01-03 #utilities for working with text pointers -import extract_maps #rom, assert_rom, load_rom, calculate_pointer, load_map_pointers, read_all_map_headers, map_headers -from pretty_map_headers import map_name_cleaner +from . import extract_maps #rom, assert_rom, load_rom, calculate_pointer, load_map_pointers, read_all_map_headers, map_headers +from .pretty_map_headers import map_name_cleaner #import analyze_incbins #asm, offset_to_pointer, find_incbin_to_replace_for, split_incbin_line_into_three, generate_diff_insert, load_asm, isolate_incbins, process_incbins spacing = " " @@ -39,10 +41,10 @@ def test_first_text_pointer_bytes(range=20): #30 for viridian city, 34 for cerul first_text_pointer = extract_maps.calculate_pointer(partial_pointer, bank) #if (first_text_pointer <= (text_list_pointer+range)): - print "map " + map["name"] + " (" + str(map["id"]) + ")" - print spacing + "text_pointer (list) = " + hex(text_list_pointer) - print spacing + "first_text_pointer (first text) = " + hex(first_text_pointer) - print spacing + "difference = " + str(first_text_pointer - text_list_pointer) + print("map " + map["name"] + " (" + str(map["id"]) + ")") + print(spacing + "text_pointer (list) = " + hex(text_list_pointer)) + print(spacing + "first_text_pointer (first text) = " + hex(first_text_pointer)) + print(spacing + "difference = " + str(first_text_pointer - text_list_pointer)) #return False return True @@ -52,4 +54,4 @@ if __name__ == "__main__": extract_maps.load_map_pointers() extract_maps.read_all_map_headers() - print test_first_text_pointer_bytes() + print(test_first_text_pointer_bytes()) |