mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
implemented variations of PAC archives and PGD images.
This commit is contained in:
parent
71e01d1ee1
commit
23e5856825
@ -63,6 +63,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Actgs\ArcDAT.cs" />
|
||||
<Compile Include="Softpal\ArcPAC.cs" />
|
||||
<Compile Include="Softpal\AudioBGM.cs" />
|
||||
<Compile Include="Softpal\ImagePGD.cs" />
|
||||
<Compile Include="Entis\ArcERI.cs" />
|
||||
<Compile Include="GSD\ArcADS.cs" />
|
||||
<Compile Include="Amaterasu\ImageGRP.cs" />
|
||||
|
138
ArcFormats/Softpal/ArcPAC.cs
Normal file
138
ArcFormats/Softpal/ArcPAC.cs
Normal file
@ -0,0 +1,138 @@
|
||||
//! \file ArcPAC.cs
|
||||
//! \date Sat Feb 13 12:42:15 2016
|
||||
//! \brief Archive format used by subsidiaries of Amuse Craft (former Softpal).
|
||||
//
|
||||
// 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.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Softpal
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class PacOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "PAC/SOFTPAL"; } }
|
||||
public override string Description { get { return "Archive format used by Softpal subsidiaries"; } }
|
||||
public override uint Signature { get { return 0; } }
|
||||
public override bool IsHierarchic { get { return false; } }
|
||||
public override bool CanCreate { get { return false; } }
|
||||
|
||||
public PacOpener ()
|
||||
{
|
||||
Extensions = new string[] { "pac" };
|
||||
}
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
int count = file.View.ReadInt32 (0);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
uint index_offset = 0x3FE;
|
||||
uint name_length = 0x20;
|
||||
uint first_offset = file.View.ReadUInt32 (index_offset+name_length+4);
|
||||
if (first_offset != index_offset + (uint)count*(name_length+8))
|
||||
{
|
||||
name_length = 0x10;
|
||||
first_offset = file.View.ReadUInt32 (index_offset+name_length+4);
|
||||
if (first_offset != index_offset + (uint)count*(name_length+8))
|
||||
return null;
|
||||
}
|
||||
if (first_offset >= file.MaxOffset)
|
||||
return null;
|
||||
return ReadIndex (file, count, index_offset, name_length);
|
||||
}
|
||||
|
||||
protected ArcFile ReadIndex (ArcView file, int count, uint index_offset, uint name_length)
|
||||
{
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = file.View.ReadString (index_offset, name_length);
|
||||
index_offset += name_length;
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+4);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
index_offset += 8;
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
if ("image" == entry.Type || "audio" == entry.Type || entry.Size <= 16
|
||||
|| '$' != arc.File.View.ReadByte (entry.Offset))
|
||||
return base.OpenEntry (arc, entry);
|
||||
var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
|
||||
int count = (data.Length - 16) / 4;
|
||||
if (count > 0)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* data8 = &data[16])
|
||||
{
|
||||
uint* data32 = (uint*)data8;
|
||||
int shift = 4;
|
||||
for (uint* data_end = data32 + count; data32 != data_end; ++data32)
|
||||
{
|
||||
byte* byte_ptr = (byte*)data32;
|
||||
*byte_ptr = Binary.RotByteL (*byte_ptr, shift++);
|
||||
*data32 ^= 0x084DF873u ^ 0xFF987DEEu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new MemoryStream (data);
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class Pac2Opener : PacOpener
|
||||
{
|
||||
public override string Tag { get { return "PAC/AMUSE"; } }
|
||||
public override string Description { get { return "Archive format used by Amuse Craft subsidiaries"; } }
|
||||
public override uint Signature { get { return 0x20434150; } } // 'PAC '
|
||||
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 (8);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
uint index_offset = 0x804;
|
||||
uint name_length = 0x20;
|
||||
uint first_offset = file.View.ReadUInt32 (index_offset+name_length+4);
|
||||
if (first_offset != index_offset + (uint)count*(name_length+8))
|
||||
return null;
|
||||
|
||||
return ReadIndex (file, count, index_offset, name_length);
|
||||
}
|
||||
}
|
||||
}
|
57
ArcFormats/Softpal/AudioBGM.cs
Normal file
57
ArcFormats/Softpal/AudioBGM.cs
Normal file
@ -0,0 +1,57 @@
|
||||
//! \file AudioBGM.cs
|
||||
//! \date Sat Feb 13 12:57:50 2016
|
||||
//! \brief Audio container used in Softpal PAC 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.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Softpal
|
||||
{
|
||||
[Export(typeof(AudioFormat))]
|
||||
public class BgmAudio : OggAudio
|
||||
{
|
||||
public override string Tag { get { return "BGM/SOFTPAL"; } }
|
||||
public override string Description { get { return "Softpal BGM format (Ogg/Vorbis)"; } }
|
||||
public override uint Signature { get { return 0x204D4742; } } // 'BGM '
|
||||
|
||||
public BgmAudio ()
|
||||
{
|
||||
Extensions = new string[] { "ogg" };
|
||||
}
|
||||
|
||||
public override SoundInput TryOpen (Stream file)
|
||||
{
|
||||
var header = new byte[0x10]; // header contains music loop timing
|
||||
if (0x10 != file.Read (header, 0, 0x10))
|
||||
return null;
|
||||
if (!Binary.AsciiEqual (header, 0xC, "OggS"))
|
||||
return null;
|
||||
var input = new StreamRegion (file, 12);
|
||||
return new OggInput (input);
|
||||
// input is [intentionally] left undisposed in case of exception.
|
||||
}
|
||||
}
|
||||
}
|
124
ArcFormats/Softpal/ImagePGD.cs
Normal file
124
ArcFormats/Softpal/ImagePGD.cs
Normal file
@ -0,0 +1,124 @@
|
||||
//! \file ImagePGD.cs
|
||||
//! \date Sat Feb 13 13:56:06 2016
|
||||
//! \brief Image format used by subsidiaries of Amuse Craft (former Softpal).
|
||||
//
|
||||
// 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.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Softpal
|
||||
{
|
||||
[Export(typeof(ImageFormat))]
|
||||
public class Pgd11Format : ImageFormat
|
||||
{
|
||||
public override string Tag { get { return "PGD/11_C"; } }
|
||||
public override string Description { get { return "Image format used by Softpal subsidiaries"; } }
|
||||
public override uint Signature { get { return 0x1C4547; } } // 'GE\x1C'
|
||||
|
||||
public Pgd11Format ()
|
||||
{
|
||||
Extensions = new string[] { "pgd" };
|
||||
}
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
var header = new byte[0x20];
|
||||
if (header.Length != stream.Read (header, 0, header.Length))
|
||||
return null;
|
||||
if (!Binary.AsciiEqual (header, 0x1C, "11_C"))
|
||||
return null;
|
||||
return new ImageMetaData
|
||||
{
|
||||
Width = LittleEndian.ToUInt32 (header, 0x0C),
|
||||
Height = LittleEndian.ToUInt32 (header, 0x10),
|
||||
OffsetX = LittleEndian.ToInt32 (header, 4),
|
||||
OffsetY = LittleEndian.ToInt32 (header, 8),
|
||||
BPP = 32,
|
||||
};
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
{
|
||||
stream.Position = 0x20;
|
||||
using (var reader = new ArcView.Reader (stream))
|
||||
{
|
||||
int unpacked_size = reader.ReadInt32();
|
||||
reader.ReadInt32(); // packed_size
|
||||
var planes = Unpack (reader, unpacked_size);
|
||||
var pixels = new byte[planes.Length];
|
||||
int plane_size = (int)info.Width*(int)info.Height;
|
||||
int b_src = 0;
|
||||
int g_src = b_src+plane_size;
|
||||
int r_src = g_src+plane_size;
|
||||
int alpha_src = r_src+plane_size;
|
||||
int dst = 0;
|
||||
while (dst < pixels.Length)
|
||||
{
|
||||
pixels[dst++] = planes[b_src++];
|
||||
pixels[dst++] = planes[g_src++];
|
||||
pixels[dst++] = planes[r_src++];
|
||||
pixels[dst++] = planes[alpha_src++];
|
||||
}
|
||||
return ImageData.Create (info, PixelFormats.Bgra32, null, pixels);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] Unpack (BinaryReader input, int unpacked_size)
|
||||
{
|
||||
var output = new byte[unpacked_size];
|
||||
int dst = 0;
|
||||
int ctl = 2;
|
||||
while (dst < output.Length)
|
||||
{
|
||||
ctl >>= 1;
|
||||
if (1 == ctl)
|
||||
{
|
||||
ctl = input.ReadByte() | 0x100;
|
||||
}
|
||||
int count;
|
||||
if (0 != (ctl & 1))
|
||||
{
|
||||
int src = input.ReadUInt16();
|
||||
count = input.ReadByte();
|
||||
if (dst >= 0xFFC)
|
||||
src += dst - 0xFFC;
|
||||
Binary.CopyOverlapped (output, src, dst, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
count = input.ReadByte();
|
||||
input.Read (output, dst, count);
|
||||
}
|
||||
dst += count;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public override void Write (Stream file, ImageData image)
|
||||
{
|
||||
throw new System.NotImplementedException ("Pgd11Format.Write not implemented");
|
||||
}
|
||||
}
|
||||
}
|
@ -490,14 +490,14 @@ Answer Dead<br/>
|
||||
Kango Sentai Nurse Ranger<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.abm</td><td><tt>BM</tt></td><td>No</td></tr>
|
||||
<tr><td>*.arc<br/>*.xarc<br/>*.bin<br/>*.004</td><td><tt>MIKO</tt><br/><tt>KOTORI</tt><br/><tt>XARC</tt></td><td>No</td><td rowspan="2">Xuse<br/>ETERNAL</td><td rowspan="2">
|
||||
<tr><td>*.arc<br/>*.xarc<br/>*.bin</td><td><tt>MIKO</tt><br/><tt>KOTORI</tt><br/><tt>XARC</tt></td><td>No</td><td rowspan="2">Xuse<br/>ETERNAL</td><td rowspan="2">
|
||||
Barbaroi<br/>
|
||||
Kikouyoku Senki Gin no Toki no Corona<br/>
|
||||
Kikouyoku Senki Tenkuu no Yumina<br/>
|
||||
Nega0<br/>
|
||||
Seinarukana -The Spirit of Eternity Sword 2-<br/>
|
||||
</td></tr>
|
||||
<tr><td>*.wag<br/>*.4ag</td><td><tt>WAG@</tt><br/><tt>GAF4</tt></td><td>No</td></tr>
|
||||
<tr><td>*.wag<br/>*.4ag<br/>*.004</td><td><tt>WAG@</tt><br/><tt>GAF4</tt></td><td>No</td></tr>
|
||||
<tr class="odd"><td>*.ykc</td><td><tt>YKC001</tt></td><td>Yes</td><td rowspan="2">Yuka</td><td rowspan="2">
|
||||
Aozora no Mieru Oka<br/>
|
||||
PriministAr<br/>
|
||||
@ -673,6 +673,10 @@ Komokyun!! ~Heart ni Yureru Tamashi no Fandisc~<br/>
|
||||
<tr><td>*</td><td><tt>NNNN</tt></td><td>No</td><td>Moko Pro</td><td>
|
||||
Houmon Hanbai ~Otona no Omocha Irimasen ka?~<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.pac</td><td>-<br/><tt>PAC</tt></td><td>No</td><td rowspan="2">Unison Shift</td><td rowspan="2">
|
||||
Unity Marriage ~Futari no Hanayome~<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.pgd</td><td><tt>GE</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