implemented NekoSDK archives.

This commit is contained in:
morkt 2016-08-02 16:40:31 +04:00
parent 0732a9cf45
commit f049441cb7
4 changed files with 179 additions and 1 deletions

View File

@ -146,6 +146,8 @@
<Compile Include="Marble\VideoANIM.cs" /> <Compile Include="Marble\VideoANIM.cs" />
<Compile Include="MD5.cs" /> <Compile Include="MD5.cs" />
<Compile Include="Nekopunch\ArcPAK.cs" /> <Compile Include="Nekopunch\ArcPAK.cs" />
<Compile Include="NekoSDK\ArcDAT.cs" />
<Compile Include="NekoSDK\ImageALP.cs" />
<Compile Include="NitroPlus\ArcPAK.cs" /> <Compile Include="NitroPlus\ArcPAK.cs" />
<Compile Include="MnoViolet\ImageDIF.cs" /> <Compile Include="MnoViolet\ImageDIF.cs" />
<Compile Include="Nexas\ImageGRP.cs" /> <Compile Include="Nexas\ImageGRP.cs" />

View File

@ -0,0 +1,95 @@
//! \file ArcDAT.cs
//! \date Tue Aug 02 12:02:04 2016
//! \brief NekoSDK resource archives.
//
// Copyright (C) 2016 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using GameRes.Compression;
using GameRes.Utility;
namespace GameRes.Formats.NekoSDK
{
[Export(typeof(ArchiveFormat))]
public class DatOpener : ArchiveFormat
{
public override string Tag { get { return "DAT/NekoSDK"; } }
public override string Description { get { return "NekoSDK engine resource archive"; } }
public override uint Signature { get { return 0; } }
public override bool IsHierarchic { get { return false; } }
public override bool CanCreate { get { return false; } }
public DatOpener ()
{
Extensions = new string[] { "dat" };
}
public override ArcFile TryOpen (ArcView file)
{
uint first_offset = file.View.ReadUInt32 (0x88) ^ 0xCACACAu;
if (first_offset <= 0 || first_offset >= file.MaxOffset)
return null;
int count = (int)first_offset / 0x8C;
if (first_offset != count * 0x8C)
return null;
if (!IsSaneCount (--count))
return null;
uint index_offset = 0;
var dir = new List<Entry> (count);
var name_buffer = new byte[0x80];
for (int i = 0; i < count; ++i)
{
file.View.Read (index_offset, name_buffer, 0, 0x80);
if (0 == name_buffer[0])
return null;
var name = Binary.GetCString (name_buffer, 0, name_buffer.Length);
var entry = FormatCatalog.Instance.Create<PackedEntry> (name);
entry.UnpackedSize = file.View.ReadUInt32 (index_offset+0x80) ^ 0xCACACAu;
entry.Size = file.View.ReadUInt32 (index_offset+0x84) ^ 0xCACACAu;
entry.Offset = file.View.ReadUInt32 (index_offset+0x88) ^ 0xCACACAu;
if (entry.Offset < first_offset || !entry.CheckPlacement (file.MaxOffset))
return null;
entry.IsPacked = entry.UnpackedSize != 0;
if (!entry.IsPacked)
entry.UnpackedSize = entry.Size;
index_offset += 0x8C;
dir.Add(entry);
}
if (0 == dir.Count)
return null;
return new ArcFile (file, this, dir);
}
public override Stream OpenEntry (ArcFile arc, Entry entry)
{
var input = arc.File.CreateStream (entry.Offset, entry.Size);
var pent = entry as PackedEntry;
if (null == pent || !pent.IsPacked)
return input;
return new LzssStream (input);
}
}
}

View File

@ -0,0 +1,69 @@
//! \file ImageALP.cs
//! \date Tue Aug 02 15:35:56 2016
//! \brief NekoSDK BMP alpha-channel extension.
//
// Copyright (C) 2016 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Windows.Media;
namespace GameRes.Formats.NekoSDK
{
[Export(typeof(IBmpExtension))]
public class AlpBitmap : IBmpExtension
{
public ImageData Read (Stream file, BmpMetaData info)
{
if (info.BPP != 24 && info.BPP != 32 || !file.CanSeek)
return null;
var alp_name = Path.ChangeExtension (info.FileName, "alp");
if (alp_name.Equals (info.FileName, StringComparison.InvariantCultureIgnoreCase)
|| !VFS.FileExists (alp_name))
return null;
var alpha_size = info.Width * info.Height;
var alpha = new byte[alpha_size];
using (var alp = VFS.OpenStream (alp_name))
{
if (alpha.Length != alp.Read (alpha, 0, alpha.Length) || alp.ReadByte() != -1)
return null;
}
file.Position = info.HeaderLength;
int dst_stride = (int)info.Width * 4;
var pixels = new byte[(int)info.Height * dst_stride];
int src_pixel_size = info.BPP / 8;
int dst = (int)(info.Height-1) * dst_stride;
for (int y = (int)info.Height-1; y >= 0; --y)
{
int a_src = (int)info.Width * y;
for (int x = 0; x < dst_stride; x += 4)
{
file.Read (pixels, dst+x, src_pixel_size);
pixels[dst+x+3] = alpha[a_src++];
}
dst -= dst_stride;
}
return ImageData.Create (info, PixelFormats.Bgra32, null, pixels, dst_stride);
}
}
}

View File

@ -284,7 +284,10 @@ Soukan Yuugi 2<br/>
</td></tr> </td></tr>
<tr class="odd"><td>*.bmd</td><td><tt>_BMD</tt></td><td>Yes</td></tr> <tr class="odd"><td>*.bmd</td><td><tt>_BMD</tt></td><td>Yes</td></tr>
<tr class="odd"><td>*.asd</td><td>-</td><td>No</td></tr> <tr class="odd"><td>*.asd</td><td>-</td><td>No</td></tr>
<tr><td>*.dat</td><td>-</td><td>Yes</td><td>Studio e.go!</td><td>Men at Work 2</td></tr> <tr><td>*.dat</td><td>-</td><td>Yes</td><td>Studio e.go!</td><td>
Men at Work 2<br/>
Natsu Kagura<br/>
</td></tr>
<tr class="odd"><td>*.mbl</td><td>-</td><td>No</td><td rowspan="3">Marble</td><td rowspan="3"> <tr class="odd"><td>*.mbl</td><td>-</td><td>No</td><td rowspan="3">Marble</td><td rowspan="3">
Assault Angel Canon<br/> Assault Angel Canon<br/>
Chikatetsu Fuusa Jiken<br/> Chikatetsu Fuusa Jiken<br/>
@ -388,6 +391,7 @@ Zansho Omimai Moushiagemasu<span class="footnote">ShiinaRio v2.41</span><br/>
<tr><td>*.pad</td><td><tt>PAD</tt></td><td>No</td></tr> <tr><td>*.pad</td><td><tt>PAD</tt></td><td>No</td></tr>
<tr class="odd"><td>*</td><td><tt>ARC2</tt><br/><tt>ARC1</tt></td><td>No</td><td>AST</td><td> <tr class="odd"><td>*</td><td><tt>ARC2</tt><br/><tt>ARC1</tt></td><td>No</td><td>AST</td><td>
Bokura wa Piacere<br/> Bokura wa Piacere<br/>
Hokenshitsu no Sensei ~Onedari Bakunyuu Lesson~<br/>
Jokyoushi wo Kurau<br/> Jokyoushi wo Kurau<br/>
Lovers Collection<br/> Lovers Collection<br/>
Nachtmusik<br/> Nachtmusik<br/>
@ -770,6 +774,8 @@ Izumo<br/>
Izumo 2<br/> Izumo 2<br/>
Izumo 2 ~Gakuen Kyousoukyoku~<br/> Izumo 2 ~Gakuen Kyousoukyoku~<br/>
Izumo 3<br/> Izumo 3<br/>
Oni Kagura<br/>
Tsuki Kagura<br/>
</td></tr> </td></tr>
<tr class="odd"><td>*.pbx</td><td><tt>Pandora.box</tt></td><td>No</td><td>Terios</td><td> <tr class="odd"><td>*.pbx</td><td><tt>Pandora.box</tt></td><td>No</td><td>Terios</td><td>
Ikinari Happy Bell<br/> Ikinari Happy Bell<br/>
@ -908,6 +914,7 @@ Sweet ~Hanjuku na Tenshi-tachi~<br/>
Gakuen Taima! Holy x Moly<br/> Gakuen Taima! Holy x Moly<br/>
Joi-san no Iitsuke!!<br/> Joi-san no Iitsuke!!<br/>
Shiawase na Ohime-sama<br/> Shiawase na Ohime-sama<br/>
Shin Genre Esudere!!<br/>
</td></tr> </td></tr>
<tr class="odd"><td>*.nwa</td><td>-</td><td>No</td></tr> <tr class="odd"><td>*.nwa</td><td>-</td><td>No</td></tr>
<tr class="odd"><td>*.g00</td><td>-</td><td>No</td></tr> <tr class="odd"><td>*.g00</td><td>-</td><td>No</td></tr>
@ -965,6 +972,8 @@ Cartagra<br/>
Kara no Shoujo 2<br/> Kara no Shoujo 2<br/>
</td></td> </td></td>
<tr><td>data.NN<br/>ArcNN.dat</td><td>-</td><td>No</td><td>Cyberworks</td><td> <tr><td>data.NN<br/>ArcNN.dat</td><td>-</td><td>No</td><td>Cyberworks</td><td>
Aniyome Kyouka-san to Sono Haha Chikako-san<br/>
Aru Kazoku no Kankeizu<br/>
Cosplay Ecchi ~Layer Kana no Yuuutsu~<br/> Cosplay Ecchi ~Layer Kana no Yuuutsu~<br/>
Hanamaru! 2<br/> Hanamaru! 2<br/>
Hime Kami 1/2<br/> Hime Kami 1/2<br/>
@ -995,6 +1004,9 @@ Soushinjutsu Plus<br/>
<tr><td>*.ns2</td><td>-</td><td>No</td><td>NScripter</td><td> <tr><td>*.ns2</td><td>-</td><td>No</td><td>NScripter</td><td>
Rakuin Hime Runed Princess<br/> Rakuin Hime Runed Princess<br/>
</td></tr> </td></tr>
<tr class="odd"><td>*.dat</td><td>-</td><td>No</td><td>NekoSDK</td><td>
Elevator Panic ~Misshitsu no Inkou~<br/>
</td></tr>
</table> </table>
<p><a name="note-1" class="footnote">1</a> Non-encrypted only</p> <p><a name="note-1" class="footnote">1</a> Non-encrypted only</p>
</body> </body>