Add swizzle checks for sdf files

This commit is contained in:
KillzXGaming 2019-06-22 08:56:23 -04:00
parent 54e88cdef5
commit fab1c82fd1
6 changed files with 17 additions and 4 deletions

Binary file not shown.

View file

@ -196,6 +196,7 @@ namespace FirstPlugin
public ulong DdsType;
public bool UseDDS;
public bool IsCompressed = false;
public bool IsSwizzled = false;
public override byte[] FileData
{
@ -209,11 +210,12 @@ namespace FirstPlugin
public override IFileFormat OpenFile()
{
byte[] Data = FileData;
var FileFormat = STFileLoader.OpenFileFormat(
IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), FileData, true);
IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), Data, true);
if (FileFormat is DDS)
((DDS)FileFormat).SwitchSwizzle = true;
((DDS)FileFormat).SwitchSwizzle = IsSwizzled;
return FileFormat;
}
@ -245,6 +247,7 @@ namespace FirstPlugin
if (UseDDS)
{
// Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)SDFParent.block2Array[DdsType].UsedBytes).ToArray());
bool IsDX10 = false;
using (var filereader = new FileReader(SDFParent.block2Array[DdsType].Data))
{
@ -252,11 +255,21 @@ namespace FirstPlugin
IsDX10 = filereader.ReadString(4) == "DX10";
if (IsDX10)
{
if (SDFParent.block2Array[DdsType].UsedBytes > 0x94)
IsSwizzled = true;
Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)0x94).ToArray());
}
else
{
if (SDFParent.block2Array[DdsType].UsedBytes > 0x80)
IsSwizzled = true;
Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)0x80).ToArray());
}
}
}
for (var i = 0; i < CompressedSizes.Count; i++)
{

View file

@ -776,7 +776,7 @@ namespace Switch_Toolbox.Library
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{
if (IsAtscFormat(Format))
SwitchSwizzle = true;
SwitchSwizzle = false;
if (SwitchSwizzle)
return TegraX1Swizzle.GetImageData(this, bdata, ArrayLevel, MipLevel);