mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
implemented 'NEKOPACK4A' archives.
This commit is contained in:
parent
6d2c26d8ee
commit
e006b898e2
@ -180,6 +180,7 @@
|
||||
<Compile Include="Morning\ArcTTD.cs" />
|
||||
<Compile Include="Nekopunch\ArcPAK.cs" />
|
||||
<Compile Include="NekoSDK\ArcDAT.cs" />
|
||||
<Compile Include="NekoSDK\ArcPAK.cs" />
|
||||
<Compile Include="NekoSDK\ImageALP.cs" />
|
||||
<Compile Include="NitroPlus\ArcPAK.cs" />
|
||||
<Compile Include="MnoViolet\ImageDIF.cs" />
|
||||
|
127
ArcFormats/NekoSDK/ArcPAK.cs
Normal file
127
ArcFormats/NekoSDK/ArcPAK.cs
Normal file
@ -0,0 +1,127 @@
|
||||
//! \file ArcPAK.cs
|
||||
//! \date Thu Sep 29 15:17:42 2016
|
||||
//! \brief NekoSDK NEKOPACK resource archive.
|
||||
//
|
||||
// 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 PakOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "NEKOPACK/4"; } }
|
||||
public override string Description { get { return "NekoSDK engine resource archive"; } }
|
||||
public override uint Signature { get { return 0x4F4B454E; } } // 'NEKOPACK'
|
||||
public override bool IsHierarchic { get { return false; } }
|
||||
public override bool CanCreate { get { return false; } }
|
||||
|
||||
public PakOpener ()
|
||||
{
|
||||
Extensions = new string[] { "pak" };
|
||||
}
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
if (!file.View.AsciiEqual (0, "NEKOPACK4"))
|
||||
return null;
|
||||
int version = file.View.ReadByte (9);
|
||||
uint index_offset, index_end;
|
||||
if ('A' == version)
|
||||
{
|
||||
index_offset = 0xE;
|
||||
index_end = index_offset + file.View.ReadUInt32 (0xA);
|
||||
}
|
||||
else if ('S' == version)
|
||||
{
|
||||
index_offset = 0xA;
|
||||
index_end = index_offset + file.View.ReadUInt32 (0xA) + 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var dir = new List<Entry>();
|
||||
var name_buffer = new byte[0x100];
|
||||
while (index_offset < index_end)
|
||||
{
|
||||
uint name_length = file.View.ReadUInt32 (index_offset);
|
||||
index_offset += 4;
|
||||
if (0 == name_length)
|
||||
break;
|
||||
if (name_length > name_buffer.Length)
|
||||
return null;
|
||||
file.View.Read (index_offset, name_buffer, 0, name_length);
|
||||
index_offset += name_length;
|
||||
uint key = 0;
|
||||
for (uint i = 0; i < name_length; ++i)
|
||||
key += name_buffer[i];
|
||||
var name = Binary.GetCString (name_buffer, 0, (int)name_length);
|
||||
var entry = FormatCatalog.Instance.Create<PackedEntry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset) ^ key;
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+4) ^ key;
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
index_offset += 8;
|
||||
}
|
||||
if (0 == dir.Count)
|
||||
return null;
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
uint key = entry.Size / 8 + 0x22;
|
||||
var header = new byte[Math.Min (4, entry.Size)];
|
||||
arc.File.View.Read (entry.Offset, header, 0, (uint)header.Length);
|
||||
for (int i = 0; i < header.Length; ++i)
|
||||
{
|
||||
header[i] ^= (byte)key;
|
||||
key <<= 3;
|
||||
}
|
||||
var pent = entry as PackedEntry;
|
||||
if (null != pent && !pent.IsPacked && entry.Size >= 8)
|
||||
{
|
||||
pent.IsPacked = true;
|
||||
pent.UnpackedSize = arc.File.View.ReadUInt32 (entry.Offset+entry.Size-4);
|
||||
}
|
||||
Stream input;
|
||||
if (header.Length == entry.Size)
|
||||
{
|
||||
input = new MemoryStream (header);
|
||||
}
|
||||
else
|
||||
{
|
||||
input = arc.File.CreateStream (entry.Offset+4, entry.Size-8);
|
||||
input = new PrefixStream (header, input);
|
||||
}
|
||||
return new ZLibStream (input, CompressionMode.Decompress);
|
||||
}
|
||||
}
|
||||
}
|
@ -389,6 +389,7 @@ Onsen Kankou Yukemuri Chijou<br/>
|
||||
Oshiete! Bloomer Sensei<br/>
|
||||
Ryoujoku Costume Play<br/>
|
||||
Seikoujo Claudia<br/>
|
||||
Shinshoku<br/>
|
||||
Sweet and Sweet<br/>
|
||||
Taijoku no Ori<br/>
|
||||
</td></tr>
|
||||
@ -555,6 +556,7 @@ Dungeon Crusaderz ~Tales of Demon Eater~<br/>
|
||||
Dungeon Crusaderz 2 ~Eigou no Rakudo~<br/>
|
||||
Inkou Haden Amatsu ~Hakudaku no Juin~<br/>
|
||||
Magical Witch Academy<br/>
|
||||
Magical Witch Concerto<br/>
|
||||
Medorei ~Okasareta Houkago~<br/>
|
||||
Onna Kyoushi<br/>
|
||||
Ore to Kanojo wa Shuju na Kankei<br/>
|
||||
@ -1163,6 +1165,9 @@ Lost Child<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.sur</td><td><tt>ESUR</tt></td><td>No</td></tr>
|
||||
<tr class="odd last"><td>*.esd</td><td><tt>ESD</tt></td><td>No</td></tr>
|
||||
<tr><td>*.pak</td><td><tt>NEKOPACK4A</tt></td><td>No</td><td>NekoSDK</td><td>
|
||||
In Vitro Shoujo -Aragaishi Junshin Naru Shoujo-<br/>
|
||||
</td></tr>
|
||||
</table>
|
||||
<p><a name="note-1" class="footnote">1</a> Non-encrypted only</p>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user