diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-01-17 14:54:06 -0600 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-01-17 14:54:06 -0600 |
commit | be34aed58e24303a9d8dee6cf36009cbc2653568 (patch) | |
tree | f57412dd4bfa4a9ca52c49f6f5fbfee5a028185e | |
parent | e5f9d4a1444d7a5dcb755ab1304b9be3ee4db6ed (diff) |
fix some offset errors in insert_texts.py
hg-commit-id: b131d049ecd3
-rw-r--r-- | extras/analyze_incbins.py | 2 | ||||
-rw-r--r-- | extras/analyze_texts.py | 3 | ||||
-rw-r--r-- | extras/insert_texts.py | 22 |
3 files changed, 23 insertions, 4 deletions
diff --git a/extras/analyze_incbins.py b/extras/analyze_incbins.py index cc8d9810..9cdc2083 100644 --- a/extras/analyze_incbins.py +++ b/extras/analyze_incbins.py @@ -235,7 +235,7 @@ def apply_diff(diff, try_fixing=True): #confirm it's working try: - subprocess.check_call("cd ../; make clean; LC_CTYPE=UTF-8 make", shell=True) + subprocess.check_call("cd ../; make clean; LC_CTYPE=C make", shell=True) return True except Exception, exc: if try_fixing: diff --git a/extras/analyze_texts.py b/extras/analyze_texts.py index 3e288dd0..b843581e 100644 --- a/extras/analyze_texts.py +++ b/extras/analyze_texts.py @@ -496,6 +496,7 @@ def text_pretty_printer_at(start_address, label="SomeLabel"): if first and needs_to_begin_with_0: output += "$0, " first = False + byte_count += 1 quotes_open = False first_byte = True @@ -550,7 +551,7 @@ def text_pretty_printer_at(start_address, label="SomeLabel"): include_newline = "\n" if output[-1] == "\n": include_newline = "" - output += include_newline + "; " + hex(start_address + byte_count + 1) + output += include_newline + "; " + hex(start_address) + " + " + str(byte_count) + " bytes" print output return (output, byte_count) diff --git a/extras/insert_texts.py b/extras/insert_texts.py index dc7f872c..8438127e 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -15,6 +15,19 @@ spacing = " " tx_fars = None failed_attempts = {} +def local_reset_incbins(): + asm = None + incbin_lines = [] + processed_incbins = {} + analyze_incbins.asm = None + analyze_incbins.incbin_lines = [] + analyze_incbins.processed_incbins = {} + + #reload + load_asm() + isolate_incbins() + process_incbins() + def find_tx_far_entry(map_id, text_id): for tx_far_line in tx_fars: if tx_far_line[0] == map_id and tx_far_line[1] == text_id: @@ -396,7 +409,7 @@ def insert_asm(start_address, label, text_asm=None, end_address=None): result = apply_diff(diff, try_fixing=True) return True -def insert_text(address, label, apply=False): +def insert_text(address, label, apply=False, try_fixing=True): "inserts a text script (but not $8s)" start_address = address @@ -428,7 +441,7 @@ def insert_text(address, label, apply=False): diff = generate_diff_insert(line_number, newlines) print diff if apply: - return apply_diff(diff) + return apply_diff(diff, try_fixing=try_fixing) else: #simulate a successful insertion return True @@ -594,6 +607,7 @@ def scan_rom_for_tx_fars_and_insert(): looks through INCBIN'd addresses from common.asm, finds TX_FARs that aren't included yet. """ + x = 0 address_bundles = scan_rom_for_tx_fars(printer=True) for address_bundle in address_bundles: tx_far_address = address_bundle[1] @@ -603,8 +617,12 @@ def scan_rom_for_tx_fars_and_insert(): tx_far_target_label = "_" + tx_far_label result = insert_text(tx_far_target_address, tx_far_target_label, apply=True) + local_reset_incbins() if result: result2 = insert_text(tx_far_address, tx_far_label, apply=True) + if not result or not result2: + sys.exit(0) + local_reset_incbins() if __name__ == "__main__": #load map headers and object data |