shithub: pokered

Download patch

ref: a6f495e25ee25453be690c31f0317e32751ac378
parent: be34aed58e24303a9d8dee6cf36009cbc2653568
author: Bryan Bishop <kanzure@gmail.com>
date: Tue Jan 17 10:31:04 EST 2012

fix insert_texts for pre-existing TX_FAR target labels

hg-commit-id: b506eecb191a


--- a/extras/insert_texts.py
+++ b/extras/insert_texts.py
@@ -416,7 +416,7 @@
     line_number = find_incbin_to_replace_for(start_address)
     if line_number == None:
         print "skipping text at " + hex(start_address) + " with address " + label
-        return
+        return "skip"
 
     text_asm, byte_count = text_pretty_printer_at(start_address, label)
     end_address = start_address + byte_count
@@ -612,17 +612,32 @@
     for address_bundle in address_bundles:
         tx_far_address = address_bundle[1]
         tx_far_target_address = address_bundle[0]
+        if tx_far_address < 0x6150f: continue
 
         tx_far_label = "UnnamedText_%.2x" % (tx_far_address)
         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:
+        #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):
+            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
+            #so, figure out the label
+            for line in analyze_incbins.asm_lines:
+                if ": ; " + hex(tx_far_address) in line:
+                    tx_far_target_label = line.split(":")[0]
+            result = "skip"
+
+        if result == True:
+            local_reset_incbins()
             result2 = insert_text(tx_far_address, tx_far_label, apply=True)
+            local_reset_incbins()
+        elif result == "skip":
+            result2 = insert_text(tx_far_address, tx_far_label, apply=True)
+            local_reset_incbins()
+
         if not result or not result2:
             sys.exit(0)
-        local_reset_incbins()
 
 if __name__ == "__main__":
     #load map headers and object data
--- a/extras/pretty_map_headers.py
+++ b/extras/pretty_map_headers.py
@@ -327,7 +327,7 @@
 ("!", 0xE7),
 (".", 0xE8),
 ("♂", 0xEF),
-("¥", 0xF0),
+#("¥", 0xF0),
 ("/", 0xF3),
 (",", 0xF4),
 ("♀", 0xF5),