From 3075fabe2622b1107debc2e28239de6d785d8ba5 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Wed, 11 Jan 2012 23:08:46 -0600 Subject: more automation to assist in text insertion hg-commit-id: e631a0e3c275 --- extras/insert_texts.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index 3257c067..f397a135 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -3,7 +3,7 @@ #date: 2012-01-07 #insert TX_FAR targets into pokered.asm import extract_maps -from analyze_texts import analyze_texts +from analyze_texts import analyze_texts, text_pretty_printer_at 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 @@ -389,6 +389,39 @@ def insert_asm(start_address, label): print diff result = apply_diff(diff, try_fixing=False) +def insert_text(address, label): + "inserts a text script (but not $8s)" + start_address = address + + line_number = find_incbin_to_replace_for(start_address) + if line_number == None: + print "skipping text at " + hex(start_address) + " with address " + label + return + + text_asm, byte_count = text_pretty_printer_at(start_address, label) + end_address = start_address + byte_count + newlines = split_incbin_line_into_three(line_number, start_address, byte_count) + + newlines = newlines.split("\n") + if len(newlines) == 2: index = 0 #replace the 1st line with new content + elif len(newlines) == 3: index = 1 #replace the 2nd line with new content + + newlines[index] = text_asm + + if len(newlines) == 3 and newlines[2][-2:] == "$0": + #get rid of the last incbin line if it is only including 0 bytes + del newlines[2] + #note that this has to be done after adding in the new asm + newlines = "\n".join(line for line in newlines) + newlines = newlines.replace("$x", "$") #where does this keep coming from?? + + #Char52 doesn't work yet + newlines = newlines.replace("Char52", "$52") + + diff = generate_diff_insert(line_number, newlines) + print diff + #apply_diff(diff) + if __name__ == "__main__": #load map headers and object data extract_maps.load_rom() @@ -428,7 +461,7 @@ if __name__ == "__main__": #insert_asm(0x758df, "CinnabarGymText1") - #insert_text_label_tx_far(95, 1) + #insert_text_label_tx_far(91, 1) missed_17s = [] #[[95, 1], [95, 2], [96, 1], [97, 1], [99, 1], [99, 2], [99, 3], [100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [124, 8], [124, 10], [124, 12], [124, 16], [124, 17], [133, 3], [139, 1], [139, 2], [139, 3], [141, 2], [141, 3], [154, 2], [154, 3], [169, 4], [171, 2], [171, 3], [174, 2], [174, 3], [176, 4], [176, 5], [182, 3], [215, 5], [91, 2], [91, 3], [124, 8], [124, 10], [124, 12], [124, 16], [124, 17], [139, 1], [139, 2], [139, 3], [141, 2], [169, 4], [171, 2], [174, 2], [176, 4], [176, 5]] for missed_17 in missed_17s: insert_text_label_tx_far(missed_17[0], missed_17[1]) @@ -444,6 +477,9 @@ if __name__ == "__main__": isolate_incbins() process_incbins() + #insert_text(0x44276, "ViridianPokeCenterText4") + insert_text(0x2461, "VermilionMartText1") + if len(failed_attempts) > 0: print "-- FAILED ATTEMPTS --" print str(failed_attempts) -- cgit v1.2.3 From 418dc214d8346828cfac03ef0af0a2d298d5d318 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Thu, 12 Jan 2012 01:31:14 -0600 Subject: insert texts pointer labels hg-commit-id: 18cc3e2ec33b --- extras/insert_texts.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index f397a135..f850f001 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -106,7 +106,7 @@ def all_texts_are_tx_fars(map_id): def texts_label_pretty_printer(map_id): "output a texts label for map if all texts are TX_FARs and in the asm already" #extract_maps.map_headers[map_id]["texts"][text_id][0]["TX_FAR"] - if not all_texts_are_tx_fars(map_id): return None + #if not all_texts_are_tx_fars(map_id): return None map2 = extract_maps.map_headers[map_id] #pointer to the list of texts @@ -139,7 +139,7 @@ def texts_label_pretty_printer(map_id): return output def insert_texts_label(map_id): - if not all_texts_are_tx_fars(map_id): return None + #if not all_texts_are_tx_fars(map_id): return None map2 = extract_maps.map_headers[map_id] base_label = map_name_cleaner(map2["name"], None)[:-2] @@ -478,7 +478,8 @@ if __name__ == "__main__": process_incbins() #insert_text(0x44276, "ViridianPokeCenterText4") - insert_text(0x2461, "VermilionMartText1") + #insert_texts_label(4) + insert_all_texts_labels() if len(failed_attempts) > 0: print "-- FAILED ATTEMPTS --" -- cgit v1.2.3 From 1ae8e7e41e5fa184ec30498defb6ebc873178da8 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Thu, 12 Jan 2012 12:55:54 -0600 Subject: insert $8 asm for NameRaterText1 hg-commit-id: dd9f5126d4a5 --- extras/insert_texts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index f850f001..561e80f7 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -459,7 +459,7 @@ if __name__ == "__main__": #insert_08_asm(83, 1) #insert_all_08s() - #insert_asm(0x758df, "CinnabarGymText1") + insert_asm(0x1da56, "NameRaterText1") #insert_text_label_tx_far(91, 1) missed_17s = [] #[[95, 1], [95, 2], [96, 1], [97, 1], [99, 1], [99, 2], [99, 3], [100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [124, 8], [124, 10], [124, 12], [124, 16], [124, 17], [133, 3], [139, 1], [139, 2], [139, 3], [141, 2], [141, 3], [154, 2], [154, 3], [169, 4], [171, 2], [171, 3], [174, 2], [174, 3], [176, 4], [176, 5], [182, 3], [215, 5], [91, 2], [91, 3], [124, 8], [124, 10], [124, 12], [124, 16], [124, 17], [139, 1], [139, 2], [139, 3], [141, 2], [169, 4], [171, 2], [174, 2], [176, 4], [176, 5]] @@ -479,7 +479,7 @@ if __name__ == "__main__": #insert_text(0x44276, "ViridianPokeCenterText4") #insert_texts_label(4) - insert_all_texts_labels() + #insert_all_texts_labels() if len(failed_attempts) > 0: print "-- FAILED ATTEMPTS --" -- cgit v1.2.3 From 9d4f5a459f79357dcb0046560b067b4a1fb73cef Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 13 Jan 2012 01:05:10 -0600 Subject: a very slow tool to find script pointers for each map hg-commit-id: a61a85fd7577 --- extras/insert_texts.py | 69 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 20 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index 561e80f7..b683d400 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -8,7 +8,7 @@ from pretty_map_headers import map_name_cleaner, make_text_label, map_constants, 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 +from gbz80disasm import text_asm_pretty_printer, output_bank_opcodes import os, sys import subprocess spacing = " " @@ -422,6 +422,51 @@ def insert_text(address, label): print diff #apply_diff(diff) +def scan_for_map_scripts_pointer(): + for map_id in extract_maps.map_headers.keys(): + map2 = extract_maps.map_headers[map_id] + script_pointer = int(map2["script_pointer"], 16) + + asm_output, offset, last_hl_address, last_a_address = output_bank_opcodes(script_pointer) + + first_script_text = "" + if last_hl_address != None and last_hl_address != "None": + hl_pointer = extract_maps.calculate_pointer(last_hl_address, int(map2["bank"], 16)) + byte1 = ord(extract_maps.rom[hl_pointer]) + byte2 = ord(extract_maps.rom[hl_pointer+1]) + address = byte1 + (byte2 << 8) + first_script_pointer = extract_maps.calculate_pointer(address, int(map2["bank"], 16)) + + first_script_text = " first_script=" + hex(first_script_pointer) + + a_numbers = [0] + script_pointers = [hex(first_script_pointer)] + last_a_id = 0 + latest_script_pointer = first_script_pointer + while last_a_id == (max(a_numbers)) or last_a_id==0: + asm_output, offset, last_hl_address2, last_a_id, byte1, byte2, address = None, None, None, None, None, None, None + asm_output, offset, last_hl_address2, last_a_id = output_bank_opcodes(latest_script_pointer) + + if last_a_id == (max(a_numbers) + 1): + a_numbers.append(last_a_id) + else: + break + + byte1 = ord(extract_maps.rom[hl_pointer + (2*last_a_id)]) + byte2 = ord(extract_maps.rom[hl_pointer + (2*last_a_id) + 1]) + address2 = byte1 + (byte2 << 8) + latest_script_pointer = extract_maps.calculate_pointer(address2, int(map2["bank"], 16)) + script_pointers.append(hex(latest_script_pointer)) + #print "latest script pointer (part 1): " + hex(address2) + #print "latest script pointer: " + hex(latest_script_pointer) + 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) + + print "map_id=" + str(map_id) + " script_pointer=" + hex(script_pointer) + " script_pointers=" + last_hl_address + first_script_text + print "\n" + if __name__ == "__main__": #load map headers and object data extract_maps.load_rom() @@ -436,6 +481,8 @@ if __name__ == "__main__": #load incbins reset_incbins() + scan_for_map_scripts_pointer() + #insert _ViridianCityText10 #insert_tx_far(1, 10) @@ -459,28 +506,10 @@ if __name__ == "__main__": #insert_08_asm(83, 1) #insert_all_08s() - insert_asm(0x1da56, "NameRaterText1") - + #insert_asm(0x1da56, "NameRaterText1") #insert_text_label_tx_far(91, 1) - missed_17s = [] #[[95, 1], [95, 2], [96, 1], [97, 1], [99, 1], [99, 2], [99, 3], [100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [124, 8], [124, 10], [124, 12], [124, 16], [124, 17], [133, 3], [139, 1], [139, 2], [139, 3], [141, 2], [141, 3], [154, 2], [154, 3], [169, 4], [171, 2], [171, 3], [174, 2], [174, 3], [176, 4], [176, 5], [182, 3], [215, 5], [91, 2], [91, 3], [124, 8], [124, 10], [124, 12], [124, 16], [124, 17], [139, 1], [139, 2], [139, 3], [141, 2], [169, 4], [171, 2], [174, 2], [176, 4], [176, 5]] - for missed_17 in missed_17s: - insert_text_label_tx_far(missed_17[0], missed_17[1]) - - asm = None - incbin_lines = [] - processed_incbins = {} - analyze_incbins.asm = None - analyze_incbins.incbin_lines = [] - analyze_incbins.processed_incbins = {} - - load_asm() - isolate_incbins() - process_incbins() #insert_text(0x44276, "ViridianPokeCenterText4") #insert_texts_label(4) #insert_all_texts_labels() - if len(failed_attempts) > 0: - print "-- FAILED ATTEMPTS --" - print str(failed_attempts) -- cgit v1.2.3 From bc3bf29219a5f3d89faa0ba82c3cb4a7d76c38c1 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 13 Jan 2012 12:10:53 -0600 Subject: update insert_texts: $0000 to $3fff don't need banks hg-commit-id: 10327274b8f8 --- extras/insert_texts.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index b683d400..27ba8696 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -425,6 +425,7 @@ def insert_text(address, label): def scan_for_map_scripts_pointer(): for map_id in extract_maps.map_headers.keys(): map2 = extract_maps.map_headers[map_id] + if map_id in extract_maps.bad_maps: continue #skip script_pointer = int(map2["script_pointer"], 16) asm_output, offset, last_hl_address, last_a_address = output_bank_opcodes(script_pointer) @@ -435,7 +436,10 @@ def scan_for_map_scripts_pointer(): byte1 = ord(extract_maps.rom[hl_pointer]) byte2 = ord(extract_maps.rom[hl_pointer+1]) address = byte1 + (byte2 << 8) - first_script_pointer = extract_maps.calculate_pointer(address, int(map2["bank"], 16)) + if address > 0x3fff: + first_script_pointer = extract_maps.calculate_pointer(address, int(map2["bank"], 16)) + else: + first_script_pointer = address first_script_text = " first_script=" + hex(first_script_pointer) @@ -455,7 +459,10 @@ def scan_for_map_scripts_pointer(): byte1 = ord(extract_maps.rom[hl_pointer + (2*last_a_id)]) byte2 = ord(extract_maps.rom[hl_pointer + (2*last_a_id) + 1]) address2 = byte1 + (byte2 << 8) - latest_script_pointer = extract_maps.calculate_pointer(address2, int(map2["bank"], 16)) + if address2 > 0x3fff: + latest_script_pointer = extract_maps.calculate_pointer(address2, int(map2["bank"], 16)) + else: + latest_script_pointer = address2 script_pointers.append(hex(latest_script_pointer)) #print "latest script pointer (part 1): " + hex(address2) #print "latest script pointer: " + hex(latest_script_pointer) @@ -464,7 +471,7 @@ def scan_for_map_scripts_pointer(): if last_hl_address == None: last_hl_address = "None" else: last_hl_address = hex(last_hl_address) - print "map_id=" + str(map_id) + " script_pointer=" + hex(script_pointer) + " script_pointers=" + last_hl_address + first_script_text + print "map_id=" + str(map_id) + " " + map2["name"] + " script_pointer=" + hex(script_pointer) + " script_pointers=" + last_hl_address + first_script_text print "\n" if __name__ == "__main__": -- cgit v1.2.3 From 71ebf0b95e9d5f31c8021910f70d0b8b9b79043c Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 13 Jan 2012 14:31:22 -0600 Subject: code to insert main scripts and subscripts hg-commit-id: 807e8743e682 --- extras/insert_texts.py | 88 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 10 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index 27ba8696..24b55899 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -369,6 +369,11 @@ def insert_asm(start_address, label): print "skipping asm because the address is taken" return + #name check + if (label + ":") in "\n".join(analyze_incbins.asm): + print "skipping asm because the label is taken" + return + newlines = split_incbin_line_into_three(line_number, start_address, end_address - start_address ) newlines = newlines.split("\n") @@ -387,7 +392,7 @@ def insert_asm(start_address, label): diff = generate_diff_insert(line_number, newlines) print diff - result = apply_diff(diff, try_fixing=False) + result = apply_diff(diff, try_fixing=True) def insert_text(address, label): "inserts a text script (but not $8s)" @@ -422,34 +427,58 @@ def insert_text(address, label): print diff #apply_diff(diff) +#move this into another file? def scan_for_map_scripts_pointer(): - for map_id in extract_maps.map_headers.keys(): + for map_id in extract_maps.map_headers.keys(): #skip id=0 (Pallet Town) because the naming conventions are wonky map2 = extract_maps.map_headers[map_id] - if map_id in extract_maps.bad_maps: continue #skip + if map_id in extract_maps.bad_maps or map_id in [0, 39, 37, 38]: continue #skip script_pointer = int(map2["script_pointer"], 16) - asm_output, offset, last_hl_address, last_a_address = output_bank_opcodes(script_pointer) + main_asm_output, offset, last_hl_address, last_a_address, used_3d97 = output_bank_opcodes(script_pointer) + hl_pointer = "None" first_script_text = "" - if last_hl_address != None and last_hl_address != "None": - hl_pointer = extract_maps.calculate_pointer(last_hl_address, int(map2["bank"], 16)) + if last_hl_address != None and last_hl_address != "None" and used_3d97==True: + if last_hl_address > 0x3fff: + hl_pointer = extract_maps.calculate_pointer(last_hl_address, int(map2["bank"], 16)) + else: + hl_pointer = last_hl_address byte1 = ord(extract_maps.rom[hl_pointer]) byte2 = ord(extract_maps.rom[hl_pointer+1]) address = byte1 + (byte2 << 8) + if address > 0x3fff: first_script_pointer = extract_maps.calculate_pointer(address, int(map2["bank"], 16)) else: first_script_pointer = address + #for later output first_script_text = " first_script=" + hex(first_script_pointer) + #go ahead and insert this script pointer + insert_asm(first_script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script0") + + #reset everything + #analyze_incbins.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() + a_numbers = [0] - script_pointers = [hex(first_script_pointer)] last_a_id = 0 + script_pointers = [hex(first_script_pointer)] latest_script_pointer = first_script_pointer while last_a_id == (max(a_numbers)) or last_a_id==0: asm_output, offset, last_hl_address2, last_a_id, byte1, byte2, address = None, None, None, None, None, None, None - asm_output, offset, last_hl_address2, last_a_id = output_bank_opcodes(latest_script_pointer) + asm_output, offset, last_hl_address2, last_a_id, used_3d97 = output_bank_opcodes(latest_script_pointer) if last_a_id == (max(a_numbers) + 1): a_numbers.append(last_a_id) @@ -463,16 +492,55 @@ def scan_for_map_scripts_pointer(): latest_script_pointer = extract_maps.calculate_pointer(address2, int(map2["bank"], 16)) else: latest_script_pointer = address2 + script_pointers.append(hex(latest_script_pointer)) #print "latest script pointer (part 1): " + hex(address2) #print "latest script pointer: " + hex(latest_script_pointer) + + #go ahead and insert the asm for this script + insert_asm(latest_script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script" + str(len(script_pointers) - 1)) + + #reset everything + #analyze_incbins.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() + 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) - print "map_id=" + str(map_id) + " " + map2["name"] + " script_pointer=" + hex(script_pointer) + " script_pointers=" + last_hl_address + first_script_text - print "\n" + 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" + + #insert asm for the main script + insert_asm(script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script") + + #reset everything + #analyze_incbins.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() if __name__ == "__main__": #load map headers and object data -- cgit v1.2.3 From dd2d259911107999d4833d2bb079091fc934f149 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 13 Jan 2012 15:27:22 -0600 Subject: insert_texts now inserts map script pointer lists hg-commit-id: a63f010e5cdc --- extras/insert_texts.py | 104 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 32 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index 24b55899..75392b5c 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -359,20 +359,21 @@ def insert_all_08s(): isolate_incbins() process_incbins() -def insert_asm(start_address, label): - (text_asm, end_address) = text_asm_pretty_printer(label, start_address, include_08=False) - print "end address is: " + hex(end_address) +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) #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" - return + return False #name check if (label + ":") in "\n".join(analyze_incbins.asm): print "skipping asm because the label is taken" - return + return False newlines = split_incbin_line_into_three(line_number, start_address, end_address - start_address ) @@ -393,6 +394,7 @@ def insert_asm(start_address, label): diff = generate_diff_insert(line_number, newlines) print diff result = apply_diff(diff, try_fixing=True) + return True def insert_text(address, label): "inserts a text script (but not $8s)" @@ -498,21 +500,22 @@ def scan_for_map_scripts_pointer(): #print "latest script pointer: " + hex(latest_script_pointer) #go ahead and insert the asm for this script - insert_asm(latest_script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script" + str(len(script_pointers) - 1)) + result = insert_asm(latest_script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script" + str(len(script_pointers) - 1)) - #reset everything - #analyze_incbins.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() + if result: + #reset everything + #analyze_incbins.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() print "map_id=" + str(map_id) + " scripts are: " + str(script_pointers) @@ -526,21 +529,58 @@ def scan_for_map_scripts_pointer(): print "\n\n" #insert asm for the main script - insert_asm(script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script") + result = insert_asm(script_pointer, map_name_cleaner(map2["name"], None)[:-2] + "Script") - #reset everything - #analyze_incbins.reset_incbins() - asm = None - incbin_lines = [] - processed_incbins = {} - analyze_incbins.asm = None - analyze_incbins.incbin_lines = [] - analyze_incbins.processed_incbins = {} + if result: + #reset everything + #analyze_incbins.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() - #reload - load_asm() - isolate_incbins() - process_incbins() + #insert script pointer list asm if there's anything of value + if hl_pointer != None and hl_pointer != "None" and used_3d97==True: + start_address = int(hl_pointer, 16) #where to insert this list + total_size = len(a_numbers) * 2 + + script_label = map_name_cleaner(map2["name"], None)[:-2] + "Script" + scripts_label = script_label + "s" + scripts_asm = scripts_label + ": ; " + hex(start_address) + "\n" + script_asm += spacing + "dw" + + first = True + for id in a_numbers: + if first: + script_asm += " " + first = False + else: + script_asm += ", " + script_asm += script_label + str(id) + script_asm += "\n" #extra newline? + + result = insert_asm(start_address, scripts_label, text_asm=script_asm, end_address=start_address + total_size) + if result: + #reset everything + #analyze_incbins.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() if __name__ == "__main__": #load map headers and object data -- cgit v1.2.3 From 4aabc95f6385c7fce81731a9553a4a4a2bf2487b Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 13 Jan 2012 15:40:32 -0600 Subject: some map subscript pointer lists hg-commit-id: b36e9b279197 --- extras/insert_texts.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'extras/insert_texts.py') diff --git a/extras/insert_texts.py b/extras/insert_texts.py index 75392b5c..b3ec4062 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -480,7 +480,7 @@ def scan_for_map_scripts_pointer(): latest_script_pointer = first_script_pointer while last_a_id == (max(a_numbers)) or last_a_id==0: asm_output, offset, last_hl_address2, last_a_id, byte1, byte2, address = None, None, None, None, None, None, None - asm_output, offset, last_hl_address2, last_a_id, used_3d97 = output_bank_opcodes(latest_script_pointer) + asm_output, offset, last_hl_address2, last_a_id, used_3d97_2 = output_bank_opcodes(latest_script_pointer) if last_a_id == (max(a_numbers) + 1): a_numbers.append(last_a_id) @@ -553,7 +553,7 @@ def scan_for_map_scripts_pointer(): script_label = map_name_cleaner(map2["name"], None)[:-2] + "Script" scripts_label = script_label + "s" - scripts_asm = scripts_label + ": ; " + hex(start_address) + "\n" + script_asm = scripts_label + ": ; " + hex(start_address) + "\n" script_asm += spacing + "dw" first = True @@ -581,6 +581,10 @@ def scan_for_map_scripts_pointer(): load_asm() isolate_incbins() process_incbins() + else: + print "trouble inserting map script pointer list" + print script_asm + sys.exit(0) if __name__ == "__main__": #load map headers and object data -- cgit v1.2.3