mirror of https://github.com/pret/pokecrystal.git
update gbz80disasm for handling known fall-throughs
When disassembling a group of functions, sometimes there are other functions known in advance. By passing in a list called stop_at to gbz80disasm, it is possible to prevent disassembled asm from running on for longer than necessary.
This commit is contained in:
parent
0e2ab04353
commit
01e10a11b2
|
@ -592,7 +592,7 @@ def asm_label(address):
|
||||||
# why using a random value when you can use the address?
|
# why using a random value when you can use the address?
|
||||||
return ".ASM_" + hex(address)[2:]
|
return ".ASM_" + hex(address)[2:]
|
||||||
|
|
||||||
def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_address=True, debug = False):
|
def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_address=True, stop_at=[], debug = False):
|
||||||
#fs = current_address
|
#fs = current_address
|
||||||
#b = bank_byte
|
#b = bank_byte
|
||||||
#in = input_data -- rom
|
#in = input_data -- rom
|
||||||
|
@ -601,6 +601,10 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_add
|
||||||
#ad = end_address
|
#ad = end_address
|
||||||
#a, oa = current_byte_number
|
#a, oa = current_byte_number
|
||||||
|
|
||||||
|
# stop_at can be used to supply a list of addresses to not disassemble
|
||||||
|
# over. This is useful if you know in advance that there are a lot of
|
||||||
|
# fall-throughs.
|
||||||
|
|
||||||
load_labels()
|
load_labels()
|
||||||
load_rom()
|
load_rom()
|
||||||
|
|
||||||
|
@ -622,6 +626,7 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_add
|
||||||
|
|
||||||
byte_labels = {}
|
byte_labels = {}
|
||||||
|
|
||||||
|
first_loop = True
|
||||||
output = ""
|
output = ""
|
||||||
keep_reading = True
|
keep_reading = True
|
||||||
while offset <= end_address and keep_reading:
|
while offset <= end_address and keep_reading:
|
||||||
|
@ -629,6 +634,11 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_add
|
||||||
is_data = False
|
is_data = False
|
||||||
maybe_byte = current_byte
|
maybe_byte = current_byte
|
||||||
|
|
||||||
|
# stop at any address
|
||||||
|
if not first_loop and offset in stop_at:
|
||||||
|
keep_reading = False
|
||||||
|
break
|
||||||
|
|
||||||
#first check if this byte already has a label
|
#first check if this byte already has a label
|
||||||
#if it does, use the label
|
#if it does, use the label
|
||||||
#if not, generate a new label
|
#if not, generate a new label
|
||||||
|
@ -816,6 +826,8 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_add
|
||||||
#offset += 1
|
#offset += 1
|
||||||
#current_byte_number += 1
|
#current_byte_number += 1
|
||||||
|
|
||||||
|
first_loop = False
|
||||||
|
|
||||||
#clean up unused labels
|
#clean up unused labels
|
||||||
for label_line in byte_labels.keys():
|
for label_line in byte_labels.keys():
|
||||||
address = label_line
|
address = label_line
|
||||||
|
|
Loading…
Reference in New Issue