1
0
Fork 0

misc fixes

This commit is contained in:
JoshuaMKW 2020-11-19 03:45:53 -06:00
parent d80a7175a2
commit c0af5c030c
2 changed files with 6 additions and 4 deletions

View file

@ -306,11 +306,14 @@ class DolFile(object):
_from: address to branch from\n
lk: 0 | 1, is branch linking? """
_from &= 0xFFFFFFFC
to &= 0xFFFFFFFC
self.seek(_from)
print(hex(to), hex(_from), hex((to - _from) & 0x3FFFFFD | 0x48000000 | lk))
write_uint32(self, (to - _from) & 0x3FFFFFD | 0x48000000 | lk)
def extract_branch_addr(self, bAddr: int) -> tuple:
""" Returns the branch offset of the given instruction,
""" Returns the destination of the given branch,
and if the branch is conditional """
self.seek(bAddr)

View file

@ -124,7 +124,7 @@ class GCT(object):
value = int.from_bytes(info, byteorder='big', signed=False)
data = read_uint16(self.codeList)
size = data & 0x3000
size = data & 0x3
counter = data & 0xFFF
address_increment = read_uint16(self.codeList)
value_increment = read_uint32(self.codeList)
@ -151,8 +151,7 @@ class GCT(object):
elif (codetype.startswith(b'\xC6') or codetype.startswith(b'\xC7')
or codetype.startswith(b'\xC6') or codetype.startswith(b'\xC7')):
dolFile.seek(address)
dolFile.insert_branch(int.from_bytes(info, byteorder='big', signed=False), address)
dolFile.insert_branch(int.from_bytes(info, byteorder='big', signed=False), address, lk=address&1)
continue
if codetype.hex().startswith('2') or codetype.hex().startswith('3'):