-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFFL2R_utils.py
More file actions
34 lines (29 loc) · 1.34 KB
/
Copy pathFFL2R_utils.py
File metadata and controls
34 lines (29 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from FFL2R_data import GameData
EIGHT_BIT_INT = 255
SIXTEEN_BIT_INT = 65535
class Utility:
twoBytes = lambda x, y : y << EIGHT_BIT_INT.bit_length() | x
threeBytes = lambda x, y, z : z << SIXTEEN_BIT_INT.bit_length() | y << EIGHT_BIT_INT.bit_length() | x
byteizeTwo = lambda x : (x & EIGHT_BIT_INT, x >> EIGHT_BIT_INT.bit_length() & EIGHT_BIT_INT)
byteizeThree = lambda x : (x & EIGHT_BIT_INT, x >> EIGHT_BIT_INT.bit_length() & EIGHT_BIT_INT, x >> SIXTEEN_BIT_INT.bit_length() & SIXTEEN_BIT_INT)
findCoordinate = lambda byte : ((byte & 0x3f) | (((byte & 0x3f) >> 4) << 4))
remainingBytes = lambda byte, sub : ((byte - sub) & 0xf0) >> 6
highNibble = lambda byte : (byte & 0xf0) >> 4
lowNibble = lambda byte : byte & 0x0f
isbitset = lambda byte, bit: bool((byte >> bit) & 1)
def setBoundaries(num:int, floor:int, ceiling:int) -> int:
if num < floor:
num = floor
elif num > ceiling:
num = ceiling
return num
def dteTranslate(strList:bytearray)->str:
result = ""
for char in strList:
try:
result = result + (GameData.dteLookup[char])
except:
result = result + " " + (str(char))
return result
def listToHex(intList:list)->list:
return [hex(x) for x in intList]