ref: d2f4073eb9b8a39c2356be0de10867aabe95dd3a
parent: a33150930bbc2a44992a6963f9686c2b32ced4ae
author: Bryan Bishop <kanzure@gmail.com>
date: Tue Jan 24 07:49:08 EST 2012
update gbz80disasm to find labels better hg-commit-id: 10be245776b4
--- a/extras/gbz80disasm.py
+++ b/extras/gbz80disasm.py
@@ -567,6 +567,10 @@
def find_label(local_address, bank_id=0):
global all_labels
+ #keep an integer
+ if type(local_address) == str:
+ local_address1 = int(local_address.replace("$", "0x"), 16)
+ else: local_address1 = local_address
#turn local_address into a string
if type(local_address) == str:
@@ -573,12 +577,12 @@
if "0x" in local_address: local_address = local_address.replace("0x", "$")
elif not "$" in local_address: local_address = "$" + local_address
if type(local_address) == int:
- local_address = "$%.2x" % (local_address)
+ local_address = "$%.x" % (local_address)
local_address = local_address.upper()
for label_entry in all_labels:
if label_entry["local_pointer"].upper() == local_address:
- if label_entry["bank_id"] == bank_id:
+ if label_entry["bank_id"] == bank_id or (local_address1 < 0x8000 and (label_entry["bank_id"] == 0 or label_entry["bank_id"] == 1)):
return label_entry["label"]
return None
@@ -599,8 +603,9 @@
#a, oa = current_byte_number
bank_id = 0
- if original_offset > 0x4000:
+ if original_offset > 0x8000:
bank_id = original_offset / 0x4000
+ print "bank id is: " + str(bank_id)
last_hl_address = None #for when we're scanning the main map script
last_a_address = None
@@ -741,7 +746,7 @@
insertion = "$%.4x" % (number)
if maybe_byte in call_commands or current_byte in relative_unconditional_jumps or current_byte in relative_jumps:
- result = find_label(insertion[1:], bank_id)
+ result = find_label(insertion, bank_id)
if result != None:
insertion = result