ref: 6630406043cda9e4ab36f8477c62025249b647d6
parent: 7804dedce469cd40efbc140b80d84733ec853338
author: yenatch <[email protected]>
date: Mon Jun 24 23:55:38 EDT 2013
gbz80disasm: local/global address conversion + fix find_label
--- a/extras/gbz80disasm.py
+++ b/extras/gbz80disasm.py
@@ -577,7 +577,7 @@
if local_address < 0x8000:
for label_entry in all_labels:
- if label_entry["address"] & 0x7fff == local_address:
+ if get_local_address(label_entry["address"]) == local_address:
if label_entry["bank"] == bank_id or label_entry["bank"] == 0:
return label_entry["label"]
if local_address in wram_labels.keys():
@@ -593,6 +593,12 @@
def data_label(address):
return '.DATA_%x' % address
+def get_local_address(address):
+ bank = address / 0x4000
+ return (address & 0x3fff) + 0x4000 * bool(bank)
+def get_global_address(address, bank):
+ return (address & 0x3fff) + 0x4000 * bank
+
def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_address=True, stop_at=[], debug = False):
#fs = current_address
#b = bank_byte
@@ -775,7 +781,7 @@
number = byte1
number += byte2 << 8
- pointer = bank_id * 0x4000 + (number & 0x3fff)
+ pointer = get_global_address(number, bank_id)
if pointer not in data_tables.keys():
data_tables[pointer] = {}
data_tables[pointer]['usage'] = 0
@@ -850,7 +856,7 @@
keep_reading = True
if offset in data_tables.keys():
- output = output.replace('$%x' % ((offset & 0x3fff) + 0x4000 * bool(bank_id)), data_label(offset).lower())
+ output = output.replace('$%x' % (get_local_address(offset)), data_label(offset).lower())
output += data_label(offset).lower() + '\n'
first_loop = False