shithub: pokecrystal

Download patch

ref: fe4b13e304decc48af0918fce281ed588f867a72
parent: b9dfd607bbac6ef0145ca2421145159d05a89bb3
author: yenatch <[email protected]>
date: Thu Jun 27 18:28:53 EDT 2013

gbz80disasm: use existing labels as addresses

--- a/extras/gbz80disasm.py
+++ b/extras/gbz80disasm.py
@@ -587,6 +587,12 @@
             return constants[local_address]
     return None
 
+def find_address_from_label(label):
+    for label_entry in all_labels:
+        if label == label_entry["label"]:
+            return label_entry["address"]
+    return None
+
 def asm_label(address):
     # why using a random value when you can use the address?
     return '.asm_%x' % address
@@ -898,10 +904,15 @@
 
 
 if __name__ == "__main__":
+    load_labels()
     addr = sys.argv[1]
     if ":" in addr:
         addr = addr.split(":")
         addr = int(addr[0], 16)*0x4000+(int(addr[1], 16)%0x4000)
     else:
-        addr = int(addr, 16)
+        label_addr = find_address_from_label(addr)
+        if label_addr:
+            addr = label_addr
+        else:
+            addr = int(addr, 16)
     print output_bank_opcodes(addr)[0]