mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 22:40:27 +00:00
Some buffer fixes for LM2
This commit is contained in:
parent
91f71c1cc5
commit
1885319061
7 changed files with 125 additions and 60 deletions
Binary file not shown.
|
@ -187,7 +187,7 @@ namespace FirstPlugin.LuigisMansion.DarkMoon
|
|||
UShortToFloatDecode(reader.ReadInt16()),
|
||||
UShortToFloatDecode(reader.ReadInt16()));
|
||||
|
||||
// reader.BaseStream.Position += 0x4;
|
||||
reader.BaseStream.Position += 0x4;
|
||||
|
||||
vert.pos = Vector3.TransformPosition(vert.pos, mesh.Transform);
|
||||
vert.uv0 = NormalizeUvCoordsToFloat(reader.ReadUInt16(), reader.ReadUInt16());
|
||||
|
@ -445,7 +445,7 @@ namespace FirstPlugin.LuigisMansion.DarkMoon
|
|||
{ 0x314A20AEFADABB22, new FormatInfo(VertexDataFormat.Float32_32_32, 0x18)},
|
||||
{ 0x0F3F68A287C2B716, new FormatInfo(VertexDataFormat.Float32_32_32, 0x18)},
|
||||
{ 0x27F993771090E6EB, new FormatInfo(VertexDataFormat.Float32_32_32, 0x1C)},
|
||||
{ 0x4E315C83A856FBF7, new FormatInfo(VertexDataFormat.Float32, 0x1C)},
|
||||
{ 0x4E315C83A856FBF7, new FormatInfo(VertexDataFormat.Float32_32_32, 0x1C)},
|
||||
{ 0xBD15F722F07FC596, new FormatInfo(VertexDataFormat.Float32_32_32, 0x1C)},
|
||||
{ 0xFBACD243DDCC31B7, new FormatInfo(VertexDataFormat.Float32_32_32, 0x1C)},
|
||||
{ 0x8A4CC565333626D9, new FormatInfo(VertexDataFormat.Float32_32, 0x1C)},
|
||||
|
|
|
@ -247,6 +247,17 @@ namespace FirstPlugin
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint NameHash(string name)
|
||||
{
|
||||
uint result = 0;
|
||||
for (int i = 0; i < name.Length; i++)
|
||||
{
|
||||
result = name[i] + result * 0x00000065;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte[] Save()
|
||||
{
|
||||
sarcData.Files.Clear();
|
||||
|
|
|
@ -63,7 +63,6 @@ namespace FirstPlugin
|
|||
return raw;
|
||||
}
|
||||
|
||||
//Decryption process from https://github.com/TheFearsomeDzeraora/BFTTFutil/blob/master/Program.cs
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
Text = FileName;
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
using System.Drawing;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class GITextureContainer : TreeNodeFile, IFileFormat
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Image;
|
||||
|
||||
public bool CanSave { get; set; }
|
||||
public string[] Description { get; set; } = new string[] { "GT1" };
|
||||
public string[] Extension { get; set; } = new string[] { "*.gt1" };
|
||||
public string FileName { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public IFileInfo IFileInfo { get; set; }
|
||||
|
||||
public bool Identify(System.IO.Stream stream)
|
||||
{
|
||||
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
|
||||
{
|
||||
return reader.CheckSignature(4, "GT1G");
|
||||
}
|
||||
}
|
||||
|
||||
public Type[] Types
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Type> types = new List<Type>();
|
||||
return types.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
Read(new FileReader(stream));
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public byte[] Save()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Read(FileReader reader)
|
||||
{
|
||||
long StartPos = reader.Position;
|
||||
string Magic = reader.ReadString(8);
|
||||
uint FileSize = reader.ReadUInt32();
|
||||
uint DataOffset = reader.ReadUInt32();
|
||||
uint TextureCount = reader.ReadUInt32();
|
||||
uint unk = reader.ReadUInt32();
|
||||
uint unk2 = reader.ReadUInt32();
|
||||
uint[] unk3s = reader.ReadUInt32s((int)TextureCount);
|
||||
|
||||
for (int i = 0; i < TextureCount; i++)
|
||||
{
|
||||
reader.SeekBegin(StartPos + DataOffset + (i * 4));
|
||||
|
||||
uint InfoOffset = reader.ReadUInt32();
|
||||
|
||||
reader.SeekBegin(DataOffset + InfoOffset);
|
||||
byte unk4 = reader.ReadByte();
|
||||
byte format = reader.ReadByte();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GITexture : STGenericTexture
|
||||
{
|
||||
public override bool CanEdit { get; set; } = false;
|
||||
|
||||
public byte[] ImageData;
|
||||
|
||||
public override TEX_FORMAT[] SupportedFormats
|
||||
{
|
||||
get
|
||||
{
|
||||
return new TEX_FORMAT[] {
|
||||
TEX_FORMAT.R8G8B8A8_UNORM,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetImageData(Bitmap bitmap, int ArrayLevel)
|
||||
{
|
||||
}
|
||||
|
||||
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
return ImageData;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -91,15 +91,16 @@ namespace FirstPlugin
|
|||
var fileEntry = new FileEntry();
|
||||
reader.SeekBegin(Offsets[i]);
|
||||
string Magic = reader.ReadString(8);
|
||||
reader.Seek(-8);
|
||||
switch (Magic)
|
||||
{
|
||||
case "G1TG0060": //PC or Wii U Texture
|
||||
GITextureContainer GITextureU = new GITextureContainer();
|
||||
GITextureU.Read(reader, true);
|
||||
GITextureU.Read(reader);
|
||||
break;
|
||||
case "GT1G0600": //Switch Texture
|
||||
GITextureContainer GITexture = new GITextureContainer();
|
||||
GITexture.Read(reader, false);
|
||||
GITexture.Read(reader);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -112,59 +113,6 @@ namespace FirstPlugin
|
|||
}
|
||||
}
|
||||
|
||||
public class GITextureContainer
|
||||
{
|
||||
public void Read(FileReader reader, bool IsWiiU)
|
||||
{
|
||||
long StartPos = reader.Position;
|
||||
|
||||
uint FileSize = reader.ReadUInt32();
|
||||
uint DataOffset = reader.ReadUInt32();
|
||||
uint TextureCount = reader.ReadUInt32();
|
||||
uint unk = reader.ReadUInt32();
|
||||
uint unk2 = reader.ReadUInt32();
|
||||
uint[] unk3s = reader.ReadUInt32s((int)TextureCount);
|
||||
|
||||
for (int i = 0; i < TextureCount; i++)
|
||||
{
|
||||
reader.SeekBegin(StartPos + DataOffset + (i * 4));
|
||||
|
||||
uint InfoOffset = reader.ReadUInt32();
|
||||
|
||||
reader.SeekBegin(DataOffset + InfoOffset);
|
||||
byte unk4 = reader.ReadByte();
|
||||
byte format = reader.ReadByte();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GITexture : STGenericTexture
|
||||
{
|
||||
public override bool CanEdit { get; set; } = false;
|
||||
|
||||
public byte[] ImageData;
|
||||
|
||||
public override TEX_FORMAT[] SupportedFormats
|
||||
{
|
||||
get
|
||||
{
|
||||
return new TEX_FORMAT[] {
|
||||
TEX_FORMAT.R8G8B8A8_UNORM,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetImageData(Bitmap bitmap, int ArrayLevel)
|
||||
{
|
||||
}
|
||||
|
||||
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
return ImageData;
|
||||
}
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
|
|
@ -205,7 +205,8 @@
|
|||
<Compile Include="FileFormats\Archives\APAK.cs" />
|
||||
<Compile Include="FileFormats\Archives\ARC.cs" />
|
||||
<Compile Include="FileFormats\Archives\GFA.cs" />
|
||||
<Compile Include="FileFormats\Archives\HyruleWarriors\HWBinGzResource.cs" />
|
||||
<Compile Include="FileFormats\HyruleWarriors\GITextureContainer.cs" />
|
||||
<Compile Include="FileFormats\HyruleWarriors\HWBinGzResource.cs" />
|
||||
<Compile Include="FileFormats\Archives\IGA_PAK.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM2\LM2_ChunkTable.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM2\LM2_DICT.cs" />
|
||||
|
|
Loading…
Reference in a new issue