mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
implemented SNN+INX archives and ZBM images.
This commit is contained in:
parent
0e17348a7d
commit
bc737cd19d
@ -66,6 +66,8 @@
|
||||
<Compile Include="Amaterasu\ImageGRP.cs" />
|
||||
<Compile Include="AnimeGameSystem\ArcDAT.cs" />
|
||||
<Compile Include="AnimeGameSystem\AudioPCM.cs" />
|
||||
<Compile Include="BlueGale\ArcSNN.cs" />
|
||||
<Compile Include="BlueGale\ImageZBM.cs" />
|
||||
<Compile Include="Cmvs\ArcCPZ.cs" />
|
||||
<Compile Include="ArcPBX.cs" />
|
||||
<Compile Include="Banana\ArcPK.cs" />
|
||||
|
74
ArcFormats/BlueGale/ArcSNN.cs
Normal file
74
ArcFormats/BlueGale/ArcSNN.cs
Normal file
@ -0,0 +1,74 @@
|
||||
//! \file ArcSNN.cs
|
||||
//! \date Sun Jan 10 01:51:27 2016
|
||||
//! \brief BlueGale 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;
|
||||
|
||||
namespace GameRes.Formats.BlueGale
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class SnnOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "SNN"; } }
|
||||
public override string Description { get { return "BlueGale 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)
|
||||
{
|
||||
if (!file.Name.EndsWith (".snn", StringComparison.InvariantCultureIgnoreCase))
|
||||
return null;
|
||||
var inx_name = Path.ChangeExtension (file.Name, "Inx");
|
||||
if (!VFS.FileExists (inx_name))
|
||||
return null;
|
||||
using (var inx = VFS.OpenView (inx_name))
|
||||
{
|
||||
int count = inx.View.ReadInt32 (0);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
int inx_offset = 4;
|
||||
if (inx_offset + count * 0x48 > inx.MaxOffset)
|
||||
return null;
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = inx.View.ReadString (inx_offset, 0x40);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = inx.View.ReadUInt32 (inx_offset+0x40);
|
||||
entry.Size = inx.View.ReadUInt32 (inx_offset+0x44);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
inx_offset += 0x48;
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
140
ArcFormats/BlueGale/ImageZBM.cs
Normal file
140
ArcFormats/BlueGale/ImageZBM.cs
Normal file
@ -0,0 +1,140 @@
|
||||
//! \file ImageZBM.cs
|
||||
//! \date Sun Jan 10 00:41:42 2016
|
||||
//! \brief BlueGale image format.
|
||||
//
|
||||
// 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 GameRes.Utility;
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
|
||||
namespace GameRes.Formats.BlueGale
|
||||
{
|
||||
internal class ZbmMetaData : ImageMetaData
|
||||
{
|
||||
public int UnpackedSize;
|
||||
public int DataOffset;
|
||||
}
|
||||
|
||||
[Export(typeof(ImageFormat))]
|
||||
public class ZbmFormat : ImageFormat
|
||||
{
|
||||
public override string Tag { get { return "ZBM/BLUEGALE"; } }
|
||||
public override string Description { get { return "BlueGale compressed image format"; } }
|
||||
public override uint Signature { get { return 0x5F706D61; } } // 'amp_'
|
||||
|
||||
public ZbmFormat ()
|
||||
{
|
||||
Extensions = new string[] { "zbm" };
|
||||
}
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
stream.Position = 4;
|
||||
using (var reader = new ArcView.Reader (stream))
|
||||
{
|
||||
int version = reader.ReadInt16();
|
||||
if (version != 1)
|
||||
return null;
|
||||
int unpacked_size = reader.ReadInt32();
|
||||
int data_offset = reader.ReadInt32();
|
||||
if (unpacked_size < 0x36 || data_offset < stream.Position)
|
||||
return null;
|
||||
var header = new byte[0x20];
|
||||
stream.Position = data_offset;
|
||||
Unpack (stream, header);
|
||||
if ('B' != header[0] || 'M' != header[1])
|
||||
return null;
|
||||
return new ZbmMetaData
|
||||
{
|
||||
Width = LittleEndian.ToUInt32 (header, 0x12),
|
||||
Height = LittleEndian.ToUInt32 (header, 0x16),
|
||||
BPP = LittleEndian.ToInt16 (header, 0x1C),
|
||||
UnpackedSize = unpacked_size,
|
||||
DataOffset = data_offset,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
{
|
||||
var meta = (ZbmMetaData)info;
|
||||
var data = new byte[meta.UnpackedSize];
|
||||
stream.Position = meta.DataOffset;
|
||||
Unpack (stream, data);
|
||||
using (var bmp = new MemoryStream (data))
|
||||
return ImageFormat.Bmp.Read (bmp, info);
|
||||
}
|
||||
|
||||
public override void Write (Stream file, ImageData image)
|
||||
{
|
||||
throw new System.NotImplementedException ("ZbmFormat.Write not implemented");
|
||||
}
|
||||
|
||||
static void Unpack (Stream input, byte[] output)
|
||||
{
|
||||
using (var bits = new MsbBitStream (input, true))
|
||||
{
|
||||
bits.GetNextBit();
|
||||
int dst = 0;
|
||||
while (dst < output.Length)
|
||||
{
|
||||
int count = bits.GetBits (8);
|
||||
if (-1 == count)
|
||||
throw new EndOfStreamException();
|
||||
if (count > 0x7F)
|
||||
{
|
||||
count &= 0x7F;
|
||||
int offset = bits.GetBits (10);
|
||||
if (-1 == offset)
|
||||
throw new EndOfStreamException();
|
||||
count = Math.Min (count & 0x7F, output.Length-dst);
|
||||
Binary.CopyOverlapped (output, dst-offset, dst, count);
|
||||
dst += count;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0 ; i < count && dst < output.Length; i++)
|
||||
{
|
||||
int v = bits.GetBits (8);
|
||||
if (-1 == v)
|
||||
throw new EndOfStreamException();
|
||||
output[dst++] = (byte)v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Decrypt (output);
|
||||
}
|
||||
|
||||
static void Decrypt (byte[] data)
|
||||
{
|
||||
if (('B'^0xFF) == data[0] && ('M'^0xFF) == data[1])
|
||||
{
|
||||
int encrypted = Math.Min (100, data.Length);
|
||||
for (int i = 0; i < encrypted; ++i)
|
||||
data[i] ^= 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ Salmon Pink<br/>
|
||||
Shisho-san to Issho<br/>
|
||||
Sensei 2<br/>
|
||||
Shoujo Settai<br/>
|
||||
Tsukushite Agechau 5<br/>
|
||||
Tsukushite Agechau series<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>
|
||||
@ -159,6 +159,7 @@ Yume Miru Kusuri<br/>
|
||||
<tr><td>*.wip<br/>*.msk<br/>*.mos</td><td><tt>WIPF</tt></td><td>No</td></tr>
|
||||
<tr class="odd"><td>*.xfl</td><td><tt>LB</tt></td><td>Yes</td><td rowspan="3">Liar-soft</td><td rowspan="3">
|
||||
Angel Bullet<br/>
|
||||
Fairytale Requiem<br/>
|
||||
Sekien no Inganock<br/>
|
||||
Shikkoku no Sharnoth<br/>
|
||||
</td></tr>
|
||||
@ -230,6 +231,7 @@ Nikutai Ten'i<br/>
|
||||
<tr><td>*.dat<br/>*.arc</td><td>-<br/><tt>M2TYPE</tt></td><td>No</td><td rowspan="4">FFA System/G-SYS</td><td rowspan="4">
|
||||
Dokusen Kango<br/>
|
||||
Genecracer Saki<br/>
|
||||
Hazama no Tsuki<br/>
|
||||
Hensai Keikaku<br/>
|
||||
Himawari Oka Sougou Byouin e Youkoso<br/>
|
||||
Inen no Yakata<br/>
|
||||
@ -281,9 +283,11 @@ Zansho Omimai Moushiagemasu<span class="footnote">ShiinaRio v2.41</span><br/>
|
||||
Jokyoushi wo Kurau<br/>
|
||||
Nachtmusik<br/>
|
||||
Nachtmusik Another<br/>
|
||||
Samayou Mitama ni Yasuragi no Toki wo<br/>
|
||||
Time Trouble ~Marie ni Kubikkake~<br/>
|
||||
</td></tr>
|
||||
<tr><td>*.dat</td><td>-</td><td>No</td><td>Ail</td><td>
|
||||
Kyouhaku 2 ~Kizu ni Saku Hana Senketsu no Beni~<br/>
|
||||
Ragna☆彡Science<br/>
|
||||
Ma wo Jutaiseshi Otome no Kuetsu<br/>
|
||||
</td></tr>
|
||||
@ -338,6 +342,7 @@ Konneko<br/>
|
||||
Natsu no Ame<br/>
|
||||
Sakura Musubi<br/>
|
||||
Santaful☆Summer<br/>
|
||||
Tonarizuma<br/>
|
||||
Yatohime Zankikou<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.eri<br/>*.mio</td><td><tt>Entis\x1a</tt></td><td>No</td></tr>
|
||||
@ -597,6 +602,12 @@ Wondering Repair!<br/>
|
||||
<tr><td>*.pac</td><td>-</td><td>No</td><td>Tmr-Hiro ADV System</td><td>
|
||||
Hitozuma Sakunyuu Hyakkaten<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.snn+*.inx</td><td>-</td><td>No</td><td rowspan="2">BlueGale</td><td rowspan="2">
|
||||
Cafe Junkie<br/>
|
||||
Majidashi! Royale ~Finish wa Watashi no Naka de~<br/>
|
||||
MILK Junkies<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.zbm</td><td><tt>amp_</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