mirror of
https://github.com/R-YaTian/TinkeDSi.git
synced 2025-06-18 16:45:43 -04:00
Versión 0.2.0.4:
* Soporte a juego LAYTON1 (carpeta ani y bg) * Lee archivos TXT * Lee archivos NCLR (paleta) * Lee archivos NCGR (imagen) * Lee archivos NSCR (tile info) * Descomprime NARC * Soporte de compresiones: - Huffman - LZ77 - LZSS - RLE
This commit is contained in:
commit
1cdc566b2d
201
Compresion/Basico.cs
Normal file
201
Compresion/Basico.cs
Normal file
@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
public static class Basico
|
||||
{
|
||||
static int MAX_OUTSIZE = 0x200000;
|
||||
const int N = 4096, F = 18;
|
||||
const byte THRESHOLD = 2;
|
||||
const int NIL = N;
|
||||
static bool showAlways = true;
|
||||
|
||||
const int LZ77_TAG = 0x10, LZSS_TAG = 0x11, RLE_TAG = 0x30, HUFF_TAG = 0x20, NONE_TAG = 0x00;
|
||||
|
||||
#region method: DecompressFolder
|
||||
public static void DecompressFolder(string inflr, string outflr)
|
||||
{
|
||||
showAlways = false; // only print errors/failures
|
||||
|
||||
if (!outflr.EndsWith("/") && !outflr.EndsWith("\\"))
|
||||
outflr += "/";
|
||||
StreamWriter sw = null;
|
||||
if (!Directory.Exists(inflr))
|
||||
{
|
||||
Console.WriteLine("No such file or folder: " + inflr);
|
||||
return;
|
||||
}
|
||||
string[] files = Directory.GetFiles(inflr);
|
||||
foreach (string fname in files)
|
||||
try
|
||||
{
|
||||
Decompress(Utils.makeSlashes(fname), outflr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (sw == null)
|
||||
sw = new StreamWriter(new FileStream(outflr + "lzsslog.txt", FileMode.Create));
|
||||
Console.WriteLine(e.Message);
|
||||
sw.WriteLine(e.Message);
|
||||
string copied = fname.Replace(inflr, outflr);
|
||||
if (!File.Exists(copied))
|
||||
File.Copy(fname, copied);
|
||||
}
|
||||
Console.WriteLine("Done decompressing files in folder " + inflr);
|
||||
if (sw != null)
|
||||
{
|
||||
Console.WriteLine("Errors have been logged to " + outflr + "lzsslog.txt");
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Method: Decompress
|
||||
public static void Decompress(string filein, string outflr)
|
||||
{
|
||||
FileStream fstr = File.OpenRead(filein);
|
||||
//if (fstr.Length > int.MaxValue)
|
||||
// throw new Exception("Files larger than 2GB cannot be decompressed by this program.");
|
||||
BinaryReader br = new BinaryReader(fstr);
|
||||
|
||||
byte tag = br.ReadByte();
|
||||
br.Close();
|
||||
try
|
||||
{
|
||||
switch (tag >> 4)
|
||||
{
|
||||
case LZ77_TAG >> 4:
|
||||
if (tag == LZ77_TAG)
|
||||
LZ77.DecompressLZ77(filein, outflr, true);
|
||||
else if (tag == LZSS_TAG)
|
||||
LZSS.Decompress11LZS(filein, outflr, true);
|
||||
else
|
||||
CopyFile(filein, outflr);
|
||||
break;
|
||||
case RLE_TAG >> 4: RLE.DecompressRLE(filein, outflr, true); break;
|
||||
case NONE_TAG >> 4: Decompress2(filein, outflr); break;
|
||||
case HUFF_TAG >> 4: Huffman.DecompressHuffman(filein, outflr, true); break;
|
||||
default: Decompress2(filein, outflr); break;
|
||||
}
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
CopyFile(filein, outflr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Could not properly decompress {0:s};", filein);
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine(e.StackTrace);
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
public static void Decompress(string filein, string outflr, bool isFolder)
|
||||
{
|
||||
FileStream fstr = File.OpenRead(filein);
|
||||
//if (fstr.Length > int.MaxValue)
|
||||
// throw new Exception("Files larger than 2GB cannot be decompressed by this program.");
|
||||
BinaryReader br = new BinaryReader(fstr);
|
||||
|
||||
byte tag = br.ReadByte();
|
||||
br.Close();
|
||||
try
|
||||
{
|
||||
switch (tag >> 4)
|
||||
{
|
||||
case LZ77_TAG >> 4:
|
||||
if (tag == LZ77_TAG)
|
||||
LZ77.DecompressLZ77(filein, outflr, isFolder);
|
||||
else if (tag == LZSS_TAG)
|
||||
LZSS.Decompress11LZS(filein, outflr, isFolder);
|
||||
else
|
||||
CopyFile(filein, outflr);
|
||||
break;
|
||||
case RLE_TAG >> 4: RLE.DecompressRLE(filein, outflr, isFolder); break;
|
||||
case NONE_TAG >> 4: Decompress2(filein, outflr); break;
|
||||
case HUFF_TAG >> 4: Huffman.DecompressHuffman(filein, outflr, isFolder); break;
|
||||
default: Decompress2(filein, outflr); break;
|
||||
}
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
CopyFile(filein, outflr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Could not properly decompress {0:s};", filein);
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine(e.StackTrace);
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
public static void Decompress2(string filein, string outflr)
|
||||
{
|
||||
if (File.Exists(outflr))
|
||||
File.Delete(outflr);
|
||||
|
||||
FileStream fstr = File.OpenRead(filein);
|
||||
if (fstr.Length > int.MaxValue)
|
||||
throw new Exception("Files larger than 2GB cannot be decompressed by this program.");
|
||||
BinaryReader br = new BinaryReader(fstr);
|
||||
|
||||
br.BaseStream.Seek(0x4, SeekOrigin.Begin);
|
||||
byte tag = br.ReadByte();
|
||||
br.Close();
|
||||
try
|
||||
{
|
||||
switch (tag >> 4)
|
||||
{
|
||||
case LZ77_TAG >> 4:
|
||||
if (tag == LZ77_TAG)
|
||||
LZ77.DecompressLZ77(filein, outflr, false);
|
||||
else if (tag == LZSS_TAG)
|
||||
LZSS.Decompress11LZS(filein, outflr, false);
|
||||
else
|
||||
CopyFile(filein, outflr);
|
||||
break;
|
||||
case RLE_TAG >> 4: RLE.DecompressRLE(filein, outflr, false); break;
|
||||
case NONE_TAG >> 4: None.DecompressNone(filein, outflr); break;
|
||||
case HUFF_TAG >> 4: Huffman.DecompressHuffman(filein, outflr, false); break;
|
||||
default: CopyFile(filein, outflr); break;
|
||||
}
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
CopyFile(filein, outflr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Could not properly decompress {0:s};", filein);
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine(e.StackTrace);
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Method: CopyFile
|
||||
/// <summary>
|
||||
/// Copies a file
|
||||
/// </summary>
|
||||
/// <param name="filein">The input file</param>
|
||||
/// <param name="outflr">The output folder. (the file keeps its name, other files get overwritten)</param>
|
||||
static void CopyFile(string filein, string outflr)
|
||||
{
|
||||
filein = Utils.makeSlashes(filein);
|
||||
string outfname = filein.Substring(filein.LastIndexOf("/") + 1);
|
||||
if (!outflr.EndsWith("/"))
|
||||
outflr += "/";
|
||||
outfname = outflr + outfname;
|
||||
File.Copy(filein, outfname, true);
|
||||
Console.WriteLine("Copied " + filein + " to " + outflr);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
148
Compresion/Compresion.csproj
Normal file
148
Compresion/Compresion.csproj
Normal file
@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Compresion</RootNamespace>
|
||||
<AssemblyName>Compresion</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Basico.cs" />
|
||||
<Compile Include="Huffman.cs" />
|
||||
<Compile Include="LZ77.cs" />
|
||||
<Compile Include="LZSS.cs" />
|
||||
<Compile Include="NARC.cs" />
|
||||
<Compile Include="None.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RLE.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
13
Compresion/Compresion.csproj.user
Normal file
13
Compresion/Compresion.csproj.user
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishUrlHistory />
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
291
Compresion/Huffman.cs
Normal file
291
Compresion/Huffman.cs
Normal file
@ -0,0 +1,291 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
public static class Huffman
|
||||
{
|
||||
static int MAX_OUTSIZE = 0x200000;
|
||||
const int N = 4096, F = 18;
|
||||
const byte THRESHOLD = 2;
|
||||
const int NIL = N;
|
||||
static bool showAlways = true;
|
||||
|
||||
const int LZ77_TAG = 0x10, LZSS_TAG = 0x11, RLE_TAG = 0x30, HUFF_TAG = 0x20, NONE_TAG = 0x00;
|
||||
|
||||
#region Huffman
|
||||
public static void DecompressHuffman(String filename, String outflr, bool isOutFolder)
|
||||
{
|
||||
/*
|
||||
Data Header (32bit)
|
||||
Bit0-3 Data size in bit units (normally 4 or 8)
|
||||
Bit4-7 Compressed type (must be 2 for Huffman)
|
||||
Bit8-31 24bit size of decompressed data in bytes
|
||||
Tree Size (8bit)
|
||||
Bit0-7 Size of Tree Table/2-1 (ie. Offset to Compressed Bitstream)
|
||||
Tree Table (list of 8bit nodes, starting with the root node)
|
||||
Root Node and Non-Data-Child Nodes are:
|
||||
Bit0-5 Offset to next child node,
|
||||
Next child node0 is at (CurrentAddr AND NOT 1)+Offset*2+2
|
||||
Next child node1 is at (CurrentAddr AND NOT 1)+Offset*2+2+1
|
||||
Bit6 Node1 End Flag (1=Next child node is data)
|
||||
Bit7 Node0 End Flag (1=Next child node is data)
|
||||
Data nodes are (when End Flag was set in parent node):
|
||||
Bit0-7 Data (upper bits should be zero if Data Size is less than 8)
|
||||
Compressed Bitstream (stored in units of 32bits)
|
||||
Bit0-31 Node Bits (Bit31=First Bit) (0=Node0, 1=Node1)
|
||||
*/
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(filename));
|
||||
|
||||
byte firstByte = br.ReadByte();
|
||||
|
||||
int dataSize = firstByte & 0x0F;
|
||||
|
||||
if ((firstByte & 0xF0) != HUFF_TAG)
|
||||
{
|
||||
br.BaseStream.Seek(0x4, SeekOrigin.Begin);
|
||||
if (br.ReadByte() != HUFF_TAG)
|
||||
throw new InvalidDataException(String.Format("Invalid huffman comressed file; invalid tag {0:x}", firstByte));
|
||||
}
|
||||
//Console.WriteLine("Data size: {0:x}", dataSize);
|
||||
if (dataSize != 8 && dataSize != 4)
|
||||
throw new InvalidDataException(String.Format("Unhandled dataSize {0:x}", dataSize));
|
||||
|
||||
int decomp_size = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
decomp_size |= br.ReadByte() << (i * 8);
|
||||
}
|
||||
//Console.WriteLine("Decompressed size: {0:x}", decomp_size);
|
||||
|
||||
byte treeSize = br.ReadByte();
|
||||
HuffTreeNode.maxInpos = 4 + (treeSize + 1) * 2;
|
||||
|
||||
//Console.WriteLine("Tree Size: {0:x}", treeSize);
|
||||
|
||||
HuffTreeNode rootNode = new HuffTreeNode();
|
||||
rootNode.parseData(br);
|
||||
|
||||
//Console.WriteLine("Tree: {0:s}", rootNode.ToString());
|
||||
|
||||
br.BaseStream.Position = 4 + (treeSize + 1) * 2; // go to start of coded bitstream.
|
||||
// read all data
|
||||
uint[] indata = new uint[(br.BaseStream.Length - br.BaseStream.Position) / 4];
|
||||
for (int i = 0; i < indata.Length; i++)
|
||||
indata[i] = br.ReadUInt32();
|
||||
|
||||
//Console.WriteLine(indata[0]);
|
||||
//Console.WriteLine(uint_to_bits(indata[0]));
|
||||
|
||||
long curr_size = 0;
|
||||
decomp_size *= dataSize == 8 ? 1 : 2;
|
||||
byte[] outdata = new byte[decomp_size];
|
||||
|
||||
int idx = -1;
|
||||
string codestr = "";
|
||||
LinkedList<byte> code = new LinkedList<byte>();
|
||||
int value;
|
||||
while (curr_size < decomp_size)
|
||||
{
|
||||
try
|
||||
{
|
||||
codestr += Utils.uint_to_bits(indata[++idx]);
|
||||
}
|
||||
catch (IndexOutOfRangeException e)
|
||||
{
|
||||
throw new IndexOutOfRangeException("not enough data.", e);
|
||||
}
|
||||
while (codestr.Length > 0)
|
||||
{
|
||||
code.AddFirst(byte.Parse(codestr[0] + ""));
|
||||
codestr = codestr.Remove(0, 1);
|
||||
if (rootNode.getValue(code.Last, out value))
|
||||
{
|
||||
try
|
||||
{
|
||||
outdata[curr_size++] = (byte)value;
|
||||
}
|
||||
catch (IndexOutOfRangeException ex)
|
||||
{
|
||||
if (code.First.Value != 0)
|
||||
throw ex;
|
||||
}
|
||||
code.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (codestr.Length > 0 || idx < indata.Length - 1)
|
||||
{
|
||||
while (idx < indata.Length - 1)
|
||||
codestr += Utils.uint_to_bits(indata[++idx]);
|
||||
codestr = codestr.Replace("0", "");
|
||||
if (codestr.Length > 0)
|
||||
Console.WriteLine("too much data; str={0:s}, idx={1:g}/{2:g}", codestr, idx, indata.Length);
|
||||
}
|
||||
|
||||
byte[] realout;
|
||||
if (dataSize == 4)
|
||||
{
|
||||
realout = new byte[decomp_size / 2];
|
||||
for (int i = 0; i < decomp_size / 2; i++)
|
||||
{
|
||||
if ((outdata[i * 2] & 0xF0) > 0
|
||||
|| (outdata[i * 2 + 1] & 0xF0) > 0)
|
||||
throw new Exception("first 4 bits of data should be 0 if dataSize = 4");
|
||||
realout[i] = (byte)((outdata[i * 2] << 4) | outdata[i * 2 + 1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
realout = outdata;
|
||||
}
|
||||
|
||||
#region save
|
||||
if (isOutFolder)
|
||||
{
|
||||
string ext = "";
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (char.IsLetterOrDigit((char)realout[i]))
|
||||
ext += (char)realout[i];
|
||||
else
|
||||
break;
|
||||
if (ext.Length == 0)
|
||||
ext = "dat";
|
||||
ext = "." + ext;
|
||||
filename = filename.Replace("\\", "/");
|
||||
outflr = outflr.Replace("\\", "/");
|
||||
string outfname = filename.Substring(filename.LastIndexOf("/") + 1);
|
||||
outfname = outfname.Substring(0, outfname.LastIndexOf('.'));
|
||||
|
||||
if (!outflr.EndsWith("/"))
|
||||
outflr += "/";
|
||||
while (File.Exists(outflr + outfname + ext))
|
||||
outfname += "_";
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr + outfname + ext, FileMode.CreateNew));
|
||||
bw.Write(realout);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr, FileMode.CreateNew));
|
||||
bw.Write(realout);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
Console.WriteLine("Huffman decompressed {0:s}", filename);
|
||||
//Console.ReadLine();
|
||||
/**/
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
class HuffTreeNode
|
||||
{
|
||||
internal static int maxInpos = 0;
|
||||
internal HuffTreeNode node0, node1;
|
||||
internal int data = -1; // [-1,0xFF]
|
||||
/// <summary>
|
||||
/// To get a value, provide the last node of a list of bytes < 2.
|
||||
/// the list will be read from back to front.
|
||||
/// </summary>
|
||||
internal bool getValue(LinkedListNode<byte> code, out int value)
|
||||
{
|
||||
value = data;
|
||||
if (code == null)
|
||||
return node0 == null && node1 == null && data >= 0;
|
||||
|
||||
if (code.Value > 1)
|
||||
throw new Exception(String.Format("the list should be a list of bytes < 2. got:{0:g}", code.Value));
|
||||
|
||||
byte c = code.Value;
|
||||
bool retVal;
|
||||
HuffTreeNode n = c == 0 ? node0 : node1;
|
||||
retVal = n != null && n.getValue(code.Previous, out value);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
internal int this[string code]
|
||||
{
|
||||
get
|
||||
{
|
||||
LinkedList<byte> c = new LinkedList<byte>();
|
||||
foreach (char ch in code)
|
||||
c.AddFirst((byte)ch);
|
||||
int val = 1;
|
||||
return this.getValue(c.Last, out val) ? val : -1;
|
||||
}
|
||||
}
|
||||
|
||||
internal void parseData(BinaryReader br)
|
||||
{
|
||||
/*
|
||||
* Tree Table (list of 8bit nodes, starting with the root node)
|
||||
Root Node and Non-Data-Child Nodes are:
|
||||
Bit0-5 Offset to next child node,
|
||||
Next child node0 is at (CurrentAddr AND NOT 1)+Offset*2+2
|
||||
Next child node1 is at (CurrentAddr AND NOT 1)+Offset*2+2+1
|
||||
Bit6 Node1 End Flag (1=Next child node is data)
|
||||
Bit7 Node0 End Flag (1=Next child node is data)
|
||||
Data nodes are (when End Flag was set in parent node):
|
||||
Bit0-7 Data (upper bits should be zero if Data Size is less than 8)
|
||||
*/
|
||||
this.node0 = new HuffTreeNode();
|
||||
this.node1 = new HuffTreeNode();
|
||||
long currPos = br.BaseStream.Position;
|
||||
byte b = br.ReadByte();
|
||||
long offset = b & 0x3F;
|
||||
bool end0 = (b & 0x80) > 0, end1 = (b & 0x40) > 0;
|
||||
// parse data for node0
|
||||
br.BaseStream.Position = (currPos - (currPos & 1)) + offset * 2 + 2;
|
||||
if (br.BaseStream.Position < maxInpos)
|
||||
{
|
||||
if (end0)
|
||||
node0.data = br.ReadByte();
|
||||
else
|
||||
node0.parseData(br);
|
||||
}
|
||||
// parse data for node1
|
||||
br.BaseStream.Position = (currPos - (currPos & 1)) + offset * 2 + 2 + 1;
|
||||
if (br.BaseStream.Position < maxInpos)
|
||||
{
|
||||
if (end1)
|
||||
node1.data = br.ReadByte();
|
||||
else
|
||||
node1.parseData(br);
|
||||
}
|
||||
// reset position
|
||||
br.BaseStream.Position = currPos;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (data < 0)
|
||||
return "<" + node0.ToString() + ", " + node1.ToString() + ">";
|
||||
else
|
||||
return String.Format("[{0:x}]", data);
|
||||
}
|
||||
|
||||
internal int Depth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data < 0)
|
||||
return 0;
|
||||
else
|
||||
return 1 + Math.Max(node0.Depth, node1.Depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
179
Compresion/LZ77.cs
Normal file
179
Compresion/LZ77.cs
Normal file
@ -0,0 +1,179 @@
|
||||
// Métodos obtenidos de DSDecmp
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
public static class LZ77
|
||||
{
|
||||
static int MAX_OUTSIZE = 0x200000;
|
||||
const int N = 4096, F = 18;
|
||||
const byte THRESHOLD = 2;
|
||||
const int NIL = N;
|
||||
static bool showAlways = true;
|
||||
|
||||
const int LZ77_TAG = 0x10, LZSS_TAG = 0x11, RLE_TAG = 0x30, HUFF_TAG = 0x20, NONE_TAG = 0x00;
|
||||
|
||||
|
||||
#region tag 0x10 LZ77
|
||||
public static void DecompressLZ77(string filein, string outflr, bool isOutFolder)
|
||||
{
|
||||
/* Data header (32bit)
|
||||
Bit 0-3 Reserved
|
||||
Bit 4-7 Compressed type (must be 1 for LZ77)
|
||||
Bit 8-31 Size of decompressed data
|
||||
Repeat below. Each Flag Byte followed by eight Blocks.
|
||||
Flag data (8bit)
|
||||
Bit 0-7 Type Flags for next 8 Blocks, MSB first
|
||||
Block Type 0 - Uncompressed - Copy 1 Byte from Source to Dest
|
||||
Bit 0-7 One data byte to be copied to dest
|
||||
Block Type 1 - Compressed - Copy N+3 Bytes from Dest-Disp-1 to Dest
|
||||
Bit 0-3 Disp MSBs
|
||||
Bit 4-7 Number of bytes to copy (minus 3)
|
||||
Bit 8-15 Disp LSBs
|
||||
*/
|
||||
FileStream fstr = new FileStream(filein, FileMode.Open);
|
||||
if (fstr.Length > int.MaxValue)
|
||||
throw new Exception("Archivos más grandes de 2GB no pueden ser archivos RLE-comprimidos.");
|
||||
BinaryReader br = new BinaryReader(fstr);
|
||||
|
||||
long decomp_size = 0, curr_size = 0;
|
||||
int flags, i, j, disp, n;
|
||||
bool flag;
|
||||
byte b;
|
||||
long cdest;
|
||||
|
||||
if (br.ReadByte() != LZ77_TAG)
|
||||
{
|
||||
br.BaseStream.Seek(0x4, SeekOrigin.Begin);
|
||||
if (br.ReadByte() != LZ77_TAG)
|
||||
throw new InvalidDataException(String.Format("El archivo {0:s} no es un archivo LZ77 válido", filein));
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
decomp_size += br.ReadByte() << (i * 8);
|
||||
if (decomp_size > MAX_OUTSIZE)
|
||||
throw new Exception(String.Format("{0:s} será más largo que 0x{1:x} (0x{2:x}) y no puede ser descomprimido.", filein, MAX_OUTSIZE, decomp_size));
|
||||
else if (decomp_size == 0)
|
||||
for (i = 0; i < 4; i++)
|
||||
decomp_size += br.ReadByte() << (i * 8);
|
||||
if (decomp_size > MAX_OUTSIZE << 8)
|
||||
throw new Exception(String.Format("{0:s} será más largo que 0x{1:x} (0x{2:x}) y no puede ser descomprimido.", filein, MAX_OUTSIZE, decomp_size));
|
||||
|
||||
if (showAlways)
|
||||
Console.WriteLine("Descomprimiendo {0:s}. (outsize: 0x{1:x})", filein, decomp_size);
|
||||
|
||||
#region decompress
|
||||
|
||||
byte[] outdata = new byte[decomp_size];
|
||||
|
||||
while (curr_size < decomp_size)
|
||||
{
|
||||
try { flags = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { break; }
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
flag = (flags & (0x80 >> i)) > 0;
|
||||
if (flag)
|
||||
{
|
||||
disp = 0;
|
||||
try { b = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { throw new Exception("Datos incompletos"); }
|
||||
n = b >> 4;
|
||||
disp = (b & 0x0F) << 8;
|
||||
try { disp |= br.ReadByte(); }
|
||||
catch (EndOfStreamException) { throw new Exception("Datos incompletos"); }
|
||||
n += 3;
|
||||
cdest = curr_size;
|
||||
//Console.WriteLine("disp: 0x{0:x}", disp);
|
||||
if (disp > curr_size)
|
||||
throw new Exception("Cannot go back more than already written");
|
||||
for (j = 0; j < n; j++)
|
||||
outdata[curr_size++] = outdata[cdest - disp - 1 + j];
|
||||
//curr_size += len;
|
||||
if (curr_size > decomp_size)
|
||||
{
|
||||
//throw new Exception(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header", filein));
|
||||
//Console.WriteLine(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header; {1:x} > {2:x}.", filein, curr_size, decomp_size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try { b = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { break; }// throw new Exception("Incomplete data"); }
|
||||
try { outdata[curr_size++] = b; }
|
||||
catch (IndexOutOfRangeException) { if (b == 0) break; }
|
||||
//curr_size++;
|
||||
if (curr_size > decomp_size)
|
||||
{
|
||||
//throw new Exception(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header", filein));
|
||||
//Console.WriteLine(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header; {1:x} > {2:x}", filein, curr_size, decomp_size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
while (br.ReadByte() == 0) { } // if we read a non-zero, print that there is still some data
|
||||
Console.WriteLine("Too many data in file; current INPOS = {0:x}", br.BaseStream.Position - 1);
|
||||
}
|
||||
catch (EndOfStreamException) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region save
|
||||
if (isOutFolder)
|
||||
{
|
||||
string ext = "";
|
||||
for (i = 0; i < 4; i++)
|
||||
if (char.IsLetterOrDigit((char)outdata[i]))
|
||||
ext += (char)outdata[i];
|
||||
else
|
||||
break;
|
||||
if (ext.Length == 0)
|
||||
ext = "dat";
|
||||
ext = "." + ext;
|
||||
filein = filein.Replace("\\", "/");
|
||||
outflr = outflr.Replace("\\", "/");
|
||||
string outfname = filein.Substring(filein.LastIndexOf("/") + 1);
|
||||
outfname = outfname.Substring(0, outfname.LastIndexOf('.'));
|
||||
|
||||
if (!outflr.EndsWith("/"))
|
||||
outflr += "/";
|
||||
while (File.Exists(outflr + outfname + ext))
|
||||
outfname += "_";
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr + outfname + ext, FileMode.CreateNew));
|
||||
bw.Write(outdata);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr, FileMode.CreateNew));
|
||||
bw.Write(outdata);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
fstr.Close();
|
||||
fstr.Dispose();
|
||||
|
||||
Console.WriteLine("LZ77 Descomprimido " + filein);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
243
Compresion/LZSS.cs
Normal file
243
Compresion/LZSS.cs
Normal file
@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
public static class LZSS
|
||||
{
|
||||
static int MAX_OUTSIZE = 0x200000;
|
||||
const int N = 4096, F = 18;
|
||||
const byte THRESHOLD = 2;
|
||||
const int NIL = N;
|
||||
static bool showAlways = true;
|
||||
|
||||
const int LZ77_TAG = 0x10, LZSS_TAG = 0x11, RLE_TAG = 0x30, HUFF_TAG = 0x20, NONE_TAG = 0x00;
|
||||
|
||||
#region tag 0x11 LZSS
|
||||
public static void Decompress11LZS(string filein, string outflr, bool isOutFolder)
|
||||
{
|
||||
/* Data header (32bit)
|
||||
Bit 0-3 Reserved
|
||||
Bit 4-7 Compressed type (must be 1 for LZ77)
|
||||
Bit 8-31 Size of decompressed data. if 0, the next 4 bytes are decompressed length
|
||||
Repeat below. Each Flag Byte followed by eight Blocks.
|
||||
Flag data (8bit)
|
||||
Bit 0-7 Type Flags for next 8 Blocks, MSB first
|
||||
Block Type 0 - Uncompressed - Copy 1 Byte from Source to Dest
|
||||
Bit 0-7 One data byte to be copied to dest
|
||||
Block Type 1 - Compressed - Copy LEN Bytes from Dest-Disp-1 to Dest
|
||||
If Reserved is 0: - Default
|
||||
Bit 0-3 Disp MSBs
|
||||
Bit 4-7 LEN - 3
|
||||
Bit 8-15 Disp LSBs
|
||||
If Reserved is 1: - Higher compression rates for files with (lots of) long repetitions
|
||||
Bit 4-7 Indicator
|
||||
If Indicator > 1:
|
||||
Bit 0-3 Disp MSBs
|
||||
Bit 4-7 LEN - 1 (same bits as Indicator)
|
||||
Bit 8-15 Disp LSBs
|
||||
If Indicator is 1:
|
||||
Bit 0-3 and 8-19 LEN - 0x111
|
||||
Bit 20-31 Disp
|
||||
If Indicator is 0:
|
||||
Bit 0-3 and 8-11 LEN - 0x11
|
||||
Bit 12-23 Disp
|
||||
|
||||
*/
|
||||
FileStream fstr = new FileStream(filein, FileMode.Open);
|
||||
if (fstr.Length > int.MaxValue)
|
||||
throw new Exception("Filer larger than 2GB cannot be LZSS-compressed files.");
|
||||
BinaryReader br = new BinaryReader(fstr);
|
||||
|
||||
int decomp_size = 0, curr_size = 0;
|
||||
int i, j, disp, len;
|
||||
bool flag;
|
||||
byte b1, bt, b2, b3, flags;
|
||||
int cdest;
|
||||
|
||||
int threshold = 1;
|
||||
|
||||
if (br.ReadByte() != LZSS_TAG)
|
||||
{
|
||||
br.BaseStream.Seek(0x4, SeekOrigin.Begin);
|
||||
if (br.ReadByte() != LZSS_TAG)
|
||||
throw new InvalidDataException(String.Format("File {0:s} is not a valid LZSS-11 file", filein));
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
decomp_size += br.ReadByte() << (i * 8);
|
||||
if (decomp_size > MAX_OUTSIZE)
|
||||
throw new Exception(String.Format("{0:s} will be larger than 0x{1:x} (0x{2:x}) and will not be decompressed.", filein, MAX_OUTSIZE, decomp_size));
|
||||
else if (decomp_size == 0)
|
||||
for (i = 0; i < 4; i++)
|
||||
decomp_size += br.ReadByte() << (i * 8);
|
||||
if (decomp_size > MAX_OUTSIZE << 8)
|
||||
throw new Exception(String.Format("{0:s} will be larger than 0x{1:x} (0x{2:x}) and will not be decompressed.", filein, MAX_OUTSIZE, decomp_size));
|
||||
|
||||
if (showAlways)
|
||||
Console.WriteLine("Decompressing {0:s}. (outsize: 0x{1:x})", filein, decomp_size);
|
||||
|
||||
|
||||
byte[] outdata = new byte[decomp_size];
|
||||
|
||||
|
||||
while (curr_size < decomp_size)
|
||||
{
|
||||
try { flags = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { break; }
|
||||
|
||||
for (i = 0; i < 8 && curr_size < decomp_size; i++)
|
||||
{
|
||||
flag = (flags & (0x80 >> i)) > 0;
|
||||
if (flag)
|
||||
{
|
||||
try { b1 = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { throw new Exception("Incomplete data"); }
|
||||
|
||||
switch (b1 >> 4)
|
||||
{
|
||||
#region case 0
|
||||
case 0:
|
||||
// ab cd ef
|
||||
// =>
|
||||
// len = abc + 0x11 = bc + 0x11
|
||||
// disp = def
|
||||
|
||||
len = b1 << 4;
|
||||
try { bt = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { throw new Exception("Incomplete data"); }
|
||||
len |= bt >> 4;
|
||||
len += 0x11;
|
||||
|
||||
disp = (bt & 0x0F) << 8;
|
||||
try { b2 = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { throw new Exception("Incomplete data"); }
|
||||
disp |= b2;
|
||||
break;
|
||||
#endregion
|
||||
|
||||
#region case 1
|
||||
case 1:
|
||||
// ab cd ef gh
|
||||
// =>
|
||||
// len = bcde + 0x111
|
||||
// disp = fgh
|
||||
// 10 04 92 3F => disp = 0x23F, len = 0x149 + 0x11 = 0x15A
|
||||
|
||||
try { bt = br.ReadByte(); b2 = br.ReadByte(); b3 = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { throw new Exception("Incomplete data"); }
|
||||
|
||||
len = (b1 & 0xF) << 12; // len = b000
|
||||
len |= bt << 4; // len = bcd0
|
||||
len |= (b2 >> 4); // len = bcde
|
||||
len += 0x111; // len = bcde + 0x111
|
||||
disp = (b2 & 0x0F) << 8; // disp = f
|
||||
disp |= b3; // disp = fgh
|
||||
break;
|
||||
#endregion
|
||||
|
||||
#region other
|
||||
default:
|
||||
// ab cd
|
||||
// =>
|
||||
// len = a + threshold = a + 1
|
||||
// disp = bcd
|
||||
|
||||
len = (b1 >> 4) + threshold;
|
||||
|
||||
disp = (b1 & 0x0F) << 8;
|
||||
try { b2 = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { throw new Exception("Incomplete data"); }
|
||||
disp |= b2;
|
||||
break;
|
||||
#endregion
|
||||
}
|
||||
|
||||
if (disp > curr_size)
|
||||
throw new Exception("Cannot go back more than already written");
|
||||
|
||||
cdest = curr_size;
|
||||
|
||||
for (j = 0; j < len && curr_size < decomp_size; j++)
|
||||
outdata[curr_size++] = outdata[cdest - disp - 1 + j];
|
||||
|
||||
if (curr_size > decomp_size)
|
||||
{
|
||||
//throw new Exception(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header", filein));
|
||||
//Console.WriteLine(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header; {1:x} > {2:x}.", filein, curr_size, decomp_size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try { outdata[curr_size++] = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { break; }// throw new Exception("Incomplete data"); }
|
||||
|
||||
if (curr_size > decomp_size)
|
||||
{
|
||||
//throw new Exception(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header", filein));
|
||||
//Console.WriteLine(String.Format("File {0:s} is not a valid LZ77 file; actual output size > output size in header; {1:x} > {2:x}", filein, curr_size, decomp_size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
while (br.ReadByte() == 0) { } // if we read a non-zero, print that there is still some data
|
||||
Console.WriteLine("Too much data in file; current INPOS = {0:x}", br.BaseStream.Position - 1);
|
||||
}
|
||||
catch (EndOfStreamException) { }
|
||||
|
||||
#region save
|
||||
if (isOutFolder)
|
||||
{
|
||||
string ext = "";
|
||||
for (i = 0; i < 4; i++)
|
||||
if (char.IsLetterOrDigit((char)outdata[i]))
|
||||
ext += (char)outdata[i];
|
||||
else
|
||||
break;
|
||||
if (ext.Length == 0)
|
||||
ext = "dat";
|
||||
ext = "." + ext;
|
||||
filein = filein.Replace("\\", "/");
|
||||
outflr = outflr.Replace("\\", "/");
|
||||
string outfname = filein.Substring(filein.LastIndexOf("/") + 1);
|
||||
outfname = outfname.Substring(0, outfname.LastIndexOf('.'));
|
||||
|
||||
if (!outflr.EndsWith("/"))
|
||||
outflr += "/";
|
||||
while (File.Exists(outflr + outfname + ext))
|
||||
outfname += "_";/**/
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr + outfname + ext, FileMode.Create));
|
||||
bw.Write(outdata);
|
||||
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr, FileMode.Create));
|
||||
bw.Write(outdata);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
Console.WriteLine("LZSS-11 Decompressed " + filein);
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
fstr.Close();
|
||||
fstr.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
355
Compresion/NARC.cs
Normal file
355
Compresion/NARC.cs
Normal file
@ -0,0 +1,355 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
// Nintendo ARChive --> by pleoNeX
|
||||
public static class NARC
|
||||
{
|
||||
public static Folder Leer(string file)
|
||||
{
|
||||
ARC arc = new ARC();
|
||||
BinaryReader br = new BinaryReader(System.IO.File.OpenRead(file));
|
||||
|
||||
// Lee cabecera genérica e inicial:
|
||||
arc.id = br.ReadChars(4);
|
||||
arc.id_endian = br.ReadUInt16();
|
||||
if (arc.id_endian == 0xFFFE)
|
||||
arc.id.Reverse<Char>();
|
||||
arc.constant = br.ReadUInt16();
|
||||
arc.file_size = br.ReadUInt32();
|
||||
arc.header_size = br.ReadUInt16();
|
||||
arc.nSections = br.ReadUInt16();
|
||||
|
||||
// Lee primera sección BTAF (File Allocation TaBle)
|
||||
arc.btaf.id = br.ReadChars(4);
|
||||
arc.btaf.section_size = br.ReadUInt32();
|
||||
arc.btaf.nFiles = br.ReadUInt32();
|
||||
arc.btaf.entries = new BTAF_Entry[arc.btaf.nFiles];
|
||||
for (int i = 0; i < arc.btaf.nFiles; i++)
|
||||
{
|
||||
arc.btaf.entries[i].start_offset = br.ReadUInt32();
|
||||
arc.btaf.entries[i].end_offset = br.ReadUInt32();
|
||||
}
|
||||
|
||||
// Lee la segunda sección BTNF (File Name TaBle)
|
||||
arc.btnf.id = br.ReadChars(4);
|
||||
arc.btnf.section_size = br.ReadUInt32();
|
||||
arc.btnf.entries = new List<BTNF_MainEntry>();
|
||||
long pos = br.BaseStream.Position;
|
||||
#region Obtener carpeta root
|
||||
do
|
||||
{
|
||||
BTNF_MainEntry main = new BTNF_MainEntry();
|
||||
main.offset = br.ReadUInt32();
|
||||
main.first_pos = br.ReadUInt16();
|
||||
main.parent = br.ReadUInt16();
|
||||
uint idFile = main.first_pos;
|
||||
|
||||
|
||||
int id = br.ReadByte();
|
||||
|
||||
while (id != 0x0) // Indicador de fin de subtable
|
||||
{
|
||||
if (id < 0x80) // Es archivo
|
||||
{
|
||||
File currFile = new File();
|
||||
currFile.id = idFile;
|
||||
idFile++;
|
||||
currFile.name = new String(br.ReadChars(id));
|
||||
if (!(main.files is List<File>))
|
||||
main.files = new List<File>();
|
||||
main.files.Add(currFile);
|
||||
}
|
||||
else if (id > 0x80) // Es carpeta
|
||||
{
|
||||
Folder currFolder = new Folder();
|
||||
currFolder.name = new String(br.ReadChars(id - 0x80));
|
||||
currFolder.id = br.ReadUInt16();
|
||||
if (!(main.folders is List<Folder>))
|
||||
main.folders = new List<Folder>();
|
||||
main.folders.Add(currFolder);
|
||||
}
|
||||
|
||||
id = br.ReadByte();
|
||||
}
|
||||
arc.btnf.entries.Add(main);
|
||||
|
||||
} while (arc.btnf.entries[0].offset == br.BaseStream.Position);
|
||||
while (br.BaseStream.Position == (pos - 8) + arc.btnf.section_size) { br.ReadByte(); } // Suele terminar la sección con 0xFFFFFF
|
||||
|
||||
Folder root = Jerarquizar_Carpetas(arc.btnf.entries, 0xF000, "root");
|
||||
#endregion
|
||||
|
||||
// Lee tercera sección GMIF (File IMaGe)
|
||||
arc.gmif.id = br.ReadChars(4);
|
||||
arc.gmif.section_size = br.ReadUInt32();
|
||||
pos = br.BaseStream.Position;
|
||||
for (int i = 0; i < arc.btaf.nFiles; i++)
|
||||
{
|
||||
br.BaseStream.Position = pos + arc.btaf.entries[i].start_offset;
|
||||
Asignar_Archivos(ref br, root, i, arc.btaf.entries[i].end_offset);
|
||||
}
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return root;
|
||||
}
|
||||
public static Folder Leer(string file, out ARC arc)
|
||||
{
|
||||
Inicio:
|
||||
BinaryReader br = new BinaryReader(System.IO.File.OpenRead(file));
|
||||
|
||||
// Lee cabecera genérica e inicial:
|
||||
arc.id = br.ReadChars(4);
|
||||
if (arc.id[0] == '\x10') // Archivo con compresión LZ77
|
||||
{
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
Basico.Decompress(file, file + ".un", false);
|
||||
System.IO.File.Copy(file + ".un", file, true);
|
||||
System.IO.File.Delete(file + ".un");
|
||||
goto Inicio;
|
||||
}
|
||||
arc.id_endian = br.ReadUInt16();
|
||||
if (arc.id_endian == 0xFFFE)
|
||||
arc.id.Reverse<Char>();
|
||||
arc.constant = br.ReadUInt16();
|
||||
arc.file_size = br.ReadUInt32();
|
||||
arc.header_size = br.ReadUInt16();
|
||||
arc.nSections = br.ReadUInt16();
|
||||
|
||||
// Lee primera sección BTAF (File Allocation TaBle)
|
||||
arc.btaf.id = br.ReadChars(4);
|
||||
arc.btaf.section_size = br.ReadUInt32();
|
||||
arc.btaf.nFiles = br.ReadUInt32();
|
||||
arc.btaf.entries = new BTAF_Entry[arc.btaf.nFiles];
|
||||
for (int i = 0; i < arc.btaf.nFiles; i++)
|
||||
{
|
||||
arc.btaf.entries[i].start_offset = br.ReadUInt32();
|
||||
arc.btaf.entries[i].end_offset = br.ReadUInt32();
|
||||
}
|
||||
|
||||
// Lee la segunda sección BTNF (File Name TaBle)
|
||||
arc.btnf.id = br.ReadChars(4);
|
||||
arc.btnf.section_size = br.ReadUInt32();
|
||||
arc.btnf.entries = new List<BTNF_MainEntry>();
|
||||
long pos = br.BaseStream.Position;
|
||||
#region Obtener carpeta root
|
||||
do
|
||||
{
|
||||
BTNF_MainEntry main = new BTNF_MainEntry();
|
||||
main.offset = br.ReadUInt32();
|
||||
main.first_pos = br.ReadUInt16();
|
||||
main.parent = br.ReadUInt16();
|
||||
uint idFile = main.first_pos;
|
||||
|
||||
if (main.offset < 0x8) // No hay nombres, juegos como el pokemon
|
||||
{
|
||||
|
||||
for (int i = 0; i < arc.btaf.nFiles; i++)
|
||||
{
|
||||
File currFile = new File();
|
||||
currFile.id = idFile; idFile++;
|
||||
currFile.name = "file" + idFile.ToString();
|
||||
if (!(main.files is List<File>))
|
||||
main.files = new List<File>();
|
||||
main.files.Add(currFile);
|
||||
}
|
||||
br.BaseStream.Position = main.offset + pos; // Para que funcione la condición while
|
||||
arc.btnf.entries.Add(main);
|
||||
continue;
|
||||
}
|
||||
long posmain = br.BaseStream.Position;
|
||||
br.BaseStream.Position = main.offset + pos;
|
||||
int id = br.ReadByte();
|
||||
|
||||
while (id != 0x0) // Indicador de fin de subtable
|
||||
{
|
||||
if (id < 0x80) // Es archivo
|
||||
{
|
||||
File currFile = new File();
|
||||
currFile.id = idFile;
|
||||
idFile++;
|
||||
currFile.name = new String(br.ReadChars(id));
|
||||
if (!(main.files is List<File>))
|
||||
main.files = new List<File>();
|
||||
main.files.Add(currFile);
|
||||
}
|
||||
else if (id > 0x80) // Es carpeta
|
||||
{
|
||||
Folder currFolder = new Folder();
|
||||
currFolder.name = new String(br.ReadChars(id - 0x80));
|
||||
currFolder.id = br.ReadUInt16();
|
||||
if (!(main.folders is List<Folder>))
|
||||
main.folders = new List<Folder>();
|
||||
main.folders.Add(currFolder);
|
||||
}
|
||||
|
||||
id = br.ReadByte();
|
||||
}
|
||||
arc.btnf.entries.Add(main);
|
||||
br.BaseStream.Position = posmain;
|
||||
|
||||
} while (arc.btnf.entries[0].offset + pos != br.BaseStream.Position);
|
||||
|
||||
br.BaseStream.Position = pos - 8 + arc.btnf.section_size;
|
||||
Folder root = Jerarquizar_Carpetas(arc.btnf.entries, 0xF000, "root");
|
||||
#endregion
|
||||
|
||||
// Lee tercera sección GMIF (File IMaGe)
|
||||
arc.gmif.id = br.ReadChars(4);
|
||||
arc.gmif.section_size = br.ReadUInt32();
|
||||
pos = br.BaseStream.Position;
|
||||
for (int i = 0; i < arc.btaf.nFiles; i++)
|
||||
{
|
||||
br.BaseStream.Position = pos + arc.btaf.entries[i].start_offset;
|
||||
Asignar_Archivos(ref br, root, i, arc.btaf.entries[i].end_offset - arc.btaf.entries[i].start_offset);
|
||||
}
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return root;
|
||||
}
|
||||
public static Folder Jerarquizar_Carpetas(List<BTNF_MainEntry> entries, int idFolder, string nameFolder)
|
||||
{
|
||||
Folder currFolder = new Folder();
|
||||
|
||||
currFolder.name = nameFolder;
|
||||
currFolder.id = (ushort)idFolder;
|
||||
currFolder.files = entries[idFolder & 0xFFF].files;
|
||||
|
||||
if (entries[idFolder & 0xFFF].folders is List<Folder>) // Si tiene carpetas dentro.
|
||||
{
|
||||
currFolder.subfolders = new List<Folder>();
|
||||
|
||||
foreach (Folder subFolder in entries[idFolder & 0xFFF].folders)
|
||||
currFolder.subfolders.Add(Jerarquizar_Carpetas(entries, subFolder.id, subFolder.name));
|
||||
}
|
||||
|
||||
return currFolder;
|
||||
}
|
||||
public static void Asignar_Archivos(ref BinaryReader br, Folder currFolder, int idFile, UInt32 size)
|
||||
{
|
||||
if (currFolder.files is List<File>)
|
||||
{
|
||||
for (int i = 0; i < currFolder.files.Count; i++)
|
||||
{
|
||||
if (currFolder.files[i].id == idFile)
|
||||
{
|
||||
File newFile = currFolder.files[i];
|
||||
newFile.bytes = br.ReadBytes((int)size);
|
||||
currFolder.files.RemoveAt(i);
|
||||
currFolder.files.Insert(i, newFile);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (currFolder.subfolders is List<Folder>) // Si tiene carpetas dentro.
|
||||
foreach (Folder subFolder in currFolder.subfolders)
|
||||
Asignar_Archivos(ref br, subFolder, idFile, size);
|
||||
}
|
||||
|
||||
public static void Descomprimir(string file, string outFolder)
|
||||
{
|
||||
ARC arc = new ARC();
|
||||
Folder root = Leer(file, out arc);
|
||||
|
||||
for (int i = 0; i < arc.btaf.nFiles; i++)
|
||||
{
|
||||
File currFile = Recursivo_Archivo(i, root);
|
||||
System.IO.File.WriteAllBytes(outFolder + '\\' + currFile.name, currFile.bytes);
|
||||
}
|
||||
}
|
||||
private static File Recursivo_Archivo(int id, Folder currFolder)
|
||||
{
|
||||
if (currFolder.files is List<File>)
|
||||
foreach (File archivo in currFolder.files)
|
||||
if (archivo.id == id)
|
||||
return archivo;
|
||||
|
||||
|
||||
if (currFolder.subfolders is List<Folder>)
|
||||
{
|
||||
foreach (Folder subFolder in currFolder.subfolders)
|
||||
{
|
||||
File currFile = Recursivo_Archivo(id, subFolder);
|
||||
if (currFile.name is string)
|
||||
return currFile;
|
||||
}
|
||||
}
|
||||
|
||||
return new File();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Estructuras
|
||||
public struct ARC
|
||||
{
|
||||
public char[] id; // Always NARC = 0x4E415243
|
||||
public UInt16 id_endian; // Si 0xFFFE hay que darle la vuelta al id
|
||||
public UInt16 constant; // Always 0x0100
|
||||
public UInt32 file_size;
|
||||
public UInt16 header_size; // Siempre 0x0010
|
||||
public UInt16 nSections; // En este caso siempre 0x0003
|
||||
|
||||
public BTAF btaf;
|
||||
public BTNF btnf;
|
||||
public GMIF gmif;
|
||||
}
|
||||
public struct BTAF
|
||||
{
|
||||
public char[] id;
|
||||
public UInt32 section_size;
|
||||
public UInt32 nFiles;
|
||||
public BTAF_Entry[] entries;
|
||||
}
|
||||
public struct BTAF_Entry
|
||||
{
|
||||
// Ambas son relativas a la sección GMIF
|
||||
public UInt32 start_offset;
|
||||
public UInt32 end_offset;
|
||||
}
|
||||
public struct BTNF
|
||||
{
|
||||
public char[] id;
|
||||
public UInt32 section_size;
|
||||
public List<BTNF_MainEntry> entries;
|
||||
}
|
||||
public struct BTNF_MainEntry
|
||||
{
|
||||
public UInt32 offset; // Relativo a la primera entrada
|
||||
public UInt32 first_pos; // ID del primer archivo.
|
||||
public UInt32 parent; // En el caso de root, número de carpetas;
|
||||
public List<File> files;
|
||||
public List<Folder> folders;
|
||||
}
|
||||
public struct File
|
||||
{
|
||||
public UInt32 id;
|
||||
public string name;
|
||||
public byte[] bytes;
|
||||
}
|
||||
public struct Folder
|
||||
{
|
||||
public UInt16 id;
|
||||
public string name;
|
||||
public List<File> files;
|
||||
public List<Folder> subfolders;
|
||||
}
|
||||
public struct GMIF
|
||||
{
|
||||
public char[] id;
|
||||
public UInt32 section_size;
|
||||
// Datos de los archivos....
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
78
Compresion/None.cs
Normal file
78
Compresion/None.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
public static class None
|
||||
{
|
||||
static int MAX_OUTSIZE = 0x200000;
|
||||
const int N = 4096, F = 18;
|
||||
const byte THRESHOLD = 2;
|
||||
const int NIL = N;
|
||||
static bool showAlways = true;
|
||||
|
||||
const int LZ77_TAG = 0x10, LZSS_TAG = 0x11, RLE_TAG = 0x30, HUFF_TAG = 0x20, NONE_TAG = 0x00;
|
||||
|
||||
#region None
|
||||
public static void DecompressNone(string filein, string outflr)
|
||||
{
|
||||
FileStream fstr = new FileStream(filein, FileMode.Open);
|
||||
if (fstr.Length > int.MaxValue)
|
||||
throw new Exception("Filer larger than 2GB cannot be NONE-compressed files.");
|
||||
BinaryReader br = new BinaryReader(fstr);
|
||||
|
||||
long decomp_size = 0;
|
||||
int i;
|
||||
|
||||
if (br.ReadByte() != NONE_TAG)
|
||||
{
|
||||
br.BaseStream.Seek(0x4, SeekOrigin.Begin);
|
||||
if (br.ReadByte() != NONE_TAG)
|
||||
throw new InvalidDataException(String.Format("File {0:s} is not a valid NONE file, it does not have the NONE-tag as first byte", filein));
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
decomp_size += br.ReadByte() << (i * 8);
|
||||
if (decomp_size != fstr.Length - 0x04)
|
||||
throw new InvalidDataException("File {0:s} is not a valid NONE file, the decompression size shold be the file size - 4");
|
||||
|
||||
#region save
|
||||
string ext = "";
|
||||
char c;
|
||||
for (i = 0; i < 4; i++)
|
||||
if (char.IsLetterOrDigit(c = (char)br.ReadByte()))
|
||||
ext += c;
|
||||
else
|
||||
break;
|
||||
if (ext.Length == 0)
|
||||
ext = "dat";
|
||||
ext = "." + ext;
|
||||
br.BaseStream.Position -= i == 4 ? 4 : i + 1;
|
||||
|
||||
filein = filein.Replace("\\", "/");
|
||||
outflr = outflr.Replace("\\", "/");
|
||||
string outfname = filein.Substring(filein.LastIndexOf("/") + 1);
|
||||
outfname = outfname.Substring(0, outfname.LastIndexOf('.'));
|
||||
|
||||
if (!outflr.EndsWith("/"))
|
||||
outflr += "/";
|
||||
while (File.Exists(outflr + outfname + ext))
|
||||
outfname += "_";
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr + outfname + ext, FileMode.CreateNew));
|
||||
|
||||
bw.Write(br.ReadBytes((int)decomp_size));
|
||||
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
|
||||
#endregion
|
||||
|
||||
Console.WriteLine("NONE-decompressed {0:s}", filein);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
36
Compresion/Properties/AssemblyInfo.cs
Normal file
36
Compresion/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// La información general sobre un ensamblado se controla mediante el siguiente
|
||||
// conjunto de atributos. Cambie estos atributos para modificar la información
|
||||
// asociada con un ensamblado.
|
||||
[assembly: AssemblyTitle("Compresion")]
|
||||
[assembly: AssemblyDescription("Compresión LZ77, LZSS, Huffman y RLE")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Tinke")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles
|
||||
// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
|
||||
// COM, establezca el atributo ComVisible como true en este tipo.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
|
||||
[assembly: Guid("2ed5ed33-a195-49dd-9463-5ef4b4753f2a")]
|
||||
|
||||
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
|
||||
//
|
||||
// Versión principal
|
||||
// Versión secundaria
|
||||
// Número de versión de compilación
|
||||
// Revisión
|
||||
//
|
||||
// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión
|
||||
// mediante el asterisco ('*'), como se muestra a continuación:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.2.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.2.0.1")]
|
154
Compresion/RLE.cs
Normal file
154
Compresion/RLE.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
public static class RLE
|
||||
{
|
||||
static int MAX_OUTSIZE = 0x200000;
|
||||
const int N = 4096, F = 18;
|
||||
const byte THRESHOLD = 2;
|
||||
const int NIL = N;
|
||||
static bool showAlways = true;
|
||||
|
||||
const int LZ77_TAG = 0x10, LZSS_TAG = 0x11, RLE_TAG = 0x30, HUFF_TAG = 0x20, NONE_TAG = 0x00;
|
||||
|
||||
#region RLE
|
||||
public static void DecompressRLE(string filein, string outflr, bool isOutFolder)
|
||||
{
|
||||
/* SWI 14h (GBA/NDS7/NDS9) - RLUnCompWram
|
||||
SWI 15h (GBA/NDS7/NDS9) - RLUnCompVram (NDS: with Callback)
|
||||
Expands run-length compressed data. The Wram function is faster, and writes in units of 8bits. For the Vram function the destination must be halfword aligned, data is written in units of 16bits.
|
||||
If the size of the compressed data is not a multiple of 4, please adjust it as much as possible by padding with 0. Align the source address to a 4Byte boundary.
|
||||
|
||||
r0 Source Address, pointing to data as such:
|
||||
Data header (32bit)
|
||||
Bit 0-3 Reserved
|
||||
Bit 4-7 Compressed type (must be 3 for run-length)
|
||||
Bit 8-31 Size of decompressed data
|
||||
Repeat below. Each Flag Byte followed by one or more Data Bytes.
|
||||
Flag data (8bit)
|
||||
Bit 0-6 Expanded Data Length (uncompressed N-1, compressed N-3)
|
||||
Bit 7 Flag (0=uncompressed, 1=compressed)
|
||||
Data Byte(s) - N uncompressed bytes, or 1 byte repeated N times
|
||||
r1 Destination Address
|
||||
r2 Callback parameter (NDS SWI 15h only, see Callback notes below)
|
||||
r3 Callback structure (NDS SWI 15h only, see Callback notes below)
|
||||
|
||||
Return: No return value, Data written to destination address.*/
|
||||
|
||||
FileStream fstr = new FileStream(filein, FileMode.Open);
|
||||
if (fstr.Length > int.MaxValue)
|
||||
throw new Exception("Files larger than 2GB cannot be RLE-compressed files.");
|
||||
BinaryReader br = new BinaryReader(fstr);
|
||||
|
||||
long decomp_size = 0, curr_size = 0;
|
||||
int i, rl;
|
||||
byte flag, b;
|
||||
bool compressed;
|
||||
|
||||
if (br.ReadByte() != RLE_TAG)
|
||||
{
|
||||
br.BaseStream.Seek(0x4, SeekOrigin.Begin);
|
||||
if (br.ReadByte() != RLE_TAG)
|
||||
throw new InvalidDataException(String.Format("File {0:s} is not a valid RLE file", filein));
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
decomp_size += br.ReadByte() << (i * 8);
|
||||
if (decomp_size > MAX_OUTSIZE)
|
||||
throw new Exception(String.Format("{0:s} will be larger than 0x{1:x} and will not be decompressed.", filein, MAX_OUTSIZE));
|
||||
|
||||
if (showAlways)
|
||||
Console.WriteLine("Decompressing {0:s}. (outsize: 0x{1:x})", filein, decomp_size);
|
||||
|
||||
#region decompress
|
||||
byte[] outdata = new byte[decomp_size];
|
||||
|
||||
while (true)
|
||||
{
|
||||
// get tag
|
||||
try { flag = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { break; }
|
||||
compressed = (flag & 0x80) > 0;
|
||||
rl = flag & 0x7F;
|
||||
if (compressed)
|
||||
rl += 3;
|
||||
else
|
||||
rl += 1;
|
||||
//curr_size += rl;
|
||||
if (compressed)
|
||||
{
|
||||
try { b = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { break; }// throw new Exception(String.Format("Invalid RLE format in file {0:s}; incomplete data near EOF.", filein)); }
|
||||
for (i = 0; i < rl; i++)
|
||||
outdata[curr_size++] = b;
|
||||
}
|
||||
else
|
||||
for (i = 0; i < rl; i++)
|
||||
try { outdata[curr_size++] = br.ReadByte(); }
|
||||
catch (EndOfStreamException) { break; }// throw new Exception(String.Format("Invalid RLE format in file {0:s}; incomplete data near EOF.", filein)); }
|
||||
|
||||
if (curr_size > decomp_size)
|
||||
{
|
||||
Console.WriteLine("curr_size > decomp_size; {0:x}>{1:x}", curr_size, decomp_size);
|
||||
break;// throw new Exception(String.Format("File {0:s} is not a valid LZSS file; actual output size > output size in header", filein));
|
||||
}
|
||||
if (curr_size == decomp_size)
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region save
|
||||
if (isOutFolder)
|
||||
{
|
||||
string ext = "";
|
||||
for (i = 0; i < 4; i++)
|
||||
if (char.IsLetterOrDigit((char)outdata[i]))
|
||||
ext += (char)outdata[i];
|
||||
else
|
||||
break;
|
||||
if (ext.Length == 0)
|
||||
ext = "dat";
|
||||
ext = "." + ext;
|
||||
filein = filein.Replace("\\", "/");
|
||||
outflr = outflr.Replace("\\", "/");
|
||||
string outfname = filein.Substring(filein.LastIndexOf("/") + 1);
|
||||
outfname = outfname.Substring(0, outfname.LastIndexOf('.'));
|
||||
|
||||
if (!outflr.EndsWith("/"))
|
||||
outflr += "/";
|
||||
/*while (File.Exists(outflr + outfname + ext))
|
||||
outfname += "_";/**/
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr + outfname + ext, FileMode.Create));
|
||||
for (i = 0; i < outdata.Length; i++)
|
||||
bw.Write(outdata[i]);
|
||||
//bw.Write(outdata);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(outflr, FileMode.Create));
|
||||
for (i = 0; i < outdata.Length; i++)
|
||||
bw.Write(outdata[i]);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
Console.WriteLine("RLE decompressed " + filein);
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
fstr.Close();
|
||||
fstr.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
53
Compresion/Utils.cs
Normal file
53
Compresion/Utils.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Compresion
|
||||
{
|
||||
|
||||
public static class Utils
|
||||
{
|
||||
#region helper methods
|
||||
public static string byte_to_bits(byte b)
|
||||
{
|
||||
string o = "";
|
||||
for (int i = 0; i < 8; i++)
|
||||
o = (((b & (1 << i)) >> i) & 1) + o;
|
||||
return o;
|
||||
}
|
||||
public static string uint_to_bits(uint u)
|
||||
{
|
||||
string o = "";
|
||||
for (int i = 3; i > -1; i--)
|
||||
o += byte_to_bits((byte)((u & (0xFF << (i * 8))) >> (i * 8)));
|
||||
return o;
|
||||
}
|
||||
|
||||
public static byte peekByte(BinaryReader br)
|
||||
{
|
||||
byte b = br.ReadByte();
|
||||
br.BaseStream.Position--;
|
||||
return b;
|
||||
}
|
||||
|
||||
public static string makeSlashes(string path)
|
||||
{
|
||||
StringBuilder sbin = new StringBuilder(path),
|
||||
sbout = new StringBuilder();
|
||||
char c;
|
||||
while (sbin.Length > 0)
|
||||
{
|
||||
c = sbin[0];
|
||||
sbin.Remove(0, 1);
|
||||
if (c == '\\')
|
||||
sbout.Append('/');
|
||||
else
|
||||
sbout.Append(c);
|
||||
}
|
||||
return sbout.ToString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
46
Tinke.sln
Normal file
46
Tinke.sln
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual C# Express 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tinke", "Tinke\Tinke.csproj", "{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compresion", "Compresion\Compresion.csproj", "{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Debug|x64.Build.0 = Debug|x64
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Debug|x86.Build.0 = Debug|x86
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Release|x64.ActiveCfg = Release|x64
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Release|x64.Build.0 = Release|x64
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Release|x86.ActiveCfg = Release|x86
|
||||
{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}.Release|x86.Build.0 = Release|x86
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Debug|x64.Build.0 = Debug|x64
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Debug|x86.Build.0 = Debug|x86
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Release|x64.ActiveCfg = Release|x64
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Release|x64.Build.0 = Release|x64
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Release|x86.ActiveCfg = Release|x86
|
||||
{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
529
Tinke/Acciones.cs
Normal file
529
Tinke/Acciones.cs
Normal file
@ -0,0 +1,529 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Tinke
|
||||
{
|
||||
/// <summary>
|
||||
/// Clase con métodos y funciones realizadas sobre los archivos de los juegos.
|
||||
/// </summary>
|
||||
public class Acciones
|
||||
{
|
||||
|
||||
string file;
|
||||
string gameCode;
|
||||
Nitro.Estructuras.Folder root;
|
||||
int idSelect;
|
||||
int lastFileId;
|
||||
int lastFolderId;
|
||||
|
||||
// Informaciones guardadas
|
||||
Imagen.Paleta.Estructuras.NCLR paleta;
|
||||
Imagen.Tile.Estructuras.NCGR tile;
|
||||
Imagen.Screen.Estructuras.NSCR screen;
|
||||
|
||||
public Acciones(string file, string name)
|
||||
{
|
||||
this.file = file;
|
||||
gameCode = name.Replace("\0", "");
|
||||
}
|
||||
|
||||
public Nitro.Estructuras.Folder Root
|
||||
{
|
||||
get { return root; }
|
||||
set { root = value; Set_LastFileID(root); lastFileId++; Set_LastFolderID(root); lastFolderId++; }
|
||||
}
|
||||
public int IDSelect
|
||||
{
|
||||
get { return idSelect; }
|
||||
set { idSelect = value; }
|
||||
}
|
||||
public String ROMFile
|
||||
{
|
||||
get { return file; }
|
||||
}
|
||||
public int LastFileID
|
||||
{
|
||||
get { return lastFileId; }
|
||||
set { lastFileId = value; }
|
||||
}
|
||||
public int LastFolderID
|
||||
{
|
||||
get { return lastFolderId; }
|
||||
set { lastFolderId = value; }
|
||||
}
|
||||
|
||||
public void Set_Data(Nitro.Estructuras.File fileData)
|
||||
{
|
||||
Tipos.Role tipo = Formato(fileData.id);
|
||||
|
||||
string tempFile = "";
|
||||
|
||||
if (fileData.offset != 0x0)
|
||||
{
|
||||
tempFile = Application.StartupPath + "\\temp.dat";
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = fileData.offset;
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(Application.StartupPath + "\\temp.dat", FileMode.Create));
|
||||
bw.Write(br.ReadBytes((int)fileData.size));
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
bw.Dispose();
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
}
|
||||
else
|
||||
tempFile = fileData.path;
|
||||
|
||||
Object obtenido;
|
||||
if (Tipos.IsSupportedGame(gameCode))
|
||||
{
|
||||
obtenido = Tipos.DoActionGame(gameCode, tempFile, tipo, idSelect, fileData.name, this);
|
||||
if (obtenido is String)
|
||||
obtenido = Tipos.DoAction(tempFile, tipo, Extension());
|
||||
}
|
||||
else
|
||||
obtenido = Tipos.DoAction(tempFile, tipo, Extension());
|
||||
|
||||
if (obtenido is Imagen.Paleta.Estructuras.NCLR)
|
||||
paleta = (Imagen.Paleta.Estructuras.NCLR)obtenido;
|
||||
else if (obtenido is Imagen.Tile.Estructuras.NCGR)
|
||||
tile = (Imagen.Tile.Estructuras.NCGR)obtenido;
|
||||
else if (obtenido is Imagen.Screen.Estructuras.NSCR)
|
||||
screen = (Imagen.Screen.Estructuras.NSCR)obtenido;
|
||||
}
|
||||
public void Set_LastFileID(Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.files is List<Nitro.Estructuras.File>)
|
||||
foreach (Nitro.Estructuras.File archivo in currFolder.files)
|
||||
if (archivo.id > lastFileId)
|
||||
lastFileId = archivo.id;
|
||||
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>)
|
||||
foreach (Nitro.Estructuras.Folder subFolder in currFolder.folders)
|
||||
Set_LastFileID(subFolder);
|
||||
|
||||
}
|
||||
public void Set_LastFolderID(Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.id > lastFolderId)
|
||||
lastFolderId = currFolder.id;
|
||||
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>)
|
||||
foreach (Nitro.Estructuras.Folder subFolder in currFolder.folders)
|
||||
Set_LastFolderID(subFolder);
|
||||
}
|
||||
public void Delete_PicturesSaved()
|
||||
{
|
||||
paleta = new Imagen.Paleta.Estructuras.NCLR();
|
||||
tile = new Imagen.Tile.Estructuras.NCGR();
|
||||
screen = new Imagen.Screen.Estructuras.NSCR();
|
||||
}
|
||||
|
||||
public void Add_Files(List<Nitro.Estructuras.File> files)
|
||||
{
|
||||
for (int i = 0; i < files.Count; i++)
|
||||
{
|
||||
Nitro.Estructuras.File currFile = files[i];
|
||||
currFile.id = (ushort)lastFileId;
|
||||
files.RemoveAt(i);
|
||||
files.Insert(i, currFile);
|
||||
lastFileId++;
|
||||
}
|
||||
|
||||
int idNewFolder = Select_File().id;
|
||||
root = FileToFolder(idNewFolder, root);
|
||||
Add_Files(files, (ushort)(lastFolderId - 1), root);
|
||||
|
||||
}
|
||||
public Nitro.Estructuras.Folder Add_Files(List<Nitro.Estructuras.File> files, ushort idFolder, Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>) // Si tiene subdirectorios, buscamos en cada uno de ellos
|
||||
{
|
||||
for (int i = 0; i < currFolder.folders.Count; i++)
|
||||
{
|
||||
if (currFolder.folders[i].id == idFolder)
|
||||
{
|
||||
Nitro.Estructuras.Folder newFolder = currFolder.folders[i];
|
||||
if (!(newFolder.files is List<Nitro.Estructuras.File>))
|
||||
newFolder.files = new List<Nitro.Estructuras.File>();
|
||||
newFolder.files.AddRange(files);
|
||||
currFolder.folders[i] = newFolder;
|
||||
return currFolder.folders[i];
|
||||
}
|
||||
|
||||
Nitro.Estructuras.Folder folder = Add_Files(files, idFolder, currFolder.folders[i]);
|
||||
if (folder.name is string) // Comprobamos que se haya devuelto un directorio, en cuyo caso es el buscado que lo devolvemos
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
|
||||
return new Nitro.Estructuras.Folder();
|
||||
}
|
||||
public Nitro.Estructuras.Folder FileToFolder(int id, Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.files is List<Nitro.Estructuras.File>)
|
||||
{
|
||||
for (int i = 0; i < currFolder.files.Count; i++)
|
||||
{
|
||||
if (currFolder.files[i].id == id)
|
||||
{
|
||||
Nitro.Estructuras.Folder newFolder = new Nitro.Estructuras.Folder();
|
||||
newFolder.name = currFolder.files[i].name;
|
||||
newFolder.id = (ushort)lastFolderId;
|
||||
lastFolderId++;
|
||||
currFolder.files.RemoveAt(i);
|
||||
if (!(currFolder.folders is List<Nitro.Estructuras.Folder>))
|
||||
currFolder.folders = new List<Nitro.Estructuras.Folder>();
|
||||
currFolder.folders.Add(newFolder);
|
||||
return currFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>)
|
||||
{
|
||||
foreach (Nitro.Estructuras.Folder subFolder in currFolder.folders)
|
||||
{
|
||||
Nitro.Estructuras.Folder folder = FileToFolder(id, subFolder);
|
||||
if (folder.name is string)
|
||||
{
|
||||
currFolder.folders.Remove(subFolder);
|
||||
currFolder.folders.Add(folder);
|
||||
currFolder.folders.Sort(Comparacion_Directorios);
|
||||
return currFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Nitro.Estructuras.Folder();
|
||||
}
|
||||
private static int Comparacion_Directorios(Nitro.Estructuras.Folder f1, Nitro.Estructuras.Folder f2)
|
||||
{
|
||||
return String.Compare(f1.name, f2.name);
|
||||
}
|
||||
public void Change_File(int id, Nitro.Estructuras.File fileChanged, Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.files is List<Nitro.Estructuras.File>)
|
||||
for (int i = 0; i < currFolder.files.Count; i++)
|
||||
if (currFolder.files[i].id == id)
|
||||
currFolder.files[i] = fileChanged;
|
||||
|
||||
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>)
|
||||
foreach (Nitro.Estructuras.Folder subFolder in currFolder.folders)
|
||||
Change_File(id, fileChanged, subFolder);
|
||||
}
|
||||
|
||||
public Nitro.Estructuras.File Select_File()
|
||||
{
|
||||
return Recursivo_Archivo(idSelect, root);
|
||||
}
|
||||
public Nitro.Estructuras.File Search_File(int id)
|
||||
{
|
||||
return Recursivo_Archivo(id, root);
|
||||
}
|
||||
public Nitro.Estructuras.Folder Select_Folder()
|
||||
{
|
||||
return Recursivo_Carpeta(idSelect, root);
|
||||
}
|
||||
private Nitro.Estructuras.File Recursivo_Archivo(int id, Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.files is List<Nitro.Estructuras.File>)
|
||||
foreach (Nitro.Estructuras.File archivo in currFolder.files)
|
||||
if (archivo.id == id)
|
||||
return archivo;
|
||||
|
||||
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>)
|
||||
{
|
||||
foreach (Nitro.Estructuras.Folder subFolder in currFolder.folders)
|
||||
{
|
||||
Nitro.Estructuras.File currFile = Recursivo_Archivo(id, subFolder);
|
||||
if (currFile.name is string)
|
||||
return currFile;
|
||||
}
|
||||
}
|
||||
|
||||
return new Nitro.Estructuras.File();
|
||||
}
|
||||
private Nitro.Estructuras.Folder Recursivo_Carpeta(int id, Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>) // Si tiene subdirectorios, buscamos en cada uno de ellos
|
||||
{
|
||||
foreach (Nitro.Estructuras.Folder subFolder in currFolder.folders)
|
||||
{
|
||||
if (subFolder.id == id) // Si lo hemos encontrado lo devolvemos, en caso contrario, seguimos buscando
|
||||
return subFolder;
|
||||
|
||||
Nitro.Estructuras.Folder folder = Recursivo_Carpeta(id, subFolder);
|
||||
if (folder.name is string) // Comprobamos que se haya devuelto un directorio, en cuyo caso es el buscado que lo devolvemos
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
|
||||
return new Nitro.Estructuras.Folder();
|
||||
}
|
||||
|
||||
public Tipos.Role Formato()
|
||||
{
|
||||
// Si el juego está soportado por una clase:
|
||||
if (Tipos.IsSupportedGame(gameCode))
|
||||
{
|
||||
Tipos.Role tipo = Tipos.FormatFileGame(gameCode, idSelect, Select_File().name);
|
||||
if (tipo != Tipos.Role.Desconocido)
|
||||
return tipo;
|
||||
else // En caso de que sea un archivo genérico
|
||||
return Tipos.FormatFile(Select_File().name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Nitro.Estructuras.File currFile = Select_File();
|
||||
Tipos.Role tipo = Tipos.FormatFile(currFile.name);
|
||||
|
||||
if (tipo != Tipos.Role.Desconocido)
|
||||
return tipo;
|
||||
else // Si la comprobación por nombre falla, se intenta leyendo un posible Magic ID de 4 bytes al inicio
|
||||
{
|
||||
BinaryReader br;
|
||||
if (currFile.offset != 0x0)
|
||||
{
|
||||
br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = currFile.offset;
|
||||
}
|
||||
else // En caso de que el archivo haya sido extraído y no esté en la ROM
|
||||
br = new BinaryReader(File.OpenRead(currFile.path));
|
||||
|
||||
string ext = "";
|
||||
try { ext = new String(br.ReadChars(4)); } // Utilizamos try pues los 4 bytes podrían superar los límites para un valor Char
|
||||
catch { return Tipos.Role.Desconocido; } // En cuyo caso será desconocido el formato por ahora.
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
tipo = Tipos.FormatFile(ext);
|
||||
if (tipo == Tipos.Role.Desconocido && ext[0] == 0x10) // En caso de descubrir una posible compresión en LZ77
|
||||
return Tipos.Role.Comprimido_LZ77; // se debería buscar también en 0x4
|
||||
else if (tipo == Tipos.Role.Desconocido && ext[0] == 0x20) // En caso de descubrir una compresión en Huffman.
|
||||
return Tipos.Role.Comprimido_Huffman; // se debería buscar también en 0x4
|
||||
|
||||
return tipo;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Tipos.Role Formato(int id)
|
||||
{
|
||||
// Si el juego está soportado por una clase:
|
||||
if (Tipos.IsSupportedGame(gameCode))
|
||||
{
|
||||
Nitro.Estructuras.File currFile = Search_File(id);
|
||||
|
||||
Tipos.Role tipo = Tipos.FormatFileGame(gameCode, id, currFile.name);
|
||||
if (tipo != Tipos.Role.Desconocido)
|
||||
return tipo;
|
||||
else // En caso de que sea un archivo genérico
|
||||
return Tipos.FormatFile(currFile.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Nitro.Estructuras.File currFile = Search_File(id);
|
||||
Tipos.Role tipo = Tipos.FormatFile(currFile.name);
|
||||
|
||||
if (tipo != Tipos.Role.Desconocido)
|
||||
return tipo;
|
||||
else // Si la comprobación por nombre falla, se intenta leyendo un posible Magic ID de 4 bytes al inicio
|
||||
{
|
||||
BinaryReader br;
|
||||
if (currFile.offset != 0x0)
|
||||
{
|
||||
br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = currFile.offset;
|
||||
}
|
||||
else // En caso de que el archivo haya sido extraído y no esté en la ROM
|
||||
br = new BinaryReader(File.OpenRead(currFile.path));
|
||||
|
||||
string ext = "";
|
||||
try { ext = new String(br.ReadChars(4)); } // Utilizamos try pues los 4 bytes podrían superar los límites para un valor Char
|
||||
catch { return Tipos.Role.Desconocido; } // En cuyo caso será desconocido el formato por ahora.
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
tipo = Tipos.FormatFile(ext);
|
||||
if (tipo == Tipos.Role.Desconocido && ext[0] == 0x10) // En caso de descubrir una posible compresión en LZ77
|
||||
return Tipos.Role.Comprimido_LZ77; // se debería buscar también en 0x4
|
||||
else if (tipo == Tipos.Role.Desconocido && ext[0] == 0x20) // En caso de descubrir una compresión en Huffman.
|
||||
return Tipos.Role.Comprimido_Huffman; // se debería buscar también en 0x4
|
||||
|
||||
return tipo;
|
||||
}
|
||||
}
|
||||
}
|
||||
public String Extension()
|
||||
{
|
||||
Nitro.Estructuras.File fileSelect = Select_File();
|
||||
string ext = Tipos.Extension(fileSelect.name);
|
||||
|
||||
if (ext != "")
|
||||
return ext;
|
||||
else
|
||||
{ // En caso de que no se reconozca, se intenta buscar leyendo un posible Magic ID
|
||||
BinaryReader br;
|
||||
if (fileSelect.offset != 0x0)
|
||||
{
|
||||
br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = Select_File().offset;
|
||||
}
|
||||
else // En caso de haber sido extraído de la ROM
|
||||
br = new BinaryReader(File.OpenRead(fileSelect.path));
|
||||
|
||||
try { ext = new String(br.ReadChars(4)); } // Pueden leerse bytes fuera del índice de chars
|
||||
catch { ext = ""; }
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return Tipos.Extension(ext);
|
||||
}
|
||||
}
|
||||
|
||||
public Control See_File()
|
||||
{
|
||||
Tipos.Role tipo = Formato();
|
||||
|
||||
Nitro.Estructuras.File fileSelect = Select_File();
|
||||
string tempFile = "";
|
||||
|
||||
if (fileSelect.offset != 0x0)
|
||||
{
|
||||
tempFile = Application.StartupPath + "\\temp.dat";
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = fileSelect.offset;
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(Application.StartupPath + "\\temp.dat", FileMode.Create));
|
||||
bw.Write(br.ReadBytes((int)fileSelect.size));
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
bw.Dispose();
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
}
|
||||
else
|
||||
tempFile = fileSelect.path;
|
||||
|
||||
Object obtenido;
|
||||
|
||||
if (Tipos.IsSupportedGame(gameCode))
|
||||
{
|
||||
obtenido = Tipos.DoActionGame(gameCode, tempFile, tipo, idSelect, fileSelect.name, this);
|
||||
if (obtenido is String)
|
||||
obtenido = Tipos.DoAction(tempFile, tipo, Extension());
|
||||
}
|
||||
else
|
||||
{
|
||||
obtenido = Tipos.DoAction(tempFile, tipo, Extension());
|
||||
}
|
||||
|
||||
if (obtenido is Bitmap[])
|
||||
return Obtenido_Imagenes((Bitmap[])obtenido);
|
||||
else if (obtenido is Bitmap)
|
||||
return Obtenido_Imagen((Bitmap)obtenido);
|
||||
else if (obtenido is Imagen.Paleta.Estructuras.NCLR)
|
||||
{
|
||||
paleta = (Imagen.Paleta.Estructuras.NCLR)obtenido;
|
||||
return Obtenido_Paleta();
|
||||
}
|
||||
else if (obtenido is Imagen.Tile.Estructuras.NCGR)
|
||||
{
|
||||
tile = (Imagen.Tile.Estructuras.NCGR)obtenido;
|
||||
return Obtenido_Tile();
|
||||
}
|
||||
else if (obtenido is Imagen.Screen.Estructuras.NSCR)
|
||||
{
|
||||
screen = (Imagen.Screen.Estructuras.NSCR)obtenido;
|
||||
tile.rahc.tileData.tiles = Imagen.Screen.NSCR.Modificar_Tile(screen, tile.rahc.tileData.tiles);
|
||||
return Obtenido_Tile();
|
||||
}
|
||||
else if (obtenido is String)
|
||||
return Obtenido_Texto((String)obtenido);
|
||||
else if (obtenido is Panel)
|
||||
return (Panel)obtenido;
|
||||
|
||||
return new Control(); // Nunca debería darse este caso
|
||||
}
|
||||
|
||||
#region Devolver GUI del archivo
|
||||
private TabControl Obtenido_Imagenes(Bitmap[] imagenes)
|
||||
{
|
||||
TabControl tab = new TabControl();
|
||||
TabPage[] pages = new TabPage[imagenes.Length];
|
||||
|
||||
for (int i = 0; i < pages.Length; i++)
|
||||
{
|
||||
pages[i] = new TabPage("Imagen " + i.ToString());
|
||||
|
||||
PictureBox pic = new PictureBox();
|
||||
pic.Image = imagenes[i];
|
||||
pic.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pages[i].Controls.Add(pic);
|
||||
}
|
||||
|
||||
tab.TabPages.AddRange(pages);
|
||||
tab.Dock = DockStyle.Fill;
|
||||
return tab;
|
||||
}
|
||||
private PictureBox Obtenido_Imagen(Bitmap imagen)
|
||||
{
|
||||
PictureBox pic = new PictureBox();
|
||||
pic.Image = imagen;
|
||||
pic.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
|
||||
return pic;
|
||||
}
|
||||
private PictureBox Obtenido_Paleta()
|
||||
{
|
||||
PictureBox pic = new PictureBox();
|
||||
pic.Image = Imagen.Paleta.NCLR.Mostrar(paleta);
|
||||
pic.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
|
||||
return pic;
|
||||
}
|
||||
private Control Obtenido_Tile()
|
||||
{
|
||||
if (paleta.constante == 0x0100) // Comprobación de que hay guardada una paleta
|
||||
{
|
||||
if (new String(screen.id) == "RCSN") // Comprobación de que hay una información de imagen guardada
|
||||
{
|
||||
tile.rahc.tileData.tiles = Imagen.Screen.NSCR.Modificar_Tile(screen, tile.rahc.tileData.tiles);
|
||||
tile.rahc.nTilesX = (ushort)(screen.section.width / 8);
|
||||
tile.rahc.nTilesY = (ushort)(screen.section.height / 8);
|
||||
}
|
||||
Imagen.Tile.iNCGR ventana = new Imagen.Tile.iNCGR(tile, paleta);
|
||||
ventana.Dock = DockStyle.Fill;
|
||||
return ventana;
|
||||
}
|
||||
else
|
||||
return new PictureBox();
|
||||
}
|
||||
private TextBox Obtenido_Texto(string texto)
|
||||
{
|
||||
TextBox txt = new TextBox();
|
||||
txt.Multiline = true;
|
||||
txt.Width = 300;
|
||||
txt.Dock = DockStyle.Fill;
|
||||
txt.ScrollBars = ScrollBars.Both;
|
||||
txt.Text = texto;
|
||||
txt.Select(0, 0);
|
||||
txt.ReadOnly = true;
|
||||
|
||||
return txt;
|
||||
}
|
||||
#endregion // Devolver GUI del archivo
|
||||
|
||||
}
|
||||
|
||||
}
|
71
Tinke/DatosHex.Designer.cs
generated
Normal file
71
Tinke/DatosHex.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
||||
namespace Tinke
|
||||
{
|
||||
partial class DatosHex
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtHex = new System.Windows.Forms.TextBox();
|
||||
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtHex
|
||||
//
|
||||
this.txtHex.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtHex.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txtHex.Location = new System.Drawing.Point(0, 0);
|
||||
this.txtHex.Multiline = true;
|
||||
this.txtHex.Name = "txtHex";
|
||||
this.txtHex.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.txtHex.Size = new System.Drawing.Size(342, 252);
|
||||
this.txtHex.TabIndex = 0;
|
||||
//
|
||||
// backgroundWorker1
|
||||
//
|
||||
this.backgroundWorker1.WorkerReportsProgress = true;
|
||||
this.backgroundWorker1.WorkerSupportsCancellation = true;
|
||||
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
|
||||
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
|
||||
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
|
||||
//
|
||||
// DatosHex
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.txtHex);
|
||||
this.Name = "DatosHex";
|
||||
this.Size = new System.Drawing.Size(342, 252);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox txtHex;
|
||||
private System.ComponentModel.BackgroundWorker backgroundWorker1;
|
||||
}
|
||||
}
|
79
Tinke/DatosHex.cs
Normal file
79
Tinke/DatosHex.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace Tinke
|
||||
{
|
||||
public partial class DatosHex : UserControl
|
||||
{
|
||||
Espera espera;
|
||||
int nByte;
|
||||
|
||||
public DatosHex()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void LeerFile(string file, UInt32 offset, UInt32 size)
|
||||
{
|
||||
espera = new Espera("Leyendo datos...", true);
|
||||
nByte = (int)size;
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = offset;
|
||||
|
||||
byte[] bytesFile = br.ReadBytes((int)size);
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
backgroundWorker1.RunWorkerAsync(bytesFile);
|
||||
espera.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
txtHex.Text = "";
|
||||
}
|
||||
|
||||
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
||||
{
|
||||
espera.Set_ProgressValue((e.ProgressPercentage * 100) / nByte);
|
||||
}
|
||||
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
byte[] value = (byte[])e.Argument;
|
||||
string text = "";
|
||||
|
||||
for (int i = 0; ; )
|
||||
{
|
||||
string ascii = "";
|
||||
for (int j = 0; j < 0xF; j++)
|
||||
{
|
||||
if (i >= value.Length) break;
|
||||
text += Tools.Helper.DecToHex(value[i]) + ' ';
|
||||
ascii += (value[i] > 0x1F && value[i] < 0x7F ? Char.ConvertFromUtf32(value[i]).ToString() + ' ' : ". ");
|
||||
i++;
|
||||
backgroundWorker1.ReportProgress(i);
|
||||
}
|
||||
text += new String(' ', 40 - ascii.Length) + ascii;
|
||||
text += "\r\n";
|
||||
if (i >= value.Length) break;
|
||||
}
|
||||
|
||||
e.Result = text;
|
||||
}
|
||||
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
espera.Close();
|
||||
txtHex.Text = (string)e.Result;
|
||||
txtHex.Select(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
123
Tinke/DatosHex.resx
Normal file
123
Tinke/DatosHex.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
77
Tinke/Espera.Designer.cs
generated
Normal file
77
Tinke/Espera.Designer.cs
generated
Normal file
@ -0,0 +1,77 @@
|
||||
namespace Tinke
|
||||
{
|
||||
partial class Espera
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(62, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Cargando...";
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Location = new System.Drawing.Point(8, 25);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(133, 23);
|
||||
this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
|
||||
this.progressBar1.TabIndex = 1;
|
||||
//
|
||||
// Espera
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(153, 56);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.progressBar1);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "Espera";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Cargando...";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
}
|
||||
}
|
42
Tinke/Espera.cs
Normal file
42
Tinke/Espera.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tinke
|
||||
{
|
||||
public partial class Espera : Form
|
||||
{
|
||||
public Espera()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public Espera(string label, bool step)
|
||||
{
|
||||
InitializeComponent();
|
||||
label1.Text = label;
|
||||
if (step)
|
||||
progressBar1.Style = ProgressBarStyle.Continuous;
|
||||
}
|
||||
public Espera(string label, int step)
|
||||
{
|
||||
InitializeComponent();
|
||||
label1.Text = label;
|
||||
progressBar1.Style = ProgressBarStyle.Continuous;
|
||||
progressBar1.Step = step;
|
||||
}
|
||||
|
||||
public void Set_ProgressValue(int porcentaje)
|
||||
{
|
||||
progressBar1.Value = porcentaje;
|
||||
}
|
||||
public void Step()
|
||||
{
|
||||
progressBar1.PerformStep();
|
||||
}
|
||||
}
|
||||
}
|
120
Tinke/Espera.resx
Normal file
120
Tinke/Espera.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
674
Tinke/Form1.Designer.cs
generated
Normal file
674
Tinke/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,674 @@
|
||||
namespace Tinke
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable del diseñador requerida.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Limpiar los recursos que se estén utilizando.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si los recursos administrados se deben eliminar; false en caso contrario, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Código generado por el Diseñador de Windows Forms
|
||||
|
||||
/// <summary>
|
||||
/// Método necesario para admitir el Diseñador. No se puede modificar
|
||||
/// el contenido del método con el editor de código.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
System.Windows.Forms.ListViewItem listViewItem49 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x0",
|
||||
"Game Title"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem50 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0xC",
|
||||
"Game Code"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem51 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x10",
|
||||
"Maker Code"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem52 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x12",
|
||||
"Unit Code"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem53 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x13",
|
||||
"Encryption seed select"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem54 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x14",
|
||||
"Tamaño del archivo"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem55 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x15",
|
||||
"Reserved"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem56 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x1E",
|
||||
"ROM Version"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem57 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x1F",
|
||||
"Internal flags"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem58 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x20",
|
||||
"ARM9 rom offset"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem59 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x24",
|
||||
"ARM9 entry address"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem60 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x28",
|
||||
"ARM9 load address"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem61 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x2C",
|
||||
"ARM9 size"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem62 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x30",
|
||||
"ARM7 rom offset"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem63 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x34",
|
||||
"ARM7 entry address"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem64 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x38",
|
||||
"ARM7 load address"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem65 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x3C",
|
||||
"ARM7 size"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem66 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x40",
|
||||
"File Name Table (FNT) offset"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem67 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x44",
|
||||
"File Name Table (FNT) length"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem68 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x48",
|
||||
"File Allocation Table (FAT) offset"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem69 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x4C",
|
||||
"File Allocation Table (FAT) length"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem70 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x50",
|
||||
"ARM9 overlay offset"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem71 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x54",
|
||||
"ARM9 overlay length"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem72 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x58",
|
||||
"ARM7 overlay offset"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem73 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x5C",
|
||||
"ARM7 overlay length"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem74 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x60",
|
||||
"Normal card control register settings"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem75 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x64",
|
||||
"Secure card control register settings"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem76 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x68",
|
||||
"Icon Banner offset"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem77 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x6C",
|
||||
"Secure area CRC"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem78 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x6E",
|
||||
"Secure transfer timeout"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem79 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x70",
|
||||
"ARM9 autoload"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem80 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x74",
|
||||
"ARM7 autoload"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem81 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x78",
|
||||
"Secure disable"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem82 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x80",
|
||||
"ROM size"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem83 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x84",
|
||||
"Header size"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem84 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x88",
|
||||
"Reserved"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem85 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x15C",
|
||||
"Nintendo logo CRC"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem86 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x15E",
|
||||
"Header CRC"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem44 = new System.Windows.Forms.ListViewItem("Nombre");
|
||||
System.Windows.Forms.ListViewItem listViewItem45 = new System.Windows.Forms.ListViewItem("ID");
|
||||
System.Windows.Forms.ListViewItem listViewItem46 = new System.Windows.Forms.ListViewItem("Offset");
|
||||
System.Windows.Forms.ListViewItem listViewItem47 = new System.Windows.Forms.ListViewItem("Tamaño");
|
||||
System.Windows.Forms.ListViewItem listViewItem48 = new System.Windows.Forms.ListViewItem("Tipo");
|
||||
this.output = new System.Windows.Forms.ListBox();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.groupBanner = new System.Windows.Forms.GroupBox();
|
||||
this.btnBannerGuardar = new System.Windows.Forms.Button();
|
||||
this.iconos = new System.Windows.Forms.ImageList(this.components);
|
||||
this.txtBannerReserved = new System.Windows.Forms.TextBox();
|
||||
this.txtBannerCRC = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtBannerVer = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.comboBannerLang = new System.Windows.Forms.ComboBox();
|
||||
this.txtBannerTitle = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.picIcon = new System.Windows.Forms.PictureBox();
|
||||
this.listInfo = new System.Windows.Forms.ListView();
|
||||
this.columnPosicion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnCampo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnValor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.textURL = new System.Windows.Forms.TextBox();
|
||||
this.btnOpen = new System.Windows.Forms.Button();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.btnDeleteChain = new System.Windows.Forms.Button();
|
||||
this.btnExtraer = new System.Windows.Forms.Button();
|
||||
this.btnUncompress = new System.Windows.Forms.Button();
|
||||
this.btnSee = new System.Windows.Forms.Button();
|
||||
this.btnHex = new System.Windows.Forms.Button();
|
||||
this.listFile = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.treeSystem = new System.Windows.Forms.TreeView();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage4 = new System.Windows.Forms.TabPage();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.groupBanner.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picIcon)).BeginInit();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// output
|
||||
//
|
||||
this.output.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.output.FormattingEnabled = true;
|
||||
this.output.Location = new System.Drawing.Point(0, 419);
|
||||
this.output.Name = "output";
|
||||
this.output.Size = new System.Drawing.Size(826, 82);
|
||||
this.output.TabIndex = 1;
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Controls.Add(this.tabPage3);
|
||||
this.tabControl1.Controls.Add(this.tabPage4);
|
||||
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(826, 419);
|
||||
this.tabControl1.TabIndex = 2;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.groupBanner);
|
||||
this.tabPage1.Controls.Add(this.listInfo);
|
||||
this.tabPage1.Controls.Add(this.textURL);
|
||||
this.tabPage1.Controls.Add(this.btnOpen);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(818, 393);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Info ROM";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBanner
|
||||
//
|
||||
this.groupBanner.Controls.Add(this.btnBannerGuardar);
|
||||
this.groupBanner.Controls.Add(this.txtBannerReserved);
|
||||
this.groupBanner.Controls.Add(this.txtBannerCRC);
|
||||
this.groupBanner.Controls.Add(this.label4);
|
||||
this.groupBanner.Controls.Add(this.label3);
|
||||
this.groupBanner.Controls.Add(this.txtBannerVer);
|
||||
this.groupBanner.Controls.Add(this.label2);
|
||||
this.groupBanner.Controls.Add(this.comboBannerLang);
|
||||
this.groupBanner.Controls.Add(this.txtBannerTitle);
|
||||
this.groupBanner.Controls.Add(this.label1);
|
||||
this.groupBanner.Controls.Add(this.picIcon);
|
||||
this.groupBanner.Location = new System.Drawing.Point(547, 44);
|
||||
this.groupBanner.Name = "groupBanner";
|
||||
this.groupBanner.Size = new System.Drawing.Size(263, 343);
|
||||
this.groupBanner.TabIndex = 3;
|
||||
this.groupBanner.TabStop = false;
|
||||
this.groupBanner.Text = "Banner";
|
||||
//
|
||||
// btnBannerGuardar
|
||||
//
|
||||
this.btnBannerGuardar.ImageKey = "picture_save.png";
|
||||
this.btnBannerGuardar.ImageList = this.iconos;
|
||||
this.btnBannerGuardar.Location = new System.Drawing.Point(127, 44);
|
||||
this.btnBannerGuardar.Name = "btnBannerGuardar";
|
||||
this.btnBannerGuardar.Size = new System.Drawing.Size(127, 32);
|
||||
this.btnBannerGuardar.TabIndex = 11;
|
||||
this.btnBannerGuardar.Text = "Guardar como...";
|
||||
this.btnBannerGuardar.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnBannerGuardar.UseVisualStyleBackColor = true;
|
||||
this.btnBannerGuardar.Click += new System.EventHandler(this.btnBannerGuardar_Click);
|
||||
//
|
||||
// iconos
|
||||
//
|
||||
this.iconos.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("iconos.ImageStream")));
|
||||
this.iconos.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.iconos.Images.SetKeyName(0, "folder.png");
|
||||
this.iconos.Images.SetKeyName(1, "page_white.png");
|
||||
this.iconos.Images.SetKeyName(2, "rainbow.png");
|
||||
this.iconos.Images.SetKeyName(3, "image.png");
|
||||
this.iconos.Images.SetKeyName(4, "page_white_text.png");
|
||||
this.iconos.Images.SetKeyName(5, "compress.png");
|
||||
this.iconos.Images.SetKeyName(6, "package.png");
|
||||
this.iconos.Images.SetKeyName(7, "package_go.png");
|
||||
this.iconos.Images.SetKeyName(8, "images.png");
|
||||
this.iconos.Images.SetKeyName(9, "image_link.png");
|
||||
this.iconos.Images.SetKeyName(10, "photo.png");
|
||||
this.iconos.Images.SetKeyName(11, "picture_save.png");
|
||||
this.iconos.Images.SetKeyName(12, "picture_delete.png");
|
||||
//
|
||||
// txtBannerReserved
|
||||
//
|
||||
this.txtBannerReserved.Location = new System.Drawing.Point(72, 159);
|
||||
this.txtBannerReserved.Name = "txtBannerReserved";
|
||||
this.txtBannerReserved.ReadOnly = true;
|
||||
this.txtBannerReserved.Size = new System.Drawing.Size(182, 20);
|
||||
this.txtBannerReserved.TabIndex = 10;
|
||||
//
|
||||
// txtBannerCRC
|
||||
//
|
||||
this.txtBannerCRC.Location = new System.Drawing.Point(72, 131);
|
||||
this.txtBannerCRC.Name = "txtBannerCRC";
|
||||
this.txtBannerCRC.ReadOnly = true;
|
||||
this.txtBannerCRC.Size = new System.Drawing.Size(182, 20);
|
||||
this.txtBannerCRC.TabIndex = 9;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(13, 162);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(53, 13);
|
||||
this.label4.TabIndex = 8;
|
||||
this.label4.Text = "Reserved";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(13, 134);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(44, 13);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "CRC16:";
|
||||
//
|
||||
// txtBannerVer
|
||||
//
|
||||
this.txtBannerVer.Location = new System.Drawing.Point(72, 101);
|
||||
this.txtBannerVer.Name = "txtBannerVer";
|
||||
this.txtBannerVer.ReadOnly = true;
|
||||
this.txtBannerVer.Size = new System.Drawing.Size(182, 20);
|
||||
this.txtBannerVer.TabIndex = 6;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(10, 104);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(45, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Version:";
|
||||
//
|
||||
// comboBannerLang
|
||||
//
|
||||
this.comboBannerLang.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append;
|
||||
this.comboBannerLang.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
|
||||
this.comboBannerLang.FormattingEnabled = true;
|
||||
this.comboBannerLang.Items.AddRange(new object[] {
|
||||
"Japonés",
|
||||
"Inglés",
|
||||
"Francés",
|
||||
"Alemán",
|
||||
"Italiano",
|
||||
"Español"});
|
||||
this.comboBannerLang.Location = new System.Drawing.Point(10, 212);
|
||||
this.comboBannerLang.Name = "comboBannerLang";
|
||||
this.comboBannerLang.Size = new System.Drawing.Size(244, 21);
|
||||
this.comboBannerLang.TabIndex = 4;
|
||||
this.comboBannerLang.Text = "Japonés";
|
||||
this.comboBannerLang.SelectedIndexChanged += new System.EventHandler(this.comboBannerLang_SelectedIndexChanged);
|
||||
//
|
||||
// txtBannerTitle
|
||||
//
|
||||
this.txtBannerTitle.Location = new System.Drawing.Point(10, 239);
|
||||
this.txtBannerTitle.Multiline = true;
|
||||
this.txtBannerTitle.Name = "txtBannerTitle";
|
||||
this.txtBannerTitle.ReadOnly = true;
|
||||
this.txtBannerTitle.Size = new System.Drawing.Size(247, 85);
|
||||
this.txtBannerTitle.TabIndex = 3;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(13, 53);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(37, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Icono:";
|
||||
//
|
||||
// picIcon
|
||||
//
|
||||
this.picIcon.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.picIcon.Location = new System.Drawing.Point(72, 44);
|
||||
this.picIcon.Name = "picIcon";
|
||||
this.picIcon.Size = new System.Drawing.Size(32, 32);
|
||||
this.picIcon.TabIndex = 0;
|
||||
this.picIcon.TabStop = false;
|
||||
//
|
||||
// listInfo
|
||||
//
|
||||
this.listInfo.Activation = System.Windows.Forms.ItemActivation.OneClick;
|
||||
this.listInfo.Alignment = System.Windows.Forms.ListViewAlignment.Default;
|
||||
this.listInfo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.listInfo.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnPosicion,
|
||||
this.columnCampo,
|
||||
this.columnValor});
|
||||
this.listInfo.HoverSelection = true;
|
||||
this.listInfo.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
|
||||
listViewItem49,
|
||||
listViewItem50,
|
||||
listViewItem51,
|
||||
listViewItem52,
|
||||
listViewItem53,
|
||||
listViewItem54,
|
||||
listViewItem55,
|
||||
listViewItem56,
|
||||
listViewItem57,
|
||||
listViewItem58,
|
||||
listViewItem59,
|
||||
listViewItem60,
|
||||
listViewItem61,
|
||||
listViewItem62,
|
||||
listViewItem63,
|
||||
listViewItem64,
|
||||
listViewItem65,
|
||||
listViewItem66,
|
||||
listViewItem67,
|
||||
listViewItem68,
|
||||
listViewItem69,
|
||||
listViewItem70,
|
||||
listViewItem71,
|
||||
listViewItem72,
|
||||
listViewItem73,
|
||||
listViewItem74,
|
||||
listViewItem75,
|
||||
listViewItem76,
|
||||
listViewItem77,
|
||||
listViewItem78,
|
||||
listViewItem79,
|
||||
listViewItem80,
|
||||
listViewItem81,
|
||||
listViewItem82,
|
||||
listViewItem83,
|
||||
listViewItem84,
|
||||
listViewItem85,
|
||||
listViewItem86});
|
||||
this.listInfo.LabelEdit = true;
|
||||
this.listInfo.Location = new System.Drawing.Point(3, 44);
|
||||
this.listInfo.Name = "listInfo";
|
||||
this.listInfo.Size = new System.Drawing.Size(538, 346);
|
||||
this.listInfo.TabIndex = 2;
|
||||
this.listInfo.UseCompatibleStateImageBehavior = false;
|
||||
this.listInfo.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnPosicion
|
||||
//
|
||||
this.columnPosicion.Text = "Posición";
|
||||
//
|
||||
// columnCampo
|
||||
//
|
||||
this.columnCampo.Text = "Campo";
|
||||
this.columnCampo.Width = 238;
|
||||
//
|
||||
// columnValor
|
||||
//
|
||||
this.columnValor.Text = "Valor";
|
||||
this.columnValor.Width = 214;
|
||||
//
|
||||
// textURL
|
||||
//
|
||||
this.textURL.Location = new System.Drawing.Point(7, 8);
|
||||
this.textURL.Name = "textURL";
|
||||
this.textURL.ReadOnly = true;
|
||||
this.textURL.Size = new System.Drawing.Size(724, 20);
|
||||
this.textURL.TabIndex = 1;
|
||||
//
|
||||
// btnOpen
|
||||
//
|
||||
this.btnOpen.Location = new System.Drawing.Point(737, 6);
|
||||
this.btnOpen.Name = "btnOpen";
|
||||
this.btnOpen.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnOpen.TabIndex = 0;
|
||||
this.btnOpen.Text = "Abrir ROM";
|
||||
this.btnOpen.UseVisualStyleBackColor = true;
|
||||
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.btnDeleteChain);
|
||||
this.tabPage2.Controls.Add(this.btnExtraer);
|
||||
this.tabPage2.Controls.Add(this.btnUncompress);
|
||||
this.tabPage2.Controls.Add(this.btnSee);
|
||||
this.tabPage2.Controls.Add(this.btnHex);
|
||||
this.tabPage2.Controls.Add(this.listFile);
|
||||
this.tabPage2.Controls.Add(this.treeSystem);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(818, 393);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Archivos";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnDeleteChain
|
||||
//
|
||||
this.btnDeleteChain.ImageKey = "picture_delete.png";
|
||||
this.btnDeleteChain.ImageList = this.iconos;
|
||||
this.btnDeleteChain.Location = new System.Drawing.Point(616, 278);
|
||||
this.btnDeleteChain.Name = "btnDeleteChain";
|
||||
this.btnDeleteChain.Size = new System.Drawing.Size(98, 32);
|
||||
this.btnDeleteChain.TabIndex = 5;
|
||||
this.btnDeleteChain.Text = "Borrar cadena";
|
||||
this.btnDeleteChain.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnDeleteChain.UseVisualStyleBackColor = true;
|
||||
this.btnDeleteChain.Click += new System.EventHandler(this.btnDeleteChain_Click);
|
||||
//
|
||||
// btnExtraer
|
||||
//
|
||||
this.btnExtraer.ImageKey = "package_go.png";
|
||||
this.btnExtraer.ImageList = this.iconos;
|
||||
this.btnExtraer.Location = new System.Drawing.Point(720, 316);
|
||||
this.btnExtraer.Name = "btnExtraer";
|
||||
this.btnExtraer.Size = new System.Drawing.Size(92, 32);
|
||||
this.btnExtraer.TabIndex = 4;
|
||||
this.btnExtraer.Text = "Extraer";
|
||||
this.btnExtraer.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnExtraer.UseVisualStyleBackColor = true;
|
||||
this.btnExtraer.Click += new System.EventHandler(this.btnExtraer_Click);
|
||||
//
|
||||
// btnUncompress
|
||||
//
|
||||
this.btnUncompress.Enabled = false;
|
||||
this.btnUncompress.ImageKey = "compress.png";
|
||||
this.btnUncompress.ImageList = this.iconos;
|
||||
this.btnUncompress.Location = new System.Drawing.Point(616, 316);
|
||||
this.btnUncompress.Name = "btnUncompress";
|
||||
this.btnUncompress.Size = new System.Drawing.Size(98, 32);
|
||||
this.btnUncompress.TabIndex = 3;
|
||||
this.btnUncompress.Text = "Descomprimir";
|
||||
this.btnUncompress.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnUncompress.UseVisualStyleBackColor = true;
|
||||
this.btnUncompress.Click += new System.EventHandler(this.btnUncompress_Click);
|
||||
//
|
||||
// btnSee
|
||||
//
|
||||
this.btnSee.Enabled = false;
|
||||
this.btnSee.Image = global::Tinke.Properties.Resources.zoom;
|
||||
this.btnSee.Location = new System.Drawing.Point(616, 355);
|
||||
this.btnSee.Name = "btnSee";
|
||||
this.btnSee.Size = new System.Drawing.Size(98, 32);
|
||||
this.btnSee.TabIndex = 2;
|
||||
this.btnSee.Text = "Ver";
|
||||
this.btnSee.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSee.UseVisualStyleBackColor = true;
|
||||
this.btnSee.Click += new System.EventHandler(this.BtnSee);
|
||||
//
|
||||
// btnHex
|
||||
//
|
||||
this.btnHex.Enabled = false;
|
||||
this.btnHex.Image = global::Tinke.Properties.Resources.calculator;
|
||||
this.btnHex.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnHex.Location = new System.Drawing.Point(720, 355);
|
||||
this.btnHex.Name = "btnHex";
|
||||
this.btnHex.Size = new System.Drawing.Size(92, 32);
|
||||
this.btnHex.TabIndex = 1;
|
||||
this.btnHex.Text = "Hexadecimal";
|
||||
this.btnHex.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnHex.UseVisualStyleBackColor = true;
|
||||
this.btnHex.Click += new System.EventHandler(this.btnHex_Click);
|
||||
//
|
||||
// listFile
|
||||
//
|
||||
this.listFile.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader2});
|
||||
this.listFile.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
|
||||
listViewItem44,
|
||||
listViewItem45,
|
||||
listViewItem46,
|
||||
listViewItem47,
|
||||
listViewItem48});
|
||||
this.listFile.Location = new System.Drawing.Point(609, 3);
|
||||
this.listFile.Name = "listFile";
|
||||
this.listFile.Size = new System.Drawing.Size(206, 161);
|
||||
this.listFile.TabIndex = 0;
|
||||
this.listFile.UseCompatibleStateImageBehavior = false;
|
||||
this.listFile.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Campo";
|
||||
this.columnHeader1.Width = 72;
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Valor";
|
||||
this.columnHeader2.Width = 116;
|
||||
//
|
||||
// treeSystem
|
||||
//
|
||||
this.treeSystem.ImageIndex = 0;
|
||||
this.treeSystem.ImageList = this.iconos;
|
||||
this.treeSystem.Location = new System.Drawing.Point(3, 3);
|
||||
this.treeSystem.Name = "treeSystem";
|
||||
this.treeSystem.SelectedImageIndex = 0;
|
||||
this.treeSystem.Size = new System.Drawing.Size(606, 387);
|
||||
this.treeSystem.TabIndex = 0;
|
||||
this.treeSystem.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSystem_AfterSelect);
|
||||
this.treeSystem.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treeSystem_MouseDoubleClick);
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage3.Size = new System.Drawing.Size(818, 393);
|
||||
this.tabPage3.TabIndex = 2;
|
||||
this.tabPage3.Text = "Info Archivo";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage4.Size = new System.Drawing.Size(818, 393);
|
||||
this.tabPage4.TabIndex = 3;
|
||||
this.tabPage4.Text = "Hexadecimal";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
this.ClientSize = new System.Drawing.Size(826, 501);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Controls.Add(this.output);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MinimumSize = new System.Drawing.Size(810, 250);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
|
||||
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage1.PerformLayout();
|
||||
this.groupBanner.ResumeLayout(false);
|
||||
this.groupBanner.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picIcon)).EndInit();
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListBox output;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private System.Windows.Forms.TabPage tabPage3;
|
||||
private System.Windows.Forms.TextBox textURL;
|
||||
private System.Windows.Forms.Button btnOpen;
|
||||
private System.Windows.Forms.ListView listInfo;
|
||||
private System.Windows.Forms.ColumnHeader columnCampo;
|
||||
private System.Windows.Forms.ColumnHeader columnValor;
|
||||
private System.Windows.Forms.ColumnHeader columnPosicion;
|
||||
private System.Windows.Forms.TreeView treeSystem;
|
||||
private System.Windows.Forms.ImageList iconos;
|
||||
private System.Windows.Forms.GroupBox groupBanner;
|
||||
private System.Windows.Forms.TextBox txtBannerTitle;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.PictureBox picIcon;
|
||||
private System.Windows.Forms.TextBox txtBannerReserved;
|
||||
private System.Windows.Forms.TextBox txtBannerCRC;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox txtBannerVer;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ComboBox comboBannerLang;
|
||||
private System.Windows.Forms.Button btnBannerGuardar;
|
||||
private System.Windows.Forms.ListView listFile;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private System.Windows.Forms.Button btnHex;
|
||||
private System.Windows.Forms.TabPage tabPage4;
|
||||
private System.Windows.Forms.Button btnSee;
|
||||
protected internal System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.Button btnUncompress;
|
||||
private System.Windows.Forms.Button btnExtraer;
|
||||
private System.Windows.Forms.Button btnDeleteChain;
|
||||
|
||||
}
|
||||
}
|
||||
|
491
Tinke/Form1.cs
Normal file
491
Tinke/Form1.cs
Normal file
@ -0,0 +1,491 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace Tinke
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
Acciones accion;
|
||||
StringBuilder sb;
|
||||
string file;
|
||||
string[] titles;
|
||||
DatosHex hexadecimal;
|
||||
List<String> FoldersToDelete;
|
||||
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = "Tinke V " + Application.ProductVersion + " - NDScene" + new string(' ', 150) +"by pleoNeX";
|
||||
listInfo.Enabled = false;
|
||||
|
||||
sb = new StringBuilder();
|
||||
TextWriter tw = new StringWriter(sb);
|
||||
Console.SetOut(tw);
|
||||
titles = new string[6];
|
||||
hexadecimal = new DatosHex();
|
||||
hexadecimal.Dock = DockStyle.Fill;
|
||||
tabControl1.TabPages[3].Controls.Add(hexadecimal);
|
||||
FoldersToDelete = new List<string>();
|
||||
}
|
||||
public Form1(string file, int id)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = "Tinke V " + Application.ProductVersion + " - NDScene" + new string(' ', 150) + "by pleoNeX";
|
||||
listInfo.Enabled = false;
|
||||
|
||||
sb = new StringBuilder();
|
||||
TextWriter tw = new StringWriter(sb);
|
||||
Console.SetOut(tw);
|
||||
titles = new string[6];
|
||||
hexadecimal = new DatosHex();
|
||||
hexadecimal.Dock = DockStyle.Fill;
|
||||
tabControl1.TabPages[3].Controls.Add(hexadecimal);
|
||||
FoldersToDelete = new List<string>();
|
||||
|
||||
//DEBUG:
|
||||
this.file = file;
|
||||
HeaderROM(file);
|
||||
accion.IDSelect = id;
|
||||
tabControl1.TabPages[2].Controls.Add(accion.See_File());
|
||||
tabControl1.SelectedTab = tabControl1.TabPages[2];
|
||||
}
|
||||
|
||||
|
||||
private void HeaderROM(string file)
|
||||
{
|
||||
Nitro.Estructuras.ROMHeader nds;
|
||||
try { nds = Nitro.NDS.LeerCabecera(file); }
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("No se puedo leer el archivo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Console.WriteLine("Error al intentar leer el archivo: " + file);
|
||||
return;
|
||||
}
|
||||
|
||||
listInfo.Items[0].SubItems.Add(new String(nds.gameTitle));
|
||||
listInfo.Items[1].SubItems.Add(new string(nds.gameCode));
|
||||
listInfo.Items[2].SubItems.Add(Nitro.NDS.CodeToString(Nitro.Makercode.Nintendo.GetType(), nds.makerCode));
|
||||
listInfo.Items[3].SubItems.Add(Nitro.NDS.CodeToString(Nitro.Unitcode.NintendoDS.GetType(), nds.unitCode));
|
||||
listInfo.Items[4].SubItems.Add(Convert.ToString(nds.encryptionSeed));
|
||||
listInfo.Items[5].SubItems.Add((nds.tamaño / 8388608).ToString() + " MB");
|
||||
listInfo.Items[6].SubItems.Add(Tools.Helper.BytesToHexString(nds.reserved));
|
||||
listInfo.Items[7].SubItems.Add(Convert.ToString(nds.ROMversion));
|
||||
listInfo.Items[8].SubItems.Add(Convert.ToString(nds.internalFlags));
|
||||
listInfo.Items[9].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM9romOffset));
|
||||
listInfo.Items[10].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM9entryAddress));
|
||||
listInfo.Items[11].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM9ramAddress));
|
||||
listInfo.Items[12].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM9size) + " bytes");
|
||||
listInfo.Items[13].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM7romOffset));
|
||||
listInfo.Items[14].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM7entryAddress));
|
||||
listInfo.Items[15].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM7ramAddress));
|
||||
listInfo.Items[16].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM7size) + " bytes");
|
||||
listInfo.Items[17].SubItems.Add("0x" + String.Format("{0:X}", nds.fileNameTableOffset));
|
||||
listInfo.Items[18].SubItems.Add("0x" + String.Format("{0:X}", nds.fileNameTableSize) + " bytes");
|
||||
listInfo.Items[19].SubItems.Add("0x" + String.Format("{0:X}", nds.FAToffset));
|
||||
listInfo.Items[20].SubItems.Add("0x" + String.Format("{0:X}", nds.FATsize) + " bytes");
|
||||
listInfo.Items[21].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM9overlayOffset));
|
||||
listInfo.Items[22].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM9overlaySize) + " bytes");
|
||||
listInfo.Items[23].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM7overlayOffset));
|
||||
listInfo.Items[24].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM7overlaySize) + " bytes");
|
||||
listInfo.Items[25].SubItems.Add(Convert.ToString(nds.flagsRead, 2));
|
||||
listInfo.Items[26].SubItems.Add(Convert.ToString(nds.flagsInit, 2));
|
||||
listInfo.Items[27].SubItems.Add("0x" + String.Format("{0:X}", nds.bannerOffset));
|
||||
listInfo.Items[28].SubItems.Add(nds.secureCRC16.ToString() + " (" + Convert.ToString(nds.secureCRC) + ")");
|
||||
listInfo.Items[29].SubItems.Add(nds.ROMtimeout.ToString());
|
||||
listInfo.Items[30].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM9autoload));
|
||||
listInfo.Items[31].SubItems.Add("0x" + String.Format("{0:X}", nds.ARM7autoload));
|
||||
listInfo.Items[32].SubItems.Add(nds.secureDisable.ToString());
|
||||
listInfo.Items[33].SubItems.Add("0x" + String.Format("{0:X}", nds.ROMsize) + " bytes");
|
||||
listInfo.Items[34].SubItems.Add("0x" + String.Format("{0:X}", nds.headerSize) + " bytes");
|
||||
listInfo.Items[35].SubItems.Add(Tools.Helper.BytesToHexString(nds.reserved2));
|
||||
listInfo.Items[36].SubItems.Add(nds.logoCRC16.ToString() + " (" + Convert.ToString(nds.logoCRC) + ")");
|
||||
listInfo.Items[37].SubItems.Add(nds.headerCRC16.ToString() + " (" + Convert.ToString(nds.headerCRC) + ")");
|
||||
|
||||
accion = new Acciones(file, new String(nds.gameCode));
|
||||
BannerROM(file, nds.bannerOffset);
|
||||
Nitro.Estructuras.Folder root = FNT(file, nds.fileNameTableOffset, nds.fileNameTableSize);
|
||||
root.folders[root.folders.Count - 1].files.AddRange(ARMOverlay(file, nds.ARM9overlayOffset, nds.ARM9overlaySize, true));
|
||||
root.folders[root.folders.Count - 1].files.AddRange(ARMOverlay(file, nds.ARM7overlayOffset, nds.ARM7overlaySize, false));
|
||||
root = FAT(file, nds.FAToffset, nds.FATsize, root);
|
||||
|
||||
accion.Root = root;
|
||||
treeSystem.Nodes.Add(Jerarquizar_Nodos(root, root));
|
||||
}
|
||||
private void BannerROM(string file, UInt32 offset)
|
||||
{
|
||||
Nitro.Estructuras.Banner bn = Nitro.NDS.LeerBanner(file, offset);
|
||||
|
||||
picIcon.BorderStyle = BorderStyle.None;
|
||||
picIcon.Image = Nitro.NDS.IconoToBitmap(bn.tileData, bn.palette);
|
||||
|
||||
txtBannerVer.Text = bn.version.ToString();
|
||||
txtBannerCRC.Text = String.Format("{0:X}", bn.CRC16) + " (" + (bn.checkCRC ? "OK)" : "Invalid)");
|
||||
txtBannerReserved.Text = Tools.Helper.BytesToHexString(bn.reserved);
|
||||
|
||||
titles = new string[] { bn.japaneseTitle, bn.englishTitle, bn.frenchTitle, bn.germanTitle, bn.italianTitle, bn.spanishTitle };
|
||||
txtBannerTitle.Text = bn.japaneseTitle;
|
||||
comboBannerLang.SelectedIndex = 0;
|
||||
|
||||
|
||||
textURL.BackColor = Color.LightGreen;
|
||||
}
|
||||
|
||||
private Nitro.Estructuras.Folder FNT(string file, UInt32 offset, UInt32 size)
|
||||
{
|
||||
Nitro.Estructuras.Folder root = Nitro.FNT.LeerFNT(file, offset);
|
||||
accion.Root = root;
|
||||
|
||||
Nitro.Estructuras.File fnt = new Nitro.Estructuras.File();
|
||||
fnt.name = "fnt.bin";
|
||||
fnt.offset = offset;
|
||||
fnt.size = size;
|
||||
//fnt.id = (ushort)accion.LastFileID;
|
||||
accion.LastFileID++;
|
||||
|
||||
if (!(root.folders is List<Nitro.Estructuras.Folder>))
|
||||
root.folders = new List<Nitro.Estructuras.Folder>();
|
||||
Nitro.Estructuras.Folder ftc = new Nitro.Estructuras.Folder();
|
||||
ftc.name = "ftc";
|
||||
ftc.id = (ushort)accion.LastFolderID;
|
||||
accion.LastFolderID++;
|
||||
ftc.files = new List<Nitro.Estructuras.File>();
|
||||
ftc.files.Add(fnt);
|
||||
root.folders.Add(ftc);
|
||||
|
||||
return root;
|
||||
}
|
||||
private TreeNode Jerarquizar_Nodos(Nitro.Estructuras.Folder root, Nitro.Estructuras.Folder currFolder)
|
||||
{
|
||||
TreeNode currNode = new TreeNode();
|
||||
|
||||
currNode = new TreeNode(currFolder.name, 0, 0);
|
||||
currNode.Tag = currFolder.id;
|
||||
currNode.Name = currFolder.name;
|
||||
|
||||
|
||||
if (currFolder.folders is List<Nitro.Estructuras.Folder>)
|
||||
foreach (Nitro.Estructuras.Folder subFolder in currFolder.folders)
|
||||
currNode.Nodes.Add(Jerarquizar_Nodos(root, subFolder));
|
||||
|
||||
|
||||
if (currFolder.files is List<Nitro.Estructuras.File>)
|
||||
{
|
||||
foreach (Nitro.Estructuras.File archivo in currFolder.files)
|
||||
{
|
||||
int nImage = Tipos.ImageFormatFile(accion.Formato(archivo.id));
|
||||
TreeNode fileNode = new TreeNode(archivo.name, nImage, nImage);
|
||||
fileNode.Name = archivo.name;
|
||||
fileNode.Tag = archivo.id;
|
||||
currNode.Nodes.Add(fileNode);
|
||||
}
|
||||
}
|
||||
|
||||
return currNode;
|
||||
}
|
||||
private Nitro.Estructuras.File[] ARMOverlay(string file, UInt32 offset, UInt32 size, bool ARM9)
|
||||
{
|
||||
return Nitro.Overlay.LeerOverlaysBasico(file, offset, size, ARM9);
|
||||
}
|
||||
private Nitro.Estructuras.Folder FAT(string file, UInt32 offset, UInt32 size, Nitro.Estructuras.Folder root)
|
||||
{
|
||||
return Nitro.FAT.LeerFAT(file, offset, size, root);
|
||||
}
|
||||
|
||||
private void btnOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog o = new OpenFileDialog();
|
||||
o.AutoUpgradeEnabled = true;
|
||||
o.CheckFileExists = true;
|
||||
o.DefaultExt = ".nds";
|
||||
if (o.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
// Limpiar posible información anterior
|
||||
if (listInfo.Items[0].SubItems.Count == 3)
|
||||
for (int i = 0; i < listInfo.Items.Count; i++)
|
||||
listInfo.Items[i].SubItems.RemoveAt(2);
|
||||
txtBannerCRC.Text = "";
|
||||
txtBannerReserved.Text = "";
|
||||
txtBannerTitle.Text = "";
|
||||
txtBannerVer.Text = "";
|
||||
picIcon.Image = null;
|
||||
picIcon.BorderStyle = BorderStyle.FixedSingle;
|
||||
treeSystem.Nodes.Clear();
|
||||
tabControl1.TabPages[2].Controls.Clear();
|
||||
hexadecimal.Clear();
|
||||
|
||||
file = o.FileName;
|
||||
textURL.Text = o.FileName;
|
||||
o.Dispose();
|
||||
|
||||
textURL.BackColor = Color.Red;
|
||||
listInfo.Enabled = true;
|
||||
|
||||
System.Threading.Thread espera = new System.Threading.Thread(ThreadEspera);
|
||||
espera.Start();
|
||||
|
||||
HeaderROM(file);
|
||||
|
||||
espera.Abort();
|
||||
}
|
||||
|
||||
output.Items.AddRange(sb.ToString().Split("\n".ToCharArray()));
|
||||
sb.Clear();
|
||||
}
|
||||
private void ThreadEspera()
|
||||
{
|
||||
Espera espera = new Espera("Cargando sistema de archivos...", false);
|
||||
espera.ShowDialog();
|
||||
}
|
||||
private void btnBannerGuardar_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog o = new SaveFileDialog();
|
||||
o.AddExtension = true;
|
||||
o.AutoUpgradeEnabled = true;
|
||||
o.CheckPathExists = true;
|
||||
o.DefaultExt = ".bmp";
|
||||
o.OverwritePrompt = true;
|
||||
o.Filter = "Imagen Bitmap (*.bmp)|*.bmp";
|
||||
if (o.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
picIcon.Image.Save(o.FileName);
|
||||
}
|
||||
private void comboBannerLang_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBannerLang.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
txtBannerTitle.Text = titles[0];
|
||||
break;
|
||||
case 1:
|
||||
txtBannerTitle.Text = titles[1];
|
||||
break;
|
||||
case 2:
|
||||
txtBannerTitle.Text = titles[2];
|
||||
break;
|
||||
case 3:
|
||||
txtBannerTitle.Text = titles[3];
|
||||
break;
|
||||
case 4:
|
||||
txtBannerTitle.Text = titles[4];
|
||||
break;
|
||||
case 5:
|
||||
txtBannerTitle.Text = titles[5];
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void Form1_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
textURL.Width = this.Width - 115;
|
||||
btnOpen.Location = new Point(this.Width - 103, 5);
|
||||
listInfo.Height = this.Height - 190;
|
||||
listInfo.Width = this.Width - 304;
|
||||
treeSystem.Height = this.Height - 190;
|
||||
treeSystem.Width = this.Width - 304;
|
||||
listFile.Location = new Point(this.Width - 240, 0);
|
||||
groupBanner.Location = new Point(this.Width - 295, 42);
|
||||
groupBanner.Height = this.Height - 190;
|
||||
|
||||
if (this.Width < 1089)
|
||||
this.Text = "Tinke V " + Application.ProductVersion + " - NDScene" + new string(' ', (int)((this.Width - 842) / (3.5)) + 150) + "by pleoNeX";
|
||||
else
|
||||
this.Text = "Tinke V " + Application.ProductVersion + " - NDScene" + new string(' ', 220) + "by pleoNeX";
|
||||
}
|
||||
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
foreach (string folder in FoldersToDelete)
|
||||
Directory.Delete(folder, true);
|
||||
}
|
||||
|
||||
private void treeSystem_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
accion.IDSelect = Convert.ToInt32(e.Node.Tag);
|
||||
// Limpiar información anterior
|
||||
if (listFile.Items[0].SubItems.Count == 2)
|
||||
for (int i = 0; i < listFile.Items.Count; i++)
|
||||
listFile.Items[i].SubItems.RemoveAt(1);
|
||||
|
||||
if (e.Node.Name == "root")
|
||||
{
|
||||
listFile.Items[0].SubItems.Add("root");
|
||||
listFile.Items[1].SubItems.Add("0xF000");
|
||||
listFile.Items[2].SubItems.Add("");
|
||||
listFile.Items[3].SubItems.Add("");
|
||||
listFile.Items[4].SubItems.Add("Directorio");
|
||||
|
||||
btnHex.Enabled = false;
|
||||
btnSee.Enabled = false;
|
||||
btnUncompress.Enabled = false;
|
||||
btnExtraer.Enabled = false;
|
||||
hexadecimal.Clear();
|
||||
}
|
||||
else if (Convert.ToUInt16(e.Node.Tag) < 0xF000)
|
||||
{
|
||||
Nitro.Estructuras.File selectFile = accion.Select_File();
|
||||
|
||||
listFile.Items[0].SubItems.Add(selectFile.name);
|
||||
listFile.Items[1].SubItems.Add(selectFile.id.ToString());
|
||||
listFile.Items[2].SubItems.Add("0x" + String.Format("{0:X}", selectFile.offset));
|
||||
listFile.Items[3].SubItems.Add(selectFile.size.ToString());
|
||||
listFile.Items[4].SubItems.Add(accion.Formato().ToString());
|
||||
btnHex.Enabled = true;
|
||||
btnExtraer.Enabled = true;
|
||||
|
||||
Tipos.Role tipo = accion.Formato();
|
||||
if (tipo != Tipos.Role.Desconocido && !Tipos.EstaComprimido(tipo))
|
||||
btnSee.Enabled = true;
|
||||
else
|
||||
btnSee.Enabled = false;
|
||||
if (!Tipos.EstaComprimido(tipo))
|
||||
btnUncompress.Enabled = false;
|
||||
else
|
||||
btnUncompress.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Nitro.Estructuras.Folder selectFolder = accion.Select_Folder();
|
||||
|
||||
listFile.Items[0].SubItems.Add(selectFolder.name);
|
||||
listFile.Items[1].SubItems.Add("0x" + String.Format("{0:X}", selectFolder.id));
|
||||
listFile.Items[2].SubItems.Add("");
|
||||
listFile.Items[3].SubItems.Add("");
|
||||
listFile.Items[4].SubItems.Add("Directorio");
|
||||
|
||||
btnHex.Enabled = false;
|
||||
btnSee.Enabled = false;
|
||||
btnUncompress.Enabled = false;
|
||||
btnExtraer.Enabled = false;
|
||||
hexadecimal.Clear();
|
||||
}
|
||||
}
|
||||
private void btnHex_Click(object sender, EventArgs e)
|
||||
{
|
||||
Nitro.Estructuras.File fileSelect = accion.Select_File();
|
||||
if (fileSelect.offset != 0x0)
|
||||
hexadecimal.LeerFile(file, fileSelect.offset, fileSelect.size);
|
||||
else
|
||||
hexadecimal.LeerFile(fileSelect.path, 0, fileSelect.size);
|
||||
tabControl1.SelectedTab = tabControl1.TabPages[3];
|
||||
}
|
||||
private void BtnSee(object sender, EventArgs e)
|
||||
{
|
||||
tabControl1.TabPages[2].Controls.Clear();
|
||||
try
|
||||
{
|
||||
tabControl1.TabPages[2].Controls.Add(accion.See_File());
|
||||
tabControl1.SelectedTab = tabControl1.TabPages[2];
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("No se pudo visualizar este fichero. Formato erróneo");
|
||||
output.Items.Add("No se pudo visualizar este fichero. Formato erróneo");
|
||||
}
|
||||
|
||||
}
|
||||
private void btnUncompress_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Se crea una carpeta temporal donde almacenar los archivos de salida.
|
||||
int n = 0;
|
||||
string[] subFolders = Directory.GetDirectories(Application.StartupPath);
|
||||
for (; ; n++)
|
||||
if (!subFolders.Contains<string>(Application.StartupPath + "\\Temp" + n))
|
||||
break;
|
||||
|
||||
Directory.CreateDirectory(Application.StartupPath + "\\Temp" + n);
|
||||
FoldersToDelete.Add(Application.StartupPath + "\\Temp" + n);
|
||||
|
||||
// Guardamos el archivo para descomprimir fuera del sistema de ROM
|
||||
string tempFile = Application.StartupPath + "\\temp.dat";
|
||||
Nitro.Estructuras.File selectFile = accion.Select_File();
|
||||
BinaryReader br;
|
||||
if (selectFile.offset != 0x0)
|
||||
{
|
||||
br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = selectFile.offset;
|
||||
}
|
||||
else
|
||||
br = new BinaryReader(File.OpenRead(selectFile.path));
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(tempFile, FileMode.Create));
|
||||
bw.Write(br.ReadBytes((int)selectFile.size));
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
bw.Dispose();
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
// Determinado el tipo de compresión y descomprimimos
|
||||
Tipos.Role tipo = accion.Formato();
|
||||
|
||||
if (tipo == Tipos.Role.Comprimido_NARC)
|
||||
Compresion.NARC.Descomprimir(tempFile, Application.StartupPath + "\\Temp" + n);
|
||||
else if (tipo == Tipos.Role.Comprimido_LZ77 || tipo == Tipos.Role.Comprimido_Huffman)
|
||||
Compresion.Basico.Decompress(tempFile, Application.StartupPath + "\\Temp" + n);
|
||||
List<Nitro.Estructuras.File> files = new List<Nitro.Estructuras.File>();
|
||||
|
||||
// Se añaden los archivos descomprimidos al árbol de archivos.
|
||||
foreach (string file in Directory.GetFiles(Application.StartupPath + "\\Temp" + n))
|
||||
{
|
||||
Nitro.Estructuras.File currFile = new Nitro.Estructuras.File();
|
||||
currFile.name = new FileInfo(file).Name;
|
||||
currFile.path = file;
|
||||
currFile.size = (uint)new FileInfo(file).Length;
|
||||
files.Add(currFile);
|
||||
}
|
||||
|
||||
accion.Add_Files(files);
|
||||
|
||||
treeSystem.Nodes.Clear();
|
||||
treeSystem.Nodes.Add(Jerarquizar_Nodos(accion.Root, accion.Root));
|
||||
}
|
||||
private void btnExtraer_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog o = new SaveFileDialog();
|
||||
if (o.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
Nitro.Estructuras.File fileSelect = accion.Select_File();
|
||||
if (fileSelect.offset != 0x0)
|
||||
{
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = fileSelect.offset;
|
||||
File.WriteAllBytes(o.FileName, br.ReadBytes((int)fileSelect.size));
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
}
|
||||
else
|
||||
File.Copy(fileSelect.path, o.FileName);
|
||||
}
|
||||
}
|
||||
private void btnDeleteChain_Click(object sender, EventArgs e)
|
||||
{
|
||||
accion.Delete_PicturesSaved();
|
||||
}
|
||||
private void treeSystem_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
try // No sé cuando pero hay veces en el que con un ID de archivo está seleccionada una carpeta y salta una excepción.
|
||||
{
|
||||
if (accion.IDSelect < 0xF000) // Comprobación de que la selección no sea un directorio
|
||||
{
|
||||
Tipos.Role tipo = accion.Formato();
|
||||
if (tipo == Tipos.Role.Paleta || tipo == Tipos.Role.Imagen || tipo == Tipos.Role.Screen)
|
||||
accion.Set_Data(accion.Select_File());
|
||||
|
||||
// Incluye información de DEBUG.
|
||||
output.Items.AddRange(sb.ToString().Split("\n".ToCharArray()));
|
||||
sb.Clear();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
output.Items.Add("Excepción en treeSystem_MouseDoubleClick: id de archivo seleccionado " + accion.IDSelect.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
7041
Tinke/Form1.resx
Normal file
7041
Tinke/Form1.resx
Normal file
File diff suppressed because it is too large
Load Diff
34
Tinke/Imagen/Estructuras.cs
Normal file
34
Tinke/Imagen/Estructuras.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tinke.Imagen
|
||||
{
|
||||
public struct NTFP // Nintendo Tile Format Palette
|
||||
{
|
||||
public Color[] colores;
|
||||
}
|
||||
public struct NTFT // Nintendo Tile Format Tile
|
||||
{
|
||||
public byte[][] tiles;
|
||||
}
|
||||
public struct NTFS // Nintedo Tile Format Screen
|
||||
{
|
||||
public byte nPalette; // Junto con los cuatro siguientes forman dos bytes de la siguiente forma (en bits):
|
||||
public byte xFlip; // PPPP X Y NNNNNNNNNN
|
||||
public byte yFlip;
|
||||
public ushort nTile;
|
||||
}
|
||||
|
||||
public enum Tiles_Form
|
||||
{
|
||||
bpp8 = 0,
|
||||
bpp4 = 1
|
||||
}
|
||||
public enum Tiles_Style
|
||||
{
|
||||
Tiled,
|
||||
Horizontal,
|
||||
Vertical
|
||||
}
|
||||
}
|
65
Tinke/Imagen/Paleta/Convertidor.cs
Normal file
65
Tinke/Imagen/Paleta/Convertidor.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Tinke.Imagen.Paleta
|
||||
{
|
||||
public static class Convertidor
|
||||
{
|
||||
/// <summary>
|
||||
/// A partir de un array de bytes devuelve un array de colores.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Bytes para convertir</param>
|
||||
/// <returns>Colores de la paleta.</returns>
|
||||
public static Color[] BGR555(byte[] bytes)
|
||||
{
|
||||
Color[] paleta = new Color[bytes.Length / 2];
|
||||
|
||||
for (int i = 0; i < bytes.Length / 2; i++)
|
||||
{
|
||||
paleta[i] = BGR555(bytes[i * 2], bytes[i * 2 + 1]);
|
||||
}
|
||||
return paleta;
|
||||
}
|
||||
/// <summary>
|
||||
/// Convierte dos bytes en un color.
|
||||
/// </summary>
|
||||
/// <param name="byte1">Primer byte</param>
|
||||
/// <param name="byte2">Segundo byte</param>
|
||||
/// <returns>Color convertido</returns>
|
||||
public static Color BGR555(byte byte1, byte byte2)
|
||||
{
|
||||
int r, b; double g;
|
||||
|
||||
r = (byte1 % 0x20) * 0x8;
|
||||
g = (byte1 / 0x20 + ((byte2 % 0x4) * 7.96875)) * 0x8;
|
||||
b = byte2 / 0x4 * 0x8;
|
||||
|
||||
return System.Drawing.Color.FromArgb(r, (int)g, b);
|
||||
}
|
||||
|
||||
public static Bitmap ColoresToImage(Color[] colores)
|
||||
{
|
||||
Bitmap imagen = new Bitmap(160, (int)(colores.Length / 16));
|
||||
bool fin = false;
|
||||
|
||||
for (int i = 0; i < 16 & !fin; i++)
|
||||
{
|
||||
for (int j = 0; j < 16 & !fin; j++)
|
||||
{
|
||||
for (int k = 0; k < 10 & !fin; k++)
|
||||
{
|
||||
for (int q = 0; q < 10; q++)
|
||||
{
|
||||
try { imagen.SetPixel(j * 10 + q, i * 10 + k, colores[j + 16 * i]); }
|
||||
catch { fin = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return imagen;
|
||||
}
|
||||
}
|
||||
}
|
35
Tinke/Imagen/Paleta/Estructuras.cs
Normal file
35
Tinke/Imagen/Paleta/Estructuras.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Tinke.Imagen.Paleta
|
||||
{
|
||||
public static class Estructuras
|
||||
{
|
||||
public struct NCLR
|
||||
{
|
||||
public char[] ID;
|
||||
public UInt16 endianness; // 0xFEFF
|
||||
public UInt16 constante;
|
||||
public UInt32 tamaño; // Incluye lo anterior
|
||||
public UInt32 tamañoCabecera; // Suele ser 0x10
|
||||
public UInt16 nSecciones;
|
||||
public TTLP pltt;
|
||||
}
|
||||
public struct TTLP
|
||||
{
|
||||
public char[] ID;
|
||||
public UInt32 tamaño; // Incluye cabecera
|
||||
public Depth profundidad;
|
||||
public UInt32 constante; // Siempre 0x00000000
|
||||
public UInt32 tamañoPaletas;
|
||||
public UInt32 nColores; // Suele ser 0x10
|
||||
public NTFP[] paletas;
|
||||
}
|
||||
}
|
||||
public enum Depth
|
||||
{
|
||||
bits4,
|
||||
bits8
|
||||
|
||||
}
|
||||
}
|
134
Tinke/Imagen/Paleta/NCLR.cs
Normal file
134
Tinke/Imagen/Paleta/NCLR.cs
Normal file
@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tinke.Imagen.Paleta
|
||||
{
|
||||
public static class NCLR
|
||||
{
|
||||
public static Estructuras.NCLR Leer(string file)
|
||||
{
|
||||
Estructuras.NCLR nclr = new Estructuras.NCLR();
|
||||
FileStream fs = File.OpenRead(file);
|
||||
BinaryReader br = new BinaryReader(fs);
|
||||
Console.WriteLine("Analizando paleta NCLR: " + new FileInfo(file).Name);
|
||||
|
||||
nclr.ID = br.ReadChars(4);
|
||||
nclr.endianness = br.ReadUInt16();
|
||||
if (nclr.endianness == 0xFFFE)
|
||||
nclr.ID.Reverse<char>();
|
||||
nclr.constante = br.ReadUInt16();
|
||||
nclr.tamaño = br.ReadUInt32();
|
||||
nclr.tamañoCabecera = br.ReadUInt16();
|
||||
if (nclr.tamañoCabecera != 0x10)
|
||||
Console.WriteLine("\tEl tamaño de la cabecera No es 0x10: " + nclr.tamañoCabecera.ToString());
|
||||
nclr.nSecciones = br.ReadUInt16();
|
||||
if (nclr.nSecciones < 1 || nclr.nSecciones > 2)
|
||||
Console.WriteLine("\tNo hay secciones o hay de más ¿?: " + nclr.nSecciones.ToString());
|
||||
br.BaseStream.Position = nclr.tamañoCabecera;
|
||||
char[] ID = br.ReadChars(4);
|
||||
if (new String(ID) == "PLTT" || new String(ID) == "TTLP")
|
||||
nclr.pltt = Seccion_PLTT(ref br);
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
fs.Dispose();
|
||||
return nclr;
|
||||
}
|
||||
public static Estructuras.TTLP Seccion_PLTT(ref BinaryReader br)
|
||||
{
|
||||
Estructuras.TTLP pltt = new Estructuras.TTLP();
|
||||
long posIni = br.BaseStream.Position;
|
||||
|
||||
pltt.ID = "PLTT".ToCharArray();
|
||||
pltt.tamaño = br.ReadUInt32();
|
||||
pltt.profundidad = (br.ReadUInt32() == 0x00000003) ? Depth.bits4 : Depth.bits8;
|
||||
pltt.constante = br.ReadUInt32();
|
||||
if (pltt.constante != 0x0) Console.WriteLine("\tLa constante PLTT errónea: " + pltt.constante.ToString());
|
||||
pltt.tamañoPaletas = br.ReadUInt32();
|
||||
pltt.nColores = br.ReadUInt32();
|
||||
pltt.paletas = new NTFP[(pltt.tamaño - 0x18) / (pltt.nColores * 2)];
|
||||
Console.WriteLine("\t" + pltt.paletas.Length + " paletas encontradas.");
|
||||
|
||||
for (int i = 0; i < pltt.paletas.Length; i++)
|
||||
{
|
||||
pltt.paletas[i] = Paleta_NTFP(ref br, pltt.nColores);
|
||||
}
|
||||
|
||||
return pltt;
|
||||
}
|
||||
public static NTFP Paleta_NTFP(ref BinaryReader br, UInt32 colores)
|
||||
{
|
||||
NTFP ntfp = new NTFP();
|
||||
|
||||
ntfp.colores = Convertidor.BGR555(br.ReadBytes((int)colores * 2));
|
||||
|
||||
return ntfp;
|
||||
}
|
||||
|
||||
public static Bitmap Mostrar(string file)
|
||||
{
|
||||
Estructuras.NCLR nclr = Leer(file);
|
||||
|
||||
Bitmap imagen = new Bitmap((int)nclr.pltt.nColores * 10, nclr.pltt.paletas.Length * 10);
|
||||
for (int b = 0; b < nclr.pltt.paletas.Length; b++)
|
||||
{
|
||||
Color[] colores = new Color[nclr.pltt.paletas.Length * nclr.pltt.nColores];
|
||||
for (int j = 0; j < nclr.pltt.paletas.Length; j++)
|
||||
for (int i = 0; i < nclr.pltt.nColores; i++)
|
||||
colores[i + j * nclr.pltt.nColores] = nclr.pltt.paletas[j].colores[i];
|
||||
|
||||
bool fin = false;
|
||||
|
||||
for (int i = 0; i < 16 & !fin; i++)
|
||||
{
|
||||
for (int j = 0; j < 16 & !fin; j++)
|
||||
{
|
||||
for (int k = 0; k < 10 & !fin; k++)
|
||||
{
|
||||
for (int q = 0; q < 10; q++)
|
||||
{
|
||||
try { imagen.SetPixel(j * 10 + q, i * 10 + k, colores[j + 16 * i]); }
|
||||
catch { fin = true; imagen.SetPixel(j * 10, i * 10 + q, Color.White); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return imagen;
|
||||
}
|
||||
public static Bitmap Mostrar(Estructuras.NCLR nclr)
|
||||
{
|
||||
Bitmap imagen = new Bitmap((int)nclr.pltt.nColores * 10, nclr.pltt.paletas.Length * 10);
|
||||
for (int b = 0; b < nclr.pltt.paletas.Length; b++)
|
||||
{
|
||||
Color[] colores = new Color[nclr.pltt.paletas.Length * nclr.pltt.nColores];
|
||||
for (int j = 0; j < nclr.pltt.paletas.Length; j++)
|
||||
for (int i = 0; i < nclr.pltt.nColores; i++)
|
||||
colores[i + j * nclr.pltt.nColores] = nclr.pltt.paletas[j].colores[i];
|
||||
|
||||
bool fin = false;
|
||||
|
||||
for (int i = 0; i < 16 & !fin; i++)
|
||||
{
|
||||
for (int j = 0; j < 16 & !fin; j++)
|
||||
{
|
||||
for (int k = 0; k < 10 & !fin; k++)
|
||||
{
|
||||
for (int q = 0; q < 10; q++)
|
||||
{
|
||||
try { imagen.SetPixel(j * 10 + q, i * 10 + k, colores[j + 16 * i]); }
|
||||
catch { fin = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return imagen;
|
||||
}
|
||||
}
|
||||
}
|
19
Tinke/Imagen/Paleta/Notas.txt
Normal file
19
Tinke/Imagen/Paleta/Notas.txt
Normal file
@ -0,0 +1,19 @@
|
||||
**NCLR (Nintendo Colour)**
|
||||
|
||||
0x0-0x3 => Cabecera (NCLR) (Nintendo Colour?) = 52 4C 43 4E
|
||||
0x4-0x7 => Constante 0x0100FEFF
|
||||
0x8-0xB => Tamaño total, incluye lo anterior
|
||||
0xC-0xD => Tamaño de cabecera (suele ser 0x10)
|
||||
0xE-0xF => Secciones
|
||||
0x10-0x13 => Seccion: PLTT (Palette?)
|
||||
0x14-0x17 => Tamaño de seccion, incluye cabecera
|
||||
0x18-0x1B => si 3=4 bits, si 4=8bits
|
||||
0x1C-0x1F => Constante 0x00000000 ¿Padding?
|
||||
0x20-0x23 => Tamaño de paletas
|
||||
0x24-0x27 => Número de colores por paleta
|
||||
0x28-.... => Comienzo de paletas en formato NTFP
|
||||
|
||||
**NTFP (Nintendo Tile Format Palette)**
|
||||
|
||||
0x0-0x1 => Un color en formato BGR555
|
||||
sucesivamente...
|
31
Tinke/Imagen/Screen/Estructuras.cs
Normal file
31
Tinke/Imagen/Screen/Estructuras.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Tinke.Imagen.Screen
|
||||
{
|
||||
public static class Estructuras
|
||||
{
|
||||
public struct NSCR
|
||||
{
|
||||
public char[] id; // RCSN = 0x5243534E
|
||||
public UInt16 endianess; // 0xFFFE -> indica little endian
|
||||
public UInt16 constant; // Siempre es 0x0100
|
||||
public UInt32 file_size; // Tamaño total del archivo
|
||||
public UInt16 header_size; // Siempre es 0x10
|
||||
public UInt16 nSection; // Número de secciones
|
||||
public NSCR_Section section; // Sección NSCR
|
||||
}
|
||||
public struct NSCR_Section
|
||||
{
|
||||
public char[] id; // NRCS = 0x4E524353
|
||||
public UInt32 section_size; // Tamaño del archivo total
|
||||
public UInt16 width; // Ancho de la imagen
|
||||
public UInt16 height; // Alto de la imagen
|
||||
public UInt32 padding; // Siempre 0x0
|
||||
public UInt32 data_size; //
|
||||
public Imagen.NTFS[] screenData;
|
||||
}
|
||||
}
|
||||
}
|
148
Tinke/Imagen/Screen/NSCR.cs
Normal file
148
Tinke/Imagen/Screen/NSCR.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace Tinke.Imagen.Screen
|
||||
{
|
||||
public static class NSCR
|
||||
{
|
||||
public static Estructuras.NSCR Leer(string file)
|
||||
{
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
Estructuras.NSCR nscr = new Estructuras.NSCR();
|
||||
|
||||
// Lee cabecera genérica
|
||||
nscr.id = br.ReadChars(4);
|
||||
nscr.endianess = br.ReadUInt16();
|
||||
if (nscr.endianess == 0xFFFE)
|
||||
nscr.id.Reverse<char>();
|
||||
nscr.constant = br.ReadUInt16();
|
||||
nscr.file_size = br.ReadUInt32();
|
||||
nscr.header_size = br.ReadUInt16();
|
||||
nscr.nSection = br.ReadUInt16();
|
||||
|
||||
// Lee primera y única sección:
|
||||
nscr.section.id = br.ReadChars(4);
|
||||
nscr.section.section_size = br.ReadUInt32();
|
||||
nscr.section.width = br.ReadUInt16();
|
||||
nscr.section.height = br.ReadUInt16();
|
||||
nscr.section.padding = br.ReadUInt32();
|
||||
nscr.section.data_size = br.ReadUInt32();
|
||||
nscr.section.screenData = new Imagen.NTFS[nscr.section.data_size / 2];
|
||||
|
||||
for (int i = 0; br.BaseStream.Position < nscr.file_size; i++)
|
||||
{
|
||||
string bits = Tools.Helper.BytesToBits(br.ReadBytes(2));
|
||||
|
||||
nscr.section.screenData[i] = new Imagen.NTFS();
|
||||
nscr.section.screenData[i].nPalette = Convert.ToByte(bits.Substring(0, 4));
|
||||
nscr.section.screenData[i].yFlip = Convert.ToByte(bits.Substring(4, 1));
|
||||
nscr.section.screenData[i].xFlip = Convert.ToByte(bits.Substring(5, 1));
|
||||
nscr.section.screenData[i].nTile = Convert.ToUInt16(bits.Substring(6, 10), 2);
|
||||
}
|
||||
|
||||
br.Dispose();
|
||||
br.Close();
|
||||
return nscr;
|
||||
}
|
||||
public static Estructuras.NSCR Leer_NoCabecera(string file, Int64 offset)
|
||||
{
|
||||
// Se omite toda la cabecera común más:
|
||||
// ID de sección + tamaño de cabecera + tamaño de sección + padding + tamaño de los datos
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = offset;
|
||||
Estructuras.NSCR nscr = new Estructuras.NSCR();
|
||||
|
||||
// Datos por defecto
|
||||
nscr.id = "NSCR".ToCharArray();
|
||||
nscr.endianess = 0xFEFF;
|
||||
nscr.constant = 0x0100;
|
||||
nscr.header_size = 0x10;
|
||||
nscr.nSection = 1;
|
||||
nscr.section.id = "NSCR".ToCharArray();
|
||||
nscr.section.padding = 0x0;
|
||||
|
||||
nscr.section.width = br.ReadUInt16();
|
||||
nscr.section.height = br.ReadUInt16();
|
||||
nscr.section.screenData = new Imagen.NTFS[nscr.section.width * nscr.section.height];
|
||||
|
||||
for (int i = 0; i < (nscr.section.height * nscr.section.width); i++)
|
||||
{
|
||||
string bits = Tools.Helper.BytesToBits(br.ReadBytes(2));
|
||||
|
||||
nscr.section.screenData[i] = new Imagen.NTFS();
|
||||
nscr.section.screenData[i].nPalette = Convert.ToByte(bits.Substring(0, 4));
|
||||
nscr.section.screenData[i].xFlip = Convert.ToByte(bits.Substring(4, 1));
|
||||
nscr.section.screenData[i].yFlip = Convert.ToByte(bits.Substring(5, 1));
|
||||
nscr.section.screenData[i].nTile = Convert.ToUInt16(bits.Substring(6, 10), 2);
|
||||
}
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return nscr;
|
||||
}
|
||||
|
||||
|
||||
public static Byte[][] Modificar_Tile(Estructuras.NSCR nscr, byte[][] tileData)
|
||||
{
|
||||
List<Byte[]> bytes = new List<byte[]>();
|
||||
int j = 0;
|
||||
|
||||
for (int i = 0; i < nscr.section.screenData.Length; i++)
|
||||
{
|
||||
byte[] currTile;
|
||||
if (nscr.section.screenData[i].nTile == j)
|
||||
{
|
||||
currTile = tileData[j];
|
||||
j++;
|
||||
}
|
||||
else
|
||||
currTile = tileData[nscr.section.screenData[i].nTile];
|
||||
|
||||
// TODO: no funciona bien los xFlip e yFlip
|
||||
if (nscr.section.screenData[i].xFlip == 1)
|
||||
currTile = XFlip(currTile);
|
||||
if (nscr.section.screenData[i].yFlip == 1)
|
||||
currTile = YFlip(currTile);
|
||||
|
||||
bytes.Add(currTile);
|
||||
}
|
||||
|
||||
return bytes.ToArray();
|
||||
}
|
||||
public static Byte[] XFlip(Byte[] tile)
|
||||
{
|
||||
for (int h = 0; h < 8; h++)
|
||||
{
|
||||
for (int w = 0; w < 4; w++)
|
||||
{
|
||||
byte color = tile[w + h * 8];
|
||||
tile[w + h * 8] = tile[(7 - w) + h * 8];
|
||||
tile[(7 - w) + h * 8] = color;
|
||||
}
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
public static Byte[] YFlip(Byte[] tile)
|
||||
{
|
||||
for (int h = 0; h < 4; h++)
|
||||
{
|
||||
for (int w = 0; w < 8; w++)
|
||||
{
|
||||
Byte color = tile[w + h * 8];
|
||||
tile[w + h * 8] = tile[w + (7 - h) * 8];
|
||||
tile[w + (7 - h) * 8] = color;
|
||||
}
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
45
Tinke/Imagen/Tile/Estructuras.cs
Normal file
45
Tinke/Imagen/Tile/Estructuras.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Tinke.Imagen.Tile
|
||||
{
|
||||
public static class Estructuras
|
||||
{
|
||||
public struct NCGR
|
||||
{
|
||||
public char[] id;
|
||||
public UInt16 id_endian;
|
||||
public UInt16 constant;
|
||||
public UInt32 size_file;
|
||||
public UInt16 size_header;
|
||||
public UInt16 nSections;
|
||||
public RAHC rahc;
|
||||
public SOPC sopc;
|
||||
}
|
||||
public struct RAHC
|
||||
{
|
||||
public char[] id; // Siempre RAHC = 0x52414843
|
||||
public UInt32 size_section;
|
||||
public UInt16 nTilesY;
|
||||
public UInt16 nTilesX;
|
||||
public Imagen.Tiles_Form depth;
|
||||
public UInt32 unknown1;
|
||||
public UInt32 unknown2;
|
||||
public UInt32 size_tiledata;
|
||||
public UInt32 unknown3; // Constante siempre 0x18 (24)
|
||||
public Imagen.NTFT tileData;
|
||||
|
||||
public UInt16 nTiles; // Campo propio para operaciones más fáciles, resultado de nTilesX * nTilesY ó size_Tiledata / 64
|
||||
}
|
||||
public struct SOPC
|
||||
{
|
||||
public char[] id;
|
||||
public UInt32 size_section;
|
||||
public UInt32 unknown1;
|
||||
public UInt16 nTilesX;
|
||||
public UInt16 nTilesY;
|
||||
}
|
||||
}
|
||||
}
|
162
Tinke/Imagen/Tile/NCGR.cs
Normal file
162
Tinke/Imagen/Tile/NCGR.cs
Normal file
@ -0,0 +1,162 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Tinke.Imagen.Tile
|
||||
{
|
||||
public static class NCGR
|
||||
{
|
||||
public static Estructuras.NCGR Leer(string file)
|
||||
{
|
||||
Estructuras.NCGR ncgr = new Estructuras.NCGR();
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
|
||||
// Lee cabecera genérica
|
||||
ncgr.id = br.ReadChars(4);
|
||||
ncgr.id_endian = br.ReadUInt16();
|
||||
if (ncgr.id_endian == 0xFFFE)
|
||||
ncgr.id.Reverse<char>();
|
||||
ncgr.constant = br.ReadUInt16();
|
||||
ncgr.size_file = br.ReadUInt32();
|
||||
ncgr.size_header = br.ReadUInt16();
|
||||
ncgr.nSections = br.ReadUInt16();
|
||||
|
||||
// Lee primera sección CHAR (CHARacter data)
|
||||
ncgr.rahc.id = br.ReadChars(4);
|
||||
ncgr.rahc.size_section = br.ReadUInt32();
|
||||
ncgr.rahc.nTilesY = br.ReadUInt16();
|
||||
ncgr.rahc.nTilesX = br.ReadUInt16();
|
||||
ncgr.rahc.depth = (br.ReadUInt32() == 0x3 ? Tiles_Form.bpp4 : Tiles_Form.bpp8);
|
||||
ncgr.rahc.unknown1 = br.ReadUInt32();
|
||||
ncgr.rahc.unknown2 = br.ReadUInt32();
|
||||
ncgr.rahc.size_tiledata = (ncgr.rahc.depth == Tiles_Form.bpp8 ? br.ReadUInt32() : br.ReadUInt32() * 2);
|
||||
ncgr.rahc.unknown3 = br.ReadUInt32();
|
||||
|
||||
ncgr.rahc.nTiles = (ushort)(ncgr.rahc.size_tiledata / 64);
|
||||
ncgr.rahc.tileData.tiles = new byte[ncgr.rahc.nTiles][];
|
||||
|
||||
for (int i = 0; i < ncgr.rahc.nTiles; i++)
|
||||
{
|
||||
if (ncgr.rahc.depth == Tiles_Form.bpp4)
|
||||
ncgr.rahc.tileData.tiles[i] = Tools.Helper.BytesTo4BitsRev(br.ReadBytes(32));
|
||||
else
|
||||
ncgr.rahc.tileData.tiles[i] = br.ReadBytes(64);
|
||||
}
|
||||
|
||||
if (ncgr.nSections == 1) // En caso de que no haya más secciones
|
||||
{
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
return ncgr;
|
||||
}
|
||||
|
||||
// Lee la segunda sección SOPC
|
||||
ncgr.sopc.id = br.ReadChars(4);
|
||||
ncgr.sopc.size_section = br.ReadUInt32();
|
||||
ncgr.sopc.unknown1 = br.ReadUInt32();
|
||||
ncgr.sopc.nTilesX = br.ReadUInt16();
|
||||
ncgr.sopc.nTilesY = br.ReadUInt16();
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
return ncgr;
|
||||
}
|
||||
public static Estructuras.NCGR Leer_SinCabecera(string file, long offset)
|
||||
{
|
||||
Estructuras.NCGR ncgr = new Estructuras.NCGR();
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = offset;
|
||||
|
||||
// Lee primera sección CHAR (CHARacter data)
|
||||
ncgr.rahc.depth = Tiles_Form.bpp8;
|
||||
ncgr.rahc.size_tiledata = br.ReadUInt32() ;
|
||||
|
||||
ncgr.rahc.nTiles = (ushort)(ncgr.rahc.size_tiledata);
|
||||
ncgr.rahc.tileData.tiles = new byte[ncgr.rahc.nTiles][];
|
||||
|
||||
for (int i = 0; i < ncgr.rahc.nTiles; i++)
|
||||
ncgr.rahc.tileData.tiles[i] = br.ReadBytes(64);
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
return ncgr;
|
||||
}
|
||||
|
||||
public static Bitmap Crear_Imagen(Estructuras.NCGR tile, Imagen.Paleta.Estructuras.NCLR paleta)
|
||||
{
|
||||
if (tile.rahc.nTilesX == 0xFFFF) // En caso de que no venga la información hacemos la imagen de 256x256
|
||||
tile.rahc.nTilesX = 0x20;
|
||||
if (tile.rahc.nTilesY == 0xFFFF)
|
||||
tile.rahc.nTilesY = 0x20;
|
||||
|
||||
Bitmap imagen = new Bitmap(tile.rahc.nTilesX * 8, tile.rahc.nTilesY * 8);
|
||||
|
||||
|
||||
for (int ht = 0; ht < tile.rahc.nTilesY; ht++)
|
||||
{
|
||||
for (int wt = 0; wt < tile.rahc.nTilesX; wt++)
|
||||
{
|
||||
for (int h = 0; h < 8; h++)
|
||||
{
|
||||
for (int w = 0; w < 8; w++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (tile.rahc.tileData.tiles[wt + ht * tile.rahc.nTilesX].Length == 0)
|
||||
goto Fin;
|
||||
imagen.SetPixel(
|
||||
w + wt * 8,
|
||||
h + ht * 8,
|
||||
paleta.pltt.paletas[0].colores[
|
||||
tile.rahc.tileData.tiles[wt + ht * tile.rahc.nTilesX][w + h * 8]
|
||||
]);
|
||||
}
|
||||
catch { goto Fin; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Fin:
|
||||
return imagen;
|
||||
|
||||
}
|
||||
public static Bitmap Crear_Imagen(Estructuras.NCGR tile, Imagen.Paleta.Estructuras.NCLR paleta, int tilesX, int tilesY)
|
||||
{
|
||||
if (tile.rahc.nTilesX == 0xFFFF) // En caso de que no venga la información hacemos la imagen de 256x256
|
||||
tile.rahc.nTilesX = 0x20;
|
||||
if (tile.rahc.nTilesY == 0xFFFF)
|
||||
tile.rahc.nTilesY = 0x20;
|
||||
|
||||
Bitmap imagen = new Bitmap(tilesX * 8, tilesY * 8);
|
||||
|
||||
for (int ht = 0; ht < tilesY; ht++)
|
||||
{
|
||||
for (int wt = 0; wt < tilesX; wt++)
|
||||
{
|
||||
for (int h = 0; h < 8; h++)
|
||||
{
|
||||
for (int w = 0; w < 8; w++)
|
||||
{
|
||||
if (tile.rahc.tileData.tiles[wt + ht * tilesX].Length == 0)
|
||||
goto Fin;
|
||||
imagen.SetPixel(
|
||||
w + wt * 8,
|
||||
h + ht * 8,
|
||||
paleta.pltt.paletas[0].colores[
|
||||
tile.rahc.tileData.tiles[wt + ht * tilesX][w + h * 8]
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Fin:
|
||||
return imagen;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
265
Tinke/Imagen/Tile/iNCGR.Designer.cs
generated
Normal file
265
Tinke/Imagen/Tile/iNCGR.Designer.cs
generated
Normal file
@ -0,0 +1,265 @@
|
||||
namespace Tinke.Imagen.Tile
|
||||
{
|
||||
partial class iNCGR
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x06",
|
||||
"Desconocido"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x0E",
|
||||
"Nº secciones"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x10",
|
||||
"ID Sección 1"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x14",
|
||||
"Tamaño"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x18",
|
||||
"Tiles Y"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x1A",
|
||||
"Tiles X"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem7 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x1C",
|
||||
"Formato"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem8 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x20",
|
||||
"Desconocido"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem9 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x24",
|
||||
"Desconocido"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem10 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x28",
|
||||
"Tamaño píxels datos"}, -1);
|
||||
System.Windows.Forms.ListViewItem listViewItem11 = new System.Windows.Forms.ListViewItem(new string[] {
|
||||
"0x2C",
|
||||
"Desconocido"}, -1);
|
||||
this.numericWidth = new System.Windows.Forms.NumericUpDown();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.numericHeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.groupProp = new System.Windows.Forms.GroupBox();
|
||||
this.listInfo = new System.Windows.Forms.ListView();
|
||||
this.columnPos = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnCampo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnValor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
this.pic = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericWidth)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericHeight)).BeginInit();
|
||||
this.groupProp.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pic)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// numericWidth
|
||||
//
|
||||
this.numericWidth.Increment = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericWidth.Location = new System.Drawing.Point(55, 171);
|
||||
this.numericWidth.Maximum = new decimal(new int[] {
|
||||
65536,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericWidth.Minimum = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericWidth.Name = "numericWidth";
|
||||
this.numericWidth.Size = new System.Drawing.Size(55, 20);
|
||||
this.numericWidth.TabIndex = 1;
|
||||
this.numericWidth.Value = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(8, 173);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(41, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Ancho:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(147, 173);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(28, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Alto:";
|
||||
//
|
||||
// numericHeight
|
||||
//
|
||||
this.numericHeight.Increment = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericHeight.Location = new System.Drawing.Point(181, 171);
|
||||
this.numericHeight.Maximum = new decimal(new int[] {
|
||||
65536,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericHeight.Minimum = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericHeight.Name = "numericHeight";
|
||||
this.numericHeight.Size = new System.Drawing.Size(55, 20);
|
||||
this.numericHeight.TabIndex = 4;
|
||||
this.numericHeight.Value = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// groupProp
|
||||
//
|
||||
this.groupProp.Controls.Add(this.listInfo);
|
||||
this.groupProp.Controls.Add(this.numericHeight);
|
||||
this.groupProp.Controls.Add(this.numericWidth);
|
||||
this.groupProp.Controls.Add(this.label2);
|
||||
this.groupProp.Controls.Add(this.label1);
|
||||
this.groupProp.Location = new System.Drawing.Point(106, 3);
|
||||
this.groupProp.Name = "groupProp";
|
||||
this.groupProp.Size = new System.Drawing.Size(243, 197);
|
||||
this.groupProp.TabIndex = 5;
|
||||
this.groupProp.TabStop = false;
|
||||
this.groupProp.Text = "Propiedades";
|
||||
//
|
||||
// listInfo
|
||||
//
|
||||
this.listInfo.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnPos,
|
||||
this.columnCampo,
|
||||
this.columnValor});
|
||||
this.listInfo.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
this.listInfo.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
|
||||
listViewItem1,
|
||||
listViewItem2,
|
||||
listViewItem3,
|
||||
listViewItem4,
|
||||
listViewItem5,
|
||||
listViewItem6,
|
||||
listViewItem7,
|
||||
listViewItem8,
|
||||
listViewItem9,
|
||||
listViewItem10,
|
||||
listViewItem11});
|
||||
this.listInfo.Location = new System.Drawing.Point(7, 20);
|
||||
this.listInfo.Name = "listInfo";
|
||||
this.listInfo.Size = new System.Drawing.Size(229, 145);
|
||||
this.listInfo.TabIndex = 5;
|
||||
this.listInfo.UseCompatibleStateImageBehavior = false;
|
||||
this.listInfo.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnPos
|
||||
//
|
||||
this.columnPos.Text = "Posición";
|
||||
//
|
||||
// columnCampo
|
||||
//
|
||||
this.columnCampo.Text = "Campo";
|
||||
//
|
||||
// columnValor
|
||||
//
|
||||
this.columnValor.Text = "Valor";
|
||||
this.columnValor.Width = 81;
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.Image = global::Tinke.Properties.Resources.picture_save;
|
||||
this.btnSave.Location = new System.Drawing.Point(263, 206);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(79, 32);
|
||||
this.btnSave.TabIndex = 6;
|
||||
this.btnSave.Text = "Guardar";
|
||||
this.btnSave.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// pic
|
||||
//
|
||||
this.pic.BackColor = System.Drawing.Color.Transparent;
|
||||
this.pic.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pic.Location = new System.Drawing.Point(0, 0);
|
||||
this.pic.Name = "pic";
|
||||
this.pic.Size = new System.Drawing.Size(100, 50);
|
||||
this.pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pic.TabIndex = 0;
|
||||
this.pic.TabStop = false;
|
||||
//
|
||||
// iNCGR
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoScroll = true;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.pic);
|
||||
this.Controls.Add(this.btnSave);
|
||||
this.Controls.Add(this.groupProp);
|
||||
this.Name = "iNCGR";
|
||||
this.Size = new System.Drawing.Size(352, 241);
|
||||
this.SizeChanged += new System.EventHandler(this.iNCGR_SizeChanged);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericWidth)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericHeight)).EndInit();
|
||||
this.groupProp.ResumeLayout(false);
|
||||
this.groupProp.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pic)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pic;
|
||||
private System.Windows.Forms.NumericUpDown numericWidth;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.NumericUpDown numericHeight;
|
||||
private System.Windows.Forms.GroupBox groupProp;
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
private System.Windows.Forms.ListView listInfo;
|
||||
private System.Windows.Forms.ColumnHeader columnPos;
|
||||
private System.Windows.Forms.ColumnHeader columnCampo;
|
||||
private System.Windows.Forms.ColumnHeader columnValor;
|
||||
}
|
||||
}
|
91
Tinke/Imagen/Tile/iNCGR.cs
Normal file
91
Tinke/Imagen/Tile/iNCGR.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tinke.Imagen.Tile
|
||||
{
|
||||
public partial class iNCGR : UserControl
|
||||
{
|
||||
Imagen.Paleta.Estructuras.NCLR paleta;
|
||||
Imagen.Tile.Estructuras.NCGR tile;
|
||||
|
||||
public iNCGR()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public iNCGR(Imagen.Tile.Estructuras.NCGR tile, Imagen.Paleta.Estructuras.NCLR paleta)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.paleta = paleta;
|
||||
this.tile = tile;
|
||||
if (tile.rahc.nTilesX != 0xFFFF)
|
||||
this.numericWidth.Value = tile.rahc.nTilesX * 8;
|
||||
else
|
||||
this.numericWidth.Value = 0x100;
|
||||
if (tile.rahc.nTilesY != 0xFFFF)
|
||||
this.numericHeight.Value = tile.rahc.nTilesY * 8;
|
||||
else
|
||||
this.numericHeight.Value = 0x100;
|
||||
this.numericWidth.ValueChanged += new EventHandler(numericSize_ValueChanged);
|
||||
this.numericHeight.ValueChanged += new EventHandler(numericSize_ValueChanged);
|
||||
pic.Image = Imagen.Tile.NCGR.Crear_Imagen(tile, paleta);
|
||||
Info();
|
||||
}
|
||||
|
||||
private void iNCGR_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
pic.Location = new Point(0, 0);
|
||||
groupProp.Location = new Point(this.Width - groupProp.Width, 0);
|
||||
groupProp.Height = this.Height - btnSave.Height - 10;
|
||||
listInfo.Height = groupProp.Height - 52;
|
||||
label1.Location = new Point(label1.Location.X, listInfo.Height + 28);
|
||||
label2.Location = new Point(label2.Location.X, listInfo.Height + 28);
|
||||
numericHeight.Location = new Point(numericHeight.Location.X, listInfo.Height + 26);
|
||||
numericWidth.Location = new Point(numericWidth.Location.X, listInfo.Height + 26);
|
||||
btnSave.Location = new Point(this.Width - btnSave.Width, groupProp.Height + 5);
|
||||
}
|
||||
|
||||
private void numericSize_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
Actualizar_Imagen();
|
||||
}
|
||||
private void Actualizar_Imagen()
|
||||
{
|
||||
tile.rahc.nTilesX = (ushort)(numericWidth.Value / 8);
|
||||
tile.rahc.nTilesY = (ushort)(numericHeight.Value / 8);
|
||||
pic.Image = Imagen.Tile.NCGR.Crear_Imagen(tile, paleta);
|
||||
}
|
||||
private void Info()
|
||||
{
|
||||
listInfo.Items[0].SubItems.Add("0x" + String.Format("{0:X}", tile.constant));
|
||||
listInfo.Items[1].SubItems.Add(tile.nSections.ToString());
|
||||
listInfo.Items[2].SubItems.Add(new String(tile.rahc.id));
|
||||
listInfo.Items[3].SubItems.Add("0x" + String.Format("{0:X}", tile.rahc.size_section));
|
||||
listInfo.Items[4].SubItems.Add(tile.rahc.nTilesY.ToString() + " (0x" + String.Format("{0:X}", tile.rahc.nTilesY) + ')');
|
||||
listInfo.Items[5].SubItems.Add(tile.rahc.nTilesX.ToString() + " (0x" + String.Format("{0:X}", tile.rahc.nTilesX) + ')');
|
||||
listInfo.Items[6].SubItems.Add(Enum.GetName(tile.rahc.depth.GetType(), tile.rahc.depth));
|
||||
listInfo.Items[7].SubItems.Add("0x" + String.Format("{0:X}", tile.rahc.unknown1));
|
||||
listInfo.Items[8].SubItems.Add("0x" + String.Format("{0:X}", tile.rahc.unknown2));
|
||||
listInfo.Items[9].SubItems.Add("0x" + String.Format("{0:X}", tile.rahc.size_tiledata));
|
||||
listInfo.Items[10].SubItems.Add("0x" + String.Format("{0:X}", tile.rahc.unknown3));
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog o = new SaveFileDialog();
|
||||
o.AddExtension = true;
|
||||
o.DefaultExt = "bmp";
|
||||
o.Filter = "Imagen BitMaP (*.bmp)|*.bmp";
|
||||
o.OverwritePrompt = true;
|
||||
if (o.ShowDialog() == DialogResult.OK)
|
||||
pic.Image.Save(o.FileName);
|
||||
o.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
120
Tinke/Imagen/Tile/iNCGR.resx
Normal file
120
Tinke/Imagen/Tile/iNCGR.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
562
Tinke/Juegos/Layton1.cs
Normal file
562
Tinke/Juegos/Layton1.cs
Normal file
@ -0,0 +1,562 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tinke.Juegos
|
||||
{
|
||||
/// <summary>
|
||||
/// Métodos y funciones para el juego "Profesor Layton y la Misteriosa Villa"
|
||||
/// </summary>
|
||||
public static class Layton1
|
||||
{
|
||||
/// <summary>
|
||||
/// Métodos para la carpeta Ani
|
||||
/// </summary>
|
||||
public static class Ani
|
||||
{
|
||||
/// <summary>
|
||||
/// Obtiene la paleta a partir de un archivo.
|
||||
/// </summary>
|
||||
/// <param name="filePath">Ruta del archivo donde se encuentra</param>
|
||||
/// <param name="posicion">Posición donde se encuentra el inicio de la paleta.</param>
|
||||
/// <returns>Paleta</returns>
|
||||
public static Paleta Obtener_Paleta(string filePath, long posicion)
|
||||
{
|
||||
FileStream file = File.OpenRead(filePath);
|
||||
BinaryReader rdr = new BinaryReader(file);
|
||||
|
||||
Paleta paleta;
|
||||
|
||||
/*
|
||||
* Estas paletas están compuestas de la siguiente forma (0x relativo al inicio):
|
||||
* -0x0-0x3 byte que al duplicarlo (x2) nos devuelve el tamaño de la paleta.
|
||||
* -0x4 inicio de la paleta.
|
||||
*/
|
||||
|
||||
rdr.BaseStream.Position = posicion; // Posición inicial de paleta
|
||||
paleta.length = (rdr.ReadUInt32() * 2); // Longitud de paleta
|
||||
paleta.offset = (ulong)rdr.BaseStream.Position;
|
||||
paleta.datos = rdr.ReadBytes((int)paleta.length); // Paleta en binario
|
||||
paleta.colores = new Color[paleta.length]; // Declaramos el tamaño
|
||||
paleta.colores = Imagen.Paleta.Convertidor.BGR555(paleta.datos); // Paleta en colores
|
||||
|
||||
rdr.Close();
|
||||
rdr.Dispose();
|
||||
file.Close();
|
||||
file.Dispose();
|
||||
|
||||
return paleta;
|
||||
}
|
||||
/// <summary>
|
||||
/// Muestra la paleta en un PictureBox
|
||||
/// </summary>
|
||||
/// <param name="paleta">Paleta para mostrar.</param>
|
||||
/// <param name="pictureBox">PictureBox donde se va a mostrar.</param>
|
||||
public static void Mostrar_Paleta(Paleta paleta, ref System.Windows.Forms.PictureBox pictureBox)
|
||||
{
|
||||
Bitmap imagen = new Bitmap(160, 160);
|
||||
bool fin = false;
|
||||
|
||||
for (int i = 0; i < 16 & !fin; i++)
|
||||
{
|
||||
for (int j = 0; j < 16 & !fin; j++)
|
||||
{
|
||||
for (int k = 0; k < 10 & !fin; k++)
|
||||
{
|
||||
for (int q = 0; q < 10; q++)
|
||||
{
|
||||
try { imagen.SetPixel(j * 10 + q, i * 10 + k, paleta.colores[j + 16 * i]); }
|
||||
catch { fin = true; imagen.SetPixel(j * 10, i * 10 + q, Color.White); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pictureBox.Image = imagen;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obtiene una imagen del archivo.
|
||||
/// </summary>
|
||||
/// <param name="filePath">Archivo</param>
|
||||
/// <param name="posicion">Posición inicial</param>
|
||||
/// <returns></returns>
|
||||
public static Image Obtener_Imagen(string filePath, long posicion, Imagen.Tiles_Form tipo)
|
||||
{
|
||||
FileStream file = File.OpenRead(filePath);
|
||||
BinaryReader rdr = new BinaryReader(file);
|
||||
|
||||
Image imagen = new Image();
|
||||
|
||||
rdr.BaseStream.Position = posicion;
|
||||
|
||||
imagen.tipo = tipo;
|
||||
imagen.width = rdr.ReadUInt16();
|
||||
imagen.height = rdr.ReadUInt16();
|
||||
imagen.imgs = rdr.ReadUInt16();
|
||||
imagen.segmentos = new Parte[imagen.imgs];
|
||||
imagen.length = (uint)imagen.width * imagen.height;
|
||||
rdr.BaseStream.Seek(2, SeekOrigin.Current);
|
||||
|
||||
for (int i = 0; i < imagen.imgs; i++)
|
||||
{
|
||||
imagen.segmentos[i] = Obtener_Parte(filePath, rdr.BaseStream.Position, imagen.tipo);
|
||||
rdr.BaseStream.Seek(imagen.segmentos[i].length + 8, SeekOrigin.Current);
|
||||
}
|
||||
|
||||
rdr.Close();
|
||||
rdr.Dispose();
|
||||
file.Close();
|
||||
file.Dispose();
|
||||
|
||||
return imagen;
|
||||
}
|
||||
/// <summary>
|
||||
/// Obtiene una parte del archivo.
|
||||
/// </summary>
|
||||
/// <param name="filePath">Archivo</param>
|
||||
/// <param name="posicion">Posición de inicio de la parte</param>
|
||||
/// <returns>Parte de imagen</returns>
|
||||
public static Parte Obtener_Parte(string filePath, long posicion, Imagen.Tiles_Form tipo)
|
||||
{
|
||||
Parte parte = new Parte();
|
||||
|
||||
FileStream file = File.OpenRead(filePath);
|
||||
BinaryReader rdr = new BinaryReader(file);
|
||||
rdr.BaseStream.Position = posicion;
|
||||
|
||||
parte.offSet = (ulong)posicion;
|
||||
parte.posX = (ushort)rdr.ReadUInt16();
|
||||
parte.posY = (ushort)rdr.ReadUInt16();
|
||||
parte.width = (ushort)Math.Pow(2, 3 + rdr.ReadUInt16());
|
||||
parte.height = (ushort)Math.Pow(2, 3 + rdr.ReadUInt16());
|
||||
if (tipo == Imagen.Tiles_Form.bpp8)
|
||||
{
|
||||
parte.length = (uint)parte.width * parte.height;
|
||||
parte.datos = rdr.ReadBytes((int)parte.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
parte.length = (uint)(parte.width * parte.height) / 2;
|
||||
parte.datos = new Byte[2 * parte.length];
|
||||
parte.datos = Tools.Helper.BytesTo4BitsRev(rdr.ReadBytes((int)parte.length));
|
||||
}
|
||||
|
||||
rdr.Close();
|
||||
rdr.Dispose();
|
||||
file.Close();
|
||||
file.Dispose();
|
||||
|
||||
return parte;
|
||||
}
|
||||
/// <summary>
|
||||
/// Muestra la estrucutura imagen en un pictueBox
|
||||
/// </summary>
|
||||
/// <param name="imagen">Estructura imagen</param>
|
||||
/// <param name="paleta">Estructura paleta</param>
|
||||
public static void Mostrar_Imagen(Image imagen, Paleta paleta, ref System.Windows.Forms.PictureBox pictureBox)
|
||||
{
|
||||
|
||||
Size original = Tamano_Original(imagen);
|
||||
Bitmap final = new Bitmap(original.Width, original.Height);
|
||||
|
||||
for (int i = 0; i < imagen.imgs; i++)
|
||||
for (int h = 0; h < imagen.segmentos[i].height; h++)
|
||||
for (int w = 0; w < imagen.segmentos[i].width; w++)
|
||||
final.SetPixel(w + imagen.segmentos[i].posX, h + imagen.segmentos[i].posY,
|
||||
paleta.colores[imagen.segmentos[i].datos[w + h * imagen.segmentos[i].width]]);
|
||||
|
||||
pictureBox.Image = final;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforma la estructura Imagen en un Bitmap.
|
||||
/// </summary>
|
||||
/// <param name="imagen">Estructura imagen.</param>
|
||||
/// <param name="paleta">Estructura paleta</param>
|
||||
/// <returns>Bitmap</returns>
|
||||
public static Bitmap Transformar_Imagen(Image imagen, Paleta paleta)
|
||||
{
|
||||
Size original = Tamano_Original(imagen);
|
||||
Bitmap final = new Bitmap(original.Width, original.Height);
|
||||
|
||||
for (int i = 0; i < imagen.imgs; i++)
|
||||
{
|
||||
for (int h = 0; h < imagen.segmentos[i].height; h++)
|
||||
{
|
||||
for (int w = 0; w < imagen.segmentos[i].width; w++)
|
||||
{
|
||||
// NOTA: en caso de error porque el color no lo contenga la paleta poner color negro.
|
||||
final.SetPixel(w + imagen.segmentos[i].posX, h + imagen.segmentos[i].posY,
|
||||
paleta.colores[imagen.segmentos[i].datos[w + h * imagen.segmentos[i].width]]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Devuelve el tamaño original de la imagen sin los recortes
|
||||
/// </summary>
|
||||
/// <param name="imagen">Imagen</param>
|
||||
/// <returns>Tamaño original</returns>
|
||||
public static Size Tamano_Original(Image imagen)
|
||||
{
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
for (int i = 0; i < imagen.imgs; i++)
|
||||
{
|
||||
if (imagen.segmentos[i].posY == 0)
|
||||
width += imagen.segmentos[i].width;
|
||||
if (imagen.segmentos[i].posX == 0)
|
||||
height += imagen.segmentos[i].height;
|
||||
}
|
||||
|
||||
return new Size(width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obtiene todas las imágenes contenidas en un archivo.
|
||||
/// </summary>
|
||||
/// <param name="filePath">Archivo</param>
|
||||
/// <returns>Array de bitmap con las imágenes</returns>
|
||||
public static Bitmap[] Obtener_Final(string filePath)
|
||||
{
|
||||
FileStream file = File.OpenRead(filePath);
|
||||
BinaryReader rdr = new BinaryReader(file);
|
||||
|
||||
Image[] imagenes = new Image[rdr.ReadUInt16()];
|
||||
Bitmap[] resultados = new Bitmap[imagenes.Length];
|
||||
Imagen.Tiles_Form tipo = rdr.ReadUInt16() == 3 ? Imagen.Tiles_Form.bpp4 : Imagen.Tiles_Form.bpp8;
|
||||
|
||||
for (int i = 0; i < imagenes.Length; i++)
|
||||
{
|
||||
imagenes[i] = Obtener_Imagen(filePath, rdr.BaseStream.Position, tipo);
|
||||
rdr.BaseStream.Position = (long)imagenes[i].segmentos[imagenes[i].imgs - 1].offSet +
|
||||
imagenes[i].segmentos[imagenes[i].imgs - 1].length + 8;
|
||||
}
|
||||
|
||||
Paleta paleta = Obtener_Paleta(filePath, rdr.BaseStream.Position);
|
||||
|
||||
rdr.Close();
|
||||
rdr = null;
|
||||
file.Dispose();
|
||||
file = null;
|
||||
|
||||
for (int i = 0; i < imagenes.Length; i++)
|
||||
{
|
||||
resultados[i] = Transformar_Imagen(imagenes[i], paleta);
|
||||
resultados[i] = resultados[i].Clone(new Rectangle(0, 0, imagenes[i].width, imagenes[i].height),
|
||||
System.Drawing.Imaging.PixelFormat.DontCare);
|
||||
}
|
||||
|
||||
return resultados;
|
||||
}
|
||||
public static Todo Obtener_Todo(string filePath)
|
||||
{
|
||||
FileStream file = File.OpenRead(filePath);
|
||||
BinaryReader rdr = new BinaryReader(file);
|
||||
Todo final = new Todo();
|
||||
|
||||
final.imgs = rdr.ReadUInt16();
|
||||
Image[] imagenes = new Image[final.imgs];
|
||||
final.tipo = rdr.ReadUInt16() == 3 ? Imagen.Tiles_Form.bpp4 : Imagen.Tiles_Form.bpp8;
|
||||
|
||||
for (int i = 0; i < imagenes.Length; i++)
|
||||
{
|
||||
imagenes[i] = Obtener_Imagen(filePath, rdr.BaseStream.Position, final.tipo);
|
||||
rdr.BaseStream.Position = (long)imagenes[i].segmentos[imagenes[i].imgs - 1].offSet +
|
||||
imagenes[i].segmentos[imagenes[i].imgs - 1].length + 8;
|
||||
}
|
||||
|
||||
Paleta paleta = Obtener_Paleta(filePath, rdr.BaseStream.Position);
|
||||
|
||||
// Obtenemos los nombres de las imágenes.
|
||||
rdr.BaseStream.Position = (long)paleta.offset + paleta.length + 0x1E;
|
||||
uint numNombres = rdr.ReadUInt32() - 1;
|
||||
rdr.BaseStream.Seek(0x13 + 0xB, SeekOrigin.Current);
|
||||
for (uint i = 0; i < numNombres & i < imagenes.Length; i++)
|
||||
{
|
||||
imagenes[i].name = new String(rdr.ReadChars(0x13));
|
||||
|
||||
// Eliminamos caracteres no admitidos por windows. El nombre llega hasta el primer \0
|
||||
imagenes[i].name = imagenes[i].name.Substring(0, imagenes[i].name.IndexOf('\0'));
|
||||
/*imagenes[i].name = imagenes[i].name.Replace("\0", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace("*", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace("?", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace("\\", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace("/", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace(":", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace("|", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace("\"", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace("<", "");
|
||||
imagenes[i].name = imagenes[i].name.Replace(">", "");*/
|
||||
|
||||
rdr.BaseStream.Seek(0xB, SeekOrigin.Current);
|
||||
}
|
||||
|
||||
rdr.Close();
|
||||
rdr = null;
|
||||
file.Dispose();
|
||||
file = null;
|
||||
|
||||
for (int i = 0; i < imagenes.Length; i++)
|
||||
{
|
||||
imagenes[i].bitmap = Transformar_Imagen(imagenes[i], paleta);
|
||||
imagenes[i].bitmap = imagenes[i].bitmap.Clone(new Rectangle(0, 0, imagenes[i].width, imagenes[i].height),
|
||||
System.Drawing.Imaging.PixelFormat.DontCare);
|
||||
if (imagenes[i].name == "" | imagenes[i].name == null)
|
||||
imagenes[i].name = "Sin Nombre " + i.ToString();
|
||||
}
|
||||
|
||||
|
||||
final.imagenes = imagenes;
|
||||
final.paleta = paleta;
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
#region Estructuras
|
||||
public struct Paleta
|
||||
{
|
||||
public ulong offset;
|
||||
public uint length;
|
||||
public byte[] datos;
|
||||
public Color[] colores;
|
||||
}
|
||||
|
||||
public struct Image
|
||||
{
|
||||
public string name;
|
||||
public Parte[] segmentos;
|
||||
public uint length;
|
||||
public ushort width;
|
||||
public ushort height;
|
||||
public ushort imgs;
|
||||
public Imagen.Tiles_Form tipo;
|
||||
public Bitmap bitmap;
|
||||
}
|
||||
public struct Parte
|
||||
{
|
||||
public ulong offSet;
|
||||
public uint length;
|
||||
public ushort width;
|
||||
public ushort height;
|
||||
public ushort posX;
|
||||
public ushort posY;
|
||||
public byte[] datos;
|
||||
}
|
||||
|
||||
public struct Todo
|
||||
{
|
||||
public Paleta paleta;
|
||||
public Image[] imagenes;
|
||||
public Imagen.Tiles_Form tipo;
|
||||
public ushort imgs;
|
||||
}
|
||||
#endregion // Estructuras
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Métodos para los archivos de la carpeta bg
|
||||
/// </summary>
|
||||
public static class Bg
|
||||
{
|
||||
public static Background Obtener_Background(string file)
|
||||
{
|
||||
Background imagen = new Background();
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
|
||||
// Paleta, NCLR sin cabecera
|
||||
// TODO: Crear la función en la clase de NCLR
|
||||
imagen.paleta.pltt.nColores = br.ReadUInt32();
|
||||
imagen.paleta.pltt.paletas = new Imagen.NTFP[1];
|
||||
imagen.paleta.pltt.paletas[0].colores =
|
||||
Imagen.Paleta.Convertidor.BGR555(br.ReadBytes((int)imagen.paleta.pltt.nColores * 2));
|
||||
|
||||
// Tile, sin cabecera
|
||||
long offset = br.BaseStream.Position;
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
imagen.tile = Imagen.Tile.NCGR.Leer_SinCabecera(file, offset);
|
||||
|
||||
|
||||
// Tile Screen Info
|
||||
offset += imagen.tile.rahc.size_tiledata * 64 + 4;
|
||||
|
||||
imagen.screen = Imagen.Screen.NSCR.Leer_NoCabecera(file, offset);
|
||||
imagen.tile.rahc.tileData.tiles = Imagen.Screen.NSCR.Modificar_Tile(imagen.screen, imagen.tile.rahc.tileData.tiles);
|
||||
imagen.tile.rahc.nTilesX = imagen.screen.section.width;
|
||||
imagen.tile.rahc.nTilesY = imagen.screen.section.height;
|
||||
|
||||
return imagen;
|
||||
}
|
||||
public static Bitmap Obtener_Imagen(string file)
|
||||
{
|
||||
Background bg = Obtener_Background(file);
|
||||
return Imagen.Tile.NCGR.Crear_Imagen(bg.tile, bg.paleta);
|
||||
}
|
||||
|
||||
#region Estructuras
|
||||
public struct Background
|
||||
{
|
||||
public Imagen.Paleta.Estructuras.NCLR paleta;
|
||||
public Imagen.Tile.Estructuras.NCGR tile;
|
||||
public Imagen.Screen.Estructuras.NSCR screen;
|
||||
}
|
||||
public struct Tile //TODO: cambiar por NCGR
|
||||
{
|
||||
public UInt32 size; // Tamaño de tiles (8x8 pixels)
|
||||
public Imagen.NTFT ntft; // Formato NTFT
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static class Txt
|
||||
{
|
||||
public static String Leer(string file)
|
||||
{
|
||||
String txt = "";
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
|
||||
while (br.BaseStream.Position != br.BaseStream.Length - 1)
|
||||
{
|
||||
byte c = br.ReadByte();
|
||||
|
||||
if (c == 0x0A)
|
||||
txt += '\r';
|
||||
|
||||
txt += Char.ConvertFromUtf32(c);
|
||||
}
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
public static Panel Obtener_Animacion(string fileTxt, string fileLay, string fondo)
|
||||
{
|
||||
// No funciona bien.. Hay que investigar más y rehacerlo de nuevo
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(fileTxt));
|
||||
Panel panel = new System.Windows.Forms.Panel();
|
||||
|
||||
string txt = Leer(fileTxt);
|
||||
TextBox txtBox = new TextBox();
|
||||
txtBox.Dock = DockStyle.Left;
|
||||
txtBox.Width = 350;
|
||||
txtBox.ReadOnly = true;
|
||||
txtBox.Multiline = true;
|
||||
txtBox.Text = txt;
|
||||
panel.Controls.Add(txtBox);
|
||||
|
||||
List<Bitmap> imagenes = new List<Bitmap>();
|
||||
List<String> textos = new List<string>();
|
||||
textos.Add(""); int y = 0;
|
||||
Bitmap imgFondo = Ani.Obtener_Final(fondo)[0];
|
||||
|
||||
for (int i = 0; br.BaseStream.Position != br.BaseStream.Length; i++)
|
||||
{
|
||||
byte c = br.ReadByte();
|
||||
if (c == 0x40)
|
||||
{
|
||||
y++;
|
||||
textos.Add("");
|
||||
br.ReadByte();
|
||||
if (br.ReadByte() == 0x40)
|
||||
br.ReadByte();
|
||||
else
|
||||
br.BaseStream.Position = br.BaseStream.Position - 1;
|
||||
}
|
||||
if (c == 0x0A)
|
||||
textos[y] += "\r";
|
||||
textos[y] += Char.ConvertFromUtf32(c);
|
||||
}
|
||||
Ani.Todo layton = Ani.Obtener_Todo(fileLay);
|
||||
|
||||
for (int i = 0; i < txt.Length; i++)
|
||||
{
|
||||
if (i + 7 < txt.Length)
|
||||
{
|
||||
if (txt.Substring(i, 7) == "&SetAni")
|
||||
{
|
||||
textos[y] += '@';
|
||||
|
||||
string script = txt.Substring(i + 1);
|
||||
script = script.Remove(script.IndexOf("&"));
|
||||
int numero = Convert.ToInt32(script[7]);
|
||||
string aniName = script.Substring(9);
|
||||
|
||||
for (int j = 0; j < layton.imagenes.Length; j++)
|
||||
if (layton.imagenes[j].name == aniName)
|
||||
imagenes.Add(Ani.Transformar_Imagen(layton.imagenes[j], layton.paleta));
|
||||
|
||||
|
||||
i += script.Length + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < textos.Count; i++)
|
||||
if (textos[i][0] != '@')
|
||||
imagenes.Insert(i, null);
|
||||
|
||||
LaytonTalks talks = new LaytonTalks(textos.ToArray(), imagenes.ToArray(), imgFondo);
|
||||
talks.Dock = DockStyle.Right;
|
||||
panel.Controls.Add(talks);
|
||||
|
||||
panel.Dock = DockStyle.Fill;
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
public static Tipos.Role FormatoArchivos(int id, Tipos.Pais version, string name, String gameCode)
|
||||
{
|
||||
name = name.ToUpper();
|
||||
|
||||
|
||||
switch (gameCode)
|
||||
{
|
||||
case "A5FP":
|
||||
case "A5FE":
|
||||
switch (version)
|
||||
{
|
||||
case Tipos.Pais.SPA:
|
||||
case Tipos.Pais.EUR:
|
||||
if (id >= 0x0001 && id <= 0x04E7 && name.EndsWith(".ARC"))
|
||||
return Tipos.Role.ImagenAnimada;
|
||||
else if (id >= 0x04E8 && id <= 0x0B72)
|
||||
return Tipos.Role.ImagenCompleta;
|
||||
return Tipos.Role.Desconocido;
|
||||
case Tipos.Pais.USA:
|
||||
if (id >= 0x0001 && id <= 0x02CB && name.EndsWith(".ARC")) // ani
|
||||
return Tipos.Role.ImagenAnimada;
|
||||
else if (id >= 0x02CD && id <= 0x0765) // bg
|
||||
return Tipos.Role.ImagenCompleta;
|
||||
else if (name.EndsWith(".TXT"))
|
||||
return Tipos.Role.Texto;
|
||||
else
|
||||
return Tipos.Role.Desconocido;
|
||||
default:
|
||||
return Tipos.Role.Desconocido;
|
||||
}
|
||||
case "YLTS":
|
||||
switch (version)
|
||||
{
|
||||
case Tipos.Pais.SPA:
|
||||
if (id >= 0x0037 && id <= 0x0408 && name.EndsWith(".ARC"))
|
||||
return Tipos.Role.ImagenAnimada;
|
||||
else if (id >= 0x0409 && id <= 0x0808 && name.Contains("ARC"))
|
||||
return Tipos.Role.ImagenCompleta;
|
||||
return Tipos.Role.Desconocido;
|
||||
default :
|
||||
return Tipos.Role.Desconocido;
|
||||
}
|
||||
default:
|
||||
return Tipos.Role.Desconocido;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
98
Tinke/Juegos/LaytonTalks.Designer.cs
generated
Normal file
98
Tinke/Juegos/LaytonTalks.Designer.cs
generated
Normal file
@ -0,0 +1,98 @@
|
||||
namespace Tinke.Juegos
|
||||
{
|
||||
partial class LaytonTalks
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.pictureBox2 = new System.Windows.Forms.PictureBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Location = new System.Drawing.Point(4, 4);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(100, 50);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.pictureBox1.SizeChanged += new System.EventHandler(this.pictureBox1_SizeChanged);
|
||||
//
|
||||
// pictureBox2
|
||||
//
|
||||
this.pictureBox2.Location = new System.Drawing.Point(4, 202);
|
||||
this.pictureBox2.Name = "pictureBox2";
|
||||
this.pictureBox2.Size = new System.Drawing.Size(100, 50);
|
||||
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBox2.TabIndex = 1;
|
||||
this.pictureBox2.TabStop = false;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.label1.Location = new System.Drawing.Point(20, 222);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(100, 23);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "label1";
|
||||
//
|
||||
// LaytonTalks
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.pictureBox2);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Name = "LaytonTalks";
|
||||
this.Size = new System.Drawing.Size(123, 255);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.PictureBox pictureBox2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
59
Tinke/Juegos/LaytonTalks.cs
Normal file
59
Tinke/Juegos/LaytonTalks.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tinke.Juegos
|
||||
{
|
||||
public partial class LaytonTalks : UserControl
|
||||
{
|
||||
string[] textos;
|
||||
Bitmap[] layton;
|
||||
int actual;
|
||||
|
||||
public LaytonTalks(string[] txts, Bitmap[] layton, Bitmap fondo)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
label1.Parent = pictureBox2;
|
||||
label1.Dock = DockStyle.Fill;
|
||||
|
||||
pictureBox2.Image = fondo;
|
||||
textos = txts;
|
||||
this.layton = layton;
|
||||
actual = 0;
|
||||
pictureBox1.Image = layton[0];
|
||||
label1.Text = "\n" + textos[0];
|
||||
timer1.Interval = TextToTime(textos[0]) * 100;
|
||||
timer1.Enabled = true;
|
||||
timer1.Start();
|
||||
}
|
||||
|
||||
private void pictureBox1_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBox2.Location = new Point(0, pictureBox1.Height);
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
actual++;
|
||||
if (actual >= textos.Length) actual = 0;
|
||||
label1.Text = "\n" + (textos[actual][0] == '@' ? textos[actual].Remove(0, 1) : textos[actual]);
|
||||
|
||||
if (textos[actual][0] == '@')
|
||||
pictureBox1.Image = layton[actual];
|
||||
}
|
||||
|
||||
private int TextToTime(string texto)
|
||||
{
|
||||
int palabras = texto.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;
|
||||
|
||||
return palabras * 4;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
123
Tinke/Juegos/LaytonTalks.resx
Normal file
123
Tinke/Juegos/LaytonTalks.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
120
Tinke/Nitro/Estructuras.cs
Normal file
120
Tinke/Nitro/Estructuras.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tinke.Nitro
|
||||
{
|
||||
public static class Estructuras
|
||||
{
|
||||
public struct ROMHeader
|
||||
{
|
||||
public char[] gameTitle;
|
||||
public char[] gameCode;
|
||||
public char[] makerCode;
|
||||
public char unitCode;
|
||||
public byte encryptionSeed;
|
||||
public UInt32 tamaño;
|
||||
public byte[] reserved;
|
||||
public byte ROMversion;
|
||||
public byte internalFlags;
|
||||
public UInt32 ARM9romOffset;
|
||||
public UInt32 ARM9entryAddress;
|
||||
public UInt32 ARM9ramAddress;
|
||||
public UInt32 ARM9size;
|
||||
public UInt32 ARM7romOffset;
|
||||
public UInt32 ARM7entryAddress;
|
||||
public UInt32 ARM7ramAddress;
|
||||
public UInt32 ARM7size;
|
||||
public UInt32 fileNameTableOffset;
|
||||
public UInt32 fileNameTableSize;
|
||||
public UInt32 FAToffset; // File Allocation Table offset
|
||||
public UInt32 FATsize; // File Allocation Table size
|
||||
public UInt32 ARM9overlayOffset; // ARM9 overlay file offset
|
||||
public UInt32 ARM9overlaySize;
|
||||
public UInt32 ARM7overlayOffset;
|
||||
public UInt32 ARM7overlaySize;
|
||||
public UInt32 flagsRead; // Control register flags for read
|
||||
public UInt32 flagsInit; // Control register flags for init
|
||||
public UInt32 bannerOffset; // Icon + titles offset
|
||||
public UInt16 secureCRC16; // Secure area CRC16 0x4000 - 0x7FFF
|
||||
public UInt16 ROMtimeout;
|
||||
public UInt32 ARM9autoload;
|
||||
public UInt32 ARM7autoload;
|
||||
public UInt64 secureDisable; // Magic number for unencrypted mode
|
||||
public UInt32 ROMsize;
|
||||
public UInt32 headerSize;
|
||||
public byte[] reserved2; // 56 bytes
|
||||
//public byte[] logo; // 156 bytes de un logo de nintendo usado para comprobaciones de seguridad
|
||||
public UInt16 logoCRC16;
|
||||
public UInt16 headerCRC16;
|
||||
public bool secureCRC;
|
||||
public bool logoCRC;
|
||||
public bool headerCRC;
|
||||
// TODO: completar datos de Nitro system desde gbatek
|
||||
|
||||
}
|
||||
public struct Banner
|
||||
{
|
||||
public UInt16 version; // Always 1
|
||||
public UInt16 CRC16; // CRC-16 of structure, not including first 32 bytes
|
||||
public bool checkCRC;
|
||||
public byte[] reserved; // 28 bytes
|
||||
public byte[] tileData; // 512 bytes
|
||||
public byte[] palette; // 32 bytes
|
||||
public string japaneseTitle;// 256 bytes
|
||||
public string englishTitle; // 256 bytes
|
||||
public string frenchTitle; // 256 bytes
|
||||
public string germanTitle; // 256 bytes
|
||||
public string italianTitle; // 256 bytes
|
||||
public string spanishTitle; // 256 bytes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Estructura de las tablas principales dentro del archivos FNT. Cada una corresponde
|
||||
/// a un directorio.
|
||||
/// </summary>
|
||||
public struct MainFNT
|
||||
{
|
||||
public UInt32 offset; // OffSet de la SubTable relativa al archivo FNT
|
||||
public UInt16 idFirstFile; // ID del primer archivo que contiene. Puede corresponder a uno que contenga un directorio interno
|
||||
public UInt16 idParentFolder; // ID del directorio padre de éste
|
||||
public Folder subTable; // SubTable que contiene los nombres de archivos y carpetas que contiene el directorio
|
||||
}
|
||||
public struct File
|
||||
{
|
||||
public UInt32 offset; // Offset dentro de la ROM
|
||||
public UInt32 size; // Tamaño definido por la resta del offset inicial y el offset final
|
||||
public string name; // Nombre dado en la FNT
|
||||
public UInt16 id; // ID único de cada archivo.
|
||||
public string path; // En caso de haber sido descomprimido y estar fuera del sistema de archivos.
|
||||
}
|
||||
public struct Folder
|
||||
{
|
||||
public List<File> files; // Lista de archivos que contiene el directorio
|
||||
public List<Folder> folders; // Lista de carpetas que contiene el directorio
|
||||
public string name; // Nombre de la carpeta
|
||||
public UInt16 id; // ID de la carpeta. Comienza en 0xF000 que es root
|
||||
}
|
||||
|
||||
public struct ARMOverlay
|
||||
{
|
||||
public UInt32 OverlayID;
|
||||
public UInt32 RAM_Adress; // Point at which to load
|
||||
public UInt32 RAM_Size; // Amount to load
|
||||
public UInt32 BSS_Size; // Size of BSS data region
|
||||
public UInt32 stInitStart; // Static initialiser start address
|
||||
public UInt32 stInitEnd; // Static initialiser end address
|
||||
public UInt32 fileID;
|
||||
public UInt32 reserved;
|
||||
public bool ARM9; // Si es true es ARM9, sino es ARM7
|
||||
}
|
||||
}
|
||||
|
||||
public enum Unitcode
|
||||
{
|
||||
NintendoDS = 00
|
||||
}
|
||||
public enum Makercode
|
||||
{
|
||||
Nintendo = 4849,
|
||||
}
|
||||
}
|
53
Tinke/Nitro/FAT.cs
Normal file
53
Tinke/Nitro/FAT.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Tinke.Nitro
|
||||
{
|
||||
public static class FAT
|
||||
{
|
||||
public static Nitro.Estructuras.Folder LeerFAT(string file, UInt32 offset, UInt32 size, Estructuras.Folder root)
|
||||
{
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = offset;
|
||||
|
||||
for (int i = 0; ; i++)
|
||||
{
|
||||
if (br.BaseStream.Position > offset + size)
|
||||
break;
|
||||
|
||||
UInt32 currOffset = br.ReadUInt32();
|
||||
UInt32 currSize = br.ReadUInt32() - currOffset;
|
||||
Asignar_Archivo(i, currOffset, currSize, root);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public static void Asignar_Archivo(int id, UInt32 offset, UInt32 size, Estructuras.Folder currFolder)
|
||||
{
|
||||
if (currFolder.files is List<Estructuras.File>)
|
||||
{
|
||||
for (int i = 0; i < currFolder.files.Count; i++)
|
||||
{
|
||||
if (currFolder.files[i].id == id)
|
||||
{
|
||||
Estructuras.File newFile = currFolder.files[i];
|
||||
newFile.offset = offset;
|
||||
newFile.size = size;
|
||||
currFolder.files.RemoveAt(i);
|
||||
currFolder.files.Insert(i, newFile);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currFolder.folders is List<Estructuras.Folder>)
|
||||
foreach (Estructuras.Folder subFolder in currFolder.folders)
|
||||
Asignar_Archivo(id, offset, size, subFolder);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
111
Tinke/Nitro/FNT.cs
Normal file
111
Tinke/Nitro/FNT.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Tinke.Nitro
|
||||
{
|
||||
/// <summary>
|
||||
/// File Name Table.
|
||||
/// </summary>
|
||||
public static class FNT
|
||||
{
|
||||
/// <summary>
|
||||
/// Devuelve el sistema de archivos internos de la ROM
|
||||
/// </summary>
|
||||
/// <param name="file">Archivo ROM</param>
|
||||
/// <param name="offset">Offset donde comienza la FNT</param>
|
||||
/// <returns></returns>
|
||||
public static Estructuras.Folder LeerFNT(string file, UInt32 offset)
|
||||
{
|
||||
Estructuras.Folder root = new Estructuras.Folder();
|
||||
List<Estructuras.MainFNT> mains = new List<Estructuras.MainFNT>();
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = offset;
|
||||
|
||||
long offsetSubTable = br.ReadUInt32(); // Offset donde comienzan las SubTable y terminan las MainTables.
|
||||
br.BaseStream.Position = offset; // Volvemos al principio de la primera MainTable
|
||||
|
||||
while (br.BaseStream.Position < offset + offsetSubTable)
|
||||
{
|
||||
Estructuras.MainFNT main = new Estructuras.MainFNT();
|
||||
main.offset = br.ReadUInt32();
|
||||
main.idFirstFile = br.ReadUInt16();
|
||||
main.idParentFolder = br.ReadUInt16();
|
||||
|
||||
long currOffset = br.BaseStream.Position; // Posición guardada donde empieza la siguienta maintable
|
||||
br.BaseStream.Position = offset + main.offset; // SubTable correspondiente
|
||||
|
||||
// SubTable
|
||||
byte id = br.ReadByte(); // Byte que identifica si es carpeta o archivo.
|
||||
ushort idFile = main.idFirstFile;
|
||||
|
||||
while (id != 0x0) // Indicador de fin de la SubTable
|
||||
{
|
||||
if (id < 0x80) // Archivo
|
||||
{
|
||||
Estructuras.File currFile = new Estructuras.File();
|
||||
|
||||
if (!(main.subTable.files is List<Estructuras.File>))
|
||||
main.subTable.files = new List<Estructuras.File>();
|
||||
|
||||
int lengthName = id;
|
||||
currFile.name = new String(br.ReadChars(lengthName));
|
||||
currFile.id = idFile; idFile++;
|
||||
|
||||
main.subTable.files.Add(currFile);
|
||||
}
|
||||
if (id > 0x80) // Directorio
|
||||
{
|
||||
Estructuras.Folder currFolder = new Estructuras.Folder();
|
||||
|
||||
if (!(main.subTable.folders is List<Estructuras.Folder>))
|
||||
main.subTable.folders = new List<Estructuras.Folder>();
|
||||
|
||||
int lengthName = id - 0x80;
|
||||
currFolder.name = new String(br.ReadChars(lengthName));
|
||||
currFolder.id = br.ReadUInt16();
|
||||
|
||||
main.subTable.folders.Add(currFolder);
|
||||
}
|
||||
|
||||
id = br.ReadByte();
|
||||
}
|
||||
|
||||
mains.Add(main);
|
||||
br.BaseStream.Position = currOffset;
|
||||
}
|
||||
|
||||
root = Jerarquizar_Carpetas(mains, 0, "root");
|
||||
root.id = 0xF000;
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public static Estructuras.Folder Jerarquizar_Carpetas(List<Estructuras.MainFNT> tables, int idFolder, string nameFolder)
|
||||
{
|
||||
Estructuras.Folder currFolder = new Estructuras.Folder();
|
||||
|
||||
currFolder.name = nameFolder;
|
||||
currFolder.id = (ushort)idFolder;
|
||||
currFolder.files = tables[idFolder & 0xFFF].subTable.files;
|
||||
|
||||
if (tables[idFolder & 0xFFF].subTable.folders is List<Estructuras.Folder>) // Si tiene carpetas dentro.
|
||||
{
|
||||
currFolder.folders = new List<Estructuras.Folder>();
|
||||
|
||||
foreach (Estructuras.Folder subFolder in tables[idFolder & 0xFFF].subTable.folders)
|
||||
currFolder.folders.Add(Jerarquizar_Carpetas(tables, subFolder.id, subFolder.name));
|
||||
}
|
||||
|
||||
return currFolder;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
313
Tinke/Nitro/MakerCodes.txt
Normal file
313
Tinke/Nitro/MakerCodes.txt
Normal file
@ -0,0 +1,313 @@
|
||||
// Ir añadiendo y eliminando de la lista. Añadir en la clase estática Estructuras en Nitro.Estructuras.MakerCodes.
|
||||
// Poner como valor en la enumeración la conversación a UTF32 de los caracteres hexadecimal. Ej: 01= 0x4849
|
||||
|
||||
{ "02", "Rocket Games, Ajinomoto" },
|
||||
{ "03", "Imagineer-Zoom" },
|
||||
{ "04", "Gray Matter?" },
|
||||
{ "05", "Zamuse" },
|
||||
{ "06", "Falcom" },
|
||||
{ "07", "Enix?" },
|
||||
{ "08", "Capcom" },
|
||||
{ "09", "Hot B Co." },
|
||||
{ "0A", "Jaleco" },
|
||||
{ "0B", "Coconuts Japan" },
|
||||
{ "0C", "Coconuts Japan/G.X.Media" },
|
||||
{ "0D", "Micronet?" },
|
||||
{ "0E", "Technos" },
|
||||
{ "0F", "Mebio Software" },
|
||||
{ "0G", "Shouei System" },
|
||||
{ "0H", "Starfish" },
|
||||
{ "0J", "Mitsui Fudosan/Dentsu" },
|
||||
{ "0L", "Warashi Inc." },
|
||||
{ "0N", "Nowpro" },
|
||||
{ "0P", "Game Village" },
|
||||
{ "10", "?????????????" },
|
||||
{ "12", "Infocom" },
|
||||
{ "13", "Electronic Arts Japan" },
|
||||
{ "15", "Cobra Team" },
|
||||
{ "16", "Human/Field" },
|
||||
{ "17", "KOEI" },
|
||||
{ "18", "Hudson Soft" },
|
||||
{ "19", "S.C.P." },
|
||||
{ "1A", "Yanoman" },
|
||||
{ "1C", "Tecmo Products" },
|
||||
{ "1D", "Japan Glary Business" },
|
||||
{ "1E", "Forum/OpenSystem" },
|
||||
{ "1F", "Virgin Games" },
|
||||
{ "1G", "SMDE" },
|
||||
{ "1J", "Daikokudenki" },
|
||||
{ "1P", "Creatures Inc." },
|
||||
{ "1Q", "TDK Deep Impresion" },
|
||||
{ "20", "Destination Software, KSS" },
|
||||
{ "21", "Sunsoft/Tokai Engineering??" },
|
||||
{ "22", "POW, VR 1 Japan??" },
|
||||
{ "23", "Micro World" },
|
||||
{ "25", "San-X" },
|
||||
{ "26", "Enix" },
|
||||
{ "27", "Loriciel/Electro Brain" },
|
||||
{ "28", "Kemco Japan" },
|
||||
{ "29", "Seta" },
|
||||
{ "2A", "Culture Brain" },
|
||||
{ "2C", "Palsoft" },
|
||||
{ "2D", "Visit Co.,Ltd." },
|
||||
{ "2E", "Intec" },
|
||||
{ "2F", "System Sacom" },
|
||||
{ "2G", "Poppo" },
|
||||
{ "2H", "Ubisoft Japan" },
|
||||
{ "2J", "Media Works" },
|
||||
{ "2K", "NEC InterChannel" },
|
||||
{ "2L", "Tam" },
|
||||
{ "2M", "Jordan" },
|
||||
{ "2N", "Smilesoft ???, Rocket ???" },
|
||||
{ "2Q", "Mediakite" },
|
||||
{ "30", "Viacom" },
|
||||
{ "31", "Carrozzeria" },
|
||||
{ "32", "Dynamic" },
|
||||
// { "33", "NOT A COMPANY!" },
|
||||
{ "34", "Magifact" },
|
||||
{ "35", "Hect" },
|
||||
{ "36", "Codemasters" },
|
||||
{ "37", "Taito/GAGA Communications" },
|
||||
{ "38", "Laguna" },
|
||||
{ "39", "Telstar Fun & Games, Event/Taito" },
|
||||
{ "3B", "Arcade Zone Ltd" },
|
||||
{ "3C", "Entertainment International/Empire Software?" },
|
||||
{ "3D", "Loriciel" },
|
||||
{ "3E", "Gremlin Graphics" },
|
||||
{ "3F", "K.Amusement Leasing Co." },
|
||||
{ "40", "Seika Corp." },
|
||||
{ "41", "Ubi Soft Entertainment" },
|
||||
{ "42", "Sunsoft US?" },
|
||||
{ "44", "Life Fitness" },
|
||||
{ "46", "System 3" },
|
||||
{ "47", "Spectrum Holobyte" },
|
||||
{ "49", "IREM" },
|
||||
{ "4B", "Raya Systems" },
|
||||
{ "4C", "Renovation Products" },
|
||||
{ "4D", "Malibu Games" },
|
||||
{ "4F", "Eidos (was U.S. Gold <=1995)" },
|
||||
{ "4G", "Playmates Interactive?" },
|
||||
{ "4J", "Fox Interactive" },
|
||||
{ "4K", "Time Warner Interactive" },
|
||||
{ "4Q", "Disney Interactive" },
|
||||
{ "4S", "Black Pearl" },
|
||||
{ "4U", "Advanced Productions" },
|
||||
{ "4X", "GT Interactive" },
|
||||
{ "4Y", "RARE?" },
|
||||
{ "4Z", "Crave Entertainment" },
|
||||
{ "50", "Absolute Entertainment" },
|
||||
{ "51", "Acclaim" },
|
||||
{ "52", "Activision" },
|
||||
{ "53", "American Sammy" },
|
||||
{ "54", "Take 2 Interactive (before it was GameTek)" },
|
||||
{ "55", "Hi Tech" },
|
||||
{ "56", "LJN LTD." },
|
||||
{ "58", "Mattel" },
|
||||
{ "5A", "Mindscape, Red Orb Entertainment?" },
|
||||
{ "5B", "Romstar" },
|
||||
{ "5C", "Taxan" },
|
||||
{ "5D", "Midway (before it was Tradewest)" },
|
||||
{ "5F", "American Softworks" },
|
||||
{ "5G", "Majesco Sales Inc" },
|
||||
{ "5H", "3DO" },
|
||||
{ "5K", "Hasbro" },
|
||||
{ "5L", "NewKidCo" },
|
||||
{ "5M", "Telegames" },
|
||||
{ "5N", "Metro3D" },
|
||||
{ "5P", "Vatical Entertainment" },
|
||||
{ "5Q", "LEGO Media" },
|
||||
{ "5S", "Xicat Interactive" },
|
||||
{ "5T", "Cryo Interactive" },
|
||||
{ "5W", "Red Storm Entertainment" },
|
||||
{ "5X", "Microids" },
|
||||
{ "5Z", "Conspiracy/Swing" },
|
||||
{ "60", "Titus" },
|
||||
{ "61", "Virgin Interactive" },
|
||||
{ "62", "Maxis" },
|
||||
{ "64", "LucasArts Entertainment" },
|
||||
{ "67", "Ocean" },
|
||||
{ "69", "Electronic Arts" },
|
||||
{ "6B", "Laser Beam" },
|
||||
{ "6E", "Elite Systems" },
|
||||
{ "6F", "Electro Brain" },
|
||||
{ "6G", "The Learning Company" },
|
||||
{ "6H", "BBC" },
|
||||
{ "6J", "Software 2000" },
|
||||
{ "6L", "BAM! Entertainment" },
|
||||
{ "6M", "Studio 3" },
|
||||
{ "6Q", "Classified Games" },
|
||||
{ "6S", "TDK Mediactive" },
|
||||
{ "6U", "DreamCatcher" },
|
||||
{ "6V", "JoWood Produtions" },
|
||||
{ "6W", "SEGA" },
|
||||
{ "6X", "Wannado Edition" },
|
||||
{ "6Y", "LSP" },
|
||||
{ "6Z", "ITE Media" },
|
||||
{ "70", "Infogrames" },
|
||||
{ "71", "Interplay" },
|
||||
{ "72", "JVC" },
|
||||
{ "73", "Parker Brothers" },
|
||||
{ "75", "Sales Curve" },
|
||||
{ "78", "THQ" },
|
||||
{ "79", "Accolade" },
|
||||
{ "7A", "Triffix Entertainment" },
|
||||
{ "7C", "Microprose Software" },
|
||||
{ "7D", "Universal Interactive, Sierra, Simon & Schuster?" },
|
||||
{ "7F", "Kemco" },
|
||||
{ "7G", "Rage Software" },
|
||||
{ "7H", "Encore" },
|
||||
{ "7J", "Zoo" },
|
||||
{ "7K", "BVM" },
|
||||
{ "7L", "Simon & Schuster Interactive" },
|
||||
{ "7M", "Asmik Ace Entertainment Inc./AIA" },
|
||||
{ "7N", "Empire Interactive?" },
|
||||
{ "7Q", "Jester Interactive" },
|
||||
{ "7T", "Scholastic" },
|
||||
{ "7U", "Ignition Entertainment" },
|
||||
{ "7W", "Stadlbauer" },
|
||||
{ "80", "Misawa" },
|
||||
{ "81", "Teichiku" },
|
||||
{ "82", "Namco Ltd." },
|
||||
{ "83", "LOZC" },
|
||||
{ "84", "KOEI" },
|
||||
{ "86", "Tokuma Shoten Intermedia" },
|
||||
{ "87", "Tsukuda Original" },
|
||||
{ "88", "DATAM-Polystar" },
|
||||
{ "8B", "Bulletproof Software" },
|
||||
{ "8C", "Vic Tokai Inc." },
|
||||
{ "8E", "Character Soft" },
|
||||
{ "8F", "I'Max" },
|
||||
{ "8G", "Saurus" },
|
||||
{ "8J", "General Entertainment" },
|
||||
{ "8N", "Success" },
|
||||
{ "8P", "SEGA Japan" },
|
||||
{ "90", "Takara Amusement" },
|
||||
{ "91", "Chun Soft" },
|
||||
{ "92", "Video System, McO'River???" },
|
||||
{ "93", "BEC" },
|
||||
{ "95", "Varie" },
|
||||
{ "96", "Yonezawa/S'pal" },
|
||||
{ "97", "Kaneko" },
|
||||
{ "99", "Victor Interactive Software, Pack in Video" },
|
||||
{ "9A", "Nichibutsu/Nihon Bussan" },
|
||||
{ "9B", "Tecmo" },
|
||||
{ "9C", "Imagineer" },
|
||||
{ "9F", "Nova" },
|
||||
{ "9G", "Den'Z" },
|
||||
{ "9H", "Bottom Up" },
|
||||
{ "9J", "TGL" },
|
||||
{ "9L", "Hasbro Japan?" },
|
||||
{ "9N", "Marvelous Entertainment" },
|
||||
{ "9P", "Keynet Inc." },
|
||||
{ "9Q", "Hands-On Entertainment" },
|
||||
{ "A0", "Telenet" },
|
||||
{ "A1", "Hori" },
|
||||
{ "A4", "Konami" },
|
||||
{ "A5", "K.Amusement Leasing Co." },
|
||||
{ "A6", "Kawada" },
|
||||
{ "A7", "Takara" },
|
||||
{ "A9", "Technos Japan Corp." },
|
||||
{ "AA", "JVC, Victor Musical Indutries" },
|
||||
{ "AC", "Toei Animation" },
|
||||
{ "AD", "Toho" },
|
||||
{ "AF", "Namco" },
|
||||
{ "AG", "Media Rings Corporation" },
|
||||
{ "AH", "J-Wing" },
|
||||
{ "AJ", "Pioneer LDC" },
|
||||
{ "AK", "KID" },
|
||||
{ "AL", "Mediafactory" },
|
||||
{ "AP", "Infogrames Hudson" },
|
||||
{ "AQ", "Kiratto. Ludic Inc" },
|
||||
{ "B0", "Acclaim Japan" },
|
||||
{ "B1", "ASCII (was Nexoft?)" },
|
||||
{ "B2", "Bandai" },
|
||||
{ "B4", "Enix" },
|
||||
{ "B6", "HAL Laboratory" },
|
||||
{ "B7", "SNK" },
|
||||
{ "B9", "Pony Canyon" },
|
||||
{ "BA", "Culture Brain" },
|
||||
{ "BB", "Sunsoft" },
|
||||
{ "BC", "Toshiba EMI" },
|
||||
{ "BD", "Sony Imagesoft" },
|
||||
{ "BF", "Sammy" },
|
||||
{ "BG", "Magical" },
|
||||
{ "BH", "Visco" },
|
||||
{ "BJ", "Compile " },
|
||||
{ "BL", "MTO Inc." },
|
||||
{ "BN", "Sunrise Interactive" },
|
||||
{ "BP", "Global A Entertainment" },
|
||||
{ "BQ", "Fuuki" },
|
||||
{ "C0", "Taito" },
|
||||
{ "C2", "Kemco" },
|
||||
{ "C3", "Square" },
|
||||
{ "C4", "Tokuma Shoten" },
|
||||
{ "C5", "Data East" },
|
||||
{ "C6", "Tonkin House (was Tokyo Shoseki)" },
|
||||
{ "C8", "Koei" },
|
||||
{ "CA", "Konami/Ultra/Palcom" },
|
||||
{ "CB", "NTVIC/VAP" },
|
||||
{ "CC", "Use Co.,Ltd." },
|
||||
{ "CD", "Meldac" },
|
||||
{ "CE", "Pony Canyon" },
|
||||
{ "CF", "Angel, Sotsu Agency/Sunrise" },
|
||||
{ "CJ", "Boss" },
|
||||
{ "CG", "Yumedia/Aroma Co., Ltd" },
|
||||
{ "CK", "Axela/Crea-Tech?" },
|
||||
{ "CL", "Sekaibunka-Sha, Sumire kobo?, Marigul Management Inc.?" },
|
||||
{ "CM", "Konami Computer Entertainment Osaka" },
|
||||
{ "CP", "Enterbrain" },
|
||||
{ "D0", "Taito/Disco" },
|
||||
{ "D1", "Sofel" },
|
||||
{ "D2", "Quest, Bothtec" },
|
||||
{ "D3", "Sigma, ?????" },
|
||||
{ "D4", "Ask Kodansha" },
|
||||
{ "D6", "Naxat" },
|
||||
{ "D7", "Copya System" },
|
||||
{ "D8", "Capcom Co., Ltd." },
|
||||
{ "D9", "Banpresto" },
|
||||
{ "DA", "TOMY" },
|
||||
{ "DB", "LJN Japan" },
|
||||
{ "DD", "NCS" },
|
||||
{ "DE", "Human Entertainment" },
|
||||
{ "DF", "Altron" },
|
||||
{ "DG", "Jaleco???" },
|
||||
{ "DH", "Gaps Inc." },
|
||||
{ "DL", "????" },
|
||||
{ "DN", "Elf" },
|
||||
{ "E0", "Jaleco" },
|
||||
{ "E1", "????" },
|
||||
{ "E2", "Yutaka" },
|
||||
{ "E3", "Varie" },
|
||||
{ "E4", "T&ESoft" },
|
||||
{ "E5", "Epoch" },
|
||||
{ "E7", "Athena" },
|
||||
{ "E8", "Asmik" },
|
||||
{ "E9", "Natsume" },
|
||||
{ "EA", "King Records" },
|
||||
{ "EB", "Atlus" },
|
||||
{ "EC", "Epic/Sony Records" },
|
||||
{ "EE", "IGS" },
|
||||
{ "EG", "Chatnoir" },
|
||||
{ "EH", "Right Stuff" },
|
||||
{ "EJ", "????" },
|
||||
{ "EL", "Spike" },
|
||||
{ "EM", "Konami Computer Entertainment Tokyo" },
|
||||
{ "EN", "Alphadream Corporation" },
|
||||
{ "F0", "A Wave" },
|
||||
{ "F1", "Motown Software" },
|
||||
{ "F2", "Left Field Entertainment" },
|
||||
{ "F3", "Extreme Ent. Grp." },
|
||||
{ "F4", "TecMagik" },
|
||||
{ "F9", "Cybersoft" },
|
||||
{ "FB", "Psygnosis" },
|
||||
{ "FE", "Davidson/Western Tech." },
|
||||
{ "G1", "PCCW Japan" },
|
||||
{ "G4", "KiKi Co Ltd" },
|
||||
{ "G5", "Open Sesame Inc???" },
|
||||
{ "G6", "Sims" },
|
||||
{ "G7", "Broccoli" },
|
||||
{ "G8", "Avex" },
|
||||
{ "G9", "D3 Publisher" },
|
||||
{ "GB", "Konami Computer Entertainment Japan" },
|
||||
{ "GD", "Square-Enix" },
|
||||
{ "IH", "Yojigen" }
|
149
Tinke/Nitro/NDS.cs
Normal file
149
Tinke/Nitro/NDS.cs
Normal file
@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Tinke.Nitro
|
||||
{
|
||||
public static class NDS
|
||||
{
|
||||
public static Estructuras.ROMHeader LeerCabecera(string file)
|
||||
{
|
||||
Estructuras.ROMHeader nds = new Estructuras.ROMHeader();
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
Console.WriteLine("Analizando ROM: " + new FileInfo(file).Name);
|
||||
|
||||
nds.gameTitle = br.ReadChars(12);
|
||||
nds.gameCode = br.ReadChars(4);
|
||||
nds.makerCode = br.ReadChars(2);
|
||||
nds.unitCode = br.ReadChar();
|
||||
nds.encryptionSeed = br.ReadByte();
|
||||
nds.tamaño = (UInt32)Math.Pow(2, 20 + br.ReadByte());
|
||||
nds.reserved = br.ReadBytes(9);
|
||||
nds.ROMversion = br.ReadByte();
|
||||
nds.internalFlags = br.ReadByte();
|
||||
nds.ARM9romOffset = br.ReadUInt32();
|
||||
nds.ARM9entryAddress = br.ReadUInt32();
|
||||
nds.ARM9ramAddress = br.ReadUInt32();
|
||||
nds.ARM9size = br.ReadUInt32();
|
||||
nds.ARM7romOffset = br.ReadUInt32();
|
||||
nds.ARM7entryAddress = br.ReadUInt32();
|
||||
nds.ARM7ramAddress = br.ReadUInt32();
|
||||
nds.ARM7size = br.ReadUInt32();
|
||||
nds.fileNameTableOffset = br.ReadUInt32();
|
||||
nds.fileNameTableSize = br.ReadUInt32();
|
||||
nds.FAToffset = br.ReadUInt32();
|
||||
nds.FATsize = br.ReadUInt32();
|
||||
nds.ARM9overlayOffset = br.ReadUInt32();
|
||||
nds.ARM9overlaySize = br.ReadUInt32();
|
||||
nds.ARM7overlayOffset = br.ReadUInt32();
|
||||
nds.ARM7overlaySize = br.ReadUInt32();
|
||||
nds.flagsRead = br.ReadUInt32();
|
||||
nds.flagsInit = br.ReadUInt32();
|
||||
nds.bannerOffset = br.ReadUInt32();
|
||||
nds.secureCRC16 = br.ReadUInt16();
|
||||
nds.ROMtimeout = br.ReadUInt16();
|
||||
nds.ARM9autoload = br.ReadUInt32();
|
||||
nds.ARM7autoload = br.ReadUInt32();
|
||||
nds.secureDisable = br.ReadUInt64();
|
||||
nds.ROMsize = br.ReadUInt32();
|
||||
nds.headerSize = br.ReadUInt32();
|
||||
nds.reserved2 = br.ReadBytes(56);
|
||||
br.BaseStream.Seek(156, SeekOrigin.Current); //nds.logo = br.ReadBytes(156); Logo de Nintendo utilizado para comprobaciones
|
||||
nds.logoCRC16 = br.ReadUInt16();
|
||||
nds.headerCRC16 = br.ReadUInt16();
|
||||
|
||||
br.BaseStream.Position = 0x4000;
|
||||
nds.secureCRC = (Tools.CRC16.Calcular(br.ReadBytes(0x4000)) == nds.secureCRC16) ? true : false;
|
||||
br.BaseStream.Position = 0xC0;
|
||||
nds.logoCRC = (Tools.CRC16.Calcular(br.ReadBytes(156)) == nds.logoCRC16) ? true : false;
|
||||
br.BaseStream.Position = 0x0;
|
||||
nds.headerCRC = (Tools.CRC16.Calcular(br.ReadBytes(0x15E)) == nds.headerCRC16) ? true : false;
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return nds;
|
||||
}
|
||||
public static string CodeToString(Type enumeracion, char[] id)
|
||||
{
|
||||
try { return Enum.GetName(enumeracion, Int32.Parse(Char.ConvertToUtf32(Char.ToString(id[0]), 0).ToString() + Char.ConvertToUtf32(char.ToString(id[1]), 0).ToString())); }
|
||||
catch { return "Desconocido"; }
|
||||
}
|
||||
public static string CodeToString(Type enumeracion, char id)
|
||||
{
|
||||
try { return Enum.GetName(enumeracion, Char.ConvertToUtf32(char.ToString(id), 0)); }
|
||||
catch { return "Desconocido"; }
|
||||
}
|
||||
|
||||
public static Estructuras.Banner LeerBanner(string file, UInt32 offset)
|
||||
{
|
||||
Estructuras.Banner bn = new Estructuras.Banner();
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = offset;
|
||||
|
||||
bn.version = br.ReadUInt16();
|
||||
bn.CRC16 = br.ReadUInt16();
|
||||
bn.reserved = br.ReadBytes(0x1C);
|
||||
bn.tileData = br.ReadBytes(0x200);
|
||||
bn.palette = br.ReadBytes(0x20);
|
||||
bn.japaneseTitle = TitleToString(br.ReadBytes(0x100));
|
||||
bn.englishTitle = TitleToString(br.ReadBytes(0x100));
|
||||
bn.frenchTitle = TitleToString(br.ReadBytes(0x100));
|
||||
bn.germanTitle = TitleToString(br.ReadBytes(0x100));
|
||||
bn.italianTitle = TitleToString(br.ReadBytes(0x100));
|
||||
bn.spanishTitle = TitleToString(br.ReadBytes(0x100));
|
||||
|
||||
br.BaseStream.Position = offset + 0x20;
|
||||
bn.checkCRC = (Tools.CRC16.Calcular(br.ReadBytes(0x820)) == bn.CRC16) ? true : false;
|
||||
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return bn;
|
||||
}
|
||||
public static string TitleToString(byte[] data)
|
||||
{
|
||||
string title = "";
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (data[i] == 0x00)
|
||||
continue;
|
||||
if (data[i] == 0x0A)
|
||||
title += '\r'; // Nueva línea
|
||||
|
||||
title += Char.ConvertFromUtf32(data[i]);
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
public static Bitmap IconoToBitmap(byte[] tileData, byte[] paletteData)
|
||||
{
|
||||
Bitmap imagen = new Bitmap(32, 32);
|
||||
Color[] paleta = Imagen.Paleta.Convertidor.BGR555(paletteData);
|
||||
|
||||
tileData = Tools.Helper.BytesTo4BitsRev(tileData);
|
||||
int i = 0;
|
||||
for (int hi = 0; hi < 4; hi++)
|
||||
{
|
||||
for (int wi = 0; wi < 4; wi++)
|
||||
{
|
||||
for (int h = 0; h < 8; h++)
|
||||
{
|
||||
for (int w = 0; w < 8; w++)
|
||||
{
|
||||
imagen.SetPixel(w + wi * 8, h + hi * 8, paleta[tileData[i]]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return imagen;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
54
Tinke/Nitro/Overlay.cs
Normal file
54
Tinke/Nitro/Overlay.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Tinke.Nitro
|
||||
{
|
||||
public static class Overlay
|
||||
{
|
||||
public static Estructuras.ARMOverlay[] LeerOverlays(string file, UInt32 offset, UInt32 size, bool arm9)
|
||||
{
|
||||
Estructuras.ARMOverlay[] overlays = new Estructuras.ARMOverlay[size / 0x20];
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
|
||||
for (int i = 0; i < overlays.Length; i++)
|
||||
{
|
||||
overlays[i] = new Estructuras.ARMOverlay();
|
||||
|
||||
overlays[i].fileID = br.ReadUInt32();
|
||||
overlays[i].RAM_Adress = br.ReadUInt32();
|
||||
overlays[i].RAM_Size = br.ReadUInt32();
|
||||
overlays[i].BSS_Size = br.ReadUInt32();
|
||||
overlays[i].stInitStart = br.ReadUInt32();
|
||||
overlays[i].stInitEnd = br.ReadUInt32();
|
||||
overlays[i].fileID = br.ReadUInt32();
|
||||
overlays[i].reserved = br.ReadUInt32();
|
||||
overlays[i].ARM9 = arm9;
|
||||
}
|
||||
|
||||
return overlays;
|
||||
}
|
||||
|
||||
public static Estructuras.File[] LeerOverlaysBasico(string file, UInt32 offset, UInt32 size, bool arm9)
|
||||
{
|
||||
Estructuras.File[] overlays = new Estructuras.File[size / 0x20];
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
br.BaseStream.Position = offset;
|
||||
|
||||
for (int i = 0; i < overlays.Length; i++)
|
||||
{
|
||||
overlays[i] = new Estructuras.File();
|
||||
overlays[i].name = "overlay" + (arm9 ? '9' : '7') + '_' + br.ReadUInt32();
|
||||
br.ReadBytes(20);
|
||||
overlays[i].id = (ushort)br.ReadUInt32();
|
||||
br.ReadBytes(4);
|
||||
|
||||
}
|
||||
|
||||
return overlays;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
37
Tinke/Program.cs
Normal file
37
Tinke/Program.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tinke
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Punto de entrada principal para la aplicación.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
if (args.Length != 2)
|
||||
Application.Run(new Form1());
|
||||
else if (args.Length == 2)
|
||||
Application.Run(new Form1(args[0], Convert.ToInt32(args[1])));
|
||||
|
||||
}
|
||||
|
||||
static void Info()
|
||||
{
|
||||
Console.WriteLine("¡Bienvenido a Tinke!, programa dedicado a la Scene o ingeniería inversa para la Consola Nintendo DS / DSL / DSi");
|
||||
Console.WriteLine("Este programa es totalmente gratuito y OpenSource, el código viene con el programa");
|
||||
Console.WriteLine("Información de uso del programa y sus herramientas:\n\n");
|
||||
Console.WriteLine("\tNarcTool 0.3 .NET:");
|
||||
Console.WriteLine("\t\tDesempaquetar archivos NARC: tinke narctool u Archivo.narc CarpetaDestino");
|
||||
Console.WriteLine("\tLZ77 0.1 .NET:");
|
||||
Console.WriteLine("\t\tDescomprimir archivos de compresión LZ77: tinke lz77 u archivo destino");
|
||||
}
|
||||
}
|
||||
}
|
36
Tinke/Properties/AssemblyInfo.cs
Normal file
36
Tinke/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// La información general sobre un ensamblado se controla mediante el siguiente
|
||||
// conjunto de atributos. Cambie estos atributos para modificar la información
|
||||
// asociada con un ensamblado.
|
||||
[assembly: AssemblyTitle("Tinke")]
|
||||
[assembly: AssemblyDescription("NDScene")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("pleoNeX")]
|
||||
[assembly: AssemblyProduct("Tinke")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2010 pleoNeX")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles
|
||||
// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
|
||||
// COM, establezca el atributo ComVisible como true en este tipo.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
|
||||
[assembly: Guid("1c265b8f-3f75-4fd8-83a6-7b1a2de4dd38")]
|
||||
|
||||
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
|
||||
//
|
||||
// Versión principal
|
||||
// Versión secundaria
|
||||
// Número de versión de compilación
|
||||
// Revisión
|
||||
//
|
||||
// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión
|
||||
// mediante el asterisco ('*'), como se muestra a continuación:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.2.0.4")]
|
||||
[assembly: AssemblyFileVersion("0.2.0.4")]
|
91
Tinke/Properties/Resources.Designer.cs
generated
Normal file
91
Tinke/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,91 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Tinke.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tinke.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap calculator {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("calculator", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap disk {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("disk", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap picture_save {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("picture_save", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap zoom {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("zoom", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
Tinke/Properties/Resources.resx
Normal file
133
Tinke/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="zoom" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\zoom.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="disk" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\disk.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="calculator" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\calculator.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="picture_save" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\picture_save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
26
Tinke/Properties/Settings.Designer.cs
generated
Normal file
26
Tinke/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Tinke.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
Tinke/Properties/Settings.settings
Normal file
7
Tinke/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
BIN
Tinke/Resources/calculator.png
Normal file
BIN
Tinke/Resources/calculator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 543 B |
BIN
Tinke/Resources/disk.png
Normal file
BIN
Tinke/Resources/disk.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 620 B |
BIN
Tinke/Resources/picture_save.png
Normal file
BIN
Tinke/Resources/picture_save.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 755 B |
BIN
Tinke/Resources/zoom.png
Normal file
BIN
Tinke/Resources/zoom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 692 B |
31
Tinke/Texto/TXT.cs
Normal file
31
Tinke/Texto/TXT.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Tinke.Texto
|
||||
{
|
||||
public static class TXT
|
||||
{
|
||||
public static string Leer(string file)
|
||||
{
|
||||
string txt = "";
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
|
||||
while (br.BaseStream.Position != br.BaseStream.Length - 1)
|
||||
{
|
||||
byte c = br.ReadByte();
|
||||
|
||||
if (c == 0x0A)
|
||||
txt += '\r';
|
||||
|
||||
txt += Char.ConvertFromUtf32(c);
|
||||
}
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
return txt;
|
||||
}
|
||||
}
|
||||
}
|
249
Tinke/Tinke.csproj
Normal file
249
Tinke/Tinke.csproj
Normal file
@ -0,0 +1,249 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0C21698B-0FC4-48E8-90FD-0DA70BFE9BB8}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Tinke</RootNamespace>
|
||||
<AssemblyName>Tinke</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<StartupObject>Tinke.Program</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>nintendo-ds.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Acciones.cs" />
|
||||
<Compile Include="DatosHex.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DatosHex.Designer.cs">
|
||||
<DependentUpon>DatosHex.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Espera.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Espera.Designer.cs">
|
||||
<DependentUpon>Espera.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Imagen\Estructuras.cs" />
|
||||
<Compile Include="Imagen\Paleta\Convertidor.cs" />
|
||||
<Compile Include="Imagen\Paleta\NCLR.cs" />
|
||||
<Compile Include="Imagen\Paleta\Estructuras.cs" />
|
||||
<Compile Include="Imagen\Screen\Estructuras.cs" />
|
||||
<Compile Include="Imagen\Screen\NSCR.cs" />
|
||||
<Compile Include="Imagen\Tile\Estructuras.cs" />
|
||||
<Compile Include="Imagen\Tile\iNCGR.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Imagen\Tile\iNCGR.Designer.cs">
|
||||
<DependentUpon>iNCGR.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Imagen\Tile\NCGR.cs" />
|
||||
<Compile Include="Juegos\Layton1.cs" />
|
||||
<Compile Include="Juegos\LaytonTalks.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Juegos\LaytonTalks.Designer.cs">
|
||||
<DependentUpon>LaytonTalks.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Nitro\Estructuras.cs" />
|
||||
<Compile Include="Nitro\FAT.cs" />
|
||||
<Compile Include="Nitro\FNT.cs" />
|
||||
<Compile Include="Nitro\NDS.cs" />
|
||||
<Compile Include="Nitro\Overlay.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Texto\TXT.cs" />
|
||||
<Compile Include="Tipos.cs" />
|
||||
<Compile Include="Tools\CRC16.cs" />
|
||||
<Compile Include="Tools\Helper.cs" />
|
||||
<EmbeddedResource Include="DatosHex.resx">
|
||||
<DependentUpon>DatosHex.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Espera.resx">
|
||||
<DependentUpon>Espera.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Imagen\Tile\iNCGR.resx">
|
||||
<DependentUpon>iNCGR.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Juegos\LaytonTalks.resx">
|
||||
<DependentUpon>LaytonTalks.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Compresion\Compresion.csproj">
|
||||
<Project>{13E418CF-056B-4A42-A31A-58DE8C7D8BEF}</Project>
|
||||
<Name>Compresion</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Imagen\Paleta\Notas.txt" />
|
||||
<Content Include="nintendo-ds.ico" />
|
||||
<Content Include="Nitro\MakerCodes.txt" />
|
||||
<None Include="Resources\picture_save.png" />
|
||||
<None Include="Resources\zoom.png" />
|
||||
<None Include="Resources\calculator.png" />
|
||||
<None Include="Resources\disk.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
37
Tinke/Tinke.csproj.user
Normal file
37
Tinke/Tinke.csproj.user
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
<StartWorkingDirectory>D:\Projectos\C#\Tinke - NDScene\Tinke - NDScene\bin\Debug\</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
<StartWorkingDirectory>D:\Projectos\C#\Tinke - NDScene\Compresion\bin\Debug\</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PublishUrlHistory />
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<StartWorkingDirectory>D:\Projectos\C#\Tinke - NDScene\Tinke - NDScene\bin\Debug\</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<StartWorkingDirectory>D:\Projectos\C#\Tinke - NDScene\Compresion\bin\Debug\</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<StartWorkingDirectory>D:\Projectos\C#\Tinke - NDScene\Tinke - NDScene\bin\Debug\</StartWorkingDirectory>
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<StartWorkingDirectory>D:\Projectos\C#\Tinke - NDScene\Compresion\bin\Debug\</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
</Project>
|
325
Tinke/Tipos.cs
Normal file
325
Tinke/Tipos.cs
Normal file
@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace Tinke
|
||||
{
|
||||
public static class Tipos
|
||||
{
|
||||
// Al añadir nuevo formato modificar funciones FormatFile y DoAction
|
||||
// Al añadir nuevo juego modificar funcion FormatFileGame y DoActionGame
|
||||
// Al añadir nuevo formato a un juego modificar funcion DoActionGame
|
||||
// Al modificar cualquiera comprobar método See_File en la clase Acciones y modificar según convenga.
|
||||
public static string[] soportados = new string[]
|
||||
{ "RLCN", "NCLR", "TXT", "NARC", "ARC", "NCGR", "RGCN", "NSCR", "RCSN" };
|
||||
public static string[] juegos = new string[] { "A5FP", "A5FE", "YLTS" };
|
||||
public enum Role
|
||||
{
|
||||
Paleta,
|
||||
Imagen,
|
||||
Screen,
|
||||
ImagenPaleta,
|
||||
ImagenCompleta,
|
||||
ImagenAnimada,
|
||||
Texto,
|
||||
Video,
|
||||
Sonido,
|
||||
Comprimido_NARC,
|
||||
Comprimido_LZ77,
|
||||
Comprimido_Huffman,
|
||||
Desconocido
|
||||
}
|
||||
public enum Pais
|
||||
{
|
||||
EUR,
|
||||
USA,
|
||||
JPN,
|
||||
NOE,
|
||||
ITA,
|
||||
SPA,
|
||||
HOL,
|
||||
KOR,
|
||||
EUU,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
public static int ImageFormatFile(Role name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case Role.Paleta:
|
||||
return 2;
|
||||
case Role.ImagenCompleta:
|
||||
return 10;
|
||||
case Role.ImagenAnimada:
|
||||
return 8;
|
||||
case Role.Texto:
|
||||
return 4;
|
||||
case Role.Comprimido_Huffman:
|
||||
case Role.Comprimido_LZ77:
|
||||
return 5;
|
||||
case Role.Comprimido_NARC:
|
||||
return 6;
|
||||
case Role.Imagen:
|
||||
return 3;
|
||||
case Role.Screen:
|
||||
return 9;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool EstaComprimido(Tipos.Role rol)
|
||||
{
|
||||
if (rol != Tipos.Role.Comprimido_LZ77 && rol != Tipos.Role.Comprimido_NARC && rol != Tipos.Role.Comprimido_Huffman)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
public static bool IsSupportedFile(string name)
|
||||
{
|
||||
if (FormatFile(name) == Role.Desconocido)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
public static string Extension(string name)
|
||||
{
|
||||
name = name.ToUpper();
|
||||
string ext = "";
|
||||
for (int i = 0; i < soportados.Length; i++)
|
||||
{
|
||||
if (name.EndsWith(soportados[i]))
|
||||
{
|
||||
ext = soportados[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
public static Role FormatFile(string name)
|
||||
{
|
||||
switch (Extension(name))
|
||||
{
|
||||
case "RLCN":
|
||||
case "NCLR":
|
||||
return Role.Paleta;
|
||||
case "RGCN":
|
||||
case "NCGR":
|
||||
return Role.Imagen;
|
||||
case "TXT":
|
||||
return Role.Texto;
|
||||
case "ARC":
|
||||
case "NARC":
|
||||
return Role.Comprimido_NARC;
|
||||
case "RCSN":
|
||||
case "NSCR":
|
||||
return Role.Screen;
|
||||
default:
|
||||
return Role.Desconocido;
|
||||
}
|
||||
}
|
||||
public static Object DoAction(string file, Role formato, string extension)
|
||||
{
|
||||
switch (formato)
|
||||
{
|
||||
case Role.Paleta:
|
||||
switch (extension)
|
||||
{
|
||||
case "RLCN":
|
||||
case "NCLR":
|
||||
return Imagen.Paleta.NCLR.Leer(file);
|
||||
}
|
||||
break;
|
||||
case Role.Imagen:
|
||||
switch (extension)
|
||||
{
|
||||
case "RGCN":
|
||||
case "NCGR":
|
||||
return Imagen.Tile.NCGR.Leer(file);
|
||||
}
|
||||
break;
|
||||
case Role.Texto:
|
||||
switch (extension)
|
||||
{
|
||||
case "TXT":
|
||||
return Texto.TXT.Leer(file);
|
||||
}
|
||||
break;
|
||||
case Role.Screen:
|
||||
switch (extension)
|
||||
{
|
||||
case "RCSN":
|
||||
case "NSCR":
|
||||
return Imagen.Screen.NSCR.Leer(file);
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new Exception("Excepción en DoAction: Formato no reconocido"); // Nunca puede darse el caso
|
||||
}
|
||||
|
||||
public static bool IsSupportedGame(string name)
|
||||
{
|
||||
name = name.ToUpper();
|
||||
|
||||
for (int i = 0; i < juegos.Length; i++)
|
||||
if (name == juegos[i])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
public static Pais GameCountry(string gameCode)
|
||||
{
|
||||
switch (gameCode[3])
|
||||
{
|
||||
case 'P':
|
||||
return Pais.EUR;
|
||||
case 'E':
|
||||
return Pais.USA;
|
||||
case 'J':
|
||||
return Pais.JPN;
|
||||
case 'D':
|
||||
case 'F':
|
||||
return Pais.NOE;
|
||||
case 'I':
|
||||
return Pais.ITA;
|
||||
case 'S':
|
||||
return Pais.SPA;
|
||||
case 'H':
|
||||
return Pais.HOL;
|
||||
case 'K':
|
||||
return Pais.KOR;
|
||||
case 'X':
|
||||
return Pais.EUU;
|
||||
default:
|
||||
return Pais.Unknown;
|
||||
}
|
||||
}
|
||||
public static Role FormatFileGame(string gameCode, int id, string name)
|
||||
{
|
||||
switch (gameCode)
|
||||
{
|
||||
case "A5FE":
|
||||
case "A5FP":
|
||||
case "YLTS": // LAYTON2 parece tener el mismo tipo de archivos.
|
||||
return Juegos.Layton1.FormatoArchivos(id, GameCountry(gameCode), name, gameCode);
|
||||
default:
|
||||
return Role.Desconocido;
|
||||
}
|
||||
}
|
||||
public static Object DoActionGame(string gameCode, string file, Role formato, int id, string name, Acciones accion)
|
||||
{
|
||||
name = name.ToUpper();
|
||||
|
||||
switch (gameCode)
|
||||
{
|
||||
case "YLTS":
|
||||
#region LAYTON2 SPA
|
||||
if (id >= 0x0037 && id <= 0x0408 && name.Contains("ARC"))
|
||||
{
|
||||
Compresion.Basico.Decompress2(file, file + ".un");
|
||||
System.IO.File.Delete(file);
|
||||
Object a5fp = Juegos.Layton1.Ani.Obtener_Final(file + ".un");
|
||||
System.IO.File.Delete(file + ".un");
|
||||
return a5fp;
|
||||
}
|
||||
else if (id >= 0x0409 && id <= 0x0808 && name.Contains("ARC"))
|
||||
{
|
||||
Compresion.Basico.Decompress2(file, file + ".un");
|
||||
System.IO.File.Delete(file);
|
||||
Object a5fp = Juegos.Layton1.Bg.Obtener_Imagen(file + ".un");
|
||||
System.IO.File.Delete(file + ".un");
|
||||
return a5fp;
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
case "A5FP":
|
||||
#region LAYTON1 EUR
|
||||
if (id >= 0x0001 && id <= 0x04E7 && name.Contains("ARC"))
|
||||
{
|
||||
Compresion.Basico.Decompress2(file, file + ".un");
|
||||
System.IO.File.Delete(file);
|
||||
Object a5fp = Juegos.Layton1.Ani.Obtener_Final(file + ".un");
|
||||
System.IO.File.Delete(file + ".un");
|
||||
return a5fp;
|
||||
}
|
||||
else if (id >= 0x04E8 && id <= 0x0B72)
|
||||
{
|
||||
Compresion.Basico.Decompress2(file, file + ".un");
|
||||
System.IO.File.Delete(file);
|
||||
Object a5fp = Juegos.Layton1.Bg.Obtener_Imagen(file + ".un");
|
||||
System.IO.File.Delete(file + ".un");
|
||||
return a5fp;
|
||||
}
|
||||
break;
|
||||
#endregion //LAYTON1 EUR
|
||||
case "A5FE":
|
||||
#region LAYTON1 USA
|
||||
if (id >= 0x0001 && id <= 0x02CB && name.EndsWith("ARC"))
|
||||
{
|
||||
Compresion.Basico.Decompress2(file, file + ".un");
|
||||
System.IO.File.Delete(file);
|
||||
Object a5fe = Juegos.Layton1.Ani.Obtener_Final(file + ".un");
|
||||
System.IO.File.Delete(file + ".un");
|
||||
return a5fe;
|
||||
}
|
||||
else if (id >= 0x02CD && id <= 0x0765) // bg
|
||||
{
|
||||
Compresion.Basico.Decompress2(file, file + ".un");
|
||||
System.IO.File.Delete(file);
|
||||
Object a5fe = Juegos.Layton1.Bg.Obtener_Imagen(file + ".un");
|
||||
System.IO.File.Delete(file + ".un");
|
||||
return a5fe;
|
||||
}
|
||||
#region TXT
|
||||
else if (name.EndsWith("DEBUG")) // No funciona bien... ya lo arreglaré..xD
|
||||
{
|
||||
string fileLay = Application.StartupPath + "\\temp2.dat";
|
||||
Nitro.Estructuras.File layton = accion.Search_File(0x013D);
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(accion.ROMFile));
|
||||
br.BaseStream.Position = layton.offset;
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(fileLay, FileMode.Create));
|
||||
bw.Write(br.ReadBytes((int)layton.size));
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
|
||||
Compresion.Basico.Decompress2(fileLay, fileLay + ".un");
|
||||
File.Delete(fileLay);
|
||||
|
||||
string fileFondo = Application.StartupPath + "\\temp3.dat";
|
||||
Nitro.Estructuras.File fondo = accion.Search_File(0x009D);
|
||||
br.BaseStream.Position = fondo.offset;
|
||||
|
||||
bw = new BinaryWriter(new FileStream(fileFondo, FileMode.Create));
|
||||
bw.Write(br.ReadBytes((int)fondo.size));
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
bw.Dispose();
|
||||
br.Close();
|
||||
br.Dispose();
|
||||
|
||||
Compresion.Basico.Decompress2(fileFondo, fileFondo + ".un");
|
||||
File.Delete(fileFondo);
|
||||
|
||||
Object a5fe = Juegos.Layton1.Txt.Obtener_Animacion(file, fileLay + ".un", fileFondo + ".un");
|
||||
File.Delete(fileLay + ".un");
|
||||
File.Delete(fileFondo + ".un");
|
||||
|
||||
return a5fe;
|
||||
}
|
||||
#endregion
|
||||
|
||||
break;
|
||||
#endregion //LAYTON1 USA
|
||||
}
|
||||
return new String('\0', 1); // Para que se distinga bien de lo demás xD
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
59
Tinke/Tools/CRC16.cs
Normal file
59
Tinke/Tools/CRC16.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Tinke.Tools
|
||||
{
|
||||
public static class CRC16
|
||||
{
|
||||
public static UInt32 Calcular(byte[] bytes, UInt32 init = 0xFFFF)
|
||||
{
|
||||
UInt32 crc = init;
|
||||
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
crc = (crc >> 8) ^ crc16tab[(crc ^ bytes[i]) & 0xFF];
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
private static ushort[] crc16tab =
|
||||
{
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
||||
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
|
||||
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
|
||||
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
|
||||
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
|
||||
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
|
||||
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
|
||||
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
|
||||
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
|
||||
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
|
||||
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
|
||||
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
|
||||
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
|
||||
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
|
||||
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
|
||||
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
|
||||
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
|
||||
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
|
||||
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
|
||||
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
|
||||
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
|
||||
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
|
||||
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
|
||||
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
|
||||
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
|
||||
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
|
||||
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
|
||||
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
|
||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
}
|
||||
}
|
206
Tinke/Tools/Helper.cs
Normal file
206
Tinke/Tools/Helper.cs
Normal file
@ -0,0 +1,206 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Tinke.Tools
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
public static string BytesToHexString(byte[] bytes)
|
||||
{
|
||||
string result = "0x";
|
||||
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
result += String.Format("{0:X}", bytes[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convierte una array de bytes en bits y les cambia el orden.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Array de bytes.</param>
|
||||
/// <returns>Array de bits.</returns>
|
||||
public static byte[] BytesTo4BitsRev(byte[] bytes)
|
||||
{
|
||||
byte[] bits = new Byte[bytes.Length * 2];
|
||||
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
string hex = DecToHex(bytes[i]);
|
||||
|
||||
bits[i * 2] = (byte)HexToSingleDec(hex[1]);
|
||||
bits[i * 2 + 1] = (byte)HexToSingleDec(hex[0]);
|
||||
}
|
||||
|
||||
return bits;
|
||||
}
|
||||
/// <summary>
|
||||
/// Convierte un byte en dos bits
|
||||
/// </summary>
|
||||
/// <param name="Byte">Byte para convertir</param>
|
||||
/// <returns>2 bytes que corresponden a los bits.</returns>
|
||||
public static byte[] ByteTo4Bits(byte Byte)
|
||||
{
|
||||
byte[] bits = new byte[2];
|
||||
|
||||
string hex = DecToHex(Byte);
|
||||
bits[0] = (byte)HexToSingleDec(hex[0]);
|
||||
bits[1] = (byte)HexToSingleDec(hex[1]);
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convierte números decimales a hexadecimales.
|
||||
/// </summary>
|
||||
/// <param name="x">Número decimal.</param>
|
||||
/// <returns>Número hexadecimal en string para que no se autoconvierta a decimal.</returns>
|
||||
public static string DecToHex(int x)
|
||||
{
|
||||
|
||||
if (x < 10) { return '0' + x.ToString(); }
|
||||
else if (x < 16) { return '0' + DecToSingleHex(x).ToString(); }
|
||||
else
|
||||
{
|
||||
string y = "";
|
||||
do
|
||||
{
|
||||
y = DecToSingleHex((x / 16)) + y;
|
||||
x = x % 16;
|
||||
} while (x > 15);
|
||||
|
||||
if (x < 10) { return y + x.ToString(); }
|
||||
else { return y + DecToSingleHex(x); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convierte los números decimales a la letra correspondiente en hexadecimal
|
||||
/// </summary>
|
||||
/// <param name="x">número decimal</param>
|
||||
/// <returns>Letra hexadecimal</returns>
|
||||
public static char DecToSingleHex(int x)
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
case 10:
|
||||
return 'A';
|
||||
case 11:
|
||||
return 'B';
|
||||
case 12:
|
||||
return 'C';
|
||||
case 13:
|
||||
return 'D';
|
||||
case 14:
|
||||
return 'E';
|
||||
case 15:
|
||||
return 'F';
|
||||
case 9:
|
||||
return '9';
|
||||
case 8:
|
||||
return '8';
|
||||
case 7:
|
||||
return '7';
|
||||
case 6:
|
||||
return '6';
|
||||
case 5:
|
||||
return '5';
|
||||
case 4:
|
||||
return '4';
|
||||
case 3:
|
||||
return '3';
|
||||
case 2:
|
||||
return '2';
|
||||
case 1:
|
||||
return '1';
|
||||
default:
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convierte de hexadecimal a decimal
|
||||
/// </summary>
|
||||
/// <param name="x">número hexadecimal</param>
|
||||
/// <returns>número decimal</returns>
|
||||
public static int HexToSingleDec(char x)
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
case 'A':
|
||||
return 10;
|
||||
case 'B':
|
||||
return 11;
|
||||
case 'C':
|
||||
return 12;
|
||||
case 'D':
|
||||
return 13;
|
||||
case 'E':
|
||||
return 14;
|
||||
case 'F':
|
||||
return 15;
|
||||
case '1':
|
||||
return 1;
|
||||
case '2':
|
||||
return 2;
|
||||
case '3':
|
||||
return 3;
|
||||
case '4':
|
||||
return 4;
|
||||
case '5':
|
||||
return 5;
|
||||
case '6':
|
||||
return 6;
|
||||
case '7':
|
||||
return 7;
|
||||
case '8':
|
||||
return 8;
|
||||
case '9':
|
||||
return 9;
|
||||
case '0':
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convierte un número hexadecimal en decimal
|
||||
/// </summary>
|
||||
/// <param name="hex">número hexadecimal</param>
|
||||
/// <returns>número decimal</returns>
|
||||
public static int HexToDec(string hex)
|
||||
{
|
||||
int resultado = 0;
|
||||
int[] numeros = new int[hex.Length];
|
||||
double j = 0;
|
||||
|
||||
for (int i = 0; i < hex.Length; i++)
|
||||
numeros[i] = HexToSingleDec(hex[i]);
|
||||
|
||||
for (int i = numeros.Length - 1; i >= 0; i--)
|
||||
{
|
||||
resultado += numeros[i] * (int)Math.Pow(2, j);
|
||||
j += 4;
|
||||
}
|
||||
|
||||
return resultado;
|
||||
}
|
||||
|
||||
public static string BytesToBits(byte[] bytes)
|
||||
{
|
||||
string bits = "";
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
bits = Convert.ToString(bytes[i], 2) + bits;
|
||||
for (int j = 0; j < (8 * (i + 1)); j++)
|
||||
if (bits.Length == j)
|
||||
bits = '0' + bits;
|
||||
}
|
||||
return bits;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
BIN
Tinke/nintendo-ds.ico
Normal file
BIN
Tinke/nintendo-ds.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 399 KiB |
Loading…
Reference in New Issue
Block a user