Created
November 11, 2023 20:16
-
-
Save F0bes/45ec9fde16e62397653f66e144c8d131 to your computer and use it in GitHub Desktop.
PS2 TEX TOOLS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
val = int(sys.argv[1], 16) | |
r = val & 0xff | |
r = r >> 3 | |
g = (val >> 8) & 0xff | |
g = g >> 3 | |
b = (val >> 16) & 0xff | |
b = b >> 3 | |
ct16 = (b << 10) | (g << 5) | (r) | (((val >> 24) & 1) << 15) | |
print("0x%04X" % (((val >> 3) & 0x1F) | ((val >> 6) & 0x3E0) | ((val >> 9) & 0x7C00) | ((val >> 16) & 0x8000))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header_data = [ | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,1,1,1,1,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,11,1,2,2,1,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,11,1,1,2,2,1,11,11,11,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, | |
11,11,1,1,1,2,3,2,1,11,1,11,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,1,1, | |
1,11,11,1,1,2,3,2,1,1,1,1,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,11,1,2, | |
1,1,1,1,2,3,3,2,1,1,2,1,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,1,1,2, | |
2,1,1,1,2,3,3,2,1,2,2,1,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,1,2,2, | |
2,2,1,2,3,3,3,2,1,2,2,1,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,1,3,3, | |
3,2,1,2,3,3,3,2,2,2,2,1,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,11,1,2,2, | |
3,2,2,2,3,3,3,2,2,3,2,1,11,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,1,1,2,2, | |
3,2,2,3,3,4,3,2,2,3,2,1,1,11,11,11, | |
11,11,11,11,11,11,11,11,11,11,11,11,1,2,2,2, | |
3,2,2,3,4,4,3,2,2,3,2,2,1,1,1,11, | |
11,11,11,11,11,11,11,11,11,1,1,1,1,2,3,3, | |
3,3,3,3,4,4,3,3,2,3,3,2,1,1,1,11, | |
11,11,11,11,11,11,11,11,1,1,2,2,1,2,3,4, | |
4,4,4,4,4,4,4,3,3,3,3,2,1,2,1,1, | |
11,11,11,11,11,11,11,11,1,2,2,2,2,2,3,4, | |
4,4,4,4,4,4,4,4,4,4,3,2,1,2,2,1, | |
11,11,11,11,11,11,11,11,1,2,2,2,2,3,3,4, | |
4,4,4,4,4,4,4,4,4,4,3,2,1,2,2,1, | |
11,11,11,11,11,11,11,11,1,2,2,2,2,3,4,4, | |
4,5,5,5,5,5,5,5,5,4,2,1,1,2,2,2, | |
11,11,11,11,11,11,11,1,1,2,3,3,4,4,4,4, | |
4,5,5,5,5,5,5,5,4,3,2,1,2,3,3,2, | |
11,11,11,11,11,11,11,1,2,2,3,3,4,4,4,4, | |
4,5,5,5,5,5,5,5,4,3,2,2,2,3,3,2, | |
11,11,11,11,11,11,11,1,2,3,3,3,4,4,4,4, | |
5,5,5,5,5,5,5,5,4,3,3,3,3,3,3,1, | |
11,11,11,11,11,11,1,1,2,3,3,3,4,4,4,5, | |
5,5,5,7,7,5,5,5,4,4,4,3,3,3,2,1, | |
11,11,11,11,11,1,1,2,2,3,3,3,4,4,4,5, | |
5,7,7,7,7,5,5,5,4,4,4,3,3,3,2,1, | |
11,11,11,11,11,1,2,3,3,3,3,3,4,4,4,5, | |
7,7,7,7,5,5,5,5,4,4,3,3,3,3,2,1, | |
11,11,11,11,11,1,2,3,3,3,3,3,4,4,4,5, | |
7,7,7,7,5,5,4,4,4,4,3,3,3,3,2,1, | |
11,11,11,11,11,1,2,3,3,3,3,3,3,4,4,5, | |
7,7,7,7,7,5,4,4,4,3,3,3,3,3,2,1, | |
11,11,11,11,11,1,2,3,3,3,3,3,3,3,4,6, | |
7,7,7,7,7,4,4,4,3,3,3,3,3,2,2,1, | |
11,11,11,11,11,1,1,2,2,2,3,3,3,4,4,6, | |
7,7,7,7,7,4,4,3,3,3,3,3,2,1,1,1, | |
11,11,11,11,11,11,1,1,1,2,2,2,3,4,7,7, | |
7,7,7,7,7,4,4,3,3,3,2,2,1,1,11,11 | |
] | |
packed_values = [] | |
for i in range(0, len(header_data), 2): | |
packed = (header_data[i + 1] & 0x0F) << 4 | (header_data[i] & 0x0F) | |
packed_values.append(packed) | |
for i, value in enumerate(packed_values): | |
print(f"0x{value:02X},", end=" ") | |
if (i + 1) % 8 == 0: | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment