diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-03-12 03:01:38 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-03-12 03:01:38 -0500 |
commit | 3e09fca53930e0563e77b8ee96ae3199d8f3b410 (patch) | |
tree | 5a5af4740889028ffd57fdb56f38fe6dc9af65fe /crystal.py | |
parent | 530b891166b941df50c99b4d29d53f000cb2e881 (diff) |
fix calculate_pointer
original-commit-id: ad0f365a372d227cf050b2c1016bda5f9b9f80c6
Diffstat (limited to 'crystal.py')
-rw-r--r-- | crystal.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -363,11 +363,15 @@ def calculate_bank(address): if type(address) == str: address = int(address, 16) return int(address) / 0x4000 -def calculate_pointer(short_pointer, bank): +def calculate_pointer(short_pointer, bank=None): """calculates the full address given a 4-byte pointer and bank byte""" short_pointer = int(short_pointer) - bank = int(bank) - pointer = short_pointer - 0x4000 + (bank * 0x4000) + if short_pointer > 0x4000: + short_pointer -= 0x4000 + bank = int(bank) + else: + bank = 0 + pointer = short_pointer + (bank * 0x4000) return pointer def calculate_pointer_from_bytes_at(address, bank=False): """calculates a pointer from 2 bytes at a location |