Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
simontime authored Oct 16, 2018
1 parent 6c5ea0f commit 5421d1b
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
74 changes: 74 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
36 changes: 36 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
57 changes: 57 additions & 0 deletions SXAssetExtractor.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5A1EF9F6-43BB-4591-ACCD-7C8DF93B85A2}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SXAssetExtractor</RootNamespace>
<AssemblyName>SXAssetExtractor</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 5421d1b

Please sign in to comment.