diff options
author | Sanky <gsanky@gmail.com> | 2013-03-02 21:40:02 +0100 |
---|---|---|
committer | Sanky <gsanky@gmail.com> | 2013-03-02 21:40:02 +0100 |
commit | aec5a652c8ed7d482330dd9254b48e5a7141866d (patch) | |
tree | 06678a02f28e62a39b2c61fb576468afc335f634 /extras/gbz80disasm.py | |
parent | 5af3f92d9080cb874b6c46aa5b52c2a6cdab24f0 (diff) | |
parent | 9ee0600524218d47ce2faa9b122a8e2b498e9b66 (diff) |
Merge http://github.com/yenatch/pokecrystal
Diffstat (limited to 'extras/gbz80disasm.py')
-rw-r--r-- | extras/gbz80disasm.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index d22f152f1..efb4689ab 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -592,7 +592,7 @@ def asm_label(address): # why using a random value when you can use the address? return ".ASM_" + hex(address)[2:] -def output_bank_opcodes(original_offset, max_byte_count=0x4000, debug = False): +def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_address=True, stop_at=[], debug = False): #fs = current_address #b = bank_byte #in = input_data -- rom @@ -601,6 +601,10 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, debug = False): #ad = end_address #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_rom() @@ -622,6 +626,7 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, debug = False): byte_labels = {} + first_loop = True output = "" keep_reading = True while offset <= end_address and keep_reading: @@ -629,6 +634,11 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, debug = False): is_data = False 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 #if it does, use the label #if not, generate a new label @@ -816,6 +826,8 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, debug = False): #offset += 1 #current_byte_number += 1 + first_loop = False + #clean up unused labels for label_line in byte_labels.keys(): address = label_line @@ -824,7 +836,8 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, debug = False): output = output.replace((label_line["name"] + "\n").lower(), "") #add the offset of the final location - output += "; " + hex(offset) + if include_last_address: + output += "; " + hex(offset) return (output, offset, last_hl_address, last_a_address, used_3d97) |