From 5421d1b3edec5a75225fcecaa565884214f826a9 Mon Sep 17 00:00:00 2001 From: Simon Aarons <40786398+simonmkwii-dev@users.noreply.github.com> Date: Wed, 17 Oct 2018 02:23:48 +1100 Subject: [PATCH] Add files via upload --- App.config | 6 ++++ Program.cs | 74 ++++++++++++++++++++++++++++++++++++++ Properties/AssemblyInfo.cs | 36 +++++++++++++++++++ SXAssetExtractor.csproj | 57 +++++++++++++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 App.config create mode 100644 Program.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 SXAssetExtractor.csproj diff --git a/App.config b/App.config new file mode 100644 index 0000000..00bfd11 --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..99d7017 --- /dev/null +++ b/Program.cs @@ -0,0 +1,74 @@ +using System; +using System.IO; +using System.Text; + +namespace SXAssetExtractor +{ + internal class Program + { + internal struct FileInfo + { + internal byte[] Filename; + internal int Offset; + internal int Size; + internal int TexWidth; + internal int TexHeight; + } + + private static string TrimB(byte[] In) + { + return Encoding.ASCII.GetString(In).Trim('\0'); + } + + private static void Main(string[] args) + { + var FO = File.OpenRead(args[0]); + var Rd = new BinaryReader(FO); + + var Magic = Rd.ReadBytes(4); + var NumOfFiles = Rd.ReadInt32(); + + FO.Position += 8; + + var Files = new FileInfo[NumOfFiles]; + + Directory.CreateDirectory(TrimB(Magic)); + + for (int i = 0; i < NumOfFiles; i++) + { + Files[i] = new FileInfo + { + Filename = Rd.ReadBytes(8), + Offset = Rd.ReadInt32(), + Size = Rd.ReadInt32(), + TexWidth = Rd.ReadInt32(), + TexHeight = Rd.ReadInt32() + }; + + FO.Position += 8; + var CurPos = FO.Position; + + var Name = TrimB(Files[i].Filename); + var Resolution = $"{Files[i].TexWidth}x{Files[i].TexHeight}"; + + Console.WriteLine($"Extracting {Name}.BIN ({Resolution})..."); + + var Out = File.OpenWrite($"GFX/{Name}_{Resolution}.BIN"); + var Wrt = new BinaryWriter(Out); + + FO.Position = Files[i].Offset; + Wrt.Write(Rd.ReadBytes(Files[i].Size)); + + Wrt.Close(); + Out.Close(); + + FO.Position = CurPos; + } + + Console.WriteLine("\nDone!"); + + Rd.Close(); + FO.Close(); + } + } +} \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9ac8afa --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SXAssetExtractor")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SXAssetExtractor")] +[assembly: AssemblyCopyright("Copyright © Simon 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5a1ef9f6-43bb-4591-accd-7c8df93b85a2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SXAssetExtractor.csproj b/SXAssetExtractor.csproj new file mode 100644 index 0000000..e3ff26b --- /dev/null +++ b/SXAssetExtractor.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {5A1EF9F6-43BB-4591-ACCD-7C8DF93B85A2} + Exe + SXAssetExtractor + SXAssetExtractor + v4.6.1 + 512 + true + + + AnyCPU + false + none + true + bin\Debug\ + + + prompt + 4 + Off + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file