mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-11-12 00:04:48 +13:00
fix some offset errors in insert_texts.py
hg-commit-id: b131d049ecd3
This commit is contained in:
parent
e5f9d4a144
commit
be34aed58e
|
|
@ -235,7 +235,7 @@ def apply_diff(diff, try_fixing=True):
|
||||||
|
|
||||||
#confirm it's working
|
#confirm it's working
|
||||||
try:
|
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
|
return True
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
if try_fixing:
|
if try_fixing:
|
||||||
|
|
|
||||||
|
|
@ -496,6 +496,7 @@ def text_pretty_printer_at(start_address, label="SomeLabel"):
|
||||||
if first and needs_to_begin_with_0:
|
if first and needs_to_begin_with_0:
|
||||||
output += "$0, "
|
output += "$0, "
|
||||||
first = False
|
first = False
|
||||||
|
byte_count += 1
|
||||||
|
|
||||||
quotes_open = False
|
quotes_open = False
|
||||||
first_byte = True
|
first_byte = True
|
||||||
|
|
@ -550,7 +551,7 @@ def text_pretty_printer_at(start_address, label="SomeLabel"):
|
||||||
include_newline = "\n"
|
include_newline = "\n"
|
||||||
if output[-1] == "\n":
|
if output[-1] == "\n":
|
||||||
include_newline = ""
|
include_newline = ""
|
||||||
output += include_newline + "; " + hex(start_address + byte_count + 1)
|
output += include_newline + "; " + hex(start_address) + " + " + str(byte_count) + " bytes"
|
||||||
print output
|
print output
|
||||||
return (output, byte_count)
|
return (output, byte_count)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,19 @@ spacing = " "
|
||||||
tx_fars = None
|
tx_fars = None
|
||||||
failed_attempts = {}
|
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):
|
def find_tx_far_entry(map_id, text_id):
|
||||||
for tx_far_line in tx_fars:
|
for tx_far_line in tx_fars:
|
||||||
if tx_far_line[0] == map_id and tx_far_line[1] == text_id:
|
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)
|
result = apply_diff(diff, try_fixing=True)
|
||||||
return 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)"
|
"inserts a text script (but not $8s)"
|
||||||
start_address = address
|
start_address = address
|
||||||
|
|
||||||
|
|
@ -428,7 +441,7 @@ def insert_text(address, label, apply=False):
|
||||||
diff = generate_diff_insert(line_number, newlines)
|
diff = generate_diff_insert(line_number, newlines)
|
||||||
print diff
|
print diff
|
||||||
if apply:
|
if apply:
|
||||||
return apply_diff(diff)
|
return apply_diff(diff, try_fixing=try_fixing)
|
||||||
else: #simulate a successful insertion
|
else: #simulate a successful insertion
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -594,6 +607,7 @@ def scan_rom_for_tx_fars_and_insert():
|
||||||
looks through INCBIN'd addresses from common.asm,
|
looks through INCBIN'd addresses from common.asm,
|
||||||
finds TX_FARs that aren't included yet.
|
finds TX_FARs that aren't included yet.
|
||||||
"""
|
"""
|
||||||
|
x = 0
|
||||||
address_bundles = scan_rom_for_tx_fars(printer=True)
|
address_bundles = scan_rom_for_tx_fars(printer=True)
|
||||||
for address_bundle in address_bundles:
|
for address_bundle in address_bundles:
|
||||||
tx_far_address = address_bundle[1]
|
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
|
tx_far_target_label = "_" + tx_far_label
|
||||||
|
|
||||||
result = insert_text(tx_far_target_address, tx_far_target_label, apply=True)
|
result = insert_text(tx_far_target_address, tx_far_target_label, apply=True)
|
||||||
|
local_reset_incbins()
|
||||||
if result:
|
if result:
|
||||||
result2 = insert_text(tx_far_address, tx_far_label, apply=True)
|
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__":
|
if __name__ == "__main__":
|
||||||
#load map headers and object data
|
#load map headers and object data
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue