mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 11:24:14 +08:00
(Legacy): PCD and VBD archives.
This commit is contained in:
parent
d03ce916e9
commit
706cf9c560
@ -44,6 +44,10 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\SharpZipLib.1.0.0-alpha2\lib\netstandard1.3\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
@ -57,13 +61,18 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Aaru\ArcFL3.cs" />
|
||||
<Compile Include="Aaru\ArcFL4.cs" />
|
||||
<Compile Include="Aaru\ImageBM2.cs" />
|
||||
<Compile Include="Acme\ImageARD.cs" />
|
||||
<Compile Include="Ags32i\AudioAGS.cs" />
|
||||
<Compile Include="Ags32i\ImageGSS.cs" />
|
||||
<Compile Include="Airyu\ArcCHR.cs" />
|
||||
<Compile Include="Akatombo\ArcX.cs" />
|
||||
<Compile Include="Akatombo\ImageFB.cs" />
|
||||
<Compile Include="Kasane\ArcAR2.cs" />
|
||||
<Compile Include="RSystem\ArcRAD.cs" />
|
||||
<Compile Include="RSystem\ImageRSG.cs" />
|
||||
<Compile Include="Brownie\ArcNAF.cs" />
|
||||
<Compile Include="Brownie\AudioWAV.cs" />
|
||||
<Compile Include="Discovery\ArcDAT.cs" />
|
||||
@ -82,6 +91,8 @@
|
||||
<Compile Include="Electriciteit\ArcDAT.cs" />
|
||||
<Compile Include="Eve\ArcGM.cs" />
|
||||
<Compile Include="Eve\AudioWV.cs" />
|
||||
<Compile Include="Force\ArcPAQ.cs" />
|
||||
<Compile Include="Force\ImageDZP.cs" />
|
||||
<Compile Include="Gaia\ImageJPG.cs" />
|
||||
<Compile Include="GPlay\ArcYSK.cs" />
|
||||
<Compile Include="Hdl\ArcHOT.cs" />
|
||||
@ -102,18 +113,24 @@
|
||||
<Compile Include="Rune\ArcYK.cs" />
|
||||
<Compile Include="Sogna\ArcSGS.cs" />
|
||||
<Compile Include="Speed\ImageDAT.cs" />
|
||||
<Compile Include="Tako\ArcMPK.cs" />
|
||||
<Compile Include="Tetratech\ArcBND.cs" />
|
||||
<Compile Include="Tigerman\ArcCHR.cs" />
|
||||
<Compile Include="Tigerman\ArcPAC.cs" />
|
||||
<Compile Include="Tigerman\ImageCHR.cs" />
|
||||
<Compile Include="Types\ArcARC.cs" />
|
||||
<Compile Include="Types\ImageTPGF.cs" />
|
||||
<Compile Include="Uma\ArcCDT.cs" />
|
||||
<Compile Include="Uma\ArcSDT.cs" />
|
||||
<Compile Include="UMeSoft\AudioIKE.cs" />
|
||||
<Compile Include="UMeSoft\AudioSTR.cs" />
|
||||
<Compile Include="UMeSoft\ImageIKE.cs" />
|
||||
<Compile Include="Unknown\ArcAQA.cs" />
|
||||
<Compile Include="Unknown\AudioMSF.cs" />
|
||||
<Compile Include="Unknown\ImageCTF.cs" />
|
||||
<Compile Include="Witch\ArcDAT.cs" />
|
||||
<Compile Include="Witch\ArcPCD.cs" />
|
||||
<Compile Include="Witch\ArcVBD.cs" />
|
||||
<Compile Include="Yaneurao\ArcDAT.cs" />
|
||||
<Compile Include="Factor\ArcRES.cs" />
|
||||
<Compile Include="Gsx\ArcK3.cs" />
|
||||
|
74
Legacy/Witch/ArcDAT.cs
Normal file
74
Legacy/Witch/ArcDAT.cs
Normal file
@ -0,0 +1,74 @@
|
||||
//! \file ArcDAT.cs
|
||||
//! \date 2018 Aug 19
|
||||
//! \brief Witch image archive.
|
||||
//
|
||||
// Copyright (C) 2018 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;
|
||||
|
||||
namespace GameRes.Formats.Witch
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class DatOpener : ImageDataOpener
|
||||
{
|
||||
public override string Tag { get { return "DAT/MK"; } }
|
||||
public override string Description { get { return "Witch resource archive"; } }
|
||||
public override uint Signature { get { return 0x144B4D; } } // 'MK'
|
||||
public override bool IsHierarchic { get { return false; } }
|
||||
public override bool CanWrite { get { return false; } }
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
int count = file.View.ReadInt32 (4);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
uint index_offset = 8;
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
uint name_length = file.View.ReadUInt32 (index_offset);
|
||||
if (0 == name_length)
|
||||
return null;
|
||||
var name = file.View.ReadString (index_offset+4, name_length);
|
||||
index_offset += 4 + name_length;
|
||||
var entry = new PcdEntry {
|
||||
Name = name,
|
||||
Type = "image",
|
||||
Size = file.View.ReadUInt32 (index_offset+8),
|
||||
Offset = file.View.ReadUInt32 (index_offset+12),
|
||||
};
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
entry.Info = new ImageMetaData {
|
||||
Width = file.View.ReadUInt32 (index_offset),
|
||||
Height = file.View.ReadUInt32 (index_offset+4),
|
||||
BPP = 8,
|
||||
};
|
||||
dir.Add (entry);
|
||||
index_offset += 16;
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
}
|
||||
}
|
176
Legacy/Witch/ArcPCD.cs
Normal file
176
Legacy/Witch/ArcPCD.cs
Normal file
@ -0,0 +1,176 @@
|
||||
//! \file ArcPCD.cs
|
||||
//! \date 2018 Aug 18
|
||||
//! \brief Witch image archive.
|
||||
//
|
||||
// Copyright (C) 2018 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 System.Windows.Media;
|
||||
using GameRes.Compression;
|
||||
using GameRes.Utility;
|
||||
using ICSharpCode.SharpZipLib.BZip2;
|
||||
|
||||
// [030627][Witch] Tsurupeta
|
||||
|
||||
namespace GameRes.Formats.Witch
|
||||
{
|
||||
internal class PcdEntry : PackedEntry
|
||||
{
|
||||
public ImageMetaData Info;
|
||||
}
|
||||
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class ImageDataOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "PCD/IMAGE"; } }
|
||||
public override string Description { get { return "Witch images archive"; } }
|
||||
public override uint Signature { get { return 0x47414D49; } } // 'IMAGEDATE'
|
||||
public override bool IsHierarchic { get { return true; } }
|
||||
public override bool CanWrite { get { return false; } }
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
if (!file.View.AsciiEqual (0, "IMAGEDATE "))
|
||||
return null;
|
||||
int count = file.View.ReadInt32 (0xA);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
long index_offset = 0xE;
|
||||
var dir = new List<Entry> (count);
|
||||
var name_buffer = new byte[0x100];
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
int left = file.View.ReadInt32 (index_offset+8);
|
||||
int top = file.View.ReadInt32 (index_offset+0xC);
|
||||
int right = file.View.ReadInt32 (index_offset+0x10);
|
||||
int bottom = file.View.ReadInt32 (index_offset+0x14);
|
||||
index_offset += 0x18;
|
||||
int name_length = file.View.ReadInt32 (index_offset);
|
||||
if (name_length <= 0)
|
||||
return null;
|
||||
if (name_length > name_buffer.Length)
|
||||
name_buffer = new byte[name_length];
|
||||
file.View.Read (index_offset+4, name_buffer, 0, (uint)name_length);
|
||||
DecryptName (name_buffer, 0, name_length);
|
||||
var name = Binary.GetCString (name_buffer, 0, name_length);
|
||||
index_offset += 4 + name_length;
|
||||
|
||||
name_length = file.View.ReadInt32 (index_offset);
|
||||
if (name_length > name_buffer.Length)
|
||||
name_buffer = new byte[name_length];
|
||||
file.View.Read (index_offset+4, name_buffer, 0, (uint)name_length);
|
||||
DecryptName (name_buffer, 0, name_length);
|
||||
var frame_name = Binary.GetCString (name_buffer, 0, name_length);
|
||||
if (frame_name != "NO NAME")
|
||||
{
|
||||
frame_name = frame_name.Replace ('/', '/');
|
||||
name = Path.Combine (name, frame_name);
|
||||
}
|
||||
index_offset += 4 + name_length;
|
||||
|
||||
var entry = new PcdEntry {
|
||||
Name = name,
|
||||
Type = "image",
|
||||
Offset = file.View.ReadUInt32 (index_offset),
|
||||
};
|
||||
if (entry.Offset > file.MaxOffset)
|
||||
return null;
|
||||
entry.Info = new ImageMetaData {
|
||||
Width = (uint)(right - left),
|
||||
Height = (uint)(bottom - top),
|
||||
OffsetX = left,
|
||||
OffsetY = top,
|
||||
BPP = 32,
|
||||
};
|
||||
dir.Add (entry);
|
||||
index_offset += 4;
|
||||
}
|
||||
SetAdjacentEntriesSize (dir, file.MaxOffset);
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
uint format_id = arc.File.View.ReadUInt32 (entry.Offset);
|
||||
switch (format_id)
|
||||
{
|
||||
case 0: // no compression
|
||||
return arc.File.CreateStream (entry.Offset+0x20, entry.Size-0x20);
|
||||
case 1: // zlib
|
||||
case 2: // bzip2
|
||||
break;
|
||||
default:
|
||||
return arc.File.CreateStream (entry.Offset, entry.Size);
|
||||
}
|
||||
var pent = (PcdEntry)entry;
|
||||
if (!pent.IsPacked)
|
||||
{
|
||||
pent.IsPacked = true;
|
||||
pent.UnpackedSize = arc.File.View.ReadUInt32 (entry.Offset+4);
|
||||
}
|
||||
var input = arc.File.CreateStream (entry.Offset+0x20, entry.Size-0x20);
|
||||
if (1 == format_id)
|
||||
return new ZLibStream (input, CompressionMode.Decompress);
|
||||
else
|
||||
return new BZip2InputStream (input);
|
||||
}
|
||||
|
||||
public override IImageDecoder OpenImage (ArcFile arc, Entry entry)
|
||||
{
|
||||
var pent = (PcdEntry)entry;
|
||||
var input = arc.OpenBinaryEntry (entry);
|
||||
return new PsdFormatDecoder (input, pent);
|
||||
}
|
||||
|
||||
internal static void DecryptName (byte[] buffer, int pos, int length)
|
||||
{
|
||||
for (int i = 0; i < length; ++i)
|
||||
buffer[pos+i] ^= 0xFF;
|
||||
}
|
||||
|
||||
internal static void SetAdjacentEntriesSize (List<Entry> dir, long max_offset)
|
||||
{
|
||||
int count = dir.Count;
|
||||
for (int i = 1; i < count; ++i)
|
||||
dir[i-1].Size = (uint)(dir[i].Offset - dir[i-1].Offset);
|
||||
dir[count-1].Size = (uint)(max_offset - dir[count-1].Offset);
|
||||
}
|
||||
}
|
||||
|
||||
internal class PsdFormatDecoder : BinaryImageDecoder
|
||||
{
|
||||
public PsdFormatDecoder (IBinaryStream input, PcdEntry entry) : base (input, entry.Info)
|
||||
{
|
||||
}
|
||||
|
||||
protected override ImageData GetImageData ()
|
||||
{
|
||||
int bpp = Info.BPP / 8;
|
||||
int stride = (int)Info.Width * bpp;
|
||||
var pixels = m_input.ReadBytes (stride * (int)Info.Height);
|
||||
PixelFormat format = 4 == bpp ? PixelFormats.Bgra32 : PixelFormats.Gray8;
|
||||
return ImageData.Create (Info, format, null, pixels, stride);
|
||||
}
|
||||
}
|
||||
}
|
74
Legacy/Witch/ArcVBD.cs
Normal file
74
Legacy/Witch/ArcVBD.cs
Normal file
@ -0,0 +1,74 @@
|
||||
//! \file ArcVBD.cs
|
||||
//! \date 2018 Aug 18
|
||||
//! \brief Witch audio archive.
|
||||
//
|
||||
// Copyright (C) 2018 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 GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Witch
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class SoundDataOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "VBD/SOUND"; } }
|
||||
public override string Description { get { return "Witch audio archive"; } }
|
||||
public override uint Signature { get { return 0x4E554F53; } } // 'SOUNDDATE'
|
||||
public override bool IsHierarchic { get { return false; } }
|
||||
public override bool CanWrite { get { return false; } }
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
if (!file.View.AsciiEqual (0, "SOUNDDATE "))
|
||||
return null;
|
||||
int count = file.View.ReadInt32 (0xA);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
long index_offset = 0xE;
|
||||
var dir = new List<Entry> (count);
|
||||
var name_buffer = new byte[0x100];
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
uint offset = file.View.ReadUInt32 (index_offset);
|
||||
if (offset <= index_offset || offset > file.MaxOffset)
|
||||
return null;
|
||||
int name_length = file.View.ReadInt32 (index_offset+4);
|
||||
if (name_length <= 0)
|
||||
return null;
|
||||
if (name_length > name_buffer.Length)
|
||||
name_buffer = new byte[name_length];
|
||||
var name = file.View.ReadString (index_offset+8, (uint)name_length);
|
||||
var entry = new Entry {
|
||||
Name = name,
|
||||
Type = "audio",
|
||||
Offset = offset,
|
||||
};
|
||||
dir.Add (entry);
|
||||
index_offset += 8 + name_length;
|
||||
}
|
||||
ImageDataOpener.SetAdjacentEntriesSize (dir, file.MaxOffset);
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user