Some more fixes for decoding gx2

This commit is contained in:
KillzXGaming 2019-06-30 18:24:23 -04:00
parent fa5fc52258
commit 44dea5fefd
11 changed files with 37 additions and 4 deletions

Binary file not shown.

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading.Tasks;
namespace System
{
public static class ByteArrayExtensions
{
public static T[] Slice<T>(this T[] arr, uint indexFrom, uint size)
{
T[] result = new T[size];
Array.Copy(arr, indexFrom, result, 0, size);
return result;
}
public static T[] SubArrayDeepClone<T>(this T[] data, int index, int length)
{
T[] arrCopy = new T[length];
Array.Copy(data, index, arrCopy, 0, length);
using (MemoryStream ms = new MemoryStream())
{
var bf = new BinaryFormatter();
bf.Serialize(ms, arrCopy);
ms.Position = 0;
return (T[])bf.Deserialize(ms);
}
}
}
}

View file

@ -568,6 +568,7 @@
<Compile Include="Generics\OpenGLTexture.cs" />
<Compile Include="Interfaces\IDirectoryNode.cs" />
<Compile Include="Interfaces\INode.cs" />
<Compile Include="IO\Extensions\ByteArrayExtensions.cs" />
<Compile Include="Rendering\RenderableTex.cs" />
<Compile Include="Generics\STBone.cs" />
<Compile Include="Generics\STGenericWrapper.cs" />
@ -625,12 +626,12 @@
<Compile Include="IO\FileWriter.cs" />
<Compile Include="IO\SyrootCommon\DWord.cs" />
<Compile Include="IO\SyrootCommon\Half.cs" />
<Compile Include="IO\IOExtensions.cs" />
<Compile Include="IO\Extensions\IOExtensions.cs" />
<Compile Include="IO\Matrix4x4.cs" />
<Compile Include="IO\STFileLoader.cs" />
<Compile Include="IO\STFileSaver.cs" />
<Compile Include="IO\StreamReaderExtensions.cs" />
<Compile Include="IO\StringExtension.cs" />
<Compile Include="IO\Extensions\StreamReaderExtensions.cs" />
<Compile Include="IO\Extensions\StringExtension.cs" />
<Compile Include="IO\STStream.cs" />
<Compile Include="Maths\Math.cs" />
<Compile Include="Plugin\GenericPluginLoader.cs" />

View file

@ -658,7 +658,7 @@ namespace Switch_Toolbox.Library
mipOffset = (tex.mipOffset[mipLevel - 1]);
if (mipLevel == 1)
mipOffset -= (uint)surfInfo.sliceSize;
mipOffset -= (uint)surfInfo.surfSize;
if (GetLevel)
{