mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
implemented NFS archives and NGP images.
This commit is contained in:
parent
a44c9b15a5
commit
bccc8303ae
@ -81,6 +81,8 @@
|
||||
<Compile Include="Gpk2\ArcGPK2.cs" />
|
||||
<Compile Include="Gpk2\ImageGFB.cs" />
|
||||
<Compile Include="MersenneTwister.cs" />
|
||||
<Compile Include="Nags\ArcNFS.cs" />
|
||||
<Compile Include="Nags\ImageNGP.cs" />
|
||||
<Compile Include="Palette\ArcCHR.cs" />
|
||||
<Compile Include="Palette\ArcPAK.cs" />
|
||||
<Compile Include="Palette\ImagePGA.cs" />
|
||||
@ -481,7 +483,9 @@
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Strings\arcStrings.ru-RU.resx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Aoi\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>perl "$(SolutionDir)inc-revision.pl" "$(ProjectPath)" $(ConfigurationName)
|
||||
|
89
ArcFormats/Nags/ArcNFS.cs
Normal file
89
ArcFormats/Nags/ArcNFS.cs
Normal file
@ -0,0 +1,89 @@
|
||||
//! \file ArcNFS.cs
|
||||
//! \date Sun Nov 08 15:56:33 2015
|
||||
//! \brief NA Game System resource archive.
|
||||
//
|
||||
// Copyright (C) 2015 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 System.Security.Cryptography;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Nags
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class NfsOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "NFS"; } }
|
||||
public override string Description { get { return "NAGS 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 override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
int count = file.View.ReadInt32 (0);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
uint index_size = (uint)count * 0x20;
|
||||
if (index_size > file.View.Reserve (4, (uint)index_size))
|
||||
return null;
|
||||
int first_offset = file.View.ReadInt32 (0x1C);
|
||||
byte key = (byte)count;
|
||||
first_offset ^= key | key << 8 | key << 16 | key << 24;
|
||||
if (first_offset != 0)
|
||||
return null;
|
||||
|
||||
var index = new byte[index_size];
|
||||
file.View.Read (4, index, 0, index_size);
|
||||
for (int i = 0; i < index.Length; ++i)
|
||||
index[i] ^= key;
|
||||
|
||||
long base_offset = 4 + index_size;
|
||||
int index_offset = 0;
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = Binary.GetCString (index, index_offset, 0x18);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = base_offset + LittleEndian.ToUInt32 (index, index_offset+0x18);
|
||||
entry.Size = LittleEndian.ToUInt32 (index, index_offset+0x1C);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
index_offset += 0x20;
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
var input = arc.File.CreateStream (entry.Offset, entry.Size);
|
||||
if (!entry.Name.EndsWith (".scb", StringComparison.InvariantCultureIgnoreCase))
|
||||
return input;
|
||||
return new CryptoStream (input, new NotTransform(), CryptoStreamMode.Read);
|
||||
}
|
||||
}
|
||||
}
|
98
ArcFormats/Nags/ImageNGP.cs
Normal file
98
ArcFormats/Nags/ImageNGP.cs
Normal file
@ -0,0 +1,98 @@
|
||||
//! \file ImageNGP.cs
|
||||
//! \date Sun Nov 08 16:11:56 2015
|
||||
//! \brief NA Game System image format.
|
||||
//
|
||||
// Copyright (C) 2015 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 GameRes.Compression;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace GameRes.Formats.Nags
|
||||
{
|
||||
internal class NgpMetaData : ImageMetaData
|
||||
{
|
||||
public int PackedSize;
|
||||
public int UnpackedSize;
|
||||
}
|
||||
|
||||
[Export(typeof(ImageFormat))]
|
||||
public class NgpFormat : ImageFormat
|
||||
{
|
||||
public override string Tag { get { return "NGP"; } }
|
||||
public override string Description { get { return "NAGS engine image format"; } }
|
||||
public override uint Signature { get { return 0x2050474E; } } // 'NGP '
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
stream.Position = 0x12;
|
||||
using (var reader = new ArcView.Reader (stream))
|
||||
{
|
||||
int packed_size = reader.ReadInt32();
|
||||
uint width = reader.ReadUInt32();
|
||||
uint height = reader.ReadUInt32();
|
||||
int bpp = reader.ReadUInt16() * 8;
|
||||
reader.BaseStream.Position = 0x100;
|
||||
int unpacked_size = reader.ReadInt32();
|
||||
if (packed_size <= 0 || unpacked_size <= 0)
|
||||
return null;
|
||||
return new NgpMetaData
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
BPP = bpp,
|
||||
PackedSize = packed_size,
|
||||
UnpackedSize = unpacked_size,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
{
|
||||
var meta = (NgpMetaData)info;
|
||||
using (var input = new StreamRegion (stream, 0x104, meta.PackedSize, true))
|
||||
using (var z = new ZLibStream (input, CompressionMode.Decompress))
|
||||
{
|
||||
var pixels = new byte[meta.UnpackedSize];
|
||||
if (pixels.Length != z.Read (pixels, 0, pixels.Length))
|
||||
throw new EndOfStreamException();
|
||||
PixelFormat format;
|
||||
if (32 == meta.BPP)
|
||||
format = PixelFormats.Bgra32;
|
||||
else if (24 == meta.BPP)
|
||||
format = PixelFormats.Bgr24;
|
||||
else if (8 == meta.BPP)
|
||||
format = PixelFormats.Gray8;
|
||||
else
|
||||
throw new System.NotSupportedException ("Not supported NGP image color depth");
|
||||
|
||||
return ImageData.Create (info, format, null, pixels);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write (Stream file, ImageData image)
|
||||
{
|
||||
throw new System.NotImplementedException ("NgpFormat.Write not implemented");
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,7 @@ Natsu no Hitoshizuku<br/>
|
||||
Private Nurse<br/>
|
||||
Sensei 2<br/>
|
||||
Shoujo Settai<br/>
|
||||
Tsukushite Agechau 5<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.ggd</td><td><tt>\xB9\xAA\xB3\xB3</tt><br/><tt>\xAB\xAD\xAA\xBA</tt><br/><tt>\xB7\xB6\xB8\xB7</tt><br/><tt>\xCD\xCA\xC9\xB8</tt></td><td>Yes</td></tr>
|
||||
<tr class="odd"><td>*.gg1<br/>*.gg2<br/>*.gg3<br/>*.gg0</td><td><tt>GGA00000</tt></td><td>No</td></tr>
|
||||
@ -79,6 +80,7 @@ Yakuchu!<br/>
|
||||
<tr class="odd"><td>*.arc</td><td><tt>MajiroArcV1.000</tt><br/><tt>MajiroArcV2.000</tt><br/><tt>MajiroArcV3.000</tt></td><td>Yes</td><td rowspan="3">Majiro</td><td rowspan="3">
|
||||
Amber Quartz<br/>
|
||||
Chikan Kizoku<br/>
|
||||
Narimono<br/>
|
||||
Reconquista<br/>
|
||||
White ~blanche comme la lune~<br/>
|
||||
</td></tr>
|
||||
@ -207,6 +209,7 @@ Kunoichi Kikyou ~Gensou Kannou Emaki~<br/>
|
||||
Momo x Momi<br/>
|
||||
Michibikareshi Mono-tachi no Rakuen ~BEDLAM~<br/>
|
||||
Onsen Kankou Yukemuri Chijou<br/>
|
||||
Ryoujoku Costume Play<br/>
|
||||
</td></tr>
|
||||
<tr><td>*.pt1</td><td>-</td><td>No</td></tr>
|
||||
<tr><td>*.wa1</td><td>-</td><td>No</td></tr>
|
||||
@ -476,6 +479,10 @@ Love Fetish series<br/>
|
||||
<tr><td>*.ani</td><td>-</td><td>No</td></tr>
|
||||
<tr><td>*.cg</td><td>-</td><td>No</td></tr>
|
||||
<tr><td>*.pcm</td><td>WAV</td><td>No</td></tr>
|
||||
<tr class="odd"><td>*.nfs</td><td>-</td><td>No</td><td rowspan="2">NAGS</td><td rowspan="2">
|
||||
Trouble Trap Laboratory<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.ngp</td><td><tt>NGP</tt></td><td>No</td></tr>
|
||||
</table>
|
||||
<p><a name="note-1" class="footnote">1</a> Non-encrypted only</p>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user