diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-06-20 01:13:15 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-06-20 01:13:15 -0500 |
commit | ca07f1d64c0235b49160fc501553a70af8331d81 (patch) | |
tree | 673276751462c0a227870b75ea0b8fd8bae018eb /extras/pointers.py | |
parent | e2babd69fb94781df54f2e4ded5efcc2aa7d0f8d (diff) |
move code around to avoid dependency loops
Diffstat (limited to 'extras/pointers.py')
-rw-r--r-- | extras/pointers.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/extras/pointers.py b/extras/pointers.py new file mode 100644 index 000000000..d7b3cb877 --- /dev/null +++ b/extras/pointers.py @@ -0,0 +1,15 @@ +""" Various functions related to pointer and address math. Mostly to avoid + depedency loops. +""" + +def calculate_pointer(short_pointer, bank=None): + """calculates the full address given a 4-byte pointer and bank byte""" + short_pointer = int(short_pointer) + if 0x4000 <= short_pointer <= 0x7fff: + short_pointer -= 0x4000 + bank = int(bank) + else: + bank = 0 + pointer = short_pointer + (bank * 0x4000) + return pointer + |