mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-09-17 02:40:50 +12:00
update gbz80disasm to account for conditional relative forward jumps
hg-commit-id: 86a98b551bf2
This commit is contained in:
parent
0bf1f601c4
commit
a43794ce2e
|
@ -546,7 +546,7 @@ end_08_scripts_with = [
|
|||
0xc9, #ret
|
||||
###0xda, 0xe9, 0xd2, 0xc2, 0xca, 0xc3, 0x38, 0x30, 0x20, 0x28, 0x18, 0xd8, 0xd0, 0xc0, 0xc8, 0xc9
|
||||
]
|
||||
relative_jumps = [0x38, 0x30, 0x20, 0x28, 0x18, 0xc3]
|
||||
relative_jumps = [0x38, 0x30, 0x20, 0x28, 0x18, 0xc3, 0xda]
|
||||
relative_unconditional_jumps = [0xc3, 0x18]
|
||||
|
||||
#TODO: replace call and a pointer with call and a label
|
||||
|
@ -746,7 +746,7 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000):
|
|||
if current_byte == 0xc3:
|
||||
if number == 0x3d97: used_3d97 = True
|
||||
#if number == 0x24d7: #jp
|
||||
if not has_outstanding_labels(byte_labels):
|
||||
if not has_outstanding_labels(byte_labels) or all_outstanding_labels_are_reverse(byte_labels, offset):
|
||||
keep_reading = False
|
||||
is_data = False
|
||||
break
|
||||
|
@ -754,11 +754,17 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000):
|
|||
is_data = True
|
||||
|
||||
#stop reading at a jump, relative jump or return
|
||||
if current_byte in end_08_scripts_with or (current_byte == 0x18 and target_address < offset):
|
||||
if not has_outstanding_labels(byte_labels) or (current_byte == 0x18 and target_address < offset):
|
||||
if current_byte in end_08_scripts_with:
|
||||
if not has_outstanding_labels(byte_labels) and all_outstanding_labels_are_reverse(byte_labels, offset):
|
||||
keep_reading = False
|
||||
is_data = False #cleanup
|
||||
break
|
||||
else:
|
||||
is_data = False
|
||||
keep_reading = True
|
||||
else:
|
||||
is_data = False
|
||||
keep_reading = True
|
||||
else:
|
||||
# if is_data and keep_reading:
|
||||
output += spacing + "db $" + hex(ord(rom[offset]))[2:] #+ " ; " + hex(offset)
|
||||
|
@ -792,6 +798,13 @@ def has_outstanding_labels(byte_labels):
|
|||
if real_line["definition"] == False: return True
|
||||
return False
|
||||
|
||||
def all_outstanding_labels_are_reverse(byte_labels, offset):
|
||||
for label_id in byte_labels.keys():
|
||||
line = byte_labels[label_id] # label_id is also the address
|
||||
if line["definition"] == False:
|
||||
if not label_id < offset: return False
|
||||
return True
|
||||
|
||||
def text_asm_pretty_printer(label, address_of_08, include_08=True):
|
||||
"""returns (output, end_address)"""
|
||||
output = label + ": ; " + hex(address_of_08) + "\n"
|
||||
|
|
Loading…
Reference in a new issue