1
- # based on https://github.com/nesrak1/UABEA /blob/master/TexturePlugin/Texture2DSwitchDeswizzler .cs
2
- from typing import Dict , Tuple
1
+ # based on https://github.com/nesrak1/AssetsTools.NET /blob/dev/AssetsTools.NET.Texture/Swizzle/SwitchSwizzle .cs
2
+ from typing import Dict , Optional , Tuple , Union
3
3
4
- from ..enums import TextureFormat
4
+ from ..enums import BuildTarget , TextureFormat
5
5
6
6
GOB_X_TEXEL_COUNT = 4
7
7
GOB_Y_TEXEL_COUNT = 8
@@ -18,7 +18,7 @@ def ceil_divide(a: int, b: int) -> int:
18
18
19
19
20
20
def deswizzle (
21
- data : bytes ,
21
+ data : Union [ bytes , bytearray ] ,
22
22
width : int ,
23
23
height : int ,
24
24
block_width : int ,
@@ -50,7 +50,7 @@ def deswizzle(
50
50
51
51
52
52
def swizzle (
53
- data : bytes ,
53
+ data : Union [ bytes , bytearray ] ,
54
54
width : int ,
55
55
height : int ,
56
56
block_width : int ,
@@ -135,3 +135,14 @@ def get_padded_texture_size(
135
135
136
136
def get_switch_gobs_per_block (platform_blob : bytes ) -> int :
137
137
return 1 << int .from_bytes (platform_blob [8 :12 ], "little" )
138
+
139
+
140
+ def is_switch_swizzled (
141
+ platform : Union [BuildTarget , int ], platform_blob : Optional [bytes ]
142
+ ) -> bool :
143
+ if platform != BuildTarget .Switch :
144
+ return False
145
+ if not platform_blob or len (platform_blob ) < 12 :
146
+ return False
147
+ gobs_per_block = get_switch_gobs_per_block (platform_blob )
148
+ return gobs_per_block > 1
0 commit comments