Merge pull request #147 from yenatch/master

gbz80disasm/sym fixes + odds and ends

original-commit-id: ac773a9dc1499f7070dc98236c66de6309885210
This commit is contained in:
Bryan Bishop
2013-06-17 16:56:00 -07:00
2 changed files with 3 additions and 3 deletions

View File

@@ -577,13 +577,13 @@ def find_label(local_address, bank_id=0):
if local_address < 0x8000:
for label_entry in all_labels:
if label_entry["address"] == local_address:
if label_entry["address"] & 0x7fff == local_address:
if label_entry["bank"] == bank_id or label_entry["bank"] == 0:
return label_entry["label"]
if local_address in wram_labels.keys():
return wram_labels[local_address][-1]
for constants in [gbhw_constants, hram_constants]:
if local_address in constants.keys():
if local_address in constants.keys() and local_address >= 0xff00:
return constants[local_address]
return None

2
sym.py
View File

@@ -10,7 +10,7 @@ def make_sym_from_json(filename = '../pokecrystal.sym', j = 'labels.json'):
# todo: delete and remake labels.json at runtime
with open(filename, 'w') as sym:
for label in json.load(open(j)):
sym.write('{0:x}:{1:x} {2}\n'.format(label['bank'], label['address']&0x3fff, label['label']))
sym.write('{0:x}:{1:x} {2}\n'.format(label['bank'], label['address']%0x4000 + (0x4000 if label['bank'] else 0), label['label']))
def make_sym_from_mapfile(filename = '../pokecrystal.sym', mapfile = '../mapfile.txt'):