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 | 8fe39c647bb50bb53fe28f8e9f38f7dcae8eb183 (patch) | |
tree | c89abba8dfd39c76bdfc65bcca01bc70ffb84c75 /pointers.py | |
parent | b0ff2abc307118fb55eeab5252213a2331e2ac22 (diff) |
move code around to avoid dependency loops
original-commit-id: ca07f1d64c0235b49160fc501553a70af8331d81
Diffstat (limited to 'pointers.py')
-rw-r--r-- | pointers.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pointers.py b/pointers.py new file mode 100644 index 0000000..d7b3cb8 --- /dev/null +++ b/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 + |