mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 12:39:16 +08:00
implemented GGP images.
This commit is contained in:
parent
0955c15181
commit
b334222997
@ -175,6 +175,7 @@
|
||||
<Compile Include="ImageEPA.cs" />
|
||||
<Compile Include="ImageERI.cs" />
|
||||
<Compile Include="ImageGCP.cs" />
|
||||
<Compile Include="ImageGGP.cs" />
|
||||
<Compile Include="ImageGR.cs" />
|
||||
<Compile Include="ImageHG3.cs" />
|
||||
<Compile Include="ImageIAF.cs" />
|
||||
|
179
ArcFormats/ImageGGP.cs
Normal file
179
ArcFormats/ImageGGP.cs
Normal file
@ -0,0 +1,179 @@
|
||||
//! \file ImageGGP.cs
|
||||
//! \date Sun Jun 14 09:06:26 2015
|
||||
//! \brief
|
||||
//
|
||||
// Copyright (C) 2014-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.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.DRS
|
||||
{
|
||||
internal class GgpMetaData : ImageMetaData
|
||||
{
|
||||
public byte[] Key = new byte[8];
|
||||
public uint Offset;
|
||||
public uint Length;
|
||||
}
|
||||
|
||||
[Export(typeof(ImageFormat))]
|
||||
public class GgpFormat : PngFormat
|
||||
{
|
||||
public override string Tag { get { return "GGP"; } }
|
||||
public override string Description { get { return "Digital Romance System encrypted image format"; } }
|
||||
public override uint Signature { get { return 0x46504747u; } } // 'GGPF'
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
var header = new byte[0x24];
|
||||
if (header.Length != stream.Read (header, 0, header.Length))
|
||||
return null;
|
||||
if (!Binary.AsciiEqual (header, 0, "GGPFAIKE"))
|
||||
return null;
|
||||
var info = new GgpMetaData
|
||||
{
|
||||
Offset = LittleEndian.ToUInt32 (header, 0x14),
|
||||
Length = LittleEndian.ToUInt32 (header, 0x18),
|
||||
};
|
||||
for (int i = 0; i < 8; ++i)
|
||||
info.Key[i] = (byte)(header[i] ^ header[i+0xC]);
|
||||
stream.Position = info.Offset;
|
||||
using (var png = new EncryptedStream (stream, info.Key, true))
|
||||
{
|
||||
var png_info = base.ReadMetaData (png);
|
||||
info.Width = png_info.Width;
|
||||
info.Height = png_info.Height;
|
||||
info.BPP = png_info.BPP;
|
||||
info.OffsetX = png_info.OffsetX;
|
||||
info.OffsetY = png_info.OffsetY;
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream file, ImageMetaData info)
|
||||
{
|
||||
var meta = info as GgpMetaData;
|
||||
if (null == meta)
|
||||
throw new ArgumentException ("GgpFormat.Read should be supplied with GgpMetaData", "info");
|
||||
using (var input = new StreamRegion (file, meta.Offset, meta.Length, true))
|
||||
using (var png = new EncryptedStream (input, meta.Key, true))
|
||||
return base.Read (png, info);
|
||||
}
|
||||
|
||||
public override void Write (Stream file, ImageData image)
|
||||
{
|
||||
throw new NotImplementedException ("GgpFormat.Write not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
internal class EncryptedStream : Stream
|
||||
{
|
||||
private Stream m_stream;
|
||||
private byte[] m_key;
|
||||
private long m_position;
|
||||
private bool m_should_dispose;
|
||||
|
||||
public EncryptedStream (Stream main, byte[] key, bool leave_open = false)
|
||||
{
|
||||
if (null == key)
|
||||
throw new ArgumentNullException ("key");
|
||||
if (key.Length < 8)
|
||||
throw new ArgumentException ("key");
|
||||
m_stream = main;
|
||||
m_key = key;
|
||||
m_position = 0;
|
||||
m_should_dispose = !leave_open;
|
||||
}
|
||||
|
||||
public override bool CanRead { get { return m_stream.CanRead; } }
|
||||
public override bool CanSeek { get { return false; } }
|
||||
public override bool CanWrite { get { return false; } }
|
||||
public override long Length { get { throw new NotSupportedException(); } }
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override long Seek (long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
m_stream.Flush();
|
||||
}
|
||||
|
||||
public override int Read (byte[] buffer, int offset, int count)
|
||||
{
|
||||
int read = m_stream.Read (buffer, offset, count);
|
||||
if (read > 0)
|
||||
{
|
||||
for (int i = 0; i < read; ++i)
|
||||
{
|
||||
buffer[offset+i] ^= m_key[m_position++ & 7];
|
||||
}
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public override int ReadByte ()
|
||||
{
|
||||
int b = m_stream.ReadByte();
|
||||
if (-1 != b)
|
||||
{
|
||||
b ^= m_key[m_position++ & 7];
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public override void SetLength (long length)
|
||||
{
|
||||
throw new NotSupportedException ("EncryptedStream.SetLength method is not supported");
|
||||
}
|
||||
|
||||
public override void Write (byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotSupportedException ("EncryptedStream.Write method is not supported");
|
||||
}
|
||||
|
||||
public override void WriteByte (byte value)
|
||||
{
|
||||
throw new NotSupportedException ("EncryptedStream.WriteByte method is not supported");
|
||||
}
|
||||
|
||||
bool m_disposed = false;
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (!m_disposed)
|
||||
{
|
||||
if (m_should_dispose)
|
||||
m_stream.Dispose();
|
||||
m_disposed = true;
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,15 +19,17 @@ tr.odd td { background-color: #eee }
|
||||
<tr><td>*.bip</td><td>-</td><td>No</td></tr>
|
||||
<tr class="odd"><td>data.ami</td><td><tt>AMI</tt></td><td>Yes</td><td>-</td><td>Muv-Luv Amaterasu Translation data files</td></tr>
|
||||
<tr><td>*.arc</td><td><tt>PackFile</tt></td><td>No</td><td>BGI/Ethornell</td><td>Chou Dengeki Stryker</td></tr>
|
||||
<tr class="odd"><td>*</td><td>-<br/><tt>SM2MPX10</tt></td><td>No</td><td rowspan="3">DRS</td><td rowspan="3">
|
||||
<tr class="odd"><td>*</td><td>-<br/><tt>SM2MPX10</tt></td><td>No</td><td rowspan="4">DRS</td><td rowspan="4">
|
||||
Anata no Osanazuma<br/>
|
||||
Ecchi na Bunny-san wa Kirai?<br/>
|
||||
Kana ~Imouto~<br/>
|
||||
Natsu no Hitoshizuku<br/>
|
||||
Private Nurse<br/>
|
||||
Sensei 2<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</td><td><tt>GGA00000</tt></td><td>No</td></tr>
|
||||
<tr class="odd"><td>*.gg1<br/>*.gg2<br/>*.gg3<br/>*.gg0</td><td><tt>GGA00000</tt></td><td>No</td></tr>
|
||||
<tr class="odd"><td>*.ggp</td><td><tt>GGPFAIKE</tt></td><td>No</td></tr>
|
||||
<tr><td>*.bin</td><td><tt>ACPXPK01</tt></td><td>No</td><td>Unison Shift</td><td>Wasurenagusa ~Forget-me-Not~</td></tr>
|
||||
<tr class="odd"><td>*.gsp</td><td>-</td><td>No</td><td rowspan="2">Black Rainbow</td><td rowspan="2">Saimin Gakuen</td></tr>
|
||||
<tr class="odd"><td>*.bmz</td><td><tt>ZLC3</tt></td><td>Yes</td></tr>
|
||||
@ -136,17 +138,20 @@ Nikutai Ten'i<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.grd</td><td><tt>CMP_</tt></td><td>No</td></tr>
|
||||
<tr><td>*.dat<br/>*.arc</td><td>-<br/><tt>M2TYPE</tt></td><td>No</td><td rowspan="2">FFA System/G-SYS</td><td rowspan="2">
|
||||
Onsen Kankou Yukemuri Chijou<br/>
|
||||
Dokusen Kango<br/>
|
||||
Inran OL Sawatari Tokiko<br/>
|
||||
Onsen Kankou Yukemuri Chijou<br/>
|
||||
</td></tr>
|
||||
<tr><td>*.pt1</td><td>-</td><td>No</td></tr>
|
||||
<tr class="odd"><td>*.pak</td><td><tt>DataPack5</tt><br/><tt>GsPack4</tt></td><td>No</td><td rowspan="2">Root</td><td rowspan="2">Para-Sol</td></tr>
|
||||
<tr class="odd"><td>*</td><td><tt>\x00\x00\x04\x00</tt></td><td>No</td></tr>
|
||||
<tr><td>*.war</td><td><tt>WARC 1.7</tt></td><td>No</td><td rowspan="2">Shiina Rio</td><td rowspan="2">
|
||||
Helter Skelter<br/>
|
||||
<tr><td>*.war</td><td><tt>WARC 1.7</tt></td><td>No</td><td rowspan="3">Shiina Rio</td><td rowspan="3">
|
||||
Classmate no Okaa-san<br/>
|
||||
Helter Skelter<br/>
|
||||
Mahou Shoujo no Taisetsu na Koto<br/>
|
||||
</td></tr>
|
||||
<tr><td>*.s25</td><td><tt>S25</tt></td><td>No</td></tr>
|
||||
<tr><td>*.ogv</td><td><tt>OGV</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>Jokyoushi wo Kurau</td></tr>
|
||||
<tr><td>*.dat</td><td>-</td><td>No</td><td>Ail</td><td>Ragna☆彡Science</td></tr>
|
||||
<tr class="odd"><td>*.lpk</td><td><tt>LPK1</tt></td><td>No</td><td rowspan="2">Lucifen</td><td rowspan="2">
|
||||
|
Loading…
x
Reference in New Issue
Block a user