quick tool for dumping a segment of ApplyMovementData objects into a bank

This commit is contained in:
Bryan Bishop 2012-05-11 16:30:12 -05:00
parent 4b1540623a
commit feab0b56bc
1 changed files with 28 additions and 0 deletions

View File

@ -5872,6 +5872,22 @@ def list_texts_in_bank(bank):
return texts return texts
def list_movements_in_bank(bank):
""" Narrows down the list of objects
to speed up Asm insertion.
"""
if len(all_movements) == 0:
raise Exception, "all_movements is blank.. run_main() will populate it"
assert bank != None, "list_movements_in_bank must be given a particular bank"
assert 0 <= bank < 0x80, "bank doesn't exist in the ROM (out of bounds)"
movements = []
for movement in all_movements:
if calculate_bank(movement.address) == bank:
movements.append(movement)
return movements
def dump_asm_for_texts_in_bank(bank, start=50, end=100): def dump_asm_for_texts_in_bank(bank, start=50, end=100):
""" Simple utility to help with dumping texts into a particular bank. This """ Simple utility to help with dumping texts into a particular bank. This
is helpful for figuring out which text is breaking that bank. is helpful for figuring out which text is breaking that bank.
@ -5896,6 +5912,18 @@ def dump_asm_for_texts_in_bank(bank, start=50, end=100):
print "done dumping texts for bank $%.2x" % (bank) print "done dumping texts for bank $%.2x" % (bank)
def dump_asm_for_movements_in_bank(bank, start=0, end=100):
if rom == None or len(rom) <= 4:
load_rom()
run_main()
movements = list_movements_in_bank(bank)[start:end]
asm = Asm()
asm.insert_with_dependencies(movements)
asm.dump()
print "done dumping movements for bank $%.2x" % (bank)
def index(seq, f): def index(seq, f):
"""return the index of the first item in seq """return the index of the first item in seq
where f(item) == True.""" where f(item) == True."""