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
33
4- from ..enums import TextureFormat
4+ from ..enums import BuildTarget , TextureFormat
55
66GOB_X_TEXEL_COUNT = 4
77GOB_Y_TEXEL_COUNT = 8
@@ -18,7 +18,7 @@ def ceil_divide(a: int, b: int) -> int:
1818
1919
2020def deswizzle (
21- data : bytes ,
21+ data : Union [ bytes , bytearray ] ,
2222 width : int ,
2323 height : int ,
2424 block_width : int ,
@@ -50,7 +50,7 @@ def deswizzle(
5050
5151
5252def swizzle (
53- data : bytes ,
53+ data : Union [ bytes , bytearray ] ,
5454 width : int ,
5555 height : int ,
5656 block_width : int ,
@@ -135,3 +135,14 @@ def get_padded_texture_size(
135135
136136def get_switch_gobs_per_block (platform_blob : bytes ) -> int :
137137 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