mirror of
https://github.com/R-YaTian/TinkeDSi.git
synced 2025-06-18 16:45:43 -04:00
Merge: Add JUS Plugins by @priverop
This commit is contained in:
parent
7d10b7e310
commit
87de7f9854
17
Plugins/JUS/JUS.sln
Normal file
17
Plugins/JUS/JUS.sln
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JUS", "JUS\JUS.csproj", "{F9DF9338-E4A6-4184-96F3-37121DC2759F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F9DF9338-E4A6-4184-96F3-37121DC2759F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F9DF9338-E4A6-4184-96F3-37121DC2759F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F9DF9338-E4A6-4184-96F3-37121DC2759F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F9DF9338-E4A6-4184-96F3-37121DC2759F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
236
Plugins/JUS/JUS/ALAR.cs
Normal file
236
Plugins/JUS/JUS/ALAR.cs
Normal file
@ -0,0 +1,236 @@
|
||||
// ----------------------------------------------------------------------
|
||||
// <copyright file="ALAR.cs" company="none">
|
||||
|
||||
// Copyright (C) 2019
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// </copyright>
|
||||
|
||||
// <author>pleoNeX, Daviex94, Priverop</author>
|
||||
// <contact>https://github.com/priverop/</contact>
|
||||
// <date>24/02/2019</date>
|
||||
// -----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Ekona;
|
||||
|
||||
namespace JUS
|
||||
{
|
||||
/// <summary>
|
||||
/// Specification from: https://web.archive.org/web/20100111220659/http://jumpstars.wikispaces.com/File+Formats
|
||||
/// </summary>
|
||||
public class ALAR
|
||||
{
|
||||
private const byte TYPE2ID = 0x02;
|
||||
private const byte TYPE3ID = 0x03;
|
||||
IPluginHost pluginHost;
|
||||
|
||||
public ALAR(IPluginHost pluginHost)
|
||||
{
|
||||
this.pluginHost = pluginHost;
|
||||
}
|
||||
|
||||
public sFolder Unpack(sFile file)
|
||||
{
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
|
||||
br.BaseStream.Position = 4;
|
||||
byte type = br.ReadByte();
|
||||
|
||||
if (type == TYPE2ID)
|
||||
return Unpack_Type2(file);
|
||||
if (type == TYPE3ID)
|
||||
return Unpack_Type3(file);
|
||||
|
||||
br.BaseStream.Position = 0;
|
||||
byte[] magic = br.ReadBytes(4);
|
||||
|
||||
br.Close();
|
||||
|
||||
string magicString = new String(Encoding.ASCII.GetChars(magic));
|
||||
if (magicString == "DSCP")
|
||||
return Decompress_LZSS(file);
|
||||
|
||||
return new sFolder();
|
||||
}
|
||||
|
||||
public sFolder Unpack_Type2(sFile file)
|
||||
{
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
|
||||
sFolder unpacked = new sFolder();
|
||||
unpacked.files = new List<sFile>();
|
||||
|
||||
// Read the header file
|
||||
char[] header = br.ReadChars(4);
|
||||
byte type = br.ReadByte();
|
||||
byte unk = br.ReadByte();
|
||||
ushort num_files = br.ReadUInt16();
|
||||
|
||||
byte[] ids = new byte[8];
|
||||
for (int i = 0; i < 8; i++)
|
||||
ids[i] = br.ReadByte();
|
||||
|
||||
// Index table
|
||||
uint name_offset = (uint)(0x10 + num_files * 0x10);
|
||||
for (int i = 0; i < num_files; i++)
|
||||
{
|
||||
uint unk1 = br.ReadUInt32();
|
||||
|
||||
sFile cfile = new sFile
|
||||
{
|
||||
path = file.path,
|
||||
offset = br.ReadUInt32(),
|
||||
size = br.ReadUInt32()
|
||||
};
|
||||
|
||||
uint unk2 = br.ReadUInt32();
|
||||
|
||||
long curpos = br.BaseStream.Position;
|
||||
br.BaseStream.Position = name_offset + 2;
|
||||
cfile.name = new String(Encoding.GetEncoding("shift_jis").GetChars(br.ReadBytes(0x20))).Replace("\0", "");
|
||||
name_offset += cfile.size + 0x24;
|
||||
br.BaseStream.Position = curpos;
|
||||
|
||||
unpacked.files.Add(cfile);
|
||||
}
|
||||
|
||||
br.Close();
|
||||
return unpacked;
|
||||
}
|
||||
|
||||
public sFolder Unpack_Type3(sFile file)
|
||||
{
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
|
||||
sFolder unpacked = new sFolder();
|
||||
unpacked.files = new List<sFile>();
|
||||
unpacked.folders = new List<sFolder>();
|
||||
|
||||
// Read the header file
|
||||
char[] header = br.ReadChars(4);
|
||||
byte type = br.ReadByte();
|
||||
byte unk = br.ReadByte();
|
||||
uint num_files = br.ReadUInt32();
|
||||
ushort unk2 = br.ReadUInt16();
|
||||
uint array_count = br.ReadUInt32();
|
||||
ushort endFileIndex = br.ReadUInt16();
|
||||
ushort[] fileTableIndex = new ushort[array_count + 1];
|
||||
|
||||
for (int i = 0; i < array_count + 1;i++)
|
||||
{
|
||||
fileTableIndex[i] = br.ReadUInt16();
|
||||
}
|
||||
|
||||
// Index table
|
||||
foreach(ushort filePosition in fileTableIndex)
|
||||
{
|
||||
br.BaseStream.Position = filePosition;
|
||||
|
||||
ushort fileID = br.ReadUInt16();
|
||||
ushort unk3 = br.ReadUInt16();
|
||||
|
||||
sFile cfile = new sFile
|
||||
{
|
||||
path = file.path,
|
||||
offset = br.ReadUInt32(), // StartOfFile
|
||||
size = br.ReadUInt32() // SizeOfFile
|
||||
};
|
||||
|
||||
ushort unk4 = br.ReadUInt16();
|
||||
ushort unk5 = br.ReadUInt16();
|
||||
ushort unk6 = br.ReadUInt16();
|
||||
|
||||
string filename = this.ReadNullTerminatedString(br);
|
||||
|
||||
AddFile(unpacked, cfile, filename);
|
||||
}
|
||||
|
||||
br.Close();
|
||||
return unpacked;
|
||||
}
|
||||
|
||||
public sFolder Decompress_LZSS(sFile file)
|
||||
{
|
||||
sFolder unpacked = new sFolder();
|
||||
unpacked.files = new List<sFile>();
|
||||
|
||||
string temp = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + Path.GetRandomFileName();
|
||||
Byte[] compressFile = new Byte[(new FileInfo(file.path).Length) - 4];
|
||||
Array.Copy(File.ReadAllBytes(file.path), 4, compressFile, 0, compressFile.Length);
|
||||
File.WriteAllBytes(temp, compressFile);
|
||||
|
||||
// Get the decompressed file
|
||||
string fileIn = Path.GetDirectoryName(temp) + Path.DirectorySeparatorChar + "de" + Path.DirectorySeparatorChar + Path.GetFileName(temp);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fileIn));
|
||||
DSDecmp.Main.Decompress(temp, fileIn, DSDecmp.Main.Get_Format(temp));
|
||||
File.Delete(temp);
|
||||
|
||||
sFile fileOut = new sFile
|
||||
{
|
||||
path = fileIn,
|
||||
name = file.name,
|
||||
size = (uint)new FileInfo(fileIn).Length
|
||||
};
|
||||
|
||||
unpacked.files.Add(fileOut);
|
||||
|
||||
return unpacked;
|
||||
}
|
||||
|
||||
private static void AddFile(sFolder folder, sFile file, string filePath)
|
||||
{
|
||||
const char SEPARATOR = '/';
|
||||
|
||||
if (filePath.Contains(SEPARATOR))
|
||||
{
|
||||
string folderName = filePath.Substring(0, filePath.IndexOf(SEPARATOR));
|
||||
sFolder subfolder = new sFolder();
|
||||
foreach (sFolder f in folder.folders)
|
||||
{
|
||||
if (f.name == folderName)
|
||||
{
|
||||
subfolder = f;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(subfolder.name))
|
||||
{
|
||||
subfolder.name = folderName;
|
||||
subfolder.folders = new List<sFolder>();
|
||||
subfolder.files = new List<sFile>();
|
||||
folder.folders.Add(subfolder);
|
||||
}
|
||||
|
||||
AddFile(subfolder, file, filePath.Substring(filePath.IndexOf(SEPARATOR) + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
file.name = filePath;
|
||||
folder.files.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
private string ReadNullTerminatedString(System.IO.BinaryReader stream)
|
||||
{
|
||||
string str = "";
|
||||
char ch;
|
||||
while ((int)(ch = stream.ReadChar()) != 0)
|
||||
str = str + ch;
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
113
Plugins/JUS/JUS/DIG.cs
Normal file
113
Plugins/JUS/JUS/DIG.cs
Normal file
@ -0,0 +1,113 @@
|
||||
// ----------------------------------------------------------------------
|
||||
// <copyright file="DIG.cs" company="none">
|
||||
|
||||
// Copyright (C) 2019
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// </copyright>
|
||||
|
||||
// <author>Priverop</author>
|
||||
// <contact>https://github.com/priverop/</contact>
|
||||
// <date>25/02/2019</date>
|
||||
// -----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using Ekona;
|
||||
using Ekona.Images;
|
||||
|
||||
namespace JUS
|
||||
{
|
||||
class DIG : ImageBase
|
||||
{
|
||||
IPluginHost pluginHost;
|
||||
|
||||
public DIG(IPluginHost pluginHost, string file, int id, string fileName = "")
|
||||
{
|
||||
this.pluginHost = pluginHost;
|
||||
this.id = id;
|
||||
this.fileName = fileName;
|
||||
|
||||
Read(file);
|
||||
}
|
||||
|
||||
public override void Read(string fileIn)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes(fileIn);
|
||||
|
||||
byte formatType = data[5];
|
||||
byte numPaletteLines = data[6];
|
||||
|
||||
short width = BitConverter.ToInt16(data, 8);
|
||||
short height = BitConverter.ToInt16(data, 10);
|
||||
|
||||
int paletteEnd = numPaletteLines * 32 + 12;
|
||||
|
||||
int startPalette = 12;
|
||||
int position = startPalette;
|
||||
|
||||
int paletteSize = paletteEnd - startPalette;
|
||||
|
||||
ColorFormat format;
|
||||
RawPalette palette;
|
||||
Color[][] palettes;
|
||||
|
||||
if ((formatType & 0x0F) == 0)
|
||||
{
|
||||
format = ColorFormat.colors16;
|
||||
palettes = new Color[numPaletteLines][];
|
||||
|
||||
for (int i = 0; i < numPaletteLines; i++)
|
||||
{
|
||||
byte[] aux = new byte[0x20];
|
||||
Array.Copy(data, startPalette + (i * 0x20), aux, 0, 0x20);
|
||||
|
||||
palettes[i] = Actions.BGR555ToColor(aux);
|
||||
}
|
||||
|
||||
palette = new RawPalette(palettes, false, format);
|
||||
}
|
||||
else
|
||||
{
|
||||
format = ColorFormat.colors256;
|
||||
int numPalettes = ((numPaletteLines - 1) / 16) + 1;
|
||||
|
||||
palettes = new Color[numPalettes][];
|
||||
|
||||
for(int i = 0; i < numPalettes; i++) {
|
||||
byte[] aux = new byte[0x200];
|
||||
Array.Copy(data, startPalette + (i * 0x200), aux, 0, 0x200);
|
||||
palettes[i] = Actions.BGR555ToColor(aux);
|
||||
}
|
||||
|
||||
palette = new RawPalette(palettes, false, format);
|
||||
|
||||
}
|
||||
|
||||
pluginHost.Set_Palette(palette);
|
||||
|
||||
// Get image
|
||||
byte[] tiles = new byte[data.Length - paletteEnd];
|
||||
Array.Copy(data, paletteEnd, tiles, 0, data.Length - paletteEnd);
|
||||
Set_Tiles(tiles, width, height, format, formatType >> 4 == 1 ? TileForm.Horizontal : TileForm.Lineal, false);
|
||||
|
||||
pluginHost.Set_Image(this);
|
||||
}
|
||||
|
||||
public override void Write(string fileOut, PaletteBase palette)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
58
Plugins/JUS/JUS/JUS.csproj
Normal file
58
Plugins/JUS/JUS/JUS.csproj
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{F9DF9338-E4A6-4184-96F3-37121DC2759F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>JUS</RootNamespace>
|
||||
<AssemblyName>JUS</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\Tinke\bin\Debug\Plugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Ekona, Version=7.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Ekona\bin\Debug\Ekona.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="DSDecmp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\build\DSDecmp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DSDecmp">
|
||||
<HintPath>..\..\..\build\DSDecmp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="DIG.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="ALAR.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
90
Plugins/JUS/JUS/Main.cs
Normal file
90
Plugins/JUS/JUS/Main.cs
Normal file
@ -0,0 +1,90 @@
|
||||
// ----------------------------------------------------------------------
|
||||
// <copyright file="Main.cs" company="none">
|
||||
|
||||
// Copyright (C) 2019
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// </copyright>
|
||||
|
||||
// <author>Priverop</author>
|
||||
// <contact>https://github.com/priverop/</contact>
|
||||
// <date>25/02/2019</date>
|
||||
// -----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Text;
|
||||
using Ekona;
|
||||
|
||||
namespace JUS
|
||||
{
|
||||
public class Main : IPlugin
|
||||
{
|
||||
IPluginHost pluginHost;
|
||||
|
||||
public void Initialize(IPluginHost pluginHost)
|
||||
{
|
||||
this.pluginHost = pluginHost;
|
||||
}
|
||||
|
||||
public Format Get_Format(sFile file, byte[] magic)
|
||||
{
|
||||
string ext = new String(Encoding.ASCII.GetChars(magic));
|
||||
|
||||
if (ext == "DSIG")
|
||||
return Format.FullImage;
|
||||
else if (ext == "ALAR")
|
||||
return Format.Pack;
|
||||
else if (ext == "DSCP")
|
||||
return Format.Compressed;
|
||||
|
||||
return Format.Unknown;
|
||||
}
|
||||
|
||||
public string Pack(ref sFolder unpacked, sFile file)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public sFolder Unpack(sFile file)
|
||||
{
|
||||
System.IO.BinaryReader br = new System.IO.BinaryReader(System.IO.File.OpenRead(file.path));
|
||||
string type = new String(Encoding.ASCII.GetChars(br.ReadBytes(4)));
|
||||
br.Close();
|
||||
|
||||
if (type == "ALAR")
|
||||
return new ALAR(pluginHost).Unpack(file);
|
||||
else if (type == "DSCP")
|
||||
return new ALAR(pluginHost).Unpack(file);
|
||||
|
||||
return new sFolder();
|
||||
}
|
||||
|
||||
public void Read(sFile file)
|
||||
{
|
||||
}
|
||||
|
||||
public System.Windows.Forms.Control Show_Info(sFile file)
|
||||
{
|
||||
|
||||
if (file.name.EndsWith(".dig", StringComparison.CurrentCulture))
|
||||
{
|
||||
new DIG(pluginHost, file.path, file. id);
|
||||
return new Ekona.Images.ImageControl(pluginHost, false);
|
||||
}
|
||||
|
||||
return new System.Windows.Forms.Control();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
26
Plugins/JUS/JUS/Properties/AssemblyInfo.cs
Normal file
26
Plugins/JUS/JUS/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("JUS")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
Loading…
Reference in New Issue
Block a user