diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-01-10 01:18:18 -0600 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-01-10 01:18:18 -0600 |
commit | 4c59064f9f65eabbf72c247d78d5607ce1b5409f (patch) | |
tree | ac92fcadf5f0521ae851ffaca81b1b0875aed859 /extras/insert_texts.py | |
parent | 983b87069d1037bb4ad4eedb2ef769c398e0d084 (diff) |
insert_asm in insert_texts for function asm
hg-commit-id: dc34a93f0f47
Diffstat (limited to 'extras/insert_texts.py')
-rw-r--r-- | extras/insert_texts.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/extras/insert_texts.py b/extras/insert_texts.py index 75be89a6..1e190545 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -357,6 +357,36 @@ 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) + + #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 + + newlines = split_incbin_line_into_three(line_number, start_address, end_address - start_address ) + + 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", "$") + + diff = generate_diff_insert(line_number, newlines) + print diff + result = apply_diff(diff, try_fixing=False) + if __name__ == "__main__": #load map headers and object data extract_maps.load_rom() @@ -392,7 +422,9 @@ if __name__ == "__main__": #insert_all_text_labels() #insert_08_asm(83, 1) - insert_all_08s() + #insert_all_08s() + + insert_asm(0x3e48, "GivePokemon") print "-- FAILED ATTEMPTS --" print str(failed_attempts) |